summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2015-09-13 08:41:44 +0200
committer Miodrag Milanovic <mmicko@gmail.com>2015-09-13 08:41:44 +0200
commitf88cefad27a1737c76e09d99c9fb43e173506081 (patch)
tree2d8167d03579c46e226471747eb4407bd00ed6fa /src/emu/machine
parente92ac9e0fa8e99869894bea00589bbb526be30aa (diff)
Move all devices into separate part of src tree (nw)
Diffstat (limited to 'src/emu/machine')
-rw-r--r--src/emu/machine/40105.c172
-rw-r--r--src/emu/machine/40105.h80
-rw-r--r--src/emu/machine/53c7xx.c1776
-rw-r--r--src/emu/machine/53c7xx.h229
-rw-r--r--src/emu/machine/53c810.c816
-rw-r--r--src/emu/machine/53c810.h119
-rw-r--r--src/emu/machine/64h156.c652
-rw-r--r--src/emu/machine/64h156.h205
-rw-r--r--src/emu/machine/6522via.c985
-rw-r--r--src/emu/machine/6522via.h221
-rw-r--r--src/emu/machine/6525tpi.c561
-rw-r--r--src/emu/machine/6525tpi.h154
-rw-r--r--src/emu/machine/6532riot.c483
-rw-r--r--src/emu/machine/6532riot.h127
-rw-r--r--src/emu/machine/6821pia.c1121
-rw-r--r--src/emu/machine/6821pia.h233
-rw-r--r--src/emu/machine/68230pit.c265
-rw-r--r--src/emu/machine/68230pit.h131
-rw-r--r--src/emu/machine/68307.c352
-rw-r--r--src/emu/machine/68307.h132
-rw-r--r--src/emu/machine/68307bus.c112
-rw-r--r--src/emu/machine/68307bus.h22
-rw-r--r--src/emu/machine/68307sim.c314
-rw-r--r--src/emu/machine/68307sim.h74
-rw-r--r--src/emu/machine/68307tmu.c245
-rw-r--r--src/emu/machine/68307tmu.h41
-rw-r--r--src/emu/machine/68340.c152
-rw-r--r--src/emu/machine/68340.h75
-rw-r--r--src/emu/machine/68340dma.c39
-rw-r--r--src/emu/machine/68340dma.h10
-rw-r--r--src/emu/machine/68340ser.c40
-rw-r--r--src/emu/machine/68340ser.h10
-rw-r--r--src/emu/machine/68340sim.c349
-rw-r--r--src/emu/machine/68340sim.h60
-rw-r--r--src/emu/machine/68340tmu.c39
-rw-r--r--src/emu/machine/68340tmu.h10
-rw-r--r--src/emu/machine/6840ptm.c755
-rw-r--r--src/emu/machine/6840ptm.h148
-rw-r--r--src/emu/machine/6850acia.c597
-rw-r--r--src/emu/machine/6850acia.h145
-rw-r--r--src/emu/machine/68561mpcc.c481
-rw-r--r--src/emu/machine/68561mpcc.h102
-rw-r--r--src/emu/machine/7200fifo.c138
-rw-r--r--src/emu/machine/7200fifo.h132
-rw-r--r--src/emu/machine/74123.c249
-rw-r--r--src/emu/machine/74123.h147
-rw-r--r--src/emu/machine/74145.c142
-rw-r--r--src/emu/machine/74145.h96
-rw-r--r--src/emu/machine/74148.c198
-rw-r--r--src/emu/machine/74148.h99
-rw-r--r--src/emu/machine/74153.c172
-rw-r--r--src/emu/machine/74153.h92
-rw-r--r--src/emu/machine/74181.c150
-rw-r--r--src/emu/machine/74181.h80
-rw-r--r--src/emu/machine/7474.c216
-rw-r--r--src/emu/machine/7474.h121
-rw-r--r--src/emu/machine/8042kbdc.c618
-rw-r--r--src/emu/machine/8042kbdc.h127
-rw-r--r--src/emu/machine/8530scc.c678
-rw-r--r--src/emu/machine/8530scc.h103
-rw-r--r--src/emu/machine/aakart.c195
-rw-r--r--src/emu/machine/aakart.h100
-rw-r--r--src/emu/machine/adc0808.c187
-rw-r--r--src/emu/machine/adc0808.h140
-rw-r--r--src/emu/machine/adc083x.c448
-rw-r--r--src/emu/machine/adc083x.h126
-rw-r--r--src/emu/machine/adc1038.c121
-rw-r--r--src/emu/machine/adc1038.h69
-rw-r--r--src/emu/machine/adc1213x.c338
-rw-r--r--src/emu/machine/adc1213x.h89
-rw-r--r--src/emu/machine/aicartc.c169
-rw-r--r--src/emu/machine/aicartc.h67
-rw-r--r--src/emu/machine/akiko.c927
-rw-r--r--src/emu/machine/akiko.h155
-rw-r--r--src/emu/machine/am53cf96.c194
-rw-r--r--src/emu/machine/am53cf96.h76
-rw-r--r--src/emu/machine/am9517a.c1279
-rw-r--r--src/emu/machine/am9517a.h255
-rw-r--r--src/emu/machine/amigafdc.c656
-rw-r--r--src/emu/machine/amigafdc.h121
-rw-r--r--src/emu/machine/at28c16.c273
-rw-r--r--src/emu/machine/at28c16.h74
-rw-r--r--src/emu/machine/at29x.c525
-rw-r--r--src/emu/machine/at29x.h116
-rw-r--r--src/emu/machine/at45dbxx.c388
-rw-r--r--src/emu/machine/at45dbxx.h152
-rw-r--r--src/emu/machine/at_keybc.c226
-rw-r--r--src/emu/machine/at_keybc.h108
-rw-r--r--src/emu/machine/atadev.c21
-rw-r--r--src/emu/machine/atadev.h44
-rw-r--r--src/emu/machine/ataflash.c209
-rw-r--r--src/emu/machine/ataflash.h41
-rw-r--r--src/emu/machine/atahle.c950
-rw-r--r--src/emu/machine/atahle.h218
-rw-r--r--src/emu/machine/ataintf.c323
-rw-r--r--src/emu/machine/ataintf.h129
-rw-r--r--src/emu/machine/atapicdr.c81
-rw-r--r--src/emu/machine/atapicdr.h38
-rw-r--r--src/emu/machine/atapihle.c277
-rw-r--r--src/emu/machine/atapihle.h78
-rw-r--r--src/emu/machine/autoconfig.c169
-rw-r--r--src/emu/machine/autoconfig.h74
-rw-r--r--src/emu/machine/ay31015.c753
-rw-r--r--src/emu/machine/ay31015.h198
-rw-r--r--src/emu/machine/bankdev.c90
-rw-r--r--src/emu/machine/bankdev.h75
-rw-r--r--src/emu/machine/bcreader.c330
-rw-r--r--src/emu/machine/bcreader.h60
-rw-r--r--src/emu/machine/buffer.c17
-rw-r--r--src/emu/machine/buffer.h31
-rw-r--r--src/emu/machine/cdp1852.c187
-rw-r--r--src/emu/machine/cdp1852.h102
-rw-r--r--src/emu/machine/cdp1871.c290
-rw-r--r--src/emu/machine/cdp1871.h172
-rw-r--r--src/emu/machine/clock.c68
-rw-r--r--src/emu/machine/clock.h37
-rw-r--r--src/emu/machine/com8116.c159
-rw-r--r--src/emu/machine/com8116.h104
-rw-r--r--src/emu/machine/corvushd.c1475
-rw-r--r--src/emu/machine/corvushd.h530
-rw-r--r--src/emu/machine/cr511b.c121
-rw-r--r--src/emu/machine/cr511b.h150
-rw-r--r--src/emu/machine/cr589.c196
-rw-r--r--src/emu/machine/cr589.h48
-rw-r--r--src/emu/machine/cs4031.c969
-rw-r--r--src/emu/machine/cs4031.h290
-rw-r--r--src/emu/machine/cs8221.c167
-rw-r--r--src/emu/machine/cs8221.h88
-rw-r--r--src/emu/machine/diablo_hd.c1464
-rw-r--r--src/emu/machine/diablo_hd.h178
-rw-r--r--src/emu/machine/dmac.c465
-rw-r--r--src/emu/machine/dmac.h171
-rw-r--r--src/emu/machine/dp8390.c479
-rw-r--r--src/emu/machine/dp8390.h147
-rw-r--r--src/emu/machine/ds1204.c375
-rw-r--r--src/emu/machine/ds1204.h93
-rw-r--r--src/emu/machine/ds128x.c16
-rw-r--r--src/emu/machine/ds128x.h26
-rw-r--r--src/emu/machine/ds1302.c413
-rw-r--r--src/emu/machine/ds1302.h96
-rw-r--r--src/emu/machine/ds1315.c277
-rw-r--r--src/emu/machine/ds1315.h72
-rw-r--r--src/emu/machine/ds2401.c270
-rw-r--r--src/emu/machine/ds2401.h71
-rw-r--r--src/emu/machine/ds2404.c405
-rw-r--r--src/emu/machine/ds2404.h129
-rw-r--r--src/emu/machine/ds75160a.c111
-rw-r--r--src/emu/machine/ds75160a.h84
-rw-r--r--src/emu/machine/ds75161a.c353
-rw-r--r--src/emu/machine/ds75161a.h177
-rw-r--r--src/emu/machine/e0516.c198
-rw-r--r--src/emu/machine/e0516.h82
-rw-r--r--src/emu/machine/e05a03.c188
-rw-r--r--src/emu/machine/e05a03.h99
-rw-r--r--src/emu/machine/e05a30.c224
-rw-r--r--src/emu/machine/e05a30.h115
-rw-r--r--src/emu/machine/eeprom.c376
-rw-r--r--src/emu/machine/eeprom.h116
-rw-r--r--src/emu/machine/eeprompar.c133
-rw-r--r--src/emu/machine/eeprompar.h105
-rw-r--r--src/emu/machine/eepromser.c1161
-rw-r--r--src/emu/machine/eepromser.h295
-rw-r--r--src/emu/machine/er2055.c177
-rw-r--r--src/emu/machine/er2055.h83
-rw-r--r--src/emu/machine/f3853.c211
-rw-r--r--src/emu/machine/f3853.h110
-rw-r--r--src/emu/machine/fdc37c665gt.c61
-rw-r--r--src/emu/machine/fdc37c665gt.h37
-rw-r--r--src/emu/machine/fdc_pll.c134
-rw-r--r--src/emu/machine/fdc_pll.h33
-rw-r--r--src/emu/machine/gayle.c210
-rw-r--r--src/emu/machine/gayle.h110
-rw-r--r--src/emu/machine/generic.c290
-rw-r--r--src/emu/machine/generic.h69
-rw-r--r--src/emu/machine/hd63450.c555
-rw-r--r--src/emu/machine/hd63450.h155
-rw-r--r--src/emu/machine/hd64610.c366
-rw-r--r--src/emu/machine/hd64610.h105
-rw-r--r--src/emu/machine/hdc92x4.c4456
-rw-r--r--src/emu/machine/hdc92x4.h487
-rw-r--r--src/emu/machine/i2cmem.c510
-rw-r--r--src/emu/machine/i2cmem.h158
-rw-r--r--src/emu/machine/i6300esb.c757
-rw-r--r--src/emu/machine/i6300esb.h160
-rw-r--r--src/emu/machine/i80130.c173
-rw-r--r--src/emu/machine/i80130.h111
-rw-r--r--src/emu/machine/i8155.c593
-rw-r--r--src/emu/machine/i8155.h153
-rw-r--r--src/emu/machine/i8212.c142
-rw-r--r--src/emu/machine/i8212.h103
-rw-r--r--src/emu/machine/i8214.c205
-rw-r--r--src/emu/machine/i8214.h94
-rw-r--r--src/emu/machine/i8243.c125
-rw-r--r--src/emu/machine/i8243.h78
-rw-r--r--src/emu/machine/i8251.c788
-rw-r--r--src/emu/machine/i8251.h155
-rw-r--r--src/emu/machine/i82541.c32
-rw-r--r--src/emu/machine/i82541.h29
-rw-r--r--src/emu/machine/i8255.c995
-rw-r--r--src/emu/machine/i8255.h148
-rw-r--r--src/emu/machine/i8257.c668
-rw-r--r--src/emu/machine/i8257.h207
-rw-r--r--src/emu/machine/i8271.c1510
-rw-r--r--src/emu/machine/i8271.h165
-rw-r--r--src/emu/machine/i8279.c489
-rw-r--r--src/emu/machine/i8279.h145
-rw-r--r--src/emu/machine/i82875p.c515
-rw-r--r--src/emu/machine/i82875p.h139
-rw-r--r--src/emu/machine/i8355.c210
-rw-r--r--src/emu/machine/i8355.h120
-rw-r--r--src/emu/machine/idectrl.c393
-rw-r--r--src/emu/machine/idectrl.h121
-rw-r--r--src/emu/machine/idehd.c836
-rw-r--r--src/emu/machine/idehd.h122
-rw-r--r--src/emu/machine/im6402.c412
-rw-r--r--src/emu/machine/im6402.h170
-rw-r--r--src/emu/machine/ins8154.c247
-rw-r--r--src/emu/machine/ins8154.h115
-rw-r--r--src/emu/machine/ins8250.c705
-rw-r--r--src/emu/machine/ins8250.h174
-rw-r--r--src/emu/machine/intelfsh.c1146
-rw-r--r--src/emu/machine/intelfsh.h427
-rw-r--r--src/emu/machine/jvsdev.c260
-rw-r--r--src/emu/machine/jvsdev.h54
-rw-r--r--src/emu/machine/jvshost.c157
-rw-r--r--src/emu/machine/jvshost.h47
-rw-r--r--src/emu/machine/k033906.c128
-rw-r--r--src/emu/machine/k033906.h71
-rw-r--r--src/emu/machine/k053252.c233
-rw-r--r--src/emu/machine/k053252.h73
-rw-r--r--src/emu/machine/k056230.c112
-rw-r--r--src/emu/machine/k056230.h72
-rw-r--r--src/emu/machine/kb3600.c201
-rw-r--r--src/emu/machine/kb3600.h151
-rw-r--r--src/emu/machine/keyboard.c395
-rw-r--r--src/emu/machine/keyboard.h60
-rw-r--r--src/emu/machine/kr2376.c350
-rw-r--r--src/emu/machine/kr2376.h106
-rw-r--r--src/emu/machine/laserdsc.c1229
-rw-r--r--src/emu/machine/laserdsc.h413
-rw-r--r--src/emu/machine/latch.c122
-rw-r--r--src/emu/machine/latch.h74
-rw-r--r--src/emu/machine/latch8.c247
-rw-r--r--src/emu/machine/latch8.h228
-rw-r--r--src/emu/machine/lc89510.c26
-rw-r--r--src/emu/machine/lc89510.h23
-rw-r--r--src/emu/machine/ldpr8210.c1107
-rw-r--r--src/emu/machine/ldpr8210.h193
-rw-r--r--src/emu/machine/ldstub.c22
-rw-r--r--src/emu/machine/ldstub.h114
-rw-r--r--src/emu/machine/ldv1000.c656
-rw-r--r--src/emu/machine/ldv1000.h128
-rw-r--r--src/emu/machine/ldvp931.c653
-rw-r--r--src/emu/machine/ldvp931.h138
-rw-r--r--src/emu/machine/legscsi.c152
-rw-r--r--src/emu/machine/legscsi.h39
-rw-r--r--src/emu/machine/lh5810.c171
-rw-r--r--src/emu/machine/lh5810.h106
-rw-r--r--src/emu/machine/linflash.c208
-rw-r--r--src/emu/machine/linflash.h72
-rw-r--r--src/emu/machine/lpc-acpi.c368
-rw-r--r--src/emu/machine/lpc-acpi.h88
-rw-r--r--src/emu/machine/lpc-pit.c47
-rw-r--r--src/emu/machine/lpc-pit.h32
-rw-r--r--src/emu/machine/lpc-rtc.c83
-rw-r--r--src/emu/machine/lpc-rtc.h44
-rw-r--r--src/emu/machine/lpc.c8
-rw-r--r--src/emu/machine/lpc.h16
-rw-r--r--src/emu/machine/lpci.c291
-rw-r--r--src/emu/machine/lpci.h83
-rw-r--r--src/emu/machine/m6m80011ap.c232
-rw-r--r--src/emu/machine/m6m80011ap.h91
-rw-r--r--src/emu/machine/matsucd.c757
-rw-r--r--src/emu/machine/matsucd.h31
-rw-r--r--src/emu/machine/mb14241.c73
-rw-r--r--src/emu/machine/mb14241.h45
-rw-r--r--src/emu/machine/mb3773.c76
-rw-r--r--src/emu/machine/mb3773.h56
-rw-r--r--src/emu/machine/mb8421.c94
-rw-r--r--src/emu/machine/mb8421.h71
-rw-r--r--src/emu/machine/mb87078.c247
-rw-r--r--src/emu/machine/mb87078.h68
-rw-r--r--src/emu/machine/mb8795.c335
-rw-r--r--src/emu/machine/mb8795.h124
-rw-r--r--src/emu/machine/mb89352.c619
-rw-r--r--src/emu/machine/mb89352.h118
-rw-r--r--src/emu/machine/mb89363b.c181
-rw-r--r--src/emu/machine/mb89363b.h134
-rw-r--r--src/emu/machine/mb89371.c31
-rw-r--r--src/emu/machine/mb89371.h35
-rw-r--r--src/emu/machine/mc146818.c593
-rw-r--r--src/emu/machine/mc146818.h177
-rw-r--r--src/emu/machine/mc2661.c499
-rw-r--r--src/emu/machine/mc2661.h149
-rw-r--r--src/emu/machine/mc68328.c2871
-rw-r--r--src/emu/machine/mc68328.h784
-rw-r--r--src/emu/machine/mc6843.c827
-rw-r--r--src/emu/machine/mc6843.h88
-rw-r--r--src/emu/machine/mc6846.c568
-rw-r--r--src/emu/machine/mc6846.h125
-rw-r--r--src/emu/machine/mc6852.c302
-rw-r--r--src/emu/machine/mc6852.h132
-rw-r--r--src/emu/machine/mc6854.c989
-rw-r--r--src/emu/machine/mc6854.h161
-rw-r--r--src/emu/machine/mc68681.c1152
-rw-r--r--src/emu/machine/mc68681.h180
-rw-r--r--src/emu/machine/mc68901.c1134
-rw-r--r--src/emu/machine/mc68901.h311
-rw-r--r--src/emu/machine/mccs1850.c584
-rw-r--r--src/emu/machine/mccs1850.h123
-rw-r--r--src/emu/machine/mcf5206e.c1118
-rw-r--r--src/emu/machine/mcf5206e.h215
-rw-r--r--src/emu/machine/microtch.c307
-rw-r--r--src/emu/machine/microtch.h79
-rw-r--r--src/emu/machine/mm58167.c261
-rw-r--r--src/emu/machine/mm58167.h70
-rw-r--r--src/emu/machine/mm58274c.c470
-rw-r--r--src/emu/machine/mm58274c.h81
-rw-r--r--src/emu/machine/mm74c922.c190
-rw-r--r--src/emu/machine/mm74c922.h138
-rw-r--r--src/emu/machine/mos6526.c1178
-rw-r--r--src/emu/machine/mos6526.h296
-rw-r--r--src/emu/machine/mos6529.c95
-rw-r--r--src/emu/machine/mos6529.h113
-rw-r--r--src/emu/machine/mos6530.c382
-rw-r--r--src/emu/machine/mos6530.h124
-rw-r--r--src/emu/machine/mos6530n.c844
-rw-r--r--src/emu/machine/mos6530n.h415
-rw-r--r--src/emu/machine/mos6551.c833
-rw-r--r--src/emu/machine/mos6551.h212
-rw-r--r--src/emu/machine/mos6702.c68
-rw-r--r--src/emu/machine/mos6702.h66
-rw-r--r--src/emu/machine/mos8706.c78
-rw-r--r--src/emu/machine/mos8706.h70
-rw-r--r--src/emu/machine/mos8722.c366
-rw-r--r--src/emu/machine/mos8722.h154
-rw-r--r--src/emu/machine/mos8726.c125
-rw-r--r--src/emu/machine/mos8726.h98
-rw-r--r--src/emu/machine/mpu401.c289
-rw-r--r--src/emu/machine/mpu401.h72
-rw-r--r--src/emu/machine/msm5832.c306
-rw-r--r--src/emu/machine/msm5832.h99
-rw-r--r--src/emu/machine/msm58321.c646
-rw-r--r--src/emu/machine/msm58321.h146
-rw-r--r--src/emu/machine/msm6242.c557
-rw-r--r--src/emu/machine/msm6242.h83
-rw-r--r--src/emu/machine/ncr5380.c424
-rw-r--r--src/emu/machine/ncr5380.h70
-rw-r--r--src/emu/machine/ncr5380n.c586
-rw-r--r--src/emu/machine/ncr5380n.h227
-rw-r--r--src/emu/machine/ncr5390.c862
-rw-r--r--src/emu/machine/ncr5390.h232
-rw-r--r--src/emu/machine/ncr539x.c831
-rw-r--r--src/emu/machine/ncr539x.h90
-rw-r--r--src/emu/machine/netlist.c660
-rw-r--r--src/emu/machine/netlist.h725
-rw-r--r--src/emu/machine/nmc9306.c322
-rw-r--r--src/emu/machine/nmc9306.h93
-rw-r--r--src/emu/machine/nsc810.c312
-rw-r--r--src/emu/machine/nsc810.h135
-rw-r--r--src/emu/machine/nscsi_bus.c741
-rw-r--r--src/emu/machine/nscsi_bus.h428
-rw-r--r--src/emu/machine/nscsi_cb.c57
-rw-r--r--src/emu/machine/nscsi_cb.h97
-rw-r--r--src/emu/machine/nscsi_cd.c251
-rw-r--r--src/emu/machine/nscsi_cd.h33
-rw-r--r--src/emu/machine/nscsi_hd.c369
-rw-r--r--src/emu/machine/nscsi_hd.h33
-rw-r--r--src/emu/machine/nscsi_s1410.c151
-rw-r--r--src/emu/machine/nscsi_s1410.h76
-rw-r--r--src/emu/machine/nvram.c181
-rw-r--r--src/emu/machine/nvram.h115
-rw-r--r--src/emu/machine/pc_fdc.c192
-rw-r--r--src/emu/machine/pc_fdc.h83
-rw-r--r--src/emu/machine/pc_lpt.c163
-rw-r--r--src/emu/machine/pc_lpt.h87
-rw-r--r--src/emu/machine/pccard.c76
-rw-r--r--src/emu/machine/pccard.h43
-rw-r--r--src/emu/machine/pcf8593.c285
-rw-r--r--src/emu/machine/pcf8593.h79
-rw-r--r--src/emu/machine/pci-apic.c20
-rw-r--r--src/emu/machine/pci-apic.h22
-rw-r--r--src/emu/machine/pci-sata.c46
-rw-r--r--src/emu/machine/pci-sata.h30
-rw-r--r--src/emu/machine/pci-smbus.c280
-rw-r--r--src/emu/machine/pci-smbus.h67
-rw-r--r--src/emu/machine/pci-usb.c44
-rw-r--r--src/emu/machine/pci-usb.h41
-rw-r--r--src/emu/machine/pci.c908
-rw-r--r--src/emu/machine/pci.h282
-rw-r--r--src/emu/machine/pci9050.c254
-rw-r--r--src/emu/machine/pci9050.h76
-rw-r--r--src/emu/machine/pckeybrd.c1305
-rw-r--r--src/emu/machine/pckeybrd.h137
-rw-r--r--src/emu/machine/pic8259.c439
-rw-r--r--src/emu/machine/pic8259.h126
-rw-r--r--src/emu/machine/pit8253.c1135
-rw-r--r--src/emu/machine/pit8253.h172
-rw-r--r--src/emu/machine/pla.c181
-rw-r--r--src/emu/machine/pla.h137
-rw-r--r--src/emu/machine/r10696.c185
-rw-r--r--src/emu/machine/r10696.h58
-rw-r--r--src/emu/machine/r10788.c226
-rw-r--r--src/emu/machine/r10788.h76
-rw-r--r--src/emu/machine/ra17xx.c131
-rw-r--r--src/emu/machine/ra17xx.h58
-rw-r--r--src/emu/machine/ram.c222
-rw-r--r--src/emu/machine/ram.h95
-rw-r--r--src/emu/machine/rescap.h29
-rw-r--r--src/emu/machine/rf5c296.c113
-rw-r--r--src/emu/machine/rf5c296.h42
-rw-r--r--src/emu/machine/roc10937.c388
-rw-r--r--src/emu/machine/roc10937.h128
-rw-r--r--src/emu/machine/rp5c01.c428
-rw-r--r--src/emu/machine/rp5c01.h112
-rw-r--r--src/emu/machine/rp5c15.c447
-rw-r--r--src/emu/machine/rp5c15.h106
-rw-r--r--src/emu/machine/rp5h01.c201
-rw-r--r--src/emu/machine/rp5h01.h77
-rw-r--r--src/emu/machine/rtc4543.c206
-rw-r--r--src/emu/machine/rtc4543.h82
-rw-r--r--src/emu/machine/rtc65271.c697
-rw-r--r--src/emu/machine/rtc65271.h76
-rw-r--r--src/emu/machine/rtc9701.c469
-rw-r--r--src/emu/machine/rtc9701.h111
-rw-r--r--src/emu/machine/s2636.c367
-rw-r--r--src/emu/machine/s2636.h84
-rw-r--r--src/emu/machine/s3520cf.c265
-rw-r--r--src/emu/machine/s3520cf.h91
-rw-r--r--src/emu/machine/s3c2400.c140
-rw-r--r--src/emu/machine/s3c2400.h894
-rw-r--r--src/emu/machine/s3c2410.c170
-rw-r--r--src/emu/machine/s3c2410.h1073
-rw-r--r--src/emu/machine/s3c2440.c175
-rw-r--r--src/emu/machine/s3c2440.h1157
-rw-r--r--src/emu/machine/s3c24xx.inc3519
-rw-r--r--src/emu/machine/s3c44b0.c2055
-rw-r--r--src/emu/machine/s3c44b0.h814
-rw-r--r--src/emu/machine/saturn.c1003
-rw-r--r--src/emu/machine/serflash.c411
-rw-r--r--src/emu/machine/serflash.h108
-rw-r--r--src/emu/machine/smc91c9x.c531
-rw-r--r--src/emu/machine/smc91c9x.h100
-rw-r--r--src/emu/machine/smpc.c1084
-rw-r--r--src/emu/machine/smpc.h7
-rw-r--r--src/emu/machine/spchrom.c139
-rw-r--r--src/emu/machine/spchrom.h41
-rw-r--r--src/emu/machine/steppers.c450
-rw-r--r--src/emu/machine/steppers.h179
-rw-r--r--src/emu/machine/strata.c675
-rw-r--r--src/emu/machine/strata.h75
-rw-r--r--src/emu/machine/stvcd.c2702
-rw-r--r--src/emu/machine/t10mmc.c765
-rw-r--r--src/emu/machine/t10mmc.h63
-rw-r--r--src/emu/machine/t10sbc.c268
-rw-r--r--src/emu/machine/t10sbc.h36
-rw-r--r--src/emu/machine/t10spc.c150
-rw-r--r--src/emu/machine/t10spc.h136
-rw-r--r--src/emu/machine/tc009xlvc.c417
-rw-r--r--src/emu/machine/tc009xlvc.h98
-rw-r--r--src/emu/machine/terminal.c411
-rw-r--r--src/emu/machine/terminal.h63
-rw-r--r--src/emu/machine/timekpr.c437
-rw-r--r--src/emu/machine/timekpr.h144
-rw-r--r--src/emu/machine/tmp68301.c337
-rw-r--r--src/emu/machine/tmp68301.h90
-rw-r--r--src/emu/machine/tms1024.c111
-rw-r--r--src/emu/machine/tms1024.h110
-rw-r--r--src/emu/machine/tms5501.c529
-rw-r--r--src/emu/machine/tms5501.h195
-rw-r--r--src/emu/machine/tms6100.c264
-rw-r--r--src/emu/machine/tms6100.h60
-rw-r--r--src/emu/machine/tms9901.c630
-rw-r--r--src/emu/machine/tms9901.h224
-rw-r--r--src/emu/machine/tms9902.c847
-rw-r--r--src/emu/machine/tms9902.h203
-rw-r--r--src/emu/machine/upd1990a.c499
-rw-r--r--src/emu/machine/upd1990a.h161
-rw-r--r--src/emu/machine/upd4701.c259
-rw-r--r--src/emu/machine/upd4701.h66
-rw-r--r--src/emu/machine/upd4992.c156
-rw-r--r--src/emu/machine/upd4992.h73
-rw-r--r--src/emu/machine/upd7002.c172
-rw-r--r--src/emu/machine/upd7002.h106
-rw-r--r--src/emu/machine/upd71071.c517
-rw-r--r--src/emu/machine/upd71071.h146
-rw-r--r--src/emu/machine/upd765.c2534
-rw-r--r--src/emu/machine/upd765.h533
-rw-r--r--src/emu/machine/v3021.c185
-rw-r--r--src/emu/machine/v3021.h78
-rw-r--r--src/emu/machine/vrc4373.c432
-rw-r--r--src/emu/machine/vrc4373.h132
-rw-r--r--src/emu/machine/vt83c461.c105
-rw-r--r--src/emu/machine/vt83c461.h51
-rw-r--r--src/emu/machine/wd11c00_17.c474
-rw-r--r--src/emu/machine/wd11c00_17.h142
-rw-r--r--src/emu/machine/wd2010.c989
-rw-r--r--src/emu/machine/wd2010.h157
-rw-r--r--src/emu/machine/wd33c93.c807
-rw-r--r--src/emu/machine/wd33c93.h109
-rw-r--r--src/emu/machine/wd7600.c557
-rw-r--r--src/emu/machine/wd7600.h240
-rw-r--r--src/emu/machine/wd_fdc.c2831
-rw-r--r--src/emu/machine/wd_fdc.h683
-rw-r--r--src/emu/machine/wozfdc.c587
-rw-r--r--src/emu/machine/wozfdc.h122
-rw-r--r--src/emu/machine/x2212.c261
-rw-r--r--src/emu/machine/x2212.h113
-rw-r--r--src/emu/machine/x76f041.c540
-rw-r--r--src/emu/machine/x76f041.h127
-rw-r--r--src/emu/machine/x76f100.c427
-rw-r--r--src/emu/machine/x76f100.h90
-rw-r--r--src/emu/machine/ym2148.c209
-rw-r--r--src/emu/machine/ym2148.h93
-rw-r--r--src/emu/machine/z80ctc.c525
-rw-r--r--src/emu/machine/z80ctc.h140
-rw-r--r--src/emu/machine/z80dart.c1357
-rw-r--r--src/emu/machine/z80dart.h684
-rw-r--r--src/emu/machine/z80dma.c881
-rw-r--r--src/emu/machine/z80dma.h165
-rw-r--r--src/emu/machine/z80pio.c809
-rw-r--r--src/emu/machine/z80pio.h260
-rw-r--r--src/emu/machine/z80sti.c720
-rw-r--r--src/emu/machine/z80sti.h250
-rw-r--r--src/emu/machine/z8536.c1123
-rw-r--r--src/emu/machine/z8536.h353
526 files changed, 0 insertions, 167246 deletions
diff --git a/src/emu/machine/40105.c b/src/emu/machine/40105.c
deleted file mode 100644
index e2f059dfed0..00000000000
--- a/src/emu/machine/40105.c
+++ /dev/null
@@ -1,172 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- CMOS 40105 FIFO Register emulation
-
-**********************************************************************/
-
-#include "40105.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type CMOS_40105 = &device_creator<cmos_40105_device>;
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// cmos_40105_device - constructor
-//-------------------------------------------------
-
-cmos_40105_device::cmos_40105_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, CMOS_40105, "40105", tag, owner, clock, "40105", __FILE__),
- m_write_dir(*this),
- m_write_dor(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void cmos_40105_device::device_start()
-{
- // resolve callbacks
- m_write_dir.resolve_safe();
- m_write_dor.resolve_safe();
-
- // state saving
- save_item(NAME(m_d));
- save_item(NAME(m_q));
- save_item(NAME(m_dir));
- save_item(NAME(m_dor));
- save_item(NAME(m_si));
- save_item(NAME(m_so));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void cmos_40105_device::device_reset()
-{
- m_fifo = std::queue<UINT8>();
-
- m_dir = 1;
- m_dor = 0;
- m_si = 0;
-
- m_write_dir(m_dir);
- m_write_dor(m_dor);
-}
-
-
-//-------------------------------------------------
-// read - read Q
-//-------------------------------------------------
-
-UINT8 cmos_40105_device::read()
-{
- return m_q;
-}
-
-
-//-------------------------------------------------
-// write - write D
-//-------------------------------------------------
-
-void cmos_40105_device::write(UINT8 data)
-{
- m_d = data & 0x0f;
-}
-
-
-//-------------------------------------------------
-// si_w - shift in write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( cmos_40105_device::si_w )
-{
- if (m_dir && !m_si && state)
- {
- m_fifo.push(m_d);
-
- if (m_fifo.size() == 16)
- {
- m_dir = 0;
- m_write_dir(m_dir);
- }
-
- if (!m_dor)
- {
- m_dor = 1;
- m_write_dor(m_dor);
- }
-
- }
-
- m_si = state;
-}
-
-
-//-------------------------------------------------
-// so_w - shift out write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( cmos_40105_device::so_w )
-{
- if (m_dor && m_so && !m_so)
- {
- m_dor = 0;
- m_write_dor(m_dor);
-
- m_q = m_fifo.front();
- m_fifo.pop();
-
- if (m_fifo.size() > 0)
- {
- m_dor = 1;
- m_write_dor(m_dor);
- }
- }
-
- m_so = state;
-}
-
-
-//-------------------------------------------------
-// dir_r - data in ready read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( cmos_40105_device::dir_r )
-{
- return m_dir;
-}
-
-
-//-------------------------------------------------
-// dor_r - data out ready read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( cmos_40105_device::dor_r )
-{
- return m_dor;
-}
diff --git a/src/emu/machine/40105.h b/src/emu/machine/40105.h
deleted file mode 100644
index bc632c8cdca..00000000000
--- a/src/emu/machine/40105.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- CMOS 40105 FIFO Register emulation
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __CMOS_40105__
-#define __CMOS_40105__
-
-#include "emu.h"
-#include <queue>
-
-
-
-///*************************************************************************
-// INTERFACE CONFIGURATION MACROS
-///*************************************************************************
-
-#define MCFG_40105_ADD(_tag, _dir, _dor) \
- MCFG_DEVICE_ADD(_tag, CMOS_40105, 0) \
- downcast<cmos_40105_device *>(device)->set_dir_callback(DEVCB_##_dir); \
- downcast<cmos_40105_device *>(device)->set_dor_callback(DEVCB_##_dor);
-
-
-
-///*************************************************************************
-// TYPE DEFINITIONS
-///*************************************************************************
-
-// ======================> cmos_40105_device
-
-class cmos_40105_device : public device_t
-{
-public:
- // construction/destruction
- cmos_40105_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _dir> void set_dir_callback(_dir dir) { m_write_dir.set_callback(dir); }
- template<class _dor> void set_dor_callback(_dor dor) { m_write_dor.set_callback(dor); }
-
- UINT8 read();
- void write(UINT8 data);
-
- DECLARE_WRITE_LINE_MEMBER( si_w );
- DECLARE_WRITE_LINE_MEMBER( so_w );
-
- DECLARE_READ_LINE_MEMBER( dir_r );
- DECLARE_READ_LINE_MEMBER( dor_r );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- devcb_write_line m_write_dir;
- devcb_write_line m_write_dor;
-
- std::queue<UINT8> m_fifo;
-
- UINT8 m_d;
- UINT8 m_q;
-
- int m_dir;
- int m_dor;
- int m_si;
- int m_so;
-};
-
-
-// device type definition
-extern const device_type CMOS_40105;
-
-
-
-#endif
diff --git a/src/emu/machine/53c7xx.c b/src/emu/machine/53c7xx.c
deleted file mode 100644
index f2aad1ad75b..00000000000
--- a/src/emu/machine/53c7xx.c
+++ /dev/null
@@ -1,1776 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Philip Bennett
-/*********************************************************************
-
- 53c7xx.c
-
- NCR 53C700 SCSI I/O Processor
-
-
- TODO:
- * Low-level register accesses
- * Remove arbitrary delays
- * Add unimplemented SCRIPTS opcodes
-
-*********************************************************************/
-
-#include "emu.h"
-#include "53c7xx.h"
-
-
-
-//**************************************************************************
-// DEBUGGERY
-//**************************************************************************
-
-#define DEBUG_LOG 1
-#define DEBUG_LEVEL 0
-
-#if DEBUG_LOG
- #define VERBOSE_LOG(machine, level, ...) verbose_log(machine, level, __VA_ARGS__)
-#else
- #define VERBOSE_LOG(machine, level, ...)
-#endif
-
-static void ATTR_PRINTF(3,4) verbose_log(running_machine &machine, int level, const char* format, ...)
-{
- if (level <= DEBUG_LEVEL)
- {
- char buffer[32768];
- va_list v;
-
- va_start(v, format);
- vsprintf(buffer, format, v);
- va_end(v);
-
- printf("53C7XX (%s): %s", machine.describe_context(), buffer);
- }
-}
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-const device_type NCR53C7XX = &device_creator<ncr53c7xx_device>;
-
-//-------------------------------------------------
-// ncr53c7xx_device - constructor/destructor
-//-------------------------------------------------
-
-ncr53c7xx_device::ncr53c7xx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : nscsi_device(mconfig, NCR53C7XX, "53C7xx SCSI", tag, owner, clock, "ncr537xx", __FILE__),
- device_execute_interface(mconfig, *this),
- m_icount(0),
- m_irq_handler(*this),
- m_host_write(*this),
- m_host_read(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ncr53c7xx_device::device_start()
-{
- // set our instruction counter
- m_icountptr = &m_icount;
-
- // resolve line callbacks
- m_irq_handler.resolve_safe();
- m_host_read.resolve_safe(0);
- m_host_write.resolve_safe();
-
- m_tm = timer_alloc(0);
-
- // The SCRIPTS processor runs at ~2 MIPS so approximate this
- set_unscaled_clock(2000000);
-
- // savestate support
- save_item(NAME(m_scntl));
- save_item(NAME(m_sdid));
- save_item(NAME(m_sien));
- save_item(NAME(m_scid));
- save_item(NAME(m_sxfer));
- save_item(NAME(m_sodl));
- save_item(NAME(m_socl));
- save_item(NAME(m_sfbr));
- save_item(NAME(m_sidl));
- save_item(NAME(m_sbdl));
- save_item(NAME(m_sbcl));
- save_item(NAME(m_dstat));
- save_item(NAME(m_sstat));
- save_item(NAME(m_ctest));
- save_item(NAME(m_temp));
- save_item(NAME(m_dfifo));
- save_item(NAME(m_istat));
- save_item(NAME(m_dbc));
- save_item(NAME(m_dcmd));
- save_item(NAME(m_dnad));
- save_item(NAME(m_dsp));
- save_item(NAME(m_dsps));
- save_item(NAME(m_dmode));
- save_item(NAME(m_dien));
- save_item(NAME(m_dwt));
- save_item(NAME(m_dcntl));
-
- // other state
- save_item(NAME(m_scsi_state));
- save_item(NAME(m_connected));
- save_item(NAME(m_finished));
- save_item(NAME(m_last_data));
- save_item(NAME(m_xfr_phase));
-
- save_item(NAME(m_scripts_state));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ncr53c7xx_device::device_reset()
-{
- // Reset registers to defaults
- m_scntl[0] = 3 << SCNTL0_ARB_SHIFT;
- m_scntl[1] = 0;
- m_sdid = 0;
- m_sien = 0;
- m_scid = 0;
- m_sxfer = 0;
- m_sodl = 0;
- m_socl = 0;
- m_sfbr = 0;
- m_sidl = 0;
- m_sbdl = 0;
- m_sbcl = 0;
- m_dstat = DSTAT_DFE;
- m_sstat[0] = 0;
- m_sstat[1] = 0;
- m_sstat[2] = 0;
- m_ctest[0] = 0;
- m_ctest[1] = 0xf0;
- m_ctest[2] = 0x21;
- m_ctest[3] = 0;
- m_ctest[4] = 0;
- m_ctest[5] = 0;
- m_ctest[6] = 0;
- m_ctest[7] = 0;
- m_dfifo = 0;
- m_istat = 0;//ISTAT_PRE;
- m_dmode = 0;
- m_dien = 0;
- m_dcntl = 0;
-
- m_finished = false;
- m_connected = false;
-
- scsi_bus->ctrl_wait(scsi_refid, S_SEL | S_BSY | S_RST, S_ALL);
- set_scripts_state(SCRIPTS_IDLE);
- set_scsi_state(IDLE);
-
- m_irq_handler(CLEAR_LINE);
-}
-
-
-//**************************************************************************
-// MEMORY HANDLERS
-//**************************************************************************
-
-//-------------------------------------------------
-// read - Host read handler
-//-------------------------------------------------
-
-READ32_MEMBER( ncr53c7xx_device::read )
-{
- VERBOSE_LOG(machine(), 1, "REG R: [%x] (%08X)\n", offset, mem_mask);
-
- UINT32 ret = 0;
-
- switch (offset)
- {
- case 0x0:
- {
- if (ACCESSING_BITS_0_7)
- {
- ret = m_scntl[0];
- }
- if (ACCESSING_BITS_8_15)
- {
- ret |= m_scntl[1] << 8;
- }
- if (ACCESSING_BITS_16_23)
- {
- ret |= m_sdid << 16;
- }
- if (ACCESSING_BITS_24_31)
- {
- ret |= m_sien << 24;
- }
-
- break;
- }
-
- case 0x1:
- {
- if (ACCESSING_BITS_0_7)
- {
- ret = m_scid;
- }
- if (ACCESSING_BITS_8_15)
- {
- ret |= m_sxfer << 8;
- }
- if (ACCESSING_BITS_16_23)
- {
- ret |= m_sodl << 16;
- }
- if (ACCESSING_BITS_24_31)
- {
- ret |= m_socl << 24;
- }
-
- break;
- }
-
- case 0x2:
- {
- if (ACCESSING_BITS_0_7)
- {
- ret = m_sfbr;
- }
- if (ACCESSING_BITS_8_15)
- {
- ret |= m_sidl << 8;
- }
- if (ACCESSING_BITS_16_23)
- {
- ret |= m_sbdl << 16;
- }
- if (ACCESSING_BITS_24_31)
- {
- ret |= m_sbcl << 24;
- }
-
- break;
- }
-
- case 0x3:
- {
- if (ACCESSING_BITS_0_7)
- {
- ret = m_dstat;
- m_dstat = 0;
- update_irqs();
- }
- if (ACCESSING_BITS_8_15)
- {
- ret |= m_sstat[0] << 8;
- m_sstat[0] = 0;
- update_irqs();
- }
- if (ACCESSING_BITS_16_23)
- {
- ret |= m_sstat[1] << 16;
- }
- if (ACCESSING_BITS_24_31)
- {
- ret |= m_sstat[2] << 24;
- }
-
- break;
- }
-
- case 0x5:
- {
- if (ACCESSING_BITS_0_7)
- {
- ret = m_ctest[0];
- }
- if (ACCESSING_BITS_8_15)
- {
- ret |= m_ctest[1] << 8;
- }
- if (ACCESSING_BITS_16_23)
- {
- ret |= m_ctest[2] << 16;
- }
- if (ACCESSING_BITS_24_31)
- {
- ret |= m_ctest[3] << 24;
- }
-
- break;
- }
-
- case 0x6:
- {
- if (ACCESSING_BITS_0_7)
- {
- ret = m_ctest[4];
- }
- if (ACCESSING_BITS_8_15)
- {
- ret |= m_ctest[5] << 8;
- }
- if (ACCESSING_BITS_16_23)
- {
- ret |= m_ctest[6] << 16;
- }
- if (ACCESSING_BITS_24_31)
- {
- ret |= m_ctest[7] << 24;
- }
-
- break;
- }
-
- case 0x7:
- {
- ret = m_temp;
-
- break;
- }
-
- case 0x8:
- {
- if (ACCESSING_BITS_0_7)
- {
- ret = m_dfifo;
- }
- if (ACCESSING_BITS_8_15)
- {
- ret |= m_istat << 8;
- }
-
- break;
- }
-
- case 0x9:
- {
- if (ACCESSING_BITS_0_7 || ACCESSING_BITS_8_15 || ACCESSING_BITS_16_23)
- {
- ret = m_dbc;
- }
- if (ACCESSING_BITS_24_31)
- {
- ret |= m_dcmd << 24;
- }
-
- break;
- }
-
- case 0xa:
- {
- ret = m_dnad;
-
- break;
- }
-
- case 0xb:
- {
- ret = m_dsp;
-
- break;
- }
-
- case 0xc:
- {
- ret = m_dsps;
-
- break;
- }
-
- case 0xd:
- {
- if (ACCESSING_BITS_0_7)
- {
- ret = m_dmode;
- }
-
- break;
- }
-
- case 0xe:
- {
- if (ACCESSING_BITS_8_15)
- {
- ret = m_dien << 8;
- }
- if (ACCESSING_BITS_16_23)
- {
- ret |= m_dwt << 16;
-
- }
- if (ACCESSING_BITS_24_31)
- {
- ret |= m_dcntl << 24;
- }
-
- break;
- }
-
- default:
- {
- VERBOSE_LOG(machine(), 0, "Unhandled register access");
- }
- }
-
- return ret;
-}
-
-
-//-------------------------------------------------
-// write - Host write handler
-//-------------------------------------------------
-
-WRITE32_MEMBER( ncr53c7xx_device::write )
-{
- VERBOSE_LOG(machine(), 1, "REG W: [%x] (%08X) %x\n", offset, mem_mask, data);
-
- switch (offset)
- {
- case 0x0:
- {
- if (ACCESSING_BITS_0_7)
- {
- m_scntl[0] = data;
-
- if (data & SCNTL0_TRG)
- fatalerror("53c7xx: Target mode unsupported!");
-
- if (data & SCNTL0_START)
- {
- // Start arbitration
- set_scsi_state(ARBITRATE_WAIT_FREE);
- step(true);
- }
- }
- if (ACCESSING_BITS_8_15)
- {
- m_scntl[1] = data >> 8;
- }
- if (ACCESSING_BITS_16_23)
- {
- m_sdid = data >> 16;
- }
- if (ACCESSING_BITS_24_31)
- {
- m_sien = data >> 24;
- }
-
- break;
- }
-
- case 0x1:
- {
- if (ACCESSING_BITS_0_7)
- {
- m_scid = data;
- }
- if (ACCESSING_BITS_8_15)
- {
- m_sxfer = data >> 8;
- }
- if (ACCESSING_BITS_16_23)
- {
- m_sodl = data >> 16;
- }
- if (ACCESSING_BITS_24_31)
- {
- m_socl = data >> 24;
- }
-
- break;
- }
-
- case 0x6:
- {
- if (ACCESSING_BITS_0_7)
- {
- m_ctest[4] = data;
- }
- if (ACCESSING_BITS_8_15)
- {
- m_ctest[5] = data >> 8;
- }
- if (ACCESSING_BITS_16_23)
- {
- m_ctest[6] = data >> 16;
- }
- if (ACCESSING_BITS_24_31)
- {
- m_ctest[7] = data >> 24;
- }
-
- break;
- }
-
- case 0x7:
- {
- m_temp = data;
-
- break;
- }
-
- case 0x8:
- {
- if (ACCESSING_BITS_0_7)
- {
- m_dfifo = data;
- }
- if (ACCESSING_BITS_8_15)
- {
- m_istat = data >> 8;
- }
-
- break;
- }
-
- case 0x9:
- {
- if (ACCESSING_BITS_0_7 || ACCESSING_BITS_8_15 || ACCESSING_BITS_16_23)
- {
- m_dbc = data & 0xffffff;
- }
- if (ACCESSING_BITS_24_31)
- {
- m_dcmd = data >> 24;
- }
-
- break;
- }
-
- case 0xa:
- {
- m_dnad = data;
-
- break;
- }
-
- case 0xb:
- {
- // Write to the upper byte starts the fetch
- m_dsp = data;
-
- if (m_dmode & 1)
- {
- set_scripts_state(SCRIPTS_WAIT_MANUAL_START);
- }
- else
- {
- set_scripts_state(SCRIPTS_FETCH);
- }
-
- break;
- }
-
- case 0xc:
- {
- m_dsps = data;
-
- break;
- }
-
- case 0xd:
- {
- if (ACCESSING_BITS_0_7)
- {
- m_dmode = data;
- }
-
- break;
- }
-
- case 0xe:
- {
- if (ACCESSING_BITS_8_15)
- {
- m_dien = data >> 8;
- }
- if (ACCESSING_BITS_16_23)
- {
- m_dwt = data >> 16;
-
- if (m_dwt)
- fatalerror("53c7xx: DMA Watchdog Timer enabled!");
- }
- if (ACCESSING_BITS_24_31)
- {
- m_dcntl = data >> 24;
-
- // Note: not self-clearing
- if (m_dcntl & 1) // RST
- {
- device_reset();
- }
- else if (m_dcntl & 2) // STD
- {
- // Only applies to these modes:
- // * Manual Start
- // * Single Step
- // * Pipeline
- fatalerror("53c7xx: Start DMA");
- }
- else if (m_dcntl & 4)
- {
- fatalerror("53c7xx: SCSI Low-Level Mode not supported!");
- }
-
- // TODO: Update clocking
- }
-
- break;
- }
-
- default:
- {
- VERBOSE_LOG(machine(), 0, "Unhandled register access");
- }
- }
-}
-
-
-
-//**************************************************************************
-// SCSI STATE MACHINE
-//**************************************************************************
-
-//-------------------------------------------------
-// update_irqs -
-//-------------------------------------------------
-void ncr53c7xx_device::update_irqs()
-{
- if (m_sstat[0] & m_sien)
- m_istat |= ISTAT_SIP;
- else
- m_istat &= ~ISTAT_SIP;
-
- if (m_dstat & m_dien)
- m_istat |= ISTAT_DIP;
- else
- m_istat &= ~ISTAT_DIP;
-
- m_irq_handler(m_istat ? ASSERT_LINE : CLEAR_LINE);
-}
-
-//-------------------------------------------------
-// set_scsi_state - change SCSI state
-//-------------------------------------------------
-
-void ncr53c7xx_device::set_scsi_state(int state)
-{
- VERBOSE_LOG(machine(), 2, "SCSI state change: %x to %x\n", m_scsi_state, state);
-
- m_scsi_state = state;
-}
-
-
-//-------------------------------------------------
-// delay - step the SCSI state machine following
-// a time delay
-//-------------------------------------------------
-
-void ncr53c7xx_device::delay(const attotime &delay)
-{
- m_tm->adjust(delay);
-}
-
-
-//-------------------------------------------------
-// scsi_ctrl_changed - callback from nscsi_device
-//-------------------------------------------------
-
-void ncr53c7xx_device::scsi_ctrl_changed()
-{
- step(false);
-}
-
-
-//-------------------------------------------------
-// send_byte - send data to a SCSI device
-//-------------------------------------------------
-
-void ncr53c7xx_device::send_byte()
-{
- if (m_dbc == 0)
- fatalerror("53C7XX: send_byte() - DBC should not be 0\n");
-
- set_scsi_state( (m_scsi_state & STATE_MASK) | (SEND_WAIT_SETTLE << SUB_SHIFT) );
-
- UINT32 data = m_host_read(m_dnad & ~3, 0xffffffff);
- data = data >> ((m_dnad & 3) * 8) & 0xff;
-
- ++m_dnad;
- --m_dbc;
-
- scsi_bus->data_w(scsi_refid, data);
- scsi_bus->ctrl_w(scsi_refid, S_ACK, S_ACK);
- scsi_bus->ctrl_wait(scsi_refid, S_REQ, S_REQ);
- delay(attotime::from_nsec(5));
-}
-
-
-//-------------------------------------------------
-// recv_byte - receive data from a SCSI device
-//-------------------------------------------------
-
-void ncr53c7xx_device::recv_byte()
-{
- scsi_bus->ctrl_wait(scsi_refid, S_REQ, S_REQ);
- set_scsi_state( (m_scsi_state & STATE_MASK) | (RECV_WAIT_REQ_1 << SUB_SHIFT) );
- step(false);
-}
-
-
-//-------------------------------------------------
-// device_timer - callback to step the SCSI
-// state machine
-//-------------------------------------------------
-
-void ncr53c7xx_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- step(true);
-}
-
-
-//-------------------------------------------------
-// step - advance the SCSI state machine
-//-------------------------------------------------
-
-void ncr53c7xx_device::step(bool timeout)
-{
- UINT32 ctrl = scsi_bus->ctrl_r();
- UINT32 data = scsi_bus->data_r();
-
- VERBOSE_LOG(machine(), 2, "Step: CTRL:%x DATA:%x (%d.%d) Timeout:%d\n", ctrl, data, m_scsi_state & STATE_MASK, m_scsi_state >> SUB_SHIFT, timeout);
-
- // Check for disconnect from target
- if (!(m_scntl[0] & SCNTL0_TRG) && m_connected && !(ctrl & S_BSY))
- {
- set_scsi_state(FINISHED);
- m_connected = false;
-// istatus |= I_DISCONNECT;
-// reset_disconnect();
-// check_irq();
- }
-
- switch (m_scsi_state & SUB_MASK ? m_scsi_state & SUB_MASK : m_scsi_state & STATE_MASK)
- {
- case IDLE:
- {
- break;
- }
-
- case FINISHED:
- {
- m_finished = true;
- set_scsi_state(IDLE);
- step(true);
-
- break;
- }
-
- case ARBITRATE_WAIT_FREE:
- {
- if (!timeout)
- break;
-
- // Is the bus free?
- if (ctrl & (S_BSY | S_SEL))
- {
- // Keep trying until it is
- delay(attotime::from_nsec(800));
- }
- else
- {
- // Bus is free; next phase
- delay(attotime::from_nsec(800));
- set_scsi_state(ARBITRATE_CHECK_FREE);
- }
-
- break;
- }
-
- case ARBITRATE_CHECK_FREE:
- {
- if ((ctrl & (S_BSY | S_SEL)) == 0)
- {
- // Bus is free - assert the controller SCSI ID and BUSY
- scsi_bus->ctrl_w(scsi_refid, S_BSY, S_BSY);
-
- if (((m_scntl[0] >> SCNTL0_ARB_SHIFT) & SCNTL0_ARB_MASK) == 3)
- {
- // Full arbitration
- scsi_bus->data_w(scsi_refid, m_scid);
- }
- else
- {
- // Simple arbitration
- scsi_bus->data_w(scsi_refid, m_sodl);
- }
-
- set_scsi_state(ARBITRATE_EXAMINE_BUS);
- delay(attotime::from_nsec(2400));
- }
-
- break;
- }
-
- case ARBITRATE_EXAMINE_BUS:
- {
- if (!timeout)
- break;
-
- if (ctrl & S_SEL)
- {
- scsi_bus->ctrl_w(scsi_refid, 0, S_BSY);
- scsi_bus->data_w(scsi_refid, 0);
-
- if (((m_scntl[0] >> SCNTL0_ARB_SHIFT) & SCNTL0_ARB_MASK) == 3)
- {
- // Try again
- set_scsi_state(ARBITRATE_WAIT_FREE);
- delay(attotime::from_nsec(2400));
- }
- else
- {
- // TODO: Is this right?
- m_sstat[1] |= SSTAT1_LOA;
- m_scntl[0] &= ~SCNTL0_START;
- m_sstat[0] |= SSTAT0_CMP;
- update_irqs();
-
- set_scsi_state(FINISHED);
- step(true);
- }
-
- break;
- }
-
- // Full arbitration?
- if (((m_scntl[0] >> SCNTL0_ARB_SHIFT) & SCNTL0_ARB_MASK) == 3)
- {
- int win;
- for (win = 7; win >=0 && !(data & (1 << win)); win--);
-
- if ((1 << win) != m_scid)
- {
- scsi_bus->data_w(scsi_refid, 0);
- scsi_bus->ctrl_w(scsi_refid, 0, S_ALL);
-
- delay(attotime::from_nsec(2400));
- break;
- }
-
- // Begin the select phase; assert SEL
- m_sstat[1] |= SSTAT1_WOA;
- scsi_bus->ctrl_w(scsi_refid, S_SEL, S_SEL);
- set_scsi_state(ARBITRATE_ASSERT_SEL);
- delay(attotime::from_nsec(1200));
- }
- else
- {
- // TODO: Worth adding another state here?
- m_sstat[0] |= SSTAT0_CMP;
- m_scntl[0] &= ~SCNTL0_START;
- update_irqs();
- set_scsi_state(FINISHED);
- step(true);
- }
-
- break;
- }
-
- case ARBITRATE_ASSERT_SEL:
- {
- if (!timeout)
- break;
-
- // Activate data line of the thing
- scsi_bus->data_w(scsi_refid, m_sdid);
-
- set_scsi_state(ARBITRATE_SELECT_DEST);
- delay(attotime::from_nsec(2));
-
- break;
- }
-
- case ARBITRATE_SELECT_DEST:
- {
- if (!timeout)
- break;
-
- scsi_bus->ctrl_w(scsi_refid, m_scntl[0] & SCNTL0_WATN ? S_ATN : 0, S_ATN | S_BSY);
-
- set_scsi_state(ARBITRATE_RELEASE_BSY);
- delay(attotime::from_nsec(20));
-
- break;
- }
-
- case ARBITRATE_RELEASE_BSY:
- {
- if (!timeout)
- break;
-
- set_scsi_state(ARBITRATE_DESKEW_WAIT);
- delay(attotime::from_nsec(500));
-
- break;
- }
-
- case ARBITRATE_DESKEW_WAIT:
- {
- if (!timeout)
- break;
-
- // Clear everything
- scsi_bus->data_w(scsi_refid, 0);
- scsi_bus->ctrl_w(scsi_refid, 0, S_SEL);
-
- // Done?
- m_sstat[0] |= SSTAT0_CMP;
- m_scntl[0] &= ~SCNTL0_START;
- //update_irqs();
- set_scsi_state(FINISHED);
- m_connected = true;
-
- step(true);
- break;
- }
-
-
- // Note this is actually block transfers
- case INIT_XFER:
- {
- if (ctrl & S_INP)
- {
- set_scsi_state(m_dbc ? INIT_XFER_RECV_BYTE_ACK : INIT_XFER_RECV_BYTE_NACK);
- recv_byte();
- }
- else
- {
- if (m_dbc == 1)
- scsi_bus->ctrl_w(scsi_refid, 0, S_ATN);
-
- set_scsi_state(INIT_XFER_SEND_BYTE);
- send_byte();
- }
-
- break;
- }
-
- case INIT_XFER_SEND_BYTE:
- {
- if (m_dbc == 0)
- {
- set_scsi_state(FINISHED);
- step(true);
- }
- else
- {
- set_scsi_state(INIT_XFER_WAIT_REQ);
- }
-
- break;
- }
-
- case INIT_XFER_RECV_BYTE_ACK:
- {
- set_scsi_state(INIT_XFER_WAIT_REQ);
- scsi_bus->ctrl_w(scsi_refid, 0, S_ACK);
-
- break;
- }
-
- case INIT_XFER_RECV_BYTE_NACK:
- {
- set_scsi_state(FINISHED);
- step(true);
-
- break;
- }
-
- case INIT_XFER_WAIT_REQ:
- {
- if (!(ctrl & S_REQ))
- break;
-
- if ((ctrl & S_PHASE_MASK) != m_xfr_phase)
- {
- set_scsi_state(FINISHED);
- step(true);
- }
- else
- {
- set_scsi_state(INIT_XFER);
- step(false);
- }
-
- break;
- }
-
- case SEND_WAIT_SETTLE << SUB_SHIFT:
- {
- if (!timeout)
- break;
-
- set_scsi_state( (m_scsi_state & STATE_MASK) | (SEND_WAIT_REQ_0 << SUB_SHIFT) );
- step(false);
-
- break;
- }
-
- case SEND_WAIT_REQ_0 << SUB_SHIFT:
- {
- if (ctrl & S_REQ)
- break;
-
- set_scsi_state(m_scsi_state & STATE_MASK);
- scsi_bus->data_w(scsi_refid, 0);
- scsi_bus->ctrl_w(scsi_refid, 0, S_ACK);
-
- step(false);
-
- break;
- }
-
- case RECV_WAIT_REQ_1 << SUB_SHIFT:
- {
- if (!(ctrl & S_REQ))
- break;
-
- set_scsi_state( (m_scsi_state & STATE_MASK) | (RECV_WAIT_SETTLE << SUB_SHIFT) );
- delay(attotime::from_nsec(5));
-
- break;
- }
-
- case RECV_WAIT_SETTLE << SUB_SHIFT:
- {
- if (!timeout)
- break;
-
- if ((m_scsi_state & STATE_MASK) != INIT_XFER_RECV_PAD)
- {
- m_last_data = scsi_bus->data_r();
-
- UINT32 shift = (8 * (m_dnad & 3));
- UINT32 mem_mask = 0xff << shift;
- m_host_write(m_dnad & ~3, data << shift, mem_mask);
-
- ++m_dnad;
- --m_dbc;
- }
-
- scsi_bus->ctrl_w(scsi_refid, S_ACK, S_ACK);
- set_scsi_state( (m_scsi_state & STATE_MASK) | (RECV_WAIT_REQ_0 << SUB_SHIFT) );
- step(false);
-
- break;
- }
-
- case RECV_WAIT_REQ_0 << SUB_SHIFT:
- {
- if (ctrl & S_REQ)
- break;
-
- set_scsi_state(m_scsi_state & STATE_MASK);
- step(false);
-
- break;
- }
-
- default:
- fatalerror("Unknown state! (%x)\n", m_scsi_state);
-
- }
-}
-
-
-//**************************************************************************
-// SCSI SCRIPTS
-//**************************************************************************
-
-#define UNIMPLEMENTED fatalerror("%s is unimplemented\n", __FUNCTION__)
-
-//-------------------------------------------------
-// set_scripts_state -
-//-------------------------------------------------
-
-void ncr53c7xx_device::set_scripts_state(scripts_state state)
-{
- m_scripts_state = state;
-}
-
-
-//-------------------------------------------------
-// scripts_yield - suspend execution
-//-------------------------------------------------
-void ncr53c7xx_device::scripts_yield()
-{
- m_icount = 0;
-}
-
-
-//-------------------------------------------------
-// execute_run - SCRIPTS execution loop
-//-------------------------------------------------
-
-void ncr53c7xx_device::execute_run()
-{
- // Not processing anything so bail
- if (m_scripts_state < SCRIPTS_FETCH)
- {
- m_icount = 0;
- return;
- }
-
- do
- {
- switch (m_scripts_state)
- {
- case SCRIPTS_FETCH:
- {
- m_finished = false;
-
- // Fetch the instruction
- UINT32 inst = m_host_read(m_dsp, 0xffffffff);
-
- m_dcmd = inst >> 24;
- m_dbc = inst & 0xffffff;
-
- // Unless we encounter an illegal instruction...
- set_scripts_state(SCRIPTS_EXECUTE);
-
- // Decode the relevant group
- switch ((m_dcmd >> 6) & 3)
- {
- case 0:
- scripts_decode_bm();
- break;
-
- case 1:
- scripts_decode_io();
- break;
-
- case 2:
- scripts_decode_tc();
- break;
-
- case 3:
- illegal();
- }
-
- VERBOSE_LOG(machine(), 3, "%s", disassemble_scripts());
- break;
- }
-
- case SCRIPTS_EXECUTE:
- {
- (*this.*m_scripts_op)();
- break;
- }
- }
-
- m_icount--;
- } while (m_icount > 0);
-}
-
-
-//-------------------------------------------------
-// scripts_decode_bm - decode block move
-//-------------------------------------------------
-
-void ncr53c7xx_device::scripts_decode_bm(void)
-{
- // Decode our instruction
- if (m_scntl[0] & SCNTL0_TRG)
- {
- // Target mode
- switch ((m_dcmd >> 3) & 3)
- {
- case 0:
- m_scripts_op = &ncr53c7xx_device::bm_t_move;
- break;
-
- default:
- illegal();
- return;
- }
- }
- else
- {
- // Initiator mode
- switch ((m_dcmd >> 3) & 3)
- {
- case 0:
- m_scripts_op = &ncr53c7xx_device::bm_i_move;
- break;
-
- case 1:
- m_scripts_op = &ncr53c7xx_device::bm_i_wmov;
- break;
-
- default:
- illegal();
- return;
- }
- }
-
- m_dnad = m_host_read(m_dsp + 4, 0xffffffff);
- m_dsp += 8;
-}
-
-
-//-------------------------------------------------
-// scripts_decode_io - decode IO
-//-------------------------------------------------
-
-void ncr53c7xx_device::scripts_decode_io(void)
-{
- // Set Target Mode?
- if (m_dbc & (1 << 9))
- m_scntl[0] |= SCNTL0_TRG;
-
- // Decode our instruction
- if (m_scntl[0] & SCNTL0_TRG)
- {
- // Initiator mode
- switch ((m_dcmd >> 3) & 7)
- {
- case 0:
- m_scripts_op = &ncr53c7xx_device::io_t_reselect;
- break;
-
- case 1:
- m_scripts_op = &ncr53c7xx_device::io_t_disconnect;
- break;
-
- case 2:
- m_scripts_op = &ncr53c7xx_device::io_t_waitselect;
- break;
-
- case 3:
- m_scripts_op = &ncr53c7xx_device::io_t_set;
- break;
-
- case 4:
- m_scripts_op = &ncr53c7xx_device::io_t_clear;
- break;
-
- default:
- illegal();
- return;
- }
- }
- else
- {
- // Initiator mode
- switch ((m_dcmd >> 3) & 7)
- {
- case 0:
- m_scripts_op = &ncr53c7xx_device::io_i_select;
- break;
-
- case 1:
- m_scripts_op = &ncr53c7xx_device::io_i_waitdisconnect;
- break;
-
- case 2:
- m_scripts_op = &ncr53c7xx_device::io_i_waitreselect;
- break;
-
- case 3:
- m_scripts_op = &ncr53c7xx_device::io_i_set;
- break;
-
- case 4:
- m_scripts_op = &ncr53c7xx_device::io_i_clear;
- break;
-
- default:
- illegal();
- return;
- }
- }
-
- // Set some additional registers
- m_dnad = m_dsps = m_host_read(m_dsp + 4, 0xffffffff);
- m_dsp += 8;
-}
-
-
-//-------------------------------------------------
-// scripts_decode_tc - decode transfer control
-//-------------------------------------------------
-
-void ncr53c7xx_device::scripts_decode_tc(void)
-{
- // Decode our instruction
- switch ((m_dcmd >> 3) & 7)
- {
- case 0:
- m_scripts_op = &ncr53c7xx_device::tc_jump;
- break;
-
- case 1:
- m_scripts_op = &ncr53c7xx_device::tc_call;
- break;
-
- case 2:
- m_scripts_op = &ncr53c7xx_device::tc_return;
- break;
-
- case 3:
- m_scripts_op = &ncr53c7xx_device::tc_int;
- break;
-
- default:
- illegal();
- break;
- }
-
- m_dnad = m_dsps = m_host_read(m_dsp + 4, 0xffffffff);
- m_dsp += 8;
-}
-
-//**************************************************************************
-// SCSI SCRIPTS INSTRUCTIONS
-//**************************************************************************
-
-//-------------------------------------------------
-// illegal - illegal instruction
-//-------------------------------------------------
-
-void ncr53c7xx_device::illegal()
-{
- m_dstat |= DSTAT_OPC;
- update_irqs();
- set_scripts_state(SCRIPTS_IDLE);
-
-}
-
-
-//-------------------------------------------------
-// bm_t_move - block move (target)
-//-------------------------------------------------
-
-void ncr53c7xx_device::bm_t_move()
-{
- UNIMPLEMENTED;
-}
-
-
-//-------------------------------------------------
-// bm_i_move - block move (initiator)
-//-------------------------------------------------
-
-void ncr53c7xx_device::bm_i_move()
-{
- UNIMPLEMENTED;
-}
-
-
-//-------------------------------------------------
-// bm_i_wmov - wait block move (initiator)
-//-------------------------------------------------
-
-void ncr53c7xx_device::bm_i_wmov()
-{
- if (!m_finished)
- {
- if (m_scsi_state == IDLE)
- {
- if (m_dbc == 0)
- {
- VERBOSE_LOG(machine(), 0, "DBC should not be 0\n");
- illegal();
- }
-
- // Indirect addressing
- if (m_dcmd & (1 << 5))
- m_dnad = m_host_read(m_dnad, 0xffffffff);
-
- // Compare the phase bits
- if ((scsi_bus->ctrl_r() & 7) == (m_dcmd & 7))
- {
- // Transfer bytes
- set_scsi_state(INIT_XFER);
- m_xfr_phase = m_dcmd & 7;
- step(false);
- }
- else
- {
- fatalerror("Phase mismatch\n");
- }
- }
- else
- {
- scripts_yield();
- }
- }
- else
- {
- // TODO: We should see what happened here; different behaviour
- // depending on whether or not we won arbitration
- set_scripts_state(SCRIPTS_FETCH);
- }
-}
-
-
-//-------------------------------------------------
-// io_t_reselect -
-//-------------------------------------------------
-
-void ncr53c7xx_device::io_t_reselect()
-{
- UNIMPLEMENTED;
-}
-
-
-//-------------------------------------------------
-// io_t_disconnect -
-//-------------------------------------------------
-
-void ncr53c7xx_device::io_t_disconnect()
-{
- UNIMPLEMENTED;
-}
-
-
-//-------------------------------------------------
-// io_t_waitselect -
-//-------------------------------------------------
-
-void ncr53c7xx_device::io_t_waitselect()
-{
- UNIMPLEMENTED;
-}
-
-
-//-------------------------------------------------
-// io_t_set -
-//-------------------------------------------------
-
-void ncr53c7xx_device::io_t_set()
-{
- UNIMPLEMENTED;
-}
-
-
-//-------------------------------------------------
-// io_t_clear -
-//-------------------------------------------------
-
-void ncr53c7xx_device::io_t_clear()
-{
- UNIMPLEMENTED;
-}
-
-
-//-------------------------------------------------
-// io_i_select -
-//-------------------------------------------------
-
-void ncr53c7xx_device::io_i_select()
-{
- if (!m_finished)
- {
- if (m_scsi_state == IDLE)
- {
- m_sdid = m_dbc >> 16;
- m_scntl[0] |= (3 << SCNTL0_ARB_SHIFT) | SCNTL0_START;
-
- // Set select with ATN bit
- if (m_dcmd & 1)
- m_scntl[0] |= SCNTL0_WATN;
-
- // Start the arbitration
- set_scsi_state(ARBITRATE_WAIT_FREE);
- step(true);
- }
-
- scripts_yield();
- }
- else
- {
- // TODO: We should see what happened here; different behaviour
- // depending on whether or not we won arbitration
- set_scripts_state(SCRIPTS_FETCH);
- }
-}
-
-
-//-------------------------------------------------
-// io_i_waitdisconnect -
-//-------------------------------------------------
-
-void ncr53c7xx_device::io_i_waitdisconnect()
-{
- if (scsi_bus->ctrl_r() & (S_BSY | S_SEL))
- scripts_yield();
- else
- set_scripts_state(SCRIPTS_FETCH);
-}
-
-
-//-------------------------------------------------
-// io_i_waitreselect -
-//-------------------------------------------------
-
-void ncr53c7xx_device::io_i_waitreselect()
-{
- UNIMPLEMENTED;
-}
-
-
-//-------------------------------------------------
-// io_i_set -
-//-------------------------------------------------
-
-void ncr53c7xx_device::io_i_set()
-{
- UINT32 mask = 0;
-
- if (m_dbc & (1 << 3))
- mask |= S_ATN;
-
- if (m_dbc & (1 << 6))
- mask |= S_ACK;
-
- scsi_bus->ctrl_w(scsi_refid, mask, mask);
-
- set_scripts_state(SCRIPTS_FETCH);
-}
-
-
-//-------------------------------------------------
-// io_i_clear -
-//-------------------------------------------------
-
-void ncr53c7xx_device::io_i_clear()
-{
- UINT32 mask = 0;
-
- if (m_dbc & (1 << 3))
- mask |= S_ATN;
-
- if (m_dbc & (1 << 6))
- mask |= S_ACK;
-
- scsi_bus->ctrl_w(scsi_refid, 0, mask);
-
- set_scripts_state(SCRIPTS_FETCH);
-}
-
-
-//-------------------------------------------------
-// tc_jump -
-//-------------------------------------------------
-
-void ncr53c7xx_device::tc_jump()
-{
-// if (m_dbc & (1 << 16))
-// printf("Must wait for valid phase?\n");
-
- bool jump = true;
-
- if (m_dbc & (1 << 17))
- {
- // Phase
- jump &= (m_dcmd & 7) == (scsi_bus->ctrl_r() & 7);
- }
- if (m_dbc & (1 << 18))
- {
- // Data
- jump &= (m_dbc & 0xff) == m_last_data;
- }
-
- if (!(m_dbc & (1 << 19)))
- jump = !jump;
-
- if (jump)
- {
- m_dsp = m_dsps;
- }
- set_scripts_state(SCRIPTS_FETCH);
-}
-
-
-//-------------------------------------------------
-// tc_call -
-//-------------------------------------------------
-
-void ncr53c7xx_device::tc_call()
-{
- bool jump = true;
-
- if (m_dbc & (1 << 17))
- {
- // Phase
- jump &= (m_dcmd & 7) == (scsi_bus->ctrl_r() & 7);
- }
- if (m_dbc & (1 << 18))
- {
- // Data
- jump &= (m_dbc & 0xff) == m_last_data;
- }
-
- if (!(m_dbc & (1 << 19)))
- jump = !jump;
-
- if (jump)
- {
- m_temp = m_dsp;
- m_dsp = m_dsps;
- }
- set_scripts_state(SCRIPTS_FETCH);
-}
-
-
-//-------------------------------------------------
-// tc_return -
-//-------------------------------------------------
-
-void ncr53c7xx_device::tc_return()
-{
- bool jump = true;
-
- if (m_dbc & (1 << 17))
- {
- // Phase
- jump &= (m_dcmd & 7) == (scsi_bus->ctrl_r() & 7);
- }
- if (m_dbc & (1 << 18))
- {
- // Data
- jump &= (m_dbc & 0xff) == m_last_data;
- }
-
- if (!(m_dbc & (1 << 19)))
- jump = !jump;
-
- if (jump)
- {
- m_dsp = m_temp;
- }
- set_scripts_state(SCRIPTS_FETCH);
-}
-
-
-//-------------------------------------------------
-// tc_int -
-//-------------------------------------------------
-
-void ncr53c7xx_device::tc_int()
-{
- bool jump = true;
-
- if (m_dbc & (1 << 17))
- {
- // Phase
- jump &= (m_dcmd & 7) == (scsi_bus->ctrl_r() & 7);
- }
- if (m_dbc & (1 << 18))
- {
- // Data
- jump &= (m_dbc & 0xff) == m_last_data;
- }
-
- if (!(m_dbc & (1 << 19)))
- jump = !jump;
-
- if (jump)
- {
- m_dstat |= DSTAT_SIR;
- update_irqs();
- set_scripts_state(SCRIPTS_IDLE);
- }
- else
- {
- set_scripts_state(SCRIPTS_FETCH);
- }
-}
-
-
-//**************************************************************************
-// SCSI SCRIPTS DISASSEMBLY
-//**************************************************************************
-
-//-------------------------------------------------
-// disassemble_scripts -
-//-------------------------------------------------
-
-const char* ncr53c7xx_device::disassemble_scripts()
-{
- static const char* phases[] =
- {
- "Data Out",
- "Data In",
- "Command",
- "Status",
- "Reserved",
- "Reserved",
- "Message Out",
- "Message In"
- };
-
- static char buffer[64];
- char opstring[64];
-
- switch ((m_dcmd >> 6) & 3)
- {
- case 0:
- {
- sprintf(opstring, "BMOV: %s [%x] %d bytes\n", phases[m_dcmd & 7], m_dnad, m_dbc);
- break;
- }
- case 1:
- {
- static const char* ops[] =
- {
- "SELECT",
- "DISCONNECT",
- "RESELECT",
- "SET",
- "CLEAR",
- "ILLEGAL",
- "ILLEGAL",
- "ILLEGAL",
- };
-
- sprintf(opstring, "IO: %s (%x)\n", ops[(m_dcmd >> 3) & 7], m_dnad);
- break;
- }
- case 2:
- {
- static const char* ops[] =
- {
- "JUMP",
- "CALL",
- "RETURN",
- "INT",
- "ILLEGAL",
- "ILLEGAL",
- "ILLEGAL",
- "ILLEGAL",
- };
-
- sprintf(opstring, "TC: %s %c (%s) (%x)\n", ops[(m_dcmd >> 3) & 7], m_dbc & (1 << 19) ? 'T' : 'F', phases[m_dcmd & 7], m_dnad);
- break;
- }
- case 3:
- {
- sprintf(opstring, "ILLEGAL");
- break;
- }
- }
-
- sprintf(buffer, "SCRIPTS [%08x]: %s", m_dsp - 8, opstring);
-
- return buffer;
-}
diff --git a/src/emu/machine/53c7xx.h b/src/emu/machine/53c7xx.h
deleted file mode 100644
index 937bd9d16a0..00000000000
--- a/src/emu/machine/53c7xx.h
+++ /dev/null
@@ -1,229 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Philip Bennett
-/*********************************************************************
-
- 53c7xx.h
-
- NCR 53C700 SCSI I/O Processor
-
-*********************************************************************/
-
-#ifndef _NCR53C7XX_H_
-#define _NCR53C7XX_H_
-
-#include "machine/nscsi_bus.h"
-
-
-//**************************************************************************
-// REGISTER DEFINES (INCOMPLETE)
-//**************************************************************************
-
-#define SCNTL0_TRG 0x01
-#define SCNTL0_AAP 0x02
-#define SCNTL0_EPG 0x04
-#define SCNTL0_EPC 0x08
-#define SCNTL0_WATN 0x10
-#define SCNTL0_START 0x20
-#define SCNTL0_ARB_MASK 3
-#define SCNTL0_ARB_SHIFT 6
-
-#define SSTAT0_PAR 0x01
-#define SSTAT0_RST 0x02
-#define SSTAT0_UDC 0x04
-#define SSTAT0_SGE 0x08
-#define SSTAT0_SEL 0x10
-#define SSTAT0_STO 0x20
-#define SSTAT0_CMP 0x40
-#define SSTAT0_MA 0x80
-
-#define SSTAT1_SDP 0x01
-#define SSTAT1_RST 0x02
-#define SSTAT1_WOA 0x04
-#define SSTAT1_LOA 0x08
-#define SSTAT1_AIP 0x10
-#define SSTAT1_ORF 0x20
-#define SSTAT1_OLF 0x40
-#define SSTAT1_ILF 0x80
-
-#define ISTAT_DIP 0x01
-#define ISTAT_SIP 0x02
-#define ISTAT_PRE 0x04
-#define ISTAT_CON 0x08
-#define ISTAT_ABRT 0x80
-
-#define DSTAT_OPC 0x01
-#define DSTAT_WTD 0x02
-#define DSTAT_SIR 0x04
-#define DSTAT_SSI 0x08
-#define DSTAT_ABRT 0x10
-#define DSTAT_DFE 0x80
-
-#define MCFG_NCR53C7XX_IRQ_HANDLER(_devcb) \
- devcb = &ncr53c7xx_device::set_irq_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_NCR53C7XX_HOST_WRITE(_devcb) \
- devcb = &ncr53c7xx_device::set_host_write(*device, DEVCB_##_devcb);
-
-#define MCFG_NCR53C7XX_HOST_READ(_devcb) \
- devcb = &ncr53c7xx_device::set_host_read(*device, DEVCB_##_devcb);
-
-class ncr53c7xx_device : public nscsi_device,
- public device_execute_interface
-{
-public:
- // construction/destruction
- ncr53c7xx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_irq_handler(device_t &device, _Object object) { return downcast<ncr53c7xx_device &>(device).m_irq_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_host_write(device_t &device, _Object object) { return downcast<ncr53c7xx_device &>(device).m_host_write.set_callback(object); }
- template<class _Object> static devcb_base &set_host_read(device_t &device, _Object object) { return downcast<ncr53c7xx_device &>(device).m_host_read.set_callback(object); }
-
- // our API
- DECLARE_READ32_MEMBER(read);
- DECLARE_WRITE32_MEMBER(write);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual void execute_run();
-
- int m_icount;
-
-private:
-
- enum
- {
- STATE_MASK = 0x00ff,
- SUB_SHIFT = 8,
- SUB_MASK = 0xff00
- };
-
- enum
- {
- MODE_I,
- MODE_T,
- MODE_D
- };
-
- enum scsi_state
- {
- IDLE,
- FINISHED,
- ARBITRATE_WAIT_FREE,
- ARBITRATE_CHECK_FREE,
- ARBITRATE_EXAMINE_BUS,
- ARBITRATE_SELECT_DEST,
- ARBITRATE_ASSERT_SEL,
- ARBITRATE_RELEASE_BSY,
- ARBITRATE_DESKEW_WAIT,
- SELECT,
- SELECT_COMPLETE,
- INIT_XFER,
- INIT_XFER_WAIT_REQ,
- INIT_XFER_SEND_BYTE,
- INIT_XFER_RECV_PAD,
- INIT_XFER_RECV_BYTE_ACK,
- INIT_XFER_RECV_BYTE_NACK,
- SEND_WAIT_REQ_0,
- SEND_WAIT_SETTLE,
- RECV_WAIT_SETTLE,
- RECV_WAIT_REQ_0,
- RECV_WAIT_REQ_1
- };
-
- void update_irqs();
- void set_scsi_state(int state);
- void delay(const attotime &delay);
- void scsi_ctrl_changed();
- void send_byte();
- void recv_byte();
- void step(bool timeout);
-
-
- enum scripts_state
- {
- SCRIPTS_IDLE,
- SCRIPTS_WAIT_MANUAL_START,
- SCRIPTS_FETCH,
- SCRIPTS_EXECUTE
- };
-
- void set_scripts_state(scripts_state state);
- void scripts_yield();
- void scripts_decode_bm(void);
- void scripts_decode_io(void);
- void scripts_decode_tc(void);
- void bm_t_move();
- void bm_i_move();
- void bm_i_wmov();
- void io_t_reselect();
- void io_t_disconnect();
- void io_t_waitselect();
- void io_t_set();
- void io_t_clear();
- void io_i_select();
- void io_i_waitdisconnect();
- void io_i_waitreselect();
- void io_i_set();
- void io_i_clear();
- void tc_jump();
- void tc_call();
- void tc_return();
- void tc_int();
- void illegal();
- const char* disassemble_scripts();
-
-
- // SCSI registers
- UINT8 m_scntl[2];
- UINT8 m_sdid;
- UINT8 m_sien;
- UINT8 m_scid;
- UINT8 m_sxfer;
- UINT8 m_sodl;
- UINT8 m_socl;
- UINT8 m_sfbr;
- UINT8 m_sidl;
- UINT8 m_sbdl;
- UINT8 m_sbcl;
- UINT8 m_dstat;
- UINT8 m_sstat[3];
- UINT8 m_ctest[8];
- UINT32 m_temp;
- UINT8 m_dfifo;
- UINT8 m_istat;
- UINT32 m_dbc;
- UINT8 m_dcmd;
- UINT32 m_dnad;
- UINT32 m_dsp;
- UINT32 m_dsps;
- UINT8 m_dmode;
- UINT8 m_dien;
- UINT8 m_dwt;
- UINT8 m_dcntl;
-
-
- // other state
- int m_scsi_state;
- bool m_connected;
- bool m_finished;
- UINT8 m_last_data;
- UINT32 m_xfr_phase;
- emu_timer *m_tm;
-
- int m_scripts_state;
- //int m_scripts_substate;
- void (ncr53c7xx_device::*m_scripts_op)();
-
- // callbacks
- devcb_write_line m_irq_handler;
- devcb_write32 m_host_write;
- devcb_read32 m_host_read;
-};
-
-// device type definition
-extern const device_type NCR53C7XX;
-#endif
diff --git a/src/emu/machine/53c810.c b/src/emu/machine/53c810.c
deleted file mode 100644
index a2a22f0fac0..00000000000
--- a/src/emu/machine/53c810.c
+++ /dev/null
@@ -1,816 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/* LSI Logic LSI53C810A PCI to SCSI I/O Processor */
-
-#include "emu.h"
-#include "53c810.h"
-#include "bus/scsi/scsihle.h"
-
-#define DMA_MAX_ICOUNT 512 /* Maximum number of DMA Scripts opcodes to run */
-#define DASM_OPCODES 0
-
-UINT32 lsi53c810_device::FETCH()
-{
- UINT32 r = m_fetch_cb(dsp);
- dsp += 4;
- return r;
-}
-
-void lsi53c810_device::dmaop_invalid()
-{
- fatalerror("LSI53C810: Invalid SCRIPTS DMA opcode %08X at %08X\n", dcmd, dsp);
-}
-
-void lsi53c810_device::dmaop_move_memory()
-{
- UINT32 src = FETCH();
- UINT32 dst = FETCH();
- int count;
-
- count = dcmd & 0xffffff;
- if (!m_dma_cb.isnull())
- m_dma_cb(src, dst, count, 1);
-}
-
-void lsi53c810_device::dmaop_interrupt()
-{
- if(dcmd & 0x100000) {
- fatalerror("LSI53C810: INTFLY opcode not implemented\n");
- }
- dsps = FETCH();
-
- istat |= 0x1; /* DMA interrupt pending */
- dstat |= 0x4; /* SIR (SCRIPTS Interrupt Instruction Received) */
-
- if (!m_irq_cb.isnull())
- m_irq_cb(1);
-
- dma_icount = 0;
- halted = 1;
-}
-
-void lsi53c810_device::dmaop_block_move()
-{
- UINT32 address;
- UINT32 count;
- INT32 dsps;
-
- address = FETCH();
- count = dcmd & 0x00ffffff;
-
- // normal indirect
- if (dcmd & 0x20000000)
- address = m_fetch_cb(address);
-
- // table indirect
- if (dcmd & 0x10000000)
- {
- dsps = (INT32)address&0xffffff;
- // sign extend
- if (dsps & 0x00800000)
- {
- dsps |= 0xff000000;
- }
- logerror("table offset: %x, DSA = %x\n", dsps, dsa);
- dsps += dsa;
-
- logerror("Loading from table at %x\n", dsps);
- count = m_fetch_cb(dsps);
- address = m_fetch_cb(dsps + 4);
- }
-
- logerror("block move: address %x count %x phase %x\n", address, count, (dcmd>>24)&7);
-
- if (scntl0 & 0x01)
- {
- /* target mode */
- fatalerror("LSI53C810: dmaop_block_move not implemented in target mode\n");
- }
- else
- {
- /* initiator mode */
- logerror("53c810: block_move not actually implemented\n");
- }
-}
-
-void lsi53c810_device::dmaop_select()
-{
-// UINT32 operand;
-
-// operand = FETCH();
-
- if (scntl0 & 0x01)
- {
- /* target mode */
- logerror("LSI53C810: reselect ID #%d\n", (dcmd >> 16) & 0x07);
- }
- else
- {
- select((dcmd>>16)&7);
-
- /* initiator mode */
- logerror("53c810: SELECT: our ID %d, target ID %d\n", scid&7, (dcmd>>16)&7);
-
- sstat1 &= ~0x07; // clear current bus phase
- if (dcmd & 0x01000000) // select with ATN
- {
- osd_printf_debug("53c810: want select with ATN, setting message phase\n");
- sstat1 |= 0x7; // ATN means we want message in phase
- }
- }
-}
-
-void lsi53c810_device::dmaop_wait_disconnect()
-{
-// UINT32 operand;
-
-// operand = FETCH();
-
- if (scntl0 & 0x01)
- {
- /* target mode */
- fatalerror("LSI53C810: dmaop_wait_disconnect not implemented in target mode\n");
- }
- else
- {
- /* initiator mode */
- fatalerror("LSI53C810: dmaop_wait_disconnect not implemented\n");
- }
-}
-
-void lsi53c810_device::dmaop_wait_reselect()
-{
- // UINT32 operand;
-
-// operand = FETCH();
-
- if (scntl0 & 0x01)
- {
- /* target mode */
- fatalerror("LSI53C810: dmaop_wait_reselect not implemented in target mode\n");
- }
- else
- {
- /* initiator mode */
- fatalerror("LSI53C810: dmaop_wait_reselect not implemented\n");
- }
-}
-
-void lsi53c810_device::dmaop_set()
-{
-// UINT32 operand;
-
-// operand = FETCH();
-
- /* initiator mode */
- if (dcmd & 0x8)
- {
- // set ATN in SOCL
- socl |= 0x08;
- }
- if (dcmd & 0x40)
- {
- // set ACK in SOCL
- socl |= 0x40;
- }
- if (dcmd & 0x200)
- {
- // set target mode
- scntl0 |= 0x01;
- }
- if (dcmd & 0x400)
- {
- // set carry in ALU
- carry = 1;
- }
-}
-
-void lsi53c810_device::dmaop_clear()
-{
-// UINT32 operand;
-
-// operand = FETCH();
-
- /* initiator mode */
- if (dcmd & 0x8)
- {
- // clear ATN in SOCL
- socl &= ~0x08;
- }
- if (dcmd & 0x40)
- {
- // clear ACK in SOCL
- socl &= ~0x40;
- }
- if (dcmd & 0x200)
- {
- // clear target mode
- scntl0 &= ~0x01;
- }
- if (dcmd & 0x400)
- {
- // clear carry in ALU
- carry = 0;
- }
-}
-
-void lsi53c810_device::dmaop_move_from_sfbr()
-{
- fatalerror("LSI53C810: dmaop_move_from_sfbr not implemented in target mode\n");
-}
-
-void lsi53c810_device::dmaop_move_to_sfbr()
-{
- fatalerror("LSI53C810: dmaop_move_to_sfbr not implemented\n");
-}
-
-void lsi53c810_device::dmaop_read_modify_write()
-{
- fatalerror("LSI53C810: dmaop_read_modify_write not implemented\n");
-}
-
-int lsi53c810_device::scripts_compute_branch()
-{
- int dtest, ptest, wanted, passed;
-
-// |jump if true
-// 878b0000 ||compare data
-// 1000 0111 1000 1011 0000 0000 0000 0000
-// | |rel ||wait valid phase
-// | |compare phase
-// |desired phase: message in
-
- if (dcmd & 0x00200000)
- {
- fatalerror("LSI53C810: jump with carry test not implemented\n");
- }
-
- if (dcmd & 0x00100000)
- {
- fatalerror("LSI53C810: jump with interrupt on the fly not implemented\n");
- }
-
- // set desired result to take jump
- wanted = (dcmd & 0x00080000) ? 1 : 0;
- // default to passing the tests in case they're disabled
- dtest = ptest = wanted;
-
- // phase test?
- if (dcmd & 0x00020000)
- {
- logerror("53c810: phase test. current: %x. target: %x\n", sstat1 & 7, (dcmd>>24)&7);
-
- // do the phases match?
- if (((dcmd>>24)&7) == (sstat1 & 7))
- {
- ptest = 1;
- }
- else
- {
- ptest = 0;
- }
- }
-
- // data test?
- if (dcmd & 0x00040000)
- {
- logerror("53c810: data test. target: %x [not yet implemented]\n", dcmd&0xff);
- }
-
- // if all conditions go, take the jump
- passed = 0;
- if ((ptest == dtest) && (dtest == wanted))
- {
- passed = 1;
- }
-
- logerror("53c810: phase test %d data test %d wanted %d => pass %d\n", ptest, dtest, wanted, passed);
-
- return passed;
-}
-
-UINT32 lsi53c810_device::scripts_get_jump_dest()
-{
- INT32 dsps;
- UINT32 dest;
-
- dsps = FETCH();
-
- /* relative or absolute addressing? */
- if (dcmd & 0x00800000)
- {
- // sign-extend the 24-bit value
- if (dsps & 0x00800000)
- {
- dsps |= 0xff000000;
- }
-
- logerror("dsps = %x, dsp = %x\n", dsps, dsp);
- dsps += dsp;
- }
-
- dest = (UINT32)dsps;
-
- logerror("cur DSP %x, dest %x\n", dsp, dest);
-
- return dest;
-}
-
-void lsi53c810_device::dmaop_jump()
-{
- if (scripts_compute_branch())
- {
- dsp = scripts_get_jump_dest();
- }
- else
- {
- FETCH(); // skip operand to continue on
- }
-}
-
-void lsi53c810_device::dmaop_call()
-{
- if (scripts_compute_branch())
- {
- // save return address
- temp = dsp;
-
- // and go
- dsp = scripts_get_jump_dest();
- }
- else
- {
- FETCH(); // skip operand to continue on
- }
-}
-
-void lsi53c810_device::dmaop_return()
-{
- // is this correct? return only happens if the condition is true?
- if (scripts_compute_branch())
- {
- // restore return address
- dsp = temp;
- }
- else
- {
- FETCH(); // skip operand to continue on
- }
-}
-
-void lsi53c810_device::dmaop_store()
-{
- fatalerror("LSI53C810: dmaop_store not implemented\n");
-}
-
-void lsi53c810_device::dmaop_load()
-{
- fatalerror("LSI53C810: dmaop_load not implemented\n");
-}
-
-
-
-void lsi53c810_device::dma_exec()
-{
- dma_icount = DMA_MAX_ICOUNT;
-
- while(dma_icount > 0)
- {
- int op;
-
- if (DASM_OPCODES)
- {
- char buf[256];
- lsi53c810_dasm(buf, dsp);
- logerror("0x%08X: %s\n", dsp, buf);
- }
-
- dcmd = FETCH();
-
- op = (dcmd >> 24) & 0xff;
- dma_opcode[op]();
-
- dma_icount--;
- }
-}
-
-UINT8 lsi53c810_device::lsi53c810_reg_r( int offset )
-{
-// logerror("53c810: read reg %d:0x%x (PC=%x)\n", offset, offset, space.device().safe_pc());
- switch(offset)
- {
- case 0x00: /* SCNTL0 */
- return scntl0;
- case 0x01: /* SCNTL1 */
- return scntl1;
- case 0x02: /* SCNTL2 */
- return scntl2;
- case 0x03: /* SCNTL3 */
- return scntl3;
- case 0x04: /* SCID */
- return scid;
- case 0x05: /* SXFER */
- return sxfer;
- case 0x09: /* SOCL */
- return socl;
- case 0x0c: /* DSTAT */
- istat &= ~1;
- return dstat;
- case 0x0d: /* SSTAT0 */
- return sstat0;
- case 0x0e: /* SSTAT1 */
- return sstat1;
- case 0x0f: /* SSTAT2 */
- return sstat2;
- case 0x10: /* DSA [7-0] */
- return dsa & 0xff;
- case 0x11: /* DSA [15-8] */
- return (dsa >> 8) & 0xff;
- case 0x12: /* DSA [23-16] */
- return (dsa >> 16) & 0xff;
- case 0x13: /* DSA [31-24] */
- return (dsa >> 24) & 0xff;
- case 0x14: /* ISTAT */
- // clear the interrupt on service
- if (!m_irq_cb.isnull())
- m_irq_cb(0);
-
- return istat;
- case 0x2c: /* DSP [7-0] */
- return dsp & 0xff;
- case 0x2d: /* DSP [15-8] */
- return (dsp >> 8) & 0xff;
- case 0x2e: /* DSP [23-16] */
- return (dsp >> 16) & 0xff;
- case 0x2f: /* DSP [31-24] */
- return (dsp >> 24) & 0xff;
- case 0x34: /* SCRATCH A */
- case 0x35:
- case 0x36:
- case 0x37:
- return scratch_a[offset % 4];
- case 0x39: /* DIEN */
- return dien;
- case 0x3b: /* DCNTL */
- return dcntl;
- case 0x40: /* SIEN0 */
- return sien0;
- case 0x41: /* SIEN1 */
- return sien1;
- case 0x48: /* STIME0 */
- return stime0;
- case 0x4a: /* RESPID */
- return respid;
- case 0x4d: /* STEST1 */
- return stest1;
- case 0x5c: /* SCRATCH B */
- case 0x5d:
- case 0x5e:
- case 0x5f:
- return scratch_b[offset % 4];
-
- default:
- fatalerror("LSI53C810: reg_r: Unknown reg %02X\n", offset);
- }
-
- // never executed
- //return 0;
-}
-
-void lsi53c810_device::lsi53c810_reg_w(int offset, UINT8 data)
-{
-// logerror("53c810: %02x to reg %d:0x%x (PC=%x)\n", data, offset, offset, space.device().safe_pc());
- switch(offset)
- {
- case 0x00: /* SCNTL0 */
- scntl0 = data;
- break;
- case 0x01: /* SCNTL1 */
- scntl1 = data;
- break;
- case 0x02: /* SCNTL2 */
- scntl2 = data;
- break;
- case 0x03: /* SCNTL3 */
- scntl3 = data;
- break;
- case 0x04: /* SCID */
- scid = data;
- break;
- case 0x05: /* SXFER */
- sxfer = data;
- break;
- case 0x09: /* SOCL */
- socl = data;
- break;
- case 0x0d: /* SSTAT0 */
- sstat0 = data;
- break;
- case 0x0e: /* SSTAT1 */
- sstat1 = data;
- break;
- case 0x0f: /* SSTAT2 */
- sstat2 = data;
- break;
- case 0x10: /* DSA [7-0] */
- dsa &= 0xffffff00;
- dsa |= data;
- break;
- case 0x11: /* DSA [15-8] */
- dsa &= 0xffff00ff;
- dsa |= data << 8;
- break;
- case 0x12: /* DSA [23-16] */
- dsa &= 0xff00ffff;
- dsa |= data << 16;
- break;
- case 0x13: /* DSA [31-24] */
- dsa &= 0x00ffffff;
- dsa |= data << 24;
- break;
- case 0x14: /* ISTAT */
- istat = data;
- break;
- case 0x2c: /* DSP [7-0] */
- dsp &= 0xffffff00;
- dsp |= data;
- break;
- case 0x2d: /* DSP [15-8] */
- dsp &= 0xffff00ff;
- dsp |= data << 8;
- break;
- case 0x2e: /* DSP [23-16] */
- dsp &= 0xff00ffff;
- dsp |= data << 16;
- break;
- case 0x2f: /* DSP [31-24] */
- dsp &= 0x00ffffff;
- dsp |= data << 24;
- halted = 0;
- if((dmode & 0x1) == 0 && !halted) {
- dma_exec();
- }
- break;
- case 0x34: /* SCRATCH A */
- case 0x35:
- case 0x36:
- case 0x37:
- scratch_a[offset % 4] = data;
- break;
- case 0x38: /* DMODE */
- dmode = data;
- break;
- case 0x39: /* DIEN */
- dien = data;
- break;
- case 0x3b: /* DCNTL */
- dcntl = data;
-
- if(dcntl & 0x14 && !halted) /* single-step & start DMA */
- {
- int op;
- dcmd = FETCH();
- op = (dcmd >> 24) & 0xff;
- dma_opcode[op]();
-
- istat |= 0x3; /* DMA interrupt pending */
- dstat |= 0x8; /* SSI (Single Step Interrupt) */
- if (!m_irq_cb.isnull())
- m_irq_cb(1);
- }
- else if(dcntl & 0x04 && !halted) /* manual start DMA */
- {
- dma_exec();
- }
- break;
- case 0x40: /* SIEN0 */
- sien0 = data;
- break;
- case 0x41: /* SIEN1 */
- sien1 = data;
- break;
- case 0x48: /* STIME0 */
- stime0 = data;
- break;
- case 0x4a: /* RESPID */
- respid = data;
- break;
- case 0x4d: /* STEST1 */
- stest1 = data;
- break;
- case 0x5c: /* SCRATCH B */
- case 0x5d:
- case 0x5e:
- case 0x5f:
- scratch_b[offset % 4] = data;
- break;
-
- default:
- fatalerror("LSI53C810: reg_w: Unknown reg %02X, %02X\n", offset, data);
- }
-}
-
-void lsi53c810_device::add_opcode(UINT8 op, UINT8 mask, opcode_handler_delegate handler)
-{
- for (int i = 0; i < 256; i++)
- {
- if ((i & mask) == op)
- {
- dma_opcode[i] = handler;
- }
- }
-}
-
-lsi53c810_device::lsi53c810_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : legacy_scsi_host_adapter(mconfig, LSI53C810, "53C810 SCSI", tag, owner, clock, "lsi53c810", __FILE__)
-{
-}
-
-void lsi53c810_device::device_start()
-{
- legacy_scsi_host_adapter::device_start();
-
- m_irq_cb.bind_relative_to(*owner());
- m_dma_cb.bind_relative_to(*owner());
- m_fetch_cb.bind_relative_to(*owner());
-
- for (int i = 0; i < 256; i++)
- {
- dma_opcode[i] = opcode_handler_delegate(FUNC(lsi53c810_device::dmaop_invalid), this);
- }
-
- add_opcode(0x00, 0xc0, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_block_move ), this));
- add_opcode(0x40, 0xf8, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_select ), this));
- add_opcode(0x48, 0xf8, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_wait_disconnect ), this));
- add_opcode(0x50, 0xf8, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_wait_reselect ), this));
- add_opcode(0x58, 0xf8, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_set ), this));
- add_opcode(0x60, 0xf8, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_clear ), this));
- add_opcode(0x68, 0xf8, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_move_from_sfbr ), this));
- add_opcode(0x70, 0xf8, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_move_to_sfbr ), this));
- add_opcode(0x78, 0xf8, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_read_modify_write ), this));
- add_opcode(0x80, 0xf8, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_jump ), this));
- add_opcode(0x88, 0xf8, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_call ), this));
- add_opcode(0x90, 0xf8, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_return ), this));
- add_opcode(0x98, 0xf8, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_interrupt ), this));
- add_opcode(0xc0, 0xfe, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_move_memory ), this));
- add_opcode(0xe0, 0xed, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_store ), this));
- add_opcode(0xe1, 0xed, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_load ), this));
-}
-
-/*************************************
- *
- * Disassembler
- *
- *************************************/
-
-UINT32 lsi53c810_device::lsi53c810_dasm_fetch(UINT32 pc)
-{
- return m_fetch_cb(pc);
-}
-
-unsigned lsi53c810_device::lsi53c810_dasm(char *buf, UINT32 pc)
-{
- unsigned result = 0;
- const char *op_mnemonic = NULL;
- UINT32 op = lsi53c810_dasm_fetch(pc);
- UINT32 dest;
- int i;
-
- static const char *const phases[] =
- {
- "DATA_OUT", "DATA_IN", "CMD", "STATUS",
- "RESERVED_OUT??", "RESERVED_IN??", "MSG_OUT", "MSG_IN"
- };
-
- if ((op & 0xF8000000) == 0x40000000)
- {
- /* SELECT */
- dest = lsi53c810_dasm_fetch(pc + 4);
-
- buf += sprintf(buf, "SELECT%s %d, 0x%08X",
- (op & 0x01000000) ? " ATN" : "",
- (op >> 16) & 0x07,
- dest);
-
- result = 8;
- }
- else if (((op & 0xF8000000) == 0x58000000)
- | ((op & 0xF8000000) == 0x60000000))
- {
- static const struct
- {
- UINT32 flag;
- const char *text;
- } flags[] =
- {
- { 0x00000008, "ATN" },
- { 0x00000040, "ACK" },
- { 0x00000200, "TARGET" },
- { 0x00000400, "CARRY" }
- };
- int need_cojunction = FALSE;
-
- /* SET/CLEAR */
- switch(op & 0xF8000000)
- {
- case 0x58000000: op_mnemonic = "SET"; break;
- case 0x60000000: op_mnemonic = "CLEAR"; break;
- }
-
- buf += sprintf(buf, "%s ", op_mnemonic);
- need_cojunction = FALSE;
-
- for (i = 0; i < ARRAY_LENGTH(flags); i++)
- {
- if (op & flags[i].flag)
- {
- if (need_cojunction)
- buf += sprintf(buf, " AND ");
- else
- need_cojunction = TRUE;
- buf += sprintf(buf, "%s", flags[i].text);
- }
- }
- }
- else if (((op & 0xF8000000) == 0x80000000)
- | ((op & 0xF8000000) == 0x88000000)
- | ((op & 0xF8000000) == 0x98000000))
- {
- /* JUMP/CALL/INT */
- switch(op & 0xF8000000)
- {
- case 0x80000000: op_mnemonic = "JUMP"; break;
- case 0x88000000: op_mnemonic = "CALL"; break;
- case 0x98000000: op_mnemonic = "INT"; break;
- }
-
- dest = lsi53c810_dasm_fetch(pc + 4);
-
- if (op & 0x00800000)
- {
- /* relative */
- if (dest & 0x00800000)
- dest |= 0xFF000000;
- else
- dest &= 0x00FFFFFF;
- dest = (pc + 8) + dest;
- buf += sprintf(buf, "%s REL(0x%08X)", op_mnemonic, dest);
- }
- else
- {
- /* absolute */
- buf += sprintf(buf, "%s 0x%08X", op_mnemonic, dest);
- }
-
- switch(op & 0x000B0000)
- {
- case 0x00000000:
- buf += sprintf(buf, ", NOT??");
- break;
-
- case 0x00080000:
- break;
-
- case 0x00020000:
- case 0x00030000:
- case 0x000A0000:
- case 0x000B0000:
- buf += sprintf(buf, ", %s%s %s",
- (op & 0x00010000) ? "WHEN" : "IF",
- (op & 0x00080000) ? "" : " NOT",
- phases[(op >> 24) & 0x07]);
- break;
-
- default:
- fatalerror("unknown op 0x%08X\n", op);
- }
- result = 8;
- }
- else if ((op & 0xE0000000) == 0x00000000)
- {
- /* MOVE FROM */
- dest = lsi53c810_dasm_fetch(pc + 4);
-
- buf += sprintf(buf, "MOVE FROM 0x%08X, WHEN %s",
- dest, phases[(op >> 24) & 0x07]);
-
- result = 8;
- }
- else if ((op & 0xE0000000) == 0x20000000)
- {
- /* MOVE PTR */
- dest = lsi53c810_dasm_fetch(pc + 4);
-
- buf += sprintf(buf, "MOVE 0x%08X, PTR 0x%08X, WHEN %s",
- (op & 0x00FFFFFF), dest, phases[(op >> 24) & 0x07]);
-
- result = 8;
- }
- else
- {
- fatalerror("unknown op 0x%08X\n", op);
- }
- return result;
-}
-
-const device_type LSI53C810 = &device_creator<lsi53c810_device>;
diff --git a/src/emu/machine/53c810.h b/src/emu/machine/53c810.h
deleted file mode 100644
index f55c3cdbfb1..00000000000
--- a/src/emu/machine/53c810.h
+++ /dev/null
@@ -1,119 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#ifndef LSI53C810_H
-#define LSI53C810_H
-
-#include "legscsi.h"
-
-typedef device_delegate<void (int state)> lsi53c810_irq_delegate;
-#define LSI53C810_IRQ_CB(name) void name(int state)
-
-typedef device_delegate<void (UINT32 src, UINT32 dst, int length, int byteswap)> lsi53c810_dma_delegate;
-#define LSI53C810_DMA_CB(name) void name(UINT32 src, UINT32 dst, int length, int byteswap)
-
-typedef device_delegate<UINT32 (UINT32 dsp)> lsi53c810_fetch_delegate;
-#define LSI53C810_FETCH_CB(name) UINT32 name(UINT32 dsp)
-
-
-class lsi53c810_device : public legacy_scsi_host_adapter
-{
-public:
- // construction/destruction
- lsi53c810_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void set_irq_callback(device_t &device, lsi53c810_irq_delegate callback) { downcast<lsi53c810_device &>(device).m_irq_cb = callback; }
- static void set_dma_callback(device_t &device, lsi53c810_dma_delegate callback) { downcast<lsi53c810_device &>(device).m_dma_cb = callback; }
- static void set_fetch_callback(device_t &device, lsi53c810_fetch_delegate callback) { downcast<lsi53c810_device &>(device).m_fetch_cb = callback; }
-
- void lsi53c810_read_data(int bytes, UINT8 *pData);
- void lsi53c810_write_data(int bytes, UINT8 *pData);
-
- UINT8 lsi53c810_reg_r( int offset );
- void lsi53c810_reg_w(int offset, UINT8 data);
-
-protected:
- // device-level overrides
- virtual void device_start();
-
-private:
- typedef delegate<void (void)> opcode_handler_delegate;
- opcode_handler_delegate dma_opcode[256];
-
- lsi53c810_irq_delegate m_irq_cb;
- lsi53c810_dma_delegate m_dma_cb;
- lsi53c810_fetch_delegate m_fetch_cb;
-
- UINT32 FETCH();
- void dmaop_invalid();
- void dmaop_move_memory();
- void dmaop_interrupt();
- void dmaop_block_move();
- void dmaop_select();
- void dmaop_wait_disconnect();
- void dmaop_wait_reselect();
- void dmaop_set();
- void dmaop_clear();
- void dmaop_move_from_sfbr();
- void dmaop_move_to_sfbr();
- void dmaop_read_modify_write();
- int scripts_compute_branch();
- UINT32 scripts_get_jump_dest();
- void dmaop_jump();
- void dmaop_call();
- void dmaop_return();
- void dmaop_store();
- void dmaop_load();
- void dma_exec();
- void add_opcode(UINT8 op, UINT8 mask, opcode_handler_delegate handler);
- void lsi53c810_init();
- UINT32 lsi53c810_dasm_fetch(UINT32 pc);
- unsigned lsi53c810_dasm(char *buf, UINT32 pc);
-
- UINT8 last_id;
-
- UINT8 scntl0;
- UINT8 scntl1;
- UINT8 scntl2;
- UINT8 scntl3;
- UINT8 scid;
- UINT8 sxfer;
- UINT8 socl;
- UINT8 istat;
- UINT8 dstat;
- UINT8 sstat0;
- UINT8 sstat1;
- UINT8 sstat2;
- UINT8 dien;
- UINT8 dcntl;
- UINT8 dmode;
- UINT32 temp;
- UINT32 dsa;
- UINT32 dsp;
- UINT32 dsps;
- UINT32 dcmd;
- UINT8 sien0;
- UINT8 sien1;
- UINT8 stime0;
- UINT8 respid;
- UINT8 stest1;
- UINT8 scratch_a[4];
- UINT8 scratch_b[4];
- int dma_icount;
- int halted;
- int carry;
-};
-
-// device type definition
-extern const device_type LSI53C810;
-
-
-#define MCFG_LSI53C810_IRQ_CB(_class, _method) \
- lsi53c810_device::set_irq_callback(*device, lsi53c810_irq_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_LSI53C810_DMA_CB(_class, _method) \
- lsi53c810_device::set_dma_callback(*device, lsi53c810_dma_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_LSI53C810_FETCH_CB(_class, _method) \
- lsi53c810_device::set_fetch_callback(*device, lsi53c810_fetch_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#endif
diff --git a/src/emu/machine/64h156.c b/src/emu/machine/64h156.c
deleted file mode 100644
index 508034169dd..00000000000
--- a/src/emu/machine/64h156.c
+++ /dev/null
@@ -1,652 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Commodore 64H156 Gate Array emulation
-
-**********************************************************************/
-
-/*
-
- TODO:
-
- http://personalpages.tds.net/~rcarlsen/cbm/1541/1541%20EARLY/1540-2.GIF
-
- - write protect
- - separate read/write methods
- - cycle exact VIA
- - get these running and we're golden
- - Bounty Bob Strikes Back (aligned halftracks)
- - Quiwi (speed change within track)
- - Defender of the Crown (V-MAX! v2, density checks)
- - Test Drive / Cabal (HLS, sub-cycle jitter)
- - Galaxian (?, needs 100% accurate VIA)
-
-*/
-
-#include "64h156.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-#define CYCLES_UNTIL_ANALOG_DESYNC 288 // 18 us
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type C64H156 = &device_creator<c64h156_device>;
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// c64h156_device - constructor
-//-------------------------------------------------
-
-c64h156_device::c64h156_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, C64H156, "64H156", tag, owner, clock, "c64h156", __FILE__),
- m_write_atn(*this),
- m_write_sync(*this),
- m_write_byte(*this),
- m_floppy(NULL),
- m_mtr(1),
- m_accl(0),
- m_stp(0),
- m_ds(0),
- m_soe(0),
- m_oe(1),
- m_ted(0),
- m_yb(0),
- m_atni(0),
- m_atna(0),
- m_period(attotime::from_hz(clock))
-{
- memset(&cur_live, 0x00, sizeof(cur_live));
- cur_live.tm = attotime::never;
- cur_live.state = IDLE;
- cur_live.next_state = -1;
- cur_live.write_start_time = attotime::never;
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void c64h156_device::device_start()
-{
- // resolve callbacks
- m_write_atn.resolve_safe();
- m_write_sync.resolve_safe();
- m_write_byte.resolve_safe();
-
- // allocate timer
- t_gen = timer_alloc(0);
-
- // register for state saving
- save_item(NAME(m_mtr));
- save_item(NAME(m_accl));
- save_item(NAME(m_stp));
- save_item(NAME(m_ds));
- save_item(NAME(m_soe));
- save_item(NAME(m_oe));
- save_item(NAME(m_ted));
- save_item(NAME(m_yb));
- save_item(NAME(m_atni));
- save_item(NAME(m_atna));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void c64h156_device::device_reset()
-{
- live_abort();
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void c64h156_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- live_sync();
- live_run();
-}
-
-void c64h156_device::live_start()
-{
- cur_live.tm = machine().time();
- cur_live.state = RUNNING;
- cur_live.next_state = -1;
-
- cur_live.shift_reg = 0;
- cur_live.shift_reg_write = 0;
- cur_live.cycle_counter = 0;
- cur_live.cell_counter = 0;
- cur_live.bit_counter = 0;
- cur_live.ds = m_ds;
- cur_live.oe = m_oe;
- cur_live.soe = m_soe;
- cur_live.accl = m_accl;
- cur_live.zero_counter = 0;
- cur_live.cycles_until_random_flux = (rand() % 31) + 289;
-
- checkpoint_live = cur_live;
-
- live_run();
-}
-
-void c64h156_device::checkpoint()
-{
- get_next_edge(machine().time());
- checkpoint_live = cur_live;
-}
-
-void c64h156_device::rollback()
-{
- cur_live = checkpoint_live;
- get_next_edge(cur_live.tm);
-}
-
-void c64h156_device::start_writing(const attotime &tm)
-{
- cur_live.write_start_time = tm;
- cur_live.write_position = 0;
-}
-
-void c64h156_device::stop_writing(const attotime &tm)
-{
- commit(tm);
- cur_live.write_start_time = attotime::never;
-}
-
-bool c64h156_device::write_next_bit(bool bit, const attotime &limit)
-{
- if(cur_live.write_start_time.is_never()) {
- cur_live.write_start_time = cur_live.tm;
- cur_live.write_position = 0;
- }
-
- attotime etime = cur_live.tm + m_period;
- if(etime > limit)
- return true;
-
- if(bit && cur_live.write_position < ARRAY_LENGTH(cur_live.write_buffer))
- cur_live.write_buffer[cur_live.write_position++] = cur_live.tm - m_period;
-
- if (LOG) logerror("%s write bit %u (%u)\n", cur_live.tm.as_string(), cur_live.bit_counter, bit);
-
- return false;
-}
-
-void c64h156_device::commit(const attotime &tm)
-{
- if(cur_live.write_start_time.is_never() || tm == cur_live.write_start_time || !cur_live.write_position)
- return;
-
- if (LOG) logerror("%s committing %u transitions since %s\n", tm.as_string(), cur_live.write_position, cur_live.write_start_time.as_string());
-
- m_floppy->write_flux(cur_live.write_start_time, tm, cur_live.write_position, cur_live.write_buffer);
-
- cur_live.write_start_time = tm;
- cur_live.write_position = 0;
-}
-
-void c64h156_device::live_delay(int state)
-{
- cur_live.next_state = state;
- if(cur_live.tm != machine().time())
- t_gen->adjust(cur_live.tm - machine().time());
- else
- live_sync();
-}
-
-void c64h156_device::live_sync()
-{
- if(!cur_live.tm.is_never()) {
- if(cur_live.tm > machine().time()) {
- rollback();
- live_run(machine().time());
- commit(cur_live.tm);
- } else {
- commit(cur_live.tm);
- if(cur_live.next_state != -1) {
- cur_live.state = cur_live.next_state;
- cur_live.next_state = -1;
- }
- if(cur_live.state == IDLE) {
- stop_writing(cur_live.tm);
- cur_live.tm = attotime::never;
- }
- }
- cur_live.next_state = -1;
- checkpoint();
- }
-}
-
-void c64h156_device::live_abort()
-{
- if(!cur_live.tm.is_never() && cur_live.tm > machine().time()) {
- rollback();
- live_run(machine().time());
- }
-
- stop_writing(cur_live.tm);
-
- cur_live.tm = attotime::never;
- cur_live.state = IDLE;
- cur_live.next_state = -1;
- cur_live.write_position = 0;
- cur_live.write_start_time = attotime::never;
-
- cur_live.sync = 1;
- cur_live.byte = 1;
-}
-
-void c64h156_device::live_run(const attotime &limit)
-{
- if(cur_live.state == IDLE || cur_live.next_state != -1)
- return;
-
- for(;;) {
- switch(cur_live.state) {
- case RUNNING: {
- bool syncpoint = false;
-
- if (cur_live.tm > limit)
- return;
-
- int bit = get_next_bit(cur_live.tm, limit);
- if(bit < 0)
- return;
-
- int cell_counter = cur_live.cell_counter;
-
- if (bit) {
- cur_live.cycle_counter = cur_live.ds;
- cur_live.cell_counter = 0;
- } else {
- cur_live.cycle_counter++;
- }
-
- if (cur_live.cycle_counter == 16) {
- cur_live.cycle_counter = cur_live.ds;
-
- cur_live.cell_counter++;
- cur_live.cell_counter &= 0xf;
- }
-
- if (!BIT(cell_counter, 1) && BIT(cur_live.cell_counter, 1)) {
- // read bit
- cur_live.shift_reg <<= 1;
- cur_live.shift_reg |= !(BIT(cur_live.cell_counter, 3) || BIT(cur_live.cell_counter, 2));
- cur_live.shift_reg &= 0x3ff;
-
- if (LOG) logerror("%s read bit %u (%u) >> %03x, oe=%u soe=%u sync=%u byte=%u\n", cur_live.tm.as_string(), cur_live.bit_counter,
- !(BIT(cur_live.cell_counter, 3) || BIT(cur_live.cell_counter, 2)), cur_live.shift_reg, cur_live.oe, cur_live.soe, cur_live.sync, cur_live.byte);
-
- syncpoint = true;
- }
-
- if (BIT(cell_counter, 1) && !BIT(cur_live.cell_counter, 1) && !cur_live.oe) { // TODO WPS
- write_next_bit(BIT(cur_live.shift_reg_write, 7), limit);
- }
-
- int sync = !((cur_live.shift_reg == 0x3ff) && cur_live.oe);
-
- if (!sync) {
- cur_live.bit_counter = 8;
- } else if (!BIT(cell_counter, 1) && BIT(cur_live.cell_counter, 1) && cur_live.sync) {
- cur_live.bit_counter++;
- cur_live.bit_counter &= 0xf;
- }
-
- int byte = !(((cur_live.bit_counter & 7) == 7) && cur_live.soe && !(cur_live.cell_counter & 2));
- int load = !(((cur_live.bit_counter & 7) == 7) && ((cur_live.cell_counter & 3) == 3));
-
- if (!load) {
- if (cur_live.oe) {
- cur_live.shift_reg_write = cur_live.shift_reg;
- if (LOG) logerror("%s load write shift register from read shift register %02x\n",cur_live.tm.as_string(),cur_live.shift_reg_write);
- } else {
- cur_live.shift_reg_write = cur_live.yb;
- if (LOG) logerror("%s load write shift register from YB %02x\n",cur_live.tm.as_string(),cur_live.shift_reg_write);
- }
- } else if (!BIT(cell_counter, 1) && BIT(cur_live.cell_counter, 1)) {
- cur_live.shift_reg_write <<= 1;
- cur_live.shift_reg_write &= 0xff;
- if (LOG) logerror("%s shift write register << %02x\n", cur_live.tm.as_string(), cur_live.shift_reg_write);
- }
-
- // update signals
- if (byte != cur_live.byte) {
- if (!byte || !cur_live.accl) {
- if (LOG) logerror("%s BYTE %02x\n", cur_live.tm.as_string(), cur_live.shift_reg & 0xff);
- cur_live.byte = byte;
- syncpoint = true;
- }
- if (!byte) {
- cur_live.accl_yb = cur_live.shift_reg & 0xff;
- }
- }
-
- if (sync != cur_live.sync) {
- if (LOG) logerror("%s SYNC %u\n", cur_live.tm.as_string(),sync);
- cur_live.sync = sync;
- syncpoint = true;
- }
-
- if (syncpoint) {
- commit(cur_live.tm);
-
- cur_live.tm += m_period;
- live_delay(RUNNING_SYNCPOINT);
- return;
- }
-
- cur_live.tm += m_period;
- break;
- }
-
- case RUNNING_SYNCPOINT: {
- m_write_sync(cur_live.sync);
- m_write_byte(cur_live.byte);
-
- cur_live.state = RUNNING;
- checkpoint();
- break;
- }
- }
- }
-}
-
-void c64h156_device::get_next_edge(const attotime &when)
-{
- cur_live.edge = m_floppy->get_next_transition(when);
-}
-
-int c64h156_device::get_next_bit(attotime &tm, const attotime &limit)
-{
- int bit = 0;
- if (!cur_live.edge.is_never())
- {
- attotime next = tm + m_period;
- if (cur_live.edge < next)
- {
- bit = 1;
-
- cur_live.zero_counter = 0;
- cur_live.cycles_until_random_flux = (rand() % 31) + 289;
-
- get_next_edge(next);
- }
- }
-
- if (cur_live.zero_counter >= cur_live.cycles_until_random_flux) {
- cur_live.zero_counter = 0;
- cur_live.cycles_until_random_flux = (rand() % 367) + 33;
-
- bit = 1;
- }
-
- return bit && cur_live.oe;
-}
-
-
-//-------------------------------------------------
-// yb_r -
-//-------------------------------------------------
-
-READ8_MEMBER( c64h156_device::yb_r )
-{
- if (checkpoint_live.accl) {
- return checkpoint_live.accl_yb;
- } else {
- return checkpoint_live.shift_reg;
- }
-}
-
-
-//-------------------------------------------------
-// yb_w -
-//-------------------------------------------------
-
-WRITE8_MEMBER( c64h156_device::yb_w )
-{
- if (m_yb != data)
- {
- live_sync();
- m_yb = cur_live.yb = data;
- checkpoint();
- if (LOG) logerror("%s YB %02x\n", machine().time().as_string(), data);
- live_run();
- }
-
-}
-
-
-//-------------------------------------------------
-// test_w - test write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( c64h156_device::test_w )
-{
-}
-
-
-//-------------------------------------------------
-// accl_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( c64h156_device::accl_w )
-{
- if (m_accl != state)
- {
- live_sync();
- m_accl = cur_live.accl = state;
- checkpoint();
- if (LOG) logerror("%s ACCL %u\n", machine().time().as_string(), state);
- live_run();
- }
-}
-
-
-//-------------------------------------------------
-// ted_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( c64h156_device::ted_w )
-{
- if (m_ted != state)
- {
- live_sync();
- if (m_ted && !state && cur_live.accl && !cur_live.byte) {
- cur_live.byte = 1;
- m_write_byte(cur_live.byte);
- }
- m_ted = state;
- checkpoint();
- if (LOG) logerror("%s TED %u\n", machine().time().as_string(), state);
- live_run();
- }
-}
-
-
-//-------------------------------------------------
-// mtr_w - motor write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( c64h156_device::mtr_w )
-{
- if (m_mtr != state)
- {
- live_sync();
- m_mtr = state;
- if (LOG) logerror("%s MTR %u\n", machine().time().as_string(), state);
- m_floppy->mon_w(!state);
- checkpoint();
-
- if (m_mtr) {
- if(cur_live.state == IDLE) {
- live_start();
- }
- } else {
- live_abort();
- }
-
- live_run();
- }
-}
-
-
-//-------------------------------------------------
-// oe_w - output enable write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( c64h156_device::oe_w )
-{
- if (m_oe != state)
- {
- live_sync();
- m_oe = cur_live.oe = state;
- if (m_oe) {
- stop_writing(machine().time());
- } else {
- start_writing(machine().time());
- }
- checkpoint();
- if (LOG) logerror("%s OE %u\n", machine().time().as_string(), state);
- live_run();
- }
-}
-
-
-//-------------------------------------------------
-// soe_w - SO enable write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( c64h156_device::soe_w )
-{
- if (m_soe != state)
- {
- live_sync();
- m_soe = cur_live.soe = state;
- checkpoint();
- if (LOG) logerror("%s SOE %u\n", machine().time().as_string(), state);
- live_run();
- }
-}
-
-
-//-------------------------------------------------
-// atni_w - serial attention input write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( c64h156_device::atni_w )
-{
- if (LOG) logerror("ATNI %u\n", state);
-
- m_atni = state;
-
- m_write_atn(m_atni ^ m_atna);
-}
-
-
-//-------------------------------------------------
-// atna_w - serial attention acknowledge write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( c64h156_device::atna_w )
-{
- if (LOG) logerror("ATNA %u\n", state);
-
- m_atna = state;
-
- m_write_atn(m_atni ^ m_atna);
-}
-
-
-//-------------------------------------------------
-// set_floppy -
-//-------------------------------------------------
-
-void c64h156_device::set_floppy(floppy_image_device *floppy)
-{
- m_floppy = floppy;
-}
-
-
-//-------------------------------------------------
-// stp_w -
-//-------------------------------------------------
-
-void c64h156_device::stp_w(int stp)
-{
- if (m_stp != stp)
- {
- live_sync();
-
- if (m_mtr)
- {
- int tracks = 0;
-
- switch (m_stp)
- {
- case 0: if (stp == 1) tracks++; else if (stp == 3) tracks--; break;
- case 1: if (stp == 2) tracks++; else if (stp == 0) tracks--; break;
- case 2: if (stp == 3) tracks++; else if (stp == 1) tracks--; break;
- case 3: if (stp == 0) tracks++; else if (stp == 2) tracks--; break;
- }
-
- if (tracks == -1)
- {
- m_floppy->dir_w(1);
- m_floppy->stp_w(1);
- m_floppy->stp_w(0);
- }
- else if (tracks == 1)
- {
- m_floppy->dir_w(0);
- m_floppy->stp_w(1);
- m_floppy->stp_w(0);
- }
-
- m_stp = stp;
- }
-
- checkpoint();
- live_run();
- }
-}
-
-
-//-------------------------------------------------
-// ds_w - density select
-//-------------------------------------------------
-
-void c64h156_device::ds_w(int ds)
-{
- if (m_ds != ds)
- {
- live_sync();
- m_ds = cur_live.ds = ds;
- checkpoint();
- if (LOG) logerror("%s DS %u\n", machine().time().as_string(), ds);
- live_run();
- }
-}
diff --git a/src/emu/machine/64h156.h b/src/emu/machine/64h156.h
deleted file mode 100644
index d21ce389dd0..00000000000
--- a/src/emu/machine/64h156.h
+++ /dev/null
@@ -1,205 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Commodore 64H156 Gate Array emulation
-
- Used in 1541B/1541C/1541-II/1551/1571
-
-**********************************************************************
- _____ _____
- TEST 1 |* \_/ | 40 _BYTE
- YB0 2 | | 39 SOE
- YB1 3 | | 38 B
- YB2 4 | | 37 CK
- YB3 5 | | 36 _QX
- YB4 6 | | 35 Q
- YB5 7 | | 34 R/_W
- YB6 8 | | 33 LOCK
- YB7 9 | | 32 PLL
- Vss 10 | 64H156-01 | 31 CLR
- STP1 11 | 251828-01 | 30 Vcc
- STP0 12 | | 29 _XRW
- MTR 13 | | 28 Y3
- _A 14 | | 27 Y2
- DS0 15 | | 26 Y1
- DS1 16 | | 25 Y0
- _SYNC 17 | | 24 ATN
- TED 18 | | 23 ATNI
- OE 19 | | 22 ATNA
- _ACCL 20 |_____________| 21 OSC
-
- _____ _____
- TEST 1 |* \_/ | 42 _BYTE
- YB0 2 | | 41 SOE
- YB1 3 | | 40 B
- YB2 4 | | 39 CK
- YB3 5 | | 38 _QX
- YB4 6 | | 37 Q
- YB5 7 | | 36 R/_W
- YB6 8 | | 35 LOCK
- YB7 9 | | 34 PLL
- Vss 10 | 64H156-02 | 33 CLR
- STP1 11 | 251828-02 | 32 Vcc
- STP0 12 | | 31 _XRW
- MTR 13 | | 30 Y3
- _A 14 | | 29 Y2
- DS0 15 | | 28 Y1
- DS1 16 | | 27 Y0
- _SYNC 17 | | 26 ATN
- TED 18 | | 25 ATNI
- OE 19 | | 24 ATNA
- _ACCL 20 | | 23 OSC
- Vcc 21 |_____________| 22 Vss
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __C64H156__
-#define __C64H156__
-
-#include "emu.h"
-#include "imagedev/floppy.h"
-#include "formats/d64_dsk.h"
-#include "formats/g64_dsk.h"
-#include "formats/d71_dsk.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_64H156_ATN_CALLBACK(_write) \
- devcb = &c64h156_device::set_atn_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_64H156_SYNC_CALLBACK(_write) \
- devcb = &c64h156_device::set_sync_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_64H156_BYTE_CALLBACK(_write) \
- devcb = &c64h156_device::set_byte_wr_callback(*device, DEVCB_##_write);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> c64h156_device
-
-class c64h156_device : public device_t
-{
-public:
- // construction/destruction
- c64h156_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_atn_wr_callback(device_t &device, _Object object) { return downcast<c64h156_device &>(device).m_write_atn.set_callback(object); }
- template<class _Object> static devcb_base &set_sync_wr_callback(device_t &device, _Object object) { return downcast<c64h156_device &>(device).m_write_sync.set_callback(object); }
- template<class _Object> static devcb_base &set_byte_wr_callback(device_t &device, _Object object) { return downcast<c64h156_device &>(device).m_write_byte.set_callback(object); }
-
- DECLARE_READ8_MEMBER( yb_r );
- DECLARE_WRITE8_MEMBER( yb_w );
-
- DECLARE_WRITE_LINE_MEMBER( test_w );
- DECLARE_WRITE_LINE_MEMBER( accl_w );
- DECLARE_WRITE_LINE_MEMBER( ted_w );
- DECLARE_WRITE_LINE_MEMBER( mtr_w );
- DECLARE_WRITE_LINE_MEMBER( oe_w );
- DECLARE_WRITE_LINE_MEMBER( soe_w );
- DECLARE_WRITE_LINE_MEMBER( atni_w );
- DECLARE_WRITE_LINE_MEMBER( atna_w );
-
- DECLARE_READ_LINE_MEMBER( sync_r ) { return checkpoint_live.sync; }
- DECLARE_READ_LINE_MEMBER( byte_r ) { return checkpoint_live.byte; }
- DECLARE_READ_LINE_MEMBER( atn_r ) { return m_atni ^ m_atna; }
-
- void stp_w(int stp);
- void ds_w(int ds);
-
- void set_floppy(floppy_image_device *floppy);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- enum {
- IDLE,
- RUNNING,
- RUNNING_SYNCPOINT
- };
-
- struct live_info {
- attotime tm;
- int state, next_state;
- int sync;
- int byte;
- int ds;
- int oe;
- int soe;
- int accl;
- UINT8 accl_yb;
-
- attotime edge;
- UINT16 shift_reg;
- int cycle_counter;
- int cell_counter;
- int bit_counter;
- int zero_counter;
- int cycles_until_random_flux;
-
- UINT8 yb;
- UINT8 shift_reg_write;
- attotime write_start_time;
- attotime write_buffer[32];
- int write_position;
- };
-
- devcb_write_line m_write_atn;
- devcb_write_line m_write_sync;
- devcb_write_line m_write_byte;
-
- floppy_image_device *m_floppy;
-
- int m_mtr;
- int m_accl;
- int m_stp;
- int m_ds;
- int m_soe;
- int m_oe;
- int m_ted;
- UINT8 m_yb;
- int m_atni;
- int m_atna;
-
- attotime m_period;
-
- live_info cur_live, checkpoint_live;
- emu_timer *t_gen;
-
- void live_start();
- void checkpoint();
- void rollback();
- bool write_next_bit(bool bit, const attotime &limit);
- void start_writing(const attotime &tm);
- void commit(const attotime &tm);
- void stop_writing(const attotime &tm);
- void live_delay(int state);
- void live_sync();
- void live_abort();
- void live_run(const attotime &limit = attotime::never);
- void get_next_edge(const attotime &when);
- int get_next_bit(attotime &tm, const attotime &limit);
-};
-
-
-
-// device type definition
-extern const device_type C64H156;
-
-
-
-#endif
diff --git a/src/emu/machine/6522via.c b/src/emu/machine/6522via.c
deleted file mode 100644
index 56a35e19040..00000000000
--- a/src/emu/machine/6522via.c
+++ /dev/null
@@ -1,985 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Peter Trauner, Mathis Rosenhauer
-/**********************************************************************
-
- Rockwell 6522 VIA interface and emulation
-
- This function emulates the functionality of up to 8 6522
- versatile interface adapters.
-
- This is based on the M6821 emulation in MAME.
-
- To do:
-
- T2 pulse counting mode
- Pulse mode handshake output
- More shift register
-
-**********************************************************************/
-
-/*
- 1999-Dec-22 PeT
- vc20 random number generation only partly working
- (reads (uninitialized) timer 1 and timer 2 counter)
- timer init, reset, read changed
- */
-
-#include "emu.h"
-#include "6522via.h"
-
-/***************************************************************************
- PARAMETERS
-***************************************************************************/
-
-#define TRACE_VIA 0
-
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-/* Macros for PCR */
-#define CA1_LOW_TO_HIGH(c) (c & 0x01)
-#define CA1_HIGH_TO_LOW(c) (!(c & 0x01))
-
-#define CB1_LOW_TO_HIGH(c) (c & 0x10)
-#define CB1_HIGH_TO_LOW(c) (!(c & 0x10))
-
-#define CA2_INPUT(c) (!(c & 0x08))
-#define CA2_LOW_TO_HIGH(c) ((c & 0x0c) == 0x04)
-#define CA2_HIGH_TO_LOW(c) ((c & 0x0c) == 0x00)
-#define CA2_IND_IRQ(c) ((c & 0x0a) == 0x02)
-
-#define CA2_OUTPUT(c) (c & 0x08)
-#define CA2_AUTO_HS(c) ((c & 0x0c) == 0x08)
-#define CA2_HS_OUTPUT(c) ((c & 0x0e) == 0x08)
-#define CA2_PULSE_OUTPUT(c) ((c & 0x0e) == 0x0a)
-#define CA2_FIX_OUTPUT(c) ((c & 0x0c) == 0x0c)
-#define CA2_OUTPUT_LEVEL(c) ((c & 0x02) >> 1)
-
-#define CB2_INPUT(c) (!(c & 0x80))
-#define CB2_LOW_TO_HIGH(c) ((c & 0xc0) == 0x40)
-#define CB2_HIGH_TO_LOW(c) ((c & 0xc0) == 0x00)
-#define CB2_IND_IRQ(c) ((c & 0xa0) == 0x20)
-
-#define CB2_OUTPUT(c) (c & 0x80)
-#define CB2_AUTO_HS(c) ((c & 0xc0) == 0x80)
-#define CB2_HS_OUTPUT(c) ((c & 0xe0) == 0x80)
-#define CB2_PULSE_OUTPUT(c) ((c & 0xe0) == 0xa0)
-#define CB2_FIX_OUTPUT(c) ((c & 0xc0) == 0xc0)
-#define CB2_OUTPUT_LEVEL(c) ((c & 0x20) >> 5)
-
-/* Macros for ACR */
-#define PA_LATCH_ENABLE(c) (c & 0x01)
-#define PB_LATCH_ENABLE(c) (c & 0x02)
-
-#define SR_DISABLED(c) (!(c & 0x1c))
-#define SI_T2_CONTROL(c) ((c & 0x1c) == 0x04)
-#define SI_O2_CONTROL(c) ((c & 0x1c) == 0x08)
-#define SI_EXT_CONTROL(c) ((c & 0x1c) == 0x0c)
-#define SO_T2_RATE(c) ((c & 0x1c) == 0x10)
-#define SO_T2_CONTROL(c) ((c & 0x1c) == 0x14)
-#define SO_O2_CONTROL(c) ((c & 0x1c) == 0x18)
-#define SO_EXT_CONTROL(c) ((c & 0x1c) == 0x1c)
-
-#define T1_SET_PB7(c) (c & 0x80)
-#define T1_CONTINUOUS(c) (c & 0x40)
-#define T2_COUNT_PB6(c) (c & 0x20)
-
-/* Interrupt flags */
-#define INT_CA2 0x01
-#define INT_CA1 0x02
-#define INT_SR 0x04
-#define INT_CB2 0x08
-#define INT_CB1 0x10
-#define INT_T2 0x20
-#define INT_T1 0x40
-#define INT_ANY 0x80
-
-#define CLR_PA_INT() clear_int(INT_CA1 | ((!CA2_IND_IRQ(m_pcr)) ? INT_CA2: 0))
-#define CLR_PB_INT() clear_int(INT_CB1 | ((!CB2_IND_IRQ(m_pcr)) ? INT_CB2: 0))
-
-#define IFR_DELAY 3
-
-#define TIMER1_VALUE (m_t1ll+(m_t1lh<<8))
-#define TIMER2_VALUE (m_t2ll+(m_t2lh<<8))
-
-
-
-/***************************************************************************
- INLINE FUNCTIONS
-***************************************************************************/
-
-UINT16 via6522_device::get_counter1_value()
-{
- UINT16 val;
-
- if(m_t1_active)
- {
- val = attotime_to_clocks(m_t1->remaining()) - IFR_DELAY;
- }
- else
- {
- val = 0xffff - attotime_to_clocks(machine().time() - m_time1);
- }
-
- return val;
-}
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type VIA6522 = &device_creator<via6522_device>;
-
-DEVICE_ADDRESS_MAP_START( map, 8, via6522_device )
- AM_RANGE(0x00, 0x0f) AM_READWRITE(read, write)
-ADDRESS_MAP_END
-
-//-------------------------------------------------
-// via6522_device - constructor
-//-------------------------------------------------
-
-via6522_device::via6522_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, VIA6522, "6522 VIA", tag, owner, clock, "via6522", __FILE__),
- m_in_a_handler(*this),
- m_in_b_handler(*this),
- m_out_a_handler(*this),
- m_out_b_handler(*this),
- m_ca2_handler(*this),
- m_cb1_handler(*this),
- m_cb2_handler(*this),
- m_irq_handler(*this),
- m_in_a(0xff),
- m_in_ca1(0),
- m_in_ca2(0),
- m_out_ca2(0),
- m_in_b(0),
- m_in_cb1(0),
- m_in_cb2(0),
- m_pcr(0),
- m_acr(0),
- m_ier(0),
- m_ifr(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void via6522_device::device_start()
-{
- m_in_a_handler.resolve();
- m_in_b_handler.resolve();
- m_out_a_handler.resolve_safe();
- m_out_b_handler.resolve_safe();
- m_cb1_handler.resolve_safe();
- m_ca2_handler.resolve_safe();
- m_cb2_handler.resolve_safe();
- m_irq_handler.resolve_safe();
-
- m_t1ll = 0xf3; /* via at 0x9110 in vic20 show these values */
- m_t1lh = 0xb5; /* ports are not written by kernel! */
- m_t2ll = 0xff; /* taken from vice */
- m_t2lh = 0xff;
- m_sr = 0;
-
- m_time2 = m_time1 = machine().time();
- m_t1 = timer_alloc(TIMER_T1);
- m_t2 = timer_alloc(TIMER_T2);
- m_ca2_timer = timer_alloc(TIMER_CA2);
- m_shift_timer = timer_alloc(TIMER_SHIFT);
-
- /* Default clock is from CPU1 */
- if (clock() == 0)
- {
- set_unscaled_clock(machine().firstcpu->clock());
- }
-
- /* save state register */
- save_item(NAME(m_in_a));
- save_item(NAME(m_in_ca1));
- save_item(NAME(m_in_ca2));
- save_item(NAME(m_out_a));
- save_item(NAME(m_out_ca2));
- save_item(NAME(m_ddr_a));
- save_item(NAME(m_latch_a));
- save_item(NAME(m_in_b));
- save_item(NAME(m_in_cb1));
- save_item(NAME(m_in_cb2));
- save_item(NAME(m_out_b));
- save_item(NAME(m_out_cb1));
- save_item(NAME(m_out_cb2));
- save_item(NAME(m_ddr_b));
- save_item(NAME(m_latch_b));
- save_item(NAME(m_t1cl));
- save_item(NAME(m_t1ch));
- save_item(NAME(m_t1ll));
- save_item(NAME(m_t1lh));
- save_item(NAME(m_t2cl));
- save_item(NAME(m_t2ch));
- save_item(NAME(m_t2ll));
- save_item(NAME(m_t2lh));
- save_item(NAME(m_sr));
- save_item(NAME(m_pcr));
- save_item(NAME(m_acr));
- save_item(NAME(m_ier));
- save_item(NAME(m_ifr));
- save_item(NAME(m_time1));
- save_item(NAME(m_t1_active));
- save_item(NAME(m_t1_pb7));
- save_item(NAME(m_time2));
- save_item(NAME(m_t2_active));
- save_item(NAME(m_shift_counter));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void via6522_device::device_reset()
-{
- m_out_a = 0;
- m_out_ca2 = 1;
- m_ddr_a = 0;
- m_latch_a = 0;
-
- m_out_b = 0;
- m_out_cb1 = 1;
- m_out_cb2 = 1;
- m_ddr_b = 0;
- m_latch_b = 0;
-
- m_t1cl = 0;
- m_t1ch = 0;
- m_t2cl = 0;
- m_t2ch = 0;
-
- m_pcr = 0;
- m_acr = 0;
- m_ier = 0;
- m_ifr = 0;
- m_t1_active = 0;
- m_t1_pb7 = 1;
- m_t2_active = 0;
- m_shift_counter = 0;
-
- output_pa();
- output_pb();
- m_ca2_handler(m_out_ca2);
- m_cb1_handler(m_out_cb1);
- m_cb2_handler(m_out_cb2);
-}
-
-
-void via6522_device::output_irq()
-{
- if (m_ier & m_ifr & 0x7f)
- {
- if ((m_ifr & INT_ANY) == 0)
- {
- m_ifr |= INT_ANY;
- m_irq_handler(ASSERT_LINE);
- }
- }
- else
- {
- if (m_ifr & INT_ANY)
- {
- m_ifr &= ~INT_ANY;
- m_irq_handler(CLEAR_LINE);
- }
- }
-}
-
-
-/*-------------------------------------------------
- via_set_int - external interrupt check
--------------------------------------------------*/
-
-void via6522_device::set_int(int data)
-{
- if (!(m_ifr & data))
- {
- m_ifr |= data;
-
- output_irq();
-
- if (TRACE_VIA)
- {
- logerror("%s:6522VIA chip %s: IFR = %02X\n", machine().describe_context(), tag(), m_ifr);
- }
- }
-}
-
-
-/*-------------------------------------------------
- via_clear_int - external interrupt check
--------------------------------------------------*/
-
-void via6522_device::clear_int(int data)
-{
- if (m_ifr & data)
- {
- m_ifr &= ~data;
-
- output_irq();
-
- if (TRACE_VIA)
- {
- logerror("%s:6522VIA chip %s: IFR = %02X\n", machine().describe_context(), tag(), m_ifr);
- }
- }
-}
-
-
-/*-------------------------------------------------
- via_shift
--------------------------------------------------*/
-
-void via6522_device::shift_out()
-{
- m_out_cb2 = (m_sr >> 7) & 1;
- m_sr = (m_sr << 1) | m_out_cb2;
-
- m_cb2_handler(m_out_cb2);
-
- if (!SO_T2_RATE(m_acr))
- {
- m_shift_counter = (m_shift_counter + 1) % 8;
-
- if (m_shift_counter == 0)
- {
- set_int(INT_SR);
- }
- }
-}
-
-void via6522_device::shift_in()
-{
- m_sr = (m_sr << 1) | (m_in_cb2 & 1);
-
- m_shift_counter = (m_shift_counter + 1) % 8;
-
- if (m_shift_counter == 0)
- {
- set_int(INT_SR);
- }
-}
-
-
-void via6522_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_SHIFT:
- m_out_cb1 = 0;
- m_cb1_handler(m_out_cb1);
-
- if (SO_T2_RATE(m_acr) || SO_T2_CONTROL(m_acr) || SO_O2_CONTROL(m_acr))
- {
- shift_out();
- }
-
- m_out_cb1 = 1;
- m_cb1_handler(m_out_cb1);
-
- if (SI_T2_CONTROL(m_acr) || SI_O2_CONTROL(m_acr))
- {
- shift_in();
- }
-
- if (SO_T2_RATE(m_acr) || m_shift_counter)
- {
- if (SI_O2_CONTROL(m_acr) || SO_O2_CONTROL(m_acr))
- {
- m_shift_timer->adjust(clocks_to_attotime(2));
- }
- else
- {
- m_shift_timer->adjust(clocks_to_attotime((m_t2ll + 2)*2));
- }
- }
- break;
-
- case TIMER_T1:
- if (T1_CONTINUOUS (m_acr))
- {
- m_t1_pb7 = !m_t1_pb7;
- m_t1->adjust(clocks_to_attotime(TIMER1_VALUE + IFR_DELAY));
- }
- else
- {
- m_t1_pb7 = 1;
- m_t1_active = 0;
- m_time1 = machine().time();
- }
-
- if (T1_SET_PB7(m_acr))
- {
- output_pb();
- }
-
- set_int(INT_T1);
- break;
-
- case TIMER_T2:
- m_t2_active = 0;
- m_time2 = machine().time();
-
- set_int(INT_T2);
- break;
-
- case TIMER_CA2:
- m_out_ca2 = 1;
- m_ca2_handler(m_out_ca2);
- break;
- }
-}
-
-UINT8 via6522_device::input_pa()
-{
- /// TODO: REMOVE THIS
- if (!m_in_a_handler.isnull())
- {
- if (m_ddr_a != 0xff)
- m_in_a = m_in_a_handler(0);
-
- return (m_out_a & m_ddr_a) + (m_in_a & ~m_ddr_a);
- }
-
- return m_in_a & (m_out_a | ~m_ddr_a);
-}
-
-void via6522_device::output_pa()
-{
- UINT8 pa = (m_out_a & m_ddr_a) | ~m_ddr_a;
- m_out_a_handler(pa);
-}
-
-UINT8 via6522_device::input_pb()
-{
- /// TODO: REMOVE THIS
- if (m_ddr_b != 0xff && !m_in_b_handler.isnull())
- {
- m_in_b = m_in_b_handler(0);
- }
-
- UINT8 pb = (m_out_b & m_ddr_b) + (m_in_b & ~m_ddr_b);
-
- if (T1_SET_PB7(m_acr))
- pb = (pb & 0x7f) | (m_t1_pb7 << 7);
-
- return pb;
-}
-
-void via6522_device::output_pb()
-{
- UINT8 pb = (m_out_b & m_ddr_b) | ~m_ddr_b;
-
- if (T1_SET_PB7(m_acr))
- pb = (pb & 0x7f) | (m_t1_pb7 << 7);
-
- m_out_b_handler(pb);
-}
-
-/*-------------------------------------------------
- via_r - CPU interface for VIA read
--------------------------------------------------*/
-
-READ8_MEMBER( via6522_device::read )
-{
- int val = 0;
- if (space.debugger_access())
- return 0;
-
- offset &= 0xf;
-
- switch (offset)
- {
- case VIA_PB:
- /* update the input */
- if (PB_LATCH_ENABLE(m_acr) == 0)
- {
- val = input_pb();
- }
- else
- {
- val = m_latch_b;
- }
-
- CLR_PB_INT();
- break;
-
- case VIA_PA:
- /* update the input */
- if (PA_LATCH_ENABLE(m_acr) == 0)
- {
- val = input_pa();
- }
- else
- {
- val = m_latch_a;
- }
-
- CLR_PA_INT();
-
- if (m_out_ca2 && (CA2_PULSE_OUTPUT(m_pcr) || CA2_AUTO_HS(m_pcr)))
- {
- m_out_ca2 = 0;
- m_ca2_handler(m_out_ca2);
- }
-
- if (CA2_PULSE_OUTPUT(m_pcr))
- m_ca2_timer->adjust(clocks_to_attotime(1));
-
- break;
-
- case VIA_PANH:
- /* update the input */
- if (PA_LATCH_ENABLE(m_acr) == 0)
- {
- val = input_pa();
- }
- else
- {
- val = m_latch_a;
- }
- break;
-
- case VIA_DDRB:
- val = m_ddr_b;
- break;
-
- case VIA_DDRA:
- val = m_ddr_a;
- break;
-
- case VIA_T1CL:
- clear_int(INT_T1);
- val = get_counter1_value() & 0xFF;
- break;
-
- case VIA_T1CH:
- val = get_counter1_value() >> 8;
- break;
-
- case VIA_T1LL:
- val = m_t1ll;
- break;
-
- case VIA_T1LH:
- val = m_t1lh;
- break;
-
- case VIA_T2CL:
- clear_int(INT_T2);
- if (m_t2_active)
- {
- val = attotime_to_clocks(m_t2->remaining()) & 0xff;
- }
- else
- {
- if (T2_COUNT_PB6(m_acr))
- {
- val = m_t2cl;
- }
- else
- {
- val = (0x10000 - (attotime_to_clocks(machine().time() - m_time2) & 0xffff) - 1) & 0xff;
- }
- }
- break;
-
- case VIA_T2CH:
- if (m_t2_active)
- {
- val = attotime_to_clocks(m_t2->remaining()) >> 8;
- }
- else
- {
- if (T2_COUNT_PB6(m_acr))
- {
- val = m_t2ch;
- }
- else
- {
- val = (0x10000 - (attotime_to_clocks(machine().time() - m_time2) & 0xffff) - 1) >> 8;
- }
- }
- break;
-
- case VIA_SR:
- val = m_sr;
- m_shift_counter=0;
- clear_int(INT_SR);
- if (SI_O2_CONTROL(m_acr))
- {
- m_shift_timer->adjust(clocks_to_attotime(2));
- }
- if (SI_T2_CONTROL(m_acr))
- {
- m_shift_timer->adjust(clocks_to_attotime((m_t2ll + 2)*2));
- }
- break;
-
- case VIA_PCR:
- val = m_pcr;
- break;
-
- case VIA_ACR:
- val = m_acr;
- break;
-
- case VIA_IER:
- val = m_ier | 0x80;
- break;
-
- case VIA_IFR:
- val = m_ifr;
- break;
- }
- return val;
-}
-
-
-/*-------------------------------------------------
- via_w - CPU interface for VIA write
--------------------------------------------------*/
-
-WRITE8_MEMBER( via6522_device::write )
-{
- offset &=0x0f;
-
- switch (offset)
- {
- case VIA_PB:
- m_out_b = data;
-
- if (m_ddr_b != 0)
- {
- output_pb();
- }
-
- CLR_PB_INT();
-
- if (m_out_cb2 && CB2_AUTO_HS(m_pcr))
- {
- m_out_cb2 = 0;
- m_cb2_handler(m_out_cb2);
- }
- break;
-
- case VIA_PA:
- m_out_a = data;
-
- if (m_ddr_a != 0)
- {
- output_pa();
- }
-
- CLR_PA_INT();
-
- if (m_out_ca2 && (CA2_PULSE_OUTPUT(m_pcr) || CA2_AUTO_HS(m_pcr)))
- {
- m_out_ca2 = 0;
- m_ca2_handler(m_out_ca2);
- }
-
- if (CA2_PULSE_OUTPUT(m_pcr))
- m_ca2_timer->adjust(clocks_to_attotime(1));
-
- break;
-
- case VIA_PANH:
- m_out_a = data;
-
- if (m_ddr_a != 0)
- {
- output_pa();
- }
-
- break;
-
- case VIA_DDRB:
- if ( data != m_ddr_b )
- {
- m_ddr_b = data;
-
- output_pb();
- }
- break;
-
- case VIA_DDRA:
- if (m_ddr_a != data)
- {
- m_ddr_a = data;
-
- output_pa();
- }
- break;
-
- case VIA_T1CL:
- case VIA_T1LL:
- m_t1ll = data;
- break;
-
- case VIA_T1LH:
- m_t1lh = data;
- clear_int(INT_T1);
- break;
-
- case VIA_T1CH:
- m_t1ch = m_t1lh = data;
- m_t1cl = m_t1ll;
-
- clear_int(INT_T1);
-
- m_t1_pb7 = 0;
-
- if (T1_SET_PB7(m_acr))
- {
- output_pb();
- }
-
- m_t1->adjust(clocks_to_attotime(TIMER1_VALUE + IFR_DELAY));
- m_t1_active = 1;
- break;
-
- case VIA_T2CL:
- m_t2ll = data;
- break;
-
- case VIA_T2CH:
- m_t2ch = m_t2lh = data;
- m_t2cl = m_t2ll;
-
- clear_int(INT_T2);
-
- if (!T2_COUNT_PB6(m_acr))
- {
- m_t2->adjust(clocks_to_attotime(TIMER2_VALUE + IFR_DELAY));
- m_t2_active = 1;
- }
- else
- {
- m_t2->adjust(clocks_to_attotime(TIMER2_VALUE));
- m_t2_active = 1;
- m_time2 = machine().time();
- }
- break;
-
- case VIA_SR:
- m_sr = data;
- m_shift_counter=0;
- clear_int(INT_SR);
- if (SO_O2_CONTROL(m_acr))
- {
- m_shift_timer->adjust(clocks_to_attotime(2));
- }
- if (SO_T2_RATE(m_acr) || SO_T2_CONTROL(m_acr))
- {
- m_shift_timer->adjust(clocks_to_attotime((m_t2ll + 2)*2));
- }
- break;
-
- case VIA_PCR:
- m_pcr = data;
-
- if (TRACE_VIA)
- {
- logerror("%s:6522VIA chip %s: PCR = %02X\n", machine().describe_context(), tag(), data);
- }
-
- if (CA2_FIX_OUTPUT(data) && m_out_ca2 != CA2_OUTPUT_LEVEL(data))
- {
- m_out_ca2 = CA2_OUTPUT_LEVEL(data);
- m_ca2_handler(m_out_ca2);
- }
-
- if (CB2_FIX_OUTPUT(data) && m_out_cb2 != CB2_OUTPUT_LEVEL(data))
- {
- m_out_cb2 = CB2_OUTPUT_LEVEL(data);
- m_cb2_handler(m_out_cb2);
- }
- break;
-
- case VIA_ACR:
- {
- UINT16 counter1 = get_counter1_value();
- m_acr = data;
-
- output_pb();
-
- if (T1_CONTINUOUS(data))
- {
- m_t1->adjust(clocks_to_attotime(counter1 + IFR_DELAY));
- m_t1_active = 1;
- }
- }
- break;
-
- case VIA_IER:
- if (data & 0x80)
- {
- m_ier |= data & 0x7f;
- }
- else
- {
- m_ier &= ~(data & 0x7f);
- }
-
- output_irq();
- break;
-
- case VIA_IFR:
- if (data & INT_ANY)
- {
- data = 0x7f;
- }
- clear_int(data);
- break;
- }
-}
-
-void via6522_device::write_pa(int line, int state)
-{
- if (state)
- m_in_a |= (1 << line);
- else
- m_in_a &= ~(1 << line);
-}
-
-WRITE8_MEMBER( via6522_device::write_pa )
-{
- m_in_a = data;
-}
-
-/*-------------------------------------------------
- ca1_w - interface setting VIA port CA1 input
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( via6522_device::write_ca1 )
-{
- if (m_in_ca1 != state)
- {
- m_in_ca1 = state;
-
- if (TRACE_VIA)
- logerror("%s:6522VIA chip %s: CA1 = %02X\n", machine().describe_context(), tag(), m_in_ca1);
-
- if ((m_in_ca1 && CA1_LOW_TO_HIGH(m_pcr)) || (!m_in_ca1 && CA1_HIGH_TO_LOW(m_pcr)))
- {
- if (PA_LATCH_ENABLE(m_acr))
- {
- m_latch_a = input_pa();
- }
-
- set_int(INT_CA1);
-
- if (!m_out_ca2 && CA2_AUTO_HS(m_pcr))
- {
- m_out_ca2 = 1;
- m_ca2_handler(m_out_ca2);
- }
- }
- }
-}
-
-
-/*-------------------------------------------------
- ca2_w - interface setting VIA port CA2 input
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( via6522_device::write_ca2 )
-{
- if (m_in_ca2 != state)
- {
- m_in_ca2 = state;
-
- if (CA2_INPUT(m_pcr))
- {
- if ((m_in_ca2 && CA2_LOW_TO_HIGH(m_pcr)) || (!m_in_ca2 && CA2_HIGH_TO_LOW(m_pcr)))
- {
- set_int(INT_CA2);
- }
- }
- }
-}
-
-void via6522_device::write_pb(int line, int state)
-{
- if (state)
- m_in_b |= (1 << line);
- else
- m_in_b &= ~(1 << line);
-}
-
-WRITE8_MEMBER( via6522_device::write_pb )
-{
- m_in_b = data;
-}
-
-/*-------------------------------------------------
- cb1_w - interface setting VIA port CB1 input
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( via6522_device::write_cb1 )
-{
- if (m_in_cb1 != state)
- {
- m_in_cb1 = state;
-
- if ((m_in_cb1 && CB1_LOW_TO_HIGH(m_pcr)) || (!m_in_cb1 && CB1_HIGH_TO_LOW(m_pcr)))
- {
- if (PB_LATCH_ENABLE(m_acr))
- {
- m_latch_b = input_pb();
- }
-
- if (SO_EXT_CONTROL(m_acr))
- {
- shift_out();
- }
-
- if (SI_EXT_CONTROL(m_acr))
- {
- shift_in();
- }
-
- set_int(INT_CB1);
-
- if (!m_out_cb2 && CB2_AUTO_HS(m_pcr))
- {
- m_out_cb2 = 1;
- m_cb2_handler(1);
- }
- }
- }
-}
-
-
-/*-------------------------------------------------
- cb2_w - interface setting VIA port CB2 input
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( via6522_device::write_cb2 )
-{
- if (m_in_cb2 != state)
- {
- m_in_cb2 = state;
-
- if (CB2_INPUT(m_pcr))
- {
- if ((m_in_cb2 && CB2_LOW_TO_HIGH(m_pcr)) || (!m_in_cb2 && CB2_HIGH_TO_LOW(m_pcr)))
- {
- set_int(INT_CB2);
- }
- }
- }
-}
diff --git a/src/emu/machine/6522via.h b/src/emu/machine/6522via.h
deleted file mode 100644
index 0b882ee7195..00000000000
--- a/src/emu/machine/6522via.h
+++ /dev/null
@@ -1,221 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Peter Trauner, Mathis Rosenhauer
-/**********************************************************************
-
- Rockwell 6522 VIA interface and emulation
-
- This function emulates all the functionality of 6522
- versatile interface adapters.
-
- This is based on the pre-existing 6821 emulation.
-
- Written by Mathis Rosenhauer
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __6522VIA_H__
-#define __6522VIA_H__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-// TODO: REMOVE THESE
-#define MCFG_VIA6522_READPA_HANDLER(_devcb) \
- devcb = &via6522_device::set_readpa_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_VIA6522_READPB_HANDLER(_devcb) \
- devcb = &via6522_device::set_readpb_handler(*device, DEVCB_##_devcb);
-
-// TODO: CONVERT THESE TO WRITE LINE
-#define MCFG_VIA6522_WRITEPA_HANDLER(_devcb) \
- devcb = &via6522_device::set_writepa_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_VIA6522_WRITEPB_HANDLER(_devcb) \
- devcb = &via6522_device::set_writepb_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_VIA6522_CA2_HANDLER(_devcb) \
- devcb = &via6522_device::set_ca2_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_VIA6522_CB1_HANDLER(_devcb) \
- devcb = &via6522_device::set_cb1_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_VIA6522_CB2_HANDLER(_devcb) \
- devcb = &via6522_device::set_cb2_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_VIA6522_IRQ_HANDLER(_devcb) \
- devcb = &via6522_device::set_irq_handler(*device, DEVCB_##_devcb);
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-
-// ======================> via6522_device
-
-class via6522_device : public device_t
-{
-public:
- // construction/destruction
- via6522_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // TODO: REMOVE THESE
- template<class _Object> static devcb_base &set_readpa_handler(device_t &device, _Object object) { return downcast<via6522_device &>(device).m_in_a_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_readpb_handler(device_t &device, _Object object) { return downcast<via6522_device &>(device).m_in_b_handler.set_callback(object); }
-
- // TODO: CONVERT THESE TO WRITE LINE
- template<class _Object> static devcb_base &set_writepa_handler(device_t &device, _Object object) { return downcast<via6522_device &>(device).m_out_a_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_writepb_handler(device_t &device, _Object object) { return downcast<via6522_device &>(device).m_out_b_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_ca2_handler(device_t &device, _Object object) { return downcast<via6522_device &>(device).m_ca2_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_cb1_handler(device_t &device, _Object object) { return downcast<via6522_device &>(device).m_cb1_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_cb2_handler(device_t &device, _Object object) { return downcast<via6522_device &>(device).m_cb2_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_irq_handler(device_t &device, _Object object) { return downcast<via6522_device &>(device).m_irq_handler.set_callback(object); }
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( write_pa0 ) { write_pa(0, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pa1 ) { write_pa(1, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pa2 ) { write_pa(2, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pa3 ) { write_pa(3, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pa4 ) { write_pa(4, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pa5 ) { write_pa(5, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pa6 ) { write_pa(6, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pa7 ) { write_pa(7, state); }
- DECLARE_WRITE8_MEMBER( write_pa );
- DECLARE_WRITE_LINE_MEMBER( write_ca1 );
- DECLARE_WRITE_LINE_MEMBER( write_ca2 );
-
- DECLARE_WRITE_LINE_MEMBER( write_pb0 ) { write_pb(0, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pb1 ) { write_pb(1, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pb2 ) { write_pb(2, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pb3 ) { write_pb(3, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pb4 ) { write_pb(4, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pb5 ) { write_pb(5, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pb6 ) { write_pb(6, state); }
- DECLARE_WRITE_LINE_MEMBER( write_pb7 ) { write_pb(7, state); }
- DECLARE_WRITE8_MEMBER( write_pb );
- DECLARE_WRITE_LINE_MEMBER( write_cb1 );
- DECLARE_WRITE_LINE_MEMBER( write_cb2 );
-
- enum
- {
- VIA_PB = 0,
- VIA_PA = 1,
- VIA_DDRB = 2,
- VIA_DDRA = 3,
- VIA_T1CL = 4,
- VIA_T1CH = 5,
- VIA_T1LL = 6,
- VIA_T1LH = 7,
- VIA_T2CL = 8,
- VIA_T2CH = 9,
- VIA_SR = 10,
- VIA_ACR = 11,
- VIA_PCR = 12,
- VIA_IFR = 13,
- VIA_IER = 14,
- VIA_PANH = 15
- };
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- static const device_timer_id TIMER_SHIFT = 0;
- static const device_timer_id TIMER_T1 = 1;
- static const device_timer_id TIMER_T2 = 2;
- static const device_timer_id TIMER_CA2 = 3;
-
- UINT16 get_counter1_value();
-
- void set_int(int data);
- void clear_int(int data);
- void shift_out();
- void shift_in();
- void write_pa(int line, int state);
- void write_pb(int line, int state);
-
- UINT8 input_pa();
- void output_pa();
- UINT8 input_pb();
- void output_pb();
- void output_irq();
-
- // TODO: REMOVE THESE
- devcb_read8 m_in_a_handler;
- devcb_read8 m_in_b_handler;
-
- // TODO: CONVERT THESE TO WRITE LINE
- devcb_write8 m_out_a_handler;
- devcb_write8 m_out_b_handler;
-
- devcb_write_line m_ca2_handler;
- devcb_write_line m_cb1_handler;
- devcb_write_line m_cb2_handler;
- devcb_write_line m_irq_handler;
-
- UINT8 m_in_a;
- int m_in_ca1;
- int m_in_ca2;
- UINT8 m_out_a;
- int m_out_ca2;
- UINT8 m_ddr_a;
- UINT8 m_latch_a;
-
- UINT8 m_in_b;
- int m_in_cb1;
- int m_in_cb2;
- UINT8 m_out_b;
- int m_out_cb1;
- int m_out_cb2;
- UINT8 m_ddr_b;
- UINT8 m_latch_b;
-
- UINT8 m_t1cl;
- UINT8 m_t1ch;
- UINT8 m_t1ll;
- UINT8 m_t1lh;
- UINT8 m_t2cl;
- UINT8 m_t2ch;
- UINT8 m_t2ll;
- UINT8 m_t2lh;
-
- UINT8 m_sr;
- UINT8 m_pcr;
- UINT8 m_acr;
- UINT8 m_ier;
- UINT8 m_ifr;
-
- emu_timer *m_t1;
- attotime m_time1;
- UINT8 m_t1_active;
- int m_t1_pb7;
- emu_timer *m_t2;
- attotime m_time2;
- UINT8 m_t2_active;
- emu_timer *m_ca2_timer;
-
- emu_timer *m_shift_timer;
- UINT8 m_shift_counter;
-};
-
-
-// device type definition
-extern const device_type VIA6522;
-
-
-#endif /* __6522VIA_H__ */
diff --git a/src/emu/machine/6525tpi.c b/src/emu/machine/6525tpi.c
deleted file mode 100644
index 038440e29d3..00000000000
--- a/src/emu/machine/6525tpi.c
+++ /dev/null
@@ -1,561 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Peter Trauner
-/***************************************************************************
- mos tri port interface 6525
- mos triple interface adapter 6523
-
- peter.trauner@jk.uni-linz.ac.at
-
- used in commodore b series
- used in commodore c1551 floppy disk drive
-***************************************************************************/
-
-/*
- mos tpi 6525
- 40 pin package
- 3 8 bit ports (pa, pb, pc)
- 8 registers to pc
- 0 port a 0 in low
- 1 port a data direction register 1 output
- 2 port b
- 3 port b ddr
- 4 port c
- handshaking, interrupt mode
- 0 interrupt 0 input, 1 interrupt enabled
- interrupt set on falling edge
- 1 interrupt 1 input
- 2 interrupt 2 input
- 3 interrupt 3 input
- 4 interrupt 4 input
- 5 irq output
- 6 ca handshake line (read handshake answer on I3 preferred)
- 7 cb handshake line (write handshake clear on I4 preferred)
- 5 port c ddr
-
- 6 cr configuration register
- 0 mc
- 0 port c normal input output mode like port a and b
- 1 port c used for handshaking and interrupt input
- 1 1 interrupt prioritized
- 2 i3 configure edge
- 1 interrupt set on positive edge
- 3 i4 configure edge
- 5,4 ca handshake
- 00 on read
- rising edge of i3 sets ca high
- read a data from computers sets ca low
- 01 pulse output
- 1 microsecond low after read a operation
- 10 manual output low
- 11 manual output high
- 7,6 cb handshake
- 00 handshake on write
- write b data from computer sets cb 0
- rising edge of i4 sets cb high
- 01 pulse output
- 1 microsecond low after write b operation
- 10 manual output low
- 11 manual output high
- 7 air active interrupt register
- 0 I0 occurred
- 1 I1 occurred
- 2 I2 occurred
- 3 I3 occurred
- 4 I4 occurred
- read clears interrupt
-
- non prioritized interrupts
- interrupt is set when occurred
- read clears all interrupts
-
- prioritized interrupts
- I4>I3>I2>I1>I0
- highest interrupt can be found in air register
- read clears highest interrupt
-*/
-
-#include "emu.h"
-#include "6525tpi.h"
-
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-#define VERBOSE_LEVEL 0
-#define DBG_LOG( MACHINE, N, M, A ) \
- do { \
- if(VERBOSE_LEVEL >= N) \
- { \
- if( M ) \
- logerror("%11.6f: %-24s", MACHINE.time().as_double(), (char*) M ); \
- logerror A; \
- } \
- } while (0)
-
-
-#define INTERRUPT_MODE (m_cr & 1)
-#define PRIORIZED_INTERRUPTS (m_cr & 2)
-#define INTERRUPT3_RISING_EDGE (m_cr & 4)
-#define INTERRUPT4_RISING_EDGE (m_cr & 8)
-#define CA_MANUAL_OUT (m_cr & 0x20)
-#define CA_MANUAL_LEVEL ((m_cr & 0x10) ? 1 : 0)
-#define CB_MANUAL_OUT (m_cr & 0x80)
-#define CB_MANUAL_LEVEL ((m_cr & 0x40) ? 1 : 0)
-
-
-const device_type TPI6525 = &device_creator<tpi6525_device>;
-
-tpi6525_device::tpi6525_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, TPI6525, "6525 TPI", tag, owner, clock, "tpi6525", __FILE__),
- m_out_irq_cb(*this),
- m_in_pa_cb(*this),
- m_out_pa_cb(*this),
- m_in_pb_cb(*this),
- m_out_pb_cb(*this),
- m_in_pc_cb(*this),
- m_out_pc_cb(*this),
- m_out_ca_cb(*this),
- m_out_cb_cb(*this),
- m_port_a(0),
- m_ddr_a(0),
- m_in_a(0),
- m_port_b(0),
- m_ddr_b(0),
- m_in_b(0),
- m_port_c(0),
- m_ddr_c(0),
- m_in_c(0),
- m_ca_level(0),
- m_cb_level(0),
- m_interrupt_level(0),
- m_cr(0),
- m_air(0)
-{
- for (int i = 0; i < 5; i++)
- {
- m_irq_level[i] = 0;
- }
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void tpi6525_device::device_start()
-{
- // resolve callbacks
- m_out_irq_cb.resolve_safe();
- m_in_pa_cb.resolve();
- m_out_pa_cb.resolve_safe();
- m_in_pb_cb.resolve();
- m_out_pb_cb.resolve_safe();
- m_in_pc_cb.resolve();
- m_out_pc_cb.resolve_safe();
- m_out_ca_cb.resolve_safe();
- m_out_cb_cb.resolve_safe();
-
- /* register for state saving */
- save_item(NAME(m_port_a));
- save_item(NAME(m_ddr_a));
- save_item(NAME(m_in_a));
- save_item(NAME(m_port_b));
- save_item(NAME(m_ddr_b));
- save_item(NAME(m_in_b));
- save_item(NAME(m_port_c));
- save_item(NAME(m_ddr_c));
- save_item(NAME(m_in_c));
- save_item(NAME(m_ca_level));
- save_item(NAME(m_cb_level));
- save_item(NAME(m_interrupt_level));
- save_item(NAME(m_cr));
- save_item(NAME(m_air));
- save_item(NAME(m_irq_level));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void tpi6525_device::device_reset()
-{
- /* setup some initial values */
- m_in_a = 0xff;
- m_in_b = 0xff;
- m_in_c = 0xff;
-}
-
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-void tpi6525_device::set_interrupt()
-{
- if (!m_interrupt_level && (m_air != 0))
- {
- m_interrupt_level = 1;
-
- DBG_LOG(machine(), 3, "tpi6525", ("%s set interrupt\n", tag()));
-
- m_out_irq_cb(m_interrupt_level);
- }
-}
-
-
-void tpi6525_device::clear_interrupt()
-{
- if (m_interrupt_level && (m_air == 0))
- {
- m_interrupt_level = 0;
-
- DBG_LOG(machine(), 3, "tpi6525", ("%s clear interrupt\n", tag()));
-
- m_out_irq_cb(m_interrupt_level);
- }
-}
-
-
-WRITE_LINE_MEMBER( tpi6525_device::i0_w )
-{
- if (INTERRUPT_MODE && (state != m_irq_level[0]))
- {
- m_irq_level[0] = state;
-
- if ((state == 0) && !(m_air & 1) && (m_ddr_c & 1))
- {
- m_air |= 1;
- set_interrupt();
- }
- }
-}
-
-
-WRITE_LINE_MEMBER( tpi6525_device::i1_w )
-{
- if (INTERRUPT_MODE && (state != m_irq_level[1]))
- {
- m_irq_level[1] = state;
-
- if ((state == 0) && !(m_air & 2) && (m_ddr_c & 2))
- {
- m_air |= 2;
- set_interrupt();
- }
- }
-}
-
-
-WRITE_LINE_MEMBER( tpi6525_device::i2_w )
-{
- if (INTERRUPT_MODE && (state != m_irq_level[2]))
- {
- m_irq_level[2] = state;
-
- if ((state == 0) && !(m_air & 4) && (m_ddr_c & 4))
- {
- m_air |= 4;
- set_interrupt();
- }
- }
-}
-
-
-WRITE_LINE_MEMBER( tpi6525_device::i3_w )
-{
- if (INTERRUPT_MODE && (state != m_irq_level[3]))
- {
- m_irq_level[3] = state;
-
- if (((INTERRUPT3_RISING_EDGE && (state == 1))
- || (!INTERRUPT3_RISING_EDGE && (state == 0)))
- && !(m_air & 8) && (m_ddr_c & 8))
- {
- m_air |= 8;
- set_interrupt();
- }
- }
-}
-
-
-WRITE_LINE_MEMBER( tpi6525_device::i4_w )
-{
- if (INTERRUPT_MODE && (state != m_irq_level[4]) )
- {
- m_irq_level[4] = state;
-
- if (((INTERRUPT4_RISING_EDGE && (state == 1))
- ||(!INTERRUPT4_RISING_EDGE&&(state == 0)))
- && !(m_air & 0x10) && (m_ddr_c & 0x10))
- {
- m_air |= 0x10;
- set_interrupt();
- }
- }
-}
-
-READ8_MEMBER( tpi6525_device::pa_r )
-{
- UINT8 data = m_in_a;
-
- if (!m_in_pa_cb.isnull())
- data = m_in_pa_cb(offset);
-
- data = (data & ~m_ddr_a) | (m_ddr_a & m_port_a);
-
- return data;
-}
-
-
-WRITE8_MEMBER( tpi6525_device::pa_w )
-{
- m_in_a = data;
-}
-
-
-READ8_MEMBER( tpi6525_device::pb_r )
-{
- UINT8 data = m_in_b;
-
- if (!m_in_pb_cb.isnull())
- data = m_in_pb_cb(offset);
-
- data = (data & ~m_ddr_b) | (m_ddr_b & m_port_b);
-
- return data;
-}
-
-
-WRITE8_MEMBER( tpi6525_device::pb_w )
-{
- m_in_b = data;
-}
-
-
-READ8_MEMBER( tpi6525_device::pc_r )
-{
- UINT8 data = m_in_c;
-
- if (!m_in_pc_cb.isnull())
- data &= m_in_pc_cb(offset);
-
- data = (data & ~m_ddr_c) | (m_ddr_c & m_port_c);
-
- return data;
-}
-
-
-WRITE8_MEMBER( tpi6525_device::pc_w )
-{
- m_in_c = data;
-}
-
-
-READ8_MEMBER( tpi6525_device::read )
-{
- UINT8 data = 0xff;
-
- switch (offset & 7)
- {
- case 0:
- data = m_in_a;
-
- if (!m_in_pa_cb.isnull())
- data &= m_in_pa_cb(0);
-
- data = (data & ~m_ddr_a) | (m_ddr_a & m_port_a);
-
- break;
-
- case 1:
- data = m_in_b;
-
- if (!m_in_pb_cb.isnull())
- data &= m_in_pb_cb(0);
-
- data = (data & ~m_ddr_b) | (m_ddr_b & m_port_b);
-
- break;
-
- case 2:
- if (INTERRUPT_MODE)
- {
- data = 0;
-
- if (m_irq_level[0]) data |= 0x01;
- if (m_irq_level[1]) data |= 0x02;
- if (m_irq_level[2]) data |= 0x04;
- if (m_irq_level[3]) data |= 0x08;
- if (m_irq_level[4]) data |= 0x10;
- if (!m_interrupt_level) data |= 0x20;
- if (m_ca_level) data |= 0x40;
- if (m_cb_level) data |= 0x80;
- }
- else
- {
- data = m_in_c;
-
- if (!m_in_pc_cb.isnull())
- data &= m_in_pc_cb(0);
-
- data = (data & ~m_ddr_c) | (m_ddr_c & m_port_c);
- }
-
- DBG_LOG(machine(), 2, "tpi6525", ("%s read %.2x %.2x\n", tag(), offset, data));
- break;
-
- case 3:
- data = m_ddr_a;
- break;
-
- case 4:
- data = m_ddr_b;
- break;
-
- case 5:
- data = m_ddr_c;
- break;
-
- case 6:
- data = m_cr;
- break;
-
- case 7: /* air */
- if (PRIORIZED_INTERRUPTS)
- {
- if (m_air & 0x10)
- {
- data = 0x10;
- m_air &= ~0x10;
- }
- else if (m_air & 8)
- {
- data = 8;
- m_air &= ~8;
- }
- else if (m_air & 4)
- {
- data = 4;
- m_air &= ~4;
- }
- else if (m_air & 2)
- {
- data = 2;
- m_air &= ~2;
- }
- else if (m_air & 1)
- {
- data = 1;
- m_air &= ~1;
- }
- }
- else
- {
- data = m_air;
- m_air = 0;
- }
-
- clear_interrupt();
- break;
-
- }
-
- DBG_LOG(machine(), 3, "tpi6525", ("%s read %.2x %.2x\n", tag(), offset, data));
-
- return data;
-}
-
-
-WRITE8_MEMBER( tpi6525_device::write )
-{
- DBG_LOG(machine(), 2, "tpi6525", ("%s write %.2x %.2x\n", tag(), offset, data));
-
- switch (offset & 7)
- {
- case 0:
- m_port_a = data;
- m_out_pa_cb((offs_t)0, (m_port_a & m_ddr_a) | (m_ddr_a ^ 0xff));
- break;
-
- case 1:
- m_port_b = data;
- m_out_pb_cb((offs_t)0, (m_port_b & m_ddr_b) | (m_ddr_b ^ 0xff));
- break;
-
- case 2:
- m_port_c = data;
-
- if (!INTERRUPT_MODE)
- m_out_pc_cb((offs_t)0, (m_port_c & m_ddr_c) | (m_ddr_c ^ 0xff));
- break;
-
- case 3:
- m_ddr_a = data;
- m_out_pa_cb((offs_t)0, (m_port_a & m_ddr_a) | (m_ddr_a ^ 0xff));
- break;
-
- case 4:
- m_ddr_b = data;
- m_out_pb_cb((offs_t)0, (m_port_b & m_ddr_b) | (m_ddr_b ^ 0xff));
- break;
-
- case 5:
- m_ddr_c = data;
-
- if (!INTERRUPT_MODE)
- m_out_pc_cb((offs_t)0, (m_port_c & m_ddr_c) | (m_ddr_c ^ 0xff));
- break;
-
- case 6:
- m_cr = data;
-
- if (INTERRUPT_MODE)
- {
- if (CA_MANUAL_OUT)
- {
- if (m_ca_level != CA_MANUAL_LEVEL)
- {
- m_ca_level = CA_MANUAL_LEVEL;
- m_out_ca_cb(m_ca_level);
- }
- }
- if (CB_MANUAL_OUT)
- {
- if (m_cb_level != CB_MANUAL_LEVEL)
- {
- m_cb_level = CB_MANUAL_LEVEL;
- m_out_cb_cb(m_cb_level);
- }
- }
- }
-
- break;
-
- case 7:
- /* m_air = data; */
- break;
- }
-}
-
-void tpi6525_device::port_line_w(UINT8 &port, int line, int state)
-{
- port &= ~(1 << line);
- port |= state << line;
-}
-
-/* this should probably be done better, needed for amigacd.c */
-
-UINT8 tpi6525_device::get_ddr_a()
-{
- return m_ddr_a;
-}
-
-UINT8 tpi6525_device::get_ddr_b()
-{
- return m_ddr_b;
-}
-
-UINT8 tpi6525_device::get_ddr_c()
-{
- return m_ddr_c;
-}
diff --git a/src/emu/machine/6525tpi.h b/src/emu/machine/6525tpi.h
deleted file mode 100644
index 5a2e07d12dd..00000000000
--- a/src/emu/machine/6525tpi.h
+++ /dev/null
@@ -1,154 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Peter Trauner
-/*****************************************************************************
- *
- * machine/tpi6525.h
- *
- * mos tri port interface 6525
- * mos triple interface adapter 6523
- *
- * peter.trauner@jk.uni-linz.ac.at
- *
- * used in commodore b series
- * used in commodore c1551 floppy disk drive
- *
- * tia6523 is a tpi6525 without control register!?
- *
- * tia6523
- * only some lines of port b and c are in the pinout!
- *
- * connector to floppy c1551 (delivered with c1551 as c16 expansion)
- * port a for data read/write
- * port b
- * 0 status 0
- * 1 status 1
- * port c
- * 6 dav output edge data on port a available
- * 7 ack input edge ready for next datum
- *
- ****************************************************************************/
-
-#ifndef __TPI6525_H__
-#define __TPI6525_H__
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-class tpi6525_device : public device_t
-{
-public:
- tpi6525_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~tpi6525_device() {}
-
- template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<tpi6525_device &>(device).m_out_irq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_pa_callback(device_t &device, _Object object) { return downcast<tpi6525_device &>(device).m_in_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pa_callback(device_t &device, _Object object) { return downcast<tpi6525_device &>(device).m_out_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_pb_callback(device_t &device, _Object object) { return downcast<tpi6525_device &>(device).m_in_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pb_callback(device_t &device, _Object object) { return downcast<tpi6525_device &>(device).m_out_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_pc_callback(device_t &device, _Object object) { return downcast<tpi6525_device &>(device).m_in_pc_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pc_callback(device_t &device, _Object object) { return downcast<tpi6525_device &>(device).m_out_pc_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_ca_callback(device_t &device, _Object object) { return downcast<tpi6525_device &>(device).m_out_ca_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_cb_callback(device_t &device, _Object object) { return downcast<tpi6525_device &>(device).m_out_cb_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( i0_w );
- DECLARE_WRITE_LINE_MEMBER( i1_w );
- DECLARE_WRITE_LINE_MEMBER( i2_w );
- DECLARE_WRITE_LINE_MEMBER( i3_w );
- DECLARE_WRITE_LINE_MEMBER( i4_w );
-
- DECLARE_READ8_MEMBER( pa_r );
- DECLARE_READ8_MEMBER( pb_r );
- DECLARE_READ8_MEMBER( pc_r );
- DECLARE_WRITE8_MEMBER( pa_w );
- DECLARE_WRITE8_MEMBER( pb_w );
- DECLARE_WRITE8_MEMBER( pc_w );
-
- WRITE_LINE_MEMBER( pb0_w ) { port_line_w(m_in_b, 0, state); }
- WRITE_LINE_MEMBER( pb1_w ) { port_line_w(m_in_b, 1, state); }
- WRITE_LINE_MEMBER( pb2_w ) { port_line_w(m_in_b, 2, state); }
- WRITE_LINE_MEMBER( pb3_w ) { port_line_w(m_in_b, 3, state); }
- WRITE_LINE_MEMBER( pb4_w ) { port_line_w(m_in_b, 4, state); }
- WRITE_LINE_MEMBER( pb5_w ) { port_line_w(m_in_b, 5, state); }
- WRITE_LINE_MEMBER( pb6_w ) { port_line_w(m_in_b, 6, state); }
- WRITE_LINE_MEMBER( pb7_w ) { port_line_w(m_in_b, 7, state); }
-
- UINT8 get_ddr_a();
- UINT8 get_ddr_b();
- UINT8 get_ddr_c();
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
- devcb_write_line m_out_irq_cb;
-
- devcb_read8 m_in_pa_cb;
- devcb_write8 m_out_pa_cb;
-
- devcb_read8 m_in_pb_cb;
- devcb_write8 m_out_pb_cb;
-
- devcb_read8 m_in_pc_cb;
- devcb_write8 m_out_pc_cb;
-
- devcb_write_line m_out_ca_cb;
- devcb_write_line m_out_cb_cb;
-
- UINT8 m_port_a, m_ddr_a, m_in_a;
- UINT8 m_port_b, m_ddr_b, m_in_b;
- UINT8 m_port_c, m_ddr_c, m_in_c;
-
- UINT8 m_ca_level, m_cb_level, m_interrupt_level;
-
- UINT8 m_cr;
- UINT8 m_air;
-
- UINT8 m_irq_level[5];
-
- void set_interrupt();
- void clear_interrupt();
-
- // helper function to write a single line
- static void port_line_w(UINT8 &port, int line, int state);
-};
-
-extern const device_type TPI6525;
-
-
-#define MCFG_TPI6525_OUT_IRQ_CB(_devcb) \
- devcb = &tpi6525_device::set_out_irq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TPI6525_IN_PA_CB(_devcb) \
- devcb = &tpi6525_device::set_in_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TPI6525_OUT_PA_CB(_devcb) \
- devcb = &tpi6525_device::set_out_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TPI6525_IN_PB_CB(_devcb) \
- devcb = &tpi6525_device::set_in_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TPI6525_OUT_PB_CB(_devcb) \
- devcb = &tpi6525_device::set_out_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TPI6525_IN_PC_CB(_devcb) \
- devcb = &tpi6525_device::set_in_pc_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TPI6525_OUT_PC_CB(_devcb) \
- devcb = &tpi6525_device::set_out_pc_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TPI6525_OUT_CA_CB(_devcb) \
- devcb = &tpi6525_device::set_out_ca_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TPI6525_OUT_CB_CB(_devcb) \
- devcb = &tpi6525_device::set_out_cb_callback(*device, DEVCB_##_devcb);
-
-
-#endif /* __TPI6525_H__ */
diff --git a/src/emu/machine/6532riot.c b/src/emu/machine/6532riot.c
deleted file mode 100644
index 98bb8c2dacc..00000000000
--- a/src/emu/machine/6532riot.c
+++ /dev/null
@@ -1,483 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- RIOT 6532 emulation
-
-The timer seems to follow these rules:
-- When the timer flag changes from 0 to 1 the timer continues to count
- down at a 1 cycle rate.
-- When the timer is being read or written the timer flag is reset.
-- When the timer flag is set and the timer contents are 0, the counting
- stops.
-
-***************************************************************************/
-
-#include "emu.h"
-#include "6532riot.h"
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-// device type definition
-const device_type RIOT6532 = &device_creator<riot6532_device>;
-
-enum
-{
- TIMER_IDLE,
- TIMER_COUNTING,
- TIMER_FINISHING
-};
-
-#define TIMER_FLAG 0x80
-#define PA7_FLAG 0x40
-
-
-
-/***************************************************************************
- INTERNAL FUNCTIONS
-***************************************************************************/
-
-/*-------------------------------------------------
- update_irqstate - update the IRQ state
- based on interrupt enables
--------------------------------------------------*/
-
-void riot6532_device::update_irqstate()
-{
- int irq = (m_irqstate & m_irqenable) ? ASSERT_LINE : CLEAR_LINE;
-
- if (m_irq != irq)
- {
- m_irq_cb(irq);
- m_irq = irq;
- }
-}
-
-
-/*-------------------------------------------------
- apply_ddr - combine inputs and outputs
- according to the DDR
--------------------------------------------------*/
-
-UINT8 riot6532_device::apply_ddr(const riot6532_port *port)
-{
- return (port->m_out & port->m_ddr) | (port->m_in & ~port->m_ddr);
-}
-
-
-/*-------------------------------------------------
- update_pa7_state - see if PA7 has changed
- and signal appropriately
--------------------------------------------------*/
-
-void riot6532_device::update_pa7_state()
-{
- UINT8 data = apply_ddr(&m_port[0]) & 0x80;
-
- /* if the state changed in the correct direction, set the PA7 flag and update IRQs */
- if ((m_pa7prev ^ data) && (m_pa7dir ^ data) == 0)
- {
- m_irqstate |= PA7_FLAG;
- update_irqstate();
- }
- m_pa7prev = data;
-}
-
-
-/*-------------------------------------------------
- get_timer - return the current timer value
--------------------------------------------------*/
-
-UINT8 riot6532_device::get_timer()
-{
- /* if idle, return 0 */
- if (m_timerstate == TIMER_IDLE)
- {
- return 0;
- }
-
- /* if counting, return the number of ticks remaining */
- else if (m_timerstate == TIMER_COUNTING)
- {
- return m_timer->remaining().as_ticks(clock()) >> m_timershift;
- }
-
- /* if finishing, return the number of ticks without the shift */
- else
- {
- return m_timer->remaining().as_ticks(clock());
- }
-}
-
-
-
-void riot6532_device::timer_end()
-{
- assert(m_timerstate != TIMER_IDLE);
-
- /* if we finished counting, switch to the finishing state */
- if(m_timerstate == TIMER_COUNTING)
- {
- m_timerstate = TIMER_FINISHING;
- m_timer->adjust(attotime::from_ticks(256, clock()));
-
- /* signal timer IRQ as well */
- m_irqstate |= TIMER_FLAG;
- update_irqstate();
- }
-
- /* if we finished finishing, keep spinning */
- else if (m_timerstate == TIMER_FINISHING)
- {
- m_timer->adjust(attotime::from_ticks(256, clock()));
- }
-}
-
-
-
-/***************************************************************************
- I/O ACCESS
-***************************************************************************/
-
-/*-------------------------------------------------
- riot6532_w - master I/O write access
--------------------------------------------------*/
-
-WRITE8_MEMBER( riot6532_device::write )
-{
- reg_w(offset, data);
-}
-
-void riot6532_device::reg_w(UINT8 offset, UINT8 data)
-{
- /* if A4 == 1 and A2 == 1, we are writing to the timer */
- if ((offset & 0x14) == 0x14)
- {
- static const UINT8 timershift[4] = { 0, 3, 6, 10 };
- attotime curtime = machine().time();
- INT64 target;
-
- /* A0-A1 contain the timer divisor */
- m_timershift = timershift[offset & 3];
-
- /* A3 contains the timer IRQ enable */
- if (offset & 8)
- m_irqenable |= TIMER_FLAG;
- else
- m_irqenable &= ~TIMER_FLAG;
-
- /* writes here clear the timer flag */
- if (m_timerstate != TIMER_FINISHING || get_timer() != 0xff)
- {
- m_irqstate &= ~TIMER_FLAG;
- }
- update_irqstate();
-
- /* update the timer */
- m_timerstate = TIMER_COUNTING;
- target = curtime.as_ticks(clock()) + 1 + (data << m_timershift);
- m_timer->adjust(attotime::from_ticks(target, clock()) - curtime);
- }
-
- /* if A4 == 0 and A2 == 1, we are writing to the edge detect control */
- else if ((offset & 0x14) == 0x04)
- {
- /* A1 contains the A7 IRQ enable */
- if (offset & 2)
- {
- m_irqenable |= PA7_FLAG;
- }
- else
- {
- m_irqenable &= ~PA7_FLAG;
- }
-
- /* A0 specifies the edge detect direction: 0=negative, 1=positive */
- m_pa7dir = (offset & 1) << 7;
- }
-
- /* if A4 == anything and A2 == 0, we are writing to the I/O section */
- else
- {
- /* A1 selects the port */
- riot6532_port *port = &m_port[BIT(offset, 1)];
-
- /* if A0 == 1, we are writing to the port's DDR */
- if (offset & 1)
- {
- port->m_ddr = data;
- }
-
- /* if A0 == 0, we are writing to the port's output */
- else
- {
- port->m_out = data;
- (*port->m_out_cb)((offs_t)0, data);
- }
-
- /* writes to port A need to update the PA7 state */
- if (port == &m_port[0])
- {
- update_pa7_state();
- }
- }
-}
-
-
-/*-------------------------------------------------
- riot6532_r - master I/O read access
--------------------------------------------------*/
-
-READ8_MEMBER( riot6532_device::read )
-{
- return reg_r(offset, space.debugger_access());
-}
-
-UINT8 riot6532_device::reg_r(UINT8 offset, bool debugger_access)
-{
- UINT8 val = 0;
-
- /* if A2 == 1 and A0 == 1, we are reading interrupt flags */
- if ((offset & 0x05) == 0x05)
- {
- val = m_irqstate;
-
- if ( ! debugger_access )
- {
- /* implicitly clears the PA7 flag */
- m_irqstate &= ~PA7_FLAG;
- update_irqstate();
- }
- }
-
- /* if A2 == 1 and A0 == 0, we are reading the timer */
- else if ((offset & 0x05) == 0x04)
- {
- val = get_timer();
-
- if ( ! debugger_access )
- {
- /* A3 contains the timer IRQ enable */
- if (offset & 8)
- {
- m_irqenable |= TIMER_FLAG;
- }
- else
- {
- m_irqenable &= ~TIMER_FLAG;
- }
-
- /* implicitly clears the timer flag */
- if (m_timerstate != TIMER_FINISHING || val != 0xff)
- {
- m_irqstate &= ~TIMER_FLAG;
- }
- update_irqstate();
- }
- }
-
- /* if A2 == 0 and A0 == anything, we are reading from ports */
- else
- {
- /* A1 selects the port */
- riot6532_port *port = &m_port[BIT(offset, 1)];
-
- /* if A0 == 1, we are reading the port's DDR */
- if (offset & 1)
- {
- val = port->m_ddr;
- }
-
- /* if A0 == 0, we are reading the port as an input */
- else
- {
- /* call the input callback if it exists */
- if (!(*port->m_in_cb).isnull())
- {
- port->m_in = (*port->m_in_cb)(0);
-
- /* changes to port A need to update the PA7 state */
- if (port == &m_port[0])
- {
- if (!debugger_access)
- {
- update_pa7_state();
- }
- }
- }
-
- /* apply the DDR to the result */
- val = apply_ddr(port);
- }
- }
- return val;
-}
-
-
-/*-------------------------------------------------
- porta_in_set - set port A input value
--------------------------------------------------*/
-
-void riot6532_device::porta_in_set(UINT8 data, UINT8 mask)
-{
- m_port[0].m_in = (m_port[0].m_in & ~mask) | (data & mask);
- update_pa7_state();
-}
-
-
-/*-------------------------------------------------
- portb_in_set - set port B input value
--------------------------------------------------*/
-
-void riot6532_device::portb_in_set(UINT8 data, UINT8 mask)
-{
- m_port[1].m_in = (m_port[1].m_in & ~mask) | (data & mask);
-}
-
-
-/*-------------------------------------------------
- porta_in_get - return port A input value
--------------------------------------------------*/
-
-UINT8 riot6532_device::porta_in_get()
-{
- return m_port[0].m_in;
-}
-
-
-/*-------------------------------------------------
- portb_in_get - return port B input value
--------------------------------------------------*/
-
-UINT8 riot6532_device::portb_in_get()
-{
- return m_port[1].m_in;
-}
-
-
-/*-------------------------------------------------
- porta_in_get - return port A output value
--------------------------------------------------*/
-
-UINT8 riot6532_device::porta_out_get()
-{
- return m_port[0].m_out;
-}
-
-
-/*-------------------------------------------------
- portb_in_get - return port B output value
--------------------------------------------------*/
-
-UINT8 riot6532_device::portb_out_get()
-{
- return m_port[1].m_out;
-}
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// riot6532_device - constructor
-//-------------------------------------------------
-
-riot6532_device::riot6532_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, RIOT6532, "6532 RIOT", tag, owner, clock, "riot6532", __FILE__),
- m_in_pa_cb(*this),
- m_out_pa_cb(*this),
- m_in_pb_cb(*this),
- m_out_pb_cb(*this),
- m_irq_cb(*this),
- m_irq(CLEAR_LINE),
- m_pa7dir(0),
- m_pa7prev(0)
-{
- memset(m_port, 0x00, sizeof(m_port));
-}
-
-/*-------------------------------------------------
- device_start - device-specific startup
--------------------------------------------------*/
-
-void riot6532_device::device_start()
-{
- /* resolve callbacks */
- m_in_pa_cb.resolve();
- m_port[0].m_in_cb = &m_in_pa_cb;
- m_out_pa_cb.resolve_safe();
- m_port[0].m_out_cb = &m_out_pa_cb;
- m_in_pb_cb.resolve();
- m_port[1].m_in_cb = &m_in_pb_cb;
- m_out_pb_cb.resolve_safe();
- m_port[1].m_out_cb = &m_out_pb_cb;
- m_irq_cb.resolve_safe();
-
- /* allocate timers */
- m_timer = timer_alloc(TIMER_END_CB);
-
- /* register for save states */
- save_item(NAME(m_port[0].m_in));
- save_item(NAME(m_port[0].m_out));
- save_item(NAME(m_port[0].m_ddr));
- save_item(NAME(m_port[1].m_in));
- save_item(NAME(m_port[1].m_out));
- save_item(NAME(m_port[1].m_ddr));
-
- save_item(NAME(m_irqstate));
- save_item(NAME(m_irqenable));
- save_item(NAME(m_irq));
-
- save_item(NAME(m_pa7dir));
- save_item(NAME(m_pa7prev));
-
- save_item(NAME(m_timershift));
- save_item(NAME(m_timerstate));
-}
-
-
-
-/*-------------------------------------------------
- device_reset - device-specific reset
--------------------------------------------------*/
-
-void riot6532_device::device_reset()
-{
- /* reset I/O states */
- m_port[0].m_in = 0;
- m_port[0].m_out = 0;
- m_port[0].m_ddr = 0;
- m_port[1].m_in = 0;
- m_port[1].m_out = 0;
- m_port[1].m_ddr = 0;
-
- /* reset IRQ states */
- m_irqenable = 0;
- m_irqstate = 0;
- update_irqstate();
-
- /* reset PA7 states */
- m_pa7dir = 0;
- m_pa7prev = 0;
-
- /* reset timer states */
- m_timershift = 10;
- m_timerstate = TIMER_COUNTING;
- m_timer->adjust(attotime::from_ticks(256 << m_timershift, clock()));
-}
-
-void riot6532_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_END_CB:
- timer_end();
- break;
- default:
- assert_always(FALSE, "Unknown id in riot6532_device::device_timer");
- }
-}
diff --git a/src/emu/machine/6532riot.h b/src/emu/machine/6532riot.h
deleted file mode 100644
index 2825f31dc9d..00000000000
--- a/src/emu/machine/6532riot.h
+++ /dev/null
@@ -1,127 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- RIOT 6532 emulation
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __RIOT6532_H__
-#define __RIOT6532_H__
-
-#include "emu.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_RIOT6532_IN_PA_CB(_devcb) \
- devcb = &riot6532_device::set_in_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_RIOT6532_OUT_PA_CB(_devcb) \
- devcb = &riot6532_device::set_out_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_RIOT6532_IN_PB_CB(_devcb) \
- devcb = &riot6532_device::set_in_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_RIOT6532_OUT_PB_CB(_devcb) \
- devcb = &riot6532_device::set_out_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_RIOT6532_IRQ_CB(_devcb) \
- devcb = &riot6532_device::set_irq_callback(*device, DEVCB_##_devcb);
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-
-// ======================> riot6532_device
-
-class riot6532_device : public device_t
-{
-public:
- // construction/destruction
- riot6532_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_in_pa_callback(device_t &device, _Object object) { return downcast<riot6532_device &>(device).m_in_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pa_callback(device_t &device, _Object object) { return downcast<riot6532_device &>(device).m_out_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_pb_callback(device_t &device, _Object object) { return downcast<riot6532_device &>(device).m_in_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pb_callback(device_t &device, _Object object) { return downcast<riot6532_device &>(device).m_out_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<riot6532_device &>(device).m_irq_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- UINT8 reg_r(UINT8 offset, bool debugger_access = false);
- void reg_w(UINT8 offset, UINT8 data);
-
- void porta_in_set(UINT8 data, UINT8 mask);
- void portb_in_set(UINT8 data, UINT8 mask);
-
- UINT8 porta_in_get();
- UINT8 portb_in_get();
-
- UINT8 porta_out_get();
- UINT8 portb_out_get();
-
- void timer_end();
-
-protected:
- class riot6532_port
- {
- public:
- UINT8 m_in;
- UINT8 m_out;
- UINT8 m_ddr;
- devcb_read8 *m_in_cb;
- devcb_write8 *m_out_cb;
- };
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual void device_post_load() { }
- virtual void device_clock_changed() { }
-
-
-private:
- void update_irqstate();
- UINT8 apply_ddr(const riot6532_port *port);
- void update_pa7_state();
- UINT8 get_timer();
-
- riot6532_port m_port[2];
-
- devcb_read8 m_in_pa_cb;
- devcb_write8 m_out_pa_cb;
- devcb_read8 m_in_pb_cb;
- devcb_write8 m_out_pb_cb;
- devcb_write_line m_irq_cb;
-
- UINT8 m_irqstate;
- UINT8 m_irqenable;
- int m_irq;
-
- UINT8 m_pa7dir; /* 0x80 = high-to-low, 0x00 = low-to-high */
- UINT8 m_pa7prev;
-
- UINT8 m_timershift;
- UINT8 m_timerstate;
- emu_timer * m_timer;
-
- enum
- {
- TIMER_END_CB
- };
-};
-
-
-// device type definition
-extern const device_type RIOT6532;
-
-#endif
diff --git a/src/emu/machine/6821pia.c b/src/emu/machine/6821pia.c
deleted file mode 100644
index 3fbf6477fa9..00000000000
--- a/src/emu/machine/6821pia.c
+++ /dev/null
@@ -1,1121 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Nathan Woods
-/**********************************************************************
-
- Motorola 6821 PIA interface and emulation
-
-**********************************************************************/
-
-#include "emu.h"
-#include "6821pia.h"
-
-
-//**************************************************************************
-// MACROS
-//**************************************************************************
-
-#define VERBOSE 1
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-#define PIA_IRQ1 (0x80)
-#define PIA_IRQ2 (0x40)
-
-#define IRQ1_ENABLED(c) ( (((c) >> 0) & 0x01))
-#define C1_LOW_TO_HIGH(c) ( (((c) >> 1) & 0x01))
-#define C1_HIGH_TO_LOW(c) (!(((c) >> 1) & 0x01))
-#define OUTPUT_SELECTED(c) ( (((c) >> 2) & 0x01))
-#define IRQ2_ENABLED(c) ( (((c) >> 3) & 0x01))
-#define STROBE_E_RESET(c) ( (((c) >> 3) & 0x01))
-#define STROBE_C1_RESET(c) (!(((c) >> 3) & 0x01))
-#define C2_SET(c) ( (((c) >> 3) & 0x01))
-#define C2_LOW_TO_HIGH(c) ( (((c) >> 4) & 0x01))
-#define C2_HIGH_TO_LOW(c) (!(((c) >> 4) & 0x01))
-#define C2_SET_MODE(c) ( (((c) >> 4) & 0x01))
-#define C2_STROBE_MODE(c) (!(((c) >> 4) & 0x01))
-#define C2_OUTPUT(c) ( (((c) >> 5) & 0x01))
-#define C2_INPUT(c) (!(((c) >> 5) & 0x01))
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type PIA6821 = &device_creator<pia6821_device>;
-
-
-//-------------------------------------------------
-// pia6821_device - constructor
-//-------------------------------------------------
-
-pia6821_device::pia6821_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, PIA6821, "6821 PIA", tag, owner, clock, "pia6821", __FILE__),
- m_in_a_handler(*this),
- m_in_b_handler(*this),
- m_in_ca1_handler(*this),
- m_in_cb1_handler(*this),
- m_in_ca2_handler(*this),
- m_out_a_handler(*this),
- m_out_b_handler(*this),
- m_ca2_handler(*this),
- m_cb2_handler(*this),
- m_irqa_handler(*this),
- m_irqb_handler(*this),
- m_in_ca1(0),
- m_ctl_a(0),
- m_irq_a_state(0),
- m_in_cb1(0),
- m_ctl_b(0),
- m_irq_b_state(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void pia6821_device::device_start()
-{
- // resolve callbacks
- m_in_a_handler.resolve();
- m_in_b_handler.resolve();
- m_in_ca1_handler.resolve();
- m_in_cb1_handler.resolve();
- m_in_ca2_handler.resolve();
- m_out_a_handler.resolve();
- m_out_b_handler.resolve();
- m_ca2_handler.resolve();
- m_cb2_handler.resolve();
- m_irqa_handler.resolve_safe();
- m_irqb_handler.resolve_safe();
-
- save_item(NAME(m_in_a));
- save_item(NAME(m_in_ca1));
- save_item(NAME(m_in_ca2));
- save_item(NAME(m_out_a));
- save_item(NAME(m_out_ca2));
- save_item(NAME(m_port_a_z_mask));
- save_item(NAME(m_ddr_a));
- save_item(NAME(m_ctl_a));
- save_item(NAME(m_irq_a1));
- save_item(NAME(m_irq_a2));
- save_item(NAME(m_irq_a_state));
- save_item(NAME(m_in_b));
- save_item(NAME(m_in_cb1));
- save_item(NAME(m_in_cb2));
- save_item(NAME(m_out_b));
- save_item(NAME(m_out_cb2));
- save_item(NAME(m_last_out_cb2_z));
- save_item(NAME(m_ddr_b));
- save_item(NAME(m_ctl_b));
- save_item(NAME(m_irq_b1));
- save_item(NAME(m_irq_b2));
- save_item(NAME(m_irq_b_state));
- save_item(NAME(m_in_a_pushed));
- save_item(NAME(m_out_a_needs_pulled));
- save_item(NAME(m_in_ca1_pushed));
- save_item(NAME(m_in_ca2_pushed));
- save_item(NAME(m_out_ca2_needs_pulled));
- save_item(NAME(m_in_b_pushed));
- save_item(NAME(m_out_b_needs_pulled));
- save_item(NAME(m_in_cb1_pushed));
- save_item(NAME(m_in_cb2_pushed));
- save_item(NAME(m_out_cb2_needs_pulled));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void pia6821_device::device_reset()
-{
- //
- // set default read values.
- //
- // ports A,CA1,CA2 default to 1
- // ports B,CB1,CB2 are three-state and undefined (set to 0)
- //
- m_in_a = 0xff;
- m_in_ca1 = TRUE;
- m_in_ca2 = TRUE;
- m_out_a = 0;
- m_out_ca2 = 0;
- m_port_a_z_mask = 0;
- m_ddr_a = 0;
- m_ctl_a = 0;
- m_irq_a1 = 0;
- m_irq_a2 = 0;
- m_irq_a_state = 0;
- m_in_b = 0;
- m_in_cb1 = 0;
- m_in_cb2 = 0;
- m_out_b = 0;
- m_out_cb2 = 0;
- m_last_out_cb2_z = 0;
- m_ddr_b = 0;
- m_ctl_b = 0;
- m_irq_b1 = 0;
- m_irq_b2 = 0;
- m_irq_b_state = 0;
- m_in_a_pushed = false;
- m_out_a_needs_pulled = false;
- m_in_ca1_pushed = false;
- m_in_ca2_pushed = false;
- m_out_ca2_needs_pulled = false;
- m_in_b_pushed = false;
- m_out_b_needs_pulled = false;
- m_in_cb1_pushed = false;
- m_in_cb2_pushed = false;
- m_out_cb2_needs_pulled = false;
- m_logged_port_a_not_connected = false;
- m_logged_port_b_not_connected = false;
- m_logged_ca1_not_connected = false;
- m_logged_ca2_not_connected = false;
- m_logged_cb1_not_connected = false;
- m_logged_cb2_not_connected = false;
-
-
- // clear the IRQs
- m_irqa_handler(FALSE);
- m_irqb_handler(FALSE);
-}
-
-
-//-------------------------------------------------
-// update_interrupts
-//-------------------------------------------------
-
-void pia6821_device::update_interrupts()
-{
- // start with IRQ A
- int new_state = (m_irq_a1 && IRQ1_ENABLED(m_ctl_a)) || (m_irq_a2 && IRQ2_ENABLED(m_ctl_a));
-
- if (new_state != m_irq_a_state)
- {
- m_irq_a_state = new_state;
- m_irqa_handler(m_irq_a_state);
- }
-
- // then do IRQ B
- new_state = (m_irq_b1 && IRQ1_ENABLED(m_ctl_b)) || (m_irq_b2 && IRQ2_ENABLED(m_ctl_b));
-
- if (new_state != m_irq_b_state)
- {
- m_irq_b_state = new_state;
- m_irqb_handler(m_irq_b_state);
- }
-}
-
-
-//-------------------------------------------------
-// get_in_a_value
-//-------------------------------------------------
-
-UINT8 pia6821_device::get_in_a_value()
-{
- UINT8 port_a_data = 0;
- UINT8 ret;
-
- // update the input
- if (!m_in_a_handler.isnull())
- {
- port_a_data = m_in_a_handler(0);
- }
- else
- {
- if (m_in_a_pushed)
- {
- port_a_data = m_in_a;
- }
- else
- {
- // mark all pins disconnected
- m_port_a_z_mask = 0xff;
-
- if (!m_logged_port_a_not_connected && (m_ddr_a != 0xff))
- {
- logerror("PIA #%s: Warning! No port A read handler. Assuming pins 0x%02X not connected\n", tag(), m_ddr_a ^ 0xff);
- m_logged_port_a_not_connected = true;
- }
- }
- }
-
- // - connected pins are always read
- // - disconnected pins read the output buffer in output mode
- // - disconnected pins are HI in input mode
- ret = (~m_port_a_z_mask & port_a_data) |
- ( m_port_a_z_mask & m_ddr_a & m_out_a) |
- ( m_port_a_z_mask & ~m_ddr_a);
-
- return ret;
-}
-
-
-//-------------------------------------------------
-// get_in_b_value
-//-------------------------------------------------
-
-UINT8 pia6821_device::get_in_b_value()
-{
- UINT8 ret;
-
- if (m_ddr_b == 0xff)
- {
- // all output, just return buffer
- ret = m_out_b;
- }
- else
- {
- UINT8 port_b_data;
-
- // update the input
- if (!m_in_b_handler.isnull())
- {
- port_b_data = m_in_b_handler(0);
- }
- else
- {
- if (m_in_b_pushed)
- {
- port_b_data = m_in_b;
- }
- else
- {
- if (!m_logged_port_b_not_connected && (m_ddr_b != 0xff))
- {
- logerror("PIA #%s: Error! No port B read handler. Three-state pins 0x%02X are undefined\n", tag(), m_ddr_b ^ 0xff);
- m_logged_port_b_not_connected = true;
- }
-
- // undefined -- need to return something
- port_b_data = 0x00;
- }
- }
-
- // the DDR determines if the pin or the output buffer is read
- ret = (m_out_b & m_ddr_b) | (port_b_data & ~m_ddr_b);
- }
-
- return ret;
-}
-
-
-//-------------------------------------------------
-// get_out_a_value
-//-------------------------------------------------
-
-UINT8 pia6821_device::get_out_a_value()
-{
- UINT8 ret;
-
- if (m_ddr_a == 0xff)
- {
- // all output
- ret = m_out_a;
- }
- else
- {
- // input pins don't change
- ret = (m_out_a & m_ddr_a) | (get_in_a_value() & ~m_ddr_a);
- }
-
- return ret;
-}
-
-
-//-------------------------------------------------
-// get_out_b_value
-//-------------------------------------------------
-
-UINT8 pia6821_device::get_out_b_value()
-{
- // input pins are high-impedance - we just send them as zeros for backwards compatibility
- return m_out_b & m_ddr_b;
-}
-
-
-//-------------------------------------------------
-// set_out_ca2
-//-------------------------------------------------
-
-void pia6821_device::set_out_ca2(int data)
-{
- if (data != m_out_ca2)
- {
- m_out_ca2 = data;
-
- // send to output function
- if (!m_ca2_handler.isnull())
- {
- m_ca2_handler(m_out_ca2);
- }
- else
- {
- if (m_out_ca2_needs_pulled)
- {
- logerror("PIA #%s: Warning! No port CA2 write handler. Previous value has been lost!\n", tag());
- }
-
- m_out_ca2_needs_pulled = true;
- }
- }
-}
-
-
-//-------------------------------------------------
-// set_out_cb2
-//-------------------------------------------------
-
-void pia6821_device::set_out_cb2(int data)
-{
- int z = cb2_output_z();
-
- if ((data != m_out_cb2) || (z != m_last_out_cb2_z))
- {
- m_out_cb2 = data;
- m_last_out_cb2_z = z;
-
- // send to output function
- if (!m_cb2_handler.isnull())
- {
- m_cb2_handler(m_out_cb2);
- }
- else
- {
- if (m_out_cb2_needs_pulled)
- {
- logerror("PIA #%s: Warning! No port CB2 write handler. Previous value has been lost!\n", tag());
- }
-
- m_out_cb2_needs_pulled = true;
- }
- }
-}
-
-
-//-------------------------------------------------
-// port_a_r
-//-------------------------------------------------
-
-UINT8 pia6821_device::port_a_r()
-{
- UINT8 ret = get_in_a_value();
-
- // IRQ flags implicitly cleared by a read
- m_irq_a1 = FALSE;
- m_irq_a2 = FALSE;
- update_interrupts();
-
- // CA2 is configured as output and in read strobe mode
- if(C2_OUTPUT(m_ctl_a) && C2_STROBE_MODE(m_ctl_a))
- {
- // this will cause a transition low
- set_out_ca2(FALSE);
-
- // if the CA2 strobe is cleared by the E, reset it right away
- if(STROBE_E_RESET(m_ctl_a))
- {
- set_out_ca2(TRUE);
- }
- }
-
- LOG(("PIA #%s: port A read = %02X\n", tag(), ret));
-
- return ret;
-}
-
-
-//-------------------------------------------------
-// ddr_a_r
-//-------------------------------------------------
-
-UINT8 pia6821_device::ddr_a_r()
-{
- UINT8 ret = m_ddr_a;
-
- LOG(("PIA #%s: DDR A read = %02X\n", tag(), ret));
-
- return ret;
-}
-
-
-//-------------------------------------------------
-// port_b_r
-//-------------------------------------------------
-
-UINT8 pia6821_device::port_b_r()
-{
- UINT8 ret = get_in_b_value();
-
- // This read will implicitly clear the IRQ B1 flag. If CB2 is in write-strobe
- // mode with CB1 restore, and a CB1 active transition set the flag,
- // clearing it will cause CB2 to go high again. Note that this is different
- // from what happens with port A.
- if(m_irq_b1 && C2_STROBE_MODE(m_ctl_b) && STROBE_C1_RESET(m_ctl_b))
- {
- set_out_cb2(TRUE);
- }
-
- // IRQ flags implicitly cleared by a read
- m_irq_b1 = FALSE;
- m_irq_b2 = FALSE;
- update_interrupts();
-
- LOG(("PIA #%s: port B read = %02X\n", tag(), ret));
-
- return ret;
-}
-
-
-//-------------------------------------------------
-// ddr_b_r
-//-------------------------------------------------
-
-UINT8 pia6821_device::ddr_b_r()
-{
- UINT8 ret = m_ddr_b;
-
- LOG(("PIA #%s: DDR B read = %02X\n", tag(), ret));
-
- return ret;
-}
-
-
-//-------------------------------------------------
-// control_a_r
-//-------------------------------------------------
-
-UINT8 pia6821_device::control_a_r()
-{
- UINT8 ret;
-
- // update CA1 & CA2 if callback exists, these in turn may update IRQ's
- if (!m_in_ca1_handler.isnull())
- {
- ca1_w(m_in_ca1_handler());
- }
- else if(!m_logged_ca1_not_connected && (!m_in_ca1_pushed))
- {
- logerror("PIA #%s: Warning! No CA1 read handler. Assuming pin not connected\n", tag());
- m_logged_ca1_not_connected = true;
- }
-
- if (!m_in_ca2_handler.isnull())
- {
- ca2_w(m_in_ca2_handler());
- }
- else if ( !m_logged_ca2_not_connected && C2_INPUT(m_ctl_a) && !m_in_ca2_pushed)
- {
- logerror("PIA #%s: Warning! No CA2 read handler. Assuming pin not connected\n", tag());
- m_logged_ca2_not_connected = true;
- }
-
- // read control register
- ret = m_ctl_a;
-
- // set the IRQ flags if we have pending IRQs
- if(m_irq_a1)
- {
- ret |= PIA_IRQ1;
- }
-
- if(m_irq_a2 && C2_INPUT(m_ctl_a))
- {
- ret |= PIA_IRQ2;
- }
-
- LOG(("PIA #%s: control A read = %02X\n", tag(), ret));
-
- return ret;
-}
-
-
-//-------------------------------------------------
-// control_b_r
-//-------------------------------------------------
-
-UINT8 pia6821_device::control_b_r()
-{
- UINT8 ret;
-
- // update CB1 & CB2 if callback exists, these in turn may update IRQ's
- if(!m_in_cb1_handler.isnull())
- {
- cb1_w(m_in_cb1_handler());
- }
- else if(!m_logged_cb1_not_connected && !m_in_cb1_pushed)
- {
- logerror("PIA #%s: Error! no CB1 read handler. Three-state pin is undefined\n", tag());
- m_logged_cb1_not_connected = true;
- }
-
- if(!m_logged_cb2_not_connected && C2_INPUT(m_ctl_b) && !m_in_cb2_pushed)
- {
- logerror("PIA #%s: Error! Three-state pin is undefined\n", tag());
- m_logged_cb2_not_connected = true;
- }
-
- // read control register
- ret = m_ctl_b;
-
- // set the IRQ flags if we have pending IRQs
- if(m_irq_b1)
- {
- ret |= PIA_IRQ1;
- }
-
- if(m_irq_b2 && C2_INPUT(m_ctl_b))
- {
- ret |= PIA_IRQ2;
- }
-
- LOG(("PIA #%s: control B read = %02X\n", tag(), ret));
-
- return ret;
-}
-
-
-//-------------------------------------------------
-// read
-//-------------------------------------------------
-
-UINT8 pia6821_device::reg_r(UINT8 offset)
-{
- UINT8 ret;
-
- switch (offset & 0x03)
- {
- default: // impossible
- case 0x00:
- if (OUTPUT_SELECTED(m_ctl_a))
- {
- ret = port_a_r();
- }
- else
- {
- ret = ddr_a_r();
- }
- break;
-
- case 0x01:
- ret = control_a_r();
- break;
-
- case 0x02:
- if (OUTPUT_SELECTED(m_ctl_b))
- {
- ret = port_b_r();
- }
- else
- {
- ret = ddr_b_r();
- }
- break;
-
- case 0x03:
- ret = control_b_r();
- break;
- }
-
- return ret;
-}
-
-
-
-//-------------------------------------------------
-// send_to_out_a_func
-//-------------------------------------------------
-
-void pia6821_device::send_to_out_a_func(const char* message)
-{
- // input pins are pulled high
- UINT8 data = get_out_a_value();
-
- LOG(("PIA #%s: %s = %02X\n", tag(), message, data));
-
- if(!m_out_a_handler.isnull())
- {
- m_out_a_handler((offs_t) 0, data);
- }
- else
- {
- if(m_out_a_needs_pulled)
- {
- logerror("PIA #%s: Warning! No port A write handler. Previous value has been lost!\n", tag());
- }
-
- m_out_a_needs_pulled = true;
- }
-}
-
-
-//-------------------------------------------------
-// send_to_out_b_func
-//-------------------------------------------------
-
-void pia6821_device::send_to_out_b_func(const char* message)
-{
- // input pins are high-impedance - we just send them as zeros for backwards compatibility
- UINT8 data = get_out_b_value();
-
- LOG(("PIA #%s: %s = %02X\n", tag(), message, data));
-
- if(!m_out_b_handler.isnull())
- {
- m_out_b_handler((offs_t)0, data);
- }
- else
- {
- if(m_out_b_needs_pulled)
- {
- logerror("PIA #%s: Warning! No port B write handler. Previous value has been lost!\n", tag());
- }
-
- m_out_b_needs_pulled = true;
- }
-}
-
-
-//-------------------------------------------------
-// port_a_w
-//-------------------------------------------------
-
-void pia6821_device::port_a_w(UINT8 data)
-{
- // buffer the output value
- m_out_a = data;
-
- send_to_out_a_func("port A write");
-}
-
-
-//-------------------------------------------------
-// ddr_a_w
-//-------------------------------------------------
-
-void pia6821_device::ddr_a_w(UINT8 data)
-{
- if(data == 0x00)
- {
- LOG(("PIA #%s: DDR A write = %02X (input mode)\n", tag(), data));
- }
- else if(data == 0xff)
- {
- LOG(("PIA #%s: DDR A write = %02X (output mode)\n", tag(), data));
- }
- else
- {
- LOG(("PIA #%s: DDR A write = %02X (mixed mode)\n", tag(), data));
- }
-
- if(m_ddr_a != data)
- {
- // DDR changed, call the callback again
- m_ddr_a = data;
- m_logged_port_a_not_connected = false;
- send_to_out_a_func("port A write due to DDR change");
- }
-}
-
-
-//-------------------------------------------------
-// port_b_w
-//-------------------------------------------------
-
-void pia6821_device::port_b_w(UINT8 data)
-{
- // buffer the output value
- m_out_b = data;
-
- send_to_out_b_func("port B write");
-
- // CB2 in write strobe mode
- if(C2_STROBE_MODE(m_ctl_b))
- {
- // this will cause a transition low
- set_out_cb2(FALSE);
-
- // if the CB2 strobe is cleared by the E, reset it right away
- if(STROBE_E_RESET(m_ctl_b))
- {
- set_out_cb2(TRUE);
- }
- }
-}
-
-
-//-------------------------------------------------
-// ddr_b_w
-//-------------------------------------------------
-
-void pia6821_device::ddr_b_w(UINT8 data)
-{
- if (data == 0x00)
- {
- LOG(("PIA #%s: DDR B write = %02X (input mode)\n", tag(), data));
- }
- else if (data == 0xff)
- {
- LOG(("PIA #%s: DDR B write = %02X (output mode)\n", tag(), data));
- }
- else
- {
- LOG(("PIA #%s: DDR B write = %02X (mixed mode)\n", tag(), data));
- }
-
- if(m_ddr_b != data)
- {
- // DDR changed, call the callback again
- m_ddr_b = data;
- m_logged_port_b_not_connected = false;
- send_to_out_b_func("port B write due to DDR change");
- }
-}
-
-
-//-------------------------------------------------
-// control_a_w
-//-------------------------------------------------
-
-void pia6821_device::control_a_w(UINT8 data)
-{
- // bit 7 and 6 are read only
- data &= 0x3f;
-
- LOG(("PIA #%s: control A write = %02X\n", tag(), data));
-
- // update the control register
- m_ctl_a = data;
-
- // CA2 is configured as output
- if(C2_OUTPUT(m_ctl_a))
- {
- int temp;
-
- if(C2_SET_MODE(m_ctl_a))
- {
- // set/reset mode - bit value determines the new output
- temp = C2_SET(m_ctl_a);
- }
- else
- {
- // strobe mode - output is always high unless strobed
- temp = TRUE;
- }
-
- set_out_ca2(temp);
- }
-
- // update externals
- update_interrupts();
-}
-
-
-//-------------------------------------------------
-// control_b_w
-//-------------------------------------------------
-
-void pia6821_device::control_b_w(UINT8 data)
-{
- int temp;
-
- // bit 7 and 6 are read only
- data &= 0x3f;
-
- LOG(("PIA #%s: control B write = %02X\n", tag(), data));
-
- // update the control register
- m_ctl_b = data;
-
- if (C2_SET_MODE(m_ctl_b))
- {
- // set/reset mode - bit value determines the new output
- temp = C2_SET(m_ctl_b);
- }
- else
- {
- // strobe mode - output is always high unless strobed
- temp = TRUE;
- }
-
- set_out_cb2(temp);
-
- // update externals
- update_interrupts();
-}
-
-
-//-------------------------------------------------
-// write
-//-------------------------------------------------
-
-void pia6821_device::reg_w(UINT8 offset, UINT8 data)
-{
- switch (offset & 0x03)
- {
- default: // impossible
- case 0x00:
- if (OUTPUT_SELECTED(m_ctl_a))
- {
- port_a_w(data);
- }
- else
- {
- ddr_a_w(data);
- }
- break;
-
- case 0x01:
- control_a_w( data);
- break;
-
- case 0x02:
- if(OUTPUT_SELECTED(m_ctl_b))
- {
- port_b_w(data);
- }
- else
- {
- ddr_b_w(data);
- }
- break;
-
- case 0x03:
- control_b_w(data);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// set_a_input
-//-------------------------------------------------
-
-void pia6821_device::set_a_input(UINT8 data, UINT8 z_mask)
-{
- assert_always(m_in_a_handler.isnull(), "pia6821_porta_w() called when in_a_func implemented");
-
- LOG(("PIA #%s: set input port A = %02X\n", tag(), data));
-
- m_in_a = data;
- m_port_a_z_mask = z_mask;
- m_in_a_pushed = true;
-}
-
-
-//-------------------------------------------------
-// pia6821_porta_w
-//-------------------------------------------------
-
-void pia6821_device::porta_w(UINT8 data)
-{
- set_a_input(data, 0);
-}
-
-
-//-------------------------------------------------
-// a_output
-//-------------------------------------------------
-
-UINT8 pia6821_device::a_output()
-{
- m_out_a_needs_pulled = false;
-
- return get_out_a_value();
-}
-
-
-//-------------------------------------------------
-// ca1_w
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( pia6821_device::ca1_w )
-{
- LOG(("PIA #%s: set input CA1 = %d\n", tag(), state));
-
- // the new state has caused a transition
- if((m_in_ca1 != state) && ((state && C1_LOW_TO_HIGH(m_ctl_a)) || (!state && C1_HIGH_TO_LOW(m_ctl_a))))
- {
- LOG(("PIA #%s: CA1 triggering\n", tag()));
-
- // mark the IRQ
- m_irq_a1 = TRUE;
-
- // update externals
- update_interrupts();
-
- // CA2 is configured as output and in read strobe mode and cleared by a CA1 transition
- if(C2_OUTPUT(m_ctl_a) && C2_STROBE_MODE(m_ctl_a) && STROBE_C1_RESET(m_ctl_a))
- {
- set_out_ca2(TRUE);
- }
- }
-
- // set the new value for CA1
- m_in_ca1 = state;
- m_in_ca1_pushed = true;
-}
-
-
-//-------------------------------------------------
-// ca2_w
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( pia6821_device::ca2_w )
-{
- LOG(("PIA #%s: set input CA2 = %d\n", tag(), state));
-
- // if input mode and the new state has caused a transition
- if(C2_INPUT(m_ctl_a) && (m_in_ca2 != state) && ((state && C2_LOW_TO_HIGH(m_ctl_a)) || (!state && C2_HIGH_TO_LOW(m_ctl_a))))
- {
- LOG(("PIA #%s: CA2 triggering\n", tag()));
-
- // mark the IRQ
- m_irq_a2 = TRUE;
-
- // update externals
- update_interrupts();
- }
-
- // set the new value for CA2
- m_in_ca2 = state;
- m_in_ca2_pushed = true;
-}
-
-
-//-------------------------------------------------
-// ca2_output
-//-------------------------------------------------
-
-int pia6821_device::ca2_output()
-{
- m_out_ca2_needs_pulled = false;
-
- return m_out_ca2;
-}
-
-
-//-------------------------------------------------
-// ca2_output_z - version of ca2_output which
-// takes account of internal pullup resistor
-//-------------------------------------------------
-
-int pia6821_device::ca2_output_z()
-{
- m_out_ca2_needs_pulled = false;
-
- // If it's an output, output the bit, if it's an input, it's
- // pulled up
- return m_out_ca2 | C2_INPUT(m_ctl_a);
-}
-
-
-//-------------------------------------------------
-// portb_w
-//-------------------------------------------------
-
-void pia6821_device::portb_w(UINT8 data)
-{
- assert_always(m_in_b_handler.isnull(), "pia_set_input_b() called when in_b_func implemented");
-
- LOG(("PIA #%s: set input port B = %02X\n", tag(), data));
-
- m_in_b = data;
- m_in_b_pushed = true;
-}
-
-
-//-------------------------------------------------
-// b_output
-//-------------------------------------------------
-
-UINT8 pia6821_device::b_output()
-{
- m_out_b_needs_pulled = false;
-
- return get_out_b_value();
-}
-
-
-//-------------------------------------------------
-// cb1_w
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( pia6821_device::cb1_w )
-{
- LOG(("PIA #%s: set input CB1 = %d\n", tag(), state));
-
- // the new state has caused a transition
- if((m_in_cb1 != state) && ((state && C1_LOW_TO_HIGH(m_ctl_b)) || (!state && C1_HIGH_TO_LOW(m_ctl_b))))
- {
- LOG(("PIA #%s: CB1 triggering\n", tag()));
-
- // mark the IRQ
- m_irq_b1 = 1;
-
- // update externals
- update_interrupts();
-
- // If CB2 is configured as a write-strobe output which is reset by a CB1
- // transition, this reset will only happen when a read from port B implicitly
- // clears the IRQ B1 flag. So we handle the CB2 reset there. Note that this
- // is different from what happens with port A.
- }
-
- // set the new value for CB1
- m_in_cb1 = state;
- m_in_cb1_pushed = true;
-}
-
-
-//-------------------------------------------------
-// cb2_w
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( pia6821_device::cb2_w )
-{
- LOG(("PIA #%s: set input CB2 = %d\n", tag(), state));
-
- // if input mode and the new state has caused a transition
- if (C2_INPUT(m_ctl_b) &&
- (m_in_cb2 != state) &&
- ((state && C2_LOW_TO_HIGH(m_ctl_b)) || (!state && C2_HIGH_TO_LOW(m_ctl_b))))
- {
- LOG(("PIA #%s: CB2 triggering\n", tag()));
-
- // mark the IRQ
- m_irq_b2 = 1;
-
- // update externals
- update_interrupts();
- }
-
- // set the new value for CA2
- m_in_cb2 = state;
- m_in_cb2_pushed = true;
-}
-
-
-//-------------------------------------------------
-// output_cb2
-//-------------------------------------------------
-
-int pia6821_device::cb2_output()
-{
- m_out_cb2_needs_pulled = false;
-
- return m_out_cb2;
-}
-
-
-//-------------------------------------------------
-// cb2_output_z
-//-------------------------------------------------
-
-int pia6821_device::cb2_output_z()
-{
- return !C2_OUTPUT(m_ctl_b);
-}
diff --git a/src/emu/machine/6821pia.h b/src/emu/machine/6821pia.h
deleted file mode 100644
index cc686114feb..00000000000
--- a/src/emu/machine/6821pia.h
+++ /dev/null
@@ -1,233 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Nathan Woods
-/**********************************************************************
-
- Motorola 6821 PIA interface and emulation
-
- Notes:
- * get_port_b_z_mask() gives the caller the bitmask that shows
- which bits are high-impendance when reading port B, and thus
- neither 0 or 1. get_output_cb2_z() returns the same info
- for the CB2 pin.
- * set_port_a_z_mask allows the input callback to indicate
- which port A bits are disconnected. For these bits, the
- read operation will return the output buffer's contents.
- * The 'alt' interface functions are used when the A0 and A1
- address bits are swapped.
- * All 'int' data or return values are bool, and should be
- converted to bool at some point.
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __6821PIA_H__
-#define __6821PIA_H__
-
-#include "emu.h"
-
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-// TODO: REMOVE THESE
-#define MCFG_PIA_READPA_HANDLER(_devcb) \
- devcb = &pia6821_device::set_readpa_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_PIA_READPB_HANDLER(_devcb) \
- devcb = &pia6821_device::set_readpb_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_PIA_READCA1_HANDLER(_devcb) \
- devcb = &pia6821_device::set_readca1_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_PIA_READCA2_HANDLER(_devcb) \
- devcb = &pia6821_device::set_readca2_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_PIA_READCB1_HANDLER(_devcb) \
- devcb = &pia6821_device::set_readcb1_handler(*device, DEVCB_##_devcb);
-
-// TODO: CONVERT THESE TO WRITE LINE
-#define MCFG_PIA_WRITEPA_HANDLER(_devcb) \
- devcb = &pia6821_device::set_writepa_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_PIA_WRITEPB_HANDLER(_devcb) \
- devcb = &pia6821_device::set_writepb_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_PIA_CA2_HANDLER(_devcb) \
- devcb = &pia6821_device::set_ca2_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_PIA_CB2_HANDLER(_devcb) \
- devcb = &pia6821_device::set_cb2_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_PIA_IRQA_HANDLER(_devcb) \
- devcb = &pia6821_device::set_irqa_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_PIA_IRQB_HANDLER(_devcb) \
- devcb = &pia6821_device::set_irqb_handler(*device, DEVCB_##_devcb);
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-// ======================> pia6821_device
-
-class pia6821_device : public device_t
-{
-public:
- // construction/destruction
- pia6821_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- // TODO: REMOVE THESE
- template<class _Object> static devcb_base &set_readpa_handler(device_t &device, _Object object) { return downcast<pia6821_device &>(device).m_in_a_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_readpb_handler(device_t &device, _Object object) { return downcast<pia6821_device &>(device).m_in_b_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_readca1_handler(device_t &device, _Object object) { return downcast<pia6821_device &>(device).m_in_ca1_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_readca2_handler(device_t &device, _Object object) { return downcast<pia6821_device &>(device).m_in_ca2_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_readcb1_handler(device_t &device, _Object object) { return downcast<pia6821_device &>(device).m_in_cb1_handler.set_callback(object); }
-
- // TODO: CONVERT THESE TO WRITE LINE
- template<class _Object> static devcb_base &set_writepa_handler(device_t &device, _Object object) { return downcast<pia6821_device &>(device).m_out_a_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_writepb_handler(device_t &device, _Object object) { return downcast<pia6821_device &>(device).m_out_b_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_ca2_handler(device_t &device, _Object object) { return downcast<pia6821_device &>(device).m_ca2_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_cb2_handler(device_t &device, _Object object) { return downcast<pia6821_device &>(device).m_cb2_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_irqa_handler(device_t &device, _Object object) { return downcast<pia6821_device &>(device).m_irqa_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_irqb_handler(device_t &device, _Object object) { return downcast<pia6821_device &>(device).m_irqb_handler.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read ) { return reg_r(offset); }
- DECLARE_WRITE8_MEMBER( write ) { reg_w(offset, data); }
- DECLARE_READ8_MEMBER( read_alt ) { return reg_r(((offset << 1) & 0x02) | ((offset >> 1) & 0x01)); }
- DECLARE_WRITE8_MEMBER( write_alt ) { reg_w(((offset << 1) & 0x02) | ((offset >> 1) & 0x01), data); }
-
- UINT8 port_b_z_mask() const { return ~m_ddr_b; } // see first note in .c
- void set_port_a_z_mask(UINT8 data) { m_port_a_z_mask = data; }// see second note in .c
-
- DECLARE_WRITE8_MEMBER( porta_w ) { porta_w(data); }
- void porta_w(UINT8 data);
- void set_a_input(UINT8 data, UINT8 z_mask);
- UINT8 a_output();
-
- DECLARE_WRITE_LINE_MEMBER( ca1_w );
-
- DECLARE_WRITE_LINE_MEMBER( ca2_w );
- int ca2_output();
- int ca2_output_z();
-
- DECLARE_WRITE8_MEMBER( portb_w ) { portb_w(data); }
- void portb_w(UINT8 data);
- UINT8 b_output();
-
- DECLARE_WRITE_LINE_MEMBER( cb1_w );
-
- DECLARE_WRITE_LINE_MEMBER( cb2_w );
- int cb2_output();
- int cb2_output_z();
-
- int irq_a_state() const { return m_irq_a_state; }
- int irq_b_state() const { return m_irq_b_state; }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- UINT8 reg_r(UINT8 offset);
- void reg_w(UINT8 offset, UINT8 data);
-
- void update_interrupts();
-
- UINT8 get_in_a_value();
- UINT8 get_in_b_value();
-
- UINT8 get_out_a_value();
- UINT8 get_out_b_value();
-
- void set_out_ca2(int data);
- void set_out_cb2(int data);
-
- UINT8 port_a_r();
- UINT8 ddr_a_r();
- UINT8 control_a_r();
-
- UINT8 port_b_r();
- UINT8 ddr_b_r();
- UINT8 control_b_r();
-
- void send_to_out_a_func(const char* message);
- void send_to_out_b_func(const char* message);
-
- void port_a_w(UINT8 data);
- void ddr_a_w(UINT8 data);
-
- void port_b_w(UINT8 data);
- void ddr_b_w(UINT8 data);
-
- void control_a_w(UINT8 data);
- void control_b_w(UINT8 data);
-
- devcb_read8 m_in_a_handler;
- devcb_read8 m_in_b_handler;
- devcb_read_line m_in_ca1_handler;
- devcb_read_line m_in_cb1_handler;
- devcb_read_line m_in_ca2_handler;
- devcb_write8 m_out_a_handler;
- devcb_write8 m_out_b_handler;
- devcb_write_line m_ca2_handler;
- devcb_write_line m_cb2_handler;
- devcb_write_line m_irqa_handler;
- devcb_write_line m_irqb_handler;
-
- UINT8 m_in_a;
- UINT8 m_in_ca1;
- UINT8 m_in_ca2;
- UINT8 m_out_a;
- UINT8 m_out_ca2;
- UINT8 m_port_a_z_mask;
- UINT8 m_ddr_a;
- UINT8 m_ctl_a;
- UINT8 m_irq_a1;
- UINT8 m_irq_a2;
- UINT8 m_irq_a_state;
-
- UINT8 m_in_b;
- UINT8 m_in_cb1;
- UINT8 m_in_cb2;
- UINT8 m_out_b;
- UINT8 m_out_cb2;
- UINT8 m_last_out_cb2_z;
- UINT8 m_ddr_b;
- UINT8 m_ctl_b;
- UINT8 m_irq_b1;
- UINT8 m_irq_b2;
- UINT8 m_irq_b_state;
-
- // variables that indicate if access a line externally -
- // used to for logging purposes ONLY
- bool m_in_a_pushed;
- bool m_out_a_needs_pulled;
- bool m_in_ca1_pushed;
- bool m_in_ca2_pushed;
- bool m_out_ca2_needs_pulled;
- bool m_in_b_pushed;
- bool m_out_b_needs_pulled;
- bool m_in_cb1_pushed;
- bool m_in_cb2_pushed;
- bool m_out_cb2_needs_pulled;
- bool m_logged_port_a_not_connected;
- bool m_logged_port_b_not_connected;
- bool m_logged_ca1_not_connected;
- bool m_logged_ca2_not_connected;
- bool m_logged_cb1_not_connected;
- bool m_logged_cb2_not_connected;
-};
-
-
-// device type definition
-extern const device_type PIA6821;
-
-
-#endif /* __6821PIA_H__ */
diff --git a/src/emu/machine/68230pit.c b/src/emu/machine/68230pit.c
deleted file mode 100644
index 46c8733f085..00000000000
--- a/src/emu/machine/68230pit.c
+++ /dev/null
@@ -1,265 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Joakim Larsson Edstr??m
-/**********************************************************************
-*
-* Motorola MC68230 PI/T Parallell Interface and Timer
-*
-* Revisions
-* 2015-07-15 JLE initial
-*
-* Todo
-* - Add clock and timers
-* - Add all missing registers
-* - Add configuration
-**********************************************************************/
-
-#include "68230pit.h"
-
-#define LOG(x) /* x */
-
-//**************************************************************************
-// DEVICE TYPE DEFINITIONS
-//**************************************************************************
-
-const device_type PIT68230 = &device_creator<pit68230_device>;
-
-//-------------------------------------------------
-// pit68230_device - constructors
-//-------------------------------------------------
-pit68230_device::pit68230_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source)
- : device_t (mconfig, type, name, tag, owner, clock, shortname, source),
- device_execute_interface (mconfig, *this)
- , m_icount (0)
- , m_write_pa (*this)
- , m_write_h2 (*this)
-{
-}
-
-
-pit68230_device::pit68230_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t (mconfig, PIT68230, "PIT68230", tag, owner, clock, "pit68230", __FILE__),
- device_execute_interface (mconfig, *this)
- , m_icount (0)
- , m_write_pa (*this)
- , m_write_h2 (*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-void pit68230_device::device_start ()
-{
- LOG (logerror ("PIT68230 device started\n"));
- m_icountptr = &m_icount;
-
- // resolve callbacks
- m_write_pa.resolve_safe ();
- m_write_h2.resolve_safe ();
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-void pit68230_device::device_reset ()
-{
- LOG (logerror ("PIT68230 device reseted\n"));
- m_pgcr = 0;
- m_psrr = 0;
- m_paddr = 0;
- m_pbddr = 0;
- m_pcddr = 0;
- m_pacr = 0; m_write_h2 (m_pacr);
- m_pbcr = 0;
- m_padr = 0; m_write_pa ((offs_t)0, m_padr); // TODO: check PADDR
- m_pbdr = 0;
- m_psr = 0;
-}
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-void pit68230_device::device_timer (emu_timer &timer, device_timer_id id, INT32 param, void *ptr)
-{
-}
-
-void pit68230_device::h1_set (UINT8 state)
-{
- LOG (logerror ("h1_set %d @ m_psr %2x => ", state, m_psr));
- if (state) m_psr |= 1; else m_psr &= ~1;
- LOG (logerror ("%02x %lld\n", m_psr, machine ().firstcpu->total_cycles ()));
-}
-
-void pit68230_device::portb_setbit (UINT8 bit, UINT8 state)
-{
- LOG (logerror ("portb_setbit %d/%d @ m_pbdr %2x => ", bit, state, m_pbdr));
- if (state) m_pbdr |= (1 << bit); else m_pbdr &= ~(1 << bit);
- LOG (logerror ("%02x %lld\n", m_pbdr, machine ().firstcpu->total_cycles ()));
-}
-
-//-------------------------------------------------
-// execute_run -
-//-------------------------------------------------
-void pit68230_device::execute_run ()
-{
- do {
- synchronize ();
-
- m_icount--;
- } while (m_icount > 0);
-}
-
-LOG (static INT32 ow_cnt = 0);
-LOG (static INT32 ow_data = 0);
-LOG (static INT32 ow_ofs = 0);
-
-WRITE8_MEMBER (pit68230_device::write){
- switch (offset) {
- case PIT_68230_PGCR:
- m_pgcr = data;
- break;
-
- case PIT_68230_PSRR:
- m_psrr = data;
- break;
-
- case PIT_68230_PADDR:
- m_paddr = data;
- break;
-
- case PIT_68230_PBDDR:
- m_pbddr = data;
- break;
-
- case PIT_68230_PCDDR:
- m_pcddr = data;
- break;
-
- case PIT_68230_PACR:
- m_pacr = data;
- // callbacks
- /*PACR in Mode 0
- * 5 43 H2 Control in Submode 00 && 01
- * ------------------------------------
- * 0 XX Input pin - edge-sensitive status input, H2S is set on an asserted edge.
- * 1 00 Output pin - negated, H2S is always clear.
- * 1 01 Output pin - asserted, H2S is always clear.
- * 1 10 Output pin - interlocked input handshake protocol, H2S is always clear.
- * 1 11 Output pin - pulsed input handshake protocol, H2S is always clear.
- *
- * 5 43 H2 Control in Submode 1x
- * ------------------------------------
- * 0 XX Input pin - edge-sensitive status input, H2S is set on an asserted edge.
- * 1 X0 Output pin - negated, H2S is always cleared.
- * 1 X1 Output pin - asserted, H2S is always cleared.
- */
- m_write_h2 (m_pacr & 0x08 ? 1 : 0); // TODO: Check mode and submodes
- break;
-
- case PIT_68230_PBCR:
- m_pbcr = data;
- break;
-
- case PIT_68230_PADR:
- m_padr = data;
- // callbacks
- m_write_pa ((offs_t)0, m_padr); // TODO: check PADDR
- break;
-
- case PIT_68230_PSR:
- m_psr = data;
- break;
-
- default:
- LOG (logerror ("unhandled register %02x", offset));
- }
-
- LOG (if (offset != ow_ofs || data != ow_data || ow_cnt >= 1000) {
- logerror ("\npit68230_device::write: previous identical operation performed %02x times\n", ow_cnt);
- ow_cnt = 0;
- ow_data = data;
- ow_ofs = offset;
- logerror ("pit68230_device::write: offset=%02x data=%02x %lld\n", ow_ofs, ow_data, machine ().firstcpu->total_cycles ());
- }
- else
- ow_cnt++; )
-}
-
-LOG (static INT32 or_cnt = 0);
-LOG (static INT32 or_data = 0);
-LOG (static INT32 or_ofs = 0);
-
-READ8_MEMBER (pit68230_device::read){
- UINT8 data = 0;
-
- switch (offset) {
- case PIT_68230_PGCR:
- data = m_pgcr;
- break;
-
- case PIT_68230_PSRR:
- data = m_psrr;
- break;
-
- case PIT_68230_PADDR:
- data = m_paddr;
- break;
-
- case PIT_68230_PBDDR:
- data = m_pbddr;
- break;
-
- case PIT_68230_PCDDR:
- data = m_pcddr;
- break;
-
- case PIT_68230_PACR:
- data = m_pacr;
- break;
-
- case PIT_68230_PBCR:
- data = m_pbcr;
- break;
-
- case PIT_68230_PADR:
- data = m_padr;
- break;
-
- case PIT_68230_PBDR:
- /* 4.6.2. PORT B DATA REGISTER (PBDR). The port B data register is a holding
- * register for moving data to and from port B pins. The port B data direction
- * register determines whether each pin is an input (zero) or an output (one).
- * This register is readable and writable at all times. Depending on the chosen
- * mode/submode, reading or writing may affect the double-buffered handshake
- * mechanism. The port B data register is not affected by the assertion of the
- * RESET pin. PB0-PB7 sits on pins 17-24 on a 48 pin DIP package */
- data = m_pbdr;
- break;
-
- case PIT_68230_PSR:
- /* 4.8. PORT STATUS REGISTER (PSR) The port status register contains information about
- * handshake pin activity. Bits 7-4 show the instantaneous level of the respective handshake
- * pin, and are independent of the handshake pin sense bits in the port general control
- * register. Bits 3-0 are the respective status bits referred to throughout this document.
- * Their interpretation depends on the programmed mode/submode of the PI/T. For bits
- * 3-0 a one is the active or asserted state. */
- data = m_psr;
- break;
-
- default:
- LOG (logerror ("unhandled register %02x", offset));
- data = 0;
- }
-
- LOG (if (offset != or_ofs || data != or_data || or_cnt >= 1000) {
- logerror ("\npit68230_device::read: previous identical operation performed %02x times\n", or_cnt);
- or_cnt = 0;
- or_data = data;
- or_ofs = offset;
- logerror ("pit68230_device::read: offset=%02x data=%02x %lld\n", or_ofs, or_data, machine ().firstcpu->total_cycles ());
- }
- else
- or_cnt++; )
-
- return data;
-}
diff --git a/src/emu/machine/68230pit.h b/src/emu/machine/68230pit.h
deleted file mode 100644
index b32cb25e928..00000000000
--- a/src/emu/machine/68230pit.h
+++ /dev/null
@@ -1,131 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Joakim Larsson Edstr??m
-/**********************************************************************
-*
-* Motorola MC68230 PI/T Parallell Interface and Timer
-*
-* _____ _____
-* D5 1 |* \_/ | 48 D4
-* D6 2 | | 47 D3
-* D7 3 | | 46 D2
-* PA0 4 | | 45 D1
-* PA1 5 | | 44 D0
-* PA2 6 | | 43 R/W*
-* PA3 7 | | 42 DTACK*
-* PA4 8 | | 41 CS*
-* PA5 9 | | 40 CLK
-* PA6 10 | | 39 RESET*
-* PA7 11 | | 38 VSS
-* Vcc 12 | TS68230 | 37 PC7/TIACK*
-* H1 13 | SC87845 | 36 PC6/PIACK*
-* H2 14 | | 35 PC5/PIRQ*
-* H3 15 | | 34 PC4/DMAREQ*
-* H4 16 | | 33 PC3/TOUT
-* PB0 17 | | 32 PC2/TIN
-* PB1 18 | | 31 PC1
-* PB2 19 | | 30 PC0
-* PB3 20 | | 29 RS1
-* PB4 21 | | 28 RS2
-* PB5 22 | | 27 RS3
-* PB6 23 | | 26 RS4
-* PB7 24 |_____________| 25 RS5
-*
-**********************************************************************/
-
-#pragma once
-
-#ifndef __68230PIT_H__
-#define __68230PIT_H__
-
-#include "emu.h"
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_PIT68230_PA_OUTPUT_CALLBACK(_write) \
- devcb = &pit68230_device::set_pa_wr_callback (*device, DEVCB_ ## _write);
-
-#define MCFG_PIT68230_PB_OUTPUT_CALLBACK(_write) \
- devcb = &pit68230_device::set_pb_wr_callback (*device, DEVCB_ ## _write);
-
-#define MCFG_PIT68230_H2_CALLBACK(_write) \
- devcb = &pit68230_device::set_h2_wr_callback (*device, DEVCB_ ## _write);
-
-/*-----------------------------------------------------------------------
- * Registers RS1-RS5 R/W Description
- * -------------------------------------------------------------------------*/
-#define PIT_68230_PGCR 0x00 /* RW Port General Control register */
-#define PIT_68230_PSRR 0x01 /* RW Port Service Request register */
-#define PIT_68230_PADDR 0x02 /* RW Port A Data Direction register */
-#define PIT_68230_PBDDR 0x03 /* RW Port B Data Direction register */
-#define PIT_68230_PCDDR 0x04 /* RW Port C Data Direction register */
-#define PIT_68230_PIVR 0x05 /* RW Port Interrupt vector register */
-#define PIT_68230_PACR 0x06 /* RW Port A Control register */
-#define PIT_68230_PBCR 0x07 /* RW Port B Control register */
-#define PIT_68230_PADR 0x08 /* RW Port A Data register */
-#define PIT_68230_PBDR 0x09 /* RW Port B Data register */
-#define PIT_68230_PAAR 0x0a /* RO Port A Alternate register */
-#define PIT_68230_PBAR 0x0b /* RO Port B Alternate register */
-#define PIT_68230_PCDR 0x0c /* RW Port C Data register */
-#define PIT_68230_PSR 0x0d /* RW Port Status register */
-#define PIT_68230_TCR 0x10 /* RW Timer Control Register */
-#define PIT_68230_TIVR 0x11 /* RW Timer Interrupt Vector Register */
-#define PIT_68230_CPRH 0x13 /* RW Counter Preload Register High */
-#define PIT_68230_CPRM 0x14 /* RW Counter Preload Register Middle */
-#define PIT_68230_CPRL 0x15 /* RW Counter Preload Register Low */
-#define PIT_68230_CNTRH 0x17 /* RO Counter Register High */
-#define PIT_68230_CNTRM 0x18 /* RO Counter Register Middle */
-#define PIT_68230_CNTRL 0x19 /* RO Counter Register Low */
-#define PIT_68230_TSR 0x1A /* RW Timer Status Register */
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-class pit68230_device : public device_t, public device_execute_interface
-{
-public:
-// construction/destruction
-pit68230_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source);
-pit68230_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-template<class _Object> static devcb_base &set_pa_wr_callback (device_t &device, _Object object)
-{
- return downcast<pit68230_device &>(device).m_write_pa.set_callback (object);
-}
-template<class _Object> static devcb_base &set_h2_wr_callback (device_t &device, _Object object)
-{
- return downcast<pit68230_device &>(device).m_write_h2.set_callback (object);
-}
-
-DECLARE_WRITE8_MEMBER (write);
-DECLARE_READ8_MEMBER (read);
-
-void h1_set (UINT8 state);
-void portb_setbit (UINT8 bit, UINT8 state);
-
-protected:
-// device-level overrides
-virtual void device_start ();
-virtual void device_reset ();
-virtual void device_timer (emu_timer &timer, device_timer_id id, int param, void *ptr);
-virtual void execute_run ();
-int m_icount;
-devcb_write8 m_write_pa;
-devcb_write_line m_write_h2;
-
-// peripheral ports
-UINT8 m_pgcr; // Port General Control register
-UINT8 m_psrr; // Port Service Request register
-UINT8 m_paddr; // Port A Data Direction register
-UINT8 m_pbddr; // Port B Data Direction register
-UINT8 m_pcddr; // Port C Data Direction register
-UINT8 m_pacr; // Port A Control register
-UINT8 m_pbcr; // Port B Control register
-UINT8 m_padr; // Port A Data register
-UINT8 m_pbdr; // Port B Data register
-UINT8 m_psr; // Port Status Register
-};
-
-// device type definition
-extern const device_type PIT68230;
-#endif /* __68230PIT_H__ */
diff --git a/src/emu/machine/68307.c b/src/emu/machine/68307.c
deleted file mode 100644
index 320c701acc7..00000000000
--- a/src/emu/machine/68307.c
+++ /dev/null
@@ -1,352 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* 68307 */
-
-#include "68307.h"
-
-/* 68307 SERIAL Module */
-/* all ports on this are 8-bit? */
-
-/* this is a 68681 'compatible' chip but with only a single channel implemented
- (writes to the other channel have no effects)
-
- for now at least we piggyback on the existing 68307 emulation rather than having
- a custom verson here, that may change later if subtle differences exist.
-
-*/
-READ8_MEMBER( m68307cpu_device::m68307_internal_serial_r )
-{
- m68307cpu_device *m68k = this;
-
- if (offset&1) return m_duart->read(*m68k->program, offset>>1);
- return 0x0000;
-}
-
-WRITE8_MEMBER(m68307cpu_device::m68307_internal_serial_w)
-{
- m68307cpu_device *m68k = this;
-
- if (offset & 1) m_duart->write(*m68k->program, offset >> 1, data);
-}
-
-
-
-static ADDRESS_MAP_START( m68307_internal_map, AS_PROGRAM, 16, m68307cpu_device )
- AM_RANGE(0x000000f0, 0x000000ff) AM_READWRITE(m68307_internal_base_r, m68307_internal_base_w)
-ADDRESS_MAP_END
-
-
-
-static MACHINE_CONFIG_FRAGMENT( 68307fragment )
- MCFG_MC68681_ADD("internal68681", 16000000/4) // ?? Mhz - should be specified in inline config
- MCFG_MC68681_IRQ_CALLBACK(WRITELINE(m68307cpu_device, m68307_duart_irq_handler))
- MCFG_MC68681_A_TX_CALLBACK(WRITELINE(m68307cpu_device, m68307_duart_txa))
- MCFG_MC68681_B_TX_CALLBACK(WRITELINE(m68307cpu_device, m68307_duart_txb))
- MCFG_MC68681_INPORT_CALLBACK(READ8(m68307cpu_device, m68307_duart_input_r))
- MCFG_MC68681_OUTPORT_CALLBACK(WRITE8(m68307cpu_device, m68307_duart_output_w))
-MACHINE_CONFIG_END
-
-machine_config_constructor m68307cpu_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( 68307fragment );
-}
-
-
-m68307cpu_device::m68307cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : m68000_device(mconfig, "MC68307", tag, owner, clock, M68307, 16,24, ADDRESS_MAP_NAME(m68307_internal_map), "mc68307", __FILE__),
- write_irq(*this),
- write_a_tx(*this),
- write_b_tx(*this),
- read_inport(*this),
- write_outport(*this),
- m_duart(*this, "internal68681")
-{
- m68307SIM = 0;
- m68307MBUS = 0;
- m68307TIMER = 0;
- m68307_base = 0;
- m68307_scrhigh = 0;
- m68307_scrlow = 0;
- m68307_currentcs = 0;
-}
-
-
-
-
-
-
-void m68307cpu_device::device_reset()
-{
- m68000_device::device_reset();
-
- if (m68307SIM) m68307SIM->reset();
- if (m68307MBUS) m68307MBUS->reset();
- if (m68307TIMER) m68307TIMER->reset();
-
- m68307_base = 0xbfff;
- m68307_scrhigh = 0x0007;
- m68307_scrlow = 0xf010;
-
-}
-
-
-/* todo: is it possible to calculate the address map based on CS when they change
- and install handlers? Going through this logic for every memory access is
- very slow */
-
-int m68307_calc_cs(m68307cpu_device *m68k, offs_t address)
-{
- m68307_sim* sim = m68k->m68307SIM;
-
- for (int i=0;i<4;i++)
- {
- int br,amask,bra;
- br = sim->m_br[i] & 1;
- amask = ((sim->m_or[i]&0x1ffc)<<11);
- bra = ((sim->m_br[i] & 0x1ffc)<<11);
- if ((br) && ((address & amask) == bra)) return i+1;
- }
- return 0;
-}
-
-
-
-UINT16 m68307cpu_device::simple_read_immediate_16_m68307(offs_t address)
-{
-// m68307_currentcs = m68307_calc_cs(this, address);
- return m_direct->read_word(address);
-}
-
-UINT8 m68307cpu_device::read_byte_m68307(offs_t address)
-{
-// m68307_currentcs = m68307_calc_cs(this, address);
- return m_space->read_byte(address);
-}
-
-UINT16 m68307cpu_device::read_word_m68307(offs_t address)
-{
-// m68307_currentcs = m68307_calc_cs(this, address);
- return m_space->read_word(address);
-}
-
-UINT32 m68307cpu_device::read_dword_m68307(offs_t address)
-{
-// m68307_currentcs = m68307_calc_cs(this, address);
- return m_space->read_dword(address);
-}
-
-void m68307cpu_device::write_byte_m68307(offs_t address, UINT8 data)
-{
-// m68307_currentcs = m68307_calc_cs(this, address);
- m_space->write_byte(address, data);
-}
-
-void m68307cpu_device::write_word_m68307(offs_t address, UINT16 data)
-{
-// m68307_currentcs = m68307_calc_cs(this, address);
- m_space->write_word(address, data);
-}
-
-void m68307cpu_device::write_dword_m68307(offs_t address, UINT32 data)
-{
-// m68307_currentcs = m68307_calc_cs(this, address);
- m_space->write_dword(address, data);
-}
-
-
-
-
-void m68307cpu_device::init16_m68307(address_space &space)
-{
- m_space = &space;
- m_direct = &space.direct();
- opcode_xor = 0;
-
- readimm16 = m68k_readimm16_delegate(FUNC(m68307cpu_device::simple_read_immediate_16_m68307), this);
- read8 = m68k_read8_delegate(FUNC(m68307cpu_device::read_byte_m68307), this);
- read16 = m68k_read16_delegate(FUNC(m68307cpu_device::read_word_m68307), this);
- read32 = m68k_read32_delegate(FUNC(m68307cpu_device::read_dword_m68307), this);
- write8 = m68k_write8_delegate(FUNC(m68307cpu_device::write_byte_m68307), this);
- write16 = m68k_write16_delegate(FUNC(m68307cpu_device::write_word_m68307), this);
- write32 = m68k_write32_delegate(FUNC(m68307cpu_device::write_dword_m68307), this);
-}
-
-
-
-void m68307cpu_device::set_port_callbacks(m68307_porta_read_delegate porta_r, m68307_porta_write_delegate porta_w, m68307_portb_read_delegate portb_r, m68307_portb_write_delegate portb_w)
-{
- m_m68307_porta_r = porta_r;
- m_m68307_porta_w = porta_w;
- m_m68307_portb_r = portb_r;
- m_m68307_portb_w = portb_w;
-}
-
-
-
-
-
-UINT16 m68307cpu_device::get_cs(offs_t address)
-{
- m68307_currentcs = m68307_calc_cs(this, address);
-
- return m68307_currentcs;
-}
-
-
-/* 68307 specifics - MOVE */
-
-void m68307cpu_device::set_interrupt(int level, int vector)
-{
- set_input_line_and_vector(level, HOLD_LINE, vector);
-}
-
-void m68307cpu_device::timer0_interrupt()
-{
- int prioritylevel = (m68307SIM->m_picr & 0x7000)>>12;
- int vector = (m68307SIM->m_pivr & 0x00f0) | 0xa;
- set_interrupt(prioritylevel, vector);
-}
-
-void m68307cpu_device::timer1_interrupt()
-{
- int prioritylevel = (m68307SIM->m_picr & 0x0700)>>8;
- int vector = (m68307SIM->m_pivr & 0x00f0) | 0xb;
- set_interrupt(prioritylevel, vector);
-}
-
-
-void m68307cpu_device::serial_interrupt(int vector)
-{
- int prioritylevel = (m68307SIM->m_picr & 0x0070)>>4;
- set_interrupt(prioritylevel, vector);
-}
-
-WRITE_LINE_MEMBER(m68307cpu_device::m68307_duart_irq_handler)
-{
- if (state == ASSERT_LINE)
- {
- serial_interrupt(m_duart->get_irq_vector());
- }
-}
-
-void m68307cpu_device::mbus_interrupt()
-{
- int prioritylevel = (m68307SIM->m_picr & 0x0007)>>0;
- int vector = (m68307SIM->m_pivr & 0x00f0) | 0xd;
- set_interrupt(prioritylevel, vector);
-}
-
-void m68307cpu_device::licr2_interrupt()
-{
- int prioritylevel = (m68307SIM->m_licr2 & 0x0007)>>0;
- int vector = (m68307SIM->m_pivr & 0x00f0) | 0x9;
- m68307SIM->m_licr2 |= 0x8;
-
-
- set_interrupt(prioritylevel, vector);
-}
-
-void m68307cpu_device::device_start()
-{
- init_cpu_m68000();
-
- /* basic CS logic, timers, mbus, serial logic
- set via remappable register
- */
-
- init16_m68307(*program);
-
- m68307SIM = new m68307_sim();
- m68307MBUS = new m68307_mbus();
- m68307TIMER = new m68307_timer();
-
- m68307TIMER->init(this);
-
- m68307SIM->reset();
- m68307MBUS->reset();
- m68307TIMER->reset();
-
- internal = &this->space(AS_PROGRAM);
- m68307_base = 0xbfff;
- m68307_scrhigh = 0x0007;
- m68307_scrlow = 0xf010;
-
- write_irq.resolve_safe();
- write_a_tx.resolve_safe();
- write_b_tx.resolve_safe();
- read_inport.resolve();
- write_outport.resolve_safe();
-
- set_port_callbacks(m68307_porta_read_delegate(),m68307_porta_write_delegate(),m68307_portb_read_delegate(),m68307_portb_write_delegate());
-}
-
-
-
-READ16_MEMBER( m68307cpu_device::m68307_internal_base_r )
-{
- m68307cpu_device *m68k = this;
-
- int pc = space.device().safe_pc();
- logerror("%08x m68307_internal_base_r %08x, (%04x)\n", pc, offset*2,mem_mask);
-
- switch (offset<<1)
- {
- case 0x2: return m68k->m68307_base;
- case 0x4: return m68k->m68307_scrhigh;
- case 0x6: return m68k->m68307_scrlow;
- }
-
- logerror("(read was illegal?)\n");
-
- return 0x0000;
-}
-
-WRITE16_MEMBER( m68307cpu_device::m68307_internal_base_w )
-{
- m68307cpu_device *m68k = this;
-
- int pc = space.device().safe_pc();
- logerror("%08x m68307_internal_base_w %08x, %04x (%04x)\n", pc, offset*2,data,mem_mask);
- int base = 0;
- //int mask = 0;
-
- switch (offset<<1)
- {
- case 0x2:
- /* remove old internal handler */
- base = (m68k->m68307_base & 0x0fff) << 12;
- //mask = (m68k->m68307_base & 0xe000) >> 13;
- //if ( m68k->m68307_base & 0x1000 ) mask |= 7;
- m68k->internal->unmap_readwrite(base+0x000, base+0x04f);
- m68k->internal->unmap_readwrite(base+0x100, base+0x11f);
- m68k->internal->unmap_readwrite(base+0x120, base+0x13f);
- m68k->internal->unmap_readwrite(base+0x140, base+0x149);
-
- /* store new base address */
- COMBINE_DATA(&m68k->m68307_base);
-
- /* install new internal handler */
- base = (m68k->m68307_base & 0x0fff) << 12;
- //mask = (m68k->m68307_base & 0xe000) >> 13;
- //if ( m68k->m68307_base & 0x1000 ) mask |= 7;
- m68k->internal->install_readwrite_handler(base + 0x000, base + 0x04f, read16_delegate(FUNC(m68307cpu_device::m68307_internal_sim_r),this), write16_delegate(FUNC(m68307cpu_device::m68307_internal_sim_w),this));
- m68k->internal->install_readwrite_handler(base + 0x100, base + 0x11f, read8_delegate(FUNC(m68307cpu_device::m68307_internal_serial_r),this), write8_delegate(FUNC(m68307cpu_device::m68307_internal_serial_w),this), 0xffff);
- m68k->internal->install_readwrite_handler(base + 0x120, base + 0x13f, read16_delegate(FUNC(m68307cpu_device::m68307_internal_timer_r),this), write16_delegate(FUNC(m68307cpu_device::m68307_internal_timer_w),this));
- m68k->internal->install_readwrite_handler(base + 0x140, base + 0x149, read8_delegate(FUNC(m68307cpu_device::m68307_internal_mbus_r),this), write8_delegate(FUNC(m68307cpu_device::m68307_internal_mbus_w),this), 0xffff);
-
-
- break;
-
- case 0x4:
- COMBINE_DATA(&m68k->m68307_scrhigh);
- break;
-
- case 0x6:
- COMBINE_DATA(&m68k->m68307_scrlow);
- break;
-
- default:
- logerror("(write was illegal?)\n");
- break;
- }
-}
diff --git a/src/emu/machine/68307.h b/src/emu/machine/68307.h
deleted file mode 100644
index 57b09b639ca..00000000000
--- a/src/emu/machine/68307.h
+++ /dev/null
@@ -1,132 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* 68307 */
-
-
-#pragma once
-#ifndef __M68307_H__
-#define __M68307_H__
-
-#include "emu.h"
-#include "cpu/m68000/m68000.h"
-
-#include "68307sim.h"
-#include "68307bus.h"
-#include "68307tmu.h"
-#include "machine/mc68681.h"
-
-
-typedef device_delegate<UINT8 (address_space &space, bool dedicated, UINT8 line_mask)> m68307_porta_read_delegate;
-typedef device_delegate<void (address_space &space, bool dedicated, UINT8 data, UINT8 line_mask)> m68307_porta_write_delegate;
-typedef device_delegate<UINT16 (address_space &space, bool dedicated, UINT16 line_mask)> m68307_portb_read_delegate;
-typedef device_delegate<void (address_space &space, bool dedicated, UINT16 data, UINT16 line_mask)> m68307_portb_write_delegate;
-
-
-/* trampolines so we can specify the 68681 serial configuration when adding the CPU */
-#define MCFG_MC68307_SERIAL_A_TX_CALLBACK(_cb) \
- devcb = &m68307cpu_device::set_a_tx_cb(*device, DEVCB_##_cb);
-
-#define MCFG_MC68307_SERIAL_B_TX_CALLBACK(_cb) \
- devcb = &m68307cpu_device::set_b_tx_cb(*device, DEVCB_##_cb);
-
-// deprecated: use ipX_w() instead
-#define MCFG_MC68307_SERIAL_INPORT_CALLBACK(_cb) \
- devcb = &m68307cpu_device::set_inport_cb(*device, DEVCB_##_cb);
-
-#define MCFG_MC68307_SERIAL_OUTPORT_CALLBACK(_cb) \
- devcb = &m68307cpu_device::set_outport_cb(*device, DEVCB_##_cb);
-
-
-class m68307cpu_device : public m68000_device {
-public:
- m68307cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- /* trampolines so we can specify the 68681 serial configuration when adding the CPU */
- template<class _Object> static devcb_base &set_irq_cb(device_t &device, _Object object) { return downcast<m68307cpu_device &>(device).write_irq.set_callback(object); }
- template<class _Object> static devcb_base &set_a_tx_cb(device_t &device, _Object object) { return downcast<m68307cpu_device &>(device).write_a_tx.set_callback(object); }
- template<class _Object> static devcb_base &set_b_tx_cb(device_t &device, _Object object) { return downcast<m68307cpu_device &>(device).write_b_tx.set_callback(object); }
- template<class _Object> static devcb_base &set_inport_cb(device_t &device, _Object object) { return downcast<m68307cpu_device &>(device).read_inport.set_callback(object); }
- template<class _Object> static devcb_base &set_outport_cb(device_t &device, _Object object) { return downcast<m68307cpu_device &>(device).write_outport.set_callback(object); }
-
- DECLARE_WRITE_LINE_MEMBER(m68307_duart_irq_handler);
- DECLARE_WRITE_LINE_MEMBER(m68307_duart_txa){ write_a_tx(state); }
- DECLARE_WRITE_LINE_MEMBER(m68307_duart_txb){ write_b_tx(state); }
- DECLARE_READ8_MEMBER(m68307_duart_input_r){ return read_inport(); }
- DECLARE_WRITE8_MEMBER(m68307_duart_output_w){ write_outport(data); }
- devcb_write_line write_irq, write_a_tx, write_b_tx;
- devcb_read8 read_inport;
- devcb_write8 write_outport;
-
- UINT16 simple_read_immediate_16_m68307(offs_t address);
-
-
- UINT8 read_byte_m68307(offs_t address);
- UINT16 read_word_m68307(offs_t address);
- UINT32 read_dword_m68307(offs_t address);
- void write_byte_m68307(offs_t address, UINT8 data);
- void write_word_m68307(offs_t address, UINT16 data);
- void write_dword_m68307(offs_t address, UINT32 data);
-
-
- /* 68307 peripheral modules */
- m68307_sim* m68307SIM;
- m68307_mbus* m68307MBUS;
-// m68307_serial* m68307SERIAL;
- m68307_timer* m68307TIMER;
-
- UINT16 m68307_base;
- UINT16 m68307_scrhigh;
- UINT16 m68307_scrlow;
-
- int m68307_currentcs;
-
-
- DECLARE_READ16_MEMBER( m68307_internal_base_r );
- DECLARE_WRITE16_MEMBER( m68307_internal_base_w );
- DECLARE_READ16_MEMBER( m68307_internal_timer_r );
- DECLARE_WRITE16_MEMBER( m68307_internal_timer_w );
- DECLARE_READ16_MEMBER( m68307_internal_sim_r );
- DECLARE_WRITE16_MEMBER( m68307_internal_sim_w );
- DECLARE_READ8_MEMBER( m68307_internal_serial_r );
- DECLARE_WRITE8_MEMBER( m68307_internal_serial_w );
- DECLARE_READ8_MEMBER( m68307_internal_mbus_r );
- DECLARE_WRITE8_MEMBER( m68307_internal_mbus_w );
-
-
- /* callbacks for internal ports */
- void set_port_callbacks(m68307_porta_read_delegate porta_r, m68307_porta_write_delegate porta_w, m68307_portb_read_delegate portb_r, m68307_portb_write_delegate portb_w);
- void set_interrupt(int level, int vector);
- UINT16 get_cs(offs_t address);
- void timer0_interrupt();
- void timer1_interrupt();
- void serial_interrupt(int vector);
- void mbus_interrupt();
- void licr2_interrupt();
-
- m68307_porta_read_delegate m_m68307_porta_r;
- m68307_porta_write_delegate m_m68307_porta_w;
- m68307_portb_read_delegate m_m68307_portb_r;
- m68307_portb_write_delegate m_m68307_portb_w;
-
- void init16_m68307(address_space &space);
- void init_cpu_m68307(void);
-
- virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
- virtual UINT32 disasm_max_opcode_bytes() const { return 10; };
-
- virtual UINT32 execute_min_cycles() const { return 4; };
- virtual UINT32 execute_max_cycles() const { return 158; };
-
- required_device<mc68681_device> m_duart;
-protected:
- virtual machine_config_constructor device_mconfig_additions() const;
- virtual void device_start();
- virtual void device_reset();
-
-private:
-};
-
-static const device_type M68307 = &device_creator<m68307cpu_device>;
-
-
-#endif
diff --git a/src/emu/machine/68307bus.c b/src/emu/machine/68307bus.c
deleted file mode 100644
index c9af37df775..00000000000
--- a/src/emu/machine/68307bus.c
+++ /dev/null
@@ -1,112 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* 68307 MBUS module */
-/* all ports on this are 8-bit? */
-
-#include "emu.h"
-#include "68307.h"
-
-
-READ8_MEMBER( m68307cpu_device::m68307_internal_mbus_r )
-{
- m68307cpu_device *m68k = this;
- m68307_mbus* mbus = m68k->m68307MBUS;
- assert(mbus != NULL);
- UINT8 retval;
-
- if (mbus)
- {
- int pc = space.device().safe_pc();
-
-
- switch (offset)
- {
- case m68307BUS_MADR:
- logerror("%08x m68307_internal_mbus_r %08x (MADR - M-Bus Address Register)\n", pc, offset);
- return space.machine().rand();
-
- case m68307BUS_MFDR:
- logerror("%08x m68307_internal_mbus_r %08x (MFDR - M-Bus Frequency Divider Register)\n", pc, offset);
- return space.machine().rand();
-
- case m68307BUS_MBCR:
- logerror("%08x m68307_internal_mbus_r %08x (MFCR - M-Bus Control Register)\n", pc, offset);
- return mbus->m_MFCR;//space.machine().rand();
-
- case m68307BUS_MBSR:
- logerror("%08x m68307_internal_mbus_r %08x (MBSR - M-Bus Status Register)\n", pc, offset);
- retval = 0;
- if (mbus->m_busy) retval |= 0x20;
- if (mbus->m_intpend) retval |= 0x02;
-
- return retval;
-
- case m68307BUS_MBDR:
- logerror("%08x m68307_internal_mbus_r %08x (MBDR - M-Bus Data I/O Register)\n", pc, offset);
- mbus->m_intpend = true;
- return 0xff;//space.machine().rand();
-
- default:
- logerror("%08x m68307_internal_mbus_r %08x (UNKNOWN / ILLEGAL)\n", pc, offset);
- return 0x00;
- }
- }
-
- return 0xff;
-}
-
-WRITE8_MEMBER( m68307cpu_device::m68307_internal_mbus_w )
-{
- m68307cpu_device *m68k = this;
- m68307_mbus* mbus = m68k->m68307MBUS;
- assert(mbus != NULL);
-
- if (mbus)
- {
- int pc = space.device().safe_pc();
-
- switch (offset)
- {
- case m68307BUS_MADR:
- logerror("%08x m68307_internal_mbus_w %08x, %02x (MADR - M-Bus Address Register)\n", pc, offset,data);
- break;
-
- case m68307BUS_MFDR:
- logerror("%08x m68307_internal_mbus_w %08x, %02x (MFDR - M-Bus Frequency Divider Register)\n", pc, offset,data);
- break;
-
- case m68307BUS_MBCR:
- logerror("%08x m68307_internal_mbus_w %08x, %02x (MFCR - M-Bus Control Register)\n", pc, offset,data);
-
- mbus->m_MFCR = data;
- if (data & 0x80)
- {
- mbus->m_busy = false;
- mbus->m_intpend = false;
- }
- if (data & 0x20) mbus->m_busy = true;
-
- break;
-
- case m68307BUS_MBSR:
- logerror("%08x m68307_internal_mbus_w %08x, %02x (MBSR - M-Bus Status Register)\n", pc, offset,data);
- break;
-
- case m68307BUS_MBDR:
- logerror("%08x m68307_internal_mbus_w %08x, %02x (MBDR - M-Bus Data I/O Register)\n", pc, offset,data);
-
- mbus->m_intpend = true;
-
- break;
-
- default:
- logerror("%08x m68307_internal_mbus_w %08x, %02x (UNKNOWN / ILLEGAL)\n", pc, offset,data);
- break;
- }
- }
-}
-
-void m68307_mbus::reset(void)
-{
- m_busy = false;
-}
diff --git a/src/emu/machine/68307bus.h b/src/emu/machine/68307bus.h
deleted file mode 100644
index 5131ad4c9c5..00000000000
--- a/src/emu/machine/68307bus.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-#include "cpu/m68000/m68000.h"
-
-#define m68307BUS_MADR (0x01)
-#define m68307BUS_MFDR (0x03)
-#define m68307BUS_MBCR (0x05)
-#define m68307BUS_MBSR (0x07)
-#define m68307BUS_MBDR (0x09)
-
-
-class m68307_mbus
-{
- public:
-
- UINT16 m_MFCR;
-
- bool m_busy;
- bool m_intpend;
-
- void reset(void);
-};
diff --git a/src/emu/machine/68307sim.c b/src/emu/machine/68307sim.c
deleted file mode 100644
index 3709c346fbf..00000000000
--- a/src/emu/machine/68307sim.c
+++ /dev/null
@@ -1,314 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* 68307 SIM module */
-
-#include "emu.h"
-#include "68307.h"
-
-
-READ16_MEMBER( m68307cpu_device::m68307_internal_sim_r )
-{
- m68307cpu_device *m68k = this;
- m68307_sim* sim = m68k->m68307SIM;
- assert(sim != NULL);
-
- int pc = space.device().safe_pc();
-
- if (sim)
- {
- switch (offset<<1)
- {
- case m68307SIM_PADAT: return sim->read_padat(this, space, mem_mask);
- case m68307SIM_PBDAT: return sim->read_pbdat(this, space, mem_mask);
-
- case m68307SIM_LICR2: return (sim->m_licr2);
-
- case m68307SIM_BR0: return (sim->m_br[0]);
- case m68307SIM_OR0: return (sim->m_or[0]);
- case m68307SIM_BR1: return (sim->m_br[1]);
- case m68307SIM_OR1: return (sim->m_or[1]);
- case m68307SIM_BR2: return (sim->m_br[2]);
- case m68307SIM_OR2: return (sim->m_or[2]);
- case m68307SIM_BR3: return (sim->m_br[3]);
- case m68307SIM_OR3: return (sim->m_or[3]);
-
- default:
- logerror("%08x m68307_internal_sim_r %08x, (%04x)\n", pc, offset*2,mem_mask);
- return 0xff;
-
- }
- }
-
- return 0x0000;
-}
-
-
-WRITE16_MEMBER( m68307cpu_device::m68307_internal_sim_w )
-{
- m68307cpu_device *m68k = this;
- m68307_sim* sim = m68k->m68307SIM;
- assert(sim != NULL);
-
- int pc = space.device().safe_pc();
-
- if (sim)
- {
- switch (offset<<1)
- {
- case m68307SIM_PACNT:
- logerror("%08x m68307_internal_sim_w %08x, %04x (%04x) (Port A (8-bit) Control Register - PACNT)\n", pc, offset*2,data,mem_mask);
- sim->write_pacnt(data,mem_mask);
- break;
-
- case m68307SIM_PADDR:
- logerror("%08x m68307_internal_sim_w %08x, %04x (%04x) (Port A (8-bit) Direction Register - PADDR)\n", pc, offset*2,data,mem_mask);
- sim->write_paddr(data,mem_mask);
- break;
-
- case m68307SIM_PADAT:
- sim->write_padat(this, space, data,mem_mask);
- break;
-
- case m68307SIM_PBCNT:
- logerror("%08x m68307_internal_sim_w %08x, %04x (%04x) (Port B (16-bit) Control Register - PBCNT)\n", pc, offset*2,data,mem_mask);
- sim->write_pbcnt(data,mem_mask);
- break;
-
- case m68307SIM_PBDDR:
- logerror("%08x m68307_internal_sim_w %08x, %04x (%04x) (Port B (16-bit) Direction Register - PBDDR)\n", pc, offset*2,data,mem_mask);
- sim->write_pbddr(data,mem_mask);
- break;
-
- case m68307SIM_PBDAT:
- sim->write_pbdat(this, space, data, mem_mask);
- break;
-
-
- case m68307SIM_LICR1:
- logerror("%08x m68307_internal_sim_w %08x, %04x (%04x) (Latched Interrupt Control Register 1 - LICR1)\n", pc, offset*2,data,mem_mask);
- sim->write_licr1(data,mem_mask);
- break;
-
- case m68307SIM_LICR2:
- logerror("%08x m68307_internal_sim_w %08x, %04x (%04x) (Latched Interrupt Control Register 2 - LICR2)\n", pc, offset*2,data,mem_mask);
- sim->write_licr2(data,mem_mask);
- break;
-
- case m68307SIM_PICR:
- logerror("%08x m68307_internal_sim_w %08x, %04x (%04x) (Peripheral Interrupt Control Register - PICR)\n", pc, offset*2,data,mem_mask);
- sim->write_picr(data,mem_mask);
- break;
-
- case m68307SIM_PIVR:
- logerror("%08x m68307_internal_sim_w %08x, %04x (%04x) (Peripheral Interrupt Vector Register - PIVR)\n", pc, offset*2,data,mem_mask);
- sim->write_pivr(data,mem_mask);
- break;
-
- case m68307SIM_BR0:
- COMBINE_DATA(&sim->m_br[0]);
- break;
- case m68307SIM_OR0:
- COMBINE_DATA(&sim->m_or[0]);
- break;
- case m68307SIM_BR1:
- COMBINE_DATA(&sim->m_br[1]);
- break;
- case m68307SIM_OR1:
- COMBINE_DATA(&sim->m_or[1]);
- break;
- case m68307SIM_BR2:
- COMBINE_DATA(&sim->m_br[2]);
- break;
- case m68307SIM_OR2:
- COMBINE_DATA(&sim->m_or[2]);
- break;
- case m68307SIM_BR3:
- COMBINE_DATA(&sim->m_br[3]);
- break;
- case m68307SIM_OR3:
- COMBINE_DATA(&sim->m_or[3]);
- break;
-
-
-
- default :
- logerror("%08x m68307_internal_sim_w %08x, %04x (%04x)\n", pc, offset*2,data,mem_mask);
- break;
-
- }
- }
-}
-
-
-void m68307_sim::write_pacnt(UINT16 data, UINT16 mem_mask)
-{
- COMBINE_DATA(&m_pacnt);
-}
-
-void m68307_sim::write_paddr(UINT16 data, UINT16 mem_mask)
-{
- COMBINE_DATA(&m_paddr);
-}
-
-
-UINT16 m68307_sim::read_padat(m68307cpu_device* m68k, address_space &space, UINT16 mem_mask)
-{
- int pc = space.device().safe_pc();
-
- if (!m68k->m_m68307_porta_r.isnull())
- {
- // for general purpose bits, if configured as 'output' then anything output gets latched
- // and anything configured as input is read from the port
- UINT8 outputbits = m_paddr;
- UINT8 inputbits = ~m_paddr;
- UINT8 general_purpose_bits = ~m_pacnt;
- UINT8 indat = m68k->m_m68307_porta_r(space, false, (inputbits & general_purpose_bits)&mem_mask) & ((inputbits & general_purpose_bits) & mem_mask); // read general purpose input lines
- indat |= m68k->m_m68307_porta_r(space, true, (inputbits & ~general_purpose_bits)&mem_mask) & ((inputbits & ~general_purpose_bits)& mem_mask); // read dedicated input lines
- UINT8 outdat = (m_padat & outputbits) & general_purpose_bits; // read general purpose output lines (reads latched data)
-
- return (indat | outdat);
-
- }
- else
- {
- logerror("%08x m68307_internal_sim_r (%04x) (Port A (8-bit) Data Register - PADAT)\n", pc, mem_mask);
- }
- return 0xffff;
-}
-
-
-void m68307_sim::write_padat(m68307cpu_device* m68k, address_space &space, UINT16 data, UINT16 mem_mask)
-{
- int pc = space.device().safe_pc();
- COMBINE_DATA(&m_padat);
-
- if (!m68k->m_m68307_porta_w.isnull())
- {
- m68k->m_m68307_porta_w(space, false, data, 0xff);
- }
- else
- {
- logerror("%08x m68307_internal_sim_w %04x (%04x) (Port A (8-bit) Data Register - PADAT)\n", pc, data,mem_mask);
- }
-}
-
-void m68307_sim::write_pbcnt(UINT16 data, UINT16 mem_mask)
-{
- COMBINE_DATA(&m_pbcnt);
-}
-
-void m68307_sim::write_pbddr(UINT16 data, UINT16 mem_mask)
-{
- COMBINE_DATA(&m_pbddr);
-}
-
-UINT16 m68307_sim::read_pbdat(m68307cpu_device* m68k, address_space &space, UINT16 mem_mask)
-{
- int pc = space.device().safe_pc();
-
- if (!m68k->m_m68307_portb_r.isnull())
- {
- // for general purpose bits, if configured as 'output' then anything output gets latched
- // and anything configured as input is read from the port
- UINT16 outputbits = m_pbddr;
- UINT16 inputbits = ~m_pbddr;
- UINT16 general_purpose_bits = ~m_pbcnt;
-
- UINT16 indat = m68k->m_m68307_portb_r(space, false, (inputbits & general_purpose_bits)&mem_mask) & ((inputbits & general_purpose_bits) & mem_mask); // read general purpose input lines
- indat |= m68k->m_m68307_portb_r(space, true, (inputbits & ~general_purpose_bits)&mem_mask) & ((inputbits & ~general_purpose_bits)& mem_mask); // read dedicated input lines
- UINT16 outdat = (m_pbdat & outputbits) & general_purpose_bits; // read general purpose output lines (reads latched data)
-
- return (indat | outdat);
- }
- else
- {
- logerror("%08x m68307_internal_sim_r (%04x) (Port B (16-bit) Data Register - PBDAT)\n", pc, mem_mask);
- }
- return 0xffff;
-}
-
-
-void m68307_sim::write_pbdat(m68307cpu_device* m68k, address_space &space, UINT16 data, UINT16 mem_mask)
-{
- int pc = space.device().safe_pc();
- COMBINE_DATA(&m_pbdat);
-
- if (!m68k->m_m68307_portb_w.isnull())
- {
- m68k->m_m68307_portb_w(space, false, data, mem_mask);
- }
- else
- {
- logerror("%08x m68307_internal_sim_w %04x (%04x) (Port B (16-bit) Data Register - PBDAT)\n", pc, data,mem_mask);
- }
-}
-
-void m68307_sim::write_licr1(UINT16 data, UINT16 mem_mask)
-{
- COMBINE_DATA(&m_licr1);
- data = m_licr1;
- logerror("m_licr1 value %04x : Details :\n", data);
- logerror("int4ipl %01x\n", (data>>0)&7);
- logerror("pir4 %01x\n", (data>>3)&1);
- logerror("int3ipl %01x\n", (data>>4)&7);
- logerror("pir3 %01x\n", (data>>7)&1);
- logerror("int2ipl %01x\n", (data>>8)&7);
- logerror("pir2 %01x\n", (data>>11)&1);
- logerror("int1ipl %01x\n", (data>>12)&7);
- logerror("pir1 %01x\n", (data>>15)&1);
- logerror("\n");
-}
-
-void m68307_sim::write_licr2(UINT16 data, UINT16 mem_mask)
-{
- COMBINE_DATA(&m_licr2);
- UINT16 newdata = m_licr2;
- logerror("m_licr2 value %04x : Details :\n", newdata);
- logerror("int8ipl %01x\n", (newdata>>0)&7);
- logerror("pir8 %01x\n", (newdata>>3)&1);
- logerror("int7ipl %01x\n", (newdata>>4)&7);
- logerror("pir7 %01x\n", (newdata>>7)&1);
- logerror("int6ipl %01x\n", (newdata>>8)&7);
- logerror("pir6 %01x\n", (newdata>>11)&1);
- logerror("int5ipl %01x\n", (newdata>>12)&7);
- logerror("pir5 %01x\n", (newdata>>15)&1);
- logerror("\n");
-
- if (data & 0x0008) m_licr2 = m_licr2 & ~0x0008;
- if (data & 0x0080) m_licr2 = m_licr2 & ~0x0080;
- if (data & 0x0800) m_licr2 = m_licr2 & ~0x0800;
- if (data & 0x8000) m_licr2 = m_licr2 & ~0x8000;
-
-
-}
-
-
-void m68307_sim::write_picr(UINT16 data, UINT16 mem_mask)
-{
- COMBINE_DATA(&m_picr);
- data = m_picr;
- logerror("picr value %04x : Details :\n", data);
- logerror("mbipl %01x\n", (data>>0)&7);
- logerror("uaipl %01x\n", (data>>4)&7);
- logerror("t2ipl %01x\n", (data>>8)&7);
- logerror("t1ipl %01x\n", (data>>12)&7);
- logerror("\n");
-}
-
-void m68307_sim::write_pivr(UINT16 data, UINT16 mem_mask)
-{
- COMBINE_DATA(&m_pivr);
- data = m_pivr;
- logerror("pivr value %04x : Details :\n", data);
- logerror("unused %01x\n", (data>>0)&0xf);
- logerror("high vector %01x\n", (data>>4)&0xf);
-}
-
-void m68307_sim::reset(void)
-{
- for (int i=0;i<4;i++)
- {
- m_br[i] = 0xc001;
- m_or[i] = 0xdffd;
- }
-}
diff --git a/src/emu/machine/68307sim.h b/src/emu/machine/68307sim.h
deleted file mode 100644
index 59b33bee1e7..00000000000
--- a/src/emu/machine/68307sim.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* 68307 SIM module */
-
-#include "cpu/m68000/m68000.h"
-
-class m68307cpu_device;
-
-
-/* ports */
-#define m68307SIM_PACNT (0x10)
-#define m68307SIM_PADDR (0x12)
-#define m68307SIM_PADAT (0x14)
-#define m68307SIM_PBCNT (0x16)
-#define m68307SIM_PBDDR (0x18)
-#define m68307SIM_PBDAT (0x1a)
-
-
-/* interrupt logic */
-#define m68307SIM_LICR1 (0x20)
-#define m68307SIM_LICR2 (0x22)
-#define m68307SIM_PICR (0x24)
-#define m68307SIM_PIVR (0x26)
-
-/* used for the CS logic */
-#define m68307SIM_BR0 (0x40)
-#define m68307SIM_OR0 (0x42)
-#define m68307SIM_BR1 (0x44)
-#define m68307SIM_OR1 (0x46)
-#define m68307SIM_BR2 (0x48)
-#define m68307SIM_OR2 (0x4a)
-#define m68307SIM_BR3 (0x4c)
-#define m68307SIM_OR3 (0x4e)
-
-class m68307_sim
-{
- public:
-
- UINT16 m_pacnt; // 8-bit
- UINT16 m_paddr; // 8-bit
- UINT16 m_padat; // 8-bit
-
- UINT16 m_pbcnt;
- UINT16 m_pbddr;
- UINT16 m_pbdat;
-
- UINT16 m_pivr; // 8-bit
-
- UINT16 m_br[4];
- UINT16 m_or[4];
- UINT16 m_picr;
- UINT16 m_licr1;
- UINT16 m_licr2;
-
-
- void write_pacnt(UINT16 data, UINT16 mem_mask);
- void write_paddr(UINT16 data, UINT16 mem_mask);
- UINT16 read_padat(m68307cpu_device* m68k, address_space &space, UINT16 mem_mask);
- void write_padat(m68307cpu_device* m68k, address_space &space, UINT16 data, UINT16 mem_mask);
-
- void write_pbcnt(UINT16 data, UINT16 mem_mask);
- void write_pbddr(UINT16 data, UINT16 mem_mask);
- UINT16 read_pbdat(m68307cpu_device* m68k, address_space &space, UINT16 mem_mask);
- void write_pbdat(m68307cpu_device* m68k, address_space &space, UINT16 data, UINT16 mem_mask);
-
-
-
- void write_licr1(UINT16 data, UINT16 mem_mask);
- void write_licr2(UINT16 data, UINT16 mem_mask);
- void write_picr(UINT16 data, UINT16 mem_mask);
- void write_pivr(UINT16 data, UINT16 mem_mask);
-
- void reset(void);
-};
diff --git a/src/emu/machine/68307tmu.c b/src/emu/machine/68307tmu.c
deleted file mode 100644
index 23a67ada9ad..00000000000
--- a/src/emu/machine/68307tmu.c
+++ /dev/null
@@ -1,245 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* 68307 TIMER module */
-// 2x timers
-
-#include "emu.h"
-#include "68307.h"
-
-READ16_MEMBER( m68307cpu_device::m68307_internal_timer_r )
-{
- m68307cpu_device *m68k = this;
- m68307_timer* timer = m68k->m68307TIMER;
- assert(timer != NULL);
-
- if (timer)
- {
- int pc = space.device().safe_pc();
- int which = offset & 0x8;
-
- switch (offset&0x7)
- {
- case m68307TIMER_TCN: /* 0x3 (0x126 / 0x136) */
- //if (pc!=0x2182e) logerror("%08x m68307_internal_timer_r %08x (%04x) (TCN - Timer Counter for timer %d)\n", pc, offset*2,mem_mask, which);
- return timer->read_tcn(mem_mask, which);
-
- default:
- logerror("%08x m68307_internal_timer_r %08x, (%04x)\n", pc, offset*2,mem_mask);
- break;
- }
- }
-
- return 0x0000;
-}
-
-WRITE16_MEMBER( m68307cpu_device::m68307_internal_timer_w )
-{
- m68307cpu_device *m68k = this;
- m68307_timer* timer = m68k->m68307TIMER;
- assert(timer != NULL);
-
- if (timer)
- {
- int pc = space.device().safe_pc();
- int which = offset & 0x8;
-
- switch (offset&0x7)
- {
- case m68307TIMER_TMR: /* 0x0 (0x120 / 0x130) */
- logerror("%08x m68307_internal_timer_w %08x, %04x (%04x) (TMR - Timer Mode Register for timer %d)\n", pc, offset*2,data,mem_mask, which);
- timer->write_tmr(data, mem_mask, which);
- break;
-
- case m68307TIMER_TRR: /* 0x1 (0x122 / 0x132) */
- logerror("%08x m68307_internal_timer_w %08x, %04x (%04x) (TRR - Timer Reference Register for timer %d)\n", pc, offset*2,data,mem_mask, which);
- timer->write_trr(data, mem_mask, which);
- break;
-
- case m68307TIMER_TCR: /* 0x2 (0x124 / 0x134) */
- logerror("%08x m68307_internal_timer_w %08x, %04x (%04x) (TCR - Timer Capture Register for timer %d) (illegal, read-only)\n", pc, offset*2,data,mem_mask, which);
- break;
-
- case m68307TIMER_TCN: /* 0x3 (0x126 / 0x136) */
- logerror("%08x m68307_internal_timer_w %08x, %04x (%04x) (TCN - Timer Counter for timer %d)\n", pc, offset*2,data,mem_mask, which);
- break;
-
- case m68307TIMER_TER: /* 0x4 (0x128 / 0x138) */
- /* 8-bit only!! */
- //logerror("%08x m68307_internal_timer_w %08x, %04x (%04x) (TER - Timer Event Register for timer %d)\n", pc, offset*2,data,mem_mask, which);
- timer->write_ter(data, mem_mask, which);
- break;
-
- case m68307TIMER_WRR: /* 0x5 (0x12a / 0x13a) */
- if (which==0)
- {
- logerror("%08x m68307_internal_timer_w %08x, %04x (%04x) (WRR - Watchdog Reference Register)\n", pc, offset*2,data,mem_mask);
- }
- else
- {
- logerror("%08x m68307_internal_timer_w %08x, %04x (%04x) (illegal)\n", pc, offset*2,data,mem_mask);
- }
- break;
-
- case m68307TIMER_WCR: /* 0x6 (0x12c / 0x13c) */
- if (which==0)
- {
- logerror("%08x m68307_internal_timer_w %08x, %04x (%04x) (WRR - Watchdog Counter Register)\n", pc, offset*2,data,mem_mask);
- }
- else
- {
- logerror("%08x m68307_internal_timer_w %08x, %04x (%04x) (illegal)\n", pc, offset*2,data,mem_mask);
- }
- break;
-
- case m68307TIMER_XXX: /* 0x7 (0x12e / 0x13e) */
- logerror("%08x m68307_internal_timer_w %08x, %04x (%04x) (illegal)\n", pc, offset*2,data,mem_mask);
- break;
-
- }
- }
-}
-
-static TIMER_CALLBACK( m68307_timer0_callback )
-{
- m68307cpu_device* m68k = (m68307cpu_device *)ptr;
- m68307_single_timer* tptr = &m68k->m68307TIMER->singletimer[0];
- tptr->regs[m68307TIMER_TMR] |= 0x2;
-
- m68k->timer0_interrupt();
-
- tptr->mametimer->adjust(m68k->cycles_to_attotime(20000));
-}
-
-static TIMER_CALLBACK( m68307_timer1_callback )
-{
- m68307cpu_device* m68k = (m68307cpu_device *)ptr;
- m68307_single_timer* tptr = &m68k->m68307TIMER->singletimer[1];
- tptr->regs[m68307TIMER_TMR] |= 0x2;
-
- m68k->timer1_interrupt();
-
- tptr->mametimer->adjust(m68k->cycles_to_attotime(20000));
-
-}
-
-static TIMER_CALLBACK( m68307_wd_timer_callback )
-{
- printf("wd timer\n");
-}
-
-void m68307_timer::init(m68307cpu_device *device)
-{
- parent = device;
-
- m68307_single_timer* tptr;
-
- tptr = &singletimer[0];
- tptr->mametimer = device->machine().scheduler().timer_alloc(FUNC(m68307_timer0_callback), parent);
-
- tptr = &singletimer[1];
- tptr->mametimer = device->machine().scheduler().timer_alloc(FUNC(m68307_timer1_callback), parent);
-
-
- wd_mametimer = device->machine().scheduler().timer_alloc(FUNC(m68307_wd_timer_callback), parent);
-
-
-}
-
-UINT16 m68307_timer::read_tcn(UINT16 mem_mask, int which)
-{
- // we should return the current timer value by
- // calculating what it should be based on the time
- // since it was last set
- return 0x3a98;
-}
-
-void m68307_timer::write_ter(UINT16 data, UINT16 mem_mask, int which)
-{
- assert(which >= 0 && which < ARRAY_LENGTH(singletimer));
- m68307_single_timer* tptr = &singletimer[which];
- if (data & 0x2) tptr->regs[m68307TIMER_TMR] &= ~0x2;
-}
-
-void m68307_timer::write_tmr(UINT16 data, UINT16 mem_mask, int which)
-{
- m68307cpu_device* m68k = parent;
- assert(which >= 0 && which < ARRAY_LENGTH(singletimer));
- m68307_single_timer* tptr = &singletimer[which];
-
- COMBINE_DATA(&tptr->regs[m68307TIMER_TMR]);
-
- data = tptr->regs[m68307TIMER_TMR];
-
- int ps = data & (0xff00)>>8;
- int ce = data & (0x00c0)>>6;
- int om = data & (0x0020)>>5;
- int ori = data & (0x0010)>>4;
- int frr = data & (0x0008)>>3;
- int iclk = data & (0x0006)>>1;
- int rst = data & (0x0001)>>0;
-
-
- logerror("tmr value %04x : Details :\n", data);
- logerror("prescale %d\n", ps);
- logerror("(clock divided by %d)\n", ps+1);
- logerror("capture edge / enable interrupt %d\n", ce);
- if (ce==0x0) logerror("(disable interrupt on capture event)\n");
- if (ce==0x1) logerror("(capture on rising edge only + enable capture interrupt)\n");
- if (ce==0x2) logerror("(capture on falling edge only + enable capture interrupt)\n");
- if (ce==0x3) logerror("(capture on any edge + enable capture interrupt)\n");
- logerror("output mode %d\n", om);
- if (om==0x0) logerror("(active-low pulse for one cycle))\n");
- if (om==0x1) logerror("(toggle output)\n");
- logerror("output reference interrupt %d\n", ori);
- if (ori==0x0) logerror("(disable reference interrupt)\n");
- if (ori==0x1) logerror("(enable interrupt on reaching reference value))\n");
- logerror("free running %d\n", frr);
- if (frr==0x0) logerror("(free running mode, counter continues after value reached)\n");
- if (frr==0x1) logerror("(restart mode, counter resets after value reached)\n");
- logerror("interrupt clock source %d\n", iclk);
- if (iclk==0x0) logerror("(stop count)\n");
- if (iclk==0x1) logerror("(master system clock)\n");
- if (iclk==0x2) logerror("(master system clock divided by 16)\n");
- if (iclk==0x3) logerror("(TIN Pin)\n");
- logerror("reset %d\n", rst);
- if (rst==0x0) logerror("(timer is reset)\n");
- if (rst==0x1) logerror("(timer is running)\n");
-
- tptr->mametimer->adjust(m68k->cycles_to_attotime(100000));
-
- logerror("\n");
-
-}
-
-void m68307_timer::write_trr(UINT16 data, UINT16 mem_mask, int which)
-{
- assert(which >= 0 && which < ARRAY_LENGTH(singletimer));
- m68307_single_timer* tptr = &singletimer[which];
-
- COMBINE_DATA(&tptr->regs[m68307TIMER_TRR]);
-}
-
-
-
-void m68307_timer::reset(void)
-{
- for (int i=0;i<2;i++)
- {
- m68307_single_timer* tptr = &singletimer[i];
-
- tptr->regs[m68307TIMER_TMR] = 0x0000;
- tptr->regs[m68307TIMER_TRR] = 0xffff;
- tptr->regs[m68307TIMER_TCR] = 0x0000;
- tptr->regs[m68307TIMER_TCN] = 0x0000;
- tptr->regs[m68307TIMER_TER] = 0x0000;
- tptr->regs[m68307TIMER_WRR] = 0xffff;
- tptr->regs[m68307TIMER_WCR] = 0xffff;
- tptr->regs[m68307TIMER_XXX] = 0;
- tptr->enabled = false;
- tptr->mametimer->adjust(attotime::never);
- }
-
- wd_mametimer->adjust(attotime::never);
-
-
-}
diff --git a/src/emu/machine/68307tmu.h b/src/emu/machine/68307tmu.h
deleted file mode 100644
index 2c62858b66d..00000000000
--- a/src/emu/machine/68307tmu.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-
-#include "cpu/m68000/m68000.h"
-
-class m68307cpu_device;
-
-
-#define m68307TIMER_TMR (0x0)
-#define m68307TIMER_TRR (0x1)
-#define m68307TIMER_TCR (0x2)
-#define m68307TIMER_TCN (0x3)
-#define m68307TIMER_TER (0x4)
-#define m68307TIMER_WRR (0x5)
-#define m68307TIMER_WCR (0x6)
-#define m68307TIMER_XXX (0x7)
-
-struct m68307_single_timer
-{
- UINT16 regs[0x8];
- bool enabled;
- emu_timer *mametimer;
-};
-
-
-class m68307_timer
-{
- public:
- m68307_single_timer singletimer[2];
-
- emu_timer *wd_mametimer;
- m68307cpu_device *parent;
-
- void write_tmr(UINT16 data, UINT16 mem_mask, int which);
- void write_trr(UINT16 data, UINT16 mem_mask, int which);
- void write_ter(UINT16 data, UINT16 mem_mask, int which);
- UINT16 read_tcn(UINT16 mem_mask, int which);
-
- void init(m68307cpu_device *device);
- void reset(void);
-};
diff --git a/src/emu/machine/68340.c b/src/emu/machine/68340.c
deleted file mode 100644
index 752a7be4592..00000000000
--- a/src/emu/machine/68340.c
+++ /dev/null
@@ -1,152 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* 68340 */
-
-#include "68340.h"
-
-
-
-
-int m68340_calc_cs(m68340cpu_device *m68k, offs_t address)
-{
- m68340_sim* sim = m68k->m68340SIM;
-
- if ( !(sim->m_ba[0] & 1) ) return 1;
-
- for (int i=0;i<4;i++)
- {
- if (sim->m_ba[i] & 1)
- {
- int mask = ((sim->m_am[i]&0xffffff00) | 0xff);
- int base = sim->m_ba[i] & 0xffffff00;
- int fcmask = (sim->m_am[i] & 0xf0);
- int fcbase = (sim->m_ba[i] & 0xf0) & ~(sim->m_am[i] & 0xf0);
- int fc = m68k->mmu_tmp_fc;
-
- if ((address & ~mask) == base && ((fc << 4) & ~fcmask ) == fcbase ) return i+1;
- }
- }
-
- return 0;
-}
-
-
-
-UINT16 m68340_get_cs(m68340cpu_device *device, offs_t address)
-{
- device->m68340_currentcs = m68340_calc_cs(device, address);
-
- return device->m68340_currentcs;
-}
-
-
-
-/* 68340 specifics - MOVE */
-
-READ32_MEMBER( m68340cpu_device::m68340_internal_base_r )
-{
- m68340cpu_device *m68k = this;
- int pc = space.device().safe_pc();
- logerror("%08x m68340_internal_base_r %08x, (%08x)\n", pc, offset*4,mem_mask);
- return m68k->m68340_base;
-}
-
-WRITE32_MEMBER( m68340cpu_device::m68340_internal_base_w )
-{
- m68340cpu_device *m68k = this;
-
- int pc = space.device().safe_pc();
- logerror("%08x m68340_internal_base_w %08x, %08x (%08x)\n", pc, offset*4,data,mem_mask);
-
- // other conditions?
- if (m68k->dfc==0x7)
- {
- // unmap old modules
- if (m68k->m68340_base&1)
- {
- int base = m68k->m68340_base & 0xfffff000;
-
- m68k->internal->unmap_readwrite(base + 0x000, base + 0x05f);
- m68k->internal->unmap_readwrite(base + 0x600, base + 0x67f);
- m68k->internal->unmap_readwrite(base + 0x700, base + 0x723);
- m68k->internal->unmap_readwrite(base + 0x780, base + 0x7bf);
-
- }
-
- COMBINE_DATA(&m68k->m68340_base);
- logerror("%08x m68340_internal_base_w %08x, %08x (%08x) (m68340_base write)\n", pc, offset*4,data,mem_mask);
-
- // map new modules
- if (m68k->m68340_base&1)
- {
- int base = m68k->m68340_base & 0xfffff000;
-
- m68k->internal->install_readwrite_handler(base + 0x000, base + 0x03f, read16_delegate(FUNC(m68340cpu_device::m68340_internal_sim_r),this), write16_delegate(FUNC(m68340cpu_device::m68340_internal_sim_w),this),0xffffffff);
- m68k->internal->install_readwrite_handler(base + 0x010, base + 0x01f, read8_delegate(FUNC(m68340cpu_device::m68340_internal_sim_ports_r),this),write8_delegate(FUNC(m68340cpu_device::m68340_internal_sim_ports_w),this),0xffffffff);
- m68k->internal->install_readwrite_handler(base + 0x040, base + 0x05f, read32_delegate(FUNC(m68340cpu_device::m68340_internal_sim_cs_r),this), write32_delegate(FUNC(m68340cpu_device::m68340_internal_sim_cs_w),this));
- m68k->internal->install_readwrite_handler(base + 0x600, base + 0x67f, read32_delegate(FUNC(m68340cpu_device::m68340_internal_timer_r),this), write32_delegate(FUNC(m68340cpu_device::m68340_internal_timer_w),this));
- m68k->internal->install_readwrite_handler(base + 0x700, base + 0x723, read32_delegate(FUNC(m68340cpu_device::m68340_internal_serial_r),this), write32_delegate(FUNC(m68340cpu_device::m68340_internal_serial_w),this));
- m68k->internal->install_readwrite_handler(base + 0x780, base + 0x7bf, read32_delegate(FUNC(m68340cpu_device::m68340_internal_dma_r),this), write32_delegate(FUNC(m68340cpu_device::m68340_internal_dma_w),this));
-
- }
-
- }
- else
- {
- logerror("%08x m68340_internal_base_w %08x, %04x (%04x) (should fall through?)\n", pc, offset*4,data,mem_mask);
- }
-
-
-
-}
-
-
-static ADDRESS_MAP_START( m68340_internal_map, AS_PROGRAM, 32, m68340cpu_device )
- AM_RANGE(0x0003ff00, 0x0003ff03) AM_READWRITE( m68340_internal_base_r, m68340_internal_base_w)
-ADDRESS_MAP_END
-
-
-
-
-
-m68340cpu_device::m68340cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : fscpu32_device(mconfig, "MC68340", tag, owner, clock, M68340, 32,32, ADDRESS_MAP_NAME(m68340_internal_map), "mc68340", __FILE__)
-{
- m68340SIM = 0;
- m68340DMA = 0;
- m68340SERIAL = 0;
- m68340TIMER = 0;
- m68340_base = 0;
-}
-
-
-
-
-
-
-void m68340cpu_device::device_reset()
-{
- fscpu32_device::device_reset();
-}
-
-
-void m68340cpu_device::device_start()
-{
- fscpu32_device::device_start();
-
- m68340SIM = new m68340_sim();
- m68340DMA = new m68340_dma();
- m68340SERIAL = new m68340_serial();
- m68340TIMER = new m68340_timer();
-
- m68340SIM->reset();
- m68340DMA->reset();
- m68340SERIAL->reset();
- m68340TIMER->reset();
-
- start_68340_sim();
-
- m68340_base = 0x00000000;
-
- internal = &this->space(AS_PROGRAM);
-}
diff --git a/src/emu/machine/68340.h b/src/emu/machine/68340.h
deleted file mode 100644
index 6f1260ae1cb..00000000000
--- a/src/emu/machine/68340.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* 68340 */
-
-
-#pragma once
-#ifndef __M68340_H__
-#define __M68340_H__
-
-#include "emu.h"
-#include "cpu/m68000/m68000.h"
-
-#include "68340sim.h"
-#include "68340dma.h"
-#include "68340ser.h"
-#include "68340tmu.h"
-
-
-
-
-
-class m68340cpu_device : public fscpu32_device {
-public:
- m68340cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-
- int m68340_currentcs;
-
- /* 68340 peripheral modules */
- m68340_sim* m68340SIM;
- m68340_dma* m68340DMA;
- m68340_serial* m68340SERIAL;
- m68340_timer* m68340TIMER;
-
- UINT32 m68340_base;
-
- UINT16 m_avr;
- UINT16 m_picr;
- UINT16 m_pitr;
-
- READ32_MEMBER( m68340_internal_base_r );
- WRITE32_MEMBER( m68340_internal_base_w );
- READ32_MEMBER( m68340_internal_dma_r );
- WRITE32_MEMBER( m68340_internal_dma_w );
- READ32_MEMBER( m68340_internal_serial_r );
- WRITE32_MEMBER( m68340_internal_serial_w );
- READ16_MEMBER( m68340_internal_sim_r );
- READ8_MEMBER( m68340_internal_sim_ports_r );
- READ32_MEMBER( m68340_internal_sim_cs_r );
- WRITE16_MEMBER( m68340_internal_sim_w );
- WRITE8_MEMBER( m68340_internal_sim_ports_w );
- WRITE32_MEMBER( m68340_internal_sim_cs_w );
- READ32_MEMBER( m68340_internal_timer_r );
- WRITE32_MEMBER( m68340_internal_timer_w );
-
- emu_timer *m_irq_timer;
- TIMER_CALLBACK_MEMBER(periodic_interrupt_timer_callback);
- void start_68340_sim(void);
- void do_timer_irq(void);
-protected:
-
- virtual void device_start();
- virtual void device_reset();
-
-};
-
-static const device_type M68340 = &device_creator<m68340cpu_device>;
-
-extern UINT16 m68340_get_cs(m68340cpu_device *device, offs_t address);
-
-
-
-
-
-#endif
diff --git a/src/emu/machine/68340dma.c b/src/emu/machine/68340dma.c
deleted file mode 100644
index 9ee0ae5114e..00000000000
--- a/src/emu/machine/68340dma.c
+++ /dev/null
@@ -1,39 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* 68340 DMA module */
-
-#include "emu.h"
-#include "68340.h"
-
-
-READ32_MEMBER( m68340cpu_device::m68340_internal_dma_r )
-{
- m68340cpu_device *m68k = this;
- m68340_dma* dma = m68k->m68340DMA;
- assert(dma != NULL);
-
- if (dma)
- {
- int pc = space.device().safe_pc();
- logerror("%08x m68340_internal_dma_r %08x, (%08x)\n", pc, offset*4,mem_mask);
- }
-
- return 0x00000000;
-}
-
-WRITE32_MEMBER( m68340cpu_device::m68340_internal_dma_w )
-{
- m68340cpu_device *m68k = this;
- m68340_dma* dma = m68k->m68340DMA;
- assert(dma != NULL);
-
- if (dma)
- {
- int pc = space.device().safe_pc();
- logerror("%08x m68340_internal_dma_w %08x, %08x (%08x)\n", pc, offset*4,data,mem_mask);
- }
-}
-
-void m68340_dma::reset(void)
-{
-}
diff --git a/src/emu/machine/68340dma.h b/src/emu/machine/68340dma.h
deleted file mode 100644
index 56d8228fa2d..00000000000
--- a/src/emu/machine/68340dma.h
+++ /dev/null
@@ -1,10 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-
-#include "cpu/m68000/m68000.h"
-
-class m68340_dma
-{
- public:
- void reset(void);
-};
diff --git a/src/emu/machine/68340ser.c b/src/emu/machine/68340ser.c
deleted file mode 100644
index 9e4118ec92e..00000000000
--- a/src/emu/machine/68340ser.c
+++ /dev/null
@@ -1,40 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* 68340 SERIAL module */
-
-#include "emu.h"
-#include "68340.h"
-
-
-READ32_MEMBER( m68340cpu_device::m68340_internal_serial_r )
-{
- m68340cpu_device *m68k = this;
- m68340_serial* serial = m68k->m68340SERIAL;
- assert(serial != NULL);
-
- if (serial)
- {
- int pc = space.device().safe_pc();
- logerror("%08x m68340_internal_serial_r %08x, (%08x)\n", pc, offset*4,mem_mask);
- }
-
- return 0x00000000;
-}
-
-WRITE32_MEMBER( m68340cpu_device::m68340_internal_serial_w )
-{
- m68340cpu_device *m68k = this;
- m68340_serial* serial = m68k->m68340SERIAL;
- assert(serial != NULL);
-
- if (serial)
- {
- int pc = space.device().safe_pc();
- logerror("%08x m68340_internal_serial_w %08x, %08x (%08x)\n", pc, offset*4,data,mem_mask);
- }
-
-}
-
-void m68340_serial::reset(void)
-{
-}
diff --git a/src/emu/machine/68340ser.h b/src/emu/machine/68340ser.h
deleted file mode 100644
index 0fda812ff0a..00000000000
--- a/src/emu/machine/68340ser.h
+++ /dev/null
@@ -1,10 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-
-#include "cpu/m68000/m68000.h"
-
-class m68340_serial
-{
- public:
- void reset(void);
-};
diff --git a/src/emu/machine/68340sim.c b/src/emu/machine/68340sim.c
deleted file mode 100644
index 88e56d78763..00000000000
--- a/src/emu/machine/68340sim.c
+++ /dev/null
@@ -1,349 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* 68340 SIM module */
-
-#include "emu.h"
-#include "68340.h"
-
-
-
-READ16_MEMBER( m68340cpu_device::m68340_internal_sim_r )
-{
- m68340cpu_device *m68k = this;
- m68340_sim* sim = m68k->m68340SIM;
- assert(sim != NULL);
-
- if (sim)
- {
- int pc = space.device().safe_pc();
-
- switch (offset<<1)
- {
- case m68340SIM_MCR:
- logerror("%08x m68340_internal_sim_r %04x, (%04x) (MCR - Module Configuration Register)\n", pc, offset*2,mem_mask);
- return space.machine().rand();
-
- case m68340SIM_SYNCR:
- logerror("%08x m68340_internal_sim_r %04x, (%04x) (SYNCR - Clock Synthesizer Register)\n", pc, offset*2,mem_mask);
- return space.machine().rand();
-
- case m68340SIM_AVR_RSR:
- logerror("%08x m68340_internal_sim_r %04x, (%04x) (AVR, RSR - Auto Vector Register, Reset Status Register)\n", pc, offset*2,mem_mask);
- return space.machine().rand();
-
- case m68340SIM_SWIV_SYPCR:
- logerror("%08x m68340_internal_sim_r %04x, (%04x) (SWIV_SYPCR - Software Interrupt Vector, System Protection Control Register)\n", pc, offset*2,mem_mask);
- return space.machine().rand();
-
- case m68340SIM_PICR:
- logerror("%08x m68340_internal_sim_r %04x, (%04x) (PICR - Periodic Interrupt Control Register)\n", pc, offset*2,mem_mask);
- return space.machine().rand();
-
- case m68340SIM_PITR:
- logerror("%08x m68340_internal_sim_r %04x, (%04x) (PITR - Periodic Interrupt Timer Register)\n", pc, offset*2,mem_mask);
- return space.machine().rand();
-
- case m68340SIM_SWSR:
- logerror("%08x m68340_internal_sim_r %04x, (%04x) (SWSR - Software Service)\n", pc, offset*2,mem_mask);
- return space.machine().rand();
-
- default:
- logerror("%08x m68340_internal_sim_r %04x, (%04x)\n", pc, offset*2,mem_mask);
-
-
- }
- }
-
- return 0x0000;
-}
-
-READ8_MEMBER( m68340cpu_device::m68340_internal_sim_ports_r )
-{
- offset += 0x10;
- m68340cpu_device *m68k = this;
- m68340_sim* sim = m68k->m68340SIM;
- assert(sim != NULL);
-
- if (sim)
- {
- int pc = space.device().safe_pc();
-
- switch (offset)
- {
- case m68340SIM_PORTA:
- logerror("%08x m68340_internal_sim_r %04x (PORTA - Port A Data)\n", pc, offset);
- return space.machine().rand();
-
- case m68340SIM_DDRA:
- logerror("%08x m68340_internal_sim_r %04x (DDRA - Port A Data Direction)\n", pc, offset);
- return space.machine().rand();
-
- case m68340SIM_PPRA1:
- logerror("%08x m68340_internal_sim_r %04x (PPRA1 - Port A Pin Assignment 1)\n", pc, offset);
- return space.machine().rand();
-
- case m68340SIM_PPRA2:
- logerror("%08x m68340_internal_sim_r %04x (PPRA2 - Port A Pin Assignment 2)\n", pc, offset);
- return space.machine().rand();
-
- case m68340SIM_PORTB:
- logerror("%08x m68340_internal_sim_r %04x (PORTB - Port B Data 0)\n", pc, offset);
- return space.machine().rand();
-
- case m68340SIM_PORTB1:
- logerror("%08x m68340_internal_sim_r %04x (PORTB1 - Port B Data 1)\n", pc, offset);
- return space.machine().rand();
-
- case m68340SIM_DDRB:
- logerror("%08x m68340_internal_sim_r %04x (DDR - Port B Data Direction)\n", pc, offset);
- return space.machine().rand();
-
- case m68340SIM_PPARB:
- logerror("%08x m68340_internal_sim_r %04x (PPARB - Port B Pin Assignment)\n", pc, offset);
- return space.machine().rand();
-
- default:
- logerror("%08x m68340_internal_sim_r %04x (ILLEGAL?)\n", pc, offset);
- return space.machine().rand();
-
- }
- }
-
- return 0x00;
-}
-
-READ32_MEMBER( m68340cpu_device::m68340_internal_sim_cs_r )
-{
- offset += m68340SIM_AM_CS0>>2;
-
- m68340cpu_device *m68k = this;
- m68340_sim* sim = m68k->m68340SIM;
- assert(sim != NULL);
-
- if (sim)
- {
- int pc = space.device().safe_pc();
-
- switch (offset<<2)
- {
- case m68340SIM_AM_CS0: return sim->m_am[0];
- case m68340SIM_BA_CS0: return sim->m_ba[0];
- case m68340SIM_AM_CS1: return sim->m_am[1];
- case m68340SIM_BA_CS1: return sim->m_ba[1];
- case m68340SIM_AM_CS2: return sim->m_am[2];
- case m68340SIM_BA_CS2: return sim->m_ba[2];
- case m68340SIM_AM_CS3: return sim->m_am[3];
- case m68340SIM_BA_CS3: return sim->m_ba[3];
-
- default:
- logerror("%08x m68340_internal_sim_r %08x, (%08x)\n", pc, offset*4,mem_mask);
-
- }
- }
-
- return 0x00000000;
-}
-
-WRITE16_MEMBER( m68340cpu_device::m68340_internal_sim_w )
-{
- m68340cpu_device *m68k = this;
- m68340_sim* sim = m68k->m68340SIM;
- assert(sim != NULL);
-
- if (sim)
- {
- int pc = space.device().safe_pc();
-
- switch (offset<<1)
- {
- case m68340SIM_MCR:
- logerror("%08x m68340_internal_sim_w %04x, %04x (%04x) (MCR - Module Configuration Register)\n", pc, offset*2,data,mem_mask);
- break;
-
- case m68340SIM_SYNCR:
- logerror("%08x m68340_internal_sim_w %04x, %04x (%04x) (SYNCR - Clock Synthesizer Register)\n", pc, offset*2,data,mem_mask);
- break;
-
-
- case m68340SIM_AVR_RSR:
- logerror("%08x m68340_internal_sim_w %04x, %04x (%04x) (AVR, RSR - Auto Vector Register, Reset Status Register)\n", pc, offset*2,data,mem_mask);
- COMBINE_DATA(&m_avr);
- break;
-
- case m68340SIM_SWIV_SYPCR:
- logerror("%08x m68340_internal_sim_w %04x, %04x (%04x) (SWIV_SYPCR - Software Interrupt Vector, System Protection Control Register)\n", pc, offset*2,data,mem_mask);
- break;
-
- case m68340SIM_PICR:
- logerror("%08x m68340_internal_sim_w %04x, %04x (%04x) (PICR - Periodic Interrupt Control Register)\n", pc, offset*2,data,mem_mask);
- COMBINE_DATA(&m_picr);
- break;
-
- case m68340SIM_PITR:
- logerror("%08x m68340_internal_sim_w %04x, %04x (%04x) (PITR - Periodic Interrupt Timer Register)\n", pc, offset*2,data,mem_mask);
- COMBINE_DATA(&m_pitr);
- if (m_pitr !=0 ) // hack
- {
- //logerror("timer set\n");
- m_irq_timer->adjust(cycles_to_attotime(20000)); // hack
- }
-
- break;
-
- case m68340SIM_SWSR:
- // basically watchdog, you must write an alternating pattern of 0x55 / 0xaa to keep the watchdog from resetting the system
- //logerror("%08x m68340_internal_sim_w %04x, %04x (%04x) (SWSR - Software Service)\n", pc, offset*2,data,mem_mask);
- break;
-
- default:
- logerror("%08x m68340_internal_sim_w %04x, %04x (%04x)\n", pc, offset*2,data,mem_mask);
-
- }
- }
-}
-
-WRITE8_MEMBER( m68340cpu_device::m68340_internal_sim_ports_w )
-{
- offset += 0x10;
- m68340cpu_device *m68k = this;
- m68340_sim* sim = m68k->m68340SIM;
- assert(sim != NULL);
-
- if (sim)
- {
- int pc = space.device().safe_pc();
-
- switch (offset)
- {
- case m68340SIM_PORTA:
- logerror("%08x m68340_internal_sim_w %04x, %02x (PORTA - Port A Data)\n", pc, offset,data);
- break;
-
- case m68340SIM_DDRA:
- logerror("%08x m68340_internal_sim_w %04x, %02x (DDRA - Port A Data Direction)\n", pc, offset,data);
- break;
-
- case m68340SIM_PPRA1:
- logerror("%08x m68340_internal_sim_w %04x, %02x (PPRA1 - Port A Pin Assignment 1)\n", pc, offset,data);
- break;
-
- case m68340SIM_PPRA2:
- logerror("%08x m68340_internal_sim_w %04x, %02x (PPRA2 - Port A Pin Assignment 2)\n", pc, offset,data);
- break;
-
- case m68340SIM_PORTB:
- logerror("%08x m68340_internal_sim_w %04x, %02x (PORTB - Port B Data)\n", pc, offset,data);
- break;
-
- case m68340SIM_PORTB1:
- logerror("%08x m68340_internal_sim_w %04x, %02x (PORTB1 - Port B Data - mirror)\n", pc, offset,data);
- break;
-
- case m68340SIM_DDRB:
- logerror("%08x m68340_internal_sim_w %04x, %02x (DDR - Port B Data Direction)\n", pc, offset,data);
- break;
-
- case m68340SIM_PPARB:
- logerror("%08x m68340_internal_sim_w %04x, %02x (PPARB - Port B Pin Assignment)\n", pc, offset,data);
- break;
-
- default:
- logerror("%08x m68340_internal_sim_w %04x, %02x (ILLEGAL?)\n", pc, offset,data);
- break;
-
- }
- }
-}
-
-WRITE32_MEMBER( m68340cpu_device::m68340_internal_sim_cs_w )
-{
- offset += m68340SIM_AM_CS0>>2;
- m68340cpu_device *m68k = this;
- m68340_sim* sim = m68k->m68340SIM;
- assert(sim != NULL);
-
- if (sim)
- {
- int pc = space.device().safe_pc();
-
- switch (offset<<2)
- {
- case m68340SIM_AM_CS0:
- COMBINE_DATA(&sim->m_am[0]);
- break;
-
- case m68340SIM_BA_CS0:
- COMBINE_DATA(&sim->m_ba[0]);
- break;
-
- case m68340SIM_AM_CS1:
- COMBINE_DATA(&sim->m_am[1]);
- break;
-
- case m68340SIM_BA_CS1:
- COMBINE_DATA(&sim->m_ba[1]);
- break;
-
- case m68340SIM_AM_CS2:
- COMBINE_DATA(&sim->m_am[2]);
- break;
-
- case m68340SIM_BA_CS2:
- COMBINE_DATA(&sim->m_ba[2]);
- break;
-
- case m68340SIM_AM_CS3:
- COMBINE_DATA(&sim->m_am[3]);
- break;
-
- case m68340SIM_BA_CS3:
- COMBINE_DATA(&sim->m_ba[3]);
- break;
-
- default:
- logerror("%08x m68340_internal_sim_w %08x, %08x (%08x)\n", pc, offset*4,data,mem_mask);
- break;
-
- }
- }
-
-}
-
-void m68340cpu_device::do_timer_irq(void)
-{
- //logerror("do_timer_irq\n");
- int timer_irq_level = (m_picr & 0x0700)>>8;
- int timer_irq_vector = (m_picr & 0x00ff)>>0;
-
- if (timer_irq_level) // 0 is irq disabled
- {
- int use_autovector = (m_avr >> timer_irq_level)&1;
-
- if (use_autovector)
- {
- //logerror("irq with autovector\n");
- set_input_line(timer_irq_level, HOLD_LINE);
- }
- else
- {
- //logerror("irq without autovector\n");
- set_input_line_and_vector(timer_irq_level, HOLD_LINE, timer_irq_vector);
- }
-
- }
-}
-
-TIMER_CALLBACK_MEMBER(m68340cpu_device::periodic_interrupt_timer_callback)
-{
- do_timer_irq();
- m_irq_timer->adjust(cycles_to_attotime(20000)); // hack
-}
-
-void m68340cpu_device::start_68340_sim(void)
-{
- m_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(m68340cpu_device::periodic_interrupt_timer_callback),this));
-}
-
-void m68340_sim::reset(void)
-{
-}
diff --git a/src/emu/machine/68340sim.h b/src/emu/machine/68340sim.h
deleted file mode 100644
index 493fa9805ce..00000000000
--- a/src/emu/machine/68340sim.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-
-#include "cpu/m68000/m68000.h"
-
-#define m68340SIM_MCR (0x00)
-// (0x02)
-#define m68340SIM_SYNCR (0x04)
-#define m68340SIM_AVR_RSR (0x06)
-// (0x08)
-// (0x0a)
-// (0x0c)
-// (0x0e)
-#define m68340SIM_PORTA (0x11)
-#define m68340SIM_DDRA (0x13)
-#define m68340SIM_PPRA1 (0x15)
-#define m68340SIM_PPRA2 (0x17)
-#define m68340SIM_PORTB (0x19)
-#define m68340SIM_PORTB1 (0x1b)
-#define m68340SIM_DDRB (0x1d)
-#define m68340SIM_PPARB (0x1f)
-#define m68340SIM_SWIV_SYPCR (0x20)
-#define m68340SIM_PICR (0x22)
-#define m68340SIM_PITR (0x24)
-#define m68340SIM_SWSR (0x26)
-// (0x28)
-// (0x2a)
-// (0x2c)
-// (0x2e)
-// (0x30)
-// (0x32)
-// (0x34)
-// (0x36)
-// (0x38)
-// (0x3a)
-// (0x3c)
-// (0x3e)
-#define m68340SIM_AM_CS0 (0x40)
-#define m68340SIM_BA_CS0 (0x44)
-#define m68340SIM_AM_CS1 (0x48)
-#define m68340SIM_BA_CS1 (0x4c)
-#define m68340SIM_AM_CS2 (0x50)
-#define m68340SIM_BA_CS2 (0x54)
-#define m68340SIM_AM_CS3 (0x58)
-#define m68340SIM_BA_CS3 (0x5c)
-
-
-
-
-
-
-class m68340_sim
-{
- public:
-
- UINT32 m_am[4];
- UINT32 m_ba[4];
-
- void reset(void);
-};
diff --git a/src/emu/machine/68340tmu.c b/src/emu/machine/68340tmu.c
deleted file mode 100644
index f8109214ba0..00000000000
--- a/src/emu/machine/68340tmu.c
+++ /dev/null
@@ -1,39 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* 68340 TIMER module */
-
-#include "emu.h"
-#include "68340.h"
-
-
-READ32_MEMBER( m68340cpu_device::m68340_internal_timer_r )
-{
- m68340cpu_device *m68k = this;
- m68340_timer* timer = m68k->m68340TIMER;
- assert(timer != NULL);
-
- if (timer)
- {
- int pc = space.device().safe_pc();
- logerror("%08x m68340_internal_timer_r %08x, (%08x)\n", pc, offset*4,mem_mask);
- }
-
- return 0x00000000;
-}
-
-WRITE32_MEMBER( m68340cpu_device::m68340_internal_timer_w )
-{
- m68340cpu_device *m68k = this;
- m68340_timer* timer = m68k->m68340TIMER;
- assert(timer != NULL);
-
- if (timer)
- {
- int pc = space.device().safe_pc();
- logerror("%08x m68340_internal_timer_w %08x, %08x (%08x)\n", pc, offset*4,data,mem_mask);
- }
-}
-
-void m68340_timer::reset(void)
-{
-}
diff --git a/src/emu/machine/68340tmu.h b/src/emu/machine/68340tmu.h
deleted file mode 100644
index a892e2792d8..00000000000
--- a/src/emu/machine/68340tmu.h
+++ /dev/null
@@ -1,10 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-#include "cpu/m68000/m68000.h"
-
-
-class m68340_timer
-{
- public:
- void reset(void);
-};
diff --git a/src/emu/machine/6840ptm.c b/src/emu/machine/6840ptm.c
deleted file mode 100644
index 239498f681c..00000000000
--- a/src/emu/machine/6840ptm.c
+++ /dev/null
@@ -1,755 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:James Wallace
-/***************************************************************************
-
- Motorola 6840 (PTM)
-
- Programmable Timer Module
-
- Written By J.Wallace based on previous work by Aaron Giles,
- 'Re-Animator' and Mathis Rosenhauer.
-
- Todo:
- Confirm handling for 'Single Shot' operation.
- (Datasheet suggests that output starts high, going low
- on timeout, opposite of continuous case)
- Establish whether ptm6840_set_c? routines can replace
- hard coding of external clock frequencies.
-
-
- Operation:
- The interface is arranged as follows:
-
- Internal Clock frequency,
- Clock 1 frequency, Clock 2 frequency, Clock 3 frequency,
- Clock 1 output, Clock 2 output, Clock 3 output,
- IRQ function
-
- If the external clock frequencies are not fixed, they should be
- entered as '0', and the ptm6840_set_c?(which, state) functions
- should be used instead if necessary (This should allow the VBLANK
- clock on the MCR units to operate).
-
-
- 2009-06 Converted to be a device
-
-***************************************************************************/
-
-#include "emu.h"
-#include "6840ptm.h"
-
-
-#define PTMVERBOSE 0
-#define PLOG(x) do { if (PTMVERBOSE) logerror x; } while (0)
-
-/***************************************************************************
- LOCAL VARIABLES
-***************************************************************************/
-
-const char *const ptm6840_device::opmode[] =
-{
- "000 continuous mode",
- "001 freq comparison mode",
- "010 continuous mode",
- "011 pulse width comparison mode",
- "100 single shot mode",
- "101 freq comparison mode",
- "110 single shot mode",
- "111 pulse width comparison mode"
-};
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-// device type definition
-const device_type PTM6840 = &device_creator<ptm6840_device>;
-
-//-------------------------------------------------
-// ptm6840_device - constructor
-//-------------------------------------------------
-
-ptm6840_device::ptm6840_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, PTM6840, "6840 PTM", tag, owner, clock, "ptm6840", __FILE__),
- m_internal_clock(0.0),
- m_out0_cb(*this),
- m_out1_cb(*this),
- m_out2_cb(*this),
- m_irq_cb(*this)
-{
- m_external_clock[0] = m_external_clock[1] = m_external_clock[2] = 0.0;
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ptm6840_device::device_start()
-{
- // resolve callbacks
- m_out0_cb.resolve_safe();
- m_out1_cb.resolve_safe();
- m_out2_cb.resolve_safe();
- m_irq_cb.resolve_safe();
-
- for (int i = 0; i < 3; i++)
- {
- if ( m_external_clock[i] == 0 )
- m_external_clock[i] = 1;
- }
-
- m_timer[0] = timer_alloc(0);
- m_timer[1] = timer_alloc(1);
- m_timer[2] = timer_alloc(2);
-
- for (int i = 0; i < 3; i++)
- {
- m_timer[i]->enable(false);
- }
-
- // register for state saving
- save_item(NAME(m_lsb_buffer));
- save_item(NAME(m_msb_buffer));
- save_item(NAME(m_status_read_since_int));
- save_item(NAME(m_status_reg));
- save_item(NAME(m_t3_divisor));
- save_item(NAME(m_t3_scaler));
- save_item(NAME(m_internal_clock));
- save_item(NAME(m_IRQ));
-
- save_item(NAME(m_control_reg));
- save_item(NAME(m_output));
- save_item(NAME(m_gate));
- save_item(NAME(m_clk));
- save_item(NAME(m_mode));
- save_item(NAME(m_fired));
- save_item(NAME(m_enabled));
- save_item(NAME(m_external_clock));
- save_item(NAME(m_counter));
- save_item(NAME(m_latch));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ptm6840_device::device_reset()
-{
- m_control_reg[2] = 0;
- m_control_reg[1] = 0;
- m_control_reg[0] = 1;
- m_status_reg = 0;
- m_t3_divisor = 1;
- m_status_read_since_int = 0;
- m_IRQ = 0;
- m_t3_scaler = 0;
- for (int i = 0; i < 3; i++)
- {
- m_counter[i] = 0xffff;
- m_latch[i] = 0xffff;
- m_output[i] = 0;
- m_fired[i] = 0;
- m_enabled[i] = 0;
- m_mode[i] = 0;
- }
-}
-
-
-//-------------------------------------------------
-// device_timer - handle timer callbacks
-//-------------------------------------------------
-
-void ptm6840_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- timeout(id);
-}
-
-
-//-------------------------------------------------
-// subtract_from_counter - Subtract from Counter
-//-------------------------------------------------
-
-void ptm6840_device::subtract_from_counter(int counter, int count)
-{
- double clock;
-
- // Determine the clock frequency for this timer
- if (m_control_reg[counter] & 0x02)
- {
- clock = m_internal_clock;
- }
- else
- {
- clock = m_external_clock[counter];
- }
-
- // Dual-byte mode
- if (m_control_reg[counter] & 0x04)
- {
- int lsb = m_counter[counter] & 0xff;
- int msb = m_counter[counter] >> 8;
-
- // Count the clocks
- lsb -= count;
-
- // Loop while we're less than zero
- while (lsb < 0)
- {
- // Borrow from the MSB
- lsb += (m_latch[counter] & 0xff) + 1;
- msb--;
-
- // If MSB goes less than zero, we've expired
- if (msb < 0)
- {
- timeout(counter);
- msb = (m_latch[counter] >> 8) + 1;
- }
- }
-
- // Store the result
- m_counter[counter] = (msb << 8) | lsb;
- }
-
- // Word mode
- else
- {
- int word = m_counter[counter];
-
- // Count the clocks
- word -= count;
-
- // loop while we're less than zero
- while (word < 0)
- {
- // Borrow from the MSB
- word += m_latch[counter] + 1;
-
- // We've expired
- timeout(counter);
- }
-
- // Store the result
- m_counter[counter] = word;
- }
-
- if (m_enabled[counter])
- {
- attotime duration = attotime::from_hz(clock) * m_counter[counter];
-
- if (counter == 2)
- {
- duration *= m_t3_divisor;
- }
-
- m_timer[counter]->adjust(duration);
- }
-}
-
-
-
-//-------------------------------------------------
-// tick
-//-------------------------------------------------
-
-void ptm6840_device::tick(int counter, int count)
-{
- if (counter == 2)
- {
- m_t3_scaler += count;
-
- if ( m_t3_scaler > m_t3_divisor - 1)
- {
- subtract_from_counter(counter, 1);
- m_t3_scaler = 0;
- }
- }
- else
- {
- subtract_from_counter(counter, count);
- }
-}
-
-
-
-//-------------------------------------------------
-// update_interrupts - Update Internal Interrupts
-//-------------------------------------------------
-
-void ptm6840_device::update_interrupts()
-{
- int new_state = ((m_status_reg & 0x01) && (m_control_reg[0] & 0x40)) ||
- ((m_status_reg & 0x02) && (m_control_reg[1] & 0x40)) ||
- ((m_status_reg & 0x04) && (m_control_reg[2] & 0x40));
-
- if (new_state != m_IRQ)
- {
- m_IRQ = new_state;
-
- if (m_IRQ)
- {
- m_status_reg |= 0x80;
- }
- else
- {
- m_status_reg &= ~0x80;
- }
-
- m_irq_cb(m_IRQ);
- }
-}
-
-
-
-//-------------------------------------------------
-// compute_counter - Compute Counter
-//-------------------------------------------------
-
-UINT16 ptm6840_device::compute_counter( int counter ) const
-{
- double clock;
-
- // If there's no timer, return the count
- if (!m_enabled[counter])
- {
- PLOG(("MC6840 #%s: read counter(%d): %d\n", tag(), counter, m_counter[counter]));
- return m_counter[counter];
- }
-
- // determine the clock frequency for this timer
- if (m_control_reg[counter] & 0x02)
- {
- clock = m_internal_clock;
- PLOG(("MC6840 #%s: %d internal clock freq %f \n", tag(), counter, clock));
- }
- else
- {
- clock = m_external_clock[counter];
- PLOG(("MC6840 #%s: %d external clock freq %f \n", tag(), counter, clock));
- }
- // See how many are left
- int remaining = (m_timer[counter]->remaining() * clock).as_double();
-
- // Adjust the count for dual byte mode
- if (m_control_reg[counter] & 0x04)
- {
- int divisor = (m_counter[counter] & 0xff) + 1;
- int msb = remaining / divisor;
- int lsb = remaining % divisor;
- remaining = (msb << 8) | lsb;
- }
- PLOG(("MC6840 #%s: read counter(%d): %d\n", tag(), counter, remaining));
- return remaining;
-}
-
-
-
-//-------------------------------------------------
-// reload_count - Reload Counter
-//-------------------------------------------------
-
-void ptm6840_device::reload_count(int idx)
-{
- double clock;
-
- // Copy the latched value in
- m_counter[idx] = m_latch[idx];
-
- // Determine the clock frequency for this timer
- if (m_control_reg[idx] & 0x02)
- {
- clock = m_internal_clock;
- PLOG(("MC6840 #%s: %d internal clock freq %f \n", tag(), idx, clock));
- }
- else
- {
- clock = m_external_clock[idx];
- PLOG(("MC6840 #%s: %d external clock freq %f \n", tag(), idx, clock));
- }
-
- // Determine the number of clock periods before we expire
- int count = m_counter[idx];
- if (m_control_reg[idx] & 0x04)
- {
- count = ((count >> 8) + 1) * ((count & 0xff) + 1);
- }
- else
- {
- count = count + 1;
- }
-
- m_fired[idx] = 0;
-
- if ((m_mode[idx] == 4) || (m_mode[idx] == 6))
- {
- m_output[idx] = 1;
- switch (idx)
- {
- case 0:
- m_out0_cb((offs_t)0, m_output[0]);
- break;
- case 1:
- m_out1_cb((offs_t)0, m_output[1]);
- break;
- case 2:
- m_out2_cb((offs_t)0, m_output[2]);
- break;
- }
- }
-
- // Set the timer
- PLOG(("MC6840 #%s: reload_count(%d): clock = %f count = %d\n", tag(), idx, clock, count));
-
- attotime duration = attotime::from_hz(clock) * count;
- if (idx == 2)
- {
- duration *= m_t3_divisor;
- }
-
- PLOG(("MC6840 #%s: reload_count(%d): output = %f\n", tag(), idx, duration.as_double()));
-
-#if 0
- if (!(m_control_reg[idx] & 0x02))
- {
- if (!m_external_clock[idx])
- {
- m_enabled[idx] = 0;
- m_timer[idx]->enable(false);
- }
- }
- else
-#endif
- {
- m_enabled[idx] = 1;
- m_timer[idx]->adjust(duration);
- m_timer[idx]->enable(true);
- }
-}
-
-
-
-//-------------------------------------------------
-// read - Read Timer
-//-------------------------------------------------
-
-READ8_MEMBER( ptm6840_device::read )
-{
- int val;
-
- switch ( offset )
- {
- case PTM_6840_CTRL1:
- {
- val = 0;
- break;
- }
-
- case PTM_6840_STATUS:
- {
- PLOG(("%s: MC6840 #%s: Status read = %04X\n", machine().describe_context(), tag(), m_status_reg));
- m_status_read_since_int |= m_status_reg & 0x07;
- val = m_status_reg;
- break;
- }
-
- case PTM_6840_MSBBUF1:
- case PTM_6840_MSBBUF2:
- case PTM_6840_MSBBUF3:
- {
- int idx = (offset - 2) / 2;
- int result = compute_counter(idx);
-
- // Clear the interrupt if the status has been read
- if (m_status_read_since_int & (1 << idx))
- {
- m_status_reg &= ~(1 << idx);
- update_interrupts();
- }
-
- m_lsb_buffer = result & 0xff;
-
- PLOG(("%s: MC6840 #%s: Counter %d read = %04X\n", machine().describe_context(), tag(), idx, result >> 8));
- val = result >> 8;
- break;
- }
-
- case PTM_6840_LSB1:
- case PTM_6840_LSB2:
- case PTM_6840_LSB3:
- {
- val = m_lsb_buffer;
- break;
- }
-
- default:
- {
- val = 0;
- break;
- }
-
- }
- return val;
-}
-
-
-//-------------------------------------------------
-// write - Write Timer
-//-------------------------------------------------
-
-WRITE8_MEMBER( ptm6840_device::write )
-{
- switch ( offset )
- {
- case PTM_6840_CTRL1:
- case PTM_6840_CTRL2:
- {
- int idx = (offset == 1) ? 1 : (m_control_reg[1] & 0x01) ? 0 : 2;
- UINT8 diffs = data ^ m_control_reg[idx];
- m_t3_divisor = (m_control_reg[2] & 0x01) ? 8 : 1;
- m_mode[idx] = (data >> 3) & 0x07;
- m_control_reg[idx] = data;
-
- PLOG(("MC6840 #%s : Control register %d selected\n", tag(), idx));
- PLOG(("operation mode = %s\n", opmode[ m_mode[idx] ]));
- PLOG(("value = %04X\n", m_control_reg[idx]));
- PLOG(("t3divisor = %d\n", m_t3_divisor));
-
- if (!(m_control_reg[idx] & 0x80 ))
- {
- // Output cleared
- switch (idx)
- {
- case 0:
- m_out0_cb((offs_t)0, 0);
- break;
- case 1:
- m_out1_cb((offs_t)0, 0);
- break;
- case 2:
- m_out2_cb((offs_t)0, 0);
- break;
- }
- }
- // Reset?
- if (idx == 0 && (diffs & 0x01))
- {
- // Holding reset down
- if (data & 0x01)
- {
- PLOG(("MC6840 #%s : Timer reset\n", tag()));
- for (int i = 0; i < 3; i++)
- {
- m_timer[i]->enable(false);
- m_enabled[i] = 0;
- }
- }
- // Releasing reset
- else
- {
- for (int i = 0; i < 3; i++)
- {
- reload_count(i);
- }
- }
-
- m_status_reg = 0;
- update_interrupts();
-
- // Changing the clock source? (e.g. Zwackery)
- if (diffs & 0x02)
- {
- reload_count(idx);
- }
- }
- break;
- }
-
- case PTM_6840_MSBBUF1:
- case PTM_6840_MSBBUF2:
- case PTM_6840_MSBBUF3:
- {
- PLOG(("MC6840 #%s msbbuf%d = %02X\n", tag(), offset / 2, data));
- m_msb_buffer = data;
- break;
- }
-
- case PTM_6840_LSB1:
- case PTM_6840_LSB2:
- case PTM_6840_LSB3:
- {
- int idx = (offset - 3) / 2;
- m_latch[idx] = (m_msb_buffer << 8) | (data & 0xff);
-
- // Clear the interrupt
- m_status_reg &= ~(1 << idx);
- update_interrupts();
-
- // Reload the count if in an appropriate mode
- if (!(m_control_reg[idx] & 0x10))
- {
- reload_count(idx);
- }
-
- PLOG(("%s:MC6840 #%s: Counter %d latch = %04X\n", machine().describe_context(), tag(), idx, m_latch[idx]));
- break;
- }
- }
-}
-
-
-//-------------------------------------------------
-// timeout - Called if timer is mature
-//-------------------------------------------------
-
-void ptm6840_device::timeout(int idx)
-{
- PLOG(("**ptm6840 %s t%d timeout**\n", tag(), idx));
-
- // Set the interrupt flag
- m_status_reg |= (1 << idx);
- m_status_read_since_int &= ~(1 << idx);
- update_interrupts();
-
- if ( m_control_reg[idx] & 0x80 )
- {
- if ((m_mode[idx] == 0)||(m_mode[idx] == 2))
- {
- m_output[idx] = m_output[idx] ? 0 : 1;
- PLOG(("**ptm6840 %s t%d output %d **\n", tag(), idx, m_output[idx]));
-
- switch (idx)
- {
- case 0:
- m_out0_cb((offs_t)0, m_output[0]);
- break;
- case 1:
- m_out1_cb((offs_t)0, m_output[1]);
- break;
- case 2:
- m_out2_cb((offs_t)0, m_output[2]);
- break;
- }
- }
- if ((m_mode[idx] == 4)||(m_mode[idx] == 6))
- {
- if (!m_fired[idx])
- {
- m_output[idx] = 1;
- PLOG(("**ptm6840 %s t%d output %d **\n", tag(), idx, m_output[idx]));
-
- switch (idx)
- {
- case 0:
- m_out0_cb((offs_t)0, m_output[0]);
- break;
- case 1:
- m_out1_cb((offs_t)0, m_output[1]);
- break;
- case 2:
- m_out2_cb((offs_t)0, m_output[2]);
- break;
- }
-
- // No changes in output until reinit
- m_fired[idx] = 1;
-
- m_status_reg |= (1 << idx);
- m_status_read_since_int &= ~(1 << idx);
- update_interrupts();
- }
- }
- }
- m_enabled[idx]= 0;
- reload_count(idx);
-}
-
-
-//-------------------------------------------------
-// set_gate - set gate status (0 or 1)
-//-------------------------------------------------
-
-void ptm6840_device::set_gate(int idx, int state)
-{
- if ((m_mode[idx] & 1) == 0)
- {
- if (state == 0 && m_gate[idx])
- {
- reload_count(idx);
- }
- }
- m_gate[idx] = state;
-}
-
-WRITE_LINE_MEMBER( ptm6840_device::set_g1 ) { set_gate(0, state); }
-WRITE_LINE_MEMBER( ptm6840_device::set_g2 ) { set_gate(1, state); }
-WRITE_LINE_MEMBER( ptm6840_device::set_g3 ) { set_gate(2, state); }
-
-
-//-------------------------------------------------
-// set_clock - set clock status (0 or 1)
-//-------------------------------------------------
-
-void ptm6840_device::set_clock(int idx, int state)
-{
- m_clk[idx] = state;
-
- if (!(m_control_reg[idx] & 0x02))
- {
- if (state)
- {
- tick(idx, 1);
- }
- }
-}
-
-WRITE_LINE_MEMBER( ptm6840_device::set_c1 ) { set_clock(0, state); }
-WRITE_LINE_MEMBER( ptm6840_device::set_c2 ) { set_clock(1, state); }
-WRITE_LINE_MEMBER( ptm6840_device::set_c3 ) { set_clock(2, state); }
-
-
-//-------------------------------------------------
-// set_ext_clock - set external clock frequency
-//-------------------------------------------------
-
-void ptm6840_device::set_ext_clock(int counter, double clock)
-{
- m_external_clock[counter] = clock;
-
- if (!(m_control_reg[counter] & 0x02))
- {
- if (!m_external_clock[counter])
- {
- m_enabled[counter] = 0;
- m_timer[counter]->enable(false);
- }
- }
- else
- {
- int count;
- attotime duration;
-
- // Determine the number of clock periods before we expire
- count = m_counter[counter];
-
- if (m_control_reg[counter] & 0x04)
- {
- count = ((count >> 8) + 1) * ((count & 0xff) + 1);
- }
- else
- {
- count = count + 1;
- }
-
- duration = attotime::from_hz(clock) * count;
-
- if (counter == 2)
- {
- duration *= m_t3_divisor;
- }
-
- m_enabled[counter] = 1;
- m_timer[counter]->adjust(duration);
- m_timer[counter]->enable(true);
- }
-}
diff --git a/src/emu/machine/6840ptm.h b/src/emu/machine/6840ptm.h
deleted file mode 100644
index d00577d62d0..00000000000
--- a/src/emu/machine/6840ptm.h
+++ /dev/null
@@ -1,148 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:James Wallace
-/***************************************************************************
-
- Motorola 6840 (PTM)
-
- Programmable Timer Module
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __6840PTM_H__
-#define __6840PTM_H__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// DEVICE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_PTM6840_INTERNAL_CLOCK(_clk) \
- ptm6840_device::set_internal_clock(*device, _clk);
-
-#define MCFG_PTM6840_EXTERNAL_CLOCKS(_clk0, _clk1, _clk2) \
- ptm6840_device::set_external_clocks(*device, _clk0, _clk1, _clk2);
-
-#define MCFG_PTM6840_OUT0_CB(_devcb) \
- devcb = &ptm6840_device::set_out0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_PTM6840_OUT1_CB(_devcb) \
- devcb = &ptm6840_device::set_out1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_PTM6840_OUT2_CB(_devcb) \
- devcb = &ptm6840_device::set_out2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_PTM6840_IRQ_CB(_devcb) \
- devcb = &ptm6840_device::set_irq_callback(*device, DEVCB_##_devcb);
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> ptm6840_device
-
-class ptm6840_device : public device_t
-{
-public:
- // construction/destruction
- ptm6840_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void set_internal_clock(device_t &device, double clock) { downcast<ptm6840_device &>(device).m_internal_clock = clock; }
- static void set_external_clocks(device_t &device, double clock0, double clock1, double clock2) { downcast<ptm6840_device &>(device).m_external_clock[0] = clock0; downcast<ptm6840_device &>(device).m_external_clock[1] = clock1; downcast<ptm6840_device &>(device).m_external_clock[2] = clock2; }
- template<class _Object> static devcb_base &set_out0_callback(device_t &device, _Object object) { return downcast<ptm6840_device &>(device).m_out0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out1_callback(device_t &device, _Object object) { return downcast<ptm6840_device &>(device).m_out1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out2_callback(device_t &device, _Object object) { return downcast<ptm6840_device &>(device).m_out2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<ptm6840_device &>(device).m_irq_cb.set_callback(object); }
-
- int status(int clock) const { return m_enabled[clock]; } // get whether timer is enabled
- int irq_state() const { return m_IRQ; } // get IRQ state
- UINT16 count(int counter) const { return compute_counter(counter); } // get counter value
- void set_ext_clock(int counter, double clock); // set clock frequency
- int ext_clock(int counter) const { return m_external_clock[counter]; } // get clock frequency
-
- DECLARE_WRITE8_MEMBER( write );
- void write(offs_t offset, UINT8 data) { write(machine().driver_data()->generic_space(), offset, data); }
- DECLARE_READ8_MEMBER( read );
- UINT8 read(offs_t offset) { return read(machine().driver_data()->generic_space(), offset); }
-
- void set_gate(int idx, int state);
- DECLARE_WRITE_LINE_MEMBER( set_g1 );
- DECLARE_WRITE_LINE_MEMBER( set_g2 );
- DECLARE_WRITE_LINE_MEMBER( set_g3 );
-
- void set_clock(int idx, int state);
- DECLARE_WRITE_LINE_MEMBER( set_c1 );
- DECLARE_WRITE_LINE_MEMBER( set_c2 );
- DECLARE_WRITE_LINE_MEMBER( set_c3 );
-
- void update_interrupts();
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- void subtract_from_counter(int counter, int count);
- void tick(int counter, int count);
- void timeout(int idx);
-
- UINT16 compute_counter(int counter) const;
- void reload_count(int idx);
-
- enum
- {
- PTM_6840_CTRL1 = 0,
- PTM_6840_CTRL2 = 1,
- PTM_6840_STATUS = 1,
- PTM_6840_MSBBUF1 = 2,
- PTM_6840_LSB1 = 3,
- PTM_6840_MSBBUF2 = 4,
- PTM_6840_LSB2 = 5,
- PTM_6840_MSBBUF3 = 6,
- PTM_6840_LSB3 = 7
- };
-
- double m_internal_clock;
- double m_external_clock[3];
-
- devcb_write8 m_out0_cb;
- devcb_write8 m_out1_cb;
- devcb_write8 m_out2_cb;
- devcb_write_line m_irq_cb; // function called if IRQ line changes
-
- UINT8 m_control_reg[3];
- UINT8 m_output[3]; // Output states
- UINT8 m_gate[3]; // Input gate states
- UINT8 m_clk[3]; // Clock states
- UINT8 m_enabled[3];
- UINT8 m_mode[3];
- UINT8 m_fired[3];
- UINT8 m_t3_divisor;
- UINT8 m_t3_scaler;
- UINT8 m_IRQ;
- UINT8 m_status_reg;
- UINT8 m_status_read_since_int;
- UINT8 m_lsb_buffer;
- UINT8 m_msb_buffer;
-
- // Each PTM has 3 timers
- emu_timer *m_timer[3];
-
- UINT16 m_latch[3];
- UINT16 m_counter[3];
-
- static const char *const opmode[];
-};
-
-
-// device type definition
-extern const device_type PTM6840;
-
-
-#endif /* __6840PTM_H__ */
diff --git a/src/emu/machine/6850acia.c b/src/emu/machine/6850acia.c
deleted file mode 100644
index 7c1fcc85178..00000000000
--- a/src/emu/machine/6850acia.c
+++ /dev/null
@@ -1,597 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*********************************************************************
-
- 6850acia.c
-
- 6850 ACIA code
-
-*********************************************************************/
-
-#include "emu.h"
-#include "6850acia.h"
-
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-#define LOG 0
-
-/***************************************************************************
- LOCAL VARIABLES
-***************************************************************************/
-
-const int acia6850_device::counter_divide_select[4] =
-{
- 1,
- 16,
- 64,
- 0
-};
-
-const int acia6850_device::word_select[8][3] =
-{
- // word length, parity, stop bits
- { 7, PARITY_EVEN, 2 },
- { 7, PARITY_ODD, 2 },
- { 7, PARITY_EVEN, 1 },
- { 7, PARITY_ODD, 1 },
- { 8, PARITY_NONE, 2 },
- { 8, PARITY_NONE, 1 },
- { 8, PARITY_EVEN, 1 },
- { 8, PARITY_ODD, 1 }
-};
-
-const int acia6850_device::transmitter_control[4][3] =
-{
- // rts, brk, tx irq
- { 0, 0, 0 },
- { 0, 0, 1 },
- { 1, 0, 0 },
- { 0, 1, 0 }
-};
-
-
-/***************************************************************************
- LIVE DEVICE
-***************************************************************************/
-
-// device type definition
-const device_type ACIA6850 = &device_creator<acia6850_device>;
-
-//-------------------------------------------------
-// acia6850_device - constructor
-//-------------------------------------------------
-
-acia6850_device::acia6850_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, ACIA6850, "6850 ACIA", tag, owner, clock, "acia6850", __FILE__),
- m_txd_handler(*this),
- m_rts_handler(*this),
- m_irq_handler(*this),
- m_status(SR_TDRE),
- m_tdr(0),
- m_first_master_reset(true),
- m_dcd_irq_pending(false),
- m_overrun_pending(false),
- m_divide(0),
- m_rts(0),
- m_dcd(0),
- m_irq(0),
- m_txc(0),
- m_txd(0),
- m_tx_counter(0),
- m_tx_irq_enable(false),
- m_rxc(0),
- m_rxd(1),
- m_rx_irq_enable(false)
-{
-}
-
-acia6850_device::acia6850_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_txd_handler(*this),
- m_rts_handler(*this),
- m_irq_handler(*this),
- m_status(SR_TDRE),
- m_tdr(0),
- m_first_master_reset(true),
- m_dcd_irq_pending(false),
- m_overrun_pending(false),
- m_divide(0),
- m_rts(0),
- m_dcd(0),
- m_irq(0),
- m_txc(0),
- m_txd(0),
- m_tx_counter(0),
- m_tx_irq_enable(false),
- m_rxc(0),
- m_rxd(1),
- m_rx_irq_enable(false)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void acia6850_device::device_start()
-{
- // resolve callbacks
- m_txd_handler.resolve_safe();
- m_rts_handler.resolve_safe();
- m_irq_handler.resolve_safe();
-
- save_item(NAME(m_status));
- save_item(NAME(m_tdr));
- save_item(NAME(m_rdr));
-
- save_item(NAME(m_first_master_reset));
- save_item(NAME(m_dcd_irq_pending));
- save_item(NAME(m_overrun_pending));
-
- save_item(NAME(m_divide));
- save_item(NAME(m_bits));
- save_item(NAME(m_stopbits));
- save_item(NAME(m_parity));
- save_item(NAME(m_brk));
-
- save_item(NAME(m_rts));
- save_item(NAME(m_dcd));
- save_item(NAME(m_irq));
-
- save_item(NAME(m_txc));
- save_item(NAME(m_txd));
- save_item(NAME(m_tx_state));
- save_item(NAME(m_tx_bits));
- save_item(NAME(m_tx_shift));
- save_item(NAME(m_tx_parity));
- save_item(NAME(m_tx_counter));
- save_item(NAME(m_tx_irq_enable));
-
- save_item(NAME(m_rxc));
- save_item(NAME(m_rxd));
- save_item(NAME(m_rx_state));
- save_item(NAME(m_rx_bits));
- save_item(NAME(m_rx_shift));
- save_item(NAME(m_rx_parity));
- save_item(NAME(m_rx_counter));
- save_item(NAME(m_rx_irq_enable));
-
- output_txd(1);
- output_rts(1);
- output_irq(1);
-}
-
-READ8_MEMBER( acia6850_device::status_r )
-{
- UINT8 status = m_status;
-
- if (status & SR_CTS)
- {
- status &= ~SR_TDRE;
- }
-
- if (m_dcd_irq_pending == DCD_IRQ_READ_STATUS)
- {
- m_dcd_irq_pending = DCD_IRQ_READ_DATA;
- }
-
- return status;
-}
-
-WRITE8_MEMBER( acia6850_device::control_w )
-{
- if (LOG) logerror("MC6850 '%s' Control: %02x\n", tag(), data);
-
- // CR0 & CR1
- int counter_divide_select_bits = (data >> 0) & 3;
- m_divide = counter_divide_select[counter_divide_select_bits];
-
- // CR2, CR3 & CR4
- int word_select_bits = (data >> 2) & 7;
- m_bits = word_select[word_select_bits][0];
- m_parity = word_select[word_select_bits][1];
- m_stopbits = word_select[word_select_bits][2];
-
- // CR5 & CR6
- int transmitter_control_bits = (data >> 5) & 3;
- int rts = transmitter_control[transmitter_control_bits][0];
- m_brk = transmitter_control[transmitter_control_bits][1];
- m_tx_irq_enable = transmitter_control[transmitter_control_bits][2];
-
- // CR7
- m_rx_irq_enable = (data >> 7) & 1;
-
- if (m_divide == 0)
- {
- if (m_first_master_reset)
- {
- /// TODO: find out whether you need to leave master reset before it stops counting as the first
- rts = 1;
- m_first_master_reset = false;
- }
-
- m_dcd_irq_pending = DCD_IRQ_NONE;
- m_overrun_pending = false;
-
- m_rx_state = STATE_START;
- m_rx_counter = 0;
-
- m_tx_state = STATE_START;
- output_txd(1);
-
- m_status &= SR_CTS;
-
- if (m_dcd)
- {
- m_status |= SR_DCD;
- }
- }
-
- output_rts(rts);
-
- update_irq();
-}
-
-
-int acia6850_device::calculate_txirq()
-{
- return !(m_tx_irq_enable && ((m_status & SR_TDRE) && !(m_status & SR_CTS)));
-}
-
-int acia6850_device::calculate_rxirq()
-{
- return !(m_rx_irq_enable && ((m_status & SR_RDRF) || m_dcd_irq_pending != DCD_IRQ_NONE));
-}
-
-void acia6850_device::update_irq()
-{
- output_irq(calculate_txirq() && calculate_rxirq());
-}
-
-WRITE8_MEMBER( acia6850_device::data_w )
-{
- if (LOG) logerror("MC6850 '%s' Data: %02x\n", tag(), data);
-
- /// TODO: find out if data stored during master reset is sent after divider is set
- if (m_divide == 0)
- {
- logerror("%s:ACIA %p: Data write while in reset!\n", machine().describe_context(), (void *)this);
- }
-
- /// TODO: find out what happens if TDRE is already clear when you write
- m_tdr = data;
- m_status &= ~SR_TDRE;
-
- update_irq();
-}
-
-READ8_MEMBER( acia6850_device::data_r )
-{
- if (m_overrun_pending)
- {
- m_status |= SR_OVRN;
- m_overrun_pending = false;
- }
- else
- {
- m_status &= ~SR_OVRN;
- m_status &= ~SR_RDRF;
- }
-
- if (m_dcd_irq_pending == DCD_IRQ_READ_DATA)
- {
- m_dcd_irq_pending = DCD_IRQ_NONE;
- }
-
- update_irq();
-
- return m_rdr;
-}
-
-DECLARE_WRITE_LINE_MEMBER( acia6850_device::write_cts )
-{
- if (state)
- {
- m_status |= SR_CTS;
- }
- else
- {
- m_status &= ~SR_CTS;
- }
-}
-
-DECLARE_WRITE_LINE_MEMBER( acia6850_device::write_dcd )
-{
- m_dcd = state;
-}
-
-WRITE_LINE_MEMBER( acia6850_device::write_rxc )
-{
- if (m_rxc != state)
- {
- m_rxc = state;
-
- if (state && m_divide > 0)
- {
- if (m_dcd)
- {
- if (!(m_status & SR_DCD))
- {
- m_status |= SR_DCD;
- m_dcd_irq_pending = DCD_IRQ_READ_STATUS;
- }
-
- m_rx_state = STATE_START;
- m_rx_counter = 0;
- }
- else
- {
- if (m_dcd_irq_pending == DCD_IRQ_NONE)
- {
- m_status &= ~SR_DCD;
- }
-
- m_rx_counter++;
-
- switch (m_rx_state)
- {
- case STATE_START:
- if (m_rxd == 0)
- {
- if (m_rx_counter == 1)
- {
- if (LOG) logerror("MC6850 '%s': RX START BIT\n", tag());
- }
-
- if (m_rx_counter >= m_divide / 2)
- {
- m_rx_state = STATE_DATA;
- m_rx_counter = 0;
- m_rx_shift = 0;
- m_rx_parity = 0;
- m_rx_bits = 0;
- }
- }
- else
- {
- if (m_rx_counter != 1)
- {
- if (LOG) logerror("MC6850 '%s': RX FALSE START BIT\n", tag());
- }
-
- m_rx_counter = 0;
- }
- break;
-
- case STATE_DATA:
- if (m_rx_counter == m_divide)
- {
- m_rx_counter = 0;
-
- if (m_rx_bits < m_bits)
- {
- if (LOG) logerror("MC6850 '%s': RX DATA BIT %d %d\n", tag(), m_rx_bits, m_rxd);
- }
- else
- {
- if (LOG) logerror("MC6850 '%s': RX PARITY BIT %x\n", tag(), m_rxd);
- }
-
- if (m_rxd)
- {
- m_rx_shift |= 1 << m_rx_bits;
- }
-
- m_rx_bits++;
-
- m_rx_parity ^= m_rxd;
-
- if ((m_rx_bits == m_bits && m_parity == PARITY_NONE) ||
- (m_rx_bits == (m_bits + 1) && m_parity != PARITY_NONE))
- {
- if (m_status & SR_RDRF)
- {
- m_overrun_pending = true;
- }
- else
- {
- /// TODO: find out if this is the correct place to calculate parity
- if (m_parity == PARITY_ODD)
- {
- m_rx_parity = !m_rx_parity;
- }
-
- if (m_parity != PARITY_NONE && m_rx_parity)
- {
- m_status |= SR_PE;
- }
- else
- {
- m_status &= ~SR_PE;
- }
-
- m_rdr = m_rx_shift;
-
- if (m_bits == 7 && m_parity != PARITY_NONE)
- {
- m_rdr &= 0x7f;
- }
-
- m_status |= SR_RDRF;
- }
-
- m_rx_state = STATE_STOP;
- }
- }
- break;
-
- case STATE_STOP:
- if (m_rx_counter == m_divide)
- {
- m_rx_counter = 0;
-
- if (LOG) logerror("MC6850 '%s': RX STOP BIT\n", tag());
-
- if (!m_rxd)
- {
- m_status |= SR_FE;
- }
- else
- {
- m_status &= ~SR_FE;
- }
-
- /// TODO: find out if 6850 only waits for 1 STOP bit when receiving
- m_rx_state = STATE_START;
- }
- break;
- }
- }
-
- update_irq();
- }
- }
-}
-
-DECLARE_WRITE_LINE_MEMBER( acia6850_device::write_rxd )
-{
- m_rxd = state;
-}
-
-WRITE_LINE_MEMBER( acia6850_device::write_txc )
-{
- if (m_txc != state)
- {
- m_txc = state;
-
- if (!state && m_divide > 0)
- {
- m_tx_counter++;
-
- /// TODO: check txd is correctly generated, check atarist mcu is reading data, start checking receive data.
- switch (m_tx_state)
- {
- case STATE_START:
- m_tx_counter = 0;
-
- if (!(m_status & SR_TDRE) && !(m_status & SR_CTS))
- {
- if (LOG) logerror("MC6850 '%s': TX DATA %x\n", tag(), m_tdr);
-
- m_tx_state = STATE_DATA;
- m_tx_shift = m_tdr;
- m_tx_bits = 0;
- m_tx_parity = 0;
- m_status |= SR_TDRE;
-
- if (LOG) logerror("MC6850 '%s': TX START BIT\n", tag());
-
- output_txd(0);
- }
- else
- {
- /// TODO: find out if break stops transmitter
- output_txd(!m_brk);
- }
- break;
-
- case STATE_DATA:
- if (m_tx_counter == m_divide)
- {
- m_tx_counter = 0;
-
- if (m_tx_bits < m_bits)
- {
- output_txd((m_tx_shift >> m_tx_bits) & 1);
-
- m_tx_bits++;
- m_tx_parity ^= m_txd;
-
- if (LOG) logerror("MC6850 '%s': TX DATA BIT %d %d\n", tag(), m_tx_bits, m_txd);
- }
- else if (m_tx_bits == m_bits && m_parity != PARITY_NONE)
- {
- m_tx_bits++;
-
- /// TODO: find out if this is the correct place to calculate parity
- if (m_parity == PARITY_ODD)
- {
- m_tx_parity = !m_tx_parity;
- }
-
- output_txd(m_tx_parity);
-
- if (LOG) logerror("MC6850 '%s': TX PARITY BIT %d\n", tag(), m_txd);
- }
- else
- {
- m_tx_state = STATE_STOP;
- m_tx_bits = 0;
-
- output_txd(1);
- }
- }
- break;
-
- case STATE_STOP:
- if (m_tx_counter == m_divide)
- {
- m_tx_counter = 0;
-
- m_tx_bits++;
-
- if (LOG) logerror("MC6850 '%s': TX STOP BIT %d\n", tag(), m_tx_bits);
-
- if (m_tx_bits == m_stopbits)
- {
- m_tx_state = STATE_START;
- }
- }
- break;
- }
- }
-
- update_irq();
- }
-}
-
-void acia6850_device::output_txd(int txd)
-{
- if (m_txd != txd)
- {
- m_txd = txd;
-
- m_txd_handler(m_txd);
- }
-}
-
-void acia6850_device::output_rts(int rts)
-{
- if (m_rts != rts)
- {
- m_rts = rts;
- m_rts_handler(m_rts);
- }
-}
-
-void acia6850_device::output_irq(int irq)
-{
- if (m_irq != irq)
- {
- m_irq = irq;
-
- if (irq)
- {
- m_status &= ~SR_IRQ;
- }
- else
- {
- m_status |= SR_IRQ;
- }
-
- m_irq_handler(!m_irq);
- }
-}
diff --git a/src/emu/machine/6850acia.h b/src/emu/machine/6850acia.h
deleted file mode 100644
index 8bb1a3891bd..00000000000
--- a/src/emu/machine/6850acia.h
+++ /dev/null
@@ -1,145 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*********************************************************************
-
- 6850acia.h
-
- 6850 ACIA code
-
-*********************************************************************/
-
-#pragma once
-
-#ifndef __ACIA6850_H__
-#define __ACIA6850_H__
-
-#include "emu.h"
-
-#define MCFG_ACIA6850_TXD_HANDLER(_devcb) \
- devcb = &acia6850_device::set_txd_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_ACIA6850_RTS_HANDLER(_devcb) \
- devcb = &acia6850_device::set_rts_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_ACIA6850_IRQ_HANDLER(_devcb) \
- devcb = &acia6850_device::set_irq_handler(*device, DEVCB_##_devcb);
-
-class acia6850_device : public device_t
-{
-public:
- // construction/destruction
- acia6850_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_txd_handler(device_t &device, _Object object) { return downcast<acia6850_device &>(device).m_txd_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_rts_handler(device_t &device, _Object object) { return downcast<acia6850_device &>(device).m_rts_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_irq_handler(device_t &device, _Object object) { return downcast<acia6850_device &>(device).m_irq_handler.set_callback(object); }
-
- DECLARE_WRITE8_MEMBER( control_w );
- DECLARE_READ8_MEMBER( status_r );
- DECLARE_WRITE8_MEMBER( data_w );
- DECLARE_READ8_MEMBER( data_r );
-
- DECLARE_WRITE_LINE_MEMBER( write_cts );
- DECLARE_WRITE_LINE_MEMBER( write_dcd );
- DECLARE_WRITE_LINE_MEMBER( write_rxd );
- DECLARE_WRITE_LINE_MEMBER( write_rxc );
- DECLARE_WRITE_LINE_MEMBER( write_txc );
-
-protected:
- acia6850_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- // device-level overrides
- virtual void device_start();
-
- virtual void update_irq();
- int calculate_txirq();
- int calculate_rxirq();
-
-private:
- void output_txd(int txd);
- void output_rts(int txd);
- void output_irq(int irq);
-
- enum
- {
- SR_RDRF = 0x01,
- SR_TDRE = 0x02,
- SR_DCD = 0x04,
- SR_CTS = 0x08,
- SR_FE = 0x10,
- SR_OVRN = 0x20,
- SR_PE = 0x40,
- SR_IRQ = 0x80
- };
-
- enum serial_state
- {
- STATE_START,
- STATE_DATA,
- STATE_STOP
- };
-
- enum parity_type
- {
- PARITY_NONE,
- PARITY_ODD,
- PARITY_EVEN
- };
-
- enum dcd_irq_state
- {
- DCD_IRQ_NONE = 0,
- DCD_IRQ_READ_DATA,
- DCD_IRQ_READ_STATUS
- };
-
- devcb_write_line m_txd_handler;
- devcb_write_line m_rts_handler;
- devcb_write_line m_irq_handler;
-
- UINT8 m_status;
- UINT8 m_tdr;
- UINT8 m_rdr;
-
- bool m_first_master_reset;
- int m_dcd_irq_pending;
- bool m_overrun_pending;
-
- int m_divide;
- int m_bits;
- int m_stopbits;
- int m_parity;
- int m_brk;
-
- int m_rts;
- int m_dcd;
- int m_irq;
-
- int m_txc;
- int m_txd;
- int m_tx_state;
- int m_tx_bits;
- int m_tx_shift;
- int m_tx_parity;
- int m_tx_counter;
- int m_tx_irq_enable;
-
- int m_rxc;
- int m_rxd;
- int m_rx_state;
- int m_rx_bits;
- int m_rx_shift;
- int m_rx_parity;
- int m_rx_counter;
- int m_rx_irq_enable;
-
- static const int counter_divide_select[4];
- static const int word_select[8][3];
- static const int transmitter_control[4][3];
-};
-
-// device type definition
-extern const device_type ACIA6850;
-
-#endif /* __ACIA6850_H__ */
diff --git a/src/emu/machine/68561mpcc.c b/src/emu/machine/68561mpcc.c
deleted file mode 100644
index 1b8a8895fed..00000000000
--- a/src/emu/machine/68561mpcc.c
+++ /dev/null
@@ -1,481 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Sergey Svishchev
-/*********************************************************************
-
- 68561mpcc.c
-
- Rockwell 68561 MPCC (Multi Protocol Communications Controller)
-
- skeleton driver, just enough for besta.c console to work
-
-*********************************************************************/
-
-
-#include "emu.h"
-#include "68561mpcc.h"
-
-const device_type MPCC68561 = &device_creator<mpcc68561_t>;
-
-
-/***************************************************************************
- PARAMETERS
-***************************************************************************/
-
-#define LOG_MPCC (1)
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-mpcc68561_t::mpcc68561_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, MPCC68561, "Rockwell 68561 MPCC", tag, owner, clock, "mpcc68561", __FILE__),
- intrq_cb(*this)
-{
-}
-
-/*-------------------------------------------------
- mpcc_updateirqs
--------------------------------------------------*/
-
-void mpcc68561_t::updateirqs()
-{
- int irqstat;
-
- irqstat = 0;
- if (MasterIRQEnable)
- {
- if ((channel[0].txIRQEnable) && (channel[0].txIRQPending))
- {
- IRQType = IRQ_B_TX;
- irqstat = 1;
- }
- else if ((channel[1].txIRQEnable) && (channel[1].txIRQPending))
- {
- IRQType = IRQ_A_TX;
- irqstat = 1;
- }
- else if ((channel[0].extIRQEnable) && (channel[0].extIRQPending))
- {
- IRQType = IRQ_B_EXT;
- irqstat = 1;
- }
- else if ((channel[1].extIRQEnable) && (channel[1].extIRQPending))
- {
- IRQType = IRQ_A_EXT;
- irqstat = 1;
- }
- }
- else
- {
- IRQType = IRQ_NONE;
- }
-
-// printf("mpcc: irqstat %d, last %d\n", irqstat, lastIRQStat);
-// printf("ch0: en %d pd %d ch1: en %d pd %d\n", channel[0].txIRQEnable, channel[0].txIRQPending, channel[1].txIRQEnable, channel[1].txIRQPending);
-
- // don't spam the driver with unnecessary transitions
- if (irqstat != lastIRQStat)
- {
- lastIRQStat = irqstat;
-
- // tell the driver the new IRQ line status if possible
-#if LOG_MPCC
- printf("mpcc68561 IRQ status => %d\n", irqstat);
-#endif
- if(!intrq_cb.isnull())
- intrq_cb(irqstat);
- }
-}
-
-/*-------------------------------------------------
- mpcc_initchannel
--------------------------------------------------*/
-void mpcc68561_t::initchannel(int ch)
-{
- channel[ch].syncHunt = 1;
-}
-
-/*-------------------------------------------------
- mpcc_resetchannel
--------------------------------------------------*/
-void mpcc68561_t::resetchannel(int ch)
-{
- emu_timer *timersave = channel[ch].baudtimer;
-
- memset(&channel[ch], 0, sizeof(Chan));
-
- channel[ch].txUnderrun = 1;
- channel[ch].baudtimer = timersave;
-
- channel[ch].baudtimer->adjust(attotime::never, ch);
-}
-
-/*-------------------------------------------------
- mpcc68561_baud_expire - baud rate timer expiry
--------------------------------------------------*/
-
-void mpcc68561_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- Chan *pChan = &channel[id];
- int brconst = pChan->reg_val[13]<<8 | pChan->reg_val[14];
- int rate;
-
- if (brconst)
- {
- rate = clock() / brconst;
- }
- else
- {
- rate = 0;
- }
-
- // is baud counter IRQ enabled on this channel?
- // always flag pending in case it's enabled after this
- pChan->baudIRQPending = 1;
- if (pChan->baudIRQEnable)
- {
- if (pChan->extIRQEnable)
- {
- pChan->extIRQPending = 1;
- pChan->baudIRQPending = 0;
- updateirqs();
- }
- }
-
- // reset timer according to current register values
- if (rate)
- {
- timer.adjust(attotime::from_hz(rate), 0, attotime::from_hz(rate));
- }
- else
- {
- timer.adjust(attotime::never, 0, attotime::never);
- }
-}
-
-/*-------------------------------------------------
- device_start - device-specific startup
--------------------------------------------------*/
-
-void mpcc68561_t::device_start()
-{
- intrq_cb.resolve_safe();
-
- memset(channel, 0, sizeof(channel));
-
- mode = 0;
- reg = 0;
- status = 0;
- IRQV = 0;
- MasterIRQEnable = 0;
- lastIRQStat = 0;
- IRQType = IRQ_NONE;
-
- channel[0].baudtimer = timer_alloc(0);
-}
-
-
-/*-------------------------------------------------
- device_reset - device-specific reset
--------------------------------------------------*/
-void mpcc68561_t::device_reset()
-{
- IRQType = IRQ_NONE;
- MasterIRQEnable = 0;
- IRQV = 0;
-
- initchannel(0);
- resetchannel(0);
-}
-
-/*-------------------------------------------------
- mpcc_set_status
--------------------------------------------------*/
-
-void mpcc68561_t::set_status(int _status)
-{
- status = _status;
-}
-
-/*-------------------------------------------------
- mpcc_acknowledge
--------------------------------------------------*/
-
-void mpcc68561_t::acknowledge()
-{
- if(!intrq_cb.isnull())
- intrq_cb(0);
-}
-
-/*-------------------------------------------------
- mpcc_getreg
--------------------------------------------------*/
-
-UINT8 mpcc68561_t::getreg()
-{
- /* Not yet implemented */
- #if LOG_MPCC
- printf("mpcc: port A reg %d read 0x%02x\n", reg, channel[0].reg_val[reg]);
- #endif
-
- if (reg == 0)
- {
- UINT8 rv = 0;
-
- Chan *ourCh = &channel[0];
-
- rv |= (ourCh->txUnderrun) ? 0x40 : 0;
- rv |= (ourCh->syncHunt) ? 0x10 : 0;
- rv |= channel[0].reg_val[0] & 0x05; // pick up TXBE and RXBF bits
-
- return rv;
- }
- else if (reg == 10)
- {
- return 0;
- }
- return channel[0].reg_val[reg];
-}
-
-/*-------------------------------------------------
- mpcc_putreg
--------------------------------------------------*/
-
-void mpcc68561_t::putreg(int ch, UINT8 data)
-{
- Chan *pChan = &channel[ch];
-
- channel[ch].reg_val[reg] = data;
- #if LOG_MPCC
- printf("mpcc: port %c reg %d write 0x%02x\n", 'A'+ch, reg, data);
- #endif
-
- switch (reg)
- {
- case 0: // command register
- switch ((data >> 3) & 7)
- {
- case 1: // select high registers (handled elsewhere)
- break;
-
- case 2: // reset external and status IRQs
- pChan->syncHunt = 0;
- break;
-
- case 5: // ack Tx IRQ
- pChan->txIRQPending = 0;
- updateirqs();
- break;
-
- case 0: // nothing
- case 3: // send SDLC abort
- case 4: // enable IRQ on next Rx byte
- case 6: // reset errors
- case 7: // reset highest IUS
- // we don't handle these yet
- break;
-
- }
- break;
-
- case 1: // Tx/Rx IRQ and data transfer mode defintion
- pChan->extIRQEnable = (data & 1);
- pChan->txIRQEnable = (data & 2) ? 1 : 0;
- pChan->rxIRQEnable = (data >> 3) & 3;
- updateirqs();
- break;
-
- case 2: // IRQ vector
- IRQV = data;
- break;
-
- case 3: // Rx parameters and controls
- pChan->rxEnable = (data & 1);
- pChan->syncHunt = (data & 0x10) ? 1 : 0;
- break;
-
- case 5: // Tx parameters and controls
-// printf("ch %d TxEnable = %d [%02x]\n", ch, data & 8, data);
- pChan->txEnable = data & 8;
-
- if (pChan->txEnable)
- {
- pChan->reg_val[0] |= 0x04; // Tx empty
- }
- break;
-
- case 4: // Tx/Rx misc parameters and modes
- case 6: // sync chars/SDLC address field
- case 7: // sync char/SDLC flag
- break;
-
- case 9: // master IRQ control
- MasterIRQEnable = (data & 8) ? 1 : 0;
- updateirqs();
-
- // channel reset command
- switch ((data>>6) & 3)
- {
- case 0: // do nothing
- break;
-
- case 1: // reset channel B
- resetchannel(0);
- break;
-
- case 3: // force h/w reset (entire chip)
- IRQType = IRQ_NONE;
- MasterIRQEnable = 0;
- IRQV = 0;
-
- initchannel(0);
- resetchannel(0);
-
- // make sure we stop yanking the IRQ line if we were
- updateirqs();
- break;
-
- }
- break;
-
- case 10: // misc transmitter/receiver control bits
- case 11: // clock mode control
- case 12: // lower byte of baud rate gen
- case 13: // upper byte of baud rate gen
- break;
-
- case 14: // misc control bits
- if (data & 0x01) // baud rate generator enable?
- {
- int brconst = pChan->reg_val[13]<<8 | pChan->reg_val[14];
- int rate = clock() / brconst;
-
- pChan->baudtimer->adjust(attotime::from_hz(rate), 0, attotime::from_hz(rate));
- }
- break;
-
- case 15: // external/status interrupt control
- pChan->baudIRQEnable = (data & 2) ? 1 : 0;
- pChan->DCDEnable = (data & 8) ? 1 : 0;
- pChan->CTSEnable = (data & 0x20) ? 1 : 0;
- pChan->txUnderrunEnable = (data & 0x40) ? 1 : 0;
- break;
- }
-}
-
-/*-------------------------------------------------
- mpcc68561_get_reg_a
--------------------------------------------------*/
-
-UINT8 mpcc68561_t::get_reg_a(int reg)
-{
- return channel[0].reg_val[reg];
-}
-
-
-
-/*-------------------------------------------------
- mpcc68561_set_reg_a
--------------------------------------------------*/
-
-void mpcc68561_t::set_reg_a(int reg, UINT8 data)
-{
- channel[0].reg_val[reg] = data;
-}
-
-
-
-/*-------------------------------------------------
- mpcc68561_r
--------------------------------------------------*/
-
-READ8_MEMBER( mpcc68561_t::reg_r)
-{
- UINT8 result = 0;
-
- offset %= 4;
-
- switch(offset)
- {
- case 1:
- /* Channel A (Modem Port) Control */
- if (mode == 1)
- mode = 0;
- else
- reg = 0;
-
- result = getreg();
- break;
-
- case 3:
- /* Channel A (Modem Port) Data */
- return channel[0].rxData;
- break;
- }
- return result;
-}
-
-
-
-/*-------------------------------------------------
- mpcc68561_w
--------------------------------------------------*/
-
-WRITE8_MEMBER( mpcc68561_t::reg_w )
-{
- Chan *pChan;
-
- offset &= 3;
-
-// printf(" mode %d data %x offset %d \n", mode, data, offset);
-
- switch(offset)
- {
- case 1:
- /* Channel A (Modem Port) Control */
- if (mode == 0)
- {
- if((data & 0xf0) == 0) // not a reset command
- {
- mode = 1;
- reg = data & 0x0f;
-// putareg(data & 0xf0);
- }
- else if (data == 0x10)
- {
- pChan = &channel[0];
- // clear ext. interrupts
- pChan->extIRQPending = 0;
- pChan->baudIRQPending = 0;
- updateirqs();
- }
- }
- else
- {
- mode = 0;
- putreg(0, data);
- }
- break;
-
- case 3:
- /* Channel A (Modem Port) Data */
- pChan = &channel[0];
-
- if (pChan->txEnable)
- {
- pChan->txData = data;
- // local loopback?
- if (pChan->reg_val[14] & 0x10)
- {
- pChan->rxData = data;
- pChan->reg_val[0] |= 0x01; // Rx character available
- }
- pChan->reg_val[1] |= 0x01; // All sent
- pChan->reg_val[0] |= 0x04; // Tx empty
- pChan->txUnderrun = 1;
- pChan->txIRQPending = 1;
- updateirqs();
- }
- break;
- }
-}
diff --git a/src/emu/machine/68561mpcc.h b/src/emu/machine/68561mpcc.h
deleted file mode 100644
index df036282f1c..00000000000
--- a/src/emu/machine/68561mpcc.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Sergey Svishchev
-/*********************************************************************
-
- 68561mpcc.h
-
- Rockwell 68561 MPCC (Multi Protocol Communications Controller)
-
- skeleton driver
-
-*********************************************************************/
-
-#ifndef __68561MPCC_H__
-#define __68561MPCC_H__
-
-#define MCFG_MPCC68561_INTRQ_CALLBACK(_write) \
- devcb = &mpcc68561_t::set_intrq_wr_callback(*device, DEVCB_##_write);
-
-class mpcc68561_t : public device_t
-{
-public:
- enum IRQType_t {
- IRQ_NONE,
- IRQ_A_RX,
- IRQ_A_RX_SPECIAL,
- IRQ_B_RX,
- IRQ_B_RX_SPECIAL,
- IRQ_A_TX,
- IRQ_B_TX,
- IRQ_A_EXT,
- IRQ_B_EXT
- };
-
- mpcc68561_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_intrq_wr_callback(device_t &device, _Object object) { return downcast<mpcc68561_t &>(device).intrq_cb.set_callback(object); }
-
- UINT8 get_reg_a(int reg);
- void set_reg_a(int reg, UINT8 data);
-
- void set_status(int status);
-
- DECLARE_READ8_MEMBER(reg_r);
- DECLARE_WRITE8_MEMBER(reg_w);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- struct Chan {
- bool txIRQEnable;
- bool rxIRQEnable;
- bool extIRQEnable;
- bool baudIRQEnable;
- bool txIRQPending;
- bool rxIRQPending;
- bool extIRQPending;
- bool baudIRQPending;
- bool txEnable;
- bool rxEnable;
- bool txUnderrun;
- bool txUnderrunEnable;
- bool syncHunt;
- bool DCDEnable;
- bool CTSEnable;
- UINT8 rxData;
- UINT8 txData;
-
- emu_timer *baudtimer;
-
- UINT8 reg_val[22];
- };
-
- int mode;
- int reg;
- int status;
- int IRQV;
- int MasterIRQEnable;
- int lastIRQStat;
- IRQType_t IRQType;
-
- Chan channel[2];
-
- devcb_write_line intrq_cb;
-
- void updateirqs();
- void initchannel(int ch);
- void resetchannel(int ch);
- void acknowledge();
- UINT8 getreg();
- void putreg(int ch, UINT8 data);
-};
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-extern const device_type MPCC68561;
-
-#endif /* __68561MPCC_H__ */
diff --git a/src/emu/machine/7200fifo.c b/src/emu/machine/7200fifo.c
deleted file mode 100644
index ee44eada962..00000000000
--- a/src/emu/machine/7200fifo.c
+++ /dev/null
@@ -1,138 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:hap
-/**********************************************************************
-
- IDT7200 series 9-bit Asynchronous FIFO Emulation
-
- TODO:
- - retransmit (RT pin)
- - cascaded width expansion mode (when needed)
-
-**********************************************************************/
-
-#include "machine/7200fifo.h"
-
-
-const device_type FIFO7200 = &device_creator<fifo7200_device>;
-
-//-------------------------------------------------
-// fifo7200_device - constructor
-//-------------------------------------------------
-
-fifo7200_device::fifo7200_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, FIFO7200, "IDT7200 FIFO", tag, owner, clock, "fifo7200", __FILE__),
- m_ram_size(0),
- m_ef_handler(*this),
- m_ff_handler(*this),
- m_hf_handler(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void fifo7200_device::device_start()
-{
- assert(m_ram_size > 1 && ~m_ram_size & 1);
- m_buffer.resize(m_ram_size);
-
- // resolve callbacks
- m_ef_handler.resolve_safe();
- m_ff_handler.resolve_safe();
- m_hf_handler.resolve_safe();
-
- // state save
- save_item(NAME(m_buffer));
- save_item(NAME(m_read_ptr));
- save_item(NAME(m_write_ptr));
- save_item(NAME(m_ef));
- save_item(NAME(m_ff));
- save_item(NAME(m_hf));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void fifo7200_device::device_reset()
-{
- // master reset
- m_buffer.clear();
- m_read_ptr = 0;
- m_write_ptr = 0;
-
- m_ef = 1;
- m_ff = 0;
- m_hf = 0;
-
- m_ef_handler(!m_ef);
- m_ff_handler(!m_ff);
- m_hf_handler(!m_hf);
-}
-
-
-
-void fifo7200_device::fifo_write(UINT16 data)
-{
- if (m_ff)
- {
- logerror("IDT7200 %s fifo_write overflow!\n", tag());
- return;
- }
-
- m_buffer[m_write_ptr] = data & 0x1ff;
- m_write_ptr = (m_write_ptr + 1) % m_ram_size;
-
- // update flags
- if (m_ef)
- {
- m_ef = 0;
- m_ef_handler(!m_ef);
- }
-
- else if (m_read_ptr == m_write_ptr)
- {
- m_ff = 1;
- m_ff_handler(!m_ff);
- }
-
- else if (((m_read_ptr + 1 + m_ram_size / 2) % m_ram_size) == m_write_ptr)
- {
- m_hf = 1;
- m_hf_handler(!m_hf);
- }
-}
-
-UINT16 fifo7200_device::fifo_read()
-{
- if (m_ef)
- {
- logerror("IDT7200 %s fifo_read underflow!\n", tag());
- return 0x1ff;
- }
-
- UINT16 ret = m_buffer[m_read_ptr];
- m_read_ptr = (m_read_ptr + 1) % m_ram_size;
-
- // update flags
- if (m_ff)
- {
- m_ff = 0;
- m_ff_handler(!m_ff);
- }
-
- else if (m_read_ptr == m_write_ptr)
- {
- m_ef = 1;
- m_ef_handler(!m_ef);
- }
-
- else if (((m_read_ptr + m_ram_size / 2) % m_ram_size) == m_write_ptr)
- {
- m_hf = 0;
- m_hf_handler(!m_hf);
- }
-
- return ret;
-}
diff --git a/src/emu/machine/7200fifo.h b/src/emu/machine/7200fifo.h
deleted file mode 100644
index 0f5c28e7048..00000000000
--- a/src/emu/machine/7200fifo.h
+++ /dev/null
@@ -1,132 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:hap
-/**********************************************************************
-
- IDT7200 series 9-bit Asynchronous FIFO Emulation
-
-**********************************************************************
- _____ _____
- _W 1 |* \_/ | 28 Vcc
- D8 2 | | 27 D4
- D3 3 | | 26 D5
- D2 4 | | 25 D6
- D1 5 | | 24 D7
- D0 6 | | 23 _FL/_RT
- _XI 7 | 7200 | 22 _MR
- _FF 8 | | 21 _EF
- Q0 9 | | 20 _XO/_HF
- Q1 10 | | 19 Q7
- Q2 11 | | 18 Q6
- Q3 12 | | 17 Q5
- Q8 13 | | 16 Q4
- GND 14 |_____________| 15 _R
-
-
-Known chips and buffer sizes are listed below. Note that in width or depth
-expansion mode (using more than one chip and XO/XI), it may be increased more.
-
- 256x9 512x9 1Kx9 2Kx9 4Kx9 8Kx9 16Kx9 32Kx9 64Kx9
- -------------------------------------------------------------------------------------------
- IDT7200 IDT7201 IDT7202 IDT7203 IDT7204 IDT7205 IDT7206 IDT7207 IDT7208
-
-The following chips are functionally equivalent and pin-compatible.
-
- AM7200 AM7201 AM7202 AM7203 AM7204
- MS7200 MS7201 MS7202 MS7203 MS7204
-
- LH5495 LH5496 LH5497 LH5498 LH5499
- LH540201 LH540202 LH540203 LH540204 LH540205 LH540206
-
- CY7C419 CY7C420 CY7C424 CY7C428 CY7C432
- CY7C421 CY7C425 CY7C429 CY7C433
-
-32-pin PLCC/LCC or TQFP configurations are also available.
-
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef _7200FIFO_H
-#define _7200FIFO_H
-
-#include "emu.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_FIFO7200_ADD(_tag, _ramsize) \
- MCFG_DEVICE_ADD(_tag, FIFO7200, 0) \
- fifo7200_device::set_ram_size(*device, _ramsize);
-
-#define MCFG_FIFO7200_EF_HANDLER(_devcb) \
- devcb = &fifo7200_device::set_ef_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_FIFO7200_FF_HANDLER(_devcb) \
- devcb = &fifo7200_device::set_ff_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_FIFO7200_HF_HANDLER(_devcb) \
- devcb = &fifo7200_device::set_hf_handler(*device, DEVCB_##_devcb);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> fifo7200_device
-
-class fifo7200_device : public device_t
-{
-public:
- fifo7200_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_ef_handler(device_t &device, _Object object) { return downcast<fifo7200_device &>(device).m_ef_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_ff_handler(device_t &device, _Object object) { return downcast<fifo7200_device &>(device).m_ff_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_hf_handler(device_t &device, _Object object) { return downcast<fifo7200_device &>(device).m_hf_handler.set_callback(object); }
- static void set_ram_size(device_t &device, int size) { downcast<fifo7200_device &>(device).m_ram_size = size; }
-
- DECLARE_READ_LINE_MEMBER( ef_r ) { return !m_ef; } // _EF
- DECLARE_READ_LINE_MEMBER( ff_r ) { return !m_ff; } // _FF
- DECLARE_READ_LINE_MEMBER( hf_r ) { return !m_hf; } // _HF
-
- // normal configuration
- DECLARE_WRITE16_MEMBER( data_word_w ) { fifo_write(data); }
- DECLARE_READ16_MEMBER( data_word_r ) { return (UINT16)fifo_read(); }
-
- // use these for simple configurations that don't have d8/q8 connected
- DECLARE_WRITE8_MEMBER( data_byte_w ) { fifo_write(data); }
- DECLARE_READ8_MEMBER( data_byte_r ) { return (UINT8)fifo_read(); }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- void fifo_write(UINT16 data);
- UINT16 fifo_read();
-
- std::vector<UINT16> m_buffer;
- int m_ram_size;
-
- int m_read_ptr;
- int m_write_ptr;
-
- int m_ef; // empty flag
- int m_ff; // full flag
- int m_hf; // half-full flag
-
- devcb_write_line m_ef_handler;
- devcb_write_line m_ff_handler;
- devcb_write_line m_hf_handler;
-};
-
-// device type definition
-extern const device_type FIFO7200;
-
-
-#endif /* _7200FIFO_H */
diff --git a/src/emu/machine/74123.c b/src/emu/machine/74123.c
deleted file mode 100644
index f88b71dfab8..00000000000
--- a/src/emu/machine/74123.c
+++ /dev/null
@@ -1,249 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Couriersud
-/*****************************************************************************
-
- 74123 monoflop emulator - see 74123.h for pin out and truth table
-
- Formulas came from the TI datasheet revised on March 1998
-
- *****************************************************************************/
-
-#include "emu.h"
-#include "machine/74123.h"
-#include "machine/rescap.h"
-
-
-#define LOG (0)
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type TTL74123 = &device_creator<ttl74123_device>;
-
-//-------------------------------------------------
-// ttl74123_device - constructor
-//-------------------------------------------------
-
-ttl74123_device::ttl74123_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, TTL74123, "74123 TTL", tag, owner, clock, "ttl74123", __FILE__),
- m_connection_type(TTL74123_NOT_GROUNDED_NO_DIODE),
- m_res(1.0),
- m_cap(1.0),
- m_a(0),
- m_b(0),
- m_clear(0),
- m_output_changed_cb(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ttl74123_device::device_start()
-{
- m_output_changed_cb.resolve_safe();
-
- m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ttl74123_device::clear_callback),this));
-
- /* register for state saving */
- save_item(NAME(m_a));
- save_item(NAME(m_b));
- save_item(NAME(m_clear));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ttl74123_device::device_reset()
-{
- set_output();
-}
-
-
-
-//-------------------------------------------------
-// compute_duration - compute timer duration
-//-------------------------------------------------
-
-attotime ttl74123_device::compute_duration()
-{
- double duration;
-
- switch (m_connection_type)
- {
- case TTL74123_NOT_GROUNDED_NO_DIODE:
- duration = 0.28 * m_res * m_cap * (1.0 + (700.0 / m_res));
- break;
-
- case TTL74123_NOT_GROUNDED_DIODE:
- duration = 0.25 * m_res * m_cap * (1.0 + (700.0 / m_res));
- break;
-
- case TTL74123_GROUNDED:
- default:
- if (m_cap < CAP_U(0.1))
- {
- /* this is really a curve - a very flat one in the 0.1uF-.01uF range */
- duration = 0.32 * m_res * m_cap;
- }
- else
- {
- duration = 0.33 * m_res * m_cap;
- }
- break;
- }
-
- return attotime::from_double(duration);
-}
-
-
-//-------------------------------------------------
-// timer_running - is the timer running?
-//-------------------------------------------------
-
-int ttl74123_device::timer_running()
-{
- return (m_timer->remaining() > attotime::zero) &&
- (m_timer->remaining() != attotime::never);
-}
-
-
-/*-------------------------------------------------
- TIMER_CALLBACK( output_callback )
--------------------------------------------------*/
-
-TIMER_CALLBACK_MEMBER( ttl74123_device::output_callback )
-{
- m_output_changed_cb((offs_t)0, param);
-}
-
-
-//-------------------------------------------------
-// set_output - set the output line state
-//-------------------------------------------------
-
-void ttl74123_device::set_output()
-{
- int output = timer_running();
-
- machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(ttl74123_device::output_callback ),this), output);
-
- if (LOG) logerror("74123 %s: Output: %d\n", tag(), output);
-}
-
-
-/*-------------------------------------------------
- TIMER_CALLBACK( clear_callback )
--------------------------------------------------*/
-
-TIMER_CALLBACK_MEMBER( ttl74123_device::clear_callback )
-{
- int output = timer_running();
-
- m_output_changed_cb((offs_t)0, output);
-}
-
-//-------------------------------------------------
-// start_pulse - begin timing
-//-------------------------------------------------
-
-void ttl74123_device::start_pulse()
-{
- attotime duration = compute_duration();
-
- if(timer_running())
- {
- /* retriggering, but not if we are called to quickly */
- attotime delay_time = attotime(0, ATTOSECONDS_PER_SECOND * m_cap * 220);
-
- if(m_timer->elapsed() >= delay_time)
- {
- m_timer->adjust(duration);
-
- if (LOG) logerror("74123 %s: Retriggering pulse. Duration: %f\n", tag(), duration.as_double());
- }
- else
- {
- if (LOG) logerror("74123 %s: Retriggering failed.\n", tag());
- }
- }
- else
- {
- /* starting */
- m_timer->adjust(duration);
-
- set_output();
-
- if (LOG) logerror("74123 %s: Starting pulse. Duration: %f\n", tag(), duration.as_double());
- }
-}
-
-
-//-------------------------------------------------
-// a_w - write register a data
-//-------------------------------------------------
-
-WRITE8_MEMBER( ttl74123_device::a_w )
-{
- /* start/regtrigger pulse if B=HI and falling edge on A (while clear is HI) */
- if (!data && m_a && m_b && m_clear)
- {
- start_pulse();
- }
-
- m_a = data;
-}
-
-
-//-------------------------------------------------
-// b_w - write register b data
-//-------------------------------------------------
-
-WRITE8_MEMBER( ttl74123_device::b_w)
-{
- /* start/regtrigger pulse if A=LO and rising edge on B (while clear is HI) */
- if (data && !m_b && !m_a && m_clear)
- {
- start_pulse();
- }
-
- m_b = data;
-}
-
-
-//-------------------------------------------------
-// clear_w - write register clear data
-//-------------------------------------------------
-
-WRITE8_MEMBER( ttl74123_device::clear_w)
-{
- /* start/regtrigger pulse if B=HI and A=LO and rising edge on clear */
- if (data && !m_a && m_b && !m_clear)
- {
- start_pulse();
- }
- else if (!data) /* clear the output */
- {
- m_timer->adjust(attotime::zero);
-
- if (LOG) logerror("74123 #%s: Cleared\n", tag() );
- }
- m_clear = data;
-}
-
-
-//-------------------------------------------------
-// reset_w - reset device
-//-------------------------------------------------
-
-WRITE8_MEMBER( ttl74123_device::reset_w)
-{
- set_output();
-}
diff --git a/src/emu/machine/74123.h b/src/emu/machine/74123.h
deleted file mode 100644
index 93325bdbeb1..00000000000
--- a/src/emu/machine/74123.h
+++ /dev/null
@@ -1,147 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Couriersud
-/*****************************************************************************
-
- 74123 monoflop emulator
-
- There are 2 monoflops per chips.
-
- Pin out:
-
- +--------+
- B1 |1 | | 16| Vcc
- A1 o|2 - 15| RCext1
- Clear1 o|3 14| Cext1
- *Output1 o|4 13| Output1
- Output2 |5 12|o *Output2
- Cext2 |6 11|o Clear2
- RCext2 |7 10| B2
- GND |8 9|o A2
- +--------+
-
- All resistor values in Ohms.
- All capacitor values in Farads.
-
-
- Truth table:
-
- C A B | Q /Q
- ----------|-------
- L X X | L H
- X H X | L H
- X X L | L H
- H L _- |_-_ -_-
- H -_ H |_-_ -_-
- _- L H |_-_ -_-
- ------------------
- C = clear
- L = LO (0)
- H = HI (1)
- X = any state
- _- = raising edge
- -_ = falling edge
- _-_ = positive pulse
- -_- = negative pulse
-
-*****************************************************************************/
-
-#pragma once
-
-#ifndef __TTL74123_H__
-#define __TTL74123_H__
-
-#include "emu.h"
-
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_TTL74123_CONNECTION_TYPE(_ctype) \
- ttl74123_device::set_connection_type(*device, _ctype);
-
-#define MCFG_TTL74123_RESISTOR_VALUE(_value) \
- ttl74123_device::set_resistor_value(*device, _value);
-
-#define MCFG_TTL74123_CAPACITOR_VALUE(_value) \
- ttl74123_device::set_capacitor_value(*device, _value);
-
-#define MCFG_TTL74123_A_PIN_VALUE(_value) \
- ttl74123_device::set_a_pin_value(*device, _value);
-
-#define MCFG_TTL74123_B_PIN_VALUE(_value) \
- ttl74123_device::set_b_pin_value(*device, _value);
-
-#define MCFG_TTL74123_CLEAR_PIN_VALUE(_value) \
- ttl74123_device::set_clear_pin_value(*device, _value);
-
-#define MCFG_TTL74123_OUTPUT_CHANGED_CB(_devcb) \
- devcb = &ttl74123_device::set_output_changed_callback(*device, DEVCB_##_devcb);
-
-/* constants for the different ways the cap/res can be connected.
- This determines the formula for calculating the pulse width */
-#define TTL74123_NOT_GROUNDED_NO_DIODE (1)
-#define TTL74123_NOT_GROUNDED_DIODE (2)
-#define TTL74123_GROUNDED (3)
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-// ======================> ttl74123_device
-
-class ttl74123_device : public device_t
-{
-public:
- // construction/destruction
- ttl74123_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void set_connection_type(device_t &device, int type) { downcast<ttl74123_device &>(device).m_connection_type = type; }
- static void set_resistor_value(device_t &device, double value) { downcast<ttl74123_device &>(device).m_res = value; }
- static void set_capacitor_value(device_t &device, double value) { downcast<ttl74123_device &>(device).m_cap = value; }
- static void set_a_pin_value(device_t &device, int value) { downcast<ttl74123_device &>(device).m_a = value; }
- static void set_b_pin_value(device_t &device, int value) { downcast<ttl74123_device &>(device).m_b = value; }
- static void set_clear_pin_value(device_t &device, int value) { downcast<ttl74123_device &>(device).m_clear = value; }
- template<class _Object> static devcb_base &set_output_changed_callback(device_t &device, _Object object) { return downcast<ttl74123_device &>(device).m_output_changed_cb.set_callback(object); }
-
- DECLARE_WRITE8_MEMBER(a_w);
- DECLARE_WRITE8_MEMBER(b_w);
- DECLARE_WRITE8_MEMBER(clear_w);
- DECLARE_WRITE8_MEMBER(reset_w);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_post_load() { }
- virtual void device_clock_changed() { }
-
- TIMER_CALLBACK_MEMBER( output_callback );
- TIMER_CALLBACK_MEMBER( clear_callback );
-
-private:
-
- int timer_running();
- void start_pulse();
- void output(INT32 param);
- void set_output();
- attotime compute_duration();
- void clear();
-
- emu_timer *m_timer;
- int m_connection_type; /* the hook up type - one of the constants above */
- double m_res; /* resistor connected to RCext */
- double m_cap; /* capacitor connected to Cext and RCext */
- int m_a; /* initial/constant value of the A pin */
- int m_b; /* initial/constant value of the B pin */
- int m_clear; /* initial/constant value of the Clear pin */
- devcb_write8 m_output_changed_cb;
-};
-
-
-// device type definition
-extern const device_type TTL74123;
-
-#endif
diff --git a/src/emu/machine/74145.c b/src/emu/machine/74145.c
deleted file mode 100644
index f85439398de..00000000000
--- a/src/emu/machine/74145.c
+++ /dev/null
@@ -1,142 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/*****************************************************************************
- *
- * TTL74145
- *
- *
- * BCD-to-Decimal decoder
- *
- * __ __
- * 0-| v |-VCC
- * 1-| |-A
- * 2-| |-B
- * 3-| |-C
- * 4-| |-D
- * 5-| |-9
- * 6-| |-8
- * GND-|_____|-7
- *
- *
- * Truth table
- * _______________________________
- * | Inputs | Outputs |
- * | D C B A | 0 1 2 3 4 5 6 7 8 9 |
- * |-------------------------------|
- * | L L L L | L H H H H H H H H H |
- * | L L L H | H L H H H H H H H H |
- * | L L H L | H H L H H H H H H H |
- * | L L H H | H H H L H H H H H H |
- * | L H L L | H H H H L H H H H H |
- * |-------------------------------|
- * | L H L H | H H H H H L H H H H |
- * | L H H L | H H H H H H L H H H |
- * | L H H H | H H H H H H H L H H |
- * | H L L L | H H H H H H H H L H |
- * | H L L H | H H H H H H H H H L |
- * |-------------------------------|
- * | H L H L | H H H H H H H H H H |
- * | H L H H | H H H H H H H H H H |
- * | H H L L | H H H H H H H H H H |
- * | H H L H | H H H H H H H H H H |
- * | H H H L | H H H H H H H H H H |
- * | H H H H | H H H H H H H H H H |
- * -------------------------------
- *
- ****************************************************************************/
-
-#include "emu.h"
-#include "74145.h"
-#include "coreutil.h"
-
-
-const device_type TTL74145 = &device_creator<ttl74145_device>;
-
-/***************************************************************************
- DEVICE INTERFACE
-***************************************************************************/
-//-------------------------------------------------
-// ttl74145_device - constructor
-//-------------------------------------------------
-
-ttl74145_device::ttl74145_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, TTL74145, "TTL74145", tag, owner, clock, "ttl74145", __FILE__)
- , m_output_line_0_cb(*this)
- , m_output_line_1_cb(*this)
- , m_output_line_2_cb(*this)
- , m_output_line_3_cb(*this)
- , m_output_line_4_cb(*this)
- , m_output_line_5_cb(*this)
- , m_output_line_6_cb(*this)
- , m_output_line_7_cb(*this)
- , m_output_line_8_cb(*this)
- , m_output_line_9_cb(*this)
- , m_number(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ttl74145_device::device_start()
-{
- /* resolve callbacks */
- m_output_line_0_cb.resolve_safe();
- m_output_line_1_cb.resolve_safe();
- m_output_line_2_cb.resolve_safe();
- m_output_line_3_cb.resolve_safe();
- m_output_line_4_cb.resolve_safe();
- m_output_line_5_cb.resolve_safe();
- m_output_line_6_cb.resolve_safe();
- m_output_line_7_cb.resolve_safe();
- m_output_line_8_cb.resolve_safe();
- m_output_line_9_cb.resolve_safe();
-
- // register for state saving
- save_item(NAME(m_number));
-}
-
-//-------------------------------------------------
-// device_start - device-specific reset
-//-------------------------------------------------
-
-void ttl74145_device::device_reset()
-{
- m_number = 0;
-}
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-void ttl74145_device::write(UINT8 data)
-{
- /* decode number */
- UINT16 new_number = bcd_2_dec(data & 0x0f);
-
- /* call output callbacks if the number changed */
- if (new_number != m_number)
- {
- m_output_line_0_cb(new_number == 0);
- m_output_line_1_cb(new_number == 1);
- m_output_line_2_cb(new_number == 2);
- m_output_line_3_cb(new_number == 3);
- m_output_line_4_cb(new_number == 4);
- m_output_line_5_cb(new_number == 5);
- m_output_line_6_cb(new_number == 6);
- m_output_line_7_cb(new_number == 7);
- m_output_line_8_cb(new_number == 8);
- m_output_line_9_cb(new_number == 9);
- }
-
- /* update state */
- m_number = new_number;
-}
-
-
-UINT16 ttl74145_device::read()
-{
- return (1 << m_number) & 0x3ff;
-}
diff --git a/src/emu/machine/74145.h b/src/emu/machine/74145.h
deleted file mode 100644
index 9b047207f1b..00000000000
--- a/src/emu/machine/74145.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- TTL74145
-
- BCD-to-Decimal decoder
-
-***************************************************************************/
-
-#ifndef __TTL74145_H__
-#define __TTL74145_H__
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-#define MCFG_TTL74145_OUTPUT_LINE_0_CB(_devcb) \
- devcb = &ttl74145_device::set_output_line_0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TTL74145_OUTPUT_LINE_1_CB(_devcb) \
- devcb = &ttl74145_device::set_output_line_1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TTL74145_OUTPUT_LINE_2_CB(_devcb) \
- devcb = &ttl74145_device::set_output_line_2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TTL74145_OUTPUT_LINE_3_CB(_devcb) \
- devcb = &ttl74145_device::set_output_line_3_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TTL74145_OUTPUT_LINE_4_CB(_devcb) \
- devcb = &ttl74145_device::set_output_line_4_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TTL74145_OUTPUT_LINE_5_CB(_devcb) \
- devcb = &ttl74145_device::set_output_line_5_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TTL74145_OUTPUT_LINE_6_CB(_devcb) \
- devcb = &ttl74145_device::set_output_line_6_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TTL74145_OUTPUT_LINE_7_CB(_devcb) \
- devcb = &ttl74145_device::set_output_line_7_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TTL74145_OUTPUT_LINE_8_CB(_devcb) \
- devcb = &ttl74145_device::set_output_line_8_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TTL74145_OUTPUT_LINE_9_CB(_devcb) \
- devcb = &ttl74145_device::set_output_line_9_callback(*device, DEVCB_##_devcb);
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> ttl74145_device
-
-class ttl74145_device : public device_t
-{
-public:
- // construction/destruction
- ttl74145_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_output_line_0_callback(device_t &device, _Object object) { return downcast<ttl74145_device &>(device).m_output_line_0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_output_line_1_callback(device_t &device, _Object object) { return downcast<ttl74145_device &>(device).m_output_line_1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_output_line_2_callback(device_t &device, _Object object) { return downcast<ttl74145_device &>(device).m_output_line_2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_output_line_3_callback(device_t &device, _Object object) { return downcast<ttl74145_device &>(device).m_output_line_3_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_output_line_4_callback(device_t &device, _Object object) { return downcast<ttl74145_device &>(device).m_output_line_4_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_output_line_5_callback(device_t &device, _Object object) { return downcast<ttl74145_device &>(device).m_output_line_5_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_output_line_6_callback(device_t &device, _Object object) { return downcast<ttl74145_device &>(device).m_output_line_6_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_output_line_7_callback(device_t &device, _Object object) { return downcast<ttl74145_device &>(device).m_output_line_7_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_output_line_8_callback(device_t &device, _Object object) { return downcast<ttl74145_device &>(device).m_output_line_8_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_output_line_9_callback(device_t &device, _Object object) { return downcast<ttl74145_device &>(device).m_output_line_9_cb.set_callback(object); }
-
- UINT16 read();
- void write(UINT8 data);
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- devcb_write_line m_output_line_0_cb;
- devcb_write_line m_output_line_1_cb;
- devcb_write_line m_output_line_2_cb;
- devcb_write_line m_output_line_3_cb;
- devcb_write_line m_output_line_4_cb;
- devcb_write_line m_output_line_5_cb;
- devcb_write_line m_output_line_6_cb;
- devcb_write_line m_output_line_7_cb;
- devcb_write_line m_output_line_8_cb;
- devcb_write_line m_output_line_9_cb;
-
- /* decoded number */
- UINT16 m_number;
-};
-
-// device type definition
-extern const device_type TTL74145;
-
-#endif /* TTL74145 */
diff --git a/src/emu/machine/74148.c b/src/emu/machine/74148.c
deleted file mode 100644
index 02d1be3927a..00000000000
--- a/src/emu/machine/74148.c
+++ /dev/null
@@ -1,198 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*****************************************************************************
-
- 74148 8-line-to-3-line priority encoder
-
-
- Pin layout and functions to access pins:
-
- input_line_w(4) [1] /IN4 VCC [16]
- input_line_w(5) [2] /IN5 /EO [15] enable_output_r
- input_line_w(6) [3] /IN6 /GS [14] output_valid_r
- input_line_w(7) [4] /IN7 /IN3 [13] input_line_w(3)
- enable_input_w [5] /EI /IN2 [12] input_line_w(2)
- output_r [6] /A2 /IN1 [11] input_line_w(1)
- output_r [7] /A1 /IN0 [10] input_line_w(0)
- [8] GND /A0 [9] output_r
-
-
- Truth table (all logic levels indicate the actual voltage on the line):
-
- INPUTS | OUTPUTS
- |
- EI I0 I1 I2 I3 I4 I5 I6 I7 | A2 A1 A0 | GS EO
- ----------------------------+----------+------
- 1 H X X X X X X X X | H H H | H H
- 2 L H H H H H H H H | H H H | H L
- 3 L X X X X X X X L | L L L | L H
- 4 L X X X X X X L H | L L H | L H
- 5 L X X X X X L H H | L H L | L H
- 6 L X X X X L H H H | L H H | L H
- 7 L X X X L H H H H | H L L | L H
- 8 L X X L H H H H H | H L H | L H
- 9 L X L H H H H H H | H H L | L H
- 10 L L H H H H H H H | H H H | L H
- ----------------------------+----------+------
- L = lo (0)
- H = hi (1)
- X = any state
-
-*****************************************************************************/
-
-#include "emu.h"
-#include "machine/74148.h"
-
-
-const device_type TTL74148 = &device_creator<ttl74148_device>;
-
-ttl74148_device::ttl74148_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, TTL74148, "74148 TTL", tag, owner, clock, "74148", __FILE__),
- m_enable_input(0),
- m_output(0),
- m_output_valid(0),
- m_enable_output(0),
- m_last_output(0),
- m_last_output_valid(0),
- m_last_enable_output(0)
-{
- for (int i = 0; i < 8; i++)
- m_input_lines[i] = 0;
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ttl74148_device::device_start()
-{
- m_output_cb.bind_relative_to(*owner());
-
- save_item(NAME(m_input_lines));
- save_item(NAME(m_enable_input));
- save_item(NAME(m_output));
- save_item(NAME(m_output_valid));
- save_item(NAME(m_enable_output));
- save_item(NAME(m_last_output));
- save_item(NAME(m_last_output_valid));
- save_item(NAME(m_last_enable_output));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ttl74148_device::device_reset()
-{
- m_enable_input = 1;
- m_input_lines[0] = 1;
- m_input_lines[1] = 1;
- m_input_lines[2] = 1;
- m_input_lines[3] = 1;
- m_input_lines[4] = 1;
- m_input_lines[5] = 1;
- m_input_lines[6] = 1;
- m_input_lines[7] = 1;
-
- m_last_output = -1;
- m_last_output_valid = -1;
- m_last_enable_output = -1;
-}
-
-
-void ttl74148_device::update()
-{
- if (m_enable_input)
- {
- // row 1 in truth table
- m_output = 0x07;
- m_output_valid = 1;
- m_enable_output = 1;
- }
- else
- {
- int bit0, bit1, bit2;
-
- /* this comes straight off the data sheet schematics */
- bit0 = !(((!m_input_lines[1]) &
- m_input_lines[2] &
- m_input_lines[4] &
- m_input_lines[6]) |
- ((!m_input_lines[3]) &
- m_input_lines[4] &
- m_input_lines[6]) |
- ((!m_input_lines[5]) &
- m_input_lines[6]) |
- (!m_input_lines[7]));
-
- bit1 = !(((!m_input_lines[2]) &
- m_input_lines[4] &
- m_input_lines[5]) |
- ((!m_input_lines[3]) &
- m_input_lines[4] &
- m_input_lines[5]) |
- (!m_input_lines[6]) |
- (!m_input_lines[7]));
-
- bit2 = !((!m_input_lines[4]) |
- (!m_input_lines[5]) |
- (!m_input_lines[6]) |
- (!m_input_lines[7]));
-
- m_output = (bit2 << 2) | (bit1 << 1) | bit0;
-
- m_output_valid = (m_input_lines[0] &
- m_input_lines[1] &
- m_input_lines[2] &
- m_input_lines[3] &
- m_input_lines[4] &
- m_input_lines[5] &
- m_input_lines[6] &
- m_input_lines[7]);
-
- m_enable_output = !m_output_valid;
- }
-
-
- /* call callback if any of the outputs changed */
- if (!m_output_cb.isnull() &&
- ((m_output != m_last_output) ||
- (m_output_valid != m_last_output_valid) || (m_enable_output != m_last_enable_output)))
- {
- m_last_output = m_output;
- m_last_output_valid = m_output_valid;
- m_last_enable_output = m_enable_output;
-
- m_output_cb();
- }
-}
-
-
-void ttl74148_device::input_line_w(int input_line, int data)
-{
- m_input_lines[input_line] = data ? 1 : 0;
-}
-
-
-void ttl74148_device::enable_input_w(int data)
-{
- m_enable_input = data ? 1 : 0;
-}
-
-
-int ttl74148_device::output_r()
-{
- return m_output;
-}
-
-
-int ttl74148_device::output_valid_r()
-{
- return m_output_valid;
-}
-
-
-int ttl74148_device::enable_output_r()
-{
- return m_enable_output;
-}
diff --git a/src/emu/machine/74148.h b/src/emu/machine/74148.h
deleted file mode 100644
index 294869de12f..00000000000
--- a/src/emu/machine/74148.h
+++ /dev/null
@@ -1,99 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*****************************************************************************
-
- 74148 8-line-to-3-line priority encoder
-
-
- Pin layout and functions to access pins:
-
- input_line_w(4) [1] /IN4 VCC [16]
- input_line_w(5) [2] /IN5 /EO [15] enable_output_r
- input_line_w(6) [3] /IN6 /GS [14] output_valid_r
- input_line_w(7) [4] /IN7 /IN3 [13] input_line_w(3)
- enable_input_w [5] /EI /IN2 [12] input_line_w(2)
- output_r [6] /A2 /IN1 [11] input_line_w(1)
- output_r [7] /A1 /IN0 [10] input_line_w(0)
- [8] GND /A0 [9] output_r
-
-
- Truth table (all logic levels indicate the actual voltage on the line):
-
- INPUTS | OUTPUTS
- |
- EI I0 I1 I2 I3 I4 I5 I6 I7 | A2 A1 A0 | GS EO
- ----------------------------+----------+------
- H X X X X X X X X | H H H | H H
- L H H H H H H H H | H H H | H L
- L X X X X X X X L | L L L | L H
- L X X X X X X L H | L L H | L H
- L X X X X X L H H | L H L | L H
- L X X X X L H H H | L H H | L H
- L X X X L H H H H | H L L | L H
- L X X L H H H H H | H L H | L H
- L X L H H H H H H | H H L | L H
- L L H H H H H H H | H H H | L H
- ----------------------------+----------+------
- L = lo (0)
- H = hi (1)
- X = any state
-
-*****************************************************************************/
-
-#ifndef TTL74148_H
-#define TTL74148_H
-
-
-typedef device_delegate<void (void)> ttl74148_output_delegate;
-
-#define TTL74148_OUTPUT_CB(_name) void _name(void)
-
-
-class ttl74148_device : public device_t
-{
-public:
- ttl74148_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~ttl74148_device() {}
-
- static void set_output_callback(device_t &device, ttl74148_output_delegate callback) { downcast<ttl74148_device &>(device).m_output_cb = callback; }
-
- /* must call update() after setting the inputs */
- void update();
-
- void input_line_w(int input_line, int data);
- void enable_input_w(int data);
- int output_r();
- int output_valid_r();
- int enable_output_r();
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-private:
- // internal state
- ttl74148_output_delegate m_output_cb;
-
- /* inputs */
- int m_input_lines[8]; /* pins 1-4,10-13 */
- int m_enable_input; /* pin 5 */
-
- /* outputs */
- int m_output; /* pins 6,7,9 */
- int m_output_valid; /* pin 14 */
- int m_enable_output; /* pin 15 */
-
- /* internals */
- int m_last_output;
- int m_last_output_valid;
- int m_last_enable_output;
-};
-
-extern const device_type TTL74148;
-
-
-#define MCFG_74148_OUTPUT_CB(_class, _method) \
- ttl74148_device::set_output_callback(*device, ttl74148_output_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-
-#endif
diff --git a/src/emu/machine/74153.c b/src/emu/machine/74153.c
deleted file mode 100644
index e38194f5d6e..00000000000
--- a/src/emu/machine/74153.c
+++ /dev/null
@@ -1,172 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*****************************************************************************
-
- 74153 Dual 4-line to 1-line data selectors/multiplexers
-
-
- Pin layout and functions to access pins:
-
- enable_w(0) [1] /1G VCC [16]
- b_w [2] B /2G [15] enable_w(1)
- input_line_w(0,3) [3] 1C3 A [14] a_w
- input_line_w(0,2) [4] 1C2 2C3 [13] input_line_w(1,3)
- input_line_w(0,1) [5] 1C1 2C2 [12] input_line_w(1,2)
- input_line_w(0,0) [6] 1C0 2C1 [11] input_line_w(1,1)
- output_r(0) [7] 1Y 2C0 [10] input_line_w(1,0)
- [8] GND 2Y [9] output_r(1)
-
-
- Truth table (all logic levels indicate the actual voltage on the line):
-
- INPUTS | OUTPUT
- |
- G | B A | C0 C1 C2 C3 | Y
- --+------+-------------+---
-1 H | X X | X X X X | L
-2 L | L L | X X X X | C0
-3 L | L H | X X X X | C1
-4 L | H L | X X X X | C2
-5 L | H H | X X X X | C3
- --+------+-------------+---
- L = lo (0)
- H = hi (1)
- X = any state
-
-*****************************************************************************/
-
-#include "emu.h"
-#include "machine/74153.h"
-
-
-const device_type TTL74153 = &device_creator<ttl74153_device>;
-
-ttl74153_device::ttl74153_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, TTL74153, "74153 TTL", tag, owner, clock, "74153", __FILE__),
- m_a(0),
- m_b(0)
-{
- m_input_lines[0][0] = 0;
- m_input_lines[0][1] = 0;
- m_input_lines[0][2] = 0;
- m_input_lines[0][3] = 0;
- m_input_lines[1][0] = 0;
- m_input_lines[1][1] = 0;
- m_input_lines[1][2] = 0;
- m_input_lines[1][3] = 0;
-
- for (int i = 0; i < 2; i++)
- m_enable[i] = 0;
-
- for (int i = 0; i < 2; i++)
- m_output[i] = 0;
-
- for (int i = 0; i < 2; i++)
- m_last_output[i] = 0;
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ttl74153_device::device_start()
-{
- m_output_cb.bind_relative_to(*owner());
-
- save_item(NAME(m_enable));
- save_item(NAME(m_last_output));
- save_item(NAME(m_input_lines[0][0]));
- save_item(NAME(m_input_lines[0][1]));
- save_item(NAME(m_input_lines[0][2]));
- save_item(NAME(m_input_lines[0][3]));
- save_item(NAME(m_input_lines[1][0]));
- save_item(NAME(m_input_lines[1][1]));
- save_item(NAME(m_input_lines[1][2]));
- save_item(NAME(m_input_lines[1][3]));
- save_item(NAME(m_a));
- save_item(NAME(m_b));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ttl74153_device::device_reset()
-{
- m_a = 1;
- m_b = 1;
- m_enable[0] = 1;
- m_enable[1] = 1;
- m_input_lines[0][0] = 1;
- m_input_lines[0][1] = 1;
- m_input_lines[0][2] = 1;
- m_input_lines[0][3] = 1;
- m_input_lines[1][0] = 1;
- m_input_lines[1][1] = 1;
- m_input_lines[1][2] = 1;
- m_input_lines[1][3] = 1;
-
- m_last_output[0] = -1;
- m_last_output[1] = -1;
-}
-
-
-void ttl74153_device::update()
-{
- int sel;
- int section;
-
-
- sel = (m_b << 1) | m_a;
-
-
- /* process both sections */
- for (section = 0; section < 2; section++)
- {
- if (m_enable[section])
- m_output[section] = 0; // row 1 in truth table
- else
- m_output[section] = m_input_lines[section][sel];
- }
-
-
- /* call callback if either of the outputs changed */
- if (!m_output_cb.isnull() &&
- ((m_output[0] != m_last_output[0]) || (m_output[1] != m_last_output[1])))
- {
- m_last_output[0] = m_output[0];
- m_last_output[1] = m_output[1];
-
- m_output_cb();
- }
-}
-
-
-void ttl74153_device::a_w(int data)
-{
- m_a = data ? 1 : 0;
-}
-
-
-void ttl74153_device::b_w(int data)
-{
- m_b = data ? 1 : 0;
-}
-
-
-void ttl74153_device::input_line_w(int section, int input_line, int data)
-{
- m_input_lines[section][input_line] = data ? 1 : 0;
-}
-
-
-void ttl74153_device::enable_w(int section, int data)
-{
- m_enable[section] = data ? 1 : 0;
-}
-
-
-int ttl74153_device::output_r(int section)
-{
- return m_output[section];
-}
diff --git a/src/emu/machine/74153.h b/src/emu/machine/74153.h
deleted file mode 100644
index bfd9967e0e4..00000000000
--- a/src/emu/machine/74153.h
+++ /dev/null
@@ -1,92 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*****************************************************************************
-
- 74153 Dual 4-line to 1-line data selectors/multiplexers
-
-
- Pin layout and functions to access pins:
-
- enable_w(0) [1] /1G VCC [16]
- b_w [2] B /2G [15] enable_w(1)
- input_line_w(0,3) [3] 1C3 A [14] a_w
- input_line_w(0,2) [4] 1C2 2C3 [13] input_line_w(1,3)
- input_line_w(0,1) [5] 1C1 2C2 [12] input_line_w(1,2)
- input_line_w(0,0) [6] 1C0 2C1 [11] input_line_w(1,1)
- output_r(0) [7] 1Y 2C0 [10] input_line_w(1,0)
- [8] GND 2Y [9] output_r(1)
-
-
- Truth table (all logic levels indicate the actual voltage on the line):
-
- INPUTS | OUTPUT
- |
- G | B A | C0 C1 C2 C3 | Y
- --+------+-------------+---
- H | X X | X X X X | L
- L | L L | X X X X | C0
- L | L H | X X X X | C1
- L | H L | X X X X | C2
- L | H H | X X X X | C3
- --+------+-------------+---
- L = lo (0)
- H = hi (1)
- X = any state
-
-*****************************************************************************/
-
-#ifndef TTL74153_H
-#define TTL74153_H
-
-
-typedef device_delegate<void (void)> ttl74153_output_delegate;
-
-#define TTL74153_OUTPUT_CB(_name) void _name(void)
-
-
-class ttl74153_device : public device_t
-{
-public:
- ttl74153_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~ttl74153_device() {}
-
- static void set_output_callback(device_t &device, ttl74153_output_delegate callback) { downcast<ttl74153_device &>(device).m_output_cb = callback; }
-
- /* must call update() after setting the inputs */
- void update();
-
- void a_w(int data);
- void b_w(int data);
- void input_line_w(int section, int input_line, int data);
- void enable_w(int section, int data);
- int output_r(int section);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
- ttl74153_output_delegate m_output_cb;
-
- /* inputs */
- int m_a; /* pin 14 */
- int m_b; /* pin 2 */
- int m_input_lines[2][4]; /* pins 3-6,10-13 */
- int m_enable[2]; /* pins 1,15 */
-
- /* output */
- int m_output[2]; /* pins 7,9 */
-
- /* internals */
- int m_last_output[2];
-};
-
-extern const device_type TTL74153;
-
-
-#define MCFG_74153_OUTPUT_CB(_class, _method) \
- ttl74153_device::set_output_callback(*device, ttl74153_output_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#endif
diff --git a/src/emu/machine/74181.c b/src/emu/machine/74181.c
deleted file mode 100644
index dee894446ea..00000000000
--- a/src/emu/machine/74181.c
+++ /dev/null
@@ -1,150 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- 74181
-
- 4-Bit Arithmetic Logic Unit
-
-***************************************************************************/
-
-#include "74181.h"
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type TTL74181 = &device_creator<ttl74181_device>;
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// ttl74181_device - constructor
-//-------------------------------------------------
-
-ttl74181_device::ttl74181_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, TTL74181, "74181 TTL", tag, owner, clock, "ttl74181", __FILE__),
- m_a(0),
- m_b(0),
- m_s(0),
- m_m(0),
- m_c(0)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ttl74181_device::device_start()
-{
- // register for state saving
- save_item(NAME(m_a));
- save_item(NAME(m_b));
- save_item(NAME(m_s));
- save_item(NAME(m_m));
- save_item(NAME(m_c));
-
- update();
-}
-
-//-------------------------------------------------
-// device_post_load - called after loading a saved state
-//-------------------------------------------------
-
-void ttl74181_device::device_post_load()
-{
- // after loading a state re-initialize our output lines
- update();
-}
-
-
-//**************************************************************************
-// ARITHMETHIC UNIT
-//**************************************************************************
-
-void ttl74181_device::update()
-{
- // inputs
- int a0 = BIT(m_a, 0), a1 = BIT(m_a, 1), a2 = BIT(m_a, 2), a3 = BIT(m_a, 3);
- int b0 = BIT(m_b, 0), b1 = BIT(m_b, 1), b2 = BIT(m_b, 2), b3 = BIT(m_b, 3);
- int s0 = BIT(m_s, 0), s1 = BIT(m_s, 1), s2 = BIT(m_s, 2), s3 = BIT(m_s, 3);
- int mp = !m_m;
-
- // intermediate calculations
- int ap0 = !(a0 | (b0 & s0) | (s1 & !b0));
- int bp0 = !(((!b0) & s2 & a0) | (a0 & b0 & s3));
- int ap1 = !(a1 | (b1 & s0) | (s1 & !b1));
- int bp1 = !(((!b1) & s2 & a1) | (a1 & b1 & s3));
- int ap2 = !(a2 | (b2 & s0) | (s1 & !b2));
- int bp2 = !(((!b2) & s2 & a2) | (a2 & b2 & s3));
- int ap3 = !(a3 | (b3 & s0) | (s1 & !b3));
- int bp3 = !(((!b3) & s2 & a3) | (a3 & b3 & s3));
-
- int fp0 = !(m_c & mp) ^ ((!ap0) & bp0);
- int fp1 = (!((mp & ap0) | (mp & bp0 & m_c))) ^ ((!ap1) & bp1);
- int fp2 = (!((mp & ap1) | (mp & ap0 & bp1) | (mp & m_c & bp0 & bp1))) ^ ((!ap2) & bp2);
- int fp3 = (!((mp & ap2) | (mp & ap1 & bp2) | (mp & ap0 & bp1 & bp2) | (mp & m_c & bp0 & bp1 & bp2))) ^ ((!ap3) & bp3);
-
- // outputs
- m_f = fp0 | fp1 << 1 | fp2 << 2 | fp3 << 3;
- m_equals = fp0 & fp1 & fp2 & fp3;
- m_p = !(bp0 & bp1 & bp2 & bp3);
- m_g = !((ap0 & bp1 & bp2 & bp3) | (ap1 & bp2 & bp3) | (ap2 & bp3) | ap3);
- m_cn = (!(m_c & bp0 & bp1 & bp2 & bp3)) | m_g;
-}
-
-void ttl74181_device::input_a_w(UINT8 data)
-{
- data &= 0x0f;
-
- if (m_a != data)
- {
- m_a = data;
- update();
- }
-}
-
-void ttl74181_device::input_b_w(UINT8 data)
-{
- data &= 0x0f;
-
- if (m_b != data)
- {
- m_b = data;
- update();
- }
-}
-
-void ttl74181_device::select_w(UINT8 data)
-{
- data &= 0x0f;
-
- if (m_s != data)
- {
- m_s = data;
- update();
- }
-}
-
-WRITE_LINE_MEMBER( ttl74181_device::mode_w )
-{
- if (m_m != state)
- {
- m_m = state;
- update();
- }
-}
-
-WRITE_LINE_MEMBER( ttl74181_device::carry_w )
-{
- if (m_c != state)
- {
- m_c = state;
- update();
- }
-}
diff --git a/src/emu/machine/74181.h b/src/emu/machine/74181.h
deleted file mode 100644
index 5aeb64768f7..00000000000
--- a/src/emu/machine/74181.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- 74181
-
- 4-Bit Arithmetic Logic Unit
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __74181_H__
-#define __74181_H__
-
-#include "emu.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_TTL74181_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, TTL74181, 0)
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> ttl74181_device
-
-class ttl74181_device : public device_t
-{
-public:
- // construction/destruction
- ttl74181_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // inputs
- void input_a_w(UINT8 data);
- void input_b_w(UINT8 data);
- void select_w(UINT8 data);
- DECLARE_WRITE_LINE_MEMBER( mode_w );
- DECLARE_WRITE_LINE_MEMBER( carry_w );
-
- // outputs
- UINT8 function_r() { return m_f; }
- DECLARE_READ_LINE_MEMBER( carry_r ) { return m_cn; }
- DECLARE_READ_LINE_MEMBER( generate_r ) { return m_g; }
- DECLARE_READ_LINE_MEMBER( propagate_r ) { return m_p; }
- DECLARE_READ_LINE_MEMBER( equals_r ) { return m_equals; }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_post_load();
-
-private:
- void update();
-
- // inputs
- UINT8 m_a;
- UINT8 m_b;
- UINT8 m_s;
- int m_m;
- int m_c;
-
- // outputs
- UINT8 m_f;
- int m_cn;
- int m_g;
- int m_p;
- int m_equals;
-};
-
-
-// device type definition
-extern const device_type TTL74181;
-
-
-#endif /* __74181_H__ */
diff --git a/src/emu/machine/7474.c b/src/emu/machine/7474.c
deleted file mode 100644
index 1b6ce95033d..00000000000
--- a/src/emu/machine/7474.c
+++ /dev/null
@@ -1,216 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*****************************************************************************
-
- 7474 positive-edge-triggered D-type flip-flop with preset, clear and
- complementary outputs. There are 2 flip-flops per chips
-
-
- Pin layout and functions to access pins:
-
- clear_w [1] /1CLR VCC [14]
- d_w [2] 1D /2CLR [13] clear_w
- clock_w [3] 1CLK 2D [12] d_w
- preset_w [4] /1PR 2CLK [11] clock_w
- output_r [5] 1Q /2PR [10] preset_w
- output_comp_r [6] /1Q 2Q [9] output_r
- [7] GND /2Q [8] output_comp_r
-
-
- Truth table (all logic levels indicate the actual voltage on the line):
-
- INPUTS | OUTPUTS
- |
- PR CLR CLK D | Q /Q
- --------------+-------
- 1 L H X X | H L
- 2 H L X X | L H
- 3 L L X X | H H (Note 1)
- 4 H H _- X | D /D
- 5 H H L X | Q0 /Q0
- --------------+-------
- L = lo (0)
- H = hi (1)
- X = any state
- _- = raising edge
- Q0 = previous state
-
- Note 1: Non-stable configuration
-
-*****************************************************************************/
-
-#include "emu.h"
-#include "7474.h"
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type TTL7474 = &device_creator<ttl7474_device>;
-
-//-------------------------------------------------
-// ttl7474_device - constructor
-//-------------------------------------------------
-
-ttl7474_device::ttl7474_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, TTL7474, "7474 TTL", tag, owner, clock, "7474", __FILE__),
- m_output_func(*this),
- m_comp_output_func(*this)
-{
- init();
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ttl7474_device::device_start()
-{
- save_item(NAME(m_clear));
- save_item(NAME(m_preset));
- save_item(NAME(m_clk));
- save_item(NAME(m_d));
- save_item(NAME(m_output));
- save_item(NAME(m_output_comp));
- save_item(NAME(m_last_clock));
- save_item(NAME(m_last_output));
- save_item(NAME(m_last_output_comp));
-
- m_output_func.resolve_safe();
- m_comp_output_func.resolve_safe();
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ttl7474_device::device_reset()
-{
- init();
-}
-
-
-//-------------------------------------------------
-// update - update internal state
-//-------------------------------------------------
-
-void ttl7474_device::update()
-{
- if (!m_preset && m_clear) // line 1 in truth table
- {
- m_output = 1;
- m_output_comp = 0;
- }
- else if (m_preset && !m_clear) // line 2 in truth table
- {
- m_output = 0;
- m_output_comp = 1;
- }
- else if (!m_preset && !m_clear) // line 3 in truth table
- {
- m_output = 1;
- m_output_comp = 1;
- }
- else if (!m_last_clock && m_clk) // line 4 in truth table
- {
- m_output = m_d;
- m_output_comp = !m_d;
- }
-
- m_last_clock = m_clk;
-
-
- // call callback if any of the outputs changed
- if (m_output != m_last_output)
- {
- m_last_output = m_output;
- m_output_func(m_output);
- }
- // call callback if any of the outputs changed
- if (m_output_comp != m_last_output_comp)
- {
- m_last_output_comp = m_output_comp;
- m_comp_output_func(m_output_comp);
- }
-}
-
-
-//-------------------------------------------------
-// clear_w - set the clear line state
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ttl7474_device::clear_w )
-{
- m_clear = state & 1;
- update();
-}
-
-
-//-------------------------------------------------
-// clear_w - set the clear line state
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ttl7474_device::preset_w )
-{
- m_preset = state & 1;
- update();
-}
-
-
-//-------------------------------------------------
-// clock_w - set the clock line state
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ttl7474_device::clock_w )
-{
- m_clk = state & 1;
- update();
-}
-
-
-//-------------------------------------------------
-// d_w - set the d line state
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ttl7474_device::d_w )
-{
- m_d = state & 1;
- update();
-}
-
-
-//-------------------------------------------------
-// output_r - get the output line state
-//-------------------------------------------------
-
-READ_LINE_MEMBER( ttl7474_device::output_r )
-{
- return m_output;
-}
-
-
-//-----------------------------------------------------
-// output_comp_r - get the output-compare line state
-//-----------------------------------------------------
-
-READ_LINE_MEMBER( ttl7474_device::output_comp_r )
-{
- return m_output_comp;
-}
-
-void ttl7474_device::init()
-{
- m_clear = 1;
- m_preset = 1;
- m_clk = 1;
- m_d = 1;
-
- m_output = -1;
- m_last_clock = 1;
- m_last_output = -1;
- m_last_output_comp = -1;
-}
diff --git a/src/emu/machine/7474.h b/src/emu/machine/7474.h
deleted file mode 100644
index 9373e41d7d3..00000000000
--- a/src/emu/machine/7474.h
+++ /dev/null
@@ -1,121 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*****************************************************************************
-
- 7474 positive-edge-triggered D-type flip-flop with preset, clear and
- complementary outputs. There are 2 flip-flops per chips
-
-
- Pin layout and functions to access pins:
-
- clear_w [1] /1CLR VCC [14]
- d_w [2] 1D /2CLR [13] clear_w
- clock_w [3] 1CLK 2D [12] d_w
- preset_w [4] /1PR 2CLK [11] clock_w
- output_r [5] 1Q /2PR [10] preset_w
- output_comp_r [6] /1Q 2Q [9] output_r
- [7] GND /2Q [8] output_comp_r
-
-
- Truth table (all logic levels indicate the actual voltage on the line):
-
- INPUTS | OUTPUTS
- |
- PR CLR CLK D | Q /Q
- --------------+-------
- L H X X | H L
- H L X X | L H
- L L X X | H H (Note 1)
- H H _- X | D /D
- H H L X | Q0 /Q01
- --------------+-------
- L = lo (0)
- H = hi (1)
- X = any state
- _- = raising edge
- Q0 = previous state
-
- Note 1: Non-stable configuration
-
-*****************************************************************************/
-
-#pragma once
-
-#ifndef __TTL7474_H__
-#define __TTL7474_H__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_7474_OUTPUT_CB(_devcb) \
- devcb = &ttl7474_device::set_output_cb(*device, DEVCB_##_devcb);
-
-#define MCFG_7474_COMP_OUTPUT_CB(_devcb) \
- devcb = &ttl7474_device::set_comp_output_cb(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> ttl7474_device
-
-class ttl7474_device : public device_t
-{
-public:
- // construction/destruction
- ttl7474_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_output_cb(device_t &device, _Object object) { return downcast<ttl7474_device &>(device).m_output_func.set_callback(object); }
- template<class _Object> static devcb_base &set_comp_output_cb(device_t &device, _Object object) { return downcast<ttl7474_device &>(device).m_comp_output_func.set_callback(object); }
-
- // public interfaces
- DECLARE_WRITE_LINE_MEMBER( clear_w );
- DECLARE_WRITE_LINE_MEMBER( preset_w );
- DECLARE_WRITE_LINE_MEMBER( clock_w );
- DECLARE_WRITE_LINE_MEMBER( d_w );
- DECLARE_READ_LINE_MEMBER( output_r );
- DECLARE_READ_LINE_MEMBER( output_comp_r ); // NOT strictly the same as !output_r()
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_post_load() { }
- virtual void device_clock_changed() { }
-private:
- // callbacks
- devcb_write_line m_output_func;
- devcb_write_line m_comp_output_func;
-
- // inputs
- UINT8 m_clear; // pin 1/13
- UINT8 m_preset; // pin 4/10
- UINT8 m_clk; // pin 3/11
- UINT8 m_d; // pin 2/12
-
- // outputs
- UINT8 m_output; // pin 5/9
- UINT8 m_output_comp; // pin 6/8
-
- // internal
- UINT8 m_last_clock;
- UINT8 m_last_output;
- UINT8 m_last_output_comp;
-
- void update();
- void init();
-};
-
-
-// device type definition
-extern const device_type TTL7474;
-
-
-#endif /* __TTL7474_H__ */
diff --git a/src/emu/machine/8042kbdc.c b/src/emu/machine/8042kbdc.c
deleted file mode 100644
index a1d36a41b43..00000000000
--- a/src/emu/machine/8042kbdc.c
+++ /dev/null
@@ -1,618 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Peter Trauner
-/*********************************************************************
-
- 8042kbdc.c
-
- Code specific to fun IBM AT stuff
-
-
- PeT's notes about various Power On Self Tests (POSTs)
-
- at post
- -------
- f81d2 01
- f82e6 05
- f8356 07
- f83e5 0a
- f847e 0e
- f8e7c 10
- f8f3a 13
- f9058 1a
- f913a 1e
- fa8ba 30
- fa96c 36
- fa9d3 3c
- fa9f4 3e
- ff122 50
- ff226 5b
- ff29f 5f
- f9228 70
- f92b2 74 ide?
-
- ibm at bios
- -----------
- f0101 after switch to real mode jump back!!!!!!!!!!
- jumping table
- f0123
- f098e memory tests
- f10b4 ???
- not reached
- f1050
- f1617
- f0119
- f10d8
- f10b7 system board error
-
- f019f
- f025b
- f02e6
- f0323
- f03b3 0e
- f03d7 0f
- f058d
- at8042 signal timing test
- sets errorcode!
-
- f0655
- f06a3 postcode 15
- f06ba 16
- f0747 18
- f0763 enter pm! (0x81, 0x85)
- f0766 1a
- f07b3 first 640kb memory test
- f084c 1c
- f086e extended memory test
- f0928 1f
- f097d 20
- ???
- f0ff4 34
- ???
- f1675 f0
- f16cb f2
- illegal access trap test!!!!
- f16fe f3
- task descriptor test!!!!
- f174a f4
- f17af f5
- f1800 f6 writing to non write segment
- f1852 f7 arpl
- f1880 f8 lar, lsl
- f18ca fa
- f10d8
- f10ec 35
- f1106 36
- f1137 !!!!!!!keyboard test fails
-
- f11aa 3a
- f1240 3c harddisk controller test!!!
- f13f3 3b
- f1a6d xthdd bios init
- f1429
- f1462
- f1493 40
- f1532
- keyboard lock
- f1 to unlock
- f155c
- jumps to f0050 (reset) without enabling of the a20 gate --> hangs
- 0412 bit 5 must be set to reach f1579
- f1579
- f15c3 41
- f1621 43
-
- routines
- f1945 read cmos ram
- f195f write to cmos al value ah
- f1a3a poll 0x61 bit 4
- f1a49 sets something in cmos ram
- f1d30 switch to protected mode
-
- neat
- ----
- f80b9
-
- at386
- -----
- fd28c fd
- fd2c3 fc
- f40dc
- fd949
- fd8e3
- fd982
- f4219 01
- f4296 03
- f42f3 04
- f4377 05
- f43ec 06
- f4430 08
- f6017 switches to PM
- f4456 09
- f55a2
- f44ec 0d
- f4557 20
- f462d 27 my special friend, the keyboard controller once more
- ed0a1
- f4679 28
- fa16a
- f46d6
- f4768 2c
- f47f0 2e
- f5081
- fa16a
- f9a83
- Message: "Checksum Error on Extended CMOS"
- f4840 34
- f488c 35
- reset
- f48ee
- f493e 3a
- f49cd
- f4fc7
- fe842
- f4a5a
- f4b01 38
- (Memory Test)
- f4b41 3b
- f4c0f
- Message: "Invalid configuration information - please run SETUP program"
- f4c5c
- f86fc
- f8838
- f4c80
- f4ca2
- f4d4c
- f4e15 (int 19h)
-
- [f9a83 output text at return address!, return after text]
-
-
- at486
- -----
- f81a5 03
- f1096 0f 09 wbinvd i486 instruction
-
-*********************************************************************/
-
-
-#include "machine/8042kbdc.h"
-
-
-/***************************************************************************
-
- Constants & macros
-
-***************************************************************************/
-
-#define PS2_MOUSE_ON 1
-#define KEYBOARD_ON 1
-
-#define LOG_KEYBOARD 0
-#define LOG_ACCESSES 0
-
-const device_type KBDC8042 = &device_creator<kbdc8042_device>;
-
-//-------------------------------------------------
-// kbdc8042_device - constructor
-//-------------------------------------------------
-
-kbdc8042_device::kbdc8042_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, KBDC8042, "8042 Keyboard Controller", tag, owner, clock, "kbdc8042", __FILE__)
- , m_keyboard_dev(*this, "at_keyboard")
- , m_system_reset_cb(*this)
- , m_gate_a20_cb(*this)
- , m_input_buffer_full_cb(*this)
- , m_output_buffer_empty_cb(*this)
- , m_speaker_cb(*this)
-{
-}
-
-static MACHINE_CONFIG_FRAGMENT( keyboard )
- MCFG_AT_KEYB_ADD("at_keyboard", 1, WRITELINE(kbdc8042_device, keyboard_w))
-MACHINE_CONFIG_END
-
-machine_config_constructor kbdc8042_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( keyboard );
-}
-
-/*-------------------------------------------------
- device_start - device-specific startup
--------------------------------------------------*/
-
-void kbdc8042_device::device_start()
-{
- // resolve callbacks
- m_system_reset_cb.resolve_safe();
- m_gate_a20_cb.resolve();
- m_input_buffer_full_cb.resolve();
- m_output_buffer_empty_cb.resolve_safe();
- m_speaker_cb.resolve();
- m_operation_write_state = 0; /* first write to 0x60 might occur before anything can set this */
- memset(&m_keyboard, 0x00, sizeof(m_keyboard));
- memset(&m_mouse, 0x00, sizeof(m_mouse));
- m_sending = 0;
- m_last_write_to_control = 0;
- m_status_read_mode = 0;
-}
-
-/*-------------------------------------------------
- device_reset - device-specific reset
--------------------------------------------------*/
-
-void kbdc8042_device::device_reset()
-{
- m_poll_delay = 10;
-
- /* ibmat bios wants 0x20 set! (keyboard locked when not set) 0x80 */
- m_inport = 0xa0;
- at_8042_set_outport(0xfe, 1);
-}
-
-void kbdc8042_device::at_8042_set_outport(UINT8 data, int initial)
-{
- UINT8 change;
- change = initial ? 0xFF : (m_outport ^ data);
- m_outport = data;
- if (change & 0x02)
- {
- if (!m_gate_a20_cb.isnull())
- m_gate_a20_cb(data & 0x02 ? 1 : 0);
- }
-}
-
-WRITE_LINE_MEMBER( kbdc8042_device::keyboard_w )
-{
- if(state)
- at_8042_check_keyboard();
-}
-
-TIMER_CALLBACK_MEMBER( kbdc8042_device::kbdc8042_clr_int )
-{
- /* Lets 8952's timers do their job before clear the interrupt line, */
- /* else Keyboard interrupt never happens. */
- m_input_buffer_full_cb(0);
-}
-
-void kbdc8042_device::at_8042_receive(UINT8 data)
-{
- if (LOG_KEYBOARD)
- logerror("at_8042_receive Received 0x%02x\n", data);
-
- m_data = data;
- m_keyboard.received = 1;
-
- if (!m_input_buffer_full_cb.isnull())
- {
- m_input_buffer_full_cb(1);
- /* Lets 8952's timers do their job before clear the interrupt line, */
- /* else Keyboard interrupt never happens. */
- machine().scheduler().timer_set(attotime::from_usec(2), timer_expired_delegate(FUNC(kbdc8042_device::kbdc8042_clr_int),this));
- }
-}
-
-void kbdc8042_device::at_8042_check_keyboard()
-{
- int data;
-
- if (!m_keyboard.received && !m_mouse.received)
- {
- if((data = m_keyboard_dev->read(machine().driver_data()->generic_space(), 0)))
- at_8042_receive(data);
- }
-}
-
-
-void kbdc8042_device::at_8042_clear_keyboard_received()
-{
- if (m_keyboard.received)
- {
- if (LOG_KEYBOARD)
- logerror("kbdc8042_8_r(): Clearing m_keyboard.received\n");
- }
-
- m_keyboard.received = 0;
- m_mouse.received = 0;
-}
-
-
-
-/* **************************************************************************
- * Port 0x60 Input and Output Buffer (keyboard and mouse data)
- * Port 0x64 Read Status Register
- * Write operation for controller
- *
- * Output port controller:
- * 7: Keyboard data
- * 6: Keyboard clock
- * 5: Mouse buffer full
- * 4: Keyboard buffer full
- * 3: Mouse clock
- * 2: Mouse data
- * 1: 0 A20 cleared
- * 0: 0 system reset
- *
- * Input port controller
- * 7: 0=Keyboard Locked
- * 6: 1 = Monochrome 0 = Color (true for real IBM, clones are undefined and use CMOS RAM data)
- * 5..2: reserved
- * 1: Mouse data in
- * 0: Keyboard data in
- */
-
-READ8_MEMBER(kbdc8042_device::data_r)
-{
- UINT8 data = 0;
-
- switch (offset) {
- case 0:
- data = m_data;
- if ((m_status_read_mode != 3) || (data != 0xfa))
- {
- if (m_keybtype != KBDC8042_AT386 || (data != 0x55))
- {
- /* at386 self test doesn't like this */
- at_8042_clear_keyboard_received();
- }
- at_8042_check_keyboard();
- }
- else
- {
- m_status_read_mode = 4;
- }
- break;
-
- case 1:
- data = m_speaker;
- data &= ~0xc0; /* AT BIOS don't likes this being set */
-
- /* needed for AMI BIOS, maybe only some keyboard controller revisions! */
- at_8042_clear_keyboard_received();
-
- /* polled for changes in ibmat bios */
- if (--m_poll_delay < 0)
- {
- if (m_keybtype != KBDC8042_PS2)
- m_poll_delay = 4; /* ibmat */
- else
- m_poll_delay = 8; /* ibm ps2m30 */
- m_offset1 ^= 0x10;
- }
- data = (data & ~0x10) | m_offset1;
-
- if (m_speaker & 1)
- data |= 0x20;
- else
- data &= ~0x20; /* ps2m30 wants this */
- break;
-
- case 2:
- if (m_out2)
- data |= 0x20;
- else
- data &= ~0x20;
- break;
-
- case 4:
- at_8042_check_keyboard();
-
- if (m_keyboard.received || m_mouse.received)
- data |= 1;
- if (m_sending)
- data |= 2;
-
- m_sending = 0; /* quicker than normal */
- data |= 4; /* selftest ok */
-
- if (m_last_write_to_control)
- data |= 8;
-
- switch (m_status_read_mode) {
- case 0:
- if (!m_keyboard.on) data|=0x10;
- if (m_mouse.received) data|=0x20;
- break;
- case 1:
- data |= m_inport&0xf;
- break;
- case 2:
- data |= m_inport<<4;
- break;
- case 4:
- at_8042_receive(0xaa);
- m_status_read_mode = 0;
- break;
- }
- break;
- }
-
- if (LOG_ACCESSES)
- logerror("kbdc8042_8_r(): offset=%d data=0x%02x\n", offset, (unsigned) data);
- return data;
-}
-
-
-
-WRITE8_MEMBER(kbdc8042_device::data_w)
-{
- switch (offset) {
- case 0:
- m_last_write_to_control = 0;
- m_status_read_mode = 0;
- switch (m_operation_write_state) {
- case 0:
- if ((data == 0xf4) || (data == 0xff)) /* keyboard enable or keyboard reset */
- {
- at_8042_receive(0xfa); /* ACK, delivered a bit differently */
-
- if (data == 0xff)
- {
- m_status_read_mode = 3; /* keyboard buffer to be written again after next read */
- }
-
- break;
- }
-
- /* normal case */
- m_data = data;
- m_sending=1;
- m_keyboard_dev->write(space, 0, data);
- break;
-
- case 1:
- /* preceded by writing 0xD1 to port 60h
- * |7|6|5|4|3|2|1|0| 8042 Output Port
- * | | | | | | | `---- system reset line
- * | | | | | | `----- gate A20
- * | | | | `-------- undefined
- * | | | `--------- output buffer full
- * | | `---------- input buffer empty
- * | `----------- keyboard clock (output)
- * `------------ keyboard data (output)
- */
- at_8042_set_outport(data, 0);
- break;
-
- case 2:
- /* preceded by writing 0xD2 to port 60h */
- m_data = data;
- m_sending=1;
- m_keyboard_dev->write(space, 0, data);
- break;
-
- case 3:
- /* preceded by writing 0xD3 to port 60h */
- m_data = data;
- break;
-
- case 4:
- /* preceded by writing 0xD4 to port 60h */
- m_data = data;
- break;
-
- case 5:
- /* preceded by writing 0x60 to port 60h */
- m_command = data;
- break;
- }
- m_operation_write_state = 0;
- break;
-
- case 1:
- m_speaker = data;
- if (!m_speaker_cb.isnull())
- m_speaker_cb((offs_t)0, m_speaker);
-
- break;
-
- case 4:
- m_last_write_to_control=0;
-
- /* switch based on the command */
- switch(data) {
- case 0x20: /* current 8042 command byte is placed on port 60h */
- m_data = m_command;
- break;
- case 0x60: /* next data byte is placed in 8042 command byte */
- m_operation_write_state = 5;
- m_send_to_mouse = 0;
- break;
- case 0xa7: /* disable auxilary interface */
- m_mouse.on = 0;
- break;
- case 0xa8: /* enable auxilary interface */
- m_mouse.on = 1;
- break;
- case 0xa9: /* test mouse */
- at_8042_receive(PS2_MOUSE_ON ? 0x00 : 0xff);
- break;
- case 0xaa: /* selftest */
- at_8042_receive(0x55);
- break;
- case 0xab: /* test keyboard */
- at_8042_receive(KEYBOARD_ON ? 0x00 : 0xff);
- break;
- case 0xad: /* disable keyboard interface */
- m_keyboard.on = 0;
- break;
- case 0xae: /* enable keyboard interface */
- m_keyboard.on = 1;
- break;
- case 0xc0: /* read input port */
- /* |7|6|5|4|3 2 1 0| 8042 Input Port
- * | | | | |
- * | | | | `------- undefined
- * | | | |
- * | | | `--------- 1=enable 2nd 256k of Motherboard RAM
- * | | `---------- 1=manufacturing jumper installed
- * | `----------- 1=primary display is MDA, 0=CGA
- * `------------ 1=keyboard not inhibited; 0=inhibited
- */
- at_8042_receive(m_inport);
- break;
- case 0xc1: /* read input port 3..0 until write to 0x60 */
- m_status_read_mode = 1;
- break;
- case 0xc2: /* read input port 7..4 until write to 0x60 */
- m_status_read_mode = 2;
- break;
- case 0xd0: /* read output port */
- at_8042_receive(m_outport);
- break;
- case 0xd1:
- /* write output port; next byte written to port 60h is placed on
- * 8042 output port */
- m_operation_write_state = 1;
- return; /* instant delivery */
- case 0xd2:
- /* write keyboard output register; on PS/2 systems next port 60h
- * write is written to port 60h output register as if initiated
- * by a device; invokes interrupt if enabled */
- m_operation_write_state = 2;
- m_send_to_mouse = 0;
- break;
- case 0xd3:
- /* write auxillary output register; on PS/2 systems next port 60h
- * write is written to port 60h input register as if initiated
- * by a device; invokes interrupt if enabled */
- m_operation_write_state = 3;
- m_send_to_mouse = 1;
- break;
- case 0xd4:
- /* write auxillary device; on PS/2 systems the next data byte
- * written to input register a port at 60h is sent to the
- * auxiliary device */
- m_operation_write_state = 4;
- break;
- case 0xe0:
- /* read test inputs; read T1/T0 test inputs into bit 1/0 */
- at_8042_receive(0x00);
- break;
-
- case 0xf0:
- case 0xf2:
- case 0xf4:
- case 0xf6:
- case 0xf8:
- case 0xfa:
- case 0xfc:
- case 0xfe:
- /* Commands 0xF0...0xFF causes certain output lines to be pulsed
- * low for six milliseconds. The bits pulsed low correspond to
- * the bits low set in the command byte. The only pulse that has
- * an effect currently is bit 0, which pulses the CPU's reset line
- */
- m_system_reset_cb(ASSERT_LINE);
- m_system_reset_cb(CLEAR_LINE);
- at_8042_set_outport(m_outport | 0x02, 0);
- break;
- }
- m_sending = 1;
- break;
- }
-}
-
-WRITE_LINE_MEMBER(kbdc8042_device::write_out2)
-{
- m_out2 = state;
-}
diff --git a/src/emu/machine/8042kbdc.h b/src/emu/machine/8042kbdc.h
deleted file mode 100644
index b8d9c4e22fd..00000000000
--- a/src/emu/machine/8042kbdc.h
+++ /dev/null
@@ -1,127 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Peter Trauner
-/**********************************************************************
-
- 8042 Keyboard Controller Emulation
-
- This is the keyboard controller used in the IBM AT and further
- models. It is a popular controller for PC style keyboards
-
-**********************************************************************/
-
-#ifndef KBDC8042_H
-#define KBDC8042_H
-
-#include "emu.h"
-#include "machine/pckeybrd.h"
-
-enum kbdc8042_type_t
-{
- KBDC8042_STANDARD,
- KBDC8042_PS2, /* another timing of integrated controller */
- KBDC8042_AT386 /* hack for at386 driver */
-};
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_KBDC8042_KEYBOARD_TYPE(_kbdt) \
- kbdc8042_device::set_keyboard_type(*device, _kbdt);
-
-#define MCFG_KBDC8042_SYSTEM_RESET_CB(_devcb) \
- devcb = &kbdc8042_device::set_system_reset_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_KBDC8042_GATE_A20_CB(_devcb) \
- devcb = &kbdc8042_device::set_gate_a20_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_KBDC8042_INPUT_BUFFER_FULL_CB(_devcb) \
- devcb = &kbdc8042_device::set_input_buffer_full_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_KBDC8042_OUTPUT_BUFFER_EMPTY_CB(_devcb) \
- devcb = &kbdc8042_device::set_output_buffer_empty_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_KBDC8042_SPEAKER_CB(_devcb) \
- devcb = &kbdc8042_device::set_speaker_callback(*device, DEVCB_##_devcb);
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> kbdc8042_device
-
-class kbdc8042_device : public device_t
-{
-public:
- // construction/destruction
- kbdc8042_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual machine_config_constructor device_mconfig_additions() const;
-
- static void set_keyboard_type(device_t &device, kbdc8042_type_t keybtype) { downcast<kbdc8042_device &>(device).m_keybtype = keybtype; }
- template<class _Object> static devcb_base &set_system_reset_callback(device_t &device, _Object object) { return downcast<kbdc8042_device &>(device).m_system_reset_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_gate_a20_callback(device_t &device, _Object object) { return downcast<kbdc8042_device &>(device).m_gate_a20_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_input_buffer_full_callback(device_t &device, _Object object) { return downcast<kbdc8042_device &>(device).m_input_buffer_full_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_output_buffer_empty_callback(device_t &device, _Object object) { return downcast<kbdc8042_device &>(device).m_output_buffer_empty_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_speaker_callback(device_t &device, _Object object) { return downcast<kbdc8042_device &>(device).m_speaker_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( data_r );
- DECLARE_WRITE8_MEMBER( data_w );
-
- DECLARE_WRITE_LINE_MEMBER( write_out2 );
- DECLARE_WRITE_LINE_MEMBER( keyboard_w );
-
- void at_8042_set_outport(UINT8 data, int initial);
- TIMER_CALLBACK_MEMBER( kbdc8042_clr_int );
- void at_8042_receive(UINT8 data);
- void at_8042_check_keyboard();
- void at_8042_clear_keyboard_received();
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- UINT8 m_inport, m_outport, m_data, m_command;
-
- struct {
- int received;
- int on;
- } m_keyboard;
- struct {
- int received;
- int on;
- } m_mouse;
-
- int m_last_write_to_control;
- int m_sending;
- int m_send_to_mouse;
-
- int m_operation_write_state;
- int m_status_read_mode;
-
- int m_speaker;
- int m_out2;
-
- /* temporary hack */
- int m_offset1;
-
- int m_poll_delay;
-
- required_device<at_keyboard_device> m_keyboard_dev;
-
- kbdc8042_type_t m_keybtype;
-
- devcb_write_line m_system_reset_cb;
- devcb_write_line m_gate_a20_cb;
- devcb_write_line m_input_buffer_full_cb;
- devcb_write_line m_output_buffer_empty_cb;
-
- devcb_write8 m_speaker_cb;
-};
-
-// device type definition
-extern const device_type KBDC8042;
-
-
-#endif /* KBDC8042_H */
diff --git a/src/emu/machine/8530scc.c b/src/emu/machine/8530scc.c
deleted file mode 100644
index 8180d01f869..00000000000
--- a/src/emu/machine/8530scc.c
+++ /dev/null
@@ -1,678 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*********************************************************************
-
- 8530scc.c
-
- Zilog 8530 SCC (Serial Control Chip) code
-
-*********************************************************************/
-
-
-#include "emu.h"
-#include "8530scc.h"
-
-const device_type SCC8530 = &device_creator<scc8530_t>;
-
-
-/***************************************************************************
- PARAMETERS
-***************************************************************************/
-
-#define LOG_SCC (0)
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-scc8530_t::scc8530_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, SCC8530, "Zilog 8530 SCC", tag, owner, clock, "scc8530", __FILE__),
- intrq_cb(*this)
-{
-}
-
-
-/*-------------------------------------------------
- scc_updateirqs
--------------------------------------------------*/
-
-void scc8530_t::updateirqs()
-{
- int irqstat;
-
- irqstat = 0;
- if (MasterIRQEnable)
- {
- if ((channel[0].txIRQEnable) && (channel[0].txIRQPending))
- {
- IRQType = IRQ_B_TX;
- irqstat = 1;
- }
- else if ((channel[1].txIRQEnable) && (channel[1].txIRQPending))
- {
- IRQType = IRQ_A_TX;
- irqstat = 1;
- }
- else if ((channel[0].extIRQEnable) && (channel[0].extIRQPending))
- {
- IRQType = IRQ_B_EXT;
- irqstat = 1;
- }
- else if ((channel[1].extIRQEnable) && (channel[1].extIRQPending))
- {
- IRQType = IRQ_A_EXT;
- irqstat = 1;
- }
- }
- else
- {
- IRQType = IRQ_NONE;
- }
-
-// printf("SCC: irqstat %d, last %d\n", irqstat, lastIRQStat);
-// printf("ch0: en %d pd %d ch1: en %d pd %d\n", channel[0].txIRQEnable, channel[0].txIRQPending, channel[1].txIRQEnable, channel[1].txIRQPending);
-
- // don't spam the driver with unnecessary transitions
- if (irqstat != lastIRQStat)
- {
- lastIRQStat = irqstat;
-
- // tell the driver the new IRQ line status if possible
-#if LOG_SCC
- printf("SCC8530 IRQ status => %d\n", irqstat);
-#endif
- if(!intrq_cb.isnull())
- intrq_cb(irqstat);
- }
-}
-
-/*-------------------------------------------------
- scc_initchannel
--------------------------------------------------*/
-void scc8530_t::initchannel(int ch)
-{
- channel[ch].syncHunt = 1;
-}
-
-/*-------------------------------------------------
- scc_resetchannel
--------------------------------------------------*/
-void scc8530_t::resetchannel(int ch)
-{
- emu_timer *timersave = channel[ch].baudtimer;
-
- memset(&channel[ch], 0, sizeof(Chan));
-
- channel[ch].txUnderrun = 1;
- channel[ch].baudtimer = timersave;
-
- channel[ch].baudtimer->adjust(attotime::never, ch);
-}
-
-/*-------------------------------------------------
- scc8530_baud_expire - baud rate timer expiry
--------------------------------------------------*/
-
-void scc8530_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- Chan *pChan = &channel[id];
- int brconst = pChan->reg_val[13]<<8 | pChan->reg_val[14];
- int rate;
-
- if (brconst)
- {
- rate = clock() / brconst;
- }
- else
- {
- rate = 0;
- }
-
- // is baud counter IRQ enabled on this channel?
- // always flag pending in case it's enabled after this
- pChan->baudIRQPending = 1;
- if (pChan->baudIRQEnable)
- {
- if (pChan->extIRQEnable)
- {
- pChan->extIRQPending = 1;
- pChan->baudIRQPending = 0;
- updateirqs();
- }
- }
-
- // reset timer according to current register values
- if (rate)
- {
- attotime attorate = attotime::from_hz(rate);
- timer.adjust(attorate, 0, attorate);
- }
- else
- {
- timer.adjust(attotime::never, 0, attotime::never);
- }
-}
-
-/*-------------------------------------------------
- device_start - device-specific startup
--------------------------------------------------*/
-
-void scc8530_t::device_start()
-{
- intrq_cb.resolve();
-
- memset(channel, 0, sizeof(channel));
-
- mode = 0;
- reg = 0;
- status = 0;
- IRQV = 0;
- MasterIRQEnable = 0;
- lastIRQStat = 0;
- IRQType = IRQ_NONE;
-
- channel[0].baudtimer = timer_alloc(0);
- channel[1].baudtimer = timer_alloc(1);
-}
-
-
-/*-------------------------------------------------
- device_reset - device-specific reset
--------------------------------------------------*/
-void scc8530_t::device_reset()
-{
- IRQType = IRQ_NONE;
- MasterIRQEnable = 0;
- IRQV = 0;
-
- initchannel(0);
- initchannel(1);
- resetchannel(0);
- resetchannel(1);
-}
-
-/*-------------------------------------------------
- scc_set_status
--------------------------------------------------*/
-
-void scc8530_t::set_status(int _status)
-{
- status = _status;
-}
-
-/*-------------------------------------------------
- scc_acknowledge
--------------------------------------------------*/
-
-void scc8530_t::acknowledge()
-{
- if(!intrq_cb.isnull())
- intrq_cb(0);
-}
-
-/*-------------------------------------------------
- scc_getareg
--------------------------------------------------*/
-
-UINT8 scc8530_t::getareg()
-{
- /* Not yet implemented */
- #if LOG_SCC
- printf("SCC: port A reg %d read 0x%02x\n", reg, channel[0].reg_val[reg]);
- #endif
-
- if (reg == 0)
- {
- UINT8 rv = 0;
-
- Chan *ourCh = &channel[0];
-
- rv |= (ourCh->txUnderrun) ? 0x40 : 0;
- rv |= (ourCh->syncHunt) ? 0x10 : 0;
- rv |= channel[0].reg_val[0] & 0x0D; // pick up TXBE, RXBF, DCD bits
-
- return rv;
- }
- else if (reg == 10)
- {
- return 0;
- }
- return channel[0].reg_val[reg];
-}
-
-
-
-/*-------------------------------------------------
- scc_getareg
--------------------------------------------------*/
-
-UINT8 scc8530_t::getbreg()
-{
- #if LOG_SCC
- printf("SCC: port B reg %i read 0x%02x\n", reg, channel[1].reg_val[reg]);
- #endif
-
- if (reg == 0)
- {
- UINT8 rv = 0;
-
- Chan *ourCh = &channel[1];
-
- rv |= (ourCh->txUnderrun) ? 0x40 : 0;
- rv |= (ourCh->syncHunt) ? 0x10 : 0;
- rv |= channel[1].reg_val[0] & 0x0D; // pick up TXBE, RXBF, DCD bits
-
- return rv;
- }
- else if (reg == 2)
- {
- /* HACK! but lets the Mac Plus mouse move again. Needs further investigation. */
- acknowledge();
-
- return status;
- }
- else if (reg == 10)
- {
- return 0;
- }
-
- return channel[1].reg_val[reg];
-}
-
-
-
-/*-------------------------------------------------
- scc_putreg
--------------------------------------------------*/
-
-void scc8530_t::putreg(int ch, UINT8 data)
-{
- Chan *pChan = &channel[ch];
-
- channel[ch].reg_val[reg] = data;
- #if LOG_SCC
- printf("SCC: port %c reg %d write 0x%02x\n", 'A'+ch, reg, data);
- #endif
-
- switch (reg)
- {
- case 0: // command register
- switch ((data >> 3) & 7)
- {
- case 1: // select high registers (handled elsewhere)
- break;
-
- case 2: // reset external and status IRQs
- pChan->syncHunt = 0;
- break;
-
- case 5: // ack Tx IRQ
- pChan->txIRQPending = 0;
- updateirqs();
- break;
-
- case 0: // nothing
- case 3: // send SDLC abort
- case 4: // enable IRQ on next Rx byte
- case 6: // reset errors
- case 7: // reset highest IUS
- // we don't handle these yet
- break;
-
- }
- break;
-
- case 1: // Tx/Rx IRQ and data transfer mode defintion
- pChan->extIRQEnable = (data & 1);
- pChan->txIRQEnable = (data & 2) ? 1 : 0;
- pChan->rxIRQEnable = (data >> 3) & 3;
- updateirqs();
- break;
-
- case 2: // IRQ vector
- IRQV = data;
- break;
-
- case 3: // Rx parameters and controls
- pChan->rxEnable = (data & 1);
- pChan->syncHunt = (data & 0x10) ? 1 : 0;
- break;
-
- case 5: // Tx parameters and controls
-// printf("ch %d TxEnable = %d [%02x]\n", ch, data & 8, data);
- pChan->txEnable = data & 8;
-
- if (pChan->txEnable)
- {
- pChan->reg_val[0] |= 0x04; // Tx empty
- }
- break;
-
- case 4: // Tx/Rx misc parameters and modes
- case 6: // sync chars/SDLC address field
- case 7: // sync char/SDLC flag
- break;
-
- case 9: // master IRQ control
- MasterIRQEnable = (data & 8) ? 1 : 0;
- updateirqs();
-
- // channel reset command
- switch ((data>>6) & 3)
- {
- case 0: // do nothing
- break;
-
- case 1: // reset channel B
- resetchannel(0);
- break;
-
- case 2: // reset channel A
- resetchannel(1);
- break;
-
- case 3: // force h/w reset (entire chip)
- IRQType = IRQ_NONE;
- MasterIRQEnable = 0;
- IRQV = 0;
-
- initchannel(0);
- initchannel(1);
- resetchannel(0);
- resetchannel(1);
-
- // make sure we stop yanking the IRQ line if we were
- updateirqs();
- break;
-
- }
- break;
-
- case 10: // misc transmitter/receiver control bits
- case 11: // clock mode control
- case 12: // lower byte of baud rate gen
- case 13: // upper byte of baud rate gen
- break;
-
- case 14: // misc control bits
- if (data & 0x01) // baud rate generator enable?
- {
- int brconst = pChan->reg_val[13]<<8 | pChan->reg_val[14];
- int rate = clock() / brconst;
-
- pChan->baudtimer->adjust(attotime::from_hz(rate), 0, attotime::from_hz(rate));
- }
- break;
-
- case 15: // external/status interrupt control
- pChan->baudIRQEnable = (data & 2) ? 1 : 0;
- pChan->DCDEnable = (data & 8) ? 1 : 0;
- pChan->CTSEnable = (data & 0x20) ? 1 : 0;
- pChan->txUnderrunEnable = (data & 0x40) ? 1 : 0;
- break;
- }
-}
-
-/*-------------------------------------------------
- scc8530_get_reg_a
--------------------------------------------------*/
-
-UINT8 scc8530_t::get_reg_a(int reg)
-{
- return channel[0].reg_val[reg];
-}
-
-
-
-/*-------------------------------------------------
- scc8530_get_reg_b
--------------------------------------------------*/
-
-UINT8 scc8530_t::get_reg_b(int reg)
-{
- return channel[1].reg_val[reg];
-}
-
-
-
-/*-------------------------------------------------
- scc8530_set_reg_a
--------------------------------------------------*/
-
-void scc8530_t::set_reg_a(int reg, UINT8 data)
-{
- channel[0].reg_val[reg] = data;
-}
-
-
-
-/*-------------------------------------------------
- scc8530_set_reg_a
--------------------------------------------------*/
-
-void scc8530_t::set_reg_b(int reg, UINT8 data)
-{
- channel[1].reg_val[reg] = data;
-}
-
-
-
-/*-------------------------------------------------
- scc8530_r
--------------------------------------------------*/
-
-READ8_MEMBER( scc8530_t::reg_r)
-{
- UINT8 result = 0;
-
- offset %= 4;
-
- switch(offset)
- {
- case 0:
- /* Channel B (Printer Port) Control */
- if (mode == 1)
- mode = 0;
- else
- reg = 0;
-
- result = getbreg();
- break;
-
- case 1:
- /* Channel A (Modem Port) Control */
- if (mode == 1)
- mode = 0;
- else
- reg = 0;
-
- result = getareg();
- break;
-
- case 2:
- /* Channel B (Printer Port) Data */
- result = channel[1].rxData;
- break;
-
- case 3:
- /* Channel A (Modem Port) Data */
- result = channel[0].rxData;
- break;
- }
- return result;
-}
-
-
-
-/*-------------------------------------------------
- scc8530_w
--------------------------------------------------*/
-
-WRITE8_MEMBER( scc8530_t::reg_w )
-{
- Chan *pChan;
-
- offset &= 3;
-
-// printf(" mode %d data %x offset %d \n", mode, data, offset);
-
- switch(offset)
- {
- case 0:
- /* Channel B (Printer Port) Control */
- if (mode == 0)
- {
- if((data & 0xf0) == 0) // not a reset command
- {
- mode = 1;
- reg = data & 0x0f;
-// putbreg(data & 0xf0);
- }
- else if (data == 0x10)
- {
- pChan = &channel[1];
- // clear ext. interrupts
- pChan->extIRQPending = 0;
- pChan->baudIRQPending = 0;
- updateirqs();
- }
- }
- else
- {
- mode = 0;
- putreg(1, data);
- }
- break;
-
- case 1:
- /* Channel A (Modem Port) Control */
- if (mode == 0)
- {
- if((data & 0xf0) == 0) // not a reset command
- {
- mode = 1;
- reg = data & 0x0f;
-// putareg(data & 0xf0);
- }
- else if (data == 0x10)
- {
- pChan = &channel[0];
- // clear ext. interrupts
- pChan->extIRQPending = 0;
- pChan->baudIRQPending = 0;
- updateirqs();
- }
- }
- else
- {
- mode = 0;
- putreg(0, data);
- }
- break;
-
- case 2:
- /* Channel B (Printer Port) Data */
- pChan = &channel[1];
-
- if (pChan->txEnable)
- {
- pChan->txData = data;
- // local loopback?
- if (pChan->reg_val[14] & 0x10)
- {
- pChan->rxData = data;
- pChan->reg_val[0] |= 0x01; // Rx character available
- }
- pChan->reg_val[1] |= 0x01; // All sent
- pChan->reg_val[0] |= 0x04; // Tx empty
- pChan->txUnderrun = 1;
- pChan->txIRQPending = 1;
- updateirqs();
- }
- break;
-
- case 3:
- /* Channel A (Modem Port) Data */
- pChan = &channel[0];
-
- if (pChan->txEnable)
- {
- pChan->txData = data;
- // local loopback?
- if (pChan->reg_val[14] & 0x10)
- {
- pChan->rxData = data;
- pChan->reg_val[0] |= 0x01; // Rx character available
- }
- pChan->reg_val[1] |= 0x01; // All sent
- pChan->reg_val[0] |= 0x04; // Tx empty
- pChan->txUnderrun = 1;
- pChan->txIRQPending = 1;
- updateirqs();
- }
- break;
- }
-}
-
-/*
-
-AppleTalk check:
-
-SCC: port B reg 9 write 0x40 Channel Reset B
-SCC: port B reg 4 write 0x20 SDLC mode
-SCC: port B reg 10 write 0xe0 CRC preset + FM0
-SCC: port B reg 6 write 0x00 SDLC address
-SCC: port B reg 7 write 0x7e SDLC flag
-SCC: port B reg 12 write 0x06 baud rate low
-SCC: port B reg 13 write 0x00 baud rate high
-SCC: port B reg 14 write 0xc0 Set FM mode
-SCC: port B reg 3 write 0xdd Rx 8 bits, enter hunt mode, CRC enable, address search mode, Rx enable
-SCC: port B reg 2 write 0x00 interrupt vector 0
-SCC: port B reg 15 write 0x08 DCD interrupt enable
-SCC: port B reg 1 write 0x09 Rx IRQ on first char or special, ext int enable
-SCC: port B reg 9 write 0x0a Master IRQ enable, no-vector mode
-SCC: port B reg 11 write 0x70 Rx clock = DPLL output, Tx clock = BR generator
-SCC: port B reg 14 write 0x21 Enter search mode, BR generator enable
-SCC: port B reg 5 write 0x60 Tx 8 bits/char
-SCC: port B reg 6 write 0x2a SDLC address
-SCC: port B reg 0 read 0x00
-SCC: port B reg 15 write 0x88 DCD interrupt enable, break/abort interrupt enable
-
-(repeats)
-SCC: port B reg 1 read 0x09
-SCC: port B reg 3 write 0xd0
-SCC: port B reg 3 write 0xdd Rx 8 bits, enter hunt mode, CRC enable, address search mode, Rx enable
-SCC: port B reg 15 write 0x08 DCD interrupt enable
-SCC: port B reg 0 read 0x00
-SCC: port B reg 15 write 0x88
-
-System 7:
-
-SCC: port B reg 9 write 0x40 Channel Reset B
-SCC: port B reg 4 write 0x20 SDLC mode
-SCC: port B reg 10 write 0xe0 CRC preset + FM0
-SCC: port B reg 6 write 0x00 SDLC address
-SCC: port B reg 7 write 0x7e SDLC flag
-SCC: port B reg 12 write 0x06 baud rate low
-SCC: port B reg 13 write 0x00 baud rate high
-SCC: port B reg 14 write 0xc0 Set FM mode
-SCC: port B reg 3 write 0xdd Rx 8 bits, enter hunt mode, CRC enable, address search mode, Rx enable
-SCC: port B reg 2 write 0x00 interrupt vector 0
-SCC: port B reg 15 write 0x08 DCD interrupt enable
-SCC: port B reg 1 write 0x09 Rx IRQ on first char or special, ext int enable
-SCC: port B reg 9 write 0x0a Master IRQ enable, no-vector mode
-SCC: port B reg 11 write 0x70 Rx clock = DPLL output, Tx clock = BR generator
-SCC: port B reg 14 write 0x21 Enter search mode, BR generator enable
-SCC: port B reg 5 write 0x60 Tx 8 bits/char
-SCC: port B reg 6 write 0x01 SDLC address
-SCC: port B reg 3 write 0xdd Rx 8 bits, enter hunt mode, CRC enable, address search mode, Rx enable
-
-(repeats)
-
-SCC: port B reg 0 read 0x00
-SCC: port B reg 15 write 0x88 DCD interrupt enable, break/abort interrupt enable
-SCC: port B reg 15 write 0x08 DCD interrupt enable
-SCC: port B reg 1 read 0x09 Rx IRQ on first char or special, ext int enable
-SCC: port B reg 3 write 0xdd Rx 8 bits, enter hunt mode, CRC enable, address search mode, Rx enable
-
-*/
diff --git a/src/emu/machine/8530scc.h b/src/emu/machine/8530scc.h
deleted file mode 100644
index af4cef88e1e..00000000000
--- a/src/emu/machine/8530scc.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*********************************************************************
-
- 8530scc.h
-
- Zilog 8530 SCC (Serial Control Chip) code
-
-*********************************************************************/
-
-#ifndef __8530SCC_H__
-#define __8530SCC_H__
-
-#define MCFG_Z8530_INTRQ_CALLBACK(_write) \
- devcb = &scc8530_t::set_intrq_wr_callback(*device, DEVCB_##_write);
-
-class scc8530_t : public device_t
-{
-public:
- enum IRQType_t {
- IRQ_NONE,
- IRQ_A_RX,
- IRQ_A_RX_SPECIAL,
- IRQ_B_RX,
- IRQ_B_RX_SPECIAL,
- IRQ_A_TX,
- IRQ_B_TX,
- IRQ_A_EXT,
- IRQ_B_EXT
- };
-
- scc8530_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_intrq_wr_callback(device_t &device, _Object object) { return downcast<scc8530_t &>(device).intrq_cb.set_callback(object); }
-
- UINT8 get_reg_a(int reg);
- UINT8 get_reg_b(int reg);
- void set_reg_a(int reg, UINT8 data);
- void set_reg_b(int reg, UINT8 data);
-
- void set_status(int status);
-
- DECLARE_READ8_MEMBER(reg_r);
- DECLARE_WRITE8_MEMBER(reg_w);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- struct Chan {
- bool txIRQEnable;
- bool rxIRQEnable;
- bool extIRQEnable;
- bool baudIRQEnable;
- bool txIRQPending;
- bool rxIRQPending;
- bool extIRQPending;
- bool baudIRQPending;
- bool txEnable;
- bool rxEnable;
- bool txUnderrun;
- bool txUnderrunEnable;
- bool syncHunt;
- bool DCDEnable;
- bool CTSEnable;
- UINT8 rxData;
- UINT8 txData;
-
- emu_timer *baudtimer;
-
- UINT8 reg_val[16];
- };
-
- int mode;
- int reg;
- int status;
- int IRQV;
- int MasterIRQEnable;
- int lastIRQStat;
- IRQType_t IRQType;
-
- Chan channel[2];
-
- devcb_write_line intrq_cb;
-
- void updateirqs();
- void initchannel(int ch);
- void resetchannel(int ch);
- void acknowledge();
- UINT8 getareg();
- UINT8 getbreg();
- void putreg(int ch, UINT8 data);
-};
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-extern const device_type SCC8530;
-
-#endif /* __8530SCC_H__ */
diff --git a/src/emu/machine/aakart.c b/src/emu/machine/aakart.c
deleted file mode 100644
index 762a1a2f8b9..00000000000
--- a/src/emu/machine/aakart.c
+++ /dev/null
@@ -1,195 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:Angelo Salese
-/***************************************************************************
-
-Acorn Archimedes KART interface
-
-TODO:
-- FIFO
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/aakart.h"
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type AAKART = &device_creator<aakart_device>;
-
-#define HRST 0xff
-#define RAK1 0xfe
-#define RAK2 0xfd
-#define BACK 0x3f
-#define SMAK 0x33 /* keyboard + mouse ack */
-#define MACK 0x32 /* mouse ack */
-#define SACK 0x31 /* keyboard ack */
-#define NACK 0x30 /* no data ack */
-#define RQID 0x20
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// aakart_device - constructor
-//-------------------------------------------------
-
-aakart_device::aakart_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, AAKART, "AAKART", tag, owner, clock, "aakart", __FILE__),
- m_out_tx_cb(*this),
- m_out_rx_cb(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_validity_check - perform validity checks
-// on this device
-//-------------------------------------------------
-
-void aakart_device::device_validity_check(validity_checker &valid) const
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void aakart_device::device_start()
-{
- m_out_tx_cb.resolve_safe();
- m_out_rx_cb.resolve_safe();
- m_rxtimer = timer_alloc(RX_TIMER);
- m_rxtimer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock()));
- m_txtimer = timer_alloc(TX_TIMER);
- m_txtimer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock()));
- m_mousetimer = timer_alloc(MOUSE_TIMER);
- m_mousetimer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock()));
- m_keybtimer = timer_alloc(KEYB_TIMER);
- m_keybtimer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock()));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void aakart_device::device_reset()
-{
- m_status = STATUS_HRST;
- m_new_command = 0;
- m_rx = -1;
- m_mouse_enable = 0;
-}
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void aakart_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if(id == TX_TIMER && m_new_command & 1)
- {
- switch(m_tx_latch)
- {
- case 0x00:
- case 0x02:
- case 0x03:
- case 0x07:
- // ---- -x-- scroll lock
- // ---- --x- num lock
- // ---- ---x caps lock
- break;
- case 0x20:
- m_rx = 0x81;
- m_out_tx_cb(ASSERT_LINE);
- break;
- case 0x30:
- case 0x31:
- case 0x32:
- case 0x33:
- m_keyb_enable = m_tx_latch & 1;
- m_mouse_enable = (m_tx_latch & 2) >> 1;
- if(m_keyb_enable & 1 && m_keyb_state & 1)
- {
- //printf("Got row\n");
- m_rx = m_keyb_row;
- m_out_tx_cb(ASSERT_LINE);
- }
-
- break;
- case 0x3f:
- if(m_keyb_enable & 1 && m_keyb_state & 1)
- {
- //printf("Got col\n");
- m_rx = m_keyb_col;
- m_out_tx_cb(ASSERT_LINE);
- m_keyb_state = 0;
- }
-
- break;
- case 0xfd:
- m_rx = 0xfd;
- m_out_tx_cb(ASSERT_LINE);
- break;
- case 0xfe:
- m_rx = 0xfe;
- m_out_tx_cb(ASSERT_LINE);
- break;
- case 0xff:
- m_rx = 0xff;
- m_out_tx_cb(ASSERT_LINE);
- break;
- default:
- //printf("%02x %02x %02x\n",m_tx_latch,m_rx_latch,m_keyb_enable);
- break;
- }
-
- //m_new_command &= ~1;
- m_out_rx_cb(ASSERT_LINE);
- }
-
-}
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-#include "debugger.h"
-
-READ8_MEMBER( aakart_device::read )
-{
- m_out_tx_cb(CLEAR_LINE);
- //debugger_break(machine());
- return m_rx;
-}
-
-WRITE8_MEMBER( aakart_device::write )
-{
- // if(m_new_command) printf("skip cmd %02x\n",data);
-
- m_tx_latch = data;
- m_out_rx_cb(CLEAR_LINE);
- m_new_command |= 1;
-}
-
-void aakart_device::send_keycode_down(UINT8 row, UINT8 col)
-{
- //printf("keycode down\n");
- m_keyb_row = row | 0xc0;
- m_keyb_col = col | 0xc0;
- m_keyb_state = 1;
-}
-
-void aakart_device::send_keycode_up(UINT8 row, UINT8 col)
-{
- //printf("keycode up\n");
- m_keyb_row = row | 0xd0;
- m_keyb_col = col | 0xd0;
- m_keyb_state = 1;
-}
diff --git a/src/emu/machine/aakart.h b/src/emu/machine/aakart.h
deleted file mode 100644
index bd59a54838a..00000000000
--- a/src/emu/machine/aakart.h
+++ /dev/null
@@ -1,100 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:Angelo Salese
-/***************************************************************************
-
-Acorn Archimedes KART interface
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __AAKARTDEV_H__
-#define __AAKARTDEV_H__
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_AAKART_OUT_TX_CB(_devcb) \
- devcb = &aakart_device::set_out_tx_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AAKART_OUT_RX_CB(_devcb) \
- devcb = &aakart_device::set_out_rx_callback(*device, DEVCB_##_devcb);
-
-
-enum{
- STATUS_NORMAL = 0,
- STATUS_KEYUP,
- STATUS_KEYDOWN,
- STATUS_MOUSE,
- STATUS_HRST,
- STATUS_UNDEFINED
-};
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> aakart_device
-
-class aakart_device : public device_t
-{
-public:
- // construction/destruction
- aakart_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_tx_callback(device_t &device, _Object object) { return downcast<aakart_device &>(device).m_out_tx_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_rx_callback(device_t &device, _Object object) { return downcast<aakart_device &>(device).m_out_rx_cb.set_callback(object); }
-
- // I/O operations
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_READ8_MEMBER( read );
- void send_keycode_down(UINT8 row, UINT8 col);
- void send_keycode_up(UINT8 row, UINT8 col);
-protected:
- // device-level overrides
- virtual void device_validity_check(validity_checker &valid) const;
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- static const device_timer_id RX_TIMER = 1;
- static const device_timer_id TX_TIMER = 2;
- static const device_timer_id MOUSE_TIMER = 3;
- static const device_timer_id KEYB_TIMER = 4;
- emu_timer * m_rxtimer;
- emu_timer * m_txtimer;
- emu_timer * m_mousetimer;
- emu_timer * m_keybtimer;
-
- devcb_write_line m_out_tx_cb;
- devcb_write_line m_out_rx_cb;
- UINT8 m_tx_latch;
- //UINT8 m_rx_latch;
- UINT8 m_rx;
- UINT8 m_new_command;
- UINT8 m_status;
- UINT8 m_mouse_enable;
- UINT8 m_keyb_enable;
- UINT8 m_keyb_row;
- UINT8 m_keyb_col;
- UINT8 m_keyb_state;
-
-};
-
-
-// device type definition
-extern const device_type AAKART;
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-
-
-#endif
diff --git a/src/emu/machine/adc0808.c b/src/emu/machine/adc0808.c
deleted file mode 100644
index dc173cc178e..00000000000
--- a/src/emu/machine/adc0808.c
+++ /dev/null
@@ -1,187 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- National Semiconductor ADC0808/ADC0809 8-Bit A/D Converter emulation
-
-**********************************************************************/
-
-#include "emu.h"
-#include "adc0808.h"
-
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type ADC0808 = &device_creator<adc0808_device>;
-
-//-------------------------------------------------
-// adc0808_device - constructor
-//-------------------------------------------------
-
-adc0808_device::adc0808_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, ADC0808, "ADC0808", tag, owner, clock, "adc0808", __FILE__),
- m_out_eoc_cb(*this),
- m_address(0),
- m_start(0),
- m_eoc(0),
- m_next_eoc(0),
- m_cycle(0),
- m_bit(0)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void adc0808_device::device_start()
-{
- // resolve callbacks
- m_out_eoc_cb.resolve_safe();
- m_in_vref_pos_cb.bind_relative_to(*owner());
- m_in_vref_neg_cb.bind_relative_to(*owner());
- m_in_in_0_cb.bind_relative_to(*owner());
- m_in_in_1_cb.bind_relative_to(*owner());
- m_in_in_2_cb.bind_relative_to(*owner());
- m_in_in_3_cb.bind_relative_to(*owner());
- m_in_in_4_cb.bind_relative_to(*owner());
- m_in_in_5_cb.bind_relative_to(*owner());
- m_in_in_6_cb.bind_relative_to(*owner());
- m_in_in_7_cb.bind_relative_to(*owner());
-
- // allocate timers
- m_cycle_timer = timer_alloc();
- m_cycle_timer->adjust(attotime::zero, 0, attotime::from_hz(clock()));
-
- // register for state saving
- save_item(NAME(m_address));
- save_item(NAME(m_start));
- save_item(NAME(m_eoc));
- save_item(NAME(m_next_eoc));
- save_item(NAME(m_sar));
- save_item(NAME(m_cycle));
- save_item(NAME(m_bit));
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void adc0808_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if (!m_start)
- {
- if (m_cycle == 7)
- {
- m_bit++;
-
- if (m_bit == 8)
- {
- /* sample input */
- double vref_pos = m_in_vref_pos_cb();
- double vref_neg = m_in_vref_neg_cb();
-
- double input = 0;
-
- switch (m_address)
- {
- case 0:
- input = m_in_in_0_cb();
- break;
- case 1:
- input = m_in_in_1_cb();
- break;
- case 2:
- input = m_in_in_2_cb();
- break;
- case 3:
- input = m_in_in_3_cb();
- break;
- case 4:
- input = m_in_in_4_cb();
- break;
- case 5:
- input = m_in_in_5_cb();
- break;
- case 6:
- input = m_in_in_6_cb();
- break;
- case 7:
- input = m_in_in_7_cb();
- break;
- }
- m_sar = (255 * (input - vref_neg)) / (vref_pos - vref_neg);
-
- /* trigger end of conversion */
- m_next_eoc = 1;
- }
- }
- }
-
- if (m_cycle == 0)
- {
- /* set end of conversion pin */
- if (m_next_eoc != m_eoc)
- {
- m_out_eoc_cb(m_next_eoc);
- m_eoc = m_next_eoc;
- }
- }
-
- m_cycle++;
-
- if (m_cycle == 8)
- {
- m_cycle = 0;
- }
-}
-
-
-//-------------------------------------------------
-// data_r - data read
-//-------------------------------------------------
-
-READ8_MEMBER( adc0808_device::data_r )
-{
- return m_sar;
-}
-
-
-//-------------------------------------------------
-// ale_w - address write
-//-------------------------------------------------
-
-WRITE8_MEMBER( adc0808_device::ale_w )
-{
- m_address = data;
-}
-
-
-//-------------------------------------------------
-// start_w - start conversion
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( adc0808_device::start_w )
-{
- if (!m_start && state) // rising edge
- {
- // reset registers
-
- m_sar = 0;
- m_bit = 0;
- }
- else if (m_start && !state) // falling edge
- {
- // start conversion
-
- m_next_eoc = 0;
- }
-
- m_start = state;
-}
diff --git a/src/emu/machine/adc0808.h b/src/emu/machine/adc0808.h
deleted file mode 100644
index a7d1c3eb6c5..00000000000
--- a/src/emu/machine/adc0808.h
+++ /dev/null
@@ -1,140 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- National Semiconductor ADC0808/ADC0809 8-Bit A/D Converter emulation
-
-**********************************************************************
- _____ _____
- IN3 1 |* \_/ | 28 IN2
- IN4 2 | | 27 IN1
- IN5 3 | | 26 IN0
- IN6 4 | | 25 ADD A
- IN7 5 | | 24 ADD B
- START 6 | | 23 ADD C
- EOC 7 | ADC0808 | 22 ALE
- 2-5 8 | ADC0809 | 21 2-1 MSB
- OUTPUT ENABLE 9 | | 20 2-2
- CLOCK 10 | | 19 2-3
- Vcc 11 | | 18 2-4
- Vref+ 12 | | 17 2-8 LSB
- GND 13 | | 16 Vref-
- 2-7 14 |_____________| 15 2-6
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __ADC0808__
-#define __ADC0808__
-
-#include "emu.h"
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> adc0808_analog_read
-
-typedef device_delegate<double ()> adc0808_analog_read_delegate;
-#define ADC0808_ANALOG_READ_CB(name) double name()
-
-
-#define MCFG_ADC0808_OUT_EOC_CB(_devcb) \
- devcb = &adc0808_device::set_out_eoc_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_ADC0808_IN_VREF_POS_CB(_class, _method) \
- adc0808_device::set_in_vref_pos_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_ADC0808_IN_VREF_NEG_CB(_class, _method) \
- adc0808_device::set_in_vref_neg_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_ADC0808_IN_IN_0_CB(_class, _method) \
- adc0808_device::set_in_in_0_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_ADC0808_IN_IN_1_CB(_class, _method) \
- adc0808_device::set_in_in_1_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_ADC0808_IN_IN_2_CB(_class, _method) \
- adc0808_device::set_in_in_2_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_ADC0808_IN_IN_3_CB(_class, _method) \
- adc0808_device::set_in_in_3_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_ADC0808_IN_IN_4_CB(_class, _method) \
- adc0808_device::set_in_in_4_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_ADC0808_IN_IN_5_CB(_class, _method) \
- adc0808_device::set_in_in_5_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_ADC0808_IN_IN_6_CB(_class, _method) \
- adc0808_device::set_in_in_6_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_ADC0808_IN_IN_7_CB(_class, _method) \
- adc0808_device::set_in_in_7_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-// ======================> adc0808_device
-
-class adc0808_device : public device_t
-{
-public:
- // construction/destruction
- adc0808_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_eoc_callback(device_t &device, _Object object) { return downcast<adc0808_device &>(device).m_out_eoc_cb.set_callback(object); }
- static void set_in_vref_pos_callback(device_t &device, adc0808_analog_read_delegate callback) { downcast<adc0808_device &>(device).m_in_vref_pos_cb = callback; }
- static void set_in_vref_neg_callback(device_t &device, adc0808_analog_read_delegate callback) { downcast<adc0808_device &>(device).m_in_vref_neg_cb = callback; }
- static void set_in_in_0_callback(device_t &device, adc0808_analog_read_delegate callback) { downcast<adc0808_device &>(device).m_in_in_0_cb = callback; }
- static void set_in_in_1_callback(device_t &device, adc0808_analog_read_delegate callback) { downcast<adc0808_device &>(device).m_in_in_1_cb = callback; }
- static void set_in_in_2_callback(device_t &device, adc0808_analog_read_delegate callback) { downcast<adc0808_device &>(device).m_in_in_2_cb = callback; }
- static void set_in_in_3_callback(device_t &device, adc0808_analog_read_delegate callback) { downcast<adc0808_device &>(device).m_in_in_3_cb = callback; }
- static void set_in_in_4_callback(device_t &device, adc0808_analog_read_delegate callback) { downcast<adc0808_device &>(device).m_in_in_4_cb = callback; }
- static void set_in_in_5_callback(device_t &device, adc0808_analog_read_delegate callback) { downcast<adc0808_device &>(device).m_in_in_5_cb = callback; }
- static void set_in_in_6_callback(device_t &device, adc0808_analog_read_delegate callback) { downcast<adc0808_device &>(device).m_in_in_6_cb = callback; }
- static void set_in_in_7_callback(device_t &device, adc0808_analog_read_delegate callback) { downcast<adc0808_device &>(device).m_in_in_7_cb = callback; }
-
- DECLARE_READ8_MEMBER( data_r );
- DECLARE_WRITE8_MEMBER( ale_w );
-
- DECLARE_WRITE_LINE_MEMBER( start_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- devcb_write_line m_out_eoc_cb;
- adc0808_analog_read_delegate m_in_vref_pos_cb;
- adc0808_analog_read_delegate m_in_vref_neg_cb;
- adc0808_analog_read_delegate m_in_in_0_cb;
- adc0808_analog_read_delegate m_in_in_1_cb;
- adc0808_analog_read_delegate m_in_in_2_cb;
- adc0808_analog_read_delegate m_in_in_3_cb;
- adc0808_analog_read_delegate m_in_in_4_cb;
- adc0808_analog_read_delegate m_in_in_5_cb;
- adc0808_analog_read_delegate m_in_in_6_cb;
- adc0808_analog_read_delegate m_in_in_7_cb;
-
- int m_address; // analog channel address
- int m_start; // start conversion pin
- int m_eoc; // end of conversion pin
- int m_next_eoc; // next value end of conversion pin
-
- UINT8 m_sar; // successive approximation register
-
- int m_cycle; // clock cycle counter
- int m_bit; // bit counter
-
- // timers
- emu_timer *m_cycle_timer;
-};
-
-
-// device type definition
-extern const device_type ADC0808;
-
-
-
-#endif
diff --git a/src/emu/machine/adc083x.c b/src/emu/machine/adc083x.c
deleted file mode 100644
index 4f1b11cebf0..00000000000
--- a/src/emu/machine/adc083x.c
+++ /dev/null
@@ -1,448 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- National Semiconductor ADC0831 / ADC0832 / ADC0834 / ADC0838
-
- 8-Bit serial I/O A/D Converters with Muliplexer Options
-
-***************************************************************************/
-
-#include "emu.h"
-#include "adc083x.h"
-
-#define VERBOSE_LEVEL ( 0 )
-
-INLINE void ATTR_PRINTF( 3, 4 ) verboselog( int n_level, running_machine &machine, const char *s_fmt, ... )
-{
- if( VERBOSE_LEVEL >= n_level )
- {
- va_list v;
- char buf[ 32768 ];
- va_start( v, s_fmt );
- vsprintf( buf, s_fmt, v );
- va_end( v );
- logerror( "%s: %s", machine.describe_context( ), buf );
- }
-}
-
-/***************************************************************************
- PARAMETERS
-***************************************************************************/
-
-enum
-{
- STATE_IDLE,
- STATE_WAIT_FOR_START,
- STATE_SHIFT_MUX,
- STATE_MUX_SETTLE,
- STATE_OUTPUT_MSB_FIRST,
- STATE_WAIT_FOR_SE,
- STATE_OUTPUT_LSB_FIRST,
- STATE_FINISHED
-};
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-const device_type ADC0831 = &device_creator<adc0831_device>;
-const device_type ADC0832 = &device_creator<adc0832_device>;
-const device_type ADC0834 = &device_creator<adc0834_device>;
-const device_type ADC0838 = &device_creator<adc0838_device>;
-
-adc083x_device::adc083x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_cs(0),
- m_clk(0),
- m_di(0),
- m_se(0),
- m_do(1),
- m_sgl(0),
- m_odd(0),
- m_sel1(0),
- m_sel0(0),
- m_state(STATE_IDLE),
- m_bit(0),
- m_output(0)
-{
-}
-
-adc0831_device::adc0831_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : adc083x_device(mconfig, ADC0831, "ADC0831", tag, owner, clock, "adc0831", __FILE__)
-{
- m_mux_bits = 0;
-}
-
-adc0832_device::adc0832_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : adc083x_device(mconfig, ADC0832, "ADC0832", tag, owner, clock, "adc0832", __FILE__)
-{
- m_mux_bits = 2;
-}
-
-adc0834_device::adc0834_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : adc083x_device(mconfig, ADC0834, "ADC0834", tag, owner, clock, "adc0834", __FILE__)
-{
- m_mux_bits = 3;
-}
-
-adc0838_device::adc0838_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : adc083x_device(mconfig, ADC0838, "ADC0838", tag, owner, clock, "adc0838", __FILE__)
-{
- m_mux_bits = 4;
-}
-
-/*-------------------------------------------------
- adc083x_device::device_start
--------------------------------------------------*/
-
-void adc083x_device::device_start()
-{
- clear_sars();
-
- /* resolve callbacks */
- m_input_callback.bind_relative_to(*owner());
-
- /* register for state saving */
- save_item( NAME(m_cs) );
- save_item( NAME(m_clk) );
- save_item( NAME(m_di) );
- save_item( NAME(m_se) );
- save_item( NAME(m_sars) );
- save_item( NAME(m_do) );
- save_item( NAME(m_sgl) );
- save_item( NAME(m_odd) );
- save_item( NAME(m_sel1) );
- save_item( NAME(m_sel0) );
- save_item( NAME(m_state) );
- save_item( NAME(m_bit) );
- save_item( NAME(m_output) );
- save_item( NAME(m_mux_bits) );
-}
-
-/*-------------------------------------------------
- adc083x_device::clear_sars
--------------------------------------------------*/
-
-void adc083x_device::clear_sars()
-{
- if( type() == ADC0834 || type() == ADC0838 )
- {
- m_sars = 1;
- }
- else
- {
- m_sars = 0;
- }
-}
-
-/*-------------------------------------------------
- adc083x_device::cs_write
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( adc083x_device::cs_write )
-{
- if( m_cs != state )
- {
- verboselog( 2, machine(), "adc083x_cs_write( %s, %d )\n", tag(), state );
- }
-
- if( m_cs == 0 && state != 0 )
- {
- m_state = STATE_IDLE;
- clear_sars();
- m_do = 1;
- }
-
- if( m_cs != 0 && state == 0 )
- {
- if( type() == ADC0831 )
- {
- m_state = STATE_MUX_SETTLE;
- }
- else
- {
- m_state = STATE_WAIT_FOR_START;
- }
-
- clear_sars();
- m_do = 1;
- }
-
- m_cs = state;
-}
-
-/*-------------------------------------------------
- adc083x_device::conversion
--------------------------------------------------*/
-
-UINT8 adc083x_device::conversion()
-{
- int result;
- int positive_channel = ADC083X_AGND;
- int negative_channel = ADC083X_AGND;
- double positive = 0;
- double negative = 0;
- double gnd = m_input_callback(ADC083X_AGND);
- double vref = m_input_callback(ADC083X_VREF);
-
- if( type() == ADC0831 )
- {
- positive_channel = ADC083X_CH0;
- negative_channel = ADC083X_CH1;
- }
- else if( type() == ADC0832 )
- {
- positive_channel = ADC083X_CH0 + m_odd;
- if( m_sgl == 0 )
- {
- negative_channel = positive_channel ^ 1;
- }
- else
- {
- negative_channel = ADC083X_AGND;
- }
- }
- else if( type() == ADC0834 )
- {
- positive_channel = ADC083X_CH0 + m_odd + ( m_sel1 * 2 );
- if( m_sgl == 0 )
- {
- negative_channel = positive_channel ^ 1;
- }
- else
- {
- negative_channel = ADC083X_AGND;
- }
- }
- else if( type() == ADC0838 )
- {
- positive_channel = ADC083X_CH0 + m_odd + ( m_sel0 * 2 ) + ( m_sel1 * 4 );
- if( m_sgl == 0 )
- {
- negative_channel = positive_channel ^ 1;
- }
- else
- {
- negative_channel = ADC083X_COM;
- }
- }
-
- if( positive_channel != ADC083X_AGND )
- {
- positive = m_input_callback(positive_channel) - gnd;
- }
-
- if( negative_channel != ADC083X_AGND )
- {
- negative = m_input_callback(negative_channel) - gnd;
- }
-
- result = (int) ( ( ( positive - negative ) * 255 ) / vref );
- if( result < 0 )
- {
- result = 0;
- }
- else if( result > 255 )
- {
- result = 255;
- }
-
- return result;
-}
-
-/*-------------------------------------------------
- adc083x_device::clk_write
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( adc083x_device::clk_write )
-{
- if( m_clk != state )
- {
- verboselog( 2, machine(), "adc083x_clk_write( %s, %d )\n", tag(), state );
- }
-
- if( m_cs == 0 )
- {
- if( m_clk == 0 && state != 0 )
- {
- switch( m_state )
- {
- case STATE_WAIT_FOR_START:
- if( m_di != 0 )
- {
- verboselog( 1, machine(), "adc083x %s got start bit\n", tag() );
- m_state = STATE_SHIFT_MUX;
- m_sars = 0;
- m_sgl = 0;
- m_odd = 0;
- m_sel1 = 0;
- m_sel0 = 0;
- m_bit = 0;
- }
- else
- {
- verboselog( 1, machine(), "adc083x %s not start bit\n", tag() );
- }
- break;
-
- case STATE_SHIFT_MUX:
- switch( m_bit )
- {
- case 0:
- if( m_di != 0 )
- {
- m_sgl = 1;
- }
- verboselog( 1, machine(), "adc083x %s sgl <- %d\n", tag(), m_sgl );
- break;
-
- case 1:
- if( m_di != 0 )
- {
- m_odd = 1;
- }
- verboselog( 1, machine(), "adc083x %s odd <- %d\n", tag(), m_odd );
- break;
-
- case 2:
- if( m_di != 0 )
- {
- m_sel1 = 1;
- }
- verboselog( 1, machine(), "adc083x %s sel1 <- %d\n", tag(), m_sel1 );
- break;
-
- case 3:
- if( m_di != 0 )
- {
- m_sel0 = 1;
- }
- verboselog( 1, machine(), "adc083x %s sel0 <- %d\n", tag(), m_sel0 );
- break;
- }
-
- m_bit++;
- if( m_bit == m_mux_bits )
- {
- m_state = STATE_MUX_SETTLE;
- }
-
- break;
-
- case STATE_WAIT_FOR_SE:
- m_sars = 0;
- if( type() == ADC0838 && m_se != 0 )
- {
- verboselog( 1, machine(), "adc083x %s not se\n", tag() );
- }
- else
- {
- verboselog( 1, machine(), "adc083x %s got se\n", tag() );
- m_state = STATE_OUTPUT_LSB_FIRST;
- m_bit = 1;
- }
- break;
- }
- }
-
- if( m_clk != 0 && state == 0 )
- {
- switch( m_state )
- {
- case STATE_MUX_SETTLE:
- verboselog( 1, machine(), "adc083x %s mux settle\n", tag() );
- m_output = conversion();
- m_state = STATE_OUTPUT_MSB_FIRST;
- m_bit = 7;
- clear_sars();
- m_do = 0;
- break;
-
- case STATE_OUTPUT_MSB_FIRST:
- m_do = ( m_output >> m_bit ) & 1;
- verboselog( 1, machine(), "adc083x %s msb %d -> %d\n", tag(), m_bit, m_do );
-
- m_bit--;
- if( m_bit < 0 )
- {
- if( type() == ADC0831 )
- {
- m_state = STATE_FINISHED;
- }
- else
- {
- m_state = STATE_WAIT_FOR_SE;
- }
- }
- break;
-
- case STATE_OUTPUT_LSB_FIRST:
- m_do = ( m_output >> m_bit ) & 1;
- verboselog( 1, machine(), "adc083x %s lsb %d -> %d\n", tag(), m_bit, m_do );
-
- m_bit++;
- if( m_bit == 8 )
- {
- m_state = STATE_FINISHED;
- }
- break;
-
- case STATE_FINISHED:
- m_state = STATE_IDLE;
- m_do = 0;
- break;
- }
- }
- }
-
- m_clk = state;
-}
-
-/*-------------------------------------------------
- adc083x_device::di_write
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( adc083x_device::di_write )
-{
- if( m_di != state )
- {
- verboselog( 2, machine(), "adc083x_di_write( %s, %d )\n", tag(), state );
- }
-
- m_di = state;
-}
-
-/*-------------------------------------------------
- adc083x_device::se_write
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( adc083x_device::se_write )
-{
- if( m_se != state )
- {
- verboselog( 2, machine(), "adc083x_se_write( %s, %d )\n", tag(), state );
- }
-
- m_se = state;
-}
-
-/*-------------------------------------------------
- adc083x_device::sars_read
--------------------------------------------------*/
-
-READ_LINE_MEMBER( adc083x_device::sars_read )
-{
- verboselog( 1, machine(), "adc083x_sars_read( %s ) %d\n", tag(), m_sars );
- return m_sars;
-}
-
-/*-------------------------------------------------
- adc083x_device::do_read
--------------------------------------------------*/
-
-READ_LINE_MEMBER( adc083x_device::do_read )
-{
- verboselog( 1, machine(), "adc083x_do_read( %s ) %d\n", tag(), m_do );
- return m_do;
-}
diff --git a/src/emu/machine/adc083x.h b/src/emu/machine/adc083x.h
deleted file mode 100644
index 60050506f81..00000000000
--- a/src/emu/machine/adc083x.h
+++ /dev/null
@@ -1,126 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- National Semiconductor ADC0831 / ADC0832 / ADC0834 / ADC0838
-
- 8-Bit serial I/O A/D Converters with Muliplexer Options
-
-***************************************************************************/
-
-#ifndef __ADC083X_H__
-#define __ADC083X_H__
-
-#include "emu.h"
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-typedef device_delegate<double (UINT8 input)> adc083x_input_delegate;
-#define ADC083X_INPUT_CB(name) double name(UINT8 input)
-
-#define MCFG_ADC083X_INPUT_CB(_class, _method) \
- adc083x_device::set_input_callback(*device, adc083x_input_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-#define ADC083X_CH0 0
-#define ADC083X_CH1 1
-#define ADC083X_CH2 2
-#define ADC083X_CH3 3
-#define ADC083X_CH4 4
-#define ADC083X_CH5 5
-#define ADC083X_CH6 6
-#define ADC083X_CH7 7
-#define ADC083X_COM 8
-#define ADC083X_AGND 9
-#define ADC083X_VREF 10
-
-/***************************************************************************
- MACROS / CONSTANTS
-***************************************************************************/
-
-class adc083x_device : public device_t
-{
-public:
- adc083x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- // static configuration helpers
- static void set_input_callback(device_t &device, adc083x_input_delegate input_callback) { downcast<adc083x_device &>(device).m_input_callback = input_callback; }
-
- DECLARE_WRITE_LINE_MEMBER( cs_write );
- DECLARE_WRITE_LINE_MEMBER( clk_write );
- DECLARE_WRITE_LINE_MEMBER( di_write );
- DECLARE_WRITE_LINE_MEMBER( se_write );
- DECLARE_READ_LINE_MEMBER( sars_read );
- DECLARE_READ_LINE_MEMBER( do_read );
-
-protected:
- // device-level overrides
- virtual void device_start();
-
- INT32 m_mux_bits;
-
-private:
- UINT8 conversion();
-
- void clear_sars();
-
- // internal state
- INT32 m_cs;
- INT32 m_clk;
- INT32 m_di;
- INT32 m_se;
- INT32 m_sars;
- INT32 m_do;
- INT32 m_sgl;
- INT32 m_odd;
- INT32 m_sel1;
- INT32 m_sel0;
- INT32 m_state;
- INT32 m_bit;
- INT32 m_output;
-
- adc083x_input_delegate m_input_callback;
-};
-
-class adc0831_device : public adc083x_device
-{
-public:
- adc0831_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-extern const device_type ADC0831;
-
-
-class adc0832_device : public adc083x_device
-{
-public:
- adc0832_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-extern const device_type ADC0832;
-
-
-class adc0834_device : public adc083x_device
-{
-public:
- adc0834_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-extern const device_type ADC0834;
-
-
-class adc0838_device : public adc083x_device
-{
-public:
- adc0838_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-extern const device_type ADC0838;
-
-
-#endif /* __ADC083X_H__ */
diff --git a/src/emu/machine/adc1038.c b/src/emu/machine/adc1038.c
deleted file mode 100644
index 46b2d7c8e76..00000000000
--- a/src/emu/machine/adc1038.c
+++ /dev/null
@@ -1,121 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Fabio Priuli
-/***************************************************************************
-
- National Semiconductor ADC1038
-
- 10-Bit Serial I/O A/D Converters with Analog Multiplexer and
- Track/hold Function
-
-***************************************************************************/
-
-#include "emu.h"
-#include "adc1038.h"
-
-
-const device_type ADC1038 = &device_creator<adc1038_device>;
-
-adc1038_device::adc1038_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, ADC1038, "ADC1038", tag, owner, clock, "adc1038", __FILE__),
- m_gticlub_hack(0)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void adc1038_device::device_start()
-{
- m_input_cb.bind_relative_to(*owner());
-
- save_item(NAME(m_cycle));
- save_item(NAME(m_clk));
- save_item(NAME(m_adr));
- save_item(NAME(m_data_in));
- save_item(NAME(m_data_out));
- save_item(NAME(m_adc_data));
- save_item(NAME(m_sars));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void adc1038_device::device_reset()
-{
- m_cycle = 0;
- m_clk = 0;
- m_adr = 0;
- m_data_in = 0;
- m_data_out = 0;
- m_adc_data = 0;
- m_sars = 1;
-}
-
-/*****************************************************************************
- DEVICE HANDLERS
-*****************************************************************************/
-
-READ_LINE_MEMBER( adc1038_device::do_read )
-{
- m_data_out = (m_adc_data & 0x200) ? 1 : 0;
- m_adc_data <<= 1;
-
- //printf("ADC DO\n");
- return m_data_out;
-}
-
-WRITE_LINE_MEMBER( adc1038_device::di_write )
-{
- m_data_in = state;
-}
-
-WRITE_LINE_MEMBER( adc1038_device::clk_write )
-{
- // GTI Club doesn't sync on SARS
- if (m_gticlub_hack)
- {
- if (m_clk == 0 && state == 0)
- {
- m_cycle = 0;
-
- /* notice that m_adr is always < 7! */
- m_adc_data = m_input_cb(m_adr);
- }
- }
-
- if (state == 1)
- {
- //printf("ADC CLK, DI = %d, cycle = %d\n", m_data_in, m_cycle);
-
- if (m_cycle == 0) // A2
- {
- m_adr = 0;
- m_adr |= (m_data_in << 2);
- }
- else if (m_cycle == 1) // A1
- {
- m_adr |= (m_data_in << 1);
- }
- else if (m_cycle == 2) // A0
- {
- m_adr |= (m_data_in << 0);
- }
-
- m_cycle++;
- }
-
- m_clk = state;
-}
-
-READ_LINE_MEMBER( adc1038_device::sars_read )
-{
- m_cycle = 0;
-
- /* notice that m_adr is always < 7! */
- m_adc_data = m_input_cb(m_adr);
-
- m_sars ^= 1;
- return m_sars;
-}
diff --git a/src/emu/machine/adc1038.h b/src/emu/machine/adc1038.h
deleted file mode 100644
index 1d6b0f890bc..00000000000
--- a/src/emu/machine/adc1038.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Fabio Priuli
-/***************************************************************************
-
- National Semiconductor ADC1038
-
- 10-Bit Serial I/O A/D Converters with Analog Multiplexer and
- Track/hold Function
-
-***************************************************************************/
-
-#ifndef __ADC1038_H__
-#define __ADC1038_H__
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-typedef device_delegate<int (int input)> adc1038_input_delegate;
-#define ADC1038_INPUT_CB(name) int name(int input)
-
-/***************************************************************************
- MACROS / CONSTANTS
-***************************************************************************/
-
-class adc1038_device : public device_t
-{
-public:
- adc1038_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~adc1038_device() {}
-
- static void set_input_callback(device_t &device, adc1038_input_delegate callback) { downcast<adc1038_device &>(device).m_input_cb = callback; }
- static void set_gti_club_hack(device_t &device, int hack) { downcast<adc1038_device &>(device).m_gticlub_hack = hack; }
-
- DECLARE_READ_LINE_MEMBER( do_read );
- DECLARE_READ_LINE_MEMBER( sars_read );
- DECLARE_WRITE_LINE_MEMBER( di_write );
- DECLARE_WRITE_LINE_MEMBER( clk_write );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
- int m_cycle;
- int m_clk;
- int m_adr;
- int m_data_in;
- int m_data_out;
- int m_adc_data;
- int m_sars;
-
- int m_gticlub_hack;
- adc1038_input_delegate m_input_cb;
-};
-
-extern const device_type ADC1038;
-
-
-#define MCFG_ADC1038_INPUT_CB(_class, _method) \
- adc1038_device::set_input_callback(*device, adc1038_input_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_ADC1038_GTIHACK(_hack) \
- adc1038_device::set_gti_club_hack(*device, _hack);
-
-
-#endif /* __ADC1038_H__ */
diff --git a/src/emu/machine/adc1213x.c b/src/emu/machine/adc1213x.c
deleted file mode 100644
index f6104f273e3..00000000000
--- a/src/emu/machine/adc1213x.c
+++ /dev/null
@@ -1,338 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- National Semiconductor ADC12130 / ADC12132 / ADC12138
-
- Self-calibrating 12-bit Plus Sign Serial I/O A/D Converters with MUX
- and Sample/Hold
-
- TODO:
- - Only ADC12138 currently supported
-
- 2009-06 Converted to be a device
-
-***************************************************************************/
-
-#include "emu.h"
-#include "adc1213x.h"
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-#define ADC1213X_CONV_MODE_12_MSB_FIRST 0
-#define ADC1213X_CONV_MODE_16_MSB_FIRST 1
-#define ADC1213X_CONV_MODE_12_LSB_FIRST 2
-#define ADC1213X_CONV_MODE_16_LSB_FIRST 3
-
-#define ADC1213X_ACQUISITION_TIME_6_CCLK 0
-#define ADC1213X_ACQUISITION_TIME_10_CCLK 1
-#define ADC1213X_ACQUISITION_TIME_18_CCLK 2
-#define ADC1213X_ACQUISITION_TIME_34_CCLK 3
-
-
-
-const device_type ADC12130 = &device_creator<adc12130_device>;
-
-adc12130_device::adc12130_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : adc12138_device(mconfig, ADC12130, "ADC12130", tag, owner, clock, "adc12130", __FILE__)
-{
-}
-
-
-const device_type ADC12132 = &device_creator<adc12132_device>;
-
-adc12132_device::adc12132_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : adc12138_device(mconfig, ADC12132, "ADC12132", tag, owner, clock, "adc12132", __FILE__)
-{
-}
-
-
-const device_type ADC12138 = &device_creator<adc12138_device>;
-
-adc12138_device::adc12138_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, ADC12138, "ADC12138", tag, owner, clock, "adc12138", __FILE__)
-{
-}
-adc12138_device::adc12138_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void adc12138_device::device_start()
-{
- m_cycle = 0;
- m_data_out = 0;
- m_data_in = 0;
- m_auto_cal = 0;
- m_auto_zero = 0;
- m_input_shift_reg = 0;
- m_output_shift_reg = 0;
- m_end_conv = 0;
-
- /* resolve callbacks */
- m_ipt_read_cb.bind_relative_to(*owner());
-
- /* register for state saving */
- save_item(NAME(m_cycle));
- save_item(NAME(m_data_out));
- save_item(NAME(m_data_in));
- save_item(NAME(m_conv_mode));
- save_item(NAME(m_auto_cal));
- save_item(NAME(m_auto_zero));
- save_item(NAME(m_acq_time));
- save_item(NAME(m_data_out_sign));
- save_item(NAME(m_input_shift_reg));
- save_item(NAME(m_output_shift_reg));
- save_item(NAME(m_end_conv));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void adc12138_device::device_reset()
-{
- m_conv_mode = ADC1213X_CONV_MODE_12_MSB_FIRST;
- m_data_out_sign = 1;
- m_auto_cal = 0;
- m_auto_zero = 0;
- m_acq_time = ADC1213X_ACQUISITION_TIME_10_CCLK;
-}
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-/*-------------------------------------------------
- di_w
--------------------------------------------------*/
-
-WRITE8_MEMBER( adc12138_device::di_w )
-{
- m_data_in = data & 1;
-}
-
-/*-------------------------------------------------
- convert
--------------------------------------------------*/
-
-void adc12138_device::convert(int channel, int bits16, int lsbfirst)
-{
- int bits;
- int input_value;
- double input = 0;
-
- if (bits16)
- fatalerror("ADC1213X: 16-bit mode not supported\n");
-
- if (lsbfirst)
- fatalerror("ADC1213X: LSB first not supported\n");
-
- switch (channel)
- {
- case 0x8: // H L L L - CH0 (single-ended)
- {
- input = m_ipt_read_cb(0);
- break;
- }
- case 0xc: // H H L L - CH1 (single-ended)
- {
- input = m_ipt_read_cb(1);
- break;
- }
- case 0x9: // H L L H - CH2 (single-ended)
- {
- input = m_ipt_read_cb(2);
- break;
- }
- case 0xd: // H H L H - CH3 (single-ended)
- {
- input = m_ipt_read_cb(3);
- break;
- }
- case 0xa: // H L H L - CH4 (single-ended)
- {
- input = m_ipt_read_cb(4);
- break;
- }
- case 0xe: // H H H L - CH5 (single-ended)
- {
- input = m_ipt_read_cb(5);
- break;
- }
- case 0xb: // H L H H - CH6 (single-ended)
- {
- input = m_ipt_read_cb(6);
- break;
- }
- case 0xf: // H H H H - CH7 (single-ended)
- {
- input = m_ipt_read_cb(7);
- break;
- }
- default:
- {
- fatalerror("ADC1213X: unsupported channel %02X\n", channel);
- }
- }
-
- input_value = (int)(input * 2047.0);
-
- bits = 12;
-
- // sign-extend if needed
- if (m_data_out_sign)
- {
- input_value = input_value | ((input_value & 0x800) << 1);
- bits++;
- }
-
- m_output_shift_reg = 0;
-
- for (int i = 0; i < bits; i++)
- {
- if (input_value & (1 << ((bits - 1) - i)))
- {
- m_output_shift_reg |= (1 << i);
- }
- }
-
- m_data_out = m_output_shift_reg & 1;
- m_output_shift_reg >>= 1;
-}
-
-/*-------------------------------------------------
- cs_w
--------------------------------------------------*/
-
-WRITE8_MEMBER( adc12138_device::cs_w )
-{
- if (data)
- {
- //printf("ADC: CS\n");
-
- if (m_cycle >= 7)
- {
- int mode = m_input_shift_reg >> (m_cycle - 8);
-
- switch (mode & 0xf)
- {
- case 0x0: // X X X X L L L L - 12 or 13 Bit MSB First conversion
- {
- convert((mode >> 4) & 0xf, 0, 0);
- break;
- }
- case 0x1: // X X X X L L L H - 16 or 17 Bit MSB First conversion
- {
- convert((mode >> 4) & 0xf, 1, 0);
- break;
- }
- case 0x4: // X X X X L H L L - 12 or 13 Bit LSB First conversion
- {
- convert((mode >> 4) & 0xf, 0, 1);
- break;
- }
- case 0x5: // X X X X L H L H - 16 or 17 Bit LSB First conversion
- {
- convert((mode >> 4) & 0xf, 1, 1);
- break;
- }
-
- default:
- {
- switch (mode)
- {
- case 0x08: // L L L L H L L L - Auto cal
- {
- m_auto_cal = 1;
- break;
- }
-
- case 0x0e: // L L L L H H H L - Acquisition time 6 CCLK cycles
- {
- m_acq_time = ADC1213X_ACQUISITION_TIME_6_CCLK;
- break;
- }
-
- case 0x8d: // H L L L H H L H - Data out with sign
- {
- m_data_out_sign = 1;
- break;
- }
-
- case 0x0f: // L L L L H H H H - User mode
- {
- break;
- }
-
- default:
- {
- fatalerror("ADC1213X: unknown config mode %02X\n", mode);
- }
- }
- break;
- }
- }
- }
-
- m_cycle = 0;
- m_input_shift_reg = 0;
-
- m_end_conv = 0;
- }
-}
-
-/*-------------------------------------------------
- sclk_w
--------------------------------------------------*/
-
-WRITE8_MEMBER( adc12138_device::sclk_w )
-{
- if (data)
- {
- //printf("ADC: cycle %d, DI = %d\n", adc1213x->cycle, adc1213x->data_in);
-
- m_input_shift_reg <<= 1;
- m_input_shift_reg |= m_data_in;
-
- m_data_out = m_output_shift_reg & 1;
- m_output_shift_reg >>= 1;
-
- m_cycle++;
- }
-}
-
-/*-------------------------------------------------
- conv_w
--------------------------------------------------*/
-
-WRITE8_MEMBER( adc12138_device::conv_w )
-{
- m_end_conv = 1;
-}
-
-/*-------------------------------------------------
- do_r
--------------------------------------------------*/
-
-READ8_MEMBER( adc12138_device::do_r )
-{
- //printf("ADC: DO\n");
- return m_data_out;
-}
-
-/*-------------------------------------------------
- eoc_r
--------------------------------------------------*/
-
-READ8_MEMBER( adc12138_device::eoc_r )
-{
- return m_end_conv;
-}
diff --git a/src/emu/machine/adc1213x.h b/src/emu/machine/adc1213x.h
deleted file mode 100644
index 3f2f0dbc63c..00000000000
--- a/src/emu/machine/adc1213x.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- National Semiconductor ADC12130 / ADC12132 / ADC12138
-
- Self-calibrating 12-bit Plus Sign Serial I/O A/D Converters with MUX
- and Sample/Hold
-
-***************************************************************************/
-
-#ifndef __ADC1213X_H__
-#define __ADC1213X_H__
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-typedef device_delegate<double (UINT8 input)> adc1213x_ipt_convert_delegate;
-#define ADC12138_IPT_CONVERT_CB(name) double name(UINT8 input)
-
-/***************************************************************************
- MACROS / CONSTANTS
-***************************************************************************/
-
-class adc12138_device : public device_t
-{
-public:
- adc12138_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- adc12138_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
- ~adc12138_device() {}
-
- static void set_ipt_convert_callback(device_t &device, adc1213x_ipt_convert_delegate callback) { downcast<adc12138_device &>(device).m_ipt_read_cb = callback; }
-
- DECLARE_WRITE8_MEMBER( di_w );
- DECLARE_WRITE8_MEMBER( cs_w );
- DECLARE_WRITE8_MEMBER( sclk_w );
- DECLARE_WRITE8_MEMBER( conv_w );
- DECLARE_READ8_MEMBER( do_r );
- DECLARE_READ8_MEMBER( eoc_r );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- void convert(int channel, int bits16, int lsbfirst);
-
- adc1213x_ipt_convert_delegate m_ipt_read_cb;
-
-private:
- // internal state
- int m_cycle;
- int m_data_out;
- int m_data_in;
- int m_conv_mode;
- int m_auto_cal;
- int m_auto_zero;
- int m_acq_time;
- int m_data_out_sign;
- int m_input_shift_reg;
- int m_output_shift_reg;
- int m_end_conv;
-};
-
-extern const device_type ADC12138;
-
-class adc12130_device : public adc12138_device
-{
-public:
- adc12130_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-extern const device_type ADC12130;
-
-class adc12132_device : public adc12138_device
-{
-public:
- adc12132_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-extern const device_type ADC12132;
-
-
-#define MCFG_ADC1213X_IPT_CONVERT_CB(_class, _method) \
- adc12138_device::set_ipt_convert_callback(*device, adc1213x_ipt_convert_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#endif /* __ADC1213X_H__ */
diff --git a/src/emu/machine/aicartc.c b/src/emu/machine/aicartc.c
deleted file mode 100644
index dc6dba7c2e6..00000000000
--- a/src/emu/machine/aicartc.c
+++ /dev/null
@@ -1,169 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Angelo Salese
-/***************************************************************************
-
- AICA-RTC sub-device
-
- TODO:
- - move this inside AICA sound core once that'll get modernized
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/aicartc.h"
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type AICARTC = &device_creator<aicartc_device>;
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// aicartc_device - constructor
-//-------------------------------------------------
-
-aicartc_device::aicartc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, AICARTC, "AICA RTC", tag, owner, clock, "aicartc", __FILE__),
- device_rtc_interface(mconfig, *this)
-{
-}
-
-
-//-------------------------------------------------
-// device_validity_check - perform validity checks
-// on this device
-//-------------------------------------------------
-
-void aicartc_device::device_validity_check(validity_checker &valid) const
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void aicartc_device::device_start()
-{
- m_clock_timer = timer_alloc();
- m_clock_timer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock()));
-
- {
- UINT32 current_time;
- int year_count,cur_year,i;
- const int month_to_day_conversion[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
- system_time systime;
- machine().base_datetime(systime);
-
- /* put the seconds */
- current_time = systime.local_time.second;
- /* put the minutes */
- current_time+= systime.local_time.minute*60;
- /* put the hours */
- current_time+= systime.local_time.hour*60*60;
- /* put the days (note -1) */
- current_time+= (systime.local_time.mday-1)*60*60*24;
- /* take the current year here for calculating leaps */
- cur_year = (systime.local_time.year);
-
- /* take the months - despite popular beliefs, leap years aren't just evenly divisible by 4 */
- if(((((cur_year % 4) == 0) && ((cur_year % 100) != 0)) || ((cur_year % 400) == 0)) && systime.local_time.month > 2)
- current_time+= (month_to_day_conversion[systime.local_time.month]+1)*60*60*24;
- else
- current_time+= (month_to_day_conversion[systime.local_time.month])*60*60*24;
-
- /* put the years */
- year_count = (cur_year-1949);
-
- for(i=0;i<year_count-1;i++)
- current_time += (((((i+1950) % 4) == 0) && (((i+1950) % 100) != 0)) || (((i+1950) % 400) == 0)) ? 60*60*24*366 : 60*60*24*365;
-
- m_rtc_reg_lo = current_time & 0x0000ffff;
- m_rtc_reg_hi = (current_time & 0xffff0000) >> 16;
- }
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void aicartc_device::device_reset()
-{
- m_rtc_tick = 0;
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-
-void aicartc_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- m_rtc_tick++;
- if(m_rtc_tick & 0x8000)
- {
- m_rtc_tick = 0;
- m_rtc_reg_lo++;
- if(m_rtc_reg_lo == 0)
- m_rtc_reg_hi++;
- }
-}
-
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-READ16_MEMBER( aicartc_device::read )
-{
- UINT16 res;
-
- res = 0;
- switch(offset)
- {
- case 0:
- res = m_rtc_reg_hi; break;
- case 1:
- res = m_rtc_reg_lo; break;
- }
-
- return res;
-}
-
-WRITE16_MEMBER( aicartc_device::write )
-{
- switch(offset)
- {
- case 0:
- if(m_we)
- {
- COMBINE_DATA(&m_rtc_reg_hi);
- // clear write enable here?
- }
-
- break;
-
- case 1:
- if(m_we)
- {
- COMBINE_DATA(&m_rtc_reg_lo);
- m_rtc_tick = 0; // low register also clears tick count
- }
-
- break;
-
- case 2:
- m_we = data & 1;
- break;
- }
-
-}
diff --git a/src/emu/machine/aicartc.h b/src/emu/machine/aicartc.h
deleted file mode 100644
index 1b877a604ff..00000000000
--- a/src/emu/machine/aicartc.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Angelo Salese
-/***************************************************************************
-
-Template for skeleton device
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __AICARTCDEV_H__
-#define __AICARTCDEV_H__
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_AICARTC_ADD(_tag,_freq) \
- MCFG_DEVICE_ADD(_tag, AICARTC, _freq)
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> aicartc_device
-
-class aicartc_device : public device_t,
- public device_rtc_interface
-{
-public:
- // construction/destruction
- aicartc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // I/O operations
- DECLARE_WRITE16_MEMBER( write );
- DECLARE_READ16_MEMBER( read );
-
- UINT16 m_rtc_reg_lo,m_rtc_reg_hi;
- UINT16 m_rtc_tick;
- UINT8 m_we;
-
-protected:
- // device-level overrides
- virtual void device_validity_check(validity_checker &valid) const;
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- emu_timer *m_clock_timer;
-};
-
-
-// device type definition
-extern const device_type AICARTC;
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-
-
-#endif
diff --git a/src/emu/machine/akiko.c b/src/emu/machine/akiko.c
deleted file mode 100644
index 99acef43cab..00000000000
--- a/src/emu/machine/akiko.c
+++ /dev/null
@@ -1,927 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Mariusz Wojcieszek
-/***************************************************************************
-
- Akiko
-
- ASIC used in the Amiga CD32. Commodore Part number 391563-01.
-
- - CD-ROM controller
- - Builtin 1KB NVRAM
- - Chunky to planar converter
- - 2x CIA chips
-
-***************************************************************************/
-
-#include "akiko.h"
-#include "includes/amiga.h"
-#include "imagedev/chd_cd.h"
-#include "coreutil.h"
-
-
-//**************************************************************************
-// CONSTANTS / MACROS
-//**************************************************************************
-
-#define LOG_AKIKO 0
-#define LOG_AKIKO_CD 0
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type AKIKO = &device_creator<akiko_device>;
-
-//-------------------------------------------------
-// machine_config_additions - device-specific
-// machine configurations
-//-------------------------------------------------
-
-static MACHINE_CONFIG_FRAGMENT( akiko )
-MACHINE_CONFIG_END
-
-machine_config_constructor akiko_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( akiko );
-}
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// akiko_device - constructor
-//-------------------------------------------------
-
-akiko_device::akiko_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, AKIKO, "CBM AKIKO", tag, owner, clock, "akiko", __FILE__),
- m_c2p_input_index(0),
- m_c2p_output_index(0),
- m_i2c_scl_out(0),
- m_i2c_scl_dir(0),
- m_i2c_sda_out(0),
- m_i2c_sda_dir(0),
- m_cdrom_track_index(0),
- m_cdrom_lba_start(0),
- m_cdrom_lba_end(0),
- m_cdrom_lba_cur(0),
- m_cdrom_readmask(0),
- m_cdrom_readreqmask(0),
- m_cdrom_dmacontrol(0),
- m_cdrom_numtracks(0),
- m_cdrom_speed(0),
- m_cdrom_cmd_start(0),
- m_cdrom_cmd_end(0),
- m_cdrom_cmd_resp(0),
- m_cdda(NULL),
- m_cdrom(NULL),
- m_cdrom_toc(NULL),
- m_dma_timer(NULL),
- m_frame_timer(NULL),
- m_cdrom_is_device(0),
- m_scl_w(*this),
- m_sda_r(*this),
- m_sda_w(*this)
-{
- for (int i = 0; i < 8; i++)
- {
- m_c2p_input_buffer[i] = 0;
- m_c2p_output_buffer[i] = 0;
- }
-
- for (int i = 0; i < 2; i++)
- {
- m_cdrom_status[i] = 0;
- m_cdrom_address[i] = 0;
- }
-}
-
-
-//-------------------------------------------------
-// set_cputag - set cpu tag for cpu we working on
-//-------------------------------------------------
-
-void akiko_device::set_cputag(device_t &device, const char *tag)
-{
- akiko_device &akiko = downcast<akiko_device &>(device);
- akiko.m_cputag = tag;
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void akiko_device::device_start()
-{
- // resolve callbacks
- m_scl_w.resolve_safe();
- m_sda_r.resolve_safe(1);
- m_sda_w.resolve_safe();
-
- m_c2p_input_index = 0;
- m_c2p_output_index = 0;
-
- m_i2c_scl_out = 0;
- m_i2c_scl_dir = 0;
- m_i2c_sda_out = 0;
- m_i2c_sda_dir = 0;
-
- m_cdrom_status[0] = m_cdrom_status[1] = 0;
- m_cdrom_address[0] = m_cdrom_address[1] = 0;
- m_cdrom_track_index = 0;
- m_cdrom_lba_start = 0;
- m_cdrom_lba_end = 0;
- m_cdrom_lba_cur = 0;
- m_cdrom_readmask = 0;
- m_cdrom_readreqmask = 0;
- m_cdrom_dmacontrol = 0;
- m_cdrom_numtracks = 0;
- m_cdrom_speed = 0;
- m_cdrom_cmd_start = 0;
- m_cdrom_cmd_end = 0;
- m_cdrom_cmd_resp = 0;
-
- device_t *cpu = machine().device(m_cputag);
- m_space = &cpu->memory().space(AS_PROGRAM);
-
- m_cdrom_toc = NULL;
- m_dma_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(akiko_device::dma_proc), this));
- m_frame_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(akiko_device::frame_proc), this));
- m_cdda = machine().device<cdda_device>("cdda");
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void akiko_device::device_reset()
-{
- cdrom_image_device *cddevice = machine().device<cdrom_image_device>("cdrom");
-
- if (cddevice != NULL)
- {
- // MESS case
- m_cdrom = cddevice->get_cdrom_file();
- m_cdrom_is_device = 1;
- }
- else
- {
- // MAME case
- m_cdrom = cdrom_open(get_disk_handle(machine(), ":cdrom"));
- m_cdrom_is_device = 0;
- }
-
- /* create the TOC table */
- if ( m_cdrom != NULL && cdrom_get_last_track(m_cdrom) )
- {
- UINT8 *p;
- int i, addrctrl = cdrom_get_adr_control( m_cdrom, 0 );
- UINT32 discend;
-
- discend = cdrom_get_track_start(m_cdrom,cdrom_get_last_track(m_cdrom)-1);
- discend += cdrom_get_toc(m_cdrom)->tracks[cdrom_get_last_track(m_cdrom)-1].frames;
- discend = lba_to_msf(discend);
-
- m_cdrom_numtracks = cdrom_get_last_track(m_cdrom)+3;
-
- m_cdrom_toc = auto_alloc_array(machine(), UINT8, 13*m_cdrom_numtracks);
- memset( m_cdrom_toc, 0, 13*m_cdrom_numtracks);
-
- p = m_cdrom_toc;
- p[1] = ((addrctrl & 0x0f) << 4) | ((addrctrl & 0xf0) >> 4);
- p[3] = 0xa0; /* first track */
- p[8] = 1;
- p += 13;
- p[1] = 0x01;
- p[3] = 0xa1; /* last track */
- p[8] = cdrom_get_last_track(m_cdrom);
- p += 13;
- p[1] = 0x01;
- p[3] = 0xa2; /* disc end */
- p[8] = (discend >> 16 ) & 0xff;
- p[9] = (discend >> 8 ) & 0xff;
- p[10] = discend & 0xff;
- p += 13;
-
- for( i = 0; i < cdrom_get_last_track(m_cdrom); i++ )
- {
- UINT32 trackpos = cdrom_get_track_start(m_cdrom,i);
-
- trackpos = lba_to_msf(trackpos);
- addrctrl = cdrom_get_adr_control( m_cdrom, i );
-
- p[1] = ((addrctrl & 0x0f) << 4) | ((addrctrl & 0xf0) >> 4);
- p[3] = dec_2_bcd( i+1 );
- p[8] = (trackpos >> 16 ) & 0xff;
- p[9] = (trackpos >> 8 ) & 0xff;
- p[10] = trackpos & 0xff;
-
- p += 13;
- }
- }
-
-}
-
-//-------------------------------------------------
-// device_stop - device-specific stop
-//-------------------------------------------------
-
-void akiko_device::device_stop()
-{
- if (!m_cdrom_is_device)
- {
- if( m_cdrom )
- {
- cdrom_close(m_cdrom);
- m_cdrom = (cdrom_file *)NULL;
- }
- }
-}
-
-void akiko_device::nvram_write(UINT32 data)
-{
- m_i2c_scl_out = BIT(data, 31);
- m_i2c_sda_out = BIT(data, 30);
- m_i2c_scl_dir = BIT(data, 15);
- m_i2c_sda_dir = BIT(data, 14);
-
- m_scl_w(m_i2c_scl_out);
- m_sda_w(m_i2c_sda_out);
-}
-
-UINT32 akiko_device::nvram_read()
-{
- UINT32 v = 0;
-
- if (m_i2c_scl_dir)
- v |= m_i2c_scl_out << 31;
-
- if (m_i2c_sda_dir)
- v |= m_i2c_sda_out << 30;
- else
- v |= m_sda_r() << 30;
-
- v |= m_i2c_scl_dir << 15;
- v |= m_i2c_sda_dir << 14;
-
- return v;
-}
-
-/*************************************
- *
- * Akiko Chunky to Planar converter
- *
- ************************************/
-
-void akiko_device::c2p_write(UINT32 data)
-{
- m_c2p_input_buffer[m_c2p_input_index] = data;
- m_c2p_input_index++;
- m_c2p_input_index &= 7;
- m_c2p_output_index = 0;
-}
-
-UINT32 akiko_device::c2p_read()
-{
- UINT32 val;
-
- if ( m_c2p_output_index == 0 )
- {
- int i;
-
- for ( i = 0; i < 8; i++ )
- m_c2p_output_buffer[i] = 0;
-
- for (i = 0; i < 8 * 32; i++)
- {
- if (m_c2p_input_buffer[7 - (i >> 5)] & (1 << (i & 31)))
- m_c2p_output_buffer[i & 7] |= 1 << (i >> 3);
- }
- }
- m_c2p_input_index = 0;
- val = m_c2p_output_buffer[m_c2p_output_index];
- m_c2p_output_index++;
- m_c2p_output_index &= 7;
- return val;
-}
-
-static const char *const akiko_reg_names[] =
-{
- /*0*/ "ID",
- /*1*/ "CDROM STATUS 1",
- /*2*/ "CDROM_STATUS 2",
- /*3*/ "???",
- /*4*/ "CDROM ADDRESS 1",
- /*5*/ "CDROM ADDRESS 2",
- /*6*/ "CDROM COMMAND 1",
- /*7*/ "CDROM COMMAND 2",
- /*8*/ "CDROM READMASK",
- /*9*/ "CDROM DMACONTROL",
- /*A*/ "???",
- /*B*/ "???",
- /*C*/ "NVRAM",
- /*D*/ "???",
- /*E*/ "C2P"
-};
-
-static const char* get_akiko_reg_name(int reg)
-{
- if (reg < 0xf )
- {
- return akiko_reg_names[reg];
- }
- else
- {
- return "???";
- }
-}
-
-/*************************************
- *
- * Akiko CDROM Controller
- *
- ************************************/
-
-void akiko_device::cdda_stop()
-{
- if (m_cdda != NULL)
- {
- m_cdda->stop_audio();
- m_frame_timer->reset( );
- }
-}
-
-void akiko_device::cdda_play(UINT32 lba, UINT32 num_blocks)
-{
- if (m_cdda != NULL)
- {
- m_cdda->start_audio(lba, num_blocks);
- m_frame_timer->adjust( attotime::from_hz( 75 ) );
- }
-}
-
-void akiko_device::cdda_pause(int pause)
-{
- if (m_cdda != NULL)
- {
- if (m_cdda->audio_active() && m_cdda->audio_paused() != pause )
- {
- m_cdda->pause_audio(pause);
-
- if ( pause )
- {
- m_frame_timer->reset( );
- }
- else
- {
- m_frame_timer->adjust( attotime::from_hz( 75 ) );
- }
- }
- }
-}
-
-UINT8 akiko_device::cdda_getstatus(UINT32 *lba)
-{
- if ( lba ) *lba = 0;
-
- if (m_cdda != NULL)
- {
- if (m_cdda->audio_active())
- {
- if ( lba ) *lba = m_cdda->get_audio_lba();
-
- if (m_cdda->audio_paused())
- {
- return 0x12; /* audio paused */
- }
- else
- {
- return 0x11; /* audio in progress */
- }
- }
- else if (m_cdda->audio_ended())
- {
- return 0x13; /* audio ended */
- }
- }
-
- return 0x15; /* no audio status */
-}
-
-void akiko_device::set_cd_status(UINT32 status)
-{
- amiga_state *amiga = machine().driver_data<amiga_state>();
-
- m_cdrom_status[0] |= status;
-
- if ( m_cdrom_status[0] & m_cdrom_status[1] )
- {
- if (LOG_AKIKO_CD)
- logerror("Akiko CD IRQ\n");
-
- amiga->custom_chip_w(REG_INTREQ, INTENA_SETCLR | INTENA_PORTS);
- }
-}
-
-TIMER_CALLBACK_MEMBER(akiko_device::frame_proc)
-{
- (void)param;
-
- if (m_cdda != NULL)
- {
- UINT8 s = cdda_getstatus(NULL);
-
- if ( s == 0x11 )
- {
- set_cd_status(0x80000000); /* subcode ready */
- }
-
- m_frame_timer->adjust( attotime::from_hz( 75 ) );
- }
-}
-
-static UINT32 lba_from_triplet( UINT8 *triplet )
-{
- UINT32 r;
-
- r = bcd_2_dec(triplet[0]) * (60*75);
- r += bcd_2_dec(triplet[1]) * 75;
- r += bcd_2_dec(triplet[2]);
-
- return r;
-}
-
-TIMER_CALLBACK_MEMBER(akiko_device::dma_proc)
-{
- UINT8 buf[2352];
- int index;
-
- if ( (m_cdrom_dmacontrol & 0x04000000) == 0 )
- return;
-
- if ( m_cdrom_readreqmask == 0 )
- return;
-
- index = (m_cdrom_lba_cur - m_cdrom_lba_start) & 0x0f;
-
- if ( m_cdrom_readreqmask & ( 1 << index ) )
- {
- amiga_state *amiga = machine().driver_data<amiga_state>();
- UINT32 track = cdrom_get_track( m_cdrom, m_cdrom_lba_cur );
- UINT32 datasize = cdrom_get_toc( m_cdrom )->tracks[track].datasize;
- UINT32 subsize = cdrom_get_toc( m_cdrom )->tracks[track].subsize;
- int i;
-
- UINT32 curmsf = lba_to_msf( m_cdrom_lba_cur );
- memset( buf, 0, 16 );
-
- buf[3] = m_cdrom_lba_cur - m_cdrom_lba_start;
- memset( &buf[4], 0xff, 8 );
-
- buf[12] = (curmsf >> 16) & 0xff;
- buf[13] = (curmsf >> 8) & 0xff;
- buf[14] = curmsf & 0xff;
- buf[15] = 0x01; /* mode1 */
-
- datasize = 2048;
- if ( !cdrom_read_data( m_cdrom, m_cdrom_lba_cur, &buf[16], CD_TRACK_MODE1 ) )
- {
- logerror( "AKIKO: Read error trying to read sector %08x!\n", m_cdrom_lba_cur );
- return;
- }
-
- if ( subsize )
- {
- if ( !cdrom_read_subcode( m_cdrom, m_cdrom_lba_cur, &buf[16+datasize] ) )
- {
- logerror( "AKIKO: Read error trying to read subcode for sector %08x!\n", m_cdrom_lba_cur );
- return;
- }
- }
-
- if (LOG_AKIKO_CD) logerror( "DMA: sector %d - address %08x\n", m_cdrom_lba_cur, m_cdrom_address[0] + (index*4096) );
-
- for( i = 0; i < 2352; i += 2 )
- {
- UINT16 data;
-
- data = buf[i];
- data <<= 8;
- data |= buf[i+1];
-
- amiga->chip_ram_w(m_cdrom_address[0] + (index*4096) + i, data );
- }
-
- m_cdrom_readmask |= ( 1 << index );
- m_cdrom_readreqmask &= ~( 1 << index );
- m_cdrom_lba_cur++;
- }
-
- if ( m_cdrom_readreqmask == 0 )
- set_cd_status(0x04000000);
- else
- m_dma_timer->adjust( attotime::from_usec( CD_SECTOR_TIME / m_cdrom_speed ) );
-}
-
-void akiko_device::start_dma()
-{
- if ( m_cdrom_readreqmask == 0 )
- return;
-
- if ( m_cdrom_lba_start > m_cdrom_lba_end )
- return;
-
- if ( m_cdrom_speed == 0 )
- return;
-
- m_cdrom_lba_cur = m_cdrom_lba_start;
-
- m_dma_timer->adjust( attotime::from_usec( CD_SECTOR_TIME / m_cdrom_speed ) );
-}
-
-void akiko_device::setup_response( int len, UINT8 *r1 )
-{
- int resp_addr = m_cdrom_address[1];
- UINT8 resp_csum = 0xff;
- UINT8 resp_buffer[32];
- int i;
-
- memset( resp_buffer, 0, sizeof( resp_buffer ) );
-
- for( i = 0; i < len; i++ )
- {
- resp_buffer[i] = r1[i];
- resp_csum -= resp_buffer[i];
- }
-
- resp_buffer[len++] = resp_csum;
-
- for( i = 0; i < len; i++ )
- {
- m_space->write_byte( resp_addr + ((m_cdrom_cmd_resp + i) & 0xff), resp_buffer[i] );
- }
-
- m_cdrom_cmd_resp = (m_cdrom_cmd_resp+len) & 0xff;
-
- set_cd_status(0x10000000); /* new data available */
-}
-
-TIMER_CALLBACK_MEMBER( akiko_device::cd_delayed_cmd )
-{
- UINT8 resp[32];
- UINT8 cddastatus;
-
- if ( m_cdrom_status[0] & 0x10000000 )
- return;
-
- cddastatus = cdda_getstatus(NULL);
-
- if ( cddastatus == 0x11 || cddastatus == 0x12 )
- return;
-
- memset( resp, 0, sizeof( resp ) );
- resp[0] = param;
-
- param &= 0x0f;
-
- if ( param == 0x05 )
- {
- if (LOG_AKIKO_CD) logerror( "AKIKO: Completing Command %d\n", param );
-
- resp[0] = 0x06;
-
- if ( m_cdrom == NULL || m_cdrom_numtracks == 0 )
- {
- resp[1] = 0x80;
- setup_response( 15, resp );
- }
- else
- {
- resp[1] = 0x00;
- memcpy( &resp[2], &m_cdrom_toc[13*m_cdrom_track_index], 13 );
-
- m_cdrom_track_index = ( m_cdrom_track_index + 1 ) % m_cdrom_numtracks;
-
- setup_response( 15, resp );
- }
- }
-}
-
-void akiko_device::update_cdrom()
-{
- UINT8 resp[32], cmdbuf[32];
-
- if ( m_cdrom_status[0] & 0x10000000 )
- return;
-
- while ( m_cdrom_cmd_start != m_cdrom_cmd_end )
- {
- UINT32 cmd_addr = m_cdrom_address[1] + 0x200 + m_cdrom_cmd_start;
- int cmd = m_space->read_byte( cmd_addr );
-
- memset( resp, 0, sizeof( resp ) );
- resp[0] = cmd;
-
- cmd &= 0x0f;
-
- if (LOG_AKIKO_CD) logerror( "CDROM command: %02X\n", cmd );
-
- if ( cmd == 0x02 ) /* pause audio */
- {
- resp[1] = 0x00;
-
- if ( cdda_getstatus(NULL) == 0x11 )
- resp[1] = 0x08;
-
- cdda_pause(1);
-
- m_cdrom_cmd_start = (m_cdrom_cmd_start+2) & 0xff;
-
- setup_response( 2, resp );
- }
- else if ( cmd == 0x03 ) /* unpause audio (and check audiocd playing status) */
- {
- resp[1] = 0x00;
-
- if ( cdda_getstatus(NULL) == 0x11 )
- resp[1] = 0x08;
-
- cdda_pause(0);
-
- m_cdrom_cmd_start = (m_cdrom_cmd_start+2) & 0xff;
-
- setup_response( 2, resp );
- }
- else if ( cmd == 0x04 ) /* seek/read/play cd multi command */
- {
- int i;
- UINT32 startpos, endpos;
-
- for( i = 0; i < 13; i++ )
- {
- cmdbuf[i] = m_space->read_byte( cmd_addr );
- cmd_addr &= 0xffffff00;
- cmd_addr += ( m_cdrom_cmd_start + i + 1 ) & 0xff;
- }
-
- m_cdrom_cmd_start = (m_cdrom_cmd_start+13) & 0xff;
-
- if ( m_cdrom == NULL || m_cdrom_numtracks == 0 )
- {
- resp[1] = 0x80;
- setup_response( 2, resp );
- }
- else
- {
- startpos = lba_from_triplet( &cmdbuf[1] );
- endpos = lba_from_triplet( &cmdbuf[4] );
-
- cdda_stop();
-
- resp[1] = 0x00;
-
- if ( cmdbuf[7] == 0x80 )
- {
- if (LOG_AKIKO_CD) logerror( "%s:AKIKO CD: Data read - start lba: %08x - end lba: %08x\n", machine().describe_context(), startpos, endpos );
- m_cdrom_speed = (cmdbuf[8] & 0x40) ? 2 : 1;
- m_cdrom_lba_start = startpos;
- m_cdrom_lba_end = endpos;
-
- resp[1] = 0x02;
- }
- else if ( cmdbuf[10] & 0x04 )
- {
- logerror( "AKIKO CD: Audio Play - start lba: %08x - end lba: %08x\n", startpos, endpos );
- cdda_play(startpos, endpos - startpos);
- resp[1] = 0x08;
- }
- else
- {
- if (LOG_AKIKO_CD) logerror( "AKIKO CD: Seek - start lba: %08x - end lba: %08x\n", startpos, endpos );
- m_cdrom_track_index = 0;
-
- for( i = 0; i < cdrom_get_last_track(m_cdrom); i++ )
- {
- if ( startpos <= cdrom_get_track_start( m_cdrom, i ) )
- {
- /* reset to 0 */
- m_cdrom_track_index = i + 2;
- m_cdrom_track_index %= m_cdrom_numtracks;
- break;
- }
- }
- }
-
- setup_response( 2, resp );
- }
- }
- else if ( cmd == 0x05 ) /* read toc */
- {
- m_cdrom_cmd_start = (m_cdrom_cmd_start+3) & 0xff;
-
- machine().scheduler().timer_set( attotime::from_msec(1), timer_expired_delegate(FUNC(akiko_device::cd_delayed_cmd ), this), resp[0]);
-
- break;
- }
- else if ( cmd == 0x06 ) /* read subq */
- {
- UINT32 lba;
-
- resp[1] = 0x00;
-
- (void)cdda_getstatus(&lba);
-
- if ( lba > 0 )
- {
- UINT32 disk_pos;
- UINT32 track_pos;
- UINT32 track;
- int addrctrl;
-
- track = cdrom_get_track(m_cdrom, lba);
- addrctrl = cdrom_get_adr_control(m_cdrom, track);
-
- resp[2] = 0x00;
- resp[3] = ((addrctrl & 0x0f) << 4) | ((addrctrl & 0xf0) >> 4);
- resp[4] = dec_2_bcd(track+1);
- resp[5] = 0; /* index */
-
- disk_pos = lba_to_msf(lba);
- track_pos = lba_to_msf(lba - cdrom_get_track_start(m_cdrom, track));
-
- /* track position */
- resp[6] = (track_pos >> 16) & 0xff;
- resp[7] = (track_pos >> 8) & 0xff;
- resp[8] = track_pos & 0xff;
-
- /* disk position */
- resp[9] = (disk_pos >> 24) & 0xff;
- resp[10] = (disk_pos >> 16) & 0xff;
- resp[11] = (disk_pos >> 8) & 0xff;
- resp[12] = disk_pos & 0xff;
- }
- else
- {
- resp[1] = 0x80;
- }
-
- setup_response( 15, resp );
- }
- else if ( cmd == 0x07 ) /* check door status */
- {
- resp[1] = 0x01;
-
- m_cdrom_cmd_start = (m_cdrom_cmd_start+2) & 0xff;
-
- if ( m_cdrom == NULL || m_cdrom_numtracks == 0 )
- resp[1] = 0x80;
-
- setup_response( 20, resp );
- break;
- }
- else
- {
- break;
- }
- }
-}
-
-READ32_MEMBER( akiko_device::read )
-{
- UINT32 retval;
-
- if ( LOG_AKIKO && offset < (0x30/4) )
- {
- logerror( "Reading AKIKO reg %0x [%s] at PC=%06x\n", offset, get_akiko_reg_name(offset), m_space->device().safe_pc() );
- }
-
- switch( offset )
- {
- case 0x00/4: /* ID */
- if ( m_cdrom != NULL ) m_cdda->set_cdrom(m_cdrom);
- return 0x0000cafe;
-
- case 0x04/4: /* CDROM STATUS 1 */
- return m_cdrom_status[0];
-
- case 0x08/4: /* CDROM STATUS 2 */
- return m_cdrom_status[1];
-
- case 0x10/4: /* CDROM ADDRESS 1 */
- return m_cdrom_address[0];
-
- case 0x14/4: /* CDROM ADDRESS 2 */
- return m_cdrom_address[1];
-
- case 0x18/4: /* CDROM COMMAND 1 */
- update_cdrom();
- retval = m_cdrom_cmd_start;
- retval <<= 8;
- retval |= m_cdrom_cmd_resp;
- retval <<= 8;
- return retval;
-
- case 0x1C/4: /* CDROM COMMAND 2 */
- update_cdrom();
- retval = m_cdrom_cmd_end;
- retval <<= 16;
- return retval;
-
- case 0x20/4: /* CDROM DMA SECTOR READ MASK */
- retval = m_cdrom_readmask << 16;
- return retval;
-
- case 0x24/4: /* CDROM DMA ENABLE? */
- retval = m_cdrom_dmacontrol;
- return retval;
-
- case 0x30/4: /* NVRAM */
- return nvram_read();
-
- case 0x38/4: /* C2P */
- return c2p_read();
-
- default:
- break;
- }
-
- return 0;
-}
-
-WRITE32_MEMBER( akiko_device::write )
-{
- if ( LOG_AKIKO && offset < (0x30/4) )
- {
- logerror( "Writing AKIKO reg %0x [%s] with %08x at PC=%06x\n", offset, get_akiko_reg_name(offset), data, m_space->device().safe_pc() );
- }
-
- switch( offset )
- {
- case 0x04/4: /* CDROM STATUS 1 */
- m_cdrom_status[0] = data;
- break;
-
- case 0x08/4: /* CDROM STATUS 2 */
- m_cdrom_status[1] = data;
- m_cdrom_status[0] &= data;
- break;
-
- case 0x10/4: /* CDROM ADDRESS 1 */
- m_cdrom_address[0] = data;
- break;
-
- case 0x14/4: /* CDROM ADDRESS 2 */
- m_cdrom_address[1] = data;
- break;
-
- case 0x18/4: /* CDROM COMMAND 1 */
- if ( ACCESSING_BITS_16_23 )
- m_cdrom_cmd_start = ( data >> 16 ) & 0xff;
-
- if ( ACCESSING_BITS_8_15 )
- m_cdrom_cmd_resp = ( data >> 8 ) & 0xff;
-
- update_cdrom();
- break;
-
- case 0x1C/4: /* CDROM COMMAND 2 */
- if ( ACCESSING_BITS_16_23 )
- m_cdrom_cmd_end = ( data >> 16 ) & 0xff;
-
- update_cdrom();
- break;
-
- case 0x20/4: /* CDROM DMA SECTOR READ REQUEST WRITE */
- if (LOG_AKIKO_CD) logerror( "Read Req mask W: data %08x - mem mask %08x\n", data, mem_mask );
- if ( ACCESSING_BITS_16_31 )
- {
- m_cdrom_readreqmask = (data >> 16);
- m_cdrom_readmask = 0;
- }
- break;
-
- case 0x24/4: /* CDROM DMA ENABLE? */
- if (LOG_AKIKO_CD) logerror( "DMA enable W: data %08x - mem mask %08x\n", data, mem_mask );
- if ( ( m_cdrom_dmacontrol ^ data ) & 0x04000000 )
- {
- if ( data & 0x04000000 )
- start_dma();
- }
- m_cdrom_dmacontrol = data;
- break;
-
- case 0x30/4:
- nvram_write(data);
- break;
-
- case 0x38/4:
- c2p_write(data);
- break;
-
- default:
- break;
- }
-}
diff --git a/src/emu/machine/akiko.h b/src/emu/machine/akiko.h
deleted file mode 100644
index 9be2ac08185..00000000000
--- a/src/emu/machine/akiko.h
+++ /dev/null
@@ -1,155 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Mariusz Wojcieszek
-/***************************************************************************
-
- Akiko
-
- Used in the Amiga CD32
-
- - CD-ROM controller
- - Builtin 1KB NVRAM
- - Chunky to planar converter
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __AKIKO_H__
-#define __AKIKO_H__
-
-#include "emu.h"
-#include "cdrom.h"
-#include "sound/cdda.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_AKIKO_ADD(_tag, _cputag) \
- MCFG_DEVICE_ADD(_tag, AKIKO, 0) \
- akiko_device::set_cputag(*device, _cputag);
-
-#define MCFG_AKIKO_SCL_HANDLER(_devcb) \
- devcb = &akiko_device::set_scl_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_AKIKO_SDA_READ_HANDLER(_devcb) \
- devcb = &akiko_device::set_sda_read_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_AKIKO_SDA_WRITE_HANDLER(_devcb) \
- devcb = &akiko_device::set_sda_write_handler(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> akiko_device
-
-class akiko_device : public device_t
-{
-public:
- akiko_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~akiko_device() {}
-
- // callbacks
- template<class _Object> static devcb_base &set_scl_handler(device_t &device, _Object object)
- { return downcast<akiko_device &>(device).m_scl_w.set_callback(object); }
-
- template<class _Object> static devcb_base &set_sda_read_handler(device_t &device, _Object object)
- { return downcast<akiko_device &>(device).m_sda_r.set_callback(object); }
-
- template<class _Object> static devcb_base &set_sda_write_handler(device_t &device, _Object object)
- { return downcast<akiko_device &>(device).m_sda_w.set_callback(object); }
-
- DECLARE_READ32_MEMBER( read );
- DECLARE_WRITE32_MEMBER( write );
-
- // inline configuration
- static void set_cputag(device_t &device, const char *tag);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_stop();
- virtual void device_reset();
- virtual machine_config_constructor device_mconfig_additions() const;
-
-private:
- // 1X CDROM sector time in msec (300KBps)
- static const int CD_SECTOR_TIME = (1000/((150*1024)/2048));
-
- // internal state
- address_space *m_space;
-
- // chunky to planar converter
- UINT32 m_c2p_input_buffer[8];
- UINT32 m_c2p_output_buffer[8];
- UINT32 m_c2p_input_index;
- UINT32 m_c2p_output_index;
-
- // i2c bus
- int m_i2c_scl_out;
- int m_i2c_scl_dir;
- int m_i2c_sda_out;
- int m_i2c_sda_dir;
-
- // cdrom
- UINT32 m_cdrom_status[2];
- UINT32 m_cdrom_address[2];
- UINT32 m_cdrom_track_index;
- UINT32 m_cdrom_lba_start;
- UINT32 m_cdrom_lba_end;
- UINT32 m_cdrom_lba_cur;
- UINT16 m_cdrom_readmask;
- UINT16 m_cdrom_readreqmask;
- UINT32 m_cdrom_dmacontrol;
- UINT32 m_cdrom_numtracks;
- UINT8 m_cdrom_speed;
- UINT8 m_cdrom_cmd_start;
- UINT8 m_cdrom_cmd_end;
- UINT8 m_cdrom_cmd_resp;
-
- cdda_device *m_cdda;
- cdrom_file *m_cdrom;
-
- UINT8 *m_cdrom_toc;
-
- emu_timer *m_dma_timer;
- emu_timer *m_frame_timer;
-
- int m_cdrom_is_device;
-
- void nvram_write(UINT32 data);
- UINT32 nvram_read();
-
- void c2p_write(UINT32 data);
- UINT32 c2p_read();
-
- void cdda_stop();
- void cdda_play(UINT32 lba, UINT32 num_blocks);
- void cdda_pause(int pause);
- UINT8 cdda_getstatus(UINT32 *lba);
- void set_cd_status(UINT32 status);
-
- TIMER_CALLBACK_MEMBER( frame_proc );
- TIMER_CALLBACK_MEMBER( dma_proc );
-
- void start_dma();
- void setup_response( int len, UINT8 *r1 );
-
- TIMER_CALLBACK_MEMBER( cd_delayed_cmd );
- void update_cdrom();
-
- // i2c interface
- devcb_write_line m_scl_w;
- devcb_read_line m_sda_r;
- devcb_write_line m_sda_w;
-
- const char *m_cputag;
-};
-
-// device type definition
-extern const device_type AKIKO;
-
-#endif
diff --git a/src/emu/machine/am53cf96.c b/src/emu/machine/am53cf96.c
deleted file mode 100644
index 595a38f985b..00000000000
--- a/src/emu/machine/am53cf96.c
+++ /dev/null
@@ -1,194 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
- * am53cf96.c
- *
- * AMD/NCR/Symbios 53CF96 SCSI-2 controller.
- * Qlogic FAS-236 and Emulex ESP-236 are equivalents
- *
- * References:
- * AMD Am53CF96 manual
- *
- */
-
-#include "emu.h"
-#include "am53cf96.h"
-#include "bus/scsi/scsihle.h"
-
-READ8_MEMBER( am53cf96_device::read )
-{
- int rv;
- static const int states[] = { 0, 0, 1, 1, 2, 3, 4, 5, 6, 7, 0 };
-
- if (offset == REG_STATUS)
- {
- scsi_regs[REG_STATUS] &= ~0x7;
- scsi_regs[REG_STATUS] |= states[xfer_state];
- if (xfer_state < 10)
- {
- xfer_state++;
- }
- }
-
- rv = scsi_regs[offset];
-
- if (offset == REG_FIFO)
- {
-// osd_printf_debug("53cf96: read FIFO PC=%x\n", space.device().safe_pc());
- return 0;
- }
-
-// logerror("53cf96: read reg %d = %x (PC=%x)\n", reg, rv>>shift, space.device().safe_pc());
-
- if (offset == REG_IRQSTATE)
- {
- scsi_regs[REG_STATUS] &= ~0x80; // clear IRQ flag
- }
-
- return rv;
-}
-
-void am53cf96_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
-{
- scsi_regs[REG_IRQSTATE] = 8; // indicate success
- scsi_regs[REG_STATUS] |= 0x80; // indicate IRQ
- m_irq_handler(1);
-}
-
-WRITE8_MEMBER( am53cf96_device::write )
-{
-// logerror("53cf96: w %x to reg %d (PC=%x)\n", data, offset, space.device().safe_pc());
-
- // if writing to the target ID, cache it off for later
- if (offset == REG_STATUS)
- {
- last_id = data;
- }
-
- if (offset == REG_XFERCNTLOW || offset == REG_XFERCNTMID || offset == REG_XFERCNTHI)
- {
- scsi_regs[REG_STATUS] &= ~0x10; // clear CTZ bit
- }
-
- // FIFO
- if (offset == REG_FIFO)
- {
-// osd_printf_debug("%02x to FIFO @ %02d\n", data, fptr);
- fifo[fptr++] = data;
- if (fptr > 15)
- {
- fptr = 15;
- }
- }
-
- // command
- if (offset == REG_COMMAND)
- {
- //dma = (data & 0x80) ? 1 : 0;
- fptr = 0;
- switch (data & 0x7f)
- {
- case 0: // NOP
- scsi_regs[REG_IRQSTATE] = 8; // indicate success
- xfer_state = 0;
- break;
- case 2: // reset am53cf96
- scsi_regs[REG_IRQSTATE] = 8; // indicate success
-
- logerror("53cf96: reset target ID = %d (PC = %x)\n", last_id, space.device().safe_pc());
-
- xfer_state = 0;
- break;
- case 3: // reset SCSI bus
- scsi_regs[REG_INTSTATE] = 4; // command sent OK
-
- reset_bus();
-
- xfer_state = 0;
- m_transfer_timer->adjust( attotime::from_hz( 16384 ) );
- break;
- case 0x42: // select with ATN steps
- m_transfer_timer->adjust( attotime::from_hz( 16384 ) );
- if ((fifo[1] == 0) || (fifo[1] == 0x48) || (fifo[1] == 0x4b))
- {
- scsi_regs[REG_INTSTATE] = 6;
- }
- else
- {
- scsi_regs[REG_INTSTATE] = 4;
- }
-
- logerror("53cf96: command %x exec. target ID = %d (PC = %x)\n", fifo[1], last_id, space.device().safe_pc());
-
- select(last_id);
- send_command(&fifo[1], 12);
- xfer_state = 0;
- break;
- case 0x44: // enable selection/reselection
- xfer_state = 0;
- break;
- case 0x10: // information transfer (must not change xfer_state)
- case 0x11: // second phase of information transfer
- case 0x12: // message accepted
- m_transfer_timer->adjust( attotime::from_hz( 16384 ) );
- scsi_regs[REG_INTSTATE] = 6; // command sent OK
- break;
- default:
- printf( "unsupported command %02x\n", data );
- break;
- }
- }
-
- // only update the register mirror if it's not a write-only reg
- if (offset != REG_STATUS && offset != REG_INTSTATE && offset != REG_IRQSTATE && offset != REG_FIFOSTATE)
- {
- scsi_regs[offset] = data;
- }
-}
-
-am53cf96_device::am53cf96_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- legacy_scsi_host_adapter(mconfig, AM53CF96, "53CF96 SCSI", tag, owner, clock, "am53cf96", __FILE__),
- m_irq_handler(*this)
-{
-}
-
-void am53cf96_device::device_start()
-{
- legacy_scsi_host_adapter::device_start();
-
- m_irq_handler.resolve_safe();
-
- memset(scsi_regs, 0, sizeof(scsi_regs));
-
- fptr = 0;
- xfer_state = 0;
- last_id = -1;
-
- save_item( NAME( scsi_regs ) );
- save_item( NAME( fifo ) );
- save_item( NAME( fptr ) );
- save_item( NAME( xfer_state ) );
- save_item( NAME( last_id ) );
-
- m_transfer_timer = timer_alloc( TIMER_TRANSFER );
-}
-
-// retrieve data from the SCSI controller
-void am53cf96_device::dma_read_data(int bytes, UINT8 *pData)
-{
- scsi_regs[REG_STATUS] |= 0x10; // indicate DMA finished
-
- read_data(pData, bytes);
-}
-
-// write data to the SCSI controller
-void am53cf96_device::dma_write_data(int bytes, UINT8 *pData)
-{
-// int i;
-
- scsi_regs[REG_STATUS] |= 0x10; // indicate DMA finished
-
- write_data(pData, bytes);
-}
-
-const device_type AM53CF96 = &device_creator<am53cf96_device>;
diff --git a/src/emu/machine/am53cf96.h b/src/emu/machine/am53cf96.h
deleted file mode 100644
index 8fda3ee0e5b..00000000000
--- a/src/emu/machine/am53cf96.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
- * am53cf96.h
- *
- */
-
-#ifndef _AM53CF96_H_
-#define _AM53CF96_H_
-
-#pragma once
-
-#include "legscsi.h"
-
-#define MCFG_AM53CF96_IRQ_HANDLER(_devcb) \
- devcb = &am53cf96_device::set_irq_handler(*device, DEVCB_##_devcb);
-
-// 53CF96 register set
-enum
-{
- REG_XFERCNTLOW = 0, // read = current xfer count lo byte, write = set xfer count lo byte
- REG_XFERCNTMID, // read = current xfer count mid byte, write = set xfer count mid byte
- REG_FIFO, // read/write = FIFO
- REG_COMMAND, // read/write = command
-
- REG_STATUS, // read = status, write = destination SCSI ID (4)
- REG_IRQSTATE, // read = IRQ status, write = timeout (5)
- REG_INTSTATE, // read = internal state, write = sync xfer period (6)
- REG_FIFOSTATE, // read = FIFO status, write = sync offset
- REG_CTRL1, // read/write = control 1
- REG_CLOCKFCTR, // clock factor (write only)
- REG_TESTMODE, // test mode (write only)
- REG_CTRL2, // read/write = control 2
- REG_CTRL3, // read/write = control 3
- REG_CTRL4, // read/write = control 4
- REG_XFERCNTHI, // read = current xfer count hi byte, write = set xfer count hi byte
- REG_DATAALIGN // data alignment (write only)
-};
-
-class am53cf96_device : public legacy_scsi_host_adapter
-{
-public:
- // construction/destruction
- am53cf96_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_irq_handler(device_t &device, _Object object) { return downcast<am53cf96_device &>(device).m_irq_handler.set_callback(object); }
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- void dma_read_data(int bytes, UINT8 *pData);
- void dma_write_data(int bytes, UINT8 *pData);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- static const device_timer_id TIMER_TRANSFER = 0;
-
- UINT8 scsi_regs[32];
- UINT8 fifo[16];
- UINT8 fptr;
- UINT8 xfer_state;
- UINT8 last_id;
-
- emu_timer* m_transfer_timer;
- devcb_write_line m_irq_handler;
-};
-
-// device type definition
-extern const device_type AM53CF96;
-
-#endif
diff --git a/src/emu/machine/am9517a.c b/src/emu/machine/am9517a.c
deleted file mode 100644
index 469da3d167f..00000000000
--- a/src/emu/machine/am9517a.c
+++ /dev/null
@@ -1,1279 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- AMD AM9517A
- Intel 8237A
- NEC uPD71037
-
- NEC uPD71071 (extended version of above)
-
- a variant is used in the V53 CPU which offers subsets of both the
- uPD71071 and uPD71037 functionality depending on a mode bit.
-
- Multimode DMA Controller emulation
-
-***************************************************************************/
-
-/*
-
- TODO:
-
- - external EOP
-
-*/
-
-/*
-
- When the V53 operates in uPD71071 compatible mode there are the following
- differences from a real uPD71071
-
- V53 Real uPD71071
- Software Reqs No Yes
- Memory-to-Memory DMA No Yes
- DMARQ active level High programmable
- DMAAK active level Low programmable
- Bus Cycle 4 4 or 3
-
- we don't currently handle the differences
-
-*/
-
-#include "am9517a.h"
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type AM9517A = &device_creator<am9517a_device>;
-const device_type V53_DMAU = &device_creator<upd71071_v53_device>;
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-enum
-{
- REGISTER_ADDRESS = 0,
- REGISTER_WORD_COUNT,
- REGISTER_STATUS = 8,
- REGISTER_COMMAND = REGISTER_STATUS,
- REGISTER_REQUEST,
- REGISTER_SINGLE_MASK,
- REGISTER_MODE,
- REGISTER_BYTE_POINTER,
- REGISTER_TEMPORARY,
- REGISTER_MASTER_CLEAR = REGISTER_TEMPORARY,
- REGISTER_CLEAR_MASK,
- REGISTER_MASK
-};
-
-
-#define COMMAND_MEM_TO_MEM BIT(m_command, 0)
-#define COMMAND_CH0_ADDRESS_HOLD BIT(m_command, 1)
-#define COMMAND_DISABLE BIT(m_command, 2)
-#define COMMAND_COMPRESSED_TIMING BIT(m_command, 3)
-#define COMMAND_ROTATING_PRIORITY BIT(m_command, 4)
-#define COMMAND_EXTENDED_WRITE BIT(m_command, 5)
-#define COMMAND_DREQ_ACTIVE_LOW BIT(m_command, 6)
-#define COMMAND_DACK_ACTIVE_HIGH BIT(m_command, 7)
-
-
-#define MODE_TRANSFER_MASK (m_channel[m_current_channel].m_mode & 0x0c)
-#define MODE_TRANSFER_VERIFY 0x00
-#define MODE_TRANSFER_WRITE 0x04
-#define MODE_TRANSFER_READ 0x08
-#define MODE_TRANSFER_ILLEGAL 0x0c
-#define MODE_AUTOINITIALIZE BIT(m_channel[m_current_channel].m_mode, 4)
-#define MODE_ADDRESS_DECREMENT BIT(m_channel[m_current_channel].m_mode, 5)
-#define MODE_MASK (m_channel[m_current_channel].m_mode & 0xc0)
-#define MODE_DEMAND 0x00
-#define MODE_SINGLE 0x40
-#define MODE_BLOCK 0x80
-#define MODE_CASCADE 0xc0
-
-
-enum
-{
- STATE_SI,
- STATE_S0,
- STATE_SC,
- STATE_S1,
- STATE_S2,
- STATE_S3,
- STATE_SW,
- STATE_S4,
- STATE_S11,
- STATE_S12,
- STATE_S13,
- STATE_S14,
- STATE_S21,
- STATE_S22,
- STATE_S23,
- STATE_S24
-};
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// dma_request -
-//-------------------------------------------------
-
-inline void am9517a_device::dma_request(int channel, int state)
-{
- if (LOG) logerror("AM9517A '%s' Channel %u DMA Request: %u\n", tag(), channel, state);
-
- if (state ^ COMMAND_DREQ_ACTIVE_LOW)
- {
- m_status |= (1 << (channel + 4));
- }
- else
- {
- m_status &= ~(1 << (channel + 4));
- }
- trigger(1);
-}
-
-
-//-------------------------------------------------
-// is_request_active -
-//-------------------------------------------------
-
-inline bool am9517a_device::is_request_active(int channel)
-{
- return (BIT(m_status, channel + 4) & !BIT(m_mask, channel)) ? true : false;
-}
-
-
-//-------------------------------------------------
-// is_software_request_active -
-//-------------------------------------------------
-
-inline bool am9517a_device::is_software_request_active(int channel)
-{
- return BIT(m_request, channel) && ((m_channel[channel].m_mode & 0xc0) == MODE_BLOCK);
-}
-
-
-//-------------------------------------------------
-// set_hreq
-//-------------------------------------------------
-
-inline void am9517a_device::set_hreq(int state)
-{
- if (m_hreq != state)
- {
- m_out_hreq_cb(state);
-
- m_hreq = state;
- }
-}
-
-
-//-------------------------------------------------
-// set_dack -
-//-------------------------------------------------
-
-inline void am9517a_device::set_dack()
-{
- for (int channel = 0; channel < 4; channel++)
- {
- if (channel == 0)
- {
- if ((channel == m_current_channel) && !COMMAND_MEM_TO_MEM)
- {
- m_out_dack_0_cb(COMMAND_DACK_ACTIVE_HIGH);
- }
- else
- {
- m_out_dack_0_cb(!COMMAND_DACK_ACTIVE_HIGH);
- }
- }
- else if (channel == 1)
- {
- if ((channel == m_current_channel) && !COMMAND_MEM_TO_MEM)
- {
- m_out_dack_1_cb(COMMAND_DACK_ACTIVE_HIGH);
- }
- else
- {
- m_out_dack_1_cb(!COMMAND_DACK_ACTIVE_HIGH);
- }
- }
- else if (channel == 2)
- {
- if ((channel == m_current_channel) && !COMMAND_MEM_TO_MEM)
- {
- m_out_dack_2_cb(COMMAND_DACK_ACTIVE_HIGH);
- }
- else
- {
- m_out_dack_2_cb(!COMMAND_DACK_ACTIVE_HIGH);
- }
- }
- else if (channel == 3)
- {
- if ((channel == m_current_channel) && !COMMAND_MEM_TO_MEM)
- {
- m_out_dack_3_cb(COMMAND_DACK_ACTIVE_HIGH);
- }
- else
- {
- m_out_dack_3_cb(!COMMAND_DACK_ACTIVE_HIGH);
- }
- }
- }
-}
-
-
-//-------------------------------------------------
-// set_eop -
-//-------------------------------------------------
-
-inline void am9517a_device::set_eop(int state)
-{
- if (m_eop != state)
- {
- m_out_eop_cb(state);
-
- m_eop = state;
- }
-}
-
-
-//-------------------------------------------------
-// dma_read -
-//-------------------------------------------------
-
-inline int am9517a_device::get_state1(bool msb_changed)
-{
- if (COMMAND_MEM_TO_MEM)
- {
- return msb_changed ? STATE_S11 : STATE_S12;
- }
- else
- {
- return msb_changed ? STATE_S1 : STATE_S2;
- }
-}
-
-
-//-------------------------------------------------
-// dma_read -
-//-------------------------------------------------
-
-inline void am9517a_device::dma_read()
-{
- offs_t offset = m_channel[m_current_channel].m_address;
-
- switch (MODE_TRANSFER_MASK)
- {
- case MODE_TRANSFER_VERIFY:
- case MODE_TRANSFER_WRITE:
- switch(m_current_channel)
- {
- case 0:
- m_temp = m_in_ior_0_cb(offset);
- break;
- case 1:
- m_temp = m_in_ior_1_cb(offset);
- break;
- case 2:
- m_temp = m_in_ior_2_cb(offset);
- break;
- case 3:
- m_temp = m_in_ior_3_cb(offset);
- break;
- }
- break;
-
- case MODE_TRANSFER_READ:
- m_temp = m_in_memr_cb(offset);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// dma_write -
-//-------------------------------------------------
-
-inline void am9517a_device::dma_write()
-{
- offs_t offset = m_channel[m_current_channel].m_address;
-
- switch (MODE_TRANSFER_MASK)
- {
- case MODE_TRANSFER_VERIFY: {
- UINT8 v1 = m_in_memr_cb(offset);
- if(0 && m_temp != v1)
- logerror("%s: verify error %02x vs. %02x\n", tag(), m_temp, v1);
- break;
- }
-
- case MODE_TRANSFER_WRITE:
- m_out_memw_cb(offset, m_temp);
- break;
-
- case MODE_TRANSFER_READ:
- switch(m_current_channel)
- {
- case 0:
- m_out_iow_0_cb(offset, m_temp);
- break;
- case 1:
- m_out_iow_1_cb(offset, m_temp);
- break;
- case 2:
- m_out_iow_2_cb(offset, m_temp);
- break;
- case 3:
- m_out_iow_3_cb(offset, m_temp);
- break;
- }
- break;
- }
-}
-
-
-//-------------------------------------------------
-// dma_advance -
-//-------------------------------------------------
-
-inline void am9517a_device::dma_advance()
-{
- bool msb_changed = false;
-
- m_channel[m_current_channel].m_count--;
-
- if (m_current_channel || !COMMAND_MEM_TO_MEM || !COMMAND_CH0_ADDRESS_HOLD)
- {
- if (MODE_ADDRESS_DECREMENT)
- {
- m_channel[m_current_channel].m_address--;
- m_channel[m_current_channel].m_address &= m_address_mask;
-
- if ((m_channel[m_current_channel].m_address & 0xff) == 0xff)
- {
- msb_changed = true;
- }
- }
- else
- {
- m_channel[m_current_channel].m_address++;
- m_channel[m_current_channel].m_address &= m_address_mask;
-
- if ((m_channel[m_current_channel].m_address & 0xff) == 0x00)
- {
- msb_changed = true;
- }
- }
- }
-
- if (m_channel[m_current_channel].m_count == 0xffff)
- {
- end_of_process();
- }
- else
- {
- switch (MODE_MASK)
- {
- case MODE_DEMAND:
- if (!is_request_active(m_current_channel))
- {
- set_hreq(0);
- set_dack();
- m_state = STATE_SI;
- }
- else
- {
- m_state = get_state1(msb_changed);
- }
- break;
-
- case MODE_SINGLE:
- set_hreq(0);
- set_dack();
- m_state = STATE_SI;
- break;
-
- case MODE_BLOCK:
- m_state = get_state1(msb_changed);
- break;
-
- case MODE_CASCADE:
- break;
- }
- }
-}
-
-
-//-------------------------------------------------
-// end_of_process -
-//-------------------------------------------------
-
-inline void am9517a_device::end_of_process()
-{
- // terminal count
- if (COMMAND_MEM_TO_MEM)
- {
- m_status |= 1 << 0;
- m_status |= 1 << 1;
- m_request &= ~(1 << 0);
- m_request &= ~(1 << 1);
- }
- else
- {
- m_status |= 1 << m_current_channel;
- m_request &= ~(1 << m_current_channel);
- }
-
- if (MODE_AUTOINITIALIZE)
- {
- // autoinitialize
- m_channel[m_current_channel].m_address = m_channel[m_current_channel].m_base_address;
- m_channel[m_current_channel].m_count = m_channel[m_current_channel].m_base_count;
- }
- else
- {
- // mask out channel
- m_mask |= 1 << m_current_channel;
- }
-
- // signal end of process
- set_eop(ASSERT_LINE);
- set_hreq(0);
-
- m_current_channel = -1;
- set_dack();
-
- m_state = STATE_SI;
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// am9517a_device - constructor
-//-------------------------------------------------
-
-
-am9517a_device::am9517a_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, __FILE__),
- device_execute_interface(mconfig, *this),
- m_icount(0),
- m_hack(0),
- m_ready(1),
- m_command(0),
- m_out_hreq_cb(*this),
- m_out_eop_cb(*this),
- m_in_memr_cb(*this),
- m_out_memw_cb(*this),
- m_in_ior_0_cb(*this),
- m_in_ior_1_cb(*this),
- m_in_ior_2_cb(*this),
- m_in_ior_3_cb(*this),
- m_out_iow_0_cb(*this),
- m_out_iow_1_cb(*this),
- m_out_iow_2_cb(*this),
- m_out_iow_3_cb(*this),
- m_out_dack_0_cb(*this),
- m_out_dack_1_cb(*this),
- m_out_dack_2_cb(*this),
- m_out_dack_3_cb(*this)
-{
-}
-
-
-am9517a_device::am9517a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, AM9517A, "AM9517A", tag, owner, clock, "am9517a", __FILE__),
- device_execute_interface(mconfig, *this),
- m_icount(0),
- m_hack(0),
- m_ready(1),
- m_command(0),
- m_out_hreq_cb(*this),
- m_out_eop_cb(*this),
- m_in_memr_cb(*this),
- m_out_memw_cb(*this),
- m_in_ior_0_cb(*this),
- m_in_ior_1_cb(*this),
- m_in_ior_2_cb(*this),
- m_in_ior_3_cb(*this),
- m_out_iow_0_cb(*this),
- m_out_iow_1_cb(*this),
- m_out_iow_2_cb(*this),
- m_out_iow_3_cb(*this),
- m_out_dack_0_cb(*this),
- m_out_dack_1_cb(*this),
- m_out_dack_2_cb(*this),
- m_out_dack_3_cb(*this)
-
-{
-}
-
-upd71071_v53_device::upd71071_v53_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : am9517a_device(mconfig, V53_DMAU, "V53 DMAU", tag, owner, clock, "v53_dmau")
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void am9517a_device::device_start()
-{
- // set our instruction counter
- m_icountptr = &m_icount;
-
- // resolve callbacks
- m_out_hreq_cb.resolve_safe();
- m_out_eop_cb.resolve_safe();
- m_in_memr_cb.resolve_safe(0);
- m_out_memw_cb.resolve_safe();
- m_in_ior_0_cb.resolve_safe(0);
- m_in_ior_1_cb.resolve_safe(0);
- m_in_ior_2_cb.resolve_safe(0);
- m_in_ior_3_cb.resolve_safe(0);
- m_out_iow_0_cb.resolve_safe();
- m_out_iow_1_cb.resolve_safe();
- m_out_iow_2_cb.resolve_safe();
- m_out_iow_3_cb.resolve_safe();
- m_out_dack_0_cb.resolve_safe();
- m_out_dack_1_cb.resolve_safe();
- m_out_dack_2_cb.resolve_safe();
- m_out_dack_3_cb.resolve_safe();
-
- for (int i = 0; i < 4; i++)
- {
- m_channel[i].m_address = 0;
- m_channel[i].m_count = 0;
- m_channel[i].m_base_address = 0;
- m_channel[i].m_base_count = 0;
- m_channel[i].m_mode = 0;
- }
-
- // state saving
- save_item(NAME(m_msb));
- save_item(NAME(m_hreq));
- save_item(NAME(m_hack));
- save_item(NAME(m_ready));
- save_item(NAME(m_eop));
- save_item(NAME(m_state));
- save_item(NAME(m_current_channel));
- save_item(NAME(m_last_channel));
- save_item(NAME(m_command));
- save_item(NAME(m_mask));
- save_item(NAME(m_status));
- save_item(NAME(m_temp));
- save_item(NAME(m_request));
-
- for (int i = 0; i < 4; i++)
- {
- save_item(NAME(m_channel[i].m_address), i);
- save_item(NAME(m_channel[i].m_count), i);
- save_item(NAME(m_channel[i].m_base_address), i);
- save_item(NAME(m_channel[i].m_base_count), i);
- save_item(NAME(m_channel[i].m_mode), i);
- }
-
- m_address_mask = 0xffff;
-
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void am9517a_device::device_reset()
-{
- m_state = STATE_SI;
- m_command = 0;
- m_status = 0;
- m_request = 0;
- m_mask = 0x0f;
- m_temp = 0;
- m_msb = 0;
- m_current_channel = -1;
- m_last_channel = 3;
- m_hreq = -1;
- m_eop = 0;
-
- set_hreq(0);
- set_eop(ASSERT_LINE);
-
- set_dack();
-}
-
-
-//-------------------------------------------------
-// execute_run -
-//-------------------------------------------------
-
-void am9517a_device::execute_run()
-{
- do
- {
- switch (m_state)
- {
- case STATE_SI:
- set_eop(CLEAR_LINE);
-
- if (!COMMAND_DISABLE)
- {
- int priority[] = { 0, 1, 2, 3 };
-
- if (COMMAND_ROTATING_PRIORITY)
- {
- int last_channel = m_last_channel;
-
- for (int channel = 3; channel >= 0; channel--)
- {
- priority[channel] = last_channel;
- last_channel--;
- if (last_channel < 0) last_channel = 3;
- }
- }
-
- for (int channel = 0; channel < 4; channel++)
- {
- if (is_request_active(priority[channel]) || is_software_request_active(priority[channel]))
- {
- m_current_channel = m_last_channel = priority[channel];
- m_state = STATE_S0;
- break;
- }
- else if (COMMAND_MEM_TO_MEM && BIT(m_request, channel) && ((m_channel[channel].m_mode & 0xc0) == MODE_SINGLE))
- {
- m_current_channel = m_last_channel = priority[channel];
- m_state = STATE_S0;
- break;
- }
- }
- }
- if(m_state == STATE_SI)
- {
- suspend_until_trigger(1, true);
- m_icount = 0;
- }
- break;
-
- case STATE_S0:
- set_hreq(1);
-
- if (m_hack)
- {
- m_state = (MODE_MASK == MODE_CASCADE) ? STATE_SC : get_state1(true);
- }
- else
- {
- suspend_until_trigger(1, true);
- m_icount = 0;
- }
- break;
-
- case STATE_SC:
- if (!is_request_active(m_current_channel))
- {
- set_hreq(0);
- m_current_channel = -1;
- m_state = STATE_SI;
- }
- else
- {
- suspend_until_trigger(1, true);
- m_icount = 0;
- }
-
- set_dack();
- break;
-
- case STATE_S1:
- m_state = STATE_S2;
- break;
-
- case STATE_S2:
- set_dack();
- m_state = COMMAND_COMPRESSED_TIMING ? STATE_S4 : STATE_S3;
- break;
-
- case STATE_S3:
- dma_read();
-
- if (COMMAND_EXTENDED_WRITE)
- {
- dma_write();
- }
-
- m_state = m_ready ? STATE_S4 : STATE_SW;
- break;
-
- case STATE_SW:
- m_state = m_ready ? STATE_S4 : STATE_SW;
- break;
-
- case STATE_S4:
- if (COMMAND_COMPRESSED_TIMING)
- {
- dma_read();
- dma_write();
- }
- else if (!COMMAND_EXTENDED_WRITE)
- {
- dma_write();
- }
-
- dma_advance();
- break;
-
- case STATE_S11:
- m_current_channel = 0;
-
- m_state = STATE_S12;
- break;
-
- case STATE_S12:
- m_state = STATE_S13;
- break;
-
- case STATE_S13:
- m_state = STATE_S14;
- break;
-
- case STATE_S14:
- dma_read();
-
- m_state = STATE_S21;
- break;
-
- case STATE_S21:
- m_current_channel = 1;
-
- m_state = STATE_S22;
- break;
-
- case STATE_S22:
- m_state = STATE_S23;
- break;
-
- case STATE_S23:
- m_state = STATE_S24;
- break;
-
- case STATE_S24:
- dma_write();
- dma_advance();
-
- m_current_channel = 0;
- m_channel[m_current_channel].m_count--;
- if (MODE_ADDRESS_DECREMENT)
- {
- m_channel[m_current_channel].m_address--;
- m_channel[m_current_channel].m_address &= m_address_mask;
- }
- else
- {
- m_channel[m_current_channel].m_address++;
- m_channel[m_current_channel].m_address &= m_address_mask;
- }
-
- break;
- }
-
- m_icount--;
- } while (m_icount > 0);
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( am9517a_device::read )
-{
- UINT8 data = 0;
-
- if (!BIT(offset, 3))
- {
- int channel = (offset >> 1) & 0x03;
-
- switch (offset & 0x01)
- {
- case REGISTER_ADDRESS:
- if (m_msb)
- {
- data = m_channel[channel].m_address >> 8;
- }
- else
- {
- data = m_channel[channel].m_address & 0xff;
- }
- break;
-
- case REGISTER_WORD_COUNT:
- if (m_msb)
- {
- data = m_channel[channel].m_count >> 8;
- }
- else
- {
- data = m_channel[channel].m_count & 0xff;
- }
- break;
- }
-
- m_msb = !m_msb;
- }
- else
- {
- switch (offset & 0x0f)
- {
- case REGISTER_STATUS:
- data = m_status;
-
- // clear TC bits
- m_status &= 0xf0;
- break;
-
- case REGISTER_TEMPORARY:
- data = m_temp;
- break;
-
- case REGISTER_MASK:
- data = m_mask;
- break;
- }
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( am9517a_device::write )
-{
- if (!BIT(offset, 3))
- {
- int channel = (offset >> 1) & 0x03;
-
- switch (offset & 0x01)
- {
- case REGISTER_ADDRESS:
- if (m_msb)
- {
- m_channel[channel].m_base_address = (data << 8) | (m_channel[channel].m_base_address & 0xff);
- m_channel[channel].m_address = (data << 8) | (m_channel[channel].m_address & 0xff);
- }
- else
- {
- m_channel[channel].m_base_address = (m_channel[channel].m_base_address & 0xff00) | data;
- m_channel[channel].m_address = (m_channel[channel].m_address & 0xff00) | data;
- }
-
- if (LOG) logerror("AM9517A '%s' Channel %u Base Address: %04x\n", tag(), channel, m_channel[channel].m_base_address);
- break;
-
- case REGISTER_WORD_COUNT:
- if (m_msb)
- {
- m_channel[channel].m_base_count = (data << 8) | (m_channel[channel].m_base_count & 0xff);
- m_channel[channel].m_count = (data << 8) | (m_channel[channel].m_count & 0xff);
- }
- else
- {
- m_channel[channel].m_base_count = (m_channel[channel].m_base_count & 0xff00) | data;
- m_channel[channel].m_count = (m_channel[channel].m_count & 0xff00) | data;
- }
-
- if (LOG) logerror("AM9517A '%s' Channel %u Base Word Count: %04x\n", tag(), channel, m_channel[channel].m_base_count);
- break;
- }
-
- m_msb = !m_msb;
- }
- else
- {
- switch (offset & 0x0f)
- {
- case REGISTER_COMMAND:
- m_command = data;
-
- if (LOG) logerror("AM9517A '%s' Command Register: %02x\n", tag(), m_command);
- break;
-
- case REGISTER_REQUEST:
- {
- int channel = data & 0x03;
-
- if (BIT(data, 2))
- {
- m_request |= (1 << (channel + 4));
- if (COMMAND_MEM_TO_MEM)
- {
- m_request |= (1 << channel);
- }
- }
- else
- {
- m_request &= ~(1 << (channel + 4));
- }
-
- if (LOG) logerror("AM9517A '%s' Request Register: %01x\n", tag(), m_request);
- }
- break;
-
- case REGISTER_SINGLE_MASK:
- {
- int channel = data & 0x03;
-
- if (BIT(data, 2))
- {
- m_mask |= (1 << channel);
- }
- else
- {
- m_mask &= ~(1 << channel);
- }
-
- if (LOG) logerror("AM9517A '%s' Mask Register: %01x\n", tag(), m_mask);
- }
- break;
-
- case REGISTER_MODE:
- {
- int channel = data & 0x03;
-
- m_channel[channel].m_mode = data & 0xfc;
-
- // clear terminal count
- m_status &= ~(1 << channel);
-
- if (LOG) logerror("AM9517A '%s' Channel %u Mode: %02x\n", tag(), channel, data & 0xfc);
- }
- break;
-
- case REGISTER_BYTE_POINTER:
- if (LOG) logerror("AM9517A '%s' Clear Byte Pointer Flip-Flop\n", tag());
-
- m_msb = 0;
- break;
-
- case REGISTER_MASTER_CLEAR:
- if (LOG) logerror("AM9517A '%s' Master Clear\n", tag());
-
- device_reset();
- break;
-
- case REGISTER_CLEAR_MASK:
- if (LOG) logerror("AM9517A '%s' Clear Mask Register\n", tag());
-
- m_mask = 0;
- break;
-
- case REGISTER_MASK:
- m_mask = data & 0x0f;
-
- if (LOG) logerror("AM9517A '%s' Mask Register: %01x\n", tag(), m_mask);
- break;
- }
- }
- trigger(1);
-}
-
-
-//-------------------------------------------------
-// hack_w - hold acknowledge
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( am9517a_device::hack_w )
-{
- if (LOG) logerror("AM9517A '%s' Hold Acknowledge: %u\n", tag(), state);
-
- m_hack = state;
- trigger(1);
-}
-
-
-//-------------------------------------------------
-// ready_w - ready
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( am9517a_device::ready_w )
-{
- if (LOG) logerror("AM9517A '%s' Ready: %u\n", tag(), state);
-
- m_ready = state;
-}
-
-
-//-------------------------------------------------
-// eop_w - end of process
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( am9517a_device::eop_w )
-{
- if (LOG) logerror("AM9517A '%s' End of Process: %u\n", tag(), state);
-}
-
-
-//-------------------------------------------------
-// dreq0_w - DMA request for channel 0
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( am9517a_device::dreq0_w )
-{
- dma_request(0, state);
-}
-
-
-//-------------------------------------------------
-// dreq0_w - DMA request for channel 1
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( am9517a_device::dreq1_w )
-{
- dma_request(1, state);
-}
-
-
-//-------------------------------------------------
-// dreq1_w - DMA request for channel 2
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( am9517a_device::dreq2_w )
-{
- dma_request(2, state);
-}
-
-
-//-------------------------------------------------
-// dreq3_w - DMA request for channel 3
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( am9517a_device::dreq3_w )
-{
- dma_request(3, state);
-}
-
-//-------------------------------------------------
-// upd71071 register layouts
-//-------------------------------------------------
-
-void upd71071_v53_device::device_start()
-{
- am9517a_device::device_start();
- m_address_mask = 0x00ffffff;
-
- m_selected_channel = 0;
- m_base = 0;
-
- save_item(NAME(m_selected_channel));
- save_item(NAME(m_base));
-}
-
-void upd71071_v53_device::device_reset()
-{
- am9517a_device::device_reset();
-
- m_selected_channel = 0;
- m_base = 0;
-}
-
-
-READ8_MEMBER(upd71071_v53_device::read)
-{
- UINT8 ret = 0;
- int channel = m_selected_channel;
-
- if (LOG) logerror("DMA: read from register %02x\n",offset);
-
- switch (offset)
- {
- case 0x01: // Channel
- ret = (1 << m_selected_channel);
- if (m_base != 0)
- ret |= 0x10;
- break;
- case 0x02: // Count (low)
- if (m_base != 0)
- ret = m_channel[channel].m_base_count & 0xff;
- else
- ret = m_channel[channel].m_count & 0xff;
- break;
- case 0x03: // Count (high)
- if (m_base != 0)
- ret = (m_channel[channel].m_base_count >> 8) & 0xff;
- else
- ret = (m_channel[channel].m_count >> 8) & 0xff;
- break;
- case 0x04: // Address (low)
- if (m_base != 0)
- ret = m_channel[channel].m_base_address & 0xff;
- else
- ret = m_channel[channel].m_address & 0xff;
- break;
- case 0x05: // Address (mid)
- if (m_base != 0)
- ret = (m_channel[channel].m_base_address >> 8) & 0xff;
- else
- ret = (m_channel[channel].m_address >> 8) & 0xff;
- break;
- case 0x06: // Address (high)
- if (m_base != 0)
- ret = (m_channel[channel].m_base_address >> 16) & 0xff;
- else
- ret = (m_channel[channel].m_address >> 16) & 0xff;
- break;
- case 0x07: // Address (highest)
- if (m_base != 0)
- ret = (m_channel[channel].m_base_address >> 24) & 0xff;
- else
- ret = (m_channel[channel].m_address >> 24) & 0xff;
- break;
- case 0x0a: // Mode control
- ret = (m_channel[channel].m_mode);
- break;
-
- case 0x08: // Device control (low)
- ret = m_command & 0xff;
- break;
- case 0x09: // Device control (high) // UPD71071 only?
- ret = m_command_high & 0xff;
- break;
- case 0x0b: // Status
- ret = m_status;
- // clear TC bits
- m_status &= 0xf0;
- break;
- case 0x0c: // Temporary (low)
- ret = m_temp & 0xff;
- break;
- case 0x0d: // Temporary (high) // UPD71071 only? (other doesn't do 16-bit?)
- ret = (m_temp >> 8 ) & 0xff;
- break;
- case 0x0e: // Request
- //ret = m_reg.request;
- ret = 0; // invalid?
- break;
- case 0x0f: // Mask
- ret = m_mask;
- break;
-
- }
-
- return ret;
-}
-
-WRITE8_MEMBER(upd71071_v53_device::write)
-{
- int channel = m_selected_channel;
-
- switch (offset)
- {
- case 0x00: // Initialise
- // TODO: reset (bit 0)
- //m_buswidth = data & 0x02;
- //if (data & 0x01)
- // soft_reset();
- logerror("DMA: Initialise [%02x]\n", data);
- break;
- case 0x01: // Channel
- m_selected_channel = data & 0x03;
- m_base = data & 0x04;
- logerror("DMA: Channel selected [%02x]\n", data);
- break;
- case 0x02: // Count (low)
- m_channel[channel].m_base_count =
- (m_channel[channel].m_base_count & 0xff00) | data;
- if (m_base == 0)
- m_channel[channel].m_count =
- (m_channel[channel].m_count & 0xff00) | data;
- logerror("DMA: Channel %i Counter set [%04x]\n", m_selected_channel, m_channel[channel].m_base_count);
- break;
- case 0x03: // Count (high)
- m_channel[channel].m_base_count =
- (m_channel[channel].m_base_count & 0x00ff) | (data << 8);
- if (m_base == 0)
- m_channel[channel].m_count =
- (m_channel[channel].m_count & 0x00ff) | (data << 8);
- logerror("DMA: Channel %i Counter set [%04x]\n", m_selected_channel, m_channel[channel].m_base_count);
- break;
- case 0x04: // Address (low)
- m_channel[channel].m_base_address =
- (m_channel[channel].m_base_address & 0xffffff00) | data;
- if (m_base == 0)
- m_channel[channel].m_address =
- (m_channel[channel].m_address & 0xffffff00) | data;
- logerror("DMA: Channel %i Address set [%08x]\n", m_selected_channel, m_channel[channel].m_base_address);
- break;
- case 0x05: // Address (mid)
- m_channel[channel].m_base_address =
- (m_channel[channel].m_base_address & 0xffff00ff) | (data << 8);
- if (m_base == 0)
- m_channel[channel].m_address =
- (m_channel[channel].m_address & 0xffff00ff) | (data << 8);
- logerror("DMA: Channel %i Address set [%08x]\n", m_selected_channel, m_channel[channel].m_base_address);
- break;
- case 0x06: // Address (high)
- m_channel[channel].m_base_address =
- (m_channel[channel].m_base_address & 0xff00ffff) | (data << 16);
- if (m_base == 0)
- m_channel[channel].m_address =
- (m_channel[channel].m_address & 0xff00ffff) | (data << 16);
- logerror("DMA: Channel %i Address set [%08x]\n", m_selected_channel, m_channel[channel].m_base_address);
- break;
- case 0x07: // Address (highest)
- m_channel[channel].m_base_address =
- (m_channel[channel].m_base_address & 0x00ffffff) | (data << 24);
- if (m_base == 0)
- m_channel[channel].m_address =
- (m_channel[channel].m_address & 0x00ffffff) | (data << 24);
- logerror("DMA: Channel %i Address set [%08x]\n", m_selected_channel, m_channel[channel].m_base_address);
- break;
- case 0x0a: // Mode control
- m_channel[channel].m_mode = data;
- // clear terminal count
- m_status &= ~(1 << channel);
-
- logerror("DMA: Channel %i Mode control set [%02x]\n",m_selected_channel,m_channel[channel].m_mode);
- break;
-
- case 0x08: // Device control (low)
- m_command = data;
- logerror("DMA: Device control low set [%02x]\n",data);
- break;
- case 0x09: // Device control (high)
- m_command_high = data;
- logerror("DMA: Device control high set [%02x]\n",data);
- break;
- case 0x0e: // Request
- //m_reg.request = data;
- logerror("(invalid) DMA: Request set [%02x]\n",data); // no software requests on the v53 integrated version
- break;
- case 0x0f: // Mask
- m_mask = data & 0x0f;
- logerror("DMA: Mask set [%02x]\n",data);
- break;
-
-
- }
- trigger(1);
-
-}
diff --git a/src/emu/machine/am9517a.h b/src/emu/machine/am9517a.h
deleted file mode 100644
index 817cf5ce9df..00000000000
--- a/src/emu/machine/am9517a.h
+++ /dev/null
@@ -1,255 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- AMD AM9517A/8237A Multimode DMA Controller emulation
-
-****************************************************************************
- _____ _____
- _IOR 1 |* \_/ | 40 A7
- _IOW 2 | | 39 A6
- _MEMR 3 | | 38 A5
- _MEMW 4 | | 37 A4
- * 5 | | 36 _EOP
- READY 6 | | 35 A3
- HACK 7 | | 34 A2
- ADSTB 8 | | 33 A1
- AEN 9 | | 32 A0
- HREQ 10 | AM9517A | 31 Vcc
- _CS 11 | 8237A | 30 DB0
- CLK 12 | | 29 DB1
- RESET 13 | | 28 DB2
- DACK2 14 | | 27 DB3
- DACK3 15 | | 26 DB4
- DREQ3 16 | | 25 DACK0
- DREQ2 17 | | 24 DACK1
- DREQ1 18 | | 23 DB5
- DREQ0 19 | | 22 DB6
- Vss 20 |_____________| 21 DB7
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __AM9517A__
-#define __AM9517A__
-
-#include "emu.h"
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-// ======================> am9517a_device
-
-class am9517a_device : public device_t,
- public device_execute_interface
-{
-public:
- // construction/destruction
- am9517a_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname);
- am9517a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_hreq_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_hreq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_eop_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_eop_cb.set_callback(object); }
-
- template<class _Object> static devcb_base &set_in_memr_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_in_memr_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_memw_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_memw_cb.set_callback(object); }
-
- template<class _Object> static devcb_base &set_in_ior_0_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_in_ior_0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_ior_1_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_in_ior_1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_ior_2_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_in_ior_2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_ior_3_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_in_ior_3_cb.set_callback(object); }
-
- template<class _Object> static devcb_base &set_out_iow_0_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_iow_0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_iow_1_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_iow_1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_iow_2_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_iow_2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_iow_3_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_iow_3_cb.set_callback(object); }
-
- template<class _Object> static devcb_base &set_out_dack_0_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_dack_0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dack_1_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_dack_1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dack_2_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_dack_2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dack_3_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_dack_3_cb.set_callback(object); }
-
- virtual DECLARE_READ8_MEMBER( read );
- virtual DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( hack_w );
- DECLARE_WRITE_LINE_MEMBER( ready_w );
- DECLARE_WRITE_LINE_MEMBER( eop_w );
-
- DECLARE_WRITE_LINE_MEMBER( dreq0_w );
- DECLARE_WRITE_LINE_MEMBER( dreq1_w );
- DECLARE_WRITE_LINE_MEMBER( dreq2_w );
- DECLARE_WRITE_LINE_MEMBER( dreq3_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void execute_run();
-
- int m_icount;
- UINT32 m_address_mask;
-
- struct
- {
- UINT32 m_address;
- UINT16 m_count;
- UINT32 m_base_address;
- UINT16 m_base_count;
- UINT8 m_mode;
- } m_channel[4];
-
- int m_msb;
- int m_hreq;
- int m_hack;
- int m_ready;
- int m_eop;
- int m_state;
- int m_current_channel;
- int m_last_channel;
- UINT8 m_command;
- UINT8 m_mask;
- UINT8 m_status;
- UINT16 m_temp;
- UINT8 m_request;
-
-private:
- inline void dma_request(int channel, int state);
- inline bool is_request_active(int channel);
- inline bool is_software_request_active(int channel);
- inline void set_hreq(int state);
- inline void set_dack();
- inline void set_eop(int state);
- inline int get_state1(bool msb_changed);
- inline void dma_read();
- inline void dma_write();
- inline void dma_advance();
- inline void end_of_process();
-
- devcb_write_line m_out_hreq_cb;
- devcb_write_line m_out_eop_cb;
-
- devcb_read8 m_in_memr_cb;
- devcb_write8 m_out_memw_cb;
-
- devcb_read8 m_in_ior_0_cb;
- devcb_read8 m_in_ior_1_cb;
- devcb_read8 m_in_ior_2_cb;
- devcb_read8 m_in_ior_3_cb;
- devcb_write8 m_out_iow_0_cb;
- devcb_write8 m_out_iow_1_cb;
- devcb_write8 m_out_iow_2_cb;
- devcb_write8 m_out_iow_3_cb;
- devcb_write_line m_out_dack_0_cb;
- devcb_write_line m_out_dack_1_cb;
- devcb_write_line m_out_dack_2_cb;
- devcb_write_line m_out_dack_3_cb;
-
-
-
-
-
-};
-
-
-class upd71071_v53_device : public am9517a_device
-{
-public:
- // construction/destruction
- upd71071_v53_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_READ8_MEMBER( read );
- virtual DECLARE_WRITE8_MEMBER( write );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- int m_selected_channel;
- int m_base;
- UINT8 m_command_high;
-
-};
-
-
-
-
-// device type definition
-extern const device_type AM9517A;
-extern const device_type V53_DMAU;
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_AM9517A_OUT_HREQ_CB(_devcb) \
- devcb = &am9517a_device::set_out_hreq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_OUT_EOP_CB(_devcb) \
- devcb = &am9517a_device::set_out_eop_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_IN_MEMR_CB(_devcb) \
- devcb = &am9517a_device::set_in_memr_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_OUT_MEMW_CB(_devcb) \
- devcb = &am9517a_device::set_out_memw_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_IN_IOR_0_CB(_devcb) \
- devcb = &am9517a_device::set_in_ior_0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_IN_IOR_1_CB(_devcb) \
- devcb = &am9517a_device::set_in_ior_1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_IN_IOR_2_CB(_devcb) \
- devcb = &am9517a_device::set_in_ior_2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_IN_IOR_3_CB(_devcb) \
- devcb = &am9517a_device::set_in_ior_3_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_OUT_IOW_0_CB(_devcb) \
- devcb = &am9517a_device::set_out_iow_0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_OUT_IOW_1_CB(_devcb) \
- devcb = &am9517a_device::set_out_iow_1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_OUT_IOW_2_CB(_devcb) \
- devcb = &am9517a_device::set_out_iow_2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_OUT_IOW_3_CB(_devcb) \
- devcb = &am9517a_device::set_out_iow_3_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_OUT_DACK_0_CB(_devcb) \
- devcb = &am9517a_device::set_out_dack_0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_OUT_DACK_1_CB(_devcb) \
- devcb = &am9517a_device::set_out_dack_1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_OUT_DACK_2_CB(_devcb) \
- devcb = &am9517a_device::set_out_dack_2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AM9517A_OUT_DACK_3_CB(_devcb) \
- devcb = &am9517a_device::set_out_dack_3_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8237_OUT_HREQ_CB MCFG_AM9517A_OUT_HREQ_CB
-#define MCFG_I8237_OUT_EOP_CB MCFG_AM9517A_OUT_EOP_CB
-#define MCFG_I8237_IN_MEMR_CB MCFG_AM9517A_IN_MEMR_CB
-#define MCFG_I8237_OUT_MEMW_CB MCFG_AM9517A_OUT_MEMW_CB
-#define MCFG_I8237_IN_IOR_0_CB MCFG_AM9517A_IN_IOR_0_CB
-#define MCFG_I8237_IN_IOR_1_CB MCFG_AM9517A_IN_IOR_1_CB
-#define MCFG_I8237_IN_IOR_2_CB MCFG_AM9517A_IN_IOR_2_CB
-#define MCFG_I8237_IN_IOR_3_CB MCFG_AM9517A_IN_IOR_3_CB
-#define MCFG_I8237_OUT_IOW_0_CB MCFG_AM9517A_OUT_IOW_0_CB
-#define MCFG_I8237_OUT_IOW_1_CB MCFG_AM9517A_OUT_IOW_1_CB
-#define MCFG_I8237_OUT_IOW_2_CB MCFG_AM9517A_OUT_IOW_2_CB
-#define MCFG_I8237_OUT_IOW_3_CB MCFG_AM9517A_OUT_IOW_3_CB
-#define MCFG_I8237_OUT_DACK_0_CB MCFG_AM9517A_OUT_DACK_0_CB
-#define MCFG_I8237_OUT_DACK_1_CB MCFG_AM9517A_OUT_DACK_1_CB
-#define MCFG_I8237_OUT_DACK_2_CB MCFG_AM9517A_OUT_DACK_2_CB
-#define MCFG_I8237_OUT_DACK_3_CB MCFG_AM9517A_OUT_DACK_3_CB
-
-#endif
diff --git a/src/emu/machine/amigafdc.c b/src/emu/machine/amigafdc.c
deleted file mode 100644
index 0be33c07ec9..00000000000
--- a/src/emu/machine/amigafdc.c
+++ /dev/null
@@ -1,656 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-/***************************************************************************
-
- Amiga floppy disk controller emulation
-
-***************************************************************************/
-
-
-#include "emu.h"
-#include "includes/amiga.h"
-#include "formats/ami_dsk.h"
-#include "amigafdc.h"
-
-const device_type AMIGA_FDC = &device_creator<amiga_fdc>;
-
-FLOPPY_FORMATS_MEMBER( amiga_fdc::floppy_formats )
- FLOPPY_ADF_FORMAT
-FLOPPY_FORMATS_END
-
-amiga_fdc::amiga_fdc(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, AMIGA_FDC, "Amiga FDC", tag, owner, clock, "amiga_fdc", __FILE__),
- m_write_index(*this)
-{
-}
-
-void amiga_fdc::device_start()
-{
- m_write_index.resolve_safe();
-
- static const char *names[] = { "0", "1", "2", "3" };
- for(int i=0; i != 4; i++) {
- floppy_connector *con = subdevice<floppy_connector>(names[i]);
- if(con)
- floppy_devices[i] = con->get_device();
- else
- floppy_devices[i] = 0;
- }
-
- floppy = 0;
-
- t_gen = timer_alloc(0);
-}
-
-
-void amiga_fdc::device_reset()
-{
- floppy = 0;
- dsklen = 0x4000;
- dsksync = 0x4489;
- adkcon = 0;
- dmacon = 0;
- dskpt = 0;
- dskbyt = 0;
- pre_dsklen = 0x4000;
- dma_value = 0;
- dma_state = DMA_IDLE;
-
- live_abort();
-}
-
-void amiga_fdc::dma_done()
-{
- amiga_state *state = machine().driver_data<amiga_state>();
- if(dskbyt & 0x2000) {
- dskbyt &= ~0x2000;
- cur_live.pll.stop_writing(floppy, cur_live.tm);
- }
-
- dma_state = DMA_IDLE;
- state->custom_chip_w(REG_INTREQ, INTENA_SETCLR | INTENA_DSKBLK);
-}
-
-void amiga_fdc::dma_write(UINT16 value)
-{
- amiga_state *state = machine().driver_data<amiga_state>();
- state->chip_ram_w(dskpt, value);
-
- dskpt += 2;
- dsklen--;
-
- if(dsklen & 0x3fff)
- dma_state = DMA_RUNNING_BYTE_0;
- else
- dma_done();
-}
-
-UINT16 amiga_fdc::dma_read()
-{
- amiga_state *state = machine().driver_data<amiga_state>();
- UINT16 res = state->chip_ram_r(dskpt);
-
- dskpt += 2;
- dsklen--;
-
- // This loses the last word. So does the real hardware.
- if(dsklen & 0x3fff)
- dma_state = DMA_RUNNING_BYTE_0;
- else
- dma_done();
-
- return res;
-}
-
-void amiga_fdc::live_start()
-{
- cur_live.tm = machine().time();
- cur_live.state = RUNNING;
- cur_live.next_state = -1;
- cur_live.shift_reg = 0;
- cur_live.bit_counter = 0;
- cur_live.pll.reset(cur_live.tm);
- cur_live.pll.set_clock(clocks_to_attotime(1));
- checkpoint_live = cur_live;
-
- live_run();
-}
-
-void amiga_fdc::checkpoint()
-{
- cur_live.pll.commit(floppy, cur_live.tm);
- checkpoint_live = cur_live;
-}
-
-void amiga_fdc::rollback()
-{
- cur_live = checkpoint_live;
-}
-
-void amiga_fdc::live_delay(int state)
-{
- cur_live.next_state = state;
- if(cur_live.tm != machine().time())
- t_gen->adjust(cur_live.tm - machine().time());
-}
-
-void amiga_fdc::live_sync()
-{
- if(!cur_live.tm.is_never()) {
- if(cur_live.tm > machine().time()) {
- rollback();
- live_run(machine().time());
- cur_live.pll.commit(floppy, cur_live.tm);
-
- } else {
- cur_live.pll.commit(floppy, cur_live.tm);
-
- if(cur_live.next_state != -1) {
- cur_live.state = cur_live.next_state;
- cur_live.next_state = -1;
- }
- if(cur_live.state == IDLE) {
- cur_live.pll.stop_writing(floppy, cur_live.tm);
- cur_live.tm = attotime::never;
- }
- }
- cur_live.next_state = -1;
- checkpoint();
- }
-}
-
-void amiga_fdc::live_abort()
-{
- if(!cur_live.tm.is_never() && cur_live.tm > machine().time()) {
- rollback();
- live_run(machine().time());
- }
-
- cur_live.pll.stop_writing(floppy, cur_live.tm);
- cur_live.tm = attotime::never;
- cur_live.state = IDLE;
- cur_live.next_state = -1;
-}
-
-void amiga_fdc::live_run(const attotime &limit)
-{
- amiga_state *state = machine().driver_data<amiga_state>();
-
- if(cur_live.state == IDLE || cur_live.next_state != -1)
- return;
-
- for(;;) {
- switch(cur_live.state) {
- case RUNNING: {
- if(!(dskbyt & 0x2000)) {
- int bit = cur_live.pll.get_next_bit(cur_live.tm, floppy, limit);
- if(bit < 0)
- return;
-
- cur_live.shift_reg = (cur_live.shift_reg << 1) | bit;
- cur_live.bit_counter++;
-
- if((adkcon & 0x0200) && !(cur_live.shift_reg & 0x80)) {
- cur_live.bit_counter--;
-
- // Avoid any risk of livelock
- live_delay(RUNNING_SYNCPOINT);
- return;
- }
-
- if(cur_live.bit_counter > 8)
- fatalerror("amiga_fdc::live_run - cur_live.bit_counter > 8\n");
-
- if(cur_live.bit_counter == 8) {
- live_delay(RUNNING_SYNCPOINT);
- return;
- }
- if(dskbyt & 0x1000) {
- if(cur_live.shift_reg != dsksync) {
- live_delay(RUNNING_SYNCPOINT);
- return;
- }
- } else {
- if(cur_live.shift_reg == dsksync) {
- live_delay(RUNNING_SYNCPOINT);
- return;
- }
- }
- } else {
- int bit = (dma_state == DMA_RUNNING_BYTE_0 ? 15 : 7) - cur_live.bit_counter;
- if(cur_live.pll.write_next_bit((dma_value >> bit) & 1, cur_live.tm, floppy, limit))
- return;
- cur_live.bit_counter++;
- if(cur_live.bit_counter > 8)
- fatalerror("amiga_fdc::live_run - cur_live.bit_counter > 8\n");
-
- if(cur_live.bit_counter == 8) {
- live_delay(RUNNING_SYNCPOINT);
- return;
- }
- }
- break;
- }
-
- case RUNNING_SYNCPOINT: {
- if(!(dskbyt & 0x2000)) {
- if(cur_live.shift_reg == dsksync) {
- if(adkcon & 0x0400) {
- if(dma_state == DMA_WAIT_START) {
- cur_live.bit_counter = 0;
-
- if(!(dsklen & 0x3fff))
- dma_done();
- else if(dsklen & 0x4000) {
- dskbyt |= 0x2000;
- cur_live.bit_counter = 0;
- dma_value = dma_read();
-
- } else
- dma_write(dsksync);
-
- } else if(dma_state != DMA_IDLE) {
- dma_write(dsksync);
- cur_live.bit_counter = 0;
-
- } else if(cur_live.bit_counter != 8)
- cur_live.bit_counter = 0;
- }
- dskbyt |= 0x1000;
- state->custom_chip_w(REG_INTREQ, INTENA_SETCLR | INTENA_DSKSYN);
- } else
- dskbyt &= ~0x1000;
-
- if(cur_live.bit_counter == 8) {
- dskbyt = (dskbyt & 0xff00) | 0x8000 | (cur_live.shift_reg & 0xff);
- cur_live.bit_counter = 0;
-
- switch(dma_state) {
- case DMA_IDLE:
- case DMA_WAIT_START:
- break;
-
- case DMA_RUNNING_BYTE_0:
- dma_value = (cur_live.shift_reg & 0xff) << 8;
- dma_state = DMA_RUNNING_BYTE_1;
- break;
-
- case DMA_RUNNING_BYTE_1: {
- dma_value |= cur_live.shift_reg & 0xff;
- dma_write(dma_value);
- break;
- }
- }
- }
- } else {
- if(cur_live.bit_counter != 8)
- fatalerror("amiga_fdc::live_run - cur_live.bit_counter != 8\n");
- cur_live.bit_counter = 0;
-
- switch(dma_state) {
- case DMA_IDLE:
- case DMA_WAIT_START:
- break;
-
- case DMA_RUNNING_BYTE_0:
- dma_state = DMA_RUNNING_BYTE_1;
- break;
-
- case DMA_RUNNING_BYTE_1: {
- dma_value = dma_read();
- break;
- }
- }
- }
-
- cur_live.state = RUNNING;
- checkpoint();
- break;
- }
- }
- }
-}
-
-bool amiga_fdc::dma_enabled()
-{
- return (dsklen & 0x8000) && ((dmacon & 0x0210) == 0x0210);
-}
-
-void amiga_fdc::dma_check()
-{
- bool was_writing = dskbyt & 0x2000;
- dskbyt &= 0x9fff;
- if(dma_enabled()) {
- if(dma_state == IDLE) {
- dma_state = adkcon & 0x0400 ? DMA_WAIT_START : DMA_RUNNING_BYTE_0;
- if(dma_state == DMA_RUNNING_BYTE_0) {
- if(!(dsklen & 0x3fff))
- dma_done();
- else if(dsklen & 0x4000) {
- dskbyt |= 0x2000;
- cur_live.bit_counter = 0;
- dma_value = dma_read();
- }
- }
- } else {
- dskbyt |= 0x4000;
- if(dsklen & 0x4000)
- dskbyt |= 0x2000;
- }
- } else
- dma_state = IDLE;
-
- if(was_writing && !(dskbyt & 0x2000))
- cur_live.pll.stop_writing(floppy, cur_live.tm);
- if(!was_writing && (dskbyt & 0x2000))
- cur_live.pll.start_writing(cur_live.tm);
-
-}
-
-void amiga_fdc::adkcon_set(UINT16 data)
-{
- live_sync();
- adkcon = data;
- live_run();
-}
-
-UINT16 amiga_fdc::adkcon_r(void)
-{
- return adkcon;
-}
-
-void amiga_fdc::dsklen_w(UINT16 data)
-{
- live_sync();
- if(!(data & 0x8000) || (data == pre_dsklen)) {
- dsklen = pre_dsklen = data;
- dma_check();
-
- } else
- pre_dsklen = data;
- live_run();
-}
-
-void amiga_fdc::dskpth_w(UINT16 data)
-{
- live_sync();
- dskpt = (dskpt & 0xffff) | (data << 16);
- live_run();
-}
-
-void amiga_fdc::dskptl_w(UINT16 data)
-{
- live_sync();
- dskpt = (dskpt & 0xffff0000) | data;
- live_run();
-}
-
-UINT16 amiga_fdc::dskpth_r()
-{
- return dskpt >> 16;
-}
-
-UINT16 amiga_fdc::dskptl_r()
-{
- return dskpt;
-}
-
-void amiga_fdc::dsksync_w(UINT16 data)
-{
- live_sync();
- dsksync = data;
- live_run();
-}
-
-void amiga_fdc::dmacon_set(UINT16 data)
-{
- live_sync();
- dmacon = data;
- dma_check();
- live_run();
-}
-
-UINT16 amiga_fdc::dskbytr_r()
-{
- UINT16 res = dskbyt;
- dskbyt &= 0x7fff;
- return res;
-}
-
-void amiga_fdc::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- live_sync();
- live_run();
-}
-
-void amiga_fdc::setup_leds()
-{
- if(floppy) {
- int drive =
- floppy == floppy_devices[0] ? 0 :
- floppy == floppy_devices[1] ? 1 :
- floppy == floppy_devices[2] ? 2 :
- 3;
-
- output_set_value("drive_0_led", drive == 0);
- output_set_value("drive_1_led", drive == 1);
- output_set_value("drive_2_led", drive == 2);
- output_set_value("drive_3_led", drive == 3);
-
- set_led_status(machine(), 1, drive == 0); /* update internal drive led */
- set_led_status(machine(), 2, drive == 1); /* update external drive led */
- }
-}
-
-WRITE8_MEMBER( amiga_fdc::ciaaprb_w )
-{
- floppy_image_device *old_floppy = floppy;
-
- live_sync();
-
- if(!(data & 0x08))
- floppy = floppy_devices[0];
- else if(!(data & 0x10))
- floppy = floppy_devices[1];
- else if(!(data & 0x20))
- floppy = floppy_devices[2];
- else if(!(data & 0x40))
- floppy = floppy_devices[3];
- else
- floppy = 0;
-
- if(old_floppy != floppy) {
- if(old_floppy)
- old_floppy->setup_index_pulse_cb(floppy_image_device::index_pulse_cb());
- if(floppy)
- floppy->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(amiga_fdc::index_callback), this));
- }
-
- if(floppy) {
- floppy->ss_w(!((data >> 2) & 1));
- floppy->dir_w((data >> 1) & 1);
- floppy->stp_w(data & 1);
- floppy->mon_w((data >> 7) & 1);
- output_set_value("fdc_led", data & 0x80); // LED directly connected to FDC motor
- }
-
- if(floppy) {
- if(cur_live.state == IDLE)
- live_start();
- } else
- live_abort();
-
- setup_leds();
- live_run();
-}
-
-UINT8 amiga_fdc::ciaapra_r()
-{
- UINT8 ret = 0x3c;
- if(floppy) {
- //if(!floppy->ready_r()) fixit: seems to not work well with multiple disk drives
- ret &= ~0x20;
- if(!floppy->trk00_r())
- ret &= ~0x10;
- if(floppy->wpt_r())
- ret &= ~0x08;
- if(!floppy->dskchg_r())
- ret &= ~0x04;
- }
-
- return ret;
-}
-
-void amiga_fdc::index_callback(floppy_image_device *floppy, int state)
-{
- /* Issue a index pulse when a disk revolution completes */
- m_write_index(!state);
-}
-
-void amiga_fdc::pll_t::set_clock(const attotime &period)
-{
- for(int i=0; i<38; i++)
- delays[i] = period*(i+1);
-}
-
-void amiga_fdc::pll_t::reset(const attotime &when)
-{
- counter = 0;
- increment = 146;
- transition_time = 0xffff;
- history = 0x80;
- slot = 0;
- ctime = when;
- phase_add = 0x00;
- phase_sub = 0x00;
- freq_add = 0x00;
- freq_sub = 0x00;
-}
-
-int amiga_fdc::pll_t::get_next_bit(attotime &tm, floppy_image_device *floppy, const attotime &limit)
-{
- attotime when = floppy ? floppy->get_next_transition(ctime) : attotime::never;
-
- for(;;) {
- attotime etime = ctime+delays[slot];
- if(etime > limit)
- return -1;
- if(transition_time == 0xffff && !when.is_never() && etime >= when)
- transition_time = counter;
- if(slot < 8) {
- UINT8 mask = 1 << slot;
- if(phase_add & mask)
- counter += 258;
- else if(phase_sub & mask)
- counter += 34;
- else
- counter += increment;
-
- if((freq_add & mask) && increment < 159)
- increment++;
- else if((freq_sub & mask) && increment > 134)
- increment--;
- } else
- counter += increment;
-
- slot++;
- tm = etime;
- if(counter & 0x800)
- break;
- }
-
- int bit = transition_time != 0xffff;
-
- if(transition_time != 0xffff) {
- static const UINT8 pha[8] = { 0xf, 0x7, 0x3, 0x1, 0, 0, 0, 0 };
- static const UINT8 phs[8] = { 0, 0, 0, 0, 0x1, 0x3, 0x7, 0xf };
- static const UINT8 freqa[4][8] = {
- { 0xf, 0x7, 0x3, 0x1, 0, 0, 0, 0 },
- { 0x7, 0x3, 0x1, 0, 0, 0, 0, 0 },
- { 0x7, 0x3, 0x1, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0 }
- };
- static const UINT8 freqs[4][8] = {
- { 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0x1, 0x3, 0x7 },
- { 0, 0, 0, 0, 0, 0x1, 0x3, 0x7 },
- { 0, 0, 0, 0, 0x1, 0x3, 0x7, 0xf },
- };
-
- int cslot = transition_time >> 8;
- phase_add = pha[cslot];
- phase_sub = phs[cslot];
- int way = transition_time & 0x400 ? 1 : 0;
- if(history & 0x80)
- history = way ? 0x80 : 0x83;
- else if(history & 0x40)
- history = way ? history & 2 : (history & 2) | 1;
- freq_add = freqa[history & 3][cslot];
- freq_sub = freqs[history & 3][cslot];
- history = way ? (history >> 1) | 2 : history >> 1;
-
- } else
- phase_add = phase_sub = freq_add = freq_sub = 0;
-
- counter &= 0x7ff;
-
- ctime = tm;
- transition_time = 0xffff;
- slot = 0;
-
- return bit;
-}
-
-void amiga_fdc::pll_t::start_writing(const attotime & tm)
-{
- write_start_time = tm;
- write_position = 0;
-}
-
-void amiga_fdc::pll_t::stop_writing(floppy_image_device *floppy, const attotime &tm)
-{
- commit(floppy, tm);
- write_start_time = attotime::never;
-}
-
-bool amiga_fdc::pll_t::write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, const attotime &limit)
-{
- if(write_start_time.is_never()) {
- write_start_time = ctime;
- write_position = 0;
- }
-
- for(;;) {
- attotime etime = ctime+delays[slot];
- if(etime > limit)
- return true;
- UINT16 pre_counter = counter;
- counter += increment;
- if(bit && !(pre_counter & 0x400) && (counter & 0x400))
- if(write_position < ARRAY_LENGTH(write_buffer))
- write_buffer[write_position++] = etime;
- slot++;
- tm = etime;
- if(counter & 0x800)
- break;
- }
-
- counter &= 0x7ff;
-
- ctime = tm;
- slot = 0;
-
- return false;
-}
-
-
-void amiga_fdc::pll_t::commit(floppy_image_device *floppy, const attotime &tm)
-{
- if(write_start_time.is_never() || tm == write_start_time)
- return;
-
- if(floppy)
- floppy->write_flux(write_start_time, tm, write_position, write_buffer);
- write_start_time = tm;
- write_position = 0;
-}
diff --git a/src/emu/machine/amigafdc.h b/src/emu/machine/amigafdc.h
deleted file mode 100644
index 77727d51a88..00000000000
--- a/src/emu/machine/amigafdc.h
+++ /dev/null
@@ -1,121 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef AMIGAFDC_H
-#define AMIGAFDC_H
-
-#include "emu.h"
-#include "imagedev/floppy.h"
-
-#define MCFG_AMIGA_FDC_INDEX_CALLBACK(_write) \
- devcb = &amiga_fdc::set_index_wr_callback(*device, DEVCB_##_write);
-
-class amiga_fdc : public device_t {
-public:
- amiga_fdc(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_index_wr_callback(device_t &device, _Object object) { return downcast<amiga_fdc &>(device).m_write_index.set_callback(object); }
-
- DECLARE_WRITE8_MEMBER(ciaaprb_w);
-
- UINT8 ciaapra_r();
- UINT16 dskbytr_r();
- UINT16 dskpth_r();
- UINT16 dskptl_r();
-
- void dsksync_w(UINT16 data);
- void dskpth_w(UINT16 data);
- void dskptl_w(UINT16 data);
- void dsklen_w(UINT16 data);
- void adkcon_set(UINT16 data);
- void dmacon_set(UINT16 data);
- UINT16 adkcon_r(void);
-
- DECLARE_FLOPPY_FORMATS( floppy_formats );
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- // Running states
- enum {
- IDLE,
- RUNNING,
- RUNNING_SYNCPOINT
- };
-
- // DMA states
- enum {
- DMA_IDLE,
- DMA_WAIT_START,
- DMA_RUNNING_BYTE_0,
- DMA_RUNNING_BYTE_1
- };
-
- struct pll_t {
- UINT16 counter;
- UINT16 increment;
- UINT16 transition_time;
- UINT8 history;
- UINT8 slot;
- UINT8 phase_add, phase_sub, freq_add, freq_sub;
- attotime ctime;
-
- attotime delays[38];
-
- attotime write_start_time;
- attotime write_buffer[32];
- int write_position;
-
- void set_clock(const attotime &period);
- void reset(const attotime &when);
- int get_next_bit(attotime &tm, floppy_image_device *floppy, const attotime &limit);
- bool write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, const attotime &limit);
- void start_writing(const attotime &tm);
- void commit(floppy_image_device *floppy, const attotime &tm);
- void stop_writing(floppy_image_device *floppy, const attotime &tm);
- };
-
- struct live_info {
- attotime tm;
- int state, next_state;
- UINT16 shift_reg;
- int bit_counter;
- pll_t pll;
- };
-
- devcb_write_line m_write_index;
-
- floppy_image_device *floppy;
- floppy_image_device *floppy_devices[4];
-
- live_info cur_live, checkpoint_live;
-
- emu_timer *t_gen;
- UINT16 dsklen, pre_dsklen, dsksync, dskbyt, adkcon, dmacon;
- UINT32 dskpt;
- UINT16 dma_value;
-
- int dma_state;
-
- void setup_leds();
- void index_callback(floppy_image_device *floppy, int state);
- bool dma_enabled();
- void dma_check();
- void dma_done();
- void dma_write(UINT16 value);
- UINT16 dma_read();
-
- void live_start();
- void checkpoint();
- void rollback();
- void live_delay(int state);
- void live_sync();
- void live_abort();
- void live_run(const attotime &limit = attotime::never);
-};
-
-extern const device_type AMIGA_FDC;
-
-#endif /* AMIGAFDC_H */
diff --git a/src/emu/machine/at28c16.c b/src/emu/machine/at28c16.c
deleted file mode 100644
index e50049d9cbc..00000000000
--- a/src/emu/machine/at28c16.c
+++ /dev/null
@@ -1,273 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
- ATMEL AT28C16
-
- 16K ( 2K x 8 ) Parallel EEPROM
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/at28c16.h"
-
-#define AT28C16_DATA_BYTES ( 0x800 )
-#define AT28C16_ID_BYTES ( 0x20 )
-#define AT28C16_TOTAL_BYTES ( AT28C16_DATA_BYTES + AT28C16_ID_BYTES )
-
-#define AT28C16_ID_OFFSET ( AT28C16_DATA_BYTES - AT28C16_ID_BYTES )
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-static ADDRESS_MAP_START( at28c16_map8, AS_PROGRAM, 8, at28c16_device )
- AM_RANGE(0x0000, 0x081f) AM_RAM
-ADDRESS_MAP_END
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type AT28C16 = &device_creator<at28c16_device>;
-
-//-------------------------------------------------
-// at28c16_device - constructor
-//-------------------------------------------------
-
-at28c16_device::at28c16_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
- : device_t(mconfig, AT28C16, "AT28C16", tag, owner, clock, "at28c16", __FILE__),
- device_memory_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this),
- m_a9_12v( 0 ),
- m_oe_12v( 0 ),
- m_last_write( -1 )
-{
-}
-
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void at28c16_device::device_config_complete()
-{
- m_space_config = address_space_config( "at28c16", ENDIANNESS_BIG, 8, 12, 0, *ADDRESS_MAP_NAME( at28c16_map8 ) );
-}
-
-
-//-------------------------------------------------
-// device_validity_check - perform validity checks
-// on this device
-//-------------------------------------------------
-
-void at28c16_device::device_validity_check(validity_checker &valid) const
-{
-}
-
-
-//-------------------------------------------------
-// memory_space_config - return a description of
-// any address spaces owned by this device
-//-------------------------------------------------
-
-const address_space_config *at28c16_device::memory_space_config( address_spacenum spacenum ) const
-{
- return ( spacenum == 0 ) ? &m_space_config : NULL;
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void at28c16_device::device_start()
-{
- m_write_timer = timer_alloc(0);
-
- save_item( NAME(m_a9_12v) );
- save_item( NAME(m_oe_12v) );
- save_item( NAME(m_last_write) );
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void at28c16_device::device_reset()
-{
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void at28c16_device::nvram_default()
-{
- UINT16 default_value = 0xff;
- for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
- {
- m_addrspace[ 0 ]->write_byte( offs, default_value );
- }
-
- /* populate from a memory region if present */
- if( m_region != NULL )
- {
- if( m_region->bytes() != AT28C16_DATA_BYTES )
- {
- fatalerror( "at28c16 region '%s' wrong size (expected size = 0x%X)\n", tag(), AT28C16_DATA_BYTES );
- }
-
- if( m_region->bytewidth() != 1 )
- {
- fatalerror( "at28c16 region '%s' needs to be an 8-bit region\n", tag() );
- }
-
- UINT8 *default_data = m_region->base();
-
- for( offs_t offs = 0; offs < AT28C16_DATA_BYTES; offs++ )
- m_addrspace[ 0 ]->write_byte( offs, default_data[offs] );
- }
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void at28c16_device::nvram_read( emu_file &file )
-{
- dynamic_buffer buffer( AT28C16_TOTAL_BYTES );
-
- file.read( &buffer[0], AT28C16_TOTAL_BYTES );
-
- for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
- {
- m_addrspace[ 0 ]->write_byte( offs, buffer[ offs ] );
- }
-}
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void at28c16_device::nvram_write( emu_file &file )
-{
- dynamic_buffer buffer ( AT28C16_TOTAL_BYTES );
-
- for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
- {
- buffer[ offs ] = m_addrspace[ 0 ]->read_byte( offs );
- }
-
- file.write( &buffer[0], AT28C16_TOTAL_BYTES );
-}
-
-
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-WRITE8_MEMBER( at28c16_device::write )
-{
- if( m_last_write >= 0 )
- {
-// logerror( "%s: AT28C16: write( %04x, %02x ) busy\n", machine.describe_context(), offset, data );
- }
- else if( m_oe_12v )
- {
-// logerror( "%s: AT28C16: write( %04x, %02x ) erase\n", machine.describe_context(), offset, data );
- if( m_last_write < 0 )
- {
- for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
- {
- m_addrspace[ 0 ]->write_byte( offs, 0xff );
- }
-
- m_last_write = 0xff;
- m_write_timer->adjust( attotime::from_usec( 200 ) );
- }
- }
- else
- {
- if( m_a9_12v && offset >= AT28C16_ID_OFFSET )
- {
- offset += AT28C16_ID_BYTES;
- }
-
-// logerror( "%s: AT28C16: write( %04x, %02x )\n", machine.describe_context(), offset, data );
- if( m_last_write < 0 && m_addrspace[ 0 ]->read_byte( offset ) != data )
- {
- m_addrspace[ 0 ]->write_byte( offset, data );
- m_last_write = data;
- m_write_timer->adjust( attotime::from_usec( 200 ) );
- }
- }
-}
-
-
-READ8_MEMBER( at28c16_device::read )
-{
- if( m_last_write >= 0 )
- {
- UINT8 data = m_last_write ^ 0x80;
-// logerror( "%s: AT28C16: read( %04x ) write status %02x\n", machine.describe_context(), offset, data );
- return data;
- }
- else
- {
- if( m_a9_12v && offset >= AT28C16_ID_OFFSET )
- {
- offset += AT28C16_ID_BYTES;
- }
-
- UINT8 data = m_addrspace[ 0 ]->read_byte( offset );
-// logerror( "%s: AT28C16: read( %04x ) data %02x\n", machine.describe_context(), offset, data );
- return data;
- }
-}
-
-
-WRITE_LINE_MEMBER( at28c16_device::set_a9_12v )
-{
- state &= 1;
- if( m_a9_12v != state )
- {
-// logerror( "%s: AT28C16: set_a9_12v( %d )\n", machine.describe_context(), state );
- m_a9_12v = state;
- }
-}
-
-
-WRITE_LINE_MEMBER( at28c16_device::set_oe_12v )
-{
- state &= 1;
- if( m_oe_12v != state )
- {
-// logerror( "%s: AT28C16: set_oe_12v( %d )\n", machine.describe_context(), state );
- m_oe_12v = state;
- }
-}
-
-
-void at28c16_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch( id )
- {
- case 0:
- m_last_write = -1;
- break;
- }
-}
diff --git a/src/emu/machine/at28c16.h b/src/emu/machine/at28c16.h
deleted file mode 100644
index f8f71011347..00000000000
--- a/src/emu/machine/at28c16.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- ATMEL AT28C16
-
- 16K ( 2K x 8 ) Parallel EEPROM
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __AT28C16_H__
-#define __AT28C16_H__
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_AT28C16_ADD( _tag, _interface ) \
- MCFG_DEVICE_ADD( _tag, AT28C16, 0 )
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> at28c16_device
-
-class at28c16_device :
- public device_t,
- public device_memory_interface,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- at28c16_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock );
-
- // I/O operations
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE_LINE_MEMBER( set_a9_12v );
- DECLARE_WRITE_LINE_MEMBER( set_oe_12v );
-
-protected:
- // device-level overrides
- virtual void device_config_complete();
- virtual void device_validity_check(validity_checker &valid) const;
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_memory_interface overrides
- virtual const address_space_config *memory_space_config( address_spacenum spacenum = AS_0 ) const;
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read( emu_file &file );
- virtual void nvram_write( emu_file &file );
-
- // internal state
- address_space_config m_space_config;
- emu_timer *m_write_timer;
- int m_a9_12v;
- int m_oe_12v;
- int m_last_write;
-};
-
-
-// device type definition
-extern const device_type AT28C16;
-
-#endif
diff --git a/src/emu/machine/at29x.c b/src/emu/machine/at29x.c
deleted file mode 100644
index 440645b4c00..00000000000
--- a/src/emu/machine/at29x.c
+++ /dev/null
@@ -1,525 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Michael Zapf
-/*
- ATMEL AT29 family of Flash EEPROM
-
- References:
- [1] ATMEL: 4-megabit (512K x 8) 5-volt Only 256-byte sector Flash Memory
- [2] ATMEL: Programming Atmel's AT29 Flash Family
-
-
- AT29 family
-
- Device Memory ID Sectors Sector Size Write Cycle Time Comments
- ------------------------------------------------------------------------------------------
- AT29C256 32K x 8 DC 512 64 bytes 10 ms
- AT29LV256 32K x 8 BC 512 64 bytes 20 ms
- AT29C257 32K x 8 DC 512 64 bytes 10 ms
- AT29C512 64K x 8 5D 512 128 bytes 10 ms
- AT29LV512 64K x 8 3D 512 128 bytes 20 ms
- AT29C010A 128K x 8 D5 1024 128 bytes 10 ms
- AT29LV010A 128K x 8 35 1024 128 bytes 20 ms
- AT29BV010A 128K x 8 35 1024 128 bytes 20 ms
- AT29C1024 64K x 16 25 512 128 words 10 ms
- AT29LV1024 64K x 16 26 512 128 words 20 ms
- AT29C020 256K x 8 DA 1024 256 bytes 10 ms
- AT29LV020 256K x 8 BA 1024 256 bytes 20 ms
- AT29BV020 256K x 8 BA 1024 256 bytes 20 ms
- AT29C040 512K x 8 5B 1024 512 bytes 10 ms Use AT29C040A for new designs
- AT29LV040 512K x 8 3B 1024 512 bytes 20 ms Use AT29LV040A for new designs
- AT29BV040 512K x 8 3B 1024 512 bytes 20 ms Use AT29BV040A for new designs
- AT29C040A 512K x 8 A4 2048 256 bytes 10 ms
- AT29LV040A 512K x 8 C4 2048 256 bytes 20 ms
- AT29BV040A 512K x 8 C4 2048 256 bytes 20 ms
-
- TODO: Implement remaining variants
-
- MZ, Aug 2015
-*/
-
-#include "at29x.h"
-
-#define TRACE_PRG 0
-#define TRACE_READ 0
-#define TRACE_WRITE 0
-#define TRACE_CONFIG 0
-#define TRACE_STATE 0
-
-enum
-{
- PRGTIMER = 1
-};
-
-/*
- Constructor for all variants
-*/
-
-at29x_device::at29x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_nvram_interface(mconfig, *this),
- m_memory_size(0), // bytes
- m_word_width(8),
- m_device_id(0),
- m_sector_size(0),
- m_cycle_time(10), // ms
- m_boot_block_size(16*1024),
- m_version(0)
-{
-}
-
-/*
- Constructor for AT29C020
-*/
-at29c020_device::at29c020_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : at29x_device(mconfig, AT29C020, "ATMEL 29C020 256K x 8 FEEPROM", tag, owner, clock, "at29c020", __FILE__)
-{
- m_memory_size = 256*1024;
- m_device_id = 0xda;
- m_sector_size = 256;
-}
-
-/*
- Constructor for AT29C040
-*/
-at29c040_device::at29c040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : at29x_device(mconfig, AT29C040, "ATMEL 29C040 512K x 8 FEEPROM", tag, owner, clock, "at29c040", __FILE__)
-{
- m_memory_size = 512*1024;
- m_device_id = 0x5b;
- m_sector_size = 512;
-}
-
-/*
- Constructor for AT29C040A
-*/
-at29c040a_device::at29c040a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : at29x_device(mconfig, AT29C040A, "ATMEL 29C040A 512K x 8 FEEPROM", tag, owner, clock, "at29c040a", __FILE__)
-{
- m_memory_size = 512*1024;
- m_device_id = 0xa4;
- m_sector_size = 256;
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void at29x_device::nvram_default()
-{
- memset(m_eememory, 0, m_memory_size+2);
-}
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void at29x_device::nvram_read(emu_file &file)
-{
- file.read(m_eememory, m_memory_size+2);
-}
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void at29x_device::nvram_write(emu_file &file)
-{
- // If we don't write (because there were no changes), the file will be wiped
- if (TRACE_PRG) logerror("%s: Write to NVRAM file\n", tag());
- m_eememory[0] = m_version;
- file.write(m_eememory, m_memory_size+2);
-}
-
-/*
- Programming timer callback
-*/
-void at29x_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (m_pgm)
- {
- case PGM_1:
- // Programming cycle timeout
- logerror("%s: Programming cycle timeout\n", tag());
- m_pgm = PGM_0;
- break;
-
- case PGM_2:
- // Programming cycle start
- if (TRACE_PRG) logerror("%s: Sector write start\n", tag());
- m_pgm = PGM_3;
- // We assume a typical delay of 70% of the max value
- m_programming_timer->adjust(attotime::from_msec(m_cycle_time*7/10));
- break;
-
- case PGM_3:
- // Programming cycle end; now burn the buffer into the flash EEPROM
- memcpy(m_eememory + 2 + get_sector_number(m_programming_last_offset) * m_sector_size, m_programming_buffer, m_sector_size);
-
- if (TRACE_PRG) logerror("%s: Sector write completed at location %04x\n", tag(), m_programming_last_offset);
-
- // Data protect state will be activated at the end of the program cycle [1]
- if (m_enabling_sdb) m_sdp = true;
-
- // Data protect state will be deactivated at the end of the program period [1]
- if (m_disabling_sdb) m_sdp = false;
-
- if (TRACE_PRG) logerror("%s: Software data protection = %d\n", tag(), m_sdp);
-
- m_pgm = PGM_0;
- m_enabling_sdb = false;
- m_disabling_sdb = false;
- sync_flags();
- break;
-
- default:
- logerror("%s: Invalid state %d during programming\n", tag(), m_pgm);
- m_pgm = PGM_0;
- break;
- }
-}
-
-void at29x_device::sync_flags()
-{
- if (m_lower_bbl) m_eememory[1] |= 0x04;
- else m_eememory[1] &= ~0x04;
-
- if (m_higher_bbl) m_eememory[1] |= 0x02;
- else m_eememory[1] &= ~0x02;
-
- if (m_sdp) m_eememory[1] |= 0x01;
- else m_eememory[1] &= ~0x01;
-}
-
-/*
- read a byte from FEEPROM
-*/
-READ8_MEMBER( at29x_device::read )
-{
- int reply;
-
- offset &= m_address_mask;
-
- // Reading in the midst of any command sequence cancels it (not verified)
- m_cmd = CMD_0;
- m_long_sequence = false;
-
- sync_flags();
-
- // Reading before the start of a programming cycle cancels it (not verified)
- if (m_pgm == PGM_1)
- {
- // Attempt to access a locked out boot block: cancel programming command if necessary
- m_pgm = PGM_0;
- m_enabling_sdb = false;
- m_disabling_sdb = false;
- m_programming_timer->adjust(attotime::never);
- }
-
- if (m_id_mode)
- {
- // Experiments showed that the manufacturer code and device code
- // are returned for every address 0 and 1 modulo sector_size.
- //
- if ((offset % m_sector_size)==0) reply = 0x1f; // Manufacturer code
- else
- {
- if ((offset % m_sector_size)==1) reply = m_device_id; // Device code
- else
- {
- // Boot block lockout detection [1]
- if (offset == 0x00002) reply = m_lower_bbl? 0xff : 0xfe;
- else
- {
- if (offset == 0x7fff2) reply = m_higher_bbl? 0xff : 0xfe;
- else reply = 0;
- }
- }
- }
- }
- else if ((m_pgm == PGM_2) || (m_pgm == PGM_3))
- {
- if (m_pgm == PGM_2)
- {
- // DATA* polling starts the programming cycle (not verified)
- m_pgm = PGM_3;
-
- // We assume a typical delay of 70% of the max value
- m_programming_timer->adjust(attotime::from_msec(m_cycle_time*7/10));
- }
-
- if (TRACE_READ) logerror("%s: DATA poll; toggle bit 1\n", tag());
- reply = m_toggle_bit? 0x02 : 0x00;
- m_toggle_bit = !m_toggle_bit;
-
- // When we read the byte on the last position, we get the inverse of the last bit [1]
- if (offset == m_programming_last_offset)
- {
- reply |= ((~m_programming_buffer[m_programming_last_offset & m_sector_mask]) & 0x01);
- }
- }
- else
- // Simple case: just read the memory contents
- reply = m_eememory[offset+2];
-
- if (TRACE_READ) logerror("%s: %05x -> %02x (PGM=%d)\n", tag(), offset, reply, m_pgm);
-
- return reply;
-}
-
-/*
- Write a byte to FEEPROM
-*/
-WRITE8_MEMBER( at29x_device::write )
-{
- offset &= m_address_mask;
- if (TRACE_WRITE) logerror("%s: %05x <- %02x\n", tag(), offset, data);
-
- // The special CFI commands assume a smaller address space according
- // to the specification ("address format A14-A0")
- offs_t cfi_offset = offset & 0x7fff;
-
- if (m_enabling_bbl)
- {
- // Determine whether we lock the upper or lower boot block
- if (TRACE_STATE) logerror("%s: Enabling boot block lockout\n", tag());
- m_enabling_bbl = false;
-
- if ((offset == 0x00000) && (data == 0x00))
- {
- if (TRACE_STATE) logerror("%s: Enabling lower boot block lockout\n", tag());
- m_lower_bbl = true;
- sync_flags();
- return;
- }
- else
- {
- if ((offset == 0x7ffff) && (data == 0xff))
- {
- if (TRACE_STATE) logerror("%s: Enabling higher boot block lockout\n", tag());
- m_higher_bbl = true;
- sync_flags();
- return;
- }
- else
- {
- logerror("%s: Invalid boot block specification: %05x/%02x\n", tag(), offset, data);
- }
- }
- }
-
- switch (m_cmd)
- {
- case CMD_0:
- // CMD_0: start state
- if ((cfi_offset == 0x5555) && (data == 0xaa))
- {
- if (TRACE_STATE) logerror("%s: Command sequence started (aa)\n", tag());
- m_cmd = CMD_1;
- return;
- }
- else
- {
- m_cmd = CMD_0;
- m_long_sequence = false;
- }
- break;
-
- case CMD_1:
- // CMD_1: state after writing aa to 5555
- if ((cfi_offset == 0x2aaa) && (data == 0x55))
- {
- if (TRACE_STATE) logerror("%s: Command sequence continued (55)\n", tag());
- m_cmd = CMD_2;
- return;
- }
- else
- {
- m_cmd = CMD_0;
- m_long_sequence = false;
- if (TRACE_STATE) logerror("%s: Command sequence aborted\n", tag());
- }
- break;
-
- case CMD_2:
- // CMD_2: state after writing 55 to 2aaa
- if (cfi_offset == 0x5555)
- {
- m_pgm = PGM_0;
- m_enabling_sdb = false;
- m_disabling_sdb = false;
- m_programming_timer->adjust(attotime::never);
-
- // Process command
- if (TRACE_STATE) logerror("%s: Command sequence continued (%2x)\n", tag(), data);
- switch (data)
- {
- case 0x10:
- // Software chip erase (optional feature, see [1])
- if (m_long_sequence)
- {
- if (m_lower_bbl || m_higher_bbl)
- logerror("%s: Boot block lockout active; chip cannot be erased.\n", tag());
- else
- {
- if (TRACE_STATE) logerror("%s: Erase chip\n", tag());
- memset(m_eememory+2, 0xff, m_memory_size);
- }
- }
- break;
-
- case 0x20:
- // Software data protection disable
- // The complete sequence is aa-55-80-aa-55-20
- // so we need a 80 before, else the sequence is invalid
- if (m_long_sequence)
- {
- if (TRACE_STATE) logerror("%s: Software data protection disable\n", tag());
- m_pgm = PGM_1;
- m_disabling_sdb = true;
- // It is not clear from the specification whether the byte cycle timer
- // is already started here or when the first data byte is written
- }
- break;
-
- case 0x40:
- // Boot block lockout enable
- // Complete sequence is aa-55-80-aa-55-40
- if (TRACE_STATE) logerror("%s: Boot block lockout enable\n", tag());
- if (m_long_sequence) m_enabling_bbl = true;
- // We'll know which boot block is affected on the next write
- break;
-
- case 0x80:
- // Long sequences are those that contain aa55 twice
- m_long_sequence = true;
- break;
-
- case 0x90:
- // Software product identification entry
- if (TRACE_STATE) logerror("%s: Entering Identification mode\n", tag());
- m_id_mode = true;
- break;
-
- case 0xa0:
- // Software data protection enable
- if (TRACE_STATE) logerror("%s: Software data protection enable\n", tag());
- m_pgm = PGM_1;
- m_enabling_sdb = true;
- // It is not clear from the specification whether the byte cycle timer
- // is already started here or when the first data byte is written
- break;
-
- case 0xf0:
- // Software product identification exit
- if (TRACE_STATE) logerror("%s: Exiting Identification mode\n", tag());
- m_id_mode = false;
- break;
- }
- m_cmd = CMD_0;
- if (data != 0x80) m_long_sequence = false;
-
- // Return, because we don't want to write the EEPROM with the command byte
- return;
- }
- else
- {
- m_cmd = CMD_0;
- m_long_sequence = false;
- }
- }
-
- if ((m_pgm == PGM_2) && (get_sector_number(offset) != get_sector_number(m_programming_last_offset)))
- {
- // cancel current programming cycle
- if (TRACE_WRITE) logerror("%s: Invalid sector change (from sector 0x%04x to 0x%04x); cancel programming cycle\n", tag(), get_sector_number(m_programming_last_offset), get_sector_number(offset));
- m_pgm = PGM_0;
- m_enabling_sdb = false;
- m_disabling_sdb = false;
- m_programming_timer->adjust(attotime::never);
- }
-
- if (((m_pgm == PGM_0) && !m_sdp) // write directly
- || (m_pgm == PGM_1)) // write after unlocking
- {
- if (((offset < m_boot_block_size) && m_lower_bbl)
- || ((offset >= m_memory_size-m_boot_block_size) && m_higher_bbl))
- {
- // attempt to access a locked out boot block: cancel programming
- // command if necessary
- if (TRACE_WRITE) logerror("%s: Attempt to access a locked out boot block: offset = %05x, lowblock=%d, highblock=%d\n", tag(), offset, m_lower_bbl, m_higher_bbl);
-
- m_pgm = PGM_0;
- m_enabling_sdb = false;
- m_disabling_sdb = false;
- }
- else
- { // enter programming mode
- if (TRACE_STATE) logerror("%s: Enter programming mode (m_pgm=%d, m_sdp=%d)\n", tag(), m_pgm, m_sdp);
- // Clear the programming buffer
- memset(m_programming_buffer, 0xff, m_sector_size);
- m_pgm = PGM_2;
- }
- }
- // TODO: If data protection is active and bytes are written, the device
- // enters a dummy write mode
-
- if (m_pgm == PGM_2)
- {
- // write data to programming buffer
- if (TRACE_PRG) logerror("%s: Write data to programming buffer: buf[%x] = %02x\n", tag(), offset & m_sector_mask, data);
- m_programming_buffer[offset & m_sector_mask] = data;
- m_programming_last_offset = offset;
- m_programming_timer->adjust(attotime::from_usec(150)); // next byte must be written before the timer expires
- }
-}
-
-void at29x_device::device_start(void)
-{
- m_programming_buffer = global_alloc_array(UINT8, m_sector_size);
- m_eememory = global_alloc_array(UINT8, m_memory_size+2);
- m_programming_timer = timer_alloc(PRGTIMER);
-
- // TODO: Complete 16-bit handling
- m_address_mask = m_memory_size/(m_word_width/8) - 1;
- m_sector_mask = m_sector_size - 1;
-}
-
-void at29x_device::device_stop(void)
-{
- global_free_array(m_programming_buffer);
- global_free_array(m_eememory);
-}
-
-void at29x_device::device_reset(void)
-{
- if (m_eememory[0] != m_version)
- {
- logerror("%s: Warning: Version mismatch; expected %d but found %d in file. Resetting.\n", tag(), m_version, m_eememory[0]);
- m_eememory[0] = 0;
- m_eememory[1] = 0;
- }
-
- m_lower_bbl = ((m_eememory[1] & 0x04)!=0);
- m_higher_bbl = ((m_eememory[1] & 0x02)!=0);
- m_sdp = ((m_eememory[1] & 0x01)!=0);
-
- if (TRACE_CONFIG) logerror("%s: LowerBBL = %d, HigherBBL = %d, SoftDataProt = %d\n", tag(), m_lower_bbl, m_higher_bbl, m_sdp);
-
- m_id_mode = false;
- m_cmd = CMD_0;
- m_enabling_bbl = false;
- m_long_sequence = false;
- m_pgm = PGM_0;
- m_enabling_sdb = false;
- m_disabling_sdb = false;
- m_toggle_bit = false;
- m_programming_last_offset = 0;
-}
-
-const device_type AT29C020 = &device_creator<at29c020_device>;
-const device_type AT29C040 = &device_creator<at29c040_device>;
-const device_type AT29C040A = &device_creator<at29c040a_device>;
diff --git a/src/emu/machine/at29x.h b/src/emu/machine/at29x.h
deleted file mode 100644
index 91c81c585cf..00000000000
--- a/src/emu/machine/at29x.h
+++ /dev/null
@@ -1,116 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Raphael Nabet, Michael Zapf
-/*
- ATMEL AT29 family
-
- Michael Zapf
- August 2015
-*/
-
-#ifndef __AT29X__
-#define __AT29X__
-
-#include "emu.h"
-
-extern const device_type AT29C020;
-extern const device_type AT29C040;
-extern const device_type AT29C040A;
-
-enum s_cmd_t
-{
- CMD_0 = 0,
- CMD_1,
- CMD_2
-};
-
-enum s_pgm_t
-{
- PGM_0 = 0,
- PGM_1,
- PGM_2,
- PGM_3
-};
-
-class at29x_device : public device_t, public device_nvram_interface
-{
-public:
- at29x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
-protected:
- virtual void device_start(void);
- virtual void device_reset(void);
- virtual void device_stop(void);
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- void nvram_default();
- void nvram_read(emu_file &file);
- void nvram_write(emu_file &file);
-
- int get_sector_number(offs_t address) { return address / m_sector_size; }
-
- int m_memory_size; // bytes
- int m_word_width;
- int m_device_id;
- int m_sector_size;
- int m_cycle_time; // ms
- int m_boot_block_size;
- int m_version;
- int m_address_mask;
- int m_sector_mask;
-
-private:
- void sync_flags(void);
-
- UINT8* m_eememory;
-
- bool m_lower_bbl; // set when lower boot block lockout is enabled
- bool m_higher_bbl; // set when upper boot block lockout is enabled
- bool m_sdp; // set when in software data protect mode
-
- bool m_id_mode; // set when in chip id mode
- s_cmd_t m_cmd; // command state
- bool m_enabling_bbl; // set when a boot block lockout command is expecting its parameter
- bool m_long_sequence; // set if 0x80 command has just been executed (some command require this prefix)
- s_pgm_t m_pgm; // programming state
- bool m_enabling_sdb; // set when a sdp enable command is in progress
- bool m_disabling_sdb; // set when a sdp disable command is in progress
- bool m_toggle_bit; // indicates flashing in progress (toggles for each query)
-
- UINT8* m_programming_buffer;
- int m_programming_last_offset;
- emu_timer* m_programming_timer;
-};
-
-/*
- Variants
-*/
-class at29c020_device : public at29x_device
-{
-public:
- at29c020_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class at29c040_device : public at29x_device
-{
-public:
- at29c040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class at29c040a_device : public at29x_device
-{
-public:
- at29c040a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-#define MCFG_AT29C020_ADD(_tag ) \
- MCFG_DEVICE_ADD(_tag, AT29C020, 0)
-
-#define MCFG_AT29C040_ADD(_tag ) \
- MCFG_DEVICE_ADD(_tag, AT29C040, 0)
-
-#define MCFG_AT29C040A_ADD(_tag ) \
- MCFG_DEVICE_ADD(_tag, AT29C040A, 0)
-
-#endif
diff --git a/src/emu/machine/at45dbxx.c b/src/emu/machine/at45dbxx.c
deleted file mode 100644
index 2890f8784d4..00000000000
--- a/src/emu/machine/at45dbxx.c
+++ /dev/null
@@ -1,388 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Schuerewegen
-/*
-
- Atmel Serial DataFlash
-
- (c) 2001-2007 Tim Schuerewegen
-
- AT45DB041 - 528 KByte
- AT45DB081 - 1056 KByte
- AT45DB161 - 2112 KByte
-
-*/
-
-#include "at45dbxx.h"
-
-#define LOG_LEVEL 1
-#define _logerror(level,x) do { if (LOG_LEVEL > level) logerror x; } while (0)
-
-#define FLASH_CMD_52 0x52
-#define FLASH_CMD_57 0x57
-#define FLASH_CMD_60 0x60
-#define FLASH_CMD_82 0x82
-
-#define FLASH_MODE_XX 0 // unknown
-#define FLASH_MODE_SI 1 // input
-#define FLASH_MODE_SO 2 // output
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type AT45DB041 = &device_creator<at45db041_device>;
-const device_type AT45DB081 = &device_creator<at45db081_device>;
-const device_type AT45DB161 = &device_creator<at45db161_device>;
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// at45db041_device - constructor
-//-------------------------------------------------
-
-at45db041_device::at45db041_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, AT45DB041, "AT45DB041", tag, owner, clock, "at45db041", __FILE__),
- device_nvram_interface(mconfig, *this),
- write_so(*this)
-{
-}
-
-
-at45db041_device::at45db041_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_nvram_interface(mconfig, *this),
- write_so(*this)
-{
-}
-
-
-at45db081_device::at45db081_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : at45db041_device(mconfig, AT45DB081, "AT45DB081", tag, owner, clock, "at45db081", __FILE__)
-{
-}
-
-
-at45db161_device::at45db161_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : at45db041_device(mconfig, AT45DB161, "AT45DB161", tag, owner, clock, "at45db161", __FILE__)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void at45db041_device::device_start()
-{
- m_size = num_pages() * page_size();
- m_data.resize(m_size);
- m_buffer1.resize(page_size());
- //m_buffer2.resize(page_size());
-
- // pins
- m_pin.cs = 0;
- m_pin.sck = 0;
- m_pin.si = 0;
- m_pin.wp = 0;
- m_pin.reset = 0;
- m_pin.busy = 0;
-
- // data
- save_item(NAME(m_data));
- // pins
- save_item(NAME(m_pin.cs));
- save_item(NAME(m_pin.sck));
- save_item(NAME(m_pin.si));
- save_item(NAME(m_pin.so));
- save_item(NAME(m_pin.wp));
- save_item(NAME(m_pin.reset));
- save_item(NAME(m_pin.busy));
-
- write_so.resolve_safe();
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void at45db041_device::device_reset()
-{
- _logerror( 1, ("at45dbxx_reset\n"));
- // mode
- m_mode = FLASH_MODE_SI;
- m_status = 0;
- // command
- memset(&m_cmd.data[0], 0, sizeof(m_cmd.data));
- m_cmd.size = 0;
- // input/output
- m_io.data = NULL;
- m_io.size = 0;
- m_io.pos = 0;
- // pins
- m_pin.so = 0;
- // output
- m_so_byte = 0;
- m_so_bits = 0;
- // input
- m_si_byte = 0;
- m_si_bits = 0;
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void at45db041_device::nvram_default()
-{
- memset(&m_data[0], 0xff, m_data.size());
-
- if (region() != NULL)
- {
- UINT32 bytes = region()->bytes();
- if (bytes > m_size)
- bytes = m_size;
-
- memcpy(&m_data[0], region()->base(), bytes);
- }
-}
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void at45db041_device::nvram_read(emu_file &file)
-{
- file.read(&m_data[0], m_size);
-}
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void at45db041_device::nvram_write(emu_file &file)
-{
- file.write(&m_data[0], m_size);
-}
-
-UINT8 at45db041_device::read_byte()
-{
- UINT8 data;
- // check mode
- if ((m_mode != FLASH_MODE_SO) || (!m_io.data)) return 0;
- // read byte
- data = m_io.data[m_io.pos++];
- _logerror( 2, ("at45dbxx_read_byte (%02X) (%03d/%03d)\n", data, m_io.pos, m_io.size));
- if (m_io.pos == m_io.size) m_io.pos = 0;
- return data;
-}
-
-void at45db041_device::flash_set_io(UINT8* data, UINT32 size, UINT32 pos)
-{
- m_io.data = data;
- m_io.size = size;
- m_io.pos = pos;
-}
-
-UINT32 at45db041_device::flash_get_page_addr()
-{
- return ((m_cmd.data[1] & 0x0F) << 7) | ((m_cmd.data[2] & 0xFE) >> 1);
-}
-
-UINT32 at45db041_device::flash_get_byte_addr()
-{
- return ((m_cmd.data[2] & 0x01) << 8) | ((m_cmd.data[3] & 0xFF) >> 0);
-}
-
-UINT32 at45db081_device::flash_get_page_addr()
-{
- return ((m_cmd.data[1] & 0x1F) << 7) | ((m_cmd.data[2] & 0xFE) >> 1);
-}
-
-UINT32 at45db161_device::flash_get_page_addr()
-{
- return ((m_cmd.data[1] & 0x3F) << 6) | ((m_cmd.data[2] & 0xFC) >> 2);
-}
-
-UINT32 at45db161_device::flash_get_byte_addr()
-{
- return ((m_cmd.data[2] & 0x03) << 8) | ((m_cmd.data[3] & 0xFF) >> 0);
-}
-
-void at45db041_device::write_byte(UINT8 data)
-{
- // check mode
- if (m_mode != FLASH_MODE_SI) return;
- // process byte
- if (m_cmd.size < 8)
- {
- UINT8 opcode;
- _logerror( 2, ("at45dbxx_write_byte (%02X)\n", data));
- // add to command buffer
- m_cmd.data[m_cmd.size++] = data;
- // check opcode
- opcode = m_cmd.data[0];
- switch (opcode)
- {
- // status register read
- case FLASH_CMD_57 :
- {
- // 8 bits command
- if (m_cmd.size == 1)
- {
- _logerror( 1, ("at45dbxx opcode %02X - status register read\n", opcode));
- m_status = (m_status & 0xC7) | device_id(); // 80 = busy / 40 = compare fail
- flash_set_io(&m_status, 1, 0);
- m_mode = FLASH_MODE_SO;
- m_cmd.size = 8;
- }
- }
- break;
- // main memory page to buffer 1 compare
- case FLASH_CMD_60 :
- {
- // 8 bits command + 4 bits reserved + 11 bits page address + 9 bits don't care
- if (m_cmd.size == 4)
- {
- UINT32 page;
- UINT8 comp;
- page = flash_get_page_addr();
- _logerror( 1, ("at45dbxx opcode %02X - main memory page to buffer 1 compare [%04X]\n", opcode, page));
- comp = memcmp( &m_data[page * page_size()], &m_buffer1[0], page_size()) == 0 ? 0 : 1;
- if (comp) m_status |= 0x40; else m_status &= ~0x40;
- _logerror( 1, ("at45dbxx page compare %s\n", comp ? "failure" : "success"));
- m_mode = FLASH_MODE_SI;
- m_cmd.size = 8;
- }
- }
- break;
- // main memory page read
- case FLASH_CMD_52 :
- {
- // 8 bits command + 4 bits reserved + 11 bits page address + 9 bits buffer address + 32 bits don't care
- if (m_cmd.size == 8)
- {
- UINT32 page, byte;
- page = flash_get_page_addr();
- byte = flash_get_byte_addr();
- _logerror( 1, ("at45dbxx opcode %02X - main memory page read [%04X/%04X]\n", opcode, page, byte));
- flash_set_io(&m_data[page * page_size()], page_size(), byte);
- m_mode = FLASH_MODE_SO;
- m_cmd.size = 8;
- }
- }
- break;
- // main memory page program through buffer 1
- case FLASH_CMD_82 :
- {
- // 8 bits command + 4 bits reserved + 11 bits page address + 9 bits buffer address
- if (m_cmd.size == 4)
- {
- UINT32 page, byte;
- page = flash_get_page_addr();
- byte = flash_get_byte_addr();
- _logerror( 1, ("at45dbxx opcode %02X - main memory page program through buffer 1 [%04X/%04X]\n",opcode, page, byte));
- flash_set_io(&m_buffer1[0], page_size(), byte);
- memset(&m_buffer1[0], 0xff, m_buffer1.size());
- m_mode = FLASH_MODE_SI;
- m_cmd.size = 8;
- }
- }
- break;
- // other
- default :
- {
- _logerror( 1, ("at45dbxx opcode %02X - unknown\n", opcode));
- m_cmd.data[0] = 0;
- m_cmd.size = 0;
- }
- break;
- }
- }
- else
- {
- _logerror( 2, ("at45dbxx_write_byte (%02X) (%03d/%03d)\n", data, m_io.pos + 1, m_io.size));
- // store byte
- m_io.data[m_io.pos] = data;
- m_io.pos++;
- if (m_io.pos == m_io.size) m_io.pos = 0;
- }
-}
-
-READ_LINE_MEMBER(at45db041_device::so_r)
-{
- if (m_pin.cs == 0) return 0;
- return m_pin.so;
-}
-
-WRITE_LINE_MEMBER(at45db041_device::si_w)
-{
- if (m_pin.cs == 0) return;
- m_pin.si = state;
-}
-
-WRITE_LINE_MEMBER(at45db041_device::cs_w)
-{
- // check if changed
- if (m_pin.cs == state) return;
- // cs low-to-high
- if (state != 0)
- {
- // complete program command
- if ((m_cmd.size >= 4) && (m_cmd.data[0] == FLASH_CMD_82))
- {
- UINT32 page, byte;
- page = flash_get_page_addr();
- byte = flash_get_byte_addr();
- _logerror( 1, ("at45dbxx - program data stored in buffer 1 into selected page in main memory [%04X/%04X]\n", page, byte));
- memcpy( &m_data[page * page_size()], &m_buffer1[0], page_size());
- }
- // reset
- at45db041_device::device_reset();
- }
- // save cs
- m_pin.cs = state;
-}
-
-WRITE_LINE_MEMBER(at45db041_device::sck_w)
-{
- // check if changed
- if (m_pin.sck == state) return;
- // sck high-to-low
- if (state == 0)
- {
- // output (part 1)
- if (m_so_bits == 8)
- {
- m_so_bits = 0;
- m_so_byte = read_byte();
- }
- // output (part 2)
- m_pin.so = (m_so_byte >> m_so_bits) & 1;
- write_so(m_pin.so);
- m_so_bits++;
- }
- else
- {
- // input
- if (m_pin.si) m_si_byte = m_si_byte | (1 << m_si_bits);
- m_si_bits++;
- if (m_si_bits == 8)
- {
- m_si_bits = 0;
- write_byte(m_si_byte);
- m_si_byte = 0;
- }
- }
- // save sck
- m_pin.sck = state;
-}
diff --git a/src/emu/machine/at45dbxx.h b/src/emu/machine/at45dbxx.h
deleted file mode 100644
index a1e41e88657..00000000000
--- a/src/emu/machine/at45dbxx.h
+++ /dev/null
@@ -1,152 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Schuerewegen
-/*
-
- Atmel Serial DataFlash
-
- (c) 2001-2007 Tim Schuerewegen
-
- AT45DB041 - 528 KByte
- AT45DB081 - 1056 KByte
- AT45DB161 - 2112 KByte
-
-*/
-
-#ifndef _AT45DBXX_H_
-#define _AT45DBXX_H_
-
-#include "emu.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_AT45DB041_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, AT45DB041, 0)
-
-#define MCFG_AT45DB081_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, AT45DB081, 0)
-
-#define MCFG_AT45DB161_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, AT45DB161, 0)
-
-#define MCFG_AT45DBXXX_SO_CALLBACK(_cb) \
- devcb = &at45db041_device::set_so_cb(*device, DEVCB_##_cb);
-
-
-// ======================> at45db041_device
-
-class at45db041_device : public device_t,
- public device_nvram_interface
-{
-public:
- at45db041_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- at45db041_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- DECLARE_WRITE_LINE_MEMBER(cs_w);
- DECLARE_WRITE_LINE_MEMBER(sck_w);
- DECLARE_WRITE_LINE_MEMBER(si_w);
- DECLARE_READ_LINE_MEMBER(so_r);
-
- UINT8 *get_ptr() { return &m_data[0]; }
-
- template<class _Object> static devcb_base &set_so_cb(device_t &device, _Object object) { return downcast<at45db041_device &>(device).write_so.set_callback(object); }
- devcb_write_line write_so;
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
-protected:
- virtual int num_pages() const { return 2048; }
- virtual int page_size() const { return 264; }
- virtual UINT8 device_id() const { return 0x18; }
-
- UINT8 read_byte();
- void flash_set_io(UINT8* data, UINT32 size, UINT32 pos);
- virtual UINT32 flash_get_page_addr();
- virtual UINT32 flash_get_byte_addr();
- void write_byte(UINT8 data);
-
- // internal state
- dynamic_buffer m_data;
- UINT32 m_size;
- UINT8 m_mode;
- UINT8 m_status;
- dynamic_buffer m_buffer1;
- //dynamic_buffer m_buffer2;
- UINT8 m_si_byte;
- UINT8 m_si_bits;
- UINT8 m_so_byte;
- UINT8 m_so_bits;
-
- struct AT45DBXX_PINS
- {
- int cs; // chip select
- int sck; // serial clock
- int si; // serial input
- int so; // serial output
- int wp; // write protect
- int reset; // reset
- int busy; // busy
- } m_pin;
-
- struct AT45DBXX_IO
- {
- UINT8 *data;
- UINT32 size;
- UINT32 pos;
- } m_io;
-
- struct AT45DBXX_CMD
- {
- UINT8 data[8];
- UINT8 size;
- } m_cmd;
-};
-
-// ======================> at45db081_device
-
-class at45db081_device : public at45db041_device
-{
-public:
- at45db081_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual int num_pages() const { return 4096; }
- virtual int page_size() const { return 264; }
- virtual UINT8 device_id() const { return 0x20; }
-
- virtual UINT32 flash_get_page_addr();
-};
-
-// ======================> at45db161_device
-
-class at45db161_device : public at45db041_device
-{
-public:
- at45db161_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual int num_pages() const { return 4096; }
- virtual int page_size() const { return 528; }
- virtual UINT8 device_id() const { return 0x28; }
-
- virtual UINT32 flash_get_page_addr();
- virtual UINT32 flash_get_byte_addr();
-};
-
-
-// device type definition
-extern const device_type AT45DB041;
-extern const device_type AT45DB081;
-extern const device_type AT45DB161;
-
-#endif
diff --git a/src/emu/machine/at_keybc.c b/src/emu/machine/at_keybc.c
deleted file mode 100644
index a2930d627f9..00000000000
--- a/src/emu/machine/at_keybc.c
+++ /dev/null
@@ -1,226 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol
-/***************************************************************************
-
- IBM PC AT compatibles 8042 keyboard controller
-
-***************************************************************************/
-
-#include "emu.h"
-#include "at_keybc.h"
-#include "cpu/mcs48/mcs48.h"
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-const device_type AT_KEYBOARD_CONTROLLER = &device_creator<at_keyboard_controller_device>;
-
-// i/o map for the 8042
-static ADDRESS_MAP_START( at_keybc_io, AS_IO, 8, at_keyboard_controller_device)
- AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_READ(t0_r)
- AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(t1_r)
- AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READ( p1_r)
- AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READWRITE(p2_r, p2_w)
-ADDRESS_MAP_END
-
-static INPUT_PORTS_START( at_keybc )
- PORT_START("DSW")
- PORT_BIT( 0xbf, 0xbf, IPT_UNUSED )
- PORT_DIPNAME( 0x40, 0x00, "Display switch")
- PORT_DIPSETTING( 0x40, "Monochrome adapter" )
- PORT_DIPSETTING( 0x00, "Color/Graphics adapter" )
-INPUT_PORTS_END
-
-// machine fragment
-static MACHINE_CONFIG_FRAGMENT( at_keybc )
- MCFG_CPU_ADD("at_keybc", I8042, DERIVED_CLOCK(1,1))
- MCFG_CPU_IO_MAP(at_keybc_io)
-MACHINE_CONFIG_END
-
-// rom definition for the 8042 internal rom
-ROM_START( at_keybc )
- ROM_REGION(0x800, "at_keybc", 0)
-
- // unknown controller bios, (c) 1985, 1986 PTL
- ROM_LOAD("yan25d05.bin", 0x000, 0x800, CRC(70c798f1) SHA1(ae9a79c7184a17331b70a50035ff63c757df094c))
-
- // 1983 ibm controller bios
- ROM_LOAD("1503033.bin", 0x000, 0x800, CRC(5a81c0d2) SHA1(0100f8789fb4de74706ae7f9473a12ec2b9bd729))
-ROM_END
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// at_keyboard_controller_device - constructor
-//-------------------------------------------------
-
-at_keyboard_controller_device::at_keyboard_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, AT_KEYBOARD_CONTROLLER, "AT Keyboard Controller", tag, owner, clock, "at_keybc", __FILE__),
- m_cpu(NULL),
- m_system_reset_cb(*this),
- m_gate_a20_cb(*this),
- m_input_buffer_full_cb(*this),
- m_output_buffer_empty_cb(*this),
- m_keyboard_clock_cb(*this),
- m_keyboard_data_cb(*this)
-{
-}
-
-//-------------------------------------------------
-// rom_region - return a pointer to the device's
-// internal ROM region
-//-------------------------------------------------
-
-const rom_entry *at_keyboard_controller_device::device_rom_region() const
-{
- return ROM_NAME(at_keybc);
-}
-
-//-------------------------------------------------
-// input_ports - device-specific input ports
-//-------------------------------------------------
-
-ioport_constructor at_keyboard_controller_device::device_input_ports() const
-{
- return INPUT_PORTS_NAME( at_keybc );
-}
-
-//-------------------------------------------------
-// machine_config_additions - return a pointer to
-// the device's machine fragment
-//-------------------------------------------------
-
-machine_config_constructor at_keyboard_controller_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME(at_keybc);
-}
-
-/*-------------------------------------------------
- device_start - device-specific startup
--------------------------------------------------*/
-
-void at_keyboard_controller_device::device_start()
-{
- // find our cpu
- m_cpu = downcast<upi41_cpu_device *>(subdevice("at_keybc"));
-
- // resolve callbacks
- m_system_reset_cb.resolve_safe();
- m_gate_a20_cb.resolve_safe();
- m_input_buffer_full_cb.resolve_safe();
- m_output_buffer_empty_cb.resolve_safe();
- m_keyboard_clock_cb.resolve_safe();
- m_keyboard_data_cb.resolve_safe();
-
- // register for save states
- save_item(NAME(m_clock_signal));
- save_item(NAME(m_data_signal));
-}
-
-/*-------------------------------------------------
- device_reset - device-specific reset
--------------------------------------------------*/
-
-void at_keyboard_controller_device::device_reset()
-{
-}
-
-
-//**************************************************************************
-// INTERNAL 8042 READ/WRITE HANDLERS
-//**************************************************************************
-
-READ8_MEMBER( at_keyboard_controller_device::t0_r )
-{
- return m_clock_signal;
-}
-
-READ8_MEMBER( at_keyboard_controller_device::t1_r )
-{
- return m_data_signal;
-}
-
-/*
- Port 1 (Input port)
- 0 - P10 - Undefined
- 1 - P11 - Undefined
- 2 - P12 - Undefined
- 3 - P13 - Undefined
- 4 - P14 - External RAM (1 = Enable external RAM, 0 = Disable external RAM)
- 5 - P15 - Manufacturing setting (1 = Setting enabled, 0 = Setting disabled)
- 6 - P16 - Display type switch (1 = Monochrome display, 0 = Color display)
- 7 - P17 - Keyboard inhibit switch (1 = Keyboard enabled, 0 = Keyboard inhibited)
-*/
-READ8_MEMBER( at_keyboard_controller_device::p1_r )
-{
- return ioport("DSW")->read();
-}
-
-READ8_MEMBER( at_keyboard_controller_device::p2_r )
-{
- return 0xff;
-}
-
-/*
- Port 2 (Output port)
- 0 - P20 - System Reset (1 = Normal, 0 = Reset computer)
- 1 - P21 - Gate A20
- 2 - P22 - Undefined
- 3 - P23 - Undefined
- 4 - P24 - Input Buffer Full
- 5 - P25 - Output Buffer Empty
- 6 - P26 - Keyboard Clock (1 = Pull Clock low, 0 = High-Z)
- 7 - P27 - Keyboard Data (1 = Pull Data low, 0 = High-Z)
-*/
-WRITE8_MEMBER( at_keyboard_controller_device::p2_w )
-{
- m_system_reset_cb(BIT(data, 0) ? CLEAR_LINE : ASSERT_LINE);
- m_gate_a20_cb(BIT(data, 1) ? ASSERT_LINE : CLEAR_LINE);
- m_input_buffer_full_cb(BIT(data, 4) ? ASSERT_LINE : CLEAR_LINE);
- m_output_buffer_empty_cb(BIT(data, 5) ? ASSERT_LINE : CLEAR_LINE);
-
- m_clock_signal = !BIT(data, 6);
- m_data_signal = BIT(data, 7);
-
- m_keyboard_data_cb(m_data_signal);
- m_keyboard_clock_cb(m_clock_signal);
-}
-
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-READ8_MEMBER( at_keyboard_controller_device::data_r )
-{
- return m_cpu->upi41_master_r(space, 0);
-}
-
-WRITE8_MEMBER( at_keyboard_controller_device::data_w )
-{
- m_cpu->upi41_master_w(space, 0, data);
-}
-
-READ8_MEMBER( at_keyboard_controller_device::status_r )
-{
- return m_cpu->upi41_master_r(space, 1);
-}
-
-WRITE8_MEMBER( at_keyboard_controller_device::command_w )
-{
- m_cpu->upi41_master_w(space, 1, data);
-}
-
-WRITE_LINE_MEMBER( at_keyboard_controller_device::keyboard_clock_w )
-{
- m_clock_signal = state;
-}
-
-WRITE_LINE_MEMBER( at_keyboard_controller_device::keyboard_data_w )
-{
- m_data_signal = state;
-}
diff --git a/src/emu/machine/at_keybc.h b/src/emu/machine/at_keybc.h
deleted file mode 100644
index 2051071da5f..00000000000
--- a/src/emu/machine/at_keybc.h
+++ /dev/null
@@ -1,108 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol
-/***************************************************************************
-
- IBM PC AT compatibles 8042 keyboard controller
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __AT_KEYBC_H__
-#define __AT_KEYBC_H__
-
-#include "emu.h"
-#include "cpu/mcs48/mcs48.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_AT_KEYBOARD_CONTROLLER_SYSTEM_RESET_CB(_devcb) \
- devcb = &at_keyboard_controller_device::set_system_reset_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AT_KEYBOARD_CONTROLLER_GATE_A20_CB(_devcb) \
- devcb = &at_keyboard_controller_device::set_gate_a20_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AT_KEYBOARD_CONTROLLER_INPUT_BUFFER_FULL_CB(_devcb) \
- devcb = &at_keyboard_controller_device::set_input_buffer_full_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AT_KEYBOARD_CONTROLLER_OUTPUT_BUFFER_EMPTY_CB(_devcb) \
- devcb = &at_keyboard_controller_device::set_output_buffer_empty_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AT_KEYBOARD_CONTROLLER_KEYBOARD_CLOCK_CB(_devcb) \
- devcb = &at_keyboard_controller_device::set_keyboard_clock_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AT_KEYBOARD_CONTROLLER_KEYBOARD_DATA_CB(_devcb) \
- devcb = &at_keyboard_controller_device::set_keyboard_data_callback(*device, DEVCB_##_devcb);
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> at_keyboard_controller_device
-
-class at_keyboard_controller_device : public device_t
-{
-public:
- // construction/destruction
- at_keyboard_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_system_reset_callback(device_t &device, _Object object) { return downcast<at_keyboard_controller_device &>(device).m_system_reset_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_gate_a20_callback(device_t &device, _Object object) { return downcast<at_keyboard_controller_device &>(device).m_gate_a20_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_input_buffer_full_callback(device_t &device, _Object object) { return downcast<at_keyboard_controller_device &>(device).m_input_buffer_full_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_output_buffer_empty_callback(device_t &device, _Object object) { return downcast<at_keyboard_controller_device &>(device).m_output_buffer_empty_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_keyboard_clock_callback(device_t &device, _Object object) { return downcast<at_keyboard_controller_device &>(device).m_keyboard_clock_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_keyboard_data_callback(device_t &device, _Object object) { return downcast<at_keyboard_controller_device &>(device).m_keyboard_data_cb.set_callback(object); }
-
- // internal 8042 interface
- DECLARE_READ8_MEMBER( t0_r );
- DECLARE_READ8_MEMBER( t1_r );
- DECLARE_READ8_MEMBER( p1_r );
- DECLARE_READ8_MEMBER( p2_r );
- DECLARE_WRITE8_MEMBER( p2_w );
-
- // interface to the host pc
- DECLARE_READ8_MEMBER( data_r );
- DECLARE_WRITE8_MEMBER( data_w );
- DECLARE_READ8_MEMBER( status_r );
- DECLARE_WRITE8_MEMBER( command_w );
-
- // interface to the keyboard
- DECLARE_WRITE_LINE_MEMBER( keyboard_clock_w );
- DECLARE_WRITE_LINE_MEMBER( keyboard_data_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- virtual const rom_entry *device_rom_region() const;
- virtual ioport_constructor device_input_ports() const;
- virtual machine_config_constructor device_mconfig_additions() const;
-
-private:
- // internal state
- upi41_cpu_device *m_cpu;
-
- // interface to the host pc
- devcb_write_line m_system_reset_cb;
- devcb_write_line m_gate_a20_cb;
- devcb_write_line m_input_buffer_full_cb;
- devcb_write_line m_output_buffer_empty_cb;
-
- // interface to the keyboard
- devcb_write_line m_keyboard_clock_cb;
- devcb_write_line m_keyboard_data_cb;
-
- UINT8 m_clock_signal;
- UINT8 m_data_signal;
-};
-
-
-// device type definition
-extern const device_type AT_KEYBOARD_CONTROLLER;
-
-
-#endif /* __AT_KEYBC__ */
diff --git a/src/emu/machine/atadev.c b/src/emu/machine/atadev.c
deleted file mode 100644
index 691ffe7562f..00000000000
--- a/src/emu/machine/atadev.c
+++ /dev/null
@@ -1,21 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- ATA Device implementation.
-
-***************************************************************************/
-
-#include "atadev.h"
-
-//-------------------------------------------------
-// ata_device_interface - constructor
-//-------------------------------------------------
-
-ata_device_interface::ata_device_interface(const machine_config &mconfig, device_t &device) :
- m_irq_handler(device),
- m_dmarq_handler(device),
- m_dasp_handler(device),
- m_pdiag_handler(device)
-{
-}
diff --git a/src/emu/machine/atadev.h b/src/emu/machine/atadev.h
deleted file mode 100644
index 3b96a6b580c..00000000000
--- a/src/emu/machine/atadev.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- atadev.h
-
- ATA Device implementation.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __ATADEV_H__
-#define __ATADEV_H__
-
-#include "emu.h"
-
-// ======================> ata_device_interface
-
-class ata_device_interface
-{
-public:
- ata_device_interface(const machine_config &mconfig, device_t &device);
- virtual ~ata_device_interface() {}
-
- virtual UINT16 read_dma() = 0;
- virtual DECLARE_READ16_MEMBER(read_cs0) = 0;
- virtual DECLARE_READ16_MEMBER(read_cs1) = 0;
-
- virtual void write_dma(UINT16 data) = 0;
- virtual DECLARE_WRITE16_MEMBER(write_cs0) = 0;
- virtual DECLARE_WRITE16_MEMBER(write_cs1) = 0;
- virtual DECLARE_WRITE_LINE_MEMBER(write_dmack) = 0;
- virtual DECLARE_WRITE_LINE_MEMBER(write_csel) = 0;
- virtual DECLARE_WRITE_LINE_MEMBER(write_dasp) = 0;
- virtual DECLARE_WRITE_LINE_MEMBER(write_pdiag) = 0;
-
- devcb_write_line m_irq_handler;
- devcb_write_line m_dmarq_handler;
- devcb_write_line m_dasp_handler;
- devcb_write_line m_pdiag_handler;
-};
-
-#endif
diff --git a/src/emu/machine/ataflash.c b/src/emu/machine/ataflash.c
deleted file mode 100644
index 914ba2bcc65..00000000000
--- a/src/emu/machine/ataflash.c
+++ /dev/null
@@ -1,209 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "ataflash.h"
-
-#define IDE_COMMAND_TAITO_GNET_UNLOCK_1 0xfe
-#define IDE_COMMAND_TAITO_GNET_UNLOCK_2 0xfc
-#define IDE_COMMAND_TAITO_GNET_UNLOCK_3 0x0f
-
-const device_type ATA_FLASH_PCCARD = &device_creator<ata_flash_pccard_device>;
-
-ata_flash_pccard_device::ata_flash_pccard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- ide_hdd_device(mconfig, ATA_FLASH_PCCARD, "ATA Flash PCCARD", tag, owner, clock, "ataflash", __FILE__)
-{
-}
-
-void ata_flash_pccard_device::device_start()
-{
- ide_hdd_device::device_start();
-
- save_item(NAME(m_locked));
- save_item(NAME(m_gnetreadlock));
-}
-
-void ata_flash_pccard_device::device_reset()
-{
- ide_hdd_device::device_reset();
-
- UINT32 metalength;
- memset(m_key, 0, sizeof(m_key));
- memset(m_cis, 0xff, 512);
-
- if (m_handle != NULL)
- {
- m_handle->read_metadata(PCMCIA_CIS_METADATA_TAG, 0, m_cis, 512, metalength);
-
- if (m_handle->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, m_key, 5, metalength) == CHDERR_NONE)
- {
- m_locked = 0x1ff;
- m_gnetreadlock = 1;
- }
- }
-}
-
-READ16_MEMBER( ata_flash_pccard_device::read_memory )
-{
- if(offset <= 7)
- {
- m_8bit_data_transfers = !ACCESSING_BITS_8_15; // HACK
- return read_cs0(space, offset, mem_mask);
- }
- else if(offset <= 15)
- {
- return read_cs1(space, offset & 7, mem_mask);
- }
- else
- {
- return 0xffff;
- }
-}
-
-WRITE16_MEMBER( ata_flash_pccard_device::write_memory )
-{
- if(offset <= 7)
- {
- m_8bit_data_transfers = !ACCESSING_BITS_8_15; // HACK
- write_cs0(space, offset, data, mem_mask);
- }
- else if( offset <= 15)
- {
- write_cs1(space, offset & 7, data, mem_mask);
- }
-}
-
-READ16_MEMBER( ata_flash_pccard_device::read_reg )
-{
- if(offset < 0x100)
- return m_cis[offset];
-
- switch(offset)
- {
- case 0x100:
- return 0x0041;
-
- case 0x101:
- return 0x0080;
-
- case 0x102:
- return 0x002e;
-
- case 0x201:
- return m_gnetreadlock;
-
- default:
- return 0;
- }
-}
-
-WRITE16_MEMBER( ata_flash_pccard_device::write_reg )
-{
- if(offset >= 0x280 && offset <= 0x288 && m_handle != NULL)
- {
- UINT8 v = data;
- int pos = offset - 0x280;
- UINT8 k = pos < sizeof(m_key) ? m_key[pos] : 0;
-
- if(v == k)
- {
- m_locked &= ~(1 << pos);
- }
- else
- {
- m_locked |= 1 << pos;
- }
-
- if (!m_locked)
- {
- m_gnetreadlock = 0;
- }
- }
-}
-
-bool ata_flash_pccard_device::is_ready()
-{
- return !m_gnetreadlock;
-}
-
-void ata_flash_pccard_device::process_command()
-{
- m_buffer_size = IDE_DISK_SECTOR_SIZE;
-
- switch (m_command)
- {
- case IDE_COMMAND_TAITO_GNET_UNLOCK_1:
- //LOGPRINT(("IDE GNET Unlock 1\n"));
-
- m_sector_count = 1;
- m_status |= IDE_STATUS_DRDY;
-
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_TAITO_GNET_UNLOCK_2:
- //LOGPRINT(("IDE GNET Unlock 2\n"));
-
- /* mark the buffer ready */
- m_status |= IDE_STATUS_DRQ;
-
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_TAITO_GNET_UNLOCK_3:
- //LOGPRINT(("IDE GNET Unlock 3\n"));
-
- /* key check */
- if (m_feature == m_key[0] && m_sector_count == m_key[1] && m_sector_number == m_key[2] && m_cylinder_low == m_key[3] && m_cylinder_high == m_key[4])
- {
- m_gnetreadlock = 0;
- }
- else
- {
- m_status &= ~IDE_STATUS_DRDY;
- }
-
- set_irq(ASSERT_LINE);
- break;
-
- default:
- if (m_gnetreadlock)
- {
- m_status |= IDE_STATUS_ERR;
- m_error = IDE_ERROR_NONE;
- m_status &= ~IDE_STATUS_DRDY;
- break;
- }
-
- ide_hdd_device::process_command();
- break;
- }
-}
-
-void ata_flash_pccard_device::process_buffer()
-{
- if (m_command == IDE_COMMAND_TAITO_GNET_UNLOCK_2)
- {
- int i, bad = 0;
-
- for (i=0; !bad && i<512; i++)
- bad = ((i < 2 || i >= 7) && m_buffer[i]) || ((i >= 2 && i < 7) && m_buffer[i] != m_key[i-2]);
-
- if (bad)
- {
- m_status |= IDE_STATUS_ERR;
- m_error = IDE_ERROR_NONE;
- }
- else
- {
- m_gnetreadlock= 0;
- }
- }
- else
- {
- ide_hdd_device::process_buffer();
- }
-}
-
-attotime ata_flash_pccard_device::seek_time()
-{
- return attotime::zero;
-}
diff --git a/src/emu/machine/ataflash.h b/src/emu/machine/ataflash.h
deleted file mode 100644
index 3bfd198f1af..00000000000
--- a/src/emu/machine/ataflash.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#pragma once
-
-#ifndef __ATAFLASH_H__
-#define __ATAFLASH_H__
-
-#include "pccard.h"
-#include "machine/idehd.h"
-
-extern const device_type ATA_FLASH_PCCARD;
-
-class ata_flash_pccard_device : public ide_hdd_device,
- public pccard_interface
-{
-public:
- ata_flash_pccard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_READ16_MEMBER(read_memory);
- virtual DECLARE_WRITE16_MEMBER(write_memory);
- virtual DECLARE_READ16_MEMBER(read_reg);
- virtual DECLARE_WRITE16_MEMBER(write_reg);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- virtual attotime seek_time();
- virtual void process_command();
- virtual void process_buffer();
- virtual bool is_ready();
-
-private:
- UINT8 m_cis[512];
- UINT8 m_key[5];
- UINT8 m_gnetreadlock;
- int m_locked;
-};
-
-#endif
diff --git a/src/emu/machine/atahle.c b/src/emu/machine/atahle.c
deleted file mode 100644
index 3a1599a3eed..00000000000
--- a/src/emu/machine/atahle.c
+++ /dev/null
@@ -1,950 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "atahle.h"
-
-#define VERBOSE 0
-#define PRINTF_IDE_COMMANDS 0
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-#define LOGPRINT(x) do { if (VERBOSE) logerror x; if (PRINTF_IDE_COMMANDS) osd_printf_debug x; } while (0)
-
-enum
-{
- IDE_CS0_DATA_RW = 0,
- IDE_CS0_ERROR_R = 1,
- IDE_CS0_FEATURE_W = 1,
- IDE_CS0_SECTOR_COUNT_RW = 2,
- IDE_CS0_SECTOR_NUMBER_RW = 3,
- IDE_CS0_CYLINDER_LOW_RW = 4,
- IDE_CS0_CYLINDER_HIGH_RW = 5,
- IDE_CS0_DEVICE_HEAD_RW = 6,
- IDE_CS0_STATUS_R = 7,
- IDE_CS0_COMMAND_W = 7
-};
-
-enum
-{
- IDE_CS1_ALTERNATE_STATUS_R = 6,
- IDE_CS1_DEVICE_CONTROL_W = 6,
- IDE_CS1_ACTIVE_STATUS = 7
-};
-
-enum
-{
- IDE_DEVICE_CONTROL_NIEN = 0x02,
- IDE_DEVICE_CONTROL_SRST = 0x04
-};
-
-#define DETECT_DEVICE1_TIME (attotime::from_msec(2))
-#define DEVICE1_PDIAG_TIME (attotime::from_msec(2))
-#define DIAGNOSTIC_TIME (attotime::from_msec(2))
-
-ata_hle_device::ata_hle_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock,const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- ata_device_interface(mconfig, *this),
- device_slot_card_interface(mconfig, *this),
- m_buffer_offset(0),
- m_buffer_size(0),
- m_error(0),
- m_feature(0),
- m_sector_count(0),
- m_sector_number(0),
- m_cylinder_low(0),
- m_cylinder_high(0),
- m_device_head(0),
- m_status(0),
- m_command(0),
- m_device_control(0),
- m_revert_to_defaults(true),
- m_8bit_data_transfers(false),
- m_csel(0),
- m_daspin(0),
- m_daspout(0),
- m_dmack(0),
- m_dmarq(0),
- m_irq(0),
- m_pdiagin(0),
- m_pdiagout(0),
- m_single_device(0),
- m_resetting(0)
-{
-}
-
-void ata_hle_device::device_start()
-{
- MINIMUM_COMMAND_TIME = attotime::from_usec(10);
-
- m_irq_handler.resolve_safe();
- m_dmarq_handler.resolve_safe();
- m_dasp_handler.resolve_safe();
- m_pdiag_handler.resolve_safe();
-
- m_buffer.resize(sector_length());
- save_item(NAME(m_buffer));
- save_item(NAME(m_buffer_offset));
- save_item(NAME(m_buffer_size));
- save_item(NAME(m_error));
- save_item(NAME(m_feature));
- save_item(NAME(m_sector_count));
- save_item(NAME(m_sector_number));
- save_item(NAME(m_cylinder_low));
- save_item(NAME(m_cylinder_high));
- save_item(NAME(m_device_head));
- save_item(NAME(m_status));
- save_item(NAME(m_command));
- save_item(NAME(m_device_control));
- save_item(NAME(m_revert_to_defaults));
-
- save_item(NAME(m_single_device));
- save_item(NAME(m_resetting));
-
- save_item(NAME(m_csel));
- save_item(NAME(m_daspin));
- save_item(NAME(m_daspout));
- save_item(NAME(m_dmack));
- save_item(NAME(m_dmarq));
- save_item(NAME(m_irq));
- save_item(NAME(m_pdiagin));
- save_item(NAME(m_pdiagout));
-
- save_item(NAME(m_identify_buffer));
-
- m_busy_timer = timer_alloc(TID_BUSY);
-}
-
-void ata_hle_device::device_reset()
-{
- /* reset the drive state */
- set_dasp(CLEAR_LINE);
- set_dmarq(CLEAR_LINE);
- set_irq(CLEAR_LINE);
- set_pdiag(CLEAR_LINE);
-
- m_status = 0;
- m_device_control = 0;
- m_resetting = true;
-
- if (m_csel == 0)
- {
- start_busy(DETECT_DEVICE1_TIME, PARAM_DETECT_DEVICE1);
- }
- else
- {
- set_dasp(ASSERT_LINE);
- soft_reset();
- }
-}
-
-void ata_hle_device::soft_reset()
-{
- m_buffer_offset = 0;
- m_buffer_size = 0;
- m_status = 0;
-
- if (is_ready())
- {
- m_status |= IDE_STATUS_DRDY;
- }
-
- start_busy(DIAGNOSTIC_TIME, PARAM_DIAGNOSTIC);
-}
-
-void ata_hle_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch(id)
- {
- case TID_BUSY:
- m_status &= ~IDE_STATUS_BSY;
-
- finished_busy(param);
- break;
- }
-}
-
-void ata_hle_device::finished_busy(int param)
-{
- switch (param)
- {
- case PARAM_DETECT_DEVICE1:
- m_single_device = (m_daspin == CLEAR_LINE);
- soft_reset();
- break;
-
- case PARAM_DIAGNOSTIC:
- start_diagnostic();
- break;
-
- case PARAM_WAIT_FOR_PDIAG:
- m_error |= IDE_ERROR_DIAGNOSTIC_DEVICE1_FAILED;
- finished_diagnostic();
- break;
-
- case PARAM_COMMAND:
- finished_command();
- break;
- }
-}
-
-void ata_hle_device::process_command()
-{
- switch (m_command)
- {
- case IDE_COMMAND_DIAGNOSTIC:
- start_busy(DIAGNOSTIC_TIME, PARAM_COMMAND);
- break;
-
- case IDE_COMMAND_SET_FEATURES:
- start_busy(MINIMUM_COMMAND_TIME, PARAM_COMMAND);
- break;
-
- case IDE_COMMAND_CACHE_FLUSH:
- start_busy(MINIMUM_COMMAND_TIME, PARAM_COMMAND);
- break;
-
- default:
- LOGPRINT(("IDE unknown command (%02X)\n", m_command));
- m_status |= IDE_STATUS_ERR;
- m_error = IDE_ERROR_ABRT;
- set_irq(ASSERT_LINE);
- //debugger_break(device->machine());
- break;
- }
-}
-
-void ata_hle_device::finished_command()
-{
- switch (m_command)
- {
- case IDE_COMMAND_DIAGNOSTIC:
- start_diagnostic();
-
- if (m_csel == 0)
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_SET_FEATURES:
- if (!set_features())
- {
- LOGPRINT(("IDE Set features failed (%02X %02X %02X %02X %02X)\n", m_feature, m_sector_count & 0xff, m_sector_number, m_cylinder_low, m_cylinder_high));
-
- m_status |= IDE_STATUS_ERR;
- m_error = IDE_ERROR_ABRT;
- }
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_CACHE_FLUSH:
- m_status |= IDE_STATUS_DRDY;
- break;
-
- default:
- logerror( "finished_command() unhandled command %02x\n", m_command );
- break;
- }
-}
-
-bool ata_hle_device::set_dma_mode(int word)
-{
- if ((m_identify_buffer[word] >> (m_sector_count & 7)) & 1)
- {
- m_identify_buffer[62] &= 0xff;
- m_identify_buffer[63] &= 0xff;
- m_identify_buffer[88] &= 0xff;
-
- m_identify_buffer[word] |= 0x100 << (m_sector_count & 7);
- return true;
- }
-
- return false;
-}
-
-bool ata_hle_device::set_features()
-{
- switch (m_feature)
- {
- case IDE_SET_FEATURES_ENABLE_8BIT_DATA_TRANSFERS:
- m_8bit_data_transfers = true;
- return true;
-
- case IDE_SET_FEATURES_TRANSFER_MODE:
- switch (m_sector_count & IDE_TRANSFER_TYPE_MASK)
- {
- case IDE_TRANSFER_TYPE_PIO_DEFAULT:
- switch (m_sector_count & 7)
- {
- case 0:
- case 1:
- return true;
- }
- break;
-
- case IDE_TRANSFER_TYPE_PIO_FLOW_CONTROL:
- switch (m_sector_count & 7)
- {
- case 0:
- case 1:
- case 2:
- return true;
-
- default:
- if ((m_identify_buffer[64] >> ((m_sector_count & 7) - 3)) & 1)
- {
- return true;
- }
- }
- break;
-
- case IDE_TRANSFER_TYPE_SINGLE_WORD_DMA:
- return set_dma_mode(62);
-
- case IDE_TRANSFER_TYPE_MULTI_WORD_DMA:
- return set_dma_mode(63);
-
- case IDE_TRANSFER_TYPE_ULTRA_DMA:
- return set_dma_mode(88);
- }
- break;
-
- case IDE_SET_FEATURES_DISABLE_REVERTING_TO_POWER_ON_DEFAULTS:
- m_revert_to_defaults = false;
- return true;
-
- case IDE_SET_FEATURES_DISABLE_8BIT_DATA_TRANSFERS:
- m_8bit_data_transfers = false;
- return true;
-
- case IDE_SET_FEATURES_ENABLE_REVERTING_TO_POWER_ON_DEFAULTS:
- m_revert_to_defaults = true;
- return true;
- }
-
- return false;
-}
-
-int ata_hle_device::bit_to_mode(UINT16 word)
-{
- switch (word>>8)
- {
- case 0x01:
- return 0;
- case 0x02:
- return 1;
- case 0x04:
- return 2;
- case 0x08:
- return 3;
- case 0x10:
- return 4;
- case 0x20:
- return 5;
- case 0x40:
- return 6;
- case 0x080:
- return 7;
- }
-
- return -1;
-}
-
-int ata_hle_device::single_word_dma_mode()
-{
- return bit_to_mode(m_identify_buffer[62]);
-}
-
-int ata_hle_device::multi_word_dma_mode()
-{
- return bit_to_mode(m_identify_buffer[63]);
-}
-
-int ata_hle_device::ultra_dma_mode()
-{
- return bit_to_mode(m_identify_buffer[88]);
-}
-
-UINT16 ata_hle_device::read_data()
-{
- /* fetch the correct amount of data */
- UINT16 result = m_buffer[m_buffer_offset++];
- if (!m_8bit_data_transfers)
- result |= m_buffer[m_buffer_offset++] << 8;
-
- /* if we're at the end of the buffer, handle it */
- if (m_buffer_offset >= m_buffer_size)
- {
- LOG(("%s:IDE completed PIO read\n", machine().describe_context()));
- read_buffer_empty();
- }
-
- return result;
-}
-
-void ata_hle_device::write_data(UINT16 data)
-{
- /* store the correct amount of data */
- m_buffer[m_buffer_offset++] = data;
- if (!m_8bit_data_transfers)
- m_buffer[m_buffer_offset++] = data >> 8;
-
- /* if we're at the end of the buffer, handle it */
- if (m_buffer_offset >= m_buffer_size)
- {
- LOG(("%s:IDE completed PIO write\n", machine().describe_context()));
- write_buffer_full();
- }
-}
-
-void ata_hle_device::update_irq()
-{
- if (device_selected() && (m_device_control & IDE_DEVICE_CONTROL_NIEN) == 0)
- m_irq_handler(m_irq);
- else
- m_irq_handler(CLEAR_LINE);
-}
-
-void ata_hle_device::set_irq(int state)
-{
- if (m_irq != state)
- {
- m_irq = state;
-
- update_irq();
- }
-}
-
-void ata_hle_device::set_dmarq(int state)
-{
- if (m_dmarq != state)
- {
- m_dmarq = state;
-
- m_dmarq_handler(state);
- }
-}
-
-void ata_hle_device::set_dasp(int state)
-{
- if (m_daspout != state)
- {
- m_daspout = state;
-
- m_dasp_handler(state);
- }
-}
-
-void ata_hle_device::set_pdiag(int state)
-{
- if (m_pdiagout != state)
- {
- m_pdiagout = state;
-
- m_pdiag_handler(state);
- }
-}
-
-void ata_hle_device::start_busy(const attotime &time, int param)
-{
- m_status |= IDE_STATUS_BSY;
- m_busy_timer->adjust(time, param);
-}
-
-void ata_hle_device::stop_busy()
-{
- m_status &= ~IDE_STATUS_BSY;
- m_busy_timer->adjust(attotime::never);
-}
-
-void ata_hle_device::read_buffer_empty()
-{
- m_buffer_offset = 0;
-
- m_status &= ~IDE_STATUS_DRQ;
-
- if (multi_word_dma_mode() >= 0)
- set_dmarq(CLEAR_LINE);
-
- fill_buffer();
-}
-
-void ata_hle_device::write_buffer_full()
-{
- m_buffer_offset = 0;
-
- m_status &= ~IDE_STATUS_DRQ;
-
- if (multi_word_dma_mode() >= 0)
- set_dmarq(CLEAR_LINE);
-
- process_buffer();
-}
-
-void ata_hle_device::start_diagnostic()
-{
- m_error = IDE_ERROR_DIAGNOSTIC_FAILED;
-
- perform_diagnostic();
-
- if (m_csel == 1 && m_error == IDE_ERROR_DIAGNOSTIC_PASSED)
- set_pdiag(ASSERT_LINE);
-
- if (m_csel == 0 && !m_single_device && m_pdiagin == CLEAR_LINE)
- start_busy(DEVICE1_PDIAG_TIME, PARAM_WAIT_FOR_PDIAG);
- else
- finished_diagnostic();
-}
-
-void ata_hle_device::finished_diagnostic()
-{
- m_resetting = false;
-
- signature();
-}
-
-
-WRITE_LINE_MEMBER( ata_hle_device::write_csel )
-{
- m_csel = state;
-}
-
-WRITE_LINE_MEMBER( ata_hle_device::write_dasp )
-{
- m_daspin = state;
-}
-
-WRITE_LINE_MEMBER( ata_hle_device::write_dmack )
-{
- if (state && !m_dmack && single_word_dma_mode() >= 0)
- set_dmarq(CLEAR_LINE);
-
- m_dmack = state;
-}
-
-WRITE_LINE_MEMBER( ata_hle_device::write_pdiag )
-{
- m_pdiagin = state;
-
- if (m_pdiagin == ASSERT_LINE && m_busy_timer->param() == PARAM_WAIT_FOR_PDIAG)
- {
- stop_busy();
- finished_diagnostic();
- }
-}
-
-UINT16 ata_hle_device::read_dma()
-{
- UINT16 result = 0xffff;
-
- if (device_selected())
- {
- if (!m_dmack)
- {
- logerror( "%s: %s dev %d read_dma ignored (!DMACK)\n", machine().describe_context(), tag(), dev() );
- }
- else if (m_dmarq && single_word_dma_mode() >= 0)
- {
- logerror( "%s: %s dev %d read_dma ignored (DMARQ)\n", machine().describe_context(), tag(), dev() );
- }
- else if (!m_dmarq && multi_word_dma_mode() >= 0)
- {
- logerror( "%s: %s dev %d read_dma ignored (!DMARQ)\n", machine().describe_context(), tag(), dev() );
- }
- else if (m_status & IDE_STATUS_BSY)
- {
- logerror( "%s: %s dev %d read_dma ignored (BSY)\n", machine().describe_context(), tag(), dev() );
- }
- else if (!(m_status & IDE_STATUS_DRQ))
- {
- logerror( "%s: %s dev %d read_dma ignored (!DRQ)\n", machine().describe_context(), tag(), dev() );
- }
- else
- {
- result = read_data();
-
- if ((m_status & IDE_STATUS_DRQ) && single_word_dma_mode() >= 0)
- set_dmarq(ASSERT_LINE);
- }
- }
-
- return result;
-}
-
-READ16_MEMBER( ata_hle_device::read_cs0 )
-{
- /* logit */
-// if (offset != IDE_CS0_DATA_RW && offset != IDE_CS0_STATUS_R)
- LOG(("%s:IDE cs0 read at %X, mem_mask=%d\n", machine().describe_context(), offset, mem_mask));
-
- UINT16 result = 0xffff;
-
- if (device_selected() || m_single_device)
- {
- if (m_dmack)
- {
- logerror( "%s: %s dev %d read_cs0 %04x %04x ignored (DMACK)\n", machine().describe_context(), tag(), dev(), offset, mem_mask );
- }
- else if ((m_status & IDE_STATUS_BSY) && offset != IDE_CS0_STATUS_R)
- {
- // ATA5 spec says status reads should also go through here, but this breaks Primal Rage 2.
- // Real hardware might work due to read ahead in the vt83c461.
- if (device_selected())
- {
- switch (offset)
- {
- case IDE_CS0_DATA_RW:
- logerror( "%s: %s dev %d read_cs0 %04x %04x ignored (BSY)\n", machine().describe_context(), tag(), dev(), offset, mem_mask );
- break;
-
- default:
- result = calculate_status();
- break;
- }
- }
- else
- {
- result = 0;
- }
- }
- else
- {
- switch (offset)
- {
- /* read data if there's data to be read */
- case IDE_CS0_DATA_RW:
- if (device_selected())
- {
- if (!(m_status & IDE_STATUS_DRQ))
- {
- logerror( "%s: %s dev %d read_cs0 ignored (!DRQ)\n", machine().describe_context(), tag(), dev() );
- }
- else
- {
- result = read_data();
- }
- }
- else
- {
- result = 0;
- }
- break;
-
- /* return the current error */
- case IDE_CS0_ERROR_R:
- result = m_error;
- break;
-
- /* return the current sector count */
- case IDE_CS0_SECTOR_COUNT_RW:
- result = m_sector_count;
- break;
-
- /* return the current sector */
- case IDE_CS0_SECTOR_NUMBER_RW:
- result = m_sector_number;
- break;
-
- /* return the current cylinder LSB */
- case IDE_CS0_CYLINDER_LOW_RW:
- result = m_cylinder_low;
- break;
-
- /* return the current cylinder MSB */
- case IDE_CS0_CYLINDER_HIGH_RW:
- result = m_cylinder_high;
- break;
-
- /* return the current head */
- case IDE_CS0_DEVICE_HEAD_RW:
- result = m_device_head;
- break;
-
- /* return the current status and clear any pending interrupts */
- case IDE_CS0_STATUS_R:
- if (device_selected())
- {
- result = calculate_status();
-
- if (!(m_status & IDE_STATUS_DRDY) && is_ready())
- m_status |= IDE_STATUS_DRDY;
-
- set_irq(CLEAR_LINE);
- }
- else
- {
- result = 0;
- }
- break;
-
- /* log anything else */
- default:
- logerror("%s:unknown IDE cs0 read at %03X, mem_mask=%d\n", machine().describe_context(), offset, mem_mask);
- break;
- }
- }
- }
-
- /* return the result */
- return result;
-}
-
-READ16_MEMBER( ata_hle_device::read_cs1 )
-{
- /* logit */
-// if (offset != IDE_CS1_ALTERNATE_STATUS_R)
- LOG(("%s:IDE cs1 read at %X, mem_mask=%d\n", machine().describe_context(), offset, mem_mask));
-
- UINT16 result = 0xffff;
-
- if (device_selected() || m_single_device)
- {
- if (m_dmack)
- {
- logerror( "%s: %s dev %d read_cs1 %04x %04x ignored (DMACK)\n", machine().describe_context(), tag(), dev(), offset, mem_mask );
- }
- else
- {
- switch (offset)
- {
- case IDE_CS1_ALTERNATE_STATUS_R:
- if (device_selected())
- {
- result = calculate_status();
- }
- else
- {
- result = 0;
- }
- break;
-
- case IDE_CS1_ACTIVE_STATUS:
- /*
-
- bit description
-
- 0 master active
- 1 slave active
- 2 complement of active disk head bit 0
- 3 complement of active disk head bit 1
- 4 complement of active disk head bit 2
- 5 complement of active disk head bit 3
- 6 write in progress
- 7 floppy present (unused)
-
- */
- if (device_selected())
- {
- result = 0x01;
- }
- else
- {
- result = 0;
- }
- break;
-
- /* log anything else */
- default:
- logerror("%s:unknown IDE cs1 read at %03X, mem_mask=%d\n", machine().describe_context(), offset, mem_mask);
- break;
- }
- }
- }
-
- /* return the result */
- return result;
-}
-
-void ata_hle_device::write_dma( UINT16 data )
-{
- if (device_selected())
- {
- if (!m_dmack)
- {
- logerror( "%s: %s dev %d write_dma %04x ignored (!DMACK)\n", machine().describe_context(), tag(), dev(), data );
- }
- else if (m_dmarq && single_word_dma_mode() >= 0)
- {
- logerror( "%s: %s dev %d write_dma %04x ignored (DMARQ)\n", machine().describe_context(), tag(), dev(), data );
- }
- else if (!m_dmarq && multi_word_dma_mode() >= 0)
- {
- logerror( "%s: %s dev %d write_dma %04x ignored (!DMARQ)\n", machine().describe_context(), tag(), dev(), data );
- }
- else if (m_status & IDE_STATUS_BSY)
- {
- logerror( "%s: %s dev %d write_dma %04x ignored (BSY)\n", machine().describe_context(), tag(), dev(), data );
- }
- else if (!(m_status & IDE_STATUS_DRQ))
- {
- logerror( "%s: %s dev %d write_dma %04x ignored (!DRQ)\n", machine().describe_context(), tag(), dev(), data );
- }
- else
- {
- write_data(data);
-
- if ((m_status & IDE_STATUS_DRQ) && single_word_dma_mode() >= 0)
- set_dmarq(ASSERT_LINE);
- }
- }
-}
-
-WRITE16_MEMBER( ata_hle_device::write_cs0 )
-{
- /* logit */
- if (offset != IDE_CS0_DATA_RW)
- LOG(("%s:IDE cs0 write to %X = %08X, mem_mask=%d\n", machine().describe_context(), offset, data, mem_mask));
- // fprintf(stderr, "ide write %03x %02x mem_mask=%d\n", offset, data, size);
-
- if (m_dmack)
- {
- logerror( "%s: %s dev %d write_cs0 %04x %04x %04x ignored (DMACK)\n", machine().describe_context(), tag(), dev(), offset, data, mem_mask );
- }
- else if ((m_status & IDE_STATUS_BSY) && offset != IDE_CS0_COMMAND_W)
- {
- logerror( "%s: %s dev %d write_cs0 %04x %04x %04x ignored (BSY) command %02x\n", machine().describe_context(), tag(), dev(), offset, data, mem_mask, m_command );
- }
- else if ((m_status & IDE_STATUS_DRQ) && offset != IDE_CS0_DATA_RW && offset != IDE_CS0_COMMAND_W)
- {
- logerror( "%s: %s dev %d write_cs0 %04x %04x %04x ignored (DRQ) command %02x\n", machine().describe_context(), tag(), dev(), offset, data, mem_mask, m_command );
- }
- else
- {
- UINT8 old;
-
- switch (offset)
- {
- /* write data */
- case IDE_CS0_DATA_RW:
- if (device_selected())
- {
- if (!(m_status & IDE_STATUS_DRQ))
- {
- logerror( "%s: %s dev %d write_cs0 %04x %04x %04x ignored (!DRQ)\n", machine().describe_context(), tag(), dev(), offset, data, mem_mask );
- }
- else
- {
- write_data(data);
- }
- }
- break;
-
- case IDE_CS0_FEATURE_W:
- m_feature = data;
- break;
-
- /* sector count */
- case IDE_CS0_SECTOR_COUNT_RW:
- m_sector_count = data ? data : 256;
- break;
-
- /* current sector */
- case IDE_CS0_SECTOR_NUMBER_RW:
- m_sector_number = data;
- break;
-
- /* current cylinder LSB */
- case IDE_CS0_CYLINDER_LOW_RW:
- m_cylinder_low = data;
- break;
-
- /* current cylinder MSB */
- case IDE_CS0_CYLINDER_HIGH_RW:
- m_cylinder_high = data;
- break;
-
- /* current head */
- case IDE_CS0_DEVICE_HEAD_RW:
- old = m_device_head;
- m_device_head = data;
-
- if ((m_device_head ^ old) & IDE_DEVICE_HEAD_DRV)
- update_irq();
- break;
-
- /* command */
- case IDE_CS0_COMMAND_W:
- // Packet devices can accept DEVICE RESET when BSY or DRQ is set.
- if (m_status & IDE_STATUS_BSY)
- {
- logerror( "%s: %s dev %d write_cs0 %04x %04x %04x ignored (BSY) command %02x\n", machine().describe_context(), tag(), dev(), offset, data, mem_mask, m_command );
- }
- else if (m_status & IDE_STATUS_DRQ)
- {
- logerror( "%s: %s dev %d write_cs0 %04x %04x %04x ignored (DRQ) command %02x\n", machine().describe_context(), tag(), dev(), offset, data, mem_mask, m_command );
- }
- else if (device_selected() || m_command == IDE_COMMAND_DIAGNOSTIC)
- {
- m_command = data;
-
- /* implicitly clear interrupts & dmarq here */
- set_irq(CLEAR_LINE);
- set_dmarq(CLEAR_LINE);
-
- m_buffer_offset = 0;
-
- set_dasp(CLEAR_LINE);
- m_status &= ~IDE_STATUS_DRQ;
- m_status &= ~IDE_STATUS_ERR;
-
- process_command();
- }
- break;
-
- default:
- logerror("%s:unknown IDE cs0 write at %03X = %04x, mem_mask=%d\n", machine().describe_context(), offset, data, mem_mask);
- break;
- }
- }
-}
-
-WRITE16_MEMBER( ata_hle_device::write_cs1 )
-{
- /* logit */
- LOG(("%s:IDE cs1 write to %X = %08X, mem_mask=%d\n", machine().describe_context(), offset, data, mem_mask));
-
- if (m_dmack)
- {
- logerror( "%s: %s dev %d write_cs1 %04x %04x %04x ignored (DMACK)\n", machine().describe_context(), tag(), dev(), offset, data, mem_mask );
- }
- else
- {
- UINT8 old;
-
- switch (offset)
- {
- /* adapter control */
- case IDE_CS1_DEVICE_CONTROL_W:
- old = m_device_control;
- m_device_control = data;
-
- if ((m_device_control ^ old) & IDE_DEVICE_CONTROL_NIEN)
- update_irq();
-
- if ((m_device_control ^ old) & IDE_DEVICE_CONTROL_SRST)
- {
- if (m_device_control & IDE_DEVICE_CONTROL_SRST)
- {
- if (m_resetting)
- {
- logerror( "%s: %s dev %d write_cs1 %04x %04x %04x ignored (RESET)\n", machine().describe_context(), tag(), dev(), offset, data, mem_mask );
- }
- else
- {
- set_dasp(CLEAR_LINE);
- set_dmarq(CLEAR_LINE);
- set_irq(CLEAR_LINE);
- set_pdiag(CLEAR_LINE);
-
- start_busy(attotime::never, PARAM_RESET);
- }
- }
- else if (m_busy_timer->param() == PARAM_RESET)
- {
- soft_reset();
- }
- }
- break;
-
- default:
- logerror("%s:unknown IDE cs1 write at %03X = %04x, mem_mask=%d\n", machine().describe_context(), offset, data, mem_mask);
- break;
- }
- }
-}
diff --git a/src/emu/machine/atahle.h b/src/emu/machine/atahle.h
deleted file mode 100644
index 30236e62d49..00000000000
--- a/src/emu/machine/atahle.h
+++ /dev/null
@@ -1,218 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- atahle.h
-
- ATA Device HLE
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __ATAHLE_H__
-#define __ATAHLE_H__
-
-#include "atadev.h"
-
-class ata_hle_device : public device_t,
- public ata_device_interface,
- public device_slot_card_interface
-{
-public:
- ata_hle_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock,const char *shortname, const char *source);
-
- virtual UINT16 read_dma();
- virtual DECLARE_READ16_MEMBER(read_cs0);
- virtual DECLARE_READ16_MEMBER(read_cs1);
-
- virtual void write_dma(UINT16 data);
- virtual DECLARE_WRITE16_MEMBER(write_cs0);
- virtual DECLARE_WRITE16_MEMBER(write_cs1);
- virtual DECLARE_WRITE_LINE_MEMBER(write_csel);
- virtual DECLARE_WRITE_LINE_MEMBER(write_dasp);
- virtual DECLARE_WRITE_LINE_MEMBER(write_dmack);
- virtual DECLARE_WRITE_LINE_MEMBER(write_pdiag);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- void set_irq(int state);
- void set_dmarq(int state);
- void set_dasp(int state);
- void set_pdiag(int state);
-
- void start_busy(const attotime &time, int param);
- void stop_busy();
-
- int dev() { return (m_device_head & IDE_DEVICE_HEAD_DRV) >> 4; }
- bool device_selected() { return m_csel == dev(); }
-
- virtual UINT8 calculate_status() { return m_status; }
- virtual void soft_reset();
- virtual void process_command();
- virtual void finished_command();
- virtual bool set_features();
- virtual int sector_length() = 0;
- virtual void process_buffer() = 0;
- virtual void fill_buffer() = 0;
- virtual bool is_ready() = 0;
- virtual void perform_diagnostic() = 0;
- virtual void signature() = 0;
- virtual UINT16 read_data();
- virtual void write_data(UINT16 data);
-
- int bit_to_mode(UINT16 word);
- int single_word_dma_mode();
- int multi_word_dma_mode();
- int ultra_dma_mode();
-
- /// TODO: not sure this should be protected.
- void read_buffer_empty();
-
- enum
- {
- IDE_STATUS_ERR = 0x01, // Error
- IDE_STATUS_IDX = 0x02, // Index
- IDE_STATUS_CORR = 0x04, // Corrected Data
- IDE_STATUS_DRQ = 0x08, // Data Request
- IDE_STATUS_DSC = 0x10, // ATA Drive Seek Complete
- IDE_STATUS_SERV = 0x10, // ATAPI Service
- IDE_STATUS_DWF = 0x20, // ATA Drive Write Fault
- IDE_STATUS_DMRD = 0x20, // ATAPI DMA Ready
- IDE_STATUS_DRDY = 0x40, // Drive Ready
- IDE_STATUS_BSY = 0x80 // Busy
- };
-
- enum
- {
- IDE_ERROR_NONE = 0x00,
- IDE_ERROR_DIAGNOSTIC_OK = 0x01,
- IDE_ERROR_TRACK0_NOT_FOUND = 0x02,
- IDE_ERROR_ABRT = 0x04,
- IDE_ERROR_BAD_LOCATION = 0x10,
- IDE_ERROR_BAD_SECTOR = 0x80,
- IDE_ERROR_DIAGNOSTIC_FAILED = 0x00,
- IDE_ERROR_DIAGNOSTIC_PASSED = 0x01,
- IDE_ERROR_DIAGNOSTIC_DEVICE1_FAILED = 0x80
- };
-
- enum
- {
- IDE_COMMAND_NOP = 0x00,
- IDE_COMMAND_DEVICE_RESET = 0x08,
- IDE_COMMAND_RECALIBRATE = 0x10,
- IDE_COMMAND_READ_SECTORS = 0x20,
- IDE_COMMAND_READ_SECTORS_NORETRY = 0x21,
- IDE_COMMAND_WRITE_SECTORS = 0x30,
- IDE_COMMAND_WRITE_SECTORS_NORETRY = 0x31,
- IDE_COMMAND_VERIFY_SECTORS = 0x40,
- IDE_COMMAND_VERIFY_SECTORS_NORETRY = 0x41,
- IDE_COMMAND_SEEK = 0x70,
- IDE_COMMAND_DIAGNOSTIC = 0x90,
- IDE_COMMAND_SET_CONFIG = 0x91,
- IDE_COMMAND_PACKET = 0xa0,
- IDE_COMMAND_IDENTIFY_PACKET_DEVICE = 0xa1,
- IDE_COMMAND_READ_MULTIPLE = 0xc4,
- IDE_COMMAND_WRITE_MULTIPLE = 0xc5,
- IDE_COMMAND_SET_BLOCK_COUNT = 0xc6,
- IDE_COMMAND_READ_DMA = 0xc8,
- IDE_COMMAND_WRITE_DMA = 0xca,
- IDE_COMMAND_IDLE_IMMEDIATE = 0xe1,
- IDE_COMMAND_IDLE = 0xe3,
- IDE_COMMAND_CHECK_POWER_MODE = 0xe5,
- IDE_COMMAND_CACHE_FLUSH = 0xe7,
- IDE_COMMAND_IDENTIFY_DEVICE = 0xec,
- IDE_COMMAND_SET_FEATURES = 0xef,
- IDE_COMMAND_SECURITY_UNLOCK = 0xf2,
- IDE_COMMAND_READ_NATIVE_MAX_ADDRESS = 0xf8,
- IDE_COMMAND_SET_MAX = 0xf9
- };
-
- enum
- {
- IDE_SET_FEATURES_ENABLE_8BIT_DATA_TRANSFERS = 0x01,
- IDE_SET_FEATURES_TRANSFER_MODE = 0x03,
- IDE_SET_FEATURES_DISABLE_REVERTING_TO_POWER_ON_DEFAULTS = 0x66,
- IDE_SET_FEATURES_DISABLE_8BIT_DATA_TRANSFERS = 0x81,
- IDE_SET_FEATURES_ENABLE_REVERTING_TO_POWER_ON_DEFAULTS = 0xcc
- };
-
- enum ide_transfer_type_t
- {
- IDE_TRANSFER_TYPE_PIO_DEFAULT = 0x00,
- IDE_TRANSFER_TYPE_PIO_FLOW_CONTROL = 0x08,
- IDE_TRANSFER_TYPE_SINGLE_WORD_DMA = 0x10,
- IDE_TRANSFER_TYPE_MULTI_WORD_DMA = 0x20,
- IDE_TRANSFER_TYPE_ULTRA_DMA = 0x40,
- IDE_TRANSFER_TYPE_MASK = 0xf8
- };
-
- enum
- {
- IDE_DEVICE_HEAD_HS = 0x0f,
- IDE_DEVICE_HEAD_DRV = 0x10,
- IDE_DEVICE_HEAD_L = 0x40,
- IDE_DEVICE_HEAD_OBSOLETE = 0x80 | 0x20
- };
-
- enum
- {
- TID_BUSY
- };
-
- enum
- {
- PARAM_RESET,
- PARAM_DETECT_DEVICE1,
- PARAM_DIAGNOSTIC,
- PARAM_WAIT_FOR_PDIAG,
- PARAM_COMMAND
- };
-
- attotime MINIMUM_COMMAND_TIME;
-
- dynamic_buffer m_buffer;
- UINT16 m_buffer_offset;
- UINT16 m_buffer_size;
- UINT8 m_error;
- UINT8 m_feature;
- UINT16 m_sector_count;
- UINT8 m_sector_number;
- UINT8 m_cylinder_low;
- UINT8 m_cylinder_high;
- UINT8 m_device_head;
- UINT8 m_status;
- UINT8 m_command;
- UINT8 m_device_control;
-
- UINT16 m_identify_buffer[256];
- bool m_revert_to_defaults;
- bool m_8bit_data_transfers;
-
-private:
- void update_irq();
- void write_buffer_full();
- void start_diagnostic();
- void finished_diagnostic();
- void finished_busy(int param);
- bool set_dma_mode(int word);
-
- int m_csel;
- int m_daspin;
- int m_daspout;
- int m_dmack;
- int m_dmarq;
- int m_irq;
- int m_pdiagin;
- int m_pdiagout;
-
- bool m_single_device;
- bool m_resetting;
-
- emu_timer *m_busy_timer;
-};
-
-#endif
diff --git a/src/emu/machine/ataintf.c b/src/emu/machine/ataintf.c
deleted file mode 100644
index 56c2031bd56..00000000000
--- a/src/emu/machine/ataintf.c
+++ /dev/null
@@ -1,323 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- ataintf.c
-
- ATA Interface implementation.
-
-***************************************************************************/
-
-#include "emu.h"
-#include "ataintf.h"
-#include "debugger.h"
-#include "idehd.h"
-#include "atapicdr.h"
-
-void ata_interface_device::set_irq(int state)
-{
-// printf( "%s: irq %d\n", machine().describe_context(), state );
-
- m_irq_handler(state);
-}
-
-void ata_interface_device::set_dmarq(int state)
-{
-// printf( "%s: dmarq %d\n", machine().describe_context(), state );
-
- m_dmarq_handler(state);
-}
-
-void ata_interface_device::set_dasp(int state)
-{
-// printf( "%s: dasp %d\n", machine().describe_context(), state );
-
- m_dasp_handler(state);
-}
-
-WRITE_LINE_MEMBER( ata_interface_device::irq0_write_line )
-{
- if (m_irq[0] != state)
- {
- m_irq[0] = state;
-
- set_irq(m_irq[0] == ASSERT_LINE || m_irq[1] == ASSERT_LINE);
- }
-}
-
-WRITE_LINE_MEMBER( ata_interface_device::irq1_write_line )
-{
- if (m_irq[1] != state)
- {
- m_irq[1] = state;
-
- set_irq(m_irq[0] == ASSERT_LINE || m_irq[1] == ASSERT_LINE);
- }
-}
-
-WRITE_LINE_MEMBER( ata_interface_device::dasp0_write_line )
-{
- if (m_dasp[0] != state)
- {
- m_dasp[0] = state;
-
- set_dasp(m_dasp[0] == ASSERT_LINE || m_dasp[1] == ASSERT_LINE);
- }
-}
-
-WRITE_LINE_MEMBER( ata_interface_device::dasp1_write_line )
-{
- if (m_dasp[1] != state)
- {
- m_dasp[1] = state;
-
- ata_device_interface *dev = m_slot[0]->dev();
- if (dev != NULL)
- dev->write_dasp(state);
-
- set_dasp(m_dasp[0] == ASSERT_LINE || m_dasp[1] == ASSERT_LINE);
- }
-}
-
-WRITE_LINE_MEMBER( ata_interface_device::dmarq0_write_line )
-{
- if (m_dmarq[0] != state)
- {
- m_dmarq[0] = state;
-
- set_dmarq(m_dmarq[0] == ASSERT_LINE || m_dmarq[1] == ASSERT_LINE);
- }
-}
-
-WRITE_LINE_MEMBER( ata_interface_device::dmarq1_write_line )
-{
- if (m_dmarq[1] != state)
- {
- m_dmarq[1] = state;
-
- set_dmarq(m_dmarq[0] == ASSERT_LINE || m_dmarq[1] == ASSERT_LINE);
- }
-}
-
-WRITE_LINE_MEMBER( ata_interface_device::pdiag0_write_line )
-{
- m_pdiag[0] = state;
-}
-
-WRITE_LINE_MEMBER( ata_interface_device::pdiag1_write_line )
-{
- if (m_pdiag[1] != state)
- {
- m_pdiag[1] = state;
-
- ata_device_interface *dev = m_slot[0]->dev();
- if (dev != NULL)
- dev->write_pdiag(state);
- }
-}
-
-/*************************************
- *
- * ATA interface read
- *
- *************************************/
-
-UINT16 ata_interface_device::read_dma()
-{
- UINT16 result = 0xffff;
- for (int i = 0; i < 2; i++)
- if (m_slot[i]->dev() != NULL)
- result &= m_slot[i]->dev()->read_dma();
-
-// printf( "%s: read_dma %04x\n", machine().describe_context(), result );
- return result;
-}
-
-READ16_MEMBER( ata_interface_device::read_cs0 )
-{
- UINT16 result = mem_mask;
- for (int i = 0; i < 2; i++)
- if (m_slot[i]->dev() != NULL)
- result &= m_slot[i]->dev()->read_cs0(space, offset, mem_mask);
-
-// { static int last_status = -1; if (offset == 7 ) { if( result == last_status ) return last_status; last_status = result; } else last_status = -1; }
-
-// printf( "%s: read cs0 %04x %04x %04x\n", machine().describe_context(), offset, result, mem_mask );
-
- return result;
-}
-
-READ16_MEMBER( ata_interface_device::read_cs1 )
-{
- UINT16 result = mem_mask;
- for (int i = 0; i < 2; i++)
- if (m_slot[i]->dev() != NULL)
- result &= m_slot[i]->dev()->read_cs1(space, offset, mem_mask);
-
-// printf( "%s: read cs1 %04x %04x %04x\n", machine().describe_context(), offset, result, mem_mask );
-
- return result;
-}
-
-
-/*************************************
- *
- * ATA interface write
- *
- *************************************/
-
-void ata_interface_device::write_dma( UINT16 data )
-{
-// printf( "%s: write_dma %04x\n", machine().describe_context(), data );
-
- for (int i = 0; i < 2; i++)
- if (m_slot[i]->dev() != NULL)
- m_slot[i]->dev()->write_dma(data);
-}
-
-WRITE16_MEMBER( ata_interface_device::write_cs0 )
-{
-// printf( "%s: write cs0 %04x %04x %04x\n", machine().describe_context(), offset, data, mem_mask );
-
- for (int i = 0; i < 2; i++)
- if (m_slot[i]->dev() != NULL)
- m_slot[i]->dev()->write_cs0(space, offset, data, mem_mask);
-}
-
-WRITE16_MEMBER( ata_interface_device::write_cs1 )
-{
-// printf( "%s: write cs1 %04x %04x %04x\n", machine().describe_context(), offset, data, mem_mask );
-
- for (int i = 0; i < 2; i++)
- if (m_slot[i]->dev() != NULL)
- m_slot[i]->dev()->write_cs1(space, offset, data, mem_mask);
-}
-
-WRITE_LINE_MEMBER( ata_interface_device::write_dmack )
-{
-// printf( "%s: write_dmack %04x\n", machine().describe_context(), state );
-
- for (int i = 0; i < 2; i++)
- if (m_slot[i]->dev() != NULL)
- m_slot[i]->dev()->write_dmack(state);
-}
-
-SLOT_INTERFACE_START(ata_devices)
- SLOT_INTERFACE("hdd", IDE_HARDDISK)
- SLOT_INTERFACE("cdrom", ATAPI_CDROM)
-SLOT_INTERFACE_END
-
-ata_interface_device::ata_interface_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_irq_handler(*this),
- m_dmarq_handler(*this),
- m_dasp_handler(*this){
-}
-
-
-const device_type ATA_INTERFACE = &device_creator<ata_interface_device>;
-
-ata_interface_device::ata_interface_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, ATA_INTERFACE, "ATA Interface", tag, owner, clock, "ata_interface", __FILE__),
- m_irq_handler(*this),
- m_dmarq_handler(*this),
- m_dasp_handler(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ata_interface_device::device_start()
-{
- m_irq_handler.resolve_safe();
- m_dmarq_handler.resolve_safe();
- m_dasp_handler.resolve_safe();
-
- /* set MAME harddisk handle */
- m_slot[0] = subdevice<ata_slot_device>("0");
- m_slot[1] = subdevice<ata_slot_device>("1");
-
- for (int i = 0; i < 2; i++)
- {
- m_irq[i] = 0;
- m_dmarq[i] = 0;
- m_dasp[i] = 0;
- m_pdiag[i] = 0;
-
- ata_device_interface *dev = m_slot[i]->dev();
- if (dev != NULL)
- {
- if (i == 0)
- {
- dev->m_irq_handler.set_callback(DEVCB_DEVWRITELINE("^", ata_interface_device, irq0_write_line));
- dev->m_dmarq_handler.set_callback(DEVCB_DEVWRITELINE("^", ata_interface_device, dmarq0_write_line));
- dev->m_dasp_handler.set_callback(DEVCB_DEVWRITELINE("^", ata_interface_device, dasp0_write_line));
- dev->m_pdiag_handler.set_callback(DEVCB_DEVWRITELINE("^", ata_interface_device, pdiag0_write_line));
- }
- else
- {
- dev->m_irq_handler.set_callback(DEVCB_DEVWRITELINE("^", ata_interface_device, irq1_write_line));
- dev->m_dmarq_handler.set_callback(DEVCB_DEVWRITELINE("^", ata_interface_device, dmarq1_write_line));
- dev->m_dasp_handler.set_callback(DEVCB_DEVWRITELINE("^", ata_interface_device, dasp1_write_line));
- dev->m_pdiag_handler.set_callback(DEVCB_DEVWRITELINE("^", ata_interface_device, pdiag1_write_line));
- }
-
- dev->write_csel(i);
- }
- }
-}
-
-static MACHINE_CONFIG_FRAGMENT( ata_interface )
- MCFG_DEVICE_ADD( "0", ATA_SLOT, 0 )
- MCFG_DEVICE_ADD( "1", ATA_SLOT, 0 )
-MACHINE_CONFIG_END
-
-//-------------------------------------------------
-// machine_config_additions - return a pointer to
-// the device's machine fragment
-//-------------------------------------------------
-
-machine_config_constructor ata_interface_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( ata_interface );
-}
-
-
-//**************************************************************************
-// ATA SLOT DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type ATA_SLOT = &device_creator<ata_slot_device>;
-
-//-------------------------------------------------
-// ata_slot_device - constructor
-//-------------------------------------------------
-
-ata_slot_device::ata_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, ATA_SLOT, "ATA Connector", tag, owner, clock, "ata_slot", __FILE__),
- device_slot_interface(mconfig, *this),
- m_dev(NULL)
-{
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void ata_slot_device::device_config_complete()
-{
- m_dev = dynamic_cast<ata_device_interface *>(get_card_device());
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ata_slot_device::device_start()
-{
-}
diff --git a/src/emu/machine/ataintf.h b/src/emu/machine/ataintf.h
deleted file mode 100644
index 01ee67e159f..00000000000
--- a/src/emu/machine/ataintf.h
+++ /dev/null
@@ -1,129 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- ataintf.h
-
- ATA Interface implementation.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __ATAINTF_H__
-#define __ATAINTF_H__
-
-#include "atadev.h"
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-// ======================> ata_slot_device
-
-class ata_slot_device : public device_t,
- public device_slot_interface
-{
-public:
- // construction/destruction
- ata_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- ata_device_interface *dev() { return m_dev; }
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_config_complete();
-
-private:
- ata_device_interface *m_dev;
-};
-
-// device type definition
-extern const device_type ATA_SLOT;
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-#define MCFG_ATA_INTERFACE_IRQ_HANDLER(_devcb) \
- devcb = &ata_interface_device::set_irq_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_ATA_INTERFACE_DMARQ_HANDLER(_devcb) \
- devcb = &ata_interface_device::set_dmarq_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_ATA_INTERFACE_DASP_HANDLER(_devcb) \
- devcb = &ata_interface_device::set_dasp_handler(*device, DEVCB_##_devcb);
-
-SLOT_INTERFACE_EXTERN(ata_devices);
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_ATA_INTERFACE_ADD(_tag, _slot_intf, _master, _slave, _fixed) \
- MCFG_DEVICE_ADD(_tag, ATA_INTERFACE, 0) \
- MCFG_DEVICE_MODIFY(_tag ":0") \
- MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _master, _fixed) \
- MCFG_DEVICE_MODIFY(_tag ":1") \
- MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _slave, _fixed) \
- MCFG_DEVICE_MODIFY(_tag)
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-/* ----- device interface ----- */
-
-class ata_interface_device : public device_t
-{
-public:
- ata_interface_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ata_interface_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_irq_handler(device_t &device, _Object object) { return downcast<ata_interface_device &>(device).m_irq_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_dmarq_handler(device_t &device, _Object object) { return downcast<ata_interface_device &>(device).m_dmarq_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_dasp_handler(device_t &device, _Object object) { return downcast<ata_interface_device &>(device).m_dasp_handler.set_callback(object); }
- UINT16 read_dma();
- virtual DECLARE_READ16_MEMBER(read_cs0);
- virtual DECLARE_READ16_MEMBER(read_cs1);
-
- void write_dma(UINT16 data);
- virtual DECLARE_WRITE16_MEMBER(write_cs0);
- virtual DECLARE_WRITE16_MEMBER(write_cs1);
- DECLARE_WRITE_LINE_MEMBER(write_dmack);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual machine_config_constructor device_mconfig_additions() const;
-
- virtual void set_irq(int state);
- virtual void set_dmarq(int state);
- virtual void set_dasp(int state);
-
-private:
- DECLARE_WRITE_LINE_MEMBER(irq0_write_line);
- DECLARE_WRITE_LINE_MEMBER(dmarq0_write_line);
- DECLARE_WRITE_LINE_MEMBER(dasp0_write_line);
- DECLARE_WRITE_LINE_MEMBER(pdiag0_write_line);
-
- DECLARE_WRITE_LINE_MEMBER(irq1_write_line);
- DECLARE_WRITE_LINE_MEMBER(dmarq1_write_line);
- DECLARE_WRITE_LINE_MEMBER(dasp1_write_line);
- DECLARE_WRITE_LINE_MEMBER(pdiag1_write_line);
-
- ata_slot_device *m_slot[2];
- int m_irq[2];
- int m_dmarq[2];
- int m_dasp[2];
- int m_pdiag[2];
-
- devcb_write_line m_irq_handler;
- devcb_write_line m_dmarq_handler;
- devcb_write_line m_dasp_handler;
-};
-
-extern const device_type ATA_INTERFACE;
-
-#endif /* __ATAINTF_H__ */
diff --git a/src/emu/machine/atapicdr.c b/src/emu/machine/atapicdr.c
deleted file mode 100644
index 1588f6d17cd..00000000000
--- a/src/emu/machine/atapicdr.c
+++ /dev/null
@@ -1,81 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "atapicdr.h"
-
-// device type definition
-const device_type ATAPI_CDROM = &device_creator<atapi_cdrom_device>;
-
-atapi_cdrom_device::atapi_cdrom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- atapi_hle_device(mconfig, ATAPI_CDROM, "ATAPI CDROM", tag, owner, clock, "cdrom", __FILE__)
-{
-}
-
-atapi_cdrom_device::atapi_cdrom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- atapi_hle_device(mconfig, type, name, tag, owner, clock, shortname, source)
-{
-}
-
-static MACHINE_CONFIG_FRAGMENT( atapicdr )
- MCFG_CDROM_ADD("image")
- MCFG_CDROM_INTERFACE("cdrom")
- MCFG_SOUND_ADD("cdda", CDDA, 0)
-MACHINE_CONFIG_END
-
-//-------------------------------------------------
-// machine_config_additions - device-specific
-// machine configurations
-//-------------------------------------------------
-
-machine_config_constructor atapi_cdrom_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( atapicdr );
-}
-
-void atapi_cdrom_device::device_start()
-{
- m_image = subdevice<cdrom_image_device>("image");
- m_cdda = subdevice<cdda_device>("cdda");
-
- memset(m_identify_buffer, 0, sizeof(m_identify_buffer));
-
- m_identify_buffer[ 0 ] = 0x8500; // ATAPI device, cmd set 5 compliant, DRQ within 3 ms of PACKET command
-
- m_identify_buffer[ 23 ] = ('1' << 8) | '.';
- m_identify_buffer[ 24 ] = ('0' << 8) | ' ';
- m_identify_buffer[ 25 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 26 ] = (' ' << 8) | ' ';
-
- m_identify_buffer[ 27 ] = ('M' << 8) | 'A';
- m_identify_buffer[ 28 ] = ('M' << 8) | 'E';
- m_identify_buffer[ 29 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 30 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 31 ] = ('V' << 8) | 'i';
- m_identify_buffer[ 32 ] = ('r' << 8) | 't';
- m_identify_buffer[ 33 ] = ('u' << 8) | 'a';
- m_identify_buffer[ 34 ] = ('l' << 8) | ' ';
- m_identify_buffer[ 35 ] = ('C' << 8) | 'D';
- m_identify_buffer[ 36 ] = ('R' << 8) | 'O';
- m_identify_buffer[ 37 ] = ('M' << 8) | ' ';
- m_identify_buffer[ 38 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 39 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 40 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 41 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 42 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 43 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 44 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 45 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 46 ] = (' ' << 8) | ' ';
-
- m_identify_buffer[ 49 ] = 0x0600; // Word 49=Capabilities, IORDY may be disabled (bit_10), LBA Supported mandatory (bit_9)
-
- atapi_hle_device::device_start();
-}
-
-void atapi_cdrom_device::perform_diagnostic()
-{
- m_error = IDE_ERROR_DIAGNOSTIC_PASSED;
-}
-
-void atapi_cdrom_device::identify_packet_device()
-{
-}
diff --git a/src/emu/machine/atapicdr.h b/src/emu/machine/atapicdr.h
deleted file mode 100644
index 535a5b801b1..00000000000
--- a/src/emu/machine/atapicdr.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- atapicdr.h
-
- ATAPI CDROM
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __ATAPICDR_H__
-#define __ATAPICDR_H__
-
-#include "atapihle.h"
-#include "t10mmc.h"
-
-class atapi_cdrom_device : public atapi_hle_device,
- public t10mmc
-{
-public:
- atapi_cdrom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- atapi_cdrom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock,const char *shortname, const char *source);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual machine_config_constructor device_mconfig_additions() const;
-
- virtual void perform_diagnostic();
- virtual void identify_packet_device();
-};
-
-// device type definition
-extern const device_type ATAPI_CDROM;
-
-#endif
diff --git a/src/emu/machine/atapihle.c b/src/emu/machine/atapihle.c
deleted file mode 100644
index dcbc00fb26c..00000000000
--- a/src/emu/machine/atapihle.c
+++ /dev/null
@@ -1,277 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "atapihle.h"
-
-atapi_hle_device::atapi_hle_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock,const char *shortname, const char *source)
- : ata_hle_device(mconfig, type, name, tag, owner, clock, shortname, source),
- m_packet(0),
- m_data_size(0)
-{
-}
-
-void atapi_hle_device::device_start()
-{
- t10_start(*this);
- ata_hle_device::device_start();
-}
-
-void atapi_hle_device::device_reset()
-{
- t10_reset();
- ata_hle_device::device_reset();
-}
-
-void atapi_hle_device::process_buffer()
-{
- if (m_packet)
- {
- //printf( "atapi command %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- // m_buffer[0],m_buffer[1],m_buffer[2],m_buffer[3],
- // m_buffer[4],m_buffer[5],m_buffer[6],m_buffer[7],
- // m_buffer[8],m_buffer[9],m_buffer[10],m_buffer[11]);
-
- m_error = 0; // HACK: This might not be the right place, but firebeat needs this cleared at some point
-
- SetCommand(&m_buffer[0], m_buffer_size);
- ExecCommand();
- GetLength(&m_data_size);
-
- if (m_status_code == SCSI_STATUS_CODE_CHECK_CONDITION)
- m_status |= IDE_STATUS_ERR;
-
- m_buffer_size = (m_cylinder_high << 8) | m_cylinder_low;
- if (m_buffer_size == 0xffff)
- m_buffer_size = 0xfffe;
-
- //printf("atapi result %08x %08x\n", m_data_size, m_buffer_size);
-
- if (m_buffer_size > ATAPI_BUFFER_LENGTH || m_buffer_size == 0)
- m_buffer_size = ATAPI_BUFFER_LENGTH;
-
- if (m_feature & ATAPI_FEATURES_FLAG_OVL)
- {
- printf( "ATAPI_FEATURES_FLAG_OVL not supported\n" );
- }
-
- switch (m_phase)
- {
- case SCSI_PHASE_DATAOUT:
- wait_buffer();
- break;
-
- case SCSI_PHASE_DATAIN:
- /// TODO: delay data
- fill_buffer();
- break;
-
- default:
- m_cylinder_low = 0;
- m_cylinder_high = 0;
- m_sector_count = ATAPI_INTERRUPT_REASON_IO | ATAPI_INTERRUPT_REASON_CD;
- set_irq(ASSERT_LINE);
- break;
- }
-
- m_packet = 0;
- }
- else
- {
- switch (m_command)
- {
- case IDE_COMMAND_PACKET:
- WriteData( &m_buffer[0], m_buffer_size );
- m_data_size -= m_buffer_size;
-
- wait_buffer();
- break;
- }
- }
-}
-
-void atapi_hle_device::fill_buffer()
-{
- switch (m_command)
- {
- case IDE_COMMAND_PACKET:
- if (m_buffer_size >= m_data_size)
- {
- m_buffer_size = m_data_size;
- }
- else if (m_buffer_size & 1)
- {
- m_buffer_size--;
- }
-
- m_cylinder_low = m_buffer_size & 0xff;
- m_cylinder_high = m_buffer_size >> 8;
-
- if (m_buffer_size > 0)
- {
- ReadData( &m_buffer[0], m_buffer_size );
- m_data_size -= m_buffer_size;
-
- m_status |= IDE_STATUS_DRQ;
- m_sector_count = ATAPI_INTERRUPT_REASON_IO;
-
- if (m_feature & ATAPI_FEATURES_FLAG_DMA)
- {
- set_dmarq(ASSERT_LINE);
- }
- else
- {
- set_irq(ASSERT_LINE);
- }
- }
- else
- {
- m_sector_count = ATAPI_INTERRUPT_REASON_IO | ATAPI_INTERRUPT_REASON_CD;
- set_irq(ASSERT_LINE);
- }
- break;
-
- case IDE_COMMAND_IDENTIFY_PACKET_DEVICE:
- m_cylinder_low = 0;
- m_cylinder_high = 0;
-
- m_sector_count = ATAPI_INTERRUPT_REASON_IO | ATAPI_INTERRUPT_REASON_CD;
- set_irq(ASSERT_LINE);
- break;
- }
-}
-
-void atapi_hle_device::wait_buffer()
-{
- if (m_buffer_size >= m_data_size)
- {
- m_buffer_size = m_data_size;
- }
- else if (m_buffer_size & 1)
- {
- m_buffer_size--;
- }
-
- m_cylinder_low = m_buffer_size & 0xff;
- m_cylinder_high = m_buffer_size >> 8;
-
- if (m_buffer_size > 0)
- {
- m_status |= IDE_STATUS_DRQ;
- m_sector_count = 0;
-
- if (m_feature & ATAPI_FEATURES_FLAG_DMA)
- {
- set_dmarq(ASSERT_LINE);
- }
- else
- {
- set_irq(ASSERT_LINE);
- }
- }
- else
- {
- m_sector_count = ATAPI_INTERRUPT_REASON_IO | ATAPI_INTERRUPT_REASON_CD;
- set_irq(ASSERT_LINE);
- }
-}
-
-void atapi_hle_device::signature()
-{
- // TODO: IDENTIFY DEVICE & READ SECTORS writes signature too.
- m_sector_count = 1;
- m_sector_number = 1;
- m_cylinder_low = 0x14;
- m_cylinder_high = 0xeb;
-
- m_device_head &= IDE_DEVICE_HEAD_DRV;
-}
-
-void atapi_hle_device::process_command()
-{
- m_packet = 0;
-
- switch (m_command)
- {
- case IDE_COMMAND_DEVICE_RESET:
- soft_reset();
- break;
-
- case IDE_COMMAND_PACKET:
- m_packet = 1;
-
- if (packet_command_length() == PACKET_COMMAND_LENGTH_16)
- {
- m_buffer_size = 16;
- }
- else
- {
- m_buffer_size = 12;
- }
-
- m_status |= IDE_STATUS_DRQ;
- m_sector_count = ATAPI_INTERRUPT_REASON_CD;
-
- if (packet_command_response() == PACKET_COMMAND_RESPONSE_INTRQ)
- {
- set_irq(ASSERT_LINE);
- }
- break;
-
- case IDE_COMMAND_IDENTIFY_PACKET_DEVICE:
- identify_packet_device();
-
- for( int w = 0; w < 256; w++ )
- {
- m_buffer[w * 2] = m_identify_buffer[ w ] & 0xff;
- m_buffer[(w * 2) + 1] = m_identify_buffer[ w ] >> 8;
- }
-
- m_buffer_size = 512;
-
- m_error = 0;
- m_cylinder_low = m_buffer_size & 0xff;
- m_cylinder_high = m_buffer_size >> 8;
-
- m_status |= IDE_STATUS_DRQ;
- m_sector_count = ATAPI_INTERRUPT_REASON_IO;
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_IDENTIFY_DEVICE:
- /// TODO: busy
- signature();
- m_status |= IDE_STATUS_ERR;
- m_error = IDE_ERROR_ABRT;
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_CHECK_POWER_MODE:
- m_status = IDE_STATUS_DRDY;
- m_sector_count = 0xff; // Power mode: 0x00 = Standby, 0x80 = Idle mode, 0xff = Active mode or Idle mode
- set_irq(ASSERT_LINE);
- break;
-
- default:
- ata_hle_device::process_command();
- break;
- }
-}
-
-void atapi_hle_device::finished_command()
-{
- switch (m_command)
- {
- default:
- ata_hle_device::finished_command();
- break;
- }
-}
-
-atapi_hle_device::packet_command_length_t atapi_hle_device::packet_command_length()
-{
- return (packet_command_length_t) (m_identify_buffer[0] & 3);
-}
-
-atapi_hle_device::packet_command_response_t atapi_hle_device::packet_command_response()
-{
- return (packet_command_response_t) ((m_identify_buffer[0] >> 5 ) & 3);
-}
diff --git a/src/emu/machine/atapihle.h b/src/emu/machine/atapihle.h
deleted file mode 100644
index 4d33e60a378..00000000000
--- a/src/emu/machine/atapihle.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- atapihle.h
-
- ATAPI High Level Emulation
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __ATAPIHLE_H__
-#define __ATAPIHLE_H__
-
-#include "atahle.h"
-#include "t10spc.h"
-
-class atapi_hle_device : public ata_hle_device,
- public virtual t10spc
-{
-public:
- atapi_hle_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock,const char *shortname, const char *source);
-
- enum atapi_features_flag_t
- {
- ATAPI_FEATURES_FLAG_DMA = 0x01,
- ATAPI_FEATURES_FLAG_OVL = 0x02
- };
-
- enum atapi_interrupt_reason_t
- {
- ATAPI_INTERRUPT_REASON_CD = 0x01, // 1 = command, 0 = data
- ATAPI_INTERRUPT_REASON_IO = 0x02, // 1 = to host, 0 = to device
- ATAPI_INTERRUPT_REASON_REL = 0x04, // 1 = bus release
- ATAPI_INTERRUPT_REASON_TAG = 0xf8 // command tag
- };
-
- enum packet_command_length_t
- {
- PACKET_COMMAND_LENGTH_12,
- PACKET_COMMAND_LENGTH_16
- };
-
- enum packet_command_response_t
- {
- PACKET_COMMAND_RESPONSE_DRQ_3MS,
- PACKET_COMMAND_RESPONSE_INTRQ,
- PACKET_COMMAND_RESPONSE_DRQ_50US
- };
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
- virtual int sector_length() { return ATAPI_BUFFER_LENGTH; }
- virtual void process_buffer();
- virtual void fill_buffer();
- virtual bool is_ready() { return false; }
- virtual void signature();
- virtual void process_command();
- virtual void finished_command();
-
- virtual void identify_packet_device() = 0;
-
- packet_command_length_t packet_command_length();
- packet_command_response_t packet_command_response();
-
-private:
- void wait_buffer();
-
- int m_packet;
- int m_data_size;
-
- static const int ATAPI_BUFFER_LENGTH = 0xf800;
-};
-
-#endif
diff --git a/src/emu/machine/autoconfig.c b/src/emu/machine/autoconfig.c
deleted file mode 100644
index 84b51cd8c24..00000000000
--- a/src/emu/machine/autoconfig.c
+++ /dev/null
@@ -1,169 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- Amiga Autoconfig
-
-***************************************************************************/
-
-#include "autoconfig.h"
-
-
-//**************************************************************************
-// CONSTANTS & MACROS
-//**************************************************************************
-
-#define VERBOSE 1
-
-
-//**************************************************************************
-// CONSTRUCTOR
-//**************************************************************************
-
-amiga_autoconfig::amiga_autoconfig()
-{
- memset(m_cfg, 0xff, sizeof(m_cfg));
-
- // interrupt status register, not inverted
- m_cfg[0x20] = 0;
- m_cfg[0x21] = 0;
-}
-
-amiga_autoconfig::~amiga_autoconfig()
-{
-}
-
-
-//**************************************************************************
-// AUTOCONFIG INFO SETTERS
-//**************************************************************************
-
-void amiga_autoconfig::autoconfig_board_type(board_type type)
-{
- m_cfg[0x00] &= 0x3000;
- m_cfg[0x00] |= (type << 2) << 12;
-}
-
-void amiga_autoconfig::autoconfig_board_size(board_size size)
-{
- m_cfg[0x01] &= 0x8000;
- m_cfg[0x01] |= (size << 0) << 12;
-}
-
-void amiga_autoconfig::autoconfig_rom_vector_valid(bool state)
-{
- m_cfg[0x00] &= 0xe000;
- m_cfg[0x00] |= (state ? 0x01 : 0x00) << 12;
-}
-
-void amiga_autoconfig::autoconfig_link_into_memory(bool state)
-{
- m_cfg[0x00] &= 0xd000;
- m_cfg[0x00] |= (state ? 0x02 : 0x00) << 12;
-}
-
-void amiga_autoconfig::autoconfig_multi_device(bool state)
-{
- m_cfg[0x01] &= 0x7000;
- m_cfg[0x01] |= (state ? 0x08 : 0x00) << 12;
-}
-
-void amiga_autoconfig::autoconfig_8meg_preferred(bool state)
-{
- m_cfg[0x04] &= 0x7000;
- m_cfg[0x04] |= (state ? 0x08 : 0x00) << 12;
-}
-
-void amiga_autoconfig::autoconfig_can_shutup(bool state)
-{
- m_cfg[0x04] &= 0xb000;
- m_cfg[0x04] |= (state ? 0x04 : 0x00) << 12;
-}
-
-void amiga_autoconfig::autoconfig_product(UINT8 data)
-{
- m_cfg[0x02] = ~((data & 0xf0) >> 4) << 12;
- m_cfg[0x03] = ~((data & 0x0f) >> 0) << 12;
-}
-
-void amiga_autoconfig::autoconfig_manufacturer(UINT16 data)
-{
- m_cfg[0x08] = ~((data & 0xf000) >> 12) << 12;
- m_cfg[0x09] = ~((data & 0x0f00) >> 8) << 12;
- m_cfg[0x0a] = ~((data & 0x00f0) >> 4) << 12;
- m_cfg[0x0b] = ~((data & 0x000f) >> 0) << 12;
-}
-
-void amiga_autoconfig::autoconfig_serial(UINT32 data)
-{
- m_cfg[0x0c] = ~((data & 0xf0000000) >> 28) << 12;
- m_cfg[0x0d] = ~((data & 0x0f000000) >> 24) << 12;
- m_cfg[0x0e] = ~((data & 0x00f00000) >> 20) << 12;
- m_cfg[0x0f] = ~((data & 0x000f0000) >> 16) << 12;
- m_cfg[0x10] = ~((data & 0x0000f000) >> 12) << 12;
- m_cfg[0x11] = ~((data & 0x00000f00) >> 8) << 12;
- m_cfg[0x12] = ~((data & 0x000000f0) >> 4) << 12;
- m_cfg[0x13] = ~((data & 0x0000000f) >> 0) << 12;
-}
-
-void amiga_autoconfig::autoconfig_rom_vector(UINT16 data)
-{
- m_cfg[0x14] = ~((data & 0xf000) >> 12) << 12;
- m_cfg[0x15] = ~((data & 0x0f00) >> 8) << 12;
- m_cfg[0x16] = ~((data & 0x00f0) >> 4) << 12;
- m_cfg[0x17] = ~((data & 0x000f) >> 0) << 12;
-}
-
-
-//**************************************************************************
-// MEMORY INTERFACE
-//**************************************************************************
-
-READ16_MEMBER( amiga_autoconfig::autoconfig_read )
-{
- UINT16 data = m_cfg[offset] | 0x0fff;
-
- if (VERBOSE && !space.debugger_access())
- logerror("autoconfig_read %04x @ %02x [mask = %04x]\n", data, offset, mem_mask);
-
- return data;
-}
-
-WRITE16_MEMBER( amiga_autoconfig::autoconfig_write )
-{
- if (VERBOSE && !space.debugger_access())
- logerror("autoconfig_write %04x @ %02x [mask = %04x]\n", data, offset, mem_mask);
-
- switch (offset)
- {
- case 0x20:
- // user-definable
- break;
-
- case 0x21:
- // bit 0 = interrupt enable
- // bit 1 = user-definable
- // bit 2 = local reset
- // bit 3 = user-definable
- break;
-
- case 0x24:
- // base address register
- m_cfg[0x24] = data & 0xf000;
- autoconfig_base_address((m_cfg[0x24] << 8) | (m_cfg[0x25] << 4));
- break;
-
- case 0x25:
- // latch low-nibble
- m_cfg[0x25] = data & 0xf000;
- break;
-
- case 0x26:
- // shut-up register
- autoconfig_base_address(0);
- break;
-
- case 0x27:
- break;
- }
-}
diff --git a/src/emu/machine/autoconfig.h b/src/emu/machine/autoconfig.h
deleted file mode 100644
index 042d3886189..00000000000
--- a/src/emu/machine/autoconfig.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- Amiga Autoconfig
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __AUTOCONFIG_H__
-#define __AUTOCONFIG_H__
-
-#include "emu.h"
-
-class amiga_autoconfig
-{
-public:
- amiga_autoconfig();
- virtual ~amiga_autoconfig();
-
- // read from autoconfig space
- DECLARE_READ16_MEMBER( autoconfig_read );
-
- // write to autoconfig space
- DECLARE_WRITE16_MEMBER( autoconfig_write );
-
-protected:
- enum board_type
- {
- BOARD_TYPE_ZORRO3 = 2,
- BOARD_TYPE_ZORRO2 = 3
- };
-
- enum board_size
- {
- BOARD_SIZE_8M = 0,
- BOARD_SIZE_64K = 1,
- BOARD_SIZE_128K = 2,
- BOARD_SIZE_256K = 3,
- BOARD_SIZE_512K = 4,
- BOARD_SIZE_1M = 5,
- BOARD_SIZE_2M = 6,
- BOARD_SIZE_4M = 7
- };
-
- // board type & size
- void autoconfig_board_type(board_type type);
- void autoconfig_board_size(board_size size);
-
- // various flags
- void autoconfig_rom_vector_valid(bool state);
- void autoconfig_link_into_memory(bool state);
- void autoconfig_multi_device(bool state);
- void autoconfig_8meg_preferred(bool state);
- void autoconfig_can_shutup(bool state);
-
- // product number, manufacturer number, serial number
- void autoconfig_product(UINT8 data);
- void autoconfig_manufacturer(UINT16 data);
- void autoconfig_serial(UINT32 data);
-
- // rom vector
- void autoconfig_rom_vector(UINT16 data);
-
- // called once we have received a valid base address from the host system
- virtual void autoconfig_base_address(offs_t address) = 0;
-
-private:
- // configuration information about our autoconfig board, 256 nibbles
- UINT16 m_cfg[0x40];
-};
-
-#endif // __AUTOCONFIG_H__
diff --git a/src/emu/machine/ay31015.c b/src/emu/machine/ay31015.c
deleted file mode 100644
index 2ecd3f311f7..00000000000
--- a/src/emu/machine/ay31015.c
+++ /dev/null
@@ -1,753 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Robbbert
-/****************************************************************************
-
- ay31015.c by Robbbert, May 2008. Bugs fixed by Judge.
-
- Code for the AY-3-1014A, AY-3-1015(D), AY-5-1013(A), and AY-6-1013 UARTs
- The HD6402 UART is compatible with the AY-3-1015 UART.
-
- This is cycle-accurate according to the specifications.
-
- It supports independent receive and transmit clocks,
- and transmission and reception can occur simultaneously if desired.
-
-*****************************************************************************
-
-Differences between the chip types:
-- All units have pull-up resistors on the inputs, except for the AY-3-1014A which is CMOS-compatible.
-- AY-3-1014A and AY-3-1015 - 1.5 stop bits mode available.
-- Max baud rate of 30k, except AY-5-1013 which has 20k.
-- AY-5-1013 has extended temperature ratings.
-- AY-5-1013 and AY-6-1013 require a -12 volt supply on pin 2. Pin is not used otherwise.
-- AY-5-1013 and AY-6-1013 do not reset the received data register when XR pin is used.
-
-******************************************************************************
-
-It is not clear in the documentation as to which settings will reset the device.
- To be safe, we will always reset whenever the control register changes.
-
- Also, it not clear exactly what happens under various error conditions.
-
-********************************************************************************
-
-Device Data:
-
-* Common Controls:
--- Pin 1 - Vcc - 5 volts
--- Pin 2 - not used (on AY-5-1013 and AY-6-1013 this is Voo = -12 volts)
--- Pin 3 - Gnd - 0 volts
--- Pin 21 - XR - External Reset - resets all registers to initial state except for the control register
--- Pin 35 - NP - No Parity - "1" will kill any parity processing
--- Pin 36 - TSB - Number of Stop Bits - "0" = 1 stop bit; "1" = 2 stop bits. If "1", and 5 bits per character, then we have 1.5 stop bits
--- pin 37 - NB1
--- pin 38 - NB2 - Number of bits per character = NB1 + (NB2 * 2) + 5
--- pin 39 - EPS - Odd or Even Parity Select - "0" = Odd parity; "1" = Even parity. Has no effect if NP is high.
--- Pin 34 - CS - Control Strobe - Read NP, TSB, EPS, NB1, NB2 into the control register.
-
-Format of data stream:
-Start bit (low), Bit 0, Bit 1... highest bit, Parity bit (if enabled), 1-2 stop bits (high)
-
-
-* Receiver Controls:
--- Pin 17 - RCP - Clock which is 16x the desired baud rate
--- Pin 20 - SI - Serial input stream - "1" = Mark (waiting for input), "0" = Space (Start bit) initiates the transfer of a byte
--- Pin 4 - RDE - "0" causes the received data to appear on RD1 to RD8.
--- Pins 5 to 12 - RD8 to RD1 - These are the data lines (bits 7 to 0). Data is right-justified.
--- Pin 16 - SWE - Status word enable - causes the status bits (PE, FE, OR, DAV, TBMT) to appear at the pins.
--- Pin 19 - DAV - "1" indicates that a byte has been received by the UART, and should now be accepted by the computer
--- Pin 18 - RDAV - "0" will force DAV low.
--- Pin 13 - PE - Parity error - "1" indicates that a parity error occurred
--- Pin 14 - FE - Framing error - "1" Indicates that the stop bit was missing
--- Pin 15 - OR - overrun - "1" indicates that a new character has become available before the computer had accepted the previous character
-
-* Transmitter controls:
--- Pin 40 - TCP - Clock which is 16x the desired baud rate
--- Pin 25 - SO - Serial output stream - it will stay at "1" while no data is being transmitted
--- Pins 26 to 33 - DB1 to DB8 - These are the data lines containing the byte to be sent
--- Pin 23 - DS - Data Strobe - "0" will copy DB1 to DB8 into the transmit buffer
--- Pin 22 - TBMT - Transmit buffer Empty - "1" indicates to the computer that another byte may be sent to the UART
--- Pin 24 - EOC - End of Character - "0" means that a character is being sent.
-
-******************************************* COMMON CONTROLS ********************************************************/
-
-#include "emu.h"
-#include "ay31015.h"
-
-
-
-/* control reg */
-#define CONTROL_NB1 0x01
-#define CONTROL_NB2 0x02
-#define CONTROL_TSB 0x04
-#define CONTROL_EPS 0x08
-#define CONTROL_NP 0x10
-
-
-/* status reg */
-#define STATUS_TBMT 0x01
-#define STATUS_DAV 0x02
-#define STATUS_OR 0x04
-#define STATUS_FE 0x08
-#define STATUS_PE 0x10
-#define STATUS_EOC 0x20
-
-
-
-const device_type AY31015 = &device_creator<ay31015_device>;
-const device_type AY51013 = &device_creator<ay51013_device>;
-
-ay31015_device::ay31015_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_control_reg(0),
- m_status_reg(0),
- m_second_stop_bit(0),
- m_total_pulses(0),
- m_internal_sample(0),
- m_rx_data(0),
- m_rx_buffer(0),
- m_rx_bit_count(0),
- m_rx_parity(0),
- m_rx_pulses(0),
- m_rx_clock(0),
- m_rx_timer(NULL),
- m_tx_data(0),
- m_tx_buffer(0),
- m_tx_parity(0),
- m_tx_pulses(0),
- m_tx_clock(0),
- m_tx_timer(NULL),
- m_read_si_cb(*this),
- m_write_so_cb(*this),
- m_status_changed_cb(*this)
-{
- for (int i = 0; i < 41; i++)
- m_pins[i] = 0;
-}
-
-ay31015_device::ay31015_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, AY31015, "AY-3-1015", tag, owner, clock, "ay31015", __FILE__),
- m_control_reg(0),
- m_status_reg(0),
- m_second_stop_bit(0),
- m_total_pulses(0),
- m_internal_sample(0),
- m_rx_data(0),
- m_rx_buffer(0),
- m_rx_bit_count(0),
- m_rx_parity(0),
- m_rx_pulses(0),
- m_rx_clock(0),
- m_rx_timer(NULL),
- m_tx_data(0),
- m_tx_buffer(0),
- m_tx_parity(0),
- m_tx_pulses(0),
- m_tx_clock(0),
- m_tx_timer(NULL),
- m_read_si_cb(*this),
- m_write_so_cb(*this),
- m_status_changed_cb(*this)
-{
- for (int i = 0; i < 41; i++)
- m_pins[i] = 0;
-}
-
-ay51013_device::ay51013_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : ay31015_device(mconfig, AY31015, "AY-5-1013", tag, owner, clock, "ay51013", __FILE__)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ay31015_device::device_start()
-{
- m_read_si_cb.resolve();
- m_write_so_cb.resolve();
- m_status_changed_cb.resolve();
-
- m_rx_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ay31015_device::rx_process),this));
- m_tx_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ay31015_device::tx_process),this));
-
- update_rx_timer();
- update_tx_timer();
-
- save_item(NAME(m_pins));
- save_item(NAME(m_control_reg));
- save_item(NAME(m_status_reg));
- save_item(NAME(m_second_stop_bit));
- save_item(NAME(m_total_pulses));
- save_item(NAME(m_internal_sample));
-
- save_item(NAME(m_rx_state));
- save_item(NAME(m_rx_data));
- save_item(NAME(m_rx_buffer));
- save_item(NAME(m_rx_bit_count));
- save_item(NAME(m_rx_parity));
- save_item(NAME(m_rx_pulses));
- save_item(NAME(m_rx_clock));
-
- save_item(NAME(m_tx_state));
- save_item(NAME(m_tx_data));
- save_item(NAME(m_tx_buffer));
- save_item(NAME(m_tx_parity));
- save_item(NAME(m_tx_pulses));
- save_item(NAME(m_tx_clock));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ay31015_device::device_reset()
-{
- m_control_reg = 0;
- m_rx_data = 0;
-
- internal_reset();
-}
-
-
-inline UINT8 ay31015_device::get_si()
-{
- if (!m_read_si_cb.isnull())
- m_pins[AY31015_SI] = m_read_si_cb(0) ? 1 : 0;
-
- return m_pins[AY31015_SI];
-}
-
-
-inline void ay31015_device::set_so( int data )
-{
- m_pins[AY31015_SO] = data ? 1 : 0;
-
- if (!m_write_so_cb.isnull())
- m_write_so_cb((offs_t)0, m_pins[AY31015_SO]);
-}
-
-
-inline int ay31015_device::update_status_pin( UINT8 reg_bit, ay31015_output_pin_t pin )
-{
- int new_value = (m_status_reg & reg_bit) ? 1 : 0;
-
- if (new_value == m_pins[pin])
- return 0;
-
- m_pins[pin] = new_value;
- return 1;
-}
-
-
-/*-------------------------------------------------
- ay31015_update_status_pins - Update the status pins
--------------------------------------------------*/
-
-void ay31015_device::update_status_pins()
-{
- int status_pins_changed = 0;
-
- /* Should status pins be updated? */
- if (!m_pins[AY31015_SWE])
- {
- status_pins_changed += update_status_pin(STATUS_PE, AY31015_PE);
- status_pins_changed += update_status_pin(STATUS_FE, AY31015_FE);
- status_pins_changed += update_status_pin(STATUS_OR, AY31015_OR);
- status_pins_changed += update_status_pin(STATUS_DAV, AY31015_DAV);
- status_pins_changed += update_status_pin(STATUS_TBMT, AY31015_TBMT);
- }
- status_pins_changed += update_status_pin(STATUS_EOC, AY31015_EOC);
-
- if (status_pins_changed && !m_status_changed_cb.isnull())
- {
- m_status_changed_cb((offs_t)0, status_pins_changed);
- }
-}
-
-
-/*************************************************** RECEIVE CONTROLS *************************************************/
-
-
-/*-------------------------------------------------
- ay31015_rx_process - convert serial to parallel
--------------------------------------------------*/
-
-TIMER_CALLBACK_MEMBER( ay31015_device::rx_process )
-{
- switch (m_rx_state)
- {
- case PREP_TIME: // assist sync by ensuring high bit occurs
- m_rx_pulses--;
- if (get_si())
- m_rx_state = IDLE;
- return;
-
- case IDLE:
- m_rx_pulses--;
- if (!get_si())
- {
- m_rx_state = START_BIT;
- m_rx_pulses = 16;
- }
- return;
-
- case START_BIT:
- m_rx_pulses--;
- if (m_rx_pulses == 8) // start bit must be low at sample time
- {
- if (get_si())
- m_rx_state = IDLE;
- }
- else
- if (!m_rx_pulses) // end of start bit
- {
- m_rx_state = PROCESSING;
- m_rx_pulses = m_total_pulses;
- m_rx_bit_count = 0;
- m_rx_parity = 0;
- m_rx_data = 0;
- }
- return;
-
- case PROCESSING:
- m_rx_pulses--;
- if (!m_rx_pulses) // end of a byte
- {
- m_rx_pulses = 16;
- if (m_control_reg & CONTROL_NP) // see if we need to get a parity bit
- m_rx_state = FIRST_STOP_BIT;
- else
- m_rx_state = PARITY_BIT;
- }
- else
- if (!(m_rx_pulses & 15)) // end of a bit
- m_rx_bit_count++;
- else
- if ((m_rx_pulses & 15) == 8) // sample input stream
- {
- m_internal_sample = get_si();
- m_rx_parity ^= m_internal_sample; // calculate cumulative parity
- m_rx_data |= m_internal_sample << m_rx_bit_count;
- }
- return;
-
- case PARITY_BIT:
- m_rx_pulses--;
-
- if (m_rx_pulses == 8) // sample input stream
- {
- m_rx_parity ^= get_si(); // calculate cumulative parity
- }
- else
- if (!m_rx_pulses) // end of a byte
- {
- m_rx_pulses = 16;
- m_rx_state = FIRST_STOP_BIT;
-
- if ((!(m_control_reg & CONTROL_EPS)) && (m_rx_parity))
- m_rx_parity = 0; // odd parity, ok
- else
- if ((m_control_reg & CONTROL_EPS) && (!m_rx_parity))
- m_rx_parity = 0; // even parity, ok
- else
- m_rx_parity = 1; // parity error
- }
- return;
-
- case FIRST_STOP_BIT:
- m_rx_pulses--;
- if (m_rx_pulses == 8) // sample input stream
- m_internal_sample = get_si();
- else
- if (m_rx_pulses == 7) // set error flags
- {
- if (!m_internal_sample)
- {
- m_status_reg |= STATUS_FE; // framing error - the stop bit not high
- m_rx_state = PREP_TIME; // lost sync - start over
- // return;
- }
- else
- m_status_reg &= ~STATUS_FE;
-
- if ((m_rx_parity) && (!(m_control_reg & CONTROL_NP)))
- m_status_reg |= STATUS_PE; // parity error
- else
- m_status_reg &= ~STATUS_PE;
-
- if (m_status_reg & STATUS_DAV)
- m_status_reg |= STATUS_OR; // overrun error - previous byte still in buffer
- else
- m_status_reg &= ~STATUS_OR;
-
- m_rx_buffer = m_rx_data; // bring received byte out for computer to read
-
- update_status_pins();
- }
- else
- if (m_rx_pulses == 6)
- {
- m_status_reg |= STATUS_DAV; // tell computer that new byte is ready
- update_status_pins();
- }
- else
- if (m_rx_pulses == 4)
- {
- if (m_second_stop_bit)
- {
- /* We should wait for the full first stop bit and
- the beginning of the second stop bit */
- m_rx_state = SECOND_STOP_BIT;
- m_rx_pulses += m_second_stop_bit - 7;
- }
- else
- {
- /* We have seen a STOP bit, go back to PREP_TIME */
- m_rx_state = PREP_TIME;
- }
- }
- return;
-
- case SECOND_STOP_BIT:
- m_rx_pulses--;
- if (!m_rx_pulses)
- m_rx_state = PREP_TIME;
- return;
-
- }
-}
-
-
-/*************************************************** TRANSMIT CONTROLS *************************************************/
-
-
-/*-------------------------------------------------
- ay31015_tx_process - convert parallel to serial
--------------------------------------------------*/
-
-TIMER_CALLBACK_MEMBER( ay31015_device::tx_process )
-{
- UINT8 t1;
- switch (m_tx_state)
- {
- case IDLE:
- if (!(m_status_reg & STATUS_TBMT))
- {
- m_tx_state = PREP_TIME; // When idle, see if a byte has been sent to us
- m_tx_pulses = 1;
- }
- return;
-
- case PREP_TIME: // This phase lets the transmitter regain sync after an idle period
- m_tx_pulses--;
- if (!m_tx_pulses)
- {
- m_tx_state = START_BIT;
- m_tx_pulses = 16;
- }
- return;
-
- case START_BIT:
- if (m_tx_pulses == 16) // beginning of start bit
- {
- m_tx_data = m_tx_buffer; // load the shift register
- m_status_reg |= STATUS_TBMT; // tell computer that another byte can be sent to uart
- set_so(0); /* start bit begins now (we are "spacing") */
- m_status_reg &= ~STATUS_EOC; // we are no longer idle
- m_tx_parity = 0;
- update_status_pins();
- }
-
- m_tx_pulses--;
- if (!m_tx_pulses) // end of start bit
- {
- m_tx_state = PROCESSING;
- m_tx_pulses = m_total_pulses;
- }
- return;
-
- case PROCESSING:
- if (!(m_tx_pulses & 15)) // beginning of a data bit
- {
- if (m_tx_data & 1)
- {
- set_so(1);
- m_tx_parity++; // calculate cumulative parity
- }
- else
- set_so(0);
-
- m_tx_data >>= 1; // adjust the shift register
- }
-
- m_tx_pulses--;
- if (!m_tx_pulses) // all data bits sent
- {
- m_tx_pulses = 16;
- if (m_control_reg & CONTROL_NP) // see if we need to make a parity bit
- m_tx_state = FIRST_STOP_BIT;
- else
- m_tx_state = PARITY_BIT;
- }
-
- return;
-
- case PARITY_BIT:
- if (m_tx_pulses == 16)
- {
- t1 = (m_control_reg & CONTROL_EPS) ? 0 : 1;
- t1 ^= (m_tx_parity & 1);
- if (t1)
- set_so(1); /* extra bit to set the correct parity */
- else
- set_so(0); /* it was already correct */
- }
-
- m_tx_pulses--;
- if (!m_tx_pulses)
- {
- m_tx_state = FIRST_STOP_BIT;
- m_tx_pulses = 16;
- }
- return;
-
- case FIRST_STOP_BIT:
- if (m_tx_pulses == 16)
- set_so(1); /* create a stop bit (marking and soon idle) */
- m_tx_pulses--;
- if (!m_tx_pulses)
- {
- m_status_reg |= STATUS_EOC; // character is completely sent
- if (m_second_stop_bit)
- {
- m_tx_state = SECOND_STOP_BIT;
- m_tx_pulses = m_second_stop_bit;
- }
- else
- if (m_status_reg & STATUS_TBMT)
- m_tx_state = IDLE; // if nothing to send, go idle
- else
- {
- m_tx_pulses = 16;
- m_tx_state = START_BIT; // otherwise immediately start next byte
- }
- update_status_pins();
- }
- return;
-
- case SECOND_STOP_BIT:
- m_tx_pulses--;
- if (!m_tx_pulses)
- {
- if (m_status_reg & STATUS_TBMT)
- m_tx_state = IDLE; // if nothing to send, go idle
- else
- {
- m_tx_pulses = 16;
- m_tx_state = START_BIT; // otherwise immediately start next byte
- }
- }
- return;
-
- }
-}
-
-
-/*-------------------------------------------------
- ay31015_reset - reset internal state
--------------------------------------------------*/
-
-void ay31015_device::internal_reset()
-{
- /* total pulses = 16 * data-bits */
- UINT8 t1;
-
- if (m_control_reg & CONTROL_NB2)
- t1 = (m_control_reg & CONTROL_NB1) ? 8 : 7;
- else
- t1 = (m_control_reg & CONTROL_NB1) ? 6 : 5;
-
- m_total_pulses = t1 << 4; /* total clock pulses to load a byte */
- m_second_stop_bit = ((m_control_reg & CONTROL_TSB) ? 16 : 0); /* 2nd stop bit */
- if ((t1 == 5) && (m_second_stop_bit == 16))
- m_second_stop_bit = 8; /* 5 data bits and 2 stop bits = 1.5 stop bits */
- m_status_reg = STATUS_EOC | STATUS_TBMT;
- m_tx_data = 0;
- m_rx_state = PREP_TIME;
- m_tx_state = IDLE;
- m_pins[AY31015_SI] = 1;
- set_so(1);
-
- m_rx_data = 0;
-}
-
-
-void ay51013_device::internal_reset()
-{
- /* total pulses = 16 * data-bits */
- UINT8 t1;
-
- if (m_control_reg & CONTROL_NB2)
- t1 = (m_control_reg & CONTROL_NB1) ? 8 : 7;
- else
- t1 = (m_control_reg & CONTROL_NB1) ? 6 : 5;
-
- m_total_pulses = t1 << 4; /* total clock pulses to load a byte */
- m_second_stop_bit = ((m_control_reg & CONTROL_TSB) ? 16 : 0); /* 2nd stop bit */
- if ((t1 == 5) && (m_second_stop_bit == 16))
- m_second_stop_bit = 8; /* 5 data bits and 2 stop bits = 1.5 stop bits */
- m_status_reg = STATUS_EOC | STATUS_TBMT;
- m_tx_data = 0;
- m_rx_state = PREP_TIME;
- m_tx_state = IDLE;
- m_pins[AY31015_SI] = 1;
- set_so(1);
- // no m_rx_data = 0 in this case
-}
-
-/*-------------------------------------------------
- ay31015_transfer_control_pins - transfers contents of controls pins to the control register
--------------------------------------------------*/
-
-void ay31015_device::transfer_control_pins()
-{
- UINT8 control = 0;
-
- control |= m_pins[AY31015_NP ] ? CONTROL_NP : 0;
- control |= m_pins[AY31015_TSB] ? CONTROL_TSB : 0;
- control |= m_pins[AY31015_NB1] ? CONTROL_NB1 : 0;
- control |= m_pins[AY31015_NB2] ? CONTROL_NB2 : 0;
- control |= m_pins[AY31015_EPS] ? CONTROL_EPS : 0;
-
- if (m_control_reg != control)
- {
- m_control_reg = control;
- internal_reset();
- }
-}
-
-
-/*-------------------------------------------------
- ay31015_set_input_pin - set an input pin
--------------------------------------------------*/
-void ay31015_device::set_input_pin( ay31015_input_pin_t pin, int data )
-{
- data = data ? 1 : 0;
-
- switch (pin)
- {
- case AY31015_SWE:
- m_pins[pin] = data;
- update_status_pins();
- break;
- case AY31015_RDAV:
- m_pins[pin] = data;
- if (!data)
- {
- m_status_reg &= ~STATUS_DAV;
- m_pins[AY31015_DAV] = 0;
- }
- break;
- case AY31015_SI:
- m_pins[pin] = data;
- break;
- case AY31015_XR:
- m_pins[pin] = data;
- if (data)
- internal_reset();
- break;
- case AY31015_CS:
- case AY31015_NP:
- case AY31015_TSB:
- case AY31015_NB1:
- case AY31015_NB2:
- case AY31015_EPS:
- m_pins[pin] = data;
- if (m_pins[AY31015_CS])
- transfer_control_pins();
- break;
- }
-}
-
-
-/*-------------------------------------------------
- ay31015_get_output_pin - get the status of an output pin
--------------------------------------------------*/
-
-int ay31015_device::get_output_pin( ay31015_output_pin_t pin )
-{
- return m_pins[pin];
-}
-
-
-inline void ay31015_device::update_rx_timer()
-{
- if (m_rx_clock > 0.0)
- {
- m_rx_timer->adjust(attotime::from_hz(m_rx_clock), 0, attotime::from_hz(m_rx_clock));
- }
- else
- {
- m_rx_timer->enable(0);
- }
-}
-
-
-inline void ay31015_device::update_tx_timer()
-{
- if (m_tx_clock > 0.0)
- {
- m_tx_timer->adjust(attotime::from_hz(m_tx_clock), 0, attotime::from_hz(m_tx_clock));
- }
- else
- {
- m_tx_timer->enable(0);
- }
-}
-
-
-/*-------------------------------------------------
- ay31015_set_receiver_clock - set receive clock
--------------------------------------------------*/
-
-void ay31015_device::set_receiver_clock( double new_clock )
-{
- m_rx_clock = new_clock;
- update_rx_timer();
-}
-
-
-/*-------------------------------------------------
- ay31015_set_transmitter_clock - set transmit clock
--------------------------------------------------*/
-
-void ay31015_device::set_transmitter_clock( double new_clock )
-{
- m_tx_clock = new_clock;
- update_tx_timer();
-}
-
-
-/*-------------------------------------------------
- ay31015_get_received_data - return a byte to the computer
--------------------------------------------------*/
-
-UINT8 ay31015_device::get_received_data()
-{
- return m_rx_buffer;
-}
-
-
-/*-------------------------------------------------
- ay31015_set_transmit_data - accept a byte to transmit, if able
--------------------------------------------------*/
-void ay31015_device::set_transmit_data( UINT8 data )
-{
- if (m_status_reg & STATUS_TBMT)
- {
- m_tx_buffer = data;
- m_status_reg &= ~STATUS_TBMT;
- update_status_pins();
- }
-}
diff --git a/src/emu/machine/ay31015.h b/src/emu/machine/ay31015.h
deleted file mode 100644
index 2f2ae33eca8..00000000000
--- a/src/emu/machine/ay31015.h
+++ /dev/null
@@ -1,198 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Robbbert
-/* ay31015.h
-
- Written for MESS by Robbbert on May 29th, 2008.
-
-*/
-
-#ifndef __AY31015_H_
-#define __AY31015_H_
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-
-enum ay31015_input_pin_t
-{
- AY31015_SWE = 16, /* -SWE - Pin 16 - Status word enable */
- AY31015_RDAV = 18, /* -RDAV - Pin 18 - Reset data available */
- AY31015_SI = 20, /* SI - Pin 20 - Serial input */
- AY31015_XR = 21, /* XR - Pin 21 - External reset */
- AY31015_CS = 34, /* CS - Pin 34 - Control strobe */
- AY31015_NP = 35, /* NP - Pin 35 - No parity */
- AY31015_TSB = 36, /* TSB - Pin 36 - Number of stop bits */
- AY31015_NB1 = 37, /* NB1 - Pin 37 - Number of bits #1 */
- AY31015_NB2 = 38, /* NB2 - Pin 38 - Number of bits #2 */
- AY31015_EPS = 39 /* EPS - Pin 39 - Odd/Even parity select */
-};
-
-
-enum ay31015_output_pin_t
-{
- AY31015_PE = 13, /* PE - Pin 13 - Parity error */
- AY31015_FE = 14, /* FE - Pin 14 - Framing error */
- AY31015_OR = 15, /* OR - Pin 15 - Over-run */
- AY31015_DAV = 19, /* DAV - Pin 19 - Data available */
- AY31015_TBMT = 22, /* TBMT - Pin 22 - Transmit buffer empty */
- AY31015_EOC = 24, /* EOC - Pin 24 - End of character */
- AY31015_SO = 25 /* SO - Pin 25 - Serial output */
-};
-
-
-/***************************************************************************
- DEVICE INTERFACE
-***************************************************************************/
-
-enum state_t
-{
- IDLE,
- START_BIT,
- PROCESSING,
- PARITY_BIT,
- FIRST_STOP_BIT,
- SECOND_STOP_BIT,
- PREP_TIME
-};
-
-ALLOW_SAVE_TYPE(state_t);
-
-class ay31015_device : public device_t
-{
-public:
- ay31015_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ay31015_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
- ~ay31015_device() {}
-
- static void set_tx_clock(device_t &device, double tx_clock) { downcast<ay31015_device &>(device).m_tx_clock = tx_clock; }
- static void set_rx_clock(device_t &device, double rx_clock) { downcast<ay31015_device &>(device).m_rx_clock = rx_clock; }
- template<class _Object> static devcb_base &set_read_si_callback(device_t &device, _Object object) { return downcast<ay31015_device &>(device).m_read_si_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_write_so_callback(device_t &device, _Object object) { return downcast<ay31015_device &>(device).m_write_so_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_status_changed_callback(device_t &device, _Object object) { return downcast<ay31015_device &>(device).m_status_changed_cb.set_callback(object); }
-
- /* Set an input pin */
- void set_input_pin( ay31015_input_pin_t pin, int data );
-
-
- /* Get an output pin */
- int get_output_pin( ay31015_output_pin_t pin );
-
-
- /* Set a new transmitter clock (new_clock is in Hz) */
- void set_transmitter_clock( double new_clock );
-
-
- /* Set a new receiver clock (new_clock is in Hz) */
- void set_receiver_clock( double new_clock );
-
-
- /* Reead the received data */
- /* The received data is available on RD8-RD1 (pins 5-12) */
- UINT8 get_received_data();
-
-
- /* Set the transmitter buffer */
- /* The data to transmit is set on DB1-DB8 (pins 26-33) */
- void set_transmit_data( UINT8 data );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- virtual void internal_reset();
-
- // internal state
- inline UINT8 get_si();
- inline void set_so(int data);
- inline int update_status_pin(UINT8 reg_bit, ay31015_output_pin_t pin);
- void update_status_pins();
- void transfer_control_pins();
- inline void update_rx_timer();
- inline void update_tx_timer();
- TIMER_CALLBACK_MEMBER(rx_process);
- TIMER_CALLBACK_MEMBER(tx_process);
-
- int m_pins[41];
-
- UINT8 m_control_reg;
- UINT8 m_status_reg;
- UINT16 m_second_stop_bit; // 0, 8, 16
- UINT16 m_total_pulses; // bits * 16
- UINT8 m_internal_sample;
-
- state_t m_rx_state;
- UINT8 m_rx_data; // byte being received
- UINT8 m_rx_buffer; // received byte waiting to be accepted by computer
- UINT8 m_rx_bit_count;
- UINT8 m_rx_parity;
- UINT16 m_rx_pulses; // total pulses left
- double m_rx_clock; /* RCP - pin 17 */
- emu_timer *m_rx_timer;
-
- state_t m_tx_state;
- UINT8 m_tx_data; // byte being sent
- UINT8 m_tx_buffer; // next byte to send
- UINT8 m_tx_parity;
- UINT16 m_tx_pulses; // total pulses left
- double m_tx_clock; /* TCP - pin 40 */
- emu_timer *m_tx_timer;
-
- devcb_read8 m_read_si_cb; /* SI - pin 20 - This will be called whenever the SI pin is sampled. Optional */
- devcb_write8 m_write_so_cb; /* SO - pin 25 - This will be called whenever data is put on the SO pin. Optional */
- devcb_write8 m_status_changed_cb; /* This will be called whenever one of the status pins may have changed. Optional */
-};
-
-class ay51013_device : public ay31015_device
-{
-public:
- ay51013_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual void internal_reset();
-
-};
-
-extern const device_type AY31015; // For AY-3-1014A, AY-3-1015(D) and HD6402 variants
-extern const device_type AY51013; // For AY-3-1014, AY-5-1013 and AY-6-1013 variants
-
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
- ***************************************************************************/
-
-
-#define MCFG_AY31015_TX_CLOCK(_txclk) \
- ay31015_device::set_tx_clock(*device, _txclk);
-
-#define MCFG_AY31015_RX_CLOCK(_rxclk) \
- ay31015_device::set_rx_clock(*device, _rxclk);
-
-#define MCFG_AY31015_READ_SI_CB(_devcb) \
- devcb = &ay31015_device::set_read_si_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AY31015_WRITE_SO_CB(_devcb) \
- devcb = &ay31015_device::set_write_so_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AY31015_STATUS_CHANGED_CB(_devcb) \
- devcb = &ay31015_device::set_status_changed_callback(*device, DEVCB_##_devcb);
-
-
-#define MCFG_AY51013_TX_CLOCK(_txclk) \
- ay51013_device::set_tx_clock(*device, _txclk);
-
-#define MCFG_AY51013_RX_CLOCK(_rxclk) \
- ay51013_device::set_rx_clock(*device, _rxclk);
-
-#define MCFG_AY51013_READ_SI_CB(_devcb) \
- devcb = &ay51013_device::set_read_si_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AY51013_WRITE_SO_CB(_devcb) \
- devcb = &ay51013_device::set_write_so_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_AY51013_STATUS_CHANGED_CB(_devcb) \
- devcb = &ay51013_device::set_status_changed_callback(*device, DEVCB_##_devcb);
-
-#endif
diff --git a/src/emu/machine/bankdev.c b/src/emu/machine/bankdev.c
deleted file mode 100644
index 1a600527511..00000000000
--- a/src/emu/machine/bankdev.c
+++ /dev/null
@@ -1,90 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "bankdev.h"
-
-// device type definition
-const device_type ADDRESS_MAP_BANK = &device_creator<address_map_bank_device>;
-
-address_map_bank_device::address_map_bank_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
- : device_t(mconfig, ADDRESS_MAP_BANK, "Address Map Bank", tag, owner, clock, "address_map_bank", __FILE__),
- device_memory_interface(mconfig, *this),
- m_endianness(ENDIANNESS_NATIVE),
- m_databus_width(0),
- m_addrbus_width(32),
- m_stride(1),
- m_offset(0)
-{
-}
-
-DEVICE_ADDRESS_MAP_START(amap8, 8, address_map_bank_device)
- AM_RANGE(0x00000000, 0xffffffff) AM_READWRITE(read8, write8)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(amap16, 16, address_map_bank_device)
- AM_RANGE(0x00000000, 0xffffffff) AM_READWRITE(read16, write16)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(amap32, 32, address_map_bank_device)
- AM_RANGE(0x00000000, 0xffffffff) AM_READWRITE(read32, write32)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(amap64, 64, address_map_bank_device)
- AM_RANGE(0x00000000, 0xffffffff) AM_READWRITE(read64, write64)
-ADDRESS_MAP_END
-
-WRITE8_MEMBER(address_map_bank_device::write8)
-{
- m_program->write_byte(m_offset + offset, data);
-}
-
-WRITE16_MEMBER(address_map_bank_device::write16)
-{
- m_program->write_word(m_offset + (offset * 2), data, mem_mask);
-}
-
-WRITE32_MEMBER(address_map_bank_device::write32)
-{
- m_program->write_dword(m_offset + (offset * 4), data, mem_mask);
-}
-
-WRITE64_MEMBER(address_map_bank_device::write64)
-{
- m_program->write_qword(m_offset + (offset * 8), data, mem_mask);
-}
-
-READ8_MEMBER(address_map_bank_device::read8)
-{
- return m_program->read_byte(m_offset + offset);
-}
-
-READ16_MEMBER(address_map_bank_device::read16)
-{
- return m_program->read_word(m_offset + (offset * 2), mem_mask);
-}
-
-READ32_MEMBER(address_map_bank_device::read32)
-{
- return m_program->read_dword(m_offset + (offset * 4), mem_mask);
-}
-
-READ64_MEMBER(address_map_bank_device::read64)
-{
- return m_program->read_qword(m_offset + (offset * 8), mem_mask);
-}
-
-void address_map_bank_device::device_config_complete()
-{
- m_program_config = address_space_config( "program", m_endianness, m_databus_width, m_addrbus_width );
-}
-
-void address_map_bank_device::device_start()
-{
- m_program = &space(AS_PROGRAM);
-
- save_item(NAME(m_offset));
-}
-
-void address_map_bank_device::set_bank(offs_t bank)
-{
- m_offset = bank * m_stride;
-}
diff --git a/src/emu/machine/bankdev.h b/src/emu/machine/bankdev.h
deleted file mode 100644
index 54359fc6282..00000000000
--- a/src/emu/machine/bankdev.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#pragma once
-
-#ifndef __BANKDEV_H__
-#define __BANKDEV_H__
-
-#include "emu.h"
-
-#define MCFG_ADDRESS_MAP_BANK_ENDIANNESS(_endianness) \
- address_map_bank_device::set_endianness(*device, _endianness);
-
-#define MCFG_ADDRESS_MAP_BANK_DATABUS_WIDTH(_databus_width) \
- address_map_bank_device::set_databus_width(*device, _databus_width);
-
-#define MCFG_ADDRESS_MAP_BANK_ADDRBUS_WIDTH(_addrbus_width) \
- address_map_bank_device::set_addrbus_width(*device, _addrbus_width);
-
-#define MCFG_ADDRESS_MAP_BANK_STRIDE(_stride) \
- address_map_bank_device::set_stride(*device, _stride);
-
-class address_map_bank_device :
- public device_t,
- public device_memory_interface
-{
-public:
- // construction/destruction
- address_map_bank_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock );
-
- // static configuration helpers
- static void set_endianness(device_t &device, endianness_t endianness) { downcast<address_map_bank_device &>(device).m_endianness = endianness; }
- static void set_databus_width(device_t &device, UINT8 databus_width) { downcast<address_map_bank_device &>(device).m_databus_width = databus_width; }
- static void set_addrbus_width(device_t &device, UINT8 addrbus_width) { downcast<address_map_bank_device &>(device).m_addrbus_width = addrbus_width; }
- static void set_stride(device_t &device, UINT32 stride) { downcast<address_map_bank_device &>(device).m_stride = stride; }
-
- DECLARE_ADDRESS_MAP(amap8, 8);
- DECLARE_ADDRESS_MAP(amap16, 16);
- DECLARE_ADDRESS_MAP(amap32, 32);
- DECLARE_ADDRESS_MAP(amap64, 64);
-
- DECLARE_WRITE8_MEMBER(write8);
- DECLARE_WRITE16_MEMBER(write16);
- DECLARE_WRITE32_MEMBER(write32);
- DECLARE_WRITE64_MEMBER(write64);
-
- DECLARE_READ8_MEMBER(read8);
- DECLARE_READ16_MEMBER(read16);
- DECLARE_READ32_MEMBER(read32);
- DECLARE_READ64_MEMBER(read64);
-
- void set_bank(offs_t offset);
-
-protected:
- virtual void device_start();
- virtual void device_config_complete();
-
- // device_memory_interface overrides
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_PROGRAM) ? &m_program_config : NULL; }
-
-private:
- // internal state
- endianness_t m_endianness;
- UINT8 m_databus_width;
- UINT8 m_addrbus_width;
- UINT32 m_stride;
- address_space_config m_program_config;
- address_space *m_program;
- offs_t m_offset;
-};
-
-
-// device type definition
-extern const device_type ADDRESS_MAP_BANK;
-
-#endif
diff --git a/src/emu/machine/bcreader.c b/src/emu/machine/bcreader.c
deleted file mode 100644
index 5a5df7fb452..00000000000
--- a/src/emu/machine/bcreader.c
+++ /dev/null
@@ -1,330 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Fabio Priuli
-/***************************************************************************
-
- bcreader.c
-
- Generic barcode reader emulation.
-
- This device only provides the storage of the actual barcode, entered
- by the user via Internal UI, both as a raw strip of pixels (up to 95,
- for an EAN-13 barcode) and as an array of 0-9 digits.
-
- It is up to the driver to handle the serial transfer of the data to
- the emulated machine, depending on the used protocol
-
- E.g. Bandai Datach games directly read the raw pixel sequence of
- black/white bars;
- OTOH Barcode Battle (used by Barcode World for NES and a few SNES
- titles) sends the digits as sequences of 20 bytes (13 for the code,
- suitably padded for shorted codes, followed by a signature) and the
- actual serial transmission to the console is up to the slot device
- connected to the NES/SNES controller port (yet to be emulated, in this
- case)
-
- Note: we currently support the following barcode formats
- * UPC-A: 12 digits
- * EAN-13: 13 digits (extension of the former)
- * EAN-8: 8 digits (same encoding as UPC-A, but 4-digits blocks instead
- of 6-digits blocks)
- Notice that since EAN-13 is an extension of UPC-A, we just treat UPC-A
- as an EAN-13 code with leading '0'. If any barcode reader shall be found
- which supports the older format only, this shall be changed
-
-
- TODO: add support for UPC-E barcodes? these are 8 digits barcodes with 17
- black stripes (they are compressed UPC-A codes). Datach reader does not
- support these, so it is low priority
-
-
- TODO 2: verify barcode checksum in is_valid() and not only length, so
- that we can then use the actual last digit in the decode function below,
- rather than replacing it with the checksum value
-
-
- TODO 3: possibly the white spaces before the actual barcode (see the
- 61 white pixels sent by read_pixel() before and after the code), shall
- be moved to the specific implementations to emulate different "sensitivity"
- of the readers? Bandai Datach seems to need at least 32 pixels...
-
-***************************************************************************/
-
-#include "emu.h"
-#include "bcreader.h"
-
-// device type definition
-const device_type BARCODE_READER = &device_creator<barcode_reader_device>;
-
-//-------------------------------------------------
-// barcode_reader_device - constructor
-//-------------------------------------------------
-
-barcode_reader_device::barcode_reader_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, BARCODE_READER, "Barcode Reader", tag, owner, clock, "bcreader", __FILE__)
- , m_byte_length(0)
- , m_pixel_length(0)
- , m_byte_count(0)
- , m_pixel_count(0)
- , m_new_code(0)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void barcode_reader_device::device_start()
-{
- save_item(m_byte_data, "DATACH/m_byte_data");
- save_item(m_pixel_data, "DATACH/m_pixel_data");
- save_item(m_byte_length, "DATACH/m_byte_length");
- save_item(m_pixel_length, "DATACH/m_pixel_length");
- save_item(m_byte_count, "DATACH/m_byte_count");
- save_item(m_pixel_count, "DATACH/m_pixel_count");
- save_item(m_new_code, "DATACH/m_new_code");
-}
-
-
-//-------------------------------------------------
-// Barcode Decoding - convert the entered sequence
-// of digits into a sequence of B/W pixels (the
-// actual bars) - each digit corresponds to 7 pixels
-// 0 is black, 1 is white
-//-------------------------------------------------
-
-// Left Odd
-static const UINT8 bcread_data_LO[10][7] =
-{
- {1, 1, 1, 0, 0, 1, 0}, {1, 1, 0, 0, 1, 1, 0},
- {1, 1, 0, 1, 1, 0, 0}, {1, 0, 0, 0, 0, 1, 0},
- {1, 0, 1, 1, 1, 0, 0}, {1, 0, 0, 1, 1, 1, 0},
- {1, 0, 1, 0, 0, 0, 0}, {1, 0, 0, 0, 1, 0, 0},
- {1, 0, 0, 1, 0, 0, 0}, {1, 1, 1, 0, 1, 0, 0}
-};
-
-// Left Even
-static const UINT8 bcread_data_LE[10][7] =
-{
- {1, 0, 1, 1, 0, 0, 0}, {1, 0, 0, 1, 1, 0, 0},
- {1, 1, 0, 0, 1, 0, 0}, {1, 0, 1, 1, 1, 1, 0},
- {1, 1, 0, 0, 0, 1, 0}, {1, 0, 0, 0, 1, 1, 0},
- {1, 1, 1, 1, 0, 1, 0}, {1, 1, 0, 1, 1, 1, 0},
- {1, 1, 1, 0, 1, 1, 0}, {1, 1, 0, 1, 0, 0, 0}
-};
-
-// Right Even
-static const UINT8 bcread_data_RE[10][7] =
-{
- {0, 0, 0, 1, 1, 0, 1}, {0, 0, 1, 1, 0, 0, 1},
- {0, 0, 1, 0, 0, 1, 1}, {0, 1, 1, 1, 1, 0, 1},
- {0, 1, 0, 0, 0, 1, 1}, {0, 1, 1, 0, 0, 0, 1},
- {0, 1, 0, 1, 1, 1, 1}, {0, 1, 1, 1, 0, 1, 1},
- {0, 1, 1, 0, 1, 1, 1}, {0, 0, 0, 1, 0, 1, 1}
-};
-
-// EAN-13 added an extra digit to determine
-// the parity type of the first digits block
-static const UINT8 bcread_parity_type[10][6] =
-{
- {1, 1, 1, 1, 1, 1}, {1, 1, 0, 1, 0, 0},
- {1, 1, 0, 0, 1, 0}, {1, 1, 0, 0, 0, 1},
- {1, 0, 1, 1, 0, 0}, {1, 0, 0, 1, 1, 0},
- {1, 0, 0, 0, 1, 1}, {1, 0, 1, 0, 1, 0},
- {1, 0, 1, 0, 0, 1}, {1, 0, 0, 1, 0, 1}
-};
-
-
-void barcode_reader_device::decode(int len)
-{
- int output = 0;
- int sum = 0;
-
- if (len == 13)
- {
- // UPC-A and EAN-13
-
- m_pixel_data[output++] = 0;
- m_pixel_data[output++] = 1;
- m_pixel_data[output++] = 0;
-
- for (int i = 1; i < 7; i++)
- {
- if (bcread_parity_type[m_byte_data[0]][i - 1])
- {
- for (int j = 0; j < 7; j++)
- m_pixel_data[output++] = bcread_data_LO[m_byte_data[i]][j];
- }
- else
- {
- for (int j = 0; j < 7; j++)
- m_pixel_data[output++] = bcread_data_LE[m_byte_data[i]][j];
- }
- }
-
- m_pixel_data[output++] = 1;
- m_pixel_data[output++] = 0;
- m_pixel_data[output++] = 1;
- m_pixel_data[output++] = 0;
- m_pixel_data[output++] = 1;
-
- for (int i = 7; i < 12; i++)
- {
- for (int j = 0; j < 7; j++)
- m_pixel_data[output++] = bcread_data_RE[m_byte_data[i]][j];
- }
-
- // ignore the last digit and compute it as checksum of the first 12
- for (int i = 0; i < 12; i++)
- sum += (i & 1) ? (m_byte_data[i] * 3) : (m_byte_data[i] * 1);
- }
- else if (len == 8)
- {
- // EAN-8 (same encoding as UPC-A, but only 4+4 digits, instead of 6+6)
-
- m_pixel_data[output++] = 0;
- m_pixel_data[output++] = 1;
- m_pixel_data[output++] = 0;
-
- for (int i = 0; i < 4; i++)
- {
- for (int j = 0; j < 7; j++)
- m_pixel_data[output++] = bcread_data_LO[m_byte_data[i]][j];
- }
-
- m_pixel_data[output++] = 1;
- m_pixel_data[output++] = 0;
- m_pixel_data[output++] = 1;
- m_pixel_data[output++] = 0;
- m_pixel_data[output++] = 1;
-
- for (int i = 4; i < 7; i++)
- {
- for (int j = 0; j < 7; j++)
- m_pixel_data[output++] = bcread_data_RE[m_byte_data[i]][j];
- }
-
- // ignore the last digit and compute it as checksum of the first 12
- for (int i = 0; i < 7; i++)
- sum += (i & 1) ? (m_byte_data[i] * 1) : (m_byte_data[i] * 3);
- }
-
- if (m_pixel_data)
- {
- sum = (10 - (sum % 10)) % 10;
- if (sum != m_byte_data[len - 1])
- logerror("WARNING: wrong checksum detected in the barcode! chksum %d last digit %d\n",
- sum, m_byte_data[len - 1]);
-
- for (int i = 0; i < 7; i++)
- m_pixel_data[output++] = bcread_data_RE[sum][i];
-
- m_pixel_data[output++] = 0;
- m_pixel_data[output++] = 1;
- m_pixel_data[output++] = 0;
- }
-
- m_byte_length = len;
- m_pixel_length = output;
-
-// printf("byte len %d - pixel len\n", m_byte_length, m_pixel_length);
-}
-
-
-//-------------------------------------------------
-// write_code - invoked by UI, stores the barcode
-// both as an array of digits and as a sequence
-// of B/W pixels (the actual bars)
-//-------------------------------------------------
-
-void barcode_reader_device::write_code(const char *barcode, int len)
-{
- int shift = 0;
- int deconde_len = len;
-
- // len has already been checked to be one of the following: 8, 12 or 13
-
- if (deconde_len == 12)
- {
- // convert UPC-A to EAN-13
- shift = 1;
- deconde_len = 13;
- m_byte_data[0] = 0;
- }
-
- for (int i = 0; i < len; i++)
- m_byte_data[i+shift] = barcode[i] - '0';
-
- decode(deconde_len);
-
- m_new_code = 1;
-}
-
-
-//-------------------------------------------------
-// read_code - accessor for drivers which read
-// the codes by bytes
-//-------------------------------------------------
-
-UINT8 barcode_reader_device::read_code()
-{
- if (m_new_code)
- {
- if (m_byte_count < m_byte_length)
- {
- UINT8 val = m_byte_data[m_byte_count];
- m_byte_count++;
- return val;
- }
- else
- {
- m_byte_count = 0;
- m_new_code = 0;
- return 0;
- }
- }
-
- // no pending transfer
- return 0;
-}
-
-//-------------------------------------------------
-// read_pixel - accessor for drivers which read
-// the codes by pixels
-//-------------------------------------------------
-
-int barcode_reader_device::read_pixel()
-{
- if (m_new_code)
- {
- // start of card: 61 white pixels
- if (m_pixel_count < 61)
- {
- m_pixel_count++;
- return 1;
- }
- // barcode: approx 95 pixels for B/W bars
- else if (m_pixel_count < 61 + m_pixel_length)
- {
- // actual barcode starts here
- int val = m_pixel_data[m_pixel_count - 61];
- m_pixel_count++;
- return val;
- }
- // end of card: 61 white pixels
- else if (m_pixel_count < 61 + m_pixel_length + 61)
- {
- m_pixel_count++;
- return 1;
- }
- // finished scan, erase code
- else
- {
- m_pixel_count = 0;
- m_new_code = 0;
- return 0;
- }
- }
-
- // no pending transfer = black pixel = 0
- return 0;
-}
diff --git a/src/emu/machine/bcreader.h b/src/emu/machine/bcreader.h
deleted file mode 100644
index 23b80ddab70..00000000000
--- a/src/emu/machine/bcreader.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Fabio Priuli
-/*********************************************************************
-
- bcreader.h
-
- Generic barcode reader emulation.
-
-*********************************************************************/
-
-#ifndef __BCREADER_H_
-#define __BCREADER_H_
-
-#define MCFG_BARCODE_READER_ADD( _tag ) \
- MCFG_DEVICE_ADD( _tag, BARCODE_READER, 0 )
-
-#define MCFG_BARCODE_READER_REMOVE( _tag ) \
- MCFG_DEVICE_REMOVE( _tag )
-
-
-// ======================> barcode_reader_device
-
-class barcode_reader_device : public device_t
-{
-public:
- // construction/destruction
- barcode_reader_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- void write_code(const char *barcode, int len);
- int get_pending_code() { return m_new_code; }
- int get_byte_length() { return m_byte_length; }
- UINT8 read_code();
- int read_pixel();
-
- // TODO: add checksum validation!
- bool is_valid(int len) { return (len != 12 && len != 13 && len != 8) ? FALSE : TRUE; }
- void decode(int len);
-
-protected:
- // device-level overrides
- virtual void device_start();
-
- UINT8 m_byte_data[13];
- UINT8 m_pixel_data[100];
- int m_byte_length;
- int m_pixel_length;
- int m_byte_count;
- int m_pixel_count;
- int m_new_code;
-};
-
-
-// device type definition
-extern const device_type BARCODE_READER;
-
-// device type iterator
-typedef device_type_iterator<&device_creator<barcode_reader_device>, barcode_reader_device> barcode_reader_device_iterator;
-
-
-#endif
diff --git a/src/emu/machine/buffer.c b/src/emu/machine/buffer.c
deleted file mode 100644
index 6b2058c6937..00000000000
--- a/src/emu/machine/buffer.c
+++ /dev/null
@@ -1,17 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "emu.h"
-#include "buffer.h"
-
-const device_type INPUT_BUFFER = &device_creator<input_buffer_device>;
-
-input_buffer_device::input_buffer_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, INPUT_BUFFER, "Input Buffer", tag, owner, clock, "input_buffer", __FILE__),
- m_input_data(0xff)
-{
-}
-
-void input_buffer_device::device_start()
-{
- save_item(NAME(m_input_data));
-}
diff --git a/src/emu/machine/buffer.h b/src/emu/machine/buffer.h
deleted file mode 100644
index cab1b9914f4..00000000000
--- a/src/emu/machine/buffer.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#ifndef __BUFFER_H__
-#define __BUFFER_H__
-
-class input_buffer_device : public device_t
-{
-public:
- input_buffer_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- UINT8 read() { return m_input_data; }
- DECLARE_READ8_MEMBER(read) { return read(); }
-
- DECLARE_WRITE_LINE_MEMBER(write_bit0) { if (state) m_input_data |= 0x01; else m_input_data &= ~0x01; }
- DECLARE_WRITE_LINE_MEMBER(write_bit1) { if (state) m_input_data |= 0x02; else m_input_data &= ~0x02; }
- DECLARE_WRITE_LINE_MEMBER(write_bit2) { if (state) m_input_data |= 0x04; else m_input_data &= ~0x04; }
- DECLARE_WRITE_LINE_MEMBER(write_bit3) { if (state) m_input_data |= 0x08; else m_input_data &= ~0x08; }
- DECLARE_WRITE_LINE_MEMBER(write_bit4) { if (state) m_input_data |= 0x10; else m_input_data &= ~0x10; }
- DECLARE_WRITE_LINE_MEMBER(write_bit5) { if (state) m_input_data |= 0x20; else m_input_data &= ~0x20; }
- DECLARE_WRITE_LINE_MEMBER(write_bit6) { if (state) m_input_data |= 0x40; else m_input_data &= ~0x40; }
- DECLARE_WRITE_LINE_MEMBER(write_bit7) { if (state) m_input_data |= 0x80; else m_input_data &= ~0x80; }
-
-protected:
- virtual void device_start();
-
- UINT8 m_input_data;
-};
-
-extern const device_type INPUT_BUFFER;
-
-#endif
diff --git a/src/emu/machine/cdp1852.c b/src/emu/machine/cdp1852.c
deleted file mode 100644
index 7a91e4060c3..00000000000
--- a/src/emu/machine/cdp1852.c
+++ /dev/null
@@ -1,187 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- RCA CDP1852 Byte-Wide Input/Output Port emulation
-
-**********************************************************************/
-
-#include "cdp1852.h"
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type CDP1852 = &device_creator<cdp1852_device>;
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-enum
-{
- MODE_INPUT = 0,
- MODE_OUTPUT
-};
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// cdp1852_device - constructor
-//-------------------------------------------------
-
-cdp1852_device::cdp1852_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, CDP1852, "CDP1852 I/O", tag, owner, clock, "cdp1852", __FILE__),
- m_read_mode(*this),
- m_write_sr(*this),
- m_read_data(*this),
- m_write_data(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void cdp1852_device::device_start()
-{
- // resolve callbacks
- m_read_mode.resolve_safe(0);
- m_write_sr.resolve_safe();
- m_read_data.resolve_safe(0);
- m_write_data.resolve_safe();
-
- // allocate timers
- if (clock() > 0)
- {
- m_scan_timer = timer_alloc();
- m_scan_timer->adjust(attotime::zero, 0, attotime::from_hz(clock()));
- }
-
- // register for state saving
- save_item(NAME(m_new_data));
- save_item(NAME(m_data));
- save_item(NAME(m_next_data));
- save_item(NAME(m_sr));
- save_item(NAME(m_next_sr));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void cdp1852_device::device_reset()
-{
- // reset data register
- m_data = 0;
-
- if (!m_read_mode())
- {
- // reset service request flip-flop
- set_sr_line(1);
- }
- else
- {
- // output data
- m_write_data((offs_t)0, m_data);
-
- // reset service request flip-flop
- set_sr_line(0);
- }
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void cdp1852_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if (!m_read_mode())
- {
- // input data into register
- m_data = m_read_data(0);
-
- // signal processor
- set_sr_line(0);
- }
- else
- {
- if (m_new_data)
- {
- m_new_data = 0;
-
- // latch data into register
- m_data = m_next_data;
-
- // output data
- m_write_data((offs_t)0, m_data);
-
- // signal peripheral device
- set_sr_line(1);
-
- m_next_sr = 0;
- }
- else
- {
- set_sr_line(m_next_sr);
- }
- }
-}
-
-
-//-------------------------------------------------
-// set_sr_line -
-//-------------------------------------------------
-
-void cdp1852_device::set_sr_line(int state)
-{
- if (m_sr != state)
- {
- m_sr = state;
-
- m_write_sr(m_sr);
- }
-}
-
-
-//-------------------------------------------------
-// read - data read
-//-------------------------------------------------
-
-READ8_MEMBER( cdp1852_device::read )
-{
- if (!m_read_mode() && !clock())
- {
- // input data into register
- m_data = m_read_data(0);
- }
-
- set_sr_line(1);
-
- return m_data;
-}
-
-
-//-------------------------------------------------
-// write - data write
-//-------------------------------------------------
-
-WRITE8_MEMBER( cdp1852_device::write )
-{
- if (m_read_mode())
- {
- m_next_data = data;
- m_new_data = 1;
- }
-}
diff --git a/src/emu/machine/cdp1852.h b/src/emu/machine/cdp1852.h
deleted file mode 100644
index 232e148e474..00000000000
--- a/src/emu/machine/cdp1852.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- RCA CDP1852 Byte-Wide Input/Output Port emulation
-
-**********************************************************************
- _____ _____
- CSI/_CSI 1 |* \_/ | 24 Vdd
- MODE 2 | | 23 _SR/SR
- DI0 3 | | 22 DI7
- DO0 4 | | 21 DO7
- DI1 5 | | 20 DI6
- DO1 6 | CDP1852 | 19 DO6
- DI2 7 | | 18 DI5
- DO2 8 | | 17 DO5
- DI3 9 | | 16 DI4
- DO3 10 | | 15 DO4
- CLOCK 11 | | 14 _CLEAR
- Vss 12 |_____________| 13 CS2
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __CDP1852__
-#define __CDP1852__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_CDP1852_MODE_CALLBACK(_read) \
- devcb = &cdp1852_device::set_mode_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1852_SR_CALLBACK(_write) \
- devcb = &cdp1852_device::set_sr_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_CDP1852_DI_CALLBACK(_read) \
- devcb = &cdp1852_device::set_data_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1852_DO_CALLBACK(_write) \
- devcb = &cdp1852_device::set_data_wr_callback(*device, DEVCB_##_write);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> cdp1852_device
-
-class cdp1852_device : public device_t
-{
-public:
- // construction/destruction
- cdp1852_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_mode_rd_callback(device_t &device, _Object object) { return downcast<cdp1852_device &>(device).m_read_mode.set_callback(object); }
- template<class _Object> static devcb_base &set_sr_wr_callback(device_t &device, _Object object) { return downcast<cdp1852_device &>(device).m_write_sr.set_callback(object); }
- template<class _Object> static devcb_base &set_data_rd_callback(device_t &device, _Object object) { return downcast<cdp1852_device &>(device).m_read_data.set_callback(object); }
- template<class _Object> static devcb_base &set_data_wr_callback(device_t &device, _Object object) { return downcast<cdp1852_device &>(device).m_write_data.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- void set_sr_line(int state);
-
- devcb_read_line m_read_mode;
- devcb_write_line m_write_sr;
- devcb_read8 m_read_data;
- devcb_write8 m_write_data;
-
- int m_new_data; // new data written
- UINT8 m_data; // data latch
- UINT8 m_next_data; // next data
-
- int m_sr; // service request flag
- int m_next_sr; // next value of service request flag
-
- // timers
- emu_timer *m_scan_timer;
-};
-
-
-// device type definition
-extern const device_type CDP1852;
-
-
-
-#endif
diff --git a/src/emu/machine/cdp1871.c b/src/emu/machine/cdp1871.c
deleted file mode 100644
index e685f8c43ad..00000000000
--- a/src/emu/machine/cdp1871.c
+++ /dev/null
@@ -1,290 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- RCA CDP1871 Keyboard Encoder emulation
-
-**********************************************************************/
-
-#include "cdp1871.h"
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type CDP1871 = &device_creator<cdp1871_device>;
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-const UINT8 cdp1871_device::key_codes[4][11][8] =
-{
- // normal
- {
- { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 },
- { 0x38, 0x39, 0x3a, 0x3b, 0x2c, 0x2d, 0x2e, 0x2f },
- { 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67 },
- { 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f },
- { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77 },
- { 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f },
- { 0x20, 0xff, 0x0a, 0x1b, 0xff, 0x0d, 0xff, 0x7f },
- { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87 },
- { 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f },
- { 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97 },
- { 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f }
- },
-
- // alpha
- {
- { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 },
- { 0x38, 0x39, 0x3a, 0x3b, 0x2c, 0x2d, 0x2e, 0x2f },
- { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47 },
- { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f },
- { 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57 },
- { 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f },
- { 0x20, 0xff, 0x0a, 0x1b, 0xff, 0x0d, 0xff, 0x7f },
- { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87 },
- { 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f },
- { 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97 },
- { 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f }
- },
-
- // shift
- {
- { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27 },
- { 0x28, 0x29, 0x2a, 0x2b, 0x3c, 0x3d, 0x3e, 0x3f },
- { 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47 },
- { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f },
- { 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57 },
- { 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f },
- { 0x20, 0xff, 0x0a, 0x1b, 0xff, 0x0d, 0xff, 0x7f },
- { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87 },
- { 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f },
- { 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97 },
- { 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f }
- },
-
- // control
- {
- { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
- { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
- { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
- { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
- { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
- { 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
- { 0x20, 0xff, 0x0a, 0x1b, 0xff, 0x0d, 0xff, 0x7f },
- { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87 },
- { 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f },
- { 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97 },
- { 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f }
- }
-};
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// cdp1871_device - constructor
-//-------------------------------------------------
-
-cdp1871_device::cdp1871_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, CDP1871, "RCA CDP1871", tag, owner, clock, "cdp1871", __FILE__),
- m_read_d1(*this),
- m_read_d2(*this),
- m_read_d3(*this),
- m_read_d4(*this),
- m_read_d5(*this),
- m_read_d6(*this),
- m_read_d7(*this),
- m_read_d8(*this),
- m_read_d9(*this),
- m_read_d10(*this),
- m_read_d11(*this),
- m_write_da(*this),
- m_write_rpt(*this),
- m_inhibit(false),
- m_sense(0),
- m_drive(0),
- m_shift(0),
- m_shift_latch(0),
- m_control(0),
- m_control_latch(0),
- m_alpha(0),
- m_da(0),
- m_next_da(CLEAR_LINE),
- m_rpt(0),
- m_next_rpt(CLEAR_LINE)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void cdp1871_device::device_start()
-{
- // resolve callbacks
- m_read_d1.resolve_safe(0xff);
- m_read_d2.resolve_safe(0xff);
- m_read_d3.resolve_safe(0xff);
- m_read_d4.resolve_safe(0xff);
- m_read_d5.resolve_safe(0xff);
- m_read_d6.resolve_safe(0xff);
- m_read_d7.resolve_safe(0xff);
- m_read_d8.resolve_safe(0xff);
- m_read_d9.resolve_safe(0xff);
- m_read_d10.resolve_safe(0xff);
- m_read_d11.resolve_safe(0xff);
- m_write_da.resolve_safe();
- m_write_rpt.resolve_safe();
-
- // set initial values
- change_output_lines();
-
- // allocate timers
- m_scan_timer = timer_alloc();
- m_scan_timer->adjust(attotime::zero, 0, attotime::from_hz(clock()));
-
- // register for state saving
- save_item(NAME(m_inhibit));
- save_item(NAME(m_sense));
- save_item(NAME(m_drive));
- save_item(NAME(m_shift));
- save_item(NAME(m_shift_latch));
- save_item(NAME(m_control));
- save_item(NAME(m_control_latch));
- save_item(NAME(m_alpha));
- save_item(NAME(m_da));
- save_item(NAME(m_next_da));
- save_item(NAME(m_rpt));
- save_item(NAME(m_next_rpt));
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void cdp1871_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- change_output_lines();
- clock_scan_counters();
- detect_keypress();
-}
-
-
-//-------------------------------------------------
-// change_output_lines - change output lines
-//-------------------------------------------------
-
-void cdp1871_device::change_output_lines()
-{
- if (m_next_da != m_da)
- {
- m_da = m_next_da;
-
- m_write_da(m_da);
- }
-
- if (m_next_rpt != m_rpt)
- {
- m_rpt = m_next_rpt;
-
- m_write_rpt(m_rpt);
- }
-}
-
-
-//-------------------------------------------------
-// clock_scan_counters - clock the keyboard
-// scan counters
-//-------------------------------------------------
-
-void cdp1871_device::clock_scan_counters()
-{
- if (!m_inhibit)
- {
- m_sense++;
-
- if (m_sense == 8)
- {
- m_sense = 0;
- m_drive++;
-
- if (m_drive == 11)
- {
- m_drive = 0;
- }
- }
- }
-}
-
-
-//-------------------------------------------------
-// detect_keypress - detect key press
-//-------------------------------------------------
-
-void cdp1871_device::detect_keypress()
-{
- UINT8 data = 0;
-
- switch (m_drive) {
- case 0: data = m_read_d1(0); break;
- case 1: data = m_read_d2(0); break;
- case 2: data = m_read_d3(0); break;
- case 3: data = m_read_d4(0); break;
- case 4: data = m_read_d5(0); break;
- case 5: data = m_read_d6(0); break;
- case 6: data = m_read_d7(0); break;
- case 7: data = m_read_d8(0); break;
- case 8: data = m_read_d9(0); break;
- case 9: data = m_read_d10(0); break;
- case 10: data = m_read_d11(0); break;
- }
-
- if (data == (1 << m_sense))
- {
- if (!m_inhibit)
- {
- m_shift_latch = m_shift;
- m_control_latch = m_control;
- m_inhibit = true;
- m_next_da = ASSERT_LINE;
- }
- else
- {
- m_next_rpt = ASSERT_LINE;
- }
- }
- else
- {
- m_inhibit = false;
- m_next_rpt = CLEAR_LINE;
- }
-}
-
-
-//-------------------------------------------------
-// read - keyboard data read
-//-------------------------------------------------
-
-READ8_MEMBER( cdp1871_device::read )
-{
- int table = 0;
-
- if (m_control_latch) table = 3; else if (m_shift_latch) table = 2; else if (m_alpha) table = 1;
-
- // reset DA on next TPB
- m_next_da = CLEAR_LINE;
-
- return key_codes[table][m_drive][m_sense];
-}
diff --git a/src/emu/machine/cdp1871.h b/src/emu/machine/cdp1871.h
deleted file mode 100644
index 651f9c4343d..00000000000
--- a/src/emu/machine/cdp1871.h
+++ /dev/null
@@ -1,172 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- RCA CDP1871 Keyboard Encoder emulation
-
-**********************************************************************
- _____ _____
- D1 1 |* \_/ | 40 Vdd
- D2 2 | | 39 SHIFT
- D3 3 | | 38 CONTROL
- D4 4 | | 37 ALPHA
- D5 5 | | 36 DEBOUNCE
- D6 6 | | 35 _RPT
- D7 7 | | 34 TPB
- D8 8 | | 33 _DA
- D9 9 | | 32 BUS 7
- D10 10 | CDP1871 | 31 BUS 6
- D11 11 | | 30 BUS 5
- S1 12 | | 29 BUS 4
- S2 13 | | 28 BUS 3
- S3 14 | | 27 BUS 2
- S4 15 | | 26 BUS 1
- S5 16 | | 25 BUS 0
- S6 17 | | 24 CS4
- S7 18 | | 23 CS3
- S8 19 | | 22 CS2
- Vss 20 |_____________| 21 _CS1
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __CDP1871__
-#define __CDP1871__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_CDP1871_D1_CALLBACK(_read) \
- devcb = &cdp1871_device::set_d1_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1871_D2_CALLBACK(_read) \
- devcb = &cdp1871_device::set_d2_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1871_D3_CALLBACK(_read) \
- devcb = &cdp1871_device::set_d3_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1871_D4_CALLBACK(_read) \
- devcb = &cdp1871_device::set_d4_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1871_D5_CALLBACK(_read) \
- devcb = &cdp1871_device::set_d5_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1871_D6_CALLBACK(_read) \
- devcb = &cdp1871_device::set_d6_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1871_D7_CALLBACK(_read) \
- devcb = &cdp1871_device::set_d7_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1871_D8_CALLBACK(_read) \
- devcb = &cdp1871_device::set_d8_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1871_D9_CALLBACK(_read) \
- devcb = &cdp1871_device::set_d9_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1871_D10_CALLBACK(_read) \
- devcb = &cdp1871_device::set_d10_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1871_D11_CALLBACK(_read) \
- devcb = &cdp1871_device::set_d11_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_CDP1871_DA_CALLBACK(_write) \
- devcb = &cdp1871_device::set_da_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_CDP1871_RPT_CALLBACK(_write) \
- devcb = &cdp1871_device::set_rpt_wr_callback(*device, DEVCB_##_write);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> cdp1871_device
-
-class cdp1871_device : public device_t
-{
-public:
- // construction/destruction
- cdp1871_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_d1_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d1.set_callback(object); }
- template<class _Object> static devcb_base &set_d2_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d2.set_callback(object); }
- template<class _Object> static devcb_base &set_d3_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d3.set_callback(object); }
- template<class _Object> static devcb_base &set_d4_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d4.set_callback(object); }
- template<class _Object> static devcb_base &set_d5_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d5.set_callback(object); }
- template<class _Object> static devcb_base &set_d6_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d6.set_callback(object); }
- template<class _Object> static devcb_base &set_d7_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d7.set_callback(object); }
- template<class _Object> static devcb_base &set_d8_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d8.set_callback(object); }
- template<class _Object> static devcb_base &set_d9_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d9.set_callback(object); }
- template<class _Object> static devcb_base &set_d10_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d10.set_callback(object); }
- template<class _Object> static devcb_base &set_d11_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d11.set_callback(object); }
- template<class _Object> static devcb_base &set_da_wr_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_write_da.set_callback(object); }
- template<class _Object> static devcb_base &set_rpt_wr_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_write_rpt.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
-
- DECLARE_READ_LINE_MEMBER( da_r ) { return m_da; }
- DECLARE_READ_LINE_MEMBER( rpt_r ) { return m_rpt; }
-
- DECLARE_WRITE_LINE_MEMBER( shift_w ) { m_shift = state; }
- DECLARE_WRITE_LINE_MEMBER( control_w ) { m_control = state; }
- DECLARE_WRITE_LINE_MEMBER( alpha_w ) { m_alpha = state; }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- void change_output_lines();
- void clock_scan_counters();
- void detect_keypress();
-
-private:
- devcb_read8 m_read_d1;
- devcb_read8 m_read_d2;
- devcb_read8 m_read_d3;
- devcb_read8 m_read_d4;
- devcb_read8 m_read_d5;
- devcb_read8 m_read_d6;
- devcb_read8 m_read_d7;
- devcb_read8 m_read_d8;
- devcb_read8 m_read_d9;
- devcb_read8 m_read_d10;
- devcb_read8 m_read_d11;
- devcb_write_line m_write_da;
- devcb_write_line m_write_rpt;
-
- bool m_inhibit; // scan counter clock inhibit
- int m_sense; // sense input scan counter
- int m_drive; // modifier inputs
-
- int m_shift;
- int m_shift_latch; // latched shift modifier
- int m_control;
- int m_control_latch; // latched control modifier
- int m_alpha;
-
- int m_da; // data available flag
- int m_next_da; // next value of data available flag
- int m_rpt; // repeat flag
- int m_next_rpt; // next value of repeat flag
-
- // timers
- emu_timer *m_scan_timer; // keyboard scan timer
-
- static const UINT8 key_codes[4][11][8];
-};
-
-
-// device type definition
-extern const device_type CDP1871;
-
-
-
-#endif
diff --git a/src/emu/machine/clock.c b/src/emu/machine/clock.c
deleted file mode 100644
index 9896bebabcc..00000000000
--- a/src/emu/machine/clock.c
+++ /dev/null
@@ -1,68 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "clock.h"
-
-const device_type CLOCK = &device_creator<clock_device>;
-
-clock_device::clock_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, CLOCK, "Clock", tag, owner, clock, "clock", __FILE__),
- m_signal(0),
- m_timer(NULL),
- m_signal_handler(*this)
-{
-}
-
-void clock_device::device_start()
-{
- m_signal_handler.resolve();
-
- save_item(NAME(m_signal));
-}
-
-void clock_device::device_clock_changed()
-{
- update_timer();
-}
-
-attotime clock_device::period()
-{
- if (m_clock > 0)
- return attotime::from_hz(m_clock * 2);
-
- return attotime::never;
-}
-
-void clock_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- m_signal = !m_signal;
- m_signal_handler(m_signal);
-
- m_timer->adjust(period());
-}
-
-void clock_device::update_timer()
-{
- if (!m_signal_handler.isnull() && m_clock > 0)
- {
- if (m_timer == NULL)
- {
- m_timer = timer_alloc(0);
- m_timer->adjust(period());
- }
- else
- {
- attotime next = period() - m_timer->elapsed();
-
- if (next < attotime::zero)
- {
- next = attotime::zero;
- }
-
- m_timer->adjust(next);
- }
- }
- else if (m_timer != NULL)
- {
- m_timer->adjust(attotime::never);
- }
-}
diff --git a/src/emu/machine/clock.h b/src/emu/machine/clock.h
deleted file mode 100644
index 9f3712327aa..00000000000
--- a/src/emu/machine/clock.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#ifndef __CLOCK_H__
-#define __CLOCK_H__
-
-#pragma once
-
-#include "emu.h"
-
-#define MCFG_CLOCK_SIGNAL_HANDLER(_devcb) \
- devcb = &clock_device::set_signal_handler(*device, DEVCB_##_devcb);
-
-class clock_device : public device_t
-{
-public:
- clock_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_signal_handler(device_t &device, _Object object) { return downcast<clock_device &>(device).m_signal_handler.set_callback(object); }
-
-protected:
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual void device_clock_changed();
-
-private:
- void update_timer();
- attotime period();
-
- int m_signal;
- emu_timer *m_timer;
-
- devcb_write_line m_signal_handler;
-};
-
-extern const device_type CLOCK;
-
-#endif
diff --git a/src/emu/machine/com8116.c b/src/emu/machine/com8116.c
deleted file mode 100644
index 46a0ce83986..00000000000
--- a/src/emu/machine/com8116.c
+++ /dev/null
@@ -1,159 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- COM8116 Dual Baud Rate Generator (Programmable Divider) emulation
-
-**********************************************************************/
-
-#include "com8116.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-// device type definition
-const device_type COM8116 = &device_creator<com8116_device>;
-
-
-const int com8116_device::divisors_16X_5_0688MHz[] =
- { 6336, 4224, 2880, 2355, 2112, 1056, 528, 264, 176, 158, 132, 88, 66, 44, 33, 16 };
-
-const int com8116_device::divisors_16X_4_9152MHz[] =
- { 6144, 4096, 2793, 2284, 2048, 1024, 512, 256, 171, 154, 128, 85, 64, 43, 32, 16 };
-
-const int com8116_device::divisors_32X_5_0688MHz[] =
- { 3168, 2112, 1440, 1177, 1056, 792, 528, 264, 132, 88, 66, 44, 33, 22, 16, 8 };
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// com8116_device - constructor
-//-------------------------------------------------
-
-com8116_device::com8116_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, COM8116, "COM8116", tag, owner, clock, "com8116", __FILE__),
- m_fx4_handler(*this),
- m_fr_handler(*this),
- m_ft_handler(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void com8116_device::device_start()
-{
- // resolve callbacks
- m_fx4_handler.resolve_safe();
- m_fr_handler.resolve_safe();
- m_ft_handler.resolve_safe();
-
- // allocate timers
- m_fx4_timer = timer_alloc(TIMER_FX4);
- m_fx4_timer->adjust(attotime::from_hz((clock() / 4) * 2), 0, attotime::from_hz((clock() / 4)) * 2);
- m_fr_timer = timer_alloc(TIMER_FR);
- m_ft_timer = timer_alloc(TIMER_FT);
-
- m_fr_divisors = divisors_16X_5_0688MHz;
- m_ft_divisors = divisors_16X_5_0688MHz;
-
- // register for state saving
- save_item(NAME(m_fx4));
- save_item(NAME(m_fr));
- save_item(NAME(m_ft));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void com8116_device::device_reset()
-{
- m_fx4 = 0;
- m_fr = 0;
- m_ft = 0;
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void com8116_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_FX4:
- m_fx4 = !m_fx4;
- m_fx4_handler(m_fx4);
- break;
-
- case TIMER_FR:
- m_fr = !m_fr;
- m_fr_handler(m_fr);
- break;
-
- case TIMER_FT:
- m_ft = !m_ft;
- m_ft_handler(m_ft);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// str_w -
-//-------------------------------------------------
-
-void com8116_device::str_w(UINT8 data)
-{
- int fr_divider = data & 0x0f;
- int fr_clock = clock() / m_fr_divisors[fr_divider];
-
- if (LOG) logerror("COM8116 '%s' Receiver Divisor Select %01x: %u (%u Hz)\n", tag(), data & 0x0f, m_fr_divisors[fr_divider], fr_clock);
-
- m_fr_timer->adjust(attotime::from_nsec(3500), 0, attotime::from_hz(fr_clock * 2));
-}
-
-WRITE8_MEMBER( com8116_device::str_w )
-{
- str_w(data);
-}
-
-
-//-------------------------------------------------
-// stt_w -
-//-------------------------------------------------
-
-void com8116_device::stt_w(UINT8 data)
-{
- int ft_divider = data & 0x0f;
- int ft_clock = clock() / m_ft_divisors[ft_divider];
-
- if (LOG) logerror("COM8116 '%s' Transmitter Divisor Select %01x: %u (%u Hz)\n", tag(), data & 0x0f, m_ft_divisors[ft_divider], ft_clock);
-
- m_ft_timer->adjust(attotime::from_nsec(3500), 0, attotime::from_hz(ft_clock * 2));
-}
-
-WRITE8_MEMBER( com8116_device::stt_w )
-{
- stt_w(data);
-}
diff --git a/src/emu/machine/com8116.h b/src/emu/machine/com8116.h
deleted file mode 100644
index a423f3782d7..00000000000
--- a/src/emu/machine/com8116.h
+++ /dev/null
@@ -1,104 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- COM8116 Dual Baud Rate Generator (Programmable Divider) emulation
-
-**********************************************************************
- _____ _____
- XTAL/EXT1 1 |* \_/ | 18 XTAL/EXT2
- +5V 2 | | 17 fT
- fR 3 | | 16 Ta
- Ra 4 | COM8116 | 15 Tb
- Rb 5 | COM8116T | 14 Tc
- Rc 6 | COM8136 | 13 Td
- Rd 7 | COM8136T | 12 STT
- STR 8 | | 11 GND
- NC 9 |_____________| 10 fX/4
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __COM8116__
-#define __COM8116__
-
-#include "emu.h"
-
-
-
-///*************************************************************************
-// INTERFACE CONFIGURATION MACROS
-///*************************************************************************
-
-#define MCFG_COM8116_FX4_HANDLER(_devcb) \
- devcb = &com8116_device::set_fx4_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_COM8116_FR_HANDLER(_devcb) \
- devcb = &com8116_device::set_fr_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_COM8116_FT_HANDLER(_devcb) \
- devcb = &com8116_device::set_ft_handler(*device, DEVCB_##_devcb);
-
-
-///*************************************************************************
-// TYPE DEFINITIONS
-///*************************************************************************
-
-// ======================> com8116_device
-
-class com8116_device : public device_t
-{
-public:
- // construction/destruction
- com8116_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_fx4_handler(device_t &device, _Object object) { return downcast<com8116_device &>(device).m_fx4_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_fr_handler(device_t &device, _Object object) { return downcast<com8116_device &>(device).m_fr_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_ft_handler(device_t &device, _Object object) { return downcast<com8116_device &>(device).m_ft_handler.set_callback(object); }
-
- void str_w(UINT8 data);
- DECLARE_WRITE8_MEMBER( str_w );
- void stt_w(UINT8 data);
- DECLARE_WRITE8_MEMBER( stt_w );
-
- static const int divisors_16X_5_0688MHz[];
- static const int divisors_16X_4_9152MHz[];
- static const int divisors_32X_5_0688MHz[];
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int m_param, void *ptr);
-
-private:
- enum
- {
- TIMER_FX4,
- TIMER_FR,
- TIMER_FT
- };
-
- devcb_write_line m_fx4_handler;
- devcb_write_line m_fr_handler;
- devcb_write_line m_ft_handler;
-
- int m_fx4;
- int m_fr;
- int m_ft;
-
- const int *m_fr_divisors;
- const int *m_ft_divisors;
-
- // timers
- emu_timer *m_fx4_timer;
- emu_timer *m_fr_timer;
- emu_timer *m_ft_timer;
-};
-
-
-// device type definition
-extern const device_type COM8116;
-
-#endif
diff --git a/src/emu/machine/corvushd.c b/src/emu/machine/corvushd.c
deleted file mode 100644
index 0444d3cb530..00000000000
--- a/src/emu/machine/corvushd.c
+++ /dev/null
@@ -1,1475 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Brett Wyer, Raphael Nabet
-//
-// corvus_hd
-//
-// Implementation of a Corvus Hard Drive / Host Bus Adapter pair. The drive
-// being emulated is a Rev B drive, functionally speaking, rather than an Omnidrive.
-//
-// The Corvus Flat Cable HBA is a very simplistic device due to the fact that most
-// of the smarts are in the Hard Drive itself. What's in the hard drive includes a
-// Z80 processor, 4K of EPROM and 5KB of RAM. Ultimately, a true emulation would include
-// the on-boad controller; however, that is outside the current scope of this code. Maybe
-// if I could get a Rev. B/H drive, it could be reverse-engineered to do this.
-//
-// The Flat Cable controller has two registers:
-//
-// Data - Single byte bidirectional data transfer
-// Status Register - Bit 7 - Controller Ready -- off = ready, on = not ready
-// Bit 6 - Bus Direction -- off = host-to-controller, on = controller-to-host
-//
-// Layout of a Corvus Hard Disk is as follows:
-//
-// Blk Len Description
-// --- --- -----------
-// 0 1 Boot Block
-// 1 1 Disk Parameter Block
-// 2 1 Diagnostic Block (prep code)
-// 3 1 Constellation Parameter Block
-// 4 2 Dispatcher Code
-// 6 2 Pipes and Semaphores code (Semaphore table contained in block 7, bytes 1-256)
-// 8 10 Mirror Controller Code
-// 18 2 LSI-11 Controller Code
-// 20 2 Pipes Controller Code
-// 22 3 Reserved for Future Use
-// 25 8 Boot Blocks 0-7. Apple II uses 0-3, Concept uses 4-7
-// 33 4 Active User Table
-// 37 3 Reserved
-//
-// All of the above blocks are initialized by the DDIAG program. This can be found on the
-// Concept FSYSGEN floppy.
-// - Boot blocks and code blocks are initialized using the "Update Firmware on Disk" function.
-// - Disk Parameter Block is initialized using the "Display/Modify Drive Parameters" function
-//
-// An on-disk structure is written with the SYSGEN utility on the same disk. Password is "HAI"
-//
-//
-// Corvus Hard Disk performance characteristics (from a 6MB Rev B-E drive)
-//
-// Average Latency: 6.25ms
-// Average Access Time: 125ms (and you thought YOUR drive was slow...)
-// Maximum Access Time: 240ms
-// Maximum Access Time (single track): 3ms
-// Data Transfer Rate: 960Kb/sec
-// Rotational Speed: 4800RPM
-//
-// Brett Wyer
-//
-//
-// TODO:
-// Implement READY line glitch after last byte of command (Disk System Tech Ref pp. 3)
-// Implement Read-after-Write (always happens on Rev B/H drives per Mass Storage GTI pp. 12)
-// Implement Drive Illegal Addresses (seek past last sector)
-// Implement Switches on front of drive (LSI-11, MUX, Format, Reset)
-// Implement an inter-sector delay during the FORMAT command (format happens too quickly now)
-//
-
-#include "emu.h"
-#include "imagedev/harddriv.h"
-#include "machine/corvushd.h"
-#include <ctype.h>
-
-
-const device_type CORVUS_HDC = &device_creator<corvus_hdc_t>;
-
-corvus_hdc_t::corvus_hdc_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, CORVUS_HDC, "Corvus Flat Cable HDC", tag, owner, clock, "corvus_hdc", __FILE__),
- m_status(0),
- m_prep_mode(false),
- m_prep_drv(0),
- m_sectors_per_track(0),
- m_tracks_per_cylinder(0),
- m_cylinders_per_drive(0),
- m_offset(0),
- m_awaiting_modifier(false),
- m_recv_bytes(0),
- m_xmit_bytes(0),
- m_last_cylinder(0),
- m_delay(0),
- m_invalid_command_flag(false)
-{
-}
-
-#define VERBOSE 0
-#define VERBOSE_RESPONSES 0
-#define ROM_VERSION 1 // Controller ROM version
-#define MAX_COMMAND_SIZE 4096 // The maximum size of a command packet (the controller only has 5K of RAM...)
-#define SPARE_TRACKS 7 // This is a Rev B drive, so 7 it is
-#define CALLBACK_CTH_MODE 1 // Set to Controller-to-Host mode when callback fires
-#define CALLBACK_HTC_MODE 2 // Set to Host-to-Controller mode when callback fires
-#define CALLBACK_SAME_MODE 3 // Leave mode the same when callback fires
-#define CALLBACK_TIMEOUT 4 // Four seconds have elapsed. We're timing out
-#define TRACK_SEEK_TIME 1667 // Track-to-track seek time in microseconds (Maximum Access Time / Total Cylinders)
-#define INTERBYTE_DELAY 5 // Inter-byte delay in microseconds communicating between controller and host
-#define INTERSECTOR_DELAY 25000 // 25ms delay between sectors (4800 RPM = 80 Rev/Second. Maximum 2 sectors transferred / Rev)
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-#define LOG_BUFFER(p,s) do { if (VERBOSE) dump_buffer(p,s); } while (0)
-
-
-
-//
-// Dump_Buffer
-//
-// Dump a buffer to the error log in a nice format.
-//
-// Pass:
-// buffer: Data to be dumped
-// length: Number of bytes to be dumped
-//
-// Returns:
-// nada
-//
-void corvus_hdc_t::dump_buffer(UINT8 *buffer, UINT16 length) {
- UINT16 offset;
- char ascii_dump[16];
-
- logerror("dump_buffer: Dump of %d bytes:\n", length);
- logerror("Base 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ASCII\n");
- logerror("---- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ----------------");
-
- for(offset=0; offset < length; offset++) {
- if(offset % 16 == 0) { // WHY IS 0 % 16 == 0???
- if(offset > 0 && offset % 16 == 0)
- logerror("%16.16s", ascii_dump);
- logerror("\n%4.4x: %2.2x ", offset, *(buffer + offset));
- } else {
- logerror("%2.2x ", *(buffer + offset));
- }
- ascii_dump[offset % 16] = isprint(*(buffer + offset)) ? *(buffer + offset) : '.';
- }
- if(offset % 16)
- logerror("%.*s", (16 - (offset % 16)) * 3, " ");
- logerror("%.*s\n", (offset % 16) ? (offset % 16) : 16, ascii_dump);
-}
-
-
-
-//
-// Parse_HDC_Command
-//
-// Process the first byte received from the host. Do some initial evaluation and
-// return either true or false as to whether the command was invalid or not.
-//
-// Note that recv_bytes and xmit_bytes in the corvus_hdc structure are updated as
-// a side-effect of this command, as is awaiting_modifier.
-//
-// Pass:
-// data: Initial byte received from the host in Host to Controller mode
-//
-// Returns:
-// Whether the command was invalid or not (true = invalid command)
-//
-bool corvus_hdc_t::parse_hdc_command(UINT8 data) {
- m_awaiting_modifier = false; // This is the case by definition
-
- LOG(("parse_hdc_command: Called with data: 0x%2.2x, Prep mode is: %d\n", data, m_prep_mode));
-
- if(!m_prep_mode) {
- switch(data) {
- //
- // Single-byte commands - Non-Prep mode
- //
- case READ_SECTOR_256:
- case WRITE_SECTOR_256:
- case READ_CHUNK_128:
- case READ_CHUNK_256:
- case READ_CHUNK_512:
- case WRITE_CHUNK_128:
- case WRITE_CHUNK_256:
- case WRITE_CHUNK_512:
- case READTEMPBLOCK:
- case WRITETEMPBLOCK:
- case BOOT:
- case READ_BOOT_BLOCK:
- case GET_DRIVE_PARAMETERS:
- // case PARK_HEADS_REVH:
- case PARK_HEADS_OMNI:
- case ECHO:
- case PREP_MODE_SELECT:
- m_recv_bytes = corvus_cmd[data][0].recv_bytes;
- m_xmit_bytes = corvus_cmd[data][0].xmit_bytes;
- LOG(("parse_hdc_command: Single byte command recognized: 0x%2.2x, to recv: %d, to xmit: %d\n", data,
- m_recv_bytes, m_xmit_bytes));
- break;
- //
- // Double-byte commands
- //
- case SEMAPHORE_LOCK_CODE:
- // case SEMAPHORE_UNLOCK_CODE:
- case SEMAPHORE_INIT_CODE:
- // case PIPE_READ_CODE:
- // case PIPE_WRITE_CODE:
- // case PIPE_CLOSE_CODE:
- // case PIPE_STATUS_CODE:
- // case SEMAPHORE_STATUS_CODE:
- case PIPE_OPEN_WRITE_CODE:
- // case PIPE_AREA_INIT_CODE:
- // case PIPE_OPEN_READ_CODE:
- case ADDACTIVE_CODE:
- // case DELACTIVEUSR_REVBH_CODE:
- // case DELACTIVEUSR_OMNI_CODE:
- // case DELACTIVENUM_OMNI_CODE:
- // case FINDACTIVE_CODE:
- m_awaiting_modifier = true;
- LOG(("parse_hdc_command: Double byte command recognized: 0x%2.2x\n", data));
- break;
-
- default: // This is an INVALID command
- m_recv_bytes = 1;
- m_xmit_bytes = 1;
- LOG(("parse_hdc_command: Invalid command detected: 0x%2.2x\n", data));
- return true;
- }
- } else {
- switch(data) {
- //
- // Prep Commands
- //
- case PREP_MODE_SELECT:
- case PREP_RESET_DRIVE:
- case PREP_FORMAT_DRIVE:
- case PREP_FILL_DRIVE_OMNI:
- case PREP_VERIFY:
- case PREP_READ_FIRMWARE:
- case PREP_WRITE_FIRMWARE:
- m_recv_bytes = corvus_prep_cmd[data].recv_bytes;
- m_xmit_bytes = corvus_prep_cmd[data].xmit_bytes;
- LOG(("parse_hdc_command: Prep command recognized: 0x%2.2x, to recv: %d, to xmit: %d\n", data,
- m_recv_bytes, m_xmit_bytes));
- break;
-
- default: // This is an INVALID prep command
- m_recv_bytes = 1;
- m_xmit_bytes = 1;
- LOG(("parse_hdc_command: Invalid Prep command detected: 0x%2.2x\n", data));
- return true;
- }
- } // if(!prep_mode)
-
- return false;
-}
-
-
-
-//
-// Corvus_Write_Sector
-//
-// Write a variably-sized chunk of data to the CHD file
-//
-// Pass:
-// drv: Corvus drive id (1..15)
-// sector: Physical sector number to write to
-// buffer: Buffer to write
-// len: Length of the buffer (amount of data to write)
-//
-// Returns:
-// status: Command status
-//
-UINT8 corvus_hdc_t::corvus_write_sector(UINT8 drv, UINT32 sector, UINT8 *buffer, int len) {
- hard_disk_file
- *disk; // Structures for interface to CHD routines
- UINT8 tbuffer[512]; // Buffer to hold an entire sector
- UINT16 cylinder; // Cylinder this sector resides on
-
- LOG(("corvus_write_sector: Write Drive: %d, physical sector: 0x%5.5x\n", drv, sector));
-
- disk = corvus_hdc_file(drv);
- if(!disk) {
- logerror("corvus_write_sector: Failure returned by corvus_hdc_file(%d)\n", drv);
- return STAT_FATAL_ERR | STAT_DRIVE_NOT_ONLINE;
- }
-
- //
- // Calculate what cylinder the sector resides on for timing purposes
- //
- cylinder = (double) sector / (double) m_sectors_per_track / (double) m_tracks_per_cylinder;
- m_delay = abs(m_last_cylinder - cylinder) * TRACK_SEEK_TIME + INTERSECTOR_DELAY;
-
- //
- // Corvus supports write sizes of 128, 256 and 512 bytes. In the case of a write smaller than
- // the sector size of 512 bytes, the sector is read, the provided data is overlayed and then the
- // sector is written back out. See pp. 5 of the Mass Storage Systems GTI for the details of this
- // wonderful functionality.
- //
- if(len == 512) {
- hard_disk_write(disk, sector, buffer);
- } else {
- hard_disk_read(disk, sector, tbuffer); // Read the existing data into our temporary buffer
- memcpy(tbuffer, buffer, len); // Overlay the data with the buffer passed
- m_delay += INTERSECTOR_DELAY; // Add another delay because of the Read / Write
- hard_disk_write(disk, sector, tbuffer); // Re-write the data
- }
-
- m_last_cylinder = cylinder;
-
- LOG(("corvus_write_sector: Full sector dump on a write of %d bytes follows:\n", len));
- LOG_BUFFER(len == 512 ? buffer : tbuffer, 512);
-
- return STAT_SUCCESS;
-}
-
-
-
-//
-// Corvus_Write_Logical_Sector
-//
-// Write a variably-sized chunk of data to the user area of the virtual Corvus drive
-//
-// Pass:
-// dadr: Corvus-encoded Disk Address -- Logical Sector
-// buffer: Buffer holding the data to be written to the disk
-// len: Length of the buffer
-//
-// Returns:
-// status: Corvus status
-//
-UINT8 corvus_hdc_t::corvus_write_logical_sector(dadr_t *dadr, UINT8 *buffer, int len) {
- UINT8 status; // Status returned from Physical Sector read
- UINT8 drv; // Corvus drive id (1..15)
- UINT32 sector; // Sector number on drive
-
- //
- // Unencode the first byte of the DADR
- //
- // High-order nibble of first byte is the most-significant nibble of the sector address
- // Low-order nibble of first byte is the drive id
- //
- // For example: 0x23 would decode to Drive ID #3, high-order nibble: 0x02.
- //
- drv = (dadr->address_msn_and_drive & 0x0f);
- sector = (dadr->address_msn_and_drive & 0xf0 << 12) | (dadr->address_mid << 8) | dadr->address_lsb;
-
- LOG(("corvus_write_logical_sector: Writing based on DADR: 0x%6.6x, logical sector: 0x%5.5x, drive: %d\n",
- dadr->address_msn_and_drive << 16 | dadr->address_lsb << 8 | dadr->address_mid, sector, drv));
-
- // Set m_tracks_per_cylinder and m_sectors_per_track
- corvus_hdc_file(drv);
-
- //
- // Shift the logical sector address forward by the number of firmware cylinders (2) + the number of spare tracks (7)
- //
- sector += (m_tracks_per_cylinder * m_sectors_per_track * 2) + (SPARE_TRACKS * m_sectors_per_track);
-
- status = corvus_write_sector(drv, sector, buffer, len);
-
- if(status != STAT_SUCCESS)
- m_xmit_bytes = 1;
-
- return status;
-}
-
-
-//
-// Corvus_Read_Sector
-//
-// Read a variably-sized chunk of data from the CHD file
-//
-// Pass:
-// drv: Corvus drive id (1..15)
-// sector: Physical sector number to read from
-// buffer: Buffer to hold the data read from the disk
-// len: Length of the buffer
-//
-// Returns:
-// status: Corvus status
-//
-UINT8 corvus_hdc_t::corvus_read_sector(UINT8 drv, UINT32 sector, UINT8 *buffer, int len) {
- hard_disk_file
- *disk; // Structures for interface to CHD routines
- UINT8 tbuffer[512]; // Buffer to store full sector results in
- UINT16 cylinder;
-
- LOG(("corvus_read_sector: Read Drive: %d, physical sector: 0x%5.5x\n", drv, sector));
-
- disk = corvus_hdc_file(drv);
- if(!disk) {
- logerror("corvus_read_sector: Failure returned by corvus_hdc_file(%d)\n", drv);
- return STAT_FATAL_ERR | STAT_DRIVE_NOT_ONLINE;
- }
-
- //
- // Calculate what cylinder the sector resides on for timing purposes
- //
- cylinder = (double) sector / (double) m_sectors_per_track / (double) m_tracks_per_cylinder;
- m_delay = abs(m_last_cylinder - cylinder) * TRACK_SEEK_TIME + INTERSECTOR_DELAY;
-
- hard_disk_read(disk, sector, tbuffer);
-
- memcpy(buffer, tbuffer, len);
-
- m_last_cylinder = cylinder;
-
- LOG(("corvus_read_sector: Data read follows:\n"));
- LOG_BUFFER(tbuffer, len);
-
- return STAT_SUCCESS;
-}
-
-
-
-//
-// Corvus_Read_Logical_Sector
-//
-// Read a variably-sized chunk of data from the user area of the virtual Corvus drive
-//
-// Pass:
-// dadr: Corvus-encoded Disk Address -- Logical Sector
-// buffer: Buffer to hold the data read from the disk
-// len: Length of the buffer
-//
-// Returns:
-// status: Corvus status
-//
-UINT8 corvus_hdc_t::corvus_read_logical_sector(dadr_t *dadr, UINT8 *buffer, int len) {
- UINT8 status; // Status returned from Physical Sector read
- UINT8 drv; // Corvus drive id (1..15)
- UINT32 sector; // Sector number on drive
-
- //
- // Unencode the first byte of the DADR
- //
- // High-order nibble of first byte is the most-significant nibble of the sector address
- // Low-order nibble of first byte is the drive id
- //
- // For example: 0x23 would decode to Drive ID #3, high-order nibble: 0x02.
- //
- drv = (dadr->address_msn_and_drive & 0x0f);
- sector = (dadr->address_msn_and_drive & 0xf0 << 12) | (dadr->address_mid << 8) | dadr->address_lsb;
-
- LOG(("corvus_read_logical_sector: Reading based on DADR: 0x%6.6x, logical sector: 0x%5.5x, drive: %d\n",
- dadr->address_msn_and_drive << 16 | dadr->address_lsb << 8 | dadr->address_mid, sector, drv));
-
- // Set up m_tracks_per_cylinder and m_sectors_per_track
- corvus_hdc_file(drv);
-
- //
- // Shift the logical sector address forward by the number of firmware cylinders (2) + the number of spare tracks (7)
- //
- sector += (m_tracks_per_cylinder * m_sectors_per_track * 2) + (SPARE_TRACKS * m_sectors_per_track);
-
- status = corvus_read_sector(drv, sector, buffer, len);
-
- if(status != STAT_SUCCESS)
- m_xmit_bytes = 1;
-
- return status;
-}
-
-
-
-//
-// Corvus_Lock_Semaphore
-//
-// Lock a semaphore in the semaphore table
-//
-// Pass:
-// name: Name of the semaphore to lock
-//
-// Returns:
-// status: Disk status
-//
-// Side-effects:
-// Fills in the semaphore result code
-//
-UINT8 corvus_hdc_t::corvus_lock_semaphore(UINT8 *name) {
- semaphore_table_block_t
- semaphore_table;
- UINT8 offset = 0;
- bool found = false;
- UINT8 blank_offset = 32; // Initialize to invalid offset
- UINT8 status; // Status returned from Physical Sector read
-
- //
- // Read the semaphore table from the drive
- //
- status = corvus_read_sector(1, 7, semaphore_table.semaphore_block.semaphore_table, 256);
- if(status != STAT_SUCCESS) {
- logerror("corvus_lock_semaphore: Error reading semaphore table, status: 0x%2.2x\n", status);
- m_buffer.semaphore_locking_response.result = SEM_DISK_ERROR;
- return status;
- }
-
- //
- // Search the semaphore table to see if the semaphore already exists--if so it's locked
- // Also look for the first blank entry to stick the new one into
- //
- do {
- if(blank_offset == 32 && strncmp((char *) &semaphore_table.semaphore_block.semaphore_entry[offset], " ", 8) == 0)
- blank_offset = offset;
- if(strncmp((char *) &semaphore_table.semaphore_block.semaphore_entry[offset], (char *) name, 8) == 0) {
- found = true;
- break;
- }
- } while( ++offset < 32 );
-
- //
- // Deal with the found status
- //
- // - Stick it into the table if we didn't find it and there's room
- // - Respond with a "set" status if we did find it
- //
- // Once that's done, write the updated table to the disk
- //
- if(!found) {
- if(blank_offset == 32) {
- m_buffer.semaphore_locking_response.result = SEM_TABLE_FULL; // No space for the semaphore!
- } else {
- m_buffer.semaphore_locking_response.result = SEM_PRIOR_STATE_NOT_SET; // It wasn't there already
- memcpy(&semaphore_table.semaphore_block.semaphore_entry[blank_offset], name, 8);// Stick it into the table
- status = corvus_write_sector(1, 7, semaphore_table.semaphore_block.semaphore_table, 256);
- if(status != STAT_SUCCESS) {
- logerror("corvus_lock_semaphore: Error updating semaphore table, status: 0x%2.2x\n", status);
- m_buffer.semaphore_locking_response.result = SEM_DISK_ERROR;
- return status;
- }
- }
- } else {
- m_buffer.semaphore_locking_response.result = SEM_PRIOR_STATE_SET; // It's already locked -- sorry
- }
-
- return STAT_SUCCESS;
-}
-
-
-
-//
-// Corvus_Unlock_Semaphore
-//
-// Unock a semaphore in the semaphore table
-//
-// Pass:
-// name: Name of the semaphore to unlock
-//
-// Returns:
-// status: Disk status
-//
-// Side-effects:
-// Fills in the semaphore result code
-//
-UINT8 corvus_hdc_t::corvus_unlock_semaphore(UINT8 *name) {
- semaphore_table_block_t
- semaphore_table;
- UINT8 offset = 0;
- bool found = false;
- UINT8 status; // Status returned from Physical Sector read
-
- //
- // Read the semaphore table from the drive
- //
- status = corvus_read_sector(1, 7, semaphore_table.semaphore_block.semaphore_table, 256);
- if(status != STAT_SUCCESS) {
- logerror("corvus_unlock_semaphore: Error reading semaphore table, status: 0x%2.2x\n", status);
- m_buffer.semaphore_locking_response.result = SEM_DISK_ERROR;
- return status;
- }
-
- //
- // Search the semaphore table to see if the semaphore already exists--if so it's locked
- //
- do {
- if(strncmp((char *) &semaphore_table.semaphore_block.semaphore_entry[offset], (char *) name, 8) == 0) {
- found = true;
- break;
- }
- } while( ++offset < 32 );
-
- //
- // Deal with the found status
- //
- // - If we didn't find it, just respond that it wasn't there
- // - If we did find it, respond with a "set" status and clear it
- //
- // Once that's done, write the updated table to the disk
- //
- if(!found) {
- m_buffer.semaphore_locking_response.result = SEM_PRIOR_STATE_NOT_SET; // It wasn't there already
- } else {
- m_buffer.semaphore_locking_response.result = SEM_PRIOR_STATE_SET; // It was there
- memcpy(&semaphore_table.semaphore_block.semaphore_entry[offset], " ", 8); // Clear it
- status = corvus_write_sector(1, 7, semaphore_table.semaphore_block.semaphore_table, 256);
- if(status != STAT_SUCCESS) {
- logerror("corvus_unlock_semaphore: Error updating semaphore table, status: 0x%2.2x\n", status);
- m_buffer.semaphore_locking_response.result = SEM_DISK_ERROR;
- return status;
- }
- }
-
- return STAT_SUCCESS;
-}
-
-
-
-//
-// Corvus_Init_Semaphore_Table
-//
-// Zap all of the semaphores from the table (set them to blanks)
-//
-// Pass:
-// Nothing
-//
-// Returns:
-// Disk status
-//
-//
-UINT8 corvus_hdc_t::corvus_init_semaphore_table() {
- semaphore_table_block_t
- semaphore_table;
- UINT8 status;
-
- memset(semaphore_table.semaphore_block.semaphore_table, 0x20, 256);
-
- status = corvus_write_sector(1, 7, semaphore_table.semaphore_block.semaphore_table, 256);
- if(status != STAT_SUCCESS) {
- logerror("corvus_init_semaphore_table: Error updating semaphore table, status: 0x%2.2x\n", status);
- return status;
- }
-
- return STAT_SUCCESS;
-}
-
-
-
-//
-// Corvus_Get_Drive_Parameters
-//
-// Fills in the Drive Parameter packet based on the opened CHD file
-//
-// Pass:
-// drv: Corvus drive id (1..15)
-//
-// Returns:
-// Status of command
-//
-UINT8 corvus_hdc_t::corvus_get_drive_parameters(UINT8 drv) {
- UINT16 capacity; // Number of usable 512-byte blocks
- UINT16 raw_capacity; // Number of actual 512-byte blocks
- union {
- UINT8
- buffer[512];
- disk_parameter_block_t
- dpb;
- } raw_disk_parameter_block; // Buffer for the Disk Parameter Block
- union {
- UINT8
- buffer[512];
- constellation_parameter_block_t
- cpb;
- } raw_constellation_parameter_block; // Buffer for the Constellation Parameter Block
- UINT8 status; // Status to return
-
- //
- // Make sure a valid drive is being accessed
- //
- if ( ! corvus_hdc_file( drv ) )
- {
- logerror("corvus_get_drive_parameters: Attempt to retrieve parameters from non-existant drive: %d\n", drv);
- m_xmit_bytes = 1;
- return STAT_FATAL_ERR | STAT_DRIVE_NOT_ONLINE;
- }
-
- //
- // Read the Disk Parameter Block (Sector 1) from the drive
- //
- status = corvus_read_sector(drv, 1, raw_disk_parameter_block.buffer, 512);
- if(status != STAT_SUCCESS) {
- logerror("corvus_get_drive_parameters: Error status returned reading Disk Parameter Block -- status: 0x%2.2x\n", status);
- m_xmit_bytes = 1;
- return status;
- }
-
- //
- // Read the Constellation Parameter Block (Sector 3) from the drive
- //
- status = corvus_read_sector(drv, 3, raw_constellation_parameter_block.buffer, 512);
- if(status != STAT_SUCCESS) {
- logerror("corvus_get_drive_parameters: Error status returned reading Constellation Parameter Block -- status: 0x%2.2x\n", status);
- m_xmit_bytes = 1;
- return status;
- }
-
- //
- // Build up the parameter packet
- //
-
- // This firmware string and revision were taken from the Corvus firmware
- // file CORVB184.CLR found on the SSE SoftBox distribution disk.
- strncpy((char *) m_buffer.drive_param_response.firmware_desc, "V18.4 -- CONST II - 11/82 ", sizeof(m_buffer.drive_param_response.firmware_desc));
- m_buffer.drive_param_response.firmware_rev = 37;
-
- // Controller ROM version
- m_buffer.drive_param_response.rom_version = ROM_VERSION;
-
- //
- // Track information
- //
- m_buffer.drive_param_response.track_info.sectors_per_track = m_sectors_per_track;
- m_buffer.drive_param_response.track_info.tracks_per_cylinder = m_tracks_per_cylinder;
- m_buffer.drive_param_response.track_info.cylinders_per_drive.msb = (m_cylinders_per_drive & 0xff00) >> 8;
- m_buffer.drive_param_response.track_info.cylinders_per_drive.lsb = (m_cylinders_per_drive & 0x00ff);
-
- //
- // Calculate the user capacity of the drive based on total capacity less spare tracks and firmware tracks
- //
- raw_capacity = m_tracks_per_cylinder * m_cylinders_per_drive * m_sectors_per_track; // Total capacity
- capacity = raw_capacity - ((m_tracks_per_cylinder * m_sectors_per_track * 2) + (SPARE_TRACKS * m_sectors_per_track));
- m_buffer.drive_param_response.capacity.msb = (capacity & 0xff0000) >> 16;
- m_buffer.drive_param_response.capacity.midb = (capacity & 0x00ff00) >> 8;
- m_buffer.drive_param_response.capacity.lsb = (capacity & 0x0000ff);
-
- //
- // Fill in the information from the Disk Parameter Block and Constellation Parameter Block
- //
- m_buffer.drive_param_response.interleave = raw_disk_parameter_block.dpb.interleave;
- memcpy(m_buffer.drive_param_response.table_info.mux_parameters, raw_constellation_parameter_block.cpb.mux_parameters, 12);
- memcpy(m_buffer.drive_param_response.table_info.pipe_name_table_ptr,
- raw_constellation_parameter_block.cpb.pipe_name_table_ptr, 2);
- memcpy(m_buffer.drive_param_response.table_info.pipe_ptr_table_ptr,
- raw_constellation_parameter_block.cpb.pipe_ptr_table_ptr, 2);
- memcpy(m_buffer.drive_param_response.table_info.pipe_area_size, raw_constellation_parameter_block.cpb.pipe_area_size, 2);
- memcpy(m_buffer.drive_param_response.table_info.vdo_table, raw_disk_parameter_block.dpb.vdo_table, 14);
- memcpy(m_buffer.drive_param_response.table_info.lsi11_vdo_table, raw_disk_parameter_block.dpb.lsi11_vdo_table, 8);
- memcpy(m_buffer.drive_param_response.table_info.lsi11_spare_table, raw_disk_parameter_block.dpb.lsi11_spare_table, 8);
-
- m_buffer.drive_param_response.drive_number = drv;
- m_buffer.drive_param_response.physical_capacity.msb = (raw_capacity & 0xff0000) >> 16;
- m_buffer.drive_param_response.physical_capacity.midb = (raw_capacity & 0x00ff00) >> 8;
- m_buffer.drive_param_response.physical_capacity.lsb = (raw_capacity & 0x0000ff);
-
- LOG(("corvus_get_drive_parameters: Drive Parameter packet follows:\n"));
- LOG_BUFFER(m_buffer.raw_data, 110);
-
- return STAT_SUCCESS;
-}
-
-
-
-//
-// Corvus_Read_Boot_Block
-//
-// Old-style Boot (0x14) command boot block reader
-//
-// Pass:
-// block: Boot block number to read (0-7)
-//
-// Returns:
-// status: Status of read operation
-//
-UINT8 corvus_hdc_t::corvus_read_boot_block(UINT8 block) {
- LOG(("corvus_read_boot_block: Reading boot block: %d\n", block));
-
- return corvus_read_sector(1, 25 + block, m_buffer.read_512_response.data, 512);
-}
-
-
-
-//
-// corvus_enter_prep_mode
-//
-// Enter prep mode. In prep mode, only prep mode commands may be executed.
-//
-// A "prep block" is 512 bytes of machine code that the host sends to the
-// controller. The controller will jump to this code after receiving it,
-// and it is what actually implements prep mode commands. This HLE ignores
-// the prep block from the host.
-//
-// On the Rev B/H drives (which we emulate), a prep block is Z80 machine
-// code and only one prep block can be sent. Sending the "put drive into
-// prep mode" command (0x11) when already in prep mode is an error. The
-// prep block sent by the Corvus program DIAG.COM on the SSE SoftBox
-// distribution disk returns error 0x8f (unrecognized command) for this case.
-//
-// On the OmniDrive and Bank, a prep block is 6801 machine code. These
-// controllers allow multiple prep blocks to be sent. The first time the
-// "put drive into prep mode" command is sent puts the drive into prep mode.
-// The command can then be sent again up to 3 times with more prep blocks.
-// (Mass Storage GTI, pages 50-51)
-//
-// Pass:
-// drv: Corvus drive id (1..15) to be prepped
-// prep_block: 512 bytes of machine code, contents ignored
-//
-// Returns:
-// Status of command
-//
-UINT8 corvus_hdc_t::corvus_enter_prep_mode(UINT8 drv, UINT8 *prep_block) {
- // on rev b/h drives, sending the "put drive into prep mode"
- // command when already in prep mode is an error.
- if (m_prep_mode) {
- logerror("corvus_enter_prep_mode: Attempt to enter prep mode while in prep mode\n");
- return STAT_FATAL_ERR | STAT_ILL_CMD_OP_CODE;
- }
-
- // check if drive is valid
- if (!corvus_hdc_file(drv)) {
- logerror("corvus_enter_prep_mode: Failure returned by corvus_hdc_file(%d)\n", drv);
- return STAT_FATAL_ERR | STAT_DRIVE_NOT_ONLINE;
- }
-
- LOG(("corvus_enter_prep_mode: Prep mode entered for drive %d, prep block follows:\n", drv));
- LOG_BUFFER(prep_block, 512);
-
- m_prep_mode = true;
- m_prep_drv = drv;
- return STAT_SUCCESS;
-}
-
-
-
-//
-// corvus_exit_prep_mode (Prep Mode Only)
-//
-// Exit from prep mode and return to normal command mode.
-//
-// Returns:
-// Status of command (always success)
-//
-UINT8 corvus_hdc_t::corvus_exit_prep_mode() {
- LOG(("corvus_exit_prep_mode: Prep mode exited\n"));
- m_prep_mode = false;
- m_prep_drv = 0;
- return STAT_SUCCESS;
-}
-
-
-
-//
-// Corvus_Read_Firmware_Block (Prep Mode Only)
-//
-// Reads firmware information from the first cylinder of the drive
-//
-// Pass:
-// head: Head number
-// sector: Sector number
-//
-// Returns:
-// Status of command
-//
-UINT8 corvus_hdc_t::corvus_read_firmware_block(UINT8 head, UINT8 sector) {
- UINT16 relative_sector; // Relative sector on drive for Physical Read
- UINT8 status;
-
- relative_sector = head * m_sectors_per_track + sector;
-
- LOG(("corvus_read_firmware_block: Reading firmware head: 0x%2.2x, sector: 0x%2.2x, relative_sector: 0x%2.2x\n",
- head, sector, relative_sector));
-
- status = corvus_read_sector(m_prep_drv, relative_sector, m_buffer.read_512_response.data, 512);
- return status;
-}
-
-
-
-//
-// Corvus_Write_Firmware_Block (Prep Mode Only)
-//
-// Writes firmware information to the first cylinder of the drive
-//
-// Pass:
-// head: Head number
-// sector: Sector number
-// buffer: Data to be written
-//
-// Returns:
-// Status of command
-//
-UINT8 corvus_hdc_t::corvus_write_firmware_block(UINT8 head, UINT8 sector, UINT8 *buffer) {
- UINT16 relative_sector; // Relative sector on drive for Physical Read
- UINT8 status;
-
- relative_sector = head * m_sectors_per_track + sector;
-
- LOG(("corvus_write_firmware_block: Writing firmware head: 0x%2.2x, sector: 0x%2.2x, relative_sector: 0x%2.2x\n",
- head, sector, relative_sector));
-
- status = corvus_write_sector(m_prep_drv, relative_sector, buffer, 512);
- return status;
-}
-
-
-
-//
-// Corvus_Format_Drive (Prep Mode Only)
-//
-// Write the pattern provided across the entire disk
-//
-// Pass:
-// pattern: 512-byte buffer containing the pattern to write to the whole drive
-//
-// Returns:
-// Status of command
-//
-UINT8 corvus_hdc_t::corvus_format_drive(UINT8 *pattern, UINT16 len) {
- UINT32 sector;
- UINT32 max_sector;
- UINT8 status = 0;
- UINT8 tbuffer[512];
-
- // Set up m_tracks_per_cylinder and m_sectors_per_track
- corvus_hdc_file(m_prep_drv);
-
- max_sector = m_sectors_per_track * m_tracks_per_cylinder * m_cylinders_per_drive;
-
- //
- // If we were passed less than 512 bytes, fill the buffer up with the first byte passed (for Omnidrive Format command)
- //
- if(len < 512) {
- memset(tbuffer, *pattern, 512);
- pattern = tbuffer;
- }
-
- LOG(("corvus_format_drive: Formatting drive with 0x%5.5x sectors, pattern buffer (passed length: %d) follows\n", max_sector, 512));
- LOG_BUFFER(pattern, 512);
-
- for(sector = 0; sector <= max_sector; sector++) {
- status = corvus_write_sector(m_prep_drv, sector, pattern, 512);
- if(status != STAT_SUCCESS) {
- logerror("corvus_format_drive: Error while formatting drive in corvus_write_sector--sector: 0x%5.5x, status: 0x%x2.2x\n",
- sector, status);
- break;
- }
- }
-
- return status;
-}
-
-
-
-//
-// Corvus_HDC_File
-//
-// Returns a hard_disk_file object for a given virtual hard drive device in the concept
-//
-// Pass:
-// drv: Corvus drive id (1..15)
-//
-// Returns:
-// hard_disk_file object
-//
-hard_disk_file *corvus_hdc_t::corvus_hdc_file(int drv) {
- static const char *const tags[] = {
- "harddisk1", "harddisk2", "harddisk3", "harddisk4"
- };
-
- // we only support 4 drives, as per the tags[] table, so prevent a crash
- // Corvus drive id numbers are 1-based so we check 1..4 instead of 0..3
- if (drv < 1 || drv > 4)
- {
- return NULL;
- }
-
- harddisk_image_device *img = siblingdevice<harddisk_image_device>(tags[drv - 1]);
-
- if ( !img )
- return NULL;
-
- if (!img->exists())
- return NULL;
-
- // Pick up the Head/Cylinder/Sector info
- hard_disk_file *file = img->get_hard_disk_file();
- hard_disk_info *info = hard_disk_get_info(file);
- m_sectors_per_track = info->sectors;
- m_tracks_per_cylinder = info->heads;
- m_cylinders_per_drive = info->cylinders;
-
- LOG(("corvus_hdc_file: Attached to drive %u image: H:%d, C:%d, S:%d\n", drv, info->heads, info->cylinders, info->sectors));
-
- return file;
-}
-
-
-
-//
-// Corvus_Process_Command_Packet
-//
-// Having received a complete packet from the host, process it
-//
-// Pass:
-// Invalid_Command_Flag: Invalid command flag responses are handled in this routine
-//
-// Returns:
-// Nothing
-//
-void corvus_hdc_t::corvus_process_command_packet(bool invalid_command_flag) {
- if (VERBOSE_RESPONSES)
- {
- LOG(("corvus_hdc_data_w: Complete packet received. Dump follows:\n"));
- LOG_BUFFER(m_buffer.raw_data, m_offset);
- }
-
- if(!invalid_command_flag) {
- if(!m_prep_mode) {
- switch(m_buffer.command.code) {
- //
- // Read / Write Chunk commands
- //
- case READ_CHUNK_128:
- m_buffer.read_128_response.status =
- corvus_read_logical_sector(&m_buffer.read_sector_command.dadr, m_buffer.read_128_response.data, 128);
- break;
- case READ_SECTOR_256:
- case READ_CHUNK_256:
- m_buffer.read_256_response.status =
- corvus_read_logical_sector(&m_buffer.read_sector_command.dadr, m_buffer.read_256_response.data, 256);
- break;
- case READ_CHUNK_512:
- m_buffer.read_512_response.status =
- corvus_read_logical_sector(&m_buffer.read_sector_command.dadr, m_buffer.read_512_response.data, 512);
- break;
- case WRITE_CHUNK_128:
- m_buffer.single_byte_response.status =
- corvus_write_logical_sector(&m_buffer.write_128_command.dadr, m_buffer.write_128_command.data, 128);
- break;
- case WRITE_SECTOR_256:
- case WRITE_CHUNK_256:
- m_buffer.single_byte_response.status =
- corvus_write_logical_sector(&m_buffer.write_256_command.dadr, m_buffer.write_256_command.data, 256);
- break;
- case WRITE_CHUNK_512:
- m_buffer.single_byte_response.status =
- corvus_write_logical_sector(&m_buffer.write_512_command.dadr, m_buffer.write_512_command.data, 512);
- break;
- //
- // Semaphore commands
- //
- case SEMAPHORE_LOCK_CODE:
- // case SEMAPHORE_UNLOCK_CODE:
- case SEMAPHORE_INIT_CODE:
- // case SEMAPHORE_STATUS_CODE:
- switch(m_buffer.command.modifier) {
- case SEMAPHORE_LOCK_MOD:
- m_buffer.semaphore_locking_response.status = corvus_lock_semaphore(m_buffer.lock_semaphore_command.name);
- break;
- case SEMAPHORE_UNLOCK_MOD:
- m_buffer.semaphore_locking_response.status =
- corvus_unlock_semaphore(m_buffer.unlock_semaphore_command.name);
- break;
- case SEMAPHORE_INIT_MOD:
- m_buffer.single_byte_response.status = corvus_init_semaphore_table();
- break;
- case SEMAPHORE_STATUS_MOD:
- m_buffer.semaphore_status_response.status =
- corvus_read_sector(1, 7, m_buffer.semaphore_status_response.table, 256);
- break;
- default:
- invalid_command_flag = true;
- }
- break;
- //
- // Miscellaneous commands
- //
- case BOOT:
- m_buffer.read_512_response.status =
- corvus_read_boot_block(m_buffer.old_boot_command.boot_block);
- break;
- case GET_DRIVE_PARAMETERS:
- m_buffer.drive_param_response.status =
- corvus_get_drive_parameters(m_buffer.get_drive_parameters_command.drive);
- break;
- case PREP_MODE_SELECT:
- m_buffer.single_byte_response.status =
- corvus_enter_prep_mode(m_buffer.prep_mode_command.drive,
- m_buffer.prep_mode_command.prep_block);
- break;
- default:
- m_xmit_bytes = 1; // Return a fatal status
- m_buffer.single_byte_response.status = STAT_FAULT | STAT_FATAL_ERR;
- logerror("corvus_hdc_data_w: Unimplemented command, returning FATAL FAULT status!\n");
- break;
- }
- } else { // In Prep mode
- switch(m_buffer.command.code) {
- case PREP_MODE_SELECT:
- // when already in prep mode, some drives allow this command to
- // be sent again. see corvus_enter_prep_mode() for details.
- m_buffer.single_byte_response.status =
- corvus_enter_prep_mode(m_buffer.prep_mode_command.drive,
- m_buffer.prep_mode_command.prep_block);
- break;
- case PREP_RESET_DRIVE:
- m_buffer.single_byte_response.status =
- corvus_exit_prep_mode();
- break;
- case PREP_READ_FIRMWARE:
- m_buffer.drive_param_response.status =
- corvus_read_firmware_block((m_buffer.read_firmware_command.encoded_h_s & 0xe0) >> 5,
- m_buffer.read_firmware_command.encoded_h_s & 0x1f);
- break;
- case PREP_WRITE_FIRMWARE:
- m_buffer.drive_param_response.status =
- corvus_write_firmware_block((m_buffer.write_firmware_command.encoded_h_s & 0xe0) >> 5,
- m_buffer.write_firmware_command.encoded_h_s & 0x1f, m_buffer.write_firmware_command.data);
- break;
- case PREP_FORMAT_DRIVE:
- m_buffer.drive_param_response.status =
- corvus_format_drive(m_buffer.format_drive_revbh_command.pattern, m_offset - 512);
- break;
- case PREP_VERIFY:
- m_buffer.verify_drive_response.status = STAT_SUCCESS;
- m_buffer.verify_drive_response.bad_sectors = 0;
- break;
- default:
- m_xmit_bytes = 1;
- m_buffer.single_byte_response.status = STAT_FAULT | STAT_FATAL_ERR;
- logerror("corvus_hdc_data_w: Unimplemented Prep command %02x, returning FATAL FAULT status!\n", m_buffer.command.code);
- }
- }
- if (VERBOSE_RESPONSES)
- {
- LOG(("corvus_hdc_data_w: Command execution complete, status: 0x%2.2x. Response dump follows:\n",
- m_buffer.single_byte_response.status));
- LOG_BUFFER(m_buffer.raw_data, m_xmit_bytes);
- }
-
- } // if(!invalid_command_flag)
-
- //
- // Use a separate "if" in case the Invalid Command Flag was set as a result of a two-byte command
- //
- if(invalid_command_flag) {
- //
- // An Illegal command was detected (Truly invalid, not just unimplemented)
- //
- m_buffer.single_byte_response.status =
- STAT_FATAL_ERR | STAT_ILL_CMD_OP_CODE; // Respond with an Illegal Op Code
-
- logerror("corvus_hdc_data_w: Illegal command 0x%2.2x, status: 0x%2.2x\n", m_buffer.command.code, m_buffer.single_byte_response.status);
- }
- //
- // Command execution complete, free up the controller
- //
- m_offset = 0; // Point to beginning of buffer for response
-
- LOG(("corvus_hdc_data_w: Setting one-time mame timer of %d microseconds to simulate disk function\n", m_delay));
-
- //
- // Set up timers for command completion and timeout from host
- //
- //machine.scheduler().timer_set(attotime::from_usec(m_delay), FUNC(corvus_hdc_callback), CALLBACK_CTH_MODE);
- m_cmd_timer->adjust(attotime::from_usec(m_delay), CALLBACK_CTH_MODE);
- m_timeout_timer->enable(0); // We've received enough data, disable the timeout timer
-
- m_delay = 0; // Reset delay for next function
-}
-
-
-
-//
-// Corvus_HDC_Callback
-//
-// Callback routine for completion of controller functions
-//
-// Pass:
-// Callback Function
-//
-// Returns:
-// Nothing
-//
-void corvus_hdc_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- int function = param;
-
- switch(function) {
- case CALLBACK_CTH_MODE:
- m_status |= CONTROLLER_DIRECTION; // Set to Controller-to-Host, Ready mode
- m_status &= ~(CONTROLLER_BUSY);
-
- LOG(("corvus_hdc_callback: Callback executed with function CALLBACK_CTH_MODE\n"));
-
- break;
- case CALLBACK_HTC_MODE:
- m_status &= ~(CONTROLLER_DIRECTION |
- CONTROLLER_BUSY); // Set to Host-to-Controller, Ready mode
-
- LOG(("corvus_hdc_callback: Callback executed with function CALLBACK_HTC_MODE\n"));
-
- break;
- case CALLBACK_SAME_MODE:
- m_status &= ~(CONTROLLER_BUSY); // Set the controller to Ready mode
-
- break;
- case CALLBACK_TIMEOUT: // We reached a four-second timeout threshold
- if(m_offset < m_recv_bytes || (m_offset > m_recv_bytes && m_recv_bytes != 0)) {
- m_buffer.single_byte_response.status = STAT_TIMEOUT;
- m_status |= CONTROLLER_DIRECTION;
- m_status &= ~(CONTROLLER_BUSY);
- m_recv_bytes = 0;
- m_xmit_bytes = 1;
- logerror("corvus_hdc_callback: Exceeded four-second timeout for data from host, resetting communications\n");
- } else { // if(m_recv_bytes == 0) This was a variable-size command
- LOG(("corvus_hdc_callback: Executing variable-length command via four-second timeout\n"));
- corvus_process_command_packet(0); // Process the command
- }
- break;
- default:
- logerror("corvus_hdc_callback: FATAL ERROR -- Unknown callback function: %d\n", function);
- assert(0);
- }
- if(function != CALLBACK_SAME_MODE) {
- m_timeout_timer->enable(0); // Disable the four-second timer now that we're done
- }
-}
-
-
-
-//
-// Corvus_HDC_Init
-//
-// Global routine to initialize the Hard Disk Controller structures and arrays
-//
-// Pass:
-// Nothing
-//
-// Returns:
-// NULL if there's no file to attach to
-//
-void corvus_hdc_t::device_start() {
- m_status &= ~(CONTROLLER_DIRECTION | CONTROLLER_BUSY); // Host-to-controller mode, Idle (awaiting command from Host mode)
- m_prep_mode = false; // We're not in Prep Mode
- m_offset = 0; // Buffer is empty
- m_awaiting_modifier = false; // We're not in the middle of a two-byte command
- m_xmit_bytes = 0; // We don't have anything to say to the host
- m_recv_bytes = 0; // We aren't waiting on additional data from the host
-
- m_timeout_timer = timer_alloc(TIMER_TIMEOUT); // Set up a timer to handle the four-second host-to-controller timeout
- m_timeout_timer->adjust(attotime::from_seconds(4), CALLBACK_TIMEOUT);
- m_timeout_timer->enable(0); // Start this timer out disabled
-
- m_cmd_timer = timer_alloc(TIMER_COMMAND);
-
- //
- // Define all of the packet sizes for the commands
- //
-
- // Read / Write commands
- corvus_cmd[READ_SECTOR_256][0].recv_bytes = 4;
- corvus_cmd[READ_SECTOR_256][0].xmit_bytes = 257;
- corvus_cmd[WRITE_SECTOR_256][0].recv_bytes = 260;
- corvus_cmd[WRITE_SECTOR_256][0].xmit_bytes = 1;
- corvus_cmd[READ_CHUNK_128][0].recv_bytes = 4;
- corvus_cmd[READ_CHUNK_128][0].xmit_bytes = 129;
- corvus_cmd[READ_CHUNK_256][0].recv_bytes = 4;
- corvus_cmd[READ_CHUNK_256][0].xmit_bytes = 257;
- corvus_cmd[READ_CHUNK_512][0].recv_bytes = 4;
- corvus_cmd[READ_CHUNK_512][0].xmit_bytes = 513;
- corvus_cmd[WRITE_CHUNK_128][0].recv_bytes = 132;
- corvus_cmd[WRITE_CHUNK_128][0].xmit_bytes = 1;
- corvus_cmd[WRITE_CHUNK_256][0].recv_bytes = 260;
- corvus_cmd[WRITE_CHUNK_256][0].xmit_bytes = 1;
- corvus_cmd[WRITE_CHUNK_512][0].recv_bytes = 516;
- corvus_cmd[WRITE_CHUNK_512][0].xmit_bytes = 1;
-
- // Semaphore commands
- corvus_cmd[SEMAPHORE_LOCK_CODE][SEMAPHORE_LOCK_MOD].recv_bytes = 10;
- corvus_cmd[SEMAPHORE_LOCK_CODE][SEMAPHORE_LOCK_MOD].xmit_bytes = 12;
- corvus_cmd[SEMAPHORE_UNLOCK_CODE][SEMAPHORE_UNLOCK_MOD].recv_bytes = 10;
- corvus_cmd[SEMAPHORE_UNLOCK_CODE][SEMAPHORE_UNLOCK_MOD].xmit_bytes = 12;
- corvus_cmd[SEMAPHORE_INIT_CODE][SEMAPHORE_INIT_MOD].recv_bytes = 5;
- corvus_cmd[SEMAPHORE_INIT_CODE][SEMAPHORE_INIT_MOD].xmit_bytes = 1;
- corvus_cmd[SEMAPHORE_STATUS_CODE][SEMAPHORE_STATUS_MOD].recv_bytes = 5;
- corvus_cmd[SEMAPHORE_STATUS_CODE][SEMAPHORE_STATUS_MOD].xmit_bytes = 257;
-
- // Pipe commands
- corvus_cmd[PIPE_READ_CODE][PIPE_READ_MOD].recv_bytes = 5;
- corvus_cmd[PIPE_READ_CODE][PIPE_READ_MOD].xmit_bytes = 516;
- corvus_cmd[PIPE_WRITE_CODE][PIPE_WRITE_MOD].recv_bytes = 517;
- corvus_cmd[PIPE_WRITE_CODE][PIPE_WRITE_MOD].xmit_bytes = 12;
- corvus_cmd[PIPE_CLOSE_CODE][PIPE_CLOSE_MOD].recv_bytes = 5;
- corvus_cmd[PIPE_CLOSE_CODE][PIPE_CLOSE_MOD].xmit_bytes = 12;
- corvus_cmd[PIPE_STATUS_CODE][PIPE_STATUS_MOD].recv_bytes = 5;
- corvus_cmd[PIPE_STATUS_CODE][PIPE_STATUS_MOD].xmit_bytes = 513; // There are actually two possibilities here
- corvus_cmd[PIPE_OPEN_WRITE_CODE][PIPE_OPEN_WRITE_MOD].recv_bytes = 10;
- corvus_cmd[PIPE_OPEN_WRITE_CODE][PIPE_OPEN_WRITE_MOD].xmit_bytes = 12;
- corvus_cmd[PIPE_AREA_INIT_CODE][PIPE_AREA_INIT_MOD].recv_bytes = 10;
- corvus_cmd[PIPE_AREA_INIT_CODE][PIPE_AREA_INIT_MOD].xmit_bytes = 12;
- corvus_cmd[PIPE_OPEN_READ_CODE][PIPE_OPEN_READ_MOD].recv_bytes = 10;
- corvus_cmd[PIPE_OPEN_READ_CODE][PIPE_OPEN_READ_MOD].xmit_bytes = 12;
-
- // Active User Table Commands
- corvus_cmd[ADDACTIVE_CODE][ADDACTIVE_MOD].recv_bytes = 18;
- corvus_cmd[ADDACTIVE_CODE][ADDACTIVE_MOD].xmit_bytes = 2;
- corvus_cmd[DELACTIVEUSR_REVBH_CODE][DELACTIVEUSR_REVBH_MOD].recv_bytes = 18;
- corvus_cmd[DELACTIVEUSR_REVBH_CODE][DELACTIVEUSR_REVBH_MOD].xmit_bytes = 2;
- corvus_cmd[DELACTIVENUM_OMNI_CODE][DELACTIVENUM_OMNI_MOD].recv_bytes = 18;
- corvus_cmd[DELACTIVENUM_OMNI_CODE][DELACTIVENUM_OMNI_MOD].xmit_bytes = 2;
- corvus_cmd[DELACTIVEUSR_OMNI_CODE][DELACTIVEUSR_OMNI_MOD].recv_bytes = 18;
- corvus_cmd[DELACTIVEUSR_OMNI_CODE][DELACTIVEUSR_OMNI_MOD].xmit_bytes = 2;
- corvus_cmd[FINDACTIVE_CODE][FINDACTIVE_MOD].recv_bytes = 18;
- corvus_cmd[FINDACTIVE_CODE][FINDACTIVE_MOD].xmit_bytes = 17;
- corvus_cmd[READTEMPBLOCK][0].recv_bytes = 2;
- corvus_cmd[READTEMPBLOCK][0].xmit_bytes = 513;
- corvus_cmd[WRITETEMPBLOCK][0].recv_bytes = 514;
- corvus_cmd[WRITETEMPBLOCK][0].xmit_bytes = 1;
-
- // Miscellaneous Commands
- corvus_cmd[BOOT][0].recv_bytes = 2;
- corvus_cmd[BOOT][0].xmit_bytes = 513;
- corvus_cmd[READ_BOOT_BLOCK][0].recv_bytes = 3;
- corvus_cmd[READ_BOOT_BLOCK][0].xmit_bytes = 513;
- corvus_cmd[GET_DRIVE_PARAMETERS][0].recv_bytes = 2;
- corvus_cmd[GET_DRIVE_PARAMETERS][0].xmit_bytes = 129;
- corvus_cmd[PARK_HEADS_REVH][0].recv_bytes = 514;
- corvus_cmd[PARK_HEADS_REVH][0].xmit_bytes = 1;
- corvus_cmd[PARK_HEADS_OMNI][0].recv_bytes = 1;
- corvus_cmd[PARK_HEADS_OMNI][0].xmit_bytes = 1;
- corvus_cmd[ECHO][0].recv_bytes = 513;
- corvus_cmd[ECHO][0].xmit_bytes = 513;
-
- // Put Drive in Prep Mode
- corvus_cmd[PREP_MODE_SELECT][0].recv_bytes = 514;
- corvus_cmd[PREP_MODE_SELECT][0].xmit_bytes = 1;
-
- // Prep Mode Commands
- corvus_prep_cmd[PREP_MODE_SELECT].recv_bytes = 514;
- corvus_prep_cmd[PREP_MODE_SELECT].xmit_bytes = 1;
- corvus_prep_cmd[PREP_RESET_DRIVE].recv_bytes = 1;
- corvus_prep_cmd[PREP_RESET_DRIVE].xmit_bytes = 1;
- corvus_prep_cmd[PREP_FORMAT_DRIVE].recv_bytes = 0;
- corvus_prep_cmd[PREP_FORMAT_DRIVE].xmit_bytes = 1;
- corvus_prep_cmd[PREP_FILL_DRIVE_OMNI].recv_bytes = 3;
- corvus_prep_cmd[PREP_FILL_DRIVE_OMNI].xmit_bytes = 1;
- corvus_prep_cmd[PREP_VERIFY].recv_bytes = 1;
- corvus_prep_cmd[PREP_VERIFY].xmit_bytes = 2;
- corvus_prep_cmd[PREP_READ_FIRMWARE].recv_bytes = 2;
- corvus_prep_cmd[PREP_READ_FIRMWARE].xmit_bytes = 513;
- corvus_prep_cmd[PREP_WRITE_FIRMWARE].recv_bytes = 514;
- corvus_prep_cmd[PREP_WRITE_FIRMWARE].xmit_bytes = 1;
-
- LOG(("corvus_hdc_init: Drive structures initialized\n"));
-}
-
-
-//
-// Corvus_HDC_Status_R
-//
-// Global routine to read the Status Register from the Controller (Controller to Host)
-//
-// Pass:
-// Nothing
-//
-// Returns:
-// Value in the controller status register
-//
-READ8_MEMBER ( corvus_hdc_t::status_r ) {
- return m_status;
-}
-
-
-
-//
-// Corvus_HDC_Data_R
-//
-// Read the Data Register from the Controller (Controller to Host). If transmission is complete,
-// as defined as offset == bytes to transmit, reset the status to Host-to-Controller mode and Idle
-// when complete.
-//
-// Pass:
-// Nothing
-//
-// Returns:
-// Value in the controller data register
-//
-READ8_MEMBER ( corvus_hdc_t::read ) {
- UINT8 result;
-
- if((m_status & CONTROLLER_DIRECTION) == 0) { // Check to see if we're in Controller-to-Host mode
- logerror("corvus_hdc_data_r: Data register read when in Host-to-Controller mode (status: 0x%2.2x)\n", m_status);
- return 0;
- }
-
- if((m_status & CONTROLLER_BUSY) != 0) { // Check to see if we're Busy
- logerror("corvus_hdc_data_r: Data register read when Busy (status: 0x%2.2x)\n", m_status);
- return 0;
- }
-
- result = m_buffer.raw_data[m_offset++];
-
- if(m_offset == m_xmit_bytes) {
- LOG(("corvus_hdc_data_r: Finished transmitting %d bytes of data. Returning to idle mode.\n", m_xmit_bytes));
-
- m_offset = 0; // We've reached the end of valid data
- m_xmit_bytes = 0; // We don't have anything more to say
- m_recv_bytes = 0; // No active commands
-
- m_cmd_timer->adjust(attotime::from_usec(INTERBYTE_DELAY), CALLBACK_HTC_MODE);
-
-// m_status &= ~(CONTROLLER_DIRECTION | CONTROLLER_BUSY); // Put us in Idle, Host-to-Controller mode
- } else {
- //
- // Not finished with this packet. Insert an interbyte delay and then let the host continue
- //
- m_cmd_timer->adjust(attotime::from_usec(INTERBYTE_DELAY), CALLBACK_SAME_MODE);
- }
-
- return result;
-}
-
-
-
-//
-// Corvus_HDC_Data_W
-//
-// Write to the Data Register on the Controller (Host to Controller)
-//
-// Pass:
-// Value to write to controller data register
-//
-// Returns:
-// Nothing
-//
-WRITE8_MEMBER ( corvus_hdc_t::write ) {
- //
- // Received a byte -- check to see if we should really respond
- //
- if((m_status & CONTROLLER_DIRECTION) != 0) { // System wrote to controller when controller wasn't listening
- logerror("corvus_hdc_data_w: Data register written when in Controller-to-Host mode (status: 0x%2.2x, data: 0x%2.2x)\n",
- m_status, data);
- return;
- }
-
- if((m_status & CONTROLLER_BUSY) != 0) { // System wrote to controller when controller was busy
- logerror("corvus_hdc_data_w: Data register written when controller not Ready (status: 0x%2.2x, data: 0x%2.2x)\n",
- m_status, data);
- return;
- }
-
- //
- // We're supposed to be paying attention. Make a decision about the data received
- //
- if(m_offset == 0) { // First byte of a packet
- LOG(("corvus_hdc_data_w: Received a byte with m_offset == 0. Processing as command: 0x%2.2x\n", data));
- m_invalid_command_flag = parse_hdc_command(data);
- m_timeout_timer->reset((attotime::from_seconds(4)));
- m_timeout_timer->enable(1); // Start our four-second timer
- } else if(m_offset == 1 && m_awaiting_modifier) { // Second byte of a packet
- LOG(("corvus_hdc_data_w: Received a byte while awaiting modifier with m_offset == 0. Processing as modifier: 0x%2.2x\n", data));
- m_awaiting_modifier = false;
- m_recv_bytes = corvus_cmd[m_buffer.command.code][data].recv_bytes;
- m_xmit_bytes = corvus_cmd[m_buffer.command.code][data].xmit_bytes;
- }
-
- m_buffer.raw_data[m_offset++] = data;
-
- assert(m_offset <= MAX_COMMAND_SIZE); // Something is wrong, or I undersized the buffer
-
- //
- // We now have enough information to make a decision whether to execute the command, respond with a fatal response
- // or just wait for more data. If we can do something, execute the command. Otherwise, just fall through and return
- // to the user with us Ready for more data and in Host-to-Controller mode.
- //
- if(m_offset == m_recv_bytes) { // We've received enough data to process
- corvus_process_command_packet(m_invalid_command_flag);
- } else {
- //
- // Reset the four-second timer since we received some data
- //
- m_timeout_timer->reset((attotime::from_seconds(4)));
-
- //
- // Make the controller busy for a few microseconds while the command is processed
- //
- m_status |= CONTROLLER_BUSY;
- m_cmd_timer->adjust(attotime::from_usec(INTERBYTE_DELAY), CALLBACK_SAME_MODE);
- }
-}
diff --git a/src/emu/machine/corvushd.h b/src/emu/machine/corvushd.h
deleted file mode 100644
index bc83fa2585d..00000000000
--- a/src/emu/machine/corvushd.h
+++ /dev/null
@@ -1,530 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Brett Wyer, Raphael Nabet
-/*****************************************************************************
- *
- * includes/corvushd.h
- *
- * Implementation of the Corvus Systems Flat Cable Hard Disk controller
- *
- * Corvus Model 6 (5 MB): IMI 5006H hard disk (-chs 144,4,20 -ss 512)
- * Corvus Model 11 (10 MB): IMI 5012H hard disk (-chs 358,3,20 -ss 512)
- * Corvus Model 20 (20 MB): IMI 5018H hard disk (-chs 388,5,20 -ss 512)
- *
- ****************************************************************************/
-
-#ifndef CORVUSHD_H_
-#define CORVUSHD_H_
-
-#include "emu.h"
-#include "imagedev/harddriv.h"
-#include <ctype.h>
-
-//
-// Controller Commands
-//
-
-// Read/Write Commands
-
-#define READ_SECTOR_256 0x02
-#define WRITE_SECTOR_256 0x03
-#define READ_CHUNK_128 0x12
-#define READ_CHUNK_256 0x22
-#define READ_CHUNK_512 0x32
-#define WRITE_CHUNK_128 0x13
-#define WRITE_CHUNK_256 0x23
-#define WRITE_CHUNK_512 0x33
-
-// Semaphore Commands
-
-#define SEMAPHORE_LOCK_CODE 0x0b
-#define SEMAPHORE_LOCK_MOD 0x01
-#define SEMAPHORE_UNLOCK_CODE 0x0b
-#define SEMAPHORE_UNLOCK_MOD 0x11
-#define SEMAPHORE_INIT_CODE 0x1a
-#define SEMAPHORE_INIT_MOD 0x10
-#define SEMAPHORE_STATUS_CODE 0x1a
-#define SEMAPHORE_STATUS_MOD 0x41
-
-// Pipe Commands
-
-#define PIPE_READ_CODE 0x1a
-#define PIPE_READ_MOD 0x20
-#define PIPE_WRITE_CODE 0x1a
-#define PIPE_WRITE_MOD 0x21
-#define PIPE_CLOSE_CODE 0x1a
-#define PIPE_CLOSE_MOD 0x40
-#define PIPE_STATUS_CODE 0x1a
-#define PIPE_STATUS_MOD 0x41
-#define PIPE_OPEN_WRITE_CODE 0x1b
-#define PIPE_OPEN_WRITE_MOD 0x80
-#define PIPE_AREA_INIT_CODE 0x1b
-#define PIPE_AREA_INIT_MOD 0xa0
-#define PIPE_OPEN_READ_CODE 0x1b
-#define PIPE_OPEN_READ_MOD 0xc0
-
-// Active User Table Commands
-
-#define ADDACTIVE_CODE 0x34
-#define ADDACTIVE_MOD 0x03
-#define DELACTIVEUSR_REVBH_CODE 0x34
-#define DELACTIVEUSR_REVBH_MOD 0x00
-#define DELACTIVENUM_OMNI_CODE 0x34
-#define DELACTIVENUM_OMNI_MOD 0x00
-#define DELACTIVEUSR_OMNI_CODE 0x34
-#define DELACTIVEUSR_OMNI_MOD 0x31
-#define FINDACTIVE_CODE 0x34
-#define FINDACTIVE_MOD 0x05
-#define READTEMPBLOCK 0xc4
-#define WRITETEMPBLOCK 0xb4
-
-// Miscellaneous Commands
-
-#define BOOT 0x14
-#define READ_BOOT_BLOCK 0x44
-#define GET_DRIVE_PARAMETERS 0x10
-#define PARK_HEADS_REVH 0x11
-#define PARK_HEADS_OMNI 0x80
-#define ECHO 0xf4
-
-// Put drive in Prep Mode
-
-#define PREP_MODE_SELECT 0x11
-
-// Prep Mode Commands
-
-#define PREP_RESET_DRIVE 0x00
-#define PREP_FORMAT_DRIVE 0x01
-#define PREP_FILL_DRIVE_OMNI 0x81
-#define PREP_VERIFY 0x07
-#define PREP_READ_FIRMWARE 0x32
-#define PREP_WRITE_FIRMWARE 0x33
-
-//
-// Controller Status Codes
-//
-
-// Disk status codes
-
-#define STAT_SUCCESS 0x00
-
-#define STAT_HEADER_FAULT 0x00
-#define STAT_SEEK_TIMEOUT 0x01
-#define STAT_SEEK_FAULT 0x02
-#define STAT_SEEK_ERROR 0x03
-#define STAT_HEADER_CRC_ERROR 0x04
-#define STAT_REZERO_FAULT 0x05
-#define STAT_REZERO_TIMEOUT 0x06
-#define STAT_DRIVE_NOT_ONLINE 0x07
-#define STAT_WRITE_FAULT 0x08
-#define STAT_NOT_USED 0x09
-#define STAT_READ_DATA_FAULT 0x0a
-#define STAT_DATA_CRC_ERROR 0x0b
-#define STAT_SECTOR_LOCATE_ERR 0x0c
-#define STAT_WRITE_PROTECTED 0x0d
-#define STAT_ILL_SECTOR_ADDRESS 0x0e
-#define STAT_ILL_CMD_OP_CODE 0x0f
-#define STAT_DRIVE_NOT_ACK 0x10
-#define STAT_ACK_STUCK_ACTIVE 0x11
-#define STAT_TIMEOUT 0x12
-#define STAT_FAULT 0x13
-#define STAT_CRC 0x14
-#define STAT_SEEK 0x15
-#define STAT_VERIFICATION 0x16
-#define STAT_SPEED_ERROR 0x17
-#define STAT_ILL_ADDRESS 0x18
-#define STAT_RW_FAULT_ERROR 0x19
-#define STAT_SERVO_ERROR 0x1a
-#define STAT_GUARD_BAND 0x1b
-#define STAT_PLO_ERROR 0x1c
-#define STAT_RW_UNSAFE 0x1d
-
-// Disk status modifiers (added to status code)
-
-#define STAT_RECOVERABLE_ERR 0x20
-#define STAT_VERIFY_ERR 0x40
-#define STAT_FATAL_ERR 0x80
-
-// Semaphore status codes
-
-#define SEM_PRIOR_STATE_NOT_SET 0x00
-#define SEM_PRIOR_STATE_SET 0x80
-#define SEM_TABLE_FULL 0xfd
-#define SEM_DISK_ERROR 0xfe
-
-// Pipe Status codes
-
-#define PIPE_REQ_SUCCESSFUL 0x00
-#define PIPE_EMPTY_PIPE_READ 0x08
-#define PIPE_NOT_OPEN 0x09
-#define PIPE_WRITE_TO_FULL_PIPE 0x0a
-#define PIPE_OPEN_OPEN_PIPE 0x0b
-#define PIPE_PIPE_NOT_EXIST 0x0c
-#define PIPE_NO_ROOM_FOR_NEW 0x0d
-#define PIPE_ILLEGAL_COMMAND 0x0e
-#define PIPE_AREA_NOT_INIT 0x0f
-
-// Pipe State codes
-
-#define PIPE_OPEN_WRITE_EMPTY 0x01
-#define PIPE_OPEN_READ_EMPTY 0x02
-#define PIPE_NOT_OPEN_FULL 0x80
-#define PIPE_OPEN_WRITE_FULL 0x81
-#define PIPE_OPEN_READ_FULL 0x82
-
-// Status Register Bits
-
-#define CONTROLLER_BUSY 0x80 // Set = Busy, Clear = Ready
-#define CONTROLLER_DIRECTION 0x40 // Set = Controller->Host, Clear = Host->Controller
-
-#define MAX_COMMAND_SIZE 4096 // The maximum size of a command packet (the controller only has 5K of RAM...)
-
-class corvus_hdc_t : public device_t
-{
-public:
- // construction/destruction
- corvus_hdc_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_READ8_MEMBER( status_r );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- enum
- {
- TIMER_TIMEOUT,
- TIMER_COMMAND
- };
-
- // Sector addressing scheme for Rev B/H drives used in various commands (Called a DADR in the docs)
- struct dadr_t {
- UINT8 address_msn_and_drive;// Most significant nibble: Most signficant nibble of sector address, Least significant nibble: Drive #
- UINT8 address_lsb; // Least significant byte of sector address
- UINT8 address_mid; // Middle byte of sector address
- };
-
- UINT8 m_status; // Controller status byte (DIRECTION + BUSY/READY)
- // Prep mode
- bool m_prep_mode; // Whether the controller is in Prep Mode or not
- UINT8 m_prep_drv; // If in prep mode, Corvus drive id (1..15) being prepped
- // Physical drive info
- UINT8 m_sectors_per_track; // Number of sectors per track for this drive
- UINT8 m_tracks_per_cylinder;// Number of tracks per cylinder (heads)
- UINT16 m_cylinders_per_drive;// Number of cylinders per drive
- // Command Processing
- UINT16 m_offset; // Current offset into raw_data buffer
- bool m_awaiting_modifier; // We've received a two-byte command and we're waiting for the mod
- UINT16 m_recv_bytes; // Number of bytes expected to be received from Host
- UINT16 m_xmit_bytes; // Number of bytes expected to be transmitted to host
- // Timing-related values
- UINT16 m_last_cylinder; // Last cylinder accessed - for calculating seek times
- UINT32 m_delay; // Delay in microseconds for callback
- emu_timer *m_timeout_timer; // Four-second timer for timeouts
- emu_timer *m_cmd_timer;
- bool m_invalid_command_flag; // I hate this, but it saves a lot more tests
-
- //
- // Union below represents both an input and output buffer and interpretations of it
- //
- union {
- //
- // Raw Buffer
- //
- UINT8 raw_data[MAX_COMMAND_SIZE];
- //
- // Basic interpretation of code and modifier
- //
- struct {
- UINT8 code; // First byte of data is the code (command)
- UINT8 modifier; // Second byte of data is the modifier
- } command;
- //
- // Basic response code
- //
- struct {
- UINT8 status; // Status code returned by the command executed
- } single_byte_response;
- //
- // Read sector command
- //
- struct {
- UINT8 code; // Command code
- dadr_t dadr; // Encoded drive and sector to read
- } read_sector_command;
- //
- // 128-byte Read Sector response
- //
- struct {
- UINT8 status; // Status code returned by command executed
- UINT8 data[128]; // Data returned from read
- } read_128_response;
- //
- // 256-byte Read Sector response
- //
- struct {
- UINT8 status; // Status code returned by command executed
- UINT8 data[256]; // Data returned from read
- } read_256_response;
- //
- // 512-byte Read Sector response
- //
- struct {
- UINT8 status; // Status code returned by command executed
- UINT8 data[512]; // Data returned by read
- } read_512_response;
- //
- // Write 128-byte sector command
- //
- struct {
- UINT8 code; // Command code
- dadr_t dadr; // Encoded drive and sector to write
- UINT8 data[128]; // Data to be written
- } write_128_command;
- //
- // Write 256-byte sector command
- //
- struct {
- UINT8 code; // Command code
- dadr_t dadr; // Encoded drive and sector to write
- UINT8 data[256]; // Data to be written
- } write_256_command;
- //
- // Write 512-byte sector command
- //
- struct {
- UINT8 code; // Command Code
- dadr_t dadr; // Encoded drive and sector to write
- UINT8 data[512]; // Data to be written
- } write_512_command;
- //
- // Semaphore Lock command
- //
- struct {
- UINT8 code; // Command code
- UINT8 modifier; // Command code modifier
- UINT8 name[8]; // Semaphore name
- } lock_semaphore_command;
- //
- // Semaphore Unlock command
- //
- struct {
- UINT8 code; // Command code
- UINT8 modifier; // Command code modifier
- UINT8 name[8]; // Semaphore name
- } unlock_semaphore_command;
- //
- // Semaphore Lock/Unlock response
- //
- struct {
- UINT8 status; // Disk access status
- UINT8 result; // Semaphore action status
- UINT8 unused[10]; // Unused
- } semaphore_locking_response;
- //
- // Initialize Semaphore table command
- //
- struct {
- UINT8 code; // Command code
- UINT8 modifier; // Command code modifier
- UINT8 unused[3]; // Unused
- } init_semaphore_command;
- //
- // Semaphore Status command
- //
- struct {
- UINT8 code; // Command code
- UINT8 modifier; // Command code modifier
- UINT8 zero_three; // Don't ask me...
- UINT8 unused[2]; // Unused
- } semaphore_status_command;
- //
- // Semaphore Status response
- //
- struct {
- UINT8 status; // Disk access status
- UINT8 table[256]; // Contents of the semaphore table
- } semaphore_status_response;
- //
- // Get Drive Parameters command (0x10)
- //
- struct {
- UINT8 code; // Command code
- UINT8 drive; // Drive number (starts at 1)
- } get_drive_parameters_command;
- //
- // Get Drive Parameters command response
- //
- struct {
- UINT8 status; // Status code returned by command executed
- UINT8 firmware_desc[31]; // Firmware string description
- UINT8 firmware_rev; // Firmware revision number
- UINT8 rom_version; // ROM Version
- struct {
- UINT8 sectors_per_track; // Sectors/Track
- UINT8 tracks_per_cylinder; // Tracks/Cylinder (heads)
- struct {
- UINT8 lsb;
- UINT8 msb;
- } cylinders_per_drive; // Byte-flipped Cylinders/Drive
- } track_info;
- struct {
- UINT8 lsb; // Least significant byte
- UINT8 midb; // Middle byte
- UINT8 msb; // Most significant byte
- } capacity; // 24-bit value, byte-flipped (lsb..msb)
- UINT8 unused[16];
- UINT8 interleave; // Interleave factor
- struct {
- UINT8 mux_parameters[12];
- UINT8 pipe_name_table_ptr[2]; // Pointer to table of 64 entries, 8 bytes each (table of names)
- UINT8 pipe_ptr_table_ptr[2]; // Pointer to table of 64 entries, 8 bytes each. See pp. 29 - Mass Storage GTI
- UINT8 pipe_area_size[2]; // Size of pipe area (lsb, msb)
- struct {
- UINT8 track_offset[2];
- } vdo_table[7]; // Virtual drive table
- UINT8 lsi11_vdo_table[8];
- UINT8 lsi11_spare_table[8];
- } table_info;
- UINT8 drive_number; // Physical drive number
- struct {
- UINT8 lsb; // Least
- UINT8 midb; // Middle
- UINT8 msb; // Most
- } physical_capacity; // Physical capacity of drive
- } drive_param_response;
- //
- // 2-byte Boot command (0x14)
- //
- struct {
- UINT8 code; // Command code
- UINT8 boot_block; // Which boot block to read (0-7)
- } old_boot_command;
- //
- // Put drive into prep mode command (0x11)
- //
- struct {
- UINT8 code; // Command code
- UINT8 drive; // Drive number (starts at 1)
- UINT8 prep_block[512]; // Machine code payload
- } prep_mode_command;
- //
- // Read Firmware command (Prep Mode 0x32)
- //
- struct {
- UINT8 code; // Command Code
- UINT8 encoded_h_s;// Encoded Head (bits 7-5) / Sector (bits 4-0)
- } read_firmware_command;
- //
- // Write Firmware command (Prep Mode 0x33)
- //
- struct {
- UINT8 code; // Command Code
- UINT8 encoded_h_s; // Encoded Head (bits 7-5) / Sector (bits 4-0)
- UINT8 data[512]; // Data to be written
- } write_firmware_command;
- //
- // Format Drive command (Prep Mode 0x01)
- //
- // Note that the following is a BLATANT ASSUMPTION. Technically, the Format Drive command
- // uses a variable-length buffer for the pattern. Unfortunately, the docs don't explain how to determine the
- // length of the buffer passed. I assume it's a timeout; however, the docs happen to say that
- // all Corvus diagnostic programs send 513 bytes total, including the command, so I'm going with that.
- //
- struct {
- UINT8 code; // Command Code
- UINT8 pattern[512]; // Pattern to be written
- } format_drive_revbh_command;
- //
- // Verify Drive command (Prep Mode 0x07)
- //
- // On the real Corvus controller, this is a variable length response. If the
- // number of bad sectors is greater than zero, an additional four bytes will
- // follow for each bad sector. We don't emulate bad sectors, so we always
- // return a count of 0. That makes this a fixed length response of 2 bytes.
- //
- struct {
- UINT8 status; // Disk access status
- UINT8 bad_sectors; // Number of bad sectors (always zero)
- } verify_drive_response;
- } m_buffer;
-
- // Structure of Block #1, the Disk Parameter Block
- struct disk_parameter_block_t {
- struct {
- UINT8 lsb;
- UINT8 msb;
- } spared_track[8]; // Spared track table (0xffff indicates end)
- UINT8 interleave; // Interleave factor
- UINT8 reserved;
- struct {
- UINT8 track_offset[2]; // Virtual drive offsets (lsb, msb) 0xffff indicates unused
- } vdo_table[7];
- UINT8 lsi11_vdo_table[8];
- UINT8 lsi11_spare_table[8];
- UINT8 reserved2[432];
- struct {
- UINT8 lsb;
- UINT8 msb;
- } revh_spare_table[16];
- };
-
- // Structure of Block #3, the Constellation Parameter Block
- struct constellation_parameter_block_t {
- UINT8 mux_parameters[12];
- UINT8 pipe_name_table_ptr[2];
- UINT8 pipe_ptr_table_ptr[2];
- UINT8 pipe_area_size[2];
- UINT8 reserved[470];
- UINT8 software_protection[12];
- UINT8 serial_number[12];
- };
-
- // Structure of Block #7, the Semaphore Table Block
- struct semaphore_table_block_t {
- union {
- UINT8 semaphore_table[256]; // Table consists of 256 bytes
- struct {
- UINT8 semaphore_name[8]; // Each semaphore name is 8 bytes
- } semaphore_entry[32]; // 32 Entries
- } semaphore_block;
- UINT8 unused[256]; // Remaining half of block is unused
- };
-
- // Command size structure (number of bytes to xmit and recv for each command)
- struct corvus_cmd_t {
- UINT16 recv_bytes; // Number of bytes from host for this command
- UINT16 xmit_bytes; // Number of bytes to return to host
- };
-
- void dump_buffer(UINT8 *buffer, UINT16 length);
- bool parse_hdc_command(UINT8 data);
- UINT8 corvus_write_sector(UINT8 drv, UINT32 sector, UINT8 *buffer, int len);
- UINT8 corvus_write_logical_sector(dadr_t *dadr, UINT8 *buffer, int len);
- UINT8 corvus_read_sector(UINT8 drv, UINT32 sector, UINT8 *buffer, int len);
- UINT8 corvus_read_logical_sector(dadr_t *dadr, UINT8 *buffer, int len);
- UINT8 corvus_lock_semaphore(UINT8 *name);
- UINT8 corvus_unlock_semaphore(UINT8 *name);
- UINT8 corvus_init_semaphore_table();
- UINT8 corvus_get_drive_parameters(UINT8 drv);
- UINT8 corvus_read_boot_block(UINT8 block);
- UINT8 corvus_enter_prep_mode(UINT8 drv, UINT8 *prep_block);
- UINT8 corvus_exit_prep_mode();
- UINT8 corvus_read_firmware_block(UINT8 head, UINT8 sector);
- UINT8 corvus_write_firmware_block(UINT8 head, UINT8 sector, UINT8 *buffer);
- UINT8 corvus_format_drive(UINT8 *pattern, UINT16 len);
- hard_disk_file *corvus_hdc_file(int id);
- void corvus_process_command_packet(bool local_invalid_command_flag);
-
- corvus_cmd_t corvus_cmd[0xf5][0xc1]; // Command sizes and their return sizes
- corvus_cmd_t corvus_prep_cmd[0x82]; // Prep Command sizes and their return sizes
-};
-
-
-// device type definition
-extern const device_type CORVUS_HDC;
-
-#endif /* CORVUSHD_H_ */
diff --git a/src/emu/machine/cr511b.c b/src/emu/machine/cr511b.c
deleted file mode 100644
index 9ce22895dba..00000000000
--- a/src/emu/machine/cr511b.c
+++ /dev/null
@@ -1,121 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- CR-511-B CD-ROM drive
-
- CD-ROM drive with a custom MKE/Panasonic interface as used in the
- Commodore CDTV and early SoundBlaster cards.
-
-***************************************************************************/
-
-#include "cr511b.h"
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type CR511B = &device_creator<cr511b_device>;
-
-//-------------------------------------------------
-// machine_config_additions - device-specific
-// machine configurations
-//-------------------------------------------------
-
-static MACHINE_CONFIG_FRAGMENT( cr511b )
- MCFG_CDROM_ADD("cdrom")
- MCFG_CDROM_INTERFACE("cdrom")
- MCFG_SOUND_ADD("cdda", CDDA, 0)
- MCFG_SOUND_ROUTE(0, ":lspeaker", 1.0)
- MCFG_SOUND_ROUTE(1, ":rspeaker", 1.0)
-MACHINE_CONFIG_END
-
-machine_config_constructor cr511b_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( cr511b );
-}
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// cr511b_device - constructor
-//-------------------------------------------------
-
-cr511b_device::cr511b_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, CR511B, "CR-511-B CD-ROM drive", tag, owner, clock, "cr511b", __FILE__),
- m_cdrom(*this, "cdrom"),
- m_cdda(*this, "cdda"),
- m_stch_handler(*this),
- m_sten_handler(*this),
- m_drq_handler(*this),
- m_dten_handler(*this),
- m_scor_handler(*this),
- m_xaen_handler(*this),
- m_frame_timer(NULL),
- //m_motor(false),
- m_enabled(-1),
- m_cmd(-1)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void cr511b_device::device_start()
-{
- // resolve callbacks
- m_stch_handler.resolve_safe();
- m_sten_handler.resolve_safe();
- m_drq_handler.resolve_safe();
- m_dten_handler.resolve_safe();
- m_scor_handler.resolve_safe();
- m_xaen_handler.resolve_safe();
-
- m_frame_timer = timer_alloc(0, NULL);
- m_frame_timer->adjust(attotime::never);
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void cr511b_device::device_reset()
-{
-}
-
-//-------------------------------------------------
-// device_timer - device-specific timer events
-//-------------------------------------------------
-
-void cr511b_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
-{
-}
-
-
-//**************************************************************************
-// IMPLEMENTATION
-//**************************************************************************
-
-READ8_MEMBER( cr511b_device::read )
-{
- return 0xff;
-}
-
-WRITE8_MEMBER ( cr511b_device::write )
-{
-}
-
-WRITE_LINE_MEMBER( cr511b_device::enable_w )
-{
- m_enabled = state;
-}
-
-WRITE_LINE_MEMBER( cr511b_device::cmd_w )
-{
- m_cmd = state;
-}
diff --git a/src/emu/machine/cr511b.h b/src/emu/machine/cr511b.h
deleted file mode 100644
index 59a8fc13fca..00000000000
--- a/src/emu/machine/cr511b.h
+++ /dev/null
@@ -1,150 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- CR-511-B CD-ROM drive
-
- CD-ROM drive with a custom MKE/Panasonic interface as used in the
- Commodore CDTV and early SoundBlaster cards.
-
- 1 _RESET 2 GND
- 3 EFFK 4 SCCK
- 5 SBCP 6 SCOR
- 7 GND 8 GND
- 9 C16M 10 GND
- 11 _XAEN 12 GND
- 13 EMPASIS 14 D0
- 15 LRCK 16 DSCK
- 17 _MUTE 18 GND
- 19 _BUSY 20 _STCH
- 21 _ENABLE 22 DRQ
- 23 _HWR 24 GND
- 25 _DTEN 26 _HRD
- 27 _STEN 28 _CMD
- 29 _EOP 30 GND
- 31 DB7 32 GND
- 33 DB6 34 DB5
- 35 DB4 36 GND
- 37 DB3 38 DB2
- 39 DB1 40 DB0
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __CR511B_H__
-#define __CR511B_H__
-
-#include "emu.h"
-#include "imagedev/chd_cd.h"
-#include "sound/cdda.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_CR511B_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, CR511B, 0)
-#define MCFG_CR511B_STCH_HANDLER(_devcb) \
- devcb = &cr511b_device::set_stch_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_CR511B_STEN_HANDLER(_devcb) \
- devcb = &cr511b_device::set_sten_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_CR511B_DRQ_HANDLER(_devcb) \
- devcb = &cr511b_device::set_drq_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_CR511B_DTEN_HANDLER(_devcb) \
- devcb = &cr511b_device::set_dten_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_CR511B_SCOR_HANDLER(_devcb) \
- devcb = &cr511b_device::set_scor_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_CR511B_XAEN_HANDLER(_devcb) \
- devcb = &cr511b_device::set_xaen_handler(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> cr511b_device
-
-class cr511b_device : public device_t
-{
-public:
- // construction/destruction
- cr511b_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // callbacks
- template<class _Object> static devcb_base &set_stch_handler(device_t &device, _Object object)
- { return downcast<cr511b_device &>(device).m_stch_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_sten_handler(device_t &device, _Object object)
- { return downcast<cr511b_device &>(device).m_sten_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_drq_handler(device_t &device, _Object object)
- { return downcast<cr511b_device &>(device).m_drq_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_dten_handler(device_t &device, _Object object)
- { return downcast<cr511b_device &>(device).m_dten_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_scor_handler(device_t &device, _Object object)
- { return downcast<cr511b_device &>(device).m_scor_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_xaen_handler(device_t &device, _Object object)
- { return downcast<cr511b_device &>(device).m_xaen_handler.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER ( write );
-
- DECLARE_WRITE_LINE_MEMBER( enable_w );
- DECLARE_WRITE_LINE_MEMBER( cmd_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual machine_config_constructor device_mconfig_additions() const;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- enum
- {
- STATUS_DOOR_CLOSED = 0x80,
- STATUS_MEDIA = 0x40,
- STATUS_MOTOR = 0x20,
- STATUS_ERROR = 0x10,
- STATUS_SUCCESS = 0x08,
- STATUS_PLAYING = 0x04,
- STATUS_DOOR_LOCKED = 0x02,
- STATUS_READY = 0x01
- };
-
- required_device<cdrom_image_device> m_cdrom;
- required_device<cdda_device> m_cdda;
-
- devcb_write_line m_stch_handler;
- devcb_write_line m_sten_handler;
- devcb_write_line m_drq_handler;
- devcb_write_line m_dten_handler;
- devcb_write_line m_scor_handler;
- devcb_write_line m_xaen_handler;
-
- emu_timer *m_frame_timer;
-
- //bool m_motor;
-
- // state of lines
- int m_enabled;
- int m_cmd;
-
- // data transfer
- //UINT8 m_sector_buffer[CD_MAX_SECTOR_DATA];
-};
-
-// device type definition
-extern const device_type CR511B;
-
-#endif
diff --git a/src/emu/machine/cr589.c b/src/emu/machine/cr589.c
deleted file mode 100644
index 8c0ae34f6c9..00000000000
--- a/src/emu/machine/cr589.c
+++ /dev/null
@@ -1,196 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "cr589.h"
-
-
-static const int identity_offset = 0x3ab;
-static const char download_identity[] = "MATSHITA CD98Q4 DOWNLOADGS0N";
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void matsushita_cr589_device::nvram_default()
-{
- memset( buffer, 0, sizeof(buffer));
- memcpy( &buffer[ identity_offset ], "MATSHITACD-ROM CR-589 GS0N", 28 );
-}
-
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void matsushita_cr589_device::nvram_read(emu_file &file)
-{
- file.read(buffer, sizeof(buffer));
-}
-
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void matsushita_cr589_device::nvram_write(emu_file &file)
-{
- file.write(buffer, sizeof(buffer));
-}
-
-
-
-void matsushita_cr589_device::ExecCommand()
-{
- switch( command[ 0 ] )
- {
- case T10SPC_CMD_INQUIRY:
- logerror("T10MMC: INQUIRY\n");
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = SCSILengthFromUINT8( &command[ 4 ] );
- break;
-
- case 0x3b: // WRITE BUFFER
- bufferOffset = ( command[ 3 ] << 16 ) | ( command[ 4 ] << 8 ) | command[ 5 ];
- m_phase = SCSI_PHASE_DATAOUT;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = ( command[ 6 ] << 16 ) | ( command[ 7 ] << 8 ) | command[ 8 ];
- break;
-
- case 0x3c: // READ BUFFER
- bufferOffset = ( command[ 3 ] << 16 ) | ( command[ 4 ] << 8 ) | command[ 5 ];
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = ( command[ 6 ] << 16 ) | ( command[ 7 ] << 8 ) | command[ 8 ];
- break;
-
- case 0xcc: // FIRMWARE DOWNLOAD ENABLE
- m_phase = SCSI_PHASE_DATAOUT;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = SCSILengthFromUINT16( &command[7] );
- break;
-
- default:
- t10mmc::ExecCommand();
- break;
- }
-}
-
-void matsushita_cr589_device::ReadData( UINT8 *data, int dataLength )
-{
- switch( command[ 0 ] )
- {
- case T10SPC_CMD_INQUIRY:
- memset(data, 0, dataLength);
-
- t10mmc::ReadData( data, dataLength );
-
- if( download )
- {
- memcpy( &data[ 8 ], download_identity, 28 );
- }
- else
- {
- memcpy( &data[ 8 ], &buffer[ identity_offset ], 28 );
- }
- break;
-
- case 0x3c: // READ BUFFER
- memcpy( data, &buffer[ bufferOffset ], dataLength );
- bufferOffset += dataLength;
- break;
-
- default:
- t10mmc::ReadData( data, dataLength );
- break;
- }
-}
-
-void matsushita_cr589_device::WriteData( UINT8 *data, int dataLength )
-{
- switch( command[ 0 ] )
- {
- case 0x3b: // WRITE BUFFER
- memcpy( &buffer[ bufferOffset ], data + 32, dataLength - 32 );
- bufferOffset += dataLength;
- break;
-
- case 0xcc: // FIRMWARE DOWNLOAD ENABLE
- if( memcmp( data, &buffer[ identity_offset ], 28 ) == 0 )
- {
- download = 1;
- }
- else if( memcmp( data, download_identity, 28 ) == 0 )
- {
- download = 0;
- }
- break;
-
- default:
- t10mmc::WriteData( data, dataLength );
- break;
- }
-}
-
-// device type definition
-const device_type CR589 = &device_creator<matsushita_cr589_device>;
-
-matsushita_cr589_device::matsushita_cr589_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- atapi_cdrom_device(mconfig, CR589, "Matsushita CR589 CD-ROM Drive", tag, owner, clock, "cr589", __FILE__),
- device_nvram_interface(mconfig, *this)
-{
-}
-
-void matsushita_cr589_device::device_start()
-{
- save_item(NAME(download));
- save_item(NAME(buffer));
- save_item(NAME(bufferOffset));
-
- atapi_cdrom_device::device_start();
-
- /// TODO: split identify buffer into another method as device_start() should be called after it's filled in, but the atapi_cdrom_device has it's own.
- memset(m_identify_buffer, 0, sizeof(m_identify_buffer));
-
- m_identify_buffer[ 0 ] = 0x8500; // ATAPI device, cmd set 5 compliant, DRQ within 3 ms of PACKET command
-
- m_identify_buffer[ 23 ] = ('1' << 8) | '.';
- m_identify_buffer[ 24 ] = ('0' << 8) | ' ';
- m_identify_buffer[ 25 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 26 ] = (' ' << 8) | ' ';
-
- m_identify_buffer[ 27 ] = ('M' << 8) | 'A';
- m_identify_buffer[ 28 ] = ('T' << 8) | 'S';
- m_identify_buffer[ 29 ] = ('H' << 8) | 'I';
- m_identify_buffer[ 30 ] = ('T' << 8) | 'A';
- m_identify_buffer[ 31 ] = (' ' << 8) | 'C';
- m_identify_buffer[ 32 ] = ('R' << 8) | '-';
- m_identify_buffer[ 33 ] = ('5' << 8) | '8';
- m_identify_buffer[ 34 ] = ('9' << 8) | ' ';
- m_identify_buffer[ 35 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 36 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 37 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 38 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 39 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 40 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 41 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 42 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 43 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 44 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 45 ] = (' ' << 8) | ' ';
- m_identify_buffer[ 46 ] = (' ' << 8) | ' ';
-
- m_identify_buffer[ 49 ] = 0x0400; // IORDY may be disabled
-}
-
-void matsushita_cr589_device::device_reset()
-{
- atapi_cdrom_device::device_reset();
-
- download = 0;
- bufferOffset = 0;
-}
diff --git a/src/emu/machine/cr589.h b/src/emu/machine/cr589.h
deleted file mode 100644
index 87fe1c16641..00000000000
--- a/src/emu/machine/cr589.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- cr589.h
-
- Matsushita CR589
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __CR589_H__
-#define __CR589_H__
-
-#include "atapicdr.h"
-#include "t10mmc.h"
-
-class matsushita_cr589_device : public atapi_cdrom_device,
- public device_nvram_interface
-{
-public:
- matsushita_cr589_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual void ExecCommand();
- virtual void WriteData( UINT8 *data, int dataLength );
- virtual void ReadData( UINT8 *data, int dataLength );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
-private:
- int download;
- UINT8 buffer[ 65536 ];
- int bufferOffset;
-};
-
-// device type definition
-extern const device_type CR589;
-
-#endif
diff --git a/src/emu/machine/cs4031.c b/src/emu/machine/cs4031.c
deleted file mode 100644
index b6d8de1acd8..00000000000
--- a/src/emu/machine/cs4031.c
+++ /dev/null
@@ -1,969 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- Chips & Technologies CS4031 chipset
-
- Chipset for 486 based PC/AT compatible systems. Consists of two
- individual chips:
-
- * F84031
- - DRAM controller
- - ISA-bus controller
- - VESA VL-BUS controller
-
- * F84035 (82C206 IPC core)
- - 2x 8257 DMA controller
- - 2x 8259 interrupt controller
- - 8254 timer
- - MC14818 RTC
-
- TODO:
- - No emulation of memory parity checks
- - Move IPC core to its own file so it can be shared with
- other chipsets
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/ram.h"
-#include "machine/cs4031.h"
-
-
-//**************************************************************************
-// MACROS/CONSTANTS
-//**************************************************************************
-
-#define LOG_REGISTER 1
-#define LOG_MEMORY 1
-#define LOG_IO 1
-#define LOG_KEYBOARD 0
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type CS4031 = &device_creator<cs4031_device>;
-
-const char* cs4031_device::m_register_names[] =
-{
- /* 00 */ "RESERVED",
- /* 01 */ "DMA WAIT STATE CONTROL",
- /* 02 */ "RESERVED",
- /* 03 */ "RESERVED",
- /* 04 */ "RESERVED",
- /* 05 */ "ISA BUS COMMAND DELAY",
- /* 06 */ "ISA BUS WAIT STATES AND ADDRESS HOLD",
- /* 07 */ "ISA BUS CLOCK SELECTION",
- /* 08 */ "PERFORMANCE CONTROL",
- /* 09 */ "84035 MISC CONTROL",
- /* 0a */ "DMA CLOCK SELECTION",
- /* 0b */ "RESERVED",
- /* 0c */ "RESERVED",
- /* 0d */ "RESERVED",
- /* 0e */ "RESERVED",
- /* 0f */ "RESERVED",
- /* 10 */ "DRAM TIMING",
- /* 11 */ "DRAM SETUP",
- /* 12 */ "DRAM CONFIGURATION 0 AND 1",
- /* 13 */ "DRAM CONFIGURATION 2 AND 3",
- /* 14 */ "DRAM BLOCK 0 STARTING ADDRESS",
- /* 15 */ "DRAM BLOCK 1 STARTING ADDRESS",
- /* 16 */ "DRAM BLOCK 2 STARTING ADDRESS",
- /* 17 */ "DRAM BLOCK 3 STARTING ADDRESS",
- /* 18 */ "VIDEO AREA SHADOW AND LOCAL BUS CONTROL",
- /* 19 */ "DRAM SHADOW READ ENABLE",
- /* 1a */ "DRAM SHADOW WRITE ENABLE",
- /* 1b */ "ROMCS ENABLE",
- /* 1c */ "SOFT RESET AND GATEA20",
- /* 1d */ "RESERVED",
- /* 1e */ "RESERVED",
- /* 1f */ "RESERVED"
-};
-
-const float cs4031_device::m_dma_clock_divider[] =
-{
- 10, 8, 6, 0, 0, 0, 0, 0, 5, 4, 3, 2.5, 2, 1.5, 0, 0
-};
-
-//-------------------------------------------------
-// machine_config_additions - device-specific
-// machine configurations
-//-------------------------------------------------
-
-static MACHINE_CONFIG_FRAGMENT( cs4031 )
- MCFG_DEVICE_ADD("dma1", AM9517A, 0)
- MCFG_I8237_OUT_HREQ_CB(DEVWRITELINE("dma2", am9517a_device, dreq0_w))
- MCFG_I8237_OUT_EOP_CB(WRITELINE(cs4031_device, dma1_eop_w))
- MCFG_I8237_IN_MEMR_CB(READ8(cs4031_device, dma_read_byte))
- MCFG_I8237_OUT_MEMW_CB(WRITE8(cs4031_device, dma_write_byte))
- MCFG_I8237_IN_IOR_0_CB(READ8(cs4031_device, dma1_ior0_r))
- MCFG_I8237_IN_IOR_1_CB(READ8(cs4031_device, dma1_ior1_r))
- MCFG_I8237_IN_IOR_2_CB(READ8(cs4031_device, dma1_ior2_r))
- MCFG_I8237_IN_IOR_3_CB(READ8(cs4031_device, dma1_ior3_r))
- MCFG_I8237_OUT_IOW_0_CB(WRITE8(cs4031_device, dma1_iow0_w))
- MCFG_I8237_OUT_IOW_1_CB(WRITE8(cs4031_device, dma1_iow1_w))
- MCFG_I8237_OUT_IOW_2_CB(WRITE8(cs4031_device, dma1_iow2_w))
- MCFG_I8237_OUT_IOW_3_CB(WRITE8(cs4031_device, dma1_iow3_w))
- MCFG_I8237_OUT_DACK_0_CB(WRITELINE(cs4031_device, dma1_dack0_w))
- MCFG_I8237_OUT_DACK_1_CB(WRITELINE(cs4031_device, dma1_dack1_w))
- MCFG_I8237_OUT_DACK_2_CB(WRITELINE(cs4031_device, dma1_dack2_w))
- MCFG_I8237_OUT_DACK_3_CB(WRITELINE(cs4031_device, dma1_dack3_w))
- MCFG_DEVICE_ADD("dma2", AM9517A, 0)
- MCFG_I8237_OUT_HREQ_CB(WRITELINE(cs4031_device, dma2_hreq_w))
- MCFG_I8237_IN_MEMR_CB(READ8(cs4031_device, dma_read_word))
- MCFG_I8237_OUT_MEMW_CB(WRITE8(cs4031_device, dma_write_word))
- MCFG_I8237_IN_IOR_1_CB(READ8(cs4031_device, dma2_ior1_r))
- MCFG_I8237_IN_IOR_2_CB(READ8(cs4031_device, dma2_ior2_r))
- MCFG_I8237_IN_IOR_3_CB(READ8(cs4031_device, dma2_ior3_r))
- MCFG_I8237_OUT_IOW_1_CB(WRITE8(cs4031_device, dma2_iow1_w))
- MCFG_I8237_OUT_IOW_2_CB(WRITE8(cs4031_device, dma2_iow2_w))
- MCFG_I8237_OUT_IOW_3_CB(WRITE8(cs4031_device, dma2_iow3_w))
- MCFG_I8237_OUT_DACK_0_CB(WRITELINE(cs4031_device, dma2_dack0_w))
- MCFG_I8237_OUT_DACK_1_CB(WRITELINE(cs4031_device, dma2_dack1_w))
- MCFG_I8237_OUT_DACK_2_CB(WRITELINE(cs4031_device, dma2_dack2_w))
- MCFG_I8237_OUT_DACK_3_CB(WRITELINE(cs4031_device, dma2_dack3_w))
- MCFG_PIC8259_ADD("intc1", WRITELINE(cs4031_device, intc1_int_w), VCC, READ8(cs4031_device, intc1_slave_ack_r))
- MCFG_PIC8259_ADD("intc2", DEVWRITELINE("intc1", pic8259_device, ir2_w), GND, NULL)
-
- MCFG_DEVICE_ADD("ctc", PIT8254, 0)
- MCFG_PIT8253_CLK0(XTAL_14_31818MHz / 12)
- MCFG_PIT8253_OUT0_HANDLER(DEVWRITELINE("intc1", pic8259_device, ir0_w))
- MCFG_PIT8253_CLK1(XTAL_14_31818MHz / 12)
- MCFG_PIT8253_OUT1_HANDLER(WRITELINE(cs4031_device, ctc_out1_w))
- MCFG_PIT8253_CLK2(XTAL_14_31818MHz / 12)
- MCFG_PIT8253_OUT2_HANDLER(WRITELINE(cs4031_device, ctc_out2_w))
-
- MCFG_DS12885_ADD("rtc")
- MCFG_MC146818_IRQ_HANDLER(WRITELINE(cs4031_device, rtc_irq_w))
- MCFG_MC146818_CENTURY_INDEX(0x32)
-MACHINE_CONFIG_END
-
-machine_config_constructor cs4031_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( cs4031 );
-}
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// cs4031_device - constructor
-//-------------------------------------------------
-
-cs4031_device::cs4031_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, CS4031, "CS4031", tag, owner, clock, "cs4031", __FILE__),
- m_read_ior(*this),
- m_write_iow(*this),
- m_write_tc(*this),
- m_write_hold(*this),
- m_write_nmi(*this),
- m_write_intr(*this),
- m_write_cpureset(*this),
- m_write_a20m(*this),
- m_write_spkr(*this),
- m_dma1(*this, "dma1"),
- m_dma2(*this, "dma2"),
- m_intc1(*this, "intc1"),
- m_intc2(*this, "intc2"),
- m_ctc(*this, "ctc"),
- m_rtc(*this, "rtc"),
- m_dma_eop(0),
- m_dma_high_byte(0xff),
- m_dma_channel(-1),
- m_portb(0x0f),
- m_refresh_toggle(0),
- m_iochck(1),
- m_nmi_mask(1),
- m_cpureset(0),
- m_kbrst(1),
- m_ext_gatea20(0),
- m_fast_gatea20(0),
- m_emu_gatea20(0),
- m_keybc_d1_written(false),
- m_keybc_data_blocked(false),
- m_address(0),
- m_address_valid(false)
-{
-}
-
-void cs4031_device::static_set_cputag(device_t &device, const char *tag)
-{
- cs4031_device &cs4031 = downcast<cs4031_device &>(device);
- cs4031.m_cputag = tag;
-}
-
-void cs4031_device::static_set_isatag(device_t &device, const char *tag)
-{
- cs4031_device &cs4031 = downcast<cs4031_device &>(device);
- cs4031.m_isatag = tag;
-}
-
-void cs4031_device::static_set_biostag(device_t &device, const char *tag)
-{
- cs4031_device &cs4031 = downcast<cs4031_device &>(device);
- cs4031.m_biostag = tag;
-}
-
-void cs4031_device::static_set_keybctag(device_t &device, const char *tag)
-{
- cs4031_device &cs4031 = downcast<cs4031_device &>(device);
- cs4031.m_keybctag = tag;
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void cs4031_device::device_start()
-{
- ram_device *ram_dev = machine().device<ram_device>(RAM_TAG);
-
- // make sure the ram device is already running
- if (!ram_dev->started())
- throw device_missing_dependencies();
-
- // resolve callbacks
- m_read_ior.resolve_safe(0);
- m_write_iow.resolve_safe();
- m_write_tc.resolve_safe();
- m_write_hold.resolve_safe();
- m_write_nmi.resolve_safe();
- m_write_intr.resolve_safe();
- m_write_cpureset.resolve_safe();
- m_write_a20m.resolve_safe();
- m_write_spkr.resolve_safe();
-
- // register for state saving
- save_item(NAME(m_dma_eop));
- save_item(NAME(m_dma_page));
- save_item(NAME(m_dma_high_byte));
- save_item(NAME(m_dma_channel));
- save_item(NAME(m_portb));
- save_item(NAME(m_refresh_toggle));
- save_item(NAME(m_iochck));
- save_item(NAME(m_nmi_mask));
- save_item(NAME(m_cpureset));
- save_item(NAME(m_kbrst));
- save_item(NAME(m_ext_gatea20));
- save_item(NAME(m_fast_gatea20));
- save_item(NAME(m_address));
- save_item(NAME(m_address_valid));
- save_item(NAME(m_registers));
-
- device_t *cpu = machine().device(m_cputag);
- m_space = &cpu->memory().space(AS_PROGRAM);
- m_space_io = &cpu->memory().space(AS_IO);
-
- m_isa = machine().root_device().memregion(m_isatag)->base();
- m_bios = machine().root_device().memregion(m_biostag)->base();
- m_keybc = downcast<at_keyboard_controller_device *>(machine().device(m_keybctag));
-
- m_ram = ram_dev->pointer();
- UINT32 ram_size = ram_dev->size();
-
- // install base memory
- m_space->install_ram(0x000000, 0x09ffff, m_ram);
-
- // install extended memory
- if (ram_size > 0x100000)
- m_space->install_ram(0x100000, ram_size - 1, m_ram + 0x100000);
-
- // install bios rom at cpu inital pc
- m_space->install_rom(0xffff0000, 0xffffffff, m_bios + 0xf0000);
-
- // install i/o accesses
- m_space_io->install_readwrite_handler(0x0000, 0x000f, read8_delegate(FUNC(am9517a_device::read), &(*m_dma1)), write8_delegate(FUNC(am9517a_device::write), &(*m_dma1)), 0xffffffff);
- m_space_io->install_readwrite_handler(0x0020, 0x0023, read8_delegate(FUNC(pic8259_device::read), &(*m_intc1)), write8_delegate(FUNC(pic8259_device::write), &(*m_intc1)), 0x0000ffff);
- m_space_io->install_write_handler(0x0020, 0x0023, write8_delegate(FUNC(cs4031_device::config_address_w), this), 0x00ff0000);
- m_space_io->install_readwrite_handler(0x0020, 0x0023, read8_delegate(FUNC(cs4031_device::config_data_r), this), write8_delegate(FUNC(cs4031_device::config_data_w), this), 0xff000000);
- m_space_io->install_readwrite_handler(0x0040, 0x0043, read8_delegate(FUNC(pit8254_device::read), &(*m_ctc)), write8_delegate(FUNC(pit8254_device::write), &(*m_ctc)), 0xffffffff);
- m_space_io->install_readwrite_handler(0x0060, 0x0063, read8_delegate(FUNC(cs4031_device::keyb_data_r), this), write8_delegate(FUNC(cs4031_device::keyb_data_w), this), 0x000000ff);
- m_space_io->install_readwrite_handler(0x0060, 0x0063, read8_delegate(FUNC(cs4031_device::portb_r), this), write8_delegate(FUNC(cs4031_device::portb_w), this), 0x0000ff00);
- m_space_io->install_readwrite_handler(0x0064, 0x0067, read8_delegate(FUNC(cs4031_device::keyb_status_r), this), write8_delegate(FUNC(cs4031_device::keyb_command_w), this), 0x000000ff);
- m_space_io->install_readwrite_handler(0x0070, 0x0073, read8_delegate(FUNC(mc146818_device::read), &(*m_rtc)), write8_delegate(FUNC(cs4031_device::rtc_w), this), 0x0000ffff);
- m_space_io->install_readwrite_handler(0x0080, 0x008f, read8_delegate(FUNC(cs4031_device::dma_page_r), this), write8_delegate(FUNC(cs4031_device::dma_page_w), this), 0xffffffff);
- m_space_io->install_readwrite_handler(0x0090, 0x0093, read8_delegate(FUNC(cs4031_device::sysctrl_r), this), write8_delegate(FUNC(cs4031_device::sysctrl_w), this), 0x00ff0000);
- m_space_io->install_readwrite_handler(0x00a0, 0x00a3, read8_delegate(FUNC(pic8259_device::read), &(*m_intc2)), write8_delegate(FUNC(pic8259_device::write), &(*m_intc2)), 0x0000ffff);
- m_space_io->install_readwrite_handler(0x00c0, 0x00df, read8_delegate(FUNC(cs4031_device::dma2_r),this), write8_delegate(FUNC(cs4031_device::dma2_w),this), 0xffffffff);
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void cs4031_device::device_reset()
-{
- // setup default values
- memset(&m_registers, 0x00, sizeof(m_registers));
- m_registers[ROMCS] = 0x60;
-
- // update rom/ram regions below 1mb
- update_read_regions();
- update_write_regions();
-
- // initialize dma controller clocks
- update_dma_clock();
-}
-
-//-------------------------------------------------
-// device_reset_after_children
-//-------------------------------------------------
-
-void cs4031_device::device_reset_after_children()
-{
- // timer 2 default state
- m_ctc->write_gate2(1);
-}
-
-
-//**************************************************************************
-// DMA CONTROLLER
-//**************************************************************************
-
-offs_t cs4031_device::page_offset()
-{
- switch (m_dma_channel)
- {
- case 0: return (offs_t) m_dma_page[0x07] << 16;
- case 1: return (offs_t) m_dma_page[0x03] << 16;
- case 2: return (offs_t) m_dma_page[0x01] << 16;
- case 3: return (offs_t) m_dma_page[0x02] << 16;
- case 5: return (offs_t) m_dma_page[0x0b] << 16;
- case 6: return (offs_t) m_dma_page[0x09] << 16;
- case 7: return (offs_t) m_dma_page[0x0a] << 16;
- }
-
- // should never get here
- return 0xff0000;
-}
-
-READ8_MEMBER( cs4031_device::dma_read_byte )
-{
- if (m_dma_channel == -1)
- return 0xff;
-
- return m_space->read_byte(page_offset() + offset);
-}
-
-WRITE8_MEMBER( cs4031_device::dma_write_byte )
-{
- if (m_dma_channel == -1)
- return;
-
- m_space->write_byte(page_offset() + offset, data);
-}
-
-READ8_MEMBER( cs4031_device::dma_read_word )
-{
- if (m_dma_channel == -1)
- return 0xff;
-
- UINT16 result = m_space->read_word(page_offset() + (offset << 1));
- m_dma_high_byte = result >> 8;
-
- return result;
-}
-
-WRITE8_MEMBER( cs4031_device::dma_write_word )
-{
- if (m_dma_channel == -1)
- return;
-
- m_space->write_word(page_offset() + (offset << 1), (m_dma_high_byte << 8) | data);
-}
-
-WRITE_LINE_MEMBER( cs4031_device::dma2_dack0_w )
-{
- m_dma1->hack_w(state ? 0 : 1); // inverted?
-}
-
-WRITE_LINE_MEMBER( cs4031_device::dma1_eop_w )
-{
- m_dma_eop = state;
- if (m_dma_channel != -1)
- m_write_tc(m_dma_channel, state, 0xff);
-}
-
-void cs4031_device::set_dma_channel(int channel, bool state)
-{
- if (!state)
- {
- m_dma_channel = channel;
- if (m_dma_eop)
- m_write_tc(channel, 1, 0xff);
- }
- else
- {
- if (m_dma_channel == channel)
- {
- m_dma_channel = -1;
- if (m_dma_eop)
- m_write_tc(channel, 0, 0xff);
- }
- }
-}
-
-void cs4031_device::update_dma_clock()
-{
- if (m_dma_clock_divider[m_registers[DMA_CLOCK] & 0x0f] != 0)
- {
- UINT32 dma_clock = clock() / m_dma_clock_divider[m_registers[DMA_CLOCK] & 0x0f];
-
- if (!BIT(m_registers[DMA_WAIT_STATE], 0))
- dma_clock /= 2;
-
- logerror("cs4031_device::update_dma_clock: dma clock is now %u\n", dma_clock);
-
- m_dma1->set_unscaled_clock(dma_clock);
- m_dma2->set_unscaled_clock(dma_clock);
- }
-}
-
-
-//**************************************************************************
-// INTERRUPTS
-//**************************************************************************
-
-/*
- Check NMI sources and generate NMI if needed
-
- Not emulated here: Parity check NMI
- */
-void cs4031_device::nmi()
-{
- if (m_nmi_mask & BIT(m_portb, 6))
- {
- m_write_nmi(1);
- m_write_nmi(0);
- }
-}
-
-READ8_MEMBER( cs4031_device::intc1_slave_ack_r )
-{
- if (offset == 2) // IRQ 2
- return m_intc2->acknowledge();
-
- return 0x00;
-}
-
-WRITE_LINE_MEMBER( cs4031_device::rtc_irq_w )
-{
- m_intc2->ir0_w(state ? 0 : 1); // inverted?
-}
-
-WRITE_LINE_MEMBER( cs4031_device::iochck_w )
-{
- if (LOG_IO)
- logerror("cs4031_device::iochck_w: %u\n", state);
-
- if (BIT(m_portb, 3) == 0)
- {
- if (m_iochck && state == 0)
- {
- // set channel check latch
- m_portb |= 1 << 6;
- nmi();
- }
-
- m_iochck = state;
- }
-}
-
-
-//**************************************************************************
-// TIMER
-//**************************************************************************
-
-WRITE_LINE_MEMBER( cs4031_device::ctc_out1_w )
-{
- m_refresh_toggle ^= state;
- m_portb = (m_portb & 0xef) | (m_refresh_toggle << 4);
-}
-
-WRITE_LINE_MEMBER( cs4031_device::ctc_out2_w )
-{
- m_write_spkr(!(state & BIT(m_portb, 1)));
- m_portb = (m_portb & 0xdf) | (state << 5);
-}
-
-
-//**************************************************************************
-// CHIPSET CONFIGURATION
-//**************************************************************************
-
-WRITE8_MEMBER( cs4031_device::config_address_w )
-{
- m_address = data;
- m_address_valid = (m_address < 0x20) ? true : false;
-}
-
-READ8_MEMBER( cs4031_device::config_data_r )
-{
- UINT8 result = 0xff;
-
- if (m_address_valid)
- {
- if (LOG_REGISTER)
- logerror("cs4031_device: read %s = %02x\n", m_register_names[m_address], m_registers[m_address]);
-
- result = m_registers[m_address];
- }
-
- // after a read the selected address needs to be reset
- m_address_valid = false;
-
- return result;
-}
-
-WRITE8_MEMBER( cs4031_device::config_data_w )
-{
- if (m_address_valid)
- {
- if (LOG_REGISTER)
- logerror("cs4031_device: write %s = %02x\n", m_register_names[m_address], data);
-
- // update register with new data
- m_registers[m_address] = data;
-
- // execute command
- switch (m_address)
- {
- case DMA_WAIT_STATE:
- update_dma_clock();
- break;
-
- case 0x05: break;
- case 0x06: break;
- case 0x07: break;
- case 0x08: break;
- case 0x09: break;
-
- case DMA_CLOCK:
- update_dma_clock();
- break;
-
- case 0x10: break;
- case 0x11: break;
- case 0x12: break;
- case 0x13: break;
- case 0x14: break;
- case 0x15: break;
- case 0x16: break;
- case 0x17: break;
- case 0x18: break;
-
- case SHADOW_READ:
- update_read_regions();
- break;
-
- case SHADOW_WRITE:
- update_write_regions();
- break;
-
- case ROMCS:
- update_read_regions();
- update_write_regions();
- break;
-
- case SOFT_RESET_AND_GATEA20:
- a20m();
- break;
- }
- }
-
- // after a write the selected address needs to be reset
- m_address_valid = false;
-}
-
-
-//**************************************************************************
-// MEMORY MAPPER
-//**************************************************************************
-
-void cs4031_device::update_read_region(int index, const char *region, offs_t start, offs_t end)
-{
- if (!BIT(m_registers[SHADOW_READ], index) && BIT(m_registers[ROMCS], index))
- {
- if (LOG_MEMORY)
- logerror("ROM read from %x to %x\n", start, end);
-
- m_space->install_read_bank(start, end, region);
- machine().root_device().membank(region)->set_base(m_bios + start);
- }
- else if (!BIT(m_registers[SHADOW_READ], index) && !BIT(m_registers[ROMCS], index))
- {
- if (LOG_MEMORY)
- logerror("ISA read from %x to %x\n", start, end);
-
- m_space->install_read_bank(start, end, region);
- machine().root_device().membank(region)->set_base(m_isa + start - 0xc0000);
- }
- else if (BIT(m_registers[SHADOW_READ], index))
- {
- if (LOG_MEMORY)
- logerror("RAM read from %x to %x\n", start, end);
-
- m_space->install_read_bank(start, end, region);
- machine().root_device().membank(region)->set_base(m_ram + start);
- }
- else
- {
- if (LOG_MEMORY)
- logerror("NOP read from %x to %x\n", start, end);
-
- m_space->nop_read(start, end);
- }
-}
-
-void cs4031_device::update_write_region(int index, const char *region, offs_t start, offs_t end)
-{
- if (!BIT(m_registers[SHADOW_WRITE], index) && BIT(m_registers[ROMCS], index) && BIT(m_registers[ROMCS], 7))
- {
- if (LOG_MEMORY)
- logerror("ROM write from %x to %x\n", start, end);
-
- m_space->install_write_bank(start, end, region);
- machine().root_device().membank(region)->set_base(m_bios + start);
- }
- else if (!BIT(m_registers[SHADOW_WRITE], index) && !BIT(m_registers[ROMCS], index))
- {
- if (LOG_MEMORY)
- logerror("ISA write from %x to %x\n", start, end);
-
- m_space->install_write_bank(start, end, region);
- machine().root_device().membank(region)->set_base(m_isa + start - 0xc0000);
- }
- else if (BIT(m_registers[SHADOW_WRITE], index))
- {
- if (LOG_MEMORY)
- logerror("RAM write from %x to %x\n", start, end);
-
- m_space->install_write_bank(start, end, region);
- machine().root_device().membank(region)->set_base(m_ram + start);
- }
- else
- {
- if (LOG_MEMORY)
- logerror("NOP write from %x to %x\n", start, end);
-
- m_space->nop_write(start, end);
- }
-}
-
-void cs4031_device::update_read_regions()
-{
- update_read_region(0, "read_c0000", 0xc0000, 0xc3fff);
- update_read_region(1, "read_c4000", 0xc4000, 0xc7fff);
- update_read_region(2, "read_c8000", 0xc8000, 0xcbfff);
- update_read_region(3, "read_cc000", 0xcc000, 0xcffff);
- update_read_region(4, "read_d0000", 0xd0000, 0xdffff);
- update_read_region(5, "read_e0000", 0xe0000, 0xeffff);
- update_read_region(6, "read_f0000", 0xf0000, 0xfffff);
-}
-
-void cs4031_device::update_write_regions()
-{
- update_write_region(0, "write_c0000", 0xc0000, 0xc3fff);
- update_write_region(1, "write_c4000", 0xc4000, 0xc7fff);
- update_write_region(2, "write_c8000", 0xc8000, 0xcbfff);
- update_write_region(3, "write_cc000", 0xcc000, 0xcffff);
- update_write_region(4, "write_d0000", 0xd0000, 0xdffff);
- update_write_region(5, "write_e0000", 0xe0000, 0xeffff);
- update_write_region(6, "write_f0000", 0xf0000, 0xfffff);
-}
-
-
-//**************************************************************************
-// KEYBOARD / 8042
-//**************************************************************************
-
-void cs4031_device::a20m()
-{
- // external signal is ignored when emulation is on
- if (BIT(m_registers[SOFT_RESET_AND_GATEA20], 5))
- m_write_a20m(m_fast_gatea20 | m_emu_gatea20);
- else
- m_write_a20m(m_fast_gatea20 | m_ext_gatea20);
-}
-
-void cs4031_device::emulated_kbreset(int state)
-{
- if (BIT(m_registers[SOFT_RESET_AND_GATEA20], 4))
- {
- // kbreset (input) is active low
- // cpureset (output) is active high
- m_write_cpureset(!state);
- }
-}
-
-void cs4031_device::emulated_gatea20(int state)
-{
- if (BIT(m_registers[SOFT_RESET_AND_GATEA20], 5))
- {
- m_emu_gatea20 = state;
- a20m();
- }
-}
-
-void cs4031_device::fast_gatea20(int state)
-{
- m_fast_gatea20 = state;
- a20m();
-}
-
-void cs4031_device::keyboard_gatea20(int state)
-{
- m_ext_gatea20 = state;
- a20m();
-}
-
-READ8_MEMBER( cs4031_device::keyb_status_r )
-{
- if (LOG_KEYBOARD)
- logerror("cs4031_device::keyb_status_r\n");
-
- return m_keybc->status_r(space, 0);
-}
-
-WRITE8_MEMBER( cs4031_device::keyb_command_blocked_w )
-{
- // command is optionally blocked
- if (!BIT(m_registers[SOFT_RESET_AND_GATEA20], 7))
- m_keybc->command_w(space, 0, data);
-}
-
-WRITE8_MEMBER( cs4031_device::keyb_command_w )
-{
- if (LOG_KEYBOARD)
- logerror("cs4031_device::keyb_command_w: %02x\n", data);
-
- m_keybc_d1_written = false;
-
- switch (data)
- {
- // self-test
- case 0xaa:
- emulated_kbreset(1);
- emulated_gatea20(1);
-
- // self-test is never blocked
- m_keybc->command_w(space, 0, data);
- break;
-
- case 0xd1:
- m_keybc_d1_written = true;
- keyb_command_blocked_w(space, 0, data);
- break;
-
- case 0xf0:
- case 0xf1:
- case 0xf2:
- case 0xf4:
- case 0xf5:
- case 0xf6:
- case 0xf8:
- case 0xf9:
- case 0xfa:
- case 0xfc:
- case 0xfd:
- case 0xfe:
- // toggle keyboard reset?
- if (!BIT(data, 0))
- {
- emulated_kbreset(0);
- emulated_kbreset(1);
- }
-
- // toggle gatea20?
- if (!BIT(data, 1))
- {
- emulated_gatea20(0);
- emulated_gatea20(1);
- }
-
- keyb_command_blocked_w(space, 0, data);
-
- break;
-
- case 0xff:
- // last data write was blocked?
- if (m_keybc_data_blocked)
- {
- m_keybc_data_blocked = false;
- keyb_command_blocked_w(space, 0, data);
- }
- else
- m_keybc->command_w(space, 0, data);
-
- break;
-
- // everything else goes directly to the keyboard controller
- default:
- m_keybc->command_w(space, 0, data);
- break;
- }
-}
-
-READ8_MEMBER( cs4031_device::keyb_data_r )
-{
- if (LOG_KEYBOARD)
- logerror("cs4031_device::keyb_data_r\n");
-
- return m_keybc->data_r(space, 0);
-}
-
-WRITE8_MEMBER( cs4031_device::keyb_data_w )
-{
- if (LOG_KEYBOARD)
- logerror("cs4031_device::keyb_data_w: %02x\n", data);
-
- // data is blocked only for d1 command
- if (BIT(m_registers[SOFT_RESET_AND_GATEA20], 7) && m_keybc_d1_written)
- {
- m_keybc_data_blocked = true;
- emulated_kbreset(BIT(data, 0));
- emulated_gatea20(BIT(data, 1));
- }
- else
- {
- m_keybc_data_blocked = false;
- m_keybc->data_w(space, 0, data);
- }
-}
-
-WRITE_LINE_MEMBER( cs4031_device::gatea20_w )
-{
- if (LOG_KEYBOARD)
- logerror("cs4031_device::gatea20_w: %u\n", state);
-
- keyboard_gatea20(state);
-}
-
-WRITE_LINE_MEMBER( cs4031_device::kbrst_w )
-{
- if (LOG_KEYBOARD)
- logerror("cs4031_device::kbrst_w: %u\n", state);
-
- // convert to active low signal (gets inverted in at_keybc.c)
- state = (state == ASSERT_LINE ? 0 : 1);
-
- // external kbreset is ignored when emulation enabled
- if (!BIT(m_registers[SOFT_RESET_AND_GATEA20], 4))
- {
- // detect transition
- if (m_kbrst == 1 && state == 0)
- {
- m_write_cpureset(1);
- m_write_cpureset(0);
- }
- }
-
- m_kbrst = state;
-}
-
-/*
- Fast CPU reset and Gate A20
-
- 0 - Fast CPU reset
- 1 - Fast Gate A20
-
- */
-WRITE8_MEMBER( cs4031_device::sysctrl_w )
-{
- if (LOG_IO)
- logerror("cs4031_device::sysctrl_w: %u\n", data);
-
- fast_gatea20(BIT(data, 1));
-
- if (m_cpureset == 0 && BIT(data, 0))
- {
- // pulse reset line
- m_write_cpureset(1);
- m_write_cpureset(0);
- }
-
- m_cpureset = BIT(data, 0);
-}
-
-READ8_MEMBER( cs4031_device::sysctrl_r )
-{
- UINT8 result = 0; // reserved bits read as 0?
-
- result |= m_cpureset << 0;
- result |= m_fast_gatea20 << 1;
-
- if (LOG_IO)
- logerror("cs4031_device::sysctrl_r: %u\n", result);
-
- return result;
-}
-
-
-//**************************************************************************
-// MISCELLANEOUS
-//**************************************************************************
-
-/*
- "Port B" - AT-compatible port with miscellaneous information
-
- 0 - Timer 2 gate (rw)
- 1 - Speaker data (rw)
- 2 - Enable parity check (rw) [not emulated]
- 3 - Enable IOCHECK (rw)
- 4 - Refresh detect (r)
- 5 - Timer 2 output (r)
- 6 - Channel check latch (r)
- 7 - Parity check latch (r) [not emulated]
-*/
-
-READ8_MEMBER( cs4031_device::portb_r )
-{
- if (0)
- logerror("cs4031_device::portb_r: %02x\n", m_portb);
-
- return m_portb;
-}
-
-WRITE8_MEMBER( cs4031_device::portb_w )
-{
- if (0)
- logerror("cs4031_device::portb_w: %02x\n", data);
-
- m_portb = (m_portb & 0xf0) | (data & 0x0f);
-
- // bit 5 forced to 1 if timer disabled
- if (!BIT(m_portb, 0))
- m_portb |= 1 << 5;
-
- m_ctc->write_gate2(BIT(m_portb, 0));
-
- m_write_spkr(!BIT(m_portb, 1));
-
- // clear channel check latch?
- if (BIT(m_portb, 3))
- m_portb &= 0xbf;
-}
-
-/*
- NMI mask and RTC address
-
- 7 - NMI mask
- 6:0 - RTC address
- */
-WRITE8_MEMBER( cs4031_device::rtc_w )
-{
- if (0)
- logerror("cs4031_device::rtc_w: %02x\n", data);
-
- if (offset == 0)
- {
- m_nmi_mask = !BIT(data, 7);
- data &= 0x7f;
- }
-
- m_rtc->write(space, offset, data);
-}
diff --git a/src/emu/machine/cs4031.h b/src/emu/machine/cs4031.h
deleted file mode 100644
index e27886f7b41..00000000000
--- a/src/emu/machine/cs4031.h
+++ /dev/null
@@ -1,290 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- Chips & Technologies CS4031 chipset
-
- Chipset for 486 based PC/AT compatible systems. Consists of two
- individual chips:
-
- * F84031
- - DRAM controller
- - ISA-bus controller
- - VESA VL-BUS controller
-
- * F84035 (82C206 IPC core)
- - 2x 8257 DMA controller
- - 2x 8259 interrupt controller
- - 8254 timer
- - MC14818 RTC
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __CS4031_H__
-#define __CS4031_H__
-
-#include "emu.h"
-#include "machine/am9517a.h"
-#include "machine/pic8259.h"
-#include "machine/pit8253.h"
-#include "machine/ds128x.h"
-#include "machine/at_keybc.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_CS4031_ADD(_tag, _clock, _cputag, _isatag, _biostag, _keybctag) \
- MCFG_DEVICE_ADD(_tag, CS4031, _clock) \
- cs4031_device::static_set_cputag(*device, _cputag); \
- cs4031_device::static_set_isatag(*device, _isatag); \
- cs4031_device::static_set_biostag(*device, _biostag); \
- cs4031_device::static_set_keybctag(*device, _keybctag);
-
-#define MCFG_CS4031_IOR(_ior) \
- downcast<cs4031_device *>(device)->set_ior_callback(DEVCB_##_ior);
-
-#define MCFG_CS4031_IOW(_iow) \
- downcast<cs4031_device *>(device)->set_iow_callback(DEVCB_##_iow);
-
-#define MCFG_CS4031_TC(_tc) \
- downcast<cs4031_device *>(device)->set_tc_callback(DEVCB_##_tc);
-
-#define MCFG_CS4031_HOLD(_hold) \
- downcast<cs4031_device *>(device)->set_hold_callback(DEVCB_##_hold);
-
-#define MCFG_CS4031_NMI(_nmi) \
- downcast<cs4031_device *>(device)->set_nmi_callback(DEVCB_##_nmi);
-
-#define MCFG_CS4031_INTR(_intr) \
- downcast<cs4031_device *>(device)->set_intr_callback(DEVCB_##_intr);
-
-#define MCFG_CS4031_CPURESET(_cpureset) \
- downcast<cs4031_device *>(device)->set_cpureset_callback(DEVCB_##_cpureset);
-
-#define MCFG_CS4031_A20M(_a20m) \
- downcast<cs4031_device *>(device)->set_a20m_callback(DEVCB_##_a20m);
-
-#define MCFG_CS4031_SPKR(_spkr) \
- downcast<cs4031_device *>(device)->set_spkr_callback(DEVCB_##_spkr);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> cs4031_device
-
-class cs4031_device : public device_t
-{
-public:
- // construction/destruction
- cs4031_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // optional information overrides
- virtual machine_config_constructor device_mconfig_additions() const;
-
- // callbacks
- template<class _ior> void set_ior_callback(_ior ior) { m_read_ior.set_callback(ior); }
- template<class _iow> void set_iow_callback(_iow iow) { m_write_iow.set_callback(iow); }
- template<class _tc> void set_tc_callback(_tc tc) { m_write_tc.set_callback(tc); }
- template<class _hold> void set_hold_callback(_hold hold) { m_write_hold.set_callback(hold); }
- template<class _cpureset> void set_cpureset_callback(_cpureset cpureset) { m_write_cpureset.set_callback(cpureset); }
- template<class _nmi> void set_nmi_callback(_nmi nmi) { m_write_nmi.set_callback(nmi); }
- template<class _intr> void set_intr_callback(_intr intr) { m_write_intr.set_callback(intr); }
- template<class _a20m> void set_a20m_callback(_a20m a20m) { m_write_a20m.set_callback(a20m); }
- template<class _spkr> void set_spkr_callback(_spkr spkr) { m_write_spkr.set_callback(spkr); }
-
- // not really public
- DECLARE_READ8_MEMBER( dma_read_byte );
- DECLARE_WRITE8_MEMBER( dma_write_byte );
- DECLARE_READ8_MEMBER( dma_read_word );
- DECLARE_WRITE8_MEMBER( dma_write_word );
- DECLARE_WRITE_LINE_MEMBER( dma1_eop_w );
- DECLARE_READ8_MEMBER( dma1_ior0_r ) { return m_read_ior(0); }
- DECLARE_READ8_MEMBER( dma1_ior1_r ) { return m_read_ior(1); }
- DECLARE_READ8_MEMBER( dma1_ior2_r ) { return m_read_ior(2); }
- DECLARE_READ8_MEMBER( dma1_ior3_r ) { return m_read_ior(3); }
- DECLARE_READ8_MEMBER( dma2_ior1_r ) { UINT16 result = m_read_ior(5); m_dma_high_byte = result >> 8; return result; }
- DECLARE_READ8_MEMBER( dma2_ior2_r ) { UINT16 result = m_read_ior(6); m_dma_high_byte = result >> 8; return result; }
- DECLARE_READ8_MEMBER( dma2_ior3_r ) { UINT16 result = m_read_ior(7); m_dma_high_byte = result >> 8; return result; }
- DECLARE_WRITE8_MEMBER( dma1_iow0_w ) { m_write_iow(0, data, 0xffff); }
- DECLARE_WRITE8_MEMBER( dma1_iow1_w ) { m_write_iow(1, data, 0xffff); }
- DECLARE_WRITE8_MEMBER( dma1_iow2_w ) { m_write_iow(2, data, 0xffff); }
- DECLARE_WRITE8_MEMBER( dma1_iow3_w ) { m_write_iow(3, data, 0xffff); }
- DECLARE_WRITE8_MEMBER( dma2_iow1_w ) { m_write_iow(5, (m_dma_high_byte << 8) | data, 0xffff); }
- DECLARE_WRITE8_MEMBER( dma2_iow2_w ) { m_write_iow(6, (m_dma_high_byte << 8) | data, 0xffff); }
- DECLARE_WRITE8_MEMBER( dma2_iow3_w ) { m_write_iow(7, (m_dma_high_byte << 8) | data, 0xffff); }
- DECLARE_WRITE_LINE_MEMBER( dma1_dack0_w ) { set_dma_channel(0, state); }
- DECLARE_WRITE_LINE_MEMBER( dma1_dack1_w ) { set_dma_channel(1, state); }
- DECLARE_WRITE_LINE_MEMBER( dma1_dack2_w ) { set_dma_channel(2, state); }
- DECLARE_WRITE_LINE_MEMBER( dma1_dack3_w ) { set_dma_channel(3, state); }
- DECLARE_WRITE_LINE_MEMBER( dma2_dack0_w );
- DECLARE_WRITE_LINE_MEMBER( dma2_dack1_w ) { set_dma_channel(5, state); }
- DECLARE_WRITE_LINE_MEMBER( dma2_dack2_w ) { set_dma_channel(6, state); }
- DECLARE_WRITE_LINE_MEMBER( dma2_dack3_w ) { set_dma_channel(7, state); }
- DECLARE_WRITE_LINE_MEMBER( dma2_hreq_w ) { m_write_hold(state); }
- DECLARE_WRITE_LINE_MEMBER( intc1_int_w ) { m_write_intr(state); }
- DECLARE_READ8_MEMBER( intc1_slave_ack_r );
- DECLARE_WRITE_LINE_MEMBER( ctc_out1_w );
- DECLARE_WRITE_LINE_MEMBER( ctc_out2_w );
- DECLARE_WRITE_LINE_MEMBER( rtc_irq_w );
-
- // internal io
- DECLARE_WRITE8_MEMBER( config_address_w );
- DECLARE_READ8_MEMBER( config_data_r );
- DECLARE_WRITE8_MEMBER( config_data_w );
- DECLARE_READ8_MEMBER( portb_r );
- DECLARE_WRITE8_MEMBER( portb_w );
- DECLARE_WRITE8_MEMBER( rtc_w );
- DECLARE_WRITE8_MEMBER( sysctrl_w );
- DECLARE_READ8_MEMBER( sysctrl_r );
- DECLARE_READ8_MEMBER( dma_page_r ) { return m_dma_page[offset]; }
- DECLARE_WRITE8_MEMBER( dma_page_w ) { m_dma_page[offset] = data; }
- DECLARE_READ8_MEMBER( dma2_r ) { return m_dma2->read(space, offset / 2); }
- DECLARE_WRITE8_MEMBER( dma2_w ) { m_dma2->write(space, offset / 2, data); }
- DECLARE_READ8_MEMBER( keyb_data_r );
- DECLARE_WRITE8_MEMBER( keyb_data_w );
- DECLARE_READ8_MEMBER( keyb_status_r );
- DECLARE_WRITE8_MEMBER( keyb_command_w );
- DECLARE_WRITE8_MEMBER( keyb_command_blocked_w );
-
- // input lines
- DECLARE_WRITE_LINE_MEMBER( irq01_w ) { m_intc1->ir1_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq03_w ) { m_intc1->ir3_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq04_w ) { m_intc1->ir4_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq05_w ) { m_intc1->ir5_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq06_w ) { m_intc1->ir6_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq07_w ) { m_intc1->ir7_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq09_w ) { m_intc2->ir1_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq10_w ) { m_intc2->ir2_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq11_w ) { m_intc2->ir3_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq12_w ) { m_intc2->ir4_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq13_w ) { m_intc2->ir5_w(state); } // also FERR#
- DECLARE_WRITE_LINE_MEMBER( irq14_w ) { m_intc2->ir6_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq15_w ) { m_intc2->ir7_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq0_w ) { m_dma1->dreq0_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq1_w ) { m_dma1->dreq1_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq2_w ) { m_dma1->dreq2_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq3_w ) { m_dma1->dreq3_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq5_w ) { m_dma2->dreq1_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq6_w ) { m_dma2->dreq2_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq7_w ) { m_dma2->dreq3_w(state); }
- DECLARE_WRITE_LINE_MEMBER( hlda_w ) { m_dma2->hack_w(state); }
- DECLARE_WRITE_LINE_MEMBER( iochck_w );
- DECLARE_WRITE_LINE_MEMBER( gatea20_w );
- DECLARE_WRITE_LINE_MEMBER( kbrst_w );
-
- IRQ_CALLBACK_MEMBER(int_ack_r) { return m_intc1->acknowledge(); }
-
- // inline configuration
- static void static_set_cputag(device_t &device, const char *tag);
- static void static_set_isatag(device_t &device, const char *tag);
- static void static_set_biostag(device_t &device, const char *tag);
- static void static_set_keybctag(device_t &device, const char *tag);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_reset_after_children();
-
-private:
- devcb_read16 m_read_ior;
- devcb_write16 m_write_iow;
- devcb_write8 m_write_tc;
- devcb_write_line m_write_hold;
- devcb_write_line m_write_nmi;
- devcb_write_line m_write_intr;
- devcb_write_line m_write_cpureset;
- devcb_write_line m_write_a20m;
- devcb_write_line m_write_spkr;
-
- offs_t page_offset();
- void set_dma_channel(int channel, bool state);
- void update_dma_clock();
-
- void nmi();
- void a20m();
-
- void emulated_kbreset(int state);
- void emulated_gatea20(int state);
- void fast_gatea20(int state);
- void keyboard_gatea20(int state);
-
- void update_read_region(int index, const char *region, offs_t start, offs_t end);
- void update_write_region(int index, const char *region, offs_t start, offs_t end);
- void update_read_regions();
- void update_write_regions();
-
- // internal state
- const char *m_cputag;
- const char *m_isatag;
- const char *m_biostag;
- const char *m_keybctag;
-
- address_space *m_space;
- address_space *m_space_io;
- UINT8 *m_isa;
- UINT8 *m_bios;
- UINT8 *m_ram;
-
- // ipc core devices
- required_device<am9517a_device> m_dma1;
- required_device<am9517a_device> m_dma2;
- required_device<pic8259_device> m_intc1;
- required_device<pic8259_device> m_intc2;
- required_device<pit8254_device> m_ctc;
- required_device<ds12885_device> m_rtc;
-
- int m_dma_eop;
- UINT8 m_dma_page[0x10];
- UINT8 m_dma_high_byte;
- int m_dma_channel;
-
- UINT8 m_portb;
- int m_refresh_toggle;
- int m_iochck;
- int m_nmi_mask;
-
- // keyboard
- at_keyboard_controller_device *m_keybc;
- int m_cpureset;
- int m_kbrst;
- int m_ext_gatea20;
- int m_fast_gatea20;
- int m_emu_gatea20;
- bool m_keybc_d1_written;
- bool m_keybc_data_blocked;
-
- // chipset configuration
- static const char* m_register_names[];
- static const float m_dma_clock_divider[];
-
- enum
- {
- DMA_WAIT_STATE = 0x01,
- PERFORMANCE = 0x08,
- F84035_MISC = 0x09,
- DMA_CLOCK = 0x0a,
- SHADOW_READ = 0x19,
- SHADOW_WRITE = 0x1a,
- ROMCS = 0x1b,
- SOFT_RESET_AND_GATEA20 = 0x1c
- };
-
- UINT8 m_address;
- bool m_address_valid;
-
- UINT8 m_registers[0x20];
-};
-
-
-// device type definition
-extern const device_type CS4031;
-
-
-#endif /* __CS4031_H__ */
diff --git a/src/emu/machine/cs8221.c b/src/emu/machine/cs8221.c
deleted file mode 100644
index 95a890d7bba..00000000000
--- a/src/emu/machine/cs8221.c
+++ /dev/null
@@ -1,167 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Miodrag Milanovic
-/***************************************************************************
-
- Chips & Technologies CS8221 chipset
-
- a.k.a. NEW ENHANCED AT (NEAT)
-
- Consists of four individual chips:
-
- * 82C211 - CPU/Bus controller
- * 82C212 - Page/Interleave and EMS Memory controller
- * 82C215 - Data/Address buffer
- * 82C206 - Integrated Peripherals Controller(IPC)
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/ram.h"
-#include "machine/cs8221.h"
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-#define LOG_REGISTER 1
-#define LOG_MEMORY 1
-
-const device_type CS8221 = &device_creator<cs8221_device>;
-
-
-static const char *const register_names[] =
-{
- /* 00 */ "PROCCLK",
- /* 01 */ "COMMAND DELAY",
- /* 02 */ "WAIT STATES",
- /* 03 */ "RESERVED",
- /* 04 */ "VERSION",
- /* 05 */ "ROM CONFIGURATION",
- /* 06 */ "MEMORY ENABLE-1",
- /* 07 */ "MEMORY ENABLE-2",
- /* 08 */ "MEMORY ENABLE-3",
- /* 09 */ "MEMORY ENABLE-4",
- /* 0a */ "BANK 0/1 ENABLE",
- /* 0b */ "DRAM CONFIGURATION",
- /* 0c */ "BANK 2/3 ENABLE",
- /* 0d */ "EMS BASE ADDRESS",
- /* 0e */ "EMS ADDRESS EXTENSION",
- /* 0f */ "MISCELLANEOUS"
-};
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// cs8221_device - constructor
-//-------------------------------------------------
-
-cs8221_device::cs8221_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, CS8221, "CS8221", tag, owner, clock, "cs8221", __FILE__),
- m_address(0),
- m_address_valid(false)
-{
-}
-
-void cs8221_device::static_set_cputag(device_t &device, const char *tag)
-{
- cs8221_device &cs8221 = downcast<cs8221_device &>(device);
- cs8221.m_cputag = tag;
-}
-
-void cs8221_device::static_set_isatag(device_t &device, const char *tag)
-{
- cs8221_device &cs8221 = downcast<cs8221_device &>(device);
- cs8221.m_isatag = tag;
-}
-
-void cs8221_device::static_set_biostag(device_t &device, const char *tag)
-{
- cs8221_device &cs8221 = downcast<cs8221_device &>(device);
- cs8221.m_biostag = tag;
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void cs8221_device::device_start()
-{
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void cs8221_device::device_reset()
-{
- // setup default values
- memset(&m_registers, 0x00, sizeof(m_registers));
-}
-
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-WRITE8_MEMBER( cs8221_device::address_w )
-{
- m_address = data;
- m_address_valid = ((m_address & 0x60)== 0x60) ? true : false;
-}
-
-READ8_MEMBER( cs8221_device::data_r )
-{
- UINT8 result = 0xff;
-
- if (m_address_valid)
- {
- if (LOG_REGISTER)
- logerror("cs8221_device: read %s = %02x\n", register_names[m_address & 0x0f], m_registers[m_address & 0x0f]);
-
- result = m_registers[m_address & 0x0f];
- }
-
- // after a read the selected address needs to be reset
- m_address_valid = false;
-
- return result;
-}
-
-WRITE8_MEMBER( cs8221_device::data_w )
-{
- if (m_address_valid)
- {
- if (LOG_REGISTER)
- logerror("cs8221_device: write %s = %02x\n", register_names[m_address & 0x0f], data);
-
- // update register with new data
- m_registers[m_address & 0x0f] = data;
-
- // execute command
- switch (m_address)
- {
- case 0x60: break;
- case 0x61: break;
- case 0x62: break;
- case 0x63: break;
- case 0x64: break;
- case 0x65: break;
- case 0x66: break;
- case 0x67: break;
- case 0x68: break;
- case 0x69: break;
- case 0x6a: break;
- case 0x6b: break;
- case 0x6c: break;
- case 0x6d: break;
- case 0x6e: break;
- case 0x6f: break;
- }
- }
-
- // after a write the selected address needs to be reset
- m_address_valid = false;
-}
diff --git a/src/emu/machine/cs8221.h b/src/emu/machine/cs8221.h
deleted file mode 100644
index b2d04dfe89e..00000000000
--- a/src/emu/machine/cs8221.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Miodrag Milanovic
-/***************************************************************************
-
- Chips & Technologies CS8221 chipset
-
- a.k.a. NEW ENHANCED AT (NEAT)
-
- Consists of four individual chips:
-
- * 82C211 - CPU/Bus controller
- * 82C212 - Page/Interleave and EMS Memory controller
- * 82C215 - Data/Address buffer
- * 82C206 - Integrated Peripherals Controller(IPC)
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __CS8221_H__
-#define __CS8221_H__
-
-#include "emu.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_CS8221_ADD(_tag, _cputag, _isatag, _biostag) \
- MCFG_DEVICE_ADD(_tag, CS8221, 0) \
- cs8221_device::static_set_cputag(*device, _cputag); \
- cs8221_device::static_set_isatag(*device, _isatag); \
- cs8221_device::static_set_biostag(*device, _biostag);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> cs8221_device
-
-class cs8221_device : public device_t
-{
-public:
- // construction/destruction
- cs8221_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_WRITE8_MEMBER( address_w );
- DECLARE_READ8_MEMBER( data_r );
- DECLARE_WRITE8_MEMBER( data_w );
-
- // inline configuration
- static void static_set_cputag(device_t &device, const char *tag);
- static void static_set_isatag(device_t &device, const char *tag);
- static void static_set_biostag(device_t &device, const char *tag);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
-
- // internal state
- //address_space *m_space;
- //UINT8 *m_isa;
- //UINT8 *m_bios;
- //UINT8 *m_ram;
-
- // address selection
- UINT8 m_address;
- bool m_address_valid;
-
- const char *m_cputag;
- const char *m_isatag;
- const char *m_biostag;
-
-
- UINT8 m_registers[0x10];
-};
-
-
-// device type definition
-extern const device_type CS8221;
-
-
-#endif /* __CS8221_H__ */
diff --git a/src/emu/machine/diablo_hd.c b/src/emu/machine/diablo_hd.c
deleted file mode 100644
index 9ee566350ff..00000000000
--- a/src/emu/machine/diablo_hd.c
+++ /dev/null
@@ -1,1464 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Juergen Buchmueller
-/**********************************************************
- * DIABLO31 and DIABLO44 hard drive support
- **********************************************************/
-#include "diablo_hd.h"
-
-/**
- *
- * Just for completeness' sake:
- * The mapping of disk controller connector P2 pins to the
- * Winchester disk drive signals (see drive.h)
- * <PRE>
- * Alto Controller Winchester
- * P2 signal disk bus
- * -----------------------------------------------
- * 1 GND D_GROUND
- * 2 RDCLK' A_READ_CLOCK
- * 3 WRDATA' B_WRITE_DATA_AND_CLOCK
- * 4 SRWRDY' F_S_R_W
- * 5 DISK L_SELECT_LINE_UNIT_1
- * 6 CYL(7)' N_CYL_7
- * 7 DISK' R_SELECT_LINE_UNIT_2
- * 8 CYL(2)' T_CYL_2
- * 9 ??? V_SELECT_LINE_UNIT_3
- * 10 CYL(4)' X_CYL_4
- * 11 CYL(0)' Z_CYL_0
- * 12 CYL(1)' BB_CYL_1
- * 13 CYL(3)' FF_CYL_3
- * 14 ??? KK_BIT_2
- * 15 CYL(8)' LL_CYL_8
- * 16 ADRACK' NN_ADDX_ACKNOWLEDGE
- * 17 SKINC' TT_SEEK_INCOMPLETE
- * 18 LAI' XX_LOG_ADDX_INTERLOCK
- * 19 CYL(6)' RR_CYL_6
- * 20 RESTOR' VV_RESTORE
- * 21 ??? UU_BIT_16
- * 22 STROBE' SS_STROBE
- * 23 ??? MM_BIT_8
- * 24 ??? KK_BIT_4
- * 25 ??? HH_WRITE_CHK
- * 26 WRTGATE' EE_WRITE_GATE
- * 27 ??? CC_BIT_SECTOR_ADDX
- * 28 HEAD' AA_HEAD_SELECT
- * 29 ??? Y_INDEX_MARK
- * 30 SECT(4)' W_SECTOR_MARK
- * 31 READY' U_FILE_READY
- * 32 ??? S_PSEUDO_SECTOR_MARK
- * 33 ??? P_WRITE_PROTECT_IND
- * 34 ??? H_WRITE_PROTECT_INPUT_ATTENTION
- * 35 ERGATE' K_ERASE_GATE
- * 36 ??? M_HIGH_DENSITY
- * 37 CYL(5)' J_CYL_5
- * 38 RDDATA' C_READ_DATA
- * 39 RDGATE' E_READ_GATE
- * 40 GND ??
- * </PRE>
- */
-
-diablo_hd_device::diablo_hd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, DIABLO_HD, "Diablo Disk", tag, owner, clock, "diablo_hd", __FILE__),
-#if DIABLO_DEBUG
- m_log_level(8),
-#endif
- m_diablo31(true),
- m_unit(0),
- m_packs(1),
- m_rotation_time(),
- m_sector_time(),
- m_sector_mark_0_time(),
- m_sector_mark_1_time(),
- m_bit_time(),
- m_s_r_w_0(1),
- m_ready_0(1),
- m_sector_mark_0(1),
- m_addx_acknowledge_0(1),
- m_log_addx_interlock_0(1),
- m_seek_incomplete_0(1),
- m_egate_0(1),
- m_wrgate_0(1),
- m_rdgate_0(1),
- m_cylinders(DIABLO_CYLINDERS),
- m_pages(DIABLO_PAGES),
- m_seekto(0),
- m_restore(0),
- m_cylinder(-1),
- m_head(-1),
- m_sector(-1),
- m_page(-1),
- m_cache(0),
- m_bits(0),
- m_rdfirst(-1),
- m_rdlast(-1),
- m_wrfirst(-1),
- m_wrlast(-1),
- m_sector_callback_cookie(0),
- m_sector_callback(0),
- m_timer(0),
- m_image(0),
- m_handle(0),
- m_disk(0)
-{
- memset(m_description, 0x00, sizeof(m_description));
-}
-
-/**
- * @brief diablo_hd_device destructor
- * Free all m_cache and m_bits pages and the arrays
- */
-diablo_hd_device::~diablo_hd_device()
-{
-}
-
-#if DIABLO_DEBUG
-void diablo_hd_device::logprintf(int level, const char* format, ...)
-{
- if (level > m_log_level)
- return;
- va_list ap;
- va_start(ap, format);
- vlogerror(format, ap);
- va_end(ap);
-}
-#endif
-
-void diablo_hd_device::set_sector_callback(void *cookie, void (*callback)(void *, int))
-{
- if (m_sector_callback_cookie == cookie && m_sector_callback == callback)
- return;
- LOG_DRIVE((0,"[DHD%u] cookie=%p callback=%p\n", m_unit, cookie, callback));
- m_sector_callback_cookie = cookie;
- m_sector_callback = callback;
-}
-
-#define DIABLO31_ROTATION_TIME attotime::from_usec(39900) //!< DIABLO 31 rotation time is approx. 40ms
-#define DIABLO31_SECTOR_TIME attotime::from_usec(39900/12) //!< DIABLO 31 sector time
-/**
- * @brief DIABLO 31 bit clock is 3330kHz ~= 300ns per bit
- * ~= 133333 bits/track (?)
- * ~= 11111 bits/sector
- * ~= 347 words/sector
- */
-#define DIABLO31_BIT_TIME(bits) attotime::from_nsec(300*(bits))
-#define DIABLO31_SECTOR_BITS 10432
-#define DIABLO31_SECTOR_WORDS 347 //!< DIABLO 31 possible sector words
-#define DIABLO31_SECTOR_MARK_PULSE_PRE DIABLO31_BIT_TIME(16) //!< pulse width of sector mark before the next sector begins
-#define DIABLO31_SECTOR_MARK_PULSE_POST DIABLO31_BIT_TIME(16) //!< pulse width of sector mark after the next sector began
-
-#define DIABLO44_ROTATION_TIME attotime::from_usec(25000) //!< DIABLO 44 rotation time is approx. 25ms
-#define DIABLO44_SECTOR_TIME attotime::from_usec(25000/12) //!< DIABLO 44 sector time
-/**
- * @brief DIABLO 44 bit clock is 5000kHz ~= 200ns per bit
- * ~= 125184 bits/track (?)
- * ~= 10432 bits/sector
- * ~= 325 words/sector
- */
-#define DIABLO44_BIT_TIME(bits) attotime::from_nsec(200*(bits))
-#define DIABLO44_SECTOR_BITS 10432
-#define DIABLO44_SECTOR_WORDS 325 //!< DIABLO 44 possible sector words
-#define DIABLO44_SECTOR_MARK_PULSE_PRE DIABLO44_BIT_TIME(16) //!< pulse width of sector mark before the next sector begins
-#define DIABLO44_SECTOR_MARK_PULSE_POST DIABLO44_BIT_TIME(16) //!< pulse width of sector mark after the next sector began
-
-#define MFROBL 34 //!< from the microcode: disk header preamble is 34 words
-#define MFRRDL 21 //!< from the microcode: disk header read delay is 21 words
-#define MIRRDL 4 //!< from the microcode: interrecord read delay is 4 words
-#define MIROBL 3 //!< from the microcode: disk interrecord preamble is 3 words
-#define MRPAL 3 //!< from the microcode: disk read postamble length is 3 words
-#define MWPAL 5 //!< from the microcode: disk write postamble length is 5 words
-
-#define GUARD_ZONE_BITS (16*32) //!< end of the guard zone at the beginning of a sector (wild guess!)
-
-/**
- * @brief description of the sector layout (reverse engineered)
- * <PRE>
- *
- * xx.x msec sector mark pulses
- * -+ +-------------------------------------------------------------------------------+ +--
- * | | | |
- * +---+ +---+
- *
- * | |
- *
- * +------+----+------+-----+------+----+-------+-----+------+----+-------+-----+------+
- * | PRE- |SYNC|HEADER|CKSUM| PRE- |SYNC| LABEL |CKSUM| PRE- |SYNC| DATA |CKSUM| POST |
- * |AMBLE1| 1 | | 1 |AMBLE2| 2 | | 2 |AMBLE3| 3 | | 3 |AMBLE |
- * +------+----+------+-----+------+----+-------+-----+------+----+-------+-----+------+
- *
- * | |
- *
- * +-----------------------------------------------------------------------------------+
- * | |
- * ---+ +----
- * FORMAT WRITE GATE FOR INITIALIZING
- * | |
- *
- * | +------------------------------+
- * | |
- * ---|----------------------------------------------------+ +----
- * WRITE GATE FOR DATA XFER (*)
- * | |
- *
- * | +-----------------------+-+------------------------------+
- * | | | may be continuous (?) |
- * ------------------------------+ +-+ +----
- * ??? WRITE GATE FOR LABEL AND DATA XFER (*)
- * | |
- *
- * | +--------------------+ +---------------------+ +----------------------------+
- * | | | | | |
- * -------+ +---+ +---+ +----
- * READ GATE FOR INITIALIZING OR DATA XFER (**)
- *
- *
- * (*) Enable should be delayed 1 byte/word time from last bit of checks sum.
- * (**) Read Gate should be enabled half way through the preamble area. This
- * ensures reading a zero field for data separator synchronization.
- *
- * </PRE>
- */
-
-#define DIABLO_PAGENO_WORDS 1 //!< number of words in a page number (this doesn't really belong here)
-#define DIABLO_HEADER_WORDS 2 //!< number of words in a header (this doesn't really belong here)
-#define DIABLO_LABEL_WORDS 8 //!< number of words in a label (this doesn't really belong here)
-#define DIABLO_DATA_WORDS 256 //!< number of data words (this doesn't really belong here)
-#define DIABLO_CKSUM_WORDS 1 //!< number of words for a checksum (this doesn't really belong here)
-
-/**
- * @brief format of the cooked disk image sectors, i.e. pure data
- *
- * The available images are a multiple of 267 words (534 bytes) per sector,
- * 1 word page number
- * 2 words header
- * 8 words label
- * 256 words data
- */
-typedef struct {
- UINT8 pageno[2*DIABLO_PAGENO_WORDS]; //!< sector page number
- UINT8 header[2*DIABLO_HEADER_WORDS]; //!< sector header words
- UINT8 label[2*DIABLO_LABEL_WORDS]; //!< sector label words
- UINT8 data[2*DIABLO_DATA_WORDS]; //!< sector data words
-} diablo_sector_t;
-
-/**
- * @brief write a bit into an array of UINT32
- * @param bits pointer to array of bits
- * @param dst destination index
- * @param bit bit value
- * @return next destination index
- */
-static inline size_t WRBIT(UINT32* bits, size_t dst, int bit)
-{
- if (bit) {
- bits[(dst)/32] |= 1 << ((dst) % 32);
- } else {
- bits[(dst)/32] &= ~(1 << ((dst) % 32));
- }
- return ++dst;
-}
-
-/**
- * @brief read a bit from an array of UINT32
- * @param bits pointer to array of bits
- * @param src source index
- * @param bit reference to the bit to set
- * @return next source index
- */
-static inline size_t RDBIT(UINT32* bits, size_t src, int& bit)
-{
- bit = (bits[src/32] >> (src % 32)) & 1;
- return ++src;
-}
-
-/**
- * @brief calculate the sector from the logical block address and read it
- *
- * Modifies drive's page by calculating the logical
- * block address from cylinder, head, and sector.
- */
-void diablo_hd_device::read_sector()
-{
- /* If there's no drive, just reset the page number */
- if (!m_image) {
- LOG_DRIVE((0,"[DHD%u] CHS:%03d/%d/%02d => no image\n", m_unit, m_cylinder, m_head, m_sector));
- m_page = -1;
- return;
- }
- if (m_cylinder < 0 || m_cylinder >= m_cylinders) {
- LOG_DRIVE((0,"[DHD%u] CHS:%03d/%d/%02d => invalid cylinder\n", m_unit, m_cylinder, m_head, m_sector));
- m_page = -1;
- return;
- }
- if (m_head < 0 || m_head >= DIABLO_HEADS) {
- LOG_DRIVE((0,"[DHD%u] CHS:%03d/%d/%02d => invalid head\n", m_unit, m_cylinder, m_head, m_sector));
- m_page = -1;
- return;
- }
- if (m_sector < 0 || m_sector >= DIABLO_SPT) {
- LOG_DRIVE((0,"[DHD%u] CHS:%03d/%d/%02d => invalid sector\n", m_unit, m_cylinder, m_head, m_sector));
- m_page = -1;
- return;
- }
- /* calculate the new disk relative sector offset */
- m_page = DIABLO_PAGE(m_cylinder, m_head, m_sector);
-
- // already have the sector image?
- if (m_cache[m_page]) {
- LOG_DRIVE((9,"[DHD%u] CHS:%03d/%d/%02d => page:%d is cached\n", m_unit, m_cylinder, m_head, m_sector, m_page));
- return;
- }
-
- if (m_disk) {
- // allocate a buffer for this page
- m_cache[m_page] = auto_alloc_array(machine(), UINT8, sizeof(diablo_sector_t));
- // and read the page from the hard_disk image
- if (hard_disk_read(m_disk, m_page, m_cache[m_page])) {
- LOG_DRIVE((2,"[DHD%u] CHS:%03d/%d/%02d => page:%d loaded\n", m_unit, m_cylinder, m_head, m_sector, m_page));
- } else {
- LOG_DRIVE((0,"[DHD%u] CHS:%03d/%d/%02d => page:%d read failed\n", m_unit, m_cylinder, m_head, m_sector, m_page));
- auto_free(machine(), m_cache[m_page]);
- m_cache[m_page] = 0;
- }
- } else {
- LOG_DRIVE((2,"[DHD%u] no disk\n", m_unit));
- }
-}
-
-/**
- * @brief compute the checksum of a record
- *
- * @param src pointer to a record (header, label, data)
- * @param size size of the record in bytes
- * @param start start value for the checksum
- * @return returns the checksum of the record
- */
-int diablo_hd_device::cksum(UINT8 *src, size_t size, int start)
-{
- int sum = start;
- /* compute XOR of all words */
- for (size_t offs = 0; offs < size; offs += 2) {
- int word = src[size - 2 - offs] + 256 * src[size - 2 - offs + 1];
- sum ^= word;
- }
- return sum;
-}
-
-/**
- * @brief expand a series of clock bits and 0 data bits
- *
- * @param bits pointer to the sector bits
- * @param dst destination offset into bits (bit number)
- * @param size number of words to write
- * @return offset to next destination bit
- */
-size_t diablo_hd_device::expand_zeroes(UINT32 *bits, size_t dst, size_t size)
-{
- for (size_t offs = 0; offs < 32 * size; offs += 2) {
- dst = WRBIT(bits, dst, 1); // write the clock bit
- dst = WRBIT(bits, dst, 0); // write the 0 data bit
- }
- return dst;
-}
-
-/**
- * @brief expand a series of 0 words and write a final sync bit
- *
- * @param bits pointer to the sector bits
- * @param dst destination offset into bits (bit number)
- * @param size number of words to write
- * @return offset to next destination bit
- */
-size_t diablo_hd_device::expand_sync(UINT32 *bits, size_t dst, size_t size)
-{
- for (size_t offs = 0; offs < 32 * size - 2; offs += 2) {
- dst = WRBIT(bits, dst, 1); // write the clock bit
- dst = WRBIT(bits, dst, 0); // write the 0 data bit
- }
- dst = WRBIT(bits, dst, 1); // write the final clock bit
- dst = WRBIT(bits, dst, 1); // write the 1 data bit
- return dst;
-}
-
-/**
- * @brief expand a record of words into a array of bits at dst
- *
- * @param bits pointer to the sector bits
- * @param dst destination offset into bits (bit number)
- * @param field pointer to the record data (bytes)
- * @param size size of the record in bytes
- * @return offset to next destination bit
- */
-size_t diablo_hd_device::expand_record(UINT32 *bits, size_t dst, UINT8 *field, size_t size)
-{
- for (size_t offs = 0; offs < size; offs += 2) {
- int word = field[size - 2 - offs] + 256 * field[size - 2 - offs + 1];
- for (size_t bit = 0; bit < 16; bit++) {
- dst = WRBIT(bits, dst, 1); // write the clock bit
- dst = WRBIT(bits, dst, (word >> 15) & 1); // write the data bit
- word <<= 1;
- }
- }
- return dst;
-}
-
-/**
- * @brief expand a record's checksum word to 32 bits
- *
- * @param bits pointer to the sector bits
- * @param dst destination offset into bits (bit number)
- * @param field pointer to the record data (bytes)
- * @param size size of the record in bytes
- * @return offset to next destination bit
- */
-size_t diablo_hd_device::expand_cksum(UINT32 *bits, size_t dst, UINT8 *field, size_t size)
-{
- int word = cksum(field, size, 0521);
- for (size_t bit = 0; bit < 32; bit += 2) {
- dst = WRBIT(bits, dst, 1); // write the clock bit
- dst = WRBIT(bits, dst, (word >> 15) & 1); // write the data bit
- word <<= 1;
- }
- return dst;
-}
-
-/**
- * @brief expand a sector into an array of clock and data bits
- *
- * @param page page number (0 to DRIVE_PAGES-1)
- * @return pointer to the newly allocated array of bits
- */
-UINT32* diablo_hd_device::expand_sector()
-{
- size_t dst;
-
- if (!m_bits)
- return NULL;
- /* already expanded this sector? */
- if (m_bits[m_page])
- return m_bits[m_page];
-
- /* allocate a sector buffer */
- if (!m_cache[m_page]) {
- LOG_DRIVE((0,"[DHD%u] no image for page #%d\n", m_unit, m_page));
- return NULL;
- }
- diablo_sector_t *s = reinterpret_cast<diablo_sector_t *>(m_cache[m_page]);
-
- /* allocate a bits image */
- UINT32 *bits = auto_alloc_array_clear(machine(), UINT32, 400);
-
- if (m_diablo31) {
- /* write sync bit after (MFROBL-MRPAL) words - 1 bit */
- dst = expand_sync(bits, 0, (MFROBL - MRPAL));
- dst = expand_record(bits, dst, s->header, sizeof(s->header));
- dst = expand_cksum(bits, dst, s->header, sizeof(s->header));
-
- /* write sync bit after 2 * MWPAL + 1 words - 1 bit */
- dst = expand_sync(bits, dst, 2 * MWPAL);
- dst = expand_record(bits, dst, s->label, sizeof(s->label));
- dst = expand_cksum(bits, dst, s->label, sizeof(s->label));
-
- /* write sync bit after 2 * MWPAL + 1 words - 1 bit */
- dst = expand_sync(bits, dst, 2 * MWPAL);
- dst = expand_record(bits, dst, s->data, sizeof(s->data));
- dst = expand_cksum(bits, dst, s->data, sizeof(s->data));
-
- /* fill MWPAL words of clock and 0 data bits */
- dst = expand_zeroes(bits, dst, MWPAL);
- } else {
- /* write sync bit after (MFROBL - MRPAL) words - 1 bit */
- dst = expand_sync(bits, 0, (MFROBL - MRPAL));
- dst = expand_record(bits, dst, s->header, sizeof(s->header));
- dst = expand_cksum(bits, dst, s->header, sizeof(s->header));
-
- /* write sync bit after 2 * MWPAL words - 1 bit */
- dst = expand_sync(bits, dst, 2 * MWPAL);
- dst = expand_record(bits, dst, s->label, sizeof(s->label));
- dst = expand_cksum(bits, dst, s->label, sizeof(s->label));
-
- /* write sync bit after 2 * MWPAL words - 1 bit */
- dst = expand_sync(bits, dst, 2 * MWPAL);
- dst = expand_record(bits, dst, s->data, sizeof(s->data));
- dst = expand_cksum(bits, dst, s->data, sizeof(s->data));
-
- /* fill MWPAL words of clock and 0 data bits */
- dst = expand_zeroes(bits, dst, MWPAL);
- }
- m_bits[m_page] = bits;
-
- LOG_DRIVE((0,"[DHD%u] CHS:%03d/%d/%02d #%5d bits\n", m_unit, m_cylinder, m_head, m_sector, dst));
-#if DIABLO_DEBUG
- dump_record(s->pageno, 0, sizeof(s->pageno), "pageno", 0);
- dump_record(s->header, 0, sizeof(s->header), "header", 0);
- dump_record(s->label, 0, sizeof(s->label), "label", 0);
- dump_record(s->data, 0, sizeof(s->data), "data", 1);
-#endif
- return bits;
-}
-
-#if DIABLO_DEBUG
-void diablo_hd_device::dump_ascii(UINT8 *src, size_t size)
-{
- size_t offs;
- LOG_DRIVE((0," ["));
- for (offs = 0; offs < size; offs++) {
- char ch = (char)src[offs ^ 1];
- LOG_DRIVE((0, "%c", ch < 32 || ch > 126 ? '.' : ch));
- }
- LOG_DRIVE((0,"]\n"));
-}
-
-
-/**
- * @brief dump a record's contents
- *
- * @param src pointer to a record (header, label, data)
- * @param size size of the record in bytes
- * @param name name to print before the dump
- */
-size_t diablo_hd_device::dump_record(UINT8 *src, size_t addr, size_t size, const char *name, int cr)
-{
- size_t offs;
- LOG_DRIVE((0,"%s:", name));
- for (offs = 0; offs < size; offs += 2) {
- int word = src[offs] + 256 * src[offs + 1];
- if (offs % 16) {
- LOG_DRIVE((0," %06o", word));
- } else {
- if (offs > 0)
- dump_ascii(&src[offs-16], 16);
- LOG_DRIVE((0,"\t%05o: %06o", (addr + offs) / 2, word));
- }
- }
- if (offs % 16) {
- dump_ascii(&src[offs - (offs % 16)], offs % 16);
- } else {
- dump_ascii(&src[offs-16], 16);
- }
- if (cr) {
- LOG_DRIVE((0,"\n"));
- }
- return size;
-}
-#endif
-
-/**
- * @brief find a sync bit in an array of clock and data bits
- *
- * @param bits pointer to the sector's bits
- * @param src source index into bits (bit number)
- * @param size number of words to scan for a sync word
- * @return next source index for reading
- */
-size_t diablo_hd_device::squeeze_sync(UINT32 *bits, size_t src, size_t size)
-{
- UINT32 accu = 0;
- /* hunt for the first 0x0001 word */
- for (size_t bitcount = 0, offs = 0; offs < size; /* */) {
- /*
- * accumulate clock and data bits until we are
- * on the clock bit boundary
- */
- int bit;
- src = RDBIT(bits,src,bit);
- accu = (accu << 1) | bit;
- /*
- * look for 15 alternating clocks and 0-bits
- * and the 16th clock with a 1-bit
- */
- if (accu == 0xaaaaaaab)
- return src;
- if (++bitcount == 32) {
- bitcount = 0;
- offs++;
- }
- }
- /* return if no sync found within size*32 clock and data bits */
- LOG_DRIVE((0,"[DHD%u] no sync within %d words\n", m_unit, size));
- return src;
-}
-
-/**
- * @brief find a 16 x 0 bits sequence in an array of clock and data bits
- *
- * @param bits pointer to the sector's bits
- * @param src source index into bits (bit number)
- * @param size number of words to scan for a sync word
- * @return next source index for reading
- */
-size_t diablo_hd_device::squeeze_unsync(UINT32 *bits, size_t src, size_t size)
-{
- UINT32 accu = 0;
- /* hunt for the first 0 word (16 x 0 bits) */
- for (size_t bitcount = 0, offs = 0; offs < size; /* */) {
- /*
- * accumulate clock and data bits until we are
- * on the clock bit boundary
- */
- int bit;
- src = RDBIT(bits,src,bit);
- accu = (accu << 1) | bit;
- /*
- * look for 16 alternating clocks and 0 data bits
- */
- if (accu == 0xaaaaaaaa)
- return src;
- if (++bitcount == 32) {
- bitcount = 0;
- offs++;
- }
- }
- /* return if no sync found within size*32 clock and data bits */
- LOG_DRIVE((0,"[DHD%u] no unsync within %d words\n", m_unit, size));
- return src;
-}
-
-/**
- * @brief squeeze an array of clock and data bits into a sector's record
- *
- * @param bits pointer to the sector's bits
- * @param src source index into bits (bit number)
- * @param field pointer to the record data (bytes)
- * @param size size of the record in bytes
- * @return next source index for reading
- */
-size_t diablo_hd_device::squeeze_record(UINT32 *bits, size_t src, UINT8 *field, size_t size)
-{
- UINT32 accu = 0;
- for (size_t bitcount = 0, offs = 0; offs < size; /* */) {
- int bit;
- src = RDBIT(bits,src,bit); // skip clock
- assert(bit == 1);
- src = RDBIT(bits,src,bit); // get data bit
- accu = (accu << 1) | bit;
- bitcount += 2;
- if (bitcount == 32) {
- /* collected a word */
- field[size - 2 - offs + 0] = accu % 256;
- field[size - 2 - offs + 1] = accu / 256;
- offs += 2;
- bitcount = 0;
- }
- }
- return src;
-}
-
-/**
- * @brief squeeze an array of 32 clock and data bits into a checksum word
- *
- * @param bits pointer to the sector's bits
- * @param src source index into bits (bit number)
- * @param cksum pointer to an int to receive the checksum word
- * @return next source index for reading
- */
-size_t diablo_hd_device::squeeze_cksum(UINT32 *bits, size_t src, int *cksum)
-{
- UINT32 accu = 0;
-
- for (size_t bitcount = 0; bitcount < 32; bitcount += 2) {
- int bit;
- src = RDBIT(bits,src,bit); // skip clock
- assert(bit == 1);
- src = RDBIT(bits,src,bit); // get data bit
- accu = (accu << 1) | bit;
- }
-
- /* set the cksum to the extracted word */
- *cksum = accu;
- return src;
-}
-
-/**
- * @brief squeeze a array of clock and data bits into a sector's data
- *
- * Find and squeeze header, label and data fields and verify for
- * zero checksums, starting with a value of 0521.
- * Write the page back to the media and free the bitmap
- */
-void diablo_hd_device::squeeze_sector()
-{
- diablo_sector_t *s;
- size_t src;
- int cksum_header, cksum_label, cksum_data;
-
- if (m_rdfirst >= 0) {
- LOG_DRIVE((0, "[DHD%u] READ CHS:%03d/%d/%02d bit#%d ... bit#%d\n",
- m_unit, m_cylinder, m_head, m_sector, m_rdfirst, m_rdlast));
- }
- m_rdfirst = -1;
- m_rdlast = -1;
-
- /* not written to, just drop it now */
- if (m_wrfirst < 0) {
- m_wrfirst = -1;
- m_wrlast = -1;
- return;
- }
-
- /* did write into the next sector (?) */
- if (m_wrlast > m_wrfirst && m_wrlast < 256) {
- m_wrfirst = -1;
- m_wrlast = -1;
- return;
- }
-
- if (m_wrfirst >= 0) {
- LOG_DRIVE((0, "[DHD%u] WRITE CHS:%03d/%d/%02d bit#%d ... bit#%d\n",
- m_unit, m_cylinder, m_head, m_sector, m_wrfirst, m_wrlast));
- }
- m_wrfirst = -1;
- m_wrlast = -1;
-
- if (m_page < 0 || m_page >= m_pages) {
- LOG_DRIVE((0,"[DHD%u] page not set\n", m_unit));
- return;
- }
-
- if (!m_cache[m_page]) {
- LOG_DRIVE((0,"[DHD%u] no image\n", m_unit));
- return;
- }
-
- /* no bits to write? */
- if (!m_bits[m_page]) {
- LOG_DRIVE((0,"[DHD%u] no bits\n", m_unit));
- return;
- }
- UINT32 *bits = m_bits[m_page];
-
- // pointer to sector buffer
- s = reinterpret_cast<diablo_sector_t *>(m_cache[m_page]);
-
- // zap the sector first
- memset(s, 0, sizeof(*s));
-
- src = MFRRDL * 32;
- src = squeeze_unsync(bits, src, 40); // skip first words and garbage until 0 bits are coming in
- src = squeeze_sync(bits, src, 40); // sync on header preamble
- LOG_DRIVE((0,"[DHD%u] header sync bit #%5d\n", m_unit, src));
- src = squeeze_record(bits, src, s->header, sizeof(s->header));
- LOG_DRIVE((0,"[DHD%u] header CRC bit #%5d\n", m_unit, src));
- src = squeeze_cksum(bits, src, &cksum_header);
-#if DIABLO_DEBUG
- dump_record(s->header, 0, sizeof(s->header), "header", 0);
-#endif
-
- src = squeeze_unsync(bits, src, 40); // skip garbage until 0 bits are coming in
- src = squeeze_sync(bits, src, 40); // sync on label preamble
- LOG_DRIVE((0,"[DHD%u] label sync bit #%5d\n", m_unit, src));
- src = squeeze_record(bits, src, s->label, sizeof(s->label));
- LOG_DRIVE((0,"[DHD%u] label CRC bit #%5d\n", m_unit, src));
- src = squeeze_cksum(bits, src, &cksum_label);
-#if DIABLO_DEBUG
- dump_record(s->label, 0, sizeof(s->label), "label", 0);
-#endif
-
- src = squeeze_unsync(bits, src, 40); // skip garbage until 0 bits are coming in
- src = squeeze_sync(bits, src, 40); // sync on data preamble
- LOG_DRIVE((0,"[DHD%u] data sync bit #%5d\n", m_unit, src));
- src = squeeze_record(bits, src, s->data, sizeof(s->data));
- LOG_DRIVE((0,"[DHD%u] data CRC bit #%5d\n", m_unit, src));
- src = squeeze_cksum(bits, src, &cksum_data);
-#if DIABLO_DEBUG
- dump_record(s->data, 0, sizeof(s->data), "data", 1);
-#endif
- LOG_DRIVE((0,"[DHD%u] postamble bit #%5d\n", m_unit, src));
-
- /* The checksum start value always seems to be 0521 */
- cksum_header ^= cksum(s->header, sizeof(s->header), 0521);
- cksum_label ^= cksum(s->label, sizeof(s->label), 0521);
- cksum_data ^= cksum(s->data, sizeof(s->data), 0521);
-
- if (cksum_header || cksum_label || cksum_data) {
-#if DIABLO_DEBUG
- LOG_DRIVE((0,"[DHD%u] cksum check - header:%06o label:%06o data:%06o\n", m_unit, cksum_header, cksum_label, cksum_data));
-#endif
- }
- auto_free(machine(), m_bits[m_page]);
- m_bits[m_page] = 0;
-
- if (m_disk) {
- if (!hard_disk_write(m_disk, m_page, m_cache[m_page])) {
- LOG_DRIVE((0,"[DHD%u] write failed for page #%d\n", m_unit, m_page));
- }
- } else {
- LOG_DRIVE((2,"[DHD%u] no disk\n", m_unit));
- }
-}
-
-/**
- * @brief return number of bit clocks for a sector (clock and data)
- * @return number of bitclks for a sector
- */
-int diablo_hd_device::bits_per_sector() const
-{
- return m_diablo31 ? DIABLO31_SECTOR_BITS : DIABLO44_SECTOR_BITS;
-}
-
-/**
- * @brief return a pointer to a drive's description
- * @return a pointer to the string description
- */
-const char* diablo_hd_device::description() const
-{
- return m_description;
-}
-
-/**
- * @brief return the number of a drive unit
- * @return the unit number of this instance
- */
-int diablo_hd_device::unit() const
-{
- return m_unit;
-}
-
-/**
- * @brief return the time for a full rotation
- * @return the time for a full track rotation in atto seconds
- */
-attotime diablo_hd_device::rotation_time() const
-{
- return m_rotation_time;
-}
-
-/**
- * @brief return the time for a sector
- * @return the time for a sector in atto seconds
- */
-attotime diablo_hd_device::sector_time() const
-{
- return m_sector_time;
-}
-
-/**
- * @brief return the time for a data bit
- * @return the time in atto seconds per bit clock
- */
-attotime diablo_hd_device::bit_time() const
-{
- return m_bit_time;
-}
-
-/**
- * @brief return the seek/read/write status of a drive
- * @return the seek/read/write status for the drive unit (0:active 1:inactive)
- */
-int diablo_hd_device::get_seek_read_write_0() const
-{
- return m_s_r_w_0;
-}
-
-/**
- * @brief return the ready status of a drive
- * @return the ready status for the drive unit (0:ready 1:not ready)
- */
-int diablo_hd_device::get_ready_0() const
-{
- return m_ready_0;
-}
-
-/**
- * @brief return the current sector mark status of a drive
- *
- * The sector mark is derived from the offset into the current sector.
- * It is deasserted except for a short time (a few micro seconds)
- * around each new sector.
- *
- * @return the current sector mark for the drive (0:active 1:inactive)
- */
-int diablo_hd_device::get_sector_mark_0() const
-{
- /* no sector marks while seeking (?) */
- if (m_s_r_w_0)
- return 1;
-
- /* return the sector mark */
- return m_sector_mark_0;
-}
-
-/**
- * @brief return the address acknowledge state
- * @return address acknowledge state (0:active 1:inactive)
- */
-int diablo_hd_device::get_addx_acknowledge_0() const
-{
- return m_addx_acknowledge_0;
-}
-
-/**
- * @brief return the log address interlock state
- * @return log address interlock state (0:active 1:inactive)
- */
-int diablo_hd_device::get_log_addx_interlock_0() const
-{
- return m_log_addx_interlock_0;
-}
-
-/**
- * @brief return the seek incomplete state
- * @return address acknowledge state (0:active 1:inactive)
- */
-int diablo_hd_device::get_seek_incomplete_0() const
-{
- return m_seek_incomplete_0;
-}
-
-/**
- * @brief return the current cylinder of a drive unit
- *
- * This is a convenience function.
- * There is no such signal on the BUS.
- *
- * Note: The bus lines are active low
- * The value on the BUS needs an XOR with DIABLO_CYLINDER_MASK
- * to resemble the physical line levels.
- *
- * @return current cylinder number for the drive
- */
-int diablo_hd_device::get_cylinder() const
-{
- return m_cylinder;
-}
-
-/**
- * @brief return the current head of a drive unit
- *
- * This is a convenience function.
- * There is no such signal on the BUS.
- *
- * Note: The bus lines are active low
- * The value on the BUS needs an XOR with DIABLO_HEAD_MASK
- * to resemble the physical line levels.
- *
- * @return currently selected head for the drive
- */
-int diablo_hd_device::get_head() const
-{
- return m_head;
-}
-
-/**
- * @brief return the current sector of a drive unit
- *
- * The current sector number is derived from the time since the
- * most recent track rotation started.
- * It counts modulo DIABLO_SPT (12).
- *
- * Note: The bus lines are active low
- * The value on the BUS needs an XOR with DIABLO_SECTOR_MASK
- * to resemble the physical line levels.
- *
- * @return current sector for the drive
- */
-int diablo_hd_device::get_sector() const
-{
- return m_sector;
-}
-
-/**
- * @brief return the current page of a drive unit
- *
- * This is a convenience function.
- * There is no such signal on the BUS.
- *
- * The current page number is derived from the cylinder,
- * head, and sector numbers.
- *
- * @return the current page for the drive
- */
-int diablo_hd_device::get_page() const
-{
- return m_page;
-}
-
-/**
- * @brief select a drive unit
- *
- * Selecting a drive unit updates the ready status
- *
- * @param unit unit number
- */
-void diablo_hd_device::select(int unit)
-{
- assert(unit == m_unit); // this drive is selected
-
- if (m_disk) {
- m_ready_0 = 0; // it is ready
- m_s_r_w_0 = 0; // and can take seek/read/write commands
- m_addx_acknowledge_0 = 0; // assert address acknowledge (?)
- m_log_addx_interlock_0 = 1; // deassert log address interlock (?)
- LOG_DRIVE((1,"[DHD%u] select unit:%d ready\n", m_unit, unit));
- read_sector();
- } else {
- m_ready_0 = 1; // it is not ready (?)
- m_s_r_w_0 = 1; // can't take seek/read/write commands (?)
- m_addx_acknowledge_0 = 0; // assert address acknowledge (?)
- m_log_addx_interlock_0 = 1; // deassert log address interlock (?)
- LOG_DRIVE((1,"[DHD%u] select unit:%d not ready (no image)\n", m_unit, unit));
- }
-}
-
-/**
- * @brief set the selected head
- * @param head head number
- */
-void diablo_hd_device::set_head(int head)
-{
- if ((head & DIABLO_HEAD_MASK) != m_head) {
- m_head = head & DIABLO_HEAD_MASK;
- LOG_DRIVE((0,"[DHD%u] select head:%d\n", m_unit, m_head));
- }
-}
-
-/**
- * @brief set the cylinder number to seek to
- *
- * This defines the cylinder to seek when the
- * STROBE line is pulsed.
- *
- * @param cylinder cylinder number (bus lines CYL[0-9])
- */
-void diablo_hd_device::set_cylinder(int cylinder)
-{
- if ((cylinder & DIABLO_CYLINDER_MASK) != m_seekto) {
- m_seekto = cylinder & DIABLO_CYLINDER_MASK;
- LOG_DRIVE((0,"[DHD%u] seek to cylinder:%d\n", m_unit, m_seekto));
- }
-}
-
-/**
- * @brief set the restore line
- *
- * If the restore line is asserted when the
- * STROBE line is pulsed, the drive seeks
- * towards cylinder 0.
- *
- * @param restore state of the restore line
- */
-void diablo_hd_device::set_restore(int restore)
-{
- if ((restore & 1) != m_restore) {
- m_restore = restore & 1;
- LOG_DRIVE((0,"[DHD%u] restore:%d\n", m_unit, m_restore));
- }
-}
-
-/**
- * @brief strobe a seek operation
- *
- * Seek to the specified cylinder m_seekto,
- * or restore to cylinder 0, if m_restore is set.
- *
- * @param strobe current level of the strobe signal (for edge detection)
- */
-void diablo_hd_device::set_strobe(int strobe)
-{
- int seekto = m_restore ? 0 : m_seekto;
- if (strobe) {
- LOG_DRIVE((1,"[DHD%u] STROBE end of interlock\n", m_unit));
- // deassert the log address interlock
- m_log_addx_interlock_0 = 1;
- return;
- }
-
- // assert the log address interlock
- m_log_addx_interlock_0 = 0;
-
- if (seekto == m_cylinder) {
- LOG_DRIVE((1,"[DHD%u] STROBE to cylinder %d acknowledge\n", m_unit, seekto));
- m_addx_acknowledge_0 = 0; // address acknowledge, if cylinder is reached
- m_seek_incomplete_0 = 1; // reset seek incomplete
- return;
- }
- // assert the seek-read-write signal
- m_s_r_w_0 = 0;
-
- bool complete = true;
- if (seekto < m_cylinder) {
- m_cylinder--; // previous cylinder
- if (m_cylinder < 0) {
- m_cylinder = 0;
- complete = false;
- }
- }
- if (seekto > m_cylinder) {
- /* increment cylinder */
- m_cylinder++;
- if (m_cylinder >= m_cylinders) {
- m_cylinder = m_cylinders - 1;
- complete = false;
- }
- }
- if (complete) {
- LOG_DRIVE((1,"[DHD%u] STROBE to cylinder %d (now %d) - interlock\n", m_unit, seekto, m_cylinder));
- m_addx_acknowledge_0 = 1; // deassert address acknowledge signal
- m_seek_incomplete_0 = 1; // deassert seek incomplete signal
- read_sector();
- } else {
- m_log_addx_interlock_0 = 0; // deassert the log address interlock signal
- m_seek_incomplete_0 = 1; // deassert seek incomplete signal
- m_addx_acknowledge_0 = 0; // assert address acknowledge signal
- LOG_DRIVE((1,"[DHD%u] STROBE to cylinder %d incomplete\n", m_unit, seekto));
- }
-}
-
-/**
- * @brief set the drive erase gate
- * @param gate value of erase gate
- */
-void diablo_hd_device::set_egate(int gate)
-{
- m_egate_0 = gate & 1;
-}
-
-/**
- * @brief set the drive write gate
- * @param gate value of write gate
- */
-void diablo_hd_device::set_wrgate(int gate)
-{
- m_wrgate_0 = gate & 1;
-}
-
-/**
- * @brief set the drive read gate
- * @param gate value of read gate
- */
-void diablo_hd_device::set_rdgate(int gate)
-{
- m_rdgate_0 = gate & 1;
-}
-
-/**
- * @brief write the sector relative bit at index
- *
- * The disk controller writes a combined clock and data pulse to one output
- * <PRE>
- * Encoding of binary 01011
- *
- * clk data clk data clk data clk data clk data
- * 0 1 2 3 4 5 6 7 8 9
- * +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--
- * | | | | | | | | | | | | | | | | |
- * --+ +--------+ +--+ +--+ +--------+ +--+ +--+ +--+ +--+
- * </PRE>
- *
- * @param index relative index of bit/clock into sector
- * @param wrdata write data clock or bit
- */
-void diablo_hd_device::wr_data(int index, int wrdata)
-{
- if (m_wrgate_0) {
- LOG_DRIVE((0,"[DHD%u] index=%d wrgate not asserted\n", m_unit, index));
- return; // write gate is not asserted (active 0)
- }
-
- if (index < 0 || index >= bits_per_sector()) {
- LOG_DRIVE((0,"[DHD%u] index=%d out of range\n", m_unit, index));
- return; // don't write before or beyond the sector
- }
-
- if (-1 == m_page) {
- LOG_DRIVE((0,"[DHD%u] invalid page\n", m_unit));
- return; // invalid page
- }
-
- UINT32 *bits = expand_sector();
- if (!bits) {
- LOG_DRIVE((0,"[DHD%u] no bits\n", m_unit));
- return; // invalid unit
- }
-
- if (-1 == m_wrfirst)
- m_wrfirst = index;
-
- LOG_DRIVE((9,"[DHD%u] CHS:%03d/%d/%02d index #%d bit:%d\n", m_unit, m_cylinder, m_head, m_sector, index, wrdata));
-
- if (index < GUARD_ZONE_BITS) {
- /* don't write in the guard zone (?) */
- } else {
- WRBIT(bits,index,wrdata);
- }
- m_wrlast = index;
-}
-
-/**
- * @brief read the sector relative bit at index
- *
- * Note: this is a gross hack to allow the controller pulling bits
- * at its will, rather than clocking them with the drive's RDCLK-
- *
- * @param index is the sector relative bit index
- * @return returns the sector's bit by index
- */
-int diablo_hd_device::rd_data(int index)
-{
- int bit = 0;
-
- if (m_rdgate_0) {
- LOG_DRIVE((1,"[DHD%u] index=%d rdgate not asserted\n", m_unit, index));
- return 0; // read gate is not asserted (active 0)
- }
-
- if (index < 0 || index >= bits_per_sector()) {
- LOG_DRIVE((0,"[DHD%u] index=%d out of range\n", m_unit, index));
- return 1; // don't read before or beyond the sector
- }
-
- if (0 == m_sector_mark_0) {
- LOG_DRIVE((0,"[DHD%u] read while sector mark is asserted\n", m_unit));
- return 1; // no data while sector mark is asserted
- }
-
- if (-1 == m_page) {
- LOG_DRIVE((0,"[DHD%u] invalid page\n", m_unit));
- return 1; // invalid unit
- }
-
- UINT32 *bits = expand_sector();
- if (!bits) {
- LOG_DRIVE((0,"[DHD%u] no bits\n", m_unit));
- return 1; // invalid page
- }
-
- if (-1 == m_rdfirst)
- m_rdfirst = index;
-
- RDBIT(bits,index,bit);
- LOG_DRIVE((9,"[DHD%u] CHS:%03d/%d/%02d index #%d bit:%d\n", m_unit, m_cylinder, m_head, m_sector, index, bit));
- m_rdlast = index;
- return bit;
-}
-
-/**
- * @brief get the sector relative clock at index
- *
- * Note: this is a gross hack to allow the controller pulling bits
- * at its will, rather than clocking them with the drive's RDCLK-
- *
- * @param index is the sector relative bit index
- * @return returns the sector's clock bit by index
- */
-int diablo_hd_device::rd_clock(int index)
-{
- int clk = 0;
-
- if (index < 0 || index >= bits_per_sector()) {
- LOG_DRIVE((0,"[DHD%u] index out of range (%d)\n", m_unit, index));
- return 1; // don't read before or beyond the sector
- }
-
- if (0 == m_sector_mark_0) {
- LOG_DRIVE((0,"[DHD%u] read while sector mark is asserted\n", m_unit));
- return 1; // no clock while sector mark is low (?)
- }
-
- if (-1 == m_page) {
- LOG_DRIVE((0,"[DHD%u] invalid page\n", m_unit));
- return 1; // invalid page
- }
-
- UINT32 *bits = expand_sector();
- if (!bits) {
- LOG_DRIVE((0,"[DHD%u] no bits\n", m_unit));
- return 1; // invalid unit
- }
-
- if (-1 == m_rdfirst)
- m_rdfirst = index;
-
- if (index & 1) {
- // clock bits are on even bit positions only
- clk = 0;
- } else if (bits) {
- RDBIT(bits,index,clk);
- } else {
- clk = 0;
- }
- LOG_DRIVE((9,"[DHD%u] CHS:%03d/%d/%02d index #%d clk:%d\n", m_unit, m_cylinder, m_head, m_sector, index, clk));
- m_rdlast = index;
- return clk ^ 1;
-}
-
-/**
- * @brief deassert the sector mark
- *
- */
-void diablo_hd_device::sector_mark_1()
-{
- LOG_DRIVE((9,"[DHD%u] CHS:%03d/%d/%02d sector_mark_0=1\n", m_unit, m_cylinder, m_head, m_sector));
- m_sector_mark_0 = 1; // deassert sector mark (set to 1)
-}
-
-/**
- * @brief assert the sector mark and read the next sector
- *
- * Assert the sector mark and reset the read and write
- * first and last bit indices.
- * Increment the sector number, wrap and read the
- * next sector from the media.
- */
-void diablo_hd_device::sector_mark_0()
-{
- LOG_DRIVE((9,"[DHD%u] CHS:%03d/%d/%02d sector_mark_0=0\n", m_unit, m_cylinder, m_head, m_sector));
-
- // HACK: deassert wrgate
- // m_wrgate_0 = 1;
-
- squeeze_sector(); // squeeze previous sector bits, if it was written to
- m_sector_mark_0 = 0; // assert sector mark (set to 0)
- // reset read and write bit locations
- m_rdfirst = -1;
- m_rdlast = -1;
- m_wrfirst = -1;
- m_wrlast = -1;
-
- // count up the sector number
- m_sector = (m_sector + 1) % DIABLO_SPT;
- read_sector();
-}
-
-void diablo_hd_device::device_start()
-{
- m_image = static_cast<diablo_image_device *>(subdevice("drive"));
-
- m_packs = 1; // FIXME: get from configuration?
- m_unit = strstr(m_image->tag(), "diablo0") ? 0 : 1;
- m_timer = timer_alloc(1, 0);
-}
-
-void diablo_hd_device::device_reset()
-{
- // free previous page cache
- if (m_cache) {
- for (int page = 0; page < m_pages; page++)
- if (m_cache[page])
- auto_free(machine(), m_cache[page]);
- auto_free(machine(), m_cache);
- m_cache = 0;
- }
- // free previous bits cache
- if (m_bits) {
- for (int page = 0; page < m_pages; page++)
- if (m_bits[page])
- auto_free(machine(), m_bits[page]);
- auto_free(machine(), m_bits);
- m_bits = 0;
- }
- m_handle = m_image->get_chd_file();
- m_diablo31 = true; // FIXME: get from m_handle meta data?
- m_disk = m_image->get_hard_disk_file();
- if (m_diablo31) {
- snprintf(m_description, sizeof(m_description), "DIABLO31");
- m_rotation_time = DIABLO31_ROTATION_TIME;
- m_sector_time = DIABLO31_ROTATION_TIME / DIABLO_SPT;
- m_sector_mark_0_time = DIABLO31_SECTOR_MARK_PULSE_PRE;
- m_sector_mark_1_time = DIABLO31_SECTOR_MARK_PULSE_PRE;
- m_bit_time = DIABLO31_BIT_TIME(1);
- m_cylinders = DIABLO_CYLINDERS;
- m_pages = DIABLO_PAGES;
- } else {
- snprintf(m_description, sizeof(m_description), "DIABLO44");
- m_rotation_time = DIABLO44_ROTATION_TIME;
- m_sector_time = DIABLO44_ROTATION_TIME / DIABLO_SPT;
- m_sector_mark_0_time = DIABLO44_SECTOR_MARK_PULSE_PRE;
- m_sector_mark_1_time = DIABLO44_SECTOR_MARK_PULSE_PRE;
- m_bit_time = DIABLO44_BIT_TIME(1);
- m_cylinders = 2 * DIABLO_CYLINDERS;
- m_pages = 2 * DIABLO_PAGES;
- }
- LOG_DRIVE((0,"[DHD%u] m_handle : %p\n", m_unit, m_handle));
- LOG_DRIVE((0,"[DHD%u] m_disk : %p\n", m_unit, m_disk));
- LOG_DRIVE((0,"[DHD%u] rotation time : %.0fns\n", m_unit, m_rotation_time.as_double() * ATTOSECONDS_PER_NANOSECOND));
- LOG_DRIVE((0,"[DHD%u] sector time : %.0fns\n", m_unit, m_sector_time.as_double() * ATTOSECONDS_PER_NANOSECOND));
- LOG_DRIVE((0,"[DHD%u] sector mark 0 time : %.0fns\n", m_unit, m_sector_mark_0_time.as_double() * ATTOSECONDS_PER_NANOSECOND));
- LOG_DRIVE((0,"[DHD%u] sector mark 1 time : %.0fns\n", m_unit, m_sector_mark_1_time.as_double() * ATTOSECONDS_PER_NANOSECOND));
- LOG_DRIVE((0,"[DHD%u] bit time : %.0fns\n", m_unit, m_bit_time.as_double() * ATTOSECONDS_PER_NANOSECOND));
-
- m_s_r_w_0 = 1; // deassert seek/read/write ready
- m_ready_0 = 1; // deassert drive ready
- m_sector_mark_0 = 1; // deassert sector mark
- m_addx_acknowledge_0 = 1; // deassert drive address acknowledge
- m_log_addx_interlock_0 = 1; // deassert drive log address interlock
- m_seek_incomplete_0 = 1; // deassert drive seek incomplete
-
- // reset the disk drive's strobe info
- m_seekto = 0;
- m_restore = 0;
- // reset the disk drive's address
- m_cylinder = 0;
- m_head = 0;
- m_sector = 0;
- m_page = 0;
-
- // disable the erase, write and read gates
- m_egate_0 = 1;
- m_wrgate_0 = 1;
- m_rdgate_0 = 1;
-
- // reset read and write first and last indices
- m_wrfirst = -1;
- m_wrlast = -1;
- m_rdfirst = -1;
- m_rdlast = -1;
-
- if (!m_handle)
- return;
- // for units with a CHD assigned to them start the timer
- m_cache = auto_alloc_array_clear(machine(), UINT8*, m_pages);
- m_bits = auto_alloc_array_clear(machine(), UINT32*, m_pages);
- timer_set(m_sector_time - m_sector_mark_0_time, 1, 0);
- read_sector();
-}
-
-/**
- * @brief timer callback that is called thrice per sector in the rotation
- *
- * The timer is called three times at the events:
- * 0: sector mark goes active
- * 1: sector mark goes inactive
- * 2: in the middle of the active phase
- *
- * @param id timer id
- * @param arg argument supplied to timer_insert (unused)
- */
-void diablo_hd_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- LOG_DRIVE((9,"[DHD%u] TIMER id=%d param=%d ptr=%p @%.0fns\n", m_unit, id, param, ptr, timer.elapsed().as_double() * ATTOSECONDS_PER_NANOSECOND));
- if (!m_disk)
- return;
-
- switch (param) {
- case 0:
- // assert sector mark
- sector_mark_0();
- // next sector timer event is in the middle between sector_mark going 0 and back to 1
- timer.adjust(m_sector_mark_0_time, 1);
- break;
- case 1:
- /* call the sector_callback, if any */
- if (m_sector_callback)
- (void)(*m_sector_callback)(m_sector_callback_cookie, m_unit);
- // next sector timer event is deassert of sector_mark_0 (set to 1)
- timer.adjust(m_sector_mark_1_time, 2);
- break;
- case 2:
- // deassert sector mark
- sector_mark_1();
- // next sector timer event is sector_mark_0 for next sector
- timer.adjust(m_sector_time - m_sector_mark_0_time, 0);
- break;
- }
-}
-
-MACHINE_CONFIG_FRAGMENT( diablo_drive )
- MCFG_DIABLO_ADD("drive")
-MACHINE_CONFIG_END
-
-machine_config_constructor diablo_hd_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( diablo_drive );
-}
-
-const device_type DIABLO_HD = &device_creator<diablo_hd_device>;
diff --git a/src/emu/machine/diablo_hd.h b/src/emu/machine/diablo_hd.h
deleted file mode 100644
index 835cc2c281d..00000000000
--- a/src/emu/machine/diablo_hd.h
+++ /dev/null
@@ -1,178 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Juergen Buchmueller
-/**********************************************************
- * DIABLO31 and DIABLO44 hard drive support
- **********************************************************/
-
-#if !defined(_DIABLO_HD_DEVICE_)
-#define _DIABLO_HD_DEVICE_
-
-#include "emu.h"
-#include "imagedev/diablo.h"
-
-#ifndef DIABLO_DEBUG
-#define DIABLO_DEBUG 1 //!< set to 1 to enable debug log output
-#endif
-
-#define DIABLO_HD_0 "diablo0"
-#define DIABLO_HD_1 "diablo1"
-
-extern const device_type DIABLO_HD;
-
-class diablo_hd_device : public device_t
-{
-public:
- diablo_hd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~diablo_hd_device();
-
- static const int DIABLO_UNIT_MAX = 2; //!< max number of drive units
- static const int DIABLO_CYLINDERS = 203; //!< number of cylinders per drive
- static const int DIABLO_CYLINDER_MASK = 0777; //!< bit maks for cylinder number (9 bits)
- static const int DIABLO_SPT = 12; //!< number of sectors per track
- static const int DIABLO_SECTOR_MASK = 017; //!< bit maks for sector number (4 bits)
- static const int DIABLO_HEADS = 2; //!< number of heads per drive
- static const int DIABLO_HEAD_MASK = 1; //!< bit maks for head number (1 bit)
- static const int DIABLO_PAGES = 203*2*12; //!< number of pages per drive
- //! convert a cylinder/head/sector to a logical block address (page)
- static inline int DIABLO_PAGE(int c, int h, int s) { return (c * DIABLO_HEADS + h) * DIABLO_SPT + s; }
-
- void set_sector_callback(void* cookie, void(*callback)(void*, int));
-
- int bits_per_sector() const;
- const char* description() const;
- int unit() const;
- attotime rotation_time() const;
- attotime sector_time() const;
- attotime bit_time() const;
-
- int get_seek_read_write_0() const;
- int get_ready_0() const;
- int get_sector_mark_0() const;
- int get_addx_acknowledge_0() const;
- int get_log_addx_interlock_0() const;
- int get_seek_incomplete_0() const;
- int get_cylinder() const;
- int get_head() const;
- int get_sector() const;
- int get_page() const;
- void select(int unit);
- void set_head(int head);
- void set_cylinder(int cylinder);
- void set_restore(int restore);
- void set_strobe(int strobe);
- void set_egate(int gate);
- void set_wrgate(int gate);
- void set_rdgate(int gate);
- void wr_data(int index, int wrdata);
- int rd_data(int index);
- int rd_clock(int index);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual machine_config_constructor device_mconfig_additions() const;
-
-private:
-#if DIABLO_DEBUG
- int m_log_level;
- void logprintf(int level, const char* format, ...);
-# define LOG_DRIVE(x) logprintf x
-
-#else
-# define LOG_DRIVE(x)
-#endif
- bool m_diablo31; //!< true, if this is a DIABLO31 drive
- int m_unit; //!< drive unit number (0 or 1)
- char m_description[32]; //!< description of the drive(s)
- int m_packs; //!< number of packs in drive (1 or 2)
- attotime m_rotation_time; //!< rotation time in atto seconds
- attotime m_sector_time; //!< sector time in atto seconds
- attotime m_sector_mark_0_time; //!< sector mark going 0 before sector pulse time
- attotime m_sector_mark_1_time; //!< sector mark going 1 after sector pulse time
- attotime m_bit_time; //!< bit time in atto seconds
- int m_s_r_w_0; //!< drive seek/read/write signal (active 0)
- int m_ready_0; //!< drive ready signal (active 0)
- int m_sector_mark_0; //!< sector mark (0 if new sector)
- int m_addx_acknowledge_0; //!< address acknowledge, i.e. seek successful (active 0)
- int m_log_addx_interlock_0; //!< log address interlock, i.e. seek in progress (active 0)
- int m_seek_incomplete_0; //!< seek incomplete, i.e. seek in progress (active 0)
- int m_egate_0; //!< erase gate
- int m_wrgate_0; //!< write gate
- int m_rdgate_0; //!< read gate
- int m_cylinders; //!< total number of cylinders
- int m_pages; //!< total number of pages
- int m_seekto; //!< seek to cylinder number
- int m_restore; //!< restore to cylinder 0 flag
- int m_cylinder; //!< current cylinder number
- int m_head; //!< current head (track) number on cylinder
- int m_sector; //!< current sector number in track
- int m_page; //!< current page (derived from cylinder, head and sector)
- UINT8** m_cache; //!< pages raw bytes
- UINT32** m_bits; //!< pages expanded to bits
- int m_rdfirst; //!< set to first bit of a sector that is read from
- int m_rdlast; //!< set to last bit of a sector that was read from
- int m_wrfirst; //!< set to non-zero if a sector is written to
- int m_wrlast; //!< set to last bit of a sector that was written to
- void *m_sector_callback_cookie; //!< cookie to pass to callback
- void (*m_sector_callback)(void*,int); //!< callback to call at the start of each sector
- emu_timer* m_timer; //!< sector timer
- diablo_image_device* m_image; //!< diablo_image_device interfacing the CHD
- chd_file* m_handle; //!< underlying CHD handle
- hard_disk_file* m_disk; //!< underlying hard disk file
-
- //! translate C/H/S to a page and read the sector
- void read_sector();
-
- //! compute the checksum of a record
- int cksum(UINT8 *src, size_t size, int start);
-
- //! expand a series of clock bits and 0 data bits
- size_t expand_zeroes(UINT32 *bits, size_t dst, size_t size);
-
- //! expand a series of 0 words and write a final sync bit
- size_t expand_sync(UINT32 *bits, size_t dst, size_t size);
-
- //! expand a record of words into a array of bits at dst
- size_t expand_record(UINT32 *bits, size_t dst, UINT8 *field, size_t size);
-
- //! expand a record's checksum word to 32 bits
- size_t expand_cksum(UINT32 *bits, size_t dst, UINT8 *field, size_t size);
-
- //! expand a sector into an array of clock and data bits
- UINT32* expand_sector();
-
-#if DIABLO_DEBUG
- //! dump a number of words as ASCII characters
- void dump_ascii(UINT8 *src, size_t size);
-
- //! dump a record's contents
- size_t dump_record(UINT8 *src, size_t addr, size_t size, const char *name, int cr);
-#endif
-
- //! find a sync bit in an array of clock and data bits
- size_t squeeze_sync(UINT32 *bits, size_t src, size_t size);
-
- //! find a 16 x 0 bits sequence in an array of clock and data bits
- size_t squeeze_unsync(UINT32 *bits, size_t src, size_t size);
-
- //! squeeze an array of clock and data bits into a sector's record
- size_t squeeze_record(UINT32 *bits, size_t src, UINT8 *field, size_t size);
-
- //! squeeze an array of 32 clock and data bits into a checksum word
- size_t squeeze_cksum(UINT32 *bits, size_t src, int *cksum);
-
- //! squeeze a array of clock and data bits into a sector's data
- void squeeze_sector();
-
- //! deassert the sector mark
- void sector_mark_1();
-
- //! assert the sector mark and read the next sector
- void sector_mark_0();
-};
-
-#define MCFG_DIABLO_DRIVES_ADD() \
- MCFG_DEVICE_ADD(DIABLO_HD_0, DIABLO_HD, 3333333) \
- MCFG_DEVICE_ADD(DIABLO_HD_1, DIABLO_HD, 3333333)
-#endif // !defined(_DIABLO_HD_DEVICE_)
diff --git a/src/emu/machine/dmac.c b/src/emu/machine/dmac.c
deleted file mode 100644
index d739d64f308..00000000000
--- a/src/emu/machine/dmac.c
+++ /dev/null
@@ -1,465 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- DMAC
-
- DMA controller used in Amiga systems
-
-BOARDS:
- CBM A590/A2091 HD controller: Prod=514/3($202/$3) (@$e90000 64K)
- CBM A2052/58. RAM I 590/2091.RAM Prod=514/10($202/$a) (@$200000 2meg mem)
-
-***************************************************************************/
-
-#include "dmac.h"
-
-
-//**************************************************************************
-// CONSTANTS / MACROS
-//**************************************************************************
-
-#define VERBOSE 1
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type DMAC = &device_creator<dmac_device>;
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// dmac_device - constructor
-//-------------------------------------------------
-
-dmac_device::dmac_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, DMAC, "DMAC DMA Controller", tag, owner, clock, "dmac", __FILE__),
- amiga_autoconfig(),
- m_cfgout_handler(*this),
- m_int_handler(*this),
- m_xdack_handler(*this),
- m_scsi_read_handler(*this),
- m_scsi_write_handler(*this),
- m_io_read_handler(*this),
- m_io_write_handler(*this),
- m_space(NULL),
- m_rom(NULL),
- m_ram(NULL),
- m_ram_size(-1),
- m_configured(false),
- m_rst(-1),
- m_cntr(0),
- m_istr(0),
- m_wtc(0),
- m_acr(0),
- m_dma_active(false)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void dmac_device::device_start()
-{
- // resolve callbacks
- m_cfgout_handler.resolve_safe();
- m_int_handler.resolve_safe();
- m_xdack_handler.resolve_safe();
- m_scsi_read_handler.resolve_safe(0);
- m_scsi_write_handler.resolve_safe();
- m_io_read_handler.resolve_safe(0);
- m_io_write_handler.resolve_safe();
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void dmac_device::device_reset()
-{
- // fifo empty
- m_istr |= ISTR_FE_FLG;
-}
-
-void dmac_device::autoconfig_base_address(offs_t address)
-{
- if (VERBOSE)
- logerror("%s('%s'): autoconfig_base_address received: 0x%06x\n", shortname(), basetag(), address);
-
- if (!m_configured && m_ram_size > 0)
- {
- if (VERBOSE)
- logerror("-> installing ram (%d bytes)\n", m_ram_size);
-
- // install access to the ram space
- if (address)
- m_space->install_ram(address, address + (m_ram_size - 1), m_ram);
-
- // prepare autoconfig for main device
- autoconfig_board_size(BOARD_SIZE_64K);
- autoconfig_product(0x03); // or 0x02 for rev 1
- autoconfig_rom_vector(0x2000);
- autoconfig_rom_vector_valid(true);
- autoconfig_link_into_memory(false);
- autoconfig_multi_device(false);
-
- // first device configured
- m_configured = true;
- }
- else
- {
- if (VERBOSE)
- logerror("-> installing dmac\n");
-
- // internal dmac registers
- m_space->install_readwrite_handler(address, address + 0xff,
- read16_delegate(FUNC(dmac_device::register_read), this),
- write16_delegate(FUNC(dmac_device::register_write), this), 0xffff);
-
- // install access to the rom space
- if (m_rom)
- {
- m_space->install_rom(address + 0x2000, address + 0x7fff, m_rom + 0x2000);
- m_space->install_rom(address + 0x8000, address + 0xffff, m_rom);
- }
-
- // stop responding to autoconfig
- m_space->unmap_readwrite(0xe80000, 0xe8007f);
-
- // we're done
- m_cfgout_handler(0);
- }
-}
-
-void dmac_device::check_interrupts()
-{
- // interrupts enabled?
- if (m_cntr & CNTR_INTEN)
- {
- // any interrupts pending?
- if (m_istr & ISTR_INT_MASK)
- m_istr |= ISTR_INT_P;
- }
- else
- m_istr &= ~ISTR_INT_P;
-
- // finally update interrupt line
- m_int_handler((m_istr & ISTR_INT_P) ? 1 : 0);
-}
-
-void dmac_device::stop_dma()
-{
- m_dma_active = false;
- m_istr &= ~ISTR_E_INT;
- check_interrupts();
-}
-
-void dmac_device::start_dma()
-{
- m_dma_active = true;
-}
-
-
-//**************************************************************************
-// IMPLEMENTATION
-//**************************************************************************
-
-READ16_MEMBER( dmac_device::register_read )
-{
- UINT16 data = 0xffff;
-
- // autoconfig handles this
- if (offset < 0x20)
- return autoconfig_read(space, offset, mem_mask);
-
- switch (offset)
- {
- case 0x20:
- data = m_istr;
-
- // reading clears fifo status (?)
- m_istr &= ~0x0f;
- check_interrupts();
-
- if (VERBOSE)
- logerror("%s('%s'): read istr %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- break;
-
- case 0x21:
- data = m_cntr;
-
- if (VERBOSE)
- logerror("%s('%s'): read cntr %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- break;
-
- case 0x48:
- case 0x49:
- case 0x50:
- case 0x58:
- case 0x59:
- case 0x5a:
- case 0x5b:
- case 0x5c:
- case 0x5e:
- case 0x5f:
- data = m_scsi_read_handler(offset);
-
- if (VERBOSE)
- logerror("%s('%s'): read scsi data @ %02x %04x [mask = %04x]\n", shortname(), basetag(), offset, data, mem_mask);
-
- break;
-
- case 0x70:
- if (VERBOSE)
- logerror("%s('%s'): read dma start strobe %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- start_dma();
- break;
-
- case 0x71:
- if (VERBOSE)
- logerror("%s('%s'): read dma stop strobe %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- stop_dma();
- break;
-
- case 0x72:
- if (VERBOSE)
- logerror("%s('%s'): read clear irq strobe %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- // clear all interrupts
- m_istr &= ~ISTR_INT_MASK;
- check_interrupts();
- break;
-
- case 0x74:
- if (VERBOSE)
- logerror("%s('%s'): read flush fifo strobe %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- m_istr |= ISTR_FE_FLG;
- break;
-
- default:
- if (VERBOSE)
- logerror("%s('%s'): register_read %04x @ %02x [mask = %04x]\n", shortname(), basetag(), data, offset, mem_mask);
- }
-
- return data;
-}
-
-WRITE16_MEMBER( dmac_device::register_write )
-{
- switch (offset)
- {
- case 0x21:
- if (VERBOSE)
- logerror("%s('%s'): write cntr %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- m_cntr = data;
- check_interrupts();
- break;
-
- case 0x40:
- if (VERBOSE)
- logerror("%s('%s'): write wtc hi %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- m_wtc &= 0x0000ffff;
- m_wtc |= ((UINT32) data) << 16;
- break;
-
- case 0x41:
- if (VERBOSE)
- logerror("%s('%s'): write wtc lo %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- m_wtc &= 0xffff0000;
- m_wtc |= data;
- break;
-
- case 0x42:
- if (VERBOSE)
- logerror("%s('%s'): write acr hi %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- m_acr &= 0x0000ffff;
- m_acr |= ((UINT32) data) << 16;
- break;
-
- case 0x43:
- if (VERBOSE)
- logerror("%s('%s'): write acr lo %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- m_acr &= 0xffff0000;
- m_acr |= data;
- break;
-
- case 0x47:
- if (VERBOSE)
- logerror("%s('%s'): write dawr %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
- break;
-
- case 0x48:
- case 0x49:
- case 0x50:
- case 0x58:
- case 0x59:
- case 0x5a:
- case 0x5b:
- case 0x5c:
- case 0x5e:
- case 0x5f:
- if (VERBOSE)
- logerror("%s('%s'): write scsi data @ %02x %04x [mask = %04x]\n", shortname(), basetag(), offset, data, mem_mask);
-
- m_scsi_write_handler(offset, data, 0xff);
- break;
-
- case 0x70:
- if (VERBOSE)
- logerror("%s('%s'): write dma start strobe %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- start_dma();
- break;
-
- case 0x71:
- if (VERBOSE)
- logerror("%s('%s'): write dma stop strobe %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- stop_dma();
- break;
-
- case 0x72:
- if (VERBOSE)
- logerror("%s('%s'): write clear irq strobe %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- // clear all interrupts
- m_istr &= ~ISTR_INT_MASK;
- check_interrupts();
- break;
-
- case 0x74:
- if (VERBOSE)
- logerror("%s('%s'): write flush fifo strobe %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask);
-
- m_istr |= ISTR_FE_FLG;
- break;
-
- default:
- if (VERBOSE)
- logerror("%s('%s'): write %04x @ %02x [mask = %04x]\n", shortname(), basetag(), data, offset, mem_mask);
- }
-}
-
-// this signal tells us to expose our autoconfig values
-WRITE_LINE_MEMBER( dmac_device::configin_w )
-{
- if (VERBOSE)
- logerror("%s('%s'): configin_w (%d)\n", shortname(), basetag(), state);
-
- if (state == 0 && !m_configured)
- {
- // common autoconfig values
- autoconfig_board_type(BOARD_TYPE_ZORRO2);
- autoconfig_manufacturer(0x0202);
- autoconfig_serial(0x00000000);
- autoconfig_8meg_preferred(false);
- autoconfig_can_shutup(true);
-
- // if we have ram, configure it first
- if (m_ram_size > 0)
- {
- // product id 10
- autoconfig_product(0x0a);
-
- // board size
- switch (m_ram_size)
- {
- case 0x080000: autoconfig_board_size(BOARD_SIZE_512K); break;
- case 0x100000: autoconfig_board_size(BOARD_SIZE_1M); break;
- case 0x200000: autoconfig_board_size(BOARD_SIZE_2M); break;
- }
-
- // no rom and link into free memory
- autoconfig_rom_vector_valid(false);
- autoconfig_link_into_memory(true);
-
- // the main device follows
- autoconfig_multi_device(true);
- }
- else
- {
- // just setup autoconfig for the main device
- autoconfig_board_size(BOARD_SIZE_64K);
- autoconfig_product(0x03); // or 0x02 for rev 1
- autoconfig_rom_vector(0x2000);
- autoconfig_rom_vector_valid(true);
- autoconfig_link_into_memory(false);
-
- // no more devices after this
- autoconfig_multi_device(false);
- }
-
- // install autoconfig handler
- m_space->install_readwrite_handler(0xe80000, 0xe8007f,
- read16_delegate(FUNC(amiga_autoconfig::autoconfig_read), static_cast<amiga_autoconfig *>(this)),
- write16_delegate(FUNC(amiga_autoconfig::autoconfig_write), static_cast<amiga_autoconfig *>(this)), 0xffff);
- }
-}
-
-// this sets the ram size depending on the line voltage
-WRITE_LINE_MEMBER( dmac_device::ramsz_w )
-{
- if (VERBOSE)
- logerror("%s('%s'): ramsz_w (%d)\n", shortname(), basetag(), state);
-
- switch (state)
- {
- case 0: m_ram_size = 0x000000; break;
- case 1: m_ram_size = 0x080000; break;
- case 2: m_ram_size = 0x100000; break;
- case 3: m_ram_size = 0x200000; break;
- }
-}
-
-// reset the device
-WRITE_LINE_MEMBER( dmac_device::rst_w )
-{
- if (VERBOSE)
- logerror("%s('%s'): rst_w (%d)\n", shortname(), basetag(), state);
-
- if (m_rst == 1 && state == 0)
- device_reset();
-
- m_rst = state;
-}
-
-// external interrupt
-WRITE_LINE_MEMBER( dmac_device::intx_w )
-{
- if (VERBOSE)
- logerror("%s('%s'): intx_w (%d)\n", shortname(), basetag(), state);
-
- if (state)
- m_istr |= ISTR_INTS;
- else
- m_istr &= ~ISTR_INTS;
-
- check_interrupts();
-}
-
-// data request
-WRITE_LINE_MEMBER( dmac_device::xdreq_w )
-{
- if (VERBOSE)
- logerror("%s('%s'): xdreq_w (%d)\n", shortname(), basetag(), state);
-
- if (m_dma_active)
- {
- }
-}
diff --git a/src/emu/machine/dmac.h b/src/emu/machine/dmac.h
deleted file mode 100644
index 52c5d64ff5d..00000000000
--- a/src/emu/machine/dmac.h
+++ /dev/null
@@ -1,171 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- DMAC
-
- DMA controller used in Amiga systems
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __DMAC_H__
-#define __DMAC_H__
-
-#include "emu.h"
-#include "autoconfig.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_DMAC_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, DMAC, _clock)
-#define MCFG_DMAC_CFGOUT_HANDLER(_devcb) \
- devcb = &dmac_device::set_cfgout_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_DMAC_INT_HANDLER(_devcb) \
- devcb = &dmac_device::set_int_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_DMAC_XDACK_HANDLER(_devcb) \
- devcb = &dmac_device::set_xdack_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_DMAC_SCSI_READ_HANDLER(_devcb) \
- devcb = &dmac_device::set_scsi_read_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_DMAC_SCSI_WRITE_HANDLER(_devcb) \
- devcb = &dmac_device::set_scsi_write_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_DMAC_IO_READ_HANDLER(_devcb) \
- devcb = &dmac_device::set_io_read_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_DMAC_IO_WRITE_HANDLER(_devcb) \
- devcb = &dmac_device::set_io_write_handler(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> dmac_device
-
-class dmac_device : public device_t, public amiga_autoconfig
-{
-public:
- // construction/destruction
- dmac_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // callbacks
- template<class _Object> static devcb_base &set_cfgout_handler(device_t &device, _Object object)
- { return downcast<dmac_device &>(device).m_cfgout_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_int_handler(device_t &device, _Object object)
- { return downcast<dmac_device &>(device).m_int_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_xdack_handler(device_t &device, _Object object)
- { return downcast<dmac_device &>(device).m_xdack_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_scsi_read_handler(device_t &device, _Object object)
- { return downcast<dmac_device &>(device).m_scsi_read_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_scsi_write_handler(device_t &device, _Object object)
- { return downcast<dmac_device &>(device).m_scsi_write_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_io_read_handler(device_t &device, _Object object)
- { return downcast<dmac_device &>(device).m_io_read_handler.set_callback(object); }
-
- template<class _Object> static devcb_base &set_io_write_handler(device_t &device, _Object object)
- { return downcast<dmac_device &>(device).m_io_write_handler.set_callback(object); }
-
- void set_address_space(address_space *space) { m_space = space; };
- void set_rom(UINT8 *rom) { m_rom = rom; };
- void set_ram(UINT8 *ram) { m_ram = ram; };
-
- // input lines
- DECLARE_WRITE_LINE_MEMBER( configin_w );
- DECLARE_WRITE_LINE_MEMBER( ramsz_w );
- DECLARE_WRITE_LINE_MEMBER( rst_w );
- DECLARE_WRITE_LINE_MEMBER( intx_w );
- DECLARE_WRITE_LINE_MEMBER( xdreq_w );
-
- // dmac register access
- DECLARE_READ16_MEMBER( register_read );
- DECLARE_WRITE16_MEMBER( register_write );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- // amiga_autoconfig overrides
- virtual void autoconfig_base_address(offs_t address);
-
-private:
-
- // control register flags
- enum
- {
- CNTR_TCEN = 0x80, // terminal count enable
- CNTR_PREST = 0x40, // peripheral reset
- CNTR_PDMD = 0x20, // peripheral device mode select (1=scsi, 0=xt)
- CNTR_INTEN = 0x10, // interrupt enable
- CNTR_DDIR = 0x08 // device direction (1=rd host, wr to peripheral)
- };
-
- // interrupt status register
- enum
- {
- ISTR_INTX = 0x100, // xt interrupt pending
- ISTR_INT_F = 0x080, // interrupt follow
- ISTR_INTS = 0x040, // scsi peripheral interrupt
- ISTR_E_INT = 0x020, // end-of-process interrupt
- ISTR_INT_P = 0x010, // interrupt pending
- ISTR_UE_INT = 0x008, // under-run fifo error interrupt
- ISTR_OE_INT = 0x004, // over-run fifo error interrupt
- ISTR_FF_FLG = 0x002, // fifo-full flag
- ISTR_FE_FLG = 0x001 // fifo-empty flag
- };
-
- static const int ISTR_INT_MASK = 0x1fc;
-
- // callbacks
- devcb_write_line m_cfgout_handler;
- devcb_write_line m_int_handler;
- devcb_write_line m_xdack_handler;
- devcb_read8 m_scsi_read_handler;
- devcb_write8 m_scsi_write_handler;
- devcb_read8 m_io_read_handler;
- devcb_write8 m_io_write_handler;
-
- address_space *m_space;
- UINT8 *m_rom;
- UINT8 *m_ram;
- int m_ram_size;
-
- // autoconfig state
- bool m_configured;
-
- // state of lines
- int m_rst;
-
- // register
- UINT16 m_cntr; // control register
- UINT16 m_istr; // interrupt status register
- UINT32 m_wtc; // word transfer count
- UINT32 m_acr; // address control register
-
- bool m_dma_active;
-
- void check_interrupts();
- void start_dma();
- void stop_dma();
-};
-
-
-// device type definition
-extern const device_type DMAC;
-
-
-#endif /* __DMAC_H__ */
diff --git a/src/emu/machine/dp8390.c b/src/emu/machine/dp8390.c
deleted file mode 100644
index e67499538ac..00000000000
--- a/src/emu/machine/dp8390.c
+++ /dev/null
@@ -1,479 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Carl
-#include "emu.h"
-#include "dp8390.h"
-
-#define DP8390_BYTE_ORDER(w) ((m_regs.dcr & 3) == 3 ? ((data << 8) | (data >> 8)) : data)
-#define LOOPBACK (!(m_regs.dcr & 8) && (m_regs.tcr & 6))
-
-const device_type DP8390D = &device_creator<dp8390d_device>;
-const device_type RTL8019A = &device_creator<rtl8019a_device>;
-
-dp8390d_device::dp8390d_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : dp8390_device(mconfig, DP8390D, "DP8390D", tag, owner, clock, 10.0f, "dp8390d", __FILE__) {
- m_type = TYPE_DP8390D;
-}
-
-rtl8019a_device::rtl8019a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : dp8390_device(mconfig, RTL8019A, "RTL8019A", tag, owner, clock, 10.0f, "rtl8019a", __FILE__) {
- m_type = TYPE_RTL8019A;
-}
-
-dp8390_device::dp8390_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, float bandwidth, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_network_interface(mconfig, *this, bandwidth),
- m_irq_cb(*this),
- m_breq_cb(*this),
- m_mem_read_cb(*this),
- m_mem_write_cb(*this)
- {
-}
-
-void dp8390_device::device_start() {
- m_irq_cb.resolve_safe();
- m_breq_cb.resolve_safe();
- m_mem_read_cb.resolve_safe(0);
- m_mem_write_cb.resolve_safe();
-}
-
-void dp8390_device::stop() {
- m_regs.isr = 0x80; // is this right?
- m_regs.cr |= 1;
- m_irq_cb(CLEAR_LINE);
- m_reset = 1;
-}
-
-void dp8390_device::device_reset() {
- memset(&m_regs, 0, sizeof(m_regs));
- m_regs.cr = 0x21;
- m_regs.isr = 0x80;
- m_regs.dcr = 0x04;
- memset(&m_8019regs, 0, sizeof(m_8019regs));
- m_8019regs.config1 = 0x80;
- m_8019regs.config3 = 0x01;
- m_irq_cb(CLEAR_LINE);
-
- m_reset = 1;
-}
-
-void dp8390_device::check_dma_complete() {
- if(m_regs.rbcr) return;
- m_regs.isr |= 0x40;
- check_irq();
- m_rdma_active = 0;
-}
-
-void dp8390_device::do_tx() {
- dynamic_buffer buf;
- int i;
- UINT32 high16 = (m_regs.dcr & 4)?m_regs.rsar<<16:0;
- if(m_reset) return;
- if(LOOPBACK) return; // TODO: loopback
- m_regs.tsr = 0;
- if(m_regs.tbcr > 1518) logerror("dp8390: trying to send overlong frame\n");
- if(!m_regs.tbcr) { // ? Bochs says solaris actually does this
- m_regs.tsr = 1;
- m_regs.cr &= ~4;
- return;
- }
-
- buf.resize(m_regs.tbcr);
- for(i = 0; i < m_regs.tbcr; i++) buf[i] = m_mem_read_cb(high16 + (m_regs.tpsr << 8) + i);
-
- if(send(&buf[0], m_regs.tbcr)) {
- m_regs.tsr = 1;
- m_regs.isr |= 2;
- } else {
- m_regs.tsr = 8; // not quite right but there isn't a generic "tx failed"
- m_regs.isr |= 8;
- }
- m_regs.cr &= ~4;
- check_irq();
-}
-
-void dp8390_device::set_cr(UINT8 newcr) {
- int ostate = ((m_regs.cr & 3) == 2);
- m_regs.cr = newcr;
- if((newcr & 1) && (ostate == 1)) return stop();
- if((newcr & 3) == 2) {
- m_reset = 0;
- m_regs.isr &= ~0x80;
- }
- if(newcr & 0x20) m_rdma_active = 0;
- if(m_reset) return;
- if(newcr & 4) do_tx();
- if((newcr & 0x38) == 8) {
- m_rdma_active = 1;
- check_dma_complete();
- }
- if((newcr & 0x38) == 0x10) m_rdma_active = 2;
-}
-
-void dp8390_device::recv_overflow() {
- m_regs.rsr = 0x10;
- m_regs.isr |= 0x10;
- check_irq();
- m_regs.cntr2++;
- return;
-}
-
-void dp8390_device::recv(UINT8 *buf, int len) {
- int i;
- UINT16 start = (m_regs.curr << 8), offset;
- UINT32 high16;
- if(m_reset) return;
- if(m_regs.curr == m_regs.pstop) start = m_regs.pstart << 8;
- offset = start + 4;
- high16 = (m_regs.dcr & 4)?m_regs.rsar<<16:0;
- if(buf[0] & 1) {
- if(!memcmp((const char *)buf, "\xff\xff\xff\xff\xff\xff", 6)) {
- if(!(m_regs.rcr & 4)) return;
- } else return; // multicast
- m_regs.rsr = 0x20;
- } else m_regs.rsr = 0;
- len &= 0xffff;
-
- for(i = 0; i < len; i++) {
- m_mem_write_cb(high16 + offset, buf[i]);
- offset++;
- if(!(offset & 0xff)) {
- if((offset >> 8) == m_regs.pstop) offset = m_regs.pstart << 8;
- if((offset >> 8) == m_regs.bnry) return recv_overflow();
- }
- }
- if(len < 60) {
- // this can't pass to the next page
- for(; i < 60; i++) {
- m_mem_write_cb(high16 + offset, 0);
- offset++;
- }
- len = 60;
- }
-
- m_regs.rsr |= 1;
- m_regs.isr |= 1;
- m_regs.curr = (offset >> 8) + ((offset & 0xff)?1:0);
- if(m_regs.curr == m_regs.pstop) m_regs.curr = m_regs.pstart;
- len += 4;
- m_mem_write_cb((offs_t)start, m_regs.rsr);
- m_mem_write_cb((offs_t)start+1, m_regs.curr);
- m_mem_write_cb((offs_t)start+2, len & 0xff);
- m_mem_write_cb((offs_t)start+3, len >> 8);
- check_irq();
-}
-
-void dp8390_device::recv_cb(UINT8 *buf, int len) {
- if(!LOOPBACK) recv(buf, len);
-}
-
-WRITE_LINE_MEMBER(dp8390_device::dp8390_cs) {
- m_cs = state;
-}
-
-WRITE_LINE_MEMBER(dp8390_device::dp8390_reset) {
- if(!state) device_reset();
-}
-
-READ16_MEMBER(dp8390_device::dp8390_r) {
- UINT16 data;
- if(m_cs) {
- UINT32 high16 = (m_regs.dcr & 4)?m_regs.rsar<<16:0;
- if(m_regs.dcr & 1) {
- m_regs.crda &= ~1;
- data = m_mem_read_cb(high16 + m_regs.crda++);
- data |= m_mem_read_cb(high16 + m_regs.crda++) << 8;
- m_regs.rbcr -= (m_regs.rbcr < 2)?m_regs.rbcr:2;
- check_dma_complete();
- return DP8390_BYTE_ORDER(data);
- } else {
- m_regs.rbcr -= (m_regs.rbcr)?1:0;
- data = m_mem_read_cb(high16 + m_regs.crda++);
- check_dma_complete();
- return data;
- }
- }
-
- switch((offset & 0x0f)|(m_regs.cr & 0xc0)) {
- case 0x00:
- case 0x40:
- case 0x80:
- data = m_regs.cr;
- break;
- case 0x01:
- data = m_regs.clda & 0xff;
- break;
- case 0x02:
- data = m_regs.clda >> 8;
- break;
- case 0x03:
- data = m_regs.bnry;
- break;
- case 0x04:
- data = m_regs.tsr;
- break;
- case 0x05:
- data = m_regs.ncr;
- break;
- case 0x06:
- data = m_regs.fifo;
- break;
- case 0x07:
- data = m_regs.isr;
- break;
- case 0x08:
- data = m_regs.crda & 0xff;
- break;
- case 0x09:
- data = m_regs.crda >> 8;
- break;
- case 0x0c:
- data = m_regs.rsr;
- break;
- case 0x0d:
- data = m_regs.cntr0;
- break;
- case 0x0e:
- data = m_regs.cntr1;
- break;
- case 0x0f:
- data = m_regs.cntr2;
- break;
- case 0x41:
- case 0x42:
- case 0x43:
- case 0x44:
- case 0x45:
- case 0x46:
- data = m_regs.par[(offset & 0x7)-1];
- break;
- case 0x47:
- data = m_regs.curr;
- break;
- case 0x48:
- case 0x49:
- case 0x4a:
- case 0x4b:
- case 0x4c:
- case 0x4d:
- case 0x4e:
- case 0x4f:
- data = m_regs.mar[offset & 0x7];
- break;
- case 0x81:
- data = m_regs.pstart;
- break;
- case 0x82:
- data = m_regs.pstop;
- break;
- case 0x83:
- data = m_regs.rnpp;
- break;
- case 0x84:
- data = m_regs.tpsr;
- break;
- case 0x85:
- data = m_regs.lnpp;
- break;
- case 0x86:
- data = m_regs.ac >> 8;
- break;
- case 0x87:
- data = m_regs.ac & 0xff;
- break;
- case 0x8c:
- data = m_regs.rcr;
- break;
- case 0x8d:
- data = m_regs.tcr;
- break;
- case 0x8e:
- data = m_regs.dcr;
- break;
- case 0x8f:
- data = m_regs.imr;
- break;
- case 0xc0:
- data = m_regs.cr;
- break;
- default:
- if(m_type == TYPE_RTL8019A) {
- switch((offset & 0x0f)|(m_regs.cr & 0xc0)) {
- case 0x0a:
- data = 'P';
- break;
- case 0x0b:
- data = 'p';
- break;
-
- case 0xc1:
- data = m_8019regs.cr9346;
- break;
- case 0xc2:
- data = m_8019regs.bpage;
- break;
- case 0xc3:
- data = m_8019regs.config0;
- break;
- case 0xc4:
- data = m_8019regs.config1;
- break;
- case 0xc5:
- data = m_8019regs.config2;
- break;
- case 0xc6:
- data = m_8019regs.config3;
- break;
- case 0xcd:
- data = m_8019regs.config4;
- break;
- case 0xc8:
- data = m_8019regs.csnsav;
- break;
- case 0xcb:
- data = m_8019regs.intr;
- break;
- default:
- logerror("rtl8019: invalid read page %01X reg %02X\n", (m_regs.cr & 0xc0) >> 6, offset & 0x0f);
- return 0;
- }
- } else {
- logerror("dp8390: invalid read page %01X reg %02X\n", (m_regs.cr & 0xc0) >> 6, offset & 0x0f);
- return 0;
- }
- }
- return data;
-}
-
-WRITE16_MEMBER(dp8390_device::dp8390_w) {
- if(m_cs) {
- UINT32 high16 = (m_regs.dcr & 4)?m_regs.rsar<<16:0;
- if(m_regs.dcr & 1) {
- data = DP8390_BYTE_ORDER(data);
- m_regs.crda &= ~1;
- m_mem_write_cb(high16 + m_regs.crda++, data & 0xff);
- m_mem_write_cb(high16 + m_regs.crda++, data >> 8);
- m_regs.rbcr -= (m_regs.rbcr < 2)?m_regs.rbcr:2;
- check_dma_complete();
- } else {
- data &= 0xff;
- m_mem_write_cb(high16 + m_regs.crda++, data);
- m_regs.rbcr -= (m_regs.rbcr)?1:0;
- check_dma_complete();
- }
- return;
- }
-
- data &= 0xff;
- switch((offset & 0x0f)|(m_regs.cr & 0xc0)) {
- case 0x00:
- case 0x40:
- case 0x80:
- set_cr(data);
- break;
- case 0x01:
- m_regs.pstart = data;
- break;
- case 0x02:
- m_regs.pstop = data;
- break;
- case 0x03:
- m_regs.bnry = data;
- break;
- case 0x04:
- m_regs.tpsr = data;
- break;
- case 0x05:
- m_regs.tbcr = (m_regs.tbcr & 0xff00) | data;
- break;
- case 0x06:
- m_regs.tbcr = (m_regs.tbcr & 0xff) | (data << 8);
- break;
- case 0x07:
- m_regs.isr &= ~data;
- check_irq();
- break;
- case 0x08:
- m_regs.rsar = (m_regs.rsar & 0xff00) | data;
- m_regs.crda = m_regs.rsar;
- break;
- case 0x09:
- m_regs.rsar = (m_regs.rsar & 0xff) | (data << 8);
- m_regs.crda = m_regs.rsar;
- break;
- case 0x0a:
- m_regs.rbcr = (m_regs.rbcr & 0xff00) | data;
- break;
- case 0x0b:
- m_regs.rbcr = (m_regs.rbcr & 0xff) | (data << 8);
- break;
- case 0x0c:
- m_regs.rcr = data;
- set_promisc((data & 0x10)?true:false);
- break;
- case 0x0d:
- m_regs.tcr = data;
- break;
- case 0x0e:
- m_regs.dcr = data;
- break;
- case 0x0f:
- m_regs.imr = data;
- check_irq();
- break;
- case 0x41:
- case 0x42:
- case 0x43:
- case 0x44:
- case 0x45:
- case 0x46:
- m_regs.par[(offset & 0x7)-1] = data;
- set_mac((const char *)m_regs.par);
- break;
- case 0x47:
- m_regs.curr = data;
- break;
- case 0x48:
- case 0x49:
- case 0x4a:
- case 0x4b:
- case 0x4c:
- case 0x4d:
- case 0x4e:
- case 0x4f:
- m_regs.mar[offset & 0x7] = data;
- break;
- case 0x81:
- m_regs.clda = (m_regs.clda & 0xff00) | data;
- break;
- case 0x82:
- m_regs.clda = (m_regs.clda & 0xff) | (data << 8);
- break;
- case 0x83:
- m_regs.rnpp = data;
- break;
- case 0x85:
- m_regs.lnpp = data;
- break;
- case 0x86:
- m_regs.ac = (m_regs.ac & 0xff) | (data << 8);
- break;
- case 0x87:
- m_regs.ac = (m_regs.ac & 0xff00) | data;
- break;
- case 0xc0:
- set_cr(data);
- break;
- default:
- if(m_type == TYPE_RTL8019A) {
- switch((offset & 0x0f)|(m_regs.cr & 0xc0)) {
- // XXX: rest of the regs
- default:
- logerror("rtl8019: invalid write page %01X reg %02X data %04X\n", (m_regs.cr & 0xc0) >> 6, offset & 0x0f, data);
- return;
- }
- } else {
- logerror("dp8390: invalid write page %01X reg %02X data %04X\n", (m_regs.cr & 0xc0) >> 6, offset & 0x0f, data);
- return;
- }
- }
-}
diff --git a/src/emu/machine/dp8390.h b/src/emu/machine/dp8390.h
deleted file mode 100644
index 46889b3b025..00000000000
--- a/src/emu/machine/dp8390.h
+++ /dev/null
@@ -1,147 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Carl
-#ifndef _DP8390_H_
-#define _DP8390_H_
-
-#include "emu.h"
-
-
-// device stuff
-
-#define MCFG_DP8390D_IRQ_CB(_devcb) \
- devcb = &dp8390d_device::set_irq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DP8390D_BREQ_CB(_devcb) \
- devcb = &dp8390d_device::set_breq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DP8390D_MEM_READ_CB(_devcb) \
- devcb = &dp8390d_device::set_mem_read_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DP8390D_MEM_WRITE_CB(_devcb) \
- devcb = &dp8390d_device::set_mem_write_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_RTL8019A_IRQ_CB(_devcb) \
- devcb = &rtl8019a_device::set_irq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_RTL8019A_BREQ_CB(_devcb) \
- devcb = &rtl8019a_device::set_breq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_RTL8019A_MEM_READ_CB(_devcb) \
- devcb = &rtl8019a_device::set_mem_read_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_RTL8019A_MEM_WRITE_CB(_devcb) \
- devcb = &rtl8019a_device::set_mem_write_callback(*device, DEVCB_##_devcb);
-
-
-class dp8390_device : public device_t,
- public device_network_interface
-{
-public:
- // construction/destruction
- dp8390_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, float bandwidth, const char *shortname, const char *source);
-
- template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<dp8390_device &>(device).m_irq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_breq_callback(device_t &device, _Object object) { return downcast<dp8390_device &>(device).m_breq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_mem_read_callback(device_t &device, _Object object) { return downcast<dp8390_device &>(device).m_mem_read_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_mem_write_callback(device_t &device, _Object object) { return downcast<dp8390_device &>(device).m_mem_write_cb.set_callback(object); }
-
- DECLARE_WRITE16_MEMBER( dp8390_w );
- DECLARE_READ16_MEMBER( dp8390_r );
- DECLARE_WRITE_LINE_MEMBER( dp8390_cs );
- DECLARE_WRITE_LINE_MEMBER( dp8390_reset );
- void recv_cb(UINT8 *buf, int len);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- int m_type;
-
- enum {
- TYPE_DP8390D = 0,
- TYPE_RTL8019A
- };
-
-private:
- devcb_write_line m_irq_cb;
- devcb_write_line m_breq_cb;
- devcb_read8 m_mem_read_cb;
- devcb_write8 m_mem_write_cb;
-
- void set_cr(UINT8 newcr);
- void check_dma_complete();
- void do_tx();
- bool mcast_ck(const UINT8 *buf, int len);
- void check_irq() { m_irq_cb((m_regs.imr & m_regs.isr & 0x7f)?ASSERT_LINE:CLEAR_LINE); }
- void recv_overflow();
- void stop();
- void recv(UINT8 *buf, int len);
-
- int m_reset;
- bool m_cs;
- int m_rdma_active;
-
- struct {
- UINT8 cr;
- UINT16 clda;
- UINT8 pstart;
- UINT8 pstop;
- UINT8 bnry;
- UINT8 tsr;
- UINT8 tpsr;
- UINT8 ncr;
- UINT8 fifo;
- UINT16 tbcr;
- UINT8 isr;
- UINT16 crda;
- UINT16 rsar;
- UINT16 rbcr;
- UINT8 rsr;
- UINT8 rcr;
- UINT8 cntr0;
- UINT8 tcr;
- UINT8 cntr1;
- UINT8 dcr;
- UINT8 cntr2;
- UINT8 imr;
-
- UINT8 par[6];
- UINT8 curr;
- UINT8 mar[8];
-
- UINT8 rnpp;
- UINT8 lnpp;
- UINT16 ac;
- } m_regs;
-
- struct {
- UINT8 cr9346;
- UINT8 bpage;
- UINT8 config0;
- UINT8 config1;
- UINT8 config2;
- UINT8 config3;
- UINT8 config4;
- UINT8 csnsav;
- UINT8 intr;
- } m_8019regs;
-};
-
-class rtl8019a_device : public dp8390_device
-{
-public:
- rtl8019a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class dp8390d_device : public dp8390_device
-{
-public:
- dp8390d_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-// device type definition
-extern const device_type DP8390D;
-extern const device_type RTL8019A;
-
-#endif
diff --git a/src/emu/machine/ds1204.c b/src/emu/machine/ds1204.c
deleted file mode 100644
index a35624a3c6a..00000000000
--- a/src/emu/machine/ds1204.c
+++ /dev/null
@@ -1,375 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
- * ds1204.c
- *
- * Electronic Key
- *
- */
-
-#include <stdio.h>
-#include "emu.h"
-#include "ds1204.h"
-
-#define VERBOSE_LEVEL ( 0 )
-
-inline void ATTR_PRINTF( 3, 4 ) ds1204_device::verboselog( int n_level, const char *s_fmt, ... )
-{
- if( VERBOSE_LEVEL >= n_level )
- {
- va_list v;
- char buf[ 32768 ];
- va_start( v, s_fmt );
- vsprintf( buf, s_fmt, v );
- va_end( v );
- logerror( "%s: ds1204(%s) %s", machine().describe_context(), tag(), buf );
- }
-}
-
-// device type definition
-const device_type DS1204 = &device_creator<ds1204_device>;
-
-ds1204_device::ds1204_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
- : device_t( mconfig, DS1204, "DS1204", tag, owner, clock, "ds1204", __FILE__ ),
- device_nvram_interface(mconfig, *this),
- m_rst( 0 ),
- m_clk( 0 ),
- m_dqw( 0 )
-{
-}
-
-void ds1204_device::device_start()
-{
- new_state( STATE_STOP );
- m_dqr = DQ_HIGH_IMPEDANCE;
-
- memset( m_command, 0, sizeof( m_command ) );
- memset( m_compare_register, 0, sizeof( m_compare_register ) );
-
- save_item( NAME( m_rst ) );
- save_item( NAME( m_clk ) );
- save_item( NAME( m_dqw ) );
- save_item( NAME( m_dqr ) );
- save_item( NAME( m_state ) );
- save_item( NAME( m_bit ) );
- save_item( NAME( m_command ) );
- save_item( NAME( m_compare_register ) );
- save_item( NAME( m_unique_pattern ) );
- save_item( NAME( m_identification ) );
- save_item( NAME( m_security_match ) );
- save_item( NAME( m_secure_memory ) );
-}
-
-void ds1204_device::nvram_default()
-{
- memset( m_unique_pattern, 0, sizeof( m_unique_pattern ) );
- memset( m_identification, 0, sizeof( m_identification ) );
- memset( m_security_match, 0, sizeof( m_security_match ) );
- memset( m_secure_memory, 0, sizeof( m_secure_memory ) );
-
- int expected_bytes = sizeof( m_unique_pattern ) + sizeof( m_identification ) + sizeof( m_security_match ) + sizeof( m_secure_memory );
-
- if( !m_region )
- {
- logerror( "ds1204(%s) region not found\n", tag() );
- }
- else if( m_region->bytes() != expected_bytes )
- {
- logerror( "ds1204(%s) region length 0x%x expected 0x%x\n", tag(), m_region->bytes(), expected_bytes );
- }
- else
- {
- UINT8 *region = m_region->base();
-
- memcpy( m_unique_pattern, region, sizeof( m_unique_pattern ) ); region += sizeof( m_unique_pattern );
- memcpy( m_identification, region, sizeof( m_identification ) ); region += sizeof( m_identification );
- memcpy( m_security_match, region, sizeof( m_security_match ) ); region += sizeof( m_security_match );
- memcpy( m_secure_memory, region, sizeof( m_secure_memory ) ); region += sizeof( m_secure_memory );
- }
-}
-
-void ds1204_device::nvram_read( emu_file &file )
-{
- file.read( m_unique_pattern, sizeof( m_unique_pattern ) );
- file.read( m_identification, sizeof( m_identification ) );
- file.read( m_security_match, sizeof( m_security_match ) );
- file.read( m_secure_memory, sizeof( m_secure_memory ) );
-}
-
-void ds1204_device::nvram_write( emu_file &file )
-{
- file.write( m_unique_pattern, sizeof( m_unique_pattern ) );
- file.write( m_identification, sizeof( m_identification ) );
- file.write( m_security_match, sizeof( m_security_match ) );
- file.write( m_secure_memory, sizeof( m_secure_memory ) );
-}
-
-void ds1204_device::new_state( int state )
-{
- m_state = state;
- m_bit = 0;
-}
-
-void ds1204_device::writebit( UINT8 *buffer )
-{
- if( m_clk )
- {
- int index = m_bit / 8;
- int mask = 1 << ( m_bit % 8 );
-
- if( m_dqw )
- {
- buffer[ index ] |= mask;
- }
- else
- {
- buffer[ index ] &= ~mask;
- }
-
- m_bit++;
- }
-}
-
-void ds1204_device::readbit( UINT8 *buffer )
-{
- if( !m_clk )
- {
- int index = m_bit / 8;
- int mask = 1 << ( m_bit % 8 );
-
- if( buffer[ index ] & mask )
- {
- m_dqr = 1;
- }
- else
- {
- m_dqr = 0;
- }
- }
- else
- {
- m_bit++;
- }
-}
-
-WRITE_LINE_MEMBER( ds1204_device::write_rst )
-{
- if( m_rst != state )
- {
- m_rst = state;
- verboselog( 2, "rst=%d\n", m_rst );
-
- if( m_rst )
- {
- new_state( STATE_PROTOCOL );
- }
- else
- {
- switch( m_state )
- {
- case STATE_WRITE_IDENTIFICATION:
- verboselog( 0, "reset during write identification (bit=%d)\n", m_bit );
- break;
- case STATE_WRITE_SECURITY_MATCH:
- verboselog( 0, "reset during write security match (bit=%d)\n", m_bit );
- break;
- case STATE_WRITE_SECURE_MEMORY:
- verboselog( 0, "reset during write secure memory (bit=%d)\n", m_bit );
- break;
- }
-
- new_state( STATE_STOP );
- m_dqr = DQ_HIGH_IMPEDANCE;
- }
- }
-}
-
-WRITE_LINE_MEMBER( ds1204_device::write_clk )
-{
- if( m_clk != state )
- {
- m_clk = state;
- verboselog( 2, "clk=%d (bit=%d)\n", m_clk, m_bit );
-
- if( m_clk )
- {
- m_dqr = DQ_HIGH_IMPEDANCE;
- }
-
- switch( m_state )
- {
- case STATE_PROTOCOL:
- writebit( m_command );
-
- if( m_bit == 24 )
- {
- verboselog( 1, "-> command %02x %02x %02x (%02x %02x)\n",
- m_command[ 0 ], m_command[ 1 ], m_command[ 2 ], m_unique_pattern[ 0 ], m_unique_pattern[ 1 ] );
-
- if( m_command[ 0 ] == COMMAND_READ && m_command[ 1 ] == ( m_unique_pattern[ 0 ] | CYCLE_NORMAL ) && m_command[ 2 ] == m_unique_pattern[ 1 ] )
- {
- new_state( STATE_READ_IDENTIFICATION );
- }
- else if( m_command[ 0 ] == COMMAND_WRITE && m_command[ 1 ] == ( m_unique_pattern[ 0 ] | CYCLE_NORMAL ) && m_command[ 2 ] == m_unique_pattern[ 1 ] )
- {
- new_state( STATE_READ_IDENTIFICATION );
- }
- else if( m_command[ 0 ] == COMMAND_WRITE && m_command[ 1 ] == ( m_unique_pattern[ 0 ] | CYCLE_PROGRAM ) && m_command[ 2 ] == m_unique_pattern[ 1 ] )
- {
- new_state( STATE_WRITE_IDENTIFICATION );
- }
- else
- {
- new_state( STATE_STOP );
- }
- }
- break;
-
- case STATE_READ_IDENTIFICATION:
- readbit( m_identification );
-
- if( m_bit == 64 )
- {
- verboselog( 1, "<- identification %02x %02x %02x %02x %02x %02x %02x %02x\n",
- m_identification[ 0 ], m_identification[ 1 ], m_identification[ 2 ], m_identification[ 3 ],
- m_identification[ 4 ], m_identification[ 5 ], m_identification[ 6 ], m_identification[ 7 ] );
-
- new_state( STATE_WRITE_COMPARE_REGISTER );
- }
- break;
-
- case STATE_WRITE_COMPARE_REGISTER:
- writebit( m_compare_register );
-
- if( m_bit == 64 )
- {
- verboselog( 1, "-> compare register %02x %02x %02x %02x %02x %02x %02x %02x (%02x %02x %02x %02x %02x %02x %02x %02x)\n",
- m_compare_register[ 0 ], m_compare_register[ 1 ], m_compare_register[ 2 ], m_compare_register[ 3 ],
- m_compare_register[ 4 ], m_compare_register[ 5 ], m_compare_register[ 6 ], m_compare_register[ 7 ],
- m_security_match[ 0 ], m_security_match[ 1 ], m_security_match[ 2 ], m_security_match[ 3 ],
- m_security_match[ 4 ], m_security_match[ 5 ], m_security_match[ 6 ], m_security_match[ 7 ] );
-
- if( memcmp( m_compare_register, m_security_match, sizeof( m_compare_register ) ) == 0 )
- {
- if( m_command[ 0 ] == COMMAND_READ )
- {
- new_state( STATE_READ_SECURE_MEMORY );
- }
- else
- {
- new_state( STATE_WRITE_SECURE_MEMORY );
- }
- }
- else
- {
- new_state( STATE_OUTPUT_GARBLED_DATA );
- }
- }
- break;
-
- case STATE_READ_SECURE_MEMORY:
- readbit( m_secure_memory );
-
- if( m_bit == 128 )
- {
- verboselog( 1, "<- secure memory %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
- m_secure_memory[ 0 ], m_secure_memory[ 1 ], m_secure_memory[ 2 ], m_secure_memory[ 3 ],
- m_secure_memory[ 4 ], m_secure_memory[ 5 ], m_secure_memory[ 6 ], m_secure_memory[ 7 ],
- m_secure_memory[ 8 ], m_secure_memory[ 9 ], m_secure_memory[ 10 ], m_secure_memory[ 11 ],
- m_secure_memory[ 12 ], m_secure_memory[ 13 ], m_secure_memory[ 14 ], m_secure_memory[ 15 ] );
-
- new_state( STATE_STOP );
- }
- break;
-
- case STATE_WRITE_SECURE_MEMORY:
- writebit( m_secure_memory );
-
- if( m_bit == 128 )
- {
- verboselog( 1, "-> secure memory %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
- m_secure_memory[ 0 ], m_secure_memory[ 1 ], m_secure_memory[ 2 ], m_secure_memory[ 3 ],
- m_secure_memory[ 4 ], m_secure_memory[ 5 ], m_secure_memory[ 6 ], m_secure_memory[ 7 ],
- m_secure_memory[ 8 ], m_secure_memory[ 9 ], m_secure_memory[ 10 ], m_secure_memory[ 11 ],
- m_secure_memory[ 12 ], m_secure_memory[ 13 ], m_secure_memory[ 14 ], m_secure_memory[ 15 ] );
-
- new_state( STATE_STOP );
- }
- break;
-
- case STATE_WRITE_IDENTIFICATION:
- writebit( m_identification );
-
- if( m_bit == 64 )
- {
- verboselog( 1, "-> identification %02x %02x %02x %02x %02x %02x %02x %02x\n",
- m_identification[ 0 ], m_identification[ 1 ], m_identification[ 2 ], m_identification[ 3 ],
- m_identification[ 4 ], m_identification[ 5 ], m_identification[ 6 ], m_identification[ 7 ] );
-
- new_state( STATE_WRITE_SECURITY_MATCH );
- }
- break;
-
- case STATE_WRITE_SECURITY_MATCH:
- writebit( m_security_match );
-
- if( m_bit == 64 )
- {
- verboselog( 1, ">- security match %02x %02x %02x %02x %02x %02x %02x %02x\n",
- m_security_match[ 0 ], m_security_match[ 1 ], m_security_match[ 2 ], m_security_match[ 3 ],
- m_security_match[ 4 ], m_security_match[ 5 ], m_security_match[ 6 ], m_security_match[ 7 ] );
-
- new_state( STATE_STOP );
- }
- break;
-
- case STATE_OUTPUT_GARBLED_DATA:
- if( !m_clk && m_command[ 0 ] == COMMAND_READ )
- {
- m_dqr = machine().rand() & 1;
- m_bit++;
- }
- else if( m_clk && m_command[ 0 ] == COMMAND_WRITE )
- {
- m_bit++;
- }
-
- if( m_bit == 64 )
- {
- if( m_command[ 0 ] == COMMAND_READ )
- {
- verboselog( 1, "<- random\n" );
- }
- else
- {
- verboselog( 1, "-> ignore\n" );
- }
-
- new_state( STATE_STOP );
- }
- break;
- }
- }
-}
-
-WRITE_LINE_MEMBER( ds1204_device::write_dq )
-{
- if( m_dqw != state )
- {
- m_dqw = state;
-
- verboselog( 2, "dqw=%d\n", m_dqw );
- }
-}
-
-READ_LINE_MEMBER( ds1204_device::read_dq )
-{
- if( m_dqr == DQ_HIGH_IMPEDANCE )
- {
- verboselog( 2, "dqr=high impedance\n" );
- return 0;
- }
-
- verboselog( 2, "dqr=%d (bit=%d)\n", m_dqr, m_bit );
- return m_dqr;
-}
diff --git a/src/emu/machine/ds1204.h b/src/emu/machine/ds1204.h
deleted file mode 100644
index 7c8f1727c37..00000000000
--- a/src/emu/machine/ds1204.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
- * ds1204.h
- *
- * Electronic Key
- *
- */
-
-#pragma once
-
-#ifndef __DS1204_H__
-#define __DS1204_H__
-
-#include "emu.h"
-
-#define MCFG_DS1204_ADD( _tag ) \
- MCFG_DEVICE_ADD( _tag, DS1204, 0 )
-
-class ds1204_device : public device_t,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- ds1204_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock );
-
- DECLARE_WRITE_LINE_MEMBER( write_rst );
- DECLARE_WRITE_LINE_MEMBER( write_clk );
- DECLARE_WRITE_LINE_MEMBER( write_dq );
- DECLARE_READ_LINE_MEMBER( read_dq );
-
-protected:
- // device-level overrides
- virtual void device_start();
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read( emu_file &file );
- virtual void nvram_write( emu_file &file );
-
-private:
- inline void ATTR_PRINTF( 3, 4 ) verboselog( int n_level, const char *s_fmt, ... );
- void new_state(int state);
- void writebit(UINT8 *buffer);
- void readbit(UINT8 *buffer);
-
- enum state_t
- {
- STATE_STOP,
- STATE_PROTOCOL,
- STATE_READ_IDENTIFICATION,
- STATE_WRITE_IDENTIFICATION,
- STATE_WRITE_COMPARE_REGISTER,
- STATE_WRITE_SECURITY_MATCH,
- STATE_READ_SECURE_MEMORY,
- STATE_WRITE_SECURE_MEMORY,
- STATE_OUTPUT_GARBLED_DATA
- };
-
- enum command_t
- {
- COMMAND_READ = 0x62,
- COMMAND_WRITE = 0x9d
- };
-
- enum cycle_t
- {
- CYCLE_NORMAL = 1,
- CYCLE_PROGRAM = 2,
- CYCLE_MASK = 3
- };
-
- static const int DQ_HIGH_IMPEDANCE = -1;
-
- int m_rst;
- int m_clk;
- int m_dqw;
- int m_dqr;
- int m_state;
- int m_bit;
- UINT8 m_command[3];
- UINT8 m_compare_register[8];
- UINT8 m_unique_pattern[2];
- UINT8 m_identification[8];
- UINT8 m_security_match[8];
- UINT8 m_secure_memory[16];
-};
-
-
-// device type definition
-extern const device_type DS1204;
-
-#endif
diff --git a/src/emu/machine/ds128x.c b/src/emu/machine/ds128x.c
deleted file mode 100644
index 5b7fa8e0663..00000000000
--- a/src/emu/machine/ds128x.c
+++ /dev/null
@@ -1,16 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "ds128x.h"
-
-/// TODO: Only DV2/DV1/DV0 == 0/1/0 is supported as the chip only has a 15 stage divider and not 22.
-
-const device_type DS12885 = &device_creator<ds12885_device>;
-
-//-------------------------------------------------
-// ds12885_device - constructor
-//-------------------------------------------------
-
-ds12885_device::ds12885_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : mc146818_device(mconfig, DS12885, "DS12885", tag, owner, clock, "ds12885", __FILE__)
-{
-}
diff --git a/src/emu/machine/ds128x.h b/src/emu/machine/ds128x.h
deleted file mode 100644
index d07e785340f..00000000000
--- a/src/emu/machine/ds128x.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#ifndef __DS128X_H__
-#define __DS128X_H__
-
-#include "mc146818.h"
-
-#define MCFG_DS12885_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, DS12885, XTAL_32_768kHz)
-
-// ======================> mc146818_device
-
-class ds12885_device : public mc146818_device
-{
-public:
- // construction/destruction
- ds12885_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual int data_size() { return 128; }
-};
-
-// device type definition
-extern const device_type DS12885;
-
-#endif
diff --git a/src/emu/machine/ds1302.c b/src/emu/machine/ds1302.c
deleted file mode 100644
index c254690cae0..00000000000
--- a/src/emu/machine/ds1302.c
+++ /dev/null
@@ -1,413 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Dallas DS1302 Trickle-Charge Timekeeping Chip emulation
-
-**********************************************************************/
-
-/*
-
- TODO:
-
- - 12 hour format
- - synchronize user buffers on falling edge of CE after write
-
-*/
-
-#include "ds1302.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-#define RAM_SIZE 0x1f // 31 bytes
-
-
-enum
-{
- STATE_COMMAND,
- STATE_INPUT,
- STATE_OUTPUT
-};
-
-enum
-{
- REGISTER_SECONDS = 0,
- REGISTER_MINUTES,
- REGISTER_HOUR,
- REGISTER_DATE,
- REGISTER_MONTH,
- REGISTER_DAY,
- REGISTER_YEAR,
- REGISTER_CONTROL,
- REGISTER_TRICKLE
-};
-
-
-#define COMMAND_READ (m_cmd & 0x01)
-#define COMMAND_RAM (m_cmd & 0x40)
-#define COMMAND_VALID (m_cmd & 0x80)
-#define COMMAND_BURST (((m_cmd >> 1) & 0x1f) == 0x1f)
-#define CLOCK_HALT (m_reg[REGISTER_SECONDS] & 0x80)
-#define WRITE_PROTECT (m_reg[REGISTER_CONTROL] & 0x80)
-#define BURST_END (COMMAND_RAM ? 0x1f : 0x09)
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type DS1302 = &device_creator<ds1302_device>;
-
-
-//-------------------------------------------------
-// ds1302_device - constructor
-//-------------------------------------------------
-
-ds1302_device::ds1302_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, DS1302, "DS1302", tag, owner, clock, "ds1302", __FILE__),
- device_rtc_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ds1302_device::device_start()
-{
- // allocate timers
- m_clock_timer = timer_alloc();
- m_clock_timer->adjust(attotime::from_hz(clock() / 32768), 0, attotime::from_hz(clock() / 32768));
-
- for (int i = 0; i < 9; i++)
- m_reg[i] = 0;
-
- // state saving
- save_item(NAME(m_ce));
- save_item(NAME(m_clk));
- save_item(NAME(m_io));
- save_item(NAME(m_state));
- save_item(NAME(m_bits));
- save_item(NAME(m_cmd));
- save_item(NAME(m_data));
- save_item(NAME(m_addr));
- save_item(NAME(m_reg));
- save_item(NAME(m_user));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ds1302_device::device_reset()
-{
- set_current_time(machine());
-
- m_clk = 0;
- m_ce = 0;
- m_state = STATE_COMMAND;
- m_bits = 0;
- m_cmd = 0;
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void ds1302_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if (!CLOCK_HALT)
- {
- advance_seconds();
- }
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void ds1302_device::nvram_default()
-{
- memset(m_ram, 0, RAM_SIZE);
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void ds1302_device::nvram_read(emu_file &file)
-{
- file.read(m_ram, RAM_SIZE);
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void ds1302_device::nvram_write(emu_file &file)
-{
- file.write(m_ram, RAM_SIZE);
-}
-
-
-//-------------------------------------------------
-// rtc_clock_updated -
-//-------------------------------------------------
-
-void ds1302_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
- m_reg[REGISTER_YEAR] = convert_to_bcd(year);
- m_reg[REGISTER_DAY] = day_of_week;
- m_reg[REGISTER_MONTH] = convert_to_bcd(month);
- m_reg[REGISTER_DATE] = convert_to_bcd(day);
- m_reg[REGISTER_HOUR] = convert_to_bcd(hour);
- m_reg[REGISTER_MINUTES] = convert_to_bcd(minute);
- m_reg[REGISTER_SECONDS] = (m_reg[REGISTER_SECONDS] & 0x80) | convert_to_bcd(second);
-}
-
-
-//-------------------------------------------------
-// ce_w - chip enable write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds1302_device::ce_w )
-{
- if (LOG) logerror("DS1302 '%s' CE: %u\n", tag(), state);
-
- if (!state && m_ce)
- {
- // synchronize user buffers
- for (int i = 0; i < 9; i++)
- {
- m_user[i] = m_reg[i];
- }
- }
- else if (state && !m_ce)
- {
- // terminate data transfer
- m_state = STATE_COMMAND;
- m_bits = 0;
- }
-
- m_ce = state;
-}
-
-
-//-------------------------------------------------
-// load_shift_register -
-//-------------------------------------------------
-
-void ds1302_device::load_shift_register()
-{
- if (COMMAND_READ)
- {
- if (COMMAND_RAM)
- {
- m_data = m_ram[m_addr];
-
- if (LOG) logerror("DS1302 '%s' Read RAM %u:%02x\n", tag(), m_addr, m_data);
- }
- else
- {
- m_data = m_user[m_addr];
-
- if (LOG) logerror("DS1302 '%s' Read Clock %u:%02x\n", tag(), m_addr, m_data);
- }
- }
- else
- {
- if (COMMAND_RAM)
- {
- if (LOG) logerror("DS1302 '%s' Write RAM %u:%02x\n", tag(), m_addr, m_data);
-
- m_ram[m_addr] = m_data;
- }
- else if (m_addr < 9)
- {
- if (LOG) logerror("DS1302 '%s' Write Clock %u:%02x\n", tag(), m_addr, m_data);
-
- m_reg[m_addr] = m_data;
- }
- }
-}
-
-
-//-------------------------------------------------
-// input_bit -
-//-------------------------------------------------
-
-void ds1302_device::input_bit()
-{
- switch (m_state)
- {
- case STATE_COMMAND:
- m_cmd >>= 1;
- m_cmd |= (m_io << 7);
- m_bits++;
-
- if (m_bits == 8)
- {
- if (LOG) logerror("DS1302 '%s' Command: %02x\n", tag(), m_cmd);
-
- m_bits = 0;
- m_addr = (m_cmd >> 1) & 0x1f;
-
- if (COMMAND_VALID)
- {
- if (COMMAND_BURST)
- {
- m_addr = 0;
- }
-
- if (COMMAND_READ)
- {
- load_shift_register();
-
- m_state = STATE_OUTPUT;
- }
- else
- {
- m_state = STATE_INPUT;
- }
- }
- else
- {
- m_state = STATE_COMMAND;
- }
- }
- break;
-
- case STATE_INPUT:
- m_data >>= 1;
- m_data |= (m_io << 7);
- m_bits++;
-
- if (m_bits == 8)
- {
- if (LOG) logerror("DS1302 '%s' Data: %02x\n", tag(), m_data);
-
- m_bits = 0;
-
- if (!WRITE_PROTECT)
- {
- load_shift_register();
- }
-
- if (COMMAND_BURST)
- {
- m_addr++;
-
- if (m_addr == BURST_END)
- {
- m_state = STATE_COMMAND;
- }
- }
- else
- {
- m_state = STATE_COMMAND;
- }
- }
- break;
- }
-}
-
-
-//-------------------------------------------------
-// output_bit -
-//-------------------------------------------------
-
-void ds1302_device::output_bit()
-{
- if (m_state != STATE_OUTPUT) return;
-
- m_io = BIT(m_data, 0);
- m_data >>= 1;
- m_bits++;
-
- if (m_bits == 8)
- {
- m_bits = 0;
-
- if (COMMAND_BURST)
- {
- m_addr++;
-
- if (m_addr == BURST_END)
- {
- m_state = STATE_COMMAND;
- }
- else
- {
- load_shift_register();
- }
- }
- else
- {
- m_state = STATE_COMMAND;
- }
- }
-}
-
-
-//-------------------------------------------------
-// sclk_w - serial clock write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds1302_device::sclk_w )
-{
- if (LOG) logerror("DS1302 '%s' CLK: %u\n", tag(), state);
-
- if (!m_ce) return;
-
- if (!m_clk && state) // rising edge
- {
- input_bit();
- }
- else if (m_clk && !state) // falling edge
- {
- output_bit();
- }
-
- m_clk = state;
-}
-
-
-//-------------------------------------------------
-// io_w - I/O write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds1302_device::io_w )
-{
- if (LOG) logerror("DS1302 '%s' I/O: %u\n", tag(), state);
-
- m_io = state;
-}
-
-
-//-------------------------------------------------
-// io_r - I/O read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( ds1302_device::io_r )
-{
- return m_io;
-}
diff --git a/src/emu/machine/ds1302.h b/src/emu/machine/ds1302.h
deleted file mode 100644
index 15a6fad80c8..00000000000
--- a/src/emu/machine/ds1302.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Dallas DS1302 Trickle-Charge Timekeeping Chip emulation
-
-**********************************************************************
- _____ _____
- Vcc2 1 |* \_/ | 8 Vcc1
- X1 2 | | 7 SCLK
- X2 3 | | 6 I/O
- GND 4 |_____________| 5 CE
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __DS1302_H__
-#define __DS1302_H__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_DS1302_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, DS1302, _clock)
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> ds1302_device
-
-class ds1302_device : public device_t,
- public device_rtc_interface,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- ds1302_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_WRITE_LINE_MEMBER( ce_w );
- DECLARE_WRITE_LINE_MEMBER( sclk_w );
- DECLARE_WRITE_LINE_MEMBER( io_w );
- DECLARE_READ_LINE_MEMBER( io_r );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
- // device_rtc_interface overrides
- virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
- virtual bool rtc_feature_leap_year() { return true; }
-
-private:
- void load_shift_register();
- void input_bit();
- void output_bit();
-
- int m_ce;
- int m_clk;
- int m_io;
- int m_state;
- int m_bits;
- UINT8 m_cmd;
- UINT8 m_data;
- int m_addr;
-
- UINT8 m_reg[9];
- UINT8 m_user[9];
- UINT8 m_ram[0x20];
-
- // timers
- emu_timer *m_clock_timer;
-};
-
-
-// device type definition
-extern const device_type DS1302;
-
-
-
-#endif
diff --git a/src/emu/machine/ds1315.c b/src/emu/machine/ds1315.c
deleted file mode 100644
index 8470aaaaf9c..00000000000
--- a/src/emu/machine/ds1315.c
+++ /dev/null
@@ -1,277 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Lindner
-/*****************************************************************************************
-
- ds1315.c
-
- Dallas Semiconductor's Phantom Time Chip DS1315.
- NOTE: writes are decoded, but the host's time will always be returned when asked.
-
- April 2015: chip enable / chip reset / phantom writes by Karl-Ludwig Deisenhofer
-
- November 2001: implementation by Tim Lindner
-
- HOW DOES IT WORK?
-
- READS: pattern recognition (64 bits in correct order). When RTC finally enables
- 64 bits of data can be read. Chance of accidential pattern recognition is minimal.
-
- WRITES: two different locations (bits 0 and 1) are used to transfer data to the
- DS1315. 64 bit with time/date info are transmitted directly after recognition
- of the magic 64 bit pattern (see read above).
- **************************************************************************************/
-
-#include "ds1315.h"
-#include "coreutil.h"
-
-
-const device_type DS1315 = &device_creator<ds1315_device>;
-
-ds1315_device::ds1315_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, DS1315, "Dallas Semiconductor DS1315", tag, owner, clock, "ds1315", __FILE__)
-{
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void ds1315_device::device_config_complete()
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ds1315_device::device_start()
-{
- save_item(NAME(m_count));
- save_item(NAME(m_mode));
- save_item(NAME(m_raw_data));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ds1315_device::device_reset()
-{
- chip_reset();
-}
-
-
-
-/***************************************************************************
- LOCAL VARIABLES
-***************************************************************************/
-
-static const UINT8 ds1315_pattern[] =
-{
- 1, 0, 1, 0, 0, 0, 1, 1,
- 0, 1, 0, 1, 1, 1, 0, 0,
- 1, 1, 0, 0, 0, 1, 0, 1,
- 0, 0, 1, 1, 1, 0, 1, 0,
- 1, 0, 1, 0, 0, 0, 1, 1,
- 0, 1, 0, 1, 1, 1, 0, 0,
- 1, 1, 0, 0, 0, 1, 0, 1,
- 0, 0, 1, 1, 1, 0, 1, 0
-};
-
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-/*-------------------------------------------------
- read_0 (actual data)
- -------------------------------------------------*/
-
-READ8_MEMBER( ds1315_device::read_0 )
-{
- if (ds1315_pattern[m_count++] == 0)
- {
- if (m_count == 64)
- {
- /* entire pattern matched */
- m_count = 0;
- m_mode = DS_CALENDAR_IO;
- fill_raw_data();
- }
-
- return 0;
- }
-
- m_count = 0;
- m_mode = DS_SEEK_MATCHING;
- return 0;
-}
-
-
-/*-------------------------------------------------
- read_1 (actual data)
--------------------------------------------------*/
-
-READ8_MEMBER( ds1315_device::read_1 )
-{
- if (ds1315_pattern[m_count++] == 1)
- {
- m_count %= 64;
- return 0;
- }
-
- m_count = 0;
- m_mode = DS_SEEK_MATCHING;
- return 0;
-}
-
-
-/*-------------------------------------------------
- read_data
--------------------------------------------------*/
-
-READ8_MEMBER( ds1315_device::read_data )
-{
- UINT8 result;
-
- if (m_mode == DS_CALENDAR_IO)
- {
- result = m_raw_data[m_count++];
-
- if (m_count == 64)
- {
- m_mode = DS_SEEK_MATCHING;
- m_count = 0;
- }
-
- return result;
- }
-
- m_count = 0;
- return 0;
-}
-
-
-/*-------------------------------------------------
- fill_raw_data
--------------------------------------------------*/
-
-void ds1315_device::fill_raw_data()
-{
- /* This routine calls a standard 'C' library routine to get the current
- date and time and then fill in the raw data struct.
- */
-
- system_time systime;
- int raw[8], i, j;
-
- /* get the current date/time from the core */
- machine().current_datetime(systime);
-
- raw[0] = 0; /* tenths and hundreths of seconds are always zero */
- raw[1] = dec_2_bcd(systime.local_time.second);
- raw[2] = dec_2_bcd(systime.local_time.minute);
- raw[3] = dec_2_bcd(systime.local_time.hour);
-
- raw[4] = dec_2_bcd((systime.local_time.weekday != 0) ? systime.local_time.weekday : 7);
- raw[5] = dec_2_bcd(systime.local_time.mday);
- raw[6] = dec_2_bcd(systime.local_time.month + 1);
- raw[7] = dec_2_bcd(systime.local_time.year - 1900); /* Epoch is 1900 */
-
- /* Ok now we have the raw bcd bytes. Now we need to push them into our bit array */
-
- for (i = 0; i < 64; i++)
- {
- j = i / 8;
- m_raw_data[i] = (raw[j] & 0x0001);
- raw[j] = raw[j] >> 1;
- }
-}
-
-
-
-
-/*-------------------------------------------------
-write_data
--------------------------------------------------*/
-
-READ8_MEMBER(ds1315_device::write_data)
-{
- static int write_count;
- if (write_count >= 64)
- write_count = 0;
-
- if (m_mode == DS_CALENDAR_IO)
- {
- m_raw_data[write_count++] = offset & 0x01;
-
- if (write_count == 64)
- {
- write_count = 0;
-
- m_mode = DS_SEEK_MATCHING;
- m_count = 0;
- input_raw_data();
- }
- }
- return 0; // ignore
-}
-
-/*-------------------------------------------------
- ds1315_input_raw_data
-
- Routine is called when new date and time has
- been written to the clock chip. Currently we
- ignore setting the date and time in the clock
- chip.
--------------------------------------------------*/
-
-void ds1315_device::input_raw_data()
-{
- int raw[8], i, j=0;
- raw[0] = raw[1] = raw[2] = raw[3] = raw[4] = raw[5] = raw[6] = raw[7] = 0;
- UINT8 flag = 1;
-
- for (i = 0; i < 64; i++)
- {
- j = i / 8;
- if ((i % 8) == 0)
- flag = 1;
-
- if (m_raw_data[i] & 1)
- raw[j] |= flag;
- flag <<= 1;
- }
- raw[0] = bcd_2_dec(raw[0]); // hundreds of seconds
- raw[1] = bcd_2_dec(raw[1]); // seconds (often set to zero)
- raw[2] = bcd_2_dec(raw[2]); // minute
- raw[3] = bcd_2_dec(raw[3]); // hour
-
- raw[4] = bcd_2_dec(raw[4]); // weekday (10 for Friday ?!)
- raw[5] = bcd_2_dec(raw[5]); // mday
- raw[6] = bcd_2_dec(raw[6]); // month
- raw[7] = bcd_2_dec(raw[7]); // year (two digits)
-
- printf("\nDS1315 RTC INPUT (WILL BE IGNORED) mm/dd/yy hh:mm:ss - %02d/%02d/%02d %02d/%02d/%02d",
- raw[6], raw[5], raw[7], raw[3], raw[2], raw[1]
- );
-}
-
-/*-------------------------------------------------
- query and reset chip status
- -------------------------------------------------*/
-bool ds1315_device::chip_enable()
-{
- return (m_mode == DS_CALENDAR_IO);
-}
-
-// Set a defined state (important for pattern detection)
-void ds1315_device::chip_reset()
-{
- memset(m_raw_data, 0, sizeof(m_raw_data));
- m_count = 0;
- m_mode = DS_SEEK_MATCHING;
-}
diff --git a/src/emu/machine/ds1315.h b/src/emu/machine/ds1315.h
deleted file mode 100644
index 0d5a7abc802..00000000000
--- a/src/emu/machine/ds1315.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Lindner
-/*********************************************************************
-
- ds1315.h
-
- Dallas Semiconductor's Phantom Time Chip DS1315.
-
- by tim lindner, November 2001.
-
-*********************************************************************/
-
-#ifndef __DS1315_H__
-#define __DS1315_H__
-
-#include "emu.h"
-
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-enum ds1315_mode_t
-{
- DS_SEEK_MATCHING,
- DS_CALENDAR_IO
-};
-
-ALLOW_SAVE_TYPE(ds1315_mode_t);
-
-class ds1315_device : public device_t
-{
-public:
- ds1315_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~ds1315_device() {}
-
- DECLARE_READ8_MEMBER(read_0);
- DECLARE_READ8_MEMBER(read_1);
- DECLARE_READ8_MEMBER(read_data);
- DECLARE_READ8_MEMBER(write_data);
-
- bool chip_enable();
- void chip_reset();
-
-protected:
- // device-level overrides
- virtual void device_config_complete();
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
- ds1315_mode_t m_mode;
-
- void fill_raw_data();
- void input_raw_data();
-
- int m_count;
- UINT8 m_raw_data[8*8];
-};
-
-extern const device_type DS1315;
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_DS1315_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, DS1315, 0)
-
-
-#endif /* __DS1315_H__ */
diff --git a/src/emu/machine/ds2401.c b/src/emu/machine/ds2401.c
deleted file mode 100644
index 48182b2d2c3..00000000000
--- a/src/emu/machine/ds2401.c
+++ /dev/null
@@ -1,270 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
- * DS2401
- *
- * Dallas Semiconductor
- * Silicon Serial Number
- *
- */
-
-#include "emu.h"
-#include "machine/ds2401.h"
-
-#define VERBOSE_LEVEL 0
-
-inline void ds2401_device::verboselog(int n_level, const char *s_fmt, ...)
-{
- if(VERBOSE_LEVEL >= n_level)
- {
- va_list v;
- char buf[32768];
- va_start(v, s_fmt);
- vsprintf(buf, s_fmt, v);
- va_end(v);
- logerror("ds2401 %s %s: %s", tag(), machine().describe_context(), buf);
- }
-}
-
-// device type definition
-const device_type DS2401 = &device_creator<ds2401_device>;
-
-ds2401_device::ds2401_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, DS2401, "DS2401", tag, owner, clock, "ds2401", __FILE__)
-{
-}
-
-void ds2401_device::device_start()
-{
- t_samp = attotime::from_usec( 30);
- t_rdv = attotime::from_usec( 30);
- t_rstl = attotime::from_usec(480);
- t_pdh = attotime::from_usec( 30);
- t_pdl = attotime::from_usec(120);
-
- m_rx = true;
- m_tx = true;
-
- save_item(NAME(m_state));
- save_item(NAME(m_bit));
- save_item(NAME(m_byte));
- save_item(NAME(m_shift));
- save_item(NAME(m_rx));
- save_item(NAME(m_tx));
-
- m_timer_main = timer_alloc(TIMER_MAIN);
- m_timer_reset = timer_alloc(TIMER_RESET);
-}
-
-void ds2401_device::device_reset()
-{
- m_state = STATE_IDLE;
- m_bit = 0;
- m_byte = 0;
- m_shift = 0;
- m_rx = true;
- m_tx = true;
-
- if(m_region)
- {
- if(m_region->bytes() == SIZE_DATA)
- {
- memcpy(m_data, m_region->base(), SIZE_DATA);
- return;
- }
-
- logerror("ds2401 %s: Wrong region length for id data, expected 0x%x, got 0x%x\n", tag(), SIZE_DATA, m_region->bytes());
- }
- else
- {
- logerror("ds2401 %s: Warning, no id provided, answer will be all zeroes.\n", tag());
- }
-
- memset(m_data, 0, SIZE_DATA);
-}
-
-void ds2401_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch(id)
- {
- case TIMER_RESET:
- verboselog(1, "timer_reset\n");
- m_state = STATE_RESET;
- m_timer_reset->adjust(attotime::never);
- break;
-
- case TIMER_MAIN:
- switch(m_state)
- {
- case STATE_RESET1:
- verboselog(2, "timer_main state_reset1 %d\n", m_rx);
- m_tx = false;
- m_state = STATE_RESET2;
- m_timer_main->adjust(t_pdl);
- break;
-
- case STATE_RESET2:
- verboselog(2, "timer_main state_reset2 %d\n", m_rx);
- m_tx = true;
- m_bit = 0;
- m_shift = 0;
- m_state = STATE_COMMAND;
- break;
-
- case STATE_COMMAND:
- verboselog(2, "timer_main state_command %d\n", m_rx);
-
- m_shift >>= 1;
- if(m_rx)
- {
- m_shift |= 0x80;
- }
-
- m_bit++;
- if(m_bit == 8)
- {
- switch(m_shift)
- {
- case COMMAND_READROM:
- verboselog(1, "timer_main readrom\n");
- m_bit = 0;
- m_byte = 0;
- m_state = STATE_READROM;
- break;
-
- default:
- verboselog(0, "timer_main command not handled %02x\n", m_shift);
- m_state = STATE_IDLE;
- break;
- }
- }
- break;
-
- case STATE_READROM:
- m_tx = true;
-
- if( m_byte == SIZE_DATA )
- {
- verboselog(1, "timer_main readrom finished\n");
- m_state = STATE_IDLE;
- }
- else
- {
- verboselog(2, "timer_main readrom window closed\n");
- }
- break;
- default:
- verboselog(0, "timer_main state not handled: %d\n", m_state);
- break;
- }
- }
-}
-
-WRITE_LINE_MEMBER( ds2401_device::write )
-{
- verboselog(1, "write(%d)\n", state);
-
- if(!state && m_rx)
- {
- switch(m_state)
- {
- case STATE_IDLE:
- break;
-
- case STATE_COMMAND:
- verboselog(2, "state_command\n");
- m_timer_main->adjust(t_samp);
- break;
-
- case STATE_READROM:
- if(!m_bit)
- {
- m_shift = m_data[7 - m_byte];
- verboselog(1, "<- data %02x\n", m_shift);
- }
-
- m_tx = m_shift & 1;
- m_shift >>= 1;
-
- m_bit++;
- if(m_bit == 8)
- {
- m_bit = 0;
- m_byte++;
- }
-
- verboselog(2, "state_readrom %d\n", m_tx);
- m_timer_main->adjust(t_rdv);
- break;
-
- default:
- verboselog(0, "state not handled: %d\n", m_state );
- break;
- }
-
- m_timer_reset->adjust(t_rstl);
- }
- else if(state && !m_rx)
- {
- switch(m_state)
- {
- case STATE_RESET:
- m_state = STATE_RESET1;
- m_timer_main->adjust(t_pdh);
- break;
- }
-
- m_timer_reset->adjust(attotime::never);
- }
-
- m_rx = state;
-}
-
-READ_LINE_MEMBER( ds2401_device::read )
-{
- verboselog(2, "read %d\n", m_tx && m_rx);
- return m_tx && m_rx;
-}
-
-UINT8 ds2401_device::direct_read(int index)
-{
- return m_data[index];
-}
-
-/*
-
-app74.pdf
-
-Under normal circumstances an ibutton will sample the line 30us after the falling edge of the start condition.
-The internal time base of ibutton may deviate from its nominal value. The allowed tollerance band ranges from 15us to 60us.
-This means that the actual slave sampling may occur anywhere from 15 and 60us after the start condition, which is a ratio of 1 to 4.
-During this time frame the voltage on the data line must stay below Vilmax or above Vihmin.
-
-In the 1-Wire system, the logical values 1 and 0 are represented by certain voltages in special waveforms.
-The waveforms needed to write commands or data to ibuttons are called write-1 and write-0 time slots.
-The duration of a low pulse to write a 1 must be shorter than 15us.
-To write a 0, the duration of the low pulse must be at least 60us to cope with worst-case conditions.
-
-The duration of the active part of a time slot can be extended beyond 60us.
-The maximum extension is limited by the fact that a low pulse of a duration of at least eight active time slots ( 480us ) is defined as a Reset Pulse.
-Allowing the same worst-case tolerance ratio, a low pulse of 120us might be sufficient for a reset.
-This limits the extension of the active part of a time slot to a maximum of 120us to prevent misinterpretation with reset.
-
-Commands and data are sent to ibuttons by combining write-0 and write-1 time slots.
-To read data, the master has to generate read-data time slots to define the start condition of each bit.
-The read-data time slots looks essentially the same as a write-1 time slot from the masters point of view.
-Starting at the high-to-low transition, the ibuttons sends 1 bit of its addressed contents.
-If the data bit is a 1, the ibutton leaves the pulse unchanged.
-If the data bit is a 0, the ibutton will pull the data line low for 15us.
-In this time frame data is valid for reading by the master.
-The duration of the low pulse sent by the master should be a minimum of 1us with a maximum value as short as possible to maximize the master sampling window.
-
-The Reset Pulse provides a clear starting condition that supersedes any time slot synchronisation.
-It is defined as single low pulse of minimum duration of eight time slots or 480us followed by a Reset-high time tRSTH of another 480us.
-After a Reset Pulse has been sent, the ibutton will wait for the time tPDH and then generate a Pulse-Presence Pulse of duration tPDL.
-No other communication on the 1-Wire bus is allowed during tRSTH.
-
-There are 1,000 microseconds in a millisecond, and 1,000 milliseconds in a second.
-Thus, there are 1,000,000 microseconds in a second. Why is it "usec"?
-The "u" is supposed to look like the Greek letter Mu that we use for "micro". .
-*/
diff --git a/src/emu/machine/ds2401.h b/src/emu/machine/ds2401.h
deleted file mode 100644
index b8b1148dc37..00000000000
--- a/src/emu/machine/ds2401.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
- * DS2401
- *
- * Dallas Semiconductor
- * Silicon Serial Number
- *
- */
-
-#ifndef __DS2401_H__
-#define __DS2401_H__
-
-#define MCFG_DS2401_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, DS2401, 0)
-
-#include "emu.h"
-
-class ds2401_device : public device_t
-{
-public:
- // construction/destruction
- ds2401_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_WRITE_LINE_MEMBER( write );
- DECLARE_READ_LINE_MEMBER( read );
- UINT8 direct_read(int index);
-
-protected:
- enum {
- SIZE_DATA = 8,
-
- COMMAND_READROM = 0x33
- };
-
- enum {
- STATE_IDLE,
- STATE_RESET,
- STATE_RESET1,
- STATE_RESET2,
- STATE_COMMAND,
- STATE_READROM
- };
-
- enum {
- TIMER_MAIN,
- TIMER_RESET
- };
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // internal state
- int m_state, m_bit, m_shift;
- UINT8 m_byte;
- bool m_rx, m_tx;
- UINT8 m_data[SIZE_DATA];
- emu_timer *m_timer_main, *m_timer_reset;
- attotime t_samp, t_rdv, t_rstl, t_pdh, t_pdl;
-
-private:
- inline void verboselog(int n_level, const char *s_fmt, ...) ATTR_PRINTF(3,4);
-};
-
-
-// device type definition
-extern const device_type DS2401;
-
-#endif
diff --git a/src/emu/machine/ds2404.c b/src/emu/machine/ds2404.c
deleted file mode 100644
index 57f8fa62d8f..00000000000
--- a/src/emu/machine/ds2404.c
+++ /dev/null
@@ -1,405 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/**********************************************************************
-
- DALLAS DS2404
-
- RTC + BACKUP RAM
-
-**********************************************************************/
-
-#include "emu.h"
-#include "ds2404.h"
-#include <time.h>
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type DS2404 = &device_creator<ds2404_device>;
-
-//-------------------------------------------------
-// ds2404_device - constructor
-//-------------------------------------------------
-
-ds2404_device::ds2404_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, DS2404, "DS2404", tag, owner, clock, "ds2404", __FILE__),
- device_nvram_interface(mconfig, *this),
- m_address(0),
- m_offset(0),
- m_end_offset(0),
- m_a1(0),
- m_a2(0),
- m_state_ptr(0)
-{
- memset(m_ram, 0, sizeof(m_ram));
-}
-
-
-//-------------------------------------------------
-// static_set_ref_year - configuration helper
-// to set the reference year
-//-------------------------------------------------
-
-void ds2404_device::static_set_ref_year(device_t &device, UINT32 year)
-{
- ds2404_device &ds2404 = downcast<ds2404_device &>(device);
- ds2404.m_ref_year = year;
-}
-
-
-//-------------------------------------------------
-// static_set_ref_month - configuration helper
-// to set the reference month
-//-------------------------------------------------
-
-void ds2404_device::static_set_ref_month(device_t &device, UINT8 month)
-{
- ds2404_device &ds2404 = downcast<ds2404_device &>(device);
- ds2404.m_ref_month = month;
-}
-
-
-//-------------------------------------------------
-// static_set_ref_day - configuration helper
-// to set the reference day
-//-------------------------------------------------
-
-void ds2404_device::static_set_ref_day(device_t &device, UINT8 day)
-{
- ds2404_device &ds2404 = downcast<ds2404_device &>(device);
- ds2404.m_ref_day = day;
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ds2404_device::device_start()
-{
- struct tm ref_tm;
-
- memset(&ref_tm, 0, sizeof(ref_tm));
- ref_tm.tm_year = m_ref_year - 1900;
- ref_tm.tm_mon = m_ref_month - 1;
- ref_tm.tm_mday = m_ref_day;
-
- time_t ref_time = mktime(&ref_tm);
-
- time_t current_time;
- time(&current_time);
- current_time -= ref_time;
-
- m_rtc[0] = 0x0;
- m_rtc[1] = (current_time >> 0) & 0xff;
- m_rtc[2] = (current_time >> 8) & 0xff;
- m_rtc[3] = (current_time >> 16) & 0xff;
- m_rtc[4] = (current_time >> 24) & 0xff;
-
- for (int i = 0; i < 8; i++)
- m_state[i] = DS2404_STATE_IDLE;
-
- m_tick_timer = timer_alloc(0);
- m_tick_timer->adjust(attotime::from_hz(256), 0, attotime::from_hz(256));
-}
-
-
-void ds2404_device::ds2404_rom_cmd(UINT8 cmd)
-{
- switch(cmd)
- {
- case 0xcc: /* Skip ROM */
- m_state[0] = DS2404_STATE_COMMAND;
- m_state_ptr = 0;
- break;
-
- default:
- fatalerror("DS2404: Unknown ROM command %02X\n", cmd);
- }
-}
-
-void ds2404_device::ds2404_cmd(UINT8 cmd)
-{
- switch(cmd)
- {
- case 0x0f: /* Write scratchpad */
- m_state[0] = DS2404_STATE_ADDRESS1;
- m_state[1] = DS2404_STATE_ADDRESS2;
- m_state[2] = DS2404_STATE_INIT_COMMAND;
- m_state[3] = DS2404_STATE_WRITE_SCRATCHPAD;
- m_state_ptr = 0;
- break;
-
- case 0x55: /* Copy scratchpad */
- m_state[0] = DS2404_STATE_ADDRESS1;
- m_state[1] = DS2404_STATE_ADDRESS2;
- m_state[2] = DS2404_STATE_OFFSET;
- m_state[3] = DS2404_STATE_INIT_COMMAND;
- m_state[4] = DS2404_STATE_COPY_SCRATCHPAD;
- m_state_ptr = 0;
- break;
-
- case 0xf0: /* Read memory */
- m_state[0] = DS2404_STATE_ADDRESS1;
- m_state[1] = DS2404_STATE_ADDRESS2;
- m_state[2] = DS2404_STATE_INIT_COMMAND;
- m_state[3] = DS2404_STATE_READ_MEMORY;
- m_state_ptr = 0;
- break;
-
- default:
- fatalerror("DS2404: Unknown command %02X\n", cmd);
- }
-}
-
-UINT8 ds2404_device::ds2404_readmem()
-{
- if( m_address < 0x200 )
- {
- return m_sram[ m_address ];
- }
- else if( m_address >= 0x202 && m_address <= 0x206 )
- {
- return m_rtc[ m_address - 0x202 ];
- }
- return 0;
-}
-
-void ds2404_device::ds2404_writemem(UINT8 value)
-{
- if( m_address < 0x200 )
- {
- m_sram[ m_address ] = value;
- }
- else if( m_address >= 0x202 && m_address <= 0x206 )
- {
- m_rtc[ m_address - 0x202 ] = value;
- }
-}
-
-WRITE8_MEMBER( ds2404_device::ds2404_1w_reset_w )
-{
- m_state[0] = DS2404_STATE_IDLE;
- m_state_ptr = 0;
-}
-
-WRITE8_MEMBER( ds2404_device::ds2404_3w_reset_w )
-{
- m_state[0] = DS2404_STATE_COMMAND;
- m_state_ptr = 0;
-}
-
-READ8_MEMBER( ds2404_device::ds2404_data_r )
-{
- UINT8 value = 0;
- switch(m_state[m_state_ptr])
- {
- case DS2404_STATE_IDLE:
- case DS2404_STATE_COMMAND:
- case DS2404_STATE_ADDRESS1:
- case DS2404_STATE_ADDRESS2:
- case DS2404_STATE_OFFSET:
- case DS2404_STATE_INIT_COMMAND:
- break;
-
- case DS2404_STATE_READ_MEMORY:
- value = ds2404_readmem();
- break;
-
- case DS2404_STATE_READ_SCRATCHPAD:
- if(m_offset < 0x20)
- {
- value = m_ram[m_offset];
- m_offset++;
- }
- break;
-
- case DS2404_STATE_WRITE_SCRATCHPAD:
- break;
-
- case DS2404_STATE_COPY_SCRATCHPAD:
- break;
- }
- return value;
-}
-
-WRITE8_MEMBER( ds2404_device::ds2404_data_w )
-{
- switch( m_state[m_state_ptr] )
- {
- case DS2404_STATE_IDLE:
- ds2404_rom_cmd(data & 0xff);
- break;
-
- case DS2404_STATE_COMMAND:
- ds2404_cmd(data & 0xff);
- break;
-
- case DS2404_STATE_ADDRESS1:
- m_a1 = data & 0xff;
- m_state_ptr++;
- break;
-
- case DS2404_STATE_ADDRESS2:
- m_a2 = data & 0xff;
- m_state_ptr++;
- break;
-
- case DS2404_STATE_OFFSET:
- m_end_offset = data & 0xff;
- m_state_ptr++;
- break;
-
- case DS2404_STATE_INIT_COMMAND:
- break;
-
- case DS2404_STATE_READ_MEMORY:
- break;
-
- case DS2404_STATE_READ_SCRATCHPAD:
- break;
-
- case DS2404_STATE_WRITE_SCRATCHPAD:
- if( m_offset < 0x20 )
- {
- m_ram[m_offset] = data & 0xff;
- m_offset++;
- }
- else
- {
- /* Set OF flag */
- }
- break;
-
- case DS2404_STATE_COPY_SCRATCHPAD:
- break;
- }
-
- if( m_state[m_state_ptr] == DS2404_STATE_INIT_COMMAND )
- {
- switch( m_state[m_state_ptr + 1] )
- {
- case DS2404_STATE_IDLE:
- case DS2404_STATE_COMMAND:
- case DS2404_STATE_ADDRESS1:
- case DS2404_STATE_ADDRESS2:
- case DS2404_STATE_OFFSET:
- case DS2404_STATE_INIT_COMMAND:
- break;
-
- case DS2404_STATE_READ_MEMORY:
- m_address = (m_a2 << 8) | m_a1;
- m_address -= 1;
- break;
-
- case DS2404_STATE_WRITE_SCRATCHPAD:
- m_address = (m_a2 << 8) | m_a1;
- m_offset = m_address & 0x1f;
- break;
-
- case DS2404_STATE_READ_SCRATCHPAD:
- m_address = (m_a2 << 8) | m_a1;
- m_offset = m_address & 0x1f;
- break;
-
- case DS2404_STATE_COPY_SCRATCHPAD:
- m_address = (m_a2 << 8) | m_a1;
-
- for(int i = 0; i <= m_end_offset; i++)
- {
- ds2404_writemem(m_ram[i]);
- m_address++;
- }
- break;
- }
- m_state_ptr++;
- }
-}
-
-WRITE8_MEMBER( ds2404_device::ds2404_clk_w )
-{
- switch( m_state[m_state_ptr] )
- {
- case DS2404_STATE_IDLE:
- case DS2404_STATE_COMMAND:
- case DS2404_STATE_ADDRESS1:
- case DS2404_STATE_ADDRESS2:
- case DS2404_STATE_OFFSET:
- case DS2404_STATE_INIT_COMMAND:
- break;
-
- case DS2404_STATE_READ_MEMORY:
- m_address++;
- break;
-
- case DS2404_STATE_READ_SCRATCHPAD:
- break;
-
- case DS2404_STATE_WRITE_SCRATCHPAD:
- break;
-
- case DS2404_STATE_COPY_SCRATCHPAD:
- break;
- }
-}
-
-void ds2404_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch(id)
- {
- case 0:
- {
- // tick
- for(int i = 0; i < 5; i++)
- {
- m_rtc[ i ]++;
- if(m_rtc[ i ] != 0)
- {
- break;
- }
- }
-
- break;
- }
-
- default:
- assert_always(FALSE, "Unknown id in ds2404_device::device_timer");
- break;
- }
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void ds2404_device::nvram_default()
-{
- memset(m_sram, 0, sizeof(m_sram));
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void ds2404_device::nvram_read(emu_file &file)
-{
- file.read(m_sram, sizeof(m_sram));
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void ds2404_device::nvram_write(emu_file &file)
-{
- file.write(m_sram, sizeof(m_sram));
-}
diff --git a/src/emu/machine/ds2404.h b/src/emu/machine/ds2404.h
deleted file mode 100644
index 31ff35a99a6..00000000000
--- a/src/emu/machine/ds2404.h
+++ /dev/null
@@ -1,129 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/**********************************************************************
-
- DALLAS DS2404
-
- RTC + BACKUP RAM
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __DS2404_H__
-#define __DS2404_H__
-
-#include "emu.h"
-
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_DS2404_ADD(_tag, _ref_year, _ref_month, _ref_day) \
- MCFG_DEVICE_ADD(_tag, DS2404, 0) \
- MCFG_DS2404_REF_YEAR(_ref_year) \
- MCFG_DS2404_REF_MONTH(_ref_month) \
- MCFG_DS2404_REF_DAY(_ref_day)
-
-#define MCFG_DS2404_REF_YEAR(_ref_year) \
- ds2404_device::static_set_ref_year(*device, _ref_year);
-
-#define MCFG_DS2404_REF_MONTH(_ref_month) \
- ds2404_device::static_set_ref_month(*device, _ref_month);
-
-#define MCFG_DS2404_REF_DAY(_ref_day) \
- ds2404_device::static_set_ref_day(*device, _ref_day);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-// ======================> ds2404_device
-
-class ds2404_device : public device_t,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- ds2404_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // inline configuration helpers
- static void static_set_ref_year(device_t &device, UINT32 m_ref_year);
- static void static_set_ref_month(device_t &device, UINT8 m_ref_month);
- static void static_set_ref_day(device_t &device, UINT8 m_ref_day);
-
- /* 1-wire interface reset */
- DECLARE_WRITE8_MEMBER(ds2404_1w_reset_w);
-
- /* 3-wire interface reset */
- DECLARE_WRITE8_MEMBER(ds2404_3w_reset_w);
-
- DECLARE_READ8_MEMBER(ds2404_data_r);
- DECLARE_WRITE8_MEMBER(ds2404_data_w);
- DECLARE_WRITE8_MEMBER(ds2404_clk_w);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset() { }
- virtual void device_post_load() { }
- virtual void device_clock_changed() { }
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
-
- void ds2404_rom_cmd(UINT8 cmd);
- void ds2404_cmd(UINT8 cmd);
-
- UINT8 ds2404_readmem();
- void ds2404_writemem(UINT8 value);
-
- enum DS2404_STATE
- {
- DS2404_STATE_IDLE = 1, /* waiting for ROM command, in 1-wire mode */
- DS2404_STATE_COMMAND, /* waiting for memory command */
- DS2404_STATE_ADDRESS1, /* waiting for address bits 0-7 */
- DS2404_STATE_ADDRESS2, /* waiting for address bits 8-15 */
- DS2404_STATE_OFFSET, /* waiting for ending offset */
- DS2404_STATE_INIT_COMMAND,
- DS2404_STATE_READ_MEMORY, /* Read Memory command active */
- DS2404_STATE_WRITE_SCRATCHPAD, /* Write Scratchpad command active */
- DS2404_STATE_READ_SCRATCHPAD, /* Read Scratchpad command active */
- DS2404_STATE_COPY_SCRATCHPAD /* Copy Scratchpad command active */
- };
-
- emu_timer *m_tick_timer;
-
- // configuration state
- UINT32 m_ref_year;
- UINT8 m_ref_month;
- UINT8 m_ref_day;
-
- UINT16 m_address;
- UINT16 m_offset;
- UINT16 m_end_offset;
- UINT8 m_a1;
- UINT8 m_a2;
- UINT8 m_sram[512]; /* 4096 bits */
- UINT8 m_ram[32]; /* scratchpad ram, 256 bits */
- UINT8 m_rtc[5]; /* 40-bit RTC counter */
- DS2404_STATE m_state[8];
- int m_state_ptr;
-};
-
-
-// device type definition
-extern const device_type DS2404;
-
-
-#endif /* __DS2404_H__ */
diff --git a/src/emu/machine/ds75160a.c b/src/emu/machine/ds75160a.c
deleted file mode 100644
index 1560fa4f0b2..00000000000
--- a/src/emu/machine/ds75160a.c
+++ /dev/null
@@ -1,111 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- National Semiconductor DS75160A IEEE-488 GPIB Transceiver emulation
-
-**********************************************************************/
-
-#include "ds75160a.h"
-
-
-
-//**************************************************************************
-// DEVICE TYPE DEFINITIONS
-//**************************************************************************
-
-const device_type DS75160A = &device_creator<ds75160a_device>;
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// ds75160a_device - constructor
-//-------------------------------------------------
-
-ds75160a_device::ds75160a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, DS75160A, "DS75160A", tag, owner, clock, "ds75160a", __FILE__),
- m_read(*this),
- m_write(*this),
- m_data(0xff),
- m_te(0),
- m_pe(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ds75160a_device::device_start()
-{
- // resolve callbacks
- m_read.resolve_safe(0);
- m_write.resolve_safe();
-
- // register for state saving
- save_item(NAME(m_data));
- save_item(NAME(m_te));
- save_item(NAME(m_pe));
-}
-
-
-//-------------------------------------------------
-// read - read data bus
-//-------------------------------------------------
-
-READ8_MEMBER( ds75160a_device::read )
-{
- UINT8 data = 0;
-
- if (!m_te)
- {
- data = m_read(0);
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write - write data bus
-//-------------------------------------------------
-
-WRITE8_MEMBER( ds75160a_device::write )
-{
- m_data = data;
-
- if (m_te)
- {
- m_write((offs_t)0, m_data);
- }
-}
-
-
-//-------------------------------------------------
-// te_w - transmit enable
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds75160a_device::te_w )
-{
- if (m_te != state)
- {
- m_write((offs_t)0, m_te ? m_data : 0xff);
- }
-
- m_te = state;
-}
-
-
-//-------------------------------------------------
-// pe_w - parallel enable
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds75160a_device::pe_w )
-{
- m_pe = state;
-}
diff --git a/src/emu/machine/ds75160a.h b/src/emu/machine/ds75160a.h
deleted file mode 100644
index d3ca0b38de6..00000000000
--- a/src/emu/machine/ds75160a.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- National Semiconductor DS75160A IEEE-488 GPIB Transceiver emulation
-
-**********************************************************************
- _____ _____
- TE 1 |* \_/ | 20 Vcc
- D1 2 | | 19 D1
- D2 3 | | 18 D2
- D3 4 | | 17 D3
- D4 5 | DS75160A | 16 D4
- D5 6 | | 15 D5
- D6 7 | | 14 D6
- D7 8 | | 13 D7
- D8 8 | | 12 D8
- GND 10 |_____________| 11 PE
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __DS75160A__
-#define __DS75160A__
-
-#include "emu.h"
-
-
-
-///*************************************************************************
-// INTERFACE CONFIGURATION MACROS
-///*************************************************************************
-
-#define MCFG_DS75160A_ADD(_tag, _read, _write) \
- MCFG_DEVICE_ADD(_tag, DS75160A, 0) \
- downcast<ds75160a_device *>(device)->set_callbacks(DEVCB_##_read, DEVCB_##_write);
-
-
-
-///*************************************************************************
-// TYPE DEFINITIONS
-///*************************************************************************
-
-// ======================> ds75160a_device
-
-class ds75160a_device : public device_t
-{
-public:
- // construction/destruction
- ds75160a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _read, class _write> void set_callbacks(_read rd, _write wr) {
- m_read.set_callback(rd);
- m_write.set_callback(wr);
- }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( te_w );
- DECLARE_WRITE_LINE_MEMBER( pe_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
-
-private:
- devcb_read8 m_read;
- devcb_write8 m_write;
-
- UINT8 m_data;
-
- int m_te;
- int m_pe;
-};
-
-
-// device type definition
-extern const device_type DS75160A;
-
-
-
-#endif
diff --git a/src/emu/machine/ds75161a.c b/src/emu/machine/ds75161a.c
deleted file mode 100644
index 5ec21a0e003..00000000000
--- a/src/emu/machine/ds75161a.c
+++ /dev/null
@@ -1,353 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- National Semiconductor DS75161A IEEE-488 GPIB Transceiver emulation
-
-**********************************************************************/
-
-#include "ds75161a.h"
-
-
-
-//**************************************************************************
-// DEVICE TYPE DEFINITIONS
-//**************************************************************************
-
-const device_type DS75161A = &device_creator<ds75161a_device>;
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// ds75161a_device - constructor
-//-------------------------------------------------
-
-ds75161a_device::ds75161a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, DS75161A, "DS75161A", tag, owner, clock, "ds75161a", __FILE__),
- m_in_ren_cb(*this),
- m_in_ifc_cb(*this),
- m_in_ndac_cb(*this),
- m_in_nrfd_cb(*this),
- m_in_dav_cb(*this),
- m_in_eoi_cb(*this),
- m_in_atn_cb(*this),
- m_in_srq_cb(*this),
- m_out_ren_cb(*this),
- m_out_ifc_cb(*this),
- m_out_ndac_cb(*this),
- m_out_nrfd_cb(*this),
- m_out_dav_cb(*this),
- m_out_eoi_cb(*this),
- m_out_atn_cb(*this),
- m_out_srq_cb(*this),
- m_ren(1),
- m_ifc(1),
- m_ndac(1),
- m_nrfd(1),
- m_dav(1),
- m_eoi(1),
- m_atn(1),
- m_srq(1),
- m_te(0),
- m_dc(0)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ds75161a_device::device_start()
-{
- // resolve callbacks
- m_in_ren_cb.resolve_safe(0);
- m_in_ifc_cb.resolve_safe(0);
- m_in_ndac_cb.resolve_safe(0);
- m_in_nrfd_cb.resolve_safe(0);
- m_in_dav_cb.resolve_safe(0);
- m_in_eoi_cb.resolve_safe(0);
- m_in_atn_cb.resolve_safe(0);
- m_in_srq_cb.resolve_safe(0);
-
- m_out_ren_cb.resolve_safe();
- m_out_ifc_cb.resolve_safe();
- m_out_ndac_cb.resolve_safe();
- m_out_nrfd_cb.resolve_safe();
- m_out_dav_cb.resolve_safe();
- m_out_eoi_cb.resolve_safe();
- m_out_atn_cb.resolve_safe();
- m_out_srq_cb.resolve_safe();
-
- // register for state saving
- save_item(NAME(m_ren));
- save_item(NAME(m_ifc));
- save_item(NAME(m_ndac));
- save_item(NAME(m_nrfd));
- save_item(NAME(m_dav));
- save_item(NAME(m_eoi));
- save_item(NAME(m_atn));
- save_item(NAME(m_srq));
- save_item(NAME(m_te));
- save_item(NAME(m_dc));
-}
-
-
-//-------------------------------------------------
-// update_signals -
-//-------------------------------------------------
-
-void ds75161a_device::update_signals()
-{
- m_out_ren_cb(m_dc ? 1 : m_ren);
- m_out_ifc_cb(m_dc ? 1 : m_ifc);
- m_out_ndac_cb(m_te ? 1 : m_ndac);
- m_out_nrfd_cb(m_te ? 1 : m_nrfd);
- m_out_dav_cb(m_te ? m_dav : 1);
- m_out_atn_cb(m_dc ? 1 : m_atn);
- m_out_srq_cb(m_dc ? m_srq : 1 );
-
- int atn = m_in_atn_cb();
-
- if (m_te && atn) m_out_eoi_cb(m_eoi);
- else if (!m_dc && !atn) m_out_eoi_cb(m_eoi);
- else m_out_eoi_cb(1);
-}
-
-
-//-------------------------------------------------
-// te_w - transmit enable
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds75161a_device::te_w )
-{
- if (m_te != state)
- {
- m_te = state;
-
- update_signals();
- }
-}
-
-
-//-------------------------------------------------
-// dc_w - direction control
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds75161a_device::dc_w )
-{
- if (m_dc != state)
- {
- m_dc = state;
-
- update_signals();
- }
-}
-
-
-//-------------------------------------------------
-// ren_r - remote enable read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( ds75161a_device::ren_r )
-{
- return m_dc ? m_in_ren_cb() : 0;
-}
-
-
-//-------------------------------------------------
-// ifc_r - interface clear read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( ds75161a_device::ifc_r )
-{
- return m_dc ? m_in_ifc_cb() : 0;
-}
-
-
-//-------------------------------------------------
-// ndac_r - not data acknowledge read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( ds75161a_device::ndac_r )
-{
- return m_te ? m_in_ndac_cb() : 0;
-}
-
-
-//-------------------------------------------------
-// nrfd_r - not ready for data read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( ds75161a_device::nrfd_r )
-{
- return m_te ? m_in_nrfd_cb() : 0;
-}
-
-
-//-------------------------------------------------
-// dav_r - data valid read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( ds75161a_device::dav_r )
-{
- return m_te ? 0 : m_in_dav_cb();
-}
-
-
-//-------------------------------------------------
-// eoi_r - end or identify read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( ds75161a_device::eoi_r )
-{
- int atn = m_in_atn_cb();
- int eoi = m_in_eoi_cb();
-
- if (!m_te && atn) return eoi;
- else if (m_dc && !atn) return eoi;
- else return 0;
-}
-
-
-//-------------------------------------------------
-// atn_r - attention read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( ds75161a_device::atn_r )
-{
- return m_dc ? m_in_atn_cb() : 0;
-}
-
-
-//-------------------------------------------------
-// srq_r - service request read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( ds75161a_device::srq_r )
-{
- return m_dc ? 0 : m_in_srq_cb();
-}
-
-
-//-------------------------------------------------
-// ren_w - remote enable write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds75161a_device::ren_w )
-{
- if (m_ren != state)
- {
- m_ren = state;
-
- update_signals();
- }
-}
-
-
-//-------------------------------------------------
-// ifc_w - interface clear write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds75161a_device::ifc_w )
-{
- if (m_ifc != state)
- {
- m_ifc = state;
-
- update_signals();
- }
-}
-
-
-//-------------------------------------------------
-// ndac_w - not data acknowledge write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds75161a_device::ndac_w )
-{
- if (m_ndac != state)
- {
- m_ndac = state;
-
- update_signals();
- }
-}
-
-
-//-------------------------------------------------
-// nrfd_w - not ready for data write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds75161a_device::nrfd_w )
-{
- if (m_nrfd != state)
- {
- m_nrfd = state;
-
- update_signals();
- }
-}
-
-
-//-------------------------------------------------
-// dav_w - data valid write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds75161a_device::dav_w )
-{
- if (m_dav != state)
- {
- m_dav = state;
-
- update_signals();
- }
-}
-
-
-//-------------------------------------------------
-// eoi_w - end or identify write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds75161a_device::eoi_w )
-{
- if (m_eoi != state)
- {
- m_eoi = state;
-
- update_signals();
- }
-}
-
-
-//-------------------------------------------------
-// atn_w - attention write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds75161a_device::atn_w )
-{
- if (m_atn != state)
- {
- m_atn = state;
-
- update_signals();
- }
-}
-
-
-//-------------------------------------------------
-// srq_w - service request write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( ds75161a_device::srq_w )
-{
- if (m_srq != state)
- {
- m_srq = state;
-
- update_signals();
- }
-}
diff --git a/src/emu/machine/ds75161a.h b/src/emu/machine/ds75161a.h
deleted file mode 100644
index 83f129857e6..00000000000
--- a/src/emu/machine/ds75161a.h
+++ /dev/null
@@ -1,177 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- National Semiconductor DS75161A IEEE-488 GPIB Transceiver emulation
-
-**********************************************************************
- _____ _____
- TE 1 |* \_/ | 20 Vcc
- REN 2 | | 19 REN
- IFC 3 | | 18 IFC
- NDAC 4 | | 17 NDAC
- NRFD 5 | DS75161A | 16 NRFD
- DAV 6 | | 15 DAV
- EOI 7 | | 14 EOI
- ATN 8 | | 13 ATN
- SRQ 8 | | 12 SRQ
- GND 10 |_____________| 11 DC
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __DS75161A__
-#define __DS75161A__
-
-#include "emu.h"
-
-
-
-///*************************************************************************
-// INTERFACE CONFIGURATION MACROS
-///*************************************************************************
-
-#define MCFG_DS75161A_IN_REN_CB(_devcb) \
- devcb = &ds75161a_device::set_in_ren_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_IN_IFC_CB(_devcb) \
- devcb = &ds75161a_device::set_in_ifc_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_IN_NDAC_CB(_devcb) \
- devcb = &ds75161a_device::set_in_ndac_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_IN_NRFD_CB(_devcb) \
- devcb = &ds75161a_device::set_in_nrfd_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_IN_DAV_CB(_devcb) \
- devcb = &ds75161a_device::set_in_dav_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_IN_EOI_CB(_devcb) \
- devcb = &ds75161a_device::set_in_eoi_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_IN_ATN_CB(_devcb) \
- devcb = &ds75161a_device::set_in_atn_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_IN_SRQ_CB(_devcb) \
- devcb = &ds75161a_device::set_in_srq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_OUT_REN_CB(_devcb) \
- devcb = &ds75161a_device::set_out_ren_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_OUT_IFC_CB(_devcb) \
- devcb = &ds75161a_device::set_out_ifc_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_OUT_NDAC_CB(_devcb) \
- devcb = &ds75161a_device::set_out_ndac_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_OUT_NRFD_CB(_devcb) \
- devcb = &ds75161a_device::set_out_nrfd_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_OUT_DAV_CB(_devcb) \
- devcb = &ds75161a_device::set_out_dav_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_OUT_EOI_CB(_devcb) \
- devcb = &ds75161a_device::set_out_eoi_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_OUT_ATN_CB(_devcb) \
- devcb = &ds75161a_device::set_out_atn_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_DS75161A_OUT_SRQ_CB(_devcb) \
- devcb = &ds75161a_device::set_out_srq_callback(*device, DEVCB_##_devcb);
-
-///*************************************************************************
-// TYPE DEFINITIONS
-///*************************************************************************
-
-// ======================> ds75161a_device
-
-class ds75161a_device : public device_t
-{
-public:
- // construction/destruction
- ds75161a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_in_ren_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_in_ren_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_ifc_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_in_ifc_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_ndac_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_in_ndac_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_nrfd_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_in_nrfd_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_dav_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_in_dav_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_eoi_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_in_eoi_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_atn_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_in_atn_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_srq_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_in_srq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_ren_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_out_ren_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_ifc_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_out_ifc_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_ndac_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_out_ndac_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_nrfd_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_out_nrfd_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dav_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_out_dav_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_eoi_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_out_eoi_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_atn_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_out_atn_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_srq_callback(device_t &device, _Object object) { return downcast<ds75161a_device &>(device).m_out_srq_cb.set_callback(object); }
-
- DECLARE_WRITE_LINE_MEMBER( te_w );
- DECLARE_WRITE_LINE_MEMBER( dc_w );
-
- DECLARE_READ_LINE_MEMBER( ren_r );
- DECLARE_READ_LINE_MEMBER( ifc_r );
- DECLARE_READ_LINE_MEMBER( ndac_r );
- DECLARE_READ_LINE_MEMBER( nrfd_r );
- DECLARE_READ_LINE_MEMBER( dav_r );
- DECLARE_READ_LINE_MEMBER( eoi_r );
- DECLARE_READ_LINE_MEMBER( atn_r );
- DECLARE_READ_LINE_MEMBER( srq_r );
-
- DECLARE_WRITE_LINE_MEMBER( ren_w );
- DECLARE_WRITE_LINE_MEMBER( ifc_w );
- DECLARE_WRITE_LINE_MEMBER( ndac_w );
- DECLARE_WRITE_LINE_MEMBER( nrfd_w );
- DECLARE_WRITE_LINE_MEMBER( dav_w );
- DECLARE_WRITE_LINE_MEMBER( eoi_w );
- DECLARE_WRITE_LINE_MEMBER( atn_w );
- DECLARE_WRITE_LINE_MEMBER( srq_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
-
-private:
- void update_signals();
-
- devcb_read_line m_in_ren_cb;
- devcb_read_line m_in_ifc_cb;
- devcb_read_line m_in_ndac_cb;
- devcb_read_line m_in_nrfd_cb;
- devcb_read_line m_in_dav_cb;
- devcb_read_line m_in_eoi_cb;
- devcb_read_line m_in_atn_cb;
- devcb_read_line m_in_srq_cb;
-
- devcb_write_line m_out_ren_cb;
- devcb_write_line m_out_ifc_cb;
- devcb_write_line m_out_ndac_cb;
- devcb_write_line m_out_nrfd_cb;
- devcb_write_line m_out_dav_cb;
- devcb_write_line m_out_eoi_cb;
- devcb_write_line m_out_atn_cb;
- devcb_write_line m_out_srq_cb;
-
- int m_ren;
- int m_ifc;
- int m_ndac;
- int m_nrfd;
- int m_dav;
- int m_eoi;
- int m_atn;
- int m_srq;
-
- int m_te;
- int m_dc;
-};
-
-
-// device type definition
-extern const device_type DS75161A;
-
-
-
-#endif
diff --git a/src/emu/machine/e0516.c b/src/emu/machine/e0516.c
deleted file mode 100644
index 0fc743ba95c..00000000000
--- a/src/emu/machine/e0516.c
+++ /dev/null
@@ -1,198 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Microelectronic-Marin E050-16 Real Time Clock emulation
-
-**********************************************************************/
-
-#include "emu.h"
-#include "e0516.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-// states
-enum
-{
- STATE_ADDRESS = 0,
- STATE_DATA
-};
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type E0516 = &device_creator<e0516_device>;
-
-//-------------------------------------------------
-// e0516_device - constructor
-//-------------------------------------------------
-
-e0516_device::e0516_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, E0516, "E05-16", tag, owner, clock, "e0516", __FILE__),
- device_rtc_interface(mconfig, *this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void e0516_device::device_start()
-{
- // allocate timers
- m_timer = timer_alloc();
- m_timer->adjust(attotime::from_hz(clock() / 32768), 0, attotime::from_hz(clock() / 32768));
-
- // state saving
- save_item(NAME(m_cs));
- save_item(NAME(m_clk));
- save_item(NAME(m_data_latch));
- save_item(NAME(m_reg_latch));
- save_item(NAME(m_read_write));
- save_item(NAME(m_state));
- save_item(NAME(m_bits));
- save_item(NAME(m_dio));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void e0516_device::device_reset()
-{
- set_current_time(machine());
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void e0516_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- advance_seconds();
-}
-
-
-//-------------------------------------------------
-// cs_w - chip select input
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( e0516_device::cs_w )
-{
- if (LOG) logerror("E05-16 '%s' CS %u\n", tag(), state);
-
- m_cs = state;
-
- if (m_cs)
- {
- m_data_latch = 0;
- m_reg_latch = 0;
- m_bits = 0;
- m_state = STATE_ADDRESS;
- }
-}
-
-
-//-------------------------------------------------
-// clk_w - serial clock input
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( e0516_device::clk_w )
-{
- if (LOG) logerror("E05-16 '%s' CLK %u\n", tag(), state);
-
- m_clk = state;
-
- if (m_cs || m_clk) return;
-
- m_bits++;
-
- if (m_state == STATE_ADDRESS)
- {
- if (LOG) logerror("E05-16 '%s' Command Bit %u\n", tag(), m_dio);
-
- // command
- m_reg_latch |= m_dio << 3;
- m_reg_latch >>= 1;
-
- if (m_bits == 4)
- {
- m_state = STATE_DATA;
- m_bits = 0;
-
- if (BIT(m_reg_latch, 0))
- {
- // load register value to data latch
- m_data_latch = convert_to_bcd(get_clock_register(m_reg_latch >> 1));
- }
- }
- }
- else
- {
- // data
- if (BIT(m_reg_latch, 0))
- {
- // read
- if (LOG) logerror("E05-16 '%s' Data Bit OUT %u\n", tag(), m_dio);
-
- m_dio = BIT(m_data_latch, 0);
- m_data_latch >>= 1;
- }
- else
- {
- // write
- if (LOG) logerror("E05-16 '%s' Data Bit IN %u\n", tag(), m_dio);
-
- m_data_latch |= m_dio << 7;
- m_data_latch >>= 1;
- }
-
- if (m_bits == 8)
- {
- m_state = STATE_ADDRESS;
- m_bits = 0;
-
- if (!BIT(m_reg_latch, 0))
- {
- // write latched data to register
- set_clock_register(m_reg_latch >> 1, bcd_to_integer(m_data_latch));
- }
- }
- }
-}
-
-
-//-------------------------------------------------
-// dio_w - serial data input
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( e0516_device::dio_w )
-{
- if (LOG) logerror("E05-16 '%s' DIO %u\n", tag(), state);
-
- m_dio = state;
-}
-
-
-//-------------------------------------------------
-// do_r - serial data output
-//-------------------------------------------------
-
-READ_LINE_MEMBER( e0516_device::dio_r )
-{
- return m_dio;
-}
diff --git a/src/emu/machine/e0516.h b/src/emu/machine/e0516.h
deleted file mode 100644
index 8adcdc75948..00000000000
--- a/src/emu/machine/e0516.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Microelectronic-Marin E050-16 Real Time Clock emulation
-
-**********************************************************************
- _____ _____
- Vdd1 1 |* \_/ | 16 Vdd2
- OSC IN 2 | | 15 Clk
- OSC OUT 3 | | 14 XOUT
- _STOP 4 | E05-16 | 13 DI/O
- _RESET 5 | E050-16 | 12 _SEC
- _OUTSEL 6 | | 11 _MIN
- _DAY 7 | | 10 _HRS
- Vss 8 |_____________| 9 _CS
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __E0516__
-#define __E0516__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_E0516_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, E0516, _clock)
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> e0516_device
-
-class e0516_device : public device_t,
- public device_rtc_interface
-{
-public:
- // construction/destruction
- e0516_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_WRITE_LINE_MEMBER( cs_w );
- DECLARE_WRITE_LINE_MEMBER( clk_w );
- DECLARE_WRITE_LINE_MEMBER( dio_w );
- DECLARE_READ_LINE_MEMBER( dio_r );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- int m_cs; // chip select
- int m_clk; // clock
- int m_data_latch; // data latch
- int m_reg_latch; // register latch
- int m_read_write; // read/write data
- int m_state; // state
- int m_bits; // number of bits transferred
- int m_dio; // data pin
-
- // timers
- emu_timer *m_timer;
-};
-
-
-// device type definition
-extern const device_type E0516;
-
-
-
-#endif
diff --git a/src/emu/machine/e05a03.c b/src/emu/machine/e05a03.c
deleted file mode 100644
index 258c3d1ca0b..00000000000
--- a/src/emu/machine/e05a03.c
+++ /dev/null
@@ -1,188 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- E05A03 Gate Array (used in the Epson LX-800)
-
-***************************************************************************/
-
-#include "emu.h"
-#include "e05a03.h"
-
-
-/*****************************************************************************
- DEVICE INTERFACE
-*****************************************************************************/
-
-const device_type E05A03 = &device_creator<e05a03_device>;
-
-e05a03_device::e05a03_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, E05A03, "E05A03", tag, owner, clock, "e05a03", __FILE__),
- m_write_nlq_lp(*this),
- m_write_pe_lp(*this),
- m_write_reso(*this),
- m_write_pe(*this),
- m_read_data(*this),
- m_shift(0),
- m_busy_leading(0),
- m_busy_software(0),
- m_nlqlp(0),
- m_cndlp(0),
- #if 0
- m_pe(0),
- m_pelp(0),
- #endif
- m_printhead(0),
- m_pf_motor(0),
- m_cr_motor(0)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void e05a03_device::device_start()
-{
- /* resolve callbacks */
- m_write_nlq_lp.resolve_safe();
- m_write_pe_lp.resolve_safe();
- m_write_reso.resolve_safe();
- m_write_pe.resolve_safe();
- m_read_data.resolve_safe(0);
-
- /* register for state saving */
- save_item(NAME(m_shift));
- save_item(NAME(m_busy_leading));
- save_item(NAME(m_busy_software));
- save_item(NAME(m_nlqlp));
- save_item(NAME(m_cndlp));
- #if 0
- save_item(NAME(m_pe));
- save_item(NAME(m_pelp));
- #endif
- save_item(NAME(m_printhead));
- save_item(NAME(m_pf_motor));
- save_item(NAME(m_cr_motor));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void e05a03_device::device_reset()
-{
- m_printhead = 0x00;
- m_pf_motor = 0x00;
- m_cr_motor = 0x0f;
-
- m_write_pe(0);
- m_write_pe_lp(1);
-
- m_busy_software = 1;
- m_nlqlp = 1;
- m_cndlp = 1;
-}
-
-
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-WRITE8_MEMBER( e05a03_device::write )
-{
- logerror("%s: e05a03_w(%02x): %02x\n", space.machine().describe_context(), offset, data);
-
- switch (offset)
- {
- /* shift register */
- case 0x00: m_shift = (m_shift & 0x00ffff) | (data << 16); break;
- case 0x01: m_shift = (m_shift & 0xff00ff) | (data << 8); break;
- case 0x02: m_shift = (m_shift & 0xffff00) | (data << 0); break;
-
- case 0x03:
- m_busy_leading = BIT(data, 7);
- m_busy_software = BIT(data, 6);
- m_nlqlp = BIT(data, 4);
- m_cndlp = BIT(data, 3);
-
- m_write_pe(BIT(data, 2));
- m_write_pe_lp(!BIT(data, 2));
-
-#if 0
- m_pe = BIT(data, 2);
- m_pelp = !BIT(data, 2);
-#endif
-
- break;
-
- /* printhead */
- case 0x04: m_printhead = (m_printhead & 0x100) | !data; break;
- case 0x05: m_printhead = (m_printhead & 0x0ff) | (!(BIT(data, 7) << 8)); break;
-
- /* paper feed and carriage motor phase data*/
- case 0x06: m_pf_motor = (data & 0xf0) >> 4; break;
- case 0x07: m_cr_motor = (data & 0x0f) >> 0; break;
- }
-}
-
-READ8_MEMBER( e05a03_device::read )
-{
- UINT8 result = 0;
-
- logerror("%s: e05a03_r(%02x)\n", space.machine().describe_context(), offset);
-
- switch (offset)
- {
- case 0x00:
- break;
-
- case 0x01:
- break;
-
- case 0x02:
- result = m_read_data(0);
- break;
-
- case 0x03:
- result |= BIT(m_shift, 23) << 7;
- m_shift <<= 1;
- break;
- }
-
- return result;
-}
-
-/* home position signal */
-WRITE_LINE_MEMBER( e05a03_device::home_w )
-{
-}
-
-/* printhead solenoids trigger */
-WRITE_LINE_MEMBER( e05a03_device::fire_w )
-{
-}
-
-WRITE_LINE_MEMBER( e05a03_device::strobe_w )
-{
-}
-
-READ_LINE_MEMBER( e05a03_device::busy_r )
-{
- return 1;
-}
-
-WRITE_LINE_MEMBER( e05a03_device::resi_w )
-{
- if (!state)
- {
- device_reset();
- m_write_reso(1);
- }
-}
-
-WRITE_LINE_MEMBER( e05a03_device::init_w )
-{
- resi_w(state);
-}
diff --git a/src/emu/machine/e05a03.h b/src/emu/machine/e05a03.h
deleted file mode 100644
index 03fa2aca98a..00000000000
--- a/src/emu/machine/e05a03.h
+++ /dev/null
@@ -1,99 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- E05A03 Gate Array (used in the Epson LX-800)
-
-***************************************************************************/
-
-#ifndef __E05A03_H__
-#define __E05A03_H__
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_E05A03_NLQ_LP_CALLBACK(_write) \
- devcb = &e05a03_device::set_nlq_lp_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_E05A03_PE_LP_CALLBACK(_write) \
- devcb = &e05a03_device::set_pe_lp_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_E05A03_RESO_CALLBACK(_write) \
- devcb = &e05a03_device::set_reso_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_E05A03_PE_CALLBACK(_write) \
- devcb = &e05a03_device::set_pe_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_E05A03_DATA_CALLBACK(_read) \
- devcb = &e05a03_device::set_data_rd_callback(*device, DEVCB_##_read);
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-class e05a03_device : public device_t
-{
-public:
- e05a03_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~e05a03_device() {}
-
- template<class _Object> static devcb_base &set_nlq_lp_wr_callback(device_t &device, _Object object) { return downcast<e05a03_device &>(device).m_write_nlq_lp.set_callback(object); }
- template<class _Object> static devcb_base &set_pe_lp_wr_callback(device_t &device, _Object object) { return downcast<e05a03_device &>(device).m_write_pe_lp.set_callback(object); }
- template<class _Object> static devcb_base &set_reso_wr_callback(device_t &device, _Object object) { return downcast<e05a03_device &>(device).m_write_reso.set_callback(object); }
- template<class _Object> static devcb_base &set_pe_wr_callback(device_t &device, _Object object) { return downcast<e05a03_device &>(device).m_write_pe.set_callback(object); }
- template<class _Object> static devcb_base &set_data_rd_callback(device_t &device, _Object object) { return downcast<e05a03_device &>(device).m_read_data.set_callback(object); }
-
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_READ8_MEMBER( read );
-
- WRITE_LINE_MEMBER( home_w ); /* home position signal */
- WRITE_LINE_MEMBER( fire_w ); /* printhead solenoids trigger */
- WRITE_LINE_MEMBER( strobe_w );
- READ_LINE_MEMBER( busy_r );
- WRITE_LINE_MEMBER( resi_w ); /* reset input */
- WRITE_LINE_MEMBER( init_w ); /* centronics init */
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
- /* callbacks */
- devcb_write_line m_write_nlq_lp; /* pin 2, nlq lamp output */
- devcb_write_line m_write_pe_lp; /* pin 3, paper empty lamp output */
- devcb_write_line m_write_reso; /* pin 25, reset output */
- devcb_write_line m_write_pe; /* pin 35, centronics pe output */
- devcb_read8 m_read_data; /* pin 47-54, centronics data input */
-
- /* 24-bit shift register, port 0x00, 0x01 and 0x02 */
- UINT32 m_shift;
-
- /* port 0x03 */
- int m_busy_leading;
- int m_busy_software;
- int m_nlqlp;
- int m_cndlp;
-
-#if 0
- int m_pe;
- int m_pelp;
-#endif
-
- /* port 0x04 and 0x05 (9-bit) */
- UINT16 m_printhead;
-
- /* port 0x06 (4-bit) */
- UINT8 m_pf_motor;
-
- /* port 0x07 (4-bit) */
- UINT8 m_cr_motor;
-};
-
-extern const device_type E05A03;
-
-
-#endif /* __E05A03_H__ */
diff --git a/src/emu/machine/e05a30.c b/src/emu/machine/e05a30.c
deleted file mode 100644
index 682a8fb96ec..00000000000
--- a/src/emu/machine/e05a30.c
+++ /dev/null
@@ -1,224 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Ramiro Polla
-/*
- * E05A30 Gate Array (used in the Epson ActionPrinter 2000)
- *
- */
-
-#include "emu.h"
-#include "e05a30.h"
-
-//#define E05A30DEBUG
-#ifdef E05A30DEBUG
-#define LOG(...) fprintf(stderr, __VA_ARGS__)
-#else
-#define LOG(...)
-#endif
-
-
-/*****************************************************************************
- DEVICE INTERFACE
-*****************************************************************************/
-
-const device_type E05A30 = &device_creator<e05a30_device>;
-
-e05a30_device::e05a30_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, E05A30, "E05A30", tag, owner, clock, "e05a30", __FILE__),
- m_write_printhead(*this),
- m_write_pf_stepper(*this),
- m_write_cr_stepper(*this),
- m_write_ready(*this),
- m_write_centronics_ack(*this),
- m_write_centronics_busy(*this),
- m_write_centronics_perror(*this),
- m_write_centronics_fault(*this),
- m_write_centronics_select(*this),
- m_printhead(0),
- m_pf_stepper(0),
- m_cr_stepper(0)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void e05a30_device::device_start()
-{
- /* resolve callbacks */
- m_write_printhead.resolve_safe();
- m_write_pf_stepper.resolve_safe();
- m_write_cr_stepper.resolve_safe();
- m_write_ready.resolve_safe();
- m_write_centronics_ack.resolve_safe();
- m_write_centronics_busy.resolve_safe();
- m_write_centronics_perror.resolve_safe();
- m_write_centronics_fault.resolve_safe();
- m_write_centronics_select.resolve_safe();
-
- /* register for state saving */
- save_item(NAME(m_printhead));
- save_item(NAME(m_pf_stepper));
- save_item(NAME(m_cr_stepper));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void e05a30_device::device_reset()
-{
- m_printhead = 0x00;
- m_pf_stepper = 0x00;
- m_cr_stepper = 0x00;
-
- /* centronics init */
- m_centronics_nack = FALSE;
- m_centronics_busy = FALSE;
- m_write_centronics_ack (!m_centronics_nack);
- m_write_centronics_busy ( m_centronics_busy);
- m_write_centronics_perror(FALSE);
- m_write_centronics_fault (TRUE);
- m_write_centronics_select(TRUE);
-
- m_write_ready(1);
-}
-
-
-/***************************************************************************
- PRINT HEAD
-***************************************************************************/
-
-/* The e05a30 controls the printhead through MMIOs 0xC005 and 0xC006.
- * MMIO 0xC006 keeps the first 8 pins.
- * MMIO 0xC005 keeps the 9th pin in the MSB.
- */
-
-void e05a30_device::update_printhead(int pos, UINT8 data)
-{
- if (pos == 0) {
- m_printhead &= 0x00ff;
- m_printhead |= (UINT16) !!data << 8;
- } else {
- m_printhead &= 0xff00;
- m_printhead |= data;
- }
- m_write_printhead(m_printhead);
-}
-
-/***************************************************************************
- STEPPER MOTORS
-***************************************************************************/
-
-/* The e05a30 controls two stepper motors:
- * - The Paper Feed stepper motor is controlled through MMIO 0xC007
- * - The Carriage Return stepper motor is controlled through MMIO 0xC008
- * The Carriage Return stepper motor is used throug the SLA7020M driver. It
- * is therefore necessary to translate the input data from the SLA7020M
- * format to a format describing the 4 phases of a stepper motor.
- * For the PF motor, the output data is fed directly to the stepper motor.
- */
-
-void e05a30_device::update_pf_stepper(UINT8 data)
-{
- m_pf_stepper = data & 0x0f;
- m_write_pf_stepper(m_pf_stepper);
-}
-
-static UINT8 cr_sla7020m(UINT8 data)
-{
- bool ina = BIT(data, 0);
- bool inb = BIT(data, 1);
- bool tda = BIT(data, 2);
- bool tdb = BIT(data, 3);
- bool outa0 = ina && tda;
- bool outa1 = !ina && tda;
- bool outb0 = inb && tdb;
- bool outb1 = !inb && tdb;
- return (outb1<<3)|(outb0<<2)|(outa1<<1)|(outa0<<0);
-}
-void e05a30_device::update_cr_stepper(UINT8 data)
-{
- m_cr_stepper = data & 0x0f;
- m_write_cr_stepper(cr_sla7020m(m_cr_stepper));
-}
-
-
-/***************************************************************************
- Centronics
-***************************************************************************/
-
-WRITE_LINE_MEMBER( e05a30_device::centronics_input_strobe )
-{
- if (m_centronics_strobe == TRUE && state == FALSE && !m_centronics_busy) {
- m_centronics_data_latch = m_centronics_data;
-
- m_centronics_data_latched = TRUE;
- m_centronics_busy = TRUE;
- m_write_centronics_busy(m_centronics_busy);
- }
-
- m_centronics_strobe = state;
-}
-
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-WRITE8_MEMBER( e05a30_device::write )
-{
- LOG("%s: e05a30_w([0xC0%02x]): %02x\n", space.machine().describe_context(), offset, data);
-
- switch (offset) {
- case 0x04:
- m_centronics_nack = BIT(data,5);
- m_centronics_busy = BIT(data,0);
- /* The ActionPrinter 2000 firmware might overwrite the busy signal at
- * address 20AB if the host depends only on the busy signal and
- * doesn't wait for the ack pulse. To avoid skipping input data, we
- * assume the busy signal cannot be reset while the data hasn't been
- * read. */
- if (m_centronics_data_latched)
- m_centronics_busy = TRUE;
- m_write_centronics_ack (!m_centronics_nack);
- m_write_centronics_busy( m_centronics_busy);
- break;
- /* printhead */
- case 0x05: update_printhead(0, data); break;
- case 0x06: update_printhead(1, data); break;
- /* paper feed stepper motor */
- case 0x07: update_pf_stepper(data); break;
- /* carriage return stepper motor */
- case 0x08: update_cr_stepper(data); break;
- }
-}
-
-READ8_MEMBER( e05a30_device::read )
-{
- UINT8 result = 0;
-
- LOG("%s: e05a30_r([0xC0%02x]): ", space.machine().describe_context(), offset);
-
- switch (offset) {
- case 0x02:
- result = m_centronics_data_latched << 7;
- break;
- case 0x03:
- result = m_centronics_data_latch;
- m_centronics_data_latched = FALSE;
- break;
- case 0x04:
- result |= m_centronics_busy << 0;
- result |= m_centronics_nack << 5;
- break;
- /* paper feed stepper motor */
- case 0x07: result = m_pf_stepper; break;
- /* carriage return stepper motor */
- case 0x08: result = m_cr_stepper; break;
- }
-
- LOG("0x%02x\n", result);
-
- return result;
-}
diff --git a/src/emu/machine/e05a30.h b/src/emu/machine/e05a30.h
deleted file mode 100644
index 95e4fadb37c..00000000000
--- a/src/emu/machine/e05a30.h
+++ /dev/null
@@ -1,115 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Ramiro Polla
-/*
- * E05A30 Gate Array (used in the Epson ActionPrinter 2000)
- *
- */
-
-#ifndef __E05A30_H__
-#define __E05A30_H__
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_E05A30_PRINTHEAD_CALLBACK(_write) \
- devcb = &e05a30_device::set_printhead_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_E05A30_PF_STEPPER_CALLBACK(_write) \
- devcb = &e05a30_device::set_pf_stepper_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_E05A30_CR_STEPPER_CALLBACK(_write) \
- devcb = &e05a30_device::set_cr_stepper_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_E05A30_READY_CALLBACK(_write) \
- devcb = &e05a30_device::set_ready_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_E05A30_CENTRONICS_ACK_CALLBACK(_write) \
- devcb = &e05a30_device::set_centronics_ack_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_E05A30_CENTRONICS_BUSY_CALLBACK(_write) \
- devcb = &e05a30_device::set_centronics_busy_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_E05A30_CENTRONICS_PERROR_CALLBACK(_write) \
- devcb = &e05a30_device::set_centronics_perror_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_E05A30_CENTRONICS_FAULT_CALLBACK(_write) \
- devcb = &e05a30_device::set_centronics_fault_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_E05A30_CENTRONICS_SELECT_CALLBACK(_write) \
- devcb = &e05a30_device::set_centronics_select_wr_callback(*device, DEVCB_##_write);
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-class e05a30_device : public device_t
-{
-public:
- e05a30_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~e05a30_device() {}
-
- template<class _Object> static devcb_base &set_printhead_wr_callback(device_t &device, _Object object) { return downcast<e05a30_device &>(device).m_write_printhead.set_callback(object); }
- template<class _Object> static devcb_base &set_pf_stepper_wr_callback(device_t &device, _Object object) { return downcast<e05a30_device &>(device).m_write_pf_stepper.set_callback(object); }
- template<class _Object> static devcb_base &set_cr_stepper_wr_callback(device_t &device, _Object object) { return downcast<e05a30_device &>(device).m_write_cr_stepper.set_callback(object); }
- template<class _Object> static devcb_base &set_ready_wr_callback(device_t &device, _Object object) { return downcast<e05a30_device &>(device).m_write_ready.set_callback(object); }
- template<class _Object> static devcb_base &set_centronics_ack_wr_callback(device_t &device, _Object object) { return downcast<e05a30_device &>(device).m_write_centronics_ack.set_callback(object); }
- template<class _Object> static devcb_base &set_centronics_busy_wr_callback(device_t &device, _Object object) { return downcast<e05a30_device &>(device).m_write_centronics_busy.set_callback(object); }
- template<class _Object> static devcb_base &set_centronics_perror_wr_callback(device_t &device, _Object object) { return downcast<e05a30_device &>(device).m_write_centronics_perror.set_callback(object); }
- template<class _Object> static devcb_base &set_centronics_fault_wr_callback(device_t &device, _Object object) { return downcast<e05a30_device &>(device).m_write_centronics_fault.set_callback(object); }
- template<class _Object> static devcb_base &set_centronics_select_wr_callback(device_t &device, _Object object) { return downcast<e05a30_device &>(device).m_write_centronics_select.set_callback(object); }
-
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_READ8_MEMBER( read );
-
- /* Centronics stuff */
- DECLARE_WRITE_LINE_MEMBER( centronics_input_strobe );
- DECLARE_WRITE_LINE_MEMBER( centronics_input_data0 ) { if (state) m_centronics_data |= 0x01; else m_centronics_data &= ~0x01; }
- DECLARE_WRITE_LINE_MEMBER( centronics_input_data1 ) { if (state) m_centronics_data |= 0x02; else m_centronics_data &= ~0x02; }
- DECLARE_WRITE_LINE_MEMBER( centronics_input_data2 ) { if (state) m_centronics_data |= 0x04; else m_centronics_data &= ~0x04; }
- DECLARE_WRITE_LINE_MEMBER( centronics_input_data3 ) { if (state) m_centronics_data |= 0x08; else m_centronics_data &= ~0x08; }
- DECLARE_WRITE_LINE_MEMBER( centronics_input_data4 ) { if (state) m_centronics_data |= 0x10; else m_centronics_data &= ~0x10; }
- DECLARE_WRITE_LINE_MEMBER( centronics_input_data5 ) { if (state) m_centronics_data |= 0x20; else m_centronics_data &= ~0x20; }
- DECLARE_WRITE_LINE_MEMBER( centronics_input_data6 ) { if (state) m_centronics_data |= 0x40; else m_centronics_data &= ~0x40; }
- DECLARE_WRITE_LINE_MEMBER( centronics_input_data7 ) { if (state) m_centronics_data |= 0x80; else m_centronics_data &= ~0x80; }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- /* callbacks */
- devcb_write16 m_write_printhead;
- devcb_write8 m_write_pf_stepper;
- devcb_write8 m_write_cr_stepper;
- devcb_write_line m_write_ready;
- devcb_write_line m_write_centronics_ack;
- devcb_write_line m_write_centronics_busy;
- devcb_write_line m_write_centronics_perror;
- devcb_write_line m_write_centronics_fault;
- devcb_write_line m_write_centronics_select;
-
- void update_printhead(int pos, UINT8 data);
- void update_pf_stepper(UINT8 data);
- void update_cr_stepper(UINT8 data);
-
- /* port 0x05 and 0x06 (9-bit) */
- UINT16 m_printhead;
- /* port 0x07 (4-bit) */
- UINT8 m_pf_stepper;
- /* port 0x08 (4-bit) */
- UINT8 m_cr_stepper;
-
- /* Centronics stuff */
- UINT8 m_centronics_data;
- int m_centronics_busy;
- int m_centronics_nack;
- UINT8 m_centronics_strobe;
- UINT8 m_centronics_data_latch;
- UINT8 m_centronics_data_latched;
-};
-
-extern const device_type E05A30;
-
-#endif /* __E05A30_H__ */
diff --git a/src/emu/machine/eeprom.c b/src/emu/machine/eeprom.c
deleted file mode 100644
index a0e8886e7f4..00000000000
--- a/src/emu/machine/eeprom.c
+++ /dev/null
@@ -1,376 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- eeprom.c
-
- Base class for EEPROM devices.
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/eeprom.h"
-
-
-
-//**************************************************************************
-// DEBUGGING
-//**************************************************************************
-
-#define VERBOSE 0
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-static ADDRESS_MAP_START( eeprom_map8, AS_PROGRAM, 8, eeprom_base_device )
- AM_RANGE(0x00000, 0xfffff) AM_RAM
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( eeprom_map16, AS_PROGRAM, 16, eeprom_base_device )
- AM_RANGE(0x00000, 0x7ffff) AM_RAM
-ADDRESS_MAP_END
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// eeprom_base_device - constructor
-//-------------------------------------------------
-
-eeprom_base_device::eeprom_base_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file)
- : device_t(mconfig, devtype, name, tag, owner, 0, shortname, file),
- device_memory_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this),
- m_cells(0),
- m_address_bits(0),
- m_data_bits(0),
- m_default_data(0),
- m_default_data_size(0),
- m_default_value(0),
- m_default_value_set(false),
- m_completion_time(attotime::zero)
-{
- // a 2ms write time is too long for rfjetsa
- m_operation_time[WRITE_TIME] = attotime::from_usec(1750);
- m_operation_time[WRITE_ALL_TIME] = attotime::from_usec(8000);
- m_operation_time[ERASE_TIME] = attotime::from_usec(1000);
- m_operation_time[ERASE_ALL_TIME] = attotime::from_usec(8000);
-}
-
-
-//-------------------------------------------------
-// static_set_default_data - configuration helpers
-// to set the default data
-//-------------------------------------------------
-
-void eeprom_base_device::static_set_size(device_t &device, int cells, int cellbits)
-{
- eeprom_base_device &eeprom = downcast<eeprom_base_device &>(device);
- eeprom.m_cells = cells;
- eeprom.m_data_bits = cellbits;
-
- // compute address bits (validation checks verify cells was an even power of 2)
- cells--;
- eeprom.m_address_bits = 0;
- while (cells != 0)
- {
- cells >>= 1;
- eeprom.m_address_bits++;
- }
-
- // describe our address space
- if (eeprom.m_data_bits == 8)
- eeprom.m_space_config = address_space_config("eeprom", ENDIANNESS_BIG, 8, eeprom.m_address_bits, 0, *ADDRESS_MAP_NAME(eeprom_map8));
- else
- eeprom.m_space_config = address_space_config("eeprom", ENDIANNESS_BIG, 16, eeprom.m_address_bits * 2, 0, *ADDRESS_MAP_NAME(eeprom_map16));
-}
-
-
-//-------------------------------------------------
-// static_set_default_data - configuration helpers
-// to set the default data
-//-------------------------------------------------
-
-void eeprom_base_device::static_set_default_data(device_t &device, const UINT8 *data, UINT32 size)
-{
- eeprom_base_device &eeprom = downcast<eeprom_base_device &>(device);
- assert(eeprom.m_data_bits == 8);
- eeprom.m_default_data.u8 = const_cast<UINT8 *>(data);
- eeprom.m_default_data_size = size;
-}
-
-void eeprom_base_device::static_set_default_data(device_t &device, const UINT16 *data, UINT32 size)
-{
- eeprom_base_device &eeprom = downcast<eeprom_base_device &>(device);
- assert(eeprom.m_data_bits == 16);
- eeprom.m_default_data.u16 = const_cast<UINT16 *>(data);
- eeprom.m_default_data_size = size / 2;
-}
-
-
-//-------------------------------------------------
-// static_set_default_value - configuration helper
-// to set the default value
-//-------------------------------------------------
-
-void eeprom_base_device::static_set_default_value(device_t &device, UINT32 value)
-{
- eeprom_base_device &eeprom = downcast<eeprom_base_device &>(device);
- eeprom.m_default_value = value;
- eeprom.m_default_value_set = true;
-}
-
-
-//-------------------------------------------------
-// static_set_timing - configuration helper
-// to set timing constants for various operations
-//-------------------------------------------------
-
-void eeprom_base_device::static_set_timing(device_t &device, timing_type type, const attotime &duration)
-{
- downcast<eeprom_base_device &>(device).m_operation_time[type] = duration;
-}
-
-
-//-------------------------------------------------
-// read - read data at the given address
-//-------------------------------------------------
-
-UINT32 eeprom_base_device::read(offs_t address)
-{
- if (!ready())
- logerror("EEPROM: Read performed before previous operation completed!");
- return internal_read(address);
-}
-
-
-//-------------------------------------------------
-// write - write data at the given address
-//-------------------------------------------------
-
-void eeprom_base_device::write(offs_t address, UINT32 data)
-{
- if (!ready())
- logerror("EEPROM: Write performed before previous operation completed!");
- internal_write(address, data);
- m_completion_time = machine().time() + m_operation_time[WRITE_TIME];
-}
-
-
-//-------------------------------------------------
-// write_all - write data at all addresses
-// (assumes an erase has previously been
-// performed)
-//-------------------------------------------------
-
-void eeprom_base_device::write_all(UINT32 data)
-{
- if (!ready())
- logerror("EEPROM: Write all performed before previous operation completed!");
- for (offs_t address = 0; address < (1 << m_address_bits); address++)
- internal_write(address, internal_read(address) & data);
- m_completion_time = machine().time() + m_operation_time[WRITE_ALL_TIME];
-}
-
-
-//-------------------------------------------------
-// erase - erase data at the given address
-//-------------------------------------------------
-
-void eeprom_base_device::erase(offs_t address)
-{
- if (!ready())
- logerror("EEPROM: Erase performed before previous operation completed!");
- internal_write(address, ~0);
- m_completion_time = machine().time() + m_operation_time[ERASE_TIME];
-}
-
-
-//-------------------------------------------------
-// erase_all - erase data at all addresses
-//-------------------------------------------------
-
-void eeprom_base_device::erase_all()
-{
- if (!ready())
- logerror("EEPROM: Erase all performed before previous operation completed!");
- for (offs_t address = 0; address < (1 << m_address_bits); address++)
- internal_write(address, ~0);
- m_completion_time = machine().time() + m_operation_time[ERASE_ALL_TIME];
-}
-
-
-//-------------------------------------------------
-// device_validity_check - perform validity checks
-// on this device
-//-------------------------------------------------
-
-void eeprom_base_device::device_validity_check(validity_checker &valid) const
-{
- // ensure the number of cells is an even power of 2
- if (m_cells != (1 << m_address_bits))
- osd_printf_error("Invalid EEPROM size %d specified\n", m_cells);
-
- // ensure only the sizes we support are requested
- if (m_data_bits != 8 && m_data_bits != 16)
- osd_printf_error("Invalid EEPROM data width %d specified\n", m_data_bits);
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void eeprom_base_device::device_start()
-{
- // save states
- save_item(NAME(m_completion_time));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void eeprom_base_device::device_reset()
-{
- // reset any pending operations
- m_completion_time = attotime::zero;
-}
-
-
-//-------------------------------------------------
-// memory_space_config - return a description of
-// any address spaces owned by this device
-//-------------------------------------------------
-
-const address_space_config *eeprom_base_device::memory_space_config(address_spacenum spacenum) const
-{
- return (spacenum == 0) ? &m_space_config : NULL;
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void eeprom_base_device::nvram_default()
-{
- UINT32 eeprom_length = 1 << m_address_bits;
- UINT32 eeprom_bytes = eeprom_length * m_data_bits / 8;
-
- // initialize to the default value
- UINT32 default_value = m_default_value_set ? m_default_value : ~0;
- for (offs_t offs = 0; offs < eeprom_length; offs++)
- if (m_data_bits == 8)
- m_addrspace[0]->write_byte(offs, default_value);
- else
- m_addrspace[0]->write_word(offs * 2, default_value);
-
- // handle hard-coded data from the driver
- if (m_default_data.u8 != NULL)
- {
- osd_printf_verbose("Warning: Driver-specific EEPROM defaults are going away soon.\n");
- for (offs_t offs = 0; offs < m_default_data_size; offs++)
- {
- if (m_data_bits == 8)
- m_addrspace[0]->write_byte(offs, m_default_data.u8[offs]);
- else
- m_addrspace[0]->write_word(offs * 2, m_default_data.u16[offs]);
- }
- }
-
- // populate from a memory region if present
- if (m_region != NULL)
- {
- if (m_region->bytes() != eeprom_bytes)
- fatalerror("eeprom region '%s' wrong size (expected size = 0x%X)\n", tag(), eeprom_bytes);
- if (m_data_bits == 8 && m_region->bytewidth() != 1)
- fatalerror("eeprom region '%s' needs to be an 8-bit region\n", tag());
- if (m_data_bits == 16 && (m_region->bytewidth() != 2 || m_region->endianness() != ENDIANNESS_BIG))
- fatalerror("eeprom region '%s' needs to be a 16-bit big-endian region\n", tag());
- osd_printf_verbose("Loading data from EEPROM region '%s'\n", tag());
-
- if (m_data_bits == 8)
- {
- UINT8 *default_data = m_region->base();
- for (offs_t offs = 0; offs < eeprom_length; offs++)
- m_addrspace[0]->write_byte(offs, default_data[offs]);
- }
- else
- {
- UINT16 *default_data = (UINT16 *)(m_region->base());
- for (offs_t offs = 0; offs < eeprom_length; offs++)
- m_addrspace[0]->write_word(offs * 2, default_data[offs]);
- }
- }
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void eeprom_base_device::nvram_read(emu_file &file)
-{
- UINT32 eeprom_length = 1 << m_address_bits;
- UINT32 eeprom_bytes = eeprom_length * m_data_bits / 8;
-
- dynamic_buffer buffer(eeprom_bytes);
- file.read(&buffer[0], eeprom_bytes);
- for (offs_t offs = 0; offs < eeprom_bytes; offs++)
- m_addrspace[0]->write_byte(offs, buffer[offs]);
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void eeprom_base_device::nvram_write(emu_file &file)
-{
- UINT32 eeprom_length = 1 << m_address_bits;
- UINT32 eeprom_bytes = eeprom_length * m_data_bits / 8;
-
- dynamic_buffer buffer(eeprom_bytes);
- for (offs_t offs = 0; offs < eeprom_bytes; offs++)
- buffer[offs] = m_addrspace[0]->read_byte(offs);
- file.write(&buffer[0], eeprom_bytes);
-}
-
-
-//-------------------------------------------------
-// internal_read - read data at the given address
-//-------------------------------------------------
-
-UINT32 eeprom_base_device::internal_read(offs_t address)
-{
- if (m_data_bits == 16)
- return m_addrspace[0]->read_word(address * 2);
- else
- return m_addrspace[0]->read_byte(address);
-}
-
-
-//-------------------------------------------------
-// internal_write - write data at the given
-// address
-//-------------------------------------------------
-
-void eeprom_base_device::internal_write(offs_t address, UINT32 data)
-{
- if (m_data_bits == 16)
- m_addrspace[0]->write_word(address * 2, data);
- else
- m_addrspace[0]->write_byte(address, data);
-}
diff --git a/src/emu/machine/eeprom.h b/src/emu/machine/eeprom.h
deleted file mode 100644
index d6db74f5a21..00000000000
--- a/src/emu/machine/eeprom.h
+++ /dev/null
@@ -1,116 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- eeprom.h
-
- Base class for EEPROM devices.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __EEPROM_H__
-#define __EEPROM_H__
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_EEPROM_SIZE(_cells, _cellbits) \
- eeprom_base_device::static_set_size(*device, _cells, _cellbits);
-#define MCFG_EEPROM_DATA(_data, _size) \
- eeprom_base_device::static_set_default_data(*device, _data, _size);
-#define MCFG_EEPROM_DEFAULT_VALUE(_value) \
- eeprom_base_device::static_set_default_value(*device, _value);
-
-#define MCFG_EEPROM_WRITE_TIME(_value) \
- eeprom_base_device::static_set_timing(*device, eeprom_base_device::WRITE_TIME, _value);
-#define MCFG_EEPROM_WRITE_ALL_TIME(_value) \
- eeprom_base_device::static_set_timing(*device, eeprom_base_device::WRITE_ALL_TIME, _value);
-#define MCFG_EEPROM_ERASE_TIME(_value) \
- eeprom_base_device::static_set_timing(*device, eeprom_base_device::ERASE_TIME, _value);
-#define MCFG_EEPROM_ERASE_ALL_TIME(_value) \
- eeprom_base_device::static_set_timing(*device, eeprom_base_device::ERASE_ALL_TIME, _value);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> eeprom_base_device
-
-class eeprom_base_device : public device_t,
- public device_memory_interface,
- public device_nvram_interface
-{
-protected:
- // construction/destruction
- eeprom_base_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file);
-
-public:
- // timing constants
- enum timing_type
- {
- WRITE_TIME, // default = 2ms
- WRITE_ALL_TIME, // default = 8ms
- ERASE_TIME, // default = 1ms
- ERASE_ALL_TIME, // default = 8ms
- TIMING_COUNT
- };
-
- // inline configuration helpers
- static void static_set_size(device_t &device, int cells, int cellbits);
- static void static_set_default_data(device_t &device, const UINT8 *data, UINT32 size);
- static void static_set_default_data(device_t &device, const UINT16 *data, UINT32 size);
- static void static_set_default_value(device_t &device, UINT32 value);
- static void static_set_timing(device_t &device, timing_type type, const attotime &duration);
-
- // read/write/erase data
- UINT32 read(offs_t address);
- void write(offs_t address, UINT32 data);
- void write_all(UINT32 data);
- void erase(offs_t address);
- void erase_all();
-
- // status
- bool ready() const { return machine().time() >= m_completion_time; }
-
-protected:
- // device-level overrides
- virtual void device_validity_check(validity_checker &valid) const;
- virtual void device_start();
- virtual void device_reset();
-
- // device_memory_interface overrides
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
- // internal read/write without side-effects
- UINT32 internal_read(offs_t address);
- void internal_write(offs_t address, UINT32 data);
-
- // configuration state
- UINT32 m_cells;
- UINT8 m_address_bits;
- UINT8 m_data_bits;
- address_space_config m_space_config;
- generic_ptr m_default_data;
- UINT32 m_default_data_size;
- UINT32 m_default_value;
- bool m_default_value_set;
- attotime m_operation_time[TIMING_COUNT];
-
- // live state
- attotime m_completion_time;
-};
-
-
-#endif
diff --git a/src/emu/machine/eeprompar.c b/src/emu/machine/eeprompar.c
deleted file mode 100644
index af575ec1419..00000000000
--- a/src/emu/machine/eeprompar.c
+++ /dev/null
@@ -1,133 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- eeprompar.c
-
- Parallel EEPROM devices.
-
-****************************************************************************
-
- Parallel EEPROMs are generally simpler than serial EEPROMs, though
- they require more pins to provide the full set of address and data
- lines necessary. They also require more pins the larger the EEPROM
- is, whereas serial EEPROMs all share the same pinout regardless of
- size.
-
- At a basic level, there are 5 sets of signals involved:
-
- * /CE = chip enable
- * /OE = output enable
- * /WE = write enable
- * D0-Dn = data lines
- * A0-An = address lines
-
- To access the chip, the various enable states must be asserted or
- cleared. Note that these are generally active-low, so asserted means
- pulled to GND, and cleared means pulled to Vcc:
-
- /CE /OE /WE Action
- ASSERT ASSERT CLEAR Read (D0-Dn contain output data)
- ASSERT CLEAR ASSERT Write/Erase (D0-Dn are input data)
-
- Erase is performed by doing a write with D0-Dn all set to 1.
-
- In general, it is slow to write or erase (9ms is quoted in the 2816A
- datasheet, for example), and the /WE must be held low for the entire
- write/erase duration in order to guarantee the data is written.
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/eeprompar.h"
-
-
-
-//**************************************************************************
-// BASE DEVICE IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// eeprom_parallel_base_device - constructor
-//-------------------------------------------------
-
-eeprom_parallel_base_device::eeprom_parallel_base_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file)
- : eeprom_base_device(mconfig, devtype, name, tag, owner, shortname, file)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void eeprom_parallel_base_device::device_start()
-{
- // start the base class
- eeprom_base_device::device_start();
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void eeprom_parallel_base_device::device_reset()
-{
- // reset the base class
- eeprom_base_device::device_reset();
-}
-
-
-
-//**************************************************************************
-// 28XX INTERFACE IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// eeprom_parallel_28xx_device - constructor
-//-------------------------------------------------
-
-eeprom_parallel_28xx_device::eeprom_parallel_28xx_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file)
- : eeprom_parallel_base_device(mconfig, devtype, name, tag, owner, shortname, file)
-{
-}
-
-
-//-------------------------------------------------
-// read/write - read/write handlers
-//-------------------------------------------------
-
-WRITE8_MEMBER(eeprom_parallel_28xx_device::write)
-{
- eeprom_base_device::write(offset, data);
-}
-
-READ8_MEMBER(eeprom_parallel_28xx_device::read)
-{
- return eeprom_base_device::read(offset);
-}
-
-
-
-//**************************************************************************
-// DERIVED TYPES
-//**************************************************************************
-
-// macro for defining a new device class
-#define DEFINE_PARALLEL_EEPROM_DEVICE(_baseclass, _lowercase, _uppercase, _bits, _cells) \
-eeprom_parallel_##_lowercase##_device::eeprom_parallel_##_lowercase##_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) \
- : eeprom_parallel_##_baseclass##_device(mconfig, EEPROM_PARALLEL_##_uppercase, "Parallel EEPROM " #_uppercase " (" #_cells "x" #_bits ")", tag, owner, #_lowercase, __FILE__) \
-{ \
- static_set_size(*this, _cells, _bits); \
-} \
-const device_type EEPROM_PARALLEL_##_uppercase = &device_creator<eeprom_parallel_##_lowercase##_device>;
-// standard 28XX class of 8-bit EEPROMs
-DEFINE_PARALLEL_EEPROM_DEVICE(28xx, 2804, 2804, 8, 512)
-DEFINE_PARALLEL_EEPROM_DEVICE(28xx, 2816, 2816, 8, 2048)
-DEFINE_PARALLEL_EEPROM_DEVICE(28xx, 2864, 2864, 8, 8192)
-DEFINE_PARALLEL_EEPROM_DEVICE(28xx, 28256, 28256, 8, 32768)
-DEFINE_PARALLEL_EEPROM_DEVICE(28xx, 28512, 28512, 8, 65536)
-DEFINE_PARALLEL_EEPROM_DEVICE(28xx, 28010, 28010, 8, 131072)
-DEFINE_PARALLEL_EEPROM_DEVICE(28xx, 28020, 28020, 8, 262144)
-DEFINE_PARALLEL_EEPROM_DEVICE(28xx, 28040, 28040, 8, 524288)
diff --git a/src/emu/machine/eeprompar.h b/src/emu/machine/eeprompar.h
deleted file mode 100644
index 84c4090f14e..00000000000
--- a/src/emu/machine/eeprompar.h
+++ /dev/null
@@ -1,105 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- eeprompar.h
-
- Parallel EEPROM devices.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __EEPROMPAR_H__
-#define __EEPROMPAR_H__
-
-#include "eeprom.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-// standard 28XX class of 8-bit parallel EEPROMs
-#define MCFG_EEPROM_2804_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_PARALLEL_2804, 0)
-#define MCFG_EEPROM_2816_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_PARALLEL_2816, 0)
-#define MCFG_EEPROM_2864_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_PARALLEL_2864, 0)
-#define MCFG_EEPROM_28256_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_PARALLEL_28256, 0)
-#define MCFG_EEPROM_28512_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_PARALLEL_28512, 0)
-#define MCFG_EEPROM_28010_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_PARALLEL_28010, 0)
-#define MCFG_EEPROM_28020_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_PARALLEL_28020, 0)
-#define MCFG_EEPROM_28040_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_PARALLEL_28040, 0)
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-// ======================> eeprom_parallel_base_device
-
-class eeprom_parallel_base_device : public eeprom_base_device
-{
-protected:
- // construction/destruction
- eeprom_parallel_base_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file);
-
-public:
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-};
-
-
-
-// ======================> eeprom_parallel_28xx_device
-
-class eeprom_parallel_28xx_device : public eeprom_parallel_base_device
-{
-protected:
- // construction/destruction
- eeprom_parallel_28xx_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file);
-
-public:
- // read/write data lines - for now we cheat and ignore the control lines, assuming
- // they are handled reasonably
- DECLARE_WRITE8_MEMBER(write);
- DECLARE_READ8_MEMBER(read);
-};
-
-
-
-//**************************************************************************
-// DERIVED TYPES
-//**************************************************************************
-
-// macro for declaring a new device class
-#define DECLARE_PARALLEL_EEPROM_DEVICE(_baseclass, _lowercase, _uppercase) \
-class eeprom_parallel_##_lowercase##_device : public eeprom_parallel_##_baseclass##_device \
-{ \
-public: \
- eeprom_parallel_##_lowercase##_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); \
-}; \
-extern const device_type EEPROM_PARALLEL_##_uppercase;
-// standard 28XX class of 8-bit EEPROMs
-DECLARE_PARALLEL_EEPROM_DEVICE(28xx, 2804, 2804)
-DECLARE_PARALLEL_EEPROM_DEVICE(28xx, 2816, 2816)
-DECLARE_PARALLEL_EEPROM_DEVICE(28xx, 2864, 2864)
-DECLARE_PARALLEL_EEPROM_DEVICE(28xx, 28256, 28256)
-DECLARE_PARALLEL_EEPROM_DEVICE(28xx, 28512, 28512)
-DECLARE_PARALLEL_EEPROM_DEVICE(28xx, 28010, 28010)
-DECLARE_PARALLEL_EEPROM_DEVICE(28xx, 28020, 28020)
-DECLARE_PARALLEL_EEPROM_DEVICE(28xx, 28040, 28040)
-
-#endif
diff --git a/src/emu/machine/eepromser.c b/src/emu/machine/eepromser.c
deleted file mode 100644
index 347accae06f..00000000000
--- a/src/emu/machine/eepromser.c
+++ /dev/null
@@ -1,1161 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- eepromser.c
-
- Serial EEPROM devices.
-
-****************************************************************************
-
- Serial EEPROMs generally work the same across manufacturers and models,
- varying largely by the size of the EEPROM and the packaging details.
-
- At a basic level, there are 5 signals involved:
-
- * CS = chip select
- * CLK = serial data clock
- * DI = serial data in
- * DO = serial data out
- * RDY/BUSY = ready (1) or busy (0) status
-
- Data is read or written via serial commands. A command is begun on a
- low-to-high transition of the CS line, following by clocking a start
- bit (1) on the DI line. After the start bit, subsequent clocks
- assemble one of the following commands:
-
- Start Opcode Address Data
- 1 01 aaaaaaaaa ddddddd WRITE data
- 1 10 aaaaaaaaa READ data
- 1 11 aaaaaaaaa ERASE data
- 1 00 00xxxxxxx WREN = WRite ENable
- 1 00 01xxxxxxx ddddddd WRAL = WRite ALl cells
- 1 00 10xxxxxxx ERAL = ERase ALl cells
- 1 00 11xxxxxxx WRDS = WRite DiSable
-
- The number of address bits (a) clocked varies based on the size of the
- chip, though it does not always map 1:1 with the size of the chip.
- For example, the 93C06 has 16 cells, which only needs 4 address bits;
- but commands to the 93C06 require 6 address bits (the top two must
- be 0).
-
- The number of data bits (d) clocked varies based on the chip and at
- times on the state of a pin on the chip which selects between multiple
- sizes (e.g., 8-bit versus 16-bit).
-
-****************************************************************************
-
- Most EEPROMs are based on the 93Cxx design (and have similar part
- designations):
-
- +--v--+
- CS |1 8| Vcc
- CLK |2 7| NC
- DI |3 6| NC
- DO |4 5| GND
- +-----+
-
- Note the lack of a READY/BUSY pin. On the 93Cxx series, the DO pin
- serves double-duty, returning READY/BUSY during a write/erase cycle,
- and outputting data during a read cycle.
-
- Some manufacturers have released "enhanced" versions with additional
- features:
-
- * Several manufacturers (ST) map pin 6 to "ORG", specifying the
- logical organization of the data. Connecting ORG to ground
- makes the EEPROM work as an 8-bit device, while connecting it
- to Vcc makes it work as a 16-bit device with one less
- address bit.
-
- * Other manufacturers (ST) have enhanced the read operations to
- allow serially streaming more than one cell. Essentially, after
- reading the first cell, keep CS high and keep clocking, and
- data from following cells will be read as well.
-
- The ER5911 is only slightly different:
-
- +--v--+
- CS |1 8| Vcc
- CLK |2 7| RDY/BUSY
- DI |3 6| ORG
- DO |4 5| GND
- +-----+
-
- Here we have an explicit RDY/BUSY signal, and the ORG flag as described
- above.
-
- From a command perspective, the ER5911 is also slightly different:
-
- 93Cxx has ERASE command; this maps to WRITE on ER5911
- 93Cxx has WRITEALL command; no equivalent on ER5911
-
-****************************************************************************
-
- Issues with:
-
- kickgoal.c - code seems wrong, clock logic writes 0-0-0 instead of 0-1-0 as expected
- overdriv.c - drops CS, raises CS, keeps DI=1, triggering extraneous start bit
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/eepromser.h"
-
-
-
-//**************************************************************************
-// DEBUGGING
-//**************************************************************************
-
-// logging levels:
-// 0 = errors and warnings only
-// 1 = commands
-// 2 = state machine
-// 3 = DI/DO/READY reads & writes
-// 4 = all reads & writes
-
-#define VERBOSE_PRINTF 0
-#define VERBOSE_LOGERROR 0
-
-#define LOG0(x) do { if (VERBOSE_PRINTF >= 1) printf x; logerror x; } while (0)
-#define LOG1(x) do { if (VERBOSE_PRINTF >= 1) printf x; if (VERBOSE_LOGERROR >= 1) logerror x; } while (0)
-#define LOG2(x) do { if (VERBOSE_PRINTF >= 2) printf x; if (VERBOSE_LOGERROR >= 2) logerror x; } while (0)
-#define LOG3(x) do { if (VERBOSE_PRINTF >= 3) printf x; if (VERBOSE_LOGERROR >= 3) logerror x; } while (0)
-#define LOG4(x) do { if (VERBOSE_PRINTF >= 4) printf x; if (VERBOSE_LOGERROR >= 4) logerror x; } while (0)
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-ALLOW_SAVE_TYPE(eeprom_serial_base_device::eeprom_command);
-ALLOW_SAVE_TYPE(eeprom_serial_base_device::eeprom_state);
-
-
-
-//**************************************************************************
-// BASE DEVICE IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// eeprom_serial_base_device - constructor
-//-------------------------------------------------
-
-eeprom_serial_base_device::eeprom_serial_base_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file)
- : eeprom_base_device(mconfig, devtype, name, tag, owner, shortname, file),
- m_command_address_bits(0),
- m_streaming_enabled(false),
- m_state(STATE_IN_RESET),
- m_cs_state(CLEAR_LINE),
- m_last_cs_rising_edge_time(attotime::zero),
- m_oe_state(CLEAR_LINE),
- m_clk_state(CLEAR_LINE),
- m_di_state(CLEAR_LINE),
- m_locked(true),
- m_bits_accum(0),
- m_command_address_accum(0),
- m_command(COMMAND_INVALID),
- m_address(0),
- m_shift_register(0)
-{
-}
-
-
-//-------------------------------------------------
-// static_set_address_bits - configuration helper
-// to set the number of address bits in the
-// serial commands
-//-------------------------------------------------
-
-void eeprom_serial_base_device::static_set_address_bits(device_t &device, int addrbits)
-{
- downcast<eeprom_serial_base_device &>(device).m_command_address_bits = addrbits;
-}
-
-
-//-------------------------------------------------
-// static_enable_streaming - configuration helper
-// to enable streaming data
-//-------------------------------------------------
-
-void eeprom_serial_base_device::static_enable_streaming(device_t &device)
-{
- downcast<eeprom_serial_base_device &>(device).m_streaming_enabled = true;
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void eeprom_serial_base_device::device_start()
-{
- // if no command address bits set, just inherit from the address bits
- if (m_command_address_bits == 0)
- m_command_address_bits = m_address_bits;
-
- // start the base class
- eeprom_base_device::device_start();
-
- // save the current state
- save_item(NAME(m_state));
- save_item(NAME(m_cs_state));
- save_item(NAME(m_oe_state));
- save_item(NAME(m_clk_state));
- save_item(NAME(m_di_state));
- save_item(NAME(m_locked));
- save_item(NAME(m_bits_accum));
- save_item(NAME(m_command_address_accum));
- save_item(NAME(m_command));
- save_item(NAME(m_address));
- save_item(NAME(m_shift_register));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void eeprom_serial_base_device::device_reset()
-{
- // reset the base class
- eeprom_base_device::device_reset();
-
- // reset the state
- set_state(STATE_IN_RESET);
- m_locked = true;
- m_bits_accum = 0;
- m_command_address_accum = 0;
- m_command = COMMAND_INVALID;
- m_address = 0;
- m_shift_register = 0;
-}
-
-
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-//-------------------------------------------------
-// base_cs_write - set the state of the chip
-// select (CS) line
-//-------------------------------------------------
-
-void eeprom_serial_base_device::base_cs_write(int state)
-{
- // ignore if the state is not changing
- state &= 1;
- if (state == m_cs_state)
- return;
-
- // set the new state
- LOG4((" cs_write(%d)\n", state));
- m_cs_state = state;
-
- // remember the rising edge time so we don't process CLK signals at the same time
- if (state == ASSERT_LINE)
- m_last_cs_rising_edge_time = machine().time();
- handle_event((m_cs_state == ASSERT_LINE) ? EVENT_CS_RISING_EDGE : EVENT_CS_FALLING_EDGE);
-}
-
-
-//-------------------------------------------------
-// base_clk_write - set the state of the clock
-// (CLK) line
-//-------------------------------------------------
-
-void eeprom_serial_base_device::base_clk_write(int state)
-{
- // ignore if the state is not changing
- state &= 1;
- if (state == m_clk_state)
- return;
-
- // set the new state
- LOG4((" clk_write(%d)\n", state));
- m_clk_state = state;
- handle_event((m_clk_state == ASSERT_LINE) ? EVENT_CLK_RISING_EDGE : EVENT_CLK_FALLING_EDGE);
-}
-
-
-//-------------------------------------------------
-// base_di_write - set the state of the data input
-// (DI) line
-//-------------------------------------------------
-
-void eeprom_serial_base_device::base_di_write(int state)
-{
- if (state != 0 && state != 1)
- LOG0(("EEPROM: Unexpected data at input 0x%X treated as %d\n", state, state & 1));
- LOG3((" di_write(%d)\n", state));
- m_di_state = state & 1;
-}
-
-
-//-------------------------------------------------
-// base_do_read - read the state of the data
-// output (DO) line
-//-------------------------------------------------
-
-int eeprom_serial_base_device::base_do_read()
-{
- // in most states, the output is tristated, and generally connected to a pull up
- // to send back a 1 value; the only exception is if reading data and the current output
- // bit is a 0
- int result = (m_state == STATE_READING_DATA && ((m_shift_register & 0x80000000) == 0)) ? CLEAR_LINE : ASSERT_LINE;
- LOG3((" do_read(%d)\n", result));
- return result;
-}
-
-
-//-------------------------------------------------
-// base_ready_read - read the state of the
-// READY/BUSY line
-//-------------------------------------------------
-
-int eeprom_serial_base_device::base_ready_read()
-{
- // ready by default, except during long operations
- int result = ready() ? ASSERT_LINE : CLEAR_LINE;
- LOG3((" ready_read(%d)\n", result));
- return result;
-}
-
-
-
-//**************************************************************************
-// INTERNAL HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// set_state - update the state to a new one
-//-------------------------------------------------
-
-void eeprom_serial_base_device::set_state(eeprom_state newstate)
-{
-#if (VERBOSE_PRINTF > 0 || VERBOSE_LOGERROR > 0)
- // for debugging purposes
- static const struct { eeprom_state state; const char *string; } s_state_names[] =
- {
- { STATE_IN_RESET, "IN_RESET" },
- { STATE_WAIT_FOR_START_BIT, "WAIT_FOR_START_BIT" },
- { STATE_WAIT_FOR_COMMAND, "WAIT_FOR_COMMAND" },
- { STATE_READING_DATA, "READING_DATA" },
- { STATE_WAIT_FOR_DATA, "WAIT_FOR_DATA" },
- { STATE_WAIT_FOR_COMPLETION, "WAIT_FOR_COMPLETION" },
- };
- const char *newstate_string = "UNKNOWN";
- for (int index = 0; index < ARRAY_LENGTH(s_state_names); index++)
- if (s_state_names[index].state == newstate)
- newstate_string = s_state_names[index].string;
- LOG2(("New state: %s\n", newstate_string));
-#endif
-
- // switch to the new state
- m_state = newstate;
-}
-
-
-//-------------------------------------------------
-// handle_event - handle an event via the state
-// machine
-//-------------------------------------------------
-
-void eeprom_serial_base_device::handle_event(eeprom_event event)
-{
-#if (VERBOSE_PRINTF > 0 || VERBOSE_LOGERROR > 0)
- // for debugging purposes
- if ((event & EVENT_CS_RISING_EDGE) != 0) LOG2(("Event: CS rising\n"));
- if ((event & EVENT_CS_FALLING_EDGE) != 0) LOG2(("Event: CS falling\n"));
- if ((event & EVENT_CLK_RISING_EDGE) != 0)
- {
- if (m_state == STATE_WAIT_FOR_COMMAND || m_state == STATE_WAIT_FOR_DATA)
- LOG2(("Event: CLK rising (%d, DI=%d)\n", m_bits_accum + 1, m_di_state));
- else if (m_state == STATE_READING_DATA)
- LOG2(("Event: CLK rising (%d, DO=%d)\n", m_bits_accum + 1, (m_shift_register >> 30) & 1));
- else if (m_state == STATE_WAIT_FOR_START_BIT)
- LOG2(("Event: CLK rising (%d)\n", m_di_state));
- else
- LOG2(("Event: CLK rising\n"));
- }
- if ((event & EVENT_CLK_FALLING_EDGE) != 0) LOG4(("Event: CLK falling\n"));
-#endif
-
- // switch off the current state
- switch (m_state)
- {
- // CS is not asserted; wait for a rising CS to move us forward, ignoring all clocks
- case STATE_IN_RESET:
- if (event == EVENT_CS_RISING_EDGE)
- set_state(STATE_WAIT_FOR_START_BIT);
- break;
-
- // CS is asserted; wait for rising clock with a 1 start bit; falling CS will reset us
- // note that because each bit is written independently, it is possible for us to receive
- // a false rising CLK edge at the exact same time as a rising CS edge; it appears we
- // should ignore these edges (makes sense really)
- case STATE_WAIT_FOR_START_BIT:
- if (event == EVENT_CLK_RISING_EDGE && m_di_state == ASSERT_LINE && ready() && machine().time() > m_last_cs_rising_edge_time)
- {
- m_command_address_accum = m_bits_accum = 0;
- set_state(STATE_WAIT_FOR_COMMAND);
- }
- else if (event == EVENT_CS_FALLING_EDGE)
- set_state(STATE_IN_RESET);
- break;
-
- // CS is asserted; wait for a command to come through; falling CS will reset us
- case STATE_WAIT_FOR_COMMAND:
- if (event == EVENT_CLK_RISING_EDGE)
- {
- // if we have enough bits for a command + address, check it out
- m_command_address_accum = (m_command_address_accum << 1) | m_di_state;
- if (++m_bits_accum == 2 + m_command_address_bits)
- execute_command();
- }
- else if (event == EVENT_CS_FALLING_EDGE)
- set_state(STATE_IN_RESET);
- break;
-
- // CS is asserted; reading data, clock the shift register; falling CS will reset us
- case STATE_READING_DATA:
- if (event == EVENT_CLK_RISING_EDGE)
- {
- int bit_index = m_bits_accum++;
-
- // wrapping the address on multi-read is required by pacslot(cave.c)
- if (bit_index % m_data_bits == 0 && (bit_index == 0 || m_streaming_enabled))
- m_shift_register = read((m_address + m_bits_accum / m_data_bits) & ((1 << m_address_bits) - 1)) << (32 - m_data_bits);
- else
- m_shift_register = (m_shift_register << 1) | 1;
- }
- else if (event == EVENT_CS_FALLING_EDGE)
- {
- set_state(STATE_IN_RESET);
- if (m_streaming_enabled)
- LOG1((" (%d cells read)\n", m_bits_accum / m_data_bits));
- if (!m_streaming_enabled && m_bits_accum > m_data_bits + 1)
- LOG0(("EEPROM: Overclocked read by %d bits\n", m_bits_accum - m_data_bits));
- else if (m_streaming_enabled && m_bits_accum > m_data_bits + 1 && m_bits_accum % m_data_bits > 2)
- LOG0(("EEPROM: Overclocked read by %d bits\n", m_bits_accum % m_data_bits));
- else if (m_bits_accum < m_data_bits)
- LOG0(("EEPROM: CS deasserted in READING_DATA after %d bits\n", m_bits_accum));
- }
- break;
-
- // CS is asserted; waiting for data; clock data through until we accumulate enough; falling CS will reset us
- case STATE_WAIT_FOR_DATA:
- if (event == EVENT_CLK_RISING_EDGE)
- {
- m_shift_register = (m_shift_register << 1) | m_di_state;
- if (++m_bits_accum == m_data_bits)
- execute_write_command();
- }
- else if (event == EVENT_CS_FALLING_EDGE)
- {
- set_state(STATE_IN_RESET);
- LOG0(("EEPROM: CS deasserted in STATE_WAIT_FOR_DATA after %d bits\n", m_bits_accum));
- }
- break;
-
- // CS is asserted; waiting for completion; watch for CS falling
- case STATE_WAIT_FOR_COMPLETION:
- if (event == EVENT_CS_FALLING_EDGE)
- set_state(STATE_IN_RESET);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// execute_command - execute a command once we
-// have enough bits for one
-//-------------------------------------------------
-
-void eeprom_serial_base_device::execute_command()
-{
- // parse into a generic command and reset the accumulator count
- parse_command_and_address();
- m_bits_accum = 0;
-
-#if (VERBOSE_PRINTF > 0 || VERBOSE_LOGERROR > 0)
- // for debugging purposes
- static const struct { eeprom_command command; const char *string; } s_command_names[] =
- {
- { COMMAND_INVALID, "Execute command: INVALID\n" },
- { COMMAND_READ, "Execute command:READ 0x%X\n" },
- { COMMAND_WRITE, "Execute command:WRITE 0x%X\n" },
- { COMMAND_ERASE, "Execute command:ERASE 0x%X\n" },
- { COMMAND_LOCK, "Execute command:LOCK\n" },
- { COMMAND_UNLOCK, "Execute command:UNLOCK\n" },
- { COMMAND_WRITEALL, "Execute command:WRITEALL\n" },
- { COMMAND_ERASEALL, "Execute command:ERASEALL\n" },
- };
- const char *command_string = s_command_names[0].string;
- for (int index = 0; index < ARRAY_LENGTH(s_command_names); index++)
- if (s_command_names[index].command == m_command)
- command_string = s_command_names[index].string;
- LOG1((command_string, m_address));
-#endif
-
- // each command advances differently
- switch (m_command)
- {
- // advance to the READING_DATA state; data is fetched after first CLK
- // reset the shift register to 0 to simulate the dummy 0 bit that happens prior
- // to the first clock
- case COMMAND_READ:
- m_shift_register = 0;
- set_state(STATE_READING_DATA);
- break;
-
- // reset the shift register and wait for enough data to be clocked through
- case COMMAND_WRITE:
- case COMMAND_WRITEALL:
- m_shift_register = 0;
- set_state(STATE_WAIT_FOR_DATA);
- break;
-
- // erase the parsed address (unless locked) and wait for it to complete
- case COMMAND_ERASE:
- if (m_locked)
- {
- LOG0(("EEPROM: Attempt to erase while locked\n"));
- set_state(STATE_IN_RESET);
- break;
- }
- erase(m_address);
- set_state(STATE_WAIT_FOR_COMPLETION);
- break;
-
- // lock the chip; return to IN_RESET state
- case COMMAND_LOCK:
- m_locked = true;
- set_state(STATE_IN_RESET);
- break;
-
- // unlock the chip; return to IN_RESET state
- case COMMAND_UNLOCK:
- m_locked = false;
- set_state(STATE_IN_RESET);
- break;
-
- // erase the entire chip (unless locked) and wait for it to complete
- case COMMAND_ERASEALL:
- if (m_locked)
- {
- LOG0(("EEPROM: Attempt to erase all while locked\n"));
- set_state(STATE_IN_RESET);
- break;
- }
- erase_all();
- set_state(STATE_WAIT_FOR_COMPLETION);
- break;
-
- default:
- throw emu_fatalerror("execute_command called with invalid command %d\n", m_command);
- }
-}
-
-
-//-------------------------------------------------
-// execute_write_command - execute a write
-// command after receiving the data bits
-//-------------------------------------------------
-
-void eeprom_serial_base_device::execute_write_command()
-{
-#if (VERBOSE_PRINTF > 0 || VERBOSE_LOGERROR > 0)
- // for debugging purposes
- static const struct { eeprom_command command; const char *string; } s_command_names[] =
- {
- { COMMAND_WRITE, "Execute write command: WRITE 0x%X = 0x%X\n" },
- { COMMAND_WRITEALL, "Execute write command: WRITEALL (%X) = 0x%X\n" },
- };
- const char *command_string = "UNKNOWN";
- for (int index = 0; index < ARRAY_LENGTH(s_command_names); index++)
- if (s_command_names[index].command == m_command)
- command_string = s_command_names[index].string;
- LOG1((command_string, m_address, m_shift_register));
-#endif
-
- // each command advances differently
- switch (m_command)
- {
- // reset the shift register and wait for enough data to be clocked through
- case COMMAND_WRITE:
- if (m_locked)
- {
- LOG0(("EEPROM: Attempt to write to address 0x%X while locked\n", m_address));
- set_state(STATE_IN_RESET);
- break;
- }
- write(m_address, m_shift_register);
- set_state(STATE_WAIT_FOR_COMPLETION);
- break;
-
- // write the entire EEPROM with the same data; ERASEALL is required before so we
- // AND against the already-present data
- case COMMAND_WRITEALL:
- if (m_locked)
- {
- LOG0(("EEPROM: Attempt to write all while locked\n"));
- set_state(STATE_IN_RESET);
- break;
- }
- write_all(m_shift_register);
- set_state(STATE_WAIT_FOR_COMPLETION);
- break;
-
- default:
- throw emu_fatalerror("execute_write_command called with invalid command %d\n", m_command);
- }
-}
-
-
-
-//**************************************************************************
-// STANDARD INTERFACE IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// eeprom_serial_93cxx_device - constructor
-//-------------------------------------------------
-
-eeprom_serial_93cxx_device::eeprom_serial_93cxx_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file)
- : eeprom_serial_base_device(mconfig, devtype, name, tag, owner, shortname, file)
-{
-}
-
-
-//-------------------------------------------------
-// parse_command_and_address - extract the
-// command and address from a bitstream
-//-------------------------------------------------
-
-void eeprom_serial_93cxx_device::parse_command_and_address()
-{
- // set the defaults
- m_command = COMMAND_INVALID;
- m_address = m_command_address_accum & ((1 << m_command_address_bits) - 1);
-
- // extract the command portion and handle it
- switch (m_command_address_accum >> m_command_address_bits)
- {
- // opcode 0 needs two more bits to decode the operation
- case 0:
- switch (m_address >> (m_command_address_bits - 2))
- {
- case 0: m_command = COMMAND_LOCK; break;
- case 1: m_command = COMMAND_WRITEALL; break;
- case 2: m_command = COMMAND_ERASEALL; break;
- case 3: m_command = COMMAND_UNLOCK; break;
- }
- m_address = 0;
- break;
- case 1: m_command = COMMAND_WRITE; break;
- case 2: m_command = COMMAND_READ; break;
- case 3: m_command = COMMAND_ERASE; break;
- }
-
- // warn about out-of-range addresses
- if (m_address >= (1 << m_address_bits))
- LOG0(("EEPROM: out-of-range address 0x%X provided (maximum should be 0x%X)\n", m_address, (1 << m_address_bits) - 1));
-}
-
-
-//-------------------------------------------------
-// do_read - read handlers
-//-------------------------------------------------
-
-READ_LINE_MEMBER(eeprom_serial_93cxx_device::do_read) { return base_do_read() & ((m_state == STATE_WAIT_FOR_START_BIT) ? base_ready_read() : 1); }
-
-
-//-------------------------------------------------
-// cs_write/clk_write/di_write - write handlers
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER(eeprom_serial_93cxx_device::cs_write) { base_cs_write(state); }
-WRITE_LINE_MEMBER(eeprom_serial_93cxx_device::clk_write) { base_clk_write(state); }
-WRITE_LINE_MEMBER(eeprom_serial_93cxx_device::di_write) { base_di_write(state); }
-
-
-
-//**************************************************************************
-// ER5911 DEVICE IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// eeprom_serial_er5911_device - constructor
-//-------------------------------------------------
-
-eeprom_serial_er5911_device::eeprom_serial_er5911_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file)
- : eeprom_serial_base_device(mconfig, devtype, name, tag, owner, shortname, file)
-{
-}
-
-
-//-------------------------------------------------
-// parse_command_and_address - extract the
-// command and address from a bitstream
-//-------------------------------------------------
-
-void eeprom_serial_er5911_device::parse_command_and_address()
-{
- // set the defaults
- m_command = COMMAND_INVALID;
- m_address = m_command_address_accum & ((1 << m_command_address_bits) - 1);
-
- // extract the command portion and handle it
- switch (m_command_address_accum >> m_command_address_bits)
- {
- // opcode 0 needs two more bits to decode the operation
- case 0:
- switch (m_address >> (m_command_address_bits - 2))
- {
- case 0: m_command = COMMAND_LOCK; break;
- case 1: m_command = COMMAND_INVALID; break; // not on ER5911
- case 2: m_command = COMMAND_ERASEALL; break;
- case 3: m_command = COMMAND_UNLOCK; break;
- }
- m_address = 0;
- break;
- case 1: m_command = COMMAND_WRITE; break;
- case 2: m_command = COMMAND_READ; break;
- case 3: m_command = COMMAND_WRITE; break; // WRITE instead of ERASE on ER5911
- }
-
- // warn about out-of-range addresses
- if (m_address >= (1 << m_address_bits))
- LOG0(("EEPROM: out-of-range address 0x%X provided (maximum should be 0x%X)\n", m_address, (1 << m_address_bits) - 1));
-}
-
-
-//-------------------------------------------------
-// do_read/ready_read - read handlers
-//-------------------------------------------------
-
-READ_LINE_MEMBER(eeprom_serial_er5911_device::do_read) { return base_do_read(); }
-READ_LINE_MEMBER(eeprom_serial_er5911_device::ready_read) { return base_ready_read(); }
-
-
-//-------------------------------------------------
-// cs_write/clk_write/di_write - write handlers
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER(eeprom_serial_er5911_device::cs_write) { base_cs_write(state); }
-WRITE_LINE_MEMBER(eeprom_serial_er5911_device::clk_write) { base_clk_write(state); }
-WRITE_LINE_MEMBER(eeprom_serial_er5911_device::di_write) { base_di_write(state); }
-
-
-
-//**************************************************************************
-// X24c44 DEVICE IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// eeprom_serial_x24c44_device - constructor
-//-------------------------------------------------
-
-eeprom_serial_x24c44_device::eeprom_serial_x24c44_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file)
- : eeprom_serial_base_device(mconfig, devtype, name, tag, owner, shortname, file)
-{
-}
-
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void eeprom_serial_x24c44_device::device_start()
-{
- // if no command address bits set, just inherit from the address bits
- if (m_command_address_bits == 0)
- m_command_address_bits = m_address_bits;
-
- // start the base class
- eeprom_base_device::device_start();
-
- INT16 i=0;
- m_ram_length=0xf;
-
- for (i=0;i<16;i++){
- m_ram_data[i]=read(i); //autoreload at power up
- }
- m_reading=0;
- m_store_latch=0;
- // save the current state
- save_item(NAME(m_state));
- save_item(NAME(m_cs_state));
- save_item(NAME(m_oe_state));
- save_item(NAME(m_clk_state));
- save_item(NAME(m_di_state));
- save_item(NAME(m_locked));
- save_item(NAME(m_bits_accum));
- save_item(NAME(m_command_address_accum));
- save_item(NAME(m_command));
- save_item(NAME(m_address));
- save_item(NAME(m_shift_register));
- save_item(NAME(m_ram_data));
- save_item(NAME(m_reading));
- save_item(NAME(m_store_latch));
-}
-
-void eeprom_serial_x24c44_device::copy_eeprom_to_ram(){
- UINT16 i=0;
- LOG1(("EEPROM TO RAM COPY!!!\n"));
- for (i=0;i<16;i++){
- m_ram_data[i]=read(i);
- }
- m_store_latch=1;
-}
-
-
-
-void eeprom_serial_x24c44_device::copy_ram_to_eeprom(){
- UINT16 i=0;
- if (m_store_latch){
- LOG1(("RAM TO EEPROM COPY\n"));
- for (i=0;i<16;i++){
- write(i, m_ram_data[i]);
- }
- m_store_latch=0;
- }else{
- LOG0(("Store command with store latch not set!\n"));
- }
-
-}
-
-//-------------------------------------------------
-// execute_command - execute a command once we
-// have enough bits for one
-//-------------------------------------------------
-
-void eeprom_serial_x24c44_device::execute_command()
-{
- // parse into a generic command and reset the accumulator count
- parse_command_and_address();
- m_bits_accum = 0;
-
-#if (VERBOSE_PRINTF > 0 || VERBOSE_LOGERROR > 0)
- // for debugging purposes
- static const struct { eeprom_command command; const char *string; } s_command_names[] =
- {
- { COMMAND_INVALID, "Execute command: INVALID\n" },
- { COMMAND_READ, "Execute command:READ 0x%X\n" },
- { COMMAND_WRITE, "Execute command:WRITE 0x%X\n" },
- { COMMAND_ERASE, "Execute command:ERASE 0x%X\n" },
- { COMMAND_LOCK, "Execute command:LOCK\n" },
- { COMMAND_UNLOCK, "Execute command:UNLOCK\n" },
- { COMMAND_WRITEALL, "Execute command:WRITEALL\n" },
- { COMMAND_ERASEALL, "Execute command:ERASEALL\n" },
- { COMMAND_COPY_EEPROM_TO_RAM, "Execute command:COPY_EEPROM_TO_RAM\n" },
- { COMMAND_COPY_RAM_TO_EEPROM, "Execute command:COPY_RAM_TO_EEPROM\n" },
- };
- const char *command_string = s_command_names[0].string;
- for (int index = 0; index < ARRAY_LENGTH(s_command_names); index++)
- if (s_command_names[index].command == m_command)
- command_string = s_command_names[index].string;
- LOG1((command_string, m_address));
-#endif
-
- // each command advances differently
- switch (m_command)
- {
- // advance to the READING_DATA state; data is fetched after first CLK
- // reset the shift register to 0 to simulate the dummy 0 bit that happens prior
- // to the first clock
-
- // reset the shift register and wait for enough data to be clocked through
- case COMMAND_WRITE:
- m_shift_register = 0;
- set_state(STATE_WAIT_FOR_DATA);
- break;
-
- // lock the chip; return to IN_RESET state
- case COMMAND_LOCK:
- m_locked = true;
- m_store_latch=0;
- set_state(STATE_IN_RESET);
- break;
-
- // unlock the chip; return to IN_RESET state
- case COMMAND_UNLOCK:
- m_locked = false;
- m_store_latch=1;
- set_state(STATE_IN_RESET);
- break;
-
- // copy eeprom to ram
- case COMMAND_COPY_EEPROM_TO_RAM:
- copy_eeprom_to_ram();
- set_state(STATE_IN_RESET);
- break;
-
- // copy ram into eeprom
- case COMMAND_COPY_RAM_TO_EEPROM:
- copy_ram_to_eeprom();
- set_state(STATE_IN_RESET);
- break;
-
- default:
- throw emu_fatalerror("execute_command called with invalid command %d\n", m_command);
- }
-}
-
-
-void eeprom_serial_x24c44_device::handle_event(eeprom_event event)
-{
-//UINT32 tmp=0;
-#if (VERBOSE_PRINTF > 0 || VERBOSE_LOGERROR > 0)
- // for debugging purposes
- if ((event & EVENT_CS_RISING_EDGE) != 0) LOG2(("Event: CS rising\n"));
- if ((event & EVENT_CS_FALLING_EDGE) != 0) LOG2(("Event: CS falling\n"));
- if ((event & EVENT_CLK_RISING_EDGE) != 0)
- {
- if (m_state == STATE_WAIT_FOR_COMMAND || m_state == STATE_WAIT_FOR_DATA)
- LOG2(("Event: CLK rising (%d, DI=%d)\n", m_bits_accum + 1, m_di_state));
- else if (m_state == STATE_READING_DATA)
- LOG2(("Event: CLK rising (%d, DO=%d)\n", m_bits_accum + 1, (m_shift_register >> 30) & 1));
- else if (m_state == STATE_WAIT_FOR_START_BIT)
- LOG2(("Event: CLK rising (%d)\n", m_di_state));
- else
- LOG2(("Event: CLK rising\n"));
- }
- if ((event & EVENT_CLK_FALLING_EDGE) != 0) LOG4(("Event: CLK falling\n"));
-#endif
-
- // switch off the current state
- switch (m_state)
- {
- // CS is not asserted; wait for a rising CS to move us forward, ignoring all clocks
- case STATE_IN_RESET:
- if (event == EVENT_CS_RISING_EDGE)
- set_state(STATE_WAIT_FOR_START_BIT);
- break;
-
- // CS is asserted; wait for rising clock with a 1 start bit; falling CS will reset us
- // note that because each bit is written independently, it is possible for us to receive
- // a false rising CLK edge at the exact same time as a rising CS edge; it appears we
- // should ignore these edges (makes sense really)
- case STATE_WAIT_FOR_START_BIT:
- if (event == EVENT_CLK_RISING_EDGE && m_di_state == ASSERT_LINE && ready() && machine().time() > m_last_cs_rising_edge_time)
- {
- m_command_address_accum = m_bits_accum = 0;
- set_state(STATE_WAIT_FOR_COMMAND);
- }
- else if (event == EVENT_CS_FALLING_EDGE)
- set_state(STATE_IN_RESET);
- break;
-
- // CS is asserted; wait for a command to come through; falling CS will reset us
- case STATE_WAIT_FOR_COMMAND:
- if (event == EVENT_CLK_RISING_EDGE)
- {
- // if we have enough bits for a command + address, check it out
- m_command_address_accum = (m_command_address_accum << 1) | m_di_state;
-
- m_bits_accum=m_bits_accum+1;
-
- if (m_bits_accum == 2 + m_command_address_bits){
- //read command is only 2 bits all other are 3 bits!!!
-
- parse_command_and_address_2_bit();
-
- }
-
- if (!m_reading){
- if (m_bits_accum == 3 + m_command_address_bits){
- execute_command();
- }
- }
- }
- else if (event == EVENT_CS_FALLING_EDGE)
- set_state(STATE_IN_RESET);
- break;
-
- // CS is asserted; reading data, clock the shift register; falling CS will reset us
- case STATE_READING_DATA:
- if (event == EVENT_CLK_RISING_EDGE)
- {
- int bit_index = m_bits_accum++;
-
- if (bit_index % m_data_bits == 0 && (bit_index == 0 || m_streaming_enabled)){
- m_shift_register=m_ram_data[m_address];
-
- //m_shift_register=BITSWAP16(m_shift_register,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
- //m_shift_register=BITSWAP16(m_shift_register,7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8);
- m_shift_register= BITSWAP16(m_shift_register,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7);
-
- m_shift_register=m_shift_register<<16;
-
- LOG1(("read from RAM addr %02X data(from ram) %04X ,m_shift_register vale %04X \n",m_address,m_ram_data[m_address],m_shift_register));
- }
- else{
- m_shift_register = (m_shift_register << 1) | 1;
-
- }
- }
- else if (event == EVENT_CS_FALLING_EDGE)
- {
- set_state(STATE_IN_RESET);
- m_reading=0;
- if (m_streaming_enabled)
- LOG1((" (%d cells read)\n", m_bits_accum / m_data_bits));
- if (!m_streaming_enabled && m_bits_accum > m_data_bits + 1)
- LOG1(("EEPROM: Overclocked read by %d bits\n", m_bits_accum - m_data_bits));
- else if (m_streaming_enabled && m_bits_accum > m_data_bits + 1 && m_bits_accum % m_data_bits > 2)
- LOG1(("EEPROM: Overclocked read by %d bits\n", m_bits_accum % m_data_bits));
- else if (m_bits_accum < m_data_bits)
- LOG1(("EEPROM: CS deasserted in READING_DATA after %d bits\n", m_bits_accum));
- }
- break;
-
- // CS is asserted; waiting for data; clock data through until we accumulate enough; falling CS will reset us
- case STATE_WAIT_FOR_DATA:
- if (event == EVENT_CLK_RISING_EDGE)
- {
- m_shift_register = (m_shift_register << 1) | m_di_state;
- if (++m_bits_accum == m_data_bits){
- //m_shift_register=BITSWAP16(m_shift_register, 0, 1, 2, 3, 4, 5,6,7, 8, 9,10,11,12,13,14,15);
- //m_shift_register=BITSWAP16(m_shift_register, 7, 6, 5, 4, 3, 2,1,0,15,14,13,12,11,10, 9, 8);
- m_shift_register=BITSWAP16(m_shift_register,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7);
- m_ram_data[m_address]=m_shift_register;
-
- LOG1(("write to RAM addr=%02X data=%04X\n",m_address,m_shift_register));
- }
- }
- else if (event == EVENT_CS_FALLING_EDGE)
- {
- set_state(STATE_IN_RESET);
- LOG1(("EEPROM: CS deasserted in STATE_WAIT_FOR_DATA after %d bits\n", m_bits_accum));
- }
- break;
-
-
- // CS is asserted; waiting for completion; watch for CS falling
- case STATE_WAIT_FOR_COMPLETION:
- if (event == EVENT_CS_FALLING_EDGE)
- set_state(STATE_IN_RESET);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// parse_command_and_address - extract the
-// command and address from a bitstream
-//-------------------------------------------------
-
-void eeprom_serial_x24c44_device::parse_command_and_address()
-{
- //command is start_bit - 4bit_address - 3bit_command
-
- // set the defaults
- m_command = COMMAND_INVALID;
-
- m_address = (m_command_address_accum >> 3) & 0x0f;
-
- LOG1(("EEPROM: command= %04X, address %02X\n", m_command_address_accum& 0x07, m_address));
-
- switch (m_command_address_accum & 0x07)
- {
- case 0: //reset write enable latch
- LOG0(("Lock eeprom\n"));
- m_command = COMMAND_LOCK; break;
- case 3: //write data into ram
- LOG0(("Write to ram\n"));
- m_command = COMMAND_WRITE; break;
- case 4: //set write enable latch
- LOG0(("Unlock eeprom\n"));
- m_command = COMMAND_UNLOCK; break;
- case 1: //store ram data in eeprom
- LOG0(("copy ram to eeprom\n"));
- m_command = COMMAND_COPY_RAM_TO_EEPROM; break;
- case 5: //reload eeprom data into ram
- LOG0(("copy eeprom to ram\n"));
- m_command = COMMAND_COPY_EEPROM_TO_RAM; break;
- case 2: //reserved (Sleep on x2444)
- m_command = COMMAND_INVALID;
- break;
-
- }
-
-}
-
-void eeprom_serial_x24c44_device::parse_command_and_address_2_bit()
-{
- if ((m_command_address_accum & 0x03) == 0x03){
- m_command = COMMAND_READ;
- m_address = ((m_command_address_accum >> 2) & 0x0f);
- m_shift_register = 0;
- set_state(STATE_READING_DATA);
- LOG1(("parse command_and_address_2_bit found a read command\n"));
- m_reading=1;
- m_bits_accum=0;
- }
-
- // warn about out-of-range addresses
- if (m_address >= (1 << m_address_bits))
- LOG1(("EEPROM: out-of-range address 0x%X provided (maximum should be 0x%X)\n", m_address, (1 << m_address_bits) - 1));
-}
-
-
-//-------------------------------------------------
-// do_read/ready_read - read handlers
-//-------------------------------------------------
-
-READ_LINE_MEMBER(eeprom_serial_x24c44_device::do_read) { return base_do_read(); }
-
-
-//-------------------------------------------------
-// cs_write/clk_write/di_write - write handlers
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER(eeprom_serial_x24c44_device::cs_write) { base_cs_write(state); }
-WRITE_LINE_MEMBER(eeprom_serial_x24c44_device::clk_write) { base_clk_write(state); }
-WRITE_LINE_MEMBER(eeprom_serial_x24c44_device::di_write) { base_di_write(state); }
-
-
-//**************************************************************************
-// DERIVED TYPES
-//**************************************************************************
-
-// macro for defining a new device class
-#define DEFINE_SERIAL_EEPROM_DEVICE(_baseclass, _lowercase, _uppercase, _bits, _cells, _addrbits) \
-eeprom_serial_##_lowercase##_##_bits##bit_device::eeprom_serial_##_lowercase##_##_bits##bit_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) \
- : eeprom_serial_##_baseclass##_device(mconfig, EEPROM_SERIAL_##_uppercase##_##_bits##BIT, "Serial EEPROM " #_uppercase " (" #_cells "x" #_bits ")", tag, owner, #_lowercase "_" #_bits, __FILE__) \
-{ \
- static_set_size(*this, _cells, _bits); \
- static_set_address_bits(*this, _addrbits); \
-} \
-const device_type EEPROM_SERIAL_##_uppercase##_##_bits##BIT = &device_creator<eeprom_serial_##_lowercase##_##_bits##bit_device>;
-// standard 93CX6 class of 16-bit EEPROMs
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c06, 93C06, 16, 16, 6)
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c46, 93C46, 16, 64, 6)
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c56, 93C56, 16, 128, 8)
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c57, 93C57, 16, 128, 7)
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c66, 93C66, 16, 256, 8)
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c76, 93C76, 16, 512, 10)
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c86, 93C86, 16, 1024, 10)
-
-// some manufacturers use pin 6 as an "ORG" pin which, when pulled low, configures memory for 8-bit accesses
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c46, 93C46, 8, 128, 7)
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c56, 93C56, 8, 256, 9)
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c57, 93C57, 8, 256, 8)
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c66, 93C66, 8, 512, 9)
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c76, 93C76, 8, 1024, 11)
-DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c86, 93C86, 8, 2048, 11)
-
-// ER5911 has a separate ready pin, a reduced command set, and supports 8/16 bit out of the box
-DEFINE_SERIAL_EEPROM_DEVICE(er5911, er5911, ER5911, 8, 128, 9)
-DEFINE_SERIAL_EEPROM_DEVICE(er5911, er5911, ER5911, 16, 64, 8)
-DEFINE_SERIAL_EEPROM_DEVICE(er5911, msm16911, MSM16911, 8, 128, 9)
-DEFINE_SERIAL_EEPROM_DEVICE(er5911, msm16911, MSM16911, 16, 64, 8)
-
-// X24c44 8 bit 32byte ram/eeprom combo
-DEFINE_SERIAL_EEPROM_DEVICE(x24c44, x24c44, X24C44, 16, 16, 4)
diff --git a/src/emu/machine/eepromser.h b/src/emu/machine/eepromser.h
deleted file mode 100644
index 49161ba883f..00000000000
--- a/src/emu/machine/eepromser.h
+++ /dev/null
@@ -1,295 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- eepromser.h
-
- Serial EEPROM devices.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __EEPROMSER_H__
-#define __EEPROMSER_H__
-
-#include "eeprom.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-// standard 93CX6 class of 16-bit EEPROMs
-#define MCFG_EEPROM_SERIAL_93C06_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C06_16BIT, 0)
-#define MCFG_EEPROM_SERIAL_93C46_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C46_16BIT, 0)
-#define MCFG_EEPROM_SERIAL_93C56_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C56_16BIT, 0)
-#define MCFG_EEPROM_SERIAL_93C57_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C57_16BIT, 0)
-#define MCFG_EEPROM_SERIAL_93C66_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C66_16BIT, 0)
-#define MCFG_EEPROM_SERIAL_93C76_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C76_16BIT, 0)
-#define MCFG_EEPROM_SERIAL_93C86_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C86_16BIT, 0)
-
-// some manufacturers use pin 6 as an "ORG" pin which, when pulled low, configures memory for 8-bit accesses
-#define MCFG_EEPROM_SERIAL_93C46_8BIT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C46_8BIT, 0)
-#define MCFG_EEPROM_SERIAL_93C56_8BIT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C56_8BIT, 0)
-#define MCFG_EEPROM_SERIAL_93C57_8BIT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C57_8BIT, 0)
-#define MCFG_EEPROM_SERIAL_93C66_8BIT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C66_8BIT, 0)
-#define MCFG_EEPROM_SERIAL_93C76_8BIT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C76_8BIT, 0)
-#define MCFG_EEPROM_SERIAL_93C86_8BIT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C86_8BIT, 0)
-
-// ER5911 has a separate ready pin, a reduced command set, and supports 8/16 bit out of the box
-#define MCFG_EEPROM_SERIAL_ER5911_8BIT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_ER5911_8BIT, 0)
-#define MCFG_EEPROM_SERIAL_ER5911_16BIT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_ER5911_16BIT, 0)
-
-#define MCFG_EEPROM_SERIAL_MSM16911_8BIT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_MSM16911_8BIT, 0)
-#define MCFG_EEPROM_SERIAL_MSM16911_16BIT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_MSM16911_16BIT, 0)
-
-// X24c44 16 bit ram/eeprom combo
-#define MCFG_EEPROM_SERIAL_X24C44_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_X24C44_16BIT, 0)
-
-// optional enable for streaming reads
-#define MCFG_EEPROM_SERIAL_ENABLE_STREAMING() \
- eeprom_serial_base_device::static_enable_streaming(*device);
-// pass-throughs to the base class for setting default data
-#define MCFG_EEPROM_SERIAL_DATA MCFG_EEPROM_DATA
-#define MCFG_EEPROM_SERIAL_DEFAULT_VALUE MCFG_EEPROM_DEFAULT_VALUE
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-// ======================> eeprom_serial_base_device
-
-class eeprom_serial_base_device : public eeprom_base_device
-{
-protected:
- // construction/destruction
- eeprom_serial_base_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file);
-
-public:
- // inline configuration helpers
- static void static_set_address_bits(device_t &device, int addrbits);
- static void static_enable_streaming(device_t &device);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- // read interfaces differ between implementations
-
- // commands
- enum eeprom_command
- {
- COMMAND_INVALID,
- COMMAND_READ,
- COMMAND_WRITE,
- COMMAND_ERASE,
- COMMAND_LOCK,
- COMMAND_UNLOCK,
- COMMAND_WRITEALL,
- COMMAND_ERASEALL,
- COMMAND_COPY_EEPROM_TO_RAM,
- COMMAND_COPY_RAM_TO_EEPROM
- };
-
- // states
- enum eeprom_state
- {
- STATE_IN_RESET,
- STATE_WAIT_FOR_START_BIT,
- STATE_WAIT_FOR_COMMAND,
- STATE_READING_DATA,
- STATE_WAIT_FOR_DATA,
- STATE_WAIT_FOR_COMPLETION
- };
-
- // events
- enum eeprom_event
- {
- EVENT_CS_RISING_EDGE = 1 << 0,
- EVENT_CS_FALLING_EDGE = 1 << 1,
- EVENT_CLK_RISING_EDGE = 1 << 2,
- EVENT_CLK_FALLING_EDGE = 1 << 3
- };
-
- // internal helpers
- void set_state(eeprom_state newstate);
- void execute_write_command();
-
- // subclass helpers
- void base_cs_write(int state);
- void base_clk_write(int state);
- void base_di_write(int state);
- int base_do_read();
- int base_ready_read();
-
- // subclass overrides
- virtual void handle_event(eeprom_event event);
- virtual void parse_command_and_address() = 0;
- virtual void execute_command();
-
-
- // configuration state
- UINT8 m_command_address_bits; // number of address bits in a command
- bool m_streaming_enabled; // true if streaming is enabled
-
- // runtime state
- eeprom_state m_state; // current internal state
- UINT8 m_cs_state; // state of the CS line
- attotime m_last_cs_rising_edge_time; // time of the last CS rising edge
- UINT8 m_oe_state; // state of the OE line
- UINT8 m_clk_state; // state of the CLK line
- UINT8 m_di_state; // state of the DI line
- bool m_locked; // are we locked against writes?
- UINT32 m_bits_accum; // number of bits accumulated
- UINT32 m_command_address_accum; // accumulator of command+address bits
- eeprom_command m_command; // current command
- UINT32 m_address; // current address extracted from command
- UINT32 m_shift_register; // holds data coming in/going out
-};
-
-
-
-// ======================> eeprom_serial_93cxx_device
-
-class eeprom_serial_93cxx_device : public eeprom_serial_base_device
-{
-protected:
- // construction/destruction
- eeprom_serial_93cxx_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file);
-
-public:
- // read handlers
- DECLARE_READ_LINE_MEMBER(do_read); // combined DO+READY/BUSY
-
- // write handlers
- DECLARE_WRITE_LINE_MEMBER(cs_write); // CS signal (active high)
- DECLARE_WRITE_LINE_MEMBER(clk_write); // CLK signal (active high)
- DECLARE_WRITE_LINE_MEMBER(di_write); // DI
-
-protected:
- // subclass overrides
- virtual void parse_command_and_address();
-};
-
-
-// ======================> eeprom_serial_er5911_device
-
-class eeprom_serial_er5911_device : public eeprom_serial_base_device
-{
-protected:
- // construction/destruction
- eeprom_serial_er5911_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file);
-
-public:
- // read handlers
- DECLARE_READ_LINE_MEMBER(do_read); // DO
- DECLARE_READ_LINE_MEMBER(ready_read); // READY/BUSY only
-
- // write handlers
- DECLARE_WRITE_LINE_MEMBER(cs_write); // CS signal (active high)
- DECLARE_WRITE_LINE_MEMBER(clk_write); // CLK signal (active high)
- DECLARE_WRITE_LINE_MEMBER(di_write); // DI
-
-protected:
- // subclass overrides
- virtual void parse_command_and_address();
-};
-
-
-// ======================> eeprom_serial_x24c44_device
-
-class eeprom_serial_x24c44_device : public eeprom_serial_base_device
-{
- //async recall not implemented
- //async store not implemented
-protected:
- // construction/destruction
- eeprom_serial_x24c44_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file);
-
-public:
- // read handlers
- DECLARE_READ_LINE_MEMBER(do_read); // DO
-
- // write handlers
- DECLARE_WRITE_LINE_MEMBER(cs_write); // CS signal (active high)
- DECLARE_WRITE_LINE_MEMBER(clk_write); // CLK signal (active high)
- DECLARE_WRITE_LINE_MEMBER(di_write); // DI
-
-protected:
- // subclass overrides
- virtual void parse_command_and_address();
- void handle_event(eeprom_event event);
- virtual void parse_command_and_address_2_bit();
- void execute_command();
- void copy_ram_to_eeprom();
- void copy_eeprom_to_ram();
- void device_start();
- UINT8 m_ram_length;
- UINT16 m_ram_data[16];
- UINT16 m_reading;
- UINT8 m_store_latch;
-};
-
-
-
-//**************************************************************************
-// DERIVED TYPES
-//**************************************************************************
-
-// macro for declaring a new device class
-#define DECLARE_SERIAL_EEPROM_DEVICE(_baseclass, _lowercase, _uppercase, _bits) \
-class eeprom_serial_##_lowercase##_##_bits##bit_device : public eeprom_serial_##_baseclass##_device \
-{ \
-public: \
- eeprom_serial_##_lowercase##_##_bits##bit_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); \
-}; \
-extern const device_type EEPROM_SERIAL_##_uppercase##_##_bits##BIT;
-// standard 93CX6 class of 16-bit EEPROMs
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c06, 93C06, 16)
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c46, 93C46, 16)
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c56, 93C56, 16)
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c57, 93C57, 16)
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c66, 93C66, 16)
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c76, 93C76, 16)
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c86, 93C86, 16)
-
-// some manufacturers use pin 6 as an "ORG" pin which, when pulled low, configures memory for 8-bit accesses
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c46, 93C46, 8)
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c56, 93C56, 8)
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c57, 93C57, 8)
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c66, 93C66, 8)
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c76, 93C76, 8)
-DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c86, 93C86, 8)
-
-// ER5911 has a separate ready pin, a reduced command set, and supports 8/16 bit out of the box
-DECLARE_SERIAL_EEPROM_DEVICE(er5911, er5911, ER5911, 8)
-DECLARE_SERIAL_EEPROM_DEVICE(er5911, er5911, ER5911, 16)
-DECLARE_SERIAL_EEPROM_DEVICE(er5911, msm16911, MSM16911, 8)
-DECLARE_SERIAL_EEPROM_DEVICE(er5911, msm16911, MSM16911, 16)
-
-// X24c44 8 bit 32byte ram/eeprom combo
-DECLARE_SERIAL_EEPROM_DEVICE(x24c44, x24c44, X24C44, 16)
-#endif
diff --git a/src/emu/machine/er2055.c b/src/emu/machine/er2055.c
deleted file mode 100644
index 24ab1766744..00000000000
--- a/src/emu/machine/er2055.c
+++ /dev/null
@@ -1,177 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- er2055.c
-
- GI 512 bit electrically alterable read-only memory.
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/er2055.h"
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type ER2055 = &device_creator<er2055_device>;
-
-static ADDRESS_MAP_START( er2055_map, AS_PROGRAM, 8, er2055_device )
- AM_RANGE(0x0000, 0x003f) AM_RAM
-ADDRESS_MAP_END
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// er2055_device - constructor
-//-------------------------------------------------
-
-er2055_device::er2055_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, ER2055, "ER2055 EAROM", tag, owner, clock, "er2055", __FILE__),
- device_memory_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this),
- m_space_config("EAROM", ENDIANNESS_BIG, 8, 6, 0, *ADDRESS_MAP_NAME(er2055_map)),
- m_control_state(0),
- m_address(0),
- m_data(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void er2055_device::device_start()
-{
- save_item(NAME(m_control_state));
- save_item(NAME(m_address));
- save_item(NAME(m_data));
-
- m_control_state = 0;
-}
-
-
-//-------------------------------------------------
-// memory_space_config - return a description of
-// any address spaces owned by this device
-//-------------------------------------------------
-
-const address_space_config *er2055_device::memory_space_config(address_spacenum spacenum) const
-{
- return (spacenum == 0) ? &m_space_config : NULL;
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void er2055_device::nvram_default()
-{
- // default to all-0xff
- for (int byte = 0; byte < SIZE_DATA; byte++)
- m_addrspace[0]->write_byte(byte, 0xff);
-
- // populate from a memory region if present
- if (m_region != NULL)
- {
- if (m_region->bytes() != SIZE_DATA)
- fatalerror("er2055 region '%s' wrong size (expected size = 0x40)\n", tag());
- if (m_region->bytewidth() != 1)
- fatalerror("er2055 region '%s' needs to be an 8-bit region\n", tag());
-
- UINT8 *default_data = m_region->base();
- for (int byte = 0; byte < SIZE_DATA; byte++)
- m_addrspace[0]->write_byte(byte, default_data[byte]);
- }
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void er2055_device::nvram_read(emu_file &file)
-{
- UINT8 buffer[SIZE_DATA];
- file.read(buffer, sizeof(buffer));
- for (int byte = 0; byte < SIZE_DATA; byte++)
- m_addrspace[0]->write_byte(byte, buffer[byte]);
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void er2055_device::nvram_write(emu_file &file)
-{
- UINT8 buffer[SIZE_DATA];
- for (int byte = 0; byte < SIZE_DATA; byte++)
- buffer[byte] = m_addrspace[0]->read_byte(byte);
- file.write(buffer, sizeof(buffer));
-}
-
-
-
-//**************************************************************************
-// I/O OPERATIONS
-//**************************************************************************
-
-//-------------------------------------------------
-// set_control - set the control lines; these
-// must be done simultaneously because the chip
-// reacts to various combinations
-//-------------------------------------------------
-
-void er2055_device::set_control(UINT8 cs1, UINT8 cs2, UINT8 c1, UINT8 c2, UINT8 ck)
-{
- // create a new composite control state
- UINT8 oldstate = m_control_state;
- m_control_state = (ck != 0) ? CK : 0;
- m_control_state |= (c1 != 0) ? C1 : 0;
- m_control_state |= (c2 != 0) ? C2 : 0;
- m_control_state |= (cs1 != 0) ? CS1 : 0;
- m_control_state |= (cs2 != 0) ? CS2 : 0;
-
- // if not selected, or if change from previous, we're done
- if ((m_control_state & (CS1 | CS2)) != (CS1 | CS2) || m_control_state == oldstate)
- return;
-
- // something changed, see what it is based on what mode we're in
- switch (m_control_state & (C1 | C2))
- {
- // write mode; erasing is required, so we perform an AND against previous
- // data to simulate incorrect behavior if erasing was not done
- case 0:
- m_addrspace[0]->write_byte(m_address, m_addrspace[0]->read_byte(m_address) & m_data);
-//printf("Write %02X = %02X\n", m_address, m_data);
- break;
-
- // erase mode
- case C2:
- m_addrspace[0]->write_byte(m_address, 0xff);
-//printf("Erase %02X\n", m_address);
- break;
-
- // read mode
- case C1:
- if ((oldstate & CK) != 0 && (m_control_state & CK) == 0)
- {
- m_data = m_addrspace[0]->read_byte(m_address);
-//printf("Read %02X = %02X\n", m_address, m_data);
- }
- break;
- }
-}
diff --git a/src/emu/machine/er2055.h b/src/emu/machine/er2055.h
deleted file mode 100644
index 58919f30e4c..00000000000
--- a/src/emu/machine/er2055.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- er2055.h
-
- GI 512 bit electrically alterable read-only memory.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __ER2055_H__
-#define __ER2055_H__
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_ER2055_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, ER2055, 0)
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-// ======================> er2055_device
-
-class er2055_device : public device_t,
- public device_memory_interface,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- er2055_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // I/O operations
- UINT8 data() const { return m_data; }
- void set_address(UINT8 address) { m_address = address & 0x3f; }
- void set_data(UINT8 data) { m_data = data; }
-
- // control lines -- all lines are specified as active-high (even CS2)
- void set_control(UINT8 cs1, UINT8 cs2, UINT8 c1, UINT8 c2, UINT8 ck);
-
-protected:
- // device-level overrides
- virtual void device_start();
-
- // device_memory_interface overrides
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
- static const int SIZE_DATA = 0x40;
-
- static const UINT8 CK = 0x01;
- static const UINT8 C1 = 0x02;
- static const UINT8 C2 = 0x04;
- static const UINT8 CS1 = 0x08;
- static const UINT8 CS2 = 0x10;
-
- // configuration state
- address_space_config m_space_config;
-
- // internal state
- UINT8 m_control_state;
- UINT8 m_address;
- UINT8 m_data;
-};
-
-
-// device type definition
-extern const device_type ER2055;
-
-
-#endif
diff --git a/src/emu/machine/f3853.c b/src/emu/machine/f3853.c
deleted file mode 100644
index a37e1b7e59b..00000000000
--- a/src/emu/machine/f3853.c
+++ /dev/null
@@ -1,211 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol
-/**********************************************************************
-
- Fairchild F3853 SRAM interface with integrated interrupt
- controller and timer (SMI)
-
- This chip is a timer shift register, basically the same as in the
- F3851.
-
- Based on a datasheet obtained from www.freetradezone.com
-
- The SMI does not have DC0 and DC1, only DC0; as a result, it does
- not respond to the main CPU's DC0/DC1 swap instruction. This may
- lead to two devices responding to the same DC0 address and
- attempting to place their bytes on the data bus simultaneously!
-
- 8-bit shift register:
- Feedback in0 = !((out3 ^ out4) ^ (out5 ^ out7))
- Interrupts are at 0xfe
- 0xff stops the register (0xfe is never reached)
-
-**********************************************************************/
-
-#include "emu.h"
-#include "f3853.h"
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-#define INTERRUPT_VECTOR(external) ( external ? m_low | ( m_high << 8 ) | 0x80 \
-: ( m_low | ( m_high << 8 ) ) & ~0x80 )
-
-
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type F3853 = &device_creator<f3853_device>;
-
-//-------------------------------------------------
-// f3853_device - constructor
-//-------------------------------------------------
-
-f3853_device::f3853_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, F3853, "F3853", tag, owner, clock, "f3853", __FILE__)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void f3853_device::device_start()
-{
- UINT8 reg = 0xfe;
- for(INT32 i=254 /* Known to get 0xfe after 255 cycles */; i >= 0; i--)
- {
- INT32 o7 = (reg & 0x80) ? TRUE : FALSE;
- INT32 o5 = (reg & 0x20) ? TRUE : FALSE;
- INT32 o4 = (reg & 0x10) ? TRUE : FALSE;
- INT32 o3 = (reg & 0x08) ? TRUE : FALSE;
- m_value_to_cycle[reg] = i;
- reg <<= 1;
- if (!((o7 != o5) != (o4 != o3)))
- {
- reg |= 1;
- }
- }
-
- m_interrupt_req_cb.bind_relative_to(*owner());
-
- m_timer = machine().scheduler().timer_alloc(FUNC(f3853_timer_callback), (void *)this );
-
- save_item(NAME(m_high) );
- save_item(NAME(m_low) );
- save_item(NAME(m_external_enable) );
- save_item(NAME(m_timer_enable) );
- save_item(NAME(m_request_flipflop) );
- save_item(NAME(m_priority_line) );
- save_item(NAME(m_external_interrupt_line) );
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void f3853_device::device_reset()
-{
- m_high = 0;
- m_low = 0;
- m_external_enable = 0;
- m_timer_enable = 0;
- m_request_flipflop = 0;
- m_priority_line = FALSE;
- m_external_interrupt_line = TRUE;
-
- m_timer->enable(false);
-}
-
-
-void f3853_device::set_interrupt_request_line()
-{
- if (m_interrupt_req_cb.isnull())
- return;
-
- if (m_external_enable && !m_priority_line)
- m_interrupt_req_cb(INTERRUPT_VECTOR(TRUE), TRUE);
- else if (m_timer_enable && !m_priority_line && m_request_flipflop)
- m_interrupt_req_cb(INTERRUPT_VECTOR(FALSE), TRUE);
- else
- m_interrupt_req_cb(0, FALSE);
-}
-
-
-void f3853_device::timer_start(UINT8 value)
-{
- attotime period = (value != 0xff) ? attotime::from_hz(clock()) * (m_value_to_cycle[value]*31) : attotime::never;
-
- m_timer->adjust(period);
-}
-
-
-TIMER_CALLBACK( f3853_device::f3853_timer_callback )
-{
- reinterpret_cast<f3853_device*>(ptr)->timer();
-}
-
-void f3853_device::timer()
-{
- if(m_timer_enable)
- {
- m_request_flipflop = TRUE;
- set_interrupt_request_line();
- }
- timer_start(0xfe);
-}
-
-void f3853_device::set_external_interrupt_in_line(int level)
-{
- if(m_external_interrupt_line && !level && m_external_enable)
- {
- m_request_flipflop = TRUE;
- }
- m_external_interrupt_line = level;
- set_interrupt_request_line();
-}
-
-void f3853_device::set_priority_in_line(int level)
-{
- m_priority_line = level;
- set_interrupt_request_line();
-}
-
-
-READ8_MEMBER(f3853_device::read)
-{
- UINT8 data = 0;
-
- switch (offset)
- {
- case 0:
- data = m_high;
- break;
-
- case 1:
- data = m_low;
- break;
-
- case 2: // Interrupt control; not readable
- case 3: // Timer; not readable
- break;
- }
-
- return data;
-}
-
-
-WRITE8_MEMBER(f3853_device::write)
-{
- switch(offset)
- {
- case 0:
- m_high = data;
- break;
-
- case 1:
- m_low = data;
- break;
-
- case 2: //interrupt control
- m_external_enable = ((data & 3) == 1);
- m_timer_enable = ((data & 3) == 3);
- set_interrupt_request_line();
- break;
-
- case 3: //timer
- m_request_flipflop = FALSE;
- set_interrupt_request_line();
- timer_start(data);
- break;
- }
-}
diff --git a/src/emu/machine/f3853.h b/src/emu/machine/f3853.h
deleted file mode 100644
index f2afc03b588..00000000000
--- a/src/emu/machine/f3853.h
+++ /dev/null
@@ -1,110 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol
-/***************************************************************************
-
- Fairchild F3853 SRAM interface with integrated interrupt
- controller and timer
-
- This chip is a timer shift register, basically the same as in the
- F3851.
-
-****************************************************************************
- _____ _____
- Vgg 1 |* \_/ | 40 Vdd
- PHI 2 | | 39 ROMC4
- WRITE 3 | | 38 ROMC3
- _INT REQ 4 | | 37 ROMC2
- _PRI IN 5 | | 36 ROMC1
- _RAM WRITE 6 | | 35 ROMC0
- _EXT INT 7 | | 34 CPU READ
- ADDR7 8 | | 33 REG DR
- ADDR6 9 | | 32 ADDR15
- ADDR5 10 | F3853 | 31 ADDR14
- ADDR4 11 | | 30 ADDR13
- ADDR3 12 | | 29 ADDR12
- ADDR2 13 | | 28 ADDR11
- ADDR1 14 | | 27 ADDR10
- ADDR0 15 | | 26 ADDR9
- DB0 16 | | 25 ADDR8
- DB1 17 | | 24 DB7
- DB2 18 | | 23 DB6
- DB3 19 | | 22 DB5
- Vss 20 |_____________| 21 DB4
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __F3853_H__
-#define __F3853_H__
-
-#include "emu.h"
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_F3853_EXT_INPUT_CB(_class, _method) \
- f3853_device::set_interrupt_req_callback(*device, f3853_interrupt_req_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-typedef device_delegate<void (UINT16 addr, int level)> f3853_interrupt_req_delegate;
-
-#define F3853_INTERRUPT_REQ_CB(_name) void _name(UINT16 addr, int level)
-
-
-// ======================> f3853_device
-
-class f3853_device : public device_t
-{
-public:
- // construction/destruction
- f3853_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void set_interrupt_req_callback(device_t &device, f3853_interrupt_req_delegate callback) { downcast<f3853_device &>(device).m_interrupt_req_cb = callback; }
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- void set_external_interrupt_in_line(int level);
- void set_priority_in_line(int level);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_post_load() { }
- virtual void device_clock_changed() { }
-
- static TIMER_CALLBACK( f3853_timer_callback );
-
-private:
-
- void set_interrupt_request_line();
- void timer_start(UINT8 value);
- void timer();
-
- f3853_interrupt_req_delegate m_interrupt_req_cb;
- UINT8 m_high;
- UINT8 m_low; // Bit 7 is set to 0 for timer interrupts, 1 for external interrupts
- INT32 m_external_enable;
- INT32 m_timer_enable;
-
- INT32 m_request_flipflop;
-
- INT32 m_priority_line; /* inverted level*/
- INT32 m_external_interrupt_line; /* inverted level */
-
- emu_timer *m_timer;
-
- UINT8 m_value_to_cycle[0x100];
-};
-
-
-// device type definition
-extern const device_type F3853;
-
-#endif /* __F3853_H__ */
diff --git a/src/emu/machine/fdc37c665gt.c b/src/emu/machine/fdc37c665gt.c
deleted file mode 100644
index 671d0314560..00000000000
--- a/src/emu/machine/fdc37c665gt.c
+++ /dev/null
@@ -1,61 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "fdc37c665gt.h"
-
-fdc37c665gt_device::fdc37c665gt_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, FDC37C665GT, "FDC37C665GT", tag, owner, clock, "fdc37c665gt", __FILE__),
- m_uart1(*this, "uart1"),
- m_uart2(*this, "uart2")
-{
-}
-
-READ8_MEMBER(fdc37c665gt_device::read)
-{
- UINT8 data = 0;
-
- if ((offset & 0x3f8) == 0x3f8)
- {
- data = m_uart1->ins8250_r(space, offset & 7, mem_mask);
- }
- else if ((offset & 0x3f8) == 0x2f8)
- {
- data = m_uart2->ins8250_r(space, offset & 7, mem_mask);
- }
- else
- {
- printf("fdc37c665gt_device::read %04x %02x\n", offset, data);
- }
- return data;
-}
-
-WRITE8_MEMBER(fdc37c665gt_device::write)
-{
- if ((offset & 0x3f8) == 0x3f8)
- {
- m_uart1->ins8250_w(space, offset & 7, data, mem_mask);
- }
- else if ((offset & 0x3f8) == 0x2f8)
- {
- m_uart2->ins8250_w(space, offset & 7, data, mem_mask);
- }
- else
- {
- printf("fdc37c665gt_device::write %04x %02x\n", offset, data);
- }
-}
-
-void fdc37c665gt_device::device_start()
-{
-}
-
-static MACHINE_CONFIG_FRAGMENT(fdc37c665gt)
- MCFG_DEVICE_ADD("uart1", NS16550, XTAL_24MHz/13)
- MCFG_DEVICE_ADD("uart2", NS16550, XTAL_24MHz/13)
-MACHINE_CONFIG_END
-
-machine_config_constructor fdc37c665gt_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME(fdc37c665gt);
-}
-
-const device_type FDC37C665GT = &device_creator<fdc37c665gt_device>;
diff --git a/src/emu/machine/fdc37c665gt.h b/src/emu/machine/fdc37c665gt.h
deleted file mode 100644
index f9401ab56ce..00000000000
--- a/src/emu/machine/fdc37c665gt.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
-* fdc37c665gt.h
-*
-*/
-
-#ifndef _FDC37C665GT_H_
-#define _FDC37C665GT_H_
-
-#pragma once
-
-#include "ins8250.h"
-
-class fdc37c665gt_device : public device_t
-{
-public:
- // construction/destruction
- fdc37c665gt_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual machine_config_constructor device_mconfig_additions() const;
-
-private:
- required_device<ns16550_device> m_uart1;
- required_device<ns16550_device> m_uart2;
-};
-
-// device type definition
-extern const device_type FDC37C665GT;
-
-#endif
diff --git a/src/emu/machine/fdc_pll.c b/src/emu/machine/fdc_pll.c
deleted file mode 100644
index cf616468a12..00000000000
--- a/src/emu/machine/fdc_pll.c
+++ /dev/null
@@ -1,134 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "fdc_pll.h"
-
-std::string fdc_pll_t::tts(attotime t)
-{
- char buf[256];
- bool neg = t.seconds() < 0;
- if(neg)
- t = attotime::zero - t;
- int nsec = t.attoseconds() / ATTOSECONDS_PER_NANOSECOND;
- sprintf(buf, "%c%3d.%03d,%03d,%03d", neg ? '-' : ' ', int(t.seconds()), nsec/1000000, (nsec/1000)%1000, nsec % 1000);
- return buf;
-}
-
-void fdc_pll_t::set_clock(const attotime &_period)
-{
- period = _period;
- period_adjust_base = period * 0.05;
- min_period = period * 0.75;
- max_period = period * 1.25;
-}
-
-void fdc_pll_t::reset(const attotime &when)
-{
- ctime = when;
- phase_adjust = attotime::zero;
- freq_hist = 0;
- write_position = 0;
- write_start_time = attotime::never;
-}
-
-void fdc_pll_t::start_writing(const attotime &tm)
-{
- write_start_time = tm;
- write_position = 0;
-}
-
-void fdc_pll_t::stop_writing(floppy_image_device *floppy, const attotime &tm)
-{
- commit(floppy, tm);
- write_start_time = attotime::never;
-}
-
-void fdc_pll_t::commit(floppy_image_device *floppy, const attotime &tm)
-{
- if(write_start_time.is_never() || tm == write_start_time)
- return;
-
- if(floppy)
- floppy->write_flux(write_start_time, tm, write_position, write_buffer);
- write_start_time = tm;
- write_position = 0;
-}
-
-int fdc_pll_t::get_next_bit(attotime &tm, floppy_image_device *floppy, const attotime &limit)
-{
- attotime edge = floppy ? floppy->get_next_transition(ctime) : attotime::never;
-
- attotime next = ctime + period + phase_adjust;
-
-#if 0
- if(!edge.is_never())
- fprintf(stderr, "ctime=%s, transition_time=%s, next=%s, pha=%s\n", tts(ctime).c_str(), tts(edge).c_str(), tts(next).c_str(), tts(phase_adjust).c_str());
-#endif
-
- if(next > limit)
- return -1;
-
- ctime = next;
- tm = next;
-
- if(edge.is_never() || edge >= next) {
- // No transition in the window means 0 and pll in free run mode
- phase_adjust = attotime::zero;
- return 0;
- }
-
- // Transition in the window means 1, and the pll is adjusted
-
- attotime delta = edge - (next - period/2);
-
- if(delta.seconds() < 0)
- phase_adjust = attotime::zero - ((attotime::zero - delta)*65)/100;
- else
- phase_adjust = (delta*65)/100;
-
- if(delta < attotime::zero) {
- if(freq_hist < 0)
- freq_hist--;
- else
- freq_hist = -1;
- } else if(delta > attotime::zero) {
- if(freq_hist > 0)
- freq_hist++;
- else
- freq_hist = 1;
- } else
- freq_hist = 0;
-
- if(freq_hist) {
- int afh = freq_hist < 0 ? -freq_hist : freq_hist;
- if(afh > 1) {
- attotime aper = attotime::from_double(period_adjust_base.as_double()*delta.as_double()/period.as_double());
- period += aper;
-
- if(period < min_period)
- period = min_period;
- else if(period > max_period)
- period = max_period;
- }
- }
-
- return 1;
-}
-
-bool fdc_pll_t::write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, const attotime &limit)
-{
- if(write_start_time.is_never()) {
- write_start_time = ctime;
- write_position = 0;
- }
-
- attotime etime = ctime + period;
- if(etime > limit)
- return true;
-
- if(bit && write_position < ARRAY_LENGTH(write_buffer))
- write_buffer[write_position++] = ctime + period/2;
-
- tm = etime;
- ctime = etime;
- return false;
-}
diff --git a/src/emu/machine/fdc_pll.h b/src/emu/machine/fdc_pll.h
deleted file mode 100644
index 31eaae07d1b..00000000000
--- a/src/emu/machine/fdc_pll.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef __FDC_PLL_H__
-#define __FDC_PLL_H__
-
-/*
- * Generic pll class for floppy controllers with analog plls
- */
-
-#include "emu.h"
-#include "imagedev/floppy.h"
-
-class fdc_pll_t {
-public:
- attotime ctime, period, min_period, max_period, period_adjust_base, phase_adjust;
-
- attotime write_start_time;
- attotime write_buffer[32];
- int write_position;
- int freq_hist;
-
- void set_clock(const attotime &period);
- void reset(const attotime &when);
- int get_next_bit(attotime &tm, floppy_image_device *floppy, const attotime &limit);
- bool write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, const attotime &limit);
- void start_writing(const attotime &tm);
- void commit(floppy_image_device *floppy, const attotime &tm);
- void stop_writing(floppy_image_device *floppy, const attotime &tm);
-
- std::string tts(attotime tm);
-};
-
-#endif
diff --git a/src/emu/machine/gayle.c b/src/emu/machine/gayle.c
deleted file mode 100644
index bf56f2aaf9e..00000000000
--- a/src/emu/machine/gayle.c
+++ /dev/null
@@ -1,210 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- GAYLE
-
- Gate array used in the Amiga 600 and Amiga 1200 computers.
-
-***************************************************************************/
-
-#include "gayle.h"
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-#define VERBOSE 0
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type GAYLE = &device_creator<gayle_device>;
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// gayle_device - constructor
-//-------------------------------------------------
-
-gayle_device::gayle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, GAYLE, "GAYLE", tag, owner, clock, "gayle", __FILE__),
- m_int2_w(*this),
- m_cs0_read(*this),
- m_cs0_write(*this),
- m_cs1_read(*this),
- m_cs1_write(*this),
- m_gayle_id(0xff),
- m_gayle_id_count(0)
-{
-}
-
-//-------------------------------------------------
-// set_id - set gayle id
-//-------------------------------------------------
-
-void gayle_device::set_id(device_t &device, UINT8 id)
-{
- gayle_device &gayle = downcast<gayle_device &>(device);
- gayle.m_gayle_id = id;
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void gayle_device::device_start()
-{
- // resolve callbacks
- m_int2_w.resolve_safe();
- m_cs0_read.resolve_safe(0xffff);
- m_cs0_write.resolve_safe();
- m_cs1_read.resolve_safe(0xffff);
- m_cs1_write.resolve_safe();
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void gayle_device::device_reset()
-{
- m_gayle_reg[0] = 0;
- m_gayle_reg[1] = 0;
- m_gayle_reg[2] = 0;
- m_gayle_reg[3] = 0;
-}
-
-
-//**************************************************************************
-// IMPLEMENTATION
-//**************************************************************************
-
-READ16_MEMBER( gayle_device::gayle_r )
-{
- UINT16 data = 0xffff;
- offset <<= 1;
-
- // swap
- mem_mask = (mem_mask << 8) | (mem_mask >> 8);
-
- if (BIT(offset, 15))
- {
- switch (offset & 0x7fff)
- {
- case 0x0000: data = m_gayle_reg[0]; break;
- case 0x1000: data = m_gayle_reg[1]; break;
- case 0x2000: data = m_gayle_reg[2]; break;
- case 0x3000: data = m_gayle_reg[3]; break;
- }
- }
- else
- {
- if (!BIT(offset, 14))
- {
- if (BIT(offset, 13))
- data = m_cs0_read(space, (offset >> 2) & 0x07, mem_mask);
- else
- data = m_cs1_read(space, (offset >> 2) & 0x07, mem_mask);
- }
- }
-
- if (VERBOSE)
- logerror("gayle_r(%06x): %04x & %04x\n", offset, data, mem_mask);
-
- // swap data
- data = (data << 8) | (data >> 8);
-
- return data;
-}
-
-WRITE16_MEMBER( gayle_device::gayle_w )
-{
- offset <<= 1;
-
- // swap
- mem_mask = (mem_mask << 8) | (mem_mask >> 8);
- data = ((data << 8) | (data >> 8)) & mem_mask;
-
- if (VERBOSE)
- logerror("gayle_w(%06x): %04x & %04x\n", offset, data, mem_mask);
-
- if (BIT(offset, 15))
- {
- switch (offset & 0x7fff)
- {
- case 0x0000:
- m_gayle_reg[0] = data;
- break;
- case 0x1000:
- m_gayle_reg[1] &= data;
- m_gayle_reg[1] |= data & 0x03;
- break;
- case 0x2000:
- m_gayle_reg[2] = data;
- break;
- case 0x3000:
- m_gayle_reg[3] = data;
- break;
- }
- }
- else
- {
- if (!BIT(offset, 14))
- {
- if (BIT(offset, 13))
- m_cs0_write(space, (offset >> 2) & 0x07, data, mem_mask);
- else
- m_cs1_write(space, (offset >> 2) & 0x07, data, mem_mask);
- }
- }
-}
-
-WRITE_LINE_MEMBER( gayle_device::ide_interrupt_w )
-{
- if (VERBOSE)
- logerror("ide_interrupt_w: %d\n", state);
-
- // did we change state?
- if (BIT(m_gayle_reg[GAYLE_CS], 7) != state)
- m_gayle_reg[GAYLE_IRQ] |= 1 << 7;
-
- // set line state
- if (state)
- m_gayle_reg[GAYLE_CS] |= 1 << 7;
- else
- m_gayle_reg[GAYLE_CS] &= ~(1 << 7);
-
- // update interrupts
- if (BIT(m_gayle_reg[GAYLE_INTEN], 7))
- m_int2_w(BIT(m_gayle_reg[GAYLE_CS], 7));
-}
-
-READ16_MEMBER( gayle_device::gayle_id_r )
-{
- UINT16 data = 0xffff;
-
- if (ACCESSING_BITS_8_15)
- data = ((m_gayle_id << m_gayle_id_count++) & 0x80) << 8;
- else
- data = 0xffff;
-
- if (VERBOSE)
- logerror("gayle_id_r(%06x): %04x & %04x (id=%02x)\n", offset, data, mem_mask, m_gayle_id);
-
- return data;
-}
-
-WRITE16_MEMBER( gayle_device::gayle_id_w )
-{
- if (VERBOSE)
- logerror("gayle_id_w(%06x): %04x & %04x (id=%02x)\n", offset, data, mem_mask, m_gayle_id);
-
- m_gayle_id_count = 0;
-}
diff --git a/src/emu/machine/gayle.h b/src/emu/machine/gayle.h
deleted file mode 100644
index 19e9cc5df73..00000000000
--- a/src/emu/machine/gayle.h
+++ /dev/null
@@ -1,110 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- GAYLE
-
- Gate array used in the Amiga 600 and Amiga 1200 computers.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __GAYLE_H__
-#define __GAYLE_H__
-
-#include "emu.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_GAYLE_ADD(_tag, _clock, _id) \
- MCFG_DEVICE_ADD(_tag, GAYLE, _clock) \
- gayle_device::set_id(*device, _id);
-
-#define MCFG_GAYLE_INT2_HANDLER(_devcb) \
- devcb = &gayle_device::set_int2_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_GAYLE_CS0_READ_HANDLER(_devcb) \
- devcb = &gayle_device::set_cs0_read_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_GAYLE_CS0_WRITE_HANDLER(_devcb) \
- devcb = &gayle_device::set_cs0_write_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_GAYLE_CS1_READ_HANDLER(_devcb) \
- devcb = &gayle_device::set_cs1_read_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_GAYLE_CS1_WRITE_HANDLER(_devcb) \
- devcb = &gayle_device::set_cs1_write_handler(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> gayle_device
-
-class gayle_device : public device_t
-{
-public:
- // construction/destruction
- gayle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // callbacks
- template<class _Object> static devcb_base &set_int2_handler(device_t &device, _Object object)
- { return downcast<gayle_device &>(device).m_int2_w.set_callback(object); }
-
- template<class _Object> static devcb_base &set_cs0_read_handler(device_t &device, _Object object)
- { return downcast<gayle_device &>(device).m_cs0_read.set_callback(object); }
-
- template<class _Object> static devcb_base &set_cs0_write_handler(device_t &device, _Object object)
- { return downcast<gayle_device &>(device).m_cs0_write.set_callback(object); }
-
- template<class _Object> static devcb_base &set_cs1_read_handler(device_t &device, _Object object)
- { return downcast<gayle_device &>(device).m_cs1_read.set_callback(object); }
-
- template<class _Object> static devcb_base &set_cs1_write_handler(device_t &device, _Object object)
- { return downcast<gayle_device &>(device).m_cs1_write.set_callback(object); }
-
- // interface
- DECLARE_WRITE_LINE_MEMBER( ide_interrupt_w );
-
- DECLARE_READ16_MEMBER( gayle_r );
- DECLARE_WRITE16_MEMBER( gayle_w );
- DECLARE_READ16_MEMBER( gayle_id_r );
- DECLARE_WRITE16_MEMBER( gayle_id_w );
-
- // inline configuration
- static void set_id(device_t &device, UINT8 id);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
-private:
- enum
- {
- GAYLE_CS = 0, // interrupt status
- GAYLE_IRQ, // interrupt change
- GAYLE_INTEN, // interrupt enable register
- GAYLE_CFG // config register
- };
-
- devcb_write_line m_int2_w;
-
- devcb_read16 m_cs0_read;
- devcb_write16 m_cs0_write;
- devcb_read16 m_cs1_read;
- devcb_write16 m_cs1_write;
-
- UINT8 m_gayle_id;
- int m_gayle_id_count;
- UINT8 m_gayle_reg[4];
-};
-
-// device type definition
-extern const device_type GAYLE;
-
-#endif
diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c
deleted file mode 100644
index 79a3ea3f5cf..00000000000
--- a/src/emu/machine/generic.c
+++ /dev/null
@@ -1,290 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Nicola Salmoria
-/*********************************************************************
-
- generic.c
-
- Generic simple machine functions.
-
-*********************************************************************/
-
-#include "emu.h"
-#include "emuopts.h"
-#include "config.h"
-
-
-
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-
-static void counters_load(running_machine &machine, int config_type, xml_data_node *parentnode);
-static void counters_save(running_machine &machine, int config_type, xml_data_node *parentnode);
-
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-struct generic_machine_private
-{
- /* tickets and coin counters */
- UINT32 dispensed_tickets;
- UINT32 coin_count[COIN_COUNTERS];
- UINT32 coinlockedout[COIN_COUNTERS];
- UINT32 lastcoin[COIN_COUNTERS];
-};
-
-
-
-/***************************************************************************
- INITIALIZATION
-***************************************************************************/
-
-/*-------------------------------------------------
- generic_machine_init - initialize globals and
- register for save states
--------------------------------------------------*/
-
-void generic_machine_init(running_machine &machine)
-{
- generic_machine_private *state;
- int counternum;
-
- /* allocate our state */
- machine.generic_machine_data = auto_alloc_clear(machine, generic_machine_private);
- state = machine.generic_machine_data;
-
- /* reset coin counters */
- for (counternum = 0; counternum < COIN_COUNTERS; counternum++)
- {
- state->lastcoin[counternum] = 0;
- state->coinlockedout[counternum] = 0;
- }
-
- /* register coin save state */
- machine.save().save_item(NAME(state->coin_count));
- machine.save().save_item(NAME(state->coinlockedout));
- machine.save().save_item(NAME(state->lastcoin));
-
- /* register for configuration */
- config_register(machine, "counters", config_saveload_delegate(FUNC(counters_load), &machine), config_saveload_delegate(FUNC(counters_save), &machine));
-}
-
-
-
-/***************************************************************************
- TICKETS
-***************************************************************************/
-
-/*-------------------------------------------------
- get_dispensed_tickets - return the number of
- tickets dispensed
--------------------------------------------------*/
-
-int get_dispensed_tickets(running_machine &machine)
-{
- generic_machine_private *state = machine.generic_machine_data;
- return state->dispensed_tickets;
-}
-
-
-/*-------------------------------------------------
- increment_dispensed_tickets - increment the
- number of dispensed tickets
--------------------------------------------------*/
-
-void increment_dispensed_tickets(running_machine &machine, int delta)
-{
- generic_machine_private *state = machine.generic_machine_data;
- state->dispensed_tickets += delta;
-}
-
-
-
-/***************************************************************************
- COIN COUNTERS
-***************************************************************************/
-
-/*-------------------------------------------------
- counters_load - load the state of the counters
- and tickets
--------------------------------------------------*/
-
-static void counters_load(running_machine &machine, int config_type, xml_data_node *parentnode)
-{
- generic_machine_private *state = machine.generic_machine_data;
- xml_data_node *coinnode, *ticketnode;
-
- /* on init, reset the counters */
- if (config_type == CONFIG_TYPE_INIT)
- {
- memset(state->coin_count, 0, sizeof(state->coin_count));
- state->dispensed_tickets = 0;
- }
-
- /* only care about game-specific data */
- if (config_type != CONFIG_TYPE_GAME)
- return;
-
- /* might not have any data */
- if (parentnode == NULL)
- return;
-
- /* iterate over coins nodes */
- for (coinnode = xml_get_sibling(parentnode->child, "coins"); coinnode; coinnode = xml_get_sibling(coinnode->next, "coins"))
- {
- int index = xml_get_attribute_int(coinnode, "index", -1);
- if (index >= 0 && index < COIN_COUNTERS)
- state->coin_count[index] = xml_get_attribute_int(coinnode, "number", 0);
- }
-
- /* get the single tickets node */
- ticketnode = xml_get_sibling(parentnode->child, "tickets");
- if (ticketnode != NULL)
- state->dispensed_tickets = xml_get_attribute_int(ticketnode, "number", 0);
-}
-
-
-/*-------------------------------------------------
- counters_save - save the state of the counters
- and tickets
--------------------------------------------------*/
-
-static void counters_save(running_machine &machine, int config_type, xml_data_node *parentnode)
-{
- generic_machine_private *state = machine.generic_machine_data;
- int i;
-
- /* only care about game-specific data */
- if (config_type != CONFIG_TYPE_GAME)
- return;
-
- /* iterate over coin counters */
- for (i = 0; i < COIN_COUNTERS; i++)
- if (state->coin_count[i] != 0)
- {
- xml_data_node *coinnode = xml_add_child(parentnode, "coins", NULL);
- if (coinnode != NULL)
- {
- xml_set_attribute_int(coinnode, "index", i);
- xml_set_attribute_int(coinnode, "number", state->coin_count[i]);
- }
- }
-
- /* output tickets */
- if (state->dispensed_tickets != 0)
- {
- xml_data_node *tickets = xml_add_child(parentnode, "tickets", NULL);
- if (tickets != NULL)
- xml_set_attribute_int(tickets, "number", state->dispensed_tickets);
- }
-}
-
-
-/*-------------------------------------------------
- coin_counter_w - sets input for coin counter
--------------------------------------------------*/
-
-void coin_counter_w(running_machine &machine, int num, int on)
-{
- generic_machine_private *state = machine.generic_machine_data;
- if (num >= ARRAY_LENGTH(state->coin_count))
- return;
-
- /* Count it only if the data has changed from 0 to non-zero */
- if (on && (state->lastcoin[num] == 0))
- state->coin_count[num]++;
- state->lastcoin[num] = on;
-}
-
-
-/*-------------------------------------------------
- coin_counter_get_count - return the coin count
- for a given coin
--------------------------------------------------*/
-
-int coin_counter_get_count(running_machine &machine, int num)
-{
- generic_machine_private *state = machine.generic_machine_data;
- if (num >= ARRAY_LENGTH(state->coin_count))
- return 0;
- return state->coin_count[num];
-}
-
-
-/*-------------------------------------------------
- coin_lockout_w - locks out one coin input
--------------------------------------------------*/
-
-void coin_lockout_w(running_machine &machine, int num,int on)
-{
- generic_machine_private *state = machine.generic_machine_data;
- if (num >= ARRAY_LENGTH(state->coinlockedout))
- return;
- state->coinlockedout[num] = on;
-}
-
-
-/*-------------------------------------------------
- coin_lockout_get_state - return current lockout
- state for a particular coin
--------------------------------------------------*/
-
-int coin_lockout_get_state(running_machine &machine, int num)
-{
- generic_machine_private *state = machine.generic_machine_data;
- if (num >= ARRAY_LENGTH(state->coinlockedout))
- return FALSE;
- return state->coinlockedout[num];
-}
-
-
-/*-------------------------------------------------
- coin_lockout_global_w - locks out all the coin
- inputs
--------------------------------------------------*/
-
-void coin_lockout_global_w(running_machine &machine, int on)
-{
- generic_machine_private *state = machine.generic_machine_data;
- int i;
-
- for (i = 0; i < ARRAY_LENGTH(state->coinlockedout); i++)
- coin_lockout_w(machine, i, on);
-}
-
-
-/***************************************************************************
- LED CODE
-***************************************************************************/
-
-/*-------------------------------------------------
- set_led_status - set the state of a given LED
--------------------------------------------------*/
-
-void set_led_status(running_machine &machine, int num, int on)
-{
- output_set_led_value(num, on);
-}
-
-
-
-
-/***************************************************************************
- PORT READING HELPERS
-***************************************************************************/
-
-/*-------------------------------------------------
- custom_port_read - act like input_port_read
- but it is a custom port, it is useful for
- e.g. input ports which expect the same port
- repeated both in the upper and lower half
--------------------------------------------------*/
-
-CUSTOM_INPUT_MEMBER( driver_device::custom_port_read )
-{
- const char *tag = (const char *)param;
- return ioport(tag)->read();
-}
diff --git a/src/emu/machine/generic.h b/src/emu/machine/generic.h
deleted file mode 100644
index b724a598a9d..00000000000
--- a/src/emu/machine/generic.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Nicola Salmoria
-/*********************************************************************
-
- generic.h
-
- Generic simple machine functions.
-
-*********************************************************************/
-
-#pragma once
-
-#ifndef __MACHINE_GENERIC_H__
-#define __MACHINE_GENERIC_H__
-
-
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-/* total # of coin counters */
-#define COIN_COUNTERS 8
-
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-
-
-/* ----- initialization ----- */
-
-/* set up all the common systems */
-void generic_machine_init(running_machine &machine);
-
-
-
-/* ----- tickets ----- */
-
-/* return the number of tickets dispensed */
-int get_dispensed_tickets(running_machine &machine);
-
-/* increment the number of dispensed tickets */
-void increment_dispensed_tickets(running_machine &machine, int delta);
-
-
-
-/* ----- coin counters ----- */
-
-/* write to a particular coin counter (clocks on active high edge) */
-void coin_counter_w(running_machine &machine, int num, int on);
-
-/* return the coin count for a given coin */
-int coin_counter_get_count(running_machine &machine, int num);
-
-/* enable/disable coin lockout for a particular coin */
-void coin_lockout_w(running_machine &machine, int num, int on);
-
-/* return current lockout state for a particular coin */
-int coin_lockout_get_state(running_machine &machine, int num);
-
-/* enable/disable global coin lockout */
-void coin_lockout_global_w(running_machine &machine, int on);
-
-/* ----- miscellaneous bits & pieces ----- */
-
-/* set the status of an LED */
-void set_led_status(running_machine &machine, int num, int value);
-
-#endif /* __MACHINE_GENERIC_H__ */
diff --git a/src/emu/machine/hd63450.c b/src/emu/machine/hd63450.c
deleted file mode 100644
index 9528026b95e..00000000000
--- a/src/emu/machine/hd63450.c
+++ /dev/null
@@ -1,555 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Barry Rodewald
-/*
- Hitachi HD63450 DMA Controller
-
- Largely based on documentation of the Sharp X68000
-*/
-
-#include "hd63450.h"
-
-const device_type HD63450 = &device_creator<hd63450_device>;
-
-hd63450_device::hd63450_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, HD63450, "Hitachi HD63450", tag, owner, clock, "hd63450", __FILE__),
- m_dma_end(*this),
- m_dma_error(*this),
- m_dma_read_0(*this),
- m_dma_read_1(*this),
- m_dma_read_2(*this),
- m_dma_read_3(*this),
- m_dma_write_0(*this),
- m_dma_write_1(*this),
- m_dma_write_2(*this),
- m_dma_write_3(*this),
- m_cpu_tag(NULL),
- m_cpu(NULL)
-{
- for (int i = 0; i < 4; i++)
- {
- memset(&m_reg[i], 0, sizeof(m_reg[i]));
- m_timer[i] = NULL;
- m_in_progress[i] = 0;
- m_transfer_size[i] = 0;
- m_halted[i] = 0;
- m_our_clock[i] = attotime::zero;
- m_burst_clock[i] = attotime::zero;
- }
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void hd63450_device::device_start()
-{
- // get the CPU device
- m_cpu = machine().device<cpu_device>(m_cpu_tag);
- assert(m_cpu != NULL);
-
- // resolve callbacks
- m_dma_end.resolve();
- m_dma_error.resolve_safe();
- m_dma_read_0.resolve();
- m_dma_read_1.resolve();
- m_dma_read_2.resolve();
- m_dma_read_3.resolve();
- m_dma_write_0.resolve();
- m_dma_write_1.resolve();
- m_dma_write_2.resolve();
- m_dma_write_3.resolve();
-
- // Initialise timers and registers
- for (int x = 0; x < 4 ; x++)
- {
- m_timer[x] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(hd63450_device::dma_transfer_timer), this));
- m_reg[x].niv = 0x0f; // defaults?
- m_reg[x].eiv = 0x0f;
- }
-}
-
-void hd63450_device::device_reset()
-{
- m_drq_state[0] = m_drq_state[1] = m_drq_state[2] = m_drq_state[3] = 0;
-}
-
-READ16_MEMBER(hd63450_device::read)
-{
- int channel,reg;
-
- channel = (offset & 0x60) >> 5;
- reg = offset & 0x1f;
-
- switch(reg)
- {
- case 0x00: // CSR / CER
- return (m_reg[channel].csr << 8) | m_reg[channel].cer;
- case 0x02: // DCR / OCR
- return (m_reg[channel].dcr << 8) | m_reg[channel].ocr;
- case 0x03: // SCR / CCR
- return (m_reg[channel].scr << 8) | m_reg[channel].ccr;
- case 0x05: // MTC
- return m_reg[channel].mtc;
- case 0x06: // MAR (high)
- return (m_reg[channel].mar & 0xffff0000) >> 16;
- case 0x07: // MAR (low)
- return (m_reg[channel].mar & 0x0000ffff);
- case 0x0a: // DAR (high)
- return (m_reg[channel].dar & 0xffff0000) >> 16;
- case 0x0b: // DAR (low)
- return (m_reg[channel].dar & 0x0000ffff);
- case 0x0d: // BTC
- return m_reg[channel].btc;
- case 0x0e: // BAR (high)
- return (m_reg[channel].bar & 0xffff0000) >> 16;
- case 0x0f: // BAR (low)
- return (m_reg[channel].bar & 0x0000ffff);
- case 0x12: // NIV
- return m_reg[channel].niv;
- case 0x13: // EIV
- return m_reg[channel].eiv;
- case 0x14: // MFC
- return m_reg[channel].mfc;
- case 0x16: // CPR
- return m_reg[channel].cpr;
- case 0x18: // DFC
- return m_reg[channel].dfc;
- case 0x1c: // BFC
- return m_reg[channel].bfc;
- case 0x1f: // GCR
- return m_reg[channel].gcr;
- }
- return 0xff;
-}
-
-WRITE16_MEMBER(hd63450_device::write)
-{
- int channel,reg;
-
- channel = (offset & 0x60) >> 5;
- reg = offset & 0x1f;
- switch(reg)
- {
- case 0x00: // CSR / CER
- if(ACCESSING_BITS_8_15)
- {
- m_reg[channel].csr &= ~((data & 0xff00) >> 8);
-// logerror("DMA#%i: Channel status write : %02x\n",channel,dmac.reg[channel].csr);
- }
- // CER is read-only, so no action needed there.
- break;
- case 0x02: // DCR / OCR
- if(ACCESSING_BITS_8_15)
- {
- m_reg[channel].dcr = (data & 0xff00) >> 8;
- logerror("DMA#%i: Device Control write : %02x\n",channel,m_reg[channel].dcr);
- }
- if(ACCESSING_BITS_0_7)
- {
- m_reg[channel].ocr = data & 0x00ff;
- logerror("DMA#%i: Operation Control write : %02x\n",channel,m_reg[channel].ocr);
- }
- break;
- case 0x03: // SCR / CCR
- if(ACCESSING_BITS_8_15)
- {
- m_reg[channel].scr = (data & 0xff00) >> 8;
- logerror("DMA#%i: Sequence Control write : %02x\n",channel,m_reg[channel].scr);
- }
- if(ACCESSING_BITS_0_7)
- {
- m_reg[channel].ccr = data & 0x00ff;
- if((data & 0x0080))// && !m_dma_read[channel] && !m_dma_write[channel])
- dma_transfer_start(channel);
- if(data & 0x0010) // software abort
- dma_transfer_abort(channel);
- if(data & 0x0020) // halt operation
- dma_transfer_halt(channel);
- if(data & 0x0040) // continure operation
- dma_transfer_continue(channel);
- logerror("DMA#%i: Channel Control write : %02x\n",channel,m_reg[channel].ccr);
- }
- break;
- case 0x05: // MTC
- m_reg[channel].mtc = data;
- logerror("DMA#%i: Memory Transfer Counter write : %04x\n",channel,m_reg[channel].mtc);
- break;
- case 0x06: // MAR (high)
- m_reg[channel].mar = (m_reg[channel].mar & 0x0000ffff) | (data << 16);
- logerror("DMA#%i: Memory Address write : %08lx\n",channel,m_reg[channel].mar);
- break;
- case 0x07: // MAR (low)
- m_reg[channel].mar = (m_reg[channel].mar & 0xffff0000) | (data & 0x0000ffff);
- logerror("DMA#%i: Memory Address write : %08lx\n",channel,m_reg[channel].mar);
- break;
- case 0x0a: // DAR (high)
- m_reg[channel].dar = (m_reg[channel].dar & 0x0000ffff) | (data << 16);
- logerror("DMA#%i: Device Address write : %08lx\n",channel,m_reg[channel].dar);
- break;
- case 0x0b: // DAR (low)
- m_reg[channel].dar = (m_reg[channel].dar & 0xffff0000) | (data & 0x0000ffff);
- logerror("DMA#%i: Device Address write : %08lx\n",channel,m_reg[channel].dar);
- break;
- case 0x0d: // BTC
- m_reg[channel].btc = data;
- logerror("DMA#%i: Base Transfer Counter write : %04x\n",channel,m_reg[channel].btc);
- break;
- case 0x0e: // BAR (high)
- m_reg[channel].bar = (m_reg[channel].bar & 0x0000ffff) | (data << 16);
- logerror("DMA#%i: Base Address write : %08lx\n",channel,m_reg[channel].bar);
- break;
- case 0x0f: // BAR (low)
- m_reg[channel].bar = (m_reg[channel].bar & 0xffff0000) | (data & 0x0000ffff);
- logerror("DMA#%i: Base Address write : %08lx\n",channel,m_reg[channel].bar);
- break;
- case 0x12: // NIV
- m_reg[channel].niv = data & 0xff;
- logerror("DMA#%i: Normal IRQ Vector write : %02x\n",channel,m_reg[channel].niv);
- break;
- case 0x13: // EIV
- m_reg[channel].eiv = data & 0xff;
- logerror("DMA#%i: Error IRQ Vector write : %02x\n",channel,m_reg[channel].eiv);
- break;
- case 0x14: // MFC
- m_reg[channel].mfc = data & 0xff;
- logerror("DMA#%i: Memory Function Code write : %02x\n",channel,m_reg[channel].mfc);
- break;
- case 0x16: // CPR
- m_reg[channel].cpr = data & 0xff;
- logerror("DMA#%i: Channel Priority write : %02x\n",channel,m_reg[channel].cpr);
- break;
- case 0x18: // DFC
- m_reg[channel].dfc = data & 0xff;
- logerror("DMA#%i: Device Function Code write : %02x\n",channel,m_reg[channel].dfc);
- break;
- case 0x1c: // BFC
- m_reg[channel].bfc = data & 0xff;
- logerror("DMA#%i: Base Function Code write : %02x\n",channel,m_reg[channel].bfc);
- break;
- case 0x1f:
- m_reg[channel].gcr = data & 0xff;
- logerror("DMA#%i: General Control write : %02x\n",channel,m_reg[channel].gcr);
- break;
- }
-}
-
-void hd63450_device::dma_transfer_start(int channel)
-{
- address_space &space = m_cpu->space(AS_PROGRAM);
- m_in_progress[channel] = 1;
- m_reg[channel].csr &= ~0xe0;
- m_reg[channel].csr |= 0x08; // Channel active
- m_reg[channel].csr &= ~0x30; // Reset Error and Normal termination bits
- if((m_reg[channel].ocr & 0x0c) != 0x00) // Array chain or Link array chain
- {
- m_reg[channel].mar = space.read_word(m_reg[channel].bar) << 16;
- m_reg[channel].mar |= space.read_word(m_reg[channel].bar+2);
- m_reg[channel].mtc = space.read_word(m_reg[channel].bar+4);
- if(m_reg[channel].btc > 0)
- m_reg[channel].btc--;
- }
-
- // Burst transfers will halt the CPU until the transfer is complete
- if((m_reg[channel].dcr & 0xc0) == 0x00) // Burst transfer
- {
- m_cpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
- m_timer[channel]->adjust(attotime::zero, channel, m_burst_clock[channel]);
- }
- else if(!(m_reg[channel].ocr & 2))
- m_timer[channel]->adjust(attotime::from_usec(500), channel, m_our_clock[channel]);
- else if((m_reg[channel].ocr & 3) == 3)
- m_timer[channel]->adjust(attotime::from_usec(500), channel, attotime::never);
- else if((m_reg[channel].ocr & 3) == 2)
- m_timer[channel]->adjust(attotime::never, channel, attotime::never);
-
- m_transfer_size[channel] = m_reg[channel].mtc;
-
- logerror("DMA: Transfer begins: size=0x%08x\n",m_transfer_size[channel]);
-}
-
-void hd63450_device::set_timer(int channel, const attotime &tm)
-{
- m_our_clock[channel] = tm;
- if(m_in_progress[channel] != 0)
- m_timer[channel]->adjust(attotime::zero, channel, m_our_clock[channel]);
-}
-
-TIMER_CALLBACK_MEMBER(hd63450_device::dma_transfer_timer)
-{
- if(((m_reg[param].ocr & 3) == 2) && !m_drq_state[param])
- return;
- single_transfer(param);
-}
-
-void hd63450_device::dma_transfer_abort(int channel)
-{
- if(!m_in_progress[channel])
- return;
-
- logerror("DMA#%i: Transfer aborted\n",channel);
- m_timer[channel]->adjust(attotime::never);
- m_in_progress[channel] = 0;
- m_reg[channel].csr |= 0x90; // channel error
- m_reg[channel].csr &= ~0x08; // channel no longer active
- m_reg[channel].cer = 0x11;
- m_reg[channel].ccr &= ~0xc0;
- m_dma_error((offs_t)3, m_reg[channel].ccr & 0x08);
-}
-
-void hd63450_device::dma_transfer_halt(int channel)
-{
- m_halted[channel] = 1;
- m_timer[channel]->adjust(attotime::never);
-}
-
-void hd63450_device::dma_transfer_continue(int channel)
-{
- if(m_halted[channel] != 0)
- {
- m_halted[channel] = 0;
- m_timer[channel]->adjust(attotime::zero, channel, m_our_clock[channel]);
- }
-}
-
-void hd63450_device::single_transfer(int x)
-{
- address_space &space = m_cpu->space(AS_PROGRAM);
- int data;
- int datasize = 1;
-
- if(m_in_progress[x] != 0) // DMA in progress in channel x
- {
- if(m_reg[x].ocr & 0x80) // direction: 1 = device -> memory
- {
- if((x == 0) && !m_dma_read_0.isnull())
- {
- data = m_dma_read_0(m_reg[x].mar);
- if(data == -1)
- return; // not ready to receive data
- space.write_byte(m_reg[x].mar,data);
- datasize = 1;
- }
- else if((x == 1) && !m_dma_read_1.isnull())
- {
- data = m_dma_read_1(m_reg[x].mar);
- if(data == -1)
- return; // not ready to receive data
- space.write_byte(m_reg[x].mar,data);
- datasize = 1;
- }
- else if((x == 2) && !m_dma_read_2.isnull())
- {
- data = m_dma_read_2(m_reg[x].mar);
- if(data == -1)
- return; // not ready to receive data
- space.write_byte(m_reg[x].mar,data);
- datasize = 1;
- }
- else if((x == 3) && !m_dma_read_3.isnull())
- {
- data = m_dma_read_3(m_reg[x].mar);
- if(data == -1)
- return; // not ready to receive data
- space.write_byte(m_reg[x].mar,data);
- datasize = 1;
- }
- else
- {
- switch(m_reg[x].ocr & 0x30) // operation size
- {
- case 0x00: // 8 bit
- data = space.read_byte(m_reg[x].dar); // read from device address
- space.write_byte(m_reg[x].mar, data); // write to memory address
- datasize = 1;
- break;
- case 0x10: // 16 bit
- data = space.read_word(m_reg[x].dar); // read from device address
- space.write_word(m_reg[x].mar, data); // write to memory address
- datasize = 2;
- break;
- case 0x20: // 32 bit
- data = space.read_word(m_reg[x].dar) << 16; // read from device address
- data |= space.read_word(m_reg[x].dar+2);
- space.write_word(m_reg[x].mar, (data & 0xffff0000) >> 16); // write to memory address
- space.write_word(m_reg[x].mar+2, data & 0x0000ffff);
- datasize = 4;
- break;
- case 0x30: // 8 bit packed (?)
- data = space.read_byte(m_reg[x].dar); // read from device address
- space.write_byte(m_reg[x].mar, data); // write to memory address
- datasize = 1;
- break;
- }
- }
-// logerror("DMA#%i: byte transfer %08lx -> %08lx (byte = %02x)\n",x,dmac.reg[x].dar,dmac.reg[x].mar,data);
- }
- else // memory -> device
- {
- if((x == 0) && !m_dma_write_0.isnull())
- {
- data = space.read_byte(m_reg[x].mar);
- m_dma_write_0((offs_t)m_reg[x].mar,data);
- datasize = 1;
- }
- else if((x == 1) && !m_dma_write_1.isnull())
- {
- data = space.read_byte(m_reg[x].mar);
- m_dma_write_1((offs_t)m_reg[x].mar,data);
- datasize = 1;
- }
- else if((x == 2) && !m_dma_write_2.isnull())
- {
- data = space.read_byte(m_reg[x].mar);
- m_dma_write_2((offs_t)m_reg[x].mar,data);
- datasize = 1;
- }
- else if((x == 3) && !m_dma_write_3.isnull())
- {
- data = space.read_byte(m_reg[x].mar);
- m_dma_write_3((offs_t)m_reg[x].mar,data);
- datasize = 1;
- }
- else
- {
- switch(m_reg[x].ocr & 0x30) // operation size
- {
- case 0x00: // 8 bit
- data = space.read_byte(m_reg[x].mar); // read from memory address
- space.write_byte(m_reg[x].dar, data); // write to device address
- datasize = 1;
- break;
- case 0x10: // 16 bit
- data = space.read_word(m_reg[x].mar); // read from memory address
- space.write_word(m_reg[x].dar, data); // write to device address
- datasize = 2;
- break;
- case 0x20: // 32 bit
- data = space.read_word(m_reg[x].mar) << 16; // read from memory address
- data |= space.read_word(m_reg[x].mar+2); // read from memory address
- space.write_word(m_reg[x].dar, (data & 0xffff0000) >> 16); // write to device address
- space.write_word(m_reg[x].dar+2, data & 0x0000ffff); // write to device address
- datasize = 4;
- break;
- case 0x30: // 8 bit packed (?)
- data = space.read_byte(m_reg[x].mar); // read from memory address
- space.write_byte(m_reg[x].dar, data); // write to device address
- datasize = 1;
- break;
- }
- }
-// logerror("DMA#%i: byte transfer %08lx -> %08lx\n",x,m_reg[x].mar,m_reg[x].dar);
- }
-
-
- // decrease memory transfer counter
- if(m_reg[x].mtc > 0)
- m_reg[x].mtc--;
-
- // handle change of memory and device addresses
- if((m_reg[x].scr & 0x03) == 0x01)
- m_reg[x].dar+=datasize;
- else if((m_reg[x].scr & 0x03) == 0x02)
- m_reg[x].dar-=datasize;
-
- if((m_reg[x].scr & 0x0c) == 0x04)
- m_reg[x].mar+=datasize;
- else if((m_reg[x].scr & 0x0c) == 0x08)
- m_reg[x].mar-=datasize;
-
- if(m_reg[x].mtc <= 0)
- {
- // End of transfer
- logerror("DMA#%i: End of transfer\n",x);
- if((m_reg[x].ocr & 0x0c) != 0 && m_reg[x].btc > 0)
- {
- m_reg[x].btc--;
- m_reg[x].bar+=6;
- m_reg[x].mar = space.read_word(m_reg[x].bar) << 16;
- m_reg[x].mar |= space.read_word(m_reg[x].bar+2);
- m_reg[x].mtc = space.read_word(m_reg[x].bar+4);
- return;
- }
- m_timer[x]->adjust(attotime::never);
- m_in_progress[x] = 0;
- m_reg[x].csr |= 0xe0; // channel operation complete, block transfer complete
- m_reg[x].csr &= ~0x08; // channel no longer active
- m_reg[x].ccr &= ~0xc0;
-
- // Burst transfer
- if((m_reg[x].dcr & 0xc0) == 0x00)
- {
- m_cpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
- }
-
- if(!m_dma_end.isnull())
- m_dma_end((offs_t)x, m_reg[x].ccr & 0x08);
- }
- }
-}
-
-WRITE_LINE_MEMBER(hd63450_device::drq0_w)
-{
- bool ostate = m_drq_state[0];
- m_drq_state[0] = state;
-
- if((m_reg[0].ocr & 2) && (state && !ostate))
- {
- // in cycle steal mode drq is supposed to be edge triggered
- single_transfer(0);
- m_timer[0]->adjust(m_our_clock[0], 0, m_our_clock[0]);
- }
- else if(!state)
- m_timer[0]->adjust(attotime::never);
-}
-
-WRITE_LINE_MEMBER(hd63450_device::drq1_w)
-{
- bool ostate = m_drq_state[1];
- m_drq_state[1] = state;
-
- if((m_reg[1].ocr & 2) && (state && !ostate))
- {
- single_transfer(1);
- m_timer[1]->adjust(m_our_clock[1], 1, m_our_clock[1]);
- }
- else if(!state)
- m_timer[1]->adjust(attotime::never);
-}
-
-WRITE_LINE_MEMBER(hd63450_device::drq2_w)
-{
- bool ostate = m_drq_state[2];
- m_drq_state[2] = state;
-
- if((m_reg[2].ocr & 2) && (state && !ostate))
- {
- single_transfer(2);
- m_timer[2]->adjust(m_our_clock[2], 2, m_our_clock[2]);
- }
- else if(!state)
- m_timer[2]->adjust(attotime::never);
-}
-
-WRITE_LINE_MEMBER(hd63450_device::drq3_w)
-{
- bool ostate = m_drq_state[3];
- m_drq_state[3] = state;
-
- if((m_reg[3].ocr & 2) && (state && !ostate))
- {
- single_transfer(3);
- m_timer[3]->adjust(m_our_clock[3], 3, m_our_clock[3]);
- }
- else if(!state)
- m_timer[3]->adjust(attotime::never);
-}
-
-int hd63450_device::get_vector(int channel)
-{
- return m_reg[channel].niv;
-}
-
-int hd63450_device::get_error_vector(int channel)
-{
- return m_reg[channel].eiv;
-}
diff --git a/src/emu/machine/hd63450.h b/src/emu/machine/hd63450.h
deleted file mode 100644
index baf6d0337f1..00000000000
--- a/src/emu/machine/hd63450.h
+++ /dev/null
@@ -1,155 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Barry Rodewald
-/*
- Hitachi HD63450 DMA Controller
-*/
-
-#include "emu.h"
-
-
-#define MCFG_HD63450_DMA_END_CB(_devcb) \
- devcb = &hd63450_device::set_dma_end_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_HD63450_DMA_ERROR_CB(_devcb) \
- devcb = &hd63450_device::set_dma_error_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_HD63450_DMA_READ_0_CB(_devcb) \
- devcb = &hd63450_device::set_dma_read_0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_HD63450_DMA_READ_1_CB(_devcb) \
- devcb = &hd63450_device::set_dma_read_1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_HD63450_DMA_READ_2_CB(_devcb) \
- devcb = &hd63450_device::set_dma_read_2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_HD63450_DMA_READ_3_CB(_devcb) \
- devcb = &hd63450_device::set_dma_read_3_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_HD63450_DMA_WRITE_0_CB(_devcb) \
- devcb = &hd63450_device::set_dma_write_0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_HD63450_DMA_WRITE_1_CB(_devcb) \
- devcb = &hd63450_device::set_dma_write_1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_HD63450_DMA_WRITE_2_CB(_devcb) \
- devcb = &hd63450_device::set_dma_write_2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_HD63450_DMA_WRITE_3_CB(_devcb) \
- devcb = &hd63450_device::set_dma_write_3_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_HD63450_CPU(_tag) \
- hd63450_device::set_cpu_tag(*device, _tag);
-
-#define MCFG_HD63450_CLOCKS(_clk1, _clk2, _clk3, _clk4) \
- hd63450_device::set_our_clocks(*device, _clk1, _clk2, _clk3, _clk4);
-
-#define MCFG_HD63450_BURST_CLOCKS(_clk1, _clk2, _clk3, _clk4) \
- hd63450_device::set_burst_clocks(*device, _clk1, _clk2, _clk3, _clk4);
-
-struct hd63450_regs
-{ // offsets in bytes
- unsigned char csr; // [00] Channel status register (R/W)
- unsigned char cer; // [01] Channel error register (R)
- unsigned char dcr; // [04] Device control register (R/W)
- unsigned char ocr; // [05] Operation control register (R/W)
- unsigned char scr; // [06] Sequence control register (R/W)
- unsigned char ccr; // [07] Channel control register (R/W)
- unsigned short mtc; // [0a,0b] Memory Transfer Counter (R/W)
- unsigned long mar; // [0c-0f] Memory Address Register (R/W)
- unsigned long dar; // [14-17] Device Address Register (R/W)
- unsigned short btc; // [1a,1b] Base Transfer Counter (R/W)
- unsigned long bar; // [1c-1f] Base Address Register (R/W)
- unsigned char niv; // [25] Normal Interrupt Vector (R/W)
- unsigned char eiv; // [27] Error Interrupt Vector (R/W)
- unsigned char mfc; // [29] Memory Function Code (R/W)
- unsigned char cpr; // [2d] Channel Priority Register (R/W)
- unsigned char dfc; // [31] Device Function Code (R/W)
- unsigned char bfc; // [39] Base Function Code (R/W)
- unsigned char gcr; // [3f] General Control Register (R/W)
-};
-
-class hd63450_device : public device_t
-{
-public:
- hd63450_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~hd63450_device() {}
-
- template<class _Object> static devcb_base &set_dma_end_callback(device_t &device, _Object object) { return downcast<hd63450_device &>(device).m_dma_end.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_error_callback(device_t &device, _Object object) { return downcast<hd63450_device &>(device).m_dma_error.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_read_0_callback(device_t &device, _Object object) { return downcast<hd63450_device &>(device).m_dma_read_0.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_read_1_callback(device_t &device, _Object object) { return downcast<hd63450_device &>(device).m_dma_read_1.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_read_2_callback(device_t &device, _Object object) { return downcast<hd63450_device &>(device).m_dma_read_2.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_read_3_callback(device_t &device, _Object object) { return downcast<hd63450_device &>(device).m_dma_read_3.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_write_0_callback(device_t &device, _Object object) { return downcast<hd63450_device &>(device).m_dma_write_0.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_write_1_callback(device_t &device, _Object object) { return downcast<hd63450_device &>(device).m_dma_write_1.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_write_2_callback(device_t &device, _Object object) { return downcast<hd63450_device &>(device).m_dma_write_2.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_write_3_callback(device_t &device, _Object object) { return downcast<hd63450_device &>(device).m_dma_write_3.set_callback(object); }
-
- static void set_cpu_tag(device_t &device, const char *tag) { downcast<hd63450_device &>(device).m_cpu_tag = tag; }
- static void set_our_clocks(device_t &device, const attotime &clk1, const attotime &clk2, const attotime &clk3, const attotime &clk4)
- {
- hd63450_device &dev = downcast<hd63450_device &>(device);
- dev.m_our_clock[0] = clk1;
- dev.m_our_clock[1] = clk2;
- dev.m_our_clock[2] = clk3;
- dev.m_our_clock[3] = clk4;
- }
- static void set_burst_clocks(device_t &device, const attotime &clk1, const attotime &clk2, const attotime &clk3, const attotime &clk4)
- {
- hd63450_device &dev = downcast<hd63450_device &>(device);
- dev.m_burst_clock[0] = clk1;
- dev.m_burst_clock[1] = clk2;
- dev.m_burst_clock[2] = clk3;
- dev.m_burst_clock[3] = clk4;
- }
-
- DECLARE_READ16_MEMBER( read );
- DECLARE_WRITE16_MEMBER( write );
- DECLARE_WRITE_LINE_MEMBER(drq0_w);
- DECLARE_WRITE_LINE_MEMBER(drq1_w);
- DECLARE_WRITE_LINE_MEMBER(drq2_w);
- DECLARE_WRITE_LINE_MEMBER(drq3_w);
-
- void single_transfer(int x);
- void set_timer(int channel, const attotime &tm);
- int get_vector(int channel);
- int get_error_vector(int channel);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- devcb_write8 m_dma_end;
- devcb_write8 m_dma_error;
- devcb_read8 m_dma_read_0;
- devcb_read8 m_dma_read_1;
- devcb_read8 m_dma_read_2;
- devcb_read8 m_dma_read_3;
- devcb_write8 m_dma_write_0;
- devcb_write8 m_dma_write_1;
- devcb_write8 m_dma_write_2;
- devcb_write8 m_dma_write_3;
-
- const char *m_cpu_tag;
- attotime m_our_clock[4];
- attotime m_burst_clock[4];
-
- // internal state
- hd63450_regs m_reg[4];
- emu_timer* m_timer[4]; // for timing data reading/writing each channel
- int m_in_progress[4]; // if a channel is in use
- int m_transfer_size[4];
- int m_halted[4]; // non-zero if a channel has been halted, and can be continued later.
- cpu_device *m_cpu;
- bool m_drq_state[4];
-
- TIMER_CALLBACK_MEMBER(dma_transfer_timer);
- void dma_transfer_abort(int channel);
- void dma_transfer_halt(int channel);
- void dma_transfer_continue(int channel);
- void dma_transfer_start(int channel);
-};
-
-extern const device_type HD63450;
diff --git a/src/emu/machine/hd64610.c b/src/emu/machine/hd64610.c
deleted file mode 100644
index d4639892e17..00000000000
--- a/src/emu/machine/hd64610.c
+++ /dev/null
@@ -1,366 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Sandro Ronco
-/**********************************************************************
-
- Hitachi HD64610 Real Time Clock
-
-*********************************************************************/
-
-/*
-
- TODO:
- - leap year
- - test mode
-
-*/
-
-#include "hd64610.h"
-#include "coreutil.h"
-
-
-// device type definition
-const device_type HD64610 = &device_creator<hd64610_device>;
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 1
-
-// internal registers
-enum
-{
- REG_64HZ = 0,
- REG_SECOND,
- REG_MINUTE,
- REG_HOUR,
- REG_DAY_OF_THE_WEEK,
- REG_DAY,
- REG_MONTH,
- REG_YEAR,
- REG_64HZ_ALARM,
- REG_SECOND_ALARM,
- REG_MINUTE_ALARM,
- REG_HOUR_ALARM,
- REG_DAY_OF_THE_WEEK_ALARM,
- REG_DAY_ALARM,
- REG_CRA,
- REG_CRB
-};
-
-
-// Control Register A
-#define CRA_CF 0x80
-#define CRA_CIE 0x10
-#define CRA_AIE 0x08
-#define CRA_AF 0x01
-
-// Control Register B
-#define CRB_TEST 0x08
-#define CRB_ADJ 0x04
-#define CRB_RESET 0x02
-#define CRB_S 0x01
-
-// alarm
-#define ALARM_ENB 0x80
-
-// register write mask
-static const int REG_WRITE_MASK[0x10] =
-{
- 0x00, 0x7f, 0x7f, 0x3f, 0x07, 0x3f, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xbf, 0x83, 0xbf, 0x18, 0xff
-};
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// set_irq_line -
-//-------------------------------------------------
-
-inline void hd64610_device::set_irq_line()
-{
- int irq_out = (((m_regs[REG_CRA] & CRA_CF) && (m_regs[REG_CRA] & CRA_CIE)) ||
- ((m_regs[REG_CRA] & CRA_AF) && (m_regs[REG_CRA] & CRA_AIE))) ? 0 : 1;
-
- if (m_irq_out != irq_out)
- {
- if (LOG) logerror("HD64610 '%s' IRQ %u\n", tag(), irq_out);
-
- m_out_irq_cb(irq_out);
- m_irq_out = irq_out;
- }
-}
-
-
-//-------------------------------------------------
-// read_counter -
-//-------------------------------------------------
-
-inline UINT8 hd64610_device::read_counter(int counter)
-{
- return bcd_2_dec(m_regs[counter]);
-}
-
-
-//-------------------------------------------------
-// write_counter -
-//-------------------------------------------------
-
-inline void hd64610_device::write_counter(int counter, UINT8 value)
-{
- m_regs[counter] = dec_2_bcd(value);
-}
-
-
-//-------------------------------------------------
-// check_alarm -
-//-------------------------------------------------
-
-inline void hd64610_device::check_alarm()
-{
- bool alarm_flag = true;
-
- // clear alarm flag
- m_regs[REG_CRA] &= ~CRA_AF;
-
- if (m_regs[REG_64HZ_ALARM] & ALARM_ENB || m_regs[REG_SECOND_ALARM] & ALARM_ENB || m_regs[REG_MINUTE_ALARM] & ALARM_ENB ||
- m_regs[REG_HOUR_ALARM] & ALARM_ENB || m_regs[REG_DAY_OF_THE_WEEK_ALARM] & ALARM_ENB || m_regs[REG_DAY_ALARM] & ALARM_ENB)
- {
- // at least one ENB is active
-
- for (int i = REG_64HZ; i <= REG_DAY; i++)
- {
- if ((m_regs[i] & REG_WRITE_MASK[i]) != (m_regs[i+8] & REG_WRITE_MASK[i]) && m_regs[i+8] & ALARM_ENB)
- alarm_flag = false;
- }
-
- m_regs[REG_CRA] |= (alarm_flag ? CRA_AF : 0);
- }
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// hd64610_device - constructor
-//-------------------------------------------------
-
-hd64610_device::hd64610_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, HD64610, "HD64610", tag, owner, clock, "hd64610", __FILE__),
- device_rtc_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this),
- m_out_irq_cb(*this),
- m_out_1hz_cb(*this),
- m_hline_state(1),
- m_irq_out(1)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void hd64610_device::device_start()
-{
- // resolve callbacks
- m_out_irq_cb.resolve_safe();
- m_out_1hz_cb.resolve_safe();
-
- // allocate timers
- m_counter_timer = timer_alloc(TIMER_UPDATE_COUNTER);
- m_counter_timer->adjust(attotime::from_hz(clock() / 256), 0, attotime::from_hz(clock() / 256));
-
- // state saving
- save_item(NAME(m_regs));
- save_item(NAME(m_irq_out));
- save_item(NAME(m_hline_state));
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific reset
-//-------------------------------------------------
-
-void hd64610_device::device_reset()
-{
- set_current_time(machine());
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void hd64610_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_UPDATE_COUNTER:
- if(m_hline_state || (m_regs[REG_CRB] & CRB_S))
- {
- m_regs[REG_64HZ]++;
-
- if (m_regs[REG_64HZ] & 0x80)
- {
- // update seconds
- advance_seconds();
-
- // set carry flag
- m_regs[REG_CRA] |= CRA_CF;
-
- m_regs[REG_64HZ] &= 0x7f;
- }
-
- // update 1Hz out
- m_out_1hz_cb(BIT(m_regs[REG_64HZ], 6));
-
- // update IRQ
- check_alarm();
- set_irq_line();
- }
- break;
- }
-}
-
-
-//-------------------------------------------------
-// rtc_clock_updated -
-//-------------------------------------------------
-
-void hd64610_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
- write_counter(REG_SECOND, second);
- write_counter(REG_MINUTE, minute);
- write_counter(REG_HOUR, hour);
- write_counter(REG_DAY, day);
- write_counter(REG_MONTH, month);
- write_counter(REG_YEAR, year);
- m_regs[REG_DAY_OF_THE_WEEK] = day_of_week;
-
- check_alarm();
- set_irq_line();
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void hd64610_device::nvram_default()
-{
- memset(m_regs, 0, 0x10);
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void hd64610_device::nvram_read(emu_file &file)
-{
- file.read(m_regs, 0x10);
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void hd64610_device::nvram_write(emu_file &file)
-{
- file.write(m_regs, 0x10);
-}
-
-
-//-------------------------------------------------
-// hardware start/stop
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( hd64610_device::h_w )
-{
- m_hline_state = state;
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( hd64610_device::read )
-{
- UINT8 data = m_regs[offset & 0x0f];
-
- if (LOG) logerror("HD64610 '%s' Register %u Read %02x\n", tag(), offset, data);
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( hd64610_device::write )
-{
- switch (offset & 0x0f)
- {
- case REG_64HZ:
- // read only
- logerror("HD64610 '%s' Writing to read-only register 64Hz Counter\n", tag());
- break;
-
- case REG_CRA:
- m_regs[REG_CRA] = data & REG_WRITE_MASK[REG_CRA];
-
- if ((data & CRA_CF) == 0)
- {
- if (LOG) logerror("HD64610 '%s' clear carry flag\n", tag());
- m_regs[REG_CRA] &= 0x7f;
- }
- if ((data & CRA_AF) == 0)
- {
- if (LOG) logerror("HD64610 '%s' clear alarm flag\n", tag());
- m_regs[REG_CRA] &= 0xfe;
- }
-
- if (LOG) logerror("HD64610 '%s' set alarm IRQ %d\n", tag(), BIT(data, 3));
- if (LOG) logerror("HD64610 '%s' set carry IRQ %d\n", tag(), BIT(data, 4));
- break;
-
- case REG_CRB:
- m_regs[REG_CRB] = data & REG_WRITE_MASK[REG_CRB];
-
- if (data & CRB_ADJ)
- {
- if (LOG) logerror("HD64610 '%s' 30-sec adjustament\n", tag());
- adjust_seconds();
- m_regs[REG_64HZ] = 0;
-
- m_regs[REG_CRB] &= ~CRB_ADJ;
- }
-
- if (data & CRB_RESET)
- {
- if (LOG) logerror("HD64610 '%s' CRB reset\n", tag());
- m_regs[REG_64HZ] = 0;
-
- m_regs[REG_CRB] &= ~CRB_RESET;
- }
-
- if (LOG) logerror("HD64610 '%s' set timer %d\n", tag(), BIT(data, 0));
- break;
-
- default:
- m_regs[offset & 0x0f] = data & REG_WRITE_MASK[offset & 0x0f];
- if (LOG) logerror("HD64610 '%s' Register %u Write %02x\n", tag(), offset & 0x0f, data);
- break;
- }
-}
diff --git a/src/emu/machine/hd64610.h b/src/emu/machine/hd64610.h
deleted file mode 100644
index cb1d79d8388..00000000000
--- a/src/emu/machine/hd64610.h
+++ /dev/null
@@ -1,105 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Sandro Ronco
-/**********************************************************************
-
- Hitachi HD64610 Real Time Clock
-
-**********************************************************************
- _____ _____
- GND 1 |* \_/ | 24 Vcc
- H-Start/Stop 2 | | 23 OSC2
- _IRQ 3 | | 22 OSC1
- 1Hz 4 | HD64610 | 21 GND
- A3 5 | | 20 _WE
- A2 6 | | 19 _OE
- A1 7 | | 18 _CS
- A0 8 | | 17 I/O8
- I/O1 9 | | 16 I/O7
- I/O2 10 | | 15 I/O6
- I/O3 11 | | 14 I/O5
- GND 12 |_____________| 13 I/O4
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __HD64610__
-#define __HD64610__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_HD64610_OUT_IRQ_CB(_devcb) \
- devcb = &hd64610_device::set_out_irq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_HD64610_OUT_1HZ_CB(_devcb) \
- devcb = &hd64610_device::set_out_1hz_callback(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> hd64610_device
-
-class hd64610_device : public device_t,
- public device_rtc_interface,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- hd64610_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<hd64610_device &>(device).m_out_irq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_1hz_callback(device_t &device, _Object object) { return downcast<hd64610_device &>(device).m_out_1hz_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- // hardware start/stop line
- DECLARE_WRITE_LINE_MEMBER( h_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_rtc_interface overrides
- virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
-private:
- inline void set_irq_line();
- inline UINT8 read_counter(int counter);
- inline void write_counter(int counter, UINT8 value);
- inline void check_alarm();
-
- static const device_timer_id TIMER_UPDATE_COUNTER = 0;
-
- devcb_write_line m_out_irq_cb;
- devcb_write_line m_out_1hz_cb;
-
- UINT8 m_regs[0x10]; // Internal registers
- int m_hline_state; // H-Start/Stop line
- int m_irq_out; // alarm output
-
- // timers
- emu_timer *m_counter_timer;
-};
-
-
-// device type definition
-extern const device_type HD64610;
-
-
-#endif
diff --git a/src/emu/machine/hdc92x4.c b/src/emu/machine/hdc92x4.c
deleted file mode 100644
index f887c9a7bbb..00000000000
--- a/src/emu/machine/hdc92x4.c
+++ /dev/null
@@ -1,4456 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Michael Zapf
-/**************************************************************************
-
- HDC 9224 and HDC 9234 Hard and Floppy Disk Controller
- Standard Microsystems Corporation (SMC)
-
- This controller handles MFM and FM encoded floppy disks and hard disks.
-
- References:
- [1] SMC HDC9234 preliminary data book (1988)
- [2] SMC HDC9224 data book
-
- The HDC 9224 / 9234 controller is also referred to as the "Universal Disk Controller" (UDC)
- by the data book
-
- Michael Zapf, August 2015
-
-***************************************************************************/
-
-#include "emu.h"
-#include "hdc92x4.h"
-#include "formats/imageutl.h"
-
-// Per-command debugging
-#define TRACE_COMMAND 0
-#define TRACE_SELECT 0
-#define TRACE_STEP 0
-#define TRACE_RESTORE 0
-#define TRACE_SUBSTATES 0
-#define TRACE_READ 0
-#define TRACE_WRITE 0
-#define TRACE_READREG 0
-#define TRACE_SETREG 0
-#define TRACE_SETPTR 0
-#define TRACE_FORMAT 0
-#define TRACE_READTRACK 0
-
-// Common states
-#define TRACE_READID 0
-#define TRACE_VERIFY 0
-#define TRACE_TRANSFER 0
-
-// Live states debugging
-#define TRACE_LIVE 0
-#define TRACE_SHIFT 0
-#define TRACE_SYNC 0
-
-// Misc debugging
-#define TRACE_DELAY 0
-#define TRACE_INT 0
-#define TRACE_LINES 0
-#define TRACE_INDEX 0
-#define TRACE_DMA 0
-#define TRACE_DONE 0
-#define TRACE_FAIL 1
-#define TRACE_AUXBUS 0
-#define TRACE_HEADER 0
-#define TRACE_GAPS 0
-
-#define TRACE_DETAIL 0
-
-#define UNRELIABLE_MEDIA 0
-
-/*
- === Not implemented ===
- ECC
- Write long (see MODE register; only useful with ECC)
- Tape operations
- AT mode (HD)
- FM-encoded HD
-
- === Implemented but untested ===
- Restore
- Poll drives
- Seek/Read ID
- Read track
-
- === TODO ===
- Create a common state machine for HD and floppy
-*/
-
-/*
- Some registers of the HDC.
-
- +------+------+------+------+------+------+------+------+
- DHEAD: | 0 | Sector size | 0 | Desired head (OUTPUT2) | AT mode
- +------+------+------+------+------+------+------+------+
- | 0 | Desired cylinder | Desired head (OUTPUT2) | SMC mode
- +------+------+------+------+------+------+------+------+
- +------+------+------+------+------+------+------+------+
- RETRY: | Retry count (ones comp!) | Progr. output (OUTPUT1) |
- +------+------+------+------+------+------+------+------+
- +------+------+------+------+------+------+------+------+
- MODE: | HD | use CRC/ECC | FM | 0 | step rate |
- +------+------+------+------+------+------+------+------+
- +------+------+------+------+------+------+------+------+
- INTCOMM:| 1 | 0 | Done | DelD | User | WrPrt| Ready|Wfault|
- +------+------+------+------+------+------+------+------+
- +------+------+------+------+------+------+------+------+
- DDELAY: | 0 | 0 | Sector size | 0 | 0 | Zone | AT mode
- +------+------+------+------+------+------+------+------+
- | Data to be written on disk | writing
- +------+------+------+------+------+------+------+------+
- | Head load timer count | drselect
- +------+------+------+------+------+------+------+------+
-
- Read registers
- +------+------+------+------+------+------+------+------+
- CHIP_ST:| Retry| ECC | CRC | DelD | Sync | Comp | Current Drv |
- +------+------+------+------+------+------+------+------+
- +------+------+------+------+------+------+------+------+
- INT_ST: | Pend | DMARQ| Done | Termcode | RdyCh| Ovrun| BdSec|
- +------+------+------+------+------+------+------+------+
- +------+------+------+------+------+------+------+------+
- DRV_ST: | ECC | Index| SeekC| Trk00| User | WrPrt| Ready|Wfault|
- +------+------+------+------+------+------+------+------+
-
-*/
-enum
-{
- // Write registers | Read registers
- //--------------------------------------
- DMA7_0=0,
- DMA15_8=1,
- DMA23_16=2,
- DESIRED_SECTOR=3, CURRENT_SECTOR=3,
- DESIRED_HEAD=4, CURRENT_HEAD=4,
- DESIRED_CYLINDER=5, CURRENT_CYLINDER=5,
- SECTOR_COUNT=6, CURRENT_IDENT=6,
- RETRY_COUNT=7, TEMP_STORAGE2=7,
- MODE=8, CHIP_STATUS=8,
- INT_COMM_TERM=9, DRIVE_STATUS=9,
- DATA_DELAY=10, DATA=10,
- COMMAND=11, INT_STATUS=11,
-
- //======================
- // Internal registers
- CURRENT_SIZE=12,
- CURRENT_CRC1=13,
- CURRENT_CRC2=14
-};
-
-/*
- Definition of bits in the status register [1] p.7
-*/
-enum
-{
- ST_INTPEND = 0x80, // interrupt pending
- ST_DMAREQ = 0x40, // DMA request
- ST_DONE = 0x20, // command done
- ST_TERMCOD = 0x18, // termination code (see below)
- TC_SUCCESS = 0x00, // Successful completion
- TC_RDIDERR = 0x08, // Error in READ-ID sequence
- TC_VRFYERR = 0x10, // Error in VERIFY sequence
- TC_DATAERR = 0x18, // Error in DATA-TRANSFER seq.
- ST_RDYCHNG = 0x04, // ready change
- ST_OVRUN = 0x02, // overrun/underrun
- ST_BADSECT = 0x01 // bad sector
-};
-
-/*
- Definition of bits in the Termination-Conditions register
-*/
-enum
-{
- TC_CRCPRE = 0x80, // CRC register preset, must be 1
- TC_UNUSED = 0x40, // bit 6 is not used and must be 0
- TC_INTDONE = 0x20, // interrupt on command completion
- TC_TDELDAT = 0x10, // terminate on deleted data mark detection
- TC_TDUSER = 0x08, // user-defined condition
- TC_TWPROT = 0x04, // terminate on write protection
- TC_INTRDCH = 0x02, // interrupt on ready change
- TC_TWRFLT = 0x01 // interrupt on write fault
-};
-
-/*
- Definition of bits in the chip status register.
-*/
-enum
-{
- CS_RETREQ = 0x80, // retry required
- CS_ECCATT = 0x40, // ECC correction attempted
- CS_CRCERR = 0x20, // ECC/CRC error
- CS_DELDATA = 0x10, // deleted data mark
- CS_SYNCERR = 0x08, // synchronization error
- CS_COMPERR = 0x04, // compare error
- CS_PRESDRV = 0x03 // present drive selected
-};
-
-/*
- Bits in the internal output registers. The registers are output via the
- auxiliary bus (AB)
-
- OUTPUT1
- AB7 drive select 3
- AB6 drive select 2
- AB5 drive select 1
- AB4 drive select 0
- AB3 programmable outputs
- AB2 programmable outputs
- AB1 programmable outputs
- AB0 programmable outputs
-
- OUTPUT2
- AB7 drive select 3* (active low, used for tape operations)
- AB6 reduce write current
- AB5 step direction (0=towards TRK00)
- AB4 step pulse (1=active)
- AB3 desired head 3
- AB2 desired head 2
- AB1 desired head 1
- AB0 desired head 0
-*/
-enum
-{
- OUT1_DRVSEL3 = 0x80,
- OUT1_DRVSEL2 = 0x40,
- OUT1_DRVSEL1 = 0x20,
- OUT1_DRVSEL0 = 0x10,
- OUT2_DRVSEL3I = 0x80,
- OUT2_REDWRT = 0x40,
- OUT2_STEPDIR = 0x20,
- OUT2_STEPPULSE = 0x10,
- OUT2_HEADSEL = 0x0f
-};
-
-#define NODRIVE -1
-
-enum
-{
- TYPE_AT = 0x00,
- TYPE_HD = 0x01,
- TYPE_FLOPPY8 = 0x02,
- TYPE_FLOPPY5 = 0x03
-};
-
-/*
- Timers
-*/
-enum
-{
- GEN_TIMER = 1,
- COM_TIMER /*,
- LIVE_TIMER */
-};
-
-/*
- Definition of bits in the Mode register
-*/
-enum {
- MO_TYPE = 0x80, // Hard disk (1) or floppy (0)
- MO_CRCECC = 0x60, // Values for CRC/ECC handling
- MO_DENSITY = 0x10, // FM = 1; MFM = 0
- MO_UNUSED = 0x08, // Unused, 0
- MO_STEPRATE = 0x07 // Step rates
-};
-
-/*
- Step rates in microseconds for MFM. This is set in the mode register,
- bits 0-2. FM mode doubles all values.
-*/
-static const int step_hd[] = { 22, 50, 100, 200, 400, 800, 1600, 3200 };
-static const int step_flop8[] = { 218, 500, 1000, 2000, 4000, 8000, 16000, 32000 };
-static const int step_flop5[] = { 436, 1000, 2000, 4000, 8000, 16000, 32000, 64000 };
-
-/*
- Head load timer increments in usec. Delay value is calculated from this value
- multiplied by the factor in the DATA/DELAY register. For FM mode all
- values are doubled. The values depend on the drive type.
-*/
-static const int head_load_timer_increment[] = { 200, 200, 2000, 4000 };
-
-/*
- ID fields association to registers
-*/
-static const int id_field[] = { CURRENT_CYLINDER, CURRENT_HEAD, CURRENT_SECTOR, CURRENT_SIZE, CURRENT_CRC1, CURRENT_CRC2 };
-
-/*
- Pulse widths for stepping in usec
-*/
-enum
-{
- pulse_hd = 11,
- pulse_flop8 = 112,
- pulse_flop5 = 224
-};
-
-/*
- Times for UDC's acceptance of command and register write accesses (ns).
-*/
-enum
-{
- REGISTER_COMMIT = 1000,
- COMMAND_COMMIT = 1000
-};
-
-enum
-{
- UNDEF = 0x00,
- IDLE,
- DONE,
- COMMAND_INIT,
- REGISTER_ACCESS,
-
- STEP_ON,
- STEP_OFF,
- RESTORE_CHECK,
- WAIT_SEEK_COMPLETE, // 0x08
- SEEK_COMPLETE,
- HEAD_DELAY,
- WAITINDEX0,
- WAITINDEX1,
- TRACKSTART,
- TRACKDONE,
- POLL1,
- POLL2, // 0x10
- POLL3,
-
- READ_ID = 0x40,
- READ_ID1,
- READ_ID_STEPON,
- READ_ID_STEPOFF,
- READ_ID_SEEK_COMPLETE,
-
- VERIFY = 0x50,
- VERIFY1,
- VERIFY2,
- VERIFY3,
-
- DATA_TRANSFER = 0x60,
- DATA_TRANSFER_READ,
- DATA_TRANSFER_WRITE,
-
- // Live states
- LIVE_STATES = 0x80,
- SEARCH_IDAM,
- SEARCH_IDAM_FAILED,
- VERIFY_FAILED,
- READ_TWO_MORE_A1_IDAM,
- READ_IDENT,
- READ_ID_FIELDS_INTO_REGS,
- SEARCH_DAM,
- READ_TWO_MORE_A1_DAM, // 0x88
- READ_DATADEL_FLAG,
- SEARCH_DAM_FAILED,
- READ_SECTOR_DATA,
- READ_SECTOR_DATA_CONT,
- WRITE_DAM_AND_SECTOR,
- WRITE_SEC_SKIP_GAP2,
- WRITE_SEC_SKIP_GAP2_LOOP,
- WRITE_SEC_BYTE, // 0x90
- WRITE_SEC_NEXT_BYTE,
-
- WRITE_TRACK_BYTE,
- WRITE_TRACK_NEXT_BYTE,
-
- READ_TRACK_BYTE,
- READ_TRACK_NEXT_BYTE,
-
- FORMAT_TRACK,
- WRITE_GAP0,
- WRITE_GAP1, // 0x98
- WRITE_GAP2,
- WRITE_GAP3,
- WRITE_GAP4,
- WRITE_IXAM_SYNC,
- WRITE_IXAM,
- WRITE_FC,
- WRITE_IDAM_SYNC,
- WRITE_IDAM, // 0xa0
- WRITE_HEADER,
- WRITE_IDENT,
-
- WRITE_DAM_SYNC,
- WRITE_A1,
- WRITE_DATAMARK,
- WRITE_SECDATA,
- WRITE_DATA_CRC,
- WRITE_DONE, // 0xa8
- WRITE_HEADER_CRC,
-
- READ_TRACK,
- READ_TRACK_ID,
- READ_TRACK_ID_DONE,
-
- NO_DMA_ACK
-};
-
-/*
- Event lines
-*/
-enum
-{
- INDEX_LINE = 1,
- READY_LINE,
- SEEKCOMP_LINE
-};
-
-/*
- State machine metastates.
-*/
-enum
-{
- CONTINUE = 0,
- WAIT,
- NEXT,
- ERROR,
- SUCCESS
-};
-
-const hdc92x4_device::cmddef hdc92x4_device::s_command[] =
-{
- { 0x00, 0xff, &hdc92x4_device::reset_controller },
- { 0x01, 0xff, &hdc92x4_device::drive_deselect },
- { 0x02, 0xfe, &hdc92x4_device::restore_drive },
- { 0x04, 0xfc, &hdc92x4_device::step_drive },
- { 0x08, 0xf8, &hdc92x4_device::tape_backup },
- { 0x10, 0xf0, &hdc92x4_device::poll_drives },
- { 0x20, 0xe0, &hdc92x4_device::drive_select },
- { 0x40, 0xf0, &hdc92x4_device::set_register_pointer },
- { 0x50, 0xf8, &hdc92x4_device::seek_read_id },
- { 0x58, 0xfe, &hdc92x4_device::read_sectors },
- { 0x5a, 0xfe, &hdc92x4_device::read_track },
- { 0x5c, 0xfc, &hdc92x4_device::read_sectors },
- { 0x60, 0xe0, &hdc92x4_device::format_track },
- { 0x80, 0x80, &hdc92x4_device::write_sectors },
- { 0, 0, 0 }
-};
-
-/*
- Standard constructor for the base class and the two variants
-*/
-hdc92x4_device::hdc92x4_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_out_intrq(*this),
- m_out_dmarq(*this),
- m_out_dip(*this),
- m_out_auxbus(*this),
- m_in_dma(*this),
- m_out_dma(*this),
- m_initialized(false)
-{
-}
-
-hdc9224_device::hdc9224_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : hdc92x4_device(mconfig, HDC9224, "SMC HDC9224 Universal Disk Controller", tag, owner, clock, "hdc9224", __FILE__)
-{
- m_is_hdc9234 = false;
-}
-
-hdc9234_device::hdc9234_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : hdc92x4_device(mconfig, HDC9234, "SMC HDC9234 Universal Disk Controller", tag, owner, clock, "hdc9234", __FILE__)
-{
- m_is_hdc9234 = true;
-}
-
-
-/*
- Set or reset some bits.
-*/
-void hdc92x4_device::set_bits(UINT8& byte, int mask, bool set)
-{
- if (set) byte |= mask;
- else byte &= ~mask;
-}
-
-/*
- Tell whether the controller is in FM mode.
-*/
-bool hdc92x4_device::fm_mode()
-{
- return ((m_register_w[MODE]&MO_DENSITY)!=0);
-}
-
-/*
- Are we back on track 0?
-*/
-bool hdc92x4_device::on_track00()
-{
- return (m_register_r[DRIVE_STATUS] & HDC_DS_TRK00)!=0;
-}
-
-/*
- Seek completed?
-*/
-bool hdc92x4_device::seek_complete()
-{
- return (m_register_r[DRIVE_STATUS] & HDC_DS_SKCOM)!=0;
-}
-
-/*
- Index hole?
-*/
-bool hdc92x4_device::index_hole()
-{
- return (m_register_r[DRIVE_STATUS] & HDC_DS_INDEX)!=0;
-}
-
-/*
- Drive ready?
-*/
-bool hdc92x4_device::drive_ready()
-{
- return (m_register_r[DRIVE_STATUS] & HDC_DS_READY)!=0;
-}
-
-/*
- Doing a track read?
-*/
-bool hdc92x4_device::reading_track()
-{
- return (current_command() & 0xfe) == 0x5a;
-}
-
-/*
- Accessor functions for specific parameters.
-*/
-
-/*
- In SMC mode, the cylinder number is stored in bit positions 4,5,6 of the
- head register and in the 8 bits of the cylinder register.
- This is true for the desired cyl/head, current cyl/head, and the header
- fields on the track.
-*/
-int hdc92x4_device::desired_head()
-{
- return m_register_w[DESIRED_HEAD] & 0x0f;
-}
-
-int hdc92x4_device::desired_cylinder()
-{
- return (m_register_w[DESIRED_CYLINDER] & 0xff) | ((m_register_w[DESIRED_HEAD] & 0x70) << 4);
-}
-
-int hdc92x4_device::desired_sector()
-{
- return m_register_w[DESIRED_SECTOR] & 0xff;
-}
-
-int hdc92x4_device::current_head()
-{
- return m_register_r[CURRENT_HEAD] & 0x0f;
-}
-
-int hdc92x4_device::current_cylinder()
-{
- return (m_register_r[CURRENT_CYLINDER] & 0xff) | ((m_register_r[CURRENT_HEAD] & 0x70) << 4);
-}
-
-int hdc92x4_device::current_sector()
-{
- return m_register_r[CURRENT_SECTOR] & 0xff;
-}
-
-UINT8 hdc92x4_device::current_command()
-{
- return m_register_w[COMMAND];
-}
-
-bool hdc92x4_device::using_floppy()
-{
- return (m_selected_drive_type == TYPE_FLOPPY5 || m_selected_drive_type == TYPE_FLOPPY8);
-}
-
-/*
- Delivers the step time (in microseconds) minus the pulse width
-*/
-int hdc92x4_device::step_time()
-{
- int time = 0;
- int index = m_register_w[MODE] & MO_STEPRATE;
- // Get seek time.
- if (m_selected_drive_type == TYPE_FLOPPY8)
- time = step_flop8[index] - pulse_flop8;
-
- else if (m_selected_drive_type == TYPE_FLOPPY5)
- time = step_flop5[index] - pulse_flop5;
- else
- time = step_hd[index] - pulse_hd;
-
- if (fm_mode()) time = time * 2;
- return time;
-}
-
-/*
- Delivers the pulse width time (in microseconds)
-*/
-int hdc92x4_device::pulse_width()
-{
- int time = 0;
- // Get seek time.
- if (m_selected_drive_type == TYPE_FLOPPY8)
- time = pulse_flop8;
-
- else if (m_selected_drive_type == TYPE_FLOPPY5)
- time = pulse_flop5;
- else
- time = pulse_hd;
-
- if (fm_mode()) time = time * 2;
- return time;
-}
-
-/*
- Delivers the sector size
-*/
-int hdc92x4_device::calc_sector_size()
-{
- return 128 << (m_register_r[CURRENT_SIZE] & 3);
-}
-
-// ===========================================================================
-// Wait handling
-// We can wait for a given time period or for a line to be set or cleared
-// ===========================================================================
-
-void hdc92x4_device::wait_time(emu_timer *tm, int microsec, int next_substate)
-{
- wait_time(tm, attotime::from_usec(microsec), next_substate);
-}
-
-void hdc92x4_device::wait_time(emu_timer *tm, const attotime &delay, int param)
-{
- if (TRACE_DELAY) logerror("%s: [%s] Delaying by %4.2f microsecs\n", tag(), ttsn().c_str(), delay.as_double()*1000000);
- tm->adjust(delay);
- m_substate = param;
- m_state_after_line = UNDEF;
- m_timed_wait = true;
-}
-
-/*
- Set the hook for line level handling
-*/
-void hdc92x4_device::wait_line(int line, line_state level, int substate, bool stopwrite)
-{
- bool line_at_level = true;
- m_timed_wait = false;
-
- if (line == SEEKCOMP_LINE && (seek_complete() == (level==ASSERT_LINE)))
- {
- if (TRACE_LINES) logerror("%s: SEEK_COMPLETE line is already %d\n", tag(), level);
- }
- else
- {
- if (line == INDEX_LINE && (index_hole() == (level==ASSERT_LINE)))
- {
- if (TRACE_LINES) logerror("%s: INDEX line is already %d\n", tag(), level);
- }
- else
- {
- if (line == READY_LINE && (drive_ready() == (level==ASSERT_LINE)))
- {
- if (TRACE_LINES) logerror("%s: READY line is already %d\n", tag(), level);
- }
- else
- {
- // The line is not yet at the desired level; hence, arm the trigger.
- m_event_line = line;
- m_line_level = level;
- m_state_after_line = substate;
- m_stopwrite = stopwrite;
- line_at_level = false;
- }
- }
- }
-
- if (line_at_level)
- {
- m_substate = substate;
- m_event_line = UNDEF;
- m_state_after_line = UNDEF;
- reenter_command_processing();
- }
-}
-
-// ==================================================================
-// Common subroutines READ ID, VERIFY, DATA TRANSFER
-// called by all sector access commands
-// ==================================================================
-/*
- READ ID FIELD ([1] p. 9)
- The controller
- - scans for the next IDAM
- - reads the ID field values into the CURRENT_HEAD/CYLINDER/SECTOR registers
- - checks the CRC
- - calculates the number of steps and the direction towards DESIRED_CYLINDER
- (must have saved that value before!)
- - steps to that location during OUTPUT2 times
-*/
-void hdc92x4_device::read_id(int& cont, bool implied_seek, bool wait_seek_complete)
-{
- cont = CONTINUE;
-
- while (cont==CONTINUE)
- {
- switch (m_substate)
- {
- case READ_ID:
- // Implied seek: Enter the READ_ID subprogram.
- if (TRACE_READID && TRACE_SUBSTATES) logerror("%s: substate READ_ID\n", tag());
-
- // First step: Search the next IDAM, and if found, read the
- // ID values into the registers
-
- // Depending on the implied seek flag, continue with read_id,
- // else switch to verify.
- m_substate = implied_seek? READ_ID1 : VERIFY;
-
- m_live_state.bit_count_total = 0;
- live_start(SEARCH_IDAM);
- cont = WAIT;
- break;
-
- case READ_ID1:
- // If an error occurred (no IDAM found), terminate the command
- if ((m_register_r[CHIP_STATUS] & CS_SYNCERR) != 0)
- {
- if (TRACE_FAIL) logerror("%s: READ_ID failed to find any IDAM\n", tag());
- cont = ERROR;
- break;
- }
-
- if (TRACE_READID)
- {
- if (TRACE_SUBSTATES) logerror("%s: substate READ_ID1\n", tag());
- logerror("%s: DESIRED_CYL = %d; CURRENT_CYL = %d\n", tag(), desired_cylinder(), current_cylinder());
- }
-
- // The CRC has been updated automatically with each read_one_bit during the live_run.
- // We just need to check whether it ended in 0000
- if (m_live_state.crc != 0)
- {
- if (TRACE_FAIL) logerror("%s: CRC error in sector header\n", tag());
- set_bits(m_register_r[CHIP_STATUS], CS_CRCERR, true);
- cont = ERROR;
- break;
- }
-
- // Calculate the direction and number of step pulses
- // positive -> towards inner cylinders
- // negative -> towards outer cylinders
- // zero -> we're already there
- m_track_delta = desired_cylinder() - current_cylinder();
- m_substate = READ_ID_STEPON;
- break;
-
- case READ_ID_STEPON:
- // Any more steps left?
- if (m_track_delta == 0)
- {
- if (wait_seek_complete)
- {
- // We have to wait for SEEK COMPLETE
- if (TRACE_READID && TRACE_SUBSTATES) logerror("%s: Waiting for SEEK COMPLETE\n", tag());
- wait_line(SEEKCOMP_LINE, ASSERT_LINE, READ_ID_SEEK_COMPLETE, false);
- cont = WAIT;
- }
- else
- {
- // We do not wait for SEEK COMPLETE
- m_substate = VERIFY;
- cont = NEXT;
- }
- break;
- }
-
- if (TRACE_READID && TRACE_SUBSTATES) logerror("%s: substate STEP_ON\n", tag());
- // STEPDIR = 0 -> towards TRK00
- set_bits(m_output2, OUT2_STEPDIR, (m_track_delta>0));
- set_bits(m_output2, OUT2_STEPPULSE, true);
- wait_time(m_timer, pulse_width(), READ_ID_STEPOFF);
- cont = WAIT;
- break;
-
- case READ_ID_STEPOFF:
- if (TRACE_READID && TRACE_SUBSTATES) logerror("%s: substate STEP_OFF\n", tag());
- set_bits(m_output2, OUT2_STEPPULSE, false);
- m_track_delta += (m_track_delta<0)? 1 : -1;
- // Return to STEP_ON, check whether there are more steps
- wait_time(m_timer, step_time(), READ_ID_STEPON);
- cont = WAIT;
- break;
-
- case READ_ID_SEEK_COMPLETE:
- m_substate = VERIFY;
- cont = NEXT;
- break;
-
- default:
- logerror("%s: BUG: Unknown substate %02x in read_id, aborting command\n", tag(), m_substate);
- cont = ERROR;
- }
- }
-
- // When an error occurs, the COMMAND_TERMINATION bits are set to 01
- if (cont == ERROR)
- {
- live_abort();
- set_command_done(TC_RDIDERR);
- }
-}
-
-/*
- VERIFY ([1] p. 10)
- The controller
- - continues to read the next ID field until the current values match the
- contents of the DESIRED_HEAD/CYLINDER/SECTOR registers
- - checks the CRC
-*/
-void hdc92x4_device::verify(int& cont)
-{
- cont = CONTINUE;
-
- while (cont==CONTINUE)
- {
- switch (m_substate)
- {
- case VERIFY:
- // After seeking (or immediately when implied seek has been disabled),
- // find the desired sector.
-
- if (TRACE_VERIFY && TRACE_SUBSTATES) logerror("%s: substate VERIFY\n", tag());
- if (TRACE_VERIFY) logerror("%s: VERIFY: Find sector CHS=(%d,%d,%d)\n", tag(),
- desired_cylinder(),
- desired_head(),
- desired_sector());
-
- // If an error occurred (no IDAM found), terminate the command
- // (This test is only relevant when we did not have a seek phase before)
- if ((m_register_r[CHIP_STATUS] & CS_SYNCERR) != 0)
- {
- if (TRACE_FAIL) logerror("%s: VERIFY failed to find any IDAM\n", tag());
- cont = ERROR;
- break;
- }
-
- // Count from 0 again
- m_live_state.bit_count_total = 0;
- m_substate = VERIFY1;
- break;
-
- case VERIFY1:
- // Check whether we are already there
- if (desired_cylinder() == current_cylinder()
- && desired_head() == current_head()
- && desired_sector() == current_sector())
- {
- if (TRACE_VERIFY) logerror("%s: Found the desired sector CHS=(%d,%d,%d)\n", tag(),
- desired_cylinder(),
- desired_head(),
- desired_sector());
- m_substate = DATA_TRANSFER;
- cont = NEXT;
- m_first_sector_found = true;
- }
- else
- {
- if (TRACE_VERIFY && TRACE_DETAIL) logerror("%s: Current CHS=(%d,%d,%d), desired CHS=(%d,%d,%d).\n", tag(),
- current_cylinder(),
- current_head(),
- current_sector(),
- desired_cylinder(),
- desired_head(),
- desired_sector());
- m_substate = VERIFY2;
- }
- break;
-
- case VERIFY2:
- // Search the next ID
- m_substate = VERIFY3;
- live_start(SEARCH_IDAM);
- cont = WAIT;
- break;
-
- case VERIFY3:
- if (TRACE_VERIFY) logerror("%s: Next IDAM found; total bytes read: %d\n", tag(), m_live_state.bit_count_total / 16);
- if ((m_register_r[CHIP_STATUS] & CS_COMPERR) != 0)
- {
- if (TRACE_FAIL) logerror("%s: VERIFY failed to find sector CHS=(%d,%d,%d)\n", tag(), desired_cylinder(), desired_head(), desired_sector());
- cont = ERROR;
- break;
- }
-
- // Continue with the loop
- if (m_logical || !m_first_sector_found)
- {
- // this is for the logical sector reading/writing
- m_substate = VERIFY1;
- }
- else
- {
- // this is for the physical sector reading/writing
- // do not verify the next ID field
- m_substate = DATA_TRANSFER;
- m_wait_for_index = true;
- cont = NEXT;
- }
- break;
-
- default:
- logerror("%s: BUG: Unknown substate %02x in verify, aborting command\n", tag(), m_substate);
- cont = ERROR;
- }
- }
-
- // When an error occurs, the COMMAND_TERMINATION bits are set to 10
- if (cont == ERROR)
- {
- live_abort();
- set_command_done(TC_VRFYERR);
- }
-}
-
-/*
- DATA TRANSFER ([1], p. 10)
- only during READ/WRITE PHYSICAL/LOGICAL
- The controller
- - scans for the next DAM
- - initiates a DMA request and waits for ACK from the system processor
- - transfers the contents of the current sector into memory via DMA (read) or
- via DMA to the sector (write)
-*/
-void hdc92x4_device::data_transfer(int& cont)
-{
- cont = CONTINUE;
-
- while (cont==CONTINUE)
- {
- switch (m_substate)
- {
- case DATA_TRANSFER:
- if (TRACE_TRANSFER && TRACE_SUBSTATES) logerror("%s: substate DATA_TRANSFER (%s)\n", tag(), m_write? "write" : "read");
-
- // Count from 0 again
- m_live_state.bit_count_total = 0;
-
- if (m_transfer_enabled) dma_address_out(m_register_w[DMA23_16], m_register_w[DMA15_8], m_register_w[DMA7_0]);
-
- if (TRACE_TRANSFER && TRACE_DETAIL)
- {
- if (m_logical)
- logerror("%s: %s sector CHS=(%d,%d,%d)\n", tag(), m_write? "Write" : "Read",
- desired_cylinder(),
- desired_head(),
- desired_sector());
- else
- logerror("%s: %s next sector on track\n", tag(), m_write? "Write" : "Read");
- }
-
- if (m_write)
- {
- m_substate = DATA_TRANSFER_WRITE;
- live_start(WRITE_DAM_AND_SECTOR);
- }
- else
- {
- m_substate = DATA_TRANSFER_READ;
- live_start(SEARCH_DAM);
- }
-
- cont = WAIT;
- break;
-
- case DATA_TRANSFER_READ:
- // OK, sector has been read.
- // Check CRC
- if (m_live_state.crc != 0)
- {
- // Set Retry Required flag
- set_bits(m_register_r[CHIP_STATUS], CS_RETREQ, true);
-
- // Decrement the retry register (one's complemented value; 0000 = 15)
- int retry = 15-((m_register_w[RETRY_COUNT] >> 4)&0x0f);
-
- if (TRACE_FAIL) logerror("%s: DATA TRANSFER got CRC error in sector data, retries = %d\n", tag(), retry);
- m_register_w[RETRY_COUNT] = (m_register_w[RETRY_COUNT] & 0x0f) | ((15-(retry-1))<<4);
-
- if (retry == 0)
- {
- if (TRACE_FAIL) logerror("%s: CRC error; no retries left\n", tag());
- set_bits(m_register_r[CHIP_STATUS], CS_CRCERR, true);
- cont = ERROR;
- }
- else
- {
- // Go back to VERIFY and try again
- // Note that the specs recommend to set the retry to 0 (1111)
- // for physical reading; failing to do so will result in
- // unpredictable behavior.
- // We'll rely on the properly written software as well.
- m_live_state.bit_count_total = 0;
- m_substate = VERIFY2;
- cont = NEXT;
- }
- }
- else
- {
- if (TRACE_TRANSFER) logerror("%s: Sector successfully read (count=%d)\n", tag(), m_register_w[SECTOR_COUNT]-1);
-
- // Update the DMA registers for multi-sector operations
- if (m_multi_sector)
- {
- int dma_address = (m_register_w[DMA23_16] & 0xff) << 16 |
- (m_register_w[DMA15_8] & 0xff) << 8 |
- (m_register_w[DMA7_0] & 0xff);
-
- dma_address = (dma_address + calc_sector_size()) & 0xffffff;
-
- m_register_w[DMA23_16] = m_register_r[DMA23_16] = (dma_address & 0xff0000) >> 16;
- m_register_w[DMA15_8] = m_register_r[DMA15_8] = (dma_address & 0x00ff00) >> 8;
- m_register_w[DMA7_0] = m_register_r[DMA7_0] = (dma_address & 0x0000ff);
- if (TRACE_TRANSFER) logerror("%s: New DMA address = %06x\n", tag(), dma_address);
- }
-
- // Decrement the count
- m_register_w[SECTOR_COUNT] = (m_register_w[SECTOR_COUNT]-1) & 0xff;
-
- // Do we have more sectors to read?
- // Surprisingly, the manual does not say what happens when
- // the sector count is zero for the first access.
- // It explicitly states that the check is done after the access.
- // If we take it (and especially the state charts) seriously, zero means 256.
- // m_stop_after_index is important for physical reading
- if (m_register_w[SECTOR_COUNT] != 0 && !m_stop_after_index)
- {
- // Increment the sector number
- // What happens when we exceed the highest sector number
- // in the track? We have to assume that this is possible
- // and that in this case the VERIFY routine fails.
- if (m_logical) m_register_w[DESIRED_SECTOR] = (desired_sector() + 1) & 0xff;
- m_substate = VERIFY2;
- cont = NEXT;
- m_live_state.bit_count_total = 0;
- }
- else
- cont = SUCCESS;
- }
- break;
-
- case DATA_TRANSFER_WRITE:
- if (TRACE_TRANSFER) logerror("%s: Sector successfully written (count=%d)\n", tag(), m_register_w[SECTOR_COUNT]-1);
-
- // Update the DMA registers for multi-sector operations
- if (m_multi_sector)
- {
- int dma_address = (m_register_w[DMA23_16] & 0xff) << 16 |
- (m_register_w[DMA15_8] & 0xff) << 8 |
- (m_register_w[DMA7_0] & 0xff);
-
- dma_address = (dma_address + calc_sector_size()) & 0xffffff;
-
- m_register_w[DMA23_16] = m_register_r[DMA23_16] = (dma_address & 0xff0000) >> 16;
- m_register_w[DMA15_8] = m_register_r[DMA15_8] = (dma_address & 0x00ff00) >> 8;
- m_register_w[DMA7_0] = m_register_r[DMA7_0] = (dma_address & 0x0000ff);
- if (TRACE_TRANSFER) logerror("%s: New DMA address = %06x\n", tag(), dma_address);
- }
-
- // Decrement the count
- m_register_w[SECTOR_COUNT] = (m_register_w[SECTOR_COUNT]-1) & 0xff;
- if (m_register_w[SECTOR_COUNT] != 0 && !m_stop_after_index)
- {
- if (m_logical) m_register_w[DESIRED_SECTOR] = (desired_sector() + 1) & 0xff;
- m_substate = VERIFY2;
- cont = NEXT;
- m_live_state.bit_count_total = 0;
- }
- else
- cont = SUCCESS;
-
- break;
-
- default:
- logerror("%s: BUG: Unknown substate %02x in data_transfer, aborting command\n", tag(), m_substate);
- cont = ERROR;
- }
- }
-
- if (cont==SUCCESS) set_command_done(TC_SUCCESS);
-
- // When an error occurs, the COMMAND_TERMINATION bits are set to 11
- if (cont==ERROR)
- {
- live_abort();
- set_command_done(TC_DATAERR);
- }
-}
-
-// ===========================================================================
-// Commands
-// ===========================================================================
-
-/*
- RESET
- Reset the controller. This has the same effect as asserting the RST* input line.
-
- Command word
-
- 7 6 5 4 3 2 1 0
- +-----+-----+-----+-----+-----+-----+-----+-----+
- | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
- +-----+-----+-----+-----+-----+-----+-----+-----+
-
-*/
-void hdc92x4_device::reset_controller()
-{
- logerror("%s: RESET command\n", tag());
- device_reset();
-}
-
-/*
- DESELECT DRIVE
- Deselect all drives.
-
- Command word
-
- 7 6 5 4 3 2 1 0
- +-----+-----+-----+-----+-----+-----+-----+-----+
- | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
- +-----+-----+-----+-----+-----+-----+-----+-----+
-*/
-void hdc92x4_device::drive_deselect()
-{
- if (TRACE_SELECT) logerror("%s: DESELECT command\n", tag());
- m_selected_drive_number = NODRIVE;
- m_output1 = 0x00;
- set_command_done(TC_SUCCESS);
-}
-
-/*
- RESTORE DRIVE
- Moves the heads to cylinder 0. If skcom is set, the command terminates
- after the SEEK COMPLETE line is set.
-
- Command word
-
- 7 6 5 4 3 2 1 0
- +-----+-----+-----+-----+-----+-----+-----+-----+
- | 0 | 0 | 0 | 0 | 0 | 0 | 1 |skcom|
- +-----+-----+-----+-----+-----+-----+-----+-----+
-*/
-void hdc92x4_device::restore_drive()
-{
- int cont = CONTINUE;
- bool buffered_step = current_command() & 1;
-
- // The substate is set to UNDEF when the command is started;
- // when we reenter the command processing after a pause, the substate is set to some other value
- // In wd_fdc this is solved using two methods <command>_start and <command>_continue
-
- if (m_substate == UNDEF)
- {
- if (TRACE_RESTORE) logerror("%s: RESTORE command %02x\n", tag(), current_command());
- m_seek_count = 0;
- m_substate = RESTORE_CHECK;
- }
-
- while (cont==CONTINUE)
- {
- switch (m_substate)
- {
- case RESTORE_CHECK:
- // Track 0 has not been reached yet
- if (!drive_ready())
- {
- if (TRACE_RESTORE) logerror("%s: restore command: Drive not ready\n", tag());
- // Does not look like a success, but this takes into account
- // that if a drive is not connected we do not want an error message
- cont = SUCCESS;
- break;
- }
-
- // Are we done?
- if (m_seek_count>=4096 || on_track00())
- {
- if (buffered_step)
- {
- // When we have buffered steps, the seek limit will be reached
- // before TRK00 is asserted. In that case we have to wait for
- // SEEK_COMPLETE. We also wait as soon as TRK00 is asserted.
- if (TRACE_RESTORE) logerror("%s: restore using buffered steps\n", tag());
- wait_line(SEEKCOMP_LINE, ASSERT_LINE, SEEK_COMPLETE, false);
- cont = WAIT;
- }
- else
- {
- // No buffered seek. If the seek limit has been reached
- // and TRK00 is not true, we failed. This will be decided below.
- m_substate = SEEK_COMPLETE;
- }
- }
- else m_substate = STEP_ON;
- break;
-
- case STEP_ON:
- if (TRACE_RESTORE && TRACE_SUBSTATES) logerror("%s: [%s] substate STEP_ON\n", tag(), ttsn().c_str());
-
- // Increase step count
- m_seek_count++;
-
- // STEPDIR = 0 -> towards TRK00
- set_bits(m_output2, OUT2_STEPDIR, false);
-
- // Raising edge (note that all signals must be inverted before leading them to the drive)
- set_bits(m_output2, OUT2_STEPPULSE, true);
- wait_time(m_timer, pulse_width(), STEP_OFF);
- cont = WAIT;
- break;
-
- case STEP_OFF:
- if (TRACE_RESTORE && TRACE_SUBSTATES) logerror("%s: [%s] substate STEP_OFF\n", tag(), ttsn().c_str());
- set_bits(m_output2, OUT2_STEPPULSE, false);
- wait_time(m_timer, step_time(), RESTORE_CHECK);
- cont = WAIT;
- break;
-
- case SEEK_COMPLETE:
- // If TRK00 is not set, the drive failed to reach it.
- if (!on_track00())
- {
- if (TRACE_FAIL) logerror("%s: restore command: failed to reach track 00\n", tag());
- set_command_done(TC_VRFYERR);
- cont = ERROR;
- }
- else
- cont = SUCCESS;
- break;
- }
- }
- if (cont==SUCCESS) set_command_done(TC_SUCCESS);
-}
-
-/*
- STEP IN / OUT 1 CYLINDER
- Move the heads 1 step towards the center (in) or towards the outermost
- track (out).
-
- Command word
-
- 7 6 5 4 3 2 1 0
- +-----+-----+-----+-----+-----+-----+-----+-----+
- | 0 | 0 | 0 | 0 | 0 | 1 | out |skcom|
- +-----+-----+-----+-----+-----+-----+-----+-----+
-
-*/
-void hdc92x4_device::step_drive()
-{
- int cont = CONTINUE;
-
- if (m_substate == UNDEF)
- {
- if (TRACE_STEP) logerror("%s: STEP IN/OUT command %02x\n", tag(), current_command());
- m_substate = STEP_ON;
- }
-
- while (cont==CONTINUE)
- {
- switch (m_substate)
- {
- case STEP_ON:
- if (TRACE_STEP && TRACE_SUBSTATES) logerror("%s: substate STEP_ON\n", tag());
-
- // STEPDIR = 0 -> towards TRK00
- set_bits(m_output2, OUT2_STEPDIR, (current_command() & 0x02)==0);
-
- // Raising edge (note that all signals must be inverted before leading them to the drive)
- set_bits(m_output2, OUT2_STEPPULSE, true);
- wait_time(m_timer, pulse_width(), STEP_OFF);
- cont = WAIT;
- break;
-
- case STEP_OFF:
- if (TRACE_STEP && TRACE_SUBSTATES) logerror("%s: substate STEP_OFF\n", tag());
- set_bits(m_output2, OUT2_STEPPULSE, false);
- wait_time(m_timer, step_time(), ((current_command() & 0x01)!=0)? WAIT_SEEK_COMPLETE : DONE);
- cont = WAIT;
- break;
-
- case WAIT_SEEK_COMPLETE:
- wait_line(SEEKCOMP_LINE, ASSERT_LINE, DONE, false);
- cont = WAIT;
- break;
-
- case DONE:
- cont = SUCCESS;
- break;
- }
- }
- if (cont==SUCCESS) set_command_done(TC_SUCCESS);
-}
-
-/*
- TAPE BACKUP
- Not implemented
-*/
-void hdc92x4_device::tape_backup()
-{
- logerror("%s: TAPE BACKUP command %02x not implemented\n", tag(), current_command());
- set_command_done(TC_SUCCESS);
-}
-
-/*
- POLL DRIVES
- Repeat
- - i = i+1 % 4
- - select drive if its bit is set in the command word
- until seek_complete is true.
-
- Command word
-
- 7 6 5 4 3 2 1 0
- +-----+-----+-----+-----+-----+-----+-----+-----+
- | 0 | 0 | 0 | 1 | Drv3| Drv2| Drv1| Drv0|
- +-----+-----+-----+-----+-----+-----+-----+-----+
-
- This command only sets the select lines but does not process parameters
- like head load times or drive types.
-*/
-void hdc92x4_device::poll_drives()
-{
- UINT8 drivebit = 0;
- if (m_substate == UNDEF)
- {
- logerror("%s: POLL DRIVES command %02x\n", tag(), current_command());
- m_substate = POLL1;
- m_selected_drive_number = 0;
- // If there is no selection, do not enter the loop
- if ((current_command() & 0x0f)==0) m_substate = DONE;
- }
-
- int cont = CONTINUE;
-
- while (cont==CONTINUE)
- {
- switch (m_substate)
- {
- case POLL1:
- drivebit = (1 << m_selected_drive_number) & 0x0f;
-
- if ((current_command() & drivebit) != 0)
- {
- // Test this drive
- m_register_r[CHIP_STATUS] = (m_register_r[CHIP_STATUS] & 0xfc) | m_selected_drive_number;
-
- m_output1 = (drivebit << 4) | (m_register_w[RETRY_COUNT]&0x0f);
- if (TRACE_AUXBUS) logerror("%s: Setting OUTPUT1 to %02x\n", tag(), m_output1);
- wait_time(m_timer, 1, POLL2); // Wait for 1 usec
- cont = WAIT;
- }
- else
- m_substate = POLL3;
-
- break;
-
- case POLL2:
- if (seek_complete())
- {
- // Seek complete has been set
- m_substate = DONE;
- // Selected drive is still found in the chip status register
- }
- else m_substate = POLL3;
- break;
-
- case POLL3:
- m_selected_drive_number = (m_selected_drive_number + 1) & 0x03;
- m_substate = POLL1;
- break;
-
- case DONE:
- cont = SUCCESS;
- break;
- }
- }
-
- if (cont==SUCCESS) set_command_done(TC_SUCCESS);
-}
-
-/*
- DRIVE SELECT
- Selects a drive. With this command, parameters for the drive are also
- defined, like the type of drive (Floppy 8" or 5", AT Hard disk, or generic
- Hard disk), the drive number, and the head load delay.
-
- On the next OUTPUT1 time, the number of the drive (one of four lines)
- is set on the higher four bits of the auxiliary bus. Also, the lower
- 4 bits of the RETRY COUNT register are put on the lower 4 bits of the bus
- (user-programmable output, [1] p. 5).
-
- The HFDC controller board uses the user-programmable output to
- select one of four floppy disk drives with Drive set to 00.
- Drive codes 01, 10, and 11 remain for three hard disk drives.
-
- Command word
-
- 7 6 5 4 3 2 1 0
- +-----+-----+-----+-----+-----+-----+-----+-----+
- | 0 | 0 | 1 |Delay| Type | Drive |
- +-----+-----+-----+-----+-----+-----+-----+-----+
-*/
-
-void hdc92x4_device::drive_select()
-{
- int cont = CONTINUE;
- int head_load_delay = 0;
-
- if (m_substate == UNDEF)
- {
- int driveparm = current_command() & 0x1f;
- bool head_load_delay_enable = (driveparm & 0x10)!=0;
-
- // The drive type is used to configure DMA burst mode ([1], p.12)
- // and to select the timing parameters
- m_selected_drive_type = (driveparm>>2) & 0x03;
- m_selected_drive_number = driveparm & 0x03;
-
- // Calculate the head load delays
- head_load_delay = head_load_delay_enable? m_register_w[DATA] * head_load_timer_increment[m_selected_drive_type] : 0;
- if (fm_mode()) head_load_delay <<= 1;
-
- if (TRACE_SELECT) logerror("%s: DRIVE SELECT command (%02x): head load delay=%d, type=%d, drive=%d, pout=%02x, step_rate=%d\n", tag(), current_command(), head_load_delay, m_selected_drive_type, driveparm&3, m_register_w[RETRY_COUNT]&0x0f, pulse_width() + step_time());
-
- // Copy the DMA registers to registers CURRENT_HEAD, CURRENT_CYLINDER,
- // and CURRENT_IDENT. This is required during formatting ([1], p. 14)
- // as the format command reuses the registers for formatting parameters.
- m_register_r[CURRENT_HEAD] = m_register_r[DMA7_0];
- m_register_r[CURRENT_CYLINDER] = m_register_r[DMA15_8];
- m_register_r[CURRENT_IDENT] = m_register_r[DMA23_16];
-
- // Copy the selected drive number to the chip status register
- m_register_r[CHIP_STATUS] = (m_register_r[CHIP_STATUS] & 0xfc) | m_selected_drive_number;
-
- m_output1 = (m_selected_drive_number != NODRIVE)? (0x10 << m_selected_drive_number) : 0;
- m_output1 |= (m_register_w[RETRY_COUNT]&0x0f);
- if (TRACE_AUXBUS) logerror("%s: Setting OUTPUT1 to %02x\n", tag(), m_output1);
- m_substate = (head_load_delay>0)? HEAD_DELAY : DONE;
- }
-
- // As for the head delay, the specs are not clear when it is applied.
- // There is no input line indicating whether the head is already loaded
- // (see WD17xx: HLT). Let's assume for now that the head is loaded with
- // this drive select operation, and that we have the delay here.
- switch (m_substate)
- {
- case HEAD_DELAY:
- wait_time(m_timer, head_load_delay, DONE);
- cont = WAIT;
- break;
- case DONE:
- cont = SUCCESS;
- break;
- }
-
- if (cont==SUCCESS) set_command_done(TC_SUCCESS);
-}
-
-/*
- SET REGISTER POINTER
-
- Sets the pointer to the read and write registers. On read or write accesses,
- the pointer is increased until it reaches the DATA register.
-*/
-void hdc92x4_device::set_register_pointer()
-{
- m_register_pointer = current_command() & 0xf;
- if (TRACE_SETPTR) logerror("%s: SET REGISTER POINTER command; start reg=%d\n", tag(), m_register_pointer);
- // The specification does not say anything about the effect of setting an
- // invalid value (only "care should be taken")
- if (m_register_pointer > 10)
- {
- logerror("%s: set register pointer: Invalid register number: %d. Setting to 10.\n", tag(), m_register_pointer);
- m_register_pointer = 10;
- }
- set_command_done(TC_SUCCESS);
-}
-
-/*
- SEEK / READ ID
- This command is used to move the head to the desired cylinder.
- Depending on the Verify setting, the target sector is sought on the
- track, else the command terminates after the step pulses have been issued.
-
- Command word
-
- 7 6 5 4 3 2 1 0
- +-----+-----+-----+-----+-----+-----+-----+-----+
- | 0 | 1 | 0 | 1 | 0 | Step| Seek| Verf|
- +-----+-----+-----+-----+-----+-----+-----+-----+
-
- All combinations of flags are legal ([1], p.12).
-*/
-void hdc92x4_device::seek_read_id()
-{
- if (m_substate == UNDEF)
- {
- // Command init
- if (TRACE_READ) logerror("%s: SEEK / READ ID command %02x, CHS=(%d,%d,%d)\n", tag(), current_command(), desired_cylinder(), desired_head(), desired_sector());
- m_substate = READ_ID;
- }
-
- int cont = NEXT;
- bool step_enable = (current_command() & 0x04)==1;
- bool wait_seek_comp = (current_command() & 0x02)==1;
- bool do_verify = (current_command() & 0x01)==1;
- m_logical = true;
-
- while (cont == NEXT)
- {
- switch (m_substate & 0xf0)
- {
- case READ_ID:
- read_id(cont, step_enable, wait_seek_comp);
- break;
- case VERIFY:
- if (!do_verify)
- cont = SUCCESS;
- else
- verify(cont);
- break;
- case DATA_TRANSFER:
- // No data transfer here. Just exit.
- cont = SUCCESS;
- break;
- default:
- logerror("%s: BUG: Unknown substate %02x in seek_read_id, aborting command\n", tag(), m_substate);
- set_command_done(TC_DATAERR);
- cont = ERROR;
- }
- }
-
- if (cont==SUCCESS) set_command_done(TC_SUCCESS);
-}
-
-/*
- READ SECTORS PHYSICAL / LOGICAL
- Read the desired sectors, maximum count being specified in SECTOR_COUNT
-
- Physical:
- For multiple sectors, read the sectors in the order as they appear on the track.
- The command terminates with the next index pulse or when all sectors have been read before.
- Implied seek (locate the correct track) is always true (opcodes 5a and 5b
- are used for READ TRACK).
-
- Logical:
- For multiple sectors, read the sectors in ascending order of their sector field (sector n, n+1, n+2 ...).
-
- Command word
-
- 7 6 5 4 3 2 1 0
- +-----+-----+-----+-----+-----+--------+------+------+
- | 0 | 1 | 0 | 1 | 1 | Logical|NoSeek| Trans|
- +-----+-----+-----+-----+-----+--------+------+------+
-
-*/
-void hdc92x4_device::read_sectors()
-{
- m_logical = (current_command() & 0x04)!=0;
-
- if (m_substate == UNDEF)
- {
- // Command init
- if (TRACE_READ) logerror("%s: READ SECTORS %s command %02x, CHS=(%d,%d,%d)\n", tag(), m_logical? "LOGICAL": "PHYSICAL", current_command(), desired_cylinder(), desired_head(), desired_sector());
- m_retry_save = m_register_w[RETRY_COUNT];
- m_multi_sector = (m_register_w[SECTOR_COUNT] != 1);
- m_write = false;
- m_substate = READ_ID;
- m_first_sector_found = false;
- }
-
- int cont = NEXT;
- bool implied_seek = (current_command() & 0x02)==0;
- m_transfer_enabled = (current_command() & 0x01)!=0;
-
- while (cont == NEXT)
- {
- switch (m_substate & 0xf0)
- {
- case READ_ID:
- read_id(cont, implied_seek, true); // Always check SEEK COMPLETE
- break;
- case VERIFY:
- verify(cont); // for physical, only verify the first sector
- break;
- case DATA_TRANSFER:
- data_transfer(cont);
- break;
- default:
- logerror("%s: BUG: Unknown substate %02x in read_sectors, aborting command\n", tag(), m_substate);
- set_command_done(TC_DATAERR);
- cont = ERROR;
- }
- }
-}
-
-/*
- READ TRACK
- Read all ID and data fields as they appear on the track. Command 5A only
- transmits the ID fields via DMA, which 5B transmits all ID and data fields.
- Note that the specifications do not mention any gaps to be transmitted as
- well.
-
- Command word
-
- 7 6 5 4 3 2 1 0
- +-----+-----+-----+-----+-----+-----+-----+------+
- | 0 | 1 | 0 | 1 | 1 | 0 | 1 | All |
- +-----+-----+-----+-----+-----+-----+-----+------+
-
-*/
-void hdc92x4_device::read_track()
-{
- if (m_substate == UNDEF)
- {
- if (TRACE_READTRACK) logerror("%s: READ TRACK command %02x, head = %d\n", tag(), current_command(), desired_head());
- dma_address_out(m_register_w[DMA23_16], m_register_w[DMA15_8], m_register_w[DMA7_0]);
- m_transfer_enabled = (current_command() & 1)!=0;
- }
-
- int cont = NEXT;
- while (cont == NEXT)
- {
- switch (m_substate)
- {
- case WAITINDEX0:
- if (TRACE_READTRACK && TRACE_DETAIL) logerror("%s: Read track - waiting for index hole\n", tag());
- if (!index_hole())
- {
- m_substate = WAITINDEX1;
- cont = NEXT;
- }
- else
- {
- // We're above the index hole; wait for the index line going down
- if (TRACE_READTRACK && TRACE_DETAIL) logerror("%s: Index hole just passing by ... waiting for next\n", tag());
- wait_line(INDEX_LINE, ASSERT_LINE, WAITINDEX1, false);
- cont = WAIT;
- }
- break;
- case WAITINDEX1:
- // Waiting for the next rising edge
- wait_line(INDEX_LINE, ASSERT_LINE, TRACKSTART, false);
- cont = WAIT;
- break;
- case TRACKSTART:
- if (TRACE_READTRACK && TRACE_DETAIL) logerror("%s: Read track - index hole arrived\n", tag());
- live_start(READ_TRACK);
- cont = WAIT;
- break;
- case TRACKDONE:
- if (TRACE_READTRACK && TRACE_SUBSTATES) logerror("%s: Track reading done\n", tag());
- cont = SUCCESS;
- m_out_dmarq(CLEAR_LINE);
- m_out_dip(CLEAR_LINE);
- break;
- }
- }
-
- if (cont==SUCCESS) set_command_done(TC_SUCCESS);
-}
-
-/*
- FORMAT TRACK
- Writes a track on the selected drive at the current cylinder. The write
- process starts with the falling edge of the index hole and stops with
- the rising edge of the next index hole.
-
- The formatting is done exclusively by the controller; user programs may
- set parameters for gaps and interleaving.
-
- 1. Before starting the command, the user program must have set up a
- sector sequence table in the controller RAM (located on the PCB):
- (ident, cylinder, head, sector1, size) (5 bytes)
- (ident, cylinder, head, sector2, size)
- (ident, cylinder, head, sector3, size)
- ...
- ident is not required for floppy FM operation. size is not required
- for IBM AT-compatible hard disks.
-
- 2. The DMA registers must point to the beginning of the table
-
- 3. DRIVE_SELECT must be executed (which moves DMA regs to CUR_HEAD ...)
-
- 4. DESIRED_HEAD register must be loaded
-
- 5. The following setup must be done:
-
- GAP 0 size DMA7_0 (2s comp)
- GAP 1 size DMA15_8 (2s comp)
- GAP 2 size DMA23_16 (2s comp)
- GAP 3 size DESIRED_SECTOR (2s comp)
- Sync size DESIRED_CYLINDER (1s comp)
- Sector count SECTOR_COUNT (1s comp)
- Sector size multiple RETRY_COUNT (1s comp)
-
- GAP4 is variable and fills the rest of the track until the next
- index hole.
-
- 6. The step rate and density must be loaded into the MODE register
-
- 7. The drive must be stepped to the desired track.
-
- 8. Now this command may be started.
-
- All data bytes of a sector are filled with 0xe5. The gaps will be filled
- with 0x4e (MFM) or 0xff (FM).
-
- To format another track, the sector id table must be updated, and steps
- 7 and 8 must be repeated. If the DESIRED_HEAD register must be updated,
- the complete setup process must be done.
-
- Command word
-
- 7 6 5 4 3 2 1 0
- +-----+-----+-----+------+-----+-----+-----+------+
- | 0 | 1 | 1 |DelMrk|RedWC| Precompensation |
- +-----+-----+-----+------+-----+-----+-----+------+
-*/
-void hdc92x4_device::format_track()
-{
- if (m_substate == UNDEF)
- {
- if (TRACE_FORMAT) logerror("%s: FORMAT TRACK command %02x, head = %d\n", tag(), current_command(), desired_head());
- m_substate = WAITINDEX0;
- m_deleted = (current_command() & 0x10)!=0;
- m_reduced_write_current = (current_command() & 0x08)!=0;
- m_precompensation = (current_command() & 0x07);
- m_write = true;
-
- m_gap0_size = -m_register_w[DMA7_0] & 0xff;
- m_gap1_size = -m_register_w[DMA15_8] & 0xff;
- m_gap2_size = -m_register_w[DMA23_16] & 0xff;
- m_gap3_size = -m_register_w[DESIRED_SECTOR] & 0xff;
- m_sync_size = ~m_register_w[DESIRED_CYLINDER] & 0xff;
- m_sector_count = ~m_register_w[SECTOR_COUNT] & 0xff;
- m_sector_size = (~m_register_w[RETRY_COUNT] & 0xff) * 128;
-
- if (TRACE_FORMAT && TRACE_DETAIL)
- {
- logerror("%s: GAP0 length = %d\n", tag(), m_gap0_size);
- logerror("%s: GAP1 length = %d\n", tag(), m_gap1_size);
- logerror("%s: GAP2 length = %d\n", tag(), m_gap2_size);
- logerror("%s: GAP3 length = %d\n", tag(), m_gap3_size);
- logerror("%s: Sync size = %d\n", tag(), m_sync_size);
- logerror("%s: Sector count = %d\n", tag(), m_sector_count);
- logerror("%s: Sector size = %d\n", tag(), m_sector_size);
- }
-
- dma_address_out(m_register_r[CURRENT_IDENT], m_register_r[CURRENT_CYLINDER], m_register_r[CURRENT_HEAD]);
- }
-
- int cont = NEXT;
- while (cont == NEXT)
- {
- switch (m_substate)
- {
- case WAITINDEX0:
- if (TRACE_FORMAT && TRACE_DETAIL) logerror("%s: Format track; looking for track start\n", tag());
- if (!index_hole())
- {
- m_substate = WAITINDEX1;
- cont = NEXT;
- }
- else
- {
- // We're above the index hole right now, so wait for the line going down
- if (TRACE_FORMAT && TRACE_DETAIL) logerror("%s: Index hole just passing by ... \n", tag());
- wait_line(INDEX_LINE, CLEAR_LINE, WAITINDEX1, false);
- cont = WAIT;
- }
- break;
- case WAITINDEX1:
- // Waiting for the next rising edge
- if (TRACE_FORMAT && TRACE_DETAIL) logerror("%s: Waiting for next index hole\n", tag());
- wait_line(INDEX_LINE, ASSERT_LINE, TRACKSTART, false);
- cont = WAIT;
- break;
- case TRACKSTART:
- if (TRACE_FORMAT && TRACE_DETAIL) logerror("%s: Format track - index hole arrived\n", tag());
- live_start(FORMAT_TRACK);
- cont = WAIT;
- break;
- case TRACKDONE:
- if (FORMAT_TRACK && TRACE_SUBSTATES) logerror("%s: Track writing done\n", tag());
- cont = SUCCESS;
- break;
- }
- }
-
- if (cont==SUCCESS) set_command_done(TC_SUCCESS);
-}
-
-/*
- WRITE SECTORS PHYSICAL / LOGICAL
-
- Write the desired sectors, maximum count being specified in SECTOR_COUNT
-
- Physical:
- For multiple sectors, write sector contents into the data fields of
- the sectors as they are arranged on the track.
- The command terminates with the next index pulse or when all sectors have been written before.
-
- Logical:
- For multiple sectors, write the sectors in ascending order of their
- sector field (sector n, n+1, n+2 ...).
-
- Command word
-
- 7 6 5 4 3 2 1 0
- +-----+------+-------+------+-----+-----+-----+------+
- | 1 |NoSeek|Logical|DelMrk|RedWC| Precompensation |
- +-----+------+-------+------+-----+-----+-----+------+
-*/
-void hdc92x4_device::write_sectors()
-{
- m_logical = (current_command() & 0x20)!=0;
-
- if (m_substate == UNDEF)
- {
- if (TRACE_WRITE) logerror("%s: WRITE SECTORS %s command %02x, CHS=(%d,%d,%d)\n", tag(), m_logical? "LOGICAL" : "PHYSICAL", current_command(), desired_cylinder(), desired_head(), desired_sector());
- m_multi_sector = (m_register_w[SECTOR_COUNT] != 1);
- m_substate = READ_ID;
-
- m_deleted = (current_command() & 0x10)!=0;
- m_reduced_write_current = (current_command() & 0x08)!=0;
- m_precompensation = (current_command() & 0x07);
- // Important for DATA TRANSFER
- m_transfer_enabled = true;
-
- // Something interesting here:
- //
- // The values for sync and gap2 are passed to the formatting routing
- // but how do we know their values right now, when we are writing sectors?
- // Since this is not clearly stated in the specification, we have to
- // use the default values here
- // Actually, why can we choose that value for formatting in the first place?
-
- if (using_floppy())
- {
- m_sync_size = fm_mode()? 6 : 12;
- m_gap2_size = fm_mode()? 11 : 22;
- }
- else
- {
- // Values for HD
- m_sync_size = 13;
- m_gap2_size = 3;
- }
- m_write = false; // until we're writing
- m_first_sector_found = false;
- }
-
- int cont = NEXT;
- bool implied_seek = (current_command() & 0x40)==0;
-
- while (cont == NEXT)
- {
- // We're dispatching by substate value range
- switch (m_substate & 0xf0)
- {
- case READ_ID:
- read_id(cont, implied_seek, true); // Always check SEEK COMPLETE
- break;
- case VERIFY:
- verify(cont);
- break;
- case DATA_TRANSFER:
- m_write = true;
- data_transfer(cont);
- break;
- default:
- logerror("%s: BUG: Unknown substate %02x in write_sectors, aborting command\n", tag(), m_substate);
- set_command_done(TC_DATAERR);
- cont = ERROR;
- }
- }
-}
-
-/*
-===========================================================================
-
- Live state machine
-
- We follow a very similar approach to track access like in wd_fdc. The live
- state machine attempts to find marks on the track, starting from the current
- position. When found, it waits for the machine to catch up. When an event
- happens in the meantime, the state machine is rolled back, and the actions
- are replayed until the position where the event occurred.
-
- Lots of code is taken from wd_fdc, with some minor restructuring and renaming.
- Same ideas, though. More comments.
-
-===========================================================================
-*/
-
-std::string hdc92x4_device::tts(const attotime &t)
-{
- char buf[256];
- int nsec = t.attoseconds() / ATTOSECONDS_PER_NANOSECOND;
- sprintf(buf, "%4d.%03d,%03d,%03d", int(t.seconds()), nsec/1000000, (nsec/1000)%1000, nsec % 1000);
- return buf;
-}
-
-std::string hdc92x4_device::ttsn()
-{
- return tts(machine().time());
-}
-
-bool hdc92x4_device::found_mark(int state)
-{
- bool ismark = false;
- if (using_floppy())
- {
- if (state==SEARCH_IDAM) ismark = (m_live_state.shift_reg == fm_mode()? 0xf57e : 0x4489);
- else
- {
- // f56a 1x1x
- ismark = fm_mode()? ((m_live_state.shift_reg & 0xfffa) == 0xf56a) : (m_live_state.shift_reg == 0x4489);
- }
- }
- else
- {
- switch (m_hd_encoding)
- {
- case MFM_BITS:
- case MFM_BYTE:
- ismark = (m_live_state.shift_reg == 0x4489);
- break;
- case SEPARATED:
- // 0 0 0 0 1 0 1 0
- // 1 0 1 0 0 0 0 1
- ismark = (m_live_state.data_reg == 0xa1 && m_live_state.clock_reg == 0x0a);
- break;
- case SEPARATED_SIMPLE:
- ismark = (m_live_state.data_reg == 0xa1 && m_live_state.clock_reg == 0xff);
- break;
- }
- }
- return ismark;
-}
-
-/*
- The controller starts to read bits from the disk. This method takes an
- argument for the state machine called at the end.
-*/
-void hdc92x4_device::live_start(int state)
-{
- if (TRACE_LIVE) logerror("%s: [%s] Live start substate=%02x\n", tag(), ttsn().c_str(), state);
- m_live_state.time = machine().time();
- m_live_state.state = state;
- m_live_state.next_state = -1;
-
- m_live_state.shift_reg = 0;
- m_live_state.crc = 0xffff;
- m_live_state.bit_counter = 0;
- m_live_state.byte_counter = 0;
- m_live_state.data_separator_phase = false;
- m_live_state.data_reg = 0;
- m_live_state.last_data_bit = false;
-
- if (using_floppy()) pll_reset(m_live_state.time, m_write);
- m_checkpoint_state = m_live_state;
-
- // Save checkpoint
- m_checkpoint_pll = m_pll;
-
- live_run();
- m_last_live_state = UNDEF;
- if (TRACE_LIVE) logerror("%s: [%s] Live start end\n", tag(), ttsn().c_str()); // delete
-}
-
-void hdc92x4_device::live_run()
-{
- if (using_floppy()) live_run_until(attotime::never);
- else live_run_hd_until(attotime::never);
-}
-
-/*
- The main method of the live state machine. We stay in this method until
- the requested data are read.
- limit: if unlimited (attotime::never), run up to the end of the track and wait there
- otherwise, used to replay the read/write operation up to the point where the event happened
-
- THIS IS THE FLOPPY-ONLY LIVE_RUN
-*/
-void hdc92x4_device::live_run_until(attotime limit)
-{
- int slot = 0;
-
- if (m_live_state.state == IDLE || m_live_state.next_state != -1)
- return;
-
- if (TRACE_LIVE)
- {
- if (limit == attotime::never)
- logerror("%s: [%s live] live_run, live_state=%02x, mode=%s\n", tag(), tts(m_live_state.time).c_str(), m_live_state.state, fm_mode()? "FM":"MFM");
- else
- logerror("%s: [%s live] live_run until %s, live_state=%02x, mode=%s\n", tag(), tts(m_live_state.time).c_str(), tts(limit).c_str(), m_live_state.state, fm_mode()? "FM":"MFM");
- }
-
- if (limit == attotime::never)
- {
- // We did not specify an upper time bound, so we take the next index pulse
- if (m_floppy != NULL) limit = m_floppy->time_next_index();
-
- if (limit == attotime::never)
- {
- // We don't have an index pulse? (no disk?)
- // See wd_fdc: Force a sync from time to time in that case
- // so that the main cpu timeout isn't too painful. Avoids
- // looping into infinity looking for data too.
- limit = machine().time() + attotime::from_msec(1);
- m_timer->adjust(attotime::from_msec(1));
- }
- }
-
- while (true)
- {
- switch (m_live_state.state)
- {
- case SEARCH_IDAM:
-
- // We're doing this complicated logerror check to avoid
- // repeated logging in the same state. This can be found for the
- // other live states as well. m_last_live_state is only used to
- // control this logging.
-
- if (TRACE_LIVE && m_last_live_state != SEARCH_IDAM)
- {
- logerror("%s: [%s live] SEARCH_IDAM [limit %s]\n", tag(),tts(m_live_state.time).c_str(), tts(limit).c_str());
- m_last_live_state = m_live_state.state;
- }
-
- // This bit will be set when the IDAM cannot be found
- set_bits(m_register_r[CHIP_STATUS], CS_SYNCERR, false);
-
- if (read_one_bit(limit))
- {
- if (TRACE_LIVE) logerror("%s: [%s live] SEARCH_IDAM limit reached\n", tag(), tts(m_live_state.time).c_str());
- return;
- }
- // logerror("%s: SEARCH_IDAM\n", tts(m_live_state.time).c_str());
- if (TRACE_SHIFT) logerror("%s: [%s live] shift = %04x data=%02x c=%d\n", tag(), tts(m_live_state.time).c_str(), m_live_state.shift_reg,
- get_data_from_encoding(m_live_state.shift_reg), m_live_state.bit_counter);
-
- // [1] p. 9: The ID field sync mark must be found within 33,792 byte times
- if (m_live_state.bit_count_total > 33792*16)
- {
- // Desired sector not found within time
- if (m_substate == VERIFY3)
- wait_for_realtime(VERIFY_FAILED);
- else
- wait_for_realtime(SEARCH_IDAM_FAILED);
- return;
- }
-
- if (!fm_mode())
- {
- // MFM case
- if (m_live_state.shift_reg == 0x4489)
- {
- if (TRACE_LIVE) logerror("%s: [%s live] Found an A1 mark\n", tag(),tts(m_live_state.time).c_str());
- m_live_state.crc = 0x443b;
- m_live_state.data_separator_phase = false;
- m_live_state.bit_counter = 0;
- // Next task: find the next two A1 marks
- m_live_state.state = READ_TWO_MORE_A1_IDAM;
- }
- }
- else
- {
- // FM case
- if (m_live_state.shift_reg == 0xf57e)
- {
- if (TRACE_LIVE) logerror("%s: SEARCH_IDAM: IDAM found\n", tag());
- m_live_state.crc = 0xef21;
- m_live_state.data_separator_phase = false;
- m_live_state.bit_counter = 0;
- m_live_state.state = READ_ID_FIELDS_INTO_REGS;
- }
- }
- break;
-
- case SEARCH_IDAM_FAILED:
- set_bits(m_register_r[CHIP_STATUS], CS_SYNCERR, true);
- m_live_state.state = IDLE;
- return;
-
- case VERIFY_FAILED:
- set_bits(m_register_r[CHIP_STATUS], CS_COMPERR, true);
- m_live_state.state = IDLE;
- return;
-
- case READ_TWO_MORE_A1_IDAM: // This state only applies for MFM mode.
-
- if (TRACE_LIVE && m_last_live_state != READ_TWO_MORE_A1_IDAM)
- {
- logerror("%s: [%s live] READ_TWO_MORE_A1\n", tag(),tts(m_live_state.time).c_str());
- m_last_live_state = m_live_state.state;
- }
-
- // Beyond time limit?
- if (read_one_bit(limit)) return;
-
- if (TRACE_SHIFT) logerror("%s: [%s live] shift = %04x data=%02x c=%d\n", tag(), tts(m_live_state.time).c_str(), m_live_state.shift_reg,
- get_data_from_encoding(m_live_state.shift_reg), m_live_state.bit_counter);
-
- if (m_live_state.bit_count_total > 33792*16)
- {
- wait_for_realtime(SEARCH_IDAM_FAILED);
- return;
- }
-
- // Repeat until we have collected 16 bits
- if (m_live_state.bit_counter & 15) break;
-
- // So we now got 16 bits. Fill this value into the next slot. We expect two more A1 values.
- slot = m_live_state.bit_counter >> 4;
- if (slot < 3)
- {
- if (m_live_state.shift_reg != 0x4489)
- {
- // This ain't A1. Step back into the previous state (look for the next IDAM).
- m_live_state.state = SEARCH_IDAM;
- }
- else
- if (TRACE_LIVE) logerror("%s: [%s live] Found an A1 mark\n", tag(),tts(m_live_state.time).c_str());
- // Continue
- break;
- }
-
- if (TRACE_LIVE) logerror("%s: [%s live] Found data value %02X\n", tag(),tts(m_live_state.time).c_str(), m_live_state.data_reg);
-
- // Check for ident field (fe, ff, fd, fc)
- if ((m_live_state.data_reg & 0xfc) != 0xfc)
- {
- // This may happen when we accidentally locked onto the DAM. Look for the next IDAM.
- if (TRACE_LIVE)
- {
- if (m_live_state.data_reg == 0xf8 || m_live_state.data_reg == 0xfb)
- logerror("%s: [%s live] Looks like a DAM; continue to next mark\n", tag(), tts(m_live_state.time).c_str());
- else
- logerror("%s: [%s live] Missing ident data after A1A1A1, and it was not DAM; format corrupt?\n", tag(), tts(m_live_state.time).c_str());
- }
- m_live_state.state = SEARCH_IDAM;
- break;
- }
-
- m_register_r[CURRENT_IDENT] = m_live_state.data_reg;
-
- // We're here after we got the three A1 and FE
- m_live_state.bit_counter = 0;
- m_live_state.state = READ_ID_FIELDS_INTO_REGS;
- break;
-
- case READ_ID_FIELDS_INTO_REGS:
- if (TRACE_LIVE && m_last_live_state != READ_ID_FIELDS_INTO_REGS)
- {
- logerror("%s: [%s live] READ_ID_FIELDS_INTO_REGS\n", tag(),tts(m_live_state.time).c_str());
- m_last_live_state = m_live_state.state;
- }
-
- if (read_one_bit(limit))
- {
- return;
- }
- // Already got 16 bits?
- if (m_live_state.bit_counter & 15) break;
-
- slot = (m_live_state.bit_counter >> 4)-1;
-
- if (TRACE_LIVE) logerror("%s: slot %d = %02x, crc=%04x\n", tag(), slot, m_live_state.data_reg, m_live_state.crc);
-
- // The id_field is an array of indexes into the chip registers.
- // Thus we get the values properly assigned to the registers.
- m_register_r[id_field[slot]] = m_live_state.data_reg;
-
- if(slot > 4)
- {
- // We successfully read the ID fields; let's wait for the machine time to catch up.
- if (reading_track())
- // Continue if we're reading a complete track
- wait_for_realtime(READ_TRACK_ID_DONE);
- else
- // Live run is done here; it is the main state machine's turn again.
- wait_for_realtime(IDLE);
- return;
- }
- break;
-
- // ==================================================
- // Live states for sector read operations
- // ==================================================
-
- case SEARCH_DAM:
- if (TRACE_LIVE && m_last_live_state != SEARCH_DAM)
- {
- logerror("%s: [%s live] SEARCH_DAM\n", tag(),tts(m_live_state.time).c_str());
- m_last_live_state = m_live_state.state;
- }
-
- set_bits(m_register_r[CHIP_STATUS], CS_DELDATA, false);
-
- if(read_one_bit(limit))
- return;
-
- if (TRACE_SHIFT) logerror("%s: [%s live] shift = %04x data=%02x c=%d\n", tag(), tts(m_live_state.time).c_str(), m_live_state.shift_reg,
- get_data_from_encoding(m_live_state.shift_reg), m_live_state.bit_counter);
-
- if (!fm_mode())
- { // MFM
- if(m_live_state.bit_counter > 43*16)
- {
- if (TRACE_FAIL) logerror("%s: SEARCH_DAM failed\n", tag());
- wait_for_realtime(SEARCH_DAM_FAILED);
- return;
- }
-
- if (m_live_state.bit_counter >= 28*16 && m_live_state.shift_reg == 0x4489)
- {
- if (TRACE_LIVE) logerror("%s: [%s live] Found an A1 mark\n", tag(),tts(m_live_state.time).c_str());
- m_live_state.crc = 0x443b;
- m_live_state.data_separator_phase = false;
- m_live_state.bit_counter = 0;
- m_live_state.state = READ_TWO_MORE_A1_DAM;
- }
- }
- else
- { // FM
- if (m_live_state.bit_counter > 23*16)
- {
- if (TRACE_FAIL) logerror("%s: SEARCH_DAM failed\n", tag());
- wait_for_realtime(SEARCH_DAM_FAILED);
- return;
- }
-
- if (m_live_state.bit_counter >= 11*16 && (m_live_state.shift_reg == 0xf56a || m_live_state.shift_reg == 0xf56b ||
- m_live_state.shift_reg == 0xf56e || m_live_state.shift_reg == 0xf56f)) {
- if (TRACE_LIVE) logerror("%s: SEARCH_DAM: found DAM = %04x\n", tag(), m_live_state.shift_reg);
- m_live_state.crc =
- m_live_state.shift_reg == 0xf56a ? 0x8fe7 :
- m_live_state.shift_reg == 0xf56b ? 0x9fc6 :
- m_live_state.shift_reg == 0xf56e ? 0xafa5 :
- 0xbf84;
- m_live_state.data_separator_phase = false;
- m_live_state.bit_counter = 0;
- m_live_state.state = READ_SECTOR_DATA;
- }
- }
- break;
-
- case READ_TWO_MORE_A1_DAM: {
- if (TRACE_LIVE && m_last_live_state != READ_TWO_MORE_A1_DAM)
- {
- logerror("%s: [%s live] READ_TWO_MORE_A1_DAM\n", tag(),tts(m_live_state.time).c_str());
- m_last_live_state = m_live_state.state;
- }
-
- if(read_one_bit(limit))
- return;
-
- if (TRACE_SHIFT) logerror("%s: [%s live] shift = %04x data=%02x c=%d\n", tag(), tts(m_live_state.time).c_str(), m_live_state.shift_reg,
- get_data_from_encoding(m_live_state.shift_reg), m_live_state.bit_counter);
-
- // Repeat until we have collected 16 bits
- if (m_live_state.bit_counter & 15) break;
-
- // Fill this value into the next slot. We expect three A1 values.
- int slot = m_live_state.bit_counter >> 4;
-
- if (slot < 3)
- {
- if (m_live_state.shift_reg != 0x4489)
- {
- wait_for_realtime(SEARCH_DAM_FAILED);
- return;
- }
- else
- if (TRACE_LIVE) logerror("%s: [%s live] Found an A1 mark\n", tag(),tts(m_live_state.time).c_str());
- // Continue
- break;
- }
-
- if (TRACE_LIVE) logerror("%s: [%s live] Found data value %02X\n", tag(),tts(m_live_state.time).c_str(), m_live_state.data_reg);
-
- if ((m_live_state.data_reg & 0xff) == 0xf8)
- {
- if (TRACE_LIVE) logerror("%s: Found deleted data mark F8 after DAM sync\n", tag());
- set_bits(m_register_r[CHIP_STATUS], CS_DELDATA, true);
- }
- else
- {
- if ((m_live_state.data_reg & 0xff) != 0xfb)
- {
- if (TRACE_FAIL) logerror("%s: Missing FB/F8 data mark after DAM sync\n", tag());
- wait_for_realtime(SEARCH_DAM_FAILED);
- return;
- }
- }
-
- m_live_state.bit_counter = 0;
- m_live_state.state = READ_SECTOR_DATA;
- break;
- }
- case SEARCH_DAM_FAILED:
- if (TRACE_FAIL) logerror("%s: SEARCH_DAM failed\n", tag());
- m_live_state.state = IDLE;
- return;
-
- case READ_SECTOR_DATA:
- {
- if (TRACE_LIVE && m_last_live_state != READ_SECTOR_DATA)
- {
- logerror("%s: [%s live] READ_SECTOR_DATA\n", tag(),tts(m_live_state.time).c_str());
- m_last_live_state = m_live_state.state;
- }
-
- if(read_one_bit(limit))
- return;
-
- // Request bus release at the first bit of each byte (floppy; [1], fig 5 and 6)
- if (m_transfer_enabled)
- {
- if ((m_live_state.bit_counter & 15)== 1)
- {
- // For floppies, request DMA for each byte. For hard disk, get it
- // only for the first byte and then keep the bus until the last byte.
- if (using_floppy() || m_live_state.bit_counter < 16)
- {
- set_bits(m_register_r[INT_STATUS], ST_OVRUN, true);
- m_out_dmarq(ASSERT_LINE);
- }
- }
- }
-
- // Repeat until we have collected 16 bits
- if (m_live_state.bit_counter & 15) break;
-
- if (TRACE_LIVE) logerror("%s: [%s live] Found data value %02X, CRC=%04x\n", tag(),tts(m_live_state.time).c_str(), m_live_state.data_reg, m_live_state.crc);
- int slot = (m_live_state.bit_counter >> 4)-1;
-
- if (slot < calc_sector_size())
- {
- // Sector data
- wait_for_realtime(READ_SECTOR_DATA_CONT);
- return;
- }
- else if (slot < calc_sector_size()+2)
- {
- // CRC
- if (slot == calc_sector_size()+1)
- {
- if (reading_track())
- {
- // Reading a track? Continue with next ID.
- wait_for_realtime(READ_TRACK_ID);
- }
- else
- {
- if (TRACE_LIVE) logerror("%s: [%s live] Sector read completed\n", tag(),tts(m_live_state.time).c_str());
- wait_for_realtime(IDLE);
- }
- return;
- }
- }
- break;
- }
-
- case READ_SECTOR_DATA_CONT:
- if (TRACE_LIVE && m_last_live_state != READ_SECTOR_DATA_CONT)
- {
- logerror("%s: [%s live] READ_SECTOR_DATA_CONT\n", tag(),tts(m_live_state.time).c_str());
- m_last_live_state = m_live_state.state;
- }
-
- // Did the system CPU send the DMA ACK in the meantime?
- if ((m_register_r[INT_STATUS] & ST_OVRUN)!=0)
- {
- if (TRACE_FAIL) logerror("%s: No DMA ACK - buffer overrun\n", tag());
- set_bits(m_register_r[INT_STATUS], TC_DATAERR, true);
- m_live_state.state = IDLE;
- return;
- }
-
- if (m_transfer_enabled)
- {
- m_register_r[DATA] = m_register_w[DATA] = m_live_state.data_reg;
- // See above: For floppy, do it for each byte; for hard disk, only for the first byte,
- if (using_floppy() || m_live_state.bit_counter == 16)
- m_out_dip(ASSERT_LINE);
-
- m_out_dma(0, m_register_r[DATA], 0xff);
-
- // And again, for floppies, clear line after writing each byte, for hard disk, only after the last byte
- if (using_floppy() || (m_live_state.bit_counter >> 4)==calc_sector_size()-1)
- {
- m_out_dip(CLEAR_LINE);
- m_out_dmarq(CLEAR_LINE);
- }
- }
-
- m_live_state.state = READ_SECTOR_DATA;
- checkpoint();
- break;
-
- // ==================================================
- // Live states for sector write operations
- // ==================================================
-
- case WRITE_DAM_AND_SECTOR:
- // 1. Wait for 22*16 cells (MFM) or 11*16 cells (FM) [704 usec, Gap 2]
- // 2. Write 12 (MFM) or 6 (FM) zeros
- // 3. Write 3*A1 sync plus the ident byte (MFM) or FB (FM) or F8 (deleted)
- // 4. Write the sector content and calculate the CRC on the fly
- // 5. Write the CRC bytes
-
- if (TRACE_LIVE)
- logerror("%s: [%s live] WRITE_DAM_AND_SECTOR\n", tag(), tts(m_live_state.time).c_str());
-
- skip_on_track(m_gap2_size, WRITE_DAM_SYNC);
- break;
-
- case WRITE_DAM_SYNC:
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Write sync zeros\n", tag());
-
- // Clear the overrun/underrun flag
- set_bits(m_register_r[INT_STATUS], ST_OVRUN, false);
- write_on_track(encode(0x00), m_sync_size, fm_mode()? WRITE_DATAMARK : WRITE_A1);
- break;
-
- case WRITE_A1:
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Write three A1\n", tag());
- write_on_track(0x4489, 3, WRITE_DATAMARK);
- break;
-
- case WRITE_DATAMARK:
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Write data mark and sector contents\n", tag());
- if (fm_mode())
- {
- // Init the CRC for the DAM and sector
- m_live_state.crc = 0xffff;
-
- // 1111 0101 0110 1010 = F8 deleted
- // 1111 0101 0110 1111 = FB normal
- write_on_track(m_deleted? 0xf56a : 0xf56f, 1, WRITE_SECDATA);
- }
- else
- {
- // Init the CRC for the ident byte and sector
- m_live_state.crc = 0xcdb4; // value for 3*A1
- write_on_track(encode(m_deleted? 0xf8 : 0xfb), 1, WRITE_SECDATA);
- }
- m_live_state.byte_counter = calc_sector_size();
-
- // Set the over/underrun flag and hope that it will be cleared before we start writing
- // (only for sector writing)
- if (m_substate == DATA_TRANSFER_WRITE)
- {
- set_bits(m_register_r[INT_STATUS], ST_OVRUN, true);
- m_out_dmarq(ASSERT_LINE);
- }
- break;
-
- case WRITE_SECDATA:
- if (m_substate == DATA_TRANSFER_WRITE)
- {
- // Check whether DMA has been acknowledged
- if ((m_register_r[INT_STATUS] & ST_OVRUN)!=0)
- {
- // No, then stop here
- m_live_state.state= NO_DMA_ACK;
- }
- else
- {
- // For floppies, set this for each byte; for hard disk, set it only at the beginning
- if (using_floppy() || m_live_state.byte_counter == calc_sector_size())
- m_out_dip(ASSERT_LINE);
-
- m_register_r[DATA] = m_register_w[DATA] = m_in_dma(0, 0xff);
-
- if (using_floppy() || m_live_state.byte_counter == 0)
- {
- m_out_dip(CLEAR_LINE);
- m_out_dmarq(CLEAR_LINE);
- }
-
- if (m_live_state.byte_counter > 0)
- {
- m_live_state.byte_counter--;
- write_on_track(encode(m_register_r[DATA]), 1, WRITE_SECDATA);
- if (using_floppy()) m_out_dmarq(ASSERT_LINE);
- }
- else
- {
- m_live_state.state = WRITE_DATA_CRC;
- m_live_state.byte_counter = 2;
- }
- }
- }
- else
- {
- // We are here in the context of track formatting. Write a
- // blank sector
- write_on_track(encode(0xe5), m_sector_size, WRITE_DATA_CRC);
- m_live_state.byte_counter = 2;
- }
- break;
-
- case WRITE_DATA_CRC:
- // N.B.: when we write the first CRC byte, the value of the CRC will
- // change to the previous second byte, so we can write the first
- // byte in two iterations to get both
- if (m_live_state.byte_counter > 0)
- {
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Write CRC\n", tag());
- m_live_state.byte_counter--;
- write_on_track(encode((m_live_state.crc >> 8) & 0xff), 1, WRITE_DATA_CRC);
- }
- else
- // Write a filler byte so that the last CRC bit is saved correctly
- // Without, the last bit of the CRC value may be flipped
- write_on_track(encode(0xff), 1, WRITE_DONE);
-
- break;
-
- case WRITE_DONE:
- if (m_substate == DATA_TRANSFER_WRITE)
- {
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Write sector complete\n", tag());
- m_pll.stop_writing(m_floppy, m_live_state.time);
- m_live_state.state = IDLE;
- return;
- }
- else
- {
- // Continue for track writing: Write GAP3
- m_live_state.state = WRITE_GAP3;
- }
- break;
-
-// --------------------------------------------------------
-
- // ==================================================
- // Live states for track formatting
- // Write GAP 0
- // Write Sync+IXAM
- // Write GAP 1
- // Per sector
- // Write Sync+IDAM
- // Write Sector header+CRC
- // Write GAP2
- // Write Sync+DAM
- // Write Sector data
- // Write CRC bytes
- // Write GAP3
- // Write GAP4 until the next pulse
- // ==================================================
-
- case FORMAT_TRACK:
- if (TRACE_LIVE) logerror("%s: FORMAT_TRACK\n", tag());
- m_live_state.state = WRITE_GAP0;
- m_pll.start_writing(m_live_state.time);
- break;
-
- case WRITE_GAP0:
- // GAP0 length is in DMA7_0 (negated, 2s comp)
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Writing GAP0\n", tag());
- write_on_track(encode(fm_mode()? 0xff : 0x4e), m_gap0_size, WRITE_IXAM_SYNC);
- break;
-
- case WRITE_IXAM_SYNC:
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Writing IXAM sync\n", tag());
- write_on_track(encode(0x00), m_sync_size, WRITE_IXAM);
- break;
-
- case WRITE_IXAM:
- // FM: FC with clock D7 = 1111 -111 -111 1010
- // MFM: C2 = 11000010
- // 0101 0010 -010 0100
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Writing IXAM\n", tag());
- if (fm_mode())
- write_on_track(0xf77a, 1, WRITE_GAP1);
- else
- write_on_track(0x5224, 3, WRITE_FC);
-
- break;
-
- case WRITE_FC:
- // Only for MFM
- write_on_track(encode(0xfc), 1, WRITE_GAP1);
- break;
-
- case WRITE_GAP1:
- // GAP1 length is in DMA15_8
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Writing GAP1\n", tag());
- write_on_track(encode(fm_mode()? 0xff : 0x4e), m_gap1_size, WRITE_IDAM_SYNC);
- break;
-
- // When does the HDC actually fetch the per-sector data? All data
- // at the beginning? Only the bytes for the next sector?
- // We assume it reads the bytes and writes them directly on the disk
-
- case WRITE_IDAM_SYNC:
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Writing IDAM sync\n", tag());
- write_on_track(encode(0x00), m_sync_size, WRITE_IDAM);
- break;
-
- case WRITE_IDAM:
- // Set the over/underrun flag and hope that it will be cleared before we enter the next state (after writing)
- set_bits(m_register_r[INT_STATUS], ST_OVRUN, true);
- m_out_dmarq(ASSERT_LINE);
-
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Writing IDAM and header\n", tag());
- if (fm_mode())
- {
- write_on_track(0xf57e, 1, WRITE_HEADER);
- m_live_state.byte_counter = 4;
- }
- else
- {
- write_on_track(0x4489, 3, WRITE_HEADER);
- m_live_state.byte_counter = 5;
- }
- m_live_state.crc = 0xffff;
- break;
-
- case WRITE_HEADER:
- if ((m_register_r[INT_STATUS] & ST_OVRUN)!=0)
- // No DMA (we do not get access to the ID table); exit
- m_live_state.state= NO_DMA_ACK;
- else
- {
- m_out_dip(ASSERT_LINE);
- m_live_state.byte_counter--;
- UINT8 headbyte = m_in_dma(0, 0xff);
-
- write_on_track(encode(headbyte), 1, (m_live_state.byte_counter>0)? WRITE_HEADER : WRITE_HEADER_CRC);
-
- if (using_floppy() || m_live_state.byte_counter==0)
- {
- m_out_dip(CLEAR_LINE);
- m_out_dmarq(CLEAR_LINE);
- }
- // Writing will occur after the break; set the DMARQ again
- if (m_live_state.byte_counter>0)
- m_out_dmarq(ASSERT_LINE);
- else
- // we will go to WRITE_HEADER_CRC state; set the byte counter for CRC
- m_live_state.byte_counter = 2;
- }
- break;
-
- case WRITE_HEADER_CRC:
- if (m_live_state.byte_counter > 0)
- {
- UINT8 crct = (m_live_state.crc >> 8) & 0xff;
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Write CRC byte %02x\n", tag(), crct);
- m_live_state.byte_counter--;
- write_on_track(encode(crct), 1, WRITE_HEADER_CRC);
- }
- else
- m_live_state.state = WRITE_GAP2;
-
- break;
-
- case WRITE_GAP2:
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Writing GAP2\n", tag());
- write_on_track(encode(fm_mode()? 0xff : 0x4e), m_gap2_size, WRITE_DAM_SYNC);
- break;
-
- case WRITE_GAP3:
- m_sector_count--;
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Writing GAP3\n", tag());
- write_on_track(encode(fm_mode()? 0xff : 0x4e), m_gap3_size, (m_sector_count>0)? WRITE_IDAM_SYNC : WRITE_GAP4);
- break;
-
- case WRITE_GAP4:
- // Write bytes up to the end of the track
- wait_line(INDEX_LINE, ASSERT_LINE, TRACKDONE, true);
- if (TRACE_WRITE && TRACE_DETAIL && m_last_live_state != WRITE_GAP4)
- {
- logerror("%s: Writing GAP4\n", tag());
- m_last_live_state = WRITE_GAP4;
- }
- // Write a single byte; when the index hole shows up, the live run will be aborted
- write_on_track(encode(fm_mode()? 0xff : 0x4e), 1, WRITE_GAP4);
- break;
-// --------------------------------------------------------
-
- // ==================================================
- // Live states for track reading
- // ==================================================
-
- // Quite simple. Read the next ID fields, then the sector contents.
- // Continue until the next index hole shows up (live_abort).
- case READ_TRACK:
- if (TRACE_LIVE) logerror("%s: READ_TRACK\n", tag());
- m_live_state.state = READ_TRACK_ID;
- break;
-
- case READ_TRACK_ID:
- m_live_state.state = SEARCH_IDAM;
- // Ask for access to bus
- set_bits(m_register_r[INT_STATUS], ST_OVRUN, true);
- m_out_dmarq(ASSERT_LINE);
- break;
-
- case READ_TRACK_ID_DONE:
- if ((m_register_r[INT_STATUS] & ST_OVRUN)!=0)
- {
- if (TRACE_FAIL) logerror("%s: No DMA ACK - buffer overrun\n", tag());
- set_bits(m_register_r[INT_STATUS], TC_DATAERR, true);
- m_live_state.state = IDLE;
- return;
- }
- if (TRACE_LIVE) logerror("%s: READ_TRACK1\n", tag());
-
- m_out_dip(ASSERT_LINE);
-
- // Write the header via DMA
- for (int slot = 0; slot < 6; slot++)
- m_out_dma(0, m_register_r[id_field[slot]], 0xff);
-
- m_out_dip(CLEAR_LINE);
- m_out_dmarq(CLEAR_LINE);
-
- // Continue with reading the sector data
- m_live_state.state = SEARCH_DAM;
- break;
-
-// =================================================================
-
- case READ_TRACK_BYTE:
- // The pause is implemented by doing dummy reads on the floppy
- if (read_one_bit(limit))
- {
- if (TRACE_LIVE) logerror("%s: [%s live] return; limit=%s\n", tag(), tts(m_live_state.time).c_str(), tts(limit).c_str());
- return;
- }
-
- // Repeat until we have collected 16 bits
- if ((m_live_state.bit_counter & 15)==0)
- {
- if (TRACE_READ && TRACE_DETAIL) logerror("%s: [%s live] Read byte %02x, repeat = %d\n", tag(), tts(m_live_state.time).c_str(), m_live_state.data_reg, m_live_state.repeat);
- wait_for_realtime(READ_TRACK_NEXT_BYTE);
- return;
- }
- break;
-
- case READ_TRACK_NEXT_BYTE:
- m_live_state.state = READ_TRACK_BYTE;
- m_live_state.repeat--;
- if (m_live_state.repeat == 0)
- {
- // All bytes read
- m_live_state.state = m_live_state.return_state;
- checkpoint();
- }
- break;
-
- case WRITE_TRACK_BYTE:
- if (write_one_bit(limit))
- return;
-
- if (m_live_state.bit_counter == 0)
- {
- // All bits written; get the next byte into the shift register
- wait_for_realtime(WRITE_TRACK_NEXT_BYTE);
- return;
- }
- break;
-
- case WRITE_TRACK_NEXT_BYTE:
- m_live_state.state = WRITE_TRACK_BYTE;
- m_live_state.repeat--;
-
- // Write all bytes
- if (m_live_state.repeat == 0)
- {
- // All bytes written
- m_live_state.state = m_live_state.return_state;
- checkpoint();
- }
- else
- encode_again();
-
- break;
-
- case NO_DMA_ACK:
- if (TRACE_FAIL) logerror("%s: No DMA ACK - buffer underrun\n", tag());
- set_bits(m_register_r[INT_STATUS], TC_DATAERR, true);
- m_pll.stop_writing(m_floppy, m_live_state.time);
- m_live_state.state = IDLE;
- return;
-
- default:
- logerror("%s: Unknown live state: %02x\n", tag(), m_live_state.state);
- m_last_live_state = m_live_state.state;
- return;
- }
- }
- m_last_live_state = UNDEF;
-}
-
-/*
- The main method of the live state machine. We stay in this method until
- the requested data are read.
- limit: if unlimited (attotime::never), run up to the end of the track and wait there
- otherwise, used to replay the read/write operation up to the point where the event happened
-
- THIS IS THE HARDDISK-ONLY LIVE_RUN
-
- NB: Although unlikely, hard disks may be recorded in FM format with this controller
- [1], section "Drive select", table
- This is currently unsupported; hard disks are forced to MFM
-*/
-void hdc92x4_device::live_run_hd_until(attotime limit)
-{
- int slot = 0;
- if (TRACE_LIVE) logerror("%s: live_run_hd\n", tag());
-
- if (m_live_state.state == IDLE || m_live_state.next_state != -1)
- return;
-
- if (TRACE_LIVE)
- {
- if (limit == attotime::never)
- logerror("%s: [%s live] live_run_hd, live_state=%02x, mode=%s\n", tag(), tts(m_live_state.time).c_str(), m_live_state.state, fm_mode()? "FM":"MFM");
- else
- logerror("%s: [%s live] live_run_hd until %s, live_state=%02x, mode=%s\n", tag(), tts(m_live_state.time).c_str(), tts(limit).c_str(), m_live_state.state, fm_mode()? "FM":"MFM");
- }
-
- // We did not specify an upper time bound, so we take the next index pulse
- if (limit == attotime::never && m_harddisk != NULL)
- {
- limit = m_harddisk->track_end_time();
- if (TRACE_LIVE) logerror("%s: [%s live] live_run_hd new limit %s\n", tag(), tts(m_live_state.time).c_str(), tts(limit).c_str());
- }
-
- while (true)
- {
- switch (m_live_state.state)
- {
- case SEARCH_IDAM:
- if (TRACE_LIVE && m_last_live_state != SEARCH_IDAM)
- {
- logerror("%s: [%s live] SEARCH_IDAM [limit %s]\n", tag(),tts(m_live_state.time).c_str(), tts(limit).c_str());
- m_last_live_state = m_live_state.state;
- }
-
- // This bit will be set when the IDAM cannot be found
- set_bits(m_register_r[CHIP_STATUS], CS_SYNCERR, false);
-
- if (read_from_mfmhd(limit))
- {
- if (TRACE_LIVE) logerror("%s: [%s live] SEARCH_IDAM limit reached\n", tag(), tts(m_live_state.time).c_str());
- return;
- }
-
- if (TRACE_LIVE)
- if ((m_live_state.bit_counter & 0x000f)==0) logerror("%s: [%s live] Read %04x\n", tag(), tts(m_live_state.time).c_str(), m_live_state.shift_reg);
-
- // [1] p. 9: The ID field sync mark must be found within 33,792 byte times
- if (m_live_state.bit_count_total > 33792*16)
- {
- // Desired sector not found within time
- if (m_substate == VERIFY3)
- wait_for_realtime(VERIFY_FAILED);
- else
- wait_for_realtime(SEARCH_IDAM_FAILED);
- return;
- }
-
- if (found_mark(SEARCH_IDAM))
- {
- if (TRACE_LIVE) logerror("%s: [%s live] Found an A1 mark\n", tag(), tts(m_live_state.time).c_str());
- m_live_state.crc = 0x443b;
- m_live_state.data_separator_phase = false;
- m_live_state.bit_counter = 0;
-
- m_live_state.state = READ_IDENT;
- }
- break;
-
- case SEARCH_IDAM_FAILED:
- set_bits(m_register_r[CHIP_STATUS], CS_SYNCERR, true);
- m_live_state.state = IDLE;
- return;
-
- case VERIFY_FAILED:
- set_bits(m_register_r[CHIP_STATUS], CS_COMPERR, true);
- m_live_state.state = IDLE;
- return;
-
- case READ_IDENT:
- if (read_from_mfmhd(limit)) return;
-
- // Repeat until we have collected 16 bits (MFM_BITS; in the other modes this is always false)
- if (m_live_state.bit_counter & 15) break;
-
- // Ident bytes are 111111xx
- if ((m_live_state.data_reg & 0xfc) != 0xfc)
- {
- if (TRACE_LIVE)
- {
- if (m_live_state.data_reg == 0xf8 || m_live_state.data_reg == 0xfb)
- logerror("%s: [%s live] Looks like a DAM; continue to next mark\n", tag(), tts(m_live_state.time).c_str());
- else
- logerror("%s: [%s live] Missing ident data after A1, and it was not DAM; format corrupt?\n", tag(), tts(m_live_state.time).c_str());
- }
- m_live_state.state = SEARCH_IDAM;
- }
- else
- {
- m_register_r[CURRENT_IDENT] = m_live_state.data_reg;
- m_live_state.state = READ_ID_FIELDS_INTO_REGS;
- slot = 0;
- }
- break;
-
- case READ_ID_FIELDS_INTO_REGS:
- if (TRACE_LIVE && m_last_live_state != READ_ID_FIELDS_INTO_REGS)
- {
- logerror("%s: [%s live] READ_ID_FIELDS_INTO_REGS\n", tag(),tts(m_live_state.time).c_str());
- m_last_live_state = m_live_state.state;
- }
-
- if (read_from_mfmhd(limit)) return;
-
- // Repeat until we have collected 16 bits
- if (m_live_state.bit_counter & 15) break;
-
- if (TRACE_LIVE) logerror("%s: slot %d = %02x, crc=%04x\n", tag(), slot, m_live_state.data_reg, m_live_state.crc);
- m_register_r[id_field[slot++]] = m_live_state.data_reg;
-
- if(slot > 5)
- {
- // We successfully read the ID fields; let's wait for the machine time to catch up.
- if (reading_track())
- // Continue if we're reading a complete track
- wait_for_realtime(READ_TRACK_ID_DONE);
- else
- // Live run is done here; it is the main state machine's turn again.
- wait_for_realtime(IDLE);
- return;
- }
- break;
-
- case SEARCH_DAM:
- if (TRACE_LIVE && m_last_live_state != SEARCH_DAM)
- {
- logerror("%s: [%s live] SEARCH_DAM\n", tag(),tts(m_live_state.time).c_str());
- m_last_live_state = m_live_state.state;
- }
- set_bits(m_register_r[CHIP_STATUS], CS_DELDATA, false);
-
- if (read_from_mfmhd(limit)) return;
-
- if (TRACE_LIVE)
- if ((m_live_state.bit_counter & 15)==0) logerror("%s: [%s live] Read %04x\n", tag(), tts(m_live_state.time).c_str(), m_live_state.shift_reg);
-
- if (m_live_state.bit_counter > 30*16)
- {
- if (TRACE_FAIL) logerror("%s: SEARCH_DAM failed\n", tag());
- wait_for_realtime(SEARCH_DAM_FAILED);
- return;
- }
-
- if (found_mark(SEARCH_DAM))
- {
- if (TRACE_LIVE) logerror("%s: [%s live] Found an A1 mark\n", tag(),tts(m_live_state.time).c_str());
- m_live_state.crc = 0x443b;
- m_live_state.data_separator_phase = false;
- m_live_state.bit_counter = 0;
- m_live_state.state = READ_DATADEL_FLAG;
- }
- break;
-
- case READ_DATADEL_FLAG:
- if (read_from_mfmhd(limit)) return;
-
- if (m_live_state.bit_counter & 15) break;
-
- if ((m_live_state.data_reg & 0xff) == 0xf8)
- {
- if (TRACE_LIVE) logerror("%s: [%s live] Found deleted data mark F8 after DAM sync\n", tag(), tts(m_live_state.time).c_str());
- set_bits(m_register_r[CHIP_STATUS], CS_DELDATA, true);
- }
- else
- {
- if ((m_live_state.data_reg & 0xff) != 0xfb)
- {
- if (TRACE_FAIL) logerror("%s: [%s live] Missing FB/F8 data mark after DAM sync; found %04x\n", tag(), tts(m_live_state.time).c_str(), m_live_state.shift_reg);
- wait_for_realtime(SEARCH_DAM_FAILED);
- return;
- }
- }
- m_live_state.bit_counter = 0;
- m_live_state.state = READ_SECTOR_DATA;
- break;
-
- case SEARCH_DAM_FAILED:
- if (TRACE_FAIL) logerror("%s: SEARCH_DAM failed\n", tag());
- m_live_state.state = IDLE;
- return;
-
- case READ_SECTOR_DATA:
- if (TRACE_LIVE && m_last_live_state != READ_SECTOR_DATA)
- {
- logerror("%s: [%s live] READ_SECTOR_DATA\n", tag(),tts(m_live_state.time).c_str());
- m_last_live_state = m_live_state.state;
- }
-
- if (read_from_mfmhd(limit)) return;
-
- // Request bus release
- // For hard disk, get it only for the first byte and then keep the bus until the last byte.
- // HD: bit_counter increases by 16 for MFM_BYTE, SEPARATED(_SIMPLE) and by 1 for MFM_BIT
- // If we are reading a track, the DMA must have already been granted
- if (!reading_track() && m_transfer_enabled && (m_live_state.bit_counter == 1 || m_live_state.bit_counter == 16))
- {
- set_bits(m_register_r[INT_STATUS], ST_OVRUN, true);
- m_out_dmarq(ASSERT_LINE);
- }
-
- // Repeat until we have collected 16 bits
- if (m_live_state.bit_counter & 15) break;
-
- slot = (m_live_state.bit_counter >> 4)-1;
- if (TRACE_LIVE) logerror("%s: [%s live] Found data value [%d/%d] = %02X, CRC=%04x\n", tag(),tts(m_live_state.time).c_str(), slot, calc_sector_size(), m_live_state.data_reg, m_live_state.crc);
-
- if (slot < calc_sector_size())
- {
- // For the first byte, allow for the DMA acknowledge to be set.
- if (slot == 0)
- {
- wait_for_realtime(READ_SECTOR_DATA_CONT);
- return;
- }
- else m_live_state.state = READ_SECTOR_DATA_CONT;
- }
- else if (slot < calc_sector_size()+2)
- {
- // CRC
- if (slot == calc_sector_size()+1)
- {
- m_out_dip(CLEAR_LINE);
- m_out_dmarq(CLEAR_LINE);
- checkpoint();
-
- if (reading_track())
- {
- // Reading a track? Continue with next ID.
- wait_for_realtime(READ_TRACK_ID);
- }
- else
- {
- if (TRACE_LIVE) logerror("%s: [%s live] Sector read completed\n", tag(),tts(m_live_state.time).c_str());
- wait_for_realtime(IDLE);
- }
- return;
- }
- }
- break;
-
- case READ_SECTOR_DATA_CONT:
-
- // Did the system CPU send the DMA ACK in the meantime?
- if ((m_register_r[INT_STATUS] & ST_OVRUN)!=0)
- {
- if (TRACE_FAIL) logerror("%s: No DMA ACK - buffer overrun\n", tag());
- set_bits(m_register_r[INT_STATUS], TC_DATAERR, true);
- m_live_state.state = IDLE;
- return;
- }
-
- if (m_transfer_enabled)
- {
- m_register_r[DATA] = m_register_w[DATA] = m_live_state.data_reg;
- // See above: For hard disk do it only for the first byte / bit
- if (m_live_state.bit_counter == 1 || m_live_state.bit_counter == 16)
- m_out_dip(ASSERT_LINE);
-
- m_out_dma(0, m_register_r[DATA], 0xff);
- if (TRACE_LIVE) logerror("%s: [%s live] Byte %02x sent via DMA\n", tag(),tts(m_live_state.time).c_str(), m_register_r[DATA] & 0xff);
- }
- m_live_state.state = READ_SECTOR_DATA;
- break;
-
- // ==== Track R/W operations (HD), also used for sector writing ===============
-
- case READ_TRACK_BYTE:
- // The pause is implemented by doing dummy reads on the hard disk
- if (read_from_mfmhd(limit))
- {
- if (TRACE_LIVE) logerror("%s: [%s live] return; limit=%s\n", tag(), tts(m_live_state.time).c_str(), tts(limit).c_str());
- return;
- }
-
- // Repeat until we have collected 16 bits
- if ((m_live_state.bit_counter & 15)==0)
- {
- if (TRACE_READ && TRACE_DETAIL) logerror("%s: [%s live] Read byte %02x, repeat = %d\n", tag(), tts(m_live_state.time).c_str(), m_live_state.data_reg, m_live_state.repeat);
- wait_for_realtime(READ_TRACK_NEXT_BYTE);
- return;
- }
- break;
-
- case READ_TRACK_NEXT_BYTE:
- m_live_state.state = READ_TRACK_BYTE;
- m_live_state.repeat--;
- if (m_live_state.repeat == 0)
- {
- // All bytes read
- m_live_state.state = m_live_state.return_state;
- checkpoint();
- }
- break;
-
- case WRITE_TRACK_BYTE:
- if (write_to_mfmhd(limit))
- {
- if (TRACE_LIVE) logerror("%s: [%s live] write limit reached\n", tag(), tts(m_live_state.time).c_str());
- return;
- }
-
- if (m_live_state.bit_counter == 0)
- {
- // All bits written; get the next byte into the shift register
- wait_for_realtime(WRITE_TRACK_NEXT_BYTE);
- return;
- }
- break;
-
- case WRITE_TRACK_NEXT_BYTE:
- m_live_state.state = WRITE_TRACK_BYTE;
- m_live_state.repeat--;
-
- // Write all bytes
- if (m_live_state.repeat == 0)
- {
- // All bytes written
- m_live_state.state = m_live_state.return_state;
- checkpoint();
- }
- else
- encode_again();
-
- break;
-
- // ======= HD sector write =====================================
-
- case WRITE_DAM_AND_SECTOR:
- if (TRACE_LIVE) logerror("%s: [%s live] Skipping GAP2\n", tag(), tts(m_live_state.time).c_str());
- skip_on_track(m_gap2_size, WRITE_DAM_SYNC);
-
- break;
-
- case WRITE_DAM_SYNC:
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Write sync zeros\n", tag());
-
- // Clear the overrun/underrun flag
- set_bits(m_register_r[INT_STATUS], ST_OVRUN, false);
- write_on_track(encode_hd(0x00), m_sync_size, WRITE_A1);
- break;
-
- case WRITE_A1:
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Write one A1\n", tag());
- write_on_track(encode_a1_hd(), 1, WRITE_DATAMARK);
- break;
-
- case WRITE_DATAMARK:
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Write data mark\n", tag());
-
- // Init the CRC for the ident byte and sector
- m_live_state.crc = 0x443b; // value for 1*A1
-
- write_on_track(encode_hd(m_deleted? 0xf8 : 0xfb), 1, WRITE_SECDATA);
-
- m_live_state.byte_counter = calc_sector_size();
-
- // Set the over/underrun flag and hope that it will be cleared before we start writing
- // (only for sector writing)
- if (m_substate == DATA_TRANSFER_WRITE)
- {
- set_bits(m_register_r[INT_STATUS], ST_OVRUN, true);
- m_out_dmarq(ASSERT_LINE);
- }
- break;
-
- case WRITE_SECDATA:
- if (m_substate == DATA_TRANSFER_WRITE)
- {
- // Check whether DMA has been acknowledged
- if ((m_register_r[INT_STATUS] & ST_OVRUN)!=0)
- {
- // No, then stop here
- m_live_state.state= NO_DMA_ACK;
- }
- else
- {
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Write sector byte, %d to go\n", tag(), m_live_state.byte_counter);
-
- // For floppies, set this for each byte; for hard disk, set it only at the beginning
- if (m_live_state.byte_counter == calc_sector_size())
- m_out_dip(ASSERT_LINE);
-
- m_register_r[DATA] = m_register_w[DATA] = m_in_dma(0, 0xff);
-
- if (m_live_state.byte_counter == 0)
- {
- m_out_dip(CLEAR_LINE);
- m_out_dmarq(CLEAR_LINE);
- }
-
- if (m_live_state.byte_counter > 0)
- {
- m_live_state.byte_counter--;
- write_on_track(encode_hd(m_register_r[DATA]), 1, WRITE_SECDATA);
- }
- else
- {
- m_live_state.state = WRITE_DATA_CRC;
- // TODO: Prepare for ECC; this is "only" CRC
- m_live_state.byte_counter = 2;
- }
- }
- }
- else
- {
- // We are here in the context of track formatting. Write a
- // blank sector
- write_on_track(encode_hd(0xe5), m_sector_size, WRITE_DATA_CRC);
- m_live_state.byte_counter = 2;
- }
- break;
-
- case WRITE_DATA_CRC:
- if (m_live_state.byte_counter > 0)
- {
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Write CRC\n", tag());
- m_live_state.byte_counter--;
- write_on_track(encode_hd((m_live_state.crc >> 8) & 0xff), 1, WRITE_DATA_CRC);
- }
- else
- // Write a filler byte so that the last CRC bit is saved correctly
- write_on_track(encode_hd(0xff), 1, WRITE_DONE);
-
- break;
-
- case WRITE_DONE:
- if (m_substate == DATA_TRANSFER_WRITE)
- {
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: Write sector complete\n", tag());
- m_live_state.state = IDLE;
- return;
- }
- else
- {
- // Continue for track writing: Write GAP3
- m_live_state.state = WRITE_GAP3;
- }
- break;
-
- // ==================================================
- // Track reading (HD)
- // ==================================================
- //
- // Read the next ID fields, then the sector contents.
- // Continue until the next index hole shows up (live_abort).
- case READ_TRACK:
- if (TRACE_LIVE) logerror("%s: READ_TRACK\n", tag());
- m_live_state.state = READ_TRACK_ID;
- break;
-
- case READ_TRACK_ID:
- m_live_state.state = SEARCH_IDAM;
- // Ask for access to bus
- set_bits(m_register_r[INT_STATUS], ST_OVRUN, true);
- m_out_dmarq(ASSERT_LINE);
- break;
-
- case READ_TRACK_ID_DONE:
- if ((m_register_r[INT_STATUS] & ST_OVRUN)!=0)
- {
- // We need an ACK right now, or the header bytes will be lost
- if (TRACE_FAIL) logerror("%s: No DMA ACK - buffer overrun\n", tag());
- set_bits(m_register_r[INT_STATUS], TC_DATAERR, true);
- m_live_state.state = IDLE;
- return;
- }
- if (TRACE_LIVE) logerror("%s: READ_TRACK_ID_DONE\n", tag());
- m_out_dip(ASSERT_LINE);
-
- // Write the header via DMA
- for (int slot = 0; slot < 6; slot++)
- m_out_dma(0, m_register_r[id_field[slot]], 0xff);
-
- // Continue with reading the sector data
- m_live_state.state = SEARCH_DAM;
- wait_line(INDEX_LINE, ASSERT_LINE, TRACKDONE, true);
- break;
-
-
- // =========== HD formatting =============
- // Live states for track formatting
- // Write GAP 1
- // Per sector
- // Write Sync+IDAM
- // Write Sector header+CRC
- // Write GAP2
- // Write Sync+DAM
- // Write Sector data
- // Write CRC bytes
- // Write GAP3
- // Write GAP4 until the next pulse
- // ==================================================
- case FORMAT_TRACK:
- if (TRACE_LIVE) logerror("%s: FORMAT_TRACK\n", tag());
- m_live_state.state = WRITE_GAP1;
- break;
-
- case WRITE_GAP1:
- // GAP1 length is in DMA15_8
- if (TRACE_GAPS) logerror("%s: Writing GAP1; size=%d\n", tag(), m_gap1_size);
- write_on_track(encode_hd(0x4e), m_gap1_size, WRITE_IDAM_SYNC);
- break;
-
- case WRITE_IDAM_SYNC:
- if (TRACE_GAPS) logerror("%s: Writing IDAM sync, size=%d\n", tag(), m_sync_size);
- write_on_track(encode_hd(0x00), m_sync_size, WRITE_IDAM);
- break;
-
- case WRITE_IDAM:
- // Set the over/underrun flag and hope that it will be cleared before we enter the next state (after writing)
- set_bits(m_register_r[INT_STATUS], ST_OVRUN, true);
- m_out_dmarq(ASSERT_LINE);
- if (TRACE_HEADER) logerror("%s: Writing IDAM and header: ", tag());
- write_on_track(encode_a1_hd(), 1, WRITE_HEADER);
- m_live_state.byte_counter = 5; // TODO: Check this for AT mode
- m_live_state.crc = 0xffff;
- break;
-
- case WRITE_HEADER:
- if ((m_register_r[INT_STATUS] & ST_OVRUN)!=0)
- // No DMA (we do not get access to the ID table); exit
- m_live_state.state= NO_DMA_ACK;
- else
- {
- m_out_dip(ASSERT_LINE);
- m_live_state.byte_counter--;
- UINT8 headbyte = m_in_dma(0, 0xff);
- if (TRACE_HEADER) logerror("%02x ", headbyte);
- write_on_track(encode_hd(headbyte), 1, (m_live_state.byte_counter>0)? WRITE_HEADER : WRITE_HEADER_CRC);
-
- if (m_live_state.byte_counter==0)
- {
- m_out_dip(CLEAR_LINE);
- m_out_dmarq(CLEAR_LINE);
- // we will go to WRITE_HEADER_CRC state; set the byte counter for CRC
- m_live_state.byte_counter = 2;
- }
- }
- break;
-
- case WRITE_HEADER_CRC:
- if (m_live_state.byte_counter > 0)
- {
- UINT8 crct = (m_live_state.crc >> 8) & 0xff;
- if (TRACE_HEADER) logerror("%02x ", crct);
- m_live_state.byte_counter--;
- write_on_track(encode_hd(crct), 1, WRITE_HEADER_CRC);
- }
- else
- {
- if (TRACE_HEADER) logerror("\n");
- m_live_state.state = WRITE_GAP2;
- }
- break;
-
- case WRITE_GAP2:
- if (TRACE_GAPS) logerror("%s: Writing GAP2, size=%d\n", tag(), m_gap2_size);
- write_on_track(encode_hd(0x4e), m_gap2_size, WRITE_DAM_SYNC);
- break;
-
- case WRITE_GAP3:
- m_sector_count--;
- if (TRACE_GAPS) logerror("%s: Writing GAP3, size=%d\n", tag(), m_gap3_size);
- write_on_track(encode_hd(0x4e), m_gap3_size, (m_sector_count>0)? WRITE_IDAM_SYNC : WRITE_GAP4);
- break;
-
- case WRITE_GAP4:
- // Write bytes up to the end of the track
- wait_line(INDEX_LINE, ASSERT_LINE, TRACKDONE, true);
- if (TRACE_GAPS && m_last_live_state != WRITE_GAP4)
- {
- logerror("%s: Writing GAP4\n", tag());
- m_last_live_state = WRITE_GAP4;
- }
- // Write a single byte; when the index hole shows up, the live run will be aborted
- write_on_track(encode_hd(0x4e), 1, WRITE_GAP4);
- break;
-// --------------------------------------------------------
-
- default:
- if (TRACE_LIVE) logerror("%s: Unknown state: %02x\n", tag(), m_live_state.state);
- break;
- }
- }
- m_last_live_state = UNDEF;
-}
-
-/*
- Synchronize the live position on the track with the real time.
- Results in a new checkpoint and a live position at machine time or behind.
- As a side effect, portions of the track may be re-read
-*/
-void hdc92x4_device::live_sync()
-{
- // Do we have some time set?
- if (!m_live_state.time.is_never())
- {
- // Are we ahead of the machine time?
- if(m_live_state.time > machine().time())
- {
- // If so, we must roll back to the last checkpoint
- if (TRACE_SYNC) logerror("%s: [%s] Rolling back and replaying [%s live]\n", tag(), ttsn().c_str(), tts(m_live_state.time).c_str());
- rollback();
-
- // and replay until we reach the machine time
- if (using_floppy())
- {
- live_run_until(machine().time());
- // Caught up, commit bits from pll buffer to disk until live time (if there is something to write)
- m_pll.commit(m_floppy, m_live_state.time);
- }
- else
- {
- // HD case
- live_run_hd_until(machine().time());
- }
- }
- else
- {
- // We are behind machine time, so we will never get back to that
- // time, thus we can commit that position
- if (TRACE_SYNC) logerror("%s: [%s] Committing [%s live]\n", tag(), ttsn().c_str(), tts(m_live_state.time).c_str());
-
- // Commit bits from pll buffer to disk until live time (if there is something to write)
- if (using_floppy())
- m_pll.commit(m_floppy, m_live_state.time);
-
- if (m_live_state.next_state != -1)
- m_live_state.state = m_live_state.next_state;
-
- if (m_live_state.state == IDLE)
- {
- // Commit until live time and stop
- if (using_floppy())
- m_pll.stop_writing(m_floppy, m_live_state.time);
- m_live_state.time = attotime::never;
- }
- }
-
- m_live_state.next_state = -1;
- checkpoint();
- }
-}
-
-void hdc92x4_device::live_abort()
-{
- if (!m_live_state.time.is_never() && m_live_state.time > machine().time())
- {
- if (TRACE_LIVE) logerror("%s: [%s] Abort; rolling back and replaying [%s live]\n", tag(), ttsn().c_str(), tts(m_live_state.time).c_str());
- rollback();
- live_run_until(machine().time());
- }
-
- if (using_floppy()) m_pll.stop_writing(m_floppy, m_live_state.time);
-
- m_live_state.time = attotime::never;
- m_live_state.state = IDLE;
- m_live_state.next_state = -1;
-}
-
-/*
- Brings the live state machine into the WRITE substate part
- comprised by WRITE_TRACK_(NEXT_)BYTE
- Arguments: byte to be written, number, state on return
-*/
-void hdc92x4_device::write_on_track(UINT16 encoded, int repeat, int next_state)
-{
- m_live_state.repeat = repeat;
- m_live_state.state = WRITE_TRACK_BYTE;
- m_live_state.return_state = next_state;
- encode_raw(encoded);
-}
-
-/*
- Brings the live state machine into the READ substate part. This is
- only intended for skipping bytes.
- Arguments: number, state on return
-*/
-void hdc92x4_device::skip_on_track(int repeat, int next_state)
-{
- m_live_state.bit_counter = 0;
- m_live_state.repeat = repeat;
- m_live_state.state = READ_TRACK_BYTE;
- m_live_state.return_state = next_state;
-}
-
-UINT8 hdc92x4_device::get_data_from_encoding(UINT16 raw)
-{
- unsigned int value = 0;
-
- if (!using_floppy() && (m_hd_encoding == SEPARATED || m_hd_encoding == SEPARATED_SIMPLE)) return raw & 0xff;
-
- for (int i=0; i < 8; i++)
- {
- value <<= 1;
- value |= (raw & 0x4000);
- raw <<= 2;
- }
- return (value >> 14) & 0xff;
-}
-
-void hdc92x4_device::rollback()
-{
- m_live_state = m_checkpoint_state;
- m_pll = m_checkpoint_pll;
-}
-
-/*
- Wait for real time to catch up. This way we pretend that the last
- operation actually needed the real time.
-*/
-void hdc92x4_device::wait_for_realtime(int state)
-{
- m_live_state.next_state = state;
- m_timer->adjust(m_live_state.time - machine().time());
- if (TRACE_LIVE) logerror("%s: [%s live] Waiting for real time [%s] to catch up; next state = %02x\n", tag(), tts(m_live_state.time).c_str(), ttsn().c_str(), state);
-}
-
-/*
- Read the next bit from the disk.
- Return true: the time limit has been reached
- Return false: The next bit is read into the shift register as the
- rightmost bit; the shift register is a member of m_live_state. Also,
- the CRC is updated.
-*/
-bool hdc92x4_device::read_one_bit(const attotime &limit)
-{
- // Get the next bit from the phase-locked loop.
- int bit = m_pll.get_next_bit(m_live_state.time, m_floppy, limit);
-
- // We have reached the time limit
- if (bit < 0) return true;
-
- // For test purposes: Drop a bit at some occasions
- // value > 1000: rare occasions
- // value = 500: can cope with
- // value < 100: big trouble for controller, will fail
- if (UNRELIABLE_MEDIA)
- {
- if ((machine().time().attoseconds() % 1009)==0) bit = 0;
- }
-
- // Push into shift register
- m_live_state.shift_reg = (m_live_state.shift_reg << 1) | bit;
- m_live_state.bit_counter++;
-
- // Used for timeout handling
- m_live_state.bit_count_total++;
-
- // Clock bit (false) or data bit (true)?
- if (m_live_state.data_separator_phase==true)
- {
- m_live_state.data_reg = (m_live_state.data_reg << 1) | bit;
- // Update CRC
- if ((m_live_state.crc ^ (bit ? 0x8000 : 0x0000)) & 0x8000)
- m_live_state.crc = (m_live_state.crc << 1) ^ 0x1021;
- else
- m_live_state.crc = m_live_state.crc << 1;
- }
-
- m_live_state.data_separator_phase = !m_live_state.data_separator_phase;
- return false;
-}
-
-bool hdc92x4_device::write_one_bit(const attotime &limit)
-{
- bool bit = (m_live_state.shift_reg & 0x8000)!=0;
-
- bool over_limit = m_pll.write_next_bit(bit, m_live_state.time, m_floppy, limit);
- if (over_limit) return true;
-
- // Calculate the CRC from the data bits on the odd positions
- if (m_live_state.bit_counter & 1)
- {
- if ((m_live_state.crc ^ (bit ? 0x8000 : 0x0000)) & 0x8000)
- m_live_state.crc = (m_live_state.crc << 1) ^ 0x1021;
- else
- m_live_state.crc = m_live_state.crc << 1;
- }
- m_live_state.shift_reg = m_live_state.shift_reg << 1;
- m_live_state.bit_counter--;
- return false;
-}
-
-UINT16 hdc92x4_device::encode(UINT8 byte)
-{
- UINT16 raw;
- UINT8 check_pos;
- bool last_bit_set;
- check_pos = 0x80;
-
- m_live_state.data_reg = byte;
- raw = 0;
-
- if (fm_mode())
- {
- raw = 0;
- // FM: data bit = 1 -> encode as 11
- // data bit = 0 -> encode as 10
- for (int i=0; i<8; i++)
- {
- raw = (raw << 2) | (((byte & check_pos)!=0)? 0x03 : 0x02);
- check_pos >>= 1;
- }
- last_bit_set = ((byte & 1)!=0);
- }
- else
- {
- last_bit_set = m_live_state.last_data_bit;
-
- for (int i=0; i<8; i++)
- {
- bool bit_set = ((byte & check_pos)!=0);
-
- // MFM: data bit = 1 -> encode as 01
- // data bit = 0 -> encode as x0 (x = !last_bit)
-
- raw <<= 2;
- if (bit_set) raw |= 1;
- else
- {
- if (!last_bit_set) raw |= 2;
- }
- last_bit_set = bit_set;
- check_pos >>= 1;
- }
- }
- return raw;
-}
-
-void hdc92x4_device::encode_again()
-{
- encode_raw(m_live_state.shift_reg_save);
-}
-
-void hdc92x4_device::encode_raw(UINT16 raw)
-{
- m_live_state.bit_counter = 16;
- m_live_state.shift_reg = m_live_state.shift_reg_save = raw;
- m_live_state.last_data_bit = raw & 1;
- if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: [%s live] Write %02x (%04x)\n", tag(), tts(m_live_state.time).c_str(), get_data_from_encoding(raw), raw);
- checkpoint();
-}
-
-/*
- Reset the PLL. For reading, data must pass through a dedicated data
- separator. The clock rate is delivered from
- m_clock_divider with values 1-3, where 1 is FM (4000), 2 is MFM (2000),
- and 3 is MFM (1000).
- When writing, the controller generates the proper output bitstream, so we
- have to set it from its own state (fm/mfm and device type).
-*/
-void hdc92x4_device::pll_reset(const attotime &when, bool output)
-{
- m_pll.reset(when);
-
- if (output)
- {
- if (fm_mode())
- m_pll.set_clock(attotime::from_nsec(4000));
- else
- m_pll.set_clock(attotime::from_nsec((m_selected_drive_type==TYPE_FLOPPY5)? 2000 : 1000));
- }
- else
- m_pll.set_clock(attotime::from_nsec(8000 >> (~m_clock_divider & 0x03)));
-}
-
-void hdc92x4_device::checkpoint()
-{
- // Commit bits from pll buffer to disk until live time (if there is something to write)
- // For HD we do not use a PLL in this implementation
- if (using_floppy())
- {
- m_pll.commit(m_floppy, m_live_state.time);
- m_checkpoint_pll = m_pll;
- }
- m_checkpoint_state = m_live_state;
-}
-
-// ===========================================================================
-
-// HD support
-/*
- Read the bit or complete byte from the hard disk at the point of time
- specified by the time in the live_state.
- Return true: the time limit has been reached
- Return false: valid return
-
- Updates the CRC and the shift register. Also, the time is updated.
-*/
-bool hdc92x4_device::read_from_mfmhd(const attotime &limit)
-{
- UINT16 data = 0;
- bool offlimit = m_harddisk->read(m_live_state.time, limit, data);
-
- // We have reached the time limit
- if (offlimit) return true;
-
- if (m_hd_encoding == MFM_BITS)
- {
- // Push bit into shift register
- m_live_state.shift_reg = (m_live_state.shift_reg << 1) | data;
- m_live_state.bit_counter++;
- // Used for timeout handling
- m_live_state.bit_count_total++;
-
- // Clock bit (false) or data bit (true)?
- if (m_live_state.data_separator_phase==true)
- {
- m_live_state.data_reg = (m_live_state.data_reg << 1) | data;
- // Update CRC
- if ((m_live_state.crc ^ (data ? 0x8000 : 0x0000)) & 0x8000)
- m_live_state.crc = (m_live_state.crc << 1) ^ 0x1021;
- else
- m_live_state.crc = m_live_state.crc << 1;
- }
-
- m_live_state.data_separator_phase = !m_live_state.data_separator_phase;
- }
- else
- {
- UINT16 separated = data;
- m_live_state.shift_reg = data;
-
- if (m_hd_encoding == MFM_BYTE)
- {
- for (int i=0; i < 8; i++)
- {
- separated <<= 1;
- if (data & 0x8000) separated |= 0x0100;
- data <<= 1;
- if (data & 0x8000) separated |= 0x0001;
- data <<= 1;
- }
- }
-
- // Push byte into data / clock register
- m_live_state.clock_reg = (separated >> 8) & 0xff;
- m_live_state.data_reg = separated & 0xff;
- m_live_state.bit_counter += 16;
- // Used for timeout handling
- m_live_state.bit_count_total += 16;
-
- // Update CRC
- m_live_state.crc = ccitt_crc16_one(m_live_state.crc, m_live_state.data_reg);
- m_live_state.data_separator_phase = false;
- }
-
- return false;
-}
-
-/*
- Write one bit or complete byte from the shift register to the hard disk
- at the point of time specified by the time in the live_state.
- Return true: the time limit has been reached
- Return false: valid return
- Updates the CRC and the shift register. Also, the time is updated.
-*/
-bool hdc92x4_device::write_to_mfmhd(const attotime &limit)
-{
- UINT16 data = 0;
- int count;
- bool offlimit;
-
- if (m_hd_encoding == MFM_BITS)
- {
- data = ((m_live_state.shift_reg & 0x8000)==0)? 0:1;
- count = 1;
- }
- else
- {
- // We'll write the complete shift register in one go
- data = m_live_state.shift_reg;
- count = 16;
- }
- offlimit = m_harddisk->write(m_live_state.time, limit, data, m_precompensation != 0, m_reduced_write_current);
- if (offlimit) return true;
-
- m_live_state.bit_counter -= count;
-
- // Calculate the CRC
- if ((m_live_state.bit_counter & 1)==0)
- {
- if (m_hd_encoding == MFM_BITS)
- {
- if ((m_live_state.crc ^ ((data==0)? 0x8000 : 0x0000)) & 0x8000)
- m_live_state.crc = (m_live_state.crc << 1) ^ 0x1021;
- else
- m_live_state.crc = m_live_state.crc << 1;
- }
- else
- {
- // Take the data byte from the stored copy in the data_reg
- m_live_state.crc = ccitt_crc16_one(m_live_state.crc, m_live_state.data_reg);
- }
- }
-
- m_live_state.shift_reg = (m_live_state.shift_reg << count) & 0xffff;
- return false;
-}
-
-UINT16 hdc92x4_device::encode_hd(UINT8 byte)
-{
- UINT16 cells;
- UINT8 check_pos;
- bool last_bit_set;
- check_pos = 0x80;
-
- last_bit_set = m_live_state.last_data_bit;
- cells = 0;
-
- int databit = (m_hd_encoding==SEPARATED)? 0x0080 : 0x4000;
- int shift = (m_hd_encoding==SEPARATED)? 1 : 2;
- int clockbit = 0x8000;
-
- if (m_hd_encoding != SEPARATED_SIMPLE)
- {
- for (int i=0; i<8; i++)
- {
- bool bit_set = ((byte & check_pos)!=0);
-
- // MFM: data bit = 1 -> encode as 01
- // data bit = 0 -> encode as x0 (x = !last_bit)
-
- if (bit_set)
- cells |= databit;
- else
- cells |= (last_bit_set? 0x0000 : clockbit);
-
- databit >>= shift;
- clockbit >>= shift;
-
- last_bit_set = bit_set;
- check_pos >>= 1;
- }
- }
- else
- {
- cells = byte & 0x00ff;
- }
-
- m_live_state.data_reg = byte;
- return cells;
-}
-
-UINT16 hdc92x4_device::encode_a1_hd()
-{
- UINT16 cells = 0;
-
- switch (m_hd_encoding)
- {
- case MFM_BITS:
- case MFM_BYTE:
- cells = 0x4489;
- break;
- case SEPARATED:
- cells = 0x0aa1;
- break;
- case SEPARATED_SIMPLE:
- cells = 0xffa1;
- break;
- }
-
- m_live_state.last_data_bit = true;
- m_live_state.data_reg = 0xa1;
- m_live_state.bit_counter = 16;
- return cells;
-}
-
-
-// ===========================================================================
-
-/*
- Read a byte of data from the controller
- The address (offset) encodes the C/D* line (command and /data)
-*/
-READ8_MEMBER( hdc92x4_device::read )
-{
- UINT8 reply = 0;
- if ((offset & 1) == 0)
- {
- // Data register
- reply = m_register_r[m_register_pointer];
- if (TRACE_READREG) logerror("%s: Read register[%d] -> %02x\n", tag(), m_register_pointer, reply);
-
- // Autoincrement until DATA is reached.
- if (m_register_pointer < DATA) m_register_pointer++;
- }
- else
- {
- // Status register
- reply = m_register_r[INT_STATUS];
-
- // "The interrupt pin is reset to its inactive state
- // when the UDC interrupt status register is read." [1] (p.3)
- if (TRACE_READREG) logerror("%s: Read interrupt status register -> %02x\n", tag(), reply);
- set_interrupt(CLEAR_LINE);
-
- // Clear the bits due to interrupt status register read.
- m_register_r[INT_STATUS] &= ~(ST_INTPEND | ST_RDYCHNG);
- }
- return reply;
-}
-
-/*
- Write a byte to the controller
- The address (offset) encodes the C/D* line (command and /data), so there
- are only two addresses: 0 (register) and 1 (command).
- The operation terminates immediately, and the controller picks up the
- values stored in this phase at a later time.
-*/
-WRITE8_MEMBER( hdc92x4_device::write )
-{
- if ((offset & 1) == 0)
- {
- if (TRACE_COMMAND) logerror("%s: New register write access %02x\n", tag(), data & 0xff);
- if (m_executing) logerror("%s: Error - previous command %02x not completed; register access ignored\n", tag(), current_command());
- else
- {
- m_regvalue = data & 0xff;
- wait_time(m_cmd_timer, attotime::from_nsec(REGISTER_COMMIT), REGISTER_ACCESS);
- }
- }
- else
- {
- if (TRACE_COMMAND) logerror("%s: New incoming command %02x\n", tag(), data);
- if (m_executing) logerror("%s: Error - previous command %02x not completed; new command %02x ignored\n", tag(), current_command(), data);
- else
- {
- m_register_w[COMMAND] = data;
- wait_time(m_cmd_timer, attotime::from_nsec(COMMAND_COMMIT), COMMAND_INIT);
- }
- }
-}
-
-/*
- When the commit period has passed, process the command or register access
-*/
-void hdc92x4_device::process_command()
-{
- if (m_substate == REGISTER_ACCESS)
- {
- // Writing data to registers
- // Data register
- if (TRACE_SETREG)
- {
- if (m_register_pointer == INT_COMM_TERM)
- logerror("%s: Setting interrupt trigger DONE=%d READY=%d\n", tag(), (m_regvalue & TC_INTDONE)? 1:0, (m_regvalue & TC_INTRDCH)? 1:0);
- else
- logerror("%s: register[%d] <- %02x\n", tag(), m_register_pointer, m_regvalue);
- }
- m_register_w[m_register_pointer] = m_regvalue;
-
- // The DMA registers and the sector register for read and
- // write are identical, so in that case we copy the contents
- if (m_register_pointer < DESIRED_HEAD) m_register_r[m_register_pointer] = m_regvalue;
-
- // Autoincrement until DATA is reached.
- if (m_register_pointer < DATA) m_register_pointer++;
- }
- else
- {
- // Reset DONE and BAD_SECTOR [1], p.7
- set_bits(m_register_r[INT_STATUS], ST_DONE | ST_BADSECT, false);
-
- // Reset interrupt line (not explicitly mentioned in spec, but seems reasonable
- set_interrupt(CLEAR_LINE);
-
- // Clear Interrupt Pending and Ready Change
- set_bits(m_register_r[INT_STATUS], ST_INTPEND | ST_RDYCHNG, false);
-
- int index = 0;
- bool found = false;
-
- while (s_command[index].mask!=0 && !found)
- {
- if ((m_register_w[COMMAND] & s_command[index].mask) == s_command[index].baseval)
- {
- found = true;
-
- m_stop_after_index = false;
- m_wait_for_index = false;
- m_substate = UNDEF;
- m_executing = true;
- m_command = s_command[index].command;
- // Invoke command
- (this->*m_command)();
- }
- else index++;
- }
- if (!found)
- {
- logerror("%s: Command %02x not defined\n", tag(), m_register_w[COMMAND]);
- }
- }
- auxbus_out();
-}
-
-void hdc92x4_device::reenter_command_processing()
-{
- if (TRACE_DELAY) logerror("%s: Re-enter command processing; live state = %02x\n", tag(), m_live_state.state);
- // Do we have a live run on the track?
- if (m_live_state.state != IDLE)
- {
- // Continue with it
- live_run();
- if (m_live_state.state != IDLE) return;
- }
-
- // We're here when there is no live_run anymore
- // Where were we last time?
- // Take care not to restart commands because of the index callback
- if (TRACE_DELAY) logerror("%s: Continue with substate %02x\n", tag(), m_substate);
- if (m_executing && m_substate != UNDEF) (this->*m_command)();
- auxbus_out();
-}
-
-/*
- Assert Command Done status bit, triggering interrupts as needed
-*/
-void hdc92x4_device::set_command_done(int flags)
-{
- // Do another output, then set the flag
- auxbus_out();
-
- set_bits(m_register_r[INT_STATUS], ST_DONE, true);
-
- if (flags != -1)
- {
- set_bits(m_register_r[INT_STATUS], ST_TERMCOD, false); // clear the previously set flags
- m_register_r[INT_STATUS] |= flags;
- if (TRACE_DONE) logerror("%s: command %02x done, flags=%02x\n", tag(), current_command(), flags);
- }
- else
- {
- if (TRACE_DONE) logerror("%s: command %02x done\n", tag(), current_command());
- }
-
- // [1], p. 6
- if (TRACE_INT) logerror("%s: Raise interrupt DONE\n", tag());
- set_interrupt(ASSERT_LINE);
-
- m_substate = UNDEF;
- m_executing = false;
-}
-
-/*
- Preserve previously set termination code
-*/
-void hdc92x4_device::set_command_done()
-{
- set_command_done(-1);
-}
-
-/*
- Auxiliary bus operation.
-
- The auxbus of the HDC92x4 is used to poll the drive status of the cur-
- rently selected drive, to transmit DMA address bytes, to output the
- OUTPUT1 register, and to output the OUTPUT2 register.
-
- The specification is not really precise on the times when this bus is
- used, but at least we can rely on this information:
-
- - Whenever there is no output of data, the bus is sampled. ([1], p.8,
- Drive status register). Data is sampled at the rising edge of STB*.
- As the minimum STB* pulse is 800ns with min 100ns S0/S1 settling time
- and min 100ns hold time we can say that the bus is polled at a maximum
- rate of 1 MHz.
-
- - Data for the DMA address is output only when the address is initially
- set; also when the address must be set again on error ([1], p.5,
- DMA registers). The external memory system has to take care of the
- addressing for subsequent bytes. The address will be increased by the
- length of a sector during multiple sector read/write operations.
-
- We may assume that the OUTPUT1 and OUTPUT2 operations only occur on
- changes to the registers in the controller. The values showing up on the
- auxiliary bus must be latched anyway.
-
- For the sampling of drive status values, the emulation would have to
- invoke a callback to the hosting board at a rate of about 1 MHz. Since
- the devices like floppy or hard disks are pushing their status changes,
- it makes much more sense to allow for an incoming call to the controller
- instead of a polling. This also allows to raise interrupts as soon
- as the drive status changes. The difference to the real controller
- would be less than 3 microseconds (in the worst case when the auxbus is
- currently outputting data as the drive status change occurs).
-
- Drive status read
- S0 = 0, S1 = 0
- +------+------+------+------+------+------+------+------+
- | ECC |Index | SeekC| Tr00 | User | WrPrt| Ready|Fault |
- +------+------+------+------+------+------+------+------+
-*/
-
-/*
- Read the drive status over the auxbus
- (as said, let the controller board push the values into the controller)
-*/
-void hdc92x4_device::auxbus_in(UINT8 data)
-{
- // Kill unwanted input via auxbus until we are initialized.
- if (!m_initialized)
- return;
-
- if (TRACE_AUXBUS) logerror("%s: Got value %02x via auxbus: ecc=%d index=%d seek_comp=%d tr00=%d user=%d writeprot=%d ready=%d fault=%d\n",
- tag(), data,
- (data&HDC_DS_ECCERR)? 1:0, (data&HDC_DS_INDEX)? 1:0,
- (data&HDC_DS_SKCOM)? 1:0, (data&HDC_DS_TRK00)? 1:0,
- (data&HDC_DS_UDEF)? 1:0, (data&HDC_DS_WRPROT)? 1:0,
- (data&HDC_DS_READY)? 1:0, (data&HDC_DS_WRFAULT)? 1:0);
-
- bool previndex = index_hole();
- bool prevready = drive_ready();
- bool prevskcom = seek_complete();
-
- m_register_r[DRIVE_STATUS] = data;
-
- // Call a handler if the respective flag changed
- if (previndex != index_hole()) index_handler();
- if (prevready != drive_ready()) ready_handler();
- if (prevskcom != seek_complete()) seek_complete_handler();
-}
-
-bool hdc92x4_device::waiting_for_line(int line, int level)
-{
- return (m_event_line == line && m_state_after_line != UNDEF && m_line_level == level);
-}
-
-bool hdc92x4_device::waiting_for_other_line(int line)
-{
- return (m_state_after_line != UNDEF && m_event_line != line);
-}
-
-/*
- Handlers for incoming signal lines.
-*/
-void hdc92x4_device::index_handler()
-{
- int level = index_hole()? ASSERT_LINE : CLEAR_LINE;
- if (TRACE_LINES) logerror("%s: [%s] Index handler; level=%d\n", tag(), ttsn().c_str(), level);
-
- // Synchronize our position on the track
- live_sync();
-
- if (level==ASSERT_LINE)
- {
- if (TRACE_INDEX) logerror("%s: Index pulse\n", tag());
- if (m_wait_for_index) m_stop_after_index = true;
- }
-
- if (waiting_for_line(INDEX_LINE, level))
- {
- if (TRACE_LINES) logerror("%s: [%s] Index pulse level=%d triggers event\n", tag(), ttsn().c_str(), level);
- m_substate = m_state_after_line;
- m_state_after_line = UNDEF;
- if (m_stopwrite)
- {
- if (using_floppy()) m_pll.stop_writing(m_floppy, m_live_state.time);
- m_live_state.state = IDLE;
- }
- reenter_command_processing();
- }
- else
- {
- // Live processing waits for INDEX
- // For harddisk we will continue processing on the falling edge
- if (!m_timed_wait && !waiting_for_other_line(INDEX_LINE) && (using_floppy() || level == CLEAR_LINE))
- reenter_command_processing();
- }
-}
-
-void hdc92x4_device::ready_handler()
-{
- int level = drive_ready()? ASSERT_LINE : CLEAR_LINE;
- if (TRACE_LINES) logerror("%s: [%s] Ready handler; level=%d\n", tag(), ttsn().c_str(), level);
-
- // Set the interrupt status flag
- set_bits(m_register_r[INT_STATUS], ST_RDYCHNG, true);
-
- // Synchronize our position on the track
- live_sync();
-
- // Raise an interrupt if desired
- if (m_register_w[INT_COMM_TERM] & TC_INTRDCH)
- {
- if (TRACE_INT) logerror("%s: Raise interrupt READY change\n", tag());
- set_interrupt(ASSERT_LINE);
- }
-
- // This is actually not needed, since we never wait for READY
- if (waiting_for_line(READY_LINE, level))
- {
- m_substate = m_state_after_line;
- m_state_after_line = UNDEF;
- reenter_command_processing();
- }
-}
-
-void hdc92x4_device::seek_complete_handler()
-{
- int level = seek_complete()? ASSERT_LINE : CLEAR_LINE;
- if (TRACE_LINES) logerror("%s: [%s] Seek complete handler; level=%d\n", tag(), ttsn().c_str(), level);
-
- // Synchronize our position on the track
- live_sync();
-
- if (waiting_for_line(SEEKCOMP_LINE, level))
- {
- m_substate = m_state_after_line;
- m_state_after_line = UNDEF;
- reenter_command_processing();
- }
-}
-
-/*
- Push the output registers over the auxiliary bus. It is expected that
- the PCB contains latches to store the values.
-
- OUTPUT1 register contents
- S0 = 0, S1 = 1
- +------+------+------+------+------+------+------+------+
- | Drv3 | Drv2 | Drv1 | Drv0 | PO3 | PO2 | PO1 | PO0 |
- +------+------+------+------+------+------+------+------+
-
- DrvX = select Drive X (only one bit allowed)
- POX = Programmable output X (contents from low 4 bits of register RETRY_COUNT)
-
-
- OUTPUT2 register contents
- S0 = 1, S1 = 1
- +------+------+------+------+------+------+------+------+
- | Drv3*| WCur | Dir | Step | Head |
- +------+------+------+------+------+------+------+------+
-
- Drv3* = inverted Drv3 signal of OUTPUT1
- WCur = Reduced write current
- Dir = Step direction (0 = towards track 0)
- Step = Step pulse
- Head = desired head
-*/
-void hdc92x4_device::auxbus_out()
-{
- // prepare output2
- set_bits(m_output2, OUT2_DRVSEL3I, (m_output1 & OUT1_DRVSEL3)==0);
-
- m_output2 = (m_output2 & 0xb0) | desired_head();
- if (m_reduced_write_current) m_output2 |= OUT2_REDWRT;
-
- if (TRACE_AUXBUS) logerror("%s: [%s] Setting OUTPUT1=%02x, OUTPUT2=%02x\n", tag(), ttsn().c_str(), m_output1, m_output2);
-
- if (m_output1 != m_output1_old || m_output2 != m_output2_old)
- {
- // Only propagate changes
- m_out_auxbus((offs_t)HDC_OUTPUT_1, m_output1);
- m_out_auxbus((offs_t)HDC_OUTPUT_2, m_output2);
- m_output1_old = m_output1;
- m_output2_old = m_output2;
- }
-}
-
-void hdc92x4_device::dma_address_out(UINT8 addrub, UINT8 addrhb, UINT8 addrlb)
-{
- if (TRACE_DMA) logerror("%s: Setting DMA address %06x\n", tag(), (addrub<<16 | addrhb<<8 | addrlb)&0xffffff);
- m_out_auxbus((offs_t)HDC_OUTPUT_DMA_ADDR, addrub);
- m_out_auxbus((offs_t)HDC_OUTPUT_DMA_ADDR, addrhb);
- m_out_auxbus((offs_t)HDC_OUTPUT_DMA_ADDR, addrlb);
-}
-
-/*
- Set/clear INT
-
- Interupts are generated in the following occasions:
- - when the DONE bit is set to 1 in the ISR and ST_DONE is set to 1
- - when the READY_CHANGE bit is set to 1 in the ISR and ST_RDYCHNG is set to 1
- (ready change: 1->0 or 0->1)
-*/
-void hdc92x4_device::set_interrupt(line_state intr)
-{
- if (intr == ASSERT_LINE)
- {
- // Only if there is not already a pending interrupt
- if ((m_register_r[INT_STATUS] & ST_INTPEND) == 0)
- {
- m_register_r[INT_STATUS] |= ST_INTPEND;
- m_out_intrq(intr);
- }
- }
- else
- {
- // if there is a pending interrupt
- if ((m_register_r[INT_STATUS] & ST_INTPEND) != 0)
- m_out_intrq(intr);
- }
-}
-
-/*
- DMA acknowledge line.
-*/
-WRITE_LINE_MEMBER( hdc92x4_device::dmaack )
-{
- if (state==ASSERT_LINE)
- {
- if (TRACE_DMA) logerror("%s: [%s] DMA acknowledged\n", tag(), ttsn().c_str());
- set_bits(m_register_r[INT_STATUS], ST_OVRUN, false);
- }
-}
-
-/*
- This is pretty simple here, compared to wd17xx, because index and ready
- callbacks have to be tied to the controller board outside the chip.
-*/
-void hdc92x4_device::connect_floppy_drive(floppy_image_device* floppy)
-{
- m_floppy = floppy;
-}
-
-/*
- Connect the current hard drive.
-*/
-void hdc92x4_device::connect_hard_drive(mfm_harddisk_device* harddisk)
-{
- m_harddisk = harddisk;
- m_hd_encoding = m_harddisk->get_encoding();
- if (TRACE_SELECT && TRACE_DETAIL) logerror("%s: HD encoding = %d\n", tag(), m_hd_encoding);
-}
-
-/*
- Clock divider. This input line actually belongs to the data separator which
- is a separate circuit. Maybe we will take it out of this implementation
- at some time and make it a device of its own.
- line: CD0 (0) and CD1(1), value 0 or 1
-*/
-void hdc92x4_device::set_clock_divider(int line, int value)
-{
- set_bits(m_clock_divider, (line==0)? 1 : 2, value&1);
-}
-
-/*
- This is reached when a timer has expired
-*/
-void hdc92x4_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- live_sync();
- m_timed_wait = false;
-
- switch (id)
- {
- case GEN_TIMER:
- reenter_command_processing();
- break;
- case COM_TIMER:
- process_command();
- break;
- }
-}
-
-/*
- Reset the controller. Negative logic, but we use ASSERT_LINE.
-*/
-WRITE_LINE_MEMBER( hdc92x4_device::reset )
-{
- if (state == ASSERT_LINE)
- {
- if (TRACE_LINES) logerror("%s: Reset via RST line\n", tag());
- device_reset();
- }
-}
-
-void hdc92x4_device::device_start()
-{
- m_out_intrq.resolve_safe();
- m_out_dip.resolve_safe();
- m_out_auxbus.resolve_safe();
- m_out_dmarq.resolve_safe();
- m_out_dma.resolve_safe();
- m_in_dma.resolve_safe(0);
-
- // allocate timers
- m_timer = timer_alloc(GEN_TIMER);
- m_cmd_timer = timer_alloc(COM_TIMER);
- // m_live_timer = timer_alloc(LIVE_TIMER);
-
- m_live_state.state = IDLE;
-}
-
-void hdc92x4_device::device_reset()
-{
- m_clock_divider = 0;
- m_deleted = false;
- m_executing = false;
- m_event_line = UNDEF;
- m_first_sector_found = false;
- m_initialized = true;
- m_line_level = CLEAR_LINE;
- m_live_state.state = IDLE;
- m_live_state.time = attotime::never;
- m_logical = true;
- m_multi_sector = false;
- m_output1 = 0;
- m_output2 = 0x80;
- m_output1_old = 1; // force an initial output
- m_output2_old = 0x81;
- m_precompensation = 0;
- m_reduced_write_current = false;
- m_regvalue = 0;
- m_register_pointer = 0;
- m_retry_save = 0;
- m_seek_count = 0;
- m_selected_drive_number = NODRIVE;
- m_selected_drive_type = 0;
- m_state_after_line = UNDEF;
- m_stop_after_index = false;
- m_substate = UNDEF;
- m_timed_wait = false;
- m_track_delta = 0;
- m_transfer_enabled = true;
- m_wait_for_index = false;
- m_write = false;
-
- for (int i=0; i<=11; i++)
- m_register_r[i] = m_register_w[i] = 0;
-
- set_interrupt(CLEAR_LINE);
- m_out_dip(CLEAR_LINE);
- m_out_dmarq(CLEAR_LINE);
-}
-
-const device_type HDC9224 = &device_creator<hdc9224_device>;
-const device_type HDC9234 = &device_creator<hdc9234_device>;
diff --git a/src/emu/machine/hdc92x4.h b/src/emu/machine/hdc92x4.h
deleted file mode 100644
index da3c5b6d954..00000000000
--- a/src/emu/machine/hdc92x4.h
+++ /dev/null
@@ -1,487 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Michael Zapf
-/*
- HDC9224 / HDC9234 Hard and Floppy Disk Controller
- For details see hdc92x4.c
-*/
-#ifndef __HDC92X4_H__
-#define __HDC92X4_H__
-
-#include "emu.h"
-#include "imagedev/floppy.h"
-#include "imagedev/mfmhd.h"
-#include "fdc_pll.h"
-
-extern const device_type HDC9224;
-extern const device_type HDC9234;
-
-/*
- Enumeration of the latches outside of the controller
-*/
-enum
-{
- HDC_INPUT_STATUS = 0x00,
- HDC_OUTPUT_DMA_ADDR = 0x01,
- HDC_OUTPUT_1 = 0x02,
- HDC_OUTPUT_2 = 0x03
-};
-
-
-/*
- Definition of bits in the Disk-Status register
-*/
-enum
-{
- HDC_DS_ECCERR = 0x80, // ECC error
- HDC_DS_INDEX = 0x40, // index hole
- HDC_DS_SKCOM = 0x20, // seek complete
- HDC_DS_TRK00 = 0x10, // track 0
- HDC_DS_UDEF = 0x08, // user-defined
- HDC_DS_WRPROT = 0x04, // write-protected
- HDC_DS_READY = 0x02, // drive ready bit
- HDC_DS_WRFAULT = 0x01 // write fault
-};
-
-//===================================================================
-
-/* Interrupt line. To be connected with the controller PCB. */
-#define MCFG_HDC92X4_INTRQ_CALLBACK(_write) \
- devcb = &hdc92x4_device::set_intrq_wr_callback(*device, DEVCB_##_write);
-
-/* DMA request line. To be connected with the controller PCB. */
-#define MCFG_HDC92X4_DMARQ_CALLBACK(_write) \
- devcb = &hdc92x4_device::set_dmarq_wr_callback(*device, DEVCB_##_write);
-
-/* DMA in progress line. To be connected with the controller PCB. */
-#define MCFG_HDC92X4_DIP_CALLBACK(_write) \
- devcb = &hdc92x4_device::set_dip_wr_callback(*device, DEVCB_##_write);
-
-/* Auxiliary Bus. These 8 lines need to be connected to external latches
- and to a counter circuitry which works together with the external RAM.
- We use the S0/S1 lines as address lines. */
-#define MCFG_HDC92X4_AUXBUS_OUT_CALLBACK(_write) \
- devcb = &hdc92x4_device::set_auxbus_wr_callback(*device, DEVCB_##_write);
-
-/* Callback to read the contents of the external RAM via the data bus.
- Note that the address must be set and automatically increased
- by external circuitry. */
-#define MCFG_HDC92X4_DMA_IN_CALLBACK(_read) \
- devcb = &hdc92x4_device::set_dma_rd_callback(*device, DEVCB_##_read);
-
-/* Callback to write the contents of the external RAM via the data bus.
- Note that the address must be set and automatically increased
- by external circuitry. */
-#define MCFG_HDC92X4_DMA_OUT_CALLBACK(_write) \
- devcb = &hdc92x4_device::set_dma_wr_callback(*device, DEVCB_##_write);
-
-//===================================================================
-
-class hdc92x4_device : public device_t
-{
-public:
- hdc92x4_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- // Accesors from the CPU side
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_WRITE_LINE_MEMBER( reset );
- DECLARE_WRITE_LINE_MEMBER( dmaack );
-
- // Callbacks
- template<class _Object> static devcb_base &set_intrq_wr_callback(device_t &device, _Object object) { return downcast<hdc92x4_device &>(device).m_out_intrq.set_callback(object); }
- template<class _Object> static devcb_base &set_dmarq_wr_callback(device_t &device, _Object object) { return downcast<hdc92x4_device &>(device).m_out_dmarq.set_callback(object); }
- template<class _Object> static devcb_base &set_dip_wr_callback(device_t &device, _Object object) { return downcast<hdc92x4_device &>(device).m_out_dip.set_callback(object); }
- template<class _Object> static devcb_base &set_auxbus_wr_callback(device_t &device, _Object object) { return downcast<hdc92x4_device &>(device).m_out_auxbus.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_rd_callback(device_t &device, _Object object) { return downcast<hdc92x4_device &>(device).m_in_dma.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_wr_callback(device_t &device, _Object object) { return downcast<hdc92x4_device &>(device).m_out_dma.set_callback(object); }
-
- // auxbus_in is intended to read events from the drives
- // In the real chip the status is polled; to avoid unnecessary load
- // we implement it as a push call
- void auxbus_in( UINT8 data );
-
- // We pretend that the data separator is part of this controller. It is
- // in fact a separate circuit. The clock divider must be properly set
- // for MFM (CD0=1, CD1=0) or FM (CD0=0, CD1=1).
- // This is not set by the controller itself!
- void set_clock_divider(int pin, int value);
-
- // Used to reconfigure the drive connections. Floppy drive selection is done
- // using the user-programmable outputs. Hence, the connection
- // is changed outside of the controller, and by this way we let it know.
- void connect_floppy_drive(floppy_image_device *floppy);
-
- // Used to reconfigure the drive connections. See connect_floppy_drive.
- void connect_hard_drive(mfm_harddisk_device *harddisk);
-
-protected:
- void device_start();
- void device_reset();
-
- bool m_is_hdc9234;
-
- devcb_write_line m_out_intrq; // INT line
- devcb_write_line m_out_dmarq; // DMA request line
- devcb_write_line m_out_dip; // DMA in progress line
- devcb_write8 m_out_auxbus; // AB0-7 lines (using S0,S1 as address)
- devcb_read8 m_in_dma; // DMA read access to the cache buffer
- devcb_write8 m_out_dma; // DMA write access to the cache buffer
-
- // Internal register pointer used for sequential register loading
- int m_register_pointer;
-
- // Read and write registers
- UINT8 m_register_w[12];
- UINT8 m_register_r[15];
-
- // Interrupt management (outgoing INT pin)
- void set_interrupt(line_state intr);
-
- // Currently connected floppy
- floppy_image_device* m_floppy;
-
- // Currently connected harddisk
- mfm_harddisk_device* m_harddisk;
-
- // internal register OUTPUT1
- UINT8 m_output1, m_output1_old;
-
- // internal register OUTPUT2
- UINT8 m_output2, m_output2_old;
-
- // Write the output registers to the latches
- void auxbus_out();
-
- // Write the DMA address to the external latches
- void dma_address_out(UINT8 addrub, UINT8 addrhb, UINT8 addrlb);
-
- // Intermediate storage for register
- UINT8 m_regvalue;
-
- // Drive type that has been selected in drive_select
- int m_selected_drive_type;
-
- // Drive numbere that has been selected in drive_select
- int m_selected_drive_number;
-
- // Indicates whether the device has completed initialization
- bool m_initialized;
-
- // Timers to delay execution/completion of commands */
- emu_timer *m_timer;
- emu_timer *m_cmd_timer;
- // emu_timer *m_live_timer;
-
- // Timer callback
- void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // Handlers for incoming signals
- void ready_handler();
- void index_handler();
- void seek_complete_handler();
-
- // Wait for this line?
- bool waiting_for_line(int line, int level);
-
- // Wait for some other line?
- bool waiting_for_other_line(int line);
-
- // Wait for some time to pass or for a line to change level
- void wait_time(emu_timer *tm, int microsec, int next_substate);
- void wait_time(emu_timer *tm, const attotime &delay, int param);
- void wait_line(int line, line_state level, int substate, bool stopwrite);
-
- // Converts attotime to a string
- std::string tts(const attotime &t);
-
- // Current time
- std::string ttsn();
-
- // Utility routine to set or reset bits
- void set_bits(UINT8& byte, int mask, bool set);
-
- // Event handling
- line_state m_line_level;
- int m_event_line;
- int m_state_after_line;
- bool m_timed_wait;
-
- // ==============================================
- // Live state machine
- // ==============================================
-
- struct live_info
- {
- attotime time;
- UINT16 shift_reg;
- UINT16 shift_reg_save;
- UINT16 crc;
- int bit_counter;
- int bit_count_total; // used for timeout handling
- int byte_counter;
- bool data_separator_phase;
- bool last_data_bit;
- UINT8 clock_reg;
- UINT8 data_reg;
- int state;
- int next_state;
- int repeat; // for formatting
- int return_state; // for formatting
- };
-
- live_info m_live_state, m_checkpoint_state;
- int m_last_live_state;
-
- // Starts the live run
- void live_start(int state);
-
- // Analyses the track until the given time
- void live_run_until(attotime limit);
-
- // Same for hard disks
- void live_run_hd_until(attotime limit);
-
- // Live run until next index pulse
- void live_run();
-
- // Control functions for syncing the track analyser with the machine time
- void wait_for_realtime(int state);
- void live_sync();
- void live_abort();
- void rollback();
- void checkpoint();
-
- // Found a mark
- bool found_mark(int state);
-
- // Delivers the data bits from the given encoding
- UINT8 get_data_from_encoding(UINT16 raw);
-
- // ==============================================
- // PLL functions and interface to floppy and harddisk
- // ==============================================
-
- // Phase-locked loops
- fdc_pll_t m_pll, m_checkpoint_pll;
-
- // Clock divider value
- UINT8 m_clock_divider;
-
- // MFM HD encoding type
- mfmhd_enc_t m_hd_encoding;
-
- // Resets the PLL to the given time
- void pll_reset(const attotime &when, bool write);
-
- // Puts the word into the shift register directly. Changes the m_live_state members
- // shift_reg, and last_data_bit
- void encode_raw(UINT16 word);
-
- // Encodes a byte in FM or MFM. Called by encode_byte.
- UINT16 encode(UINT8 byte);
-
- // Encodes a byte in FM or MFM. Called by encode_byte.
- UINT16 encode_hd(UINT8 byte);
- UINT16 encode_a1_hd();
-
- // Encode the latest byte again
- void encode_again();
-
- // Reads from the current position on the track
- bool read_one_bit(const attotime &limit);
-
- // Writes to the current position on the track
- bool write_one_bit(const attotime &limit);
-
- // Writes to the current position on the track
- void write_on_track(UINT16 raw, int count, int next_state);
-
- // Skips bytes on the track
- void skip_on_track(int count, int next_state);
-
- // Read from the MFM HD
- bool read_from_mfmhd(const attotime &limit);
-
- // Write to the MFM HD
- bool write_to_mfmhd(const attotime &limit);
-
- // ==============================================
- // Command state machine
- // ==============================================
-
- int m_substate;
-
- typedef void (hdc92x4_device::*cmdfunc)(void);
-
- typedef struct
- {
- UINT8 baseval;
- UINT8 mask;
- cmdfunc command;
- } cmddef;
-
- static const cmddef s_command[];
-
- // Indicates whether a command is currently being executed
- bool m_executing;
-
- // Keeps the pointer to the function for later continuation
- cmdfunc m_command;
-
- // Invoked after the commit period for command initiation or register write access
- void process_command();
-
- // Re-enters the state machine after a delay
- void reenter_command_processing();
-
- // Command is done
- void set_command_done(int flags);
- void set_command_done();
-
- // Difference between current cylinder and desired cylinder
- int m_track_delta;
-
- // Used to restore the retry count for multi-sector operations
- int m_retry_save;
-
- // ==============================================
- // Operation properties
- // ==============================================
-
- // Precompensation value
- int m_precompensation;
-
- // Do we have a multi-sector operation?
- bool m_multi_sector;
-
- // Shall we wait for the index hole?
- bool m_wait_for_index;
-
- // Shall we stop after the next index hole?
- bool m_stop_after_index;
-
- // Is data transfer enabled for read operations?
- bool m_transfer_enabled;
-
- // Is it a read or a write operation?
- bool m_write;
-
- // Have we found a deleted sector?
- bool m_deleted;
-
- // Do we apply a reduced write current?
- bool m_reduced_write_current;
-
- // Used in RESTORE to find out when to give up
- int m_seek_count;
-
- // Read/write logical or physical?
- bool m_logical;
-
- // Signals to abort writing
- bool m_stopwrite;
-
- // Flag to remember whether we found the first sector during a physical access
- bool m_first_sector_found;
-
- // Used for formatting
- int m_sector_count;
- int m_sector_size;
- int m_gap0_size;
- int m_gap1_size;
- int m_gap2_size;
- int m_gap3_size;
- int m_sync_size;
-
- // Are we in FM mode?
- bool fm_mode();
-
- // Seek completed?
- bool seek_complete();
-
- // Are we on track 0?
- bool on_track00();
-
- // Are we at the index hole?
- bool index_hole();
-
- // Is the attached drive ready?
- bool drive_ready();
-
- // Are we reading a track?
- bool reading_track();
-
- // Delivers the desired head
- int desired_head();
-
- // Delivers the desired sector
- int desired_sector();
-
- // Delivers the desired cylinder. The value is spread over two registers.
- int desired_cylinder();
-
- // Delivers the current head as read from the track
- int current_head();
-
- // Delivers the current sector as read from the track
- int current_sector();
-
- // Delivers the current cylinder as read from the track
- int current_cylinder();
-
- // Delivers the current command
- UINT8 current_command();
-
- // Step time (minus pulse width)
- int step_time();
-
- // Step pulse width
- int pulse_width();
-
- // Sector size as read from the track
- int calc_sector_size();
-
- // Is the currently selected drive a floppy drive?
- bool using_floppy();
-
- // Common subprograms READ ID, VERIFY, and DATA TRANSFER
- void read_id(int& cont, bool implied_seek, bool wait_seek_complete);
- void verify(int& cont);
- void data_transfer(int& cont);
-
- // ===================================================
- // Commands
- // ===================================================
-
- void reset_controller();
- void drive_deselect();
- void restore_drive();
- void step_drive();
- void tape_backup();
- void poll_drives();
- void drive_select();
- void set_register_pointer();
- void seek_read_id();
- void read_sectors();
- void read_track();
- void format_track();
- void write_sectors();
-};
-
-// =====================================================
-// Subclasses: the two variants
-// =====================================================
-
-class hdc9224_device : public hdc92x4_device
-{
-public:
- hdc9224_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class hdc9234_device : public hdc92x4_device
-{
-public:
- hdc9234_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-#endif
diff --git a/src/emu/machine/i2cmem.c b/src/emu/machine/i2cmem.c
deleted file mode 100644
index 5e714c0b129..00000000000
--- a/src/emu/machine/i2cmem.c
+++ /dev/null
@@ -1,510 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
-I2C Memory
-
-Generic ram/rom/eeprom/flash on an i2c bus. Supports specifying the slave address,
-the data size & the page size for writing.
-
-inputs:
- e0,e1,e2 lower 3 bits of the slave address
- sda serial data
- scl serial clock
- wc write protect
-
-outputs:
- sda serial data
-
-The memory address is only 8 bits, devices larger than this have multiple slave addresses.
-The top five address bits are set at manufacture time, two values are standard.
-Up to 4096 bytes can be addressed.
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/i2cmem.h"
-
-#define STATE_IDLE ( 0 )
-#define STATE_DEVSEL ( 1 )
-#define STATE_BYTEADDR ( 2 )
-#define STATE_DATAIN ( 3 )
-#define STATE_DATAOUT ( 4 )
-
-#define DEVSEL_RW ( 1 )
-#define DEVSEL_ADDRESS ( 0xfe )
-
-//**************************************************************************
-// DEBUGGING
-//**************************************************************************
-
-#define VERBOSE_LEVEL ( 0 )
-
-INLINE void ATTR_PRINTF( 3, 4 ) verboselog( device_t *device, int n_level, const char *s_fmt, ... )
-{
- if( VERBOSE_LEVEL >= n_level )
- {
- va_list v;
- char buf[ 32768 ];
- va_start( v, s_fmt );
- vsprintf( buf, s_fmt, v );
- va_end( v );
- logerror( "%s: I2CMEM(%s) %s", device->machine().describe_context( ), device->tag(), buf );
- }
-}
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type I2CMEM = &device_creator<i2cmem_device>;
-
-static ADDRESS_MAP_START( i2cmem_map8, AS_PROGRAM, 8, i2cmem_device )
- AM_RANGE(0x0000, 0x0fff) AM_RAM
-ADDRESS_MAP_END
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// i2cmem_device - constructor
-//-------------------------------------------------
-
-i2cmem_device::i2cmem_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
- : device_t(mconfig, I2CMEM, "I2C Memory", tag, owner, clock, "i2cmem", __FILE__),
- device_memory_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this),
- m_slave_address( I2CMEM_SLAVE_ADDRESS ),
- m_page_size( 0 ),
- m_data_size( 0 ),
- m_scl( 0 ),
- m_sdaw( 0 ),
- m_e0( 0 ),
- m_e1( 0 ),
- m_e2( 0 ),
- m_wc( 0 ),
- m_sdar( 1 ),
- m_state( STATE_IDLE ),
- m_shift( 0 ),
- m_byteaddr( 0 )
-{
-}
-
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void i2cmem_device::device_config_complete()
-{
- int address_bits = 0;
-
- int i = m_data_size - 1;
- while( i > 0 )
- {
- address_bits++;
- i >>= 1;
- }
-
- m_space_config = address_space_config( "i2cmem", ENDIANNESS_BIG, 8, address_bits, 0, *ADDRESS_MAP_NAME( i2cmem_map8 ) );
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void i2cmem_device::device_start()
-{
- m_page.resize( m_page_size );
-
- save_item( NAME(m_scl) );
- save_item( NAME(m_sdaw) );
- save_item( NAME(m_e0) );
- save_item( NAME(m_e1) );
- save_item( NAME(m_e2) );
- save_item( NAME(m_wc) );
- save_item( NAME(m_sdar) );
- save_item( NAME(m_state) );
- save_item( NAME(m_bits) );
- save_item( NAME(m_shift) );
- save_item( NAME(m_devsel) );
- save_item( NAME(m_byteaddr) );
- if ( m_page_size > 0 )
- {
- save_item( NAME(m_page) );
- }
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void i2cmem_device::device_reset()
-{
-}
-
-
-//-------------------------------------------------
-// memory_space_config - return a description of
-// any address spaces owned by this device
-//-------------------------------------------------
-
-const address_space_config *i2cmem_device::memory_space_config( address_spacenum spacenum ) const
-{
- return ( spacenum == 0 ) ? &m_space_config : NULL;
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void i2cmem_device::nvram_default()
-{
- int i2cmem_bytes = m_data_size;
-
- UINT16 default_value = 0xff;
- for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
- {
- m_addrspace[ 0 ]->write_byte( offs, default_value );
- }
-
- /* populate from a memory region if present */
- if( m_region != NULL )
- {
- if( m_region->bytes() != i2cmem_bytes )
- {
- fatalerror( "i2cmem region '%s' wrong size (expected size = 0x%X)\n", tag(), i2cmem_bytes );
- }
-
- if( m_region->bytewidth() != 1 )
- {
- fatalerror( "i2cmem region '%s' needs to be an 8-bit region\n", tag() );
- }
-
- UINT8 *default_data = m_region->base();
- for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
- m_addrspace[ 0 ]->write_byte( offs, default_data[offs] );
- }
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void i2cmem_device::nvram_read( emu_file &file )
-{
- int i2cmem_bytes = m_data_size;
- dynamic_buffer buffer ( i2cmem_bytes );
-
- file.read( &buffer[0], i2cmem_bytes );
-
- for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
- {
- m_addrspace[ 0 ]->write_byte( offs, buffer[ offs ] );
- }
-}
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void i2cmem_device::nvram_write( emu_file &file )
-{
- int i2cmem_bytes = m_data_size;
- dynamic_buffer buffer ( i2cmem_bytes );
-
- for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
- {
- buffer[ offs ] = m_addrspace[ 0 ]->read_byte( offs );
- }
-
- file.write( &buffer[0], i2cmem_bytes );
-}
-
-
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-WRITE_LINE_MEMBER( i2cmem_device::write_e0 )
-{
- state &= 1;
- if( m_e0 != state )
- {
- verboselog( this, 2, "set e0 %d\n", state );
- m_e0 = state;
- }
-}
-
-
-WRITE_LINE_MEMBER( i2cmem_device::write_e1 )
-{
- state &= 1;
- if( m_e1 != state )
- {
- verboselog( this, 2, "set e1 %d\n", state );
- m_e1 = state;
- }
-}
-
-
-WRITE_LINE_MEMBER( i2cmem_device::write_e2 )
-{
- state &= 1;
- if( m_e2 != state )
- {
- verboselog( this, 2, "set e2 %d\n", state );
- m_e2 = state;
- }
-}
-
-
-WRITE_LINE_MEMBER( i2cmem_device::write_sda )
-{
- state &= 1;
- if( m_sdaw != state )
- {
- verboselog( this, 2, "set sda %d\n", state );
- m_sdaw = state;
-
- if( m_scl )
- {
- if( m_sdaw )
- {
- verboselog( this, 1, "stop\n" );
- m_state = STATE_IDLE;
- }
- else
- {
- verboselog( this, 2, "start\n" );
- m_state = STATE_DEVSEL;
- m_bits = 0;
- }
-
- m_sdar = 1;
- }
- }
-}
-
-WRITE_LINE_MEMBER( i2cmem_device::write_scl )
-{
- if( m_scl != state )
- {
- m_scl = state;
- verboselog( this, 2, "set_scl_line %d\n", m_scl );
-
- switch( m_state )
- {
- case STATE_DEVSEL:
- case STATE_BYTEADDR:
- case STATE_DATAIN:
- if( m_bits < 8 )
- {
- if( m_scl )
- {
- m_shift = ( ( m_shift << 1 ) | m_sdaw ) & 0xff;
- m_bits++;
- }
- }
- else
- {
- if( m_scl )
- {
- switch( m_state )
- {
- case STATE_DEVSEL:
- m_devsel = m_shift;
-
- if( !select_device() )
- {
- verboselog( this, 1, "devsel %02x: not this device\n", m_devsel );
- m_state = STATE_IDLE;
- }
- else if( ( m_devsel & DEVSEL_RW ) == 0 )
- {
- verboselog( this, 1, "devsel %02x: write\n", m_devsel );
- m_state = STATE_BYTEADDR;
- }
- else
- {
- verboselog( this, 1, "devsel %02x: read\n", m_devsel );
- m_state = STATE_DATAOUT;
- }
- break;
-
- case STATE_BYTEADDR:
- m_byteaddr = m_shift;
- m_page_offset = 0;
-
- verboselog( this, 1, "byteaddr %02x\n", m_byteaddr );
-
- m_state = STATE_DATAIN;
- break;
-
- case STATE_DATAIN:
- if( m_wc )
- {
- verboselog( this, 0, "write not enabled\n" );
- m_state = STATE_IDLE;
- }
- else if( m_page_size > 0 )
- {
- m_page[ m_page_offset ] = m_shift;
- verboselog( this, 1, "page[ %04x ] <- %02x\n", m_page_offset, m_page[ m_page_offset ] );
-
- m_page_offset++;
- if( m_page_offset == m_page_size )
- {
- int offset = data_offset() & ~( m_page_size - 1 );
-
- verboselog( this, 1, "data[ %04x to %04x ] = page\n", offset, offset + m_page_size - 1 );
-
- for( int i = 0; i < m_page_size; i++ )
- {
- m_addrspace[ 0 ]->write_byte( offset + i, m_page[ i ] );
- }
-
- m_page_offset = 0;
- }
- }
- else
- {
- int offset = data_offset();
-
- verboselog( this, 1, "data[ %04x ] <- %02x\n", offset, m_shift );
- m_addrspace[ 0 ]->write_byte( offset, m_shift );
-
- m_byteaddr++;
- }
- break;
- }
-
- m_bits++;
- }
- else
- {
- if( m_bits == 8 )
- {
- m_sdar = 0;
- }
- else
- {
- m_bits = 0;
- m_sdar = 1;
- }
- }
- }
- break;
-
- case STATE_DATAOUT:
- if( m_bits < 8 )
- {
- if( m_scl )
- {
- if( m_bits == 0 )
- {
- int offset = data_offset();
-
- m_shift = m_addrspace[ 0 ]->read_byte( offset );
- verboselog( this, 1, "data[ %04x ] -> %02x\n", offset, m_shift );
- m_byteaddr++;
- }
-
- m_sdar = ( m_shift >> 7 ) & 1;
-
- m_shift = ( m_shift << 1 ) & 0xff;
- m_bits++;
- }
- }
- else
- {
- if( m_scl )
- {
- if( m_sdaw )
- {
- verboselog( this, 1, "sleep\n" );
- m_state = STATE_IDLE;
- m_sdar = 0;
- }
-
- m_bits++;
- }
- else
- {
- if( m_bits == 8 )
- {
- m_sdar = 1;
- }
- else
- {
- m_bits = 0;
- }
- }
- }
- break;
- }
- }
-}
-
-
-WRITE_LINE_MEMBER( i2cmem_device::write_wc )
-{
- state &= 1;
- if( m_wc != state )
- {
- verboselog( this, 2, "set wc %d\n", state );
- m_wc = state;
- }
-}
-
-
-READ_LINE_MEMBER( i2cmem_device::read_sda )
-{
- int res = m_sdar & 1;
-
- verboselog( this, 2, "read sda %d\n", res );
-
- return res;
-}
-
-
-//**************************************************************************
-// INTERNAL HELPERS
-//**************************************************************************
-
-int i2cmem_device::address_mask()
-{
- return (m_data_size - 1);
-}
-
-int i2cmem_device::select_device()
-{
- int device = ( m_slave_address & 0xf0 ) | ( m_e2 << 3 ) | ( m_e1 << 2 ) | ( m_e0 << 1 );
- int mask = DEVSEL_ADDRESS & ~( address_mask() >> 7 );
-
- if( ( m_devsel & mask ) == ( device & mask ) )
- {
- return 1;
- }
-
- return 0;
-}
-
-int i2cmem_device::data_offset()
-{
- return ( ( ( m_devsel << 7 ) & 0xff00 ) | ( m_byteaddr & 0xff ) ) & address_mask();
-}
diff --git a/src/emu/machine/i2cmem.h b/src/emu/machine/i2cmem.h
deleted file mode 100644
index ce1bbdb3141..00000000000
--- a/src/emu/machine/i2cmem.h
+++ /dev/null
@@ -1,158 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- i2cmem.h
-
- I2C Memory
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __I2CMEM_H__
-#define __I2CMEM_H__
-
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-#define I2CMEM_SLAVE_ADDRESS ( 0xa0 )
-#define I2CMEM_SLAVE_ADDRESS_ALT ( 0xb0 )
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_I2CMEM_ADD( _tag ) \
- MCFG_DEVICE_ADD( _tag, I2CMEM, 0 )
-
-#define MCFG_I2CMEM_ADDRESS( address ) \
- i2cmem_device::set_address(*device, address);
-#define MCFG_I2CMEM_PAGE_SIZE( page_size ) \
- i2cmem_device::set_page_size(*device, page_size);
-#define MCFG_I2CMEM_DATA_SIZE(data_size) \
- i2cmem_device::set_data_size(*device, data_size);
-#define MCFG_I2CMEM_E0(e0) \
- i2cmem_device::set_e0(*device, e0);
-#define MCFG_I2CMEM_E1(e1) \
- i2cmem_device::set_e1(*device, e1);
-#define MCFG_I2CMEM_E2(e2) \
- i2cmem_device::set_e2(*device, e2);
-#define MCFG_I2CMEM_WC(wc) \
- i2cmem_device::set_wc(*device, wc);
-
-#define MCFG_X2404P_ADD( _tag ) \
- MCFG_I2CMEM_ADD( _tag ) \
- MCFG_I2CMEM_PAGE_SIZE(8) \
- MCFG_I2CMEM_DATA_SIZE(0x200)
-
-#define MCFG_24C01_ADD( _tag ) \
- MCFG_I2CMEM_ADD( _tag ) \
- MCFG_I2CMEM_PAGE_SIZE(4) \
- MCFG_I2CMEM_DATA_SIZE(0x80)
-
-#define MCFG_24C02_ADD( _tag ) \
- MCFG_I2CMEM_ADD( _tag ) \
- MCFG_I2CMEM_PAGE_SIZE(4) \
- MCFG_I2CMEM_DATA_SIZE(0x100)
-
-#define MCFG_24C08_ADD( _tag ) \
- MCFG_I2CMEM_ADD( _tag ) \
- MCFG_I2CMEM_DATA_SIZE(0x400)
-
-#define MCFG_24C16_ADD( _tag ) \
- MCFG_I2CMEM_ADD( _tag ) \
- MCFG_I2CMEM_PAGE_SIZE(8) \
- MCFG_I2CMEM_DATA_SIZE(0x800)
-
-#define MCFG_24C16A_ADD( _tag ) \
- MCFG_I2CMEM_ADD( _tag ) \
- MCFG_I2CMEM_DATA_SIZE(0x800)
-
-#define MCFG_24C64_ADD( _tag ) \
- MCFG_I2CMEM_ADD( _tag ) \
- MCFG_I2CMEM_PAGE_SIZE(8) \
- MCFG_I2CMEM_DATA_SIZE(0x2000)
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> i2cmem_device
-
-class i2cmem_device :
- public device_t,
- public device_memory_interface,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- i2cmem_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock );
-
- static void set_address(device_t &device, int address) { downcast<i2cmem_device &>(device).m_slave_address = address; }
- static void set_page_size(device_t &device, int page_size) { downcast<i2cmem_device &>(device).m_page_size = page_size; }
- static void set_data_size(device_t &device, int data_size) { downcast<i2cmem_device &>(device).m_data_size = data_size; }
- static void set_e0(device_t &device, int e0) { downcast<i2cmem_device &>(device).m_e0 = e0; }
- static void set_e1(device_t &device, int e1) { downcast<i2cmem_device &>(device).m_e1 = e1; }
- static void set_e2(device_t &device, int e2) { downcast<i2cmem_device &>(device).m_e2 = e2; }
- static void set_wc(device_t &device, int wc) { downcast<i2cmem_device &>(device).m_wc = wc; }
-
- // I/O operations
- DECLARE_WRITE_LINE_MEMBER( write_e0 );
- DECLARE_WRITE_LINE_MEMBER( write_e1 );
- DECLARE_WRITE_LINE_MEMBER( write_e2 );
- DECLARE_WRITE_LINE_MEMBER( write_sda );
- DECLARE_WRITE_LINE_MEMBER( write_scl );
- DECLARE_WRITE_LINE_MEMBER( write_wc );
- DECLARE_READ_LINE_MEMBER( read_sda );
-
-protected:
- // device-level overrides
- virtual void device_config_complete();
- virtual void device_start();
- virtual void device_reset();
-
- // device_memory_interface overrides
- virtual const address_space_config *memory_space_config( address_spacenum spacenum = AS_0 ) const;
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read( emu_file &file );
- virtual void nvram_write( emu_file &file );
-
- // internal helpers
- int address_mask();
- int select_device();
- int data_offset();
-
- // device-specific configuration
- address_space_config m_space_config;
-
- // internal state
- int m_slave_address;
- int m_page_size;
- int m_data_size;
- int m_scl;
- int m_sdaw;
- int m_e0;
- int m_e1;
- int m_e2;
- int m_wc;
- int m_sdar;
- int m_state;
- int m_bits;
- int m_shift;
- int m_devsel;
- int m_byteaddr;
- dynamic_buffer m_page;
- int m_page_offset;
-};
-
-
-// device type definition
-extern const device_type I2CMEM;
-
-#endif /* __I2CMEM_H__ */
diff --git a/src/emu/machine/i6300esb.c b/src/emu/machine/i6300esb.c
deleted file mode 100644
index ec7ca934d31..00000000000
--- a/src/emu/machine/i6300esb.c
+++ /dev/null
@@ -1,757 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "i6300esb.h"
-
-const device_type I6300ESB_WATCHDOG = &device_creator<i6300esb_watchdog_device>;
-const device_type I6300ESB_LPC = &device_creator<i6300esb_lpc_device>;
-
-DEVICE_ADDRESS_MAP_START(map, 32, i6300esb_watchdog_device)
-ADDRESS_MAP_END
-
-i6300esb_watchdog_device::i6300esb_watchdog_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_device(mconfig, I6300ESB_WATCHDOG, "i6300ESB southbridge watchdog", tag, owner, clock, "i6300esb_watchdog", __FILE__)
-{
-}
-
-void i6300esb_watchdog_device::device_start()
-{
- pci_device::device_start();
- add_map(16, M_MEM, FUNC(i6300esb_watchdog_device::map));
-}
-
-void i6300esb_watchdog_device::device_reset()
-{
- pci_device::device_reset();
- command = 0x000f;
- command_mask = 0x0140;
- status = 0x0280;
-}
-
-
-DEVICE_ADDRESS_MAP_START(config_map, 32, i6300esb_lpc_device)
- AM_RANGE(0x40, 0x43) AM_READWRITE (pmbase_r, pmbase_w)
- AM_RANGE(0x44, 0x47) AM_READWRITE8 (acpi_cntl_r, acpi_cntl_w, 0x000000ff)
- AM_RANGE(0x4c, 0x4f) AM_READWRITE16(bios_cntl_r, bios_cntl_w, 0xffff0000)
- AM_RANGE(0x54, 0x57) AM_READWRITE8 (tco_cntl_r, tco_cntl_w, 0x000000ff)
- AM_RANGE(0x58, 0x5b) AM_READWRITE (gpio_base_r, gpio_base_w)
- AM_RANGE(0x5c, 0x5f) AM_READWRITE8 (gpio_cntl_r, gpio_cntl_w, 0x000000ff)
- AM_RANGE(0x60, 0x63) AM_READWRITE8 (pirq_rout_r, pirq_rout_w, 0xffffffff)
- AM_RANGE(0x64, 0x67) AM_READWRITE8 (serirq_cntl_r, serirq_cntl_w, 0x000000ff)
- AM_RANGE(0x68, 0x6b) AM_READWRITE8 (pirq2_rout_r, pirq2_rout_w, 0xffffffff)
- AM_RANGE(0x88, 0x8b) AM_READWRITE8 (d31_err_cfg_r, d31_err_cfg_w, 0x000000ff)
- AM_RANGE(0x88, 0x8b) AM_READWRITE8 (d31_err_sts_r, d31_err_sts_w, 0x00ff0000)
- AM_RANGE(0x90, 0x93) AM_READWRITE16(pci_dma_cfg_r, pci_dma_cfg_w, 0x0000ffff)
- AM_RANGE(0xa0, 0xa3) AM_READWRITE16(gen_pmcon_1_r, gen_pmcon_1_w, 0x0000ffff)
- AM_RANGE(0xa0, 0xa3) AM_READWRITE8 (gen_pmcon_2_r, gen_pmcon_2_w, 0x00ff0000)
- AM_RANGE(0xa4, 0xa7) AM_READWRITE8 (gen_pmcon_3_r, gen_pmcon_3_w, 0x000000ff)
- AM_RANGE(0xac, 0xaf) AM_READWRITE (rst_cnt2_r, rst_cnt2_w)
- AM_RANGE(0xb0, 0xb3) AM_READWRITE8 (apm_cnt_r, apm_cnt_w, 0x00ff0000)
- AM_RANGE(0xb0, 0xb3) AM_READWRITE8 (apm_sts_r, apm_sts_w, 0xff000000)
- AM_RANGE(0xb8, 0xbb) AM_READWRITE (gpi_rout_r, gpi_rout_w)
- AM_RANGE(0xc0, 0xc3) AM_READWRITE8 (mon_fwd_en_r, mon_fwd_en_w, 0x000000ff)
- AM_RANGE(0xc4, 0xcb) AM_READWRITE16(mon_trp_rng_r, mon_trp_rng_w, 0xffffffff)
- AM_RANGE(0xcc, 0xcf) AM_READWRITE16(mon_trp_msk_r, mon_trp_msk_w, 0x0000ffff)
- AM_RANGE(0xd0, 0xd3) AM_READWRITE (gen_cntl_r, gen_cntl_w)
- AM_RANGE(0xd4, 0xd7) AM_READWRITE8 (gen_sta_r, gen_sta_w, 0x000000ff)
- AM_RANGE(0xd4, 0xd7) AM_READWRITE8 (back_cntl_r, back_cntl_w, 0x0000ff00)
- AM_RANGE(0xd8, 0xdb) AM_READWRITE8 (rtc_conf_r, rtc_conf_w, 0x000000ff)
- AM_RANGE(0xe0, 0xe3) AM_READWRITE8 (lpc_if_com_range_r, lpc_if_com_range_w, 0x000000ff)
- AM_RANGE(0xe0, 0xe3) AM_READWRITE8 (lpc_if_fdd_lpt_range_r, lpc_if_fdd_lpt_range_w, 0x0000ff00)
- AM_RANGE(0xe0, 0xe3) AM_READWRITE8 (lpc_if_sound_range_r, lpc_if_sound_range_w, 0x00ff0000)
- AM_RANGE(0xe0, 0xe3) AM_READWRITE8 (fwh_dec_en1_r, fwh_dec_en1_w, 0xff000000)
- AM_RANGE(0xe4, 0xe7) AM_READWRITE16(gen1_dec_r, gen1_dec_w, 0x0000ffff)
- AM_RANGE(0xe4, 0xe7) AM_READWRITE16(lpc_en_r, lpc_en_w, 0xffff0000)
- AM_RANGE(0xe8, 0xeb) AM_READWRITE (fwh_sel1_r, fwh_sel1_w)
- AM_RANGE(0xec, 0xef) AM_READWRITE16(gen2_dec_r, gen2_dec_w, 0x0000ffff)
- AM_RANGE(0xec, 0xef) AM_READWRITE16(fwh_sel2_r, fwh_sel2_w, 0xffff0000)
- AM_RANGE(0xf0, 0xf3) AM_READWRITE8 (fwh_dec_en2_r, fwh_dec_en2_w, 0x000000ff)
- AM_RANGE(0xf0, 0xf3) AM_READWRITE16(func_dis_r, func_dis_w, 0xffff0000)
- AM_RANGE(0xf4, 0xf7) AM_READWRITE (etr1_r, etr1_w)
- AM_RANGE(0xf8, 0xfb) AM_READ (mfid_r)
- AM_RANGE(0xfc, 0xff) AM_READWRITE (unk_fc_r, unk_fc_w)
-
- AM_INHERIT_FROM(pci_device::config_map)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(internal_io_map, 32, i6300esb_lpc_device)
- if(lpc_en & 0x2000) {
- AM_RANGE(0x004c, 0x004f) AM_READWRITE8(siu_config_port_r, siu_config_port_w, 0x00ff0000)
- AM_RANGE(0x004c, 0x004f) AM_READWRITE8(siu_data_port_r, siu_data_port_w, 0xff000000)
- }
-
- AM_RANGE(0x0060, 0x0063) AM_READWRITE8( nmi_sc_r, nmi_sc_w, 0x0000ff00)
-
- AM_RANGE(0x0080, 0x0083) AM_WRITE8( nop_w, 0x000000ff) // POST/non-existing, used for delays by the bios/os
- AM_RANGE(0x00ec, 0x00ef) AM_WRITE8( nop_w, 0x0000ff00) // Non-existing, used for delays by the bios/os
-ADDRESS_MAP_END
-
-
-i6300esb_lpc_device::i6300esb_lpc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_device(mconfig, I6300ESB_LPC, "i6300ESB southbridge ISA/LPC bridge", tag, owner, clock, "i6300esb_lpc", __FILE__),
- acpi(*this, "acpi"),
- rtc (*this, "rtc"),
- pit (*this, "pit")
-{
-}
-
-void i6300esb_lpc_device::device_start()
-{
- pci_device::device_start();
-}
-
-void i6300esb_lpc_device::device_reset()
-{
- pci_device::device_reset();
- tco_cntl = 0x00;
- serirq_cntl = 0x10;
- memset(pirq_rout, 0x80, sizeof(pirq_rout));
- d31_err_cfg = 0x00;
- d31_err_sts = 0x00;
- pci_dma_cfg = 0x0000;
- func_dis = 0x0080;
- etr1 = 0x00000000;
- siu_config_port = 0;
- siu_config_state = 0;
- gen_pmcon_1 = 0;
- gen_pmcon_2 = 0;
- gen_pmcon_3 = 0;
- rst_cnt2 = 0;
- apm_cnt = 0;
- apm_sts = 0;
- gpi_rout = 0;
- mon_fwd_en = 0;
- memset(mon_trp_rng, 0, sizeof(mon_trp_rng));
- mon_trp_msk = 0;
- nmi_sc = 0;
- gen_sta = 0x00;
-}
-
-void i6300esb_lpc_device::reset_all_mappings()
-{
- pci_device::reset_all_mappings();
-
- pmbase = 0;
- acpi_cntl = 0;
- gpio_base = 0;
- gpio_cntl = 0x00;
- back_cntl = 0x0f;
- lpc_if_com_range = 0x00;
- lpc_if_fdd_lpt_range = 0x00;
- lpc_if_sound_range = 0x00;
- fwh_dec_en1 = 0xff;
- fwh_dec_en2 = 0x0f;
- gen1_dec = 0x0000;
- lpc_en = 0x0000;
- fwh_sel1 = 0x00112233;
- gen_cntl = 0x00000080;
- rtc_conf = 0x00;
-}
-
-READ32_MEMBER (i6300esb_lpc_device::pmbase_r)
-{
- return pmbase | 1;
-}
-
-WRITE32_MEMBER(i6300esb_lpc_device::pmbase_w)
-{
- COMBINE_DATA(&pmbase);
- pmbase &= 0x0000ff80;
- logerror("%s: pmbase = %08x\n", tag(), pmbase);
- remap_cb();
-}
-
-READ8_MEMBER (i6300esb_lpc_device::acpi_cntl_r)
-{
- return acpi_cntl;
-}
-
-WRITE8_MEMBER(i6300esb_lpc_device::acpi_cntl_w)
-{
- acpi_cntl = data;
- logerror("%s: acpi_cntl = %08x\n", tag(), acpi_cntl);
- remap_cb();
-}
-
-READ16_MEMBER (i6300esb_lpc_device::bios_cntl_r)
-{
- return pmbase | 1;
-}
-
-WRITE16_MEMBER(i6300esb_lpc_device::bios_cntl_w)
-{
- COMBINE_DATA(&bios_cntl);
- logerror("%s: bios_cntl = %08x\n", tag(), bios_cntl);
- remap_cb();
-}
-
-READ8_MEMBER (i6300esb_lpc_device::tco_cntl_r)
-{
- return tco_cntl;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::tco_cntl_w)
-{
- tco_cntl = data;
- logerror("%s: tco_cntl = %02x\n", tag(), tco_cntl);
-}
-
-READ32_MEMBER (i6300esb_lpc_device::gpio_base_r)
-{
- return gpio_base | 1;
-}
-
-WRITE32_MEMBER(i6300esb_lpc_device::gpio_base_w)
-{
- COMBINE_DATA(&gpio_base);
- gpio_base &= 0x0000ffc0;
- logerror("%s: gpio_base = %08x\n", tag(), gpio_base);
- remap_cb();
-}
-
-READ8_MEMBER (i6300esb_lpc_device::gpio_cntl_r)
-{
- return gpio_cntl;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::gpio_cntl_w)
-{
- gpio_cntl = data;
- logerror("%s: gpio_cntl = %02x\n", tag(), gpio_cntl);
- remap_cb();
-}
-
-READ8_MEMBER (i6300esb_lpc_device::pirq_rout_r)
-{
- return pirq_rout[offset];
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::pirq_rout_w)
-{
- pirq_rout[offset] = data;
- logerror("%s: pirq_rout[%d] = %02x\n", tag(), offset, pirq_rout[offset]);
-}
-
-READ8_MEMBER (i6300esb_lpc_device::serirq_cntl_r)
-{
- return serirq_cntl;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::serirq_cntl_w)
-{
- serirq_cntl = data;
- logerror("%s: serirq_cntl = %02x\n", tag(), serirq_cntl);
-}
-
-READ8_MEMBER (i6300esb_lpc_device::pirq2_rout_r)
-{
- return pirq_rout_r(space, offset+4);
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::pirq2_rout_w)
-{
- pirq_rout_w(space, offset+4, data);
-}
-
-READ8_MEMBER (i6300esb_lpc_device::d31_err_cfg_r)
-{
- return d31_err_cfg;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::d31_err_cfg_w)
-{
- d31_err_cfg = data;
- logerror("%s: d31_err_cfg = %02x\n", tag(), d31_err_cfg);
-}
-
-READ8_MEMBER (i6300esb_lpc_device::d31_err_sts_r)
-{
- return d31_err_sts;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::d31_err_sts_w)
-{
- d31_err_sts &= ~data;
- logerror("%s: d31_err_sts = %02x\n", tag(), d31_err_sts);
-}
-
-READ16_MEMBER (i6300esb_lpc_device::pci_dma_cfg_r)
-{
- return pci_dma_cfg;
-}
-
-WRITE16_MEMBER(i6300esb_lpc_device::pci_dma_cfg_w)
-{
- COMBINE_DATA(&pci_dma_cfg);
- logerror("%s: pci_dma_cfg = %04x\n", tag(), pci_dma_cfg);
-}
-
-READ16_MEMBER (i6300esb_lpc_device::gen_pmcon_1_r)
-{
- return gen_pmcon_1;
-}
-
-WRITE16_MEMBER(i6300esb_lpc_device::gen_pmcon_1_w)
-{
- COMBINE_DATA(&gen_pmcon_1);
- logerror("%s: gen_pmcon_1 = %04x\n", tag(), gen_pmcon_1);
-}
-
-READ8_MEMBER (i6300esb_lpc_device::gen_pmcon_2_r)
-{
- return gen_pmcon_2;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::gen_pmcon_2_w)
-{
- gen_pmcon_2 = data;
- logerror("%s: gen_pmcon_2 = %02x\n", tag(), gen_pmcon_2);
-}
-
-READ8_MEMBER (i6300esb_lpc_device::gen_pmcon_3_r)
-{
- return gen_pmcon_3;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::gen_pmcon_3_w)
-{
- gen_pmcon_3 = data;
- logerror("%s: gen_pmcon_3 = %02x\n", tag(), gen_pmcon_3);
-}
-
-READ32_MEMBER (i6300esb_lpc_device::rst_cnt2_r)
-{
- return rst_cnt2;
-}
-
-WRITE32_MEMBER(i6300esb_lpc_device::rst_cnt2_w)
-{
- COMBINE_DATA(&rst_cnt2);
- logerror("%s: rst_cnt2 = %08x\n", tag(), rst_cnt2);
-}
-
-READ8_MEMBER (i6300esb_lpc_device::apm_cnt_r)
-{
- return apm_cnt;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::apm_cnt_w)
-{
- apm_cnt = data;
- logerror("%s: apm_cnt = %02x\n", tag(), apm_cnt);
-}
-
-READ8_MEMBER (i6300esb_lpc_device::apm_sts_r)
-{
- return apm_sts;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::apm_sts_w)
-{
- apm_sts = data;
- logerror("%s: apm_sts = %02x\n", tag(), apm_sts);
-}
-
-READ32_MEMBER (i6300esb_lpc_device::gpi_rout_r)
-{
- return gpi_rout;
-}
-
-WRITE32_MEMBER(i6300esb_lpc_device::gpi_rout_w)
-{
- COMBINE_DATA(&gpi_rout);
- logerror("%s: gpi_rout = %08x\n", tag(), gpi_rout);
-}
-
-READ8_MEMBER (i6300esb_lpc_device::mon_fwd_en_r)
-{
- return mon_fwd_en;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::mon_fwd_en_w)
-{
- mon_fwd_en = data;
- logerror("%s: mon_fwd_en = %02x\n", tag(), mon_fwd_en);
-}
-
-READ16_MEMBER (i6300esb_lpc_device::mon_trp_rng_r)
-{
- return mon_trp_rng[offset];
-}
-
-WRITE16_MEMBER(i6300esb_lpc_device::mon_trp_rng_w)
-{
- COMBINE_DATA(&mon_trp_rng[offset]);
- logerror("%s: mon_trp_rng[%d] = %04x\n", tag(), 4+offset, mon_trp_rng[offset]);
-}
-
-READ16_MEMBER (i6300esb_lpc_device::mon_trp_msk_r)
-{
- return mon_trp_msk;
-}
-
-WRITE16_MEMBER(i6300esb_lpc_device::mon_trp_msk_w)
-{
- COMBINE_DATA(&mon_trp_msk);
- logerror("%s: mon_trp_msk = %04x\n", tag(), mon_trp_msk);
-}
-
-READ32_MEMBER (i6300esb_lpc_device::gen_cntl_r)
-{
- return gen_cntl;
-}
-
-WRITE32_MEMBER(i6300esb_lpc_device::gen_cntl_w)
-{
- COMBINE_DATA(&gen_cntl);
- logerror("%s: gen_cntl = %08x\n", tag(), gen_cntl);
-}
-
-READ8_MEMBER (i6300esb_lpc_device::gen_sta_r)
-{
- return gen_sta;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::gen_sta_w)
-{
- gen_sta = data;
- logerror("%s: gen_sta = %02x\n", tag(), gen_sta);
-}
-
-READ8_MEMBER (i6300esb_lpc_device::back_cntl_r)
-{
- return back_cntl;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::back_cntl_w)
-{
- back_cntl = data;
- logerror("%s: back_cntl = %02x\n", tag(), back_cntl);
- remap_cb();
-}
-
-READ8_MEMBER (i6300esb_lpc_device::rtc_conf_r)
-{
- return rtc_conf;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::rtc_conf_w)
-{
- rtc_conf = data;
- logerror("%s: rtc_conf = %02x\n", tag(), rtc_conf);
- remap_cb();
-}
-
-READ8_MEMBER (i6300esb_lpc_device::lpc_if_com_range_r)
-{
- return lpc_if_com_range;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::lpc_if_com_range_w)
-{
- lpc_if_com_range = data;
- logerror("%s: lpc_if_com_range = %02x\n", tag(), lpc_if_com_range);
- remap_cb();
-}
-
-READ8_MEMBER (i6300esb_lpc_device::lpc_if_fdd_lpt_range_r)
-{
- return lpc_if_fdd_lpt_range;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::lpc_if_fdd_lpt_range_w)
-{
- COMBINE_DATA(&lpc_if_fdd_lpt_range);
- logerror("%s: lpc_if_fdd_lpt_range = %02x\n", tag(), lpc_if_fdd_lpt_range);
- remap_cb();
-}
-
-READ8_MEMBER (i6300esb_lpc_device::lpc_if_sound_range_r)
-{
- return lpc_if_sound_range;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::lpc_if_sound_range_w)
-{
- COMBINE_DATA(&lpc_if_sound_range);
- logerror("%s: lpc_if_sound_range = %02x\n", tag(), lpc_if_sound_range);
- remap_cb();
-}
-
-READ8_MEMBER (i6300esb_lpc_device::fwh_dec_en1_r)
-{
- return fwh_dec_en1;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::fwh_dec_en1_w)
-{
- fwh_dec_en1 = data | 0x80;
- logerror("%s: fwh_dec_en1 = %02x\n", tag(), fwh_dec_en1);
- remap_cb();
-}
-
-READ16_MEMBER (i6300esb_lpc_device::gen1_dec_r)
-{
- return gen1_dec;
-}
-
-WRITE16_MEMBER(i6300esb_lpc_device::gen1_dec_w)
-{
- COMBINE_DATA(&gen1_dec);
- logerror("%s: gen1_dec = %04x\n", tag(), gen1_dec);
- remap_cb();
-}
-
-READ16_MEMBER (i6300esb_lpc_device::lpc_en_r)
-{
- return lpc_en;
-}
-
-WRITE16_MEMBER(i6300esb_lpc_device::lpc_en_w)
-{
- COMBINE_DATA(&lpc_en);
- logerror("%s: lpc_en = %04x\n", tag(), lpc_en);
- remap_cb();
-}
-
-READ32_MEMBER (i6300esb_lpc_device::fwh_sel1_r)
-{
- return fwh_sel1;
-}
-
-WRITE32_MEMBER(i6300esb_lpc_device::fwh_sel1_w)
-{
- COMBINE_DATA(&fwh_sel1);
- logerror("%s: fwh_sel1 = %08x\n", tag(), fwh_sel1);
- remap_cb();
-}
-
-READ16_MEMBER (i6300esb_lpc_device::gen2_dec_r)
-{
- return gen2_dec;
-}
-
-WRITE16_MEMBER(i6300esb_lpc_device::gen2_dec_w)
-{
- COMBINE_DATA(&gen2_dec);
- logerror("%s: gen2_dec = %04x\n", tag(), gen2_dec);
- remap_cb();
-}
-
-READ16_MEMBER (i6300esb_lpc_device::fwh_sel2_r)
-{
- return fwh_sel2;
-}
-
-WRITE16_MEMBER(i6300esb_lpc_device::fwh_sel2_w)
-{
- COMBINE_DATA(&fwh_sel2);
- logerror("%s: fwh_sel2 = %04x\n", tag(), fwh_sel2);
- remap_cb();
-}
-
-READ8_MEMBER (i6300esb_lpc_device::fwh_dec_en2_r)
-{
- return fwh_dec_en2;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::fwh_dec_en2_w)
-{
- fwh_dec_en2 = data;
- logerror("%s: fwh_dec_en2 = %02x\n", tag(), fwh_dec_en2);
- remap_cb();
-}
-
-READ16_MEMBER (i6300esb_lpc_device::func_dis_r)
-{
- return func_dis;
-}
-
-WRITE16_MEMBER(i6300esb_lpc_device::func_dis_w)
-{
- COMBINE_DATA(&func_dis);
- logerror("%s: func_dis = %04x\n", tag(), func_dis);
-}
-
-READ32_MEMBER (i6300esb_lpc_device::etr1_r)
-{
- return etr1;
-}
-
-WRITE32_MEMBER(i6300esb_lpc_device::etr1_w)
-{
- COMBINE_DATA(&etr1);
- logerror("%s: etr1 = %08x\n", tag(), etr1);
-}
-
-READ32_MEMBER (i6300esb_lpc_device::mfid_r)
-{
- return 0xf66;
-}
-
-READ32_MEMBER (i6300esb_lpc_device::unk_fc_r)
-{
- logerror("%s: read undocumented config reg fc\n", tag());
- return 0;
-}
-
-WRITE32_MEMBER(i6300esb_lpc_device::unk_fc_w)
-{
- logerror("%s: write undocumented config reg fc (%08x)\n", tag(), data);
-}
-
-
-
-READ8_MEMBER (i6300esb_lpc_device::siu_config_port_r)
-{
- return siu_config_port;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::siu_config_port_w)
-{
- siu_config_port = data;
- switch(siu_config_state) {
- case 0:
- siu_config_state = data == 0x80 ? 1 : 0;
- break;
- case 1:
- siu_config_state = data == 0x86 ? 2 : data == 0x80 ? 1 : 0;
- if(siu_config_state == 2)
- logerror("%s: siu configuration active\n", tag());
- break;
- case 2:
- siu_config_state = data == 0x68 ? 3 : 2;
- break;
- case 3:
- siu_config_state = data == 0x08 ? 0 : data == 0x68 ? 3 : 2;
- if(!siu_config_state)
- logerror("%s: siu configuration disabled\n", tag());
- break;
- }
-}
-
-READ8_MEMBER (i6300esb_lpc_device::siu_data_port_r)
-{
- logerror("%s: siu config read port %02x\n", tag(), siu_config_port);
- return 0xff;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::siu_data_port_w)
-{
- if(siu_config_state < 2) {
- logerror("%s: siu config write port with config disabled (port=%02x, data=%02x)\n", tag(), siu_config_port, data);
- return;
- }
- logerror("%s: siu config write port %02x, %02x\n", tag(), siu_config_port, data);
-}
-
-READ8_MEMBER (i6300esb_lpc_device::nmi_sc_r)
-{
- nmi_sc ^= 0x10;
- return nmi_sc;
-}
-
-WRITE8_MEMBER (i6300esb_lpc_device::nmi_sc_w)
-{
- nmi_sc = data;
- logerror("%s: nmi_sc = %02x\n", tag(), nmi_sc);
-}
-
-
-WRITE8_MEMBER (i6300esb_lpc_device::nop_w)
-{
-}
-
-void i6300esb_lpc_device::map_bios(address_space *memory_space, UINT32 start, UINT32 end, int idsel)
-{
- // Ignore idsel, a16 inversion for now
- UINT32 mask = m_region->bytes() - 1;
- memory_space->install_rom(start, end, m_region->base() + (start & mask));
-}
-
-void i6300esb_lpc_device::map_extra(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space)
-{
- if(fwh_dec_en1 & 0x80) {
- map_bios(memory_space, 0xfff80000, 0xffffffff, 7);
- map_bios(memory_space, 0xffb80000, 0xffbfffff, 7);
- map_bios(memory_space, 0x000e0000, 0x000fffff, 7);
- }
- if(fwh_dec_en1 & 0x40) {
- map_bios(memory_space, 0xfff00000, 0xfff7ffff, 6);
- map_bios(memory_space, 0xffb00000, 0xffb7ffff, 6);
- }
- if(fwh_dec_en1 & 0x20) {
- map_bios(memory_space, 0xffe80000, 0xffefffff, 5);
- map_bios(memory_space, 0xffa80000, 0xffafffff, 5);
- }
- if(fwh_dec_en1 & 0x10) {
- map_bios(memory_space, 0xffe00000, 0xffe7ffff, 4);
- map_bios(memory_space, 0xffa00000, 0xffa7ffff, 4);
- }
- if(fwh_dec_en1 & 0x08) {
- map_bios(memory_space, 0xffd80000, 0xffdfffff, 3);
- map_bios(memory_space, 0xff980000, 0xff9fffff, 3);
- }
- if(fwh_dec_en1 & 0x04) {
- map_bios(memory_space, 0xffd00000, 0xffd7ffff, 2);
- map_bios(memory_space, 0xff900000, 0xff97ffff, 2);
- }
- if(fwh_dec_en1 & 0x02) {
- map_bios(memory_space, 0xffc80000, 0xffcfffff, 1);
- map_bios(memory_space, 0xff880000, 0xff8fffff, 1);
- }
- if(fwh_dec_en1 & 0x01) {
- map_bios(memory_space, 0xffc00000, 0xffc7ffff, 0);
- map_bios(memory_space, 0xff800000, 0xff87ffff, 0);
- }
-
- io_space->install_device(0, 0xffff, *this, &i6300esb_lpc_device::internal_io_map);
-
- if(acpi_cntl & 0x10)
- acpi->map_device(memory_window_start, memory_window_end, 0, memory_space, io_window_start, io_window_end, pmbase, io_space);
- if(gpio_cntl & 0x10)
- logerror("%s: Warning: gpio range enabled at %04x-%04x\n", tag(), gpio_base, gpio_base+63);
-
- UINT32 hpet = 0xfed00000 + ((gen_cntl & 0x00018000) >> 3);
- logerror("%s: Warning: hpet at %08x-%08x\n", tag(), hpet, hpet+0x3ff);
-
- if(lpc_en & 0x1000)
- logerror("%s: Warning: superio at 2e-2f\n", tag());
- if(lpc_en & 0x0800)
- logerror("%s: Warning: mcu at 62/66\n", tag());
- if(lpc_en & 0x0400)
- logerror("%s: Warning: mcu at 60/64\n", tag());
- if(lpc_en & 0x0200)
- logerror("%s: Warning: gameport at 208-20f\n", tag());
- if(lpc_en & 0x0100)
- logerror("%s: Warning: gameport at 200-207\n", tag());
-
- if(lpc_en & 0x0008) {
- UINT16 fdc = lpc_if_fdd_lpt_range & 0x10 ? 0x370 : 0x3f0;
- logerror("%s: Warning: floppy at %04x-%04x\n", tag(), fdc, fdc+7);
- }
-
- if(lpc_en & 0x0004) {
- static const UINT16 lpt_pos[4] = { 0x378, 0x278, 0x3bc, 0x000 };
- UINT16 lpt = lpt_pos[lpc_if_fdd_lpt_range & 3];
- if(lpt)
- logerror("%s: Warning: lpt at %04x-%04x %04x-%04x\n", tag(), lpt, lpt+7, lpt+0x400, lpt+0x407);
- }
-
- static const UINT16 com_pos[8] = { 0x3f8, 0x2f8, 0x220, 0x228, 0x238, 0x2e8, 0x338, 0x3e8 };
-
- if(lpc_en & 0x0002) {
- UINT16 comb = com_pos[(lpc_if_com_range >> 4) & 7];
- logerror("%s: Warning: comb at %04x-%04x\n", tag(), comb, comb+7);
- }
-
- if(lpc_en & 0x0001) {
- UINT16 coma = com_pos[lpc_if_com_range & 7];
- logerror("%s: Warning: coma at %04x-%04x\n", tag(), coma, coma+7);
- }
-
- rtc->map_device(memory_window_start, memory_window_end, 0, memory_space, io_window_start, io_window_end, 0, io_space);
- if(rtc_conf & 4)
- rtc->map_extdevice(memory_window_start, memory_window_end, 0, memory_space, io_window_start, io_window_end, 0, io_space);
- pit->map_device(memory_window_start, memory_window_end, 0, memory_space, io_window_start, io_window_end, 0, io_space);
-}
diff --git a/src/emu/machine/i6300esb.h b/src/emu/machine/i6300esb.h
deleted file mode 100644
index 2349db91b73..00000000000
--- a/src/emu/machine/i6300esb.h
+++ /dev/null
@@ -1,160 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-// Intel i6300ESB southbridge
-
-#ifndef I6300ESB_H
-#define I6300ESB_H
-
-#include "pci.h"
-#include "lpc-acpi.h"
-#include "lpc-rtc.h"
-#include "lpc-pit.h"
-
-#define MCFG_I6300ESB_LPC_ADD(_tag) \
- MCFG_PCI_DEVICE_ADD(_tag, I6300ESB_LPC, 0x808625a1, 0x02, 0x060100, 0x00000000)
-
-#define MCFG_I6300ESB_WATCHDOG_ADD(_tag, _subdevice_id) \
- MCFG_PCI_DEVICE_ADD(_tag, I6300ESB_WATCHDOG, 0x808625ab, 0x02, 0x088000, _subdevice_id)
-
-class i6300esb_lpc_device : public pci_device {
-public:
- i6300esb_lpc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual void reset_all_mappings();
- virtual void map_extra(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space);
-
- virtual DECLARE_ADDRESS_MAP(config_map, 32);
-
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
-private:
- required_device<lpc_acpi_device> acpi;
- required_device<lpc_rtc_device> rtc;
- required_device<lpc_pit_device> pit;
-
- DECLARE_ADDRESS_MAP(internal_io_map, 32);
-
- UINT32 pmbase, gpio_base, fwh_sel1, gen_cntl, etr1, rst_cnt2, gpi_rout;
- UINT16 bios_cntl, pci_dma_cfg, gen1_dec, lpc_en, gen2_dec, fwh_sel2, func_dis, gen_pmcon_1;
- UINT16 mon_trp_rng[4], mon_trp_msk;
- UINT8 pirq_rout[8];
- UINT8 acpi_cntl, tco_cntl, gpio_cntl, serirq_cntl, d31_err_cfg, d31_err_sts, gen_sta, back_cntl, rtc_conf;
- UINT8 lpc_if_com_range, lpc_if_fdd_lpt_range, lpc_if_sound_range, fwh_dec_en1, fwh_dec_en2, siu_config_port;
- UINT8 gen_pmcon_2, gen_pmcon_3, apm_cnt, apm_sts, mon_fwd_en, nmi_sc;
- int siu_config_state;
-
- DECLARE_WRITE8_MEMBER (nop_w);
-
- // configuration space registers
- DECLARE_READ32_MEMBER (pmbase_r); // 40
- DECLARE_WRITE32_MEMBER(pmbase_w);
- DECLARE_READ8_MEMBER (acpi_cntl_r); // 44
- DECLARE_WRITE8_MEMBER (acpi_cntl_w);
- DECLARE_READ16_MEMBER (bios_cntl_r); // 4e
- DECLARE_WRITE16_MEMBER(bios_cntl_w);
- DECLARE_READ8_MEMBER (tco_cntl_r); // 54
- DECLARE_WRITE8_MEMBER (tco_cntl_w);
- DECLARE_READ32_MEMBER (gpio_base_r); // 58
- DECLARE_WRITE32_MEMBER(gpio_base_w);
- DECLARE_READ8_MEMBER (gpio_cntl_r); // 5c
- DECLARE_WRITE8_MEMBER (gpio_cntl_w);
- DECLARE_READ8_MEMBER (pirq_rout_r); // 60-63
- DECLARE_WRITE8_MEMBER (pirq_rout_w);
- DECLARE_READ8_MEMBER (serirq_cntl_r); // 64
- DECLARE_WRITE8_MEMBER (serirq_cntl_w);
- DECLARE_READ8_MEMBER (pirq2_rout_r); // 68-6b
- DECLARE_WRITE8_MEMBER (pirq2_rout_w);
- DECLARE_READ8_MEMBER (d31_err_cfg_r); // 88
- DECLARE_WRITE8_MEMBER (d31_err_cfg_w);
- DECLARE_READ8_MEMBER (d31_err_sts_r); // 8a
- DECLARE_WRITE8_MEMBER (d31_err_sts_w);
- DECLARE_READ16_MEMBER (pci_dma_cfg_r); // 90
- DECLARE_WRITE16_MEMBER(pci_dma_cfg_w);
- DECLARE_READ16_MEMBER (gen_pmcon_1_r); // a0
- DECLARE_WRITE16_MEMBER(gen_pmcon_1_w);
- DECLARE_READ8_MEMBER (gen_pmcon_2_r); // a2
- DECLARE_WRITE8_MEMBER(gen_pmcon_2_w);
- DECLARE_READ8_MEMBER (gen_pmcon_3_r); // a4
- DECLARE_WRITE8_MEMBER (gen_pmcon_3_w);
- DECLARE_READ32_MEMBER (rst_cnt2_r); // ac
- DECLARE_WRITE32_MEMBER(rst_cnt2_w);
- DECLARE_READ8_MEMBER (apm_cnt_r); // b2
- DECLARE_WRITE8_MEMBER (apm_cnt_w);
- DECLARE_READ8_MEMBER (apm_sts_r); // b3
- DECLARE_WRITE8_MEMBER (apm_sts_w);
- DECLARE_READ32_MEMBER (gpi_rout_r); // b8
- DECLARE_WRITE32_MEMBER(gpi_rout_w);
- DECLARE_READ8_MEMBER (mon_fwd_en_r); // c0
- DECLARE_WRITE8_MEMBER (mon_fwd_en_w);
- DECLARE_READ16_MEMBER (mon_trp_rng_r); // c4-ca
- DECLARE_WRITE16_MEMBER(mon_trp_rng_w);
- DECLARE_READ16_MEMBER (mon_trp_msk_r); // cc
- DECLARE_WRITE16_MEMBER(mon_trp_msk_w);
- DECLARE_READ32_MEMBER (gen_cntl_r); // d0
- DECLARE_WRITE32_MEMBER(gen_cntl_w);
- DECLARE_READ8_MEMBER (gen_sta_r); // d4
- DECLARE_WRITE8_MEMBER (gen_sta_w);
- DECLARE_READ8_MEMBER (back_cntl_r); // d5
- DECLARE_WRITE8_MEMBER (back_cntl_w);
- DECLARE_READ8_MEMBER (rtc_conf_r); // d8
- DECLARE_WRITE8_MEMBER (rtc_conf_w);
- DECLARE_READ8_MEMBER (lpc_if_com_range_r); // e0
- DECLARE_WRITE8_MEMBER (lpc_if_com_range_w);
- DECLARE_READ8_MEMBER (lpc_if_fdd_lpt_range_r); // e1
- DECLARE_WRITE8_MEMBER (lpc_if_fdd_lpt_range_w);
- DECLARE_READ8_MEMBER (lpc_if_sound_range_r); // e2
- DECLARE_WRITE8_MEMBER (lpc_if_sound_range_w);
- DECLARE_READ8_MEMBER (fwh_dec_en1_r); // e3
- DECLARE_WRITE8_MEMBER (fwh_dec_en1_w);
- DECLARE_READ16_MEMBER (gen1_dec_r); // e4
- DECLARE_WRITE16_MEMBER(gen1_dec_w);
- DECLARE_READ16_MEMBER (lpc_en_r); // e6
- DECLARE_WRITE16_MEMBER(lpc_en_w);
- DECLARE_READ32_MEMBER (fwh_sel1_r); // e8
- DECLARE_WRITE32_MEMBER(fwh_sel1_w);
- DECLARE_READ16_MEMBER (gen2_dec_r); // ec
- DECLARE_WRITE16_MEMBER(gen2_dec_w);
- DECLARE_READ16_MEMBER (fwh_sel2_r); // ee
- DECLARE_WRITE16_MEMBER(fwh_sel2_w);
- DECLARE_READ8_MEMBER (fwh_dec_en2_r); // f0
- DECLARE_WRITE8_MEMBER (fwh_dec_en2_w);
- DECLARE_READ16_MEMBER (func_dis_r); // f2
- DECLARE_WRITE16_MEMBER(func_dis_w);
- DECLARE_READ32_MEMBER (etr1_r); // f4
- DECLARE_WRITE32_MEMBER(etr1_w);
- DECLARE_READ32_MEMBER (mfid_r); // f8
- DECLARE_READ32_MEMBER (unk_fc_r); // fc
- DECLARE_WRITE32_MEMBER(unk_fc_w);
-
-
- // i/o space registers
- DECLARE_READ8_MEMBER (siu_config_port_r); // 4e
- DECLARE_WRITE8_MEMBER (siu_config_port_w);
- DECLARE_READ8_MEMBER (siu_data_port_r); // 4f
- DECLARE_WRITE8_MEMBER (siu_data_port_w);
- DECLARE_READ8_MEMBER (nmi_sc_r); // 61
- DECLARE_WRITE8_MEMBER (nmi_sc_w);
-
- void map_bios(address_space *memory_space, UINT32 start, UINT32 end, int idsel);
-};
-
-class i6300esb_watchdog_device : public pci_device {
-public:
- i6300esb_watchdog_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
-private:
- DECLARE_ADDRESS_MAP(map, 32);
-};
-
-extern const device_type I6300ESB_LPC;
-extern const device_type I6300ESB_WATCHDOG;
-
-#endif
diff --git a/src/emu/machine/i80130.c b/src/emu/machine/i80130.c
deleted file mode 100644
index fb419a06090..00000000000
--- a/src/emu/machine/i80130.c
+++ /dev/null
@@ -1,173 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Intel 80130 iRMX Operating System Processor emulation
-
-**********************************************************************/
-
-#include "i80130.h"
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-// device type definition
-const device_type I80130 = &device_creator<i80130_device>;
-
-
-DEVICE_ADDRESS_MAP_START( rom_map, 16, i80130_device )
- //AM_RANGE(0x0000, 0x3fff) AM_ROM AM_REGION("rom", 0)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START( io_map, 16, i80130_device )
- AM_RANGE(0x00, 0x0f) AM_READWRITE(io_r, io_w)
- //AM_RANGE(0x00, 0x01) AM_MIRROR(0x2) AM_DEVREADWRITE8("pic", pic8259_device, read, write, 0x00ff)
- //AM_RANGE(0x08, 0x0f) AM_DEVREADWRITE8("pit", pit8254_device, read, write, 0x00ff)
-ADDRESS_MAP_END
-
-READ16_MEMBER( i80130_device::io_r )
-{
- UINT16 data = 0;
-
- switch (offset)
- {
- case 0: case 1:
- if (ACCESSING_BITS_0_7)
- {
- data = m_pic->read(space, offset & 0x01);
- }
- break;
-
- case 4: case 5: case 6: case 7:
- if (ACCESSING_BITS_0_7)
- {
- data = m_pit->read(space, offset & 0x03);
- }
- break;
- }
-
- return data;
-}
-
-WRITE16_MEMBER( i80130_device::io_w )
-{
- switch (offset)
- {
- case 0: case 1:
- if (ACCESSING_BITS_0_7)
- {
- m_pic->write(space, offset & 0x01, data & 0xff);
- }
- break;
-
- case 4: case 5: case 6: case 7:
- if (ACCESSING_BITS_0_7)
- {
- m_pit->write(space, offset & 0x03, data & 0xff);
- }
- break;
- }
-}
-
-
-//-------------------------------------------------
-// ROM( i80130 )
-//-------------------------------------------------
-
-ROM_START( i80130 )
- ROM_REGION16_LE( 0x4000, "rom", 0 )
- ROM_LOAD( "80130", 0x0000, 0x4000, NO_DUMP )
-ROM_END
-
-
-//-------------------------------------------------
-// rom_region - device-specific ROM region
-//-------------------------------------------------
-
-const rom_entry *i80130_device::device_rom_region() const
-{
- return ROM_NAME( i80130 );
-}
-
-
-//-------------------------------------------------
-// MACHINE_CONFIG_FRAGMENT( i80130 )
-//-------------------------------------------------
-
-static MACHINE_CONFIG_FRAGMENT( i80130 )
- MCFG_PIC8259_ADD("pic", DEVWRITELINE(DEVICE_SELF, i80130_device, irq_w), VCC, NULL)
-
- MCFG_DEVICE_ADD("pit", PIT8254, 0)
- MCFG_PIT8253_CLK0(0)
- MCFG_PIT8253_OUT0_HANDLER(WRITELINE(i80130_device, systick_w))
- MCFG_PIT8253_CLK1(0)
- MCFG_PIT8253_OUT1_HANDLER(WRITELINE(i80130_device, delay_w))
- MCFG_PIT8253_CLK2(0)
- MCFG_PIT8253_OUT2_HANDLER(WRITELINE(i80130_device, baud_w))
-MACHINE_CONFIG_END
-
-
-//-------------------------------------------------
-// machine_config_additions - device-specific
-// machine configurations
-//-------------------------------------------------
-
-machine_config_constructor i80130_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( i80130 );
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// i80130_device - constructor
-//-------------------------------------------------
-
-i80130_device::i80130_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, I80130, "I80130", tag, owner, clock, "i80130", __FILE__),
- m_pic(*this, "pic"),
- m_pit(*this, "pit"),
- m_write_irq(*this),
- m_write_ack(*this),
- m_write_lir(*this),
- m_write_systick(*this),
- m_write_delay(*this),
- m_write_baud(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void i80130_device::device_start()
-{
- // resolve callbacks
- m_write_irq.resolve_safe();
- m_write_ack.resolve_safe();
- m_write_lir.resolve_safe();
- m_write_systick.resolve_safe();
- m_write_delay.resolve_safe();
- m_write_baud.resolve_safe();
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void i80130_device::device_reset()
-{
- // set PIT clocks
- m_pit->set_clockin(0, clock());
- m_pit->set_clockin(1, clock());
- m_pit->set_clockin(2, clock());
-}
diff --git a/src/emu/machine/i80130.h b/src/emu/machine/i80130.h
deleted file mode 100644
index b7aaece8fe7..00000000000
--- a/src/emu/machine/i80130.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Intel 80130 iRMX Operating System Processor emulation
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __I80130__
-#define __I80130__
-
-#include "emu.h"
-#include "machine/pic8259.h"
-#include "machine/pit8253.h"
-
-
-
-///*************************************************************************
-// INTERFACE CONFIGURATION MACROS
-///*************************************************************************
-
-#define MCFG_I80130_IRQ_CALLBACK(_write) \
- devcb = &i80130_device::set_irq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_I80130_ACK_CALLBACK(_write) \
- devcb = &i80130_device::set_ack_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_I80130_LIR_CALLBACK(_write) \
- devcb = &i80130_device::set_lir_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_I80130_SYSTICK_CALLBACK(_write) \
- devcb = &i80130_device::set_systick_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_I80130_DELAY_CALLBACK(_write) \
- devcb = &i80130_device::set_delay_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_I80130_BAUD_CALLBACK(_write) \
- devcb = &i80130_device::set_baud_wr_callback(*device, DEVCB_##_write);
-
-
-
-///*************************************************************************
-// TYPE DEFINITIONS
-///*************************************************************************
-
-// ======================> i80130_device
-
-class i80130_device : public device_t
-{
-public:
- // construction/destruction
- i80130_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<i80130_device &>(device).m_write_irq.set_callback(object); }
- template<class _Object> static devcb_base &set_ack_wr_callback(device_t &device, _Object object) { return downcast<i80130_device &>(device).m_write_ack.set_callback(object); }
- template<class _Object> static devcb_base &set_lir_wr_callback(device_t &device, _Object object) { return downcast<i80130_device &>(device).m_write_lir.set_callback(object); }
- template<class _Object> static devcb_base &set_systick_wr_callback(device_t &device, _Object object) { return downcast<i80130_device &>(device).m_write_systick.set_callback(object); }
- template<class _Object> static devcb_base &set_delay_wr_callback(device_t &device, _Object object) { return downcast<i80130_device &>(device).m_write_delay.set_callback(object); }
- template<class _Object> static devcb_base &set_baud_wr_callback(device_t &device, _Object object) { return downcast<i80130_device &>(device).m_write_baud.set_callback(object); }
-
- virtual DECLARE_ADDRESS_MAP(rom_map, 16);
- virtual DECLARE_ADDRESS_MAP(io_map, 16);
-
- // optional information overrides
- virtual const rom_entry *device_rom_region() const;
- virtual machine_config_constructor device_mconfig_additions() const;
-
- UINT8 inta_r() { return m_pic->acknowledge(); }
-
- DECLARE_WRITE_LINE_MEMBER( ir0_w ) { m_pic->ir0_w(state); }
- DECLARE_WRITE_LINE_MEMBER( ir1_w ) { m_pic->ir1_w(state); }
- DECLARE_WRITE_LINE_MEMBER( ir2_w ) { m_pic->ir2_w(state); }
- DECLARE_WRITE_LINE_MEMBER( ir3_w ) { m_pic->ir3_w(state); }
- DECLARE_WRITE_LINE_MEMBER( ir4_w ) { m_pic->ir4_w(state); }
- DECLARE_WRITE_LINE_MEMBER( ir5_w ) { m_pic->ir5_w(state); }
- DECLARE_WRITE_LINE_MEMBER( ir6_w ) { m_pic->ir6_w(state); }
- DECLARE_WRITE_LINE_MEMBER( ir7_w ) { m_pic->ir7_w(state); }
-
- DECLARE_WRITE_LINE_MEMBER( irq_w ) { m_write_irq(state); }
- DECLARE_WRITE_LINE_MEMBER( systick_w ) { m_write_systick(state); }
- DECLARE_WRITE_LINE_MEMBER( delay_w ) { m_write_delay(state); }
- DECLARE_WRITE_LINE_MEMBER( baud_w ) { m_write_baud(state); }
-
- DECLARE_READ16_MEMBER( io_r );
- DECLARE_WRITE16_MEMBER( io_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- required_device<pic8259_device> m_pic;
- required_device<pit8254_device> m_pit;
-
- devcb_write_line m_write_irq;
- devcb_write_line m_write_ack;
- devcb_write_line m_write_lir;
- devcb_write_line m_write_systick;
- devcb_write_line m_write_delay;
- devcb_write_line m_write_baud;
-};
-
-
-// device type definition
-extern const device_type I80130;
-
-
-
-#endif
diff --git a/src/emu/machine/i8155.c b/src/emu/machine/i8155.c
deleted file mode 100644
index a2914b9081f..00000000000
--- a/src/emu/machine/i8155.c
+++ /dev/null
@@ -1,593 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Intel 8155/8156 - 2048-Bit Static MOS RAM with I/O Ports and Timer emulation
-
-**********************************************************************/
-
-/*
-
- TODO:
-
- - strobed mode
-
-*/
-
-#include "emu.h"
-#include "i8155.h"
-
-
-// device type definitions
-const device_type I8155 = &device_creator<i8155_device>;
-const device_type I8156 = &device_creator<i8155_device>;
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-enum
-{
- REGISTER_COMMAND = 0,
- REGISTER_STATUS = 0,
- REGISTER_PORT_A,
- REGISTER_PORT_B,
- REGISTER_PORT_C,
- REGISTER_TIMER_LOW,
- REGISTER_TIMER_HIGH
-};
-
-enum
-{
- PORT_A = 0,
- PORT_B,
- PORT_C,
- PORT_COUNT
-};
-
-enum
-{
- PORT_MODE_INPUT = 0,
- PORT_MODE_OUTPUT,
- PORT_MODE_STROBED_PORT_A, // not supported
- PORT_MODE_STROBED // not supported
-};
-
-enum
-{
- MEMORY = 0,
- IO
-};
-
-#define COMMAND_PA 0x01
-#define COMMAND_PB 0x02
-#define COMMAND_PC_MASK 0x0c
-#define COMMAND_PC_ALT_1 0x00
-#define COMMAND_PC_ALT_2 0x0c
-#define COMMAND_PC_ALT_3 0x04 // not supported
-#define COMMAND_PC_ALT_4 0x08 // not supported
-#define COMMAND_IEA 0x10 // not supported
-#define COMMAND_IEB 0x20 // not supported
-#define COMMAND_TM_MASK 0xc0
-#define COMMAND_TM_NOP 0x00
-#define COMMAND_TM_STOP 0x40
-#define COMMAND_TM_STOP_AFTER_TC 0x80
-#define COMMAND_TM_START 0xc0
-
-#define STATUS_INTR_A 0x01 // not supported
-#define STATUS_A_BF 0x02 // not supported
-#define STATUS_INTE_A 0x04 // not supported
-#define STATUS_INTR_B 0x08 // not supported
-#define STATUS_B_BF 0x10 // not supported
-#define STATUS_INTE_B 0x20 // not supported
-#define STATUS_TIMER 0x40
-
-#define TIMER_MODE_MASK 0xc0
-#define TIMER_MODE_LOW 0x00
-#define TIMER_MODE_SQUARE_WAVE 0x40
-#define TIMER_MODE_SINGLE_PULSE 0x80
-#define TIMER_MODE_AUTOMATIC_RELOAD 0xc0
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// default address map
-static ADDRESS_MAP_START( i8155, AS_0, 8, i8155_device )
- AM_RANGE(0x00, 0xff) AM_RAM
-ADDRESS_MAP_END
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-inline UINT8 i8155_device::get_timer_mode()
-{
- return (m_count_length >> 8) & TIMER_MODE_MASK;
-}
-
-inline void i8155_device::timer_output()
-{
- m_out_to_cb(m_to);
-
- if (LOG) logerror("8155 '%s' Timer Output: %u\n", tag(), m_to);
-}
-
-inline void i8155_device::pulse_timer_output()
-{
- m_to = 0; timer_output();
- m_to = 1; timer_output();
-}
-
-inline int i8155_device::get_port_mode(int port)
-{
- int mode = -1;
-
- switch (port)
- {
- case PORT_A:
- mode = (m_command & COMMAND_PA) ? PORT_MODE_OUTPUT : PORT_MODE_INPUT;
- break;
-
- case PORT_B:
- mode = (m_command & COMMAND_PB) ? PORT_MODE_OUTPUT : PORT_MODE_INPUT;
- break;
-
- case PORT_C:
- switch (m_command & COMMAND_PC_MASK)
- {
- case COMMAND_PC_ALT_1: mode = PORT_MODE_INPUT; break;
- case COMMAND_PC_ALT_2: mode = PORT_MODE_OUTPUT; break;
- case COMMAND_PC_ALT_3: mode = PORT_MODE_STROBED_PORT_A; break;
- case COMMAND_PC_ALT_4: mode = PORT_MODE_STROBED; break;
- }
- break;
- }
-
- return mode;
-}
-
-inline UINT8 i8155_device::read_port(int port)
-{
- UINT8 data = 0;
-
- switch (get_port_mode(port))
- {
- case PORT_MODE_INPUT:
- data = (port == PORT_A) ? m_in_pa_cb(0) : ((port == PORT_B) ? m_in_pb_cb(0) : m_in_pc_cb(0));
- break;
-
- case PORT_MODE_OUTPUT:
- data = m_output[port];
- break;
-
- default:
- // strobed mode not implemented yet
- logerror("8155 '%s' Unsupported Port C mode!\n", tag());
- break;
- }
-
- return data;
-}
-
-inline void i8155_device::write_port(int port, UINT8 data)
-{
- switch (get_port_mode(port))
- {
- case PORT_MODE_OUTPUT:
- m_output[port] = data;
- if (port == PORT_A)
- m_out_pa_cb((offs_t)0, m_output[port]);
- else if (port == PORT_B)
- m_out_pb_cb((offs_t)0, m_output[port]);
- else
- m_out_pc_cb((offs_t)0, m_output[port]);
- break;
- }
-}
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// i8155_device - constructor
-//-------------------------------------------------
-
-i8155_device::i8155_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, I8155, "8155 RIOT", tag, owner, clock, "i8155", __FILE__),
- device_memory_interface(mconfig, *this),
- m_in_pa_cb(*this),
- m_in_pb_cb(*this),
- m_in_pc_cb(*this),
- m_out_pa_cb(*this),
- m_out_pb_cb(*this),
- m_out_pc_cb(*this),
- m_out_to_cb(*this),
- m_command(0),
- m_status(0),
- m_space_config("ram", ENDIANNESS_LITTLE, 8, 8, 0, NULL, *ADDRESS_MAP_NAME(i8155))
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void i8155_device::device_start()
-{
- // resolve callbacks
- m_in_pa_cb.resolve_safe(0);
- m_in_pb_cb.resolve_safe(0);
- m_in_pc_cb.resolve_safe(0);
- m_out_pa_cb.resolve_safe();
- m_out_pb_cb.resolve_safe();
- m_out_pc_cb.resolve_safe();
- m_out_to_cb.resolve_safe();
-
- // allocate timers
- m_timer = timer_alloc();
-
- // register for state saving
- save_item(NAME(m_io_m));
- save_item(NAME(m_ad));
- save_item(NAME(m_command));
- save_item(NAME(m_status));
- save_item(NAME(m_output));
- save_item(NAME(m_count_length));
- save_item(NAME(m_counter));
- save_item(NAME(m_to));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void i8155_device::device_reset()
-{
- // clear output registers
- m_output[PORT_A] = 0;
- m_output[PORT_B] = 0;
- m_output[PORT_C] = 0;
-
- // set ports to input mode
- register_w(REGISTER_COMMAND, m_command & ~(COMMAND_PA | COMMAND_PB | COMMAND_PC_MASK));
-
- // clear timer flag
- m_status &= ~STATUS_TIMER;
-
- // stop counting
- m_timer->enable(0);
-
- // clear timer output
- m_to = 1;
- timer_output();
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void i8155_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- // count down
- m_counter--;
-
- if (get_timer_mode() == TIMER_MODE_LOW)
- {
- // pulse on every count
- pulse_timer_output();
- }
-
- if (m_counter == 0)
- {
- if (LOG) logerror("8155 '%s' Timer Count Reached\n", tag());
-
- switch (m_command & COMMAND_TM_MASK)
- {
- case COMMAND_TM_STOP_AFTER_TC:
- // stop timer
- m_timer->enable(0);
-
- if (LOG) logerror("8155 '%s' Timer Stopped\n", tag());
- break;
- }
-
- switch (get_timer_mode())
- {
- case TIMER_MODE_SQUARE_WAVE:
- // toggle timer output
- m_to = !m_to;
- timer_output();
- break;
-
- case TIMER_MODE_SINGLE_PULSE:
- // single pulse upon TC being reached
- pulse_timer_output();
-
- // clear timer mode setting
- m_command &= ~COMMAND_TM_MASK;
- break;
-
- case TIMER_MODE_AUTOMATIC_RELOAD:
- // automatic reload, i.e. single pulse every time TC is reached
- pulse_timer_output();
- break;
- }
-
- // set timer flag
- m_status |= STATUS_TIMER;
-
- // reload timer counter
- m_counter = m_count_length & 0x3fff;
- }
-}
-
-
-//-------------------------------------------------
-// memory_space_config - return a description of
-// any address spaces owned by this device
-//-------------------------------------------------
-
-const address_space_config *i8155_device::memory_space_config(address_spacenum spacenum) const
-{
- return (spacenum == AS_0) ? &m_space_config : NULL;
-}
-
-
-//-------------------------------------------------
-// io_r - register read
-//-------------------------------------------------
-
-READ8_MEMBER( i8155_device::io_r )
-{
- UINT8 data = 0;
-
- switch (offset & 0x07)
- {
- case REGISTER_STATUS:
- data = m_status;
-
- // clear timer flag
- m_status &= ~STATUS_TIMER;
- break;
-
- case REGISTER_PORT_A:
- data = read_port(PORT_A);
- break;
-
- case REGISTER_PORT_B:
- data = read_port(PORT_B);
- break;
-
- case REGISTER_PORT_C:
- data = read_port(PORT_C) | 0xc0;
- break;
-
- case REGISTER_TIMER_LOW:
- data = m_counter & 0xff;
- break;
-
- case REGISTER_TIMER_HIGH:
- data = (m_counter >> 8 & 0x3f) | get_timer_mode();
- break;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// register_w - register write
-//-------------------------------------------------
-
-void i8155_device::register_w(int offset, UINT8 data)
-{
- switch (offset & 0x07)
- {
- case REGISTER_COMMAND:
- m_command = data;
-
- if (LOG) logerror("8155 '%s' Port A Mode: %s\n", tag(), (data & COMMAND_PA) ? "output" : "input");
- if (LOG) logerror("8155 '%s' Port B Mode: %s\n", tag(), (data & COMMAND_PB) ? "output" : "input");
-
- if (LOG) logerror("8155 '%s' Port A Interrupt: %s\n", tag(), (data & COMMAND_IEA) ? "enabled" : "disabled");
- if (LOG) logerror("8155 '%s' Port B Interrupt: %s\n", tag(), (data & COMMAND_IEB) ? "enabled" : "disabled");
-
- switch (data & COMMAND_PC_MASK)
- {
- case COMMAND_PC_ALT_1:
- if (LOG) logerror("8155 '%s' Port C Mode: Alt 1\n", tag());
- break;
-
- case COMMAND_PC_ALT_2:
- if (LOG) logerror("8155 '%s' Port C Mode: Alt 2\n", tag());
- break;
-
- case COMMAND_PC_ALT_3:
- if (LOG) logerror("8155 '%s' Port C Mode: Alt 3\n", tag());
- break;
-
- case COMMAND_PC_ALT_4:
- if (LOG) logerror("8155 '%s' Port C Mode: Alt 4\n", tag());
- break;
- }
-
- switch (data & COMMAND_TM_MASK)
- {
- case COMMAND_TM_NOP:
- // do not affect counter operation
- break;
-
- case COMMAND_TM_STOP:
- // NOP if timer has not started, stop counting if the timer is running
- if (LOG) logerror("8155 '%s' Timer Command: Stop\n", tag());
- m_to = 1;
- timer_output();
- m_timer->enable(0);
- break;
-
- case COMMAND_TM_STOP_AFTER_TC:
- // stop immediately after present TC is reached (NOP if timer has not started)
- if (LOG) logerror("8155 '%s' Timer Command: Stop after TC\n", tag());
- break;
-
- case COMMAND_TM_START:
- if (LOG) logerror("8155 '%s' Timer Command: Start\n", tag());
-
- if (m_timer->enabled())
- {
- // if timer is running, start the new mode and CNT length immediately after present TC is reached
- }
- else
- {
- // load mode and CNT length and start immediately after loading (if timer is not running)
- m_counter = m_count_length & 0x3fff;
- m_timer->adjust(attotime::zero, 0, attotime::from_hz(clock()));
- }
- break;
- }
- break;
-
- case REGISTER_PORT_A:
- write_port(PORT_A, data);
- break;
-
- case REGISTER_PORT_B:
- write_port(PORT_B, data);
- break;
-
- case REGISTER_PORT_C:
- write_port(PORT_C, data & 0x3f);
- break;
-
- case REGISTER_TIMER_LOW:
- m_count_length = (m_count_length & 0xff00) | data;
- if (LOG) logerror("8155 '%s' Count Length Low: %04x\n", tag(), m_count_length);
- break;
-
- case REGISTER_TIMER_HIGH:
- m_count_length = (data << 8) | (m_count_length & 0xff);
- if (LOG) logerror("8155 '%s' Count Length High: %04x\n", tag(), m_count_length);
-
- switch (data & TIMER_MODE_MASK)
- {
- case TIMER_MODE_LOW:
- // puts out LOW during second half of count
- if (LOG) logerror("8155 '%s' Timer Mode: LOW\n", tag());
- break;
-
- case TIMER_MODE_SQUARE_WAVE:
- // square wave, i.e. the period of the square wave equals the count length programmed with automatic reload at terminal count
- if (LOG) logerror("8155 '%s' Timer Mode: Square wave\n", tag());
- break;
-
- case TIMER_MODE_SINGLE_PULSE:
- // single pulse upon TC being reached
- if (LOG) logerror("8155 '%s' Timer Mode: Single pulse\n", tag());
- break;
-
- case TIMER_MODE_AUTOMATIC_RELOAD:
- // automatic reload, i.e. single pulse every time TC is reached
- if (LOG) logerror("8155 '%s' Timer Mode: Automatic reload\n", tag());
- break;
- }
- break;
- }
-}
-
-//-------------------------------------------------
-// io_w - register write
-//-------------------------------------------------
-
-WRITE8_MEMBER( i8155_device::io_w )
-{
- register_w(offset, data);
-}
-
-
-//-------------------------------------------------
-// memory_r - internal RAM read
-//-------------------------------------------------
-
-READ8_MEMBER( i8155_device::memory_r )
-{
- return this->space().read_byte(offset);
-}
-
-
-//-------------------------------------------------
-// memory_w - internal RAM write
-//-------------------------------------------------
-
-WRITE8_MEMBER( i8155_device::memory_w )
-{
- this->space().write_byte(offset, data);
-}
-
-
-//-------------------------------------------------
-// ale_w - address latch write
-//-------------------------------------------------
-
-WRITE8_MEMBER( i8155_device::ale_w )
-{
- // I/O / memory select
- m_io_m = BIT(offset, 0);
-
- // address
- m_ad = data;
-}
-
-
-//-------------------------------------------------
-// read - memory or I/O read
-//-------------------------------------------------
-
-READ8_MEMBER( i8155_device::read )
-{
- UINT8 data = 0;
-
- switch (m_io_m)
- {
- case MEMORY:
- data = memory_r(space, m_ad);
- break;
-
- case IO:
- data = io_r(space, m_ad);
- break;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write - memory or I/O write
-//-------------------------------------------------
-
-WRITE8_MEMBER( i8155_device::write )
-{
- switch (m_io_m)
- {
- case MEMORY:
- memory_w(space, m_ad, data);
- break;
-
- case IO:
- io_w(space, m_ad, data);
- break;
- }
-}
diff --git a/src/emu/machine/i8155.h b/src/emu/machine/i8155.h
deleted file mode 100644
index c85c0a62846..00000000000
--- a/src/emu/machine/i8155.h
+++ /dev/null
@@ -1,153 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Intel 8155/8156 - 2048-Bit Static MOS RAM with I/O Ports and Timer emulation
- 8156 is the same as 8155, except that chip enable is active high instead of low
-
-**********************************************************************
- _____ _____
- PC3 1 |* \_/ | 40 Vcc
- PC4 2 | | 39 PC2
- TIMER IN 3 | | 38 PC1
- RESET 4 | | 37 PC0
- PC5 5 | | 36 PB7
- _TIMER OUT 6 | | 35 PB6
- IO/_M 7 | | 34 PB5
- CE or _CE 8 | | 33 PB4
- _RD 9 | | 32 PB3
- _WR 10 | 8155 | 31 PB2
- ALE 11 | 8156 | 30 PB1
- AD0 12 | | 29 PB0
- AD1 13 | | 28 PA7
- AD2 14 | | 27 PA6
- AD3 15 | | 26 PA5
- AD4 16 | | 25 PA4
- AD5 17 | | 24 PA3
- AD6 18 | | 23 PA2
- AD7 19 | | 22 PA1
- Vss 20 |_____________| 21 PA0
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __I8155__
-#define __I8155__
-
-#include "emu.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_I8155_IN_PORTA_CB(_devcb) \
- devcb = &i8155_device::set_in_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8155_IN_PORTB_CB(_devcb) \
- devcb = &i8155_device::set_in_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8155_IN_PORTC_CB(_devcb) \
- devcb = &i8155_device::set_in_pc_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8155_OUT_PORTA_CB(_devcb) \
- devcb = &i8155_device::set_out_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8155_OUT_PORTB_CB(_devcb) \
- devcb = &i8155_device::set_out_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8155_OUT_PORTC_CB(_devcb) \
- devcb = &i8155_device::set_out_pc_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8155_OUT_TIMEROUT_CB(_devcb) \
- devcb = &i8155_device::set_out_to_callback(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> i8155_device
-
-class i8155_device : public device_t,
- public device_memory_interface
-{
-public:
- // construction/destruction
- i8155_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_in_pa_callback(device_t &device, _Object object) { return downcast<i8155_device &>(device).m_in_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_pb_callback(device_t &device, _Object object) { return downcast<i8155_device &>(device).m_in_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_pc_callback(device_t &device, _Object object) { return downcast<i8155_device &>(device).m_in_pc_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pa_callback(device_t &device, _Object object) { return downcast<i8155_device &>(device).m_out_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pb_callback(device_t &device, _Object object) { return downcast<i8155_device &>(device).m_out_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pc_callback(device_t &device, _Object object) { return downcast<i8155_device &>(device).m_out_pc_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_to_callback(device_t &device, _Object object) { return downcast<i8155_device &>(device).m_out_to_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( io_r );
- DECLARE_WRITE8_MEMBER( io_w );
-
- DECLARE_READ8_MEMBER( memory_r );
- DECLARE_WRITE8_MEMBER( memory_w );
-
- DECLARE_WRITE8_MEMBER( ale_w );
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
-
- inline UINT8 get_timer_mode();
- inline void timer_output();
- inline void pulse_timer_output();
- inline int get_port_mode(int port);
- inline UINT8 read_port(int port);
- inline void write_port(int port, UINT8 data);
-
- void register_w(int offset, UINT8 data);
-
-private:
- devcb_read8 m_in_pa_cb;
- devcb_read8 m_in_pb_cb;
- devcb_read8 m_in_pc_cb;
-
- devcb_write8 m_out_pa_cb;
- devcb_write8 m_out_pb_cb;
- devcb_write8 m_out_pc_cb;
-
- // this gets called for each change of the TIMER OUT pin (pin 6)
- devcb_write_line m_out_to_cb;
-
- // CPU interface
- int m_io_m; // I/O or memory select
- UINT8 m_ad; // address
-
- // registers
- UINT8 m_command; // command register
- UINT8 m_status; // status register
- UINT8 m_output[3]; // output latches
-
- // counter
- UINT16 m_count_length; // count length register
- UINT16 m_counter; // counter register
- int m_to; // timer output
-
- // timers
- emu_timer *m_timer; // counter timer
-
- const address_space_config m_space_config;
-};
-
-
-// device type definition
-extern const device_type I8155;
-extern const device_type I8156;
-
-
-#endif
diff --git a/src/emu/machine/i8212.c b/src/emu/machine/i8212.c
deleted file mode 100644
index 14b06841278..00000000000
--- a/src/emu/machine/i8212.c
+++ /dev/null
@@ -1,142 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Intel 8212 8-Bit Input/Output Port emulation
-
-**********************************************************************/
-
-#include "emu.h"
-#include "i8212.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type I8212 = &device_creator<i8212_device>;
-
-//-------------------------------------------------
-// i8212_device - constructor
-//-------------------------------------------------
-
-i8212_device::i8212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, I8212, "I8212", tag, owner, clock, "i8212", __FILE__),
- m_write_irq(*this),
- m_read_di(*this),
- m_write_do(*this),
- m_md(I8212_MODE_INPUT),
- m_stb(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void i8212_device::device_start()
-{
- // resolve callbacks
- m_write_irq.resolve_safe();
- m_read_di.resolve_safe(0);
- m_write_do.resolve_safe();
-
- // register for state saving
- save_item(NAME(m_md));
- save_item(NAME(m_stb));
- save_item(NAME(m_data));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void i8212_device::device_reset()
-{
- m_data = 0;
-
- if (m_md == I8212_MODE_OUTPUT)
- {
- // output data
- m_write_do((offs_t)0, m_data);
- }
-}
-
-
-//-------------------------------------------------
-// read - data latch read
-//-------------------------------------------------
-
-READ8_MEMBER( i8212_device::read )
-{
- // clear interrupt line
- m_write_irq(CLEAR_LINE);
-
- if (LOG) logerror("I8212 '%s' INT: %u\n", tag(), CLEAR_LINE);
-
- return m_data;
-}
-
-
-//-------------------------------------------------
-// write - data latch write
-//-------------------------------------------------
-
-WRITE8_MEMBER( i8212_device::write )
-{
- // latch data
- m_data = data;
-
- // output data
- m_write_do((offs_t)0, m_data);
-}
-
-
-//-------------------------------------------------
-// md_w - mode write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8212_device::md_w )
-{
- if (LOG) logerror("I8212 '%s' Mode: %s\n", tag(), state ? "output" : "input");
-
- m_md = state;
-}
-
-
-//-------------------------------------------------
-// stb_w - data strobe write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8212_device::stb_w )
-{
- if (LOG) logerror("I8212 '%s' STB: %u\n", tag(), state);
-
- if (m_md == I8212_MODE_INPUT)
- {
- if (m_stb && !state)
- {
- // input data
- m_data = m_read_di(0);
-
- // assert interrupt line
- m_write_irq(ASSERT_LINE);
-
- if (LOG) logerror("I8212 '%s' INT: %u\n", tag(), ASSERT_LINE);
- }
- }
-
- m_stb = state;
-}
diff --git a/src/emu/machine/i8212.h b/src/emu/machine/i8212.h
deleted file mode 100644
index 78e87470acd..00000000000
--- a/src/emu/machine/i8212.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Intel 8212 8-Bit Input/Output Port emulation
-
-**********************************************************************
- _____ _____
- _DS1 1 |* \_/ | 24 Vcc
- MD 2 | | 23 _INT
- DI1 3 | | 22 DI8
- DO1 4 | | 21 DO8
- DI2 5 | | 20 DI7
- DO2 6 | 8212 | 19 DO7
- DI3 7 | | 18 DI6
- DO3 8 | | 17 DO6
- DI4 9 | | 16 DI5
- DO4 10 | | 15 DO5
- STB 11 | | 14 _CLR
- GND 12 |_____________| 13 DS2
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __I8212__
-#define __I8212__
-
-#include "emu.h"
-
-
-
-///*************************************************************************
-// MACROS / CONSTANTS
-///*************************************************************************
-
-enum
-{
- I8212_MODE_INPUT = 0,
- I8212_MODE_OUTPUT
-};
-
-
-
-///*************************************************************************
-// INTERFACE CONFIGURATION MACROS
-///*************************************************************************
-
-#define MCFG_I8212_IRQ_CALLBACK(_write) \
- devcb = &i8212_device::set_irq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_I8212_DI_CALLBACK(_read) \
- devcb = &i8212_device::set_di_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_I8212_DO_CALLBACK(_write) \
- devcb = &i8212_device::set_do_wr_callback(*device, DEVCB_##_write);
-
-
-
-///*************************************************************************
-// TYPE DEFINITIONS
-///*************************************************************************
-
-// ======================> i8212_device
-
-class i8212_device : public device_t
-{
-public:
- // construction/destruction
- i8212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<i8212_device &>(device).m_write_irq.set_callback(object); }
- template<class _Object> static devcb_base &set_di_rd_callback(device_t &device, _Object object) { return downcast<i8212_device &>(device).m_read_di.set_callback(object); }
- template<class _Object> static devcb_base &set_do_wr_callback(device_t &device, _Object object) { return downcast<i8212_device &>(device).m_write_do.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( md_w );
- DECLARE_WRITE_LINE_MEMBER( stb_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- devcb_write_line m_write_irq;
- devcb_read8 m_read_di;
- devcb_write8 m_write_do;
-
- int m_md; // mode
- int m_stb; // strobe
- UINT8 m_data; // data latch
-};
-
-
-// device type definition
-extern const device_type I8212;
-
-
-
-#endif
diff --git a/src/emu/machine/i8214.c b/src/emu/machine/i8214.c
deleted file mode 100644
index 9a7cf9ecd1c..00000000000
--- a/src/emu/machine/i8214.c
+++ /dev/null
@@ -1,205 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Intel 8214 Priority Interrupt Controller emulation
-
-**********************************************************************/
-
-#include "emu.h"
-#include "i8214.h"
-
-
-
-// device type definition
-const device_type I8214 = &device_creator<i8214_device>;
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// trigger_interrupt -
-//-------------------------------------------------
-
-inline void i8214_device::trigger_interrupt(int level)
-{
- if (LOG) logerror("I8214 '%s' Interrupt Level %u\n", tag(), level);
-
- m_a = level;
-
- // disable interrupts
- m_int_dis = 1;
-
- // disable next level group
- m_write_enlg(0);
-
- // toggle interrupt line
- m_write_irq(ASSERT_LINE);
- m_write_irq(CLEAR_LINE);
-}
-
-
-//-------------------------------------------------
-// check_interrupt -
-//-------------------------------------------------
-
-inline void i8214_device::check_interrupt()
-{
- int level;
-
- if (m_int_dis || !m_etlg) return;
-
- for (level = 7; level >= 0; level--)
- {
- if (!BIT(m_r, 7 - level))
- {
- if (m_sgs)
- {
- if (level > m_b)
- {
- trigger_interrupt(level);
- }
- }
- else
- {
- trigger_interrupt(level);
- }
- }
- }
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// i8214_device - constructor
-//-------------------------------------------------
-
-i8214_device::i8214_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, I8214, "I8214", tag, owner, clock, "i8214", __FILE__),
- m_write_irq(*this),
- m_write_enlg(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void i8214_device::device_start()
-{
- // resolve callbacks
- m_write_irq.resolve_safe();
- m_write_enlg.resolve_safe();
-
- m_int_dis = 0;
-
- // register for state saving
- save_item(NAME(m_inte));
- save_item(NAME(m_int_dis));
- save_item(NAME(m_a));
- save_item(NAME(m_b));
- save_item(NAME(m_r));
- save_item(NAME(m_sgs));
- save_item(NAME(m_etlg));
-}
-
-
-//-------------------------------------------------
-// a_r -
-//-------------------------------------------------
-
-UINT8 i8214_device::a_r()
-{
- UINT8 a = m_a & 0x07;
-
- if (LOG) logerror("I8214 '%s' A: %01x\n", tag(), a);
-
- return a;
-}
-
-
-//-------------------------------------------------
-// b_w -
-//-------------------------------------------------
-
-void i8214_device::b_w(UINT8 data)
-{
- m_b = data & 0x07;
-
- if (LOG) logerror("I8214 '%s' B: %01x\n", tag(), m_b);
-
- // enable interrupts
- m_int_dis = 0;
-
- // enable next level group
- m_write_enlg(1);
-
- check_interrupt();
-}
-
-
-//-------------------------------------------------
-// r_w -
-//-------------------------------------------------
-
-void i8214_device::r_w(UINT8 data)
-{
- if (LOG) logerror("I8214 '%s' R: %02x\n", tag(), data);
-
- m_r = data;
-
- check_interrupt();
-}
-
-
-//-------------------------------------------------
-// sgs_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8214_device::sgs_w )
-{
- if (LOG) logerror("I8214 '%s' SGS: %u\n", tag(), state);
-
- m_sgs = state;
-
- check_interrupt();
-}
-
-
-//-------------------------------------------------
-// etlg_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8214_device::etlg_w )
-{
- if (LOG) logerror("I8214 '%s' ETLG: %u\n", tag(), state);
-
- m_etlg = state;
-}
-
-
-//-------------------------------------------------
-// inte_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8214_device::inte_w )
-{
- if (LOG) logerror("I8214 '%s' INTE: %u\n", tag(), state);
-
- m_inte = state;
-}
diff --git a/src/emu/machine/i8214.h b/src/emu/machine/i8214.h
deleted file mode 100644
index 62e7f98fd51..00000000000
--- a/src/emu/machine/i8214.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Intel 8214 Priority Interrupt Controller emulation
-
-**********************************************************************
- _____ _____
- _B0 1 |* \_/ | 24 Vcc
- _B1 2 | | 23 _ECS
- _B2 3 | | 22 _R7
- _SGS 4 | | 21 _R6
- _INT 5 | | 20 _R5
- _CLK 6 | 8214 | 19 _R4
- INTE 7 | | 18 _R3
- _A0 8 | | 17 _R2
- _A1 9 | | 16 _R1
- _A2 10 | | 15 _R0
- _ELR 11 | | 14 ENLG
- GND 12 |_____________| 13 ETLG
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __I8214__
-#define __I8214__
-
-#include "emu.h"
-
-
-
-///*************************************************************************
-// INTERFACE CONFIGURATION MACROS
-///*************************************************************************
-
-#define MCFG_I8214_IRQ_CALLBACK(_write) \
- devcb = &i8214_device::set_irq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_I8214_ENLG_CALLBACK(_write) \
- devcb = &i8214_device::set_enlg_wr_callback(*device, DEVCB_##_write);
-
-
-
-///*************************************************************************
-// TYPE DEFINITIONS
-///*************************************************************************
-
-// ======================> i8214_device
-
-class i8214_device : public device_t
-{
-public:
- // construction/destruction
- i8214_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<i8214_device &>(device).m_write_irq.set_callback(object); }
- template<class _Object> static devcb_base &set_enlg_wr_callback(device_t &device, _Object object) { return downcast<i8214_device &>(device).m_write_enlg.set_callback(object); }
-
- DECLARE_WRITE_LINE_MEMBER( sgs_w );
- DECLARE_WRITE_LINE_MEMBER( etlg_w );
- DECLARE_WRITE_LINE_MEMBER( inte_w );
-
- UINT8 a_r();
- void b_w(UINT8 data);
- void r_w(UINT8 data);
-
-protected:
- // device-level overrides
- virtual void device_start();
-
-private:
- inline void trigger_interrupt(int level);
- inline void check_interrupt();
-
- devcb_write_line m_write_irq;
- devcb_write_line m_write_enlg;
-
- int m_inte; // interrupt enable
- int m_int_dis; // interrupt disable flip-flop
- int m_a; // request level
- int m_b; // current status register
- UINT8 m_r; // interrupt request latch
- int m_sgs; // status group select
- int m_etlg; // enable this level group
-};
-
-
-// device type definition
-extern const device_type I8214;
-
-
-
-#endif
diff --git a/src/emu/machine/i8243.c b/src/emu/machine/i8243.c
deleted file mode 100644
index d3393cea4fd..00000000000
--- a/src/emu/machine/i8243.c
+++ /dev/null
@@ -1,125 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- i8243.c
-
- Intel 8243 Port Expander
-
-***************************************************************************/
-
-#include "emu.h"
-#include "i8243.h"
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type I8243 = &device_creator<i8243_device>;
-
-//-------------------------------------------------
-// i8243_device - constructor
-//-------------------------------------------------
-
-i8243_device::i8243_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, I8243, "8243 I/O Expander", tag, owner, clock, "i8243", __FILE__),
- m_readhandler(*this),
- m_writehandler(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void i8243_device::device_start()
-{
- m_readhandler.resolve_safe(0);
- m_writehandler.resolve_safe();
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void i8243_device::device_reset()
-{
- m_p2 = 0x0f;
- m_p2out = 0x0f;
- m_prog = 1;
-}
-
-
-/*-------------------------------------------------
- i8243_p2_r - handle a read from port 2
--------------------------------------------------*/
-
-READ8_MEMBER(i8243_device::i8243_p2_r)
-{
- return m_p2out;
-}
-
-
-/*-------------------------------------------------
- i8243_p2_r - handle a write to port 2
--------------------------------------------------*/
-
-WRITE8_MEMBER(i8243_device::i8243_p2_w)
-{
- m_p2 = data & 0x0f;
-}
-
-
-/*-------------------------------------------------
- i8243_prog_w - handle a change in the PROG
- line state
--------------------------------------------------*/
-
-WRITE8_MEMBER(i8243_device::i8243_prog_w)
-{
- /* only care about low bit */
- data &= 1;
-
- /* on high->low transition state, latch opcode/port */
- if(m_prog && !data)
- {
- m_opcode = m_p2;
-
- /* if this is a read opcode, copy result to p2out */
- if((m_opcode >> 2) == MCS48_EXPANDER_OP_READ)
- {
- if (m_readhandler.isnull())
- {
- m_p[m_opcode & 3] = m_readhandler(m_opcode & 3);
- }
- m_p2out = m_p[m_opcode & 3] & 0x0f;
- }
- }
-
- /* on low->high transition state, act on opcode */
- else if(!m_prog && data)
- {
- switch(m_opcode >> 2)
- {
- case MCS48_EXPANDER_OP_WRITE:
- m_p[m_opcode & 3] = m_p2 & 0x0f;
- m_writehandler((offs_t)(m_opcode & 3), m_p[m_opcode & 3]);
- break;
-
- case MCS48_EXPANDER_OP_OR:
- m_p[m_opcode & 3] |= m_p2 & 0x0f;
- m_writehandler((offs_t)(m_opcode & 3), m_p[m_opcode & 3]);
- break;
-
- case MCS48_EXPANDER_OP_AND:
- m_p[m_opcode & 3] &= m_p2 & 0x0f;
- m_writehandler((offs_t)(m_opcode & 3), m_p[m_opcode & 3]);
- break;
- }
- }
-
- /* remember the state */
- m_prog = data;
-}
diff --git a/src/emu/machine/i8243.h b/src/emu/machine/i8243.h
deleted file mode 100644
index 7ac782f3496..00000000000
--- a/src/emu/machine/i8243.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- i8243.h
-
- Intel 8243 Port Expander
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __I8243_H__
-#define __I8243_H__
-
-#include "emu.h"
-#include "cpu/mcs48/mcs48.h"
-
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_I8243_ADD(_tag, _read, _write) \
- MCFG_DEVICE_ADD(_tag, I8243, 0) \
- MCFG_I8243_READHANDLER(_read) \
- MCFG_I8243_WRITEHANDLER(_write)
-#define MCFG_I8243_READHANDLER(_devcb) \
- devcb = &i8243_device::set_read_handler(*device, DEVCB_##_devcb);
-#define MCFG_I8243_WRITEHANDLER(_devcb) \
- devcb = &i8243_device::set_write_handler(*device, DEVCB_##_devcb);
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-
-// ======================> i8243_device
-
-class i8243_device : public device_t
-{
-public:
- // construction/destruction
- i8243_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_read_handler(device_t &device, _Object object) { return downcast<i8243_device &>(device).m_readhandler.set_callback(object); }
- template<class _Object> static devcb_base &set_write_handler(device_t &device, _Object object) { return downcast<i8243_device &>(device).m_writehandler.set_callback(object); }
-
- DECLARE_READ8_MEMBER(i8243_p2_r);
- DECLARE_WRITE8_MEMBER(i8243_p2_w);
-
- DECLARE_WRITE8_MEMBER(i8243_prog_w);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_post_load() { }
- virtual void device_clock_changed() { }
-
-private:
-
- UINT8 m_p[4]; /* 4 ports' worth of data */
- UINT8 m_p2out; /* port 2 bits that will be returned */
- UINT8 m_p2; /* most recent port 2 value */
- UINT8 m_opcode; /* latched opcode */
- UINT8 m_prog; /* previous PROG state */
-
- devcb_read8 m_readhandler;
- devcb_write8 m_writehandler;
-};
-
-
-// device type definition
-extern const device_type I8243;
-
-#endif /* __I8243_H__ */
diff --git a/src/emu/machine/i8251.c b/src/emu/machine/i8251.c
deleted file mode 100644
index 7008fe394a3..00000000000
--- a/src/emu/machine/i8251.c
+++ /dev/null
@@ -1,788 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*********************************************************************
-
- i8251.c
-
- Intel 8251 Universal Synchronous/Asynchronous Receiver Transmitter code
- NEC uPD71051 is a clone
-
- The V53/V53A use a customized version with only the Asynchronous mode
- and a split command / mode register
-
-
-
-*********************************************************************/
-
-#include "emu.h"
-#include "i8251.h"
-
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-#define VERBOSE 0
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type I8251 = &device_creator<i8251_device>;
-const device_type V53_SCU = &device_creator<v53_scu_device>;
-
-//-------------------------------------------------
-// i8251_device - constructor
-//-------------------------------------------------
-
-i8251_device::i8251_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, __FILE__),
- device_serial_interface(mconfig, *this),
- m_txd_handler(*this),
- m_dtr_handler(*this),
- m_rts_handler(*this),
- m_rxrdy_handler(*this),
- m_txrdy_handler(*this),
- m_txempty_handler(*this),
- m_syndet_handler(*this),
- m_cts(1),
- m_dsr(1),
- m_rxd(0),
- m_rxc(0),
- m_txc(0)
-{
-}
-
-i8251_device::i8251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, I8251, "8251 USART", tag, owner, clock, "i8251", __FILE__),
- device_serial_interface(mconfig, *this),
- m_txd_handler(*this),
- m_dtr_handler(*this),
- m_rts_handler(*this),
- m_rxrdy_handler(*this),
- m_txrdy_handler(*this),
- m_txempty_handler(*this),
- m_syndet_handler(*this),
- m_cts(1),
- m_dsr(1),
- m_rxd(0),
- m_rxc(0),
- m_txc(0)
-{
-}
-
-v53_scu_device::v53_scu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : i8251_device(mconfig, V53_SCU, "V53 SCU", tag, owner, clock, "v53_scu")
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void i8251_device::device_start()
-{
- // resolve callbacks
- m_txd_handler.resolve_safe();
- m_rts_handler.resolve_safe();
- m_dtr_handler.resolve_safe();
- m_rxrdy_handler.resolve_safe();
- m_txrdy_handler.resolve_safe();
- m_txempty_handler.resolve_safe();
- save_item(NAME(m_flags));
- save_item(NAME(m_sync_byte_offset));
- save_item(NAME(m_sync_byte_count));
- save_item(NAME(m_sync_bytes));
- save_item(NAME(m_status));
- save_item(NAME(m_command));
- save_item(NAME(m_mode_byte));
- save_item(NAME(m_cts));
- save_item(NAME(m_dsr));
- save_item(NAME(m_rxd));
- save_item(NAME(m_rxc));
- save_item(NAME(m_txc));
- save_item(NAME(m_rxc_count));
- save_item(NAME(m_txc_count));
- save_item(NAME(m_br_factor));
- save_item(NAME(m_rx_data));
- save_item(NAME(m_tx_data));
- save_item(NAME(m_tx_busy));
- save_item(NAME(m_disable_tx_pending));
- device_serial_interface::register_save_state(machine().save(), this);
-}
-
-
-
-
-/*-------------------------------------------------
- update_rx_ready
--------------------------------------------------*/
-
-void i8251_device::update_rx_ready()
-{
- int state;
-
- state = m_status & I8251_STATUS_RX_READY;
-
- /* masked? */
- if ((m_command & (1<<2))==0)
- {
- state = 0;
- }
-
- m_rxrdy_handler(state != 0);
-}
-
-
-
-/*-------------------------------------------------
- receive_clock
--------------------------------------------------*/
-
-void i8251_device::receive_clock()
-{
- m_rxc_count++;
-
- if (m_rxc_count == m_br_factor)
- m_rxc_count = 0;
- else
- return;
-
- /* receive enable? */
- if (m_command & (1<<2))
- {
- //logerror("I8251\n");
- /* get bit received from other side and update receive register */
- receive_register_update_bit(m_rxd);
-
- if (is_receive_register_full())
- {
- receive_register_extract();
- receive_character(get_received_char());
- }
- }
-}
-
-
-
-/*-------------------------------------------------
- transmit_clock
--------------------------------------------------*/
-
-void i8251_device::transmit_clock()
-{
- m_txc_count++;
-
- if (m_txc_count == m_br_factor)
- m_txc_count = 0;
- else
- return;
-
- /* transmit enabled? */
- if (m_command & (1<<0))
- {
- /* do we have a character to send? */
- if ((m_status & I8251_STATUS_TX_READY)==0)
- {
- /* is diserial ready for it? */
- if (is_transmit_register_empty())
- {
- /* set it up */
- transmit_register_setup(m_tx_data);
- /* i8251 transmit reg now empty */
- m_status |=I8251_STATUS_TX_EMPTY;
- /* ready for next transmit */
- m_status |=I8251_STATUS_TX_READY;
-
- update_tx_empty();
- update_tx_ready();
- }
- }
-
- /* if diserial has bits to send, make them so */
- if (!is_transmit_register_empty())
- {
- UINT8 data = transmit_register_get_data_bit();
- m_tx_busy = true;
- m_txd_handler(data);
- }
-
- // is transmitter totally done?
- if ((m_status & I8251_STATUS_TX_READY) && is_transmit_register_empty())
- {
- m_tx_busy = false;
-
- if (m_disable_tx_pending)
- {
- LOG(("Applying pending disable\n"));
- m_disable_tx_pending = false;
- m_command &= ~(1<<0);
- m_txd_handler(1);
- update_tx_ready();
- }
- }
- }
-
-#if 0
- /* hunt mode? */
- /* after each bit has been shifted in, it is compared against the current sync byte */
- if (m_command & (1<<7))
- {
- /* data matches sync byte? */
- if (m_data == m_sync_bytes[m_sync_byte_offset])
- {
- /* sync byte matches */
- /* update for next sync byte? */
- m_sync_byte_offset++;
-
- /* do all sync bytes match? */
- if (m_sync_byte_offset == m_sync_byte_count)
- {
- /* ent hunt mode */
- m_command &=~(1<<7);
- }
- }
- else
- {
- /* if there is no match, reset */
- m_sync_byte_offset = 0;
- }
- }
-#endif
-}
-
-
-
-/*-------------------------------------------------
- update_tx_ready
--------------------------------------------------*/
-
-void i8251_device::update_tx_ready()
-{
- /* clear tx ready state */
- int tx_ready;
-
- /* tx ready output is set if:
- DB Buffer Empty &
- CTS is set &
- Transmit enable is 1
- */
-
- tx_ready = 0;
-
- /* transmit enable? */
- if ((m_command & (1<<0))!=0)
- {
- /* other side has rts set (comes in as CTS at this side) */
- if (!m_cts)
- {
- if (m_status & I8251_STATUS_TX_EMPTY)
- {
- /* enable transfer */
- tx_ready = 1;
- }
- }
- }
-
- m_txrdy_handler(tx_ready);
-}
-
-
-
-/*-------------------------------------------------
- update_tx_empty
--------------------------------------------------*/
-
-void i8251_device::update_tx_empty()
-{
- if (m_status & I8251_STATUS_TX_EMPTY)
- {
- /* tx is in marking state (high) when tx empty! */
- m_txd_handler(1);
- }
-
- m_txempty_handler((m_status & I8251_STATUS_TX_EMPTY) != 0);
-}
-
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void i8251_device::device_reset()
-{
- LOG(("I8251: Reset\n"));
-
- /* what is the default setup when the 8251 has been reset??? */
-
- /* i8251 datasheet explains the state of tx pin at reset */
- /* tx is set to 1 */
- m_txd_handler(1);
-
- /* assumption */
- m_rts_handler(1);
- m_dtr_handler(1);
-
- transmit_register_reset();
- receive_register_reset();
- m_flags = 0;
- /* expecting mode byte */
- m_flags |= I8251_EXPECTING_MODE;
- /* not expecting a sync byte */
- m_flags &= ~I8251_EXPECTING_SYNC_BYTE;
-
- /* no character to read by cpu */
- /* transmitter is ready and is empty */
- m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY;
- m_mode_byte = 0;
- m_command = 0;
- m_rx_data = 0;
- m_tx_data = 0;
- m_rxc_count = m_txc_count = 0;
- m_br_factor = 1;
- m_tx_busy = m_disable_tx_pending = false;
-
- /* update tx empty pin output */
- update_tx_empty();
- /* update rx ready pin output */
- update_rx_ready();
- /* update tx ready pin output */
- update_tx_ready();
-}
-
-
-
-/*-------------------------------------------------
- control_w
--------------------------------------------------*/
-
-WRITE8_MEMBER(i8251_device::command_w)
-{
- /* command */
- LOG(("I8251: Command byte\n"));
-
- m_command = data;
-
- LOG(("Command byte: %02x\n", data));
-
- if (data & (1<<7))
- {
- LOG(("hunt mode\n"));
- }
-
- if (data & (1<<5))
- {
- LOG(("/rts set to 0\n"));
- }
- else
- {
- LOG(("/rts set to 1\n"));
- }
-
- if (data & (1<<2))
- {
- LOG(("receive enable\n"));
- }
- else
- {
- LOG(("receive disable\n"));
- }
-
- if (data & (1<<1))
- {
- LOG(("/dtr set to 0\n"));
- }
- else
- {
- LOG(("/dtr set to 1\n"));
- }
-
- if (data & (1<<0))
- {
- LOG(("transmit enable\n"));
-
- /* if we get a tx enable with a disable pending, cancel the disable */
- m_disable_tx_pending = false;
- }
- else
- {
- if (m_tx_busy)
- {
- if (!m_disable_tx_pending)
- {
- LOG(("Tx busy, set pending disable\n"));
- }
- m_disable_tx_pending = true;
- m_command |= (1<<0);
- }
- else
- {
- LOG(("transmit disable\n"));
- if ((data & (1<<0))==0)
- {
- /* held in high state when transmit disable */
- m_txd_handler(1);
- }
- }
- }
-
-
- /* bit 7:
- 0 = normal operation
- 1 = hunt mode
- bit 6:
- 0 = normal operation
- 1 = internal reset
- bit 5:
- 0 = /RTS set to 1
- 1 = /RTS set to 0
- bit 4:
- 0 = normal operation
- 1 = reset error flag
- bit 3:
- 0 = normal operation
- 1 = send break character
- bit 2:
- 0 = receive disable
- 1 = receive enable
- bit 1:
- 0 = /DTR set to 1
- 1 = /DTR set to 0
- bit 0:
- 0 = transmit disable
- 1 = transmit enable
- */
-
- m_rts_handler(!BIT(data, 5));
- m_dtr_handler(!BIT(data, 1));
-
- if (data & (1<<4))
- {
- m_status &= ~(I8251_STATUS_PARITY_ERROR | I8251_STATUS_OVERRUN_ERROR | I8251_STATUS_FRAMING_ERROR);
- }
-
- if (data & (1<<6))
- {
- // datasheet says "returns to mode format", not
- // completely resets the chip. behavior of DEC Rainbow
- // backs this up.
- m_flags |= I8251_EXPECTING_MODE;
- }
-
- update_rx_ready();
- update_tx_ready();
-}
-
-WRITE8_MEMBER(i8251_device::mode_w)
-{
- LOG(("I8251: Mode byte\n"));
-
- m_mode_byte = data;
-
- /* Synchronous or Asynchronous? */
- if ((data & 0x03) != 0)
- {
- /* Asynchronous
-
- bit 7,6: stop bit length
- 0 = inhibit
- 1 = 1 bit
- 2 = 1.5 bits
- 3 = 2 bits
- bit 5: parity type
- 0 = parity odd
- 1 = parity even
- bit 4: parity test enable
- 0 = disable
- 1 = enable
- bit 3,2: character length
- 0 = 5 bits
- 1 = 6 bits
- 2 = 7 bits
- 3 = 8 bits
- bit 1,0: baud rate factor
- 0 = defines command byte for synchronous or asynchronous
- 1 = x1
- 2 = x16
- 3 = x64
- */
-
- LOG(("I8251: Asynchronous operation\n"));
-
- LOG(("Character length: %d\n", (((data >> 2) & 0x03) + 5)));
-
- parity_t parity;
-
- if (data & (1 << 4))
- {
- LOG(("enable parity checking\n"));
-
- if (data & (1 << 5))
- {
- LOG(("even parity\n"));
- parity = PARITY_EVEN;
- }
- else
- {
- LOG(("odd parity\n"));
- parity = PARITY_ODD;
- }
- }
- else
- {
- LOG(("parity check disabled\n"));
- parity = PARITY_NONE;
- }
-
- stop_bits_t stop_bits;
-
- switch ((data >> 6) & 0x03)
- {
- case 0:
- default:
- stop_bits = STOP_BITS_0;
- LOG(("stop bit: inhibit\n"));
- break;
-
- case 1:
- stop_bits = STOP_BITS_1;
- LOG(("stop bit: 1 bit\n"));
- break;
-
- case 2:
- stop_bits = STOP_BITS_1_5;
- LOG(("stop bit: 1.5 bits\n"));
- break;
-
- case 3:
- stop_bits = STOP_BITS_2;
- LOG(("stop bit: 2 bits\n"));
- break;
- }
-
- int data_bits_count = ((data >> 2) & 0x03) + 5;
-
- set_data_frame(1, data_bits_count, parity, stop_bits);
- receive_register_reset();
-
- switch (data & 0x03)
- {
- case 1: m_br_factor = 1; break;
- case 2: m_br_factor = 16; break;
- case 3: m_br_factor = 64; break;
- }
-
- m_rxc_count = m_txc_count = 0;
-
-#if 0
- /* data bits */
- m_receive_char_length = (((data >> 2) & 0x03) + 5);
-
- if (data & (1 << 4))
- {
- /* parity */
- m_receive_char_length++;
- }
-
- /* stop bits */
- m_receive_char_length++;
-
- m_receive_flags &= ~I8251_TRANSFER_RECEIVE_SYNCHRONISED;
- m_receive_flags |= I8251_TRANSFER_RECEIVE_WAITING_FOR_START_BIT;
-#endif
- /* not expecting mode byte now */
- m_flags &= ~I8251_EXPECTING_MODE;
- // m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY;
- }
- else
- {
- /* bit 7: Number of sync characters
- 0 = 1 character
- 1 = 2 character
- bit 6: Synchronous mode
- 0 = Internal synchronisation
- 1 = External synchronisation
- bit 5: parity type
- 0 = parity odd
- 1 = parity even
- bit 4: parity test enable
- 0 = disable
- 1 = enable
- bit 3,2: character length
- 0 = 5 bits
- 1 = 6 bits
- 2 = 7 bits
- 3 = 8 bits
- bit 1,0 = 0
- */
- LOG(("I8251: Synchronous operation\n"));
-
- /* setup for sync byte(s) */
- m_flags |= I8251_EXPECTING_SYNC_BYTE;
- m_sync_byte_offset = 0;
- if (data & 0x07)
- {
- m_sync_byte_count = 1;
- }
- else
- {
- m_sync_byte_count = 2;
- }
-
- }
-}
-
-WRITE8_MEMBER(i8251_device::control_w)
-{
- if (m_flags & I8251_EXPECTING_MODE)
- {
- if (m_flags & I8251_EXPECTING_SYNC_BYTE)
- {
- LOG(("I8251: Sync byte\n"));
-
- LOG(("Sync byte: %02x\n", data));
- /* store sync byte written */
- m_sync_bytes[m_sync_byte_offset] = data;
- m_sync_byte_offset++;
-
- if (m_sync_byte_offset == m_sync_byte_count)
- {
- /* finished transfering sync bytes, now expecting command */
- m_flags &= ~(I8251_EXPECTING_MODE | I8251_EXPECTING_SYNC_BYTE);
- m_sync_byte_offset = 0;
- // m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY;
- }
- }
- else
- {
- mode_w(space, offset, data);
- }
- }
- else
- {
- command_w(space, offset, data);
- }
-}
-
-
-
-/*-------------------------------------------------
- status_r
--------------------------------------------------*/
-
-READ8_MEMBER(i8251_device::status_r)
-{
- UINT8 status = (m_dsr << 7) | m_status;
-
- LOG(("status: %02x\n", status));
- return status;
-}
-
-
-
-/*-------------------------------------------------
- data_w
--------------------------------------------------*/
-
-WRITE8_MEMBER(i8251_device::data_w)
-{
- m_tx_data = data;
-
- LOG(("data_w %02x\n" , data));
-// printf("i8251 transmit char: %02x\n",data);
-
- /* writing clears */
- m_status &=~I8251_STATUS_TX_READY;
- m_status &=~I8251_STATUS_TX_EMPTY;
-
- /* if transmitter is active, then tx empty will be signalled */
-
- update_tx_ready();
- update_tx_empty();
-}
-
-
-
-/*-------------------------------------------------
- receive_character - called when last
- bit of data has been received
--------------------------------------------------*/
-
-void i8251_device::receive_character(UINT8 ch)
-{
- m_rx_data = ch;
-
- /* char has not been read and another has arrived! */
- if (m_status & I8251_STATUS_RX_READY)
- {
- m_status |= I8251_STATUS_OVERRUN_ERROR;
- }
- m_status |= I8251_STATUS_RX_READY;
-
- update_rx_ready();
-}
-
-
-
-/*-------------------------------------------------
- data_r - read data
--------------------------------------------------*/
-
-READ8_MEMBER(i8251_device::data_r)
-{
- LOG(("read data: %02x, STATUS=%02x\n",m_rx_data,m_status));
- /* reading clears */
- m_status &= ~I8251_STATUS_RX_READY;
-
- update_rx_ready();
- return m_rx_data;
-}
-
-
-void i8251_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- device_serial_interface::device_timer(timer, id, param, ptr);
-}
-
-
-WRITE_LINE_MEMBER(i8251_device::write_rxd)
-{
- m_rxd = state;
-// device_serial_interface::rx_w(state);
-}
-
-WRITE_LINE_MEMBER(i8251_device::write_cts)
-{
- m_cts = state;
-}
-
-WRITE_LINE_MEMBER(i8251_device::write_dsr)
-{
- m_dsr = !state;
-}
-
-WRITE_LINE_MEMBER(i8251_device::write_rxc)
-{
- if (m_rxc != state)
- {
- m_rxc = state;
-
- if (m_rxc)
- receive_clock();
- }
-}
-
-WRITE_LINE_MEMBER(i8251_device::write_txc)
-{
- if (m_txc != state)
- {
- m_txc = state;
-
- if (!m_txc)
- transmit_clock();
- }
-}
diff --git a/src/emu/machine/i8251.h b/src/emu/machine/i8251.h
deleted file mode 100644
index 2825faf1ed1..00000000000
--- a/src/emu/machine/i8251.h
+++ /dev/null
@@ -1,155 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*********************************************************************
-
- i8251.h
-
- Intel 8251 Universal Synchronous/Asynchronous Receiver Transmitter code
-
-*********************************************************************/
-
-#ifndef __I8251_H__
-#define __I8251_H__
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_I8251_TXD_HANDLER(_devcb) \
- devcb = &i8251_device::set_txd_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_I8251_DTR_HANDLER(_devcb) \
- devcb = &i8251_device::set_dtr_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_I8251_RTS_HANDLER(_devcb) \
- devcb = &i8251_device::set_rts_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_I8251_RXRDY_HANDLER(_devcb) \
- devcb = &i8251_device::set_rxrdy_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_I8251_TXRDY_HANDLER(_devcb) \
- devcb = &i8251_device::set_txrdy_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_I8251_TXEMPTY_HANDLER(_devcb) \
- devcb = &i8251_device::set_txempty_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_I8251_SYNDET_HANDLER(_devcb) \
- devcb = &i8251_device::set_syndet_handler(*device, DEVCB_##_devcb);
-
-class i8251_device : public device_t,
- public device_serial_interface
-{
-public:
- // construction/destruction
- i8251_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname);
- i8251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_txd_handler(device_t &device, _Object object) { return downcast<i8251_device &>(device).m_txd_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_dtr_handler(device_t &device, _Object object) { return downcast<i8251_device &>(device).m_dtr_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_rts_handler(device_t &device, _Object object) { return downcast<i8251_device &>(device).m_rts_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_rxrdy_handler(device_t &device, _Object object) { return downcast<i8251_device &>(device).m_rxrdy_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_txrdy_handler(device_t &device, _Object object) { return downcast<i8251_device &>(device).m_txrdy_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_txempty_handler(device_t &device, _Object object) { return downcast<i8251_device &>(device).m_txempty_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_syndet_handler(device_t &device, _Object object) { return downcast<i8251_device &>(device).m_syndet_handler.set_callback(object); }
-
- DECLARE_READ8_MEMBER(data_r);
- DECLARE_WRITE8_MEMBER(data_w);
- DECLARE_READ8_MEMBER(status_r);
- DECLARE_WRITE8_MEMBER(control_w);
- DECLARE_WRITE8_MEMBER(command_w);
- DECLARE_WRITE8_MEMBER(mode_w);
-
- DECLARE_WRITE_LINE_MEMBER( write_rxd );
- DECLARE_WRITE_LINE_MEMBER( write_cts );
- DECLARE_WRITE_LINE_MEMBER( write_dsr );
- DECLARE_WRITE_LINE_MEMBER( write_txc );
- DECLARE_WRITE_LINE_MEMBER( write_rxc );
-
- /// TODO: REMOVE THIS
- void receive_character(UINT8 ch);
-
- /// TODO: this shouldn't be public
- enum
- {
- I8251_STATUS_FRAMING_ERROR = 0x20,
- I8251_STATUS_OVERRUN_ERROR = 0x10,
- I8251_STATUS_PARITY_ERROR = 0x08,
- I8251_STATUS_TX_EMPTY = 0x04,
- I8251_STATUS_RX_READY = 0x02,
- I8251_STATUS_TX_READY = 0x01
- };
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- void update_rx_ready();
- void update_tx_ready();
- void update_tx_empty();
- void transmit_clock();
- void receive_clock();
-
- enum
- {
- I8251_EXPECTING_MODE = 0x01,
- I8251_EXPECTING_SYNC_BYTE = 0x02
- };
-
-private:
- devcb_write_line m_txd_handler;
- devcb_write_line m_dtr_handler;
- devcb_write_line m_rts_handler;
- devcb_write_line m_rxrdy_handler;
- devcb_write_line m_txrdy_handler;
- devcb_write_line m_txempty_handler;
- devcb_write_line m_syndet_handler;
-
- /* flags controlling how i8251_control_w operates */
- UINT8 m_flags;
- /* offset into sync_bytes used during sync byte transfer */
- UINT8 m_sync_byte_offset;
- /* number of sync bytes written so far */
- UINT8 m_sync_byte_count;
- /* the sync bytes written */
- UINT8 m_sync_bytes[2];
- /* status of i8251 */
- UINT8 m_status;
- UINT8 m_command;
- /* mode byte - bit definitions depend on mode - e.g. synchronous, asynchronous */
- UINT8 m_mode_byte;
-
- int m_cts;
- int m_dsr;
- int m_rxd;
- int m_rxc;
- int m_txc;
- int m_rxc_count;
- int m_txc_count;
- int m_br_factor;
-
- /* data being received */
- UINT8 m_rx_data;
- UINT8 m_tx_data;
- bool m_tx_busy;
- bool m_disable_tx_pending;
-};
-
-class v53_scu_device : public i8251_device
-{
-public:
- // construction/destruction
- v53_scu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-
-
-// device type definition
-extern const device_type I8251;
-extern const device_type V53_SCU;
-
-
-#endif /* __I8251_H__ */
diff --git a/src/emu/machine/i82541.c b/src/emu/machine/i82541.c
deleted file mode 100644
index 8e5a1467183..00000000000
--- a/src/emu/machine/i82541.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "i82541.h"
-
-const device_type I82541 = &device_creator<i82541_device>;
-
-DEVICE_ADDRESS_MAP_START(registers_map, 32, i82541_device)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(flash_map, 32, i82541_device)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(registers_io_map, 32, i82541_device)
-ADDRESS_MAP_END
-
-i82541_device::i82541_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_device(mconfig, I82541, "I82541 ethernet controller", tag, owner, clock, "i82541", __FILE__)
-{
-}
-
-void i82541_device::device_start()
-{
- pci_device::device_start();
- add_map(128*1024, M_MEM, FUNC(i82541_device::registers_map));
- add_map(128*1024, M_MEM, FUNC(i82541_device::flash_map));
- add_map(32, M_IO, FUNC(i82541_device::registers_io_map));
-}
-
-void i82541_device::device_reset()
-{
- pci_device::device_reset();
-}
diff --git a/src/emu/machine/i82541.h b/src/emu/machine/i82541.h
deleted file mode 100644
index 810c4dc7b4a..00000000000
--- a/src/emu/machine/i82541.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-// Intel I82541 ethernet controller
-
-#ifndef I82541_H
-#define I82541_H
-
-#include "pci.h"
-
-#define MCFG_I82541PI_ADD(_tag, _subdevice_id) \
- MCFG_PCI_DEVICE_ADD(_tag, I82541, 0x8086107c, 0x05, 0x020000, _subdevice_id)
-
-class i82541_device : public pci_device {
-public:
- i82541_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
-private:
- DECLARE_ADDRESS_MAP(registers_map, 32);
- DECLARE_ADDRESS_MAP(flash_map, 32);
- DECLARE_ADDRESS_MAP(registers_io_map, 32);
-};
-
-extern const device_type I82541;
-
-#endif
diff --git a/src/emu/machine/i8255.c b/src/emu/machine/i8255.c
deleted file mode 100644
index 7725565cde2..00000000000
--- a/src/emu/machine/i8255.c
+++ /dev/null
@@ -1,995 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Intel 8255(A) Programmable Peripheral Interface emulation
-
-**********************************************************************/
-
-#include "i8255.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-enum
-{
- PORT_A = 0,
- PORT_B,
- PORT_C,
- CONTROL
-};
-
-
-enum
-{
- GROUP_A = 0,
- GROUP_B
-};
-
-
-enum
-{
- MODE_0 = 0,
- MODE_1,
- MODE_2
-};
-
-
-enum
-{
- MODE_OUTPUT = 0,
- MODE_INPUT
-};
-
-
-#define CONTROL_PORT_C_LOWER_INPUT 0x01
-#define CONTROL_PORT_B_INPUT 0x02
-#define CONTROL_GROUP_B_MODE_1 0x04
-#define CONTROL_PORT_C_UPPER_INPUT 0x08
-#define CONTROL_PORT_A_INPUT 0x10
-#define CONTROL_GROUP_A_MODE_MASK 0x60
-#define CONTROL_MODE_SET 0x80
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type I8255 = &device_creator<i8255_device>;
-const device_type I8255A = &device_creator<i8255_device>;
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// check_interrupt -
-//-------------------------------------------------
-
-inline void i8255_device::check_interrupt(int port)
-{
- switch (group_mode(port))
- {
- case MODE_1:
- switch (port_mode(port))
- {
- case MODE_INPUT:
- set_intr(port, (m_inte[port] && m_ibf[port]));
- break;
-
- case MODE_OUTPUT:
- set_intr(port, (m_inte[port] && m_obf[port]));
- break;
- }
- break;
-
- case MODE_2:
- set_intr(port, ((m_inte1 && m_obf[port]) || (m_inte2 && m_ibf[port])));
- break;
- }
-}
-
-
-//-------------------------------------------------
-// set_ibf -
-//-------------------------------------------------
-
-inline void i8255_device::set_ibf(int port, int state)
-{
- if (LOG) logerror("I8255 '%s' Port %c IBF: %u\n", tag(), 'A' + port, state);
-
- m_ibf[port] = state;
-
- check_interrupt(port);
-}
-
-
-//-------------------------------------------------
-// set_obf -
-//-------------------------------------------------
-
-inline void i8255_device::set_obf(int port, int state)
-{
- if (LOG) logerror("I8255 '%s' Port %c OBF: %u\n", tag(), 'A' + port, state);
-
- m_obf[port] = state;
-
- check_interrupt(port);
-}
-
-
-//-------------------------------------------------
-// set_inte -
-//-------------------------------------------------
-
-inline void i8255_device::set_inte(int port, int state)
-{
- if (LOG) logerror("I8255 '%s' Port %c INTE: %u\n", tag(), 'A' + port, state);
-
- m_inte[port] = state;
-
- check_interrupt(port);
-}
-
-
-//-------------------------------------------------
-// set_inte1 -
-//-------------------------------------------------
-
-inline void i8255_device::set_inte1(int state)
-{
- if (LOG) logerror("I8255 '%s' Port A INTE1: %u\n", tag(), state);
-
- m_inte1 = state;
-
- check_interrupt(PORT_A);
-}
-
-
-//-------------------------------------------------
-// set_inte2 -
-//-------------------------------------------------
-
-inline void i8255_device::set_inte2(int state)
-{
- if (LOG) logerror("I8255 '%s' Port A INTE2: %u\n", tag(), state);
-
- m_inte2 = state;
-
- check_interrupt(PORT_A);
-}
-
-
-//-------------------------------------------------
-// set_intr -
-//-------------------------------------------------
-
-inline void i8255_device::set_intr(int port, int state)
-{
- if (LOG) logerror("I8255 '%s' Port %c INTR: %u\n", tag(), 'A' + port, state);
-
- m_intr[port] = state;
-
- output_pc();
-}
-
-
-//-------------------------------------------------
-// group_mode -
-//-------------------------------------------------
-
-inline int i8255_device::group_mode(int group)
-{
- int mode = 0;
-
- switch (group)
- {
- case GROUP_A:
- switch ((m_control & CONTROL_GROUP_A_MODE_MASK) >> 5)
- {
- case 0: mode = MODE_0; break;
- case 1: mode = MODE_1; break;
- case 2: case 3: mode = MODE_2; break;
- }
- break;
-
- case GROUP_B:
- mode = m_control & CONTROL_GROUP_B_MODE_1 ? MODE_1 : MODE_0;
- break;
- }
-
- return mode;
-}
-
-
-//-------------------------------------------------
-// port_mode -
-//-------------------------------------------------
-
-inline int i8255_device::port_mode(int port)
-{
- int mode = 0;
-
- switch (port)
- {
- case PORT_A: mode = m_control & CONTROL_PORT_A_INPUT ? MODE_INPUT : MODE_OUTPUT; break;
- case PORT_B: mode = m_control & CONTROL_PORT_B_INPUT ? MODE_INPUT : MODE_OUTPUT; break;
- }
-
- return mode;
-}
-
-
-//-------------------------------------------------
-// port_c_lower_mode -
-//-------------------------------------------------
-
-inline int i8255_device::port_c_lower_mode()
-{
- return m_control & CONTROL_PORT_C_LOWER_INPUT ? MODE_INPUT : MODE_OUTPUT;
-}
-
-
-//-------------------------------------------------
-// port_c_upper_mode -
-//-------------------------------------------------
-
-inline int i8255_device::port_c_upper_mode()
-{
- return m_control & CONTROL_PORT_C_UPPER_INPUT ? MODE_INPUT : MODE_OUTPUT;
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// i8255_device - constructor
-//-------------------------------------------------
-
-i8255_device::i8255_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, I8255, "8255 PPI", tag, owner, clock, "i8255", __FILE__),
- m_in_pa_cb(*this),
- m_in_pb_cb(*this),
- m_in_pc_cb(*this),
- m_out_pa_cb(*this),
- m_out_pb_cb(*this),
- m_out_pc_cb(*this)
-{
- m_intr[PORT_A] = m_intr[PORT_B] = 0;
- m_control = 0;
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void i8255_device::device_start()
-{
- // resolve callbacks
- m_in_pa_cb.resolve_safe(0);
- m_in_pb_cb.resolve_safe(0);
- m_in_pc_cb.resolve_safe(0);
- m_out_pa_cb.resolve_safe();
- m_out_pb_cb.resolve_safe();
- m_out_pc_cb.resolve_safe();
-
- // register for state saving
- save_item(NAME(m_control));
- save_item(NAME(m_output));
- save_item(NAME(m_input));
- save_item(NAME(m_ibf));
- save_item(NAME(m_obf));
- save_item(NAME(m_inte));
- save_item(NAME(m_inte1));
- save_item(NAME(m_inte2));
- save_item(NAME(m_intr));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void i8255_device::device_reset()
-{
- set_mode(0x9b);
-}
-
-
-//-------------------------------------------------
-// read_mode0 -
-//-------------------------------------------------
-
-UINT8 i8255_device::read_mode0(int port)
-{
- UINT8 data = 0;
-
- if (port_mode(port) == MODE_OUTPUT)
- {
- // read data from output latch
- data = m_output[port];
- }
- else
- {
- // read data from port
- data = (port == PORT_A) ? m_in_pa_cb(0) : ((port == PORT_B) ? m_in_pb_cb(0) : m_in_pc_cb(0));
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// read_mode1 -
-//-------------------------------------------------
-
-UINT8 i8255_device::read_mode1(int port)
-{
- UINT8 data = 0;
-
- if (port_mode(port) == MODE_OUTPUT)
- {
- // read data from output latch
- data = m_output[port];
- }
- else
- {
- // read data from input latch
- data = m_input[port];
-
- // clear input buffer full flag
- set_ibf(port, 0);
-
- // clear interrupt
- set_intr(port, 0);
-
- // clear input latch
- m_input[port] = 0;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// read_mode2 -
-//-------------------------------------------------
-
-UINT8 i8255_device::read_mode2()
-{
- UINT8 data = 0;
-
- // read data from input latch
- data = m_input[PORT_A];
-
- // clear input buffer full flag
- set_ibf(PORT_A, 0);
-
- // clear interrupt
- set_intr(PORT_A, 0);
-
- // clear input latch
- m_input[PORT_A] = 0;
-
- return data;
-}
-
-
-//-------------------------------------------------
-// read_pc -
-//-------------------------------------------------
-
-UINT8 i8255_device::read_pc()
-{
- UINT8 data = 0;
- UINT8 mask = 0;
- UINT8 b_mask = 0x0f;
-
- // PC upper
- switch (group_mode(GROUP_A))
- {
- case MODE_0:
- if (port_c_upper_mode() == MODE_OUTPUT)
- {
- // read data from output latch
- data |= m_output[PORT_C] & 0xf0;
- }
- else
- {
- // read data from port
- mask |= 0xf0;
- }
- break;
-
- case MODE_1:
- data |= m_intr[PORT_A] ? 0x08 : 0x00;
-
- if (port_mode(PORT_A) == MODE_OUTPUT)
- {
- data |= m_obf[PORT_A] ? 0x80 : 0x00;
- data |= m_inte[PORT_A] ? 0x40 : 0x00;
- mask |= 0x30;
- }
- else
- {
- data |= m_ibf[PORT_A] ? 0x20 : 0x00;
- data |= m_inte[PORT_A] ? 0x10 : 0x00;
- mask |= 0xc0;
- }
- break;
-
- case MODE_2:
- b_mask = 0x07;
- data |= m_intr[PORT_A] ? 0x08 : 0x00;
- data |= m_inte2 ? 0x10 : 0x00;
- data |= m_ibf[PORT_A] ? 0x20 : 0x00;
- data |= m_inte1 ? 0x40 : 0x00;
- data |= m_obf[PORT_A] ? 0x80 : 0x00;
- break;
- }
-
- // PC lower
- switch (group_mode(GROUP_B))
- {
- case MODE_0:
- if (port_c_lower_mode() == MODE_OUTPUT)
- {
- // read data from output latch
- data |= m_output[PORT_C] & b_mask;
- }
- else
- {
- // read data from port
- mask |= b_mask;
- }
- break;
-
- case MODE_1:
- data |= m_inte[PORT_B] ? 0x04 : 0x00;
- data |= m_intr[PORT_B] ? 0x01 : 0x00;
-
- if (port_mode(PORT_B) == MODE_OUTPUT)
- {
- data |= m_obf[PORT_B] ? 0x02 : 0x00;
- }
- else
- {
- data |= m_ibf[PORT_B] ? 0x02 : 0x00;
- }
- }
-
- if (mask)
- {
- // read data from port
- data |= m_in_pc_cb(0) & mask;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write_mode0 -
-//-------------------------------------------------
-
-void i8255_device::write_mode0(int port, UINT8 data)
-{
- if (port_mode(port) == MODE_OUTPUT)
- {
- // latch output data
- m_output[port] = data;
-
- // write data to port
- if (port == PORT_A)
- m_out_pa_cb((offs_t)0, m_output[port]);
- else if (port == PORT_B)
- m_out_pb_cb((offs_t)0, m_output[port]);
- else
- m_out_pc_cb((offs_t)0, m_output[port]);
- }
-}
-
-
-//-------------------------------------------------
-// write_mode1 -
-//-------------------------------------------------
-
-void i8255_device::write_mode1(int port, UINT8 data)
-{
- if (port_mode(port) == MODE_OUTPUT)
- {
- // latch output data
- m_output[port] = data;
-
- // write data to port
- if (port == PORT_A)
- m_out_pa_cb((offs_t)0, m_output[port]);
- else if (port == PORT_B)
- m_out_pb_cb((offs_t)0, m_output[port]);
- else
- m_out_pc_cb((offs_t)0, m_output[port]);
-
- // set output buffer full flag
- set_obf(port, 0);
-
- // clear interrupt
- set_intr(port, 0);
- }
-}
-
-
-//-------------------------------------------------
-// write_mode2 -
-//-------------------------------------------------
-
-void i8255_device::write_mode2(UINT8 data)
-{
- // latch output data
- m_output[PORT_A] = data;
-
- // write data to port
- m_out_pa_cb((offs_t)0, data);
-
- // set output buffer full flag
- set_obf(PORT_A, 0);
-
- // clear interrupt
- set_intr(PORT_A, 0);
-}
-
-
-//-------------------------------------------------
-// output_pc -
-//-------------------------------------------------
-
-void i8255_device::output_pc()
-{
- UINT8 data = 0;
- UINT8 mask = 0;
- UINT8 b_mask = 0x0f;
-
- // PC upper
- switch (group_mode(GROUP_A))
- {
- case MODE_0:
- if (port_c_upper_mode() == MODE_OUTPUT)
- {
- mask |= 0xf0;
- }
- else
- {
- // TTL inputs float high
- data |= 0xf0;
- }
- break;
-
- case MODE_1:
- data |= m_intr[PORT_A] ? 0x08 : 0x00;
-
- if (port_mode(PORT_A) == MODE_OUTPUT)
- {
- data |= m_obf[PORT_A] ? 0x80 : 0x00;
- mask |= 0x30;
- }
- else
- {
- data |= m_ibf[PORT_A] ? 0x20 : 0x00;
- mask |= 0xc0;
- }
- break;
-
- case MODE_2:
- b_mask = 0x07;
- data |= m_intr[PORT_A] ? 0x08 : 0x00;
- data |= m_ibf[PORT_A] ? 0x20 : 0x00;
- data |= m_obf[PORT_A] ? 0x80 : 0x00;
- break;
- }
-
- // PC lower
- switch (group_mode(GROUP_B))
- {
- case MODE_0:
- if (port_c_lower_mode() == MODE_OUTPUT)
- {
- mask |= b_mask;
- }
- else
- {
- // TTL inputs float high
- data |= b_mask;
- }
- break;
-
- case MODE_1:
- data |= m_intr[PORT_B] ? 0x01 : 0x00;
-
- if (port_mode(PORT_B) == MODE_OUTPUT)
- {
- data |= m_obf[PORT_B] ? 0x02 : 0x00;
- }
- else
- {
- data |= m_ibf[PORT_B] ? 0x02 : 0x00;
- }
- }
-
- data |= m_output[PORT_C] & mask;
-
- m_out_pc_cb((offs_t)0, data);
-}
-
-
-//-------------------------------------------------
-// set_mode -
-//-------------------------------------------------
-
-void i8255_device::set_mode(UINT8 data)
-{
- m_control = data;
-
- // group A
- m_output[PORT_A] = 0;
- m_input[PORT_A] = 0;
- m_ibf[PORT_A] = 0;
- m_obf[PORT_A] = 1;
- m_inte[PORT_A] = 0;
- m_inte1 = 0;
- m_inte2 = 0;
-
- if (port_mode(PORT_A) == MODE_OUTPUT)
- {
- m_out_pa_cb((offs_t)0, m_output[PORT_A]);
- }
- else
- {
- // TTL inputs float high
- m_out_pa_cb((offs_t)0, 0xff);
- }
-
- if (LOG)
- {
- logerror("I8255 '%s' Group A Mode: %u\n", tag(), group_mode(GROUP_A));
- logerror("I8255 '%s' Port A Mode: %s\n", tag(), (port_mode(PORT_A) == MODE_OUTPUT) ? "output" : "input");
- logerror("I8255 '%s' Port C Upper Mode: %s\n", tag(), (port_c_upper_mode() == MODE_OUTPUT) ? "output" : "input");
- logerror("I8255 '%s' Group B Mode: %u\n", tag(), group_mode(GROUP_B));
- logerror("I8255 '%s' Port B Mode: %s\n", tag(), (port_mode(PORT_B) == MODE_OUTPUT) ? "output" : "input");
- logerror("I8255 '%s' Port C Lower Mode: %s\n", tag(), (port_c_lower_mode() == MODE_OUTPUT) ? "output" : "input");
- }
-
- // group B
- m_output[PORT_B] = 0;
- m_input[PORT_B] = 0;
- m_ibf[PORT_B] = 0;
- m_obf[PORT_B] = 1;
- m_inte[PORT_B] = 0;
-
- if (port_mode(PORT_B) == MODE_OUTPUT)
- {
- m_out_pb_cb((offs_t)0, m_output[PORT_B]);
- }
- else
- {
- // TTL inputs float high
- m_out_pb_cb((offs_t)0, 0xff);
- }
-
- m_output[PORT_C] = 0;
- m_input[PORT_C] = 0;
-
- output_pc();
-}
-
-
-//-------------------------------------------------
-// set_pc_bit -
-//-------------------------------------------------
-
-void i8255_device::set_pc_bit(int bit, int state)
-{
- // set output latch bit
- m_output[PORT_C] &= ~(1 << bit);
- m_output[PORT_C] |= state << bit;
-
- switch (group_mode(GROUP_A))
- {
- case MODE_1:
- if (port_mode(PORT_A) == MODE_OUTPUT)
- {
- switch (bit)
- {
- case 3: set_intr(PORT_A, state); break;
- case 6: set_inte(PORT_A, state); break;
- case 7: set_obf(PORT_A, state); break;
- default: break;
- }
- }
- else
- {
- switch (bit)
- {
- case 3: set_intr(PORT_A, state); break;
- case 4: set_inte(PORT_A, state); break;
- case 5: set_ibf(PORT_A, state); break;
- default: break;
- }
- }
- break;
-
- case MODE_2:
- switch (bit)
- {
- case 3: set_intr(PORT_A, state); break;
- case 4: set_inte2(state); break;
- case 5: set_ibf(PORT_A, state); break;
- case 6: set_inte1(state); break;
- case 7: set_obf(PORT_A, state); break;
- default: break;
- }
- break;
- }
-
- if (group_mode(GROUP_B) == MODE_1)
- {
- switch (bit)
- {
- case 0: set_intr(PORT_B, state); break;
- case 1:
- if (port_mode(PORT_B) == MODE_OUTPUT)
- set_obf(PORT_B, state);
- else
- set_ibf(PORT_B, state);
- break;
- case 2: set_inte(PORT_B, state); break;
- default: break;
- }
- }
-
- output_pc();
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( i8255_device::read )
-{
- UINT8 data = 0;
-
- switch (offset & 0x03)
- {
- case PORT_A:
- switch (group_mode(GROUP_A))
- {
- case MODE_0: data = read_mode0(PORT_A); break;
- case MODE_1: data = read_mode1(PORT_A); break;
- case MODE_2: data = read_mode2(); break;
- }
- if (LOG) logerror("I8255 '%s' Port A Read: %02x\n", tag(), data);
- break;
-
- case PORT_B:
- switch (group_mode(GROUP_B))
- {
- case MODE_0: data = read_mode0(PORT_B); break;
- case MODE_1: data = read_mode1(PORT_B); break;
- }
- if (LOG) logerror("I8255 '%s' Port B Read: %02x\n", tag(), data);
- break;
-
- case PORT_C:
- data = read_pc();
- if (LOG) logerror("I8255 '%s' Port C Read: %02x\n", tag(), data);
- break;
-
- case CONTROL:
- data = m_control;
- if (LOG) logerror("I8255 '%s' Mode Control Word Read: %02x\n", tag(), data);
- break;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( i8255_device::write )
-{
- switch (offset & 0x03)
- {
- case PORT_A:
- if (LOG) logerror("I8255 '%s' Port A Write: %02x\n", tag(), data);
-
- switch (group_mode(GROUP_A))
- {
- case MODE_0: write_mode0(PORT_A, data); break;
- case MODE_1: write_mode1(PORT_A, data); break;
- case MODE_2: write_mode2(data); break;
- }
- break;
-
- case PORT_B:
- if (LOG) logerror("I8255 '%s' Port B Write: %02x\n", tag(), data);
-
- switch (group_mode(GROUP_B))
- {
- case MODE_0: write_mode0(PORT_B, data); break;
- case MODE_1: write_mode1(PORT_B, data); break;
- }
- break;
-
- case PORT_C:
- if (LOG) logerror("I8255 '%s' Port C Write: %02x\n", tag(), data);
-
- m_output[PORT_C] = data;
- output_pc();
- break;
-
- case CONTROL:
- if (data & CONTROL_MODE_SET)
- {
- if (LOG) logerror("I8255 '%s' Mode Control Word: %02x\n", tag(), data);
-
- set_mode(data);
- }
- else
- {
- int bit = (data >> 1) & 0x07;
- int state = BIT(data, 0);
-
- if (LOG) logerror("I8255 '%s' %s Port C Bit %u\n", tag(), state ? "Set" : "Reset", bit);
-
- set_pc_bit(bit, state);
- }
- break;
- }
-}
-
-
-//-------------------------------------------------
-// pa_r -
-//-------------------------------------------------
-
-READ8_MEMBER( i8255_device::pa_r )
-{
- return pa_r();
-}
-
-
-//-------------------------------------------------
-// pb_r - port A read
-//-------------------------------------------------
-
-UINT8 i8255_device::pa_r()
-{
- UINT8 data = 0xff;
-
- if (port_mode(PORT_A) == MODE_OUTPUT)
- {
- data = m_output[PORT_A];
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// pb_r -
-//-------------------------------------------------
-
-READ8_MEMBER( i8255_device::pb_r )
-{
- return pb_r();
-}
-
-
-//-------------------------------------------------
-// pb_r - port B read
-//-------------------------------------------------
-
-UINT8 i8255_device::pb_r()
-{
- UINT8 data = 0xff;
-
- if (port_mode(PORT_B) == MODE_OUTPUT)
- {
- data = m_output[PORT_B];
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// pc2_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8255_device::pc2_w )
-{
- if (group_mode(GROUP_B) == 1)
- {
- if (port_mode(PORT_B) == MODE_OUTPUT)
- {
- // port B acknowledge
- if (!m_obf[PORT_B] && !state)
- {
- if (LOG) logerror("I8255 '%s' Port B Acknowledge\n", tag());
-
- // clear output buffer flag
- set_obf(PORT_B, 1);
- }
- }
- else
- {
- // port B strobe
- if (!m_ibf[PORT_B] && !state)
- {
- if (LOG) logerror("I8255 '%s' Port B Strobe\n", tag());
-
- // read port into latch
- m_input[PORT_B] = m_in_pb_cb(0);
-
- // set input buffer flag
- set_ibf(PORT_B, 1);
- }
- }
- }
-}
-
-
-//-------------------------------------------------
-// pc4_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8255_device::pc4_w )
-{
- if ((group_mode(GROUP_A) == 2) || ((group_mode(GROUP_A) == 1) && (port_mode(PORT_A) == MODE_INPUT)))
- {
- // port A strobe
- if (!m_ibf[PORT_A] && !state)
- {
- if (LOG) logerror("I8255 '%s' Port A Strobe\n", tag());
-
- // read port into latch
- m_input[PORT_A] = m_in_pa_cb(0);
-
- // set input buffer flag
- set_ibf(PORT_A, 1);
- }
- }
-}
-
-
-//-------------------------------------------------
-// pc6_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8255_device::pc6_w )
-{
- if ((group_mode(GROUP_A) == 2) || ((group_mode(GROUP_A) == 1) && (port_mode(PORT_A) == MODE_OUTPUT)))
- {
- // port A acknowledge
- if (!m_obf[PORT_A] && !state)
- {
- if (LOG) logerror("I8255 '%s' Port A Acknowledge\n", tag());
-
- // clear output buffer flag
- set_obf(PORT_A, 1);
- }
- }
-}
diff --git a/src/emu/machine/i8255.h b/src/emu/machine/i8255.h
deleted file mode 100644
index c232b2105e0..00000000000
--- a/src/emu/machine/i8255.h
+++ /dev/null
@@ -1,148 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Intel 8255(A) Programmable Peripheral Interface emulation
-
-**********************************************************************
- _____ _____
- PA3 1 |* \_/ | 40 PA4
- PA2 2 | | 39 PA5
- PA1 3 | | 38 PA6
- PA0 4 | | 37 PA7
- _RD 5 | | 36 WR
- _CS 6 | | 35 RESET
- GND 7 | | 34 D0
- A1 8 | | 33 D1
- A0 9 | | 32 D2
- PC7 10 | 8255 | 31 D3
- PC6 11 | 8255A | 30 D4
- PC5 12 | | 29 D5
- PC4 13 | | 28 D6
- PC0 14 | | 27 D7
- PC1 15 | | 26 Vcc
- PC2 16 | | 25 PB7
- PC3 17 | | 24 PB6
- PB0 18 | | 23 PB5
- PB1 19 | | 22 PB4
- PB2 20 |_____________| 21 PB3
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __I8255__
-#define __I8255__
-
-#include "emu.h"
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_I8255_IN_PORTA_CB(_devcb) \
- devcb = &i8255_device::set_in_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8255_IN_PORTB_CB(_devcb) \
- devcb = &i8255_device::set_in_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8255_IN_PORTC_CB(_devcb) \
- devcb = &i8255_device::set_in_pc_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8255_OUT_PORTA_CB(_devcb) \
- devcb = &i8255_device::set_out_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8255_OUT_PORTB_CB(_devcb) \
- devcb = &i8255_device::set_out_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8255_OUT_PORTC_CB(_devcb) \
- devcb = &i8255_device::set_out_pc_callback(*device, DEVCB_##_devcb);
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> i8255_device
-
-class i8255_device : public device_t
-{
-public:
- // construction/destruction
- i8255_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_in_pa_callback(device_t &device, _Object object) { return downcast<i8255_device &>(device).m_in_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_pb_callback(device_t &device, _Object object) { return downcast<i8255_device &>(device).m_in_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_pc_callback(device_t &device, _Object object) { return downcast<i8255_device &>(device).m_in_pc_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pa_callback(device_t &device, _Object object) { return downcast<i8255_device &>(device).m_out_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pb_callback(device_t &device, _Object object) { return downcast<i8255_device &>(device).m_out_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pc_callback(device_t &device, _Object object) { return downcast<i8255_device &>(device).m_out_pc_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_READ8_MEMBER( pa_r );
- UINT8 pa_r();
-
- DECLARE_READ8_MEMBER( pb_r );
- UINT8 pb_r();
-
- DECLARE_WRITE_LINE_MEMBER( pc2_w );
- DECLARE_WRITE_LINE_MEMBER( pc4_w );
- DECLARE_WRITE_LINE_MEMBER( pc6_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- inline void check_interrupt(int port);
- inline void set_ibf(int port, int state);
- inline void set_obf(int port, int state);
- inline void set_inte(int port, int state);
- inline void set_inte1(int state);
- inline void set_inte2(int state);
- inline void set_intr(int port, int state);
- inline int group_mode(int group);
- inline int port_mode(int port);
- inline int port_c_lower_mode();
- inline int port_c_upper_mode();
-
- UINT8 read_mode0(int port);
- UINT8 read_mode1(int port);
- UINT8 read_mode2();
- UINT8 read_pc();
- void write_mode0(int port, UINT8 data);
- void write_mode1(int port, UINT8 data);
- void write_mode2(UINT8 data);
- void output_pc();
- void set_mode(UINT8 data);
- void set_pc_bit(int bit, int state);
-
- devcb_read8 m_in_pa_cb;
- devcb_read8 m_in_pb_cb;
- devcb_read8 m_in_pc_cb;
-
- devcb_write8 m_out_pa_cb;
- devcb_write8 m_out_pb_cb;
- devcb_write8 m_out_pc_cb;
-
- UINT8 m_control; // mode control word
- UINT8 m_output[3]; // output latch
- UINT8 m_input[3]; // input latch
-
- int m_ibf[2]; // input buffer full flag
- int m_obf[2]; // output buffer full flag, negative logic
- int m_inte[2]; // interrupt enable
- int m_inte1; // interrupt enable
- int m_inte2; // interrupt enable
- int m_intr[2]; // interrupt
-};
-
-
-// device type definition
-extern const device_type I8255;
-extern const device_type I8255A;
-
-
-#endif
diff --git a/src/emu/machine/i8257.c b/src/emu/machine/i8257.c
deleted file mode 100644
index 23abcc3915c..00000000000
--- a/src/emu/machine/i8257.c
+++ /dev/null
@@ -1,668 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder,Carl
-/***************************************************************************
-
- Intel 8257 DMA Controller emulation
-
-***************************************************************************/
-
-#include "i8257.h"
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type I8257 = &device_creator<i8257_device>;
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-enum
-{
- REGISTER_ADDRESS = 0,
- REGISTER_WORD_COUNT,
- REGISTER_STATUS = 8,
- REGISTER_MODE = REGISTER_STATUS
-};
-
-
-#define MODE_CHAN_ENABLE(x) BIT(m_transfer_mode, x)
-#define MODE_ROTATING_PRIORITY BIT(m_transfer_mode, 4)
-#define MODE_EXTENDED_WRITE BIT(m_transfer_mode, 5)
-#define MODE_TC_STOP BIT(m_transfer_mode, 6)
-#define MODE_AUTOLOAD BIT(m_transfer_mode, 7)
-#define MODE_TRANSFER_MASK (m_channel[m_current_channel].m_mode)
-#define MODE_TRANSFER_VERIFY 0
-#define MODE_TRANSFER_WRITE 1
-#define MODE_TRANSFER_READ 2
-
-
-enum
-{
- STATE_SI,
- STATE_S0,
- STATE_S1,
- STATE_S2,
- STATE_S3,
- STATE_SW,
- STATE_S4
-};
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// dma_request -
-//-------------------------------------------------
-
-inline void i8257_device::dma_request(int channel, int state)
-{
- if (LOG) logerror("I8257 '%s' Channel %u DMA Request: %u\n", tag(), channel, state);
-
- if (state)
- {
- m_request |= 1 << channel;
- }
- else
- {
- m_request &= ~(1 << channel);
- }
- trigger(1);
-}
-
-
-//-------------------------------------------------
-// is_request_active -
-//-------------------------------------------------
-
-inline bool i8257_device::is_request_active(int channel)
-{
- return (BIT(m_request, channel) && MODE_CHAN_ENABLE(channel)) ? true : false;
-}
-
-//-------------------------------------------------
-// set_hreq
-//-------------------------------------------------
-
-inline void i8257_device::set_hreq(int state)
-{
- if (m_hreq != state)
- {
- m_out_hrq_cb(state);
- m_hreq = state;
- }
-}
-
-
-//-------------------------------------------------
-// set_tc -
-//-------------------------------------------------
-
-inline void i8257_device::set_tc(int state)
-{
- if (m_tc != state)
- {
- m_out_tc_cb(state);
-
- m_tc = state;
- }
-}
-
-
-//-------------------------------------------------
-// set_dack - dack is active low
-//-------------------------------------------------
-
-inline void i8257_device::set_dack()
-{
- m_out_dack_0_cb(m_current_channel != 0);
- m_out_dack_1_cb(m_current_channel != 1);
- m_out_dack_2_cb(m_current_channel != 2);
- m_out_dack_3_cb(m_current_channel != 3);
-}
-
-
-//-------------------------------------------------
-// dma_read -
-//-------------------------------------------------
-
-inline void i8257_device::dma_read()
-{
- offs_t offset = m_channel[m_current_channel].m_address;
-
- switch (MODE_TRANSFER_MASK)
- {
- case MODE_TRANSFER_VERIFY:
- case MODE_TRANSFER_WRITE:
- switch(m_current_channel)
- {
- case 0:
- m_temp = m_in_ior_0_cb(offset);
- break;
- case 1:
- m_temp = m_in_ior_1_cb(offset);
- break;
- case 2:
- m_temp = m_in_ior_2_cb(offset);
- break;
- case 3:
- m_temp = m_in_ior_3_cb(offset);
- break;
- }
- break;
-
- case MODE_TRANSFER_READ:
- m_temp = m_in_memr_cb(offset);
- break;
- }
-
-}
-
-
-//-------------------------------------------------
-// dma_write -
-//-------------------------------------------------
-
-inline void i8257_device::dma_write()
-{
- offs_t offset = m_channel[m_current_channel].m_address;
-
- switch (MODE_TRANSFER_MASK)
- {
- case MODE_TRANSFER_VERIFY: {
- UINT8 v1 = m_in_memr_cb(offset);
- if(0 && m_temp != v1)
- logerror("%s: verify error %02x vs. %02x\n", tag(), m_temp, v1);
- break;
- }
-
- case MODE_TRANSFER_WRITE:
- m_out_memw_cb(offset, m_temp);
- break;
-
- case MODE_TRANSFER_READ:
- switch(m_current_channel)
- {
- case 0:
- m_out_iow_0_cb(offset, m_temp);
- break;
- case 1:
- m_out_iow_1_cb(offset, m_temp);
- break;
- case 2:
- m_out_iow_2_cb(offset, m_temp);
- break;
- case 3:
- m_out_iow_3_cb(offset, m_temp);
- break;
- }
- break;
- }
-}
-
-
-//-------------------------------------------------
-// end_of_process -
-//-------------------------------------------------
-
-inline void i8257_device::advance()
-{
- bool tc = (m_channel[m_current_channel].m_count == 0);
- bool al = (MODE_AUTOLOAD && (m_current_channel == 2));
-
- if(tc)
- {
- m_status |= 1 << m_current_channel;
- m_request &= ~(1 << m_current_channel); // docs imply this isn't right but pc-8001 works better with it
- set_tc(1);
-
- if(al)
- {
- // autoinitialize
- m_channel[2].m_address = m_channel[3].m_address;
- m_channel[2].m_count = m_channel[3].m_count;
- m_channel[2].m_mode = m_channel[3].m_mode;
- }
- else if(MODE_TC_STOP)
- // disable channel
- m_transfer_mode &= ~(1 << m_current_channel);
- }
-
- if(!(al && tc))
- {
- m_channel[m_current_channel].m_count--;
- m_channel[m_current_channel].m_count &= 0x3fff;
- m_channel[m_current_channel].m_address++;
- }
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// i8257_device - constructor
-//-------------------------------------------------
-
-i8257_device::i8257_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, I8257, "Intel 8257", tag, owner, clock, "i8257", __FILE__),
- device_execute_interface(mconfig, *this),
- m_icount(0),
- m_reverse_rw(0),
- m_tc(false),
- m_msb(0),
- m_hreq(CLEAR_LINE),
- m_hack(0),
- m_ready(1),
- m_state(0),
- m_current_channel(0),
- m_last_channel(0),
- m_transfer_mode(0),
- m_status(0),
- m_request(0),
- m_temp(0),
- m_out_hrq_cb(*this),
- m_out_tc_cb(*this),
- m_in_memr_cb(*this),
- m_out_memw_cb(*this),
- m_in_ior_0_cb(*this),
- m_in_ior_1_cb(*this),
- m_in_ior_2_cb(*this),
- m_in_ior_3_cb(*this),
- m_out_iow_0_cb(*this),
- m_out_iow_1_cb(*this),
- m_out_iow_2_cb(*this),
- m_out_iow_3_cb(*this),
- m_out_dack_0_cb(*this),
- m_out_dack_1_cb(*this),
- m_out_dack_2_cb(*this),
- m_out_dack_3_cb(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void i8257_device::device_start()
-{
- // set our instruction counter
- m_icountptr = &m_icount;
-
- // resolve callbacks
- m_out_hrq_cb.resolve_safe();
- m_out_tc_cb.resolve_safe();
- m_in_memr_cb.resolve_safe(0);
- m_out_memw_cb.resolve_safe();
- m_in_ior_0_cb.resolve_safe(0);
- m_in_ior_1_cb.resolve_safe(0);
- m_in_ior_2_cb.resolve_safe(0);
- m_in_ior_3_cb.resolve_safe(0);
- m_out_iow_0_cb.resolve_safe();
- m_out_iow_1_cb.resolve_safe();
- m_out_iow_2_cb.resolve_safe();
- m_out_iow_3_cb.resolve_safe();
- m_out_dack_0_cb.resolve_safe();
- m_out_dack_1_cb.resolve_safe();
- m_out_dack_2_cb.resolve_safe();
- m_out_dack_3_cb.resolve_safe();
-
- // state saving
- save_item(NAME(m_msb));
- save_item(NAME(m_hreq));
- save_item(NAME(m_hack));
- save_item(NAME(m_ready));
- save_item(NAME(m_state));
- save_item(NAME(m_current_channel));
- save_item(NAME(m_last_channel));
- save_item(NAME(m_transfer_mode));
- save_item(NAME(m_status));
- save_item(NAME(m_request));
-
- save_item(NAME(m_channel[0].m_address));
- save_item(NAME(m_channel[0].m_count));
- save_item(NAME(m_channel[0].m_mode));
- save_item(NAME(m_channel[1].m_address));
- save_item(NAME(m_channel[1].m_count));
- save_item(NAME(m_channel[1].m_mode));
- save_item(NAME(m_channel[2].m_address));
- save_item(NAME(m_channel[2].m_count));
- save_item(NAME(m_channel[2].m_mode));
- save_item(NAME(m_channel[3].m_address));
- save_item(NAME(m_channel[3].m_count));
- save_item(NAME(m_channel[3].m_mode));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void i8257_device::device_reset()
-{
- m_state = STATE_SI;
- m_transfer_mode = 0;
- m_status = 0;
- m_request = 0;
- m_msb = 0;
- m_current_channel = -1;
- m_last_channel = 3;
- m_hreq = -1;
- m_tc = 0;
-
- for (int i = 0; i < 4; i++)
- {
- m_channel[i].m_address = 0;
- m_channel[i].m_count = 0;
- m_channel[i].m_mode = 0;
- }
- set_hreq(0);
- set_dack();
-}
-
-bool i8257_device::next_channel()
-{
- int priority[] = { 0, 1, 2, 3 };
-
- if (MODE_ROTATING_PRIORITY)
- {
- int last_channel = m_last_channel;
-
- for (int channel = 3; channel >= 0; channel--)
- {
- priority[channel] = last_channel;
- last_channel--;
- if (last_channel < 0) last_channel = 3;
- }
- }
-
- for (int channel = 0; channel < 4; channel++)
- {
- if (is_request_active(priority[channel]))
- {
- m_current_channel = m_last_channel = priority[channel];
- return true;
- }
- }
- return false;
-}
-
-
-//-------------------------------------------------
-// execute_run -
-//-------------------------------------------------
-
-void i8257_device::execute_run()
-{
- do
- {
- switch (m_state)
- {
- case STATE_SI:
- set_tc(0);
- if(next_channel())
- m_state = STATE_S0;
- else
- {
- suspend_until_trigger(1, true);
- m_icount = 0;
- }
- break;
-
- case STATE_S0:
- set_hreq(1);
-
- if (m_hack)
- {
- m_state = STATE_S1;
- }
- else
- {
- suspend_until_trigger(1, true);
- m_icount = 0;
- }
- break;
-
- case STATE_S1:
- set_tc(0);
- m_state = STATE_S2;
- break;
-
- case STATE_S2:
- set_dack();
- m_state = STATE_S3;
- break;
-
- case STATE_S3:
- dma_read();
-
- if (MODE_EXTENDED_WRITE)
- {
- dma_write();
- }
-
- m_state = m_ready ? STATE_S4 : STATE_SW;
- break;
-
- case STATE_SW:
- m_state = m_ready ? STATE_S4 : STATE_SW;
- break;
-
- case STATE_S4:
- if (!MODE_EXTENDED_WRITE)
- {
- dma_write();
- }
- advance();
-
- if(next_channel())
- m_state = STATE_S1;
- else
- {
- set_hreq(0);
- m_current_channel = -1;
- m_state = STATE_SI;
- set_dack();
- }
- break;
- }
- m_icount--;
- } while (m_icount > 0);
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( i8257_device::read )
-{
- UINT8 data = 0;
-
- if (!BIT(offset, 3))
- {
- int channel = (offset >> 1) & 0x03;
-
- switch (offset & 0x01)
- {
- case REGISTER_ADDRESS:
- if (m_msb)
- {
- data = m_channel[channel].m_address >> 8;
- }
- else
- {
- data = m_channel[channel].m_address & 0xff;
- }
- break;
-
- case REGISTER_WORD_COUNT:
- if (m_msb)
- {
- data = (m_channel[channel].m_count >> 8);
- if(m_reverse_rw && m_channel[channel].m_mode)
- data |= (m_channel[channel].m_mode == 1) ? 0x80 : 0x40;
- else
- data |= (m_channel[channel].m_mode << 6);
- }
- else
- {
- data = m_channel[channel].m_count & 0xff;
- }
- break;
- }
-
- m_msb = !m_msb;
- }
- else if(offset == REGISTER_STATUS)
- {
- data = m_status;
-
- // clear TC bits
- m_status &= 0xf0;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( i8257_device::write )
-{
- if (!BIT(offset, 3))
- {
- int channel = (offset >> 1) & 0x03;
-
- switch (offset & 0x01)
- {
- case REGISTER_ADDRESS:
- if (m_msb)
- {
- m_channel[channel].m_address = (data << 8) | (m_channel[channel].m_address & 0xff);
- if(MODE_AUTOLOAD && (channel == 2))
- m_channel[3].m_address = (data << 8) | (m_channel[3].m_address & 0xff);
- }
- else
- {
- m_channel[channel].m_address = (m_channel[channel].m_address & 0xff00) | data;
- if(MODE_AUTOLOAD && (channel == 2))
- m_channel[3].m_address = (m_channel[3].m_address & 0xff00) | data;
- }
- break;
-
- case REGISTER_WORD_COUNT:
- if (m_msb)
- {
- m_channel[channel].m_count = ((data & 0x3f) << 8) | (m_channel[channel].m_count & 0xff);
- m_channel[channel].m_mode = (data >> 6);
-
- if(m_reverse_rw && m_channel[channel].m_mode)
- m_channel[channel].m_mode = (m_channel[channel].m_mode == 1) ? 2 : 1;
-
- if(MODE_AUTOLOAD && (channel == 2))
- {
- m_channel[3].m_count = ((data & 0x3f) << 8) | (m_channel[3].m_count & 0xff);
- m_channel[3].m_mode = m_channel[2].m_mode;
- }
- }
- else
- {
- m_channel[channel].m_count = (m_channel[channel].m_count & 0xff00) | data;
- if(MODE_AUTOLOAD && (channel == 2))
- m_channel[3].m_count = (m_channel[3].m_count & 0xff00) | data;
- }
- break;
- }
-
- m_msb = !m_msb;
- }
- else if(offset == REGISTER_MODE)
- {
- m_transfer_mode = data;
-
- if (LOG) logerror("I8257 '%s' Command Register: %02x\n", tag(), m_transfer_mode);
- }
- trigger(1);
-}
-
-
-//-------------------------------------------------
-// hlda_w - hold acknowledge
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8257_device::hlda_w )
-{
- if (LOG) logerror("I8257 '%s' Hold Acknowledge: %u\n", tag(), state);
-
- m_hack = state;
- trigger(1);
-}
-
-
-//-------------------------------------------------
-// ready_w - ready
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8257_device::ready_w )
-{
- if (LOG) logerror("I8257 '%s' Ready: %u\n", tag(), state);
-
- m_ready = state;
-}
-
-
-//-------------------------------------------------
-// dreq0_w - DMA request for channel 0
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8257_device::dreq0_w )
-{
- dma_request(0, state);
-}
-
-
-//-------------------------------------------------
-// dreq0_w - DMA request for channel 1
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8257_device::dreq1_w )
-{
- dma_request(1, state);
-}
-
-
-//-------------------------------------------------
-// dreq1_w - DMA request for channel 2
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8257_device::dreq2_w )
-{
- dma_request(2, state);
-}
-
-
-//-------------------------------------------------
-// dreq3_w - DMA request for channel 3
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( i8257_device::dreq3_w )
-{
- dma_request(3, state);
-}
diff --git a/src/emu/machine/i8257.h b/src/emu/machine/i8257.h
deleted file mode 100644
index 9ab509d38e7..00000000000
--- a/src/emu/machine/i8257.h
+++ /dev/null
@@ -1,207 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- Intel 8257 DMA Controller emulation
-
-****************************************************************************
- _____ _____
- _I/OR 1 |* \_/ | 40 A7
- _I/OW 2 | | 39 A6
- _MEMR 3 | | 38 A5
- _MEMW 4 | | 37 A4
- MARK 5 | | 36 TC
- READY 6 | | 35 A3
- HLDA 7 | | 34 A2
- ADSTB 8 | | 33 A1
- AEN 9 | | 32 A0
- HRQ 10 | 8257 | 31 Vcc
- _CS 11 | | 30 D0
- CLK 12 | | 29 D1
- RESET 13 | | 28 D2
- _DACK2 14 | | 27 D3
- _DACK3 15 | | 26 D4
- DRQ3 16 | | 25 _DACK0
- DRQ2 17 | | 24 _DACK1
- DRQ1 18 | | 23 D5
- DRQ0 19 | | 22 D6
- GND 20 |_____________| 21 D7
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __I8257__
-#define __I8257__
-
-#include "emu.h"
-
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_I8257_OUT_HRQ_CB(_devcb) \
- devcb = &i8257_device::set_out_hrq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_OUT_TC_CB(_devcb) \
- devcb = &i8257_device::set_out_tc_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_IN_MEMR_CB(_devcb) \
- devcb = &i8257_device::set_in_memr_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_OUT_MEMW_CB(_devcb) \
- devcb = &i8257_device::set_out_memw_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_IN_IOR_0_CB(_devcb) \
- devcb = &i8257_device::set_in_ior_0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_IN_IOR_1_CB(_devcb) \
- devcb = &i8257_device::set_in_ior_1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_IN_IOR_2_CB(_devcb) \
- devcb = &i8257_device::set_in_ior_2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_IN_IOR_3_CB(_devcb) \
- devcb = &i8257_device::set_in_ior_3_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_OUT_IOW_0_CB(_devcb) \
- devcb = &i8257_device::set_out_iow_0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_OUT_IOW_1_CB(_devcb) \
- devcb = &i8257_device::set_out_iow_1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_OUT_IOW_2_CB(_devcb) \
- devcb = &i8257_device::set_out_iow_2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_OUT_IOW_3_CB(_devcb) \
- devcb = &i8257_device::set_out_iow_3_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_OUT_DACK_0_CB(_devcb) \
- devcb = &i8257_device::set_out_dack_0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_OUT_DACK_1_CB(_devcb) \
- devcb = &i8257_device::set_out_dack_1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_OUT_DACK_2_CB(_devcb) \
- devcb = &i8257_device::set_out_dack_2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8257_OUT_DACK_3_CB(_devcb) \
- devcb = &i8257_device::set_out_dack_3_callback(*device, DEVCB_##_devcb);
-
-// HACK: the radio86 and alikes require this, is it a bug in the soviet clone or is there something else happening?
-#define MCFG_I8257_REVERSE_RW_MODE(_flag) \
- i8257_device::static_set_reverse_rw_mode(*device, _flag);
-
-// ======================> i8257_device
-
-class i8257_device : public device_t,
- public device_execute_interface
-{
-public:
- // construction/destruction
- i8257_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( hlda_w );
- DECLARE_WRITE_LINE_MEMBER( ready_w );
-
- DECLARE_WRITE_LINE_MEMBER( dreq0_w );
- DECLARE_WRITE_LINE_MEMBER( dreq1_w );
- DECLARE_WRITE_LINE_MEMBER( dreq2_w );
- DECLARE_WRITE_LINE_MEMBER( dreq3_w );
-
- template<class _Object> static devcb_base &set_out_hrq_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_out_hrq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_tc_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_out_tc_cb.set_callback(object); }
-
- template<class _Object> static devcb_base &set_in_memr_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_in_memr_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_memw_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_out_memw_cb.set_callback(object); }
-
- template<class _Object> static devcb_base &set_in_ior_0_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_in_ior_0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_ior_1_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_in_ior_1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_ior_2_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_in_ior_2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_ior_3_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_in_ior_3_cb.set_callback(object); }
-
- template<class _Object> static devcb_base &set_out_iow_0_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_out_iow_0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_iow_1_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_out_iow_1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_iow_2_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_out_iow_2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_iow_3_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_out_iow_3_cb.set_callback(object); }
-
- template<class _Object> static devcb_base &set_out_dack_0_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_out_dack_0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dack_1_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_out_dack_1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dack_2_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_out_dack_2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dack_3_callback(device_t &device, _Object object) { return downcast<i8257_device &>(device).m_out_dack_3_cb.set_callback(object); }
-
- static void static_set_reverse_rw_mode(device_t &device, bool flag) { downcast<i8257_device &>(device).m_reverse_rw = flag; }
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void execute_run();
-
- int m_icount;
-
-private:
- inline void dma_request(int channel, int state);
- inline bool is_request_active(int channel);
- inline void set_hreq(int state);
- inline void set_dack();
- inline void dma_read();
- inline void dma_write();
- inline void advance();
- inline void set_tc(int state);
- bool next_channel();
-
- bool m_reverse_rw;
- bool m_tc;
- int m_msb;
- int m_hreq;
- int m_hack;
- int m_ready;
- int m_state;
- int m_current_channel;
- int m_last_channel;
- UINT8 m_transfer_mode;
- UINT8 m_status;
- UINT8 m_request;
- UINT8 m_temp;
-
- devcb_write_line m_out_hrq_cb;
- devcb_write_line m_out_tc_cb;
-
- /* accessors to main memory */
- devcb_read8 m_in_memr_cb;
- devcb_write8 m_out_memw_cb;
-
- /* channel accessors */
- devcb_read8 m_in_ior_0_cb;
- devcb_read8 m_in_ior_1_cb;
- devcb_read8 m_in_ior_2_cb;
- devcb_read8 m_in_ior_3_cb;
- devcb_write8 m_out_iow_0_cb;
- devcb_write8 m_out_iow_1_cb;
- devcb_write8 m_out_iow_2_cb;
- devcb_write8 m_out_iow_3_cb;
- devcb_write_line m_out_dack_0_cb;
- devcb_write_line m_out_dack_1_cb;
- devcb_write_line m_out_dack_2_cb;
- devcb_write_line m_out_dack_3_cb;
-
- struct
- {
- UINT16 m_address;
- UINT16 m_count;
- UINT8 m_mode;
- } m_channel[4];
-};
-
-
-// device type definition
-extern const device_type I8257;
-
-
-
-#endif
diff --git a/src/emu/machine/i8271.c b/src/emu/machine/i8271.c
deleted file mode 100644
index 08e5944f4fc..00000000000
--- a/src/emu/machine/i8271.c
+++ /dev/null
@@ -1,1510 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Kevin Thacker
-/* Intel 8271 Floppy Disc Controller */
-/* used in BBC Micro B,Acorn Atom */
-/* Jun 2000. Kev Thacker */
-
-/* TODO:
-
- - Scan commands
- - Check the commands work properly using a BBC disc copier program
- - check if 0 is specified as number of sectors, how many sectors
- is actually transfered
- - deleted data functions (error if data finds deleted data?)
-*/
-
-
-#include "emu.h"
-#include "i8271.h"
-
-/* data request */
-#define I8271_FLAGS_DATA_REQUEST 0x01
-/* data direction. If 0x02, then it is from fdc to cpu, else
-it is from cpu to fdc */
-#define I8271_FLAGS_DATA_DIRECTION 0x02
-
-enum I8271_STATE_t
-{
- I8271_STATE_EXECUTION_READ = 0,
- I8271_STATE_EXECUTION_WRITE
-};
-
-/* commands accepted */
-#define I8271_COMMAND_SPECIFY 0x035
-#define I8271_COMMAND_SEEK 0x029
-#define I8271_COMMAND_READ_DRIVE_STATUS 0x02c
-#define I8271_COMMAND_READ_SPECIAL_REGISTER 0x03d
-#define I8271_COMMAND_WRITE_SPECIAL_REGISTER 0x03a
-#define I8271_COMMAND_FORMAT 0x023
-#define I8271_COMMAND_READ_ID 0x01b
-#define I8271_COMMAND_READ_DATA_SINGLE_RECORD 0x012
-#define I8271_COMMAND_READ_DATA_AND_DELETED_DATA_SINGLE_RECORD 0x016
-#define I8271_COMMAND_WRITE_DATA_SINGLE_RECORD 0x00a
-#define I8271_COMMAND_WRITE_DELETED_DATA_SINGLE_RECORD 0x00e
-#define I8271_COMMAND_VERIFY_DATA_AND_DELETED_DATA_SINGLE_RECORD 0x01e
-#define I8271_COMMAND_READ_DATA_MULTI_RECORD 0x013
-#define I8271_COMMAND_READ_DATA_AND_DELETED_DATA_MULTI_RECORD 0x017
-#define I8271_COMMAND_WRITE_DATA_MULTI_RECORD 0x00b
-#define I8271_COMMAND_WRITE_DELETED_DATA_MULTI_RECORD 0x00f
-#define I8271_COMMAND_VERIFY_DATA_AND_DELETED_DATA_MULTI_RECORD 0x01f
-#define I8271_COMMAND_SCAN_DATA 0x000
-#define I8271_COMMAND_SCAN_DATA_AND_DELETED_DATA 0x004
-
-/*
-#define I8271_COMMAND_READ_OPERATION (1<<4)
-#define I8271_COMMAND_DELETED_DATA (1<<2)
-#define I8271_COMMAND_MULTI_RECORD (1<<0)
-*/
-
-
-
-/* first parameter for specify command */
-#define I8271_SPECIFY_INITIALIZATION 0x0d
-#define I8271_SPECIFY_LOAD_BAD_TRACKS_SURFACE_0 0x010
-#define I8271_SPECIFY_LOAD_BAD_TRACKS_SURFACE_1 0x018
-
-/* first parameter for read/write special register */
-#define I8271_SPECIAL_REGISTER_SCAN_SECTOR_NUMBER 0x06
-#define I8271_SPECIAL_REGISTER_SCAN_MSB_OF_COUNT 0x014
-#define I8271_SPECIAL_REGISTER_SCAN_LSB_OF_COUNT 0x013
-#define I8271_SPECIAL_REGISTER_SURFACE_0_CURRENT_TRACK 0x012
-#define I8271_SPECIAL_REGISTER_SURFACE_1_CURRENT_TRACK 0x01a
-#define I8271_SPECIAL_REGISTER_MODE_REGISTER 0x017
-#define I8271_SPECIAL_REGISTER_DRIVE_CONTROL_OUTPUT_PORT 0x023
-#define I8271_SPECIAL_REGISTER_DRIVE_CONTROL_INPUT_PORT 0x022
-#define I8271_SPECIAL_REGISTER_SURFACE_0_BAD_TRACK_1 0x010
-#define I8271_SPECIAL_REGISTER_SURFACE_0_BAD_TRACK_2 0x011
-#define I8271_SPECIAL_REGISTER_SURFACE_1_BAD_TRACK_1 0x018
-#define I8271_SPECIAL_REGISTER_SURFACE_1_BAD_TRACK_2 0x019
-
-
-/* status register bits */
-#define I8271_STATUS_COMMAND_BUSY 0x080
-#define I8271_STATUS_COMMAND_FULL 0x040
-#define I8271_STATUS_PARAMETER_FULL 0x020
-#define I8271_STATUS_RESULT_FULL 0x010
-#define I8271_STATUS_INT_REQUEST 0x008
-#define I8271_STATUS_NON_DMA_REQUEST 0x004
-
-#define VERBOSE 0
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-#define FDC_LOG(x) do { if (VERBOSE) logerror("I8271: %s\n",x); } while (0)
-#define FDC_LOG_COMMAND(x) do { if (VERBOSE) logerror("I8271: COMMAND %s\n",x); } while (0)
-
-
-/* Device Interface */
-
-const device_type I8271 = &device_creator<i8271_device>;
-
-i8271_device::i8271_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, I8271, "Intel 8271", tag, owner, clock, "i8271", __FILE__),
- m_write_irq(*this),
- m_write_drq(*this),
- m_floppy_tag1(NULL),
- m_floppy_tag2(NULL),
- m_flags(0),
- m_state(0),
- m_Command(0),
- m_StatusRegister(0),
- m_CommandRegister(0),
- m_ResultRegister(0),
- m_ParameterRegister(0),
- m_ResetRegister(0),
- m_data(0),
- m_ParameterCount(0),
- m_ParameterCountWritten(0),
- m_Mode(0),
- m_drive(0),
- m_side(0),
- m_drive_control_output(0),
- m_drive_control_input(0),
- m_StepRate(0),
- m_HeadSettlingTime(0),
- m_IndexCountBeforeHeadUnload(0),
- m_HeadLoadTime(0),
- //m_ID_C(0),
- //m_ID_H(0),
- m_ID_R(0),
- m_ID_N(0),
- m_data_id(0),
- m_ExecutionPhaseTransferCount(0),
- m_ExecutionPhaseCount(0),
- m_Counter(0)
- //m_data_direction(0)
-{
- for (int i = 0; i < 8; i++ )
- {
- m_CommandParameters[i] = 0;
- }
-
- for (int i = 0; i < 2; i++ )
- {
- m_CurrentTrack[i] = 0;
- }
-
- for (int i = 0; i < 4; i++ )
- {
- m_BadTracks[i] = 0;
- }
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void i8271_device::device_start()
-{
- m_write_irq.resolve_safe();
- m_write_drq.resolve_safe();
-
- m_data_timer = timer_alloc(TIMER_DATA_CALLBACK);
- m_command_complete_timer = timer_alloc(TIMER_TIMED_COMMAND_COMPLETE);
- m_drive = 0;
- m_pExecutionPhaseData = auto_alloc_array(machine(), char, 0x4000);
-
- m_floppy[0] = machine().device<legacy_floppy_image_device>(m_floppy_tag1);
- m_floppy[1] = machine().device<legacy_floppy_image_device>(m_floppy_tag2);
-
- // register for state saving
- /*save_item(NAME(m_flags));
- save_item(NAME(m_state));
- save_item(NAME(m_Command));
- save_item(NAME(m_StatusRegister));
- save_item(NAME(m_CommandRegister));
- save_item(NAME(m_ResultRegister));
- save_item(NAME(m_ParameterRegister));
- save_item(NAME(m_ResetRegister));
- save_item(NAME(m_data));
- //save_item(NAME(m_ParameterCount));
- //save_item(NAME(m_ParameterCountWritten));
- save_item(NAME(m_CommandParameters));
- //save_item(NAME(m_CurrentTrack));
- //save_item(NAME(m_BadTracks));
- //save_item(NAME(m_Mode));
- save_item(NAME(m_drive));
- save_item(NAME(m_side));
- save_item(NAME(m_drive_control_output));
- save_item(NAME(m_drive_control_input));
- //save_item(NAME(m_StepRate));
- //save_item(NAME(m_HeadSettlingTime));
- //save_item(NAME(m_IndexCountBeforeHeadUnload));
- //save_item(NAME(m_HeadLoadTime));
- save_item(NAME(m_ID_C));
- save_item(NAME(m_ID_H));
- save_item(NAME(m_ID_R));
- save_item(NAME(m_ID_N));
- save_item(NAME(m_data_id));
- save_item(NAME(m_ExecutionPhaseTransferCount));
- save_item(NAME(m_ExecutionPhaseCount));
- save_item(NAME(m_Counter));
- save_item(NAME(m_data_direction));
- save_pointer(NAME(m_pExecutionPhaseData), 0x4000);*/
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void i8271_device::device_reset()
-{
- m_StatusRegister = 0; //I8271_STATUS_INT_REQUEST | I8271_STATUS_NON_DMA_REQUEST;
- m_Mode = 0x0c0; /* bits 0, 1 are initialized to zero */
- m_ParameterCountWritten = 0;
- m_ParameterCount = 0;
-
- /* if timer is active remove */
- m_command_complete_timer->reset();
- m_data_timer->reset();
-
- /* clear irq */
- set_irq_state(0);
- /* clear dma */
- set_dma_drq();
-}
-
-void i8271_device::seek_to_track(int track)
-{
- if (track==0)
- {
- /* seek to track 0 */
- unsigned char StepCount = 0x0ff;
-
- /*logerror("step\n"); */
-
- /* track 0 not set, not seeked more than 255 tracks */
- while (m_floppy[m_drive]->floppy_tk00_r() && (StepCount != 0))
- {
-/* logerror("step\n"); */
- StepCount--;
- m_floppy[m_drive]->floppy_drive_seek(-1);
- }
-
- m_CurrentTrack[m_drive] = 0;
-
- /* failed to find track 0? */
- if (StepCount==0)
- {
- /* Completion Type: operator intervation probably required for recovery */
- /* Completion code: track 0 not found */
- m_ResultRegister |= (2<<3) | 2<<1;
- }
-
- /* step out - towards track 0 */
- m_drive_control_output &=~(1<<2);
- }
- else
- {
- signed int SignedTracks;
-
- /* calculate number of tracks to seek */
- SignedTracks = track - m_CurrentTrack[m_drive];
-
- /* step towards 0 */
- m_drive_control_output &= ~(1<<2);
-
- if (SignedTracks>0)
- {
- /* step away from 0 */
- m_drive_control_output |= (1<<2);
- }
-
-
- /* seek to track 0 */
- m_floppy[m_drive]->floppy_drive_seek(SignedTracks);
-
- m_CurrentTrack[m_drive] = track;
- }
-}
-
-void i8271_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_DATA_CALLBACK:
- /* ok, trigger data request now */
- data_request();
-
- /* stop it */
- m_data_timer->reset();
- break;
-
- case TIMER_TIMED_COMMAND_COMPLETE:
- command_complete(1,1);
-
- /* stop it, but don't allow it to be free'd */
- m_command_complete_timer->reset();
- break;
-
- default:
- break;
- }
-}
-
-/* setup a timed data request - data request will be triggered in a few usecs time */
-void i8271_device::timed_data_request()
-{
- int usecs;
- /* 64 for single density */
- usecs = 64;
-
- /* set timers */
- m_command_complete_timer->reset();
- m_data_timer->adjust(attotime::from_usec(usecs));
-}
-
-
-/* setup a irq to occur 128us later - in reality this would be much later, because the int would
-come after reading the two CRC bytes at least! This function is used when a irq is required at
-command completion. Required for read data and write data, where last byte could be missed! */
-void i8271_device::timed_command_complete()
-{
- int usecs;
-
- /* 64 for single density - 2 crc bytes later*/
- usecs = 64*2;
-
- /* set timers */
- m_data_timer->reset();
- m_command_complete_timer->adjust(attotime::from_usec(usecs));
-}
-
-void i8271_device::set_irq_state(int state)
-{
- m_StatusRegister &= ~I8271_STATUS_INT_REQUEST;
- if (state)
- {
- m_StatusRegister |= I8271_STATUS_INT_REQUEST;
- }
-
- m_write_irq((m_StatusRegister & I8271_STATUS_INT_REQUEST) ? ASSERT_LINE : CLEAR_LINE);
-}
-
-void i8271_device::set_dma_drq()
-{
- m_write_drq((m_flags & I8271_FLAGS_DATA_REQUEST) ? 1 : 0);
-}
-
-void i8271_device::load_bad_tracks(int surface)
-{
- m_BadTracks[(surface<<1) + 0] = m_CommandParameters[1];
- m_BadTracks[(surface<<1) + 1] = m_CommandParameters[2];
- m_CurrentTrack[surface] = m_CommandParameters[3];
-}
-
-void i8271_device::write_bad_track(int surface, int track, int data)
-{
- m_BadTracks[(surface<<1) + (track-1)] = data;
-}
-
-void i8271_device::write_current_track(int surface, int track)
-{
- m_CurrentTrack[surface] = track;
-}
-
-int i8271_device::read_current_track(int surface)
-{
- return m_CurrentTrack[surface];
-}
-
-int i8271_device::read_bad_track(int surface, int track)
-{
- return m_BadTracks[(surface<<1) + (track-1)];
-}
-
-void i8271_device::get_drive()
-{
- /* &40 = drive 0 side 0 */
- /* &80 = drive 1 side 0 */
-
-
-
- if (m_CommandRegister & (1<<6))
- {
- m_drive = 0;
- }
-
- if (m_CommandRegister & (1<<7))
- {
- m_drive = 1;
- }
-
-}
-
-void i8271_device::check_all_parameters_written()
-{
- if (m_ParameterCount == m_ParameterCountWritten)
- {
- m_StatusRegister &= ~I8271_STATUS_COMMAND_FULL;
-
- command_execute();
- }
-}
-
-
-void i8271_device::update_state()
-{
- switch (m_state)
- {
- /* fdc reading data and passing it to cpu which must read it */
- case I8271_STATE_EXECUTION_READ:
- {
- // /* if data request has been cleared, i.e. caused by a read of the register */
- // if ((m_flags & I8271_FLAGS_DATA_REQUEST)==0)
- {
- /* setup data with byte */
- m_data = m_pExecutionPhaseData[m_ExecutionPhaseCount];
-
-/* logerror("read data %02x\n", m_data); */
-
- /* update counters */
- m_ExecutionPhaseCount++;
- m_ExecutionPhaseTransferCount--;
-
- // logerror("Count: %04x\n", m_ExecutionPhaseCount);
- // logerror("Remaining: %04x\n", m_ExecutionPhaseTransferCount);
-
- /* completed? */
- if (m_ExecutionPhaseTransferCount==0)
- {
- /* yes */
-
- // logerror("sector read complete!\n");
- /* continue command */
- command_continue();
- }
- else
- {
- /* no */
-
- /* issue data request */
- timed_data_request();
- }
- }
- }
- break;
-
- /* fdc reading data and passing it to cpu which must read it */
- case I8271_STATE_EXECUTION_WRITE:
- {
- /* setup data with byte */
- m_pExecutionPhaseData[m_ExecutionPhaseCount] = m_data;
- /* update counters */
- m_ExecutionPhaseCount++;
- m_ExecutionPhaseTransferCount--;
-
- /* completed? */
- if (m_ExecutionPhaseTransferCount==0)
- {
- /* yes */
-
- /* continue command */
- command_continue();
- }
- else
- {
- /* no */
-
- /* issue data request */
- timed_data_request();
- }
- }
- break;
-
- default:
- break;
- }
-}
-
-void i8271_device::initialise_execution_phase_read(int transfer_size)
-{
- /* read */
- m_flags |= I8271_FLAGS_DATA_DIRECTION;
- m_ExecutionPhaseCount = 0;
- m_ExecutionPhaseTransferCount = transfer_size;
- m_state = I8271_STATE_EXECUTION_READ;
-}
-
-
-void i8271_device::initialise_execution_phase_write(int transfer_size)
-{
- /* write */
- m_flags &= ~I8271_FLAGS_DATA_DIRECTION;
- m_ExecutionPhaseCount = 0;
- m_ExecutionPhaseTransferCount = transfer_size;
- m_state = I8271_STATE_EXECUTION_WRITE;
-}
-
-/* for data transfers */
-void i8271_device::data_request()
-{
- m_flags |= I8271_FLAGS_DATA_REQUEST;
-
- if ((m_Mode & 0x01)!=0)
- {
- /* non-dma */
- m_StatusRegister |= I8271_STATUS_NON_DMA_REQUEST;
- /* set int */
- set_irq_state(1);
- }
- else
- {
- /* dma */
- m_StatusRegister &= ~I8271_STATUS_NON_DMA_REQUEST;
-
- set_dma_drq();
- }
-}
-
-void i8271_device::command_complete(int result, int int_rq)
-{
- /* not busy, and not a execution phase data request in non-dma mode */
- m_StatusRegister &= ~(I8271_STATUS_COMMAND_BUSY | I8271_STATUS_NON_DMA_REQUEST);
-
- if (result)
- {
- m_StatusRegister |= I8271_STATUS_RESULT_FULL;
- }
-
- if (int_rq)
- {
- /* trigger an int */
- set_irq_state(1);
- }
-
- /* correct?? */
- m_drive_control_output &=~1;
-}
-
-
-/* for data transfers */
-void i8271_device::clear_data_request()
-{
- m_flags &= ~I8271_FLAGS_DATA_REQUEST;
-
- if ((m_Mode & 0x01)!=0)
- {
- /* non-dma */
- m_StatusRegister &= ~I8271_STATUS_NON_DMA_REQUEST;
- /* set int */
- set_irq_state(0);
- }
- else
- {
- /* dma */
- set_dma_drq();
- }
-}
-
-
-void i8271_device::command_continue()
-{
- switch (m_Command)
- {
- case I8271_COMMAND_READ_DATA_MULTI_RECORD:
- case I8271_COMMAND_READ_DATA_SINGLE_RECORD:
- {
- /* completed all sectors? */
- m_Counter--;
- /* increment sector id */
- m_ID_R++;
-
- /* end command? */
- if (m_Counter==0)
- {
- timed_command_complete();
- return;
- }
-
- do_read();
- }
- break;
-
- case I8271_COMMAND_WRITE_DATA_MULTI_RECORD:
- case I8271_COMMAND_WRITE_DATA_SINGLE_RECORD:
- {
- /* put the buffer to the sector */
- m_floppy[m_drive]->floppy_drive_write_sector_data(m_side, m_data_id, m_pExecutionPhaseData, 1<<(m_ID_N+7),0);
-
- /* completed all sectors? */
- m_Counter--;
- /* increment sector id */
- m_ID_R++;
-
- /* end command? */
- if (m_Counter==0)
- {
- timed_command_complete();
- return;
- }
-
- do_write();
- }
- break;
-
- case I8271_COMMAND_READ_ID:
- {
- m_Counter--;
-
- if (m_Counter==0)
- {
- timed_command_complete();
- return;
- }
-
- do_read_id();
- }
- break;
-
- default:
- break;
- }
-}
-
-void i8271_device::do_read()
-{
- /* find the sector */
- if (find_sector())
- {
- /* get the sector into the buffer */
- m_floppy[m_drive]->floppy_drive_read_sector_data(m_side, m_data_id, m_pExecutionPhaseData, 1<<(m_ID_N+7));
-
- /* initialise for reading */
- initialise_execution_phase_read(1<<(m_ID_N+7));
-
- /* update state - gets first byte and triggers a data request */
- timed_data_request();
- return;
- }
- LOG(("error getting sector data\n"));
-
- timed_command_complete();
-}
-
-void i8271_device::do_read_id()
-{
- chrn_id id;
-
- /* get next id from disc */
- m_floppy[m_drive]->floppy_drive_get_next_id(m_side,&id);
-
- m_pExecutionPhaseData[0] = id.C;
- m_pExecutionPhaseData[1] = id.H;
- m_pExecutionPhaseData[2] = id.R;
- m_pExecutionPhaseData[3] = id.N;
-
- initialise_execution_phase_read(4);
-}
-
-
-void i8271_device::do_write()
-{
- /* find the sector */
- if (find_sector())
- {
- /* initialise for reading */
- initialise_execution_phase_write(1<<(m_ID_N+7));
-
- /* update state - gets first byte and triggers a data request */
- timed_data_request();
- return;
- }
- LOG(("error getting sector data\n"));
-
- timed_command_complete();
-}
-
-
-
-int i8271_device::find_sector()
-{
-// int track_count_attempt;
-
-// track_count_attempt
- /* find sector within one revolution of the disc - 2 index pulses */
-
- /* number of times we have seen index hole */
- int index_count = 0;
-
- /* get sector id's */
- do
- {
- chrn_id id;
-
- /* get next id from disc */
- if (m_floppy[m_drive]->floppy_drive_get_next_id(m_side,&id))
- {
- /* tested on Amstrad CPC - All bytes must match, otherwise
- a NO DATA error is reported */
- if (id.R == m_ID_R)
- {
- /* TODO: Is this correct? What about bad tracks? */
- if (id.C == m_CurrentTrack[m_drive])
- {
- m_data_id = id.data_id;
- return 1;
- }
- else
- {
- /* TODO: if track doesn't match, the real 8271 does a step */
-
-
- return 0;
- }
- }
- }
-
- /* index set? */
- if (m_floppy[m_drive]->floppy_drive_get_flag_state(FLOPPY_DRIVE_INDEX))
- {
- index_count++;
- }
-
- }
- while (index_count!=2);
-
- /* completion type: command/drive error */
- /* completion code: sector not found */
- m_ResultRegister |= (3<<3);
-
- return 0;
-}
-
-void i8271_device::command_execute()
-{
- /* clear it = good completion status */
- /* this will be changed if anything bad happens! */
- m_ResultRegister = 0;
-
- switch (m_Command)
- {
- case I8271_COMMAND_SPECIFY:
- {
- switch (m_CommandParameters[0])
- {
- case 0x0d:
- {
- LOG(("Initialization\n"));
- m_StepRate = m_CommandParameters[1];
- m_HeadSettlingTime = m_CommandParameters[2];
- m_IndexCountBeforeHeadUnload = (m_CommandParameters[3]>>4) & 0x0f;
- m_HeadLoadTime = (m_CommandParameters[3] & 0x0f);
- }
- break;
-
- case 0x010:
- {
- LOG(("Load bad Tracks Surface 0\n"));
- load_bad_tracks(0);
-
- }
- break;
-
- case 0x018:
- {
- LOG(("Load bad Tracks Surface 1\n"));
- load_bad_tracks(1);
-
- }
- break;
- }
-
- /* no result */
- command_complete(0,0);
- }
- break;
-
- case I8271_COMMAND_READ_SPECIAL_REGISTER:
- {
- /* unknown - what is read when a special register that isn't allowed is specified? */
- int data = 0x0ff;
-
- switch (m_CommandParameters[0])
- {
- case I8271_SPECIAL_REGISTER_MODE_REGISTER:
- {
- data = m_Mode;
- }
- break;
-
- case I8271_SPECIAL_REGISTER_SURFACE_0_CURRENT_TRACK:
- {
- data = read_current_track(0);
-
- }
- break;
-
- case I8271_SPECIAL_REGISTER_SURFACE_1_CURRENT_TRACK:
- {
- data = read_current_track(1);
- }
- break;
-
- case I8271_SPECIAL_REGISTER_SURFACE_0_BAD_TRACK_1:
- {
- data = read_bad_track(0,1);
- }
- break;
-
- case I8271_SPECIAL_REGISTER_SURFACE_0_BAD_TRACK_2:
- {
- data = read_bad_track(0,2);
- }
- break;
-
- case I8271_SPECIAL_REGISTER_SURFACE_1_BAD_TRACK_1:
- {
- data = read_bad_track(1,1);
- }
- break;
-
- case I8271_SPECIAL_REGISTER_SURFACE_1_BAD_TRACK_2:
- {
- data = read_bad_track(1,2);
- }
- break;
-
- case I8271_SPECIAL_REGISTER_DRIVE_CONTROL_OUTPUT_PORT:
- {
- FDC_LOG_COMMAND("Read Drive Control Output port\n");
-
- get_drive();
-
- /* assumption: select bits reflect the select bits from the previous
- command. i.e. read drive status */
- data = (m_drive_control_output & ~0x0c0) | (m_CommandRegister & 0x0c0);
- }
- break;
-
- case I8271_SPECIAL_REGISTER_DRIVE_CONTROL_INPUT_PORT:
- {
- /* bit 7: not used */
- /* bit 6: ready 1 */
- /* bit 5: write fault */
- /* bit 4: index */
- /* bit 3: wr prot */
- /* bit 2: rdy 0 */
- /* bit 1: track 0 */
- /* bit 0: cnt/opi */
-
- FDC_LOG_COMMAND("Read Drive Control Input port\n");
-
-
- m_drive_control_input = (1<<6) | (1<<2);
-
- /* bit 3 = 0 if write protected */
- m_drive_control_input |= m_floppy[m_drive]->floppy_wpt_r() << 3;
-
- /* bit 1 = 0 if head at track 0 */
- m_drive_control_input |= m_floppy[m_drive]->floppy_tk00_r() << 1;
-
- /* need to setup this register based on drive selected */
- data = m_drive_control_input;
- }
- break;
-
- }
-
- m_ResultRegister = data;
-
- command_complete(1,0);
- }
- break;
-
-
- case I8271_COMMAND_WRITE_SPECIAL_REGISTER:
- {
- switch (m_CommandParameters[0])
- {
- case I8271_SPECIAL_REGISTER_MODE_REGISTER:
- {
- /* TODO: Check bits 6-7 and 5-2 are valid */
- m_Mode = m_CommandParameters[1];
-
- if (m_Mode & 0x01)
- {
- LOG(("Mode: Non-DMA\n"));
- }
- else
- {
- LOG(("Mode: DMA\n"));
- }
-
- if (m_Mode & 0x02)
- {
- LOG(("Single actuator\n"));
- }
- else
- {
- LOG(("Double actuator\n"));
- }
- }
- break;
-
- case I8271_SPECIAL_REGISTER_SURFACE_0_CURRENT_TRACK:
- {
- LOG(("Surface 0 Current Track\n"));
- write_current_track(0, m_CommandParameters[1]);
- }
- break;
-
- case I8271_SPECIAL_REGISTER_SURFACE_1_CURRENT_TRACK:
- {
- LOG(("Surface 1 Current Track\n"));
- write_current_track(1, m_CommandParameters[1]);
- }
- break;
-
- case I8271_SPECIAL_REGISTER_SURFACE_0_BAD_TRACK_1:
- {
- LOG(("Surface 0 Bad Track 1\n"));
- write_bad_track(0, 1, m_CommandParameters[1]);
- }
- break;
-
- case I8271_SPECIAL_REGISTER_SURFACE_0_BAD_TRACK_2:
- {
- LOG(("Surface 0 Bad Track 2\n"));
- write_bad_track(0, 2,m_CommandParameters[1]);
- }
- break;
-
- case I8271_SPECIAL_REGISTER_SURFACE_1_BAD_TRACK_1:
- {
- LOG(("Surface 1 Bad Track 1\n"));
-
-
- write_bad_track(1, 1, m_CommandParameters[1]);
- }
- break;
-
- case I8271_SPECIAL_REGISTER_SURFACE_1_BAD_TRACK_2:
- {
- LOG(("Surface 1 Bad Track 2\n"));
-
- write_bad_track(1, 2, m_CommandParameters[1]);
- }
- break;
-
- case I8271_SPECIAL_REGISTER_DRIVE_CONTROL_OUTPUT_PORT:
- {
-// /* get drive selected */
-// m_drive = (m_CommandParameters[1]>>6) & 0x03;
-
- FDC_LOG_COMMAND("Write Drive Control Output port\n");
-
-
- if (m_CommandParameters[1] & 0x01)
- {
- LOG(("Write Enable\n"));
- }
- if (m_CommandParameters[1] & 0x02)
- {
- LOG(("Seek/Step\n"));
- }
- if (m_CommandParameters[1] & 0x04)
- {
- LOG(("Direction\n"));
- }
- if (m_CommandParameters[1] & 0x08)
- {
- LOG(("Load Head\n"));
- }
- if (m_CommandParameters[1] & 0x010)
- {
- LOG(("Low head current\n"));
- }
- if (m_CommandParameters[1] & 0x020)
- {
- LOG(("Write Fault Reset\n"));
- }
-
- LOG(("Select %02x\n", (m_CommandParameters[1] & 0x0c0)>>6));
-
- /* get drive */
- get_drive();
-
- /* on bbc dfs 09 this is the side select output */
- m_side = (m_CommandParameters[1]>>5) & 0x01;
-
- /* load head - on mini-sized drives this turns on the disc motor,
- on standard-sized drives this loads the head and turns the motor on */
- m_floppy[m_drive]->floppy_mon_w(!BIT(m_CommandParameters[1], 3));
- m_floppy[m_drive]->floppy_drive_set_ready_state(1, 1);
-
- /* step pin changed? if so perform a step in the direction indicated */
- if (((m_drive_control_output^m_CommandParameters[1]) & (1<<1))!=0)
- {
- /* step pin changed state? */
-
- if (BIT(m_CommandParameters[1], 1))
- {
- signed int signed_tracks;
-
- if (BIT(m_CommandParameters[1], 2))
- {
- signed_tracks = 1;
- }
- else
- {
- signed_tracks = -1;
- }
-
- m_floppy[m_drive]->floppy_drive_seek(signed_tracks);
- }
- }
-
- m_drive_control_output = m_CommandParameters[1];
-
-
- }
- break;
-
- case I8271_SPECIAL_REGISTER_DRIVE_CONTROL_INPUT_PORT:
- {
- FDC_LOG_COMMAND("Write Drive Control Input port\n");
-
- // m_drive_control_input = m_CommandParameters[1];
- }
- break;
-
- }
-
- /* write doesn't supply a result */
- command_complete(0,0);
- }
- break;
-
- case I8271_COMMAND_READ_DRIVE_STATUS:
- {
- unsigned char status;
-
- get_drive();
-
- /* no write fault */
- status = 0;
-
- status |= (1<<2) | (1<<6);
-
- /* these two do not appear to be set at all! ?? */
-
- if (m_floppy[0])
- {
- if (m_floppy[0]->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
- {
- status |= (1 << 2);
- }
- }
-
- if (m_floppy[1])
- {
- if (m_floppy[1]->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
- {
- status |= (1 << 6);
- }
- }
-
- /* bit 3 = 1 if write protected */
- status |= !m_floppy[m_drive]->floppy_wpt_r() << 3;
-
- /* bit 1 = 1 if head at track 0 */
- status |= !m_floppy[m_drive]->floppy_tk00_r() << 1;
-
- m_ResultRegister = status;
- command_complete(1,0);
-
- }
- break;
-
- case I8271_COMMAND_SEEK:
- {
- get_drive();
-
- seek_to_track(m_CommandParameters[0]);
-
- /* check for bad seek */
- timed_command_complete();
-
- }
- break;
-
- case I8271_COMMAND_READ_DATA_MULTI_RECORD:
- {
- /* N value as stored in ID field */
- m_ID_N = (m_CommandParameters[2]>>5) & 0x07;
-
- /* starting sector id */
- m_ID_R = m_CommandParameters[1];
-
- /* number of sectors to transfer */
- m_Counter = m_CommandParameters[2] & 0x01f;
-
-
- FDC_LOG_COMMAND("READ DATA MULTI RECORD");
-
- LOG(("Sector Count: %02x\n", m_Counter));
- LOG(("Track: %02x\n",m_CommandParameters[0]));
- LOG(("Sector: %02x\n", m_CommandParameters[1]));
- LOG(("Sector Length: %02x bytes\n", 1<<(m_ID_N+7)));
-
- get_drive();
-
- if (!m_floppy[m_drive]->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
- {
- /* Completion type: operation intervention probably required for recovery */
- /* Completion code: Drive not ready */
- m_ResultRegister = (2<<3);
- timed_command_complete();
- }
- else
- {
- seek_to_track(m_CommandParameters[0]);
-
-
- do_read();
- }
-
- }
- break;
-
- case I8271_COMMAND_READ_DATA_SINGLE_RECORD:
- {
- FDC_LOG_COMMAND("READ DATA SINGLE RECORD");
-
- m_ID_N = 0;
- m_Counter = 1;
- m_ID_R = m_CommandParameters[1];
-
- LOG(("Sector Count: %02x\n", m_Counter));
- LOG(("Track: %02x\n",m_CommandParameters[0]));
- LOG(("Sector: %02x\n", m_CommandParameters[1]));
- LOG(("Sector Length: %02x bytes\n", 1<<(m_ID_N+7)));
-
- get_drive();
-
- if (!m_floppy[m_drive]->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
- {
- /* Completion type: operation intervention probably required for recovery */
- /* Completion code: Drive not ready */
- m_ResultRegister = (2<<3);
- timed_command_complete();
- }
- else
- {
- seek_to_track(m_CommandParameters[0]);
-
- do_read();
- }
-
- }
- break;
-
- case I8271_COMMAND_WRITE_DATA_MULTI_RECORD:
- {
- /* N value as stored in ID field */
- m_ID_N = (m_CommandParameters[2]>>5) & 0x07;
-
- /* starting sector id */
- m_ID_R = m_CommandParameters[1];
-
- /* number of sectors to transfer */
- m_Counter = m_CommandParameters[2] & 0x01f;
-
- FDC_LOG_COMMAND("READ DATA MULTI RECORD");
-
- LOG(("Sector Count: %02x\n", m_Counter));
- LOG(("Track: %02x\n",m_CommandParameters[0]));
- LOG(("Sector: %02x\n", m_CommandParameters[1]));
- LOG(("Sector Length: %02x bytes\n", 1<<(m_ID_N+7)));
-
- get_drive();
-
- m_drive_control_output &=~1;
-
- if (!m_floppy[m_drive]->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
- {
- /* Completion type: operation intervention probably required for recovery */
- /* Completion code: Drive not ready */
- m_ResultRegister = (2<<3);
- timed_command_complete();
- }
- else
- {
- if (m_floppy[m_drive]->floppy_wpt_r() == CLEAR_LINE)
- {
- /* Completion type: operation intervention probably required for recovery */
- /* Completion code: Drive write protected */
- m_ResultRegister = (2<<3) | (1<<1);
- timed_command_complete();
- }
- else
- {
- m_drive_control_output |=1;
-
- seek_to_track(m_CommandParameters[0]);
-
- do_write();
- }
- }
- }
- break;
-
- case I8271_COMMAND_WRITE_DATA_SINGLE_RECORD:
- {
- FDC_LOG_COMMAND("WRITE DATA SINGLE RECORD");
-
- m_ID_N = 0;
- m_Counter = 1;
- m_ID_R = m_CommandParameters[1];
-
-
- LOG(("Sector Count: %02x\n", m_Counter));
- LOG(("Track: %02x\n",m_CommandParameters[0]));
- LOG(("Sector: %02x\n", m_CommandParameters[1]));
- LOG(("Sector Length: %02x bytes\n", 1<<(m_ID_N+7)));
- get_drive();
-
- m_drive_control_output &=~1;
-
- if (!m_floppy[m_drive]->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
- {
- /* Completion type: operation intervention probably required for recovery */
- /* Completion code: Drive not ready */
- m_ResultRegister = (2<<3);
- timed_command_complete();
- }
- else
- {
- if (m_floppy[m_drive]->floppy_wpt_r() == CLEAR_LINE)
- {
- /* Completion type: operation intervention probably required for recovery */
- /* Completion code: Drive write protected */
- m_ResultRegister = (2<<3) | (1<<1);
- timed_command_complete();
- }
- else
- {
- m_drive_control_output |=1;
-
- seek_to_track(m_CommandParameters[0]);
-
- do_write();
- }
- }
-
- }
- break;
-
-
- case I8271_COMMAND_READ_ID:
- {
- FDC_LOG_COMMAND("READ ID");
-
- LOG(("Track: %02x\n",m_CommandParameters[0]));
- LOG(("ID Field Count: %02x\n", m_CommandParameters[2]));
-
- get_drive();
-
- if (!m_floppy[m_drive]->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
- {
- /* Completion type: operation intervention probably required for recovery */
- /* Completion code: Drive not ready */
- m_ResultRegister = (2<<3);
- timed_command_complete();
- }
- else
- {
- m_Counter = m_CommandParameters[2];
-
- seek_to_track(m_CommandParameters[0]);
-
- do_read_id();
- }
- }
- break;
-
- default:
- LOG(("ERROR Unrecognised Command\n"));
- break;
- }
-}
-
-
-
-WRITE8_MEMBER(i8271_device::write)
-{
- switch (offset & 3)
- {
- case 0:
- {
- LOG(("I8271 W Command Register: %02x\n", data));
-
- m_CommandRegister = data;
- m_Command = m_CommandRegister & 0x03f;
-
- m_StatusRegister |= I8271_STATUS_COMMAND_BUSY | I8271_STATUS_COMMAND_FULL;
- m_StatusRegister &= ~I8271_STATUS_PARAMETER_FULL | I8271_STATUS_RESULT_FULL;
- m_ParameterCountWritten = 0;
-
- switch (m_Command)
- {
- case I8271_COMMAND_SPECIFY:
- {
- FDC_LOG_COMMAND("SPECIFY");
-
- m_ParameterCount = 4;
- }
- break;
-
- case I8271_COMMAND_SEEK:
- {
- FDC_LOG_COMMAND("SEEK");
-
- m_ParameterCount = 1;
- }
- break;
-
- case I8271_COMMAND_READ_DRIVE_STATUS:
- {
- FDC_LOG_COMMAND("READ DRIVE STATUS");
-
- m_ParameterCount = 0;
- }
- break;
-
- case I8271_COMMAND_READ_SPECIAL_REGISTER:
- {
- FDC_LOG_COMMAND("READ SPECIAL REGISTER");
-
- m_ParameterCount = 1;
- }
- break;
-
- case I8271_COMMAND_WRITE_SPECIAL_REGISTER:
- {
- FDC_LOG_COMMAND("WRITE SPECIAL REGISTER");
-
- m_ParameterCount = 2;
- }
- break;
-
- case I8271_COMMAND_FORMAT:
- {
- m_ParameterCount = 5;
- }
- break;
-
- case I8271_COMMAND_READ_ID:
- {
- m_ParameterCount = 3;
-
- }
- break;
-
-
- case I8271_COMMAND_READ_DATA_SINGLE_RECORD:
- case I8271_COMMAND_READ_DATA_AND_DELETED_DATA_SINGLE_RECORD:
- case I8271_COMMAND_WRITE_DATA_SINGLE_RECORD:
- case I8271_COMMAND_WRITE_DELETED_DATA_SINGLE_RECORD:
- case I8271_COMMAND_VERIFY_DATA_AND_DELETED_DATA_SINGLE_RECORD:
- {
- m_ParameterCount = 2;
- }
- break;
-
- case I8271_COMMAND_READ_DATA_MULTI_RECORD:
- case I8271_COMMAND_READ_DATA_AND_DELETED_DATA_MULTI_RECORD:
- case I8271_COMMAND_WRITE_DATA_MULTI_RECORD:
- case I8271_COMMAND_WRITE_DELETED_DATA_MULTI_RECORD:
- case I8271_COMMAND_VERIFY_DATA_AND_DELETED_DATA_MULTI_RECORD:
- {
- m_ParameterCount = 3;
- }
- break;
-
- case I8271_COMMAND_SCAN_DATA:
- case I8271_COMMAND_SCAN_DATA_AND_DELETED_DATA:
- {
- m_ParameterCount = 5;
- }
- break;
-
-
-
-
-
-
- }
-
- check_all_parameters_written();
- }
- break;
-
- case 1:
- {
- LOG(("I8271 W Parameter Register: %02x\n",data));
- m_ParameterRegister = data;
-
- if (m_ParameterCount!=0)
- {
- m_CommandParameters[m_ParameterCountWritten] = data;
- m_ParameterCountWritten++;
- }
-
- check_all_parameters_written();
- }
- break;
-
- case 2:
- {
- LOG(("I8271 W Reset Register: %02x\n", data));
- if (((data ^ m_ResetRegister) & 0x01)!=0)
- {
- if ((data & 0x01)==0)
- {
- reset();
- }
- }
-
- m_ResetRegister = data;
-
-
- }
- break;
-
- default:
- break;
- }
-}
-
-READ8_MEMBER(i8271_device::read)
-{
- switch (offset & 3)
- {
- case 0:
- {
- /* bit 1,0 are zero other bits contain status data */
- m_StatusRegister &= ~0x03;
- LOG(("I8271 R Status Register: %02x\n",m_StatusRegister));
- return m_StatusRegister;
- }
-
- case 1:
- {
- if ((m_StatusRegister & I8271_STATUS_COMMAND_BUSY)==0)
- {
- /* clear IRQ */
- set_irq_state(0);
-
- m_StatusRegister &= ~I8271_STATUS_RESULT_FULL;
- LOG(("I8271 R Result Register %02x\n",m_ResultRegister));
- return m_ResultRegister;
- }
-
- /* not useful information when command busy */
- return 0x0ff;
- }
-
-
- default:
- break;
- }
-
- return 0x0ff;
-}
-
-
-/* to be completed! */
-READ8_MEMBER(i8271_device::dack_r)
-{
- return data_r(space, offset);
-}
-
-/* to be completed! */
-WRITE8_MEMBER(i8271_device::dack_w)
-{
- data_w(space, offset, data);
-}
-
-READ8_MEMBER(i8271_device::data_r)
-{
- clear_data_request();
-
- update_state();
-
- // logerror("I8271 R data: %02x\n",m_data);
-
-
- return m_data;
-}
-
-WRITE8_MEMBER(i8271_device::data_w)
-{
- m_data = data;
-
-// logerror("I8271 W data: %02x\n",m_data);
-
- clear_data_request();
-
- update_state();
-}
diff --git a/src/emu/machine/i8271.h b/src/emu/machine/i8271.h
deleted file mode 100644
index c73fb4b680c..00000000000
--- a/src/emu/machine/i8271.h
+++ /dev/null
@@ -1,165 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Kevin Thacker
-/*****************************************************************************
- *
- * machine/i8271.h
- *
- ****************************************************************************/
-
-#ifndef I8271_H_
-#define I8271_H_
-
-#include "imagedev/flopdrv.h"
-
-#define MCFG_I8271_IRQ_CALLBACK(_write) \
- devcb = &i8271_device::set_irq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_I8271_DRQ_CALLBACK(_write) \
- devcb = &i8271_device::set_drq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_I8271_FLOPPIES(_tag1, _tag2) \
- i8271_device::set_floppy_tags(*device, _tag1, _tag2);
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-class i8271_device : public device_t
-{
-public:
- i8271_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~i8271_device() {}
-
- template<class _Object> static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<i8271_device &>(device).m_write_irq.set_callback(object); }
- template<class _Object> static devcb_base &set_drq_wr_callback(device_t &device, _Object object) { return downcast<i8271_device &>(device).m_write_drq.set_callback(object); }
-
- static void set_floppy_tags(device_t &device, const char *tag1, const char *tag2)
- {
- i8271_device &dev = downcast<i8271_device &>(device);
- dev.m_floppy_tag1 = tag1;
- dev.m_floppy_tag2 = tag2;
- }
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- DECLARE_READ8_MEMBER(dack_r);
- DECLARE_WRITE8_MEMBER(dack_w);
-
- DECLARE_READ8_MEMBER(data_r);
- DECLARE_WRITE8_MEMBER(data_w);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- // internal state
- enum
- {
- TIMER_DATA_CALLBACK,
- TIMER_TIMED_COMMAND_COMPLETE
- };
-
- devcb_write_line m_write_irq;
- devcb_write_line m_write_drq;
-
- const char *m_floppy_tag1, *m_floppy_tag2;
- legacy_floppy_image_device *m_floppy[2];
-
- int m_flags;
- int m_state;
- unsigned char m_Command;
- unsigned char m_StatusRegister;
- unsigned char m_CommandRegister;
- unsigned char m_ResultRegister;
- unsigned char m_ParameterRegister;
- unsigned char m_ResetRegister;
- unsigned char m_data;
-
- /* number of parameters required after command is specified */
- unsigned long m_ParameterCount;
- /* number of parameters written so far */
- unsigned long m_ParameterCountWritten;
-
- unsigned char m_CommandParameters[8];
-
- /* current track for each drive */
- unsigned long m_CurrentTrack[2];
-
- /* 2 bad tracks for drive 0, followed by 2 bad tracks for drive 1 */
- unsigned long m_BadTracks[4];
-
- /* mode special register */
- unsigned long m_Mode;
-
-
- /* drive outputs */
- int m_drive;
- int m_side;
-
- /* drive control output special register */
- int m_drive_control_output;
- /* drive control input special register */
- int m_drive_control_input;
-
- unsigned long m_StepRate;
- unsigned long m_HeadSettlingTime;
- unsigned long m_IndexCountBeforeHeadUnload;
- unsigned long m_HeadLoadTime;
-
- /* id on disc to find */
- //int m_ID_C;
- //int m_ID_H;
- int m_ID_R;
- int m_ID_N;
-
- /* id of data for read/write */
- int m_data_id;
-
- int m_ExecutionPhaseTransferCount;
- char *m_pExecutionPhaseData;
- int m_ExecutionPhaseCount;
-
- /* sector counter and id counter */
- int m_Counter;
-
- /* ==0, to cpu, !=0 =from cpu */
- //int m_data_direction;
-
- emu_timer *m_data_timer;
- emu_timer *m_command_complete_timer;
-
- void seek_to_track(int track);
- void load_bad_tracks(int surface);
- void write_bad_track(int surface, int track, int data);
- void write_current_track(int surface, int track);
- int read_current_track(int surface);
- int read_bad_track(int surface, int track);
- void get_drive();
- void check_all_parameters_written();
- void update_state();
- void initialise_execution_phase_read(int transfer_size);
- void initialise_execution_phase_write(int transfer_size);
- void command_execute();
- void command_continue();
- void command_complete(int result, int int_rq);
- void timed_command_complete();
- void data_request();
- void clear_data_request();
- void timed_data_request();
- /* locate sector for read/write operation */
- int find_sector();
- /* do a read operation */
- void do_read();
- void do_write();
- void do_read_id();
- void set_irq_state(int);
- void set_dma_drq();
-};
-
-extern const device_type I8271;
-
-#endif /* I8271_H_ */
diff --git a/src/emu/machine/i8279.c b/src/emu/machine/i8279.c
deleted file mode 100644
index abd4fb3beb1..00000000000
--- a/src/emu/machine/i8279.c
+++ /dev/null
@@ -1,489 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Robbbert
-/**********************************************************************
-
- i8279
-
-2012-JAN-08 First draft [Robbbert]
-2012-JAN-12 Implemented
-
-Notes:
-- All keys MUST be ACTIVE_LOW
-
-
-ToDo:
-- Command 5 (Nibble masking and blanking)
-- Command 7 (Error Mode)
-- Interrupts
-- BD pin
-- Sensor ram stuff
-- save state
-
-
-What has been done:
-CMD 0:
-- Display Mode
--- Left & Right with no increment are the same thing
--- Right with increment is not emulated yet ***
-- Keyboard Mode
--- No particular code has been added for 2-key/N-key rollover, no need
--- Sensor mode is not complete yet ***
--- Encoded and Decoded are done
--- Strobe is done
--- Sensor and FIFO may share the same internal RAM, not sure
-CMD 1:
-- Clock Divider
--- Value is stored, but internally a fixed value is always used
-CMD 2:
-- Read FIFO/Sensor RAM
--- FIFO works
--- Sensor RAM works
-CMD 3:
-- Read Display RAM
--- This works
-CMD 4:
-- Write Display RAM
--- Right with increment does nothing, the rest is working ***
-CMD 5:
-- Blank Nibble
--- Not done ***
-- Mask Nibble
--- Implemented
-CMD 6:
--- All implemented
-CMD 7:
-- Interrupt
--- Not done
-- Error Mode
--- No need to do.
-
-Interface:
--- All done except BD pin ***
-
-Status word:
-- FIFO bits
--- All done
-- Error bit
--- Not done (no need)
-- Display unavailable
--- Not done (no need)
-
-
-Items marked (***) can be added if a system appears
-that uses this feature.
-
-**********************************************************************/
-
-#include "i8279.h"
-
-#define LOG 0
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type I8279 = &device_creator<i8279_device>;
-
-//-------------------------------------------------
-// i8279_device - constructor
-//-------------------------------------------------
-
-i8279_device::i8279_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, I8279, "8279 KDC", tag, owner, clock, "i8279", __FILE__),
- m_out_irq_cb(*this),
- m_out_sl_cb(*this),
- m_out_disp_cb(*this),
- m_out_bd_cb(*this),
- m_in_rl_cb(*this),
- m_in_shift_cb(*this),
- m_in_ctrl_cb(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void i8279_device::device_start()
-{
- /* resolve callbacks */
- m_out_irq_cb.resolve();
- m_out_sl_cb.resolve();
- m_out_disp_cb.resolve();
- m_out_bd_cb.resolve();
- m_in_rl_cb.resolve();
- m_in_shift_cb.resolve();
- m_in_ctrl_cb.resolve();
- m_clock = clock();
- m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(i8279_device::timerproc_callback), this));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void i8279_device::device_reset()
-{
- UINT8 i;
-
- // startup values are unknown: setting to 0
- for (i = 2; i < 8; i++) m_cmd[i] = 0;
- for (i = 0; i < 8; i++) m_fifo[i] = 0;
- for (i = 0; i < 8; i++) m_s_ram[i] = 0;
- for (i = 0; i < 16; i++) m_d_ram[i] = 0;
- m_status = 0;
- m_autoinc = 1;
- m_d_ram_ptr = 0;
- m_s_ram_ptr = 0;
- m_read_flag = 0;
- m_scanner = 0;
- m_ctrl_key = 1;
- m_key_down = 0xffff;
-
- // from here is confirmed
- m_cmd[0] = 8;
- m_cmd[1] = 31;
- logerror("Initial clock = 3100kHz\n");
- timer_adjust();
-}
-
-
-void i8279_device::timer_adjust()
-{
-// Real device runs at about 100kHz internally, clock divider is chosen so that
-// this is the case. We do not need such speed, 2000Hz is enough.
-// If this is too long, the sensor mode doesn't work correctly.
-
-#if 0
- UINT8 divider = (m_cmd[1]) ? m_cmd[1] : 1;
- UINT32 new_clock = clock() / divider;
-#else
- UINT32 new_clock = 2000;
-#endif
-
- if (m_clock != new_clock)
- {
- m_timer->adjust(attotime::from_hz(new_clock), 0, attotime::from_hz(new_clock));
-
- m_clock = new_clock;
- }
-}
-
-
-void i8279_device::clear_display()
-{
- // clear all digits
- UINT8 i,patterns[4] = { 0, 0, 0x20, 0xff };
- UINT8 data = patterns[(m_cmd[6] & 12) >> 2];
-
- // The CD high bit (also done by CA)
- if (m_cmd[6] & 0x11)
- for (i = 0; i < 16; i++)
- m_d_ram[i] = data;
-
- m_status &= 0x7f; // bit 7 not emulated, but do it anyway
- m_d_ram_ptr = 0; // not in the datasheet, but needed
-
- // The CF bit (also done by CA)
- if (m_cmd[6] & 3)
- {
- m_status &= 0xc0; // blow away fifo
- m_s_ram_ptr = 0; // reset sensor pointer
- set_irq(0); // reset irq
- }
-}
-
-
-void i8279_device::set_irq(bool state)
-{
- if ( !m_out_irq_cb.isnull() )
- m_out_irq_cb( state );
-}
-
-
-void i8279_device::new_key(UINT8 data, bool skey, bool ckey)
-{
- UINT8 i, rl, sl;
- for (i = 0; BIT(data, i); i++);
- rl = i;
- if (BIT(m_cmd[0], 0))
- {
- for (i = 0; !BIT(data, i); i++);
- sl = i;
- }
- else
- sl = m_scanner;
-
- new_fifo( (ckey << 7) | (skey << 6) | (sl << 3) | rl);
-}
-
-
-void i8279_device::new_fifo(UINT8 data)
-{
- // see if already overrun
- if (BIT(m_status, 5))
- return;
-
- // set overrun flag if full
- if (BIT(m_status, 3))
- {
- m_status |= 0x20;
- return;
- }
-
- m_fifo[m_status & 7] = data;
-
- // bump fifo size & turn off underrun
- UINT8 fifo_size = m_status & 7;
- if ((fifo_size)==7)
- m_status |= 8; // full
- else
- m_status = (m_status & 0xe8) + fifo_size + 1;
-
- if (!fifo_size)
- set_irq(1); // something just went into fifo, so int
-}
-
-
-TIMER_CALLBACK_MEMBER( i8279_device::timerproc_callback )
-{
- timer_mainloop();
-}
-
-
-void i8279_device::timer_mainloop()
-{
- // control byte 0
- // bit 0 - encoded or decoded keyboard scan
- // bits 1,2 - keyboard type
- // bit 3 - number of digits to display
- // bit 4 - left or right entry
-
- UINT8 scanner_mask = BIT(m_cmd[0], 0) ? 15 : BIT(m_cmd[0], 3) ? 15 : 7;
- bool decoded = BIT(m_cmd[0], 0);
- UINT8 kbd_type = (m_cmd[0] & 6) >> 1;
- bool shift_key = 1;
- bool ctrl_key = 1;
- bool strobe_pulse = 0;
-
- // keyboard
- // type 0 = kbd, 2-key lockout
- // type 1 = kdb, n-key
- // type 2 = sensor
- // type 3 = strobed
-
- // Get shift keys
- if ( !m_in_shift_cb.isnull() )
- shift_key = m_in_shift_cb();
-
- if ( !m_in_ctrl_cb.isnull() )
- ctrl_key = m_in_ctrl_cb();
-
- if (ctrl_key && !m_ctrl_key)
- strobe_pulse = 1; // low-to-high is a strobe
-
- m_ctrl_key = ctrl_key;
-
- // Read a row of keys
-
- if ( !m_in_rl_cb.isnull() )
- {
- UINT8 rl = m_in_rl_cb(0);
-
- // see if key still down from last time
- UINT16 key_down = (m_scanner << 8) | rl;
- if (key_down == m_key_down)
- rl = 0xff;
- else
- if ((rl == 0xff) && (m_scanner == m_key_down >> 8))
- m_key_down = 0xffff;
-
- // now process new key
- if (rl < 0xff || kbd_type == 2)
- {
- m_key_down = key_down;
- switch (kbd_type)
- {
- case 0:
- case 1:
- new_key(rl, shift_key, ctrl_key);
- break;
- case 2:
- {
- UINT8 addr = m_scanner &7;
-
- if (decoded)
- for (addr=0; !BIT(m_scanner, addr); addr++);
-
- rl ^= 0xff; // inverted
- assert(addr < ARRAY_LENGTH(m_s_ram));
- if (m_s_ram[addr] != rl)
- {
- m_s_ram[addr] = rl;
-
- // IRQ line goes high if a row change value
- set_irq(1);
- }
- }
- break;
- case 3:
- if (strobe_pulse) new_fifo(rl);
- break;
- }
- }
- }
-
- // Increment scanline
-
- if (decoded)
- {
- m_scanner<<= 1;
- if ((m_scanner & 15)==0)
- m_scanner = 1;
- }
- else
- m_scanner++;
-
- m_scanner &= scanner_mask; // 4-bit port
-
- if ( !m_out_sl_cb.isnull() )
- m_out_sl_cb((offs_t)0, m_scanner);
-
- // output a digit
-
- if ( !m_out_disp_cb.isnull() )
- m_out_disp_cb((offs_t)0, m_d_ram[m_scanner] );
-}
-
-
-READ8_MEMBER( i8279_device::status_r )
-{
- return m_status;
-}
-
-
-READ8_MEMBER( i8279_device::data_r )
-{
- UINT8 i;
- bool sensor_mode = ((m_cmd[0] & 6)==4);
- UINT8 data;
- if (m_read_flag)
- {
- // read the display ram
- data = m_d_ram[m_d_ram_ptr];
- if (m_autoinc)
- m_d_ram_ptr++;
- }
- else
- if (sensor_mode)
- {
- // read sensor ram
- assert(m_s_ram_ptr < ARRAY_LENGTH(m_s_ram));
- data = m_s_ram[m_s_ram_ptr];
- if (m_autoinc)
- m_s_ram_ptr++;
- else
- set_irq(0);
- }
- else
- {
- // read a key from fifo
- data = m_fifo[0];
- UINT8 fifo_size = m_status & 7;
- switch (m_status & 0x38)
- {
- case 0x00: // no errors
- if (!fifo_size)
- m_status |= 0x10; // underrun
- else
- {
- for (i = 1; i < 8; i++)
- m_fifo[i-1] = m_fifo[i];
- fifo_size--;
- if (!fifo_size)
- set_irq(0);
- }
- break;
- case 0x28: // overrun
- case 0x08: // fifo full
- for (i = 1; i < 8; i++)
- m_fifo[i-1] = m_fifo[i];
- break;
- case 0x10: // underrun
- if (!fifo_size)
- break;
- default:
- printf("Invalid status: %X\n", m_status);
- }
- m_status = (m_status & 0xd0) | fifo_size; // turn off overrun & full
- }
-
- m_d_ram_ptr &= 15;
- m_s_ram_ptr &= 7;
- return data;
-}
-
-
-WRITE8_MEMBER( i8279_device::cmd_w )
-{//printf("Command: %X=%X ",data>>5,data&31);
- UINT8 cmd = data >> 5;
- data &= 0x1f;
- m_cmd[cmd] = data;
- switch (cmd)
- {
- case 0:
- if (LOG) logerror("I8279 '%s' kb mode %x, display mode %x\n", tag(), data & 7, (data>>3) & 3);
- break;
- case 1:
- if (data > 1)
- {
- logerror("Clock set to %dkHz\n",data*100);
- timer_adjust();
- }
- break;
- case 2:
- m_read_flag = 0;
- if ((m_cmd[0] & 6)==4) // sensor mode only
- {
- m_autoinc = BIT(data, 4);
- m_s_ram_ptr = data & 7;
- if (LOG) logerror("I8279 '%s' selct sensor row %x, AI %d\n", tag(), m_s_ram_ptr, m_autoinc);
- }
- break;
- case 3:
- m_read_flag = 1;
- m_d_ram_ptr = data & 15;
- m_autoinc = BIT(data, 4);
- break;
- case 4:
- m_d_ram_ptr = data & 15;
- m_autoinc = BIT(data, 4);
- break;
- case 6:
- if (LOG) logerror("I8279 '%s' clear cmd %x\n", tag(), data);
- clear_display();
- break;
- }
-}
-
-
-WRITE8_MEMBER( i8279_device::data_w )
-{//printf("Data: %X ",data);
- if (BIT(m_cmd[0], 4) & m_autoinc)
- {
- // right-entry autoincrement not implemented yet
- }
- else
- {
- if (!(m_cmd[5] & 0x04))
- m_d_ram[m_d_ram_ptr] = (m_d_ram[m_d_ram_ptr] & 0xf0) | (data & 0x0f);
- if (!(m_cmd[5] & 0x08))
- m_d_ram[m_d_ram_ptr] = (m_d_ram[m_d_ram_ptr] & 0x0f) | (data & 0xf0);
-
- if (m_autoinc)
- m_d_ram_ptr++;
- }
- m_d_ram_ptr &= 15;
-}
diff --git a/src/emu/machine/i8279.h b/src/emu/machine/i8279.h
deleted file mode 100644
index 42a77d7634f..00000000000
--- a/src/emu/machine/i8279.h
+++ /dev/null
@@ -1,145 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Robbbert
-/***************************************************************************
-
- Intel 8279 Programmable Keyboard/Display Interface emulation
-
-****************************************************************************
- _____ _____
- RL2 1 |* \_/ | 40 Vcc
- RL3 2 | | 39 RL1
- CLK 3 | | 38 RL0
- IRQ 4 | | 37 CNTL/STB
- RL4 5 | | 36 SHIFT
- RL5 6 | | 35 SL3
- RL6 7 | | 34 SL2
- RL7 8 | | 33 SL1
- RESET 9 | | 32 SL0
- /RD 10 | 8279 | 31 B0
- /WR 11 | | 30 B1
- DB0 12 | | 29 B2
- DB1 13 | | 28 B3
- DB2 14 | | 27 A0
- DB3 15 | | 26 A1
- DB4 16 | | 25 A2
- DB5 17 | | 24 A3
- DB6 18 | | 23 /BD
- DB7 19 | | 22 /CS
- Vss 20 |_____________| 21 CTRL/DATA
-
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __I8279__
-#define __I8279__
-
-#include "emu.h"
-
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_I8279_OUT_IRQ_CB(_devcb) \
- devcb = &i8279_device::set_out_irq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8279_OUT_SL_CB(_devcb) \
- devcb = &i8279_device::set_out_sl_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8279_OUT_DISP_CB(_devcb) \
- devcb = &i8279_device::set_out_disp_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8279_OUT_BD_CB(_devcb) \
- devcb = &i8279_device::set_out_bd_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8279_IN_RL_CB(_devcb) \
- devcb = &i8279_device::set_in_rl_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8279_IN_SHIFT_CB(_devcb) \
- devcb = &i8279_device::set_in_shift_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8279_IN_CTRL_CB(_devcb) \
- devcb = &i8279_device::set_in_ctrl_callback(*device, DEVCB_##_devcb);
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-// ======================> i8279_device
-
-class i8279_device : public device_t
-{
-public:
- // construction/destruction
- i8279_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<i8279_device &>(device).m_out_irq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_sl_callback(device_t &device, _Object object) { return downcast<i8279_device &>(device).m_out_sl_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_disp_callback(device_t &device, _Object object) { return downcast<i8279_device &>(device).m_out_disp_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_bd_callback(device_t &device, _Object object) { return downcast<i8279_device &>(device).m_out_bd_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_rl_callback(device_t &device, _Object object) { return downcast<i8279_device &>(device).m_in_rl_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_shift_callback(device_t &device, _Object object) { return downcast<i8279_device &>(device).m_in_shift_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_ctrl_callback(device_t &device, _Object object) { return downcast<i8279_device &>(device).m_in_ctrl_cb.set_callback(object); }
-
- // read & write handlers
- DECLARE_READ8_MEMBER(status_r);
- DECLARE_READ8_MEMBER(data_r);
- DECLARE_WRITE8_MEMBER(cmd_w);
- DECLARE_WRITE8_MEMBER(data_w);
- void timer_mainloop();
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_post_load() { }
- virtual void device_clock_changed() { }
-
- TIMER_CALLBACK_MEMBER( timerproc_callback );
-
-private:
-
- void timer_adjust();
- void clear_display();
- void new_key(UINT8 data, bool skey, bool ckey);
- void new_fifo(UINT8 data);
- UINT8 get_segments();
- void set_irq(bool state);
- void set_display_mode(UINT8 data);
-
- devcb_write_line m_out_irq_cb; // IRQ
- devcb_write8 m_out_sl_cb; // Scanlines SL0-3
- devcb_write8 m_out_disp_cb; // B0-3,A0-3
- devcb_write_line m_out_bd_cb; // BD
- devcb_read8 m_in_rl_cb; // kbd readlines RL0-7
- devcb_read_line m_in_shift_cb; // Shift key
- devcb_read_line m_in_ctrl_cb; // Ctrl-Strobe line
-
- emu_timer *m_timer;
-
- UINT8 m_d_ram[16]; // display ram
- UINT8 m_d_ram_ptr;
- UINT8 m_s_ram[8]; // might be same as fifo ram
- UINT8 m_s_ram_ptr;
- UINT8 m_fifo[8]; // queued keystrokes
- UINT8 m_cmd[8]; // Device settings
- UINT8 m_status; // Returned via status_r
- UINT32 m_clock; // Internal scan clock
- UINT8 m_scanner; // next output on SL lines
-
- bool m_autoinc; // auto-increment flag
- bool m_read_flag; // read from where
- bool m_ctrl_key; // previous state of strobe input
- UINT16 m_key_down;
-};
-
-
-// device type definition
-extern const device_type I8279;
-
-
-
-#endif
diff --git a/src/emu/machine/i82875p.c b/src/emu/machine/i82875p.c
deleted file mode 100644
index 58f8b3264c9..00000000000
--- a/src/emu/machine/i82875p.c
+++ /dev/null
@@ -1,515 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "i82875p.h"
-
-const device_type I82875P_HOST = &device_creator<i82875p_host_device>;
-const device_type I82875P_AGP = &device_creator<i82875p_agp_device>;
-const device_type I82875P_OVERFLOW = &device_creator<i82875p_overflow_device>;
-
-DEVICE_ADDRESS_MAP_START(agp_translation_map, 32, i82875p_host_device)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(config_map, 32, i82875p_host_device)
- AM_RANGE(0x50, 0x53) AM_READWRITE8 (agpm_r, agpm_w, 0x0000ff00)
- AM_RANGE(0x50, 0x53) AM_READ8 (gc_r, 0x00ff0000)
- AM_RANGE(0x50, 0x53) AM_READ8 (csabcont_r, 0xff000000)
- AM_RANGE(0x58, 0x5b) AM_READ (eap_r)
- AM_RANGE(0x5c, 0x5f) AM_READ8 (derrsyn_r, 0x000000ff)
- AM_RANGE(0x5c, 0x5f) AM_READ8 (des_r, 0x0000ff00)
- AM_RANGE(0x60, 0x63) AM_READWRITE8 (fpllcont_r, fpllcont_w, 0x000000ff)
- AM_RANGE(0x90, 0x97) AM_READWRITE8 (pam_r, pam_w, 0xffffffff)
- AM_RANGE(0x9c, 0x9f) AM_READWRITE8 (smram_r, smram_w, 0x0000ff00)
- AM_RANGE(0x9c, 0x9f) AM_READWRITE8 (esmramc_r, esmramc_w, 0x00ff0000)
- AM_RANGE(0xa0, 0xa3) AM_READ (acapid_r)
- AM_RANGE(0xa4, 0xa7) AM_READ (agpstat_r)
- AM_RANGE(0xa8, 0xab) AM_READ (agpcmd_r)
- AM_RANGE(0xb0, 0xb3) AM_READWRITE (agpctrl_r, agpctrl_w)
- AM_RANGE(0xb4, 0xb7) AM_READWRITE8 (apsize_r, apsize_w, 0x000000ff)
- AM_RANGE(0xb8, 0xbb) AM_READWRITE (attbase_r, attbase_w)
- AM_RANGE(0xbc, 0xbf) AM_READWRITE8 (amtt_r, amtt_w, 0x000000ff)
- AM_RANGE(0xbc, 0xbf) AM_READWRITE8 (lptt_r, lptt_w, 0x0000ff00)
- AM_RANGE(0xc4, 0xc7) AM_READWRITE16(toud_r, toud_w, 0x0000ffff)
- AM_RANGE(0xc4, 0xc7) AM_READWRITE16(mchcfg_r, mchcfg_w, 0xffff0000)
- AM_RANGE(0xc8, 0xcb) AM_READ16 (errsts_r, 0x0000ffff)
- AM_RANGE(0xc8, 0xcb) AM_READWRITE16(errcmd_r, errcmd_w, 0xffff0000)
- AM_RANGE(0xcc, 0xcf) AM_READWRITE16(smicmd_r, smicmd_w, 0x0000ffff)
- AM_RANGE(0xcc, 0xcf) AM_READWRITE16(scicmd_r, scicmd_w, 0xffff0000)
- AM_RANGE(0xdc, 0xdf) AM_READWRITE16(skpd_r, skpd_w, 0xffff0000)
- AM_RANGE(0xe4, 0xe7) AM_READ (capreg1_r)
- AM_RANGE(0xe8, 0xeb) AM_READ8 (capreg2_r, 0x000000ff)
-
- AM_INHERIT_FROM(pci_host_device::config_map)
-ADDRESS_MAP_END
-
-i82875p_host_device::i82875p_host_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_host_device(mconfig, I82875P_HOST, "I82875P Northbridge", tag, owner, clock, "i82875p_host", __FILE__)
-{
-}
-
-void i82875p_host_device::set_cpu_tag(const char *_cpu_tag)
-{
- cpu_tag = _cpu_tag;
-}
-
-void i82875p_host_device::set_ram_size(int _ram_size)
-{
- ram_size = _ram_size;
-}
-
-READ8_MEMBER(i82875p_host_device::capptr_r)
-{
- return 0xe4;
-}
-
-void i82875p_host_device::device_start()
-{
- pci_host_device::device_start();
- cpu = machine().device<cpu_device>(cpu_tag);
- memory_space = &cpu->space(AS_PROGRAM);
- io_space = &cpu->space(AS_IO);
-
- memory_window_start = 0;
- memory_window_end = 0xffffffff;
- memory_offset = 0;
- io_window_start = 0;
- io_window_end = 0xffff;
- io_offset = 0;
- status = 0x0010;
-
- ram.resize(ram_size/4);
-
- // Resizeable with the apsize register
- add_map(256*1024*1024, M_MEM, FUNC(i82875p_host_device::agp_translation_map));
-}
-
-READ8_MEMBER( i82875p_host_device::agpm_r)
-{
- return agpm;
-}
-
-WRITE8_MEMBER( i82875p_host_device::agpm_w)
-{
- agpm = data;
- logerror("%s: agpm = %02x\n", tag(), agpm);
-}
-
-READ8_MEMBER( i82875p_host_device::gc_r)
-{
- return 0x08;
-}
-
-READ8_MEMBER( i82875p_host_device::csabcont_r)
-{
- return 0x00;
-}
-
-READ32_MEMBER( i82875p_host_device::eap_r)
-{
- return 0x00000000;
-}
-
-READ8_MEMBER( i82875p_host_device::derrsyn_r)
-{
- return 0x00;
-}
-
-READ8_MEMBER( i82875p_host_device::des_r)
-{
- return 0x00;
-}
-
-READ8_MEMBER( i82875p_host_device::fpllcont_r)
-{
- return fpllcont;
-}
-
-WRITE8_MEMBER( i82875p_host_device::fpllcont_w)
-{
- fpllcont = data;
- logerror("%s: fpllcont = %02x\n", tag(), data);
-}
-
-READ8_MEMBER( i82875p_host_device::pam_r)
-{
- return pam[offset];
-}
-
-WRITE8_MEMBER( i82875p_host_device::pam_w)
-{
- pam[offset] = data;
- logerror("%s: pam[%d] = %02x\n", tag(), offset, data);
- remap_cb();
-}
-
-READ8_MEMBER( i82875p_host_device::smram_r)
-{
- return smram;
-}
-
-WRITE8_MEMBER( i82875p_host_device::smram_w)
-{
- if(!(smram & 0x10))
- smram = (data & 0xfe) | 0x02;
- logerror("%s: smram = %02x\n", tag(), smram);
- remap_cb();
-}
-
-READ8_MEMBER( i82875p_host_device::esmramc_r)
-{
- return esmramc;
-}
-
-WRITE8_MEMBER( i82875p_host_device::esmramc_w)
-{
- if(!(smram & 0x10))
- esmramc = (data & 0x87) | 0x38;
- logerror("%s: esmramc = %02x\n", tag(), smram);
- remap_cb();
-}
-
-READ32_MEMBER( i82875p_host_device::acapid_r)
-{
- return 0x00300002;
-}
-
-READ32_MEMBER( i82875p_host_device::agpstat_r)
-{
- return 0x1f004a13;
-}
-
-READ32_MEMBER( i82875p_host_device::agpcmd_r)
-{
- return 0x00000a00;
-}
-
-READ32_MEMBER( i82875p_host_device::agpctrl_r)
-{
- return agpctrl;
-}
-
-WRITE32_MEMBER(i82875p_host_device::agpctrl_w)
-{
- COMBINE_DATA(&agpctrl);
- logerror("%s: agpctrl = %08x\n", tag(), agpctrl);
-}
-
-READ8_MEMBER( i82875p_host_device::apsize_r)
-{
- return apsize;
-}
-
-WRITE8_MEMBER( i82875p_host_device::apsize_w)
-{
- apsize = data;
- logerror("%s: apsize = %02x\n", tag(), apsize);
-}
-
-READ32_MEMBER( i82875p_host_device::attbase_r)
-{
- return attbase;
-}
-
-WRITE32_MEMBER(i82875p_host_device::attbase_w)
-{
- COMBINE_DATA(&attbase);
- logerror("%s: attbase = %08x\n", tag(), attbase);
-}
-
-READ8_MEMBER( i82875p_host_device::amtt_r)
-{
- return amtt;
-}
-
-WRITE8_MEMBER( i82875p_host_device::amtt_w)
-{
- amtt = data;
-}
-
-READ8_MEMBER( i82875p_host_device::lptt_r)
-{
- return lptt;
-}
-
-WRITE8_MEMBER( i82875p_host_device::lptt_w)
-{
- lptt = data;
-}
-
-READ16_MEMBER( i82875p_host_device::toud_r)
-{
- return toud;
-}
-
-WRITE16_MEMBER(i82875p_host_device::toud_w)
-{
- COMBINE_DATA(&toud);
- toud &= ~7;
- logerror("%s: toud = %08x\n", tag(), toud << 16);
- remap_cb();
-}
-
-READ16_MEMBER( i82875p_host_device::mchcfg_r)
-{
- return mchcfg;
-}
-
-WRITE16_MEMBER(i82875p_host_device::mchcfg_w)
-{
- COMBINE_DATA(&mchcfg);
-}
-
-READ16_MEMBER( i82875p_host_device::errsts_r)
-{
- return 0x0000;
-}
-
-READ16_MEMBER( i82875p_host_device::errcmd_r)
-{
- return errcmd;
-}
-
-WRITE16_MEMBER(i82875p_host_device::errcmd_w)
-{
- COMBINE_DATA(&errcmd);
-}
-
-READ16_MEMBER( i82875p_host_device::smicmd_r)
-{
- return smicmd;
-}
-
-WRITE16_MEMBER(i82875p_host_device::smicmd_w)
-{
- COMBINE_DATA(&smicmd);
-}
-
-READ16_MEMBER( i82875p_host_device::scicmd_r)
-{
- return scicmd;
-}
-
-WRITE16_MEMBER(i82875p_host_device::scicmd_w)
-{
- COMBINE_DATA(&scicmd);
-}
-
-READ16_MEMBER( i82875p_host_device::skpd_r)
-{
- return skpd;
-}
-
-WRITE16_MEMBER(i82875p_host_device::skpd_w)
-{
- COMBINE_DATA(&skpd);
-}
-
-READ32_MEMBER( i82875p_host_device::capreg1_r)
-{
- return 0x0106a009;
-}
-
-READ8_MEMBER( i82875p_host_device::capreg2_r)
-{
- return 0x00;
-}
-
-void i82875p_host_device::reset_all_mappings()
-{
- pci_host_device::reset_all_mappings();
-
- toud = 0x0400;
- smram = 0x02;
- esmramc = 0x38;
- memset(pam, 0, sizeof(pam));
-}
-
-void i82875p_host_device::device_reset()
-{
- pci_host_device::device_reset();
-
- agpm = 0x00;
- fpllcont = 0x00;
- agpctrl = 0x00000000;
- apsize = 0x00;
- attbase = 0x00000000;
- amtt = 0x10;
- lptt = 0x10;
- mchcfg = 0x0000;
- errcmd = 0x0000;
- smicmd = 0x0000;
- scicmd = 0x0000;
- skpd = 0x0000;
-}
-
-void i82875p_host_device::map_extra(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space)
-{
- io_space->install_device(0, 0xffff, *static_cast<pci_host_device *>(this), &pci_host_device::io_configuration_access_map);
-
- UINT32 top = toud << 16;
- if(esmramc & 1) {
- switch((esmramc >> 1) & 3) {
- case 2: top += 512*1024; break;
- case 3: top += 1024*1024; break;
- }
- }
-
- if(top > ram_size)
- top = ram_size;
-
- memory_space->install_ram (0x00000000, 0x0009ffff, &ram[0x00000000/4]);
-
- if(smram & 0x40)
- memory_space->install_ram (0x000a0000, 0x000bffff, &ram[0x000a0000/4]);
-
- if(pam[1] & 0x01)
- memory_space->install_rom (0x000c0000, 0x000c3fff, &ram[0x000c0000/4]);
- if(pam[1] & 0x02)
- memory_space->install_writeonly(0x000c0000, 0x000c3fff, &ram[0x000c0000/4]);
- if(pam[1] & 0x10)
- memory_space->install_rom (0x000c4000, 0x000c7fff, &ram[0x000c4000/4]);
- if(pam[1] & 0x20)
- memory_space->install_writeonly(0x000c4000, 0x000c7fff, &ram[0x000c4000/4]);
- if(pam[2] & 0x01)
- memory_space->install_rom (0x000c8000, 0x000cbfff, &ram[0x000c8000/4]);
- if(pam[2] & 0x02)
- memory_space->install_writeonly(0x000c8000, 0x000cbfff, &ram[0x000c8000/4]);
- if(pam[2] & 0x10)
- memory_space->install_rom (0x000cc000, 0x000cffff, &ram[0x000cc000/4]);
- if(pam[2] & 0x20)
- memory_space->install_writeonly(0x000cc000, 0x000cffff, &ram[0x000cc000/4]);
- if(pam[3] & 0x01)
- memory_space->install_rom (0x000d0000, 0x000d3fff, &ram[0x000d0000/4]);
- if(pam[3] & 0x02)
- memory_space->install_writeonly(0x000d0000, 0x000d3fff, &ram[0x000d0000/4]);
- if(pam[3] & 0x10)
- memory_space->install_rom (0x000d4000, 0x000d7fff, &ram[0x000d4000/4]);
- if(pam[3] & 0x20)
- memory_space->install_writeonly(0x000d4000, 0x000d7fff, &ram[0x000d4000/4]);
- if(pam[4] & 0x01)
- memory_space->install_rom (0x000d8000, 0x000dbfff, &ram[0x000d8000/4]);
- if(pam[4] & 0x02)
- memory_space->install_writeonly(0x000d8000, 0x000dbfff, &ram[0x000d8000/4]);
- if(pam[4] & 0x10)
- memory_space->install_rom (0x000dc000, 0x000dffff, &ram[0x000dc000/4]);
- if(pam[4] & 0x20)
- memory_space->install_writeonly(0x000dc000, 0x000dffff, &ram[0x000dc000/4]);
- if(pam[5] & 0x01)
- memory_space->install_rom (0x000e0000, 0x000e3fff, &ram[0x000e0000/4]);
- if(pam[5] & 0x02)
- memory_space->install_writeonly(0x000e0000, 0x000e3fff, &ram[0x000e0000/4]);
- if(pam[5] & 0x10)
- memory_space->install_rom (0x000e4000, 0x000e7fff, &ram[0x000e4000/4]);
- if(pam[5] & 0x20)
- memory_space->install_writeonly(0x000e4000, 0x000e7fff, &ram[0x000e4000/4]);
- if(pam[6] & 0x01)
- memory_space->install_rom (0x000e8000, 0x000ebfff, &ram[0x000e8000/4]);
- if(pam[6] & 0x02)
- memory_space->install_writeonly(0x000e8000, 0x000ebfff, &ram[0x000e8000/4]);
- if(pam[6] & 0x10)
- memory_space->install_rom (0x000ec000, 0x000effff, &ram[0x000ec000/4]);
- if(pam[6] & 0x20)
- memory_space->install_writeonly(0x000ec000, 0x000effff, &ram[0x000ec000/4]);
- if(pam[0] & 0x10)
- memory_space->install_rom (0x000f0000, 0x000fffff, &ram[0x000f0000/4]);
- if(pam[0] & 0x20)
- memory_space->install_writeonly(0x000f0000, 0x000fffff, &ram[0x000f0000/4]);
-
- memory_space->install_ram (0x00100000, 0x00efffff, &ram[0x00100000/4]);
- if(!(pam[7] & 0x80))
- memory_space->install_ram (0x00f00000, 0x00ffffff, &ram[0x00f00000/4]);
- if(top > 0x01000000)
- memory_space->install_ram (0x01000000, top-1, &ram[0x01000000/4]);
-
- if((esmramc & 0x40) && (smram & 0x08))
- memory_space->install_ram (0xfeda0000, 0xfedbffff, &ram[0x000a0000/4]);
-}
-
-
-i82875p_agp_device::i82875p_agp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : agp_bridge_device(mconfig, I82875P_AGP, "I82875P AGP Bridge", tag, owner, clock, "i82875p_agp", __FILE__)
-{
-}
-
-void i82875p_agp_device::device_start()
-{
- agp_bridge_device::device_start();
-}
-
-void i82875p_agp_device::device_reset()
-{
- agp_bridge_device::device_reset();
-}
-
-DEVICE_ADDRESS_MAP_START(overflow_map, 32, i82875p_overflow_device)
- AM_RANGE(0x000, 0x007) AM_READWRITE8(dram_row_boundary_r, dram_row_boundary_w, 0xffffffff)
- AM_RANGE(0x010, 0x013) AM_READWRITE8(dram_row_attribute_r, dram_row_attribute_w, 0xffffffff)
- AM_RANGE(0x060, 0x064) AM_READWRITE (dram_timing_r, dram_timing_w)
- AM_RANGE(0x068, 0x06b) AM_READWRITE (dram_controller_mode_r, dram_controller_mode_w)
-ADDRESS_MAP_END
-
-
-i82875p_overflow_device::i82875p_overflow_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_device(mconfig, I82875P_OVERFLOW, "I82875P Configuration Overflow", tag, owner, clock, "i82875p_overflow", __FILE__)
-{
-}
-
-void i82875p_overflow_device::device_start()
-{
- pci_device::device_start();
-
- add_map(4*1024, M_MEM, FUNC(i82875p_overflow_device::overflow_map));
-}
-
-void i82875p_overflow_device::device_reset()
-{
- pci_device::device_reset();
- memset(dram_row_boundary, 1, sizeof(dram_row_boundary));
- memset(dram_row_attribute, 0, sizeof(dram_row_attribute));
- dram_timing = 0;
- dram_controller_mode = 0x00010001;
-}
-
-READ8_MEMBER (i82875p_overflow_device::dram_row_boundary_r)
-{
- return dram_row_boundary[offset];
-}
-
-WRITE8_MEMBER (i82875p_overflow_device::dram_row_boundary_w)
-{
- dram_row_boundary[offset] = data;
- logerror("%s: dram_row_boundary_w %d, %02x\n", tag(), offset, data);
-}
-
-READ8_MEMBER (i82875p_overflow_device::dram_row_attribute_r)
-{
- return dram_row_attribute[offset];
-}
-
-WRITE8_MEMBER (i82875p_overflow_device::dram_row_attribute_w)
-{
- dram_row_attribute[offset] = data;
- logerror("%s: dram_row_attribute_w %d, %02x\n", tag(), offset, data);
-}
-
-READ32_MEMBER (i82875p_overflow_device::dram_timing_r)
-{
- return dram_timing;
-}
-
-WRITE32_MEMBER(i82875p_overflow_device::dram_timing_w)
-{
- COMBINE_DATA(&dram_timing);
- logerror("%s: dram_timing_w %08x\n", tag(), dram_timing);
-}
-
-READ32_MEMBER (i82875p_overflow_device::dram_controller_mode_r)
-{
- return dram_controller_mode;
-}
-
-WRITE32_MEMBER(i82875p_overflow_device::dram_controller_mode_w)
-{
- COMBINE_DATA(&dram_controller_mode);
- logerror("%s: dram_controller_mode_w %08x\n", tag(), dram_controller_mode);
-}
diff --git a/src/emu/machine/i82875p.h b/src/emu/machine/i82875p.h
deleted file mode 100644
index 8ab4a597eb2..00000000000
--- a/src/emu/machine/i82875p.h
+++ /dev/null
@@ -1,139 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-// Intel i82875p northbridge
-
-#ifndef I82875P_H
-#define I82875P_H
-
-#include "pci.h"
-
-#define MCFG_I82875P_HOST_ADD(_tag, _subdevice_id, _cpu_tag, _ram_size) \
- MCFG_PCI_HOST_ADD(_tag, I82875P_HOST, 0x80862578, 0x02, _subdevice_id) \
- downcast<i82875p_host_device *>(device)->set_cpu_tag(_cpu_tag); \
- downcast<i82875p_host_device *>(device)->set_ram_size(_ram_size);
-
-#define MCFG_I82875P_AGP_ADD(_tag) \
- MCFG_AGP_BRIDGE_ADD(_tag, I82875P_AGP, 0x80862579, 0x02)
-
-#define MCFG_I82875P_OVERFLOW_ADD(_tag, _subdevice_id) \
- MCFG_PCI_DEVICE_ADD(_tag, I82875P_OVERFLOW, 0x8086257e, 0x02, 0x088000, _subdevice_id)
-
-class i82875p_host_device : public pci_host_device {
-public:
- i82875p_host_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- void set_cpu_tag(const char *tag);
- void set_ram_size(int ram_size);
-
- virtual void reset_all_mappings();
-
- virtual void map_extra(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space);
-
- virtual DECLARE_ADDRESS_MAP(config_map, 32);
-
- virtual DECLARE_READ8_MEMBER(capptr_r);
-
- DECLARE_READ8_MEMBER( agpm_r);
- DECLARE_WRITE8_MEMBER( agpm_w);
- DECLARE_READ8_MEMBER( gc_r);
- DECLARE_READ8_MEMBER( csabcont_r);
- DECLARE_READ32_MEMBER( eap_r);
- DECLARE_READ8_MEMBER( derrsyn_r);
- DECLARE_READ8_MEMBER( des_r);
- DECLARE_READ8_MEMBER( fpllcont_r);
- DECLARE_WRITE8_MEMBER( fpllcont_w);
- DECLARE_READ8_MEMBER( pam_r);
- DECLARE_WRITE8_MEMBER( pam_w);
- DECLARE_READ8_MEMBER( smram_r);
- DECLARE_WRITE8_MEMBER( smram_w);
- DECLARE_READ8_MEMBER( esmramc_r);
- DECLARE_WRITE8_MEMBER( esmramc_w);
- DECLARE_READ32_MEMBER( acapid_r);
- DECLARE_READ32_MEMBER( agpstat_r);
- DECLARE_READ32_MEMBER( agpcmd_r);
- DECLARE_READ32_MEMBER( agpctrl_r);
- DECLARE_WRITE32_MEMBER(agpctrl_w);
- DECLARE_READ8_MEMBER( apsize_r);
- DECLARE_WRITE8_MEMBER( apsize_w);
- DECLARE_READ32_MEMBER( attbase_r);
- DECLARE_WRITE32_MEMBER(attbase_w);
- DECLARE_READ8_MEMBER( amtt_r);
- DECLARE_WRITE8_MEMBER( amtt_w);
- DECLARE_READ8_MEMBER( lptt_r);
- DECLARE_WRITE8_MEMBER( lptt_w);
- DECLARE_READ16_MEMBER( toud_r);
- DECLARE_WRITE16_MEMBER(toud_w);
- DECLARE_READ16_MEMBER( mchcfg_r);
- DECLARE_WRITE16_MEMBER(mchcfg_w);
- DECLARE_READ16_MEMBER( errsts_r);
- DECLARE_READ16_MEMBER( errcmd_r);
- DECLARE_WRITE16_MEMBER(errcmd_w);
- DECLARE_READ16_MEMBER( smicmd_r);
- DECLARE_WRITE16_MEMBER(smicmd_w);
- DECLARE_READ16_MEMBER( scicmd_r);
- DECLARE_WRITE16_MEMBER(scicmd_w);
- DECLARE_READ16_MEMBER( skpd_r);
- DECLARE_WRITE16_MEMBER(skpd_w);
- DECLARE_READ32_MEMBER( capreg1_r);
- DECLARE_READ8_MEMBER( capreg2_r);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
-private:
- DECLARE_ADDRESS_MAP(agp_translation_map, 32);
-
- const char *cpu_tag;
- int ram_size;
- cpu_device *cpu;
- std::vector<UINT32> ram;
-
- UINT8 agpm, fpllcont, pam[8], smram, esmramc;
- UINT8 apsize, amtt, lptt;
- UINT16 toud, mchcfg, errcmd, smicmd, scicmd, skpd;
- UINT32 agpctrl, attbase;
-};
-
-class i82875p_agp_device : public agp_bridge_device {
-public:
- i82875p_agp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-};
-
-class i82875p_overflow_device : public pci_device {
-public:
- i82875p_overflow_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-
- DECLARE_READ8_MEMBER (dram_row_boundary_r);
- DECLARE_WRITE8_MEMBER (dram_row_boundary_w);
- DECLARE_READ8_MEMBER (dram_row_attribute_r);
- DECLARE_WRITE8_MEMBER (dram_row_attribute_w);
- DECLARE_READ32_MEMBER (dram_timing_r);
- DECLARE_WRITE32_MEMBER(dram_timing_w);
- DECLARE_READ32_MEMBER (dram_controller_mode_r);
- DECLARE_WRITE32_MEMBER(dram_controller_mode_w);
-
-protected:
-
- virtual void device_start();
- virtual void device_reset();
-
-private:
- DECLARE_ADDRESS_MAP(overflow_map, 32);
-
- UINT8 dram_row_boundary[8], dram_row_attribute[4];
- UINT32 dram_timing, dram_controller_mode;
-};
-
-extern const device_type I82875P_HOST;
-extern const device_type I82875P_AGP;
-extern const device_type I82875P_OVERFLOW;
-
-
-#endif
diff --git a/src/emu/machine/i8355.c b/src/emu/machine/i8355.c
deleted file mode 100644
index d417bd1e3c3..00000000000
--- a/src/emu/machine/i8355.c
+++ /dev/null
@@ -1,210 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Intel 8355 - 16,384-Bit ROM with I/O emulation
-
-**********************************************************************/
-
-#include "emu.h"
-#include "i8355.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-enum
-{
- REGISTER_PORT_A = 0,
- REGISTER_PORT_B,
- REGISTER_PORT_A_DDR,
- REGISTER_PORT_B_DDR
-};
-
-enum
-{
- PORT_A = 0,
- PORT_B,
- PORT_COUNT
-};
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type I8355 = &device_creator<i8355_device>;
-
-// default address map
-static ADDRESS_MAP_START( i8355, AS_0, 8, i8355_device )
- AM_RANGE(0x000, 0x7ff) AM_ROM
-ADDRESS_MAP_END
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// read_port - read from input port
-//-------------------------------------------------
-
-inline UINT8 i8355_device::read_port(int port)
-{
- UINT8 data = m_output[port] & m_ddr[port];
-
- if (m_ddr[port] != 0xff)
- {
- if (port == 0) {data |= m_in_pa_cb(0) & ~m_ddr[port];}
- else { data |= m_in_pb_cb(0) & ~m_ddr[port];}
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write_port - write to output port
-//-------------------------------------------------
-
-inline void i8355_device::write_port(int port, UINT8 data)
-{
- m_output[port] = data;
-
- if (port == 0) {m_out_pa_cb((offs_t)0, m_output[port] & m_ddr[port]);}
- else {m_out_pb_cb((offs_t)0, m_output[port] & m_ddr[port]);}
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// i8355_device - constructor
-//-------------------------------------------------
-
-i8355_device::i8355_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, I8355, "Intel 8355", tag, owner, clock, "i8355", __FILE__),
- device_memory_interface(mconfig, *this),
- m_in_pa_cb(*this),
- m_out_pa_cb(*this),
- m_in_pb_cb(*this),
- m_out_pb_cb(*this),
- m_space_config("ram", ENDIANNESS_LITTLE, 8, 11, 0, NULL, *ADDRESS_MAP_NAME(i8355))
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void i8355_device::device_start()
-{
- // resolve callbacks
- m_in_pa_cb.resolve_safe(0);
- m_in_pb_cb.resolve_safe(0);
- m_out_pa_cb.resolve_safe();
- m_out_pb_cb.resolve_safe();
-
- // register for state saving
- save_item(NAME(m_output));
- save_item(NAME(m_ddr));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void i8355_device::device_reset()
-{
- // set ports to input mode
- m_ddr[PORT_A] = 0;
- m_ddr[PORT_B] = 0;
-}
-
-
-//-------------------------------------------------
-// memory_space_config - return a description of
-// any address spaces owned by this device
-//-------------------------------------------------
-
-const address_space_config *i8355_device::memory_space_config(address_spacenum spacenum) const
-{
- return (spacenum == AS_0) ? &m_space_config : NULL;
-}
-
-
-
-//-------------------------------------------------
-// io_r - register read
-//-------------------------------------------------
-
-READ8_MEMBER( i8355_device::io_r )
-{
- int port = offset & 0x01;
-
- UINT8 data = 0;
-
- switch (offset & 0x03)
- {
- case REGISTER_PORT_A:
- case REGISTER_PORT_B:
- data = read_port(port);
- break;
-
- case REGISTER_PORT_A_DDR:
- case REGISTER_PORT_B_DDR:
- // write only
- break;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// io_w - register write
-//-------------------------------------------------
-
-WRITE8_MEMBER( i8355_device::io_w )
-{
- int port = offset & 0x01;
-
- switch (offset & 0x03)
- {
- case REGISTER_PORT_A:
- case REGISTER_PORT_B:
- if (LOG) logerror("I8355 '%s' Port %c Write %02x\n", tag(), 'A' + port, data);
-
- write_port(port, data);
- break;
-
- case REGISTER_PORT_A_DDR:
- case REGISTER_PORT_B_DDR:
- if (LOG) logerror("I8355 '%s' Port %c DDR: %02x\n", tag(), 'A' + port, data);
-
- m_ddr[port] = data;
- write_port(port, data);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// memory_r - internal ROM read
-//-------------------------------------------------
-
-READ8_MEMBER( i8355_device::memory_r )
-{
- return this->space().read_byte(offset);
-}
diff --git a/src/emu/machine/i8355.h b/src/emu/machine/i8355.h
deleted file mode 100644
index 33d68d0fa57..00000000000
--- a/src/emu/machine/i8355.h
+++ /dev/null
@@ -1,120 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Intel 8355 - 16,384-Bit ROM with I/O emulation
-
-**********************************************************************
- _____ _____
- _CE1 1 |* \_/ | 40 Vcc
- CE2 2 | | 39 PB7
- CLK 3 | | 38 PB6
- RESET 4 | | 37 PB5
- N.C. 5 | | 36 PB4
- READY 6 | | 35 PB3
- IO/_M 7 | | 34 PB2
- _IOR 8 | | 33 PB1
- _RD 9 | | 32 PB0
- _IOW 10 | 8355 | 31 PA7
- ALE 11 | 8355-2 | 30 PA6
- AD0 12 | | 29 PA5
- AD1 13 | | 28 PA4
- AD2 14 | | 27 PA3
- AD3 15 | | 26 PA2
- AD4 16 | | 25 PA1
- AD5 17 | | 24 PA0
- AD6 18 | | 23 A10
- AD7 19 | | 22 A9
- Vss 20 |_____________| 21 A8
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __I8355__
-#define __I8355__
-
-#include "emu.h"
-
-
-
-///*************************************************************************
-// MACROS / CONSTANTS
-///*************************************************************************
-
-
-
-
-///*************************************************************************
-// INTERFACE CONFIGURATION MACROS
-///*************************************************************************
-
-#define MCFG_I8355_IN_PA_CB(_devcb) \
- devcb = &i8355_device::set_in_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8355_OUT_PA_CB(_devcb) \
- devcb = &i8355_device::set_out_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8355_IN_PB_CB(_devcb) \
- devcb = &i8355_device::set_in_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_I8355_OUT_PB_CB(_devcb) \
- devcb = &i8355_device::set_out_pb_callback(*device, DEVCB_##_devcb);
-
-
-///*************************************************************************
-// TYPE DEFINITIONS
-///*************************************************************************
-
-// ======================> i8355_device
-
-class i8355_device : public device_t,
- public device_memory_interface
-{
-public:
- // construction/destruction
- i8355_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_in_pa_callback(device_t &device, _Object object) { return downcast<i8355_device &>(device).m_in_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pa_callback(device_t &device, _Object object) { return downcast<i8355_device &>(device).m_out_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_pb_callback(device_t &device, _Object object) { return downcast<i8355_device &>(device).m_in_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pb_callback(device_t &device, _Object object) { return downcast<i8355_device &>(device).m_out_pb_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( io_r );
- DECLARE_WRITE8_MEMBER( io_w );
-
- DECLARE_READ8_MEMBER( memory_r );
- DECLARE_WRITE8_MEMBER( memory_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- // device_memory_interface overrides
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
-
- inline UINT8 read_port(int port);
- inline void write_port(int port, UINT8 data);
-
-private:
- devcb_read8 m_in_pa_cb;
- devcb_write8 m_out_pa_cb;
-
- devcb_read8 m_in_pb_cb;
- devcb_write8 m_out_pb_cb;
-
- // registers
- UINT8 m_output[2]; // output latches
- UINT8 m_ddr[2]; // DDR latches
-
- const address_space_config m_space_config;
-};
-
-
-// device type definition
-extern const device_type I8355;
-
-
-
-#endif
diff --git a/src/emu/machine/idectrl.c b/src/emu/machine/idectrl.c
deleted file mode 100644
index 403364d57c1..00000000000
--- a/src/emu/machine/idectrl.c
+++ /dev/null
@@ -1,393 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- idectrl.c
-
- Generic (PC-style) IDE controller implementation.
-
-***************************************************************************/
-
-#include "idectrl.h"
-
-
-/***************************************************************************
- DEBUGGING
-***************************************************************************/
-
-#define VERBOSE 0
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-const device_type IDE_CONTROLLER = &device_creator<ide_controller_device>;
-
-ide_controller_device::ide_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- ata_interface_device(mconfig, IDE_CONTROLLER, "IDE Controller", tag, owner, clock, "ide_controller", __FILE__)
-{
-}
-
-ide_controller_device::ide_controller_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- ata_interface_device(mconfig, type, name, tag, owner, clock, shortname, source)
-{
-}
-
-READ16_MEMBER( ide_controller_device::read_cs0 )
-{
- if (mem_mask == 0xffff && offset == 1 ){ offset = 0; popmessage( "requires ide_controller_32_device" ); }
- if (mem_mask == 0xff00)
- {
- return ata_interface_device::read_cs0(space, (offset * 2) + 1, 0xff) << 8;
- }
- else
- {
- return ata_interface_device::read_cs0(space, offset * 2, mem_mask);
- }
-}
-
-READ16_MEMBER( ide_controller_device::read_cs1 )
-{
- if (mem_mask == 0xff00)
- {
- return ata_interface_device::read_cs1(space, (offset * 2) + 1, 0xff) << 8;
- }
- else
- {
- return ata_interface_device::read_cs1(space, offset * 2, mem_mask);
- }
-}
-
-WRITE16_MEMBER( ide_controller_device::write_cs0 )
-{
- if (mem_mask == 0xffff && offset == 1 ){ offset = 0; popmessage( "requires ide_controller_32_device" ); }
- if (mem_mask == 0xff00)
- {
- return ata_interface_device::write_cs0(space, (offset * 2) + 1, data >> 8, 0xff);
- }
- else
- {
- return ata_interface_device::write_cs0(space, offset * 2, data, mem_mask);
- }
-}
-
-WRITE16_MEMBER( ide_controller_device::write_cs1 )
-{
- if (mem_mask == 0xff00)
- {
- return ata_interface_device::write_cs1(space, (offset * 2) + 1, data >> 8, 0xff);
- }
- else
- {
- return ata_interface_device::write_cs1(space, offset * 2, data, mem_mask);
- }
-}
-
-
-const device_type IDE_CONTROLLER_32 = &device_creator<ide_controller_32_device>;
-
-ide_controller_32_device::ide_controller_32_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- ide_controller_device(mconfig, IDE_CONTROLLER, "IDE Controller (32 bit)", tag, owner, clock, "ide_controller", __FILE__)
-{
-}
-
-ide_controller_32_device::ide_controller_32_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- ide_controller_device(mconfig, type, name, tag, owner, clock, shortname, source)
-{
-}
-
-READ32_MEMBER(ide_controller_32_device::read_cs0)
-{
- UINT32 data = 0;
-
- if (ACCESSING_BITS_0_15)
- {
- data = ide_controller_device::read_cs0(space, (offset * 2), mem_mask);
-
- if (offset == 0 && ACCESSING_BITS_16_31)
- data |= ide_controller_device::read_cs0(space, (offset * 2), mem_mask >> 16) << 16;
- }
- else if (ACCESSING_BITS_16_31)
- {
- data = ide_controller_device::read_cs0(space, (offset * 2) + 1, mem_mask >> 16) << 16;
- }
-
- return data;
-}
-
-READ32_MEMBER(ide_controller_32_device::read_cs1)
-{
- UINT32 data = 0;
-
- if (ACCESSING_BITS_0_15)
- {
- data = ide_controller_device::read_cs1(space, (offset * 2), mem_mask);
- }
- else if (ACCESSING_BITS_16_23)
- {
- data = ide_controller_device::read_cs1(space, (offset * 2) + 1, mem_mask >> 16) << 16;
- }
-
- return data;
-}
-
-WRITE32_MEMBER(ide_controller_32_device::write_cs0)
-{
- if (ACCESSING_BITS_0_15)
- {
- ide_controller_device::write_cs0(space, (offset * 2), data, mem_mask);
-
- if (offset == 0 && ACCESSING_BITS_16_31)
- ata_interface_device::write_cs0(space, (offset * 2), data >> 16, mem_mask >> 16);
- }
- else if (ACCESSING_BITS_16_31)
- {
- ide_controller_device::write_cs0(space, (offset * 2) + 1, data >> 16, mem_mask >> 16);
- }
-}
-
-WRITE32_MEMBER(ide_controller_32_device::write_cs1)
-{
- if (ACCESSING_BITS_0_15)
- {
- ide_controller_device::write_cs1(space, (offset * 2), data, mem_mask);
- }
- else if (ACCESSING_BITS_16_31)
- {
- ide_controller_device::write_cs1(space, (offset * 2) + 1, data >> 16, mem_mask >> 16);
- }
-}
-
-
-#define IDE_BUSMASTER_STATUS_ACTIVE 0x01
-#define IDE_BUSMASTER_STATUS_ERROR 0x02
-#define IDE_BUSMASTER_STATUS_IRQ 0x04
-
-const device_type BUS_MASTER_IDE_CONTROLLER = &device_creator<bus_master_ide_controller_device>;
-
-bus_master_ide_controller_device::bus_master_ide_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- ide_controller_32_device(mconfig, BUS_MASTER_IDE_CONTROLLER, "Bus Master IDE Controller", tag, owner, clock, "bus_master_ide_controller", __FILE__),
- m_dma_address(0),
- m_dma_bytes_left(0),
- m_dma_descriptor(0),
- m_dma_last_buffer(0),
- m_bus_master_command(0),
- m_bus_master_status(0),
- m_bus_master_descriptor(0),
- m_irq(0),
- m_dmarq(0)
-{
-}
-
-void bus_master_ide_controller_device::device_start()
-{
- ide_controller_32_device::device_start();
-
- /* find the bus master space */
- if (m_bmcpu != NULL)
- {
- device_t *bmtarget = machine().device(m_bmcpu);
- if (bmtarget == NULL)
- throw emu_fatalerror("IDE controller '%s' bus master target '%s' doesn't exist!", tag(), m_bmcpu);
- device_memory_interface *memory;
- if (!bmtarget->interface(memory))
- throw emu_fatalerror("IDE controller '%s' bus master target '%s' has no memory!", tag(), m_bmcpu);
- m_dma_space = &memory->space(m_bmspace);
- m_dma_address_xor = (m_dma_space->endianness() == ENDIANNESS_LITTLE) ? 0 : 3;
- }
-
- save_item(NAME(m_dma_address));
- save_item(NAME(m_dma_bytes_left));
- save_item(NAME(m_dma_descriptor));
- save_item(NAME(m_dma_last_buffer));
- save_item(NAME(m_bus_master_command));
- save_item(NAME(m_bus_master_status));
- save_item(NAME(m_bus_master_descriptor));
-}
-
-void bus_master_ide_controller_device::set_irq(int state)
-{
- ata_interface_device::set_irq(state);
-
- if (m_irq != state)
- {
- m_irq = state;
-
- if( m_irq )
- m_bus_master_status |= IDE_BUSMASTER_STATUS_IRQ;
- }
-}
-
-void bus_master_ide_controller_device::set_dmarq(int state)
-{
- ata_interface_device::set_dmarq(state);
-
- if (m_dmarq != state)
- {
- m_dmarq = state;
-
- execute_dma();
- }
-}
-
-/*************************************
- *
- * Bus master read
- *
- *************************************/
-
-READ32_MEMBER( bus_master_ide_controller_device::bmdma_r )
-{
- LOG(("%s:ide_bus_master32_r(%d, %08x)\n", machine().describe_context(), offset, mem_mask));
-
- switch( offset )
- {
- case 0:
- /* command register/status register */
- return m_bus_master_command | (m_bus_master_status << 16);
-
- case 1:
- /* descriptor table register */
- return m_bus_master_descriptor;
- }
-
- return 0xffffffff;
-}
-
-
-
-/*************************************
- *
- * Bus master write
- *
- *************************************/
-
-WRITE32_MEMBER( bus_master_ide_controller_device::bmdma_w )
-{
- LOG(("%s:ide_bus_master32_w(%d, %08x, %08X)\n", machine().describe_context(), offset, mem_mask, data));
-
- switch( offset )
- {
- case 0:
- if( ACCESSING_BITS_0_7 )
- {
- /* command register */
- UINT8 old = m_bus_master_command;
- UINT8 val = data & 0xff;
-
- /* save the read/write bit and the start/stop bit */
- m_bus_master_command = (old & 0xf6) | (val & 0x09);
-
- if ((old ^ m_bus_master_command) & 1)
- {
- if (m_bus_master_command & 1)
- {
- /* handle starting a transfer */
- m_bus_master_status |= IDE_BUSMASTER_STATUS_ACTIVE;
-
- /* reset all the DMA data */
- m_dma_bytes_left = 0;
- m_dma_descriptor = m_bus_master_descriptor;
-
- /* if we're going live, start the pending read/write */
- execute_dma();
- }
- else if (m_bus_master_status & IDE_BUSMASTER_STATUS_ACTIVE)
- {
- m_bus_master_status &= ~IDE_BUSMASTER_STATUS_ACTIVE;
-
- LOG(("DMA Aborted!\n"));
- }
- }
- }
-
- if( ACCESSING_BITS_16_23 )
- {
- /* status register */
- UINT8 old = m_bus_master_status;
- UINT8 val = data >> 16;
-
- /* save the DMA capable bits */
- m_bus_master_status = (old & 0x9f) | (val & 0x60);
-
- /* clear interrupt and error bits */
- if (val & IDE_BUSMASTER_STATUS_IRQ)
- m_bus_master_status &= ~IDE_BUSMASTER_STATUS_IRQ;
- if (val & IDE_BUSMASTER_STATUS_ERROR)
- m_bus_master_status &= ~IDE_BUSMASTER_STATUS_ERROR;
- }
- break;
-
- case 1:
- /* descriptor table register */
- m_bus_master_descriptor = data & 0xfffffffc;
- break;
- }
-}
-
-void bus_master_ide_controller_device::execute_dma()
-{
- write_dmack(ASSERT_LINE);
-
- while (m_dmarq && (m_bus_master_status & IDE_BUSMASTER_STATUS_ACTIVE))
- {
- /* if we're out of space, grab the next descriptor */
- if (m_dma_bytes_left == 0)
- {
- /* fetch the address */
- m_dma_address = m_dma_space->read_byte(m_dma_descriptor++ ^ m_dma_address_xor);
- m_dma_address |= m_dma_space->read_byte(m_dma_descriptor++ ^ m_dma_address_xor) << 8;
- m_dma_address |= m_dma_space->read_byte(m_dma_descriptor++ ^ m_dma_address_xor) << 16;
- m_dma_address |= m_dma_space->read_byte(m_dma_descriptor++ ^ m_dma_address_xor) << 24;
- m_dma_address &= 0xfffffffe;
-
- /* fetch the length */
- m_dma_bytes_left = m_dma_space->read_byte(m_dma_descriptor++ ^ m_dma_address_xor);
- m_dma_bytes_left |= m_dma_space->read_byte(m_dma_descriptor++ ^ m_dma_address_xor) << 8;
- m_dma_bytes_left |= m_dma_space->read_byte(m_dma_descriptor++ ^ m_dma_address_xor) << 16;
- m_dma_bytes_left |= m_dma_space->read_byte(m_dma_descriptor++ ^ m_dma_address_xor) << 24;
- m_dma_last_buffer = (m_dma_bytes_left >> 31) & 1;
- m_dma_bytes_left &= 0xfffe;
- if (m_dma_bytes_left == 0)
- m_dma_bytes_left = 0x10000;
-
-// LOG(("New DMA descriptor: address = %08X bytes = %04X last = %d\n", m_dma_address, m_dma_bytes_left, m_dma_last_buffer));
- }
-
- if (m_bus_master_command & 8)
- {
- // read from ata bus
- UINT16 data = read_dma();
-
- // write to memory
- m_dma_space->write_byte(m_dma_address++, data & 0xff);
- m_dma_space->write_byte(m_dma_address++, data >> 8);
- }
- else
- {
- // read from memory;
- UINT16 data = m_dma_space->read_byte(m_dma_address++);
- data |= m_dma_space->read_byte(m_dma_address++) << 8;
-
- // write to ata bus
- write_dma(data);
- }
-
- m_dma_bytes_left -= 2;
-
- if (m_dma_bytes_left == 0 && m_dma_last_buffer)
- {
- m_bus_master_status &= ~IDE_BUSMASTER_STATUS_ACTIVE;
-
- if (m_dmarq)
- {
- LOG(("DMA Out of buffer space!\n"));
- }
- }
- }
-
- write_dmack(CLEAR_LINE);
-}
diff --git a/src/emu/machine/idectrl.h b/src/emu/machine/idectrl.h
deleted file mode 100644
index d31490e2385..00000000000
--- a/src/emu/machine/idectrl.h
+++ /dev/null
@@ -1,121 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- idectrl.h
-
- Generic (PC-style) IDE controller implementation.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __IDECTRL_H__
-#define __IDECTRL_H__
-
-#include "ataintf.h"
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_IDE_CONTROLLER_ADD(_tag, _slot_intf, _master, _slave, _fixed) \
- MCFG_DEVICE_ADD(_tag, IDE_CONTROLLER, 0) \
- MCFG_DEVICE_MODIFY(_tag ":0") \
- MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _master, _fixed) \
- MCFG_DEVICE_MODIFY(_tag ":1") \
- MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _slave, _fixed) \
- MCFG_DEVICE_MODIFY(_tag)
-
-class ide_controller_device : public ata_interface_device
-{
-public:
- ide_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ide_controller_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- virtual DECLARE_READ16_MEMBER(read_cs0);
- virtual DECLARE_READ16_MEMBER(read_cs1);
- virtual DECLARE_WRITE16_MEMBER(write_cs0);
- virtual DECLARE_WRITE16_MEMBER(write_cs1);
-};
-
-extern const device_type IDE_CONTROLLER;
-
-
-#define MCFG_IDE_CONTROLLER_32_ADD(_tag, _slot_intf, _master, _slave, _fixed) \
- MCFG_DEVICE_ADD(_tag, IDE_CONTROLLER_32, 0) \
- MCFG_DEVICE_MODIFY(_tag ":0") \
- MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _master, _fixed) \
- MCFG_DEVICE_MODIFY(_tag ":1") \
- MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _slave, _fixed) \
- MCFG_DEVICE_MODIFY(_tag)
-
-class ide_controller_32_device : public ide_controller_device
-{
-public:
- ide_controller_32_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ide_controller_32_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- virtual DECLARE_READ32_MEMBER(read_cs0);
- virtual DECLARE_READ32_MEMBER(read_cs1);
- virtual DECLARE_WRITE32_MEMBER(write_cs0);
- virtual DECLARE_WRITE32_MEMBER(write_cs1);
-
-private:
- using ide_controller_device::read_cs0;
- using ide_controller_device::read_cs1;
- using ide_controller_device::write_cs0;
- using ide_controller_device::write_cs1;
-};
-
-extern const device_type IDE_CONTROLLER_32;
-
-
-#define MCFG_BUS_MASTER_IDE_CONTROLLER_ADD(_tag, _slot_intf, _master, _slave, _fixed) \
- MCFG_DEVICE_ADD(_tag, BUS_MASTER_IDE_CONTROLLER, 0) \
- MCFG_DEVICE_MODIFY(_tag ":0") \
- MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _master, _fixed) \
- MCFG_DEVICE_MODIFY(_tag ":1") \
- MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _slave, _fixed) \
- MCFG_DEVICE_MODIFY(_tag)
-
-#define MCFG_BUS_MASTER_IDE_CONTROLLER_SPACE(bmcpu, bmspace) \
- bus_master_ide_controller_device::set_bus_master_space(*device, bmcpu, bmspace);
-
-class bus_master_ide_controller_device : public ide_controller_32_device
-{
-public:
- bus_master_ide_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- static void set_bus_master_space(device_t &device, const char *bmcpu, UINT32 bmspace) {bus_master_ide_controller_device &ide = downcast<bus_master_ide_controller_device &>(device); ide.m_bmcpu = bmcpu; ide.m_bmspace = bmspace; }
-
- DECLARE_READ32_MEMBER( bmdma_r );
- DECLARE_WRITE32_MEMBER( bmdma_w );
-
-protected:
- virtual void device_start();
-
- virtual void set_irq(int state);
- virtual void set_dmarq(int state);
-
-private:
- void execute_dma();
-
- const char *m_bmcpu;
- UINT32 m_bmspace;
- address_space * m_dma_space;
- UINT8 m_dma_address_xor;
-
- offs_t m_dma_address;
- UINT32 m_dma_bytes_left;
- offs_t m_dma_descriptor;
- UINT8 m_dma_last_buffer;
- UINT8 m_bus_master_command;
- UINT8 m_bus_master_status;
- UINT32 m_bus_master_descriptor;
- int m_irq;
- int m_dmarq;
-};
-
-extern const device_type BUS_MASTER_IDE_CONTROLLER;
-
-#endif /* __IDECTRL_H__ */
diff --git a/src/emu/machine/idehd.c b/src/emu/machine/idehd.c
deleted file mode 100644
index aa5517a1a3e..00000000000
--- a/src/emu/machine/idehd.c
+++ /dev/null
@@ -1,836 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "idehd.h"
-
-/***************************************************************************
- DEBUGGING
-***************************************************************************/
-
-#define VERBOSE 0
-#define PRINTF_IDE_COMMANDS 0
-#define PRINTF_IDE_PASSWORD 0
-
-#define LOGPRINT(x) do { if (VERBOSE) logerror x; if (PRINTF_IDE_COMMANDS) osd_printf_debug x; } while (0)
-
-#define TIME_PER_SECTOR_WRITE (attotime::from_usec(100))
-/* read time <2 breaks primrag2, ==100 breaks bm1stmix */
-#define TIME_PER_SECTOR_READ (attotime::from_usec(2))
-#define TIME_PER_ROTATION (attotime::from_hz(5400/60))
-#define TIME_BETWEEN_SECTORS (attotime::from_nsec(400))
-
-#define TIME_FULL_STROKE_SEEK (attotime::from_usec(13000))
-#define TIME_AVERAGE_ROTATIONAL_LATENCY (attotime::from_usec(1300))
-
-ata_mass_storage_device::ata_mass_storage_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock,const char *shortname, const char *source)
- : ata_hle_device(mconfig, type, name, tag, owner, clock, shortname, source),
- m_can_identify_device(0),
- m_num_cylinders(0),
- m_num_sectors(0),
- m_num_heads(0),
- m_master_password(NULL),
- m_user_password(NULL)
-{
-}
-
-/*************************************
- *
- * Compute the LBA address
- *
- *************************************/
-
-UINT32 ata_mass_storage_device::lba_address()
-{
- /* LBA direct? */
- if (m_device_head & IDE_DEVICE_HEAD_L)
- return ((m_device_head & IDE_DEVICE_HEAD_HS) << 24) | (m_cylinder_high << 16) | (m_cylinder_low << 8) | m_sector_number;
-
- /* standard CHS */
- else
- return (((((m_cylinder_high << 8) | m_cylinder_low) * m_num_heads) + (m_device_head & IDE_DEVICE_HEAD_HS)) * m_num_sectors) + m_sector_number - 1;
-}
-
-
-/*************************************
- *
- * Build a features page
- *
- *************************************/
-
-static void swap_strncpy(UINT16 *dst, const char *src, int field_size_in_words)
-{
- for (int i = 0; i < field_size_in_words; i++)
- {
- UINT16 d = 0;
-
- if (*src)
- {
- d = *(src++) << 8;
- }
- else
- {
- d = ' ' << 8;
- }
-
- if (*src)
- {
- d |= *(src++);
- }
- else
- {
- d |= ' ';
- }
-
- dst[i] = d;
- }
-
- assert(*(src) == 0);
-}
-
-
-void ata_mass_storage_device::ide_build_identify_device()
-{
- memset(m_identify_buffer, 0, sizeof(m_identify_buffer));
- int total_sectors = m_num_cylinders * m_num_heads * m_num_sectors;
-
- /* basic geometry */
- m_identify_buffer[0] = 0x045a; /* 0: configuration bits */
- m_identify_buffer[1] = m_num_cylinders; /* 1: logical cylinders */
- m_identify_buffer[2] = 0; /* 2: reserved */
- m_identify_buffer[3] = m_num_heads; /* 3: logical heads */
- m_identify_buffer[4] = 0; /* 4: vendor specific (obsolete) */
- m_identify_buffer[5] = 0; /* 5: vendor specific (obsolete) */
- m_identify_buffer[6] = m_num_sectors; /* 6: logical sectors per logical track */
- m_identify_buffer[7] = 0; /* 7: vendor-specific */
- m_identify_buffer[8] = 0; /* 8: vendor-specific */
- m_identify_buffer[9] = 0; /* 9: vendor-specific */
- swap_strncpy(&m_identify_buffer[10], /* 10-19: serial number */
- "00000000000000000000", 10);
- m_identify_buffer[20] = 0; /* 20: vendor-specific */
- m_identify_buffer[21] = 0; /* 21: vendor-specific */
- m_identify_buffer[22] = 4; /* 22: # of vendor-specific bytes on read/write long commands */
- swap_strncpy(&m_identify_buffer[23], /* 23-26: firmware revision */
- "1.0", 4);
- swap_strncpy(&m_identify_buffer[27], /* 27-46: model number */
- "MAME Compressed Hard Disk", 20);
- m_identify_buffer[47] = 0x8001; /* 47: read/write multiple support */
- m_identify_buffer[48] = 0; /* 48: reserved */
- m_identify_buffer[49] = 0x0f03; /* 49: capabilities */
- m_identify_buffer[50] = 0; /* 50: reserved */
- m_identify_buffer[51] = 2; /* 51: PIO data transfer cycle timing mode */
- m_identify_buffer[52] = 2; /* 52: single word DMA transfer cycle timing mode */
- m_identify_buffer[53] = 3; /* 53: field validity */
- m_identify_buffer[54] = m_num_cylinders; /* 54: number of current logical cylinders */
- m_identify_buffer[55] = m_num_heads; /* 55: number of current logical heads */
- m_identify_buffer[56] = m_num_sectors; /* 56: number of current logical sectors per track */
- m_identify_buffer[57] = total_sectors & 0xffff; /* 57-58: current capacity in sectors (ATA-1 through ATA-5; obsoleted in ATA-6) */
- m_identify_buffer[58] = total_sectors >> 16;
- m_identify_buffer[59] = 0; /* 59: multiple sector timing */
- m_identify_buffer[60] = total_sectors & 0xffff; /* 60-61: total user addressable sectors for LBA mode (ATA-1 through ATA-7) */
- m_identify_buffer[61] = total_sectors >> 16;
- m_identify_buffer[62] = 0x0007; /* 62: single word dma transfer */
- m_identify_buffer[63] = 0x0407; /* 63: multiword DMA transfer */
- m_identify_buffer[64] = 0x0003; /* 64: flow control PIO transfer modes supported */
- m_identify_buffer[65] = 0x78; /* 65: minimum multiword DMA transfer cycle time per word */
- m_identify_buffer[66] = 0x78; /* 66: mfr's recommended multiword DMA transfer cycle time */
- m_identify_buffer[67] = 0x014d; /* 67: minimum PIO transfer cycle time without flow control */
- m_identify_buffer[68] = 0x78; /* 68: minimum PIO transfer cycle time with IORDY */
- m_identify_buffer[69] = 0x00; /* 69-70: reserved */
- m_identify_buffer[71] = 0x00; /* 71: reserved for IDENTIFY PACKET command */
- m_identify_buffer[72] = 0x00; /* 72: reserved for IDENTIFY PACKET command */
- m_identify_buffer[73] = 0x00; /* 73: reserved for IDENTIFY PACKET command */
- m_identify_buffer[74] = 0x00; /* 74: reserved for IDENTIFY PACKET command */
- m_identify_buffer[75] = 0x00; /* 75: queue depth */
- m_identify_buffer[76] = 0x00; /* 76-79: reserved */
- m_identify_buffer[80] = 0x00; /* 80: major version number */
- m_identify_buffer[81] = 0x00; /* 81: minor version number */
- m_identify_buffer[82] = 0x00; /* 82: command set supported */
- m_identify_buffer[83] = 0x00; /* 83: command sets supported */
- m_identify_buffer[84] = 0x00; /* 84: command set/feature supported extension */
- m_identify_buffer[85] = 0x00; /* 85: command set/feature enabled */
- m_identify_buffer[86] = 0x00; /* 86: command set/feature enabled */
- m_identify_buffer[87] = 0x00; /* 87: command set/feature default */
- m_identify_buffer[88] = 0x00; /* 88: additional DMA modes */
- m_identify_buffer[89] = 0x00; /* 89: time required for security erase unit completion */
- m_identify_buffer[90] = 0x00; /* 90: time required for enhanced security erase unit completion */
- m_identify_buffer[91] = 0x00; /* 91: current advanced power management value */
- m_identify_buffer[92] = 0x00; /* 92: master password revision code */
- m_identify_buffer[93] = 0x00; /* 93: hardware reset result */
- m_identify_buffer[94] = 0x00; /* 94: acoustic management values */
- m_identify_buffer[95] = 0x00; /* 95-99: reserved */
- m_identify_buffer[100] = total_sectors & 0xffff; /* 100-103: maximum 48-bit LBA */
- m_identify_buffer[101] = total_sectors >> 16;
- m_identify_buffer[102] = 0x00;
- m_identify_buffer[103] = 0x00;
- m_identify_buffer[104] = 0x00; /* 104-126: reserved */
- m_identify_buffer[127] = 0x00; /* 127: removable media status notification */
- m_identify_buffer[128] = 0x00; /* 128: security status */
- m_identify_buffer[129] = 0x00; /* 129-159: vendor specific */
- m_identify_buffer[160] = 0x00; /* 160: CFA power mode 1 */
- m_identify_buffer[161] = 0x00; /* 161-175: reserved for CompactFlash */
- m_identify_buffer[176] = 0x00; /* 176-205: current media serial number */
- m_identify_buffer[206] = 0x00; /* 206-254: reserved */
- m_identify_buffer[255] = 0x00; /* 255: integrity word */
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ata_mass_storage_device::device_start()
-{
- ata_hle_device::device_start();
-
- save_item(NAME(m_can_identify_device));
- save_item(NAME(m_num_cylinders));
- save_item(NAME(m_num_sectors));
- save_item(NAME(m_num_heads));
-
- save_item(NAME(m_cur_lba));
- save_item(NAME(m_sectors_until_int));
- save_item(NAME(m_master_password_enable));
- save_item(NAME(m_user_password_enable));
- save_item(NAME(m_block_count));
-}
-
-void ata_mass_storage_device::soft_reset()
-{
- ata_hle_device::soft_reset();
-
- m_cur_lba = 0;
- m_status |= IDE_STATUS_DSC;
-
- m_master_password_enable = (m_master_password != NULL);
- m_user_password_enable = (m_user_password != NULL);
-}
-
-void ata_mass_storage_device::perform_diagnostic()
-{
- if (m_can_identify_device)
- m_error = IDE_ERROR_DIAGNOSTIC_PASSED;
-}
-
-void ata_mass_storage_device::signature()
-{
- m_sector_count = 1;
- m_sector_number = 1;
- m_cylinder_low = 0;
- m_cylinder_high = 0;
- m_device_head = 0;
-}
-
-void ata_mass_storage_device::finished_command()
-{
- int total_sectors = m_num_cylinders * m_num_heads * m_num_sectors;
-
- switch (m_command)
- {
- case IDE_COMMAND_IDENTIFY_DEVICE:
- if (m_can_identify_device)
- {
- for( int w = 0; w < 256; w++ )
- {
- m_buffer[w * 2] = m_identify_buffer[ w ] & 0xff;
- m_buffer[(w * 2) + 1] = m_identify_buffer[ w ] >> 8;
- }
-
- m_status |= IDE_STATUS_DRQ;
- }
- else
- {
- m_status |= IDE_STATUS_ERR;
- m_error = IDE_ERROR_NONE;
- }
-
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_SET_CONFIG:
- set_geometry(m_sector_count,(m_device_head & IDE_DEVICE_HEAD_HS) + 1);
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_READ_SECTORS:
- case IDE_COMMAND_READ_SECTORS_NORETRY:
- case IDE_COMMAND_READ_MULTIPLE:
- case IDE_COMMAND_VERIFY_SECTORS:
- case IDE_COMMAND_VERIFY_SECTORS_NORETRY:
- case IDE_COMMAND_READ_DMA:
- finished_read();
- break;
-
- case IDE_COMMAND_WRITE_SECTORS:
- case IDE_COMMAND_WRITE_SECTORS_NORETRY:
- case IDE_COMMAND_WRITE_MULTIPLE:
- case IDE_COMMAND_WRITE_DMA:
- finished_write();
- break;
-
- case IDE_COMMAND_RECALIBRATE:
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_READ_NATIVE_MAX_ADDRESS:
- m_buffer[0] = (total_sectors & 0xff000000) >> 24;
- m_buffer[1] = (total_sectors & 0x00ff0000) >> 16;
- m_buffer[2] = (total_sectors & 0x0000ff00) >> 8;
- m_buffer[3] = (total_sectors & 0x000000ff);
- set_irq(ASSERT_LINE);
- break;
-
- default:
- ata_hle_device::finished_command();
- break;
- }
-}
-
-/*************************************
- *
- * Advance to the next sector
- *
- *************************************/
-
-void ata_mass_storage_device::next_sector()
-{
- UINT8 cur_head = m_device_head & IDE_DEVICE_HEAD_HS;
-
- /* LBA direct? */
- if (m_device_head & IDE_DEVICE_HEAD_L)
- {
- m_sector_number++;
- if (m_sector_number == 0)
- {
- m_cylinder_low++;
- if (m_cylinder_low == 0)
- {
- m_cylinder_high++;
- if (m_cylinder_high == 0)
- cur_head++;
- }
- }
- }
-
- /* standard CHS */
- else
- {
- /* sectors are 1-based */
- m_sector_number++;
- if (m_sector_number > m_num_sectors)
- {
- /* heads are 0 based */
- m_sector_number = 1;
- cur_head++;
- if (cur_head >= m_num_heads)
- {
- cur_head = 0;
- m_cylinder_low++;
- if (m_cylinder_low == 0)
- m_cylinder_high++;
- }
- }
- }
-
- m_device_head = (m_device_head & ~IDE_DEVICE_HEAD_HS) | cur_head;
-
- m_cur_lba = lba_address();
-}
-
-
-
-/*************************************
- *
- * security error handling
- *
- *************************************/
-
-void ata_mass_storage_device::security_error()
-{
- /* set error state */
- m_status |= IDE_STATUS_ERR;
- m_error = IDE_ERROR_NONE;
- m_status &= ~IDE_STATUS_DRDY;
-}
-
-
-
-/*************************************
- *
- * Sector reading
- *
- *************************************/
-
-attotime ata_mass_storage_device::seek_time()
-{
- int sectors_per_cylinder = m_num_heads * m_num_sectors;
-
- if (sectors_per_cylinder == 0 || m_num_cylinders == 0)
- return attotime::zero;
-
- int new_lba = lba_address();
- int old_cylinder = m_cur_lba / sectors_per_cylinder;
- int new_cylinder = new_lba / sectors_per_cylinder;
- int diff = abs(old_cylinder - new_cylinder);
-
- m_cur_lba = new_lba;
-
- if (diff == 0)
- return TIME_BETWEEN_SECTORS;
-
- attotime seek_time = (TIME_FULL_STROKE_SEEK * diff) / m_num_cylinders;
-
- return seek_time + TIME_AVERAGE_ROTATIONAL_LATENCY;
-}
-
-void ata_mass_storage_device::fill_buffer()
-{
- switch (m_command)
- {
- case IDE_COMMAND_IDENTIFY_DEVICE:
- break;
-
- default:
- /* if there is more data to read, keep going */
- if (m_sector_count > 0)
- m_sector_count--;
-
- if (m_sector_count > 0)
- {
- set_dasp(ASSERT_LINE);
- start_busy(TIME_PER_SECTOR_READ, PARAM_COMMAND);
- }
- break;
- }
-}
-
-
-void ata_mass_storage_device::finished_read()
-{
- int lba = lba_address(), count = 0;
-
- set_dasp(CLEAR_LINE);
-
- /* now do the read */
- count = read_sector(lba, &m_buffer[0]);
-
- /* if we succeeded, advance to the next sector and set the nice bits */
- if (count == 1)
- {
- /* advance the pointers, unless this is the last sector */
- /* Gauntlet: Dark Legacy checks to make sure we stop on the last sector */
- if (m_sector_count != 1)
- next_sector();
-
- /* signal an interrupt */
- if (--m_sectors_until_int == 0 || m_sector_count == 1)
- {
- m_sectors_until_int = ((m_command == IDE_COMMAND_READ_MULTIPLE) ? m_block_count : 1);
- set_irq(ASSERT_LINE);
- }
-
- /* if we're just verifying we can read the next sector */
- if (m_command == IDE_COMMAND_VERIFY_SECTORS ||
- m_command == IDE_COMMAND_VERIFY_SECTORS_NORETRY )
- {
- read_buffer_empty();
- }
- else
- {
- m_status |= IDE_STATUS_DRQ;
-
- if (m_command == IDE_COMMAND_READ_DMA)
- set_dmarq(ASSERT_LINE);
- }
- }
-
- /* if we got an error, we need to report it */
- else
- {
- /* set the error flag and the error */
- m_status |= IDE_STATUS_ERR;
- m_error = IDE_ERROR_BAD_SECTOR;
-
- /* signal an interrupt */
- set_irq(ASSERT_LINE);
- }
-}
-
-
-void ata_mass_storage_device::read_first_sector()
-{
- if (m_master_password_enable || m_user_password_enable)
- {
- security_error();
- }
- else
- {
- set_dasp(ASSERT_LINE);
-
- start_busy(seek_time(), PARAM_COMMAND);
- }
-}
-
-/*************************************
- *
- * Sector writing
- *
- *************************************/
-
-void ata_mass_storage_device::process_buffer()
-{
- if (m_command == IDE_COMMAND_SECURITY_UNLOCK)
- {
- if (m_user_password_enable && memcmp(&m_buffer[0], m_user_password, 2 + 32) == 0)
- {
- LOGPRINT(("IDE Unlocked user password\n"));
- m_user_password_enable = 0;
- }
- if (m_master_password_enable && memcmp(&m_buffer[0], m_master_password, 2 + 32) == 0)
- {
- LOGPRINT(("IDE Unlocked master password\n"));
- m_master_password_enable = 0;
- }
- if (PRINTF_IDE_PASSWORD)
- {
- int i;
-
- for (i = 0; i < 34; i += 2)
- {
- if (i % 8 == 2)
- osd_printf_debug("\n");
-
- osd_printf_debug("0x%02x, 0x%02x, ", m_buffer[i], m_buffer[i + 1]);
- //osd_printf_debug("0x%02x%02x, ", m_buffer[i], m_buffer[i + 1]);
- }
- osd_printf_debug("\n");
- }
-
- if (m_master_password_enable || m_user_password_enable)
- security_error();
- }
- else
- {
- set_dasp(ASSERT_LINE);
-
- if (m_command == IDE_COMMAND_WRITE_MULTIPLE)
- {
- if (m_sectors_until_int != 1)
- {
- /* ready to write now */
- finished_write();
- }
- else
- {
- /* set a timer to do the write */
- start_busy(TIME_PER_SECTOR_WRITE, PARAM_COMMAND);
- }
- }
- else
- {
- /* set a timer to do the write */
- start_busy(TIME_PER_SECTOR_WRITE, PARAM_COMMAND);
- }
- }
-}
-
-
-void ata_mass_storage_device::finished_write()
-{
- int lba = lba_address(), count = 0;
-
- set_dasp(CLEAR_LINE);
-
- /* now do the write */
- count = write_sector(lba, &m_buffer[0]);
-
- /* if we succeeded, advance to the next sector and set the nice bits */
- if (count == 1)
- {
- /* advance the pointers, unless this is the last sector */
- /* Gauntlet: Dark Legacy checks to make sure we stop on the last sector */
- if (m_sector_count != 1)
- next_sector();
-
- /* signal an interrupt */
- if (--m_sectors_until_int == 0 || m_sector_count == 1)
- {
- m_sectors_until_int = ((m_command == IDE_COMMAND_WRITE_MULTIPLE) ? m_block_count : 1);
- set_irq(ASSERT_LINE);
- }
-
- /* signal an interrupt if there's more data needed */
- if (m_sector_count > 0)
- m_sector_count--;
-
- if (m_sector_count > 0)
- {
- m_status |= IDE_STATUS_DRQ;
-
- if (m_command == IDE_COMMAND_WRITE_DMA)
- set_dmarq(ASSERT_LINE);
- }
- }
-
- /* if we got an error, we need to report it */
- else
- {
- /* set the error flag and the error */
- m_status |= IDE_STATUS_ERR;
- m_error = IDE_ERROR_BAD_SECTOR;
-
- /* signal an interrupt */
- set_irq(ASSERT_LINE);
- }
-}
-
-
-/*************************************
- *
- * Handle IDE commands
- *
- *************************************/
-
-void ata_mass_storage_device::process_command()
-{
- m_sectors_until_int = 0;
- m_buffer_size = IDE_DISK_SECTOR_SIZE;
-
- switch (m_command)
- {
- case IDE_COMMAND_READ_SECTORS:
- case IDE_COMMAND_READ_SECTORS_NORETRY:
- LOGPRINT(("IDE Read multiple: C=%d H=%d S=%d LBA=%d count=%d\n",
- (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
-
- m_sectors_until_int = 1;
-
- /* start the read going */
- read_first_sector();
- break;
-
- case IDE_COMMAND_READ_MULTIPLE:
- LOGPRINT(("IDE Read multiple block: C=%d H=%d S=%d LBA=%d count=%d\n",
- (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
-
- m_sectors_until_int = 1;
-
- /* start the read going */
- read_first_sector();
- break;
-
- case IDE_COMMAND_VERIFY_SECTORS:
- case IDE_COMMAND_VERIFY_SECTORS_NORETRY:
- LOGPRINT(("IDE Read verify multiple with/without retries: C=%d H=%d S=%d LBA=%d count=%d\n",
- (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
-
- /* reset the buffer */
- m_sectors_until_int = m_sector_count;
-
- /* start the read going */
- read_first_sector();
- break;
-
- case IDE_COMMAND_READ_DMA:
- LOGPRINT(("IDE Read multiple DMA: C=%d H=%d S=%d LBA=%d count=%d\n",
- (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
-
- /* reset the buffer */
- m_sectors_until_int = m_sector_count;
-
- /* start the read going */
- read_first_sector();
- break;
-
- case IDE_COMMAND_WRITE_SECTORS:
- case IDE_COMMAND_WRITE_SECTORS_NORETRY:
- LOGPRINT(("IDE Write multiple: C=%d H=%d S=%d LBA=%d count=%d\n",
- (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
-
- /* reset the buffer */
- m_sectors_until_int = 1;
-
- /* mark the buffer ready */
- m_status |= IDE_STATUS_DRQ;
- break;
-
- case IDE_COMMAND_WRITE_MULTIPLE:
- LOGPRINT(("IDE Write multiple block: C=%d H=%d S=%d LBA=%d count=%d\n",
- (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
-
- /* reset the buffer */
- m_sectors_until_int = 1;
-
- /* mark the buffer ready */
- m_status |= IDE_STATUS_DRQ;
- break;
-
- case IDE_COMMAND_WRITE_DMA:
- LOGPRINT(("IDE Write multiple DMA: C=%d H=%d S=%d LBA=%d count=%d\n",
- (m_cylinder_high << 8) | m_cylinder_low, m_device_head & IDE_DEVICE_HEAD_HS, m_sector_number, lba_address(), m_sector_count));
-
- /* reset the buffer */
- m_sectors_until_int = m_sector_count;
-
- /* mark the buffer ready */
- m_status |= IDE_STATUS_DRQ;
-
- /* start the read going */
- set_dmarq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_SECURITY_UNLOCK:
- LOGPRINT(("IDE Security Unlock\n"));
-
- /* mark the buffer ready */
- m_status |= IDE_STATUS_DRQ;
-
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_IDENTIFY_DEVICE:
- LOGPRINT(("IDE Identify device\n"));
-
- start_busy(MINIMUM_COMMAND_TIME, PARAM_COMMAND);
- break;
-
- case IDE_COMMAND_RECALIBRATE:
- start_busy(MINIMUM_COMMAND_TIME, PARAM_COMMAND);
- break;
-
- case IDE_COMMAND_IDLE:
- /* signal an interrupt */
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_SET_CONFIG:
- LOGPRINT(("IDE Set configuration (%d heads, %d sectors)\n", (m_device_head & IDE_DEVICE_HEAD_HS) + 1, m_sector_count));
-
- start_busy(MINIMUM_COMMAND_TIME, PARAM_COMMAND);
- break;
-
- case IDE_COMMAND_SET_MAX:
- LOGPRINT(("IDE Set max (%02X %02X %02X %02X %02X)\n", m_feature, m_sector_count & 0xff, m_sector_number, m_cylinder_low, m_cylinder_high));
-
- /* signal an interrupt */
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_SET_BLOCK_COUNT:
- LOGPRINT(("IDE Set block count (%02X)\n", m_sector_count));
-
- m_block_count = m_sector_count;
-
- /* signal an interrupt */
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_SEEK:
- /* signal an interrupt */
- set_irq(ASSERT_LINE);
- break;
-
- case IDE_COMMAND_READ_NATIVE_MAX_ADDRESS:
- start_busy(MINIMUM_COMMAND_TIME, PARAM_COMMAND);
- break;
-
- default:
- ata_hle_device::process_command();
- break;
- }
-}
-
-//**************************************************************************
-// IDE HARD DISK DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type IDE_HARDDISK = &device_creator<ide_hdd_device>;
-
-//-------------------------------------------------
-// ide_hdd_device - constructor
-//-------------------------------------------------
-
-ide_hdd_device::ide_hdd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : ata_mass_storage_device(mconfig, IDE_HARDDISK, "IDE Hard Disk", tag, owner, clock, "hdd", __FILE__),
- m_image(*this, "image")
-{
-}
-
-ide_hdd_device::ide_hdd_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : ata_mass_storage_device(mconfig, type, name, tag, owner, clock, shortname, source),
- m_image(*this, "image")
-{
-}
-
-void ide_hdd_device::device_start()
-{
- ata_mass_storage_device::device_start();
-
- /* create a timer for timing status */
- m_last_status_timer = timer_alloc(TID_NULL);
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ide_hdd_device::device_reset()
-{
- m_handle = m_image->get_chd_file();
- m_disk = m_image->get_hard_disk_file();
-
- if (m_disk != NULL && !m_can_identify_device)
- {
- const hard_disk_info *hdinfo = hard_disk_get_info(m_disk);
- if (hdinfo->sectorbytes == IDE_DISK_SECTOR_SIZE)
- {
- m_num_cylinders = hdinfo->cylinders;
- m_num_sectors = hdinfo->sectors;
- m_num_heads = hdinfo->heads;
- if (PRINTF_IDE_COMMANDS) osd_printf_debug("CHS: %d %d %d\n", m_num_cylinders, m_num_heads, m_num_sectors);
- osd_printf_debug("CHS: %d %d %d\n", m_num_cylinders, m_num_heads, m_num_sectors);
- }
-
- // build the features page
- UINT32 metalength;
- if (m_handle->read_metadata (HARD_DISK_IDENT_METADATA_TAG, 0, &m_buffer[0], 512, metalength) == CHDERR_NONE)
- {
- for( int w = 0; w < 256; w++ )
- {
- m_identify_buffer[w] = (m_buffer[(w * 2) + 1] << 8) | m_buffer[w * 2];
- }
- }
- else
- {
- ide_build_identify_device();
- }
-
- m_can_identify_device = 1;
- }
-
- ata_mass_storage_device::device_reset();
-}
-
-UINT8 ide_hdd_device::calculate_status()
-{
- UINT8 result = ata_hle_device::calculate_status();
-
- if (m_last_status_timer->elapsed() > TIME_PER_ROTATION)
- {
- result |= IDE_STATUS_IDX;
- m_last_status_timer->adjust(attotime::never);
- }
-
- return result;
-}
-
-//-------------------------------------------------
-// machine_config_additions - device-specific
-// machine configurations
-//-------------------------------------------------
-static MACHINE_CONFIG_FRAGMENT( hdd_image )
- MCFG_HARDDISK_ADD( "image" )
-MACHINE_CONFIG_END
-
-machine_config_constructor ide_hdd_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( hdd_image );
-}
diff --git a/src/emu/machine/idehd.h b/src/emu/machine/idehd.h
deleted file mode 100644
index beacb0a25c4..00000000000
--- a/src/emu/machine/idehd.h
+++ /dev/null
@@ -1,122 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- idehd.h
-
- IDE Harddisk
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __IDEHD_H__
-#define __IDEHD_H__
-
-#include "atahle.h"
-#include "harddisk.h"
-#include "imagedev/harddriv.h"
-
-class ata_mass_storage_device : public ata_hle_device
-{
-public:
- ata_mass_storage_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock,const char *shortname, const char *source);
-
- UINT16 *identify_device_buffer() { return m_identify_buffer; }
-
- void set_master_password(const UINT8 *password)
- {
- m_master_password = password;
- m_master_password_enable = (password != NULL);
- }
-
- void set_user_password(const UINT8 *password)
- {
- m_user_password = password;
- m_user_password_enable = (password != NULL);
- }
-
-protected:
- virtual void device_start();
-
- virtual int read_sector(UINT32 lba, void *buffer) = 0;
- virtual int write_sector(UINT32 lba, const void *buffer) = 0;
- virtual attotime seek_time();
-
- void ide_build_identify_device();
-
- static const int IDE_DISK_SECTOR_SIZE = 512;
- virtual int sector_length() { return IDE_DISK_SECTOR_SIZE; }
- virtual void process_buffer();
- virtual void fill_buffer();
- virtual bool is_ready() { return true; }
- virtual void process_command();
- virtual void finished_command();
- virtual void perform_diagnostic();
- virtual void signature();
-
- int m_can_identify_device;
- UINT16 m_num_cylinders;
- UINT8 m_num_sectors;
- UINT8 m_num_heads;
-
- virtual UINT32 lba_address();
-
-private:
- void set_geometry(UINT8 sectors, UINT8 heads) { m_num_sectors = sectors; m_num_heads = heads; }
- void finished_read();
- void finished_write();
- void next_sector();
- void security_error();
- void read_first_sector();
- void soft_reset();
-
- UINT32 m_cur_lba;
- UINT16 m_block_count;
- UINT16 m_sectors_until_int;
-
- UINT8 m_master_password_enable;
- UINT8 m_user_password_enable;
- const UINT8 * m_master_password;
- const UINT8 * m_user_password;
-};
-
-// ======================> ide_hdd_device
-
-class ide_hdd_device : public ata_mass_storage_device
-{
-public:
- // construction/destruction
- ide_hdd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ide_hdd_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- // optional information overrides
- virtual machine_config_constructor device_mconfig_additions() const;
-
- virtual int read_sector(UINT32 lba, void *buffer) { if (m_disk == NULL) return 0; return hard_disk_read(m_disk, lba, buffer); }
- virtual int write_sector(UINT32 lba, const void *buffer) { if (m_disk == NULL) return 0; return hard_disk_write(m_disk, lba, buffer); }
- virtual UINT8 calculate_status();
-
- chd_file *m_handle;
- hard_disk_file *m_disk;
-
- enum
- {
- TID_NULL = TID_BUSY + 1
- };
-
-private:
- required_device<harddisk_image_device> m_image;
-
- emu_timer * m_last_status_timer;
-};
-
-// device type definition
-extern const device_type IDE_HARDDISK;
-
-#endif
diff --git a/src/emu/machine/im6402.c b/src/emu/machine/im6402.c
deleted file mode 100644
index f713a048517..00000000000
--- a/src/emu/machine/im6402.c
+++ /dev/null
@@ -1,412 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- Intersil IM6402 Universal Asynchronous Receiver/Transmitter emulation
-
-***************************************************************************/
-
-#include "im6402.h"
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type IM6402 = &device_creator<im6402_device>;
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// set_dr -
-//-------------------------------------------------
-
-inline void im6402_device::set_dr(int state)
-{
- m_dr = state;
-
- m_write_dr(state);
-}
-
-
-//-------------------------------------------------
-// set_tbre -
-//-------------------------------------------------
-
-inline void im6402_device::set_tbre(int state)
-{
- m_tbre = state;
-
- m_write_tbre(state);
-}
-
-
-//-------------------------------------------------
-// set_tre -
-//-------------------------------------------------
-
-inline void im6402_device::set_tre(int state)
-{
- m_tre = state;
-
- m_write_tre(state);
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// im6402_device - constructor
-//-------------------------------------------------
-
-im6402_device::im6402_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, IM6402, "Intersil IM6402", tag, owner, clock, "im6402", __FILE__),
- device_serial_interface(mconfig, *this),
- m_write_tro(*this),
- m_write_dr(*this),
- m_write_tbre(*this),
- m_write_tre(*this),
- m_rrc_count(0),
- m_trc_count(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void im6402_device::device_start()
-{
- // resolve callbacks
- m_write_tro.resolve_safe();
- m_write_dr.resolve_safe();
- m_write_tbre.resolve_safe();
- m_write_tre.resolve_safe();
-
- // create the timers
- if (m_rrc > 0)
- {
- set_rcv_rate(m_rrc/16);
- }
-
- if (m_trc > 0)
- {
- set_tra_rate(m_trc/16);
- }
-
- // state saving
- save_item(NAME(m_dr));
- save_item(NAME(m_tbre));
- save_item(NAME(m_tre));
- save_item(NAME(m_pe));
- save_item(NAME(m_fe));
- save_item(NAME(m_oe));
- save_item(NAME(m_cls1));
- save_item(NAME(m_cls2));
- save_item(NAME(m_sbs));
- save_item(NAME(m_sfd));
- save_item(NAME(m_epe));
- save_item(NAME(m_pi));
- save_item(NAME(m_rbr));
- save_item(NAME(m_rrc_count));
- save_item(NAME(m_tbr));
- save_item(NAME(m_trc_count));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void im6402_device::device_reset()
-{
- receive_register_reset();
- transmit_register_reset();
-
- m_write_tro(1);
-
- m_rrc_count = 0;
- m_trc_count = 0;
-
- m_rbr = 0;
- m_pe = 0;
- m_fe = 0;
- m_oe = 0;
-
- set_dr(CLEAR_LINE);
- set_tbre(ASSERT_LINE);
- set_tre(ASSERT_LINE);
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void im6402_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- device_serial_interface::device_timer(timer, id, param, ptr);
-}
-
-
-//-------------------------------------------------
-// tra_callback -
-//-------------------------------------------------
-
-void im6402_device::tra_callback()
-{
- m_write_tro(transmit_register_get_data_bit());
-}
-
-
-//-------------------------------------------------
-// tra_complete -
-//-------------------------------------------------
-
-void im6402_device::tra_complete()
-{
- if (!m_tbre)
- {
- if (LOG) logerror("IM6402 '%s' Transmit Data %02x\n", tag(), m_tbr);
-
- transmit_register_setup(m_tbr);
-
- set_tbre(ASSERT_LINE);
- set_tre(CLEAR_LINE);
- }
-}
-
-
-//-------------------------------------------------
-// rcv_callback -
-//-------------------------------------------------
-
-void im6402_device::rcv_callback()
-{
-}
-
-
-//-------------------------------------------------
-// rcv_complete -
-//-------------------------------------------------
-
-void im6402_device::rcv_complete()
-{
- receive_register_extract();
- m_rbr = get_received_char();
-
- if (LOG) logerror("IM6402 '%s' Receive Data %02x\n", tag(), m_rbr);
-
- if (m_dr)
- {
- m_oe = 1;
- }
-
- set_dr(ASSERT_LINE);
-}
-
-
-//-------------------------------------------------
-// write - transmitter buffer register write
-//-------------------------------------------------
-
-WRITE8_MEMBER( im6402_device::write )
-{
- if (LOG) logerror("IM6402 '%s' Transmit Buffer Register %02x\n", tag(), data);
-
- m_tbr = data;
-
- if (is_transmit_register_empty())
- {
- if (LOG) logerror("IM6402 '%s' Transmit Data %02x\n", tag(), m_tbr);
-
- transmit_register_setup(m_tbr);
-
- set_tbre(ASSERT_LINE);
- set_tre(CLEAR_LINE);
- }
- else
- {
- set_tbre(CLEAR_LINE);
- }
-}
-
-
-//-------------------------------------------------
-// rrc_w - receiver register clock
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( im6402_device::rrc_w )
-{
- if (state)
- {
- rx_clock_w(m_rrc_count < 8);
- m_rrc_count = (m_rrc_count + 1) & 15;
- }
-}
-
-
-//-------------------------------------------------
-// trc_w - transmitter register clock
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( im6402_device::trc_w )
-{
- if (state)
- {
- tx_clock_w(m_trc_count < 8);
- m_trc_count = (m_trc_count + 1) & 15;
- }
-}
-
-
-//-------------------------------------------------
-// rrd_w - receiver register disable
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( im6402_device::rrd_w )
-{
-}
-
-
-//-------------------------------------------------
-// sfd_w - status flags disable
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( im6402_device::sfd_w )
-{
-}
-
-
-//-------------------------------------------------
-// drr_w - data received reset
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( im6402_device::drr_w )
-{
- if (state)
- {
- set_dr(CLEAR_LINE);
- }
-}
-
-
-//-------------------------------------------------
-// mr_w - master reset
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( im6402_device::mr_w )
-{
- if (state)
- {
- device_reset();
- }
-}
-
-
-//-------------------------------------------------
-// crl_w - control register load
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( im6402_device::crl_w )
-{
- if (state)
- {
- if (LOG) logerror("IM6402 '%s' Control Register Load\n", tag());
-
- int data_bit_count = 5 + ((m_cls2 << 1) | m_cls1);
- stop_bits_t stop_bits = (m_sbs ? ((data_bit_count == 5) ? STOP_BITS_1_5 : STOP_BITS_2) : STOP_BITS_1);
- parity_t parity;
-
- if (m_pi) parity = PARITY_NONE;
- else if (m_epe) parity = PARITY_EVEN;
- else parity = PARITY_ODD;
-
- set_data_frame(1, data_bit_count, parity, stop_bits);
- }
-}
-
-
-//-------------------------------------------------
-// pi_w - parity inhibit
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( im6402_device::pi_w )
-{
- if (LOG) logerror("IM6402 '%s' Parity Inhibit %u\n", tag(), state);
-
- m_pi = state;
-}
-
-
-//-------------------------------------------------
-// sbs_w - stop bit select
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( im6402_device::sbs_w )
-{
- if (LOG) logerror("IM6402 '%s' Stop Bit Select %u\n", tag(), state);
-
- m_sbs = state;
-}
-
-
-//-------------------------------------------------
-// cls1_w - character length select 1
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( im6402_device::cls1_w )
-{
- if (LOG) logerror("IM6402 '%s' Character Length Select 1 %u\n", tag(), state);
-
- m_cls1 = state;
-}
-
-
-//-------------------------------------------------
-// cls2_w - character length select 2
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( im6402_device::cls2_w )
-{
- if (LOG) logerror("IM6402 '%s' Character Length Select 2 %u\n", tag(), state);
-
- m_cls2 = state;
-}
-
-
-//-------------------------------------------------
-// epe_w - even parity enable
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( im6402_device::epe_w )
-{
- if (LOG) logerror("IM6402 '%s' Even Parity Enable %u\n", tag(), state);
-
- m_epe = state;
-}
-
-WRITE_LINE_MEMBER(im6402_device::write_rri)
-{
- // HACK derive clock from data line as wangpckb sends bytes instantly to make up for mcs51 serial implementation
- receive_register_update_bit(state);
- rx_clock_w(1);
- rx_clock_w(0);
-}
diff --git a/src/emu/machine/im6402.h b/src/emu/machine/im6402.h
deleted file mode 100644
index 46ac592b7ac..00000000000
--- a/src/emu/machine/im6402.h
+++ /dev/null
@@ -1,170 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- Intersil IM6402 Universal Asynchronous Receiver/Transmitter emulation
-
-****************************************************************************
- _____ _____
- Vcc 1 |* \_/ | 40 NOTE
- NOTE 2 | | 39 EPE
- GND 3 | | 38 CLS1
- RRD 4 | | 37 CLS2
- RBR8 5 | | 36 SBS
- RBR7 6 | | 35 PI
- RBR6 7 | | 34 CRL
- RBR5 8 | | 33 TBR8
- RBR4 9 | | 32 TBR7
- RBR3 10 | IM6402 | 31 TBR6
- RBR2 11 | IM6403 | 30 TBR5
- RBR1 12 | | 29 TBR4
- PE 13 | | 28 TBR3
- FE 14 | | 27 TBR2
- OE 15 | | 26 TBR1
- SFD 16 | | 25 TRO
- NOTE 17 | | 24 TRE
- DRR 18 | | 23 TRBL
- DR 19 | | 22 TBRE
- RRI 20 |_____________| 21 MR
-
-
- NOTE: PIN IM6402 IM6403
- ---------------------------
- 2 N/C CONTROL
- 17 RRC OSC IN
- 40 TRC OSC OUT
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __IM6402__
-#define __IM6402__
-
-#include "emu.h"
-
-
-
-/***************************************************************************
- INTERFACE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_IM6402_ADD(_tag, _rrc, _trc) \
- MCFG_DEVICE_ADD(_tag, IM6402, 0) \
- im6402_device::set_rrc(*device, _rrc); \
- im6402_device::set_trc(*device, _trc);
-
-#define MCFG_IM6402_TRO_CALLBACK(_write) \
- devcb = &im6402_device::set_tro_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_IM6402_DR_CALLBACK(_write) \
- devcb = &im6402_device::set_dr_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_IM6402_TBRE_CALLBACK(_write) \
- devcb = &im6402_device::set_tbre_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_IM6402_TRE_CALLBACK(_write) \
- devcb = &im6402_device::set_tre_wr_callback(*device, DEVCB_##_write);
-
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-// ======================> im6402_device
-
-class im6402_device : public device_t,
- public device_serial_interface
-{
-public:
- // construction/destruction
- im6402_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void set_rrc(device_t &device, int rrc) { downcast<im6402_device &>(device).m_rrc = rrc; }
- static void set_trc(device_t &device, int trc) { downcast<im6402_device &>(device).m_trc = trc; }
- template<class _Object> static devcb_base &set_tro_wr_callback(device_t &device, _Object object) { return downcast<im6402_device &>(device).m_write_tro.set_callback(object); }
- template<class _Object> static devcb_base &set_dr_wr_callback(device_t &device, _Object object) { return downcast<im6402_device &>(device).m_write_dr.set_callback(object); }
- template<class _Object> static devcb_base &set_tbre_wr_callback(device_t &device, _Object object) { return downcast<im6402_device &>(device).m_write_tbre.set_callback(object); }
- template<class _Object> static devcb_base &set_tre_wr_callback(device_t &device, _Object object) { return downcast<im6402_device &>(device).m_write_tre.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read ) { return m_rbr; }
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_READ_LINE_MEMBER( dr_r ) { return m_dr; }
- DECLARE_READ_LINE_MEMBER( tbre_r ) { return m_tbre; }
- DECLARE_READ_LINE_MEMBER( tre_r ) { return m_tre; }
- DECLARE_READ_LINE_MEMBER( pe_r ) { return m_pe; }
- DECLARE_READ_LINE_MEMBER( fe_r ) { return m_fe; }
- DECLARE_READ_LINE_MEMBER( oe_r ) { return m_oe; }
-
- DECLARE_WRITE_LINE_MEMBER( write_rri ); // receiver register input
- DECLARE_WRITE_LINE_MEMBER( rrc_w );
- DECLARE_WRITE_LINE_MEMBER( trc_w );
- DECLARE_WRITE_LINE_MEMBER( rrd_w );
- DECLARE_WRITE_LINE_MEMBER( sfd_w );
- DECLARE_WRITE_LINE_MEMBER( drr_w );
- DECLARE_WRITE_LINE_MEMBER( mr_w );
- DECLARE_WRITE_LINE_MEMBER( crl_w );
- DECLARE_WRITE_LINE_MEMBER( pi_w );
- DECLARE_WRITE_LINE_MEMBER( sbs_w );
- DECLARE_WRITE_LINE_MEMBER( cls1_w );
- DECLARE_WRITE_LINE_MEMBER( cls2_w );
- DECLARE_WRITE_LINE_MEMBER( epe_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_serial_interface overrides
- virtual void tra_callback();
- virtual void tra_complete();
- virtual void rcv_callback();
- virtual void rcv_complete();
-
-private:
- inline void set_dr(int state);
- inline void set_tbre(int state);
- inline void set_tre(int state);
-
- devcb_write_line m_write_tro;
- devcb_write_line m_write_dr;
- devcb_write_line m_write_tbre;
- devcb_write_line m_write_tre;
-
- // status
- int m_dr;
- int m_tbre;
- int m_tre;
- int m_pe;
- int m_fe;
- int m_oe;
-
- // control
- int m_cls1;
- int m_cls2;
- int m_sbs;
- int m_sfd;
- int m_epe;
- int m_pi;
-
- // receiver
- UINT8 m_rbr;
- int m_rrc;
- int m_rrc_count;
-
- // transmitter
- UINT8 m_tbr;
- int m_trc;
- int m_trc_count;
-};
-
-
-// device type definition
-extern const device_type IM6402;
-
-
-
-#endif
diff --git a/src/emu/machine/ins8154.c b/src/emu/machine/ins8154.c
deleted file mode 100644
index 1c36af845be..00000000000
--- a/src/emu/machine/ins8154.c
+++ /dev/null
@@ -1,247 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- National Semiconductor INS8154
-
- N-Channel 128-by-8 Bit RAM Input/Output (RAM I/O)
-
- TODO: Strobed modes
-
-***************************************************************************/
-
-#include "emu.h"
-#include "ins8154.h"
-
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-#define VERBOSE 1
-
-/* Mode Definition Register */
-enum
-{
- MDR_BASIC = 0x00,
- MDR_STROBED_INPUT = 0x20,
- MDR_STROBED_OUTPUT = 0x60,
- MDR_STROBED_OUTPUT_3STATE = 0xe0
-};
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type INS8154 = &device_creator<ins8154_device>;
-
-//-------------------------------------------------
-// ins8154_device - constructor
-//-------------------------------------------------
-
-ins8154_device::ins8154_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, INS8154, "INS8154 RAM I/O", tag, owner, clock, "ins8154", __FILE__),
- m_in_a_cb(*this),
- m_out_a_cb(*this),
- m_in_b_cb(*this),
- m_out_b_cb(*this),
- m_out_irq_cb(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ins8154_device::device_start()
-{
- /* resolve callbacks */
- m_in_a_cb.resolve();
- m_out_a_cb.resolve_safe();
- m_in_b_cb.resolve();
- m_out_b_cb.resolve_safe();
- m_out_irq_cb.resolve_safe();
-
- /* register for state saving */
- save_item(NAME(m_in_a));
- save_item(NAME(m_in_b));
- save_item(NAME(m_out_a));
- save_item(NAME(m_out_b));
- save_item(NAME(m_mdr));
- save_item(NAME(m_odra));
- save_item(NAME(m_odrb));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ins8154_device::device_reset()
-{
- m_in_a = 0;
- m_in_b = 0;
- m_out_a = 0;
- m_out_b = 0;
- m_mdr = 0;
- m_odra = 0;
- m_odrb = 0;
-}
-
-
-READ8_MEMBER(ins8154_device::ins8154_r)
-{
- UINT8 val = 0xff;
-
- if (offset > 0x24)
- {
- if (VERBOSE)
- {
- logerror("%s: INS8154 '%s' Read from invalid offset %02x!\n", machine().describe_context(), tag(), offset);
- }
- return 0xff;
- }
-
- switch (offset)
- {
- case 0x20:
- if(!m_in_a_cb.isnull())
- {
- val = m_in_a_cb(0);
- }
- m_in_a = val;
- break;
-
- case 0x21:
- if(!m_in_b_cb.isnull())
- {
- val = m_in_b_cb(0);
- }
- m_in_b = val;
- break;
-
- default:
- if (offset < 0x08)
- {
- if(!m_in_a_cb.isnull())
- {
- val = (m_in_a_cb(0) << (8 - offset)) & 0x80;
- }
- m_in_a = val;
- }
- else
- {
- if(!m_in_b_cb.isnull())
- {
- val = (m_in_b_cb(0) << (8 - (offset >> 4))) & 0x80;
- }
- m_in_b = val;
- }
- break;
- }
-
- return val;
-}
-
-WRITE8_MEMBER(ins8154_device::ins8154_porta_w)
-{
- m_out_a = data;
-
- /* Test if any pins are set as outputs */
- if (m_odra)
- {
- m_out_a_cb((offs_t)0, (data & m_odra) | (m_odra ^ 0xff));
- }
-}
-
-WRITE8_MEMBER(ins8154_device::ins8154_portb_w)
-{
- m_out_b = data;
-
- /* Test if any pins are set as outputs */
- if (m_odrb)
- {
- m_out_b_cb((offs_t)0, (data & m_odrb) | (m_odrb ^ 0xff));
- }
-}
-
-WRITE8_MEMBER(ins8154_device::ins8154_w)
-{
- if (offset > 0x24)
- {
- if (VERBOSE)
- {
- logerror("%s: INS8154 '%s' Write %02x to invalid offset %02x!\n", machine().describe_context(), tag(), data, offset);
- }
- return;
- }
-
- switch (offset)
- {
- case 0x20:
- ins8154_porta_w(space, 0, data);
- break;
-
- case 0x21:
- ins8154_portb_w(space, 0, data);
- break;
-
- case 0x22:
- if (VERBOSE)
- {
- logerror("%s: INS8154 '%s' ODRA set to %02x\n", machine().describe_context(), tag(), data);
- }
-
- m_odra = data;
- break;
-
- case 0x23:
- if (VERBOSE)
- {
- logerror("%s: INS8154 '%s' ODRB set to %02x\n", machine().describe_context(), tag(), data);
- }
-
- m_odrb = data;
- break;
-
- case 0x24:
- if (VERBOSE)
- {
- logerror("%s: INS8154 '%s' MDR set to %02x\n", machine().describe_context(), tag(), data);
- }
-
- m_mdr = data;
- break;
-
- default:
- if (offset & 0x10)
- {
- /* Set bit */
- if (offset < 0x08)
- {
- ins8154_porta_w(space, 0, m_out_a |= offset & 0x07);
- }
- else
- {
- ins8154_portb_w(space, 0, m_out_b |= (offset >> 4) & 0x07);
- }
- }
- else
- {
- /* Clear bit */
- if (offset < 0x08)
- {
- ins8154_porta_w(space, 0, m_out_a & ~(offset & 0x07));
- }
- else
- {
- ins8154_portb_w(space, 0, m_out_b & ~((offset >> 4) & 0x07));
- }
- }
-
- break;
- }
-}
diff --git a/src/emu/machine/ins8154.h b/src/emu/machine/ins8154.h
deleted file mode 100644
index 300b9763a9b..00000000000
--- a/src/emu/machine/ins8154.h
+++ /dev/null
@@ -1,115 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- National Semiconductor INS8154
-
- N-Channel 128-by-8 Bit RAM Input/Output (RAM I/O)
-
- _____ _____
- PB6 1 |* \_/ | 40 VCC
- PB5 2 | | 39 PB7
- PB4 3 | | 38 NWDS
- PB3 4 | | 37 NRDS
- PB2 5 | | 36 NRST
- PB1 6 | | 35 _CS0
- PB0 7 | | 34 CS1
- DB7 8 | | 33 M/_IO
- DB6 9 | | 32 AD6
- DB5 10 | INS8154 | 31 AD5
- DB4 11 | | 30 AD4
- DB3 12 | | 29 AD3
- DB2 13 | | 28 AD2
- DB1 14 | | 27 AD1
- DB0 15 | | 26 AD0
- PA7 16 | | 25 INTR
- PA6 17 | | 24 PA0
- PA5 18 | | 23 PA1
- PA4 19 | | 22 PA2
- GND 20 |_____________| 21 PA3
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __INS8154_H__
-#define __INS8154_H__
-
-#include "emu.h"
-
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_INS8154_IN_A_CB(_devcb) \
- devcb = &ins8154_device::set_in_a_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_INS8154_OUT_A_CB(_devcb) \
- devcb = &ins8154_device::set_out_a_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_INS8154_IN_B_CB(_devcb) \
- devcb = &ins8154_device::set_in_b_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_INS8154_OUT_B_CB(_devcb) \
- devcb = &ins8154_device::set_out_b_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_INS8154_OUT_IRQ_CB(_devcb) \
- devcb = &ins8154_device::set_out_irq_callback(*device, DEVCB_##_devcb); //currently unused
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-// ======================> ins8154_device
-
-class ins8154_device : public device_t
-{
-public:
- // construction/destruction
- ins8154_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_in_a_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_in_a_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_a_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_out_a_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_b_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_in_b_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_b_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_out_b_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_out_irq_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( ins8154_r );
- DECLARE_WRITE8_MEMBER( ins8154_w );
-
- DECLARE_WRITE8_MEMBER( ins8154_porta_w );
- DECLARE_WRITE8_MEMBER( ins8154_portb_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_post_load() { }
- virtual void device_clock_changed() { }
-
-private:
-
- /* i/o lines */
- devcb_read8 m_in_a_cb;
- devcb_write8 m_out_a_cb;
- devcb_read8 m_in_b_cb;
- devcb_write8 m_out_b_cb;
- devcb_write_line m_out_irq_cb;
-
- /* registers */
- UINT8 m_in_a; /* Input Latch Port A */
- UINT8 m_in_b; /* Input Latch Port B */
- UINT8 m_out_a; /* Output Latch Port A */
- UINT8 m_out_b; /* Output Latch Port B */
- UINT8 m_mdr; /* Mode Definition Register */
- UINT8 m_odra; /* Output Definition Register Port A */
- UINT8 m_odrb; /* Output Definition Register Port B */
-};
-
-
-// device type definition
-extern const device_type INS8154;
-
-#endif /* __INS8154_H__ */
diff --git a/src/emu/machine/ins8250.c b/src/emu/machine/ins8250.c
deleted file mode 100644
index bbd0fee1584..00000000000
--- a/src/emu/machine/ins8250.c
+++ /dev/null
@@ -1,705 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf, Carl
-/**********************************************************************
-
- National Semiconductor 8250 UART interface and emulation
-
- More information on the different models can be found in
- section 1.6 at this location:
- http://www.freebsd.org/doc/en_US.ISO8859-1/articles/serial-uart/
-
-Model overview (from page above):
-
-INS8250
-This part was used in the original IBM PC and IBM PC/XT. The original name
-for this part was the INS8250 ACE (Asynchronous Communications Element) and
-it is made from NMOS technology.
-
-The 8250 uses eight I/O ports and has a one-byte send and a one-byte receive
-buffer. This original UART has several race conditions and other flaws. The
-original IBM BIOS includes code to work around these flaws, but this made
-the BIOS dependent on the flaws being present, so subsequent parts like the
-8250A, 16450 or 16550 could not be used in the original IBM PC or IBM PC/XT.
-
-The original 8250 pulses the interrupt line if a higher priority interrupt is
-cleared but a lower priority one is still active. It also clears the tsre bit
-for a moment before loading the tsr from the thr. These may be the bugs the
-PC and XT depend on as the 8250A and up fix them.
-
-INS8250-B
-This is the slower speed of the INS8250 made from NMOS technology. It contains
-the same problems as the original INS8250.
-
-INS8250A
-An improved version of the INS8250 using XMOS technology with various functional
-flaws corrected. The INS8250A was used initially in PC clone computers by vendors
-who used "clean" BIOS designs. Because of the corrections in the chip, this part
-could not be used with a BIOS compatible with the INS8250 or INS8250B.
-
-INS82C50A
-This is a CMOS version (low power consumption) of the INS8250A and has similar
-functional characteristics.
-
-NS16450
-Same as NS8250A with improvements so it can be used with faster CPU bus designs.
-IBM used this part in the IBM AT and updated the IBM BIOS to no longer rely on
-the bugs in the INS8250.
-
-NS16C450
-This is a CMOS version (low power consumption) of the NS16450.
-
-NS16550
-Same as NS16450 with a 16-byte send and receive buffer but the buffer design
-was flawed and could not be reliably be used.
-
-The 16550 sometimes will send more then one character over the bus from the fifo
-when the rbr is read making the rx fifo useless. It's unlikely anything depends
-on this behavior.
-
-NS16550A
-Same as NS16550 with the buffer flaws corrected. The 16550A and its successors
-have become the most popular UART design in the PC industry, mainly due to
-its ability to reliably handle higher data rates on operating systems with
-sluggish interrupt response times.
-
-NS16C552
-This component consists of two NS16C550A CMOS UARTs in a single package.
-
-PC16550D
-Same as NS16550A with subtle flaws corrected. This is revision D of the
-16550 family and is the latest design available from National Semiconductor.
-
-
-Known issues:
-- MESS does currently not handle all these model specific features.
-
-
-History:
- KT - 14-Jun-2000 - Improved Interrupt setting/clearing
- KT - moved into separate file so it can be used in Super I/O emulation and
- any other system which uses a PC type COM port
- KT - 24-Jun-2000 - removed pc specific input port tests. More compatible
- with PCW16 and PCW16 doesn't requre the PC input port definitions
- which are not required by the PCW16 hardware
-
-**********************************************************************/
-
-#include "machine/ins8250.h"
-
-const device_type INS8250 = &device_creator<ins8250_device>;
-const device_type NS16450 = &device_creator<ns16450_device>;
-const device_type NS16550 = &device_creator<ns16550_device>;
-const device_type PC16552D = &device_creator<pc16552_device>;
-
-ins8250_uart_device::ins8250_uart_device(const machine_config &mconfig, device_type type, const char* name, const char *tag, device_t *owner, UINT32 clock, const char *shortname)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, __FILE__),
- device_serial_interface(mconfig, *this),
- m_out_tx_cb(*this),
- m_out_dtr_cb(*this),
- m_out_rts_cb(*this),
- m_out_int_cb(*this),
- m_out_out1_cb(*this),
- m_out_out2_cb(*this),
- m_rxd(1),
- m_dcd(1),
- m_dsr(1),
- m_ri(1),
- m_cts(1)
-{
- m_regs.ier = 0;
-}
-
-ins8250_device::ins8250_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : ins8250_uart_device(mconfig, INS8250, "National Semiconductor INS8250", tag, owner, clock, "ins8250")
-{
- m_device_type = TYPE_INS8250;
-}
-
-ns16450_device::ns16450_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : ins8250_uart_device(mconfig, NS16450, "National Semiconductor NS16450", tag, owner, clock, "ns16450")
-{
- m_device_type = TYPE_NS16450;
-}
-
-ns16550_device::ns16550_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : ins8250_uart_device(mconfig, NS16550, "National Semiconductor NS16550", tag, owner, clock, "ns16550")
-{
- m_device_type = TYPE_NS16550;
-}
-
-pc16552_device::pc16552_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, PC16552D, "National Semiconductor PC16552D", tag, owner, clock, "pc16552d", __FILE__)
-{
-}
-
-void pc16552_device::device_start()
-{
- m_chan0 = subdevice<ns16550_device>("chan0");
- m_chan1 = subdevice<ns16550_device>("chan1");
-}
-
-/* int's pending */
-#define COM_INT_PENDING_RECEIVED_DATA_AVAILABLE 0x0001
-#define COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY 0x0002
-#define COM_INT_PENDING_RECEIVER_LINE_STATUS 0x0004
-#define COM_INT_PENDING_MODEM_STATUS_REGISTER 0x0008
-#define COM_INT_PENDING_CHAR_TIMEOUT 0x0011
-
-/* ints will continue to be set for as long as there are ints pending */
-void ins8250_uart_device::update_interrupt()
-{
- int state;
-
- /* if any bits are set and are enabled */
- if (((m_int_pending & m_regs.ier) & 0x0f) != 0)
- {
- /* trigger next highest priority int */
-
- /* set int */
- state = 1;
- m_regs.iir &= ~(0x08|0x04|0x02);
-
- /* highest to lowest */
- if (m_regs.ier & m_int_pending & COM_INT_PENDING_RECEIVER_LINE_STATUS)
- m_regs.iir |=0x04|0x02;
- else if (m_regs.ier & m_int_pending & COM_INT_PENDING_RECEIVED_DATA_AVAILABLE)
- {
- m_regs.iir |=0x04;
- if ((m_int_pending & COM_INT_PENDING_CHAR_TIMEOUT) == 0x11)
- m_regs.iir |= 0x08;
- }
- else if (m_regs.ier & m_int_pending & COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY)
- m_regs.iir |=0x02;
-
- /* int pending */
- m_regs.iir &= ~0x01;
- }
- else
- {
- /* clear int */
- state = 0;
-
- /* no ints pending */
- m_regs.iir |= 0x01;
- /* priority level */
- m_regs.iir &= ~(0x08|0x04|0x02);
- }
-
- /* set or clear the int */
- m_out_int_cb(state);
-}
-
-/* set pending bit and trigger int */
-void ins8250_uart_device::trigger_int(int flag)
-{
- m_int_pending |= flag;
- update_interrupt();
-}
-
-/* clear pending bit, if any ints are pending, then int will be triggered, otherwise it
-will be cleared */
-void ins8250_uart_device::clear_int(int flag)
-{
- m_int_pending &= ~flag;
- update_interrupt();
-}
-
-WRITE8_MEMBER( ins8250_uart_device::ins8250_w )
-{
- int tmp;
-
- switch (offset)
- {
- case 0:
- if (m_regs.lcr & 0x80)
- {
- m_regs.dl = (m_regs.dl & 0xff00) | data;
- set_rate(clock(), m_regs.dl*16);
- }
- else
- {
- m_regs.thr = data;
- m_regs.lsr &= ~0x20;
- if((m_device_type >= TYPE_NS16550) && (m_regs.fcr & 1))
- push_tx(data);
- clear_int(COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY);
- if(m_regs.lsr & 0x40)
- tra_complete();
- }
- break;
- case 1:
- if (m_regs.lcr & 0x80)
- {
- m_regs.dl = (m_regs.dl & 0xff) | (data << 8);
- set_rate(clock(), m_regs.dl*16);
- }
- else
- {
- m_regs.ier = data;
- update_interrupt();
- }
- break;
- case 2:
- set_fcr(data);
- break;
- case 3:
- m_regs.lcr = data;
-
- {
- int data_bit_count = (m_regs.lcr & 3) + 5;
- parity_t parity;
- stop_bits_t stop_bits;
-
- switch ((m_regs.lcr>>3) & 7)
- {
- case 1:
- parity = PARITY_ODD;
- break;
-
- case 3:
- parity = PARITY_EVEN;
- break;
-
- case 5:
- parity = PARITY_MARK;
- break;
-
- case 7:
- parity = PARITY_SPACE;
- break;
-
- default:
- parity = PARITY_NONE;
- break;
- }
-
- if (!(m_regs.lcr & 4))
- stop_bits = STOP_BITS_1;
- else if (data_bit_count == 5)
- stop_bits = STOP_BITS_1_5;
- else
- stop_bits = STOP_BITS_2;
-
- set_data_frame(1, data_bit_count, parity, stop_bits);
- }
- break;
- case 4:
- if ( ( m_regs.mcr & 0x1f ) != ( data & 0x1f ) )
- {
- m_regs.mcr = data & 0x1f;
-
- update_msr();
-
- if (m_regs.mcr & 0x10) /* loopback test */
- {
- m_out_tx_cb(1);
- device_serial_interface::rx_w(m_txd);
- m_out_dtr_cb(1);
- m_out_rts_cb(1);
- m_out_out1_cb(1);
- m_out_out2_cb(1);
- }
- else
- {
- m_out_tx_cb(m_txd);
- device_serial_interface::rx_w(m_rxd);
- m_out_dtr_cb((m_regs.mcr & 1) ? 0 : 1);
- m_out_rts_cb((m_regs.mcr & 2) ? 0 : 1);
- m_out_out1_cb((m_regs.mcr & 4) ? 0 : 1);
- m_out_out2_cb((m_regs.mcr & 8) ? 0 : 1);
- }
- }
- break;
- case 5:
- /*
- This register can be written, but if you write a 1 bit into any of
- bits 5 - 0, you could cause an interrupt if the appropriate IER bit
- is set.
- */
- m_regs.lsr = (m_regs.lsr & 0x40) | (data & ~0x40);
-
- tmp = 0;
- tmp |= ( m_regs.lsr & 0x01 ) ? COM_INT_PENDING_RECEIVED_DATA_AVAILABLE : 0;
- tmp |= ( m_regs.lsr & 0x1e ) ? COM_INT_PENDING_RECEIVER_LINE_STATUS : 0;
- tmp |= ( m_regs.lsr & 0x20 ) ? COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY : 0;
- trigger_int(tmp);
-
- break;
- case 6:
- /*
- This register can be written, but if you write a 1 bit into any of
- bits 3 - 0, you could cause an interrupt if the appropriate IER bit
- is set.
- */
- m_regs.msr = data;
-
- if ( m_regs.msr & 0x0f )
- trigger_int(COM_INT_PENDING_MODEM_STATUS_REGISTER);
- break;
- case 7:
- m_regs.scr = data;
- break;
- }
-}
-
-READ8_MEMBER( ins8250_uart_device::ins8250_r )
-{
- int data = 0x0ff;
-
- switch (offset)
- {
- case 0:
- if (m_regs.lcr & 0x80)
- data = (m_regs.dl & 0xff);
- else
- {
- if((m_device_type >= TYPE_NS16550) && (m_regs.fcr & 1))
- m_regs.rbr = pop_rx();
- else
- {
- clear_int(COM_INT_PENDING_RECEIVED_DATA_AVAILABLE);
- if( m_regs.lsr & 0x01 )
- m_regs.lsr &= ~0x01;
- }
- data = m_regs.rbr;
- }
- break;
- case 1:
- if (m_regs.lcr & 0x80)
- data = (m_regs.dl >> 8);
- else
- data = m_regs.ier & 0x0f;
- break;
- case 2:
- data = m_regs.iir;
- /* The documentation says that reading this register will
- clear the int if this is the source of the int */
- if ( m_regs.ier & COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY )
- clear_int(COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY);
- break;
- case 3:
- data = m_regs.lcr;
- break;
- case 4:
- data = m_regs.mcr;
- break;
- case 5:
- data = m_regs.lsr;
- if( m_regs.lsr & 0x1f )
- m_regs.lsr &= 0xe1; /* clear FE, PE and OE and BREAK bits */
-
- /* reading line status register clears int */
- clear_int(COM_INT_PENDING_RECEIVER_LINE_STATUS);
- break;
- case 6:
- data = m_regs.msr;
- m_regs.msr &= 0xf0; /* reset delta values */
-
- /* reading msr clears int */
- clear_int(COM_INT_PENDING_MODEM_STATUS_REGISTER);
-
- break;
- case 7:
- data = m_regs.scr;
- break;
- }
- return data;
-}
-
-void ns16550_device::rcv_complete()
-{
- if(!(m_regs.fcr & 1))
- return ins8250_uart_device::rcv_complete();
-
- receive_register_extract();
-
- if(m_rnum == 16)
- {
- m_regs.lsr |= 0x02; //overrun
- trigger_int(COM_INT_PENDING_RECEIVER_LINE_STATUS);
- return;
- }
-
- m_regs.lsr |= 0x01;
- m_rfifo[m_rhead] = get_received_char();
- ++m_rhead &= 0x0f;
- m_rnum++;
- if(m_rnum >= m_rintlvl)
- trigger_int(COM_INT_PENDING_RECEIVED_DATA_AVAILABLE);
- set_timer();
-}
-
-void ns16550_device::tra_complete()
-{
- if(!(m_regs.fcr & 1))
- return ins8250_uart_device::tra_complete();
-
- if(m_ttail != m_thead)
- {
- transmit_register_setup(m_tfifo[m_ttail]);
- ++m_ttail &= 0x0f;
- m_regs.lsr &= ~0x40;
- if(m_ttail == m_thead)
- {
- m_regs.lsr |= 0x20;
- trigger_int(COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY);
- }
- }
- else
- m_regs.lsr |= 0x40;
-}
-
-void ins8250_uart_device::rcv_complete()
-{
- if(m_regs.lsr & 0x01)
- {
- m_regs.lsr |= 0x02; //overrun
- trigger_int(COM_INT_PENDING_RECEIVER_LINE_STATUS);
- receive_register_reset();
- }
- else
- {
- m_regs.lsr |= 0x01;
- receive_register_extract();
- m_regs.rbr = get_received_char();
- trigger_int(COM_INT_PENDING_RECEIVED_DATA_AVAILABLE);
- }
-}
-
-void ins8250_uart_device::tra_complete()
-{
- if(!(m_regs.lsr & 0x20))
- {
- transmit_register_setup(m_regs.thr);
- m_regs.lsr &= ~0x40;
- m_regs.lsr |= 0x20;
- trigger_int(COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY);
- }
- else
- m_regs.lsr |= 0x40;
-}
-
-void ins8250_uart_device::tra_callback()
-{
- m_txd = transmit_register_get_data_bit();
- if (m_regs.mcr & 0x10)
- {
- device_serial_interface::rx_w(m_txd);
- }
- else
- {
- m_out_tx_cb(m_txd);
- }
-}
-
-void ins8250_uart_device::update_msr()
-{
- UINT8 data;
- int change;
-
- if (m_regs.mcr & 0x10)
- {
- data = (((m_regs.mcr & 0x0c) << 4) | ((m_regs.mcr & 0x01) << 5) | ((m_regs.mcr & 0x02) << 3));
- change = (m_regs.msr ^ data) >> 4;
- if(!(m_regs.msr & 0x40) && (data & 0x40))
- change &= ~4;
- }
- else
- {
- data = (!m_dcd << 7) | (!m_ri << 6) | (!m_dsr << 5) | (!m_cts << 4);
- change = (m_regs.msr ^ data) >> 4;
- }
-
- m_regs.msr = data | change;
-
- if(change)
- trigger_int(COM_INT_PENDING_MODEM_STATUS_REGISTER);
-}
-
-WRITE_LINE_MEMBER(ins8250_uart_device::dcd_w)
-{
- m_dcd = state;
- update_msr();
-}
-
-WRITE_LINE_MEMBER(ins8250_uart_device::dsr_w)
-{
- m_dsr = state;
- update_msr();
-}
-
-WRITE_LINE_MEMBER(ins8250_uart_device::ri_w)
-{
- m_ri = state;
- update_msr();
-}
-
-WRITE_LINE_MEMBER(ins8250_uart_device::cts_w)
-{
- m_cts = state;
- update_msr();
-}
-
-WRITE_LINE_MEMBER(ins8250_uart_device::rx_w)
-{
- m_rxd = state;
-
- if (!(m_regs.mcr & 0x10))
- device_serial_interface::rx_w(m_rxd);
-}
-
-void ins8250_uart_device::device_start()
-{
- m_out_tx_cb.resolve_safe();
- m_out_dtr_cb.resolve_safe();
- m_out_rts_cb.resolve_safe();
- m_out_int_cb.resolve_safe();
- m_out_out1_cb.resolve_safe();
- m_out_out2_cb.resolve_safe();
- set_tra_rate(0);
- set_rcv_rate(0);
-
- device_serial_interface::register_save_state(machine().save(), this);
- save_item(NAME(m_regs.thr));
- save_item(NAME(m_regs.rbr));
- save_item(NAME(m_regs.ier));
- save_item(NAME(m_regs.dl));
- save_item(NAME(m_regs.iir));
- save_item(NAME(m_regs.fcr));
- save_item(NAME(m_regs.lcr));
- save_item(NAME(m_regs.mcr));
- save_item(NAME(m_regs.lsr));
- save_item(NAME(m_regs.msr));
- save_item(NAME(m_regs.scr));
- save_item(NAME(m_int_pending));
- save_item(NAME(m_txd));
- save_item(NAME(m_rxd));
- save_item(NAME(m_dcd));
- save_item(NAME(m_dsr));
- save_item(NAME(m_ri));
- save_item(NAME(m_cts));
-}
-
-void ins8250_uart_device::device_reset()
-{
- m_regs.ier = 0;
- m_regs.iir = 1;
- m_regs.lcr = 0;
- m_regs.mcr = 0;
- m_regs.lsr = (1<<5) | (1<<6);
- update_msr();
- m_regs.msr &= 0xf0;
- m_int_pending = 0;
- update_interrupt();
- receive_register_reset();
- transmit_register_reset();
- m_txd = 1;
- m_out_tx_cb(1);
- m_out_rts_cb(1);
- m_out_dtr_cb(1);
- m_out_out1_cb(1);
- m_out_out2_cb(1);
-}
-
-void ins8250_uart_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- device_serial_interface::device_timer(timer, id, param, ptr);
-}
-
-void ns16550_device::device_start()
-{
- m_timeout = timer_alloc();
- ins8250_uart_device::device_start();
- save_item(NAME(m_rintlvl));
- save_item(NAME(m_rfifo));
- save_item(NAME(m_tfifo));
- save_item(NAME(m_rhead));
- save_item(NAME(m_rtail));
- save_item(NAME(m_rnum));
- save_item(NAME(m_thead));
- save_item(NAME(m_ttail));
-}
-
-void ns16550_device::device_reset()
-{
- memset(&m_rfifo, '\0', sizeof(m_rfifo));
- memset(&m_tfifo, '\0', sizeof(m_tfifo));
- m_rhead = m_rtail = m_rnum = 0;
- m_thead = m_ttail = 0;
- m_timeout->adjust(attotime::never);
- ins8250_uart_device::device_reset();
-}
-
-void ns16550_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if(id)
- device_serial_interface::device_timer(timer, id, param, ptr);
- else
- {
- trigger_int(COM_INT_PENDING_CHAR_TIMEOUT);
- m_timeout->adjust(attotime::never);
- }
-}
-
-void ns16550_device::push_tx(UINT8 data)
-{
- m_tfifo[m_thead] = data;
- ++m_thead &= 0x0f;
-}
-
-UINT8 ns16550_device::pop_rx()
-{
- UINT8 data = m_rfifo[m_rtail];
- clear_int(COM_INT_PENDING_CHAR_TIMEOUT & ~1); // don't clear bit 1 yet
-
- if(m_rnum)
- {
- ++m_rtail &= 0x0f;
- m_rnum--;
- }
- else
- data = 0;
-
- if(m_rnum < m_rintlvl)
- clear_int(COM_INT_PENDING_RECEIVED_DATA_AVAILABLE);
-
- if(m_rnum)
- set_timer();
- else
- {
- m_timeout->adjust(attotime::never);
- m_regs.lsr &= ~1;
- }
-
- return data;
-}
-
-void ns16550_device::set_fcr(UINT8 data)
-{
- const int bytes_per_int[] = {1, 4, 8, 14};
- if(!(data & 1))
- {
- m_regs.fcr = 0;
- m_regs.iir &= ~0xc8;
- return;
- }
- if(!(m_regs.fcr & 1) && (data & 1))
- data |= 0x06;
- if(data & 2)
- {
- memset(&m_rfifo, '\0', sizeof(m_rfifo));
- m_rhead = m_rtail = m_rnum = 0;
- clear_int(COM_INT_PENDING_CHAR_TIMEOUT | COM_INT_PENDING_RECEIVED_DATA_AVAILABLE);
- m_timeout->adjust(attotime::never);
- }
- if(data & 4)
- {
- memset(&m_tfifo, '\0', sizeof(m_tfifo));
- m_thead = m_ttail = 0;
- m_regs.lsr |= 0x20;
- trigger_int(COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY);
- }
- m_rintlvl = bytes_per_int[(data>>6)&3];
- m_regs.iir |= 0xc0;
- m_regs.fcr = data & 0xc9;
-}
diff --git a/src/emu/machine/ins8250.h b/src/emu/machine/ins8250.h
deleted file mode 100644
index 9415c2b70ce..00000000000
--- a/src/emu/machine/ins8250.h
+++ /dev/null
@@ -1,174 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf, Carl
-/**********************************************************************
-
- 8250 UART interface and emulation
-
-**********************************************************************/
-
-#ifndef __INS8250_H_
-#define __INS8250_H_
-
-#include "emu.h"
-
-/***************************************************************************
- CLASS DEFINITIONS
-***************************************************************************/
-
-class ins8250_uart_device : public device_t,
- public device_serial_interface
-{
-public:
- ins8250_uart_device(const machine_config &mconfig, device_type type, const char* name, const char *tag, device_t *owner, UINT32 clock, const char *shortname);
-
- template<class _Object> static devcb_base &set_out_tx_callback(device_t &device, _Object object) { return downcast<ins8250_uart_device &>(device).m_out_tx_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dtr_callback(device_t &device, _Object object) { return downcast<ins8250_uart_device &>(device).m_out_dtr_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_rts_callback(device_t &device, _Object object) { return downcast<ins8250_uart_device &>(device).m_out_rts_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_int_callback(device_t &device, _Object object) { return downcast<ins8250_uart_device &>(device).m_out_int_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_out1_callback(device_t &device, _Object object) { return downcast<ins8250_uart_device &>(device).m_out_out1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_out2_callback(device_t &device, _Object object) { return downcast<ins8250_uart_device &>(device).m_out_out2_cb.set_callback(object); }
-
- DECLARE_WRITE8_MEMBER( ins8250_w );
- DECLARE_READ8_MEMBER( ins8250_r );
- DECLARE_WRITE_LINE_MEMBER( dcd_w );
- DECLARE_WRITE_LINE_MEMBER( dsr_w );
- DECLARE_WRITE_LINE_MEMBER( ri_w );
- DECLARE_WRITE_LINE_MEMBER( cts_w );
- DECLARE_WRITE_LINE_MEMBER( rx_w );
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void rcv_complete();
- virtual void tra_complete();
- virtual void tra_callback();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- virtual void set_fcr(UINT8 data) {}
- virtual void push_tx(UINT8 data) {}
- virtual UINT8 pop_rx() { return 0; }
-
- void trigger_int(int flag);
- void clear_int(int flag);
-
- enum {
- TYPE_INS8250 = 0,
- TYPE_INS8250A,
- TYPE_NS16450,
- TYPE_NS16550,
- TYPE_NS16550A
- };
- int m_device_type;
- struct {
- UINT8 thr; /* 0 -W transmitter holding register */
- UINT8 rbr; /* 0 R- receiver buffer register */
- UINT8 ier; /* 1 RW interrupt enable register */
- UINT16 dl; /* 0/1 RW divisor latch (if DLAB = 1) */
- UINT8 iir; /* 2 R- interrupt identification register */
- UINT8 fcr;
- UINT8 lcr; /* 3 RW line control register (bit 7: DLAB) */
- UINT8 mcr; /* 4 RW modem control register */
- UINT8 lsr; /* 5 R- line status register */
- UINT8 msr; /* 6 R- modem status register */
- UINT8 scr; /* 7 RW scratch register */
- } m_regs;
-private:
- UINT8 m_int_pending;
-
- devcb_write_line m_out_tx_cb;
- devcb_write_line m_out_dtr_cb;
- devcb_write_line m_out_rts_cb;
- devcb_write_line m_out_int_cb;
- devcb_write_line m_out_out1_cb;
- devcb_write_line m_out_out2_cb;
-
- void update_interrupt();
- void update_msr();
-
- int m_txd;
- int m_rxd;
- int m_dcd;
- int m_dsr;
- int m_ri;
- int m_cts;
-};
-
-class ins8250_device : public ins8250_uart_device
-{
-public:
- ins8250_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class ns16450_device : public ins8250_uart_device
-{
-public:
- ns16450_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class ns16550_device : public ins8250_uart_device
-{
-public:
- ns16550_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void rcv_complete();
- virtual void tra_complete();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual void set_fcr(UINT8 data);
- virtual void push_tx(UINT8 data);
- virtual UINT8 pop_rx();
-private:
- void set_timer() { m_timeout->adjust(attotime::from_hz((clock()*4*8)/(m_regs.dl*16))); }
- int m_rintlvl;
- UINT8 m_rfifo[16];
- UINT8 m_tfifo[16];
- int m_rhead, m_rtail, m_rnum;
- int m_thead, m_ttail;
- emu_timer *m_timeout;
-};
-
-class pc16552_device : public device_t
-{
-public:
- pc16552_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER(read) { return ((offset & 8) ? m_chan1 : m_chan0)->ins8250_r(space, offset & 7, mem_mask); }
- DECLARE_WRITE8_MEMBER(write) { ((offset & 8) ? m_chan1 : m_chan0)->ins8250_w(space, offset & 7, data, mem_mask); }
-
-protected:
- virtual void device_start();
-
-private:
- ns16550_device *m_chan0;
- ns16550_device *m_chan1;
-};
-
-extern const device_type PC16552D;
-extern const device_type INS8250;
-extern const device_type NS16450;
-extern const device_type NS16550;
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_INS8250_OUT_TX_CB(_devcb) \
- devcb = &ins8250_uart_device::set_out_tx_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_INS8250_OUT_DTR_CB(_devcb) \
- devcb = &ins8250_uart_device::set_out_dtr_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_INS8250_OUT_RTS_CB(_devcb) \
- devcb = &ins8250_uart_device::set_out_rts_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_INS8250_OUT_INT_CB(_devcb) \
- devcb = &ins8250_uart_device::set_out_int_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_INS8250_OUT_OUT1_CB(_devcb) \
- devcb = &ins8250_uart_device::set_out_out1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_INS8250_OUT_OUT2_CB(_devcb) \
- devcb = &ins8250_uart_device::set_out_out2_callback(*device, DEVCB_##_devcb);
-
-#endif
diff --git a/src/emu/machine/intelfsh.c b/src/emu/machine/intelfsh.c
deleted file mode 100644
index 6f841692bea..00000000000
--- a/src/emu/machine/intelfsh.c
+++ /dev/null
@@ -1,1146 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*
- Flash ROM emulation
-
- Explicitly supports:
- Intel 28F016S5 (byte-wide)
- AMD/Fujitsu 29F016 (byte-wide)
- Sharp LH28F400 (word-wide)
-
- Flash ROMs use a standardized command set across manufacturers,
- so this emulation should work even for non-Intel and non-Sharp chips
- as long as the game doesn't query the maker ID.
-*/
-
-#include "emu.h"
-#include "intelfsh.h"
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-enum
-{
- FM_NORMAL, // normal read/write
- FM_READID, // read ID
- FM_READSTATUS, // read status
- FM_WRITEPART1, // first half of programming, awaiting second
- FM_CLEARPART1, // first half of clear, awaiting second
- FM_SETMASTER, // first half of set master lock, awaiting on/off
- FM_READAMDID1, // part 1 of alt ID sequence
- FM_READAMDID2, // part 2 of alt ID sequence
- FM_READAMDID3, // part 3 of alt ID sequence
- FM_ERASEAMD1, // part 1 of AMD erase sequence
- FM_ERASEAMD2, // part 2 of AMD erase sequence
- FM_ERASEAMD3, // part 3 of AMD erase sequence
- FM_ERASEAMD4, // part 4 of AMD erase sequence
- FM_BYTEPROGRAM,
- FM_BANKSELECT,
- FM_WRITEPAGEATMEL
-};
-
-
-enum
-{
- MFG_ALLIANCE = 0x52,
- MFG_AMD = 0x01,
- MFG_AMIC = 0x37,
- MFG_ATMEL = 0x1f,
- MFG_BRIGHT = 0xad,
- MFG_CATALYST = 0x31,
- MFG_EON = 0x1c,
- MFG_FUJITSU = 0x04,
- MFG_GIGADEVICE = 0xc8,
- MFG_HYUNDAI = 0xad,
- MFG_INTEL = 0x89,
- MFG_ISSI = 0xd5,
- MFG_MACRONIX = 0xc2,
- MFG_PANASONIC = 0x32,
- MFG_PMC = 0x9d,
- MFG_SANYO = 0x62,
- MFG_SHARP = 0xb0,
- MFG_SPANSION = 0x01,
- MFG_SST = 0xbf,
- MFG_ST = 0x20,
- MFG_SYNCMOS = 0x40,
- MFG_TI = 0x97,
- MFG_TI_OLD = 0x01,
- MFG_WINBOND_NEX = 0xef,
- MFG_WINBOND = 0xda
-};
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type INTEL_28F016S5 = &device_creator<intel_28f016s5_device>;
-const device_type SHARP_LH28F016S = &device_creator<sharp_lh28f016s_device>;
-const device_type ATMEL_29C010 = &device_creator<atmel_29c010_device>;
-const device_type AMD_29F010 = &device_creator<amd_29f010_device>;
-const device_type AMD_29F040 = &device_creator<amd_29f040_device>;
-const device_type AMD_29F080 = &device_creator<amd_29f080_device>;
-const device_type AMD_29F400T = &device_creator<amd_29f400t_device>;
-const device_type AMD_29F800T = &device_creator<amd_29f800t_device>;
-const device_type AMD_29LV200T = &device_creator<amd_29lv200t_device>;
-const device_type FUJITSU_29F160T = &device_creator<fujitsu_29f160t_device>;
-const device_type FUJITSU_29F016A = &device_creator<fujitsu_29f016a_device>;
-const device_type FUJITSU_29DL16X = &device_creator<fujitsu_29dl16x_device>;
-const device_type INTEL_E28F400B = &device_creator<intel_e28f400b_device>;
-const device_type MACRONIX_29L001MC = &device_creator<macronix_29l001mc_device>;
-const device_type MACRONIX_29LV160TMC = &device_creator<macronix_29lv160tmc_device>;
-const device_type TMS_29F040 = &device_creator<tms_29f040_device>;
-
-const device_type PANASONIC_MN63F805MNP = &device_creator<panasonic_mn63f805mnp_device>;
-const device_type SANYO_LE26FV10N1TS = &device_creator<sanyo_le26fv10n1ts_device>;
-const device_type SST_28SF040 = &device_creator<sst_28sf040_device>;
-const device_type SST_39VF020 = &device_creator<sst_39vf020_device>;
-
-const device_type SHARP_LH28F400 = &device_creator<sharp_lh28f400_device>;
-const device_type INTEL_E28F008SA = &device_creator<intel_e28f008sa_device>;
-const device_type INTEL_TE28F160 = &device_creator<intel_te28f160_device>;
-const device_type SHARP_UNK128MBIT = &device_creator<sharp_unk128mbit_device>;
-const device_type INTEL_28F320J3D = &device_creator<intel_28f320j3d_device>;
-const device_type INTEL_28F320J5 = &device_creator<intel_28f320j5_device>;
-
-const device_type SST_39VF400A = &device_creator<sst_39vf400a_device>;
-
-static ADDRESS_MAP_START( memory_map8_512Kb, AS_PROGRAM, 8, intelfsh_device )
- AM_RANGE(0x00000, 0x00ffff) AM_RAM
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( memory_map8_1Mb, AS_PROGRAM, 8, intelfsh_device )
- AM_RANGE(0x00000, 0x01ffff) AM_RAM
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( memory_map8_2Mb, AS_PROGRAM, 8, intelfsh_device )
- AM_RANGE(0x00000, 0x03ffff) AM_RAM
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( memory_map8_4Mb, AS_PROGRAM, 8, intelfsh_device )
- AM_RANGE(0x00000, 0x07ffff) AM_RAM
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( memory_map8_8Mb, AS_PROGRAM, 8, intelfsh_device )
- AM_RANGE(0x00000, 0x0fffff) AM_RAM
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( memory_map8_16Mb, AS_PROGRAM, 8, intelfsh_device )
- AM_RANGE(0x00000, 0x1fffff) AM_RAM
-ADDRESS_MAP_END
-
-
-static ADDRESS_MAP_START( memory_map16_4Mb, AS_PROGRAM, 16, intelfsh_device )
- AM_RANGE(0x00000, 0x03ffff) AM_RAM
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( memory_map16_16Mb, AS_PROGRAM, 16, intelfsh_device )
- AM_RANGE(0x00000, 0x0fffff) AM_RAM
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( memory_map16_32Mb, AS_PROGRAM, 16, intelfsh_device )
- AM_RANGE(0x00000, 0x1fffff) AM_RAM
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( memory_map16_64Mb, AS_PROGRAM, 16, intelfsh_device )
- AM_RANGE(0x00000, 0x3fffff) AM_RAM
-ADDRESS_MAP_END
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// intelfsh_device - constructor
-//-------------------------------------------------
-
-intelfsh_device::intelfsh_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_memory_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this),
- m_type(variant),
- m_size(0),
- m_bits(8),
- m_addrmask(0),
- m_device_id(0),
- m_maker_id(0),
- m_sector_is_4k(false),
- m_sector_is_16k(false),
- m_top_boot_sector(false),
- m_status(0x80),
- m_erase_sector(0),
- m_flash_mode(FM_NORMAL),
- m_flash_master_lock(false),
- m_timer(NULL),
- m_bank(0)
-{
- address_map_constructor map = NULL;
-
- switch( variant )
- {
- case FLASH_INTEL_28F016S5:
- case FLASH_SHARP_LH28F016S:
- m_bits = 8;
- m_size = 0x200000;
- m_maker_id = MFG_INTEL;
- m_device_id = 0xaa;
- map = ADDRESS_MAP_NAME( memory_map8_16Mb );
- break;
- case FLASH_ATMEL_29C010:
- m_bits = 8;
- m_size = 0x20000;
- m_page_size = 0x80;
- m_maker_id = MFG_ATMEL;
- m_device_id = 0xd5;
- map = ADDRESS_MAP_NAME( memory_map8_1Mb );
- break;
- case FLASH_AMD_29F010:
- m_bits = 8;
- m_size = 0x20000;
- m_maker_id = MFG_AMD;
- m_device_id = 0x20;
- map = ADDRESS_MAP_NAME( memory_map8_1Mb );
- break;
- case FLASH_AMD_29F040:
- m_bits = 8;
- m_size = 0x80000;
- m_maker_id = MFG_AMD;
- m_device_id = 0xa4;
- map = ADDRESS_MAP_NAME( memory_map8_4Mb );
- break;
- case FLASH_AMD_29F080:
- m_bits = 8;
- m_size = 0x100000;
- m_addrmask = 0x7ff;
- m_maker_id = MFG_AMD;
- m_device_id = 0xd5;
- map = ADDRESS_MAP_NAME( memory_map8_8Mb );
- break;
- case FLASH_AMD_29F400T:
- m_bits = 8;
- m_size = 0x80000;
- m_maker_id = MFG_AMD;
- m_device_id = 0x23;
- m_top_boot_sector = true;
- map = ADDRESS_MAP_NAME( memory_map8_4Mb );
- break;
- case FLASH_AMD_29F800T:
- m_bits = 8;
- m_size = 0x100000;
- m_maker_id = MFG_AMD;
- m_device_id = 0xda;
- m_top_boot_sector = true;
- map = ADDRESS_MAP_NAME( memory_map8_8Mb );
- break;
- case FLASH_AMD_29LV200T:
- m_bits = 8;
- m_size = 0x40000;
- m_maker_id = MFG_AMD;
- m_device_id = 0x3b;
- map = ADDRESS_MAP_NAME( memory_map8_2Mb );
- break;
- case FLASH_INTEL_28F320J3D:
- m_bits = 16;
- m_size = 0x400000;
- m_maker_id = MFG_INTEL;
- m_device_id = 0x16;
- m_sector_is_4k = true;
- map = ADDRESS_MAP_NAME( memory_map16_32Mb );
- break;
- case FLASH_INTEL_28F320J5: // funkball
- m_bits = 16;
- m_size = 0x400000;
- m_maker_id = MFG_INTEL;
- m_device_id = 0x14;
-// m_sector_is_4k = true; 128kb?
- map = ADDRESS_MAP_NAME( memory_map16_32Mb );
- break;
- case FLASH_SST_39VF020:
- m_bits = 8;
- m_size = 0x40000;
- m_maker_id = MFG_SST;
- m_device_id = 0xd6;
- m_sector_is_4k = true;
- map = ADDRESS_MAP_NAME( memory_map8_2Mb );
- break;
- case FLASH_SST_39VF400A:
- m_bits = 16;
- m_size = 0x80000;
- m_maker_id = MFG_SST;
- m_device_id = 0xd6;
- m_sector_is_4k = true;
- map = ADDRESS_MAP_NAME( memory_map16_4Mb );
- break;
- case FLASH_SHARP_LH28F400:
- m_bits = 16;
- m_size = 0x80000;
- m_maker_id = MFG_SHARP;
- m_device_id = 0xed;
- map = ADDRESS_MAP_NAME( memory_map16_4Mb );
- break;
- case FLASH_INTEL_E28F400B:
- m_bits = 16;
- m_size = 0x80000;
- m_maker_id = MFG_INTEL;
- m_device_id = 0x4471;
- map = ADDRESS_MAP_NAME( memory_map16_4Mb );
- break;
- case FLASH_FUJITSU_29F160T:
- m_bits = 8;
- m_size = 0x200000;
- m_maker_id = MFG_FUJITSU;
- m_device_id = 0xad;
- m_top_boot_sector = true;
- map = ADDRESS_MAP_NAME( memory_map8_16Mb );
- break;
- case FLASH_FUJITSU_29F016A:
- m_bits = 8;
- m_size = 0x200000;
- m_maker_id = MFG_FUJITSU;
- m_device_id = 0xad;
- map = ADDRESS_MAP_NAME( memory_map8_16Mb );
- break;
- case FLASH_FUJITSU_29DL16X:
- m_bits = 8;
- m_size = 0x200000;
- m_maker_id = MFG_FUJITSU;
- m_device_id = 0x35;
- map = ADDRESS_MAP_NAME( memory_map8_16Mb );
- break;
- case FLASH_INTEL_E28F008SA:
- m_bits = 8;
- m_size = 0x100000;
- m_maker_id = MFG_INTEL;
- m_device_id = 0xa2;
- map = ADDRESS_MAP_NAME( memory_map8_8Mb );
- break;
- case FLASH_INTEL_TE28F160:
- m_bits = 16;
- m_size = 0x200000;
- m_maker_id = MFG_SHARP;
- m_device_id = 0xd0;
- map = ADDRESS_MAP_NAME( memory_map16_16Mb );
- break;
- case FLASH_SHARP_UNK128MBIT:
- m_bits = 16;
- m_size = 0x800000;
- m_maker_id = MFG_SHARP;
- m_device_id = 0xb0;
- map = ADDRESS_MAP_NAME( memory_map16_64Mb );
- break;
- case FLASH_MACRONIX_29L001MC:
- m_bits = 8;
- m_size = 0x20000;
- m_maker_id = MFG_MACRONIX;
- m_device_id = 0x51;
- map = ADDRESS_MAP_NAME( memory_map8_1Mb );
- break;
- case FLASH_MACRONIX_29LV160TMC:
- m_bits = 8;
- m_size = 0x20000;
- m_maker_id = MFG_MACRONIX;
- m_device_id = 0x49;
- m_sector_is_16k = true;
- map = ADDRESS_MAP_NAME( memory_map8_1Mb );
- break;
- case FLASH_PANASONIC_MN63F805MNP:
- m_bits = 8;
- m_size = 0x10000;
- m_maker_id = MFG_PANASONIC;
- m_device_id = 0x1b;
- m_sector_is_4k = true;
- map = ADDRESS_MAP_NAME( memory_map8_512Kb );
- break;
- case FLASH_SANYO_LE26FV10N1TS:
- m_bits = 8;
- m_size = 0x20000;
- m_maker_id = MFG_SANYO;
- m_device_id = 0x13;
- m_sector_is_4k = true;
- map = ADDRESS_MAP_NAME( memory_map8_1Mb );
- break;
- case FLASH_SST_28SF040:
- m_bits = 8;
- m_size = 0x80000;
- m_maker_id = MFG_SST;
- m_device_id = 0x04;
- map = ADDRESS_MAP_NAME( memory_map8_4Mb );
- break;
- case FLASH_TMS_29F040:
- m_bits = 8;
- m_addrmask = 0x7fff;
- m_size = 0x80000;
- m_maker_id = MFG_AMD;
- m_device_id = 0xa4;
- map = ADDRESS_MAP_NAME( memory_map8_4Mb );
- break;
- }
-
- int addrbits;
- for (addrbits = 24; addrbits > 0; addrbits--)
- if ((m_size & (1 << addrbits)) != 0)
- break;
-
- m_space_config = address_space_config("flash", ENDIANNESS_BIG, m_bits, addrbits, (m_bits == 8) ? 0 : -1, map);
-}
-
-intelfsh8_device::intelfsh8_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source)
- : intelfsh_device(mconfig, type, name, tag, owner, clock, variant, shortname, source) { }
-
-intelfsh16_device::intelfsh16_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source)
- : intelfsh_device(mconfig, type, name, tag, owner, clock, variant, shortname, source) { }
-
-
-intel_28f016s5_device::intel_28f016s5_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, INTEL_28F016S5, "Intel 28F016S5 Flash", tag, owner, clock, FLASH_INTEL_28F016S5, "intel_28f016s5", __FILE__) { }
-
-fujitsu_29f160t_device::fujitsu_29f160t_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, FUJITSU_29F160T, "Fujitsu 29F160 Flash", tag, owner, clock, FLASH_FUJITSU_29F160T, "fujitsu_29f160t", __FILE__) { }
-
-fujitsu_29f016a_device::fujitsu_29f016a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, FUJITSU_29F016A, "Fujitsu 29F016A Flash", tag, owner, clock, FLASH_FUJITSU_29F016A, "fujitsu_29f016a", __FILE__) { }
-
-fujitsu_29dl16x_device::fujitsu_29dl16x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, FUJITSU_29DL16X, "Fujitsu 29DL16X Flash", tag, owner, clock, FLASH_FUJITSU_29DL16X, "fujitsu_29dl16x", __FILE__) { }
-
-sharp_lh28f016s_device::sharp_lh28f016s_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, SHARP_LH28F016S, "Sharp LH28F016S Flash", tag, owner, clock, FLASH_SHARP_LH28F016S, "sharp_lh28f016s", __FILE__) { }
-
-atmel_29c010_device::atmel_29c010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, ATMEL_29C010, "Atmel 29C010 Flash", tag, owner, clock, FLASH_ATMEL_29C010, "atmel_29c010", __FILE__) { }
-
-amd_29f010_device::amd_29f010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, AMD_29F010, "AMD 29F010 Flash", tag, owner, clock, FLASH_AMD_29F010, "amd_29f010", __FILE__) { }
-
-amd_29f040_device::amd_29f040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, AMD_29F040, "AMD 29F040 Flash", tag, owner, clock, FLASH_AMD_29F040, "amd_29f040", __FILE__) { }
-
-amd_29f080_device::amd_29f080_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, AMD_29F080, "AMD 29F080 Flash", tag, owner, clock, FLASH_AMD_29F080, "amd_29f080", __FILE__) { }
-
-amd_29f400t_device::amd_29f400t_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, AMD_29F400T, "AMD 29F400 Flash", tag, owner, clock, FLASH_AMD_29F400T, "amd_29f400t", __FILE__) { }
-
-amd_29f800t_device::amd_29f800t_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, AMD_29F800T, "AMD 29F800 Flash", tag, owner, clock, FLASH_AMD_29F800T, "amd_29f800t", __FILE__) { }
-
-amd_29lv200t_device::amd_29lv200t_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, AMD_29LV200T, "AMD 29LV200T Flash", tag, owner, clock, FLASH_AMD_29LV200T, "amd_29lv200t", __FILE__) { }
-
-intel_e28f008sa_device::intel_e28f008sa_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, INTEL_E28F008SA, "Intel E28F008SA Flash", tag, owner, clock, FLASH_INTEL_E28F008SA, "intel_e28f008sa", __FILE__) { }
-
-macronix_29l001mc_device::macronix_29l001mc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, MACRONIX_29L001MC, "Macronix 29L001MC Flash", tag, owner, clock, FLASH_MACRONIX_29L001MC, "macronix_29l001mc", __FILE__) { }
-
-macronix_29lv160tmc_device::macronix_29lv160tmc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, MACRONIX_29LV160TMC, "Macronix 29LV160TMC Flash", tag, owner, clock, FLASH_MACRONIX_29LV160TMC, "macronix_29lv160tmc", __FILE__) { }
-
-panasonic_mn63f805mnp_device::panasonic_mn63f805mnp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, PANASONIC_MN63F805MNP, "Panasonic MN63F805MNP Flash", tag, owner, clock, FLASH_PANASONIC_MN63F805MNP, "panasonic_mn63f805mnp", __FILE__) { }
-
-sanyo_le26fv10n1ts_device::sanyo_le26fv10n1ts_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, SANYO_LE26FV10N1TS, "Sanyo LE26FV10N1TS Flash", tag, owner, clock, FLASH_SANYO_LE26FV10N1TS, "sanyo_le26fv10n1ts", __FILE__) { }
-
-sst_28sf040_device::sst_28sf040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, SST_28SF040, "SST 28SF040 Flash", tag, owner, clock, FLASH_SST_28SF040, "sst_28sf040", __FILE__) { }
-
-sst_39vf020_device::sst_39vf020_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, SST_39VF020, "SST 39VF020 Flash", tag, owner, clock, FLASH_SST_39VF020, "sst_39vf020", __FILE__) { }
-
-sharp_lh28f400_device::sharp_lh28f400_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh16_device(mconfig, SHARP_LH28F400, "Sharp LH28F400 Flash", tag, owner, clock, FLASH_SHARP_LH28F400, "sharp_lh28f400", __FILE__) { }
-
-intel_te28f160_device::intel_te28f160_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh16_device(mconfig, INTEL_TE28F160, "Intel TE28F160 Flash", tag, owner, clock, FLASH_INTEL_TE28F160, "intel_te28f160", __FILE__) { }
-
-intel_e28f400b_device::intel_e28f400b_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh16_device(mconfig, INTEL_E28F400B, "Intel E28F400B Flash", tag, owner, clock, FLASH_INTEL_E28F400B, "intel_e28f400b", __FILE__) { }
-
-sharp_unk128mbit_device::sharp_unk128mbit_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh16_device(mconfig, SHARP_UNK128MBIT, "Sharp Unknown 128Mbit Flash", tag, owner, clock, FLASH_SHARP_UNK128MBIT, "sharp_unk128mbit", __FILE__) { }
-
-intel_28f320j3d_device::intel_28f320j3d_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh16_device(mconfig, INTEL_28F320J3D, "Intel 28F320J3D Flash", tag, owner, clock, FLASH_INTEL_28F320J3D, "intel_28f320j3d", __FILE__) { }
-
-intel_28f320j5_device::intel_28f320j5_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh16_device(mconfig, INTEL_28F320J5, "Intel 28F320J3D_a Flash", tag, owner, clock, FLASH_INTEL_28F320J5, "intel_28f320j5", __FILE__) { }
-
-
-sst_39vf400a_device::sst_39vf400a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh16_device(mconfig, SST_39VF400A, "SST 39VF400A Flash", tag, owner, clock, FLASH_SST_39VF400A, "sst_39vf400a", __FILE__) { }
-
-
-tms_29f040_device::tms_29f040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : intelfsh8_device(mconfig, TMS_29F040, "Texas Instruments 29F040 Flash", tag, owner, clock, FLASH_TMS_29F040, "tms_29f040", __FILE__) { }
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void intelfsh_device::device_start()
-{
- m_timer = timer_alloc();
-
- save_item( NAME(m_status) );
- save_item( NAME(m_flash_mode) );
- save_item( NAME(m_flash_master_lock) );
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void intelfsh_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch( m_flash_mode )
- {
- case FM_READSTATUS:
- m_status = 0x80;
- break;
-
- case FM_ERASEAMD4:
- m_flash_mode = FM_NORMAL;
- break;
- }
-}
-
-
-//-------------------------------------------------
-// memory_space_config - return a description of
-// any address spaces owned by this device
-//-------------------------------------------------
-
-const address_space_config *intelfsh_device::memory_space_config(address_spacenum spacenum) const
-{
- return (spacenum == 0) ? &m_space_config : NULL;
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void intelfsh_device::nvram_default()
-{
- // region always wins
- if (m_region != NULL)
- {
- UINT32 bytes = m_region->bytes();
- if (bytes > m_size)
- bytes = m_size;
-
- if (m_bits == 8)
- {
- for (offs_t offs = 0; offs < bytes; offs++)
- m_addrspace[0]->write_byte(offs, m_region->u8(offs));
- }
- else
- {
- for (offs_t offs = 0; offs < bytes; offs += 2)
- m_addrspace[0]->write_word(offs, m_region->u16(offs / 2));
- }
- return;
- }
-
- // otherwise, default to 0xff
- for (offs_t offs = 0; offs < m_size; offs++)
- m_addrspace[0]->write_byte(offs, 0xff);
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void intelfsh_device::nvram_read(emu_file &file)
-{
- dynamic_buffer buffer(m_size);
- file.read(&buffer[0], m_size);
- for (int byte = 0; byte < m_size; byte++)
- m_addrspace[0]->write_byte(byte, buffer[byte]);
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void intelfsh_device::nvram_write(emu_file &file)
-{
- dynamic_buffer buffer(m_size);
- for (int byte = 0; byte < m_size; byte++)
- buffer[byte] = m_addrspace[0]->read_byte(byte);
- file.write(&buffer[0], m_size);
-}
-
-
-//-------------------------------------------------
-// read_full - generic read, called by the
-// bit-width-specific readers
-//-------------------------------------------------
-
-UINT32 intelfsh_device::read_full(UINT32 address)
-{
- UINT32 data = 0;
- address += m_bank << 16;
- switch( m_flash_mode )
- {
- default:
- case FM_NORMAL:
- switch( m_bits )
- {
- case 8:
- {
- data = m_addrspace[0]->read_byte(address);
- }
- break;
- case 16:
- {
- data = m_addrspace[0]->read_word(address * 2);
- }
- break;
- }
- break;
- case FM_READSTATUS:
- data = m_status;
- break;
- case FM_READAMDID3:
- if ((m_maker_id == MFG_FUJITSU && m_device_id == 0x35) || (m_maker_id == MFG_AMD && m_device_id == 0x3b))
- {
- // used in Fujitsu 29DL16X 8bits mode
- // used in AMD 29LV200 8bits mode
- switch (address)
- {
- case 0: data = m_maker_id; break;
- case 2: data = m_device_id; break;
- case 4: data = 0; break;
- }
- }
- else
- {
- switch (address)
- {
- case 0: data = m_maker_id; break;
- case 1: data = m_device_id; break;
- case 2: data = 0; break;
- }
- }
- break;
- case FM_READID:
- if (m_maker_id == MFG_INTEL && m_device_id == 0x16)
- {
- switch (address)
- {
- case 0: data = m_maker_id; break;
- case 2: data = m_device_id; break;
- case 4: data = 0; break;
- }
- }
- else
- {
- switch (address)
- {
- case 0: // maker ID
- data = m_maker_id;
- break;
- case 1: // chip ID
- data = m_device_id;
- break;
- case 2: // block lock config
- data = 0; // we don't support this yet
- break;
- case 3: // master lock config
- if (m_flash_master_lock)
- {
- data = 1;
- }
- else
- {
- data = 0;
- }
- break;
- }
- }
- break;
- case FM_ERASEAMD4:
- // reads outside of the erasing sector return normal data
- if ((address < m_erase_sector) || (address >= m_erase_sector+(64*1024)))
- {
- switch( m_bits )
- {
- case 8:
- {
- data = m_addrspace[0]->read_byte(address);
- }
- break;
- case 16:
- {
- data = m_addrspace[0]->read_word(address * 2);
- }
- break;
- }
- }
- else
- {
- m_status ^= ( 1 << 6 ) | ( 1 << 2 );
- data = m_status;
- }
- break;
- }
-
- //logerror( "intelflash_read( %08x ) %08x\n", address, data );
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write_full - generic write, called by the
-// bit-width-specific writers
-//-------------------------------------------------
-
-void intelfsh_device::write_full(UINT32 address, UINT32 data)
-{
- //logerror( "intelflash_write( %u : %08x, %08x )\n", m_flash_mode, address, data );
-
- address += m_bank << 16;
-
- switch( m_flash_mode )
- {
- case FM_NORMAL:
- case FM_READSTATUS:
- case FM_READID:
- case FM_READAMDID3:
- switch( data & 0xff )
- {
- case 0xf0:
- case 0xff: // reset chip mode
- m_flash_mode = FM_NORMAL;
- break;
- case 0x90: // read ID
- m_flash_mode = FM_READID;
- break;
- case 0x40:
- case 0x10: // program
- m_flash_mode = FM_WRITEPART1;
- break;
- case 0x50: // clear status reg
- m_status = 0x80;
- m_flash_mode = FM_READSTATUS;
- break;
- case 0x20: // block erase
- m_flash_mode = FM_CLEARPART1;
- break;
- case 0x60: // set master lock
- m_flash_mode = FM_SETMASTER;
- break;
- case 0x70: // read status
- m_flash_mode = FM_READSTATUS;
- break;
- case 0xaa: // AMD ID select part 1
- if( ( address & 0xfff ) == 0x555 )
- {
- m_flash_mode = FM_READAMDID1;
- }
- else if( ( address & 0xfff ) == 0xaaa )
- {
- m_flash_mode = FM_READAMDID1;
- }
- break;
- default:
- logerror( "Unknown flash mode byte %x\n", data & 0xff );
- break;
- }
- break;
- case FM_READAMDID1:
- if( ( address & 0xffff ) == 0x2aa && ( data & 0xff ) == 0x55 )
- {
- m_flash_mode = FM_READAMDID2;
- }
- else if( ( address & 0xffff ) == 0x2aaa && ( data & 0xff ) == 0x55 )
- {
- m_flash_mode = FM_READAMDID2;
- }
- else if( ( address & 0xfff ) == 0x555 && ( data & 0xff ) == 0x55 )
- {
- m_flash_mode = FM_READAMDID2;
- }
- // for AMD 29F080 address bits A11-A19 don't care, for TMS 29F040 address bits A15-A18 don't care
- else if( ( address & m_addrmask ) == ( 0xaaaa & m_addrmask ) && ( data & 0xff ) == 0x55 && m_addrmask )
- {
- m_flash_mode = FM_READAMDID2;
- }
- else
- {
- logerror( "unexpected %08x=%02x in FM_READAMDID1\n", address, data & 0xff );
- m_flash_mode = FM_NORMAL;
- }
- break;
- case FM_READAMDID2:
- if( ( address & 0xffff ) == 0x555 && ( data & 0xff ) == 0x90 )
- {
- m_flash_mode = FM_READAMDID3;
- }
- else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0x90 )
- {
- m_flash_mode = FM_READAMDID3;
- }
- else if( ( address & 0xfff ) == 0xaaa && ( data & 0xff ) == 0x90 )
- {
- m_flash_mode = FM_READAMDID3;
- }
- else if( ( address & 0xffff ) == 0x555 && ( data & 0xff ) == 0x80 )
- {
- m_flash_mode = FM_ERASEAMD1;
- }
- else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0x80 )
- {
- m_flash_mode = FM_ERASEAMD1;
- }
- else if( ( address & 0xfff ) == 0xaaa && ( data & 0xff ) == 0x80 )
- {
- m_flash_mode = FM_ERASEAMD1;
- }
- else if( ( address & 0xffff ) == 0x555 && ( data & 0xff ) == 0xa0 )
- {
- m_flash_mode = FM_BYTEPROGRAM;
- }
- else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0xa0 )
- {
- if (m_type == FLASH_ATMEL_29C010)
- {
- m_flash_mode = FM_WRITEPAGEATMEL;
- m_byte_count = 0;
- }
- else
- {
- m_flash_mode = FM_BYTEPROGRAM;
- }
- }
- else if( ( address & 0xfff ) == 0xaaa && ( data & 0xff ) == 0xa0 )
- {
- m_flash_mode = FM_BYTEPROGRAM;
- }
- else if( ( address & 0xffff ) == 0x555 && ( data & 0xff ) == 0xf0 )
- {
- m_flash_mode = FM_NORMAL;
- }
- else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0xf0 )
- {
- m_flash_mode = FM_NORMAL;
- }
- else if( ( address & 0xfff ) == 0xaaa && ( data & 0xff ) == 0xf0 )
- {
- m_flash_mode = FM_NORMAL;
- }
- else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0xb0 && m_maker_id == 0x62 && m_device_id == 0x13 )
- {
- m_flash_mode = FM_BANKSELECT;
- }
-
- // for AMD 29F080 address bits A11-A19 don't care, for TMS 29F040 address bits A15-A18 don't care
- else if(( address & m_addrmask ) == ( 0x5555 & m_addrmask ) && ( data & 0xff ) == 0x80 && m_addrmask )
- {
- m_flash_mode = FM_ERASEAMD1;
- }
- else if(( address & m_addrmask ) == ( 0x5555 & m_addrmask ) && ( data & 0xff ) == 0x90 && m_addrmask )
- {
- m_flash_mode = FM_READAMDID3;
- }
- else if(( address & m_addrmask ) == ( 0x5555 & m_addrmask ) && ( data & 0xff ) == 0xa0 && m_addrmask )
- {
- m_flash_mode = FM_BYTEPROGRAM;
- }
- else if(( address & m_addrmask ) == ( 0x5555 & m_addrmask ) && ( data & 0xff ) == 0xf0 && m_addrmask )
- {
- m_flash_mode = FM_NORMAL;
- }
- else
- {
- logerror( "unexpected %08x=%02x in FM_READAMDID2\n", address, data & 0xff );
- m_flash_mode = FM_NORMAL;
- }
- break;
- case FM_ERASEAMD1:
- if( ( address & 0xfff ) == 0x555 && ( data & 0xff ) == 0xaa )
- {
- m_flash_mode = FM_ERASEAMD2;
- }
- else if( ( address & 0xfff ) == 0xaaa && ( data & 0xff ) == 0xaa )
- {
- m_flash_mode = FM_ERASEAMD2;
- }
- else
- {
- logerror( "unexpected %08x=%02x in FM_ERASEAMD1\n", address, data & 0xff );
- }
- break;
- case FM_ERASEAMD2:
- if( ( address & 0xffff ) == 0x2aa && ( data & 0xff ) == 0x55 )
- {
- m_flash_mode = FM_ERASEAMD3;
- }
- else if( ( address & 0xffff ) == 0x2aaa && ( data & 0xff ) == 0x55 )
- {
- m_flash_mode = FM_ERASEAMD3;
- }
- else if( ( address & 0xfff ) == 0x555 && ( data & 0xff ) == 0x55 )
- {
- m_flash_mode = FM_ERASEAMD3;
- }
- else
- {
- logerror( "unexpected %08x=%02x in FM_ERASEAMD2\n", address, data & 0xff );
- }
- break;
- case FM_ERASEAMD3:
- if( (( address & 0xfff ) == 0x555 && ( data & 0xff ) == 0x10 ) ||
- (( address & 0xfff ) == 0xaaa && ( data & 0xff ) == 0x10 ) )
- {
- // chip erase
- for (offs_t offs = 0; offs < m_size; offs++)
- m_addrspace[0]->write_byte(offs, 0xff);
-
- m_status = 1 << 3;
- m_flash_mode = FM_ERASEAMD4;
-
- if (m_sector_is_4k)
- {
- m_timer->adjust( attotime::from_seconds( 1 ) );
- }
- else if(m_sector_is_16k)
- {
- m_timer->adjust( attotime::from_seconds( 4 ) );
- }
- else
- {
- m_timer->adjust( attotime::from_seconds( 16 ) );
- }
- }
- else if( ( data & 0xff ) == 0x30 )
- {
- // sector erase
- // clear the 4k/64k block containing the current address to all 0xffs
- UINT32 base = address * ((m_bits == 16) ? 2 : 1);
- if (m_sector_is_4k)
- {
- for (offs_t offs = 0; offs < 4 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0xfff) + offs, 0xff);
- m_erase_sector = address & ((m_bits == 16) ? ~0x7ff : ~0xfff);
- m_timer->adjust( attotime::from_msec( 125 ) );
- }
- else if(m_sector_is_16k)
- {
- for (offs_t offs = 0; offs < 16 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0x3fff) + offs, 0xff);
- m_erase_sector = address & ((m_bits == 16) ? ~0x1fff : ~0x3fff);
- m_timer->adjust( attotime::from_msec( 500 ) );
- }
- else if(m_top_boot_sector && address >= (m_size - 64*1024))
- {
- if (address >= (m_size - (16*1024)))
- {
- for (offs_t offs = 0; offs < 16 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0x3fff) + offs, 0xff);
- m_erase_sector = address & ((m_bits == 16) ? ~0x1fff : ~0x3fff);
- m_timer->adjust( attotime::from_msec( 500 ) );
- }
- else if (address >= (m_size - (32*1024)))
- {
- for (offs_t offs = 0; offs < 8 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0x1fff) + offs, 0xff);
- m_erase_sector = address & ((m_bits == 16) ? ~0xfff : ~0x1fff);
- m_timer->adjust( attotime::from_msec( 250 ) );
- }
- else
- {
- for (offs_t offs = 0; offs < 32 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0x7fff) + offs, 0xff);
- m_erase_sector = address & ((m_bits == 16) ? ~0x3fff : ~0x7fff);
- m_timer->adjust( attotime::from_msec( 500 ) );
- }
- }
- else
- {
- for (offs_t offs = 0; offs < 64 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0xffff) + offs, 0xff);
- m_erase_sector = address & ((m_bits == 16) ? ~0x7fff : ~0xffff);
- m_timer->adjust( attotime::from_seconds( 1 ) );
- }
-
- m_status = 1 << 3;
- m_flash_mode = FM_ERASEAMD4;
- }
- else
- {
- logerror( "unexpected %08x=%02x in FM_ERASEAMD3\n", address, data & 0xff );
- }
- break;
- case FM_BYTEPROGRAM:
- switch( m_bits )
- {
- case 8:
- {
- m_addrspace[0]->write_byte(address, data);
- }
- break;
- default:
- logerror( "FM_BYTEPROGRAM not supported when m_bits == %d\n", m_bits );
- break;
- }
- m_flash_mode = FM_NORMAL;
- break;
- case FM_WRITEPART1:
- switch( m_bits )
- {
- case 8:
- {
- m_addrspace[0]->write_byte(address, data);
- }
- break;
- case 16:
- {
- m_addrspace[0]->write_word(address * 2, data);
- }
- break;
- default:
- logerror( "FM_WRITEPART1 not supported when m_bits == %d\n", m_bits );
- break;
- }
- m_status = 0x80;
- if (m_type == FLASH_SST_28SF040)
- m_flash_mode = FM_NORMAL;
- else
- m_flash_mode = FM_READSTATUS;
- break;
- case FM_WRITEPAGEATMEL:
- switch( m_bits )
- {
- case 8:
- {
- m_addrspace[0]->write_byte(address, data);
- }
- break;
- case 16:
- {
- m_addrspace[0]->write_word(address * 2, data);
- }
- break;
- default:
- logerror( "FM_WRITEPAGEATMEL not supported when m_bits == %d\n", m_bits );
- break;
- }
-
- m_byte_count++;
-
- if (m_byte_count == m_page_size)
- {
- m_flash_mode = FM_NORMAL;
- }
- break;
- case FM_CLEARPART1:
- if( ( data & 0xff ) == 0xd0 )
- {
- if (m_type == FLASH_SST_28SF040)
- {
- // clear the 256 bytes block containing the current address to all 0xffs
- UINT32 base = address * ((m_bits == 16) ? 2 : 1);
- for (offs_t offs = 0; offs < 256; offs++)
- m_addrspace[0]->write_byte((base & ~0xff) + offs, 0xff);
-
- m_timer->adjust( attotime::from_msec( 4 ) );
- }
- else if (m_type == FLASH_INTEL_E28F400B)
- {
- // 00000-03fff - 16KB boot block (may be write protected via external pins)
- // 04000-05fff - 8KB parameter block
- // 06000-07fff - 8KB parameter block
- // 08000-1ffff - 96KB main block
- // 20000-3ffff - 128KB main block
- // 40000-5ffff - 128KB main block
- // 60000-7ffff - 128KB main block
- // erase duration is 0.3s for boot and parameter blocks, and 0.6s for main blocks
- UINT32 base = (address & 0x3ffff) * 2;
- int size, duration;
- if (base < 0x4000)
- {
- base = 0;
- size = 0x4000;
- duration = 300;
- }
- else if (base < 0x8000)
- {
- base &= 0x6000;
- size = 0x2000;
- duration = 300;
- }
- else if (base < 0x20000)
- {
- base = 0x8000;
- size = 0x18000;
- duration = 600;
- }
- else
- {
- base &= 0x60000;
- size = 0x20000;
- duration = 600;
- }
-
- // clear the block containing the current address to all 0xffffs
- for (offs_t offs = 0; offs < size / 2; offs += 2)
- m_addrspace[0]->write_word(base | offs, 0xffff);
-
- m_timer->adjust( attotime::from_msec( duration ) );
- }
- else
- {
- // clear the 64k block containing the current address to all 0xffs
- UINT32 base = address * ((m_bits == 16) ? 2 : 1);
- for (offs_t offs = 0; offs < 64 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0xffff) + offs, 0xff);
-
- m_timer->adjust( attotime::from_seconds( 1 ) );
- }
-
- m_status = 0x00;
- m_flash_mode = FM_READSTATUS;
- break;
- }
- else
- {
- logerror( "unexpected %02x in FM_CLEARPART1\n", data & 0xff );
- }
- break;
- case FM_SETMASTER:
- switch( data & 0xff )
- {
- case 0xf1:
- m_flash_master_lock = true;
- break;
- case 0xd0:
- m_flash_master_lock = false;
- break;
- default:
- logerror( "unexpected %08x=%02x in FM_SETMASTER:\n", address, data & 0xff );
- break;
- }
- m_flash_mode = FM_NORMAL;
- break;
- case FM_BANKSELECT:
- m_bank = data & 0xff;
- m_flash_mode = FM_NORMAL;
- break;
- }
-}
diff --git a/src/emu/machine/intelfsh.h b/src/emu/machine/intelfsh.h
deleted file mode 100644
index 5e4b86f10d2..00000000000
--- a/src/emu/machine/intelfsh.h
+++ /dev/null
@@ -1,427 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*
- Intel Flash ROM emulation
-*/
-
-#ifndef _INTELFLASH_H_
-#define _INTELFLASH_H_
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_INTEL_28F016S5_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, INTEL_28F016S5, 0)
-
-#define MCFG_SHARP_LH28F016S_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SHARP_LH28F016S, 0)
-
-#define MCFG_ATMEL_29C010_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, ATMEL_29C010, 0)
-
-#define MCFG_AMD_29F010_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, AMD_29F010, 0)
-
-#define MCFG_AMD_29F040_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, AMD_29F040, 0)
-
-#define MCFG_AMD_29F080_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, AMD_29F080, 0)
-
-#define MCFG_AMD_29F400T_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, AMD_29F400T, 0)
-
-#define MCFG_AMD_29F800T_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, AMD_29F800T, 0)
-
-#define MCFG_AMD_29LV200T_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, AMD_29LV200T, 0)
-
-#define MCFG_FUJITSU_29F160T_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, FUJITSU_29F160T, 0)
-
-#define MCFG_FUJITSU_29F016A_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, FUJITSU_29F016A, 0)
-
-#define MCFG_FUJITSU_29DL16X_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, FUJITSU_29DL16X, 0)
-
-#define MCFG_INTEL_E28F400B_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, INTEL_E28F400B, 0)
-
-#define MCFG_MACRONIX_29L001MC_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, MACRONIX_29L001MC, 0)
-
-#define MCFG_MACRONIX_29LV160TMC_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, MACRONIX_29LV160TMC, 0)
-
-#define MCFG_PANASONIC_MN63F805MNP_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, PANASONIC_MN63F805MNP, 0)
-
-#define MCFG_SANYO_LE26FV10N1TS_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SANYO_LE26FV10N1TS, 0)
-
-#define MCFG_SST_28SF040_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SST_28SF040, 0)
-
-#define MCFG_SST_39VF020_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SST_39VF020, 0)
-
-#define MCFG_SHARP_LH28F400_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SHARP_LH28F400, 0)
-
-#define MCFG_INTEL_E28F008SA_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, INTEL_E28F008SA, 0)
-
-#define MCFG_INTEL_TE28F160_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, INTEL_TE28F160, 0)
-
-#define MCFG_SHARP_UNK128MBIT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SHARP_UNK128MBIT, 0)
-
-#define MCFG_INTEL_28F320J3D_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, INTEL_28F320J3D, 0)
-
-#define MCFG_INTEL_28F320J5_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, INTEL_28F320J5, 0)
-
-#define MCFG_SST_39VF400A_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SST_39VF400A, 0)
-
-#define MCFG_TMS_29F040_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, TMS_29F040, 0)
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-class intelfsh_device;
-
-
-// ======================> intelfsh_device
-
-class intelfsh_device : public device_t,
- public device_memory_interface,
- public device_nvram_interface
-{
-public:
- enum
- {
- // 8-bit variants
- FLASH_INTEL_28F016S5 = 0x0800,
- FLASH_FUJITSU_29F160T,
- FLASH_FUJITSU_29F016A,
- FLASH_FUJITSU_29DL16X,
- FLASH_ATMEL_29C010,
- FLASH_AMD_29F010,
- FLASH_AMD_29F040,
- FLASH_AMD_29F080,
- FLASH_AMD_29F400T,
- FLASH_AMD_29F800T,
- FLASH_AMD_29LV200T,
- FLASH_SHARP_LH28F016S,
- FLASH_INTEL_E28F008SA,
- FLASH_MACRONIX_29L001MC,
- FLASH_MACRONIX_29LV160TMC,
- FLASH_PANASONIC_MN63F805MNP,
- FLASH_SANYO_LE26FV10N1TS,
- FLASH_SST_28SF040,
- FLASH_SST_39VF020,
- FLASH_TMS_29F040,
-
- // 16-bit variants
- FLASH_SHARP_LH28F400 = 0x1000,
- FLASH_INTEL_E28F400B,
- FLASH_INTEL_TE28F160,
- FLASH_SHARP_UNK128MBIT,
- FLASH_INTEL_28F320J3D,
- FLASH_INTEL_28F320J5,
- FLASH_SST_39VF400A
- };
-
-protected:
- // construction/destruction
- intelfsh_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_memory_interface overrides
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
- // derived helpers
- UINT32 read_full(UINT32 offset);
- void write_full(UINT32 offset, UINT32 data);
-
- // configuration state
- address_space_config m_space_config;
- UINT32 m_type;
- INT32 m_size;
- UINT8 m_bits;
- UINT32 m_addrmask;
- UINT16 m_device_id;
- UINT8 m_maker_id;
- bool m_sector_is_4k;
- bool m_sector_is_16k;
- bool m_top_boot_sector;
- UINT8 m_page_size;
-
- // internal state
- UINT8 m_status;
- INT32 m_erase_sector;
- INT32 m_flash_mode;
- bool m_flash_master_lock;
- emu_timer * m_timer;
- INT32 m_bank;
- UINT8 m_byte_count;
-};
-
-
-// ======================> intelfsh8_device
-
-class intelfsh8_device : public intelfsh_device
-{
-protected:
- // construction/destruction
- intelfsh8_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source);
-
-public:
- // public interface
- UINT8 read(offs_t offset) { return read_full(offset); }
- void write(offs_t offset, UINT8 data) { write_full(offset, data); }
- DECLARE_READ8_MEMBER(read) { return read_full(offset); }
- DECLARE_WRITE8_MEMBER(write) { write_full(offset, data); }
-
- UINT8 read_raw(offs_t offset) { return m_addrspace[0]->read_byte(offset); }
- void write_raw(offs_t offset, UINT8 data) { m_addrspace[0]->write_byte(offset, data); }
-};
-
-
-// ======================> intelfsh16_device
-
-class intelfsh16_device : public intelfsh_device
-{
-protected:
- // construction/destruction
- intelfsh16_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source);
-
-public:
- // public interface
- UINT16 read(offs_t offset) { return read_full(offset); }
- void write(offs_t offset, UINT16 data) { write_full(offset, data); }
- DECLARE_READ16_MEMBER(read) { return read_full(offset); }
- DECLARE_WRITE16_MEMBER(write) { write_full(offset, data); }
-
- UINT16 read_raw(offs_t offset) { return m_addrspace[0]->read_word(offset * 2); }
- void write_raw(offs_t offset, UINT16 data) { m_addrspace[0]->write_word(offset * 2, data); }
-};
-
-
-// ======================> trivial variants
-
-// 8-bit variants
-class intel_28f016s5_device : public intelfsh8_device
-{
-public:
- intel_28f016s5_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class fujitsu_29f160t_device : public intelfsh8_device
-{
-public:
- fujitsu_29f160t_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class fujitsu_29f016a_device : public intelfsh8_device
-{
-public:
- fujitsu_29f016a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class fujitsu_29dl16x_device : public intelfsh8_device
-{
-public:
- fujitsu_29dl16x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class atmel_29c010_device : public intelfsh8_device
-{
-public:
- atmel_29c010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class amd_29f010_device : public intelfsh8_device
-{
-public:
- amd_29f010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class amd_29f040_device : public intelfsh8_device
-{
-public:
- amd_29f040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class amd_29f080_device : public intelfsh8_device
-{
-public:
- amd_29f080_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class amd_29f400t_device : public intelfsh8_device
-{
-public:
- amd_29f400t_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class amd_29f800t_device : public intelfsh8_device
-{
-public:
- amd_29f800t_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class amd_29lv200t_device : public intelfsh8_device
-{
-public:
- amd_29lv200t_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class sharp_lh28f016s_device : public intelfsh8_device
-{
-public:
- sharp_lh28f016s_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class intel_e28f008sa_device : public intelfsh8_device
-{
-public:
- intel_e28f008sa_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class macronix_29l001mc_device : public intelfsh8_device
-{
-public:
- macronix_29l001mc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class macronix_29lv160tmc_device : public intelfsh8_device
-{
-public:
- macronix_29lv160tmc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class panasonic_mn63f805mnp_device : public intelfsh8_device
-{
-public:
- panasonic_mn63f805mnp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class sanyo_le26fv10n1ts_device : public intelfsh8_device
-{
-public:
- sanyo_le26fv10n1ts_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class sst_28sf040_device : public intelfsh8_device
-{
-public:
- sst_28sf040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class sst_39vf020_device : public intelfsh8_device
-{
-public:
- sst_39vf020_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class tms_29f040_device : public intelfsh8_device
-{
-public:
- tms_29f040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-// 16-bit variants
-class sharp_lh28f400_device : public intelfsh16_device
-{
-public:
- sharp_lh28f400_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class intel_te28f160_device : public intelfsh16_device
-{
-public:
- intel_te28f160_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class intel_e28f400b_device : public intelfsh16_device
-{
-public:
- intel_e28f400b_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class sharp_unk128mbit_device : public intelfsh16_device
-{
-public:
- sharp_unk128mbit_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class intel_28f320j3d_device : public intelfsh16_device
-{
-public:
- intel_28f320j3d_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class intel_28f320j5_device : public intelfsh16_device
-{
-public:
- intel_28f320j5_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class sst_39vf400a_device : public intelfsh16_device
-{
-public:
- sst_39vf400a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-
-// device type definition
-extern const device_type INTEL_28F016S5;
-extern const device_type SHARP_LH28F016S;
-extern const device_type ATMEL_29C010;
-extern const device_type AMD_29F010;
-extern const device_type AMD_29F040;
-extern const device_type AMD_29F080;
-extern const device_type AMD_29F400T;
-extern const device_type AMD_29F800T;
-extern const device_type AMD_29LV200T;
-extern const device_type FUJITSU_29F160T;
-extern const device_type FUJITSU_29F016A;
-extern const device_type FUJITSU_29DL16X;
-extern const device_type INTEL_E28F400B;
-extern const device_type MACRONIX_29L001MC;
-extern const device_type MACRONIX_29LV160TMC;
-extern const device_type TMS_29F040;
-
-extern const device_type PANASONIC_MN63F805MNP;
-extern const device_type SANYO_LE26FV10N1TS;
-extern const device_type SST_28SF040;
-extern const device_type SST_39VF020;
-
-extern const device_type SHARP_LH28F400;
-extern const device_type INTEL_E28F008SA;
-extern const device_type INTEL_TE28F160;
-extern const device_type SHARP_UNK128MBIT;
-extern const device_type INTEL_28F320J3D;
-extern const device_type INTEL_28F320J5;
-extern const device_type SST_39VF400A;
-
-#endif
diff --git a/src/emu/machine/jvsdev.c b/src/emu/machine/jvsdev.c
deleted file mode 100644
index 3357ce90f55..00000000000
--- a/src/emu/machine/jvsdev.c
+++ /dev/null
@@ -1,260 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "jvsdev.h"
-#include "jvshost.h"
-
-void jvs_device::static_set_jvs_host_tag(device_t &device, const char *jvs_host_tag)
-{
- jvs_device &jvsdev = downcast<jvs_device &>(device);
- jvsdev.jvs_host_tag = jvs_host_tag;
-}
-
-jvs_device::jvs_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source)
-{
- jvs_host_tag = 0;
- next_device = 0;
-}
-
-const char *jvs_device::device_id()
-{
- return "";
-}
-
-UINT8 jvs_device::command_format_version()
-{
- return 0x13;
-}
-
-UINT8 jvs_device::jvs_standard_version()
-{
- return 0x30;
-}
-
-UINT8 jvs_device::comm_method_version()
-{
- return 0x10;
-}
-
-void jvs_device::chain(jvs_device *dev)
-{
- if(next_device)
- next_device->chain(dev);
- else
- next_device = dev;
-}
-
-void jvs_device::message(UINT8 dest, const UINT8 *send_buffer, UINT32 send_size, UINT8 *recv_buffer, UINT32 &recv_size)
-{
- recv_size = 0;
-
- // Set Address special case
- if(send_size == 2 && send_buffer[0] == 0xf1) {
- if(next_device && !next_device->get_address_set_line())
- next_device->message(dest, send_buffer, send_size, recv_buffer, recv_size);
- else {
- jvs_address = send_buffer[1];
- recv_size = 2;
- recv_buffer[0] = 0x01;
- recv_buffer[1] = 0x01;
- }
- return;
- }
-
- // dest=0xff is broadcast
- if(dest == 0xff || dest == jvs_address) {
- const UINT8 *s = send_buffer;
- UINT8 *d = recv_buffer;
- *d++ = 0x01;
- while(s < send_buffer + send_size) {
- int len = handle_message(s, send_size-(s-send_buffer), d);
- if(len == -1) {
- // Unknown command
- recv_size = 1;
- recv_buffer[0] = 0x02;
- return;
- } else if(len == 0) {
- // Incorrect parameter
- *d++ = 0x02;
- break;
- } else
- s += len;
- }
- recv_size = d - recv_buffer;
- }
-
- // Pass along the message if the device hasn't replied
- // Should we cumulate answers instead?
- if(next_device && !recv_size)
- next_device->message(dest, send_buffer, send_size, recv_buffer, recv_size);
-}
-
-int jvs_device::handle_message(const UINT8 *send_buffer, UINT32 send_size, UINT8 *&recv_buffer)
-{
- UINT32 old_reset_counter = jvs_reset_counter;
- jvs_reset_counter = 0;
-
- switch(send_buffer[0]) {
- case 0xf0:
- if(send_size < 2 || send_buffer[1] != 0xd9)
- return 0;
-
- // Reset, must be sent twice
- jvs_reset_counter = old_reset_counter+1;
- if(jvs_reset_counter == 2)
- device_reset();
- return 2;
-
- case 0x10: {
- const char *id = device_id();
- int len = strlen(id)+1;
- *recv_buffer++ = 0x01;
- memcpy(recv_buffer, id, len);
- recv_buffer += len;
- return 1;
- }
-
- case 0x11:
- *recv_buffer++ = 0x01;
- *recv_buffer++ = command_format_version();
- return 1;
-
- case 0x12:
- *recv_buffer++ = 0x01;
- *recv_buffer++ = jvs_standard_version();
- return 1;
-
- case 0x13:
- *recv_buffer++ = 0x01;
- *recv_buffer++ = comm_method_version();
- return 1;
-
- case 0x14:
- *recv_buffer++ = 0x01;
- function_list(recv_buffer);
- *recv_buffer++ = 0x00;
- return 1;
-
- case 0x20:
- if(send_size < 3)
- return 0;
- *recv_buffer++ = 0x01;
- return switches(recv_buffer, send_buffer[1], send_buffer[2]) ? 3 : 0;
-
- case 0x21:
- if(send_size < 2)
- return 0;
- *recv_buffer++ = 0x01;
- return coin_counters(recv_buffer, send_buffer[1]) ? 2 : 0;
-
- case 0x22:
- if(send_size < 2)
- return 0;
- *recv_buffer++ = 0x01;
- return analogs(recv_buffer, send_buffer[1]) ? 2 : 0;
-
- case 0x30:
- if(send_size < 4)
- return 0;
- *recv_buffer++ = 0x01;
- return coin_add(send_buffer[1], -((send_buffer[2] << 8) | send_buffer[3])) ? 4 : 0;
-
- case 0x31:
- if(send_size < 4)
- return 0;
- *recv_buffer++ = 0x01;
- return coin_add(send_buffer[1], ((send_buffer[2] << 8) | send_buffer[3])) ? 4 : 0;
-
- case 0x32:
- if(send_size < 2 || send_size < 2+send_buffer[1])
- return 0;
- *recv_buffer++ = 0x01;
- return swoutputs(send_buffer[1], send_buffer+2) ? 2+send_buffer[1] : 0;
-
- case 0x38:
- if(send_size < 3)
- return 0;
- *recv_buffer++ = 0x01;
- return swoutputs(send_buffer[1], send_buffer[2]) ? 3 : 0;
-
- default:
- logerror("JVSDEV: unhandled command %02x\n", send_buffer[0]);
- return 0;
- }
-
- // never executed
- //return -1;
-}
-
-bool jvs_device::get_address_set_line()
-{
- return jvs_address != 0xff && (!next_device || next_device->get_address_set_line());
-}
-
-void jvs_device::device_start()
-{
- jvs_host *host = machine().device<jvs_host>(jvs_host_tag);
- if(!host)
- fatalerror("JVS device %s could not find JVS host %s\n", tag(), jvs_host_tag);
- host->add_device(this);
-
- save_item(NAME(jvs_address));
- save_item(NAME(jvs_reset_counter));
-}
-
-void jvs_device::device_reset()
-{
- jvs_address = 0xff;
- jvs_reset_counter = 0;
- jvs_outputs = 0;
-}
-
-void jvs_device::function_list(UINT8 *&buf)
-{
-}
-
-bool jvs_device::coin_counters(UINT8 *&buf, UINT8 count)
-{
- return false;
-}
-
-bool jvs_device::coin_add(UINT8 slot, INT32 count)
-{
- return false;
-}
-
-
-bool jvs_device::switches(UINT8 *&buf, UINT8 count_players, UINT8 bytes_per_switch)
-{
- return false;
-}
-
-bool jvs_device::analogs(UINT8 *&buf, UINT8 count)
-{
- return false;
-}
-
-bool jvs_device::swoutputs(UINT8 count, const UINT8 *vals)
-{
- return false;
-}
-
-bool jvs_device::swoutputs(UINT8 id, UINT8 val)
-{
- return false;
-}
-
-void jvs_device::handle_output(ioport_port *port, UINT8 id, UINT8 val)
-{
- UINT32 m = 1 << id;
- switch(val) {
- case 0: jvs_outputs &= ~m; break;
- case 1: jvs_outputs |= m; break;
- case 2: jvs_outputs ^= m; break;
- }
-
- if (port)
- {
- port->write(jvs_outputs, m);
- }
-}
diff --git a/src/emu/machine/jvsdev.h b/src/emu/machine/jvsdev.h
deleted file mode 100644
index 97382ea1655..00000000000
--- a/src/emu/machine/jvsdev.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef __JVSDEV_H__
-#define __JVSDEV_H__
-
-#include "emu.h"
-
-#define MCFG_JVS_DEVICE_ADD(_tag, _type, _host) \
- MCFG_DEVICE_ADD(_tag, _type, 0) \
- jvs_device::static_set_jvs_host_tag(*device, _host);
-class jvs_host;
-
-class jvs_device : public device_t
-{
-public:
- jvs_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
- static void static_set_jvs_host_tag(device_t &device, const char *jvs_host_tag);
-
- void chain(jvs_device *dev);
- void message(UINT8 dest, const UINT8 *send_buffer, UINT32 send_size, UINT8 *recv_buffer, UINT32 &recv_size);
- bool get_address_set_line();
-
-protected:
- UINT32 jvs_outputs;
-
- void handle_output(ioport_port *port, UINT8 id, UINT8 val);
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- // JVS device overrides
- virtual const char *device_id();
- virtual UINT8 command_format_version();
- virtual UINT8 jvs_standard_version();
- virtual UINT8 comm_method_version();
- virtual void function_list(UINT8 *&buf);
- virtual bool switches(UINT8 *&buf, UINT8 count_players, UINT8 bytes_per_switch);
- virtual bool coin_counters(UINT8 *&buf, UINT8 count);
- virtual bool coin_add(UINT8 slot, INT32 count);
- virtual bool analogs(UINT8 *&buf, UINT8 count);
- virtual bool swoutputs(UINT8 count, const UINT8 *vals);
- virtual bool swoutputs(UINT8 id, UINT8 val);
-
-private:
- const char *jvs_host_tag;
- jvs_device *next_device;
- UINT8 jvs_address;
- UINT32 jvs_reset_counter;
-
- int handle_message(const UINT8 *send_buffer, UINT32 send_size, UINT8 *&recv_buffer);
-};
-
-#endif
diff --git a/src/emu/machine/jvshost.c b/src/emu/machine/jvshost.c
deleted file mode 100644
index 1621d691cea..00000000000
--- a/src/emu/machine/jvshost.c
+++ /dev/null
@@ -1,157 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "jvshost.h"
-#include "jvsdev.h"
-
-void jvs_host::add_device(jvs_device *dev)
-{
- if(first_device)
- first_device->chain(dev);
- else
- first_device = dev;
-}
-
-void jvs_host::device_start()
-{
- save_item(NAME(send_size));
- save_item(NAME(recv_size));
- save_item(NAME(send_buffer));
- save_item(NAME(recv_buffer));
- save_item(NAME(recv_is_encoded));
-}
-
-void jvs_host::device_reset()
-{
- send_size = recv_size = 0;
- recv_is_encoded = false;
- memset(send_buffer, 0, sizeof(send_buffer));
- memset(recv_buffer, 0, sizeof(recv_buffer));
-}
-
-jvs_host::jvs_host(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source)
-{
- first_device = 0;
-}
-
-void jvs_host::push(UINT8 val)
-{
- send_buffer[send_size++] = val;
-}
-
-void jvs_host::commit_raw()
-{
- recv_size = 0;
- if(!send_size)
- return;
-
- // Message must:
- // - have a non-zero destination in the first byte
- // - have the message length without the two header bytes but with the checksum byte in the second byte
- // - have at least one command byte
- if(send_size < 3 || send_buffer[0] == 0x00 || send_buffer[1] != send_size-1) {
- logerror("JVS checksum error\n");
- // "This message is crap" doesn't exist so call it checksum error
- recv_buffer[0] = 0x00;
- recv_buffer[1] = 0x02;
- recv_buffer[2] = 0x03;
- recv_size = 3;
- } else {
- if(first_device) {
- first_device->message(send_buffer[0], send_buffer+2, send_size-2, recv_buffer+2, recv_size);
- recv_is_encoded = false;
- if(recv_size) {
- // Add the reply header, host is always destination 0x00
- recv_buffer[0] = 0x00;
- recv_buffer[1] = recv_size+1;
- recv_size += 2;
- }
- } else
- recv_size = 0;
- }
- send_size = 0;
-}
-
-void jvs_host::commit_encoded()
-{
- recv_size = 0;
- if(!send_size)
- return;
- decode(send_buffer, send_size);
- commit_raw();
-}
-
-
-void jvs_host::get_raw_reply(const UINT8 *&buffer, UINT32 &size)
-{
- if(recv_is_encoded) {
- decode(recv_buffer, recv_size);
- recv_is_encoded = false;
- }
- buffer = recv_buffer;
- size = recv_size;
-}
-
-void jvs_host::get_encoded_reply(const UINT8 *&buffer, UINT32 &size)
-{
- if(!recv_is_encoded) {
- encode(recv_buffer, recv_size);
- recv_is_encoded = true;
- }
- buffer = recv_buffer;
- size = recv_size;
-}
-
-bool jvs_host::get_presence_line()
-{
- return first_device != 0;
-}
-
-bool jvs_host::get_address_set_line()
-{
- return first_device && first_device->get_address_set_line();
-}
-
-
-void jvs_host::encode(UINT8 *buffer, UINT32 &size)
-{
- if(!size)
- return;
- UINT32 add = 1;
- UINT8 sum = 0;
- for(UINT32 i=0; i<size; i++)
- sum += buffer[i];
- buffer[size++] = sum;
- for(UINT32 i=0; i<size; i++)
- if(buffer[i] == 0xd0 || buffer[i] == 0xe0)
- add++;
- for(UINT32 i=size; i; i--) {
- UINT8 t = buffer[i-1];
- if(t == 0xd0 || t == 0xe0) {
- buffer[i+add-1] = t-1;
- buffer[i+add-2] = 0xd0;
- add--;
- } else
- buffer[i+add-1] = t;
- }
- buffer[0] = 0xe0;
- size += add;
-}
-
-void jvs_host::decode(UINT8 *buffer, UINT32 &size)
-{
- if(!size)
- return;
- UINT32 pos = 0;
- for(UINT32 i=0; i<size; i++) {
- UINT8 t = buffer[i];
- if(!i && t == 0xe0)
- continue;
- if(t == 0xd0) {
- i++;
- t = buffer[i]+1;
- }
- buffer[pos++] = t;
- }
- size = pos ? pos - 1 : 0;
-}
diff --git a/src/emu/machine/jvshost.h b/src/emu/machine/jvshost.h
deleted file mode 100644
index 872e8a774e5..00000000000
--- a/src/emu/machine/jvshost.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef __JVSHOST_H__
-#define __JVSHOST_H__
-
-#include "emu.h"
-
-class jvs_device;
-
-class jvs_host : public device_t {
-public:
- jvs_host(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- void add_device(jvs_device *dev);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-
- void push(UINT8 val);
- void commit_raw();
- void commit_encoded();
-
- void get_raw_reply(const UINT8 *&buffer, UINT32 &size);
- void get_encoded_reply(const UINT8 *&buffer, UINT32 &size);
-
- bool get_presence_line();
- bool get_address_set_line();
-
-private:
- enum { BUFFER_SIZE = 512 };
-
- jvs_device *first_device;
-
- UINT32 send_size, recv_size;
- UINT8 send_buffer[BUFFER_SIZE];
- UINT8 recv_buffer[BUFFER_SIZE];
-
- bool recv_is_encoded;
-
- void encode(UINT8 *buffer, UINT32 &size);
- void decode(UINT8 *buffer, UINT32 &size);
-};
-
-#endif
diff --git a/src/emu/machine/k033906.c b/src/emu/machine/k033906.c
deleted file mode 100644
index 37ad31cff45..00000000000
--- a/src/emu/machine/k033906.c
+++ /dev/null
@@ -1,128 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Fabio Priuli
-/***************************************************************************
-
- Konami IC 033906 (PCI bridge)
-
-***************************************************************************/
-
-#include "emu.h"
-#include "k033906.h"
-#include "video/voodoo.h"
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type K033906 = &device_creator<k033906_device>;
-
-//-------------------------------------------------
-// k033906_device - constructor
-//-------------------------------------------------
-
-k033906_device::k033906_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, K033906, "K033906 PCI bridge", tag, owner, clock, "k033906", __FILE__)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void k033906_device::device_start()
-{
- m_voodoo = machine().device(m_voodoo_tag);
-
- m_reg_set = 0;
-
- save_item(NAME(m_reg));
- save_item(NAME(m_ram));
- save_item(NAME(m_reg_set));
-}
-
-
-WRITE_LINE_MEMBER(k033906_device::set_reg)
-{
- m_reg_set = state & 1;
-}
-
-UINT32 k033906_device::reg_r(int reg)
-{
- switch (reg)
- {
- case 0x00: return 0x0001121a; // PCI Vendor ID (0x121a = 3dfx), Device ID (0x0001 = Voodoo)
- case 0x02: return 0x04000000; // Revision ID
- case 0x04: return m_reg[0x04]; // memBaseAddr
- case 0x0f: return m_reg[0x0f]; // interrupt_line, interrupt_pin, min_gnt, max_lat
-
- default:
- fatalerror("%s: k033906_reg_r: %08X\n", machine().describe_context(), reg);
- }
- // never executed
- //return 0;
-}
-
-void k033906_device::reg_w(int reg, UINT32 data)
-{
- switch (reg)
- {
- case 0x00:
- break;
-
- case 0x01: // command register
- break;
-
- case 0x04: // memBaseAddr
- {
- if (data == 0xffffffff)
- {
- m_reg[0x04] = 0xff000000;
- }
- else
- {
- m_reg[0x04] = data & 0xff000000;
- }
- break;
- }
-
- case 0x0f: // interrupt_line, interrupt_pin, min_gnt, max_lat
- {
- m_reg[0x0f] = data;
- break;
- }
-
- case 0x10: // initEnable
- {
- voodoo_set_init_enable(m_voodoo, data);
- break;
- }
-
- case 0x11: // busSnoop0
- case 0x12: // busSnoop1
- break;
-
- case 0x38: // ???
- break;
-
- default:
- fatalerror("%s:K033906_w: %08X, %08X\n", machine().describe_context(), data, reg);
- }
-}
-
-READ32_MEMBER(k033906_device::read)
-{
- if (m_reg_set)
- return reg_r(offset);
- else
- return m_ram[offset];
-}
-
-WRITE32_MEMBER(k033906_device::write)
-{
- if (m_reg_set)
- reg_w(offset, data);
- else
- m_ram[offset] = data;
-}
diff --git a/src/emu/machine/k033906.h b/src/emu/machine/k033906.h
deleted file mode 100644
index bec3bc1c3ac..00000000000
--- a/src/emu/machine/k033906.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Fabio Priuli
-/***************************************************************************
-
- Konami 033906
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __K033906_H__
-#define __K033906_H__
-
-#include "emu.h"
-
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_K033906_VOODOO(_tag) \
- k033906_device::set_voodoo_tag(*device, _tag);
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-
-// ======================> k033906_device
-
-class k033906_device : public device_t
-{
-public:
- // construction/destruction
- k033906_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void set_voodoo_tag(device_t &device, const char *tag) { downcast<k033906_device &>(device).m_voodoo_tag = tag; }
-
- DECLARE_READ32_MEMBER( read );
- DECLARE_WRITE32_MEMBER( write );
- DECLARE_WRITE_LINE_MEMBER( set_reg );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset() { }
- virtual void device_post_load() { }
- virtual void device_clock_changed() { }
-
-private:
-
- UINT32 reg_r(int reg);
- void reg_w(int reg, UINT32 data);
-
- /* i/o lines */
-
- int m_reg_set; // 1 = access reg / 0 = access ram
-
- const char *m_voodoo_tag;
- device_t *m_voodoo;
-
- UINT32 m_reg[256];
- UINT32 m_ram[32768];
-};
-
-
-// device type definition
-extern const device_type K033906;
-
-#endif /* __K033906_H__ */
diff --git a/src/emu/machine/k053252.c b/src/emu/machine/k053252.c
deleted file mode 100644
index 1cea029d38d..00000000000
--- a/src/emu/machine/k053252.c
+++ /dev/null
@@ -1,233 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:Angelo Salese
-/***************************************************************************************************************************
-
- Konami 053252 chip emulation, codenamed "CCU"
-
- device emulation by Angelo Salese, based off notes by Olivier Galibert
-
-============================================================================================================================
-
-left res = current in game, right res = computed
-
-hexion: 02 FF 00 4D 00 73 00 00 01 1F 05 0E B7 7C 00 00 512x256 ~ 512x256 <- writes to e and f regs, in an irq ack fashion
-overdriv: 01 7F 00 22 00 0D 00 03 01 07 10 0F 73 00 00 00 304x256 ~ 305x224
-esckids: 01 7F 00 12 00 0D 00 01 01 07 08 07 73 00 00 00 304x224 ~ 321x240
-rollerg: 01 7F 00 23 00 1D 02 00 01 07 10 0F 73 00 02 00 288x224 ~ 288x224 <- writes to 6 and e regs, in an irq ack fashion
-gaiapols: 01 FB 00 19 00 37 00 00 01 06 10 0E 75 00 D1 00 376x224 ~ 380x224
-mmaulers: 01 7F 00 19 00 27 00 00 01 07 10 0F 73 00 00 00 288x224 ~ 288x224
-mystwarr: 01 7F 00 12 00 2E 00 00 01 07 11 0E 73 00 00 00 288x224 ~ 288x224
-metamrph: 01 7F 00 11 00 27 01 00 01 07 10 0F 74 00 00 00 288x224 ~ 288x224
-viostorm: 01 FF 00 16 00 39 00 00 01 07 11 0E 75 00 00 00 384x224 ~ 385x224
-mtlchamp: 01 FF 00 21 00 37 00 00 01 07 11 0E 74 00 00 00 384x224 ~ 384x224
-dbz: 01 FF 00 21 00 37 00 00 01 20 0C 0E 54 00 00 00 384x256 ~ 384x256
-dbz2: 01 FF 00 21 00 37 00 00 01 20 0C 0E 54 00 00 00 384x256 ~ 384x256
-xexex: 01 FF 00 21 00 37 01 00 00 20 0C 0E 54 00 00 00 384x256 ~ 384x256 (*)
-(all konamigx, cowboys of moo mesa, run & gun, dj main)
-
-(*) hcount total 512 (0x200), hdisp 384 (0x180), vcount total 289 (0x121), vdisp 256 (0x100)
-
- Definitions from GX, look similar, all values big-endian, write-only:
-
- 0-1: bits 9-0: HC - Total horizontal count (-1) Hres ~ (HC+1) - HFP - HBP - 8*(HSW+1)
- 2-3: bits 8-0: HFP - HBlank front porch
- 4-5: bits 8-0: HBP - HBlank back porch
- 6 : bits 7-0: INT1EN
- 7 : bits 7-0: INT2EN
- 8-9: bits 8-0: VC - Total vertical count (-1) Vres ~ (VC+1) - VFP - (VBP+1) - (VSW+1)
- a : bits 7-0: VFP - VBlank front porch
- b : bits 7-0: VBP - VBlank back porch (-1) (?)
- c : bits 7-4: VSW - V-Sync Width
- c : bits 3-0: HSW - H-Sync Width
- d : bits 7-0: INT-TIME
- e : bits 7-0: INT1ACK
- f : bits 7-0: INT2ACK
-
- Read-only:
- e-f: bits 8-0: VCT
-
-TODO:
-- xexex sets up 0x20 as the VC? default value?
-- xexex layers are offsetted if you try to use the CCU
-- according to p.14-15 both HBP and VBP have +1 added, but to get correct visible areas you have to add it only to VBP
-- understand how to interpret the back / front porch values, and remove the offset x/y hack
-- dual screen support (for Konami GX types 3/4)
-- viostorm and dbz reads the VCT port, but their usage is a side effect to send an irq ack thru the same port:
- i.e. first one uses move.b $26001d.l, $26001d.l, second one clr.b
-
-***************************************************************************************************************************/
-
-
-#include "emu.h"
-#include "k053252.h"
-
-
-const device_type K053252 = &device_creator<k053252_device>;
-
-k053252_device::k053252_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, K053252, "K053252 Timing/Interrupt", tag, owner, clock, "k053252", __FILE__),
- device_video_interface(mconfig, *this),
- m_int1_en_cb(*this),
- m_int2_en_cb(*this),
- m_int1_ack_cb(*this),
- m_int2_ack_cb(*this),
- //m_int_time_cb(*this),
- m_offsx(0),
- m_offsy(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void k053252_device::device_start()
-{
- m_int1_en_cb.resolve_safe();
- m_int2_en_cb.resolve_safe();
- m_int1_ack_cb.resolve_safe();
- m_int2_ack_cb.resolve_safe();
- //m_int_time_cb.resolve_safe();
-
- save_item(NAME(m_regs));
- save_item(NAME(m_hc));
- save_item(NAME(m_hfp));
- save_item(NAME(m_hbp));
- save_item(NAME(m_vc));
- save_item(NAME(m_vfp));
- save_item(NAME(m_vbp));
- save_item(NAME(m_vsw));
- save_item(NAME(m_hsw));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void k053252_device::device_reset()
-{
- int i;
-
- for (i = 0; i < 16; i++)
- m_regs[i] = 0;
-
- m_regs[0x08] = 1; // Xexex apparently does a wrong assignment for VC (sets up the INT enable register instead)
-
- m_hc=0;
- m_hfp=0;
- m_hbp=0;
- m_vc=0;
- m_vfp=0;
- m_vbp=0;
- m_vsw=0;
- m_hsw=0;
-}
-
-
-/*****************************************************************************
- DEVICE HANDLERS
-*****************************************************************************/
-
-READ8_MEMBER( k053252_device::read )
-{
- //TODO: debugger_access()
- switch(offset)
- {
- /* VCT read-back (TODO: values not extensively tested) */
- case 0x0e:
- return (m_screen->vpos() >> 8) & 1;
- case 0x0f:
- return m_screen->vpos() & 0xff;
- default:
- //popmessage("Warning: k053252 read %02x, contact MAMEdev",offset);
- break;
- }
-
- return m_regs[offset];
-}
-
-void k053252_device::res_change()
-{
- if(m_hc && m_vc &&
- m_hbp && m_hfp &&
- m_vbp && m_vfp &&
- m_hsw && m_vsw) //safety checks
- {
- rectangle visarea;
- //(HC+1) - HFP - HBP - 8*(HSW+1)
- //VC - VFP - VBP - (VSW+1)
- attoseconds_t refresh = HZ_TO_ATTOSECONDS(clock()) * (m_hc) * m_vc;
-
- //printf("H %d %d %d %d\n",m_hc,m_hfp,m_hbp,m_hsw);
- //printf("V %d %d %d %d\n",m_vc,m_vfp,m_vbp,m_vsw);
-
- visarea.min_x = m_offsx;
- visarea.min_y = m_offsy;
- visarea.max_x = m_offsx + m_hc - m_hfp - m_hbp - 8*(m_hsw) - 1;
- visarea.max_y = m_offsy + m_vc - m_vfp - m_vbp - (m_vsw) - 1;
-
- m_screen->configure(m_hc, m_vc, visarea, refresh);
- }
-}
-
-WRITE8_MEMBER( k053252_device::write )
-{
- m_regs[offset] = data;
-
- switch(offset)
- {
- case 0x00:
- case 0x01:
- m_hc = (m_regs[1]&0xff);
- m_hc |= ((m_regs[0]&0x03)<<8);
- m_hc++;
- logerror("%d (%04x) HC set\n",m_hc,m_hc);
- res_change();
- break;
- case 0x02:
- case 0x03:
- m_hfp = (m_regs[3]&0xff);
- m_hfp |= ((m_regs[2]&0x01)<<8);
- logerror("%d (%04x) HFP set\n",m_hfp,m_hfp);
- res_change();
- break;
- case 0x04:
- case 0x05:
- m_hbp = (m_regs[5]&0xff);
- m_hbp |= ((m_regs[4]&0x01)<<8);
- logerror("%d (%04x) HBP set\n",m_hbp,m_hbp);
- res_change();
- break;
- case 0x06: m_int1_en_cb(data); break;
- case 0x07: m_int2_en_cb(data); break;
- case 0x08:
- case 0x09:
- m_vc = (m_regs[9]&0xff);
- m_vc |= ((m_regs[8]&0x01)<<8);
- m_vc++;
- logerror("%d (%04x) VC set\n",m_vc,m_vc);
- res_change();
- break;
- case 0x0a:
- m_vfp = (m_regs[0x0a]&0xff);
- logerror("%d (%04x) VFP set\n",m_vfp,m_vfp);
- res_change();
- break;
- case 0x0b:
- m_vbp = (m_regs[0x0b]&0xff);
- m_vbp++;
- logerror("%d (%04x) VBP set\n",m_vbp,m_vbp);
- res_change();
- break;
- case 0x0c:
- m_vsw = ((m_regs[0x0c]&0xf0) >> 4) + 1;
- m_hsw = ((m_regs[0x0c]&0x0f) >> 0) + 1;
- logerror("%02x VSW / %02x HSW set\n",m_vsw,m_hsw);
- res_change();
- break;
- //case 0x0d: m_int_time(data); break;
- case 0x0e: m_int1_ack_cb(1); break;
- case 0x0f: m_int2_ack_cb(1); break;
- }
-}
diff --git a/src/emu/machine/k053252.h b/src/emu/machine/k053252.h
deleted file mode 100644
index 79bfe9fa7a4..00000000000
--- a/src/emu/machine/k053252.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:Angelo Salese
-/** Konami 053252 **/
-/* CRT and interrupt control unit */
-#pragma once
-
-#ifndef __K053252_H__
-#define __K053252_H__
-
-
-#define MCFG_K053252_INT1_EN_CB(_devcb) \
- devcb = &k053252_device::set_int1_en_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_K053252_INT2_EN_CB(_devcb) \
- devcb = &k053252_device::set_int2_en_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_K053252_INT1_ACK_CB(_devcb) \
- devcb = &k053252_device::set_int1_ack_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_K053252_INT2_ACK_CB(_devcb) \
- devcb = &k053252_device::set_int2_ack_callback(*device, DEVCB_##_devcb);
-
-/*#define MCFG_K053252_INT_TIME_CB(_devcb) \
- devcb = &k053252_device::set_int_time_callback(*device, DEVCB_##_devcb); */
-
-#define MCFG_K053252_OFFSETS(_offsx, _offsy) \
- k053252_device::set_offsets(*device, _offsx, _offsy);
-
-
-class k053252_device : public device_t,
- public device_video_interface
-{
-public:
- k053252_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~k053252_device() {}
-
- template<class _Object> static devcb_base &set_int1_en_callback(device_t &device, _Object object) { return downcast<k053252_device &>(device).m_int1_en_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_int2_en_callback(device_t &device, _Object object) { return downcast<k053252_device &>(device).m_int2_en_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_int1_ack_callback(device_t &device, _Object object) { return downcast<k053252_device &>(device).m_int1_ack_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_int2_ack_callback(device_t &device, _Object object) { return downcast<k053252_device &>(device).m_int2_ack_cb.set_callback(object); }
- //template<class _Object> static devcb_base &set_int_time_callback(device_t &device, _Object object) { return downcast<k053252_device &>(device).m_int_time_cb.set_callback(object); }
- static void set_offsets(device_t &device, int offsx, int offsy) { downcast<k053252_device &>(device).m_offsx = offsx; downcast<k053252_device &>(device).m_offsy = offsy;}
-
- DECLARE_READ8_MEMBER( read ); // CCU registers
- DECLARE_WRITE8_MEMBER( write );
-
- void res_change();
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- private:
- // internal state
- UINT8 m_regs[16];
- UINT16 m_hc,m_hfp,m_hbp;
- UINT16 m_vc,m_vfp,m_vbp;
- UINT8 m_vsw,m_hsw;
-
- devcb_write_line m_int1_en_cb;
- devcb_write_line m_int2_en_cb;
- devcb_write_line m_int1_ack_cb;
- devcb_write_line m_int2_ack_cb;
-// devcb_write8 m_int_time_cb;
- int m_offsx;
- int m_offsy;
-};
-
-extern const device_type K053252;
-
-
-#endif /* __K033906_H__ */
diff --git a/src/emu/machine/k056230.c b/src/emu/machine/k056230.c
deleted file mode 100644
index 8d750b66a8a..00000000000
--- a/src/emu/machine/k056230.c
+++ /dev/null
@@ -1,112 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Fabio Priuli
-/***************************************************************************
-
- Konami IC 056230 (LANC)
-
-***************************************************************************/
-
-#include "emu.h"
-#include "k056230.h"
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type K056230 = &device_creator<k056230_device>;
-
-//-------------------------------------------------
-// k056230_device - constructor
-//-------------------------------------------------
-
-k056230_device::k056230_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, K056230, "K056230 LANC", tag, owner, clock, "k056230", __FILE__),
- m_is_thunderh(0),
- m_cpu(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void k056230_device::device_start()
-{
- save_item(NAME(m_ram));
-}
-
-
-READ8_MEMBER(k056230_device::read)
-{
- switch (offset)
- {
- case 0: // Status register
- {
- return 0x08;
- }
- }
-
-// osd_printf_debug("k056230_r: %d at %08X\n", offset, space.device().safe_pc());
-
- return 0;
-}
-
-TIMER_CALLBACK( k056230_device::network_irq_clear_callback )
-{
- reinterpret_cast<k056230_device*>(ptr)->network_irq_clear();
-}
-
-void k056230_device::network_irq_clear()
-{
- if (m_cpu)
- m_cpu->set_input_line(INPUT_LINE_IRQ2, CLEAR_LINE);
-}
-
-
-WRITE8_MEMBER(k056230_device::write)
-{
- switch(offset)
- {
- case 0: // Mode register
- {
- break;
- }
- case 1: // Control register
- {
- if(data & 0x20)
- {
- // Thunder Hurricane breaks otherwise...
- if (!m_is_thunderh)
- {
- if (m_cpu)
- m_cpu->set_input_line(INPUT_LINE_IRQ2, ASSERT_LINE);
-
- machine().scheduler().timer_set(attotime::from_usec(10), FUNC(network_irq_clear_callback), 0, (void*)this);
- }
- }
-// else
-// m_cpu->set_input_line(INPUT_LINE_IRQ2, CLEAR_LINE);
- break;
- }
- case 2: // Sub ID register
- {
- break;
- }
- }
-// osd_printf_debug("k056230_w: %d, %02X at %08X\n", offset, data, space.device().safe_pc());
-}
-
-READ32_MEMBER(k056230_device::lanc_ram_r)
-{
- //osd_printf_debug("LANC_RAM_r: %08X, %08X at %08X\n", offset, mem_mask, space.device().safe_pc());
- return m_ram[offset & 0x7ff];
-}
-
-WRITE32_MEMBER(k056230_device::lanc_ram_w)
-{
- //osd_printf_debug("LANC_RAM_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, space.device().safe_pc());
- COMBINE_DATA(m_ram + (offset & 0x7ff));
-}
diff --git a/src/emu/machine/k056230.h b/src/emu/machine/k056230.h
deleted file mode 100644
index d8ec4a70ebc..00000000000
--- a/src/emu/machine/k056230.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Fabio Priuli
-/***************************************************************************
-
- Konami 056230
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __K056230_H__
-#define __K056230_H__
-
-#include "emu.h"
-
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_K056230_CPU(_tag) \
- k056230_device::set_cpu_tag(*device, "^" _tag);
-
-#define MCFG_K056230_HACK(_region) \
- k056230_device::set_thunderh_hack(*device, _region);
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-// ======================> k056230_device
-
-class k056230_device : public device_t
-{
-public:
- // construction/destruction
- k056230_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void set_cpu_tag(device_t &device, const char *tag) { downcast<k056230_device &>(device).m_cpu.set_tag(tag); }
- static void set_thunderh_hack(device_t &device, int thunderh) { downcast<k056230_device &>(device).m_is_thunderh = thunderh; }
-
- DECLARE_READ32_MEMBER(lanc_ram_r);
- DECLARE_WRITE32_MEMBER(lanc_ram_w);
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- static TIMER_CALLBACK( network_irq_clear_callback );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset() { }
- virtual void device_post_load() { }
- virtual void device_clock_changed() { }
-
-private:
-
- void network_irq_clear();
- int m_is_thunderh;
-
- required_device<cpu_device> m_cpu;
- UINT32 m_ram[0x2000];
-};
-
-
-// device type definition
-extern const device_type K056230;
-
-#endif /* __K056230_H__ */
diff --git a/src/emu/machine/kb3600.c b/src/emu/machine/kb3600.c
deleted file mode 100644
index f83ba9c46d8..00000000000
--- a/src/emu/machine/kb3600.c
+++ /dev/null
@@ -1,201 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/**********************************************************************
-
- General Instruments AY-5-3600 Keyboard Encoder emulation
-
-*********************************************************************/
-
-/*
-
- TODO:
-
- - scan timer clock frequency
- - more accurate emulation of real chip
-
-*/
-
-#include "kb3600.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// devices
-const device_type AY3600 = &device_creator<ay3600_device>;
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// ay3600_device - constructor
-//-------------------------------------------------
-
-ay3600_device::ay3600_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, AY3600, "AY-5-3600", tag, owner, clock, "ay3600", __FILE__),
- m_read_x0(*this),
- m_read_x1(*this),
- m_read_x2(*this),
- m_read_x3(*this),
- m_read_x4(*this),
- m_read_x5(*this),
- m_read_x6(*this),
- m_read_x7(*this),
- m_read_x8(*this),
- m_read_shift(*this),
- m_read_control(*this),
- m_write_data_ready(*this),
- m_write_ako(*this)
-{
- for (int i = 0; i < 9; i++)
- {
- m_x_mask[i] = 0;
- }
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ay3600_device::device_start()
-{
- // resolve callbacks
- m_read_x0.resolve_safe(0);
- m_read_x1.resolve_safe(0);
- m_read_x2.resolve_safe(0);
- m_read_x3.resolve_safe(0);
- m_read_x4.resolve_safe(0);
- m_read_x5.resolve_safe(0);
- m_read_x6.resolve_safe(0);
- m_read_x7.resolve_safe(0);
- m_read_x8.resolve_safe(0);
- m_read_shift.resolve_safe(0);
- m_read_control.resolve_safe(0);
- m_write_data_ready.resolve_safe();
- m_write_ako.resolve_safe();
-
- // allocate timers
- m_scan_timer = timer_alloc();
- m_scan_timer->adjust(attotime::from_hz(60), 0, attotime::from_hz(60));
-
- m_ako = 0;
-
- // state saving
- save_item(NAME(m_b));
- save_item(NAME(m_ako));
- save_item(NAME(m_x_mask));
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific reset
-//-------------------------------------------------
-
-void ay3600_device::device_reset()
-{
-}
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void ay3600_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- int ako = 0;
-
- for (int x = 0; x < 9; x++)
- {
- UINT16 data = 0;
-
- switch(x)
- {
- case 0: data = m_read_x0(); break;
- case 1: data = m_read_x1(); break;
- case 2: data = m_read_x2(); break;
- case 3: data = m_read_x3(); break;
- case 4: data = m_read_x4(); break;
- case 5: data = m_read_x5(); break;
- case 6: data = m_read_x6(); break;
- case 7: data = m_read_x7(); break;
- case 8: data = m_read_x8(); break;
- }
-
- for (int y = 0; y < 10; y++)
- {
- int b = (x * 10) + y;
-
- if (b > 63)
- {
- b -= 64;
- b = 0x100 | b;
- }
-
- b |= (m_read_shift() << 6);
- b |= (m_read_control() << 7);
-
- if (BIT(data, y))
- {
- ako = 1;
-
- if (!(m_x_mask[x] & (1 << y)))
- {
- m_x_mask[x] |= (1 << y);
-
- if (m_b != b)
- {
- m_b = b;
-
- m_write_data_ready(1);
-
- if (ako != m_ako)
- {
- m_write_ako(ako);
- m_ako = ako;
- }
- return;
- }
- }
- }
- else // key released, unmark it from the "down" info
- {
- m_x_mask[x] &= ~(1 << y);
- }
- }
- }
-
- if (!ako)
- {
- m_b = -1;
- }
-
- if (ako != m_ako)
- {
- m_write_ako(ako);
- m_ako = ako;
- }
-}
-
-
-//-------------------------------------------------
-// b_r -
-//-------------------------------------------------
-
-UINT16 ay3600_device::b_r()
-{
- UINT16 data = m_b;
-
- m_write_data_ready(0);
-
- return data;
-}
diff --git a/src/emu/machine/kb3600.h b/src/emu/machine/kb3600.h
deleted file mode 100644
index 57a42c906fb..00000000000
--- a/src/emu/machine/kb3600.h
+++ /dev/null
@@ -1,151 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/**********************************************************************
-
- General Instruments AY-5-3600 Keyboard Encoder emulation
-
-**********************************************************************
- _____ _____
- 1 |* \_/ | 40 X0
- 2 | | 39 X1
- 3 | | 38 X2
- 4 | | 37 X3
- 5 | | 36 X4
- B9 6 | | 35 X5
- B8 7 | | 34 X6
- B7 8 | | 33 X7
- B6 9 | | 32 X8
- B5 10 | AY-5-3600 | 31 DELAY NODE
- B4 11 | | 30 Vcc
- B3 12 | | 29 SHIFT
- B2 13 | | 28 CONTROL
- B1 14 | | 27 Vgg
- Vdd 15 | | 26 Y9
- DATA READY 16 | | 25 Y8
- Y0 17 | | 24 Y7
- Y1 18 | | 23 Y6
- Y2 19 | | 22 Y5
- Y3 20 |_____________| 21 Y4
-
- _____ _____
- Vcc 1 |* \_/ | 40 Vss
- B9 2 | | 39 Vgg
- B8 3 | | 38 _STCL?
- B7 4 | | 37 _MCLR
- TEST 5 | | 36 OSC
- B6 6 | | 35 CLK OUT
- B5 7 | | 34 X7
- B4 8 | | 33 X6
- B3 9 | | 32 X5
- B2 10 | AY-5-3600 | 31 X4
- B1 11 | PRO 002 | 30 X3
- X8 12 | | 29 X2
- AKO 13 | | 28 X1
- CTRL 14 | | 27 X0
- SHIFT 15 | | 26 Y9
- DATA READY 16 | | 25 Y8
- Y0 17 | | 24 Y7
- Y1 18 | | 23 Y6
- Y2 19 | | 22 Y5
- Y3 20 |_____________| 21 Y4
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __AY3600__
-#define __AY3600__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_AY3600_MATRIX_X0(_cb) \
- devcb = &ay3600_device::set_x0_cb(*device, DEVCB_##_cb);
-#define MCFG_AY3600_MATRIX_X1(_cb) \
- devcb = &ay3600_device::set_x1_cb(*device, DEVCB_##_cb);
-#define MCFG_AY3600_MATRIX_X2(_cb) \
- devcb = &ay3600_device::set_x2_cb(*device, DEVCB_##_cb);
-#define MCFG_AY3600_MATRIX_X3(_cb) \
- devcb = &ay3600_device::set_x3_cb(*device, DEVCB_##_cb);
-#define MCFG_AY3600_MATRIX_X4(_cb) \
- devcb = &ay3600_device::set_x4_cb(*device, DEVCB_##_cb);
-#define MCFG_AY3600_MATRIX_X5(_cb) \
- devcb = &ay3600_device::set_x5_cb(*device, DEVCB_##_cb);
-#define MCFG_AY3600_MATRIX_X6(_cb) \
- devcb = &ay3600_device::set_x6_cb(*device, DEVCB_##_cb);
-#define MCFG_AY3600_MATRIX_X7(_cb) \
- devcb = &ay3600_device::set_x7_cb(*device, DEVCB_##_cb);
-#define MCFG_AY3600_MATRIX_X8(_cb) \
- devcb = &ay3600_device::set_x8_cb(*device, DEVCB_##_cb);
-#define MCFG_AY3600_SHIFT_CB(_cb) \
- devcb = &ay3600_device::set_shift_cb(*device, DEVCB_##_cb);
-#define MCFG_AY3600_CONTROL_CB(_cb) \
- devcb = &ay3600_device::set_control_cb(*device, DEVCB_##_cb);
-#define MCFG_AY3600_DATA_READY_CB(_cb) \
- devcb = &ay3600_device::set_data_ready_cb(*device, DEVCB_##_cb);
-#define MCFG_AY3600_AKO_CB(_cb) \
- devcb = &ay3600_device::set_ako_cb(*device, DEVCB_##_cb);
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> ay3600_device
-
-class ay3600_device : public device_t
-{
-public:
- // construction/destruction
- ay3600_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // public interface
- UINT16 b_r();
-
- template<class _Object> static devcb_base &set_x0_cb(device_t &device, _Object rd) { return downcast<ay3600_device &>(device).m_read_x0.set_callback(rd); }
- template<class _Object> static devcb_base &set_x1_cb(device_t &device, _Object rd) { return downcast<ay3600_device &>(device).m_read_x1.set_callback(rd); }
- template<class _Object> static devcb_base &set_x2_cb(device_t &device, _Object rd) { return downcast<ay3600_device &>(device).m_read_x2.set_callback(rd); }
- template<class _Object> static devcb_base &set_x3_cb(device_t &device, _Object rd) { return downcast<ay3600_device &>(device).m_read_x3.set_callback(rd); }
- template<class _Object> static devcb_base &set_x4_cb(device_t &device, _Object rd) { return downcast<ay3600_device &>(device).m_read_x4.set_callback(rd); }
- template<class _Object> static devcb_base &set_x5_cb(device_t &device, _Object rd) { return downcast<ay3600_device &>(device).m_read_x5.set_callback(rd); }
- template<class _Object> static devcb_base &set_x6_cb(device_t &device, _Object rd) { return downcast<ay3600_device &>(device).m_read_x6.set_callback(rd); }
- template<class _Object> static devcb_base &set_x7_cb(device_t &device, _Object rd) { return downcast<ay3600_device &>(device).m_read_x7.set_callback(rd); }
- template<class _Object> static devcb_base &set_x8_cb(device_t &device, _Object rd) { return downcast<ay3600_device &>(device).m_read_x8.set_callback(rd); }
- template<class _Object> static devcb_base &set_shift_cb(device_t &device, _Object rd) { return downcast<ay3600_device &>(device).m_read_shift.set_callback(rd); }
- template<class _Object> static devcb_base &set_control_cb(device_t &device, _Object rd) { return downcast<ay3600_device &>(device).m_read_control.set_callback(rd); }
- template<class _Object> static devcb_base &set_data_ready_cb(device_t &device, _Object wr) { return downcast<ay3600_device &>(device).m_write_data_ready.set_callback(wr); }
- template<class _Object> static devcb_base &set_ako_cb(device_t &device, _Object wr) { return downcast<ay3600_device &>(device).m_write_ako.set_callback(wr); }
-
- devcb_read16 m_read_x0, m_read_x1, m_read_x2, m_read_x3, m_read_x4, m_read_x5, m_read_x6, m_read_x7, m_read_x8;
- devcb_read_line m_read_shift, m_read_control;
- devcb_write_line m_write_data_ready, m_write_ako;
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- static const int MAX_KEYS_DOWN = 4;
-
- int m_b; // output buffer
- int m_ako; // any key down
-
- int m_x_mask[9]; // mask of what keys are down
-
- // timers
- emu_timer *m_scan_timer; // keyboard scan timer
-};
-
-
-// device type definition
-extern const device_type AY3600;
-
-
-
-#endif
diff --git a/src/emu/machine/keyboard.c b/src/emu/machine/keyboard.c
deleted file mode 100644
index 03d538f2a3e..00000000000
--- a/src/emu/machine/keyboard.c
+++ /dev/null
@@ -1,395 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-Generic ASCII Keyboard
-
-Use GENERIC_KEYBOARD to attach as a generic ascii input device in
-cases where either the driver isn't developed enough yet; or for testing;
-or for the case of a computer with an inbuilt (not serial) ascii keyboard.
-
-Example of usage in a driver.
-
-In MACHINE_CONFIG
-
- MCFG_DEVICE_ADD(KEYBOARD_TAG, GENERIC_KEYBOARD, 0)
- MCFG_GENERIC_KEYBOARD_CB(WRITE8(xxx_state, kbd_put))
-
-In the code:
-
-WRITE8_MEMBER( xxx_state::kbd_put )
-{
- (code to capture the key as it is pressed)
- (if your machine uses function keys, add your conversion code here)
-}
-
-***************************************************************************/
-
-#include "machine/keyboard.h"
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-
-generic_keyboard_device::generic_keyboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_io_kbd0(*this, "TERM_LINE0"),
- m_io_kbd1(*this, "TERM_LINE1"),
- m_io_kbd2(*this, "TERM_LINE2"),
- m_io_kbd3(*this, "TERM_LINE3"),
- m_io_kbd4(*this, "TERM_LINE4"),
- m_io_kbd5(*this, "TERM_LINE5"),
- m_io_kbd6(*this, "TERM_LINE6"),
- m_io_kbd7(*this, "TERM_LINE7"),
- m_io_kbd8(*this, "TERM_LINE8"),
- m_io_kbd9(*this, "TERM_LINE9"),
- m_io_kbdc(*this, "TERM_LINEC"),
- m_keyboard_cb(*this)
-{
-}
-
-generic_keyboard_device::generic_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, GENERIC_KEYBOARD, "Generic Keyboard", tag, owner, clock, "generic_keyboard", __FILE__),
- m_io_kbd0(*this, "TERM_LINE0"),
- m_io_kbd1(*this, "TERM_LINE1"),
- m_io_kbd2(*this, "TERM_LINE2"),
- m_io_kbd3(*this, "TERM_LINE3"),
- m_io_kbd4(*this, "TERM_LINE4"),
- m_io_kbd5(*this, "TERM_LINE5"),
- m_io_kbd6(*this, "TERM_LINE6"),
- m_io_kbd7(*this, "TERM_LINE7"),
- m_io_kbd8(*this, "TERM_LINE8"),
- m_io_kbd9(*this, "TERM_LINE9"),
- m_io_kbdc(*this, "TERM_LINEC"),
- m_keyboard_cb(*this)
-{
-}
-
-
-UINT8 generic_keyboard_device::row_number(UINT8 code)
-{
- if BIT(code,0) return 0;
- if BIT(code,1) return 1;
- if BIT(code,2) return 2;
- if BIT(code,3) return 3;
- if BIT(code,4) return 4;
- if BIT(code,5) return 5;
- if BIT(code,6) return 6;
- if BIT(code,7) return 7;
- return 0;
-}
-
-UINT8 generic_keyboard_device::keyboard_handler(UINT8 last_code, UINT8 *scan_line)
-{
- int i;
- UINT8 code = 0;
- UINT8 key_code = 0;
- UINT8 retVal = 0;
- UINT8 shift = BIT(m_io_kbdc->read(), 1);
- UINT8 caps = BIT(m_io_kbdc->read(), 2);
- UINT8 ctrl = BIT(m_io_kbdc->read(), 0);
- i = *scan_line;
- {
- if (i == 0) code = m_io_kbd0->read();
- else
- if (i == 1) code = m_io_kbd1->read();
- else
- if (i == 2) code = m_io_kbd2->read();
- else
- if (i == 3) code = m_io_kbd3->read();
- else
- if (i == 4) code = m_io_kbd4->read();
- else
- if (i == 5) code = m_io_kbd5->read();
- else
- if (i == 6) code = m_io_kbd6->read();
- else
- if (i == 7) code = m_io_kbd7->read();
- else
- if (i == 8) code = m_io_kbd8->read();
- else
- if (i == 9) code = m_io_kbd9->read();
-
- if (code != 0)
- {
- if (i==0 && shift==0) {
- key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs
- }
- if (i==0 && shift==1) {
- key_code = 0x20 + row_number(code) + 8*i; // for shifted numbers
- }
- if (i==1 && shift==0) {
- if (row_number(code) < 4) {
- key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs
- } else {
- key_code = 0x20 + row_number(code) + 8*i; // for numbers and some signs
- }
- }
- if (i==1 && shift==1) {
- if (row_number(code) < 4) {
- key_code = 0x20 + row_number(code) + 8*i; // for numbers and some signs
- } else {
- key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs
- }
- }
- if (i>=2 && i<=4 && (shift ^ caps)==0 && ctrl==0) {
- key_code = 0x60 + row_number(code) + (i-2)*8; // for small letters
- }
- if (i>=2 && i<=4 && (shift ^ caps)==1 && ctrl==0) {
- key_code = 0x40 + row_number(code) + (i-2)*8; // for big letters
- }
- if (i>=2 && i<=5 && ctrl==1) {
- key_code = 0x00 + row_number(code) + (i-2)*8; // for CTRL + letters
- }
- if (i==5 && shift==1 && ctrl==0) {
- if (row_number(code)<7) {
- if (row_number(code)<3) {
- key_code = (caps ? 0x60 : 0x40) + row_number(code) + (i-2)*8; // for big letters
- } else {
- key_code = 0x60 + row_number(code) + (i-2)*8; // for upper symbols letters
- }
- } else {
- key_code = 0x40 + row_number(code) + (i-2)*8; // for DEL it is switched
- }
- }
- if (i==5 && shift==0 && ctrl==0) {
- if (row_number(code)<7) {
- if (row_number(code)<3) {
- key_code = (caps ? 0x40 : 0x60) + row_number(code) + (i-2)*8; // for small letters
- } else {
- key_code = 0x40 + row_number(code) + (i-2)*8; // for lower symbols letters
- }
- } else {
- key_code = 0x60 + row_number(code) + (i-2)*8; // for DEL it is switched
- }
- }
-
- if (i==6) {
- switch(row_number(code))
- {
-/* case 0: key_code = 0x11; break;
- case 1: key_code = 0x12; break;
- case 2: key_code = 0x13; break;
- case 3: key_code = 0x14; break;*/
- case 4: key_code = 0x20; break; // Space
- case 5: key_code = 0x0A; break; // LineFeed
- case 6: key_code = 0x09; break; // TAB
- case 7: key_code = 0x0D; break; // Enter
- }
- }
- if (i==7)
- {
- switch(row_number(code))
- {
- case 0: key_code = 0x1B; break; // Escape
- case 1: key_code = 0x08; break; // Backspace
- }
- }
- else
- if (i==8)
- {
- key_code = row_number(code)+0x81;
- if (ctrl) key_code+=0x10;
- if (shift) key_code+=0x20;
- }
- else
- if (i==9)
- {
- key_code = row_number(code)+0x89;
- if (ctrl) key_code+=0x10;
- if (shift) key_code+=0x20;
- }
-
- retVal = key_code;
- }
- else
- {
- *scan_line += 1;
- if (*scan_line==10)
- *scan_line = 0;
- }
- }
- return retVal;
-}
-
-void generic_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- UINT8 new_code;
- new_code = keyboard_handler(m_last_code, &m_scan_line);
- if ((m_last_code != new_code) && (new_code))
- send_key(new_code);
- m_last_code = new_code;
-}
-
-/***************************************************************************
- VIDEO HARDWARE
-***************************************************************************/
-
-static MACHINE_CONFIG_FRAGMENT( generic_keyboard )
-MACHINE_CONFIG_END
-
-machine_config_constructor generic_keyboard_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME(generic_keyboard);
-}
-
-void generic_keyboard_device::device_start()
-{
- m_keyboard_cb.resolve_safe();
- m_timer = timer_alloc();
- save_item(NAME(m_last_code));
- save_item(NAME(m_scan_line));
-}
-
-void generic_keyboard_device::device_reset()
-{
- m_last_code = 0;
- m_scan_line = 0;
- m_timer->adjust(attotime::from_hz(2400), 0, attotime::from_hz(2400));
-}
-
-/*
-Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex
--------------------------------------------------------------------------------------
-(nul) 0 0000 0x00 | (sp) 32 0040 0x20 | @ 64 0100 0x40 | ` 96 0140 0x60
-(soh) 1 0001 0x01 | ! 33 0041 0x21 | A 65 0101 0x41 | a 97 0141 0x61
-(stx) 2 0002 0x02 | " 34 0042 0x22 | B 66 0102 0x42 | b 98 0142 0x62
-(etx) 3 0003 0x03 | # 35 0043 0x23 | C 67 0103 0x43 | c 99 0143 0x63
-(eot) 4 0004 0x04 | $ 36 0044 0x24 | D 68 0104 0x44 | d 100 0144 0x64
-(enq) 5 0005 0x05 | % 37 0045 0x25 | E 69 0105 0x45 | e 101 0145 0x65
-(ack) 6 0006 0x06 | & 38 0046 0x26 | F 70 0106 0x46 | f 102 0146 0x66
-(bel) 7 0007 0x07 | ' 39 0047 0x27 | G 71 0107 0x47 | g 103 0147 0x67
-(bs) 8 0010 0x08 | ( 40 0050 0x28 | H 72 0110 0x48 | h 104 0150 0x68
-(ht) 9 0011 0x09 | ) 41 0051 0x29 | I 73 0111 0x49 | i 105 0151 0x69
-(nl) 10 0012 0x0a | * 42 0052 0x2a | J 74 0112 0x4a | j 106 0152 0x6a
-(vt) 11 0013 0x0b | + 43 0053 0x2b | K 75 0113 0x4b | k 107 0153 0x6b
-(np) 12 0014 0x0c | , 44 0054 0x2c | L 76 0114 0x4c | l 108 0154 0x6c
-(cr) 13 0015 0x0d | - 45 0055 0x2d | M 77 0115 0x4d | m 109 0155 0x6d
-(so) 14 0016 0x0e | . 46 0056 0x2e | N 78 0116 0x4e | n 110 0156 0x6e
-(si) 15 0017 0x0f | / 47 0057 0x2f | O 79 0117 0x4f | o 111 0157 0x6f
-(dle) 16 0020 0x10 | 0 48 0060 0x30 | P 80 0120 0x50 | p 112 0160 0x70
-(dc1) 17 0021 0x11 | 1 49 0061 0x31 | Q 81 0121 0x51 | q 113 0161 0x71
-(dc2) 18 0022 0x12 | 2 50 0062 0x32 | R 82 0122 0x52 | r 114 0162 0x72
-(dc3) 19 0023 0x13 | 3 51 0063 0x33 | S 83 0123 0x53 | s 115 0163 0x73
-(dc4) 20 0024 0x14 | 4 52 0064 0x34 | T 84 0124 0x54 | t 116 0164 0x74
-(nak) 21 0025 0x15 | 5 53 0065 0x35 | U 85 0125 0x55 | u 117 0165 0x75
-(syn) 22 0026 0x16 | 6 54 0066 0x36 | V 86 0126 0x56 | v 118 0166 0x76
-(etb) 23 0027 0x17 | 7 55 0067 0x37 | W 87 0127 0x57 | w 119 0167 0x77
-(can) 24 0030 0x18 | 8 56 0070 0x38 | X 88 0130 0x58 | x 120 0170 0x78
-(em) 25 0031 0x19 | 9 57 0071 0x39 | Y 89 0131 0x59 | y 121 0171 0x79
-(sub) 26 0032 0x1a | : 58 0072 0x3a | Z 90 0132 0x5a | z 122 0172 0x7a
-(esc) 27 0033 0x1b | ; 59 0073 0x3b | [ 91 0133 0x5b | { 123 0173 0x7b
-(fs) 28 0034 0x1c | < 60 0074 0x3c | \ 92 0134 0x5c | | 124 0174 0x7c
-(gs) 29 0035 0x1d | = 61 0075 0x3d | ] 93 0135 0x5d | } 125 0175 0x7d
-(rs) 30 0036 0x1e | > 62 0076 0x3e | ^ 94 0136 0x5e | ~ 126 0176 0x7e
-(us) 31 0037 0x1f | ? 63 0077 0x3f | _ 95 0137 0x5f | (del) 127 0177 0x7f
-
-*/
-INPUT_PORTS_START( generic_keyboard )
- PORT_START("TERM_LINEC")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Ctrl") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL)
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
- PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Caps Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
- PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_UNUSED)
- PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_UNUSED)
- PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_UNUSED)
- PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_UNUSED)
- PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED)
-
- PORT_START("TERM_LINE0")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0')
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
- PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"')
- PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
- PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
- PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
- PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
- PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'')
-
- PORT_START("TERM_LINE1")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(')
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')')
- PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*')
- PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+')
- PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
- PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=')
- PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
- PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
-
- PORT_START("TERM_LINE2")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_END) PORT_CHAR('`') PORT_CHAR('@')
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
- PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B')
- PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C')
- PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D')
- PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
- PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F')
- PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G')
-
- PORT_START("TERM_LINE3")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H')
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I')
- PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J')
- PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K')
- PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L')
- PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M')
- PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N')
- PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O')
-
- PORT_START("TERM_LINE4")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P')
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q')
- PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R')
- PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S')
- PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T')
- PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
- PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V')
- PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W')
-
- PORT_START("TERM_LINE5")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X')
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y')
- PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z')
- PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{')
- PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|')
- PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}')
- PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('^') PORT_CHAR('~')
- PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("DEL") PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL))
-
- PORT_START("TERM_LINE6")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
- PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Up") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
- PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Down") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
- PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
- PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("LF") PORT_CODE(KEYCODE_RALT) PORT_CHAR(10)
- PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR(9)
- PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
-
- PORT_START("TERM_LINE7")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Escape") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Backspace") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
-
- PORT_START("TERM_LINE8")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1))
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))
- PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
- PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4))
- PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5))
- PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6))
- PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7))
- PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8))
-
- PORT_START("TERM_LINE9")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F9") PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9))
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F10") PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10))
- PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F11") PORT_CODE(KEYCODE_F11) PORT_CHAR(UCHAR_MAMEKEY(F11))
- PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F12") PORT_CODE(KEYCODE_F12) PORT_CHAR(UCHAR_MAMEKEY(F12))
-INPUT_PORTS_END
-
-ioport_constructor generic_keyboard_device::device_input_ports() const
-{
- return INPUT_PORTS_NAME(generic_keyboard);
-}
-
-const device_type GENERIC_KEYBOARD = &device_creator<generic_keyboard_device>;
diff --git a/src/emu/machine/keyboard.h b/src/emu/machine/keyboard.h
deleted file mode 100644
index 8658cf3f92f..00000000000
--- a/src/emu/machine/keyboard.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#ifndef __KEYBOARD_H__
-#define __KEYBOARD_H__
-
-#include "emu.h"
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_GENERIC_KEYBOARD_CB(_devcb) \
- devcb = &generic_keyboard_device::set_keyboard_callback(*device, DEVCB_##_devcb);
-
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-
-INPUT_PORTS_EXTERN( generic_keyboard );
-
-class generic_keyboard_device : public device_t
-{
-public:
- generic_keyboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
- generic_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_keyboard_callback(device_t &device, _Object object) { return downcast<generic_keyboard_device &>(device).m_keyboard_cb.set_callback(object); }
-
- virtual ioport_constructor device_input_ports() const;
- virtual machine_config_constructor device_mconfig_additions() const;
-protected:
- required_ioport m_io_kbd0;
- required_ioport m_io_kbd1;
- required_ioport m_io_kbd2;
- required_ioport m_io_kbd3;
- required_ioport m_io_kbd4;
- required_ioport m_io_kbd5;
- required_ioport m_io_kbd6;
- required_ioport m_io_kbd7;
- required_ioport m_io_kbd8;
- required_ioport m_io_kbd9;
- required_ioport m_io_kbdc;
-
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual void send_key(UINT8 code) { m_keyboard_cb((offs_t)0, code); }
- emu_timer *m_timer;
-private:
- virtual UINT8 keyboard_handler(UINT8 last_code, UINT8 *scan_line);
- UINT8 row_number(UINT8 code);
- UINT8 m_last_code;
- UINT8 m_scan_line;
-
- devcb_write8 m_keyboard_cb;
-};
-
-extern const device_type GENERIC_KEYBOARD;
-
-#endif /* __KEYBOARD_H__ */
diff --git a/src/emu/machine/kr2376.c b/src/emu/machine/kr2376.c
deleted file mode 100644
index d818c52ce68..00000000000
--- a/src/emu/machine/kr2376.c
+++ /dev/null
@@ -1,350 +0,0 @@
-// license:???
-// copyright-holders:Roberto Lavarone
-/**********************************************************************
-
- SMC KR2376 Keyboard Encoder emulation
-
-**********************************************************************/
-
-#include "emu.h"
-#include "kr2376.h"
-
-static const UINT8 KR2376_KEY_CODES[3][8][11] =
-{
- // normal
- {
- // Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10
- // NUL SOH STX ETX EOT ENQ ACK BEL DC1 P O X0
- { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x11, 0x50, 0x30 }, // X0
- // DLE K L N M NAK SYN ETB CAN EM SUB X1
- { 0x10, 0x4b, 0x4c, 0x4e, 0x4d, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a }, // X1
- // - FS GS RS US < > , SP . _ X2
- { 0x2d, 0x1c, 0x1d, 0x1e, 0x1f, 0x3c, 0x3e, 0x2c, 0x20, 0x2e, 0x5f }, // X2
- // 0 : p _ @ BS [ ] CR LF DEL X3
- { 0x30, 0x3a, 0x70, 0x5f, 0x40, 0x08, 0x5B, 0x5d, 0x0d, 0x0a, 0x7f }, // X3
- { 0x3b, 0x2f, 0x2e, 0x2c, 0x6d, 0x6e, 0x62, 0x76, 0x63, 0x78, 0x7a }, // X4
- { 0x6c, 0x6b, 0x6a, 0x68, 0x67, 0x66, 0x64, 0x73, 0x61, 0x0c, 0x1b }, // X5
- { 0x6f, 0x69, 0x75, 0x79, 0x74, 0x72, 0x65, 0x77, 0x71, 0x09, 0x0b }, // X6
- { 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x5e, 0x5c } // X7
- },
-
- // shift
- {
- // Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10
- // NUL SOH STX ETX EOT ENQ ACK BEL DC1 @ _ X0
- { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x11, 0x40, 0x5f }, // X0
- // DLE [ \ ^ ] NAK SYN ETB CAN EM SUB X1
- { 0x10, 0x5b, 0x5c, 0x5e, 0x5d, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a }, // X1
- // = FS GS RS US < > , SP . _ X2
- { 0x3d, 0x1c, 0x1d, 0x1e, 0x1f, 0x3c, 0x3e, 0x2c, 0x20, 0x2e, 0x5f }, // X2
- // NUL * P DEL ` BS { } CR LF DEL X3
- { 0x00, 0x2a, 0x50, 0x7f, 0x60, 0x08, 0x7b, 0x7d, 0x0d, 0x0a, 0x7f }, // X3
- { 0x2b, 0x3f, 0x3e, 0x3c, 0x4d, 0x4e, 0x42, 0x56, 0x43, 0x58, 0x5a }, // X4
- { 0x4c, 0x4b, 0x4a, 0x48, 0x47, 0x46, 0x44, 0x53, 0x41, 0x0c, 0x1b }, // X5
- { 0x4f, 0x49, 0x55, 0x59, 0x54, 0x52, 0x45, 0x57, 0x51, 0x09, 0x0b }, // X6
- { 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x7e, 0x7c } // X7
- },
-
- // control
- {
- // Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10
- // NUL SOH STX ETX EOT ENQ ACK BEL DC1 DLE SI X0
- { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x11, 0x10, 0x0f }, // X0
- // DLE VT FF SO CR NAK SYN ETB CAN EM SUB X1
- { 0x10, 0x0b, 0x0c, 0x0e, 0x0d, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a }, // X1
- // NUL FS GS RS US NUL NUL NUL SP NUL US X2
- { 0x00, 0x1c, 0x1d, 0x1e, 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x1f }, // X2
- // NUL NUL DLE US NUL BS ESC GS CR LF DEL X3
- { 0x00, 0x00, 0x10, 0x1f, 0x00, 0x08, 0x1B, 0x1d, 0x0d, 0x0a, 0x7f }, // X3
- { 0x00, 0x00, 0x00, 0x00, 0x1d, 0x0e, 0x02, 0x16, 0x03, 0x18, 0x1a }, // X4
- { 0x0c, 0x0b, 0x0a, 0x08, 0x07, 0x06, 0x04, 0x13, 0x01, 0x0c, 0x1b }, // X5
- { 0x1f, 0x09, 0x15, 0x19, 0x14, 0x12, 0x05, 0x17, 0x11, 0x09, 0x0b }, // X6
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x1c } // X7
- }
-};
-
-
-const device_type KR2376 = &device_creator<kr2376_device>;
-
-kr2376_device::kr2376_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, KR2376, "SMC KR2376", tag, owner, clock, "kr2376", __FILE__),
- m_write_strobe(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void kr2376_device::device_start()
-{
- m_write_strobe.resolve_safe();
-
- /* set initial values */
- m_ring11 = 0;
- m_ring8 = 0;
- m_modifiers = 0;
- m_strobe = 0;
- m_strobe_old = 0;
- m_parity = 0;
- m_data = 0;
- memset(m_pins, 0x00, sizeof(m_pins));
- change_output_lines();
-
- /* create the timers */
- m_scan_timer = timer_alloc(TIMER_SCAN_TICK);
- m_scan_timer->adjust(attotime::zero, 0, attotime::from_hz(clock()));
-
- /* register for state saving */
- save_item(NAME(m_pins));
- save_item(NAME(m_ring11));
- save_item(NAME(m_ring8));
- save_item(NAME(m_modifiers));
- save_item(NAME(m_strobe));
- save_item(NAME(m_strobe_old));
- save_item(NAME(m_parity));
- save_item(NAME(m_data));
-}
-
-/*-------------------------------------------------
- set_input_pin - set an input pin
--------------------------------------------------*/
-void kr2376_device::set_input_pin( kr2376_input_pin_t pin, int data )
-{
- data = data ? 1 : 0;
- switch ( pin )
- {
- case KR2376_PII:
- case KR2376_DSII:
- m_pins[pin] = data;
- break;
- }
-}
-
-
-/*-------------------------------------------------
- get_output_pin - get the status of an output pin
--------------------------------------------------*/
-int kr2376_device::get_output_pin( kr2376_output_pin_t pin )
-{
- return m_pins[pin];
-}
-
-
-void kr2376_device::change_output_lines()
-{
- if (m_strobe != m_strobe_old)
- {
- m_strobe_old = m_strobe;
-
- if (m_strobe) // strobe 0 --> 1 transition
- {
- /* update parity */
- m_pins[KR2376_PO] = m_parity ^ m_pins[KR2376_PII];
- }
- m_pins[KR2376_SO] = m_strobe ^ m_pins[KR2376_DSII];
- m_write_strobe(m_strobe ^ m_pins[KR2376_DSII]);
- }
-}
-
-void kr2376_device::clock_scan_counters()
-{
- /* ring counters inhibited while strobe active */
- if (!m_strobe)
- {
- m_ring11++;
- if (m_ring11 == 11)
- {
- m_ring11 = 0;
- m_ring8++;
- if (m_ring8 == 8)
- m_ring8 = 0;
- }
- }
-}
-
-void kr2376_device::detect_keypress()
-{
- static const char *const keynames[] = { "X0", "X1", "X2", "X3", "X4", "X5", "X6", "X7" };
-
- if (ioport(keynames[m_ring8])->read() == (1 << m_ring11))
- {
- m_modifiers = ioport("MODIFIERS")->read();
-
- m_strobe = 1;
- /* strobe 0->1 transition, encode char and update parity */
- if (!m_strobe_old)
- {
- int i;
- int parbit;
- int shift = BIT(m_modifiers, 0);
- int control = BIT(m_modifiers, 1);
- int alpha = BIT(m_modifiers, 2);
- int table = 0;
-
- if (shift || alpha)
- table = 1;
- else if (control)
- table = 2;
-
- m_data = KR2376_KEY_CODES[table][m_ring8][m_ring11];
-
- /* Compute ODD parity */
- m_parity = m_data;
- parbit = 0;
- for (i=0; i<8; i++)
- parbit ^= (m_parity >> i) & 1;
- m_parity = parbit;
- }
- }
- else
- {
- m_strobe = 0;
- }
-}
-
-void kr2376_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_SCAN_TICK:
- change_output_lines();
- clock_scan_counters();
- detect_keypress();
- break;
- }
-}
-
-/* Keyboard Data */
-
-READ8_MEMBER( kr2376_device::data_r )
-{
- if (m_pins[KR2376_DSII])
- return m_data ^ 0xff;
- else
- return m_data;
-}
-
-/* Input Ports */
-
-INPUT_PORTS_START( kr2376 )
- PORT_START("X0")
- PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_UNUSED )
-
- PORT_START("X1")
- PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_UNUSED )
-
-
- PORT_START("X2")
- PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=')
- PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
- PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CHAR('_')
-
- PORT_START("X3")
- PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0')
- PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':') PORT_CHAR('*')
- PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P')
- PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('`') PORT_CHAR('@')
- PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) PORT_NAME("Del")
- PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{')
- PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}')
- PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) PORT_NAME("CR")
- PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME)) PORT_CHAR(10) PORT_NAME("LF")
- PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_UNUSED )
-
- PORT_START("X4")
- PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+')
- PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
- PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
- PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
- PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M')
- PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N')
- PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B')
- PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V')
- PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C')
- PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X')
- PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z')
-
-
- PORT_START("X5")
- PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L')
- PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K')
- PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J')
- PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H')
- PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('c') PORT_CHAR('G')
- PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F')
- PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D')
- PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S')
- PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
- PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_UNUSED )
- PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
-
-
- PORT_START("X6")
- PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O')
- PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I')
- PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
- PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y')
- PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T')
- PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R')
- PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
- PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W')
- PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q')
-
- PORT_START("X7")
- PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')')
- PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(')
- PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'')
- PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
- PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
- PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
- PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
- PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"')
- PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
- PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('^') PORT_CHAR('~')
- PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|')
-
- PORT_START("MODIFIERS")
- PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
- PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL)) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL))
- PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
-INPUT_PORTS_END
-
-//-------------------------------------------------
-// input_ports - device-specific input ports
-//-------------------------------------------------
-
-ioport_constructor kr2376_device::device_input_ports() const
-{
- return INPUT_PORTS_NAME( kr2376 );
-}
diff --git a/src/emu/machine/kr2376.h b/src/emu/machine/kr2376.h
deleted file mode 100644
index e282362d761..00000000000
--- a/src/emu/machine/kr2376.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// license:???
-// copyright-holders:Roberto Lavarone
-/**********************************************************************
-
- SMC KR2376 Keyboard Encoder emulation
-
-**********************************************************************
- _____ _____
- Vcc 1 |* \_/ | 40 Frequency Control A
- Frequency Control B 2 | | 39 X0
- Frequency Control C 3 | | 38 X1
- Shift Input 4 | | 37 X2
- Control Input 5 | | 36 X3
- Parity Invert Input 6 | | 35 X4
- Parity Output 7 | | 34 X5
- Data Output B8 8 | | 33 X6
- Data Output B7 9 | | 32 X7
- Data Output B6 10 | KR2376 | 31 Y0
- Data Output B5 11 | | 30 Y1
- Data Output B4 12 | | 29 Y2
- Data Output B3 13 | | 28 Y3
- Data Output B2 14 | | 27 Y4
- Data Output B1 15 | | 26 Y5
- Strobe Output 16 | | 25 Y6
- Ground 17 | | 24 Y7
- Vgg 18 | | 23 Y8
- Strobe Control Input 19 | | 22 Y9
- Invert Input 20 |_____________| 21 Y10
-
-**********************************************************************/
-
-#ifndef __KR2376__
-#define __KR2376__
-
-
-#define MCFG_KR2376_STROBE_CALLBACK(_write) \
- devcb = &kr2376_device::set_strobe_wr_callback(*device, DEVCB_##_write);
-
-/*
- * Input pins
- */
-enum kr2376_input_pin_t
-{
- KR2376_DSII=20, /* DSII - Pin 20 - Data & Strobe Invert Input */
- KR2376_PII=6 /* PII - Pin 6 - Parity Invert Input */
-};
-
-enum kr2376_output_pin_t
-{
- KR2376_SO=16, /* SO - Pin 16 - Strobe Output */
- KR2376_PO=7 /* PO - Pin 7 - Parity Output */
-};
-
-class kr2376_device : public device_t
-{
-public:
- kr2376_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~kr2376_device() {}
-
- template<class _Object> static devcb_base &set_strobe_wr_callback(device_t &device, _Object object) { return downcast<kr2376_device &>(device).m_write_strobe.set_callback(object); }
-
- /* keyboard data */
- DECLARE_READ8_MEMBER( data_r );
-
- /* Set an input pin */
- void set_input_pin( kr2376_input_pin_t pin, int data );
-
- /* Get an output pin */
- int get_output_pin( kr2376_output_pin_t pin );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual ioport_constructor device_input_ports() const;
-
-private:
- // internal state
- int m_pins[41];
-
- int m_ring11; /* sense input scan counter */
- int m_ring8; /* drive output scan counter */
- int m_modifiers; /* modifier inputs */
-
- int m_strobe; /* strobe output */
- int m_strobe_old;
- int m_parity;
- int m_data;
-
- /* timers */
- emu_timer *m_scan_timer; /* keyboard scan timer */
- devcb_write_line m_write_strobe;
-
- enum
- {
- TIMER_SCAN_TICK
- };
-
- void change_output_lines();
- void clock_scan_counters();
- void detect_keypress();
-};
-
-extern const device_type KR2376;
-
-#endif
diff --git a/src/emu/machine/laserdsc.c b/src/emu/machine/laserdsc.c
deleted file mode 100644
index a027ac62271..00000000000
--- a/src/emu/machine/laserdsc.c
+++ /dev/null
@@ -1,1229 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- laserdsc.c
-
- Core laserdisc player implementation.
-
-*************************************************************************/
-
-#include "emu.h"
-#include "laserdsc.h"
-#include "avhuff.h"
-#include "vbiparse.h"
-#include "config.h"
-#include "render.h"
-#include "chd.h"
-
-
-
-//**************************************************************************
-// DEBUGGING
-//**************************************************************************
-
-#define LOG_SLIDER 0
-
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-// these specs code from IEC 60857, for NTSC players
-const UINT32 LEAD_IN_MIN_RADIUS_IN_UM = 53500; // 53.5 mm
-const UINT32 PROGRAM_MIN_RADIUS_IN_UM = 55000; // 55 mm
-const UINT32 PROGRAM_MAX_RADIUS_IN_UM = 145000; // 145 mm
-const UINT32 LEAD_OUT_MIN_SIZE_IN_UM = 2000; // 2 mm
-
-// the track pitch is defined as a range; we pick a nominal pitch
-// that ensures we can fit 54,000 tracks
-//const UINT32 MIN_TRACK_PITCH_IN_NM = 1400; // 1.4 um
-//const UINT32 MAX_TRACK_PITCH_IN_NM = 2000; // 2 um
-const UINT32 NOMINAL_TRACK_PITCH_IN_NM = (PROGRAM_MAX_RADIUS_IN_UM - PROGRAM_MIN_RADIUS_IN_UM) * 1000 / 54000;
-
-// we simulate extra lead-in and lead-out tracks
-const UINT32 VIRTUAL_LEAD_IN_TRACKS = (PROGRAM_MIN_RADIUS_IN_UM - LEAD_IN_MIN_RADIUS_IN_UM) * 1000 / NOMINAL_TRACK_PITCH_IN_NM;
-const UINT32 MAX_TOTAL_TRACKS = 54000;
-const UINT32 VIRTUAL_LEAD_OUT_TRACKS = LEAD_OUT_MIN_SIZE_IN_UM * 1000 / NOMINAL_TRACK_PITCH_IN_NM;
-
-
-
-//**************************************************************************
-// CORE IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// laserdisc_device - constructor
-//-------------------------------------------------
-
-laserdisc_device::laserdisc_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_sound_interface(mconfig, *this),
- device_video_interface(mconfig, *this),
- m_overwidth(0),
- m_overheight(0),
- m_overclip(0, -1, 0, -1),
- m_disc(NULL),
- m_width(0),
- m_height(0),
- m_fps_times_1million(0),
- m_samplerate(0),
- m_readresult(CHDERR_NONE),
- m_chdtracks(0),
- m_work_queue(osd_work_queue_alloc(WORK_QUEUE_FLAG_IO)),
- m_audiosquelch(0),
- m_videosquelch(0),
- m_fieldnum(0),
- m_curtrack(0),
- m_maxtrack(0),
- m_attospertrack(0),
- m_sliderupdate(attotime::zero),
- m_videoindex(0),
- m_stream(NULL),
- m_audiobufsize(0),
- m_audiobufin(0),
- m_audiobufout(0),
- m_audiocursamples(0),
- m_audiomaxsamples(0),
- m_videoenable(false),
- m_videotex(NULL),
- m_videopalette(NULL),
- m_overenable(false),
- m_overindex(0),
- m_overtex(NULL),
- m_overlay_palette(*this)
-{
- // initialize overlay_config
- m_orig_config.m_overposx = m_orig_config.m_overposy = 0.0f;
- m_orig_config.m_overscalex = m_orig_config.m_overscaley = 1.0f;
- *static_cast<laserdisc_overlay_config *>(this) = m_orig_config;
-}
-
-
-//-------------------------------------------------
-// ~laserdisc_device - destructor
-//-------------------------------------------------
-
-laserdisc_device::~laserdisc_device()
-{
- osd_work_queue_free(m_work_queue);
-}
-
-
-
-//**************************************************************************
-// PUBLIC INTERFACES
-//**************************************************************************
-
-//-------------------------------------------------
-// get_field_code - return raw field information
-// read from the disc
-//-------------------------------------------------
-
-UINT32 laserdisc_device::get_field_code(laserdisc_field_code code, bool zero_if_squelched)
-{
- // return nothing if the video is off (external devices can't sense)
- if (zero_if_squelched && m_videosquelch)
- return 0;
-
- switch (code)
- {
- case LASERDISC_CODE_WHITE_FLAG:
- return m_metadata[m_fieldnum].white;
-
- case LASERDISC_CODE_LINE16:
- return m_metadata[m_fieldnum].line16;
-
- case LASERDISC_CODE_LINE17:
- return m_metadata[m_fieldnum].line17;
-
- case LASERDISC_CODE_LINE18:
- return m_metadata[m_fieldnum].line18;
-
- case LASERDISC_CODE_LINE1718:
- return m_metadata[m_fieldnum].line1718;
- }
- return 0;
-}
-
-
-//-------------------------------------------------
-// screen_update - handle updating the screen
-//-------------------------------------------------
-
-UINT32 laserdisc_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
-{
- // handle the overlay if present
- screen_bitmap &overbitmap = m_overbitmap[m_overindex];
- if (overbitmap.valid() && (!m_overupdate_ind16.isnull() || !m_overupdate_rgb32.isnull()))
- {
- // scale the cliprect to the overlay size
- rectangle clip(m_overclip);
- clip.min_y = cliprect.min_y * overbitmap.height() / bitmap.height();
- if (cliprect.min_y == screen.visible_area().min_y)
- clip.min_y = MIN(clip.min_y, m_overclip.min_y);
- clip.max_y = (cliprect.max_y + 1) * overbitmap.height() / bitmap.height() - 1;
-
- // call the update callback
- if (!m_overupdate_ind16.isnull())
- m_overupdate_ind16(screen, overbitmap.as_ind16(), clip);
- else
- m_overupdate_rgb32(screen, overbitmap.as_rgb32(), clip);
- }
-
- // if this is the last update, do the rendering
- if (cliprect.max_y == screen.visible_area().max_y)
- {
- // update the texture with the overlay contents
- if (overbitmap.valid())
- m_overtex->set_bitmap(overbitmap, m_overclip, overbitmap.texformat());
-
- // get the laserdisc video
- bitmap_yuy16 &vidbitmap = get_video();
- m_videotex->set_bitmap(vidbitmap, vidbitmap.cliprect(), TEXFORMAT_YUY16);
-
- // reset the screen contents
- screen.container().empty();
-
- // add the video texture
- if (m_videoenable)
- screen.container().add_quad(0.0f, 0.0f, 1.0f, 1.0f, rgb_t(0xff,0xff,0xff,0xff), m_videotex, PRIMFLAG_BLENDMODE(BLENDMODE_NONE) | PRIMFLAG_SCREENTEX(1));
-
- // add the overlay
- if (m_overenable && overbitmap.valid())
- {
- float x0 = 0.5f - 0.5f * m_overscalex + m_overposx;
- float y0 = 0.5f - 0.5f * m_overscaley + m_overposy;
- float x1 = x0 + m_overscalex;
- float y1 = y0 + m_overscaley;
- screen.container().add_quad(x0, y0, x1, y1, rgb_t(0xff,0xff,0xff,0xff), m_overtex, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_SCREENTEX(1));
- }
-
- // swap to the next bitmap
- m_overindex = (m_overindex + 1) % ARRAY_LENGTH(m_overbitmap);
- }
- return 0;
-}
-
-
-//-------------------------------------------------
-// static_set_get_disc - set the get disc
-// delegate
-//-------------------------------------------------
-
-void laserdisc_device::static_set_get_disc(device_t &device, laserdisc_get_disc_delegate callback)
-{
- downcast<laserdisc_device &>(device).m_getdisc_callback = callback;
-}
-
-
-//-------------------------------------------------
-// static_set_get_disc - set the audio interceptor
-// delegate
-//-------------------------------------------------
-
-void laserdisc_device::static_set_audio(device_t &device, laserdisc_audio_delegate callback)
-{
- downcast<laserdisc_device &>(device).m_audio_callback = callback;
-}
-
-
-//-------------------------------------------------
-// static_set_overlay - set the overlay parameters
-//-------------------------------------------------
-
-void laserdisc_device::static_set_overlay(device_t &device, UINT32 width, UINT32 height, screen_update_ind16_delegate update)
-{
- laserdisc_device &ld = downcast<laserdisc_device &>(device);
- ld.m_overwidth = width;
- ld.m_overheight = height;
- ld.m_overclip.set(0, width - 1, 0, height - 1);
- ld.m_overupdate_ind16 = update;
- ld.m_overupdate_rgb32 = screen_update_rgb32_delegate();
-}
-
-void laserdisc_device::static_set_overlay(device_t &device, UINT32 width, UINT32 height, screen_update_rgb32_delegate update)
-{
- laserdisc_device &ld = downcast<laserdisc_device &>(device);
- ld.m_overwidth = width;
- ld.m_overheight = height;
- ld.m_overclip.set(0, width - 1, 0, height - 1);
- ld.m_overupdate_ind16 = screen_update_ind16_delegate();
- ld.m_overupdate_rgb32 = update;
-}
-
-
-//-------------------------------------------------
-// static_set_overlay - set the overlay visible
-// memregion
-//-------------------------------------------------
-
-void laserdisc_device::static_set_overlay_clip(device_t &device, INT32 minx, INT32 maxx, INT32 miny, INT32 maxy)
-{
- downcast<laserdisc_device &>(device).m_overclip.set(minx, maxx, miny, maxy);
-}
-
-
-//-------------------------------------------------
-// static_set_overlay_position - set the overlay
-// position parameters
-//-------------------------------------------------
-
-void laserdisc_device::static_set_overlay_position(device_t &device, float posx, float posy)
-{
- laserdisc_device &ld = downcast<laserdisc_device &>(device);
- ld.m_orig_config.m_overposx = ld.m_overposx = posx;
- ld.m_orig_config.m_overposy = ld.m_overposy = posy;
-}
-
-
-//-------------------------------------------------
-// static_set_overlay_scale - set the overlay
-// scale parameters
-//-------------------------------------------------
-
-void laserdisc_device::static_set_overlay_scale(device_t &device, float scalex, float scaley)
-{
- laserdisc_device &ld = downcast<laserdisc_device &>(device);
- ld.m_orig_config.m_overscalex = ld.m_overscalex = scalex;
- ld.m_orig_config.m_overscaley = ld.m_overscaley = scaley;
-
-}
-
-//-------------------------------------------------
-// static_set_overlay_palette - set the screen palette
-// configuration
-//-------------------------------------------------
-
-void laserdisc_device::static_set_overlay_palette(device_t &device, const char *tag)
-{
- downcast<laserdisc_device &>(device).m_overlay_palette.set_tag(tag);
-}
-
-//**************************************************************************
-// DEVICE INTERFACE
-//**************************************************************************
-
-//-------------------------------------------------
-// device start callback
-//-------------------------------------------------
-
-void laserdisc_device::device_start()
-{
- // if we have a palette and it's not started, wait for it
- if (m_overlay_palette != NULL && !m_overlay_palette->started())
- throw device_missing_dependencies();
-
- // initialize the various pieces
- init_disc();
- init_video();
- init_audio();
-
- // register callbacks
- config_register(machine(), "laserdisc", config_saveload_delegate(FUNC(laserdisc_device::config_load), this), config_saveload_delegate(FUNC(laserdisc_device::config_save), this));
-}
-
-
-//-------------------------------------------------
-// device stop callback
-//-------------------------------------------------
-
-void laserdisc_device::device_stop()
-{
- // make sure all async operations have completed
- if (m_disc != NULL)
- osd_work_queue_wait(m_work_queue, osd_ticks_per_second() * 10);
-
- // free any textures and palettes
- if (m_videotex != NULL)
- machine().render().texture_free(m_videotex);
- if (m_videopalette != NULL)
- m_videopalette->deref();
- if (m_overtex != NULL)
- machine().render().texture_free(m_overtex);
-}
-
-
-//-------------------------------------------------
-// device reset callback
-//-------------------------------------------------
-
-void laserdisc_device::device_reset()
-{
- // attempt to wire up the audio
- m_stream->set_sample_rate(m_samplerate);
-
- // set up the general ld
- m_audiosquelch = 3;
- m_videosquelch = 1;
- m_fieldnum = 0;
- m_curtrack = 1;
- m_attospertrack = 0;
- m_sliderupdate = machine().time();
-}
-
-
-//-------------------------------------------------
-// device_validity_check - verify device
-// configuration
-//-------------------------------------------------
-
-void laserdisc_device::device_validity_check(validity_checker &valid) const
-{
- texture_format texformat = !m_overupdate_ind16.isnull() ? TEXFORMAT_PALETTE16 : TEXFORMAT_RGB32;
- if (m_overlay_palette == NULL && texformat == TEXFORMAT_PALETTE16)
- osd_printf_error("Overlay screen does not have palette defined\n");
-}
-
-//-------------------------------------------------
-// device_timer - handle timers set by this
-// device
-//-------------------------------------------------
-
-void laserdisc_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TID_VBI_FETCH:
- {
- // wait for previous read and decode to finish
- process_track_data();
-
- // update current track based on slider speed
- update_slider_pos();
-
- // update the state
- add_and_clamp_track(player_update(m_metadata[m_fieldnum], m_fieldnum, machine().time()));
-
- // flush any audio before we read more
- m_stream->update();
-
- // start reading the track data for the next round
- m_fieldnum ^= 1;
- read_track_data();
- break;
- }
- }
-}
-
-
-//-------------------------------------------------
-// sound_stream_update - audio streamer for
-// laserdiscs
-//-------------------------------------------------
-
-void laserdisc_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
-{
- // compute AND values based on the squelch
- INT16 leftand = (m_audiosquelch & 1) ? 0x0000 : 0xffff;
- INT16 rightand = (m_audiosquelch & 2) ? 0x0000 : 0xffff;
-
- // see if we have enough samples to fill the buffer; if not, drop out
- int samples_avail = m_audiobufin - m_audiobufout;
- if (samples_avail < 0)
- samples_avail += m_audiobufsize;
-
- // if no attached ld, just clear the buffers
- stream_sample_t *dst0 = outputs[0];
- stream_sample_t *dst1 = outputs[1];
- if (samples_avail < samples)
- {
- memset(dst0, 0, samples * sizeof(dst0[0]));
- memset(dst1, 0, samples * sizeof(dst1[0]));
- }
-
- // otherwise, stream from our buffer
- else
- {
- INT16 *buffer0 = &m_audiobuffer[0][0];
- INT16 *buffer1 = &m_audiobuffer[1][0];
- int sampout = m_audiobufout;
-
- // copy samples, clearing behind us as we go
- while (sampout != m_audiobufin && samples-- > 0)
- {
- *dst0++ = buffer0[sampout] & leftand;
- *dst1++ = buffer1[sampout] & rightand;
- buffer0[sampout] = 0;
- buffer1[sampout] = 0;
- sampout++;
- if (sampout >= m_audiobufsize)
- sampout = 0;
- }
- m_audiobufout = sampout;
-
- // clear out the rest of the buffer
- if (samples > 0)
- {
- sampout = (m_audiobufout == 0) ? m_audiobufsize - 1 : m_audiobufout - 1;
- stream_sample_t fill0 = buffer0[sampout] & leftand;
- stream_sample_t fill1 = buffer1[sampout] & rightand;
-
- while (samples-- > 0)
- {
- *dst0++ = fill0;
- *dst1++ = fill1;
- }
- }
- }
-}
-
-
-//**************************************************************************
-// SUBCLASS HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// set_slider_speed - dynamically change the
-// slider speed
-//-------------------------------------------------
-
-void laserdisc_device::set_slider_speed(INT32 tracks_per_vsync)
-{
- // update to the current time
- update_slider_pos();
-
- // if 0, set the time to 0
- attotime vsyncperiod = m_screen->frame_period();
- if (tracks_per_vsync == 0)
- m_attospertrack = 0;
-
- // positive values store positive times
- else if (tracks_per_vsync > 0)
- m_attospertrack = (vsyncperiod / tracks_per_vsync).as_attoseconds();
-
- // negative values store negative times
- else
- m_attospertrack = -(vsyncperiod / -tracks_per_vsync).as_attoseconds();
-
- if (LOG_SLIDER)
- printf("Slider speed = %d\n", tracks_per_vsync);
-}
-
-
-//-------------------------------------------------
-// advance_slider - advance the slider by
-// a certain number of tracks
-//-------------------------------------------------
-
-void laserdisc_device::advance_slider(INT32 numtracks)
-{
- // first update to the current time
- update_slider_pos();
-
- // then update the track position
- add_and_clamp_track(numtracks);
- if (LOG_SLIDER)
- printf("Advance by %d\n", numtracks);
-}
-
-
-//-------------------------------------------------
-// get_slider_position - get the current
-// slider position
-//-------------------------------------------------
-
-laserdisc_device::slider_position laserdisc_device::get_slider_position()
-{
- // update the slider position first
- update_slider_pos();
-
- // return the status
- if (m_curtrack == 1)
- return SLIDER_MINIMUM;
- else if (m_curtrack < VIRTUAL_LEAD_IN_TRACKS)
- return SLIDER_VIRTUAL_LEADIN;
- else if (m_curtrack < VIRTUAL_LEAD_IN_TRACKS + m_chdtracks)
- return SLIDER_CHD;
- else if (m_curtrack < VIRTUAL_LEAD_IN_TRACKS + MAX_TOTAL_TRACKS)
- return SLIDER_OUTSIDE_CHD;
- else if (m_curtrack < m_maxtrack - 1)
- return SLIDER_VIRTUAL_LEADOUT;
- else
- return SLIDER_MAXIMUM;
-}
-
-
-//-------------------------------------------------
-// generic_update - generically update in a way
-// that works for most situations
-//-------------------------------------------------
-
-INT32 laserdisc_device::generic_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime, player_state_info &newstate)
-{
- INT32 advanceby = 0;
- int frame;
-
- // start by assuming the state doesn't change
- newstate = m_player_state;
-
- // handle things based on the state
- switch (m_player_state.m_state)
- {
- case LDSTATE_EJECTING:
- // when time expires, switch to the ejected state
- if (curtime >= m_player_state.m_endtime)
- newstate.m_state = LDSTATE_EJECTED;
- break;
-
- case LDSTATE_EJECTED:
- // do nothing
- break;
-
- case LDSTATE_PARKED:
- // do nothing
- break;
-
- case LDSTATE_LOADING:
- // when time expires, switch to the spinup state
- if (curtime >= m_player_state.m_endtime)
- newstate.m_state = LDSTATE_SPINUP;
- advanceby = -GENERIC_SEARCH_SPEED;
- break;
-
- case LDSTATE_SPINUP:
- // when time expires, switch to the playing state
- if (curtime >= m_player_state.m_endtime)
- newstate.m_state = LDSTATE_PLAYING;
- advanceby = -GENERIC_SEARCH_SPEED;
- break;
-
- case LDSTATE_PAUSING:
- // if he hit the start of a frame, switch to paused state
- if (is_start_of_frame(vbi))
- {
- newstate.m_state = LDSTATE_PAUSED;
- newstate.m_param = fieldnum;
- }
-
- // else advance until we hit it
- else if (fieldnum == 1)
- advanceby = 1;
- break;
-
- case LDSTATE_PAUSED:
- // if we paused on field 1, we must flip back and forth
- if (m_player_state.m_param == 1)
- advanceby = (fieldnum == 1) ? 1 : -1;
- break;
-
- case LDSTATE_PLAYING:
- // if we hit the target frame, switch to the paused state
- if (m_player_state.m_param > 0 && is_start_of_frame(vbi) && frame_from_metadata(vbi) == m_player_state.m_param)
- {
- newstate.m_state = LDSTATE_PAUSED;
- newstate.m_param = fieldnum;
- }
-
- // otherwise after the second field of each frame
- else if (fieldnum == 1)
- advanceby = 1;
- break;
-
- case LDSTATE_PLAYING_SLOW_REVERSE:
- // after the second field of each frame, see if we need to advance
- if (fieldnum == 1 && ++m_player_state.m_substate > m_player_state.m_param)
- {
- advanceby = -1;
- m_player_state.m_substate = 0;
- }
- break;
-
- case LDSTATE_PLAYING_SLOW_FORWARD:
- // after the second field of each frame, see if we need to advance
- if (fieldnum == 1 && ++m_player_state.m_substate > m_player_state.m_param)
- {
- advanceby = 1;
- m_player_state.m_substate = 0;
- }
- break;
-
- case LDSTATE_PLAYING_FAST_REVERSE:
- // advance after the second field of each frame
- if (fieldnum == 1)
- advanceby = -m_player_state.m_param;
- break;
-
- case LDSTATE_PLAYING_FAST_FORWARD:
- // advance after the second field of each frame
- if (fieldnum == 1)
- advanceby = m_player_state.m_param;
- break;
-
- case LDSTATE_SCANNING:
- // advance after the second field of each frame
- if (fieldnum == 1)
- advanceby = m_player_state.m_param >> 8;
-
- // after we run out of vsyncs, revert to the saved state
- if (++m_player_state.m_substate >= (m_player_state.m_param & 0xff))
- newstate = m_saved_state;
- break;
-
- case LDSTATE_STEPPING_REVERSE:
- // wait for the first field of the frame and then leap backwards
- if (is_start_of_frame(vbi))
- {
- advanceby = (fieldnum == 1) ? -1 : -2;
- newstate.m_state = LDSTATE_PAUSING;
- }
- break;
-
- case LDSTATE_STEPPING_FORWARD:
- // wait for the first field of the frame and then switch to pausing state
- if (is_start_of_frame(vbi))
- newstate.m_state = LDSTATE_PAUSING;
- break;
-
- case LDSTATE_SEEKING:
- // if we're in the final state, look for a matching frame and pause there
- frame = frame_from_metadata(vbi);
- if (m_player_state.m_substate == 1 && is_start_of_frame(vbi) && frame == m_player_state.m_param)
- {
- newstate.m_state = LDSTATE_PAUSED;
- newstate.m_param = fieldnum;
- }
-
- // otherwise, if we got frame data from the VBI, update our seeking logic
- else if (m_player_state.m_substate == 0 && frame != FRAME_NOT_PRESENT)
- {
- INT32 delta = (m_player_state.m_param - 2) - frame;
-
- // if we're within a couple of frames, just play until we hit it
- if (delta >= 0 && delta <= 2)
- m_player_state.m_substate++;
-
- // otherwise, compute the delta assuming 1:1 track to frame; this will correct eventually
- else
- {
- if (delta < 0)
- delta--;
- advanceby = delta;
- advanceby = MIN(advanceby, GENERIC_SEARCH_SPEED);
- advanceby = MAX(advanceby, -GENERIC_SEARCH_SPEED);
- }
- }
-
- // otherwise, keep advancing until we know what's up
- else
- {
- if (fieldnum == 1)
- advanceby = 1;
- }
- break;
-
- default:
- // do nothing
- break;
- }
-
- return advanceby;
-}
-
-
-//**************************************************************************
-// INITIALIZATION
-//**************************************************************************
-
-//-------------------------------------------------
-// init_disc - initialize the state of the
-// CHD disc
-//-------------------------------------------------
-
-void laserdisc_device::init_disc()
-{
- // get a handle to the disc to play
- if (!m_getdisc_callback.isnull())
- m_disc = m_getdisc_callback(*this);
- else
- m_disc = get_disk_handle(machine(), tag());
-
- // set default parameters
- m_width = 720;
- m_height = 240;
- m_fps_times_1million = 59940000;
- m_samplerate = 48000;
-
- // get the disc metadata and extract the ld
- m_chdtracks = 0;
- m_maxtrack = VIRTUAL_LEAD_IN_TRACKS + MAX_TOTAL_TRACKS + VIRTUAL_LEAD_OUT_TRACKS;
- if (m_disc != NULL)
- {
- // require the A/V codec and nothing else
- if (m_disc->compression(0) != CHD_CODEC_AVHUFF || m_disc->compression(1) != CHD_CODEC_NONE)
- throw emu_fatalerror("Laserdisc video must be compressed with the A/V codec!");
-
- // read the metadata
- std::string metadata;
- chd_error err = m_disc->read_metadata(AV_METADATA_TAG, 0, metadata);
- if (err != CHDERR_NONE)
- throw emu_fatalerror("Non-A/V CHD file specified");
-
- // extract the metadata
- int fps, fpsfrac, interlaced, channels;
- if (sscanf(metadata.c_str(), AV_METADATA_FORMAT, &fps, &fpsfrac, &m_width, &m_height, &interlaced, &channels, &m_samplerate) != 7)
- throw emu_fatalerror("Invalid metadata in CHD file");
- else
- m_fps_times_1million = fps * 1000000 + fpsfrac;
-
- // require interlaced video
- if (!interlaced)
- throw emu_fatalerror("Laserdisc video must be interlaced!");
-
- // determine the maximum track and allocate a frame buffer
- UINT32 totalhunks = m_disc->hunk_count();
- m_chdtracks = totalhunks / 2;
-
- // allocate memory for the precomputed per-frame metadata
- err = m_disc->read_metadata(AV_LD_METADATA_TAG, 0, m_vbidata);
- if (err != CHDERR_NONE || m_vbidata.size() != totalhunks * VBI_PACKED_BYTES)
- throw emu_fatalerror("Precomputed VBI metadata missing or incorrect size");
- }
- m_maxtrack = MAX(m_maxtrack, VIRTUAL_LEAD_IN_TRACKS + VIRTUAL_LEAD_OUT_TRACKS + m_chdtracks);
-}
-
-
-//-------------------------------------------------
-// init_video - initialize the state of the
-// video rendering
-//-------------------------------------------------
-
-void laserdisc_device::init_video()
-{
- // register for VBLANK callbacks
- m_screen->register_vblank_callback(vblank_state_delegate(FUNC(laserdisc_device::vblank_state_changed), this));
-
- // allocate palette for applying brightness/contrast/gamma
- m_videopalette = palette_t::alloc(256);
- if (m_videopalette == NULL)
- throw emu_fatalerror("Out of memory allocating video palette");
- for (int index = 0; index < 256; index++)
- m_videopalette->entry_set_color(index, rgb_t(index, index, index));
-
- // allocate video frames
- for (int index = 0; index < ARRAY_LENGTH(m_frame); index++)
- {
- // first allocate a YUY16 bitmap at 2x the height
- frame_data &frame = m_frame[index];
- frame.m_bitmap.allocate(m_width, m_height * 2);
- frame.m_bitmap.set_palette(m_videopalette);
- fillbitmap_yuy16(frame.m_bitmap, 40, 109, 240);
-
- // make a copy of the bitmap that clips out the VBI and horizontal blanking areas
- frame.m_visbitmap.wrap(&frame.m_bitmap.pix16(44, frame.m_bitmap.width() * 8 / 720),
- frame.m_bitmap.width() - 2 * frame.m_bitmap.width() * 8 / 720,
- frame.m_bitmap.height() - 44,
- frame.m_bitmap.rowpixels());
- frame.m_visbitmap.set_palette(m_videopalette);
- }
-
- // allocate an empty frame of the same size
- m_emptyframe.allocate(m_width, m_height * 2);
- m_emptyframe.set_palette(m_videopalette);
- fillbitmap_yuy16(m_emptyframe, 0, 128, 128);
-
- // allocate texture for rendering
- m_videoenable = true;
- m_videotex = machine().render().texture_alloc();
- if (m_videotex == NULL)
- fatalerror("Out of memory allocating video texture\n");
-
- // allocate overlay
- m_overenable = overlay_configured();
- if (m_overenable)
- {
- // bind our handlers
- m_overupdate_ind16.bind_relative_to(*owner());
- m_overupdate_rgb32.bind_relative_to(*owner());
-
- // configure bitmap formats
- bitmap_format format = !m_overupdate_ind16.isnull() ? BITMAP_FORMAT_IND16 : BITMAP_FORMAT_RGB32;
- texture_format texformat = !m_overupdate_ind16.isnull() ? TEXFORMAT_PALETTEA16 : TEXFORMAT_ARGB32;
-
- // allocate overlay bitmaps
- for (int index = 0; index < ARRAY_LENGTH(m_overbitmap); index++)
- {
- m_overbitmap[index].set_format(format, texformat);
- if (format==BITMAP_FORMAT_IND16)
- m_overbitmap[index].set_palette(m_overlay_palette->palette());
- m_overbitmap[index].resize(m_overwidth, m_overheight);
- }
-
- // allocate overlay texture
- m_overtex = machine().render().texture_alloc();
- if (m_overtex == NULL)
- fatalerror("Out of memory allocating overlay texture\n");
- }
-}
-
-
-//-------------------------------------------------
-// init_audio - initialize the state of the
-// audio rendering
-//-------------------------------------------------
-
-void laserdisc_device::init_audio()
-{
- // allocate a stream
- m_stream = stream_alloc(0, 2, 48000);
-
- // allocate audio buffers
- m_audiomaxsamples = ((UINT64)m_samplerate * 1000000 + m_fps_times_1million - 1) / m_fps_times_1million;
- m_audiobufsize = m_audiomaxsamples * 4;
- m_audiobuffer[0].resize(m_audiobufsize);
- m_audiobuffer[1].resize(m_audiobufsize);
-}
-
-
-//**************************************************************************
-// INTERNAL HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// fillbitmap_yuy16 - fill a YUY16 bitmap with a
-// given color pattern
-//-------------------------------------------------
-
-void laserdisc_device::fillbitmap_yuy16(bitmap_yuy16 &bitmap, UINT8 yval, UINT8 cr, UINT8 cb)
-{
- UINT16 color0 = (yval << 8) | cb;
- UINT16 color1 = (yval << 8) | cr;
-
- // write 32 bits of color (2 pixels at a time)
- for (int y = 0; y < bitmap.height(); y++)
- {
- UINT16 *dest = &bitmap.pix16(y);
- for (int x = 0; x < bitmap.width() / 2; x++)
- {
- *dest++ = color0;
- *dest++ = color1;
- }
- }
-}
-
-
-//-------------------------------------------------
-// update_slider_pos - based on the current
-// speed and elapsed time, update the current
-// track position
-//-------------------------------------------------
-
-void laserdisc_device::update_slider_pos()
-{
- attotime curtime = machine().time();
-
- // if not moving, update to now
- if (m_attospertrack == 0)
- m_sliderupdate = curtime;
-
- // otherwise, compute the number of tracks covered
- else
- {
- attoseconds_t delta = (curtime - m_sliderupdate).as_attoseconds();
-
- // determine how many tracks we covered and advance
- if (m_attospertrack >= 0)
- {
- INT32 tracks_covered = delta / m_attospertrack;
- add_and_clamp_track(tracks_covered);
- if (tracks_covered != 0)
- m_sliderupdate += attotime(0, tracks_covered * m_attospertrack);
- }
- else
- {
- INT32 tracks_covered = delta / -m_attospertrack;
- add_and_clamp_track(-tracks_covered);
- if (tracks_covered != 0)
- m_sliderupdate += attotime(0, tracks_covered * -m_attospertrack);
- }
- }
-}
-
-
-//-------------------------------------------------
-// vblank_state_changed - called on each state
-// change of the VBLANK signal
-//-------------------------------------------------
-
-void laserdisc_device::vblank_state_changed(screen_device &screen, bool vblank_state)
-{
- // update current track based on slider speed
- update_slider_pos();
-
- // on rising edge, process previously-read frame and inform the player
- if (vblank_state)
- {
- // call the player's VSYNC callback
- player_vsync(m_metadata[m_fieldnum], m_fieldnum, machine().time());
-
- // set a timer to begin fetching the next frame just before the VBI data would be fetched
- timer_set(screen.time_until_pos(16*2), TID_VBI_FETCH);
- }
-}
-
-
-//-------------------------------------------------
-// current_frame - return a reference to the
-// currently visible frame
-//-------------------------------------------------
-
-laserdisc_device::frame_data &laserdisc_device::current_frame()
-{
- // determine the most recent live set of frames
- frame_data *frame = &m_frame[m_videoindex];
- if (frame->m_numfields < 2)
- frame = &m_frame[(m_videoindex + ARRAY_LENGTH(m_frame) - 1) % ARRAY_LENGTH(m_frame)];
- return *frame;
-}
-
-
-//-------------------------------------------------
-// read_track_data - read and process data for
-// a particular video track
-//-------------------------------------------------
-
-void laserdisc_device::read_track_data()
-{
- // compute the chdhunk number we are going to read
- INT32 chdtrack = m_curtrack - 1 - VIRTUAL_LEAD_IN_TRACKS;
- chdtrack = MAX(chdtrack, 0);
- chdtrack = MIN(chdtrack, m_chdtracks - 1);
- UINT32 readhunk = chdtrack * 2 + m_fieldnum;
-
- // cheat and look up the metadata we are about to retrieve
- vbi_metadata vbidata = { 0 };
- if (!m_vbidata.empty())
- vbi_metadata_unpack(&vbidata, NULL, &m_vbidata[readhunk * VBI_PACKED_BYTES]);
-
- // if we're in the lead-in area, force the VBI data to be standard lead-in
- if (m_curtrack - 1 < VIRTUAL_LEAD_IN_TRACKS)
- {
- vbidata.line16 = 0;
- vbidata.line17 = vbidata.line18 = vbidata.line1718 = VBI_CODE_LEADIN;
- }
-//printf("track %5d.%d: %06X %06X %06X\n", m_curtrack, m_fieldnum, vbidata.line16, vbidata.line17, vbidata.line18);
-
- // if we're about to read the first field in a frame, advance
- frame_data *frame = &m_frame[m_videoindex];
- if ((vbidata.line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE)
- {
- if (frame->m_numfields >= 2)
- m_videoindex = (m_videoindex + 1) % ARRAY_LENGTH(m_frame);
- frame = &m_frame[m_videoindex];
- frame->m_numfields = 0;
- }
-
- // if we're squelched, reset the frame counter
- if (m_videosquelch)
- frame->m_numfields = 0;
-
- // remember the last field number
- frame->m_lastfield = m_curtrack * 2 + m_fieldnum;
-
- // set the video target information
- m_avhuff_config.video.wrap(&frame->m_bitmap.pix16(m_fieldnum), frame->m_bitmap.width(), frame->m_bitmap.height() / 2, frame->m_bitmap.rowpixels() * 2);
-
- // set the audio target information
- if (m_audiobufin + m_audiomaxsamples <= m_audiobufsize)
- {
- // if we can fit without wrapping, just read the data directly
- m_avhuff_config.audio[0] = &m_audiobuffer[0][m_audiobufin];
- m_avhuff_config.audio[1] = &m_audiobuffer[1][m_audiobufin];
- }
- else
- {
- // otherwise, read to the beginning of the buffer
- m_avhuff_config.audio[0] = &m_audiobuffer[0][0];
- m_avhuff_config.audio[1] = &m_audiobuffer[1][0];
- }
-
- // override if we're not decoding
- m_avhuff_config.maxsamples = m_audiomaxsamples;
- m_avhuff_config.actsamples = &m_audiocursamples;
- m_audiocursamples = 0;
-
- // set the VBI data for the new field from our precomputed data
- if (!m_vbidata.empty())
- {
- UINT32 vbiframe;
- vbi_metadata_unpack(&m_metadata[m_fieldnum], &vbiframe, &m_vbidata[readhunk * VBI_PACKED_BYTES]);
- }
-
- // if we're in the lead-in area, force the VBI data to be standard lead-in
- if (m_curtrack - 1 < VIRTUAL_LEAD_IN_TRACKS)
- {
- m_metadata[m_fieldnum].line16 = 0;
- m_metadata[m_fieldnum].line17 = m_metadata[m_fieldnum].line18 = m_metadata[m_fieldnum].line1718 = VBI_CODE_LEADIN;
- }
-
- // configure the codec and then read
- m_readresult = CHDERR_FILE_NOT_FOUND;
- if (m_disc != NULL && !m_videosquelch)
- {
- m_readresult = m_disc->codec_configure(CHD_CODEC_AVHUFF, AVHUFF_CODEC_DECOMPRESS_CONFIG, &m_avhuff_config);
- if (m_readresult == CHDERR_NONE)
- {
- m_queued_hunknum = readhunk;
- m_readresult = CHDERR_OPERATION_PENDING;
- osd_work_item_queue(m_work_queue, read_async_static, this, WORK_ITEM_FLAG_AUTO_RELEASE);
- }
- }
-}
-
-
-//-------------------------------------------------
-// read_async_static - work item callback for
-// asynchronous reads
-//-------------------------------------------------
-
-void *laserdisc_device::read_async_static(void *param, int threadid)
-{
- laserdisc_device &ld = *reinterpret_cast<laserdisc_device *>(param);
- ld.m_readresult = ld.m_disc->read_hunk(ld.m_queued_hunknum, NULL);
- return NULL;
-}
-
-
-//-------------------------------------------------
-// process_track_data - process data from a
-// track after it has been read
-//-------------------------------------------------
-
-void laserdisc_device::process_track_data()
-{
- // wait for the async operation to complete
- if (m_readresult == CHDERR_OPERATION_PENDING)
- osd_work_queue_wait(m_work_queue, osd_ticks_per_second() * 10);
- assert(m_readresult != CHDERR_OPERATION_PENDING);
-
- // remove the video if we had an error
- if (m_readresult != CHDERR_NONE)
- m_avhuff_config.video.reset();
-
- // count the field as read if we are successful
- if (m_avhuff_config.video.valid())
- {
- m_frame[m_videoindex].m_numfields++;
- player_overlay(m_avhuff_config.video);
- }
-
- // pass the audio to the callback
- if (!m_audio_callback.isnull())
- m_audio_callback(*this, m_samplerate, m_audiocursamples, m_avhuff_config.audio[0], m_avhuff_config.audio[1]);
-
- // shift audio data if we read it into the beginning of the buffer
- if (m_audiocursamples != 0 && m_audiobufin != 0)
- for (int chnum = 0; chnum < 2; chnum++)
- if (m_avhuff_config.audio[chnum] == &m_audiobuffer[chnum][0])
- {
- // move data to the end
- int samplesleft = m_audiobufsize - m_audiobufin;
- samplesleft = MIN(samplesleft, m_audiocursamples);
- memmove(&m_audiobuffer[chnum][m_audiobufin], &m_audiobuffer[chnum][0], samplesleft * 2);
-
- // shift data at the beginning
- if (samplesleft < m_audiocursamples)
- memmove(&m_audiobuffer[chnum][0], &m_audiobuffer[chnum][samplesleft], (m_audiocursamples - samplesleft) * 2);
- }
-
- // update the input buffer pointer
- m_audiobufin = (m_audiobufin + m_audiocursamples) % m_audiobufsize;
-}
-
-
-
-//**************************************************************************
-// CONFIG SETTINGS ACCESS
-//**************************************************************************
-
-//-------------------------------------------------
-// config_load - read and apply data from the
-// configuration file
-//-------------------------------------------------
-
-void laserdisc_device::config_load(int config_type, xml_data_node *parentnode)
-{
- // we only care about game files
- if (config_type != CONFIG_TYPE_GAME)
- return;
-
- // might not have any data
- if (parentnode == NULL)
- return;
-
- // iterate over overlay nodes
- for (xml_data_node *ldnode = xml_get_sibling(parentnode->child, "device"); ldnode != NULL; ldnode = xml_get_sibling(ldnode->next, "device"))
- {
- const char *devtag = xml_get_attribute_string(ldnode, "tag", "");
- if (strcmp(devtag, tag()) == 0)
- {
- // handle the overlay node
- xml_data_node *overnode = xml_get_sibling(ldnode->child, "overlay");
- if (overnode != NULL)
- {
- // fetch positioning controls
- m_overposx = xml_get_attribute_float(overnode, "hoffset", m_overposx);
- m_overscalex = xml_get_attribute_float(overnode, "hstretch", m_overscalex);
- m_overposy = xml_get_attribute_float(overnode, "voffset", m_overposy);
- m_overscaley = xml_get_attribute_float(overnode, "vstretch", m_overscaley);
- }
- }
- }
-}
-
-
-//-------------------------------------------------
-// config_save - save data to the configuration
-// file
-//-------------------------------------------------
-
-void laserdisc_device::config_save(int config_type, xml_data_node *parentnode)
-{
- // we only care about game files
- if (config_type != CONFIG_TYPE_GAME)
- return;
-
- // create a node
- xml_data_node *ldnode = xml_add_child(parentnode, "device", NULL);
- if (ldnode != NULL)
- {
- // output the basics
- xml_set_attribute(ldnode, "tag", tag());
-
- // add an overlay node
- xml_data_node *overnode = xml_add_child(ldnode, "overlay", NULL);
- bool changed = false;
- if (overnode != NULL)
- {
- // output the positioning controls
- if (m_overposx != m_orig_config.m_overposx)
- {
- xml_set_attribute_float(overnode, "hoffset", m_overposx);
- changed = true;
- }
-
- if (m_overscalex != m_orig_config.m_overscalex)
- {
- xml_set_attribute_float(overnode, "hstretch", m_overscalex);
- changed = true;
- }
-
- if (m_overposy != m_orig_config.m_overposy)
- {
- xml_set_attribute_float(overnode, "voffset", m_overposy);
- changed = true;
- }
-
- if (m_overscaley != m_orig_config.m_overscaley)
- {
- xml_set_attribute_float(overnode, "vstretch", m_overscaley);
- changed = true;
- }
- }
-
- // if nothing changed, kill the node
- if (!changed)
- xml_delete_node(ldnode);
- }
-}
diff --git a/src/emu/machine/laserdsc.h b/src/emu/machine/laserdsc.h
deleted file mode 100644
index 55d4aeda1b3..00000000000
--- a/src/emu/machine/laserdsc.h
+++ /dev/null
@@ -1,413 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- laserdsc.h
-
- Core laserdisc player implementation.
-
-*************************************************************************/
-
-#pragma once
-
-#ifndef __LASERDSC_H__
-#define __LASERDSC_H__
-
-#include "vbiparse.h"
-#include "avhuff.h"
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-// laserdisc field codes
-enum laserdisc_field_code
-{
- LASERDISC_CODE_WHITE_FLAG = 11, // boolean white flag
- LASERDISC_CODE_LINE16 = 16, // 24-bit line 16 code
- LASERDISC_CODE_LINE17 = 17, // 24-bit line 17 code
- LASERDISC_CODE_LINE18 = 18, // 24-bit line 18 code
- LASERDISC_CODE_LINE1718 = 1718 // 24-bit best of line 17/18 code
-};
-
-
-// special frame and chapter numbers from VBI conversion
-#define FRAME_NOT_PRESENT -2 // no frame number information present
-#define FRAME_LEAD_IN -1 // lead-in code detected
-#define FRAME_LEAD_OUT 99999 // lead-out code detected
-#define CHAPTER_NOT_PRESENT -2 // no chapter number information present
-#define CHAPTER_LEAD_IN -1 // lead-in code detected
-#define CHAPTER_LEAD_OUT 100 // lead-out code detected
-
-// generic head movement speeds; use player-specific information where appropriate
-#define GENERIC_SLOW_SPEED (5) // 1/5 normal speed
-#define GENERIC_FAST_SPEED (3) // 3x normal speed
-#define GENERIC_SCAN_SPEED (50) // 50x normal speed
-#define GENERIC_SEARCH_SPEED (5000) // 5000x normal speed
-
-// generic timings; use player-specific information where appropriate
-#define GENERIC_EJECT_TIME (attotime::from_seconds(5))
-#define GENERIC_SPINUP_TIME (attotime::from_seconds(2))
-#define GENERIC_LOAD_TIME (attotime::from_seconds(5))
-
-
-
-//**************************************************************************
-// DEVICE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_LASERDISC_GET_DISC(_func) \
- laserdisc_device::static_set_get_disc(*device, _func);
-#define MCFG_LASERDISC_AUDIO(_func) \
- laserdisc_device::static_set_audio(*device, _func);
-#define MCFG_LASERDISC_SCREEN(_tag) \
- laserdisc_device::static_set_screen(*device, _tag);
-#define MCFG_LASERDISC_OVERLAY_STATIC(_width, _height, _func) \
- laserdisc_device::static_set_overlay(*device, _width, _height, screen_update_delegate_smart(&screen_update_##_func, "screen_update_" #_func));
-#define MCFG_LASERDISC_OVERLAY_DRIVER(_width, _height, _class, _method) \
- laserdisc_device::static_set_overlay(*device, _width, _height, screen_update_delegate_smart(&_class::_method, #_class "::" #_method, NULL));
-#define MCFG_LASERDISC_OVERLAY_DEVICE(_width, _height, _device, _class, _method) \
- laserdisc_device::static_set_overlay(*device, _width, _height, screen_update_delegate_smart(&_class::_method, #_class "::" #_method, _device));
-#define MCFG_LASERDISC_OVERLAY_CLIP(_minx, _maxx, _miny, _maxy) \
- laserdisc_device::static_set_overlay_clip(*device, _minx, _maxx, _miny, _maxy);
-#define MCFG_LASERDISC_OVERLAY_POSITION(_posx, _posy) \
- laserdisc_device::static_set_overlay_position(*device, _posx, _posy);
-#define MCFG_LASERDISC_OVERLAY_SCALE(_scalex, _scaley) \
- laserdisc_device::static_set_overlay_scale(*device, _scalex, _scaley);
-#define MCFG_LASERDISC_OVERLAY_PALETTE(_palette_tag) \
- laserdisc_device::static_set_overlay_palette(*device, "^" _palette_tag);
-
-// use these to add laserdisc screens with proper video update parameters
-#define MCFG_LASERDISC_SCREEN_ADD_NTSC(_tag, _ldtag) \
- MCFG_DEVICE_MODIFY(_ldtag) \
- laserdisc_device::static_set_screen(*device, _tag); \
- MCFG_SCREEN_ADD(_tag, RASTER) \
- MCFG_SCREEN_VIDEO_ATTRIBUTES(VIDEO_SELF_RENDER) \
- MCFG_SCREEN_RAW_PARAMS(XTAL_14_31818MHz*2, 910, 0, 704, 525, 44, 524) \
- MCFG_SCREEN_UPDATE_DEVICE(_ldtag, laserdisc_device, screen_update)
-// not correct yet; fix me...
-#define MCFG_LASERDISC_SCREEN_ADD_PAL(_tag, _ldtag) \
- MCFG_DEVICE_MODIFY(_ldtag) \
- laserdisc_device::static_set_screen(*device, _tag); \
- MCFG_SCREEN_ADD(_tag, RASTER) \
- MCFG_SCREEN_VIDEO_ATTRIBUTES(VIDEO_SELF_RENDER) \
- MCFG_SCREEN_RAW_PARAMS(XTAL_14_31818MHz, 910, 0, 704, 525.0/2, 0, 480/2) \
- MCFG_SCREEN_UPDATE_DEVICE(_ldtag, laserdisc_device, screen_update)
-
-
-//**************************************************************************
-// MACROS
-//**************************************************************************
-
-#define SCANNING_PARAM(speed,duration) (((speed) << 8) | ((duration) & 0xff))
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// forward declarations
-class laserdisc_device;
-
-// delegates
-typedef delegate<chd_file *(laserdisc_device &device)> laserdisc_get_disc_delegate;
-typedef delegate<void (laserdisc_device &device, int samplerate, int samples, const INT16 *ch0, const INT16 *ch1)> laserdisc_audio_delegate;
-
-
-// ======================> laserdisc_overlay_config
-
-// overlay configuration
-struct laserdisc_overlay_config
-{
- float m_overposx;
- float m_overposy;
- float m_overscalex;
- float m_overscaley;
-};
-
-
-// ======================> laserdisc_device
-
-// base laserdisc class
-class laserdisc_device : public device_t,
- public device_sound_interface,
- public device_video_interface,
- public laserdisc_overlay_config
-{
-protected:
- // construction/destruction
- laserdisc_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
- virtual ~laserdisc_device();
-
-public:
- // reset line control
-
- // core control and status
- bool video_active() { return (!m_videosquelch && current_frame().m_numfields >= 2); }
- bitmap_yuy16 &get_video() { return (!video_active()) ? m_emptyframe : current_frame().m_visbitmap; }
- UINT32 get_field_code(laserdisc_field_code code, bool zero_if_squelched);
-
- // video interface
- void video_enable(bool enable) { m_videoenable = enable; }
- void overlay_enable(bool enable) { m_overenable = enable; }
-
- // video update callback
- UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
-
- // configuration
- bool overlay_configured() const { return (m_overwidth > 0 && m_overheight > 0 && (!m_overupdate_ind16.isnull() || !m_overupdate_rgb32.isnull())); }
- void get_overlay_config(laserdisc_overlay_config &config) { config = static_cast<laserdisc_overlay_config &>(*this); }
- void set_overlay_config(const laserdisc_overlay_config &config) { static_cast<laserdisc_overlay_config &>(*this) = config; }
-
- // static configuration helpers
- static void static_set_get_disc(device_t &device, laserdisc_get_disc_delegate callback);
- static void static_set_audio(device_t &device, laserdisc_audio_delegate callback);
- static void static_set_overlay(device_t &device, UINT32 width, UINT32 height, screen_update_ind16_delegate update);
- static void static_set_overlay(device_t &device, UINT32 width, UINT32 height, screen_update_rgb32_delegate update);
- static void static_set_overlay_clip(device_t &device, INT32 minx, INT32 maxx, INT32 miny, INT32 maxy);
- static void static_set_overlay_position(device_t &device, float posx, float posy);
- static void static_set_overlay_scale(device_t &device, float scalex, float scaley);
- static void static_set_overlay_palette(device_t &device, const char *tag);
-
-protected:
- // timer IDs
- enum
- {
- TID_VBI_FETCH,
- TID_FIRST_PLAYER_TIMER
- };
-
- // common laserdisc states
- enum player_state
- {
- LDSTATE_NONE, // unspecified state
- LDSTATE_EJECTING, // in the process of ejecting
- LDSTATE_EJECTED, // fully ejected
- LDSTATE_PARKED, // head parked in lead-in
- LDSTATE_LOADING, // loading from ejected state
- LDSTATE_SPINUP, // spinning up
- LDSTATE_PAUSING, // looking for a frame boundary to pause
- LDSTATE_PAUSED, // found a frame boundary; now paused
- // parameter specifies the fieldnum of the first frame
- LDSTATE_PLAYING, // playing forward normally, with audio
- // parameter specifies the target frame, or 0 if none
- LDSTATE_PLAYING_SLOW_REVERSE, // playing slow in the reverse direction, with no audio
- // parameter specifies the number of times to repeat each track
- LDSTATE_PLAYING_SLOW_FORWARD, // playing slow in the forward direction, with no audio
- // parameter specifies the number of times to repeat each track
- LDSTATE_PLAYING_FAST_REVERSE, // playing fast in the reverse direction, with no audio
- // parameter specifies the number of frames to skip backwards after each frame
- LDSTATE_PLAYING_FAST_FORWARD, // playing fast in the forward direction, with no audio
- // parameter specifies the number of frames to skip forwards after each frame
- LDSTATE_STEPPING_REVERSE, // single frame stepping in the reverse direction
- LDSTATE_STEPPING_FORWARD, // single frame stepping in the forward direction
- LDSTATE_SCANNING, // scanning in the forward or reverse direction
- // parameter(0:7) controls how many vsyncs until revert to savestate
- // parameter(8:31) specifies the speed
- LDSTATE_SEEKING, // seeking to a specific frame
- // parameter specifies the target frame
- LDSTATE_OTHER // other states start here
- };
-
- // slider position
- enum slider_position
- {
- SLIDER_MINIMUM, // at the minimum value
- SLIDER_VIRTUAL_LEADIN, // within the virtual lead-in area
- SLIDER_CHD, // within the boundaries of the CHD
- SLIDER_OUTSIDE_CHD, // outside of the CHD area but before the virtual lead-out area
- SLIDER_VIRTUAL_LEADOUT, // within the virtual lead-out area
- SLIDER_MAXIMUM // at the maximum value
- };
-
- // information about the current player state
- struct player_state_info
- {
- player_state m_state; // current state
- INT32 m_substate; // internal sub-state; starts at 0 on any state change
- INT32 m_param; // parameter for current state
- attotime m_endtime; // minimum ending time for current state
- };
-
- // subclass overrides
- virtual void player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime) = 0;
- virtual INT32 player_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime) = 0;
- virtual void player_overlay(bitmap_yuy16 &bitmap) = 0;
-
- // device-level overrides
- virtual void device_start();
- virtual void device_stop();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual void device_validity_check(validity_checker &valid) const;
-
- // device_sound_interface overrides
- virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
-
- // subclass helpers
- void set_audio_squelch(bool squelchleft, bool squelchright) { m_stream->update(); m_audiosquelch = (squelchleft ? 1 : 0) | (squelchright ? 2 : 0); }
- void set_video_squelch(bool squelch) { m_videosquelch = squelch; }
- void set_slider_speed(INT32 tracks_per_vsync);
- void advance_slider(INT32 numtracks);
- slider_position get_slider_position();
- INT32 generic_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime, player_state_info &curstate);
-
- // general helpers
- bool is_start_of_frame(const vbi_metadata &vbi);
- int frame_from_metadata(const vbi_metadata &metadata);
- int chapter_from_metadata(const vbi_metadata &metadata);
-
- player_state_info m_player_state; // active state
- player_state_info m_saved_state; // saved state during temporary operations
-
-private:
- // internal type definitions
- struct frame_data
- {
- bitmap_yuy16 m_bitmap; // cached bitmap
- bitmap_yuy16 m_visbitmap; // wrapper around bitmap with only visible lines
- UINT8 m_numfields; // number of fields in this frame
- INT32 m_lastfield; // last absolute field number
- };
-
- // internal helpers
- void init_disc();
- void init_video();
- void init_audio();
- void add_and_clamp_track(INT32 delta) { m_curtrack += delta; m_curtrack = MAX(m_curtrack, 1); m_curtrack = MIN(m_curtrack, m_maxtrack - 1); }
- void fillbitmap_yuy16(bitmap_yuy16 &bitmap, UINT8 yval, UINT8 cr, UINT8 cb);
- void update_slider_pos();
- void vblank_state_changed(screen_device &screen, bool vblank_state);
- frame_data &current_frame();
- void read_track_data();
- static void *read_async_static(void *param, int threadid);
- void process_track_data();
- void config_load(int config_type, xml_data_node *parentnode);
- void config_save(int config_type, xml_data_node *parentnode);
-
- // configuration
- laserdisc_get_disc_delegate m_getdisc_callback;
- laserdisc_audio_delegate m_audio_callback; // audio streaming callback
- laserdisc_overlay_config m_orig_config; // original overlay configuration
- UINT32 m_overwidth; // overlay screen width
- UINT32 m_overheight; // overlay screen height
- rectangle m_overclip; // overlay visarea
- screen_update_ind16_delegate m_overupdate_ind16; // overlay update delegate
- screen_update_rgb32_delegate m_overupdate_rgb32; // overlay update delegate
-
- // disc parameters
- chd_file * m_disc; // handle to the disc itself
- dynamic_buffer m_vbidata; // pointer to precomputed VBI data
- int m_width; // width of video
- int m_height; // height of video
- UINT32 m_fps_times_1million; // frame rate of video
- int m_samplerate; // audio samplerate
- int m_readresult; // result of the most recent read
- UINT32 m_chdtracks; // number of tracks in the CHD
- avhuff_decompress_config m_avhuff_config; // decompression configuration
-
- // async operations
- osd_work_queue * m_work_queue; // work queue
- UINT32 m_queued_hunknum; // queued hunk
-
- // core states
- UINT8 m_audiosquelch; // audio squelch state: bit 0 = audio 1, bit 1 = audio 2
- UINT8 m_videosquelch; // video squelch state: bit 0 = on/off
- UINT8 m_fieldnum; // field number (0 or 1)
- INT32 m_curtrack; // current track at this end of this vsync
- UINT32 m_maxtrack; // maximum track number
- attoseconds_t m_attospertrack; // attoseconds per track, or 0 if not moving
- attotime m_sliderupdate; // time of last slider update
-
- // video data
- frame_data m_frame[3]; // circular list of frames
- UINT8 m_videoindex; // index of the current video buffer
- bitmap_yuy16 m_emptyframe; // blank frame
-
- // audio data
- sound_stream * m_stream;
- std::vector<INT16> m_audiobuffer[2]; // buffer for audio samples
- UINT32 m_audiobufsize; // size of buffer
- UINT32 m_audiobufin; // input index
- UINT32 m_audiobufout; // output index
- UINT32 m_audiocursamples; // current samples this track
- UINT32 m_audiomaxsamples; // maximum samples per track
-
- // metadata
- vbi_metadata m_metadata[2]; // metadata parsed from the stream, for each field
-
- // video updating
- bool m_videoenable; // is video enabled?
- render_texture * m_videotex; // texture for the video
- palette_t * m_videopalette; // palette for the video
-
- // overlays
- bool m_overenable; // is the overlay enabled?
- screen_bitmap m_overbitmap[2]; // overlay bitmaps
- int m_overindex; // index of the overlay bitmap
- render_texture * m_overtex; // texture for the overlay
- optional_device<palette_device> m_overlay_palette; // overlay screen palette
-};
-
-// iterator - interface iterator works for subclasses too
-typedef device_interface_iterator<laserdisc_device> laserdisc_device_iterator;
-
-
-
-//**************************************************************************
-// INLINE FUNCTIONS
-//**************************************************************************
-
-//-------------------------------------------------
-// is_start_of_frame - return true if this is
-// the start of a frame
-//-------------------------------------------------
-
-inline bool laserdisc_device::is_start_of_frame(const vbi_metadata &vbi)
-{
- // is it not known if the white flag or the presence of a frame code
- // determines the start of frame; the former seems to be the "official"
- // way, but the latter seems to be the practical implementation
- return (vbi.white || (vbi.line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE);
-}
-
-
-//-------------------------------------------------
-// frame_from_metadata - return the frame number
-// encoded in the metadata, if present, or
-// FRAME_NOT_PRESENT
-//-------------------------------------------------
-
-inline int laserdisc_device::frame_from_metadata(const vbi_metadata &metadata)
-{
- if ((metadata.line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE)
- return VBI_CAV_PICTURE(metadata.line1718);
- else if (metadata.line1718 == VBI_CODE_LEADIN)
- return FRAME_LEAD_IN;
- else if (metadata.line1718 == VBI_CODE_LEADOUT)
- return FRAME_LEAD_OUT;
- return FRAME_NOT_PRESENT;
-}
-
-
-//-------------------------------------------------
-// chapter_from_metadata - return the chapter
-// number encoded in the metadata, if present,
-// or CHAPTER_NOT_PRESENT
-//-------------------------------------------------
-
-inline int laserdisc_device::chapter_from_metadata(const vbi_metadata &metadata)
-{
- if ((metadata.line1718 & VBI_MASK_CHAPTER) == VBI_CODE_CHAPTER)
- return VBI_CHAPTER(metadata.line1718);
- else if (metadata.line1718 == VBI_CODE_LEADIN)
- return CHAPTER_LEAD_IN;
- else if (metadata.line1718 == VBI_CODE_LEADOUT)
- return CHAPTER_LEAD_OUT;
- return CHAPTER_NOT_PRESENT;
-}
-
-
-#endif
diff --git a/src/emu/machine/latch.c b/src/emu/machine/latch.c
deleted file mode 100644
index 55aaf7dfeba..00000000000
--- a/src/emu/machine/latch.c
+++ /dev/null
@@ -1,122 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "emu.h"
-#include "latch.h"
-
-const device_type OUTPUT_LATCH = &device_creator<output_latch_device>;
-
-output_latch_device::output_latch_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, OUTPUT_LATCH, "Output Latch", tag, owner, clock, "output_latch", __FILE__),
- m_resolved(false),
- m_bit0(-1),
- m_bit1(-1),
- m_bit2(-1),
- m_bit3(-1),
- m_bit4(-1),
- m_bit5(-1),
- m_bit6(-1),
- m_bit7(-1),
- m_bit0_handler(*this),
- m_bit1_handler(*this),
- m_bit2_handler(*this),
- m_bit3_handler(*this),
- m_bit4_handler(*this),
- m_bit5_handler(*this),
- m_bit6_handler(*this),
- m_bit7_handler(*this)
-{
-}
-
-void output_latch_device::device_start()
-{
- save_item(NAME(m_bit0));
- save_item(NAME(m_bit1));
- save_item(NAME(m_bit2));
- save_item(NAME(m_bit3));
- save_item(NAME(m_bit4));
- save_item(NAME(m_bit5));
- save_item(NAME(m_bit6));
- save_item(NAME(m_bit7));
-}
-
-void output_latch_device::write(UINT8 data)
-{
- if (!m_resolved)
- {
- // HACK: move to device_config_complete() when devcb supports that
- m_bit0_handler.resolve_safe();
- m_bit1_handler.resolve_safe();
- m_bit2_handler.resolve_safe();
- m_bit3_handler.resolve_safe();
- m_bit4_handler.resolve_safe();
- m_bit5_handler.resolve_safe();
- m_bit6_handler.resolve_safe();
- m_bit7_handler.resolve_safe();
-
- m_resolved = true;
- }
-
- int bit0 = (data >> 0) & 1;
- if (m_bit0 != bit0)
- {
- m_bit0 = bit0;
- if (!m_bit0_handler.isnull())
- m_bit0_handler(bit0);
- }
-
- int bit1 = (data >> 1) & 1;
- if (m_bit1 != bit1)
- {
- m_bit1 = bit1;
- if (!m_bit1_handler.isnull())
- m_bit1_handler(bit1);
- }
-
- int bit2 = (data >> 2) & 1;
- if (m_bit2 != bit2)
- {
- m_bit2 = bit2;
- if (!m_bit2_handler.isnull())
- m_bit2_handler(bit2);
- }
-
- int bit3 = (data >> 3) & 1;
- if (m_bit3 != bit3)
- {
- m_bit3 = bit3;
- if (!m_bit3_handler.isnull())
- m_bit3_handler(bit3);
- }
-
- int bit4 = (data >> 4) & 1;
- if (m_bit4 != bit4)
- {
- m_bit4 = bit4;
- if (!m_bit4_handler.isnull())
- m_bit4_handler(bit4);
- }
-
- int bit5 = (data >> 5) & 1;
- if (m_bit5 != bit5)
- {
- m_bit5 = bit5;
- if (!m_bit5_handler.isnull())
- m_bit5_handler(bit5);
- }
-
- int bit6 = (data >> 6) & 1;
- if (m_bit6 != bit6)
- {
- m_bit6 = bit6;
- if (!m_bit6_handler.isnull())
- m_bit6_handler(bit6);
- }
-
- int bit7 = (data >> 7) & 1;
- if (m_bit7 != bit7)
- {
- m_bit7 = bit7;
- if (!m_bit7_handler.isnull())
- m_bit7_handler(bit7);
- }
-}
diff --git a/src/emu/machine/latch.h b/src/emu/machine/latch.h
deleted file mode 100644
index f184fd3a865..00000000000
--- a/src/emu/machine/latch.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#ifndef __LATCH_H__
-#define __LATCH_H__
-
-#define MCFG_OUTPUT_LATCH_BIT0_HANDLER(_devcb) \
- devcb = &output_latch_device::set_bit0_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_OUTPUT_LATCH_BIT1_HANDLER(_devcb) \
- devcb = &output_latch_device::set_bit1_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_OUTPUT_LATCH_BIT2_HANDLER(_devcb) \
- devcb = &output_latch_device::set_bit2_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_OUTPUT_LATCH_BIT3_HANDLER(_devcb) \
- devcb = &output_latch_device::set_bit3_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_OUTPUT_LATCH_BIT4_HANDLER(_devcb) \
- devcb = &output_latch_device::set_bit4_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_OUTPUT_LATCH_BIT5_HANDLER(_devcb) \
- devcb = &output_latch_device::set_bit5_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_OUTPUT_LATCH_BIT6_HANDLER(_devcb) \
- devcb = &output_latch_device::set_bit6_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_OUTPUT_LATCH_BIT7_HANDLER(_devcb) \
- devcb = &output_latch_device::set_bit7_handler(*device, DEVCB_##_devcb);
-
-class output_latch_device : public device_t
-{
-public:
- output_latch_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_bit0_handler(device_t &device, _Object object) { return downcast<output_latch_device &>(device).m_bit0_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_bit1_handler(device_t &device, _Object object) { return downcast<output_latch_device &>(device).m_bit1_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_bit2_handler(device_t &device, _Object object) { return downcast<output_latch_device &>(device).m_bit2_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_bit3_handler(device_t &device, _Object object) { return downcast<output_latch_device &>(device).m_bit3_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_bit4_handler(device_t &device, _Object object) { return downcast<output_latch_device &>(device).m_bit4_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_bit5_handler(device_t &device, _Object object) { return downcast<output_latch_device &>(device).m_bit5_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_bit6_handler(device_t &device, _Object object) { return downcast<output_latch_device &>(device).m_bit6_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_bit7_handler(device_t &device, _Object object) { return downcast<output_latch_device &>(device).m_bit7_handler.set_callback(object); }
-
- void write(UINT8 data);
- DECLARE_WRITE8_MEMBER(write) { write(data); }
-
-protected:
- virtual void device_start();
-
-private:
- bool m_resolved;
-
- int m_bit0;
- int m_bit1;
- int m_bit2;
- int m_bit3;
- int m_bit4;
- int m_bit5;
- int m_bit6;
- int m_bit7;
-
- devcb_write_line m_bit0_handler;
- devcb_write_line m_bit1_handler;
- devcb_write_line m_bit2_handler;
- devcb_write_line m_bit3_handler;
- devcb_write_line m_bit4_handler;
- devcb_write_line m_bit5_handler;
- devcb_write_line m_bit6_handler;
- devcb_write_line m_bit7_handler;
-};
-
-extern const device_type OUTPUT_LATCH;
-
-#endif
diff --git a/src/emu/machine/latch8.c b/src/emu/machine/latch8.c
deleted file mode 100644
index 9213f8e50c6..00000000000
--- a/src/emu/machine/latch8.c
+++ /dev/null
@@ -1,247 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Couriersud
-/**********************************************************************
-
- 8 bit latch interface and emulation
-
- 2008/08 couriersud
-
-**********************************************************************/
-
-#include "emu.h"
-#include "latch8.h"
-
-void latch8_device::update(UINT8 new_val, UINT8 mask)
-{
- UINT8 old_val = m_value;
-
- m_value = (m_value & ~mask) | (new_val & mask);
-
- if (m_has_write)
- {
- int i;
- UINT8 changed = old_val ^ m_value;
- for (i=0; i<8; i++)
- if (((changed & (1<<i)) != 0)) {
- if (i==0 && !m_write_0.isnull()) m_write_0(machine().driver_data()->generic_space(), m_offset[i] , (m_value >> i) & 1);
- if (i==1 && !m_write_1.isnull()) m_write_1(machine().driver_data()->generic_space(), m_offset[i] , (m_value >> i) & 1);
- if (i==2 && !m_write_2.isnull()) m_write_2(machine().driver_data()->generic_space(), m_offset[i] , (m_value >> i) & 1);
- if (i==3 && !m_write_3.isnull()) m_write_3(machine().driver_data()->generic_space(), m_offset[i] , (m_value >> i) & 1);
- if (i==4 && !m_write_4.isnull()) m_write_4(machine().driver_data()->generic_space(), m_offset[i] , (m_value >> i) & 1);
- if (i==5 && !m_write_5.isnull()) m_write_5(machine().driver_data()->generic_space(), m_offset[i] , (m_value >> i) & 1);
- if (i==6 && !m_write_6.isnull()) m_write_6(machine().driver_data()->generic_space(), m_offset[i] , (m_value >> i) & 1);
- if (i==7 && !m_write_7.isnull()) m_write_7(machine().driver_data()->generic_space(), m_offset[i] , (m_value >> i) & 1);
- }
- }
-}
-
-TIMER_CALLBACK_MEMBER( latch8_device::timerproc )
-{
- UINT8 new_val = param & 0xFF;
- UINT8 mask = param >> 8;
-
- update( new_val, mask);
-}
-
-/* ----------------------------------------------------------------------- */
-
-READ8_MEMBER( latch8_device::read )
-{
- UINT8 res;
-
- assert(offset == 0);
-
- res = m_value;
- if (m_has_read)
- {
- int i;
- for (i=0; i<8; i++)
- {
- if (i==0 && !m_read_0.isnull()) { res &= ~( 1 << i); res |= ((m_read_0(space, 0, 0xff) >> m_offset[i]) & 0x01) << i; }
- if (i==1 && !m_read_1.isnull()) { res &= ~( 1 << i); res |= ((m_read_1(space, 0, 0xff) >> m_offset[i]) & 0x01) << i; }
- if (i==2 && !m_read_2.isnull()) { res &= ~( 1 << i); res |= ((m_read_2(space, 0, 0xff) >> m_offset[i]) & 0x01) << i; }
- if (i==3 && !m_read_3.isnull()) { res &= ~( 1 << i); res |= ((m_read_3(space, 0, 0xff) >> m_offset[i]) & 0x01) << i; }
- if (i==4 && !m_read_4.isnull()) { res &= ~( 1 << i); res |= ((m_read_4(space, 0, 0xff) >> m_offset[i]) & 0x01) << i; }
- if (i==5 && !m_read_5.isnull()) { res &= ~( 1 << i); res |= ((m_read_5(space, 0, 0xff) >> m_offset[i]) & 0x01) << i; }
- if (i==6 && !m_read_6.isnull()) { res &= ~( 1 << i); res |= ((m_read_6(space, 0, 0xff) >> m_offset[i]) & 0x01) << i; }
- if (i==7 && !m_read_7.isnull()) { res &= ~( 1 << i); res |= ((m_read_7(space, 0, 0xff) >> m_offset[i]) & 0x01) << i;}
- }
- }
- return (res & ~m_maskout) ^ m_xorvalue;
-}
-
-
-WRITE8_MEMBER( latch8_device::write )
-{
- assert(offset == 0);
-
- if (m_nosync != 0xff)
- machine().scheduler().synchronize(timer_expired_delegate(FUNC(latch8_device::timerproc),this), (0xFF << 8) | data);
- else
- update(data, 0xFF);
-}
-
-
-WRITE8_MEMBER( latch8_device::reset_w )
-{
- assert(offset == 0);
-
- m_value = 0;
-}
-
-/* read bit x */
-/* return (latch >> x) & 0x01 */
-
-UINT8 latch8_device::bitx_r( offs_t offset, int bit)
-{
- assert( offset == 0);
-
- return (m_value >> bit) & 0x01;
-}
-
-READ8_MEMBER( latch8_device::bit0_r) { return bitx_r(offset, 0); }
-READ8_MEMBER( latch8_device::bit1_r) { return bitx_r(offset, 1); }
-READ8_MEMBER( latch8_device::bit2_r) { return bitx_r(offset, 2); }
-READ8_MEMBER( latch8_device::bit3_r) { return bitx_r(offset, 3); }
-READ8_MEMBER( latch8_device::bit4_r) { return bitx_r(offset, 4); }
-READ8_MEMBER( latch8_device::bit5_r) { return bitx_r(offset, 5); }
-READ8_MEMBER( latch8_device::bit6_r) { return bitx_r(offset, 6); }
-READ8_MEMBER( latch8_device::bit7_r) { return bitx_r(offset, 7); }
-
-READ8_MEMBER( latch8_device::bit0_q_r) { return bitx_r(offset, 0) ^ 1; }
-READ8_MEMBER( latch8_device::bit1_q_r) { return bitx_r(offset, 1) ^ 1; }
-READ8_MEMBER( latch8_device::bit2_q_r) { return bitx_r(offset, 2) ^ 1; }
-READ8_MEMBER( latch8_device::bit3_q_r) { return bitx_r(offset, 3) ^ 1; }
-READ8_MEMBER( latch8_device::bit4_q_r) { return bitx_r(offset, 4) ^ 1; }
-READ8_MEMBER( latch8_device::bit5_q_r) { return bitx_r(offset, 5) ^ 1; }
-READ8_MEMBER( latch8_device::bit6_q_r) { return bitx_r(offset, 6) ^ 1; }
-READ8_MEMBER( latch8_device::bit7_q_r) { return bitx_r(offset, 7) ^ 1; }
-
-/* write bit x from data into bit determined by offset */
-/* latch = (latch & ~(1<<offset)) | (((data >> x) & 0x01) << offset) */
-
-void latch8_device::bitx_w(int bit, offs_t offset, UINT8 data)
-{
- UINT8 mask = (1<<offset);
- UINT8 masked_data = (((data >> bit) & 0x01) << offset);
-
- assert( offset < 8);
-
- /* No need to synchronize ? */
- if (m_nosync & mask)
- update(masked_data, mask);
- else
- machine().scheduler().synchronize(timer_expired_delegate(FUNC(latch8_device::timerproc),this), (mask << 8) | masked_data);
-}
-
-WRITE8_MEMBER( latch8_device::bit0_w ) { bitx_w(0, offset, data); }
-WRITE8_MEMBER( latch8_device::bit1_w ) { bitx_w(1, offset, data); }
-WRITE8_MEMBER( latch8_device::bit2_w ) { bitx_w(2, offset, data); }
-WRITE8_MEMBER( latch8_device::bit3_w ) { bitx_w(3, offset, data); }
-WRITE8_MEMBER( latch8_device::bit4_w ) { bitx_w(4, offset, data); }
-WRITE8_MEMBER( latch8_device::bit5_w ) { bitx_w(5, offset, data); }
-WRITE8_MEMBER( latch8_device::bit6_w ) { bitx_w(6, offset, data); }
-WRITE8_MEMBER( latch8_device::bit7_w ) { bitx_w(7, offset, data); }
-
-const device_type LATCH8 = &device_creator<latch8_device>;
-
-latch8_device::latch8_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, LATCH8, "8 bit latch", tag, owner, clock, "latch8", __FILE__),
- m_value(0),
- m_has_write(0),
- m_has_read(0),
- m_maskout(0),
- m_xorvalue(0),
- m_nosync(0),
- m_write_0(*this),
- m_write_1(*this),
- m_write_2(*this),
- m_write_3(*this),
- m_write_4(*this),
- m_write_5(*this),
- m_write_6(*this),
- m_write_7(*this),
- m_read_0(*this),
- m_read_1(*this),
- m_read_2(*this),
- m_read_3(*this),
- m_read_4(*this),
- m_read_5(*this),
- m_read_6(*this),
- m_read_7(*this)
-{
- memset(m_offset, 0, sizeof(m_offset));
-}
-
-
-//-------------------------------------------------
-// device_validity_check - validate device
-// configuration
-//-------------------------------------------------
-
-void latch8_device::device_validity_check(validity_checker &valid) const
-{
- if (!m_read_0.isnull() && !m_write_0.isnull()) osd_printf_error("Device %s: Bit 0 already has a handler.\n", tag());
- if (!m_read_1.isnull() && !m_write_1.isnull()) osd_printf_error("Device %s: Bit 1 already has a handler.\n", tag());
- if (!m_read_2.isnull() && !m_write_2.isnull()) osd_printf_error("Device %s: Bit 2 already has a handler.\n", tag());
- if (!m_read_3.isnull() && !m_write_3.isnull()) osd_printf_error("Device %s: Bit 3 already has a handler.\n", tag());
- if (!m_read_4.isnull() && !m_write_4.isnull()) osd_printf_error("Device %s: Bit 4 already has a handler.\n", tag());
- if (!m_read_5.isnull() && !m_write_5.isnull()) osd_printf_error("Device %s: Bit 5 already has a handler.\n", tag());
- if (!m_read_6.isnull() && !m_write_6.isnull()) osd_printf_error("Device %s: Bit 6 already has a handler.\n", tag());
- if (!m_read_7.isnull() && !m_write_7.isnull()) osd_printf_error("Device %s: Bit 7 already has a handler.\n", tag());
-}
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void latch8_device::device_start()
-{
- m_write_0.resolve();
- m_write_1.resolve();
- m_write_2.resolve();
- m_write_3.resolve();
- m_write_4.resolve();
- m_write_5.resolve();
- m_write_6.resolve();
- m_write_7.resolve();
-
- m_read_0.resolve();
- m_read_1.resolve();
- m_read_2.resolve();
- m_read_3.resolve();
- m_read_4.resolve();
- m_read_5.resolve();
- m_read_6.resolve();
- m_read_7.resolve();
-
- /* setup nodemap */
- if (!m_write_0.isnull()) m_has_write = 1;
- if (!m_write_1.isnull()) m_has_write = 1;
- if (!m_write_2.isnull()) m_has_write = 1;
- if (!m_write_3.isnull()) m_has_write = 1;
- if (!m_write_4.isnull()) m_has_write = 1;
- if (!m_write_5.isnull()) m_has_write = 1;
- if (!m_write_6.isnull()) m_has_write = 1;
- if (!m_write_7.isnull()) m_has_write = 1;
-
- /* setup device read handlers */
- if (!m_read_0.isnull()) m_has_read = 1;
- if (!m_read_1.isnull()) m_has_read = 1;
- if (!m_read_2.isnull()) m_has_read = 1;
- if (!m_read_3.isnull()) m_has_read = 1;
- if (!m_read_4.isnull()) m_has_read = 1;
- if (!m_read_5.isnull()) m_has_read = 1;
- if (!m_read_6.isnull()) m_has_read = 1;
- if (!m_read_7.isnull()) m_has_read = 1;
-
- save_item(NAME(m_value));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void latch8_device::device_reset()
-{
- m_value = 0;
-}
diff --git a/src/emu/machine/latch8.h b/src/emu/machine/latch8.h
deleted file mode 100644
index 6c82bd0689d..00000000000
--- a/src/emu/machine/latch8.h
+++ /dev/null
@@ -1,228 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Couriersud
-/**********************************************************************
-
- 8 bit latch interface and emulation
-
- Generic emulation of 74LS174/175, 74LS259 and other latches.
- Apart from providing synched latch operation, these
- latches can be configured to read their input bitwise from other
- devices as well and individual bits can be connected to
- discrete nodes.
-
- Please see audio/dkong.c for examples.
-
-**********************************************************************/
-
-#ifndef __LATCH8_H_
-#define __LATCH8_H_
-
-#include "sound/discrete.h"
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-class latch8_device : public device_t
-{
-public:
- latch8_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-
- /* write & read full byte */
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- /* reset the latch */
-
- DECLARE_WRITE8_MEMBER( reset_w );
-
- /* read bit x */
- /* return (latch >> x) & 0x01 */
-
- DECLARE_READ8_MEMBER( bit0_r );
- DECLARE_READ8_MEMBER( bit1_r );
- DECLARE_READ8_MEMBER( bit2_r );
- DECLARE_READ8_MEMBER( bit3_r );
- DECLARE_READ8_MEMBER( bit4_r );
- DECLARE_READ8_MEMBER( bit5_r );
- DECLARE_READ8_MEMBER( bit6_r );
- DECLARE_READ8_MEMBER( bit7_r );
-
- /* read inverted bit x */
- /* return (latch >> x) & 0x01 */
-
- DECLARE_READ8_MEMBER( bit0_q_r );
- DECLARE_READ8_MEMBER( bit1_q_r );
- DECLARE_READ8_MEMBER( bit2_q_r );
- DECLARE_READ8_MEMBER( bit3_q_r );
- DECLARE_READ8_MEMBER( bit4_q_r );
- DECLARE_READ8_MEMBER( bit5_q_r );
- DECLARE_READ8_MEMBER( bit6_q_r );
- DECLARE_READ8_MEMBER( bit7_q_r );
-
- /* write bit x from data into bit determined by offset */
- /* latch = (latch & ~(1<<offset)) | (((data >> x) & 0x01) << offset) */
-
- DECLARE_WRITE8_MEMBER( bit0_w );
- DECLARE_WRITE8_MEMBER( bit1_w );
- DECLARE_WRITE8_MEMBER( bit2_w );
- DECLARE_WRITE8_MEMBER( bit3_w );
- DECLARE_WRITE8_MEMBER( bit4_w );
- DECLARE_WRITE8_MEMBER( bit5_w );
- DECLARE_WRITE8_MEMBER( bit6_w );
- DECLARE_WRITE8_MEMBER( bit7_w );
-
- static void set_maskout(device_t &device, UINT32 maskout) { downcast<latch8_device &>(device).m_maskout = maskout; }
- static void set_xorvalue(device_t &device, UINT32 xorvalue) { downcast<latch8_device &>(device).m_xorvalue = xorvalue; }
- static void set_nosync(device_t &device, UINT32 nosync) { downcast<latch8_device &>(device).m_nosync = nosync; }
-
- template<class _Object> static devcb_base &set_write_0(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[0] = offset; return downcast<latch8_device &>(device).m_write_0.set_callback(object); }
- template<class _Object> static devcb_base &set_write_1(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[1] = offset; return downcast<latch8_device &>(device).m_write_1.set_callback(object); }
- template<class _Object> static devcb_base &set_write_2(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[2] = offset; return downcast<latch8_device &>(device).m_write_2.set_callback(object); }
- template<class _Object> static devcb_base &set_write_3(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[3] = offset; return downcast<latch8_device &>(device).m_write_3.set_callback(object); }
- template<class _Object> static devcb_base &set_write_4(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[4] = offset; return downcast<latch8_device &>(device).m_write_4.set_callback(object); }
- template<class _Object> static devcb_base &set_write_5(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[5] = offset; return downcast<latch8_device &>(device).m_write_5.set_callback(object); }
- template<class _Object> static devcb_base &set_write_6(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[6] = offset; return downcast<latch8_device &>(device).m_write_6.set_callback(object); }
- template<class _Object> static devcb_base &set_write_7(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[7] = offset; return downcast<latch8_device &>(device).m_write_7.set_callback(object); }
-
- template<class _Object> static devcb_base &set_read_0(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[0] = offset; return downcast<latch8_device &>(device).m_read_0.set_callback(object); }
- template<class _Object> static devcb_base &set_read_1(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[1] = offset; return downcast<latch8_device &>(device).m_read_1.set_callback(object); }
- template<class _Object> static devcb_base &set_read_2(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[2] = offset; return downcast<latch8_device &>(device).m_read_2.set_callback(object); }
- template<class _Object> static devcb_base &set_read_3(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[3] = offset; return downcast<latch8_device &>(device).m_read_3.set_callback(object); }
- template<class _Object> static devcb_base &set_read_4(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[4] = offset; return downcast<latch8_device &>(device).m_read_4.set_callback(object); }
- template<class _Object> static devcb_base &set_read_5(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[5] = offset; return downcast<latch8_device &>(device).m_read_5.set_callback(object); }
- template<class _Object> static devcb_base &set_read_6(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[6] = offset; return downcast<latch8_device &>(device).m_read_6.set_callback(object); }
- template<class _Object> static devcb_base &set_read_7(device_t &device, _Object object, UINT32 offset) { downcast<latch8_device &>(device).m_offset[7] = offset; return downcast<latch8_device &>(device).m_read_7.set_callback(object); }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_validity_check(validity_checker &valid) const;
-
- TIMER_CALLBACK_MEMBER( timerproc );
- void update(UINT8 new_val, UINT8 mask);
- inline UINT8 bitx_r( offs_t offset, int bit);
- inline void bitx_w(int bit, offs_t offset, UINT8 data);
-private:
- // internal state
- UINT8 m_value;
- UINT8 m_has_write;
- UINT8 m_has_read;
-
- /* only for byte reads, does not affect bit reads and node_map */
- UINT32 m_maskout;
- UINT32 m_xorvalue; /* after mask */
- UINT32 m_nosync;
-
- devcb_write8 m_write_0;
- devcb_write8 m_write_1;
- devcb_write8 m_write_2;
- devcb_write8 m_write_3;
- devcb_write8 m_write_4;
- devcb_write8 m_write_5;
- devcb_write8 m_write_6;
- devcb_write8 m_write_7;
-
- devcb_read8 m_read_0;
- devcb_read8 m_read_1;
- devcb_read8 m_read_2;
- devcb_read8 m_read_3;
- devcb_read8 m_read_4;
- devcb_read8 m_read_5;
- devcb_read8 m_read_6;
- devcb_read8 m_read_7;
-
- UINT32 m_offset[8];
-};
-
-extern const device_type LATCH8;
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-/* add device */
-#define MCFG_LATCH8_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, LATCH8, 0)
-
-/* Bit mask specifying bits to be masked *out* */
-#define MCFG_LATCH8_MASKOUT(_maskout) \
- latch8_device::set_maskout(*device, _maskout);
-
-/* Bit mask specifying bits to be inverted */
-#define MCFG_LATCH8_INVERT(_xor) \
- latch8_device::set_xorvalue(*device, _xor);
-
-/* Bit mask specifying bits not needing cpu synchronization. */
-#define MCFG_LATCH8_NOSYNC(_nosync) \
- latch8_device::set_nosync(*device, _nosync);
-
-/* Write bit to discrete node */
-#define MCFG_LATCH8_WRITE_0(_devcb, _node) \
- devcb = &latch8_device::set_write_0(*device, DEVCB_##_devcb, _node);
-
-#define MCFG_LATCH8_WRITE_1(_devcb, _node) \
- devcb = &latch8_device::set_write_1(*device, DEVCB_##_devcb, _node);
-
-#define MCFG_LATCH8_WRITE_2(_devcb, _node) \
- devcb = &latch8_device::set_write_2(*device, DEVCB_##_devcb, _node);
-
-#define MCFG_LATCH8_WRITE_3(_devcb, _node) \
- devcb = &latch8_device::set_write_3(*device, DEVCB_##_devcb, _node);
-
-#define MCFG_LATCH8_WRITE_4(_devcb, _node) \
- devcb = &latch8_device::set_write_4(*device, DEVCB_##_devcb, _node);
-
-#define MCFG_LATCH8_WRITE_5(_devcb, _node) \
- devcb = &latch8_device::set_write_5(*device, DEVCB_##_devcb, _node);
-
-#define MCFG_LATCH8_WRITE_6(_devcb, _node) \
- devcb = &latch8_device::set_write_6(*device, DEVCB_##_devcb, _node);
-
-#define MCFG_LATCH8_WRITE_7(_devcb, _node) \
- devcb = &latch8_device::set_write_7(*device, DEVCB_##_devcb, _node);
-
-/* Upon read, replace bits by reading from another device handler */
-#define MCFG_LATCH8_READ_0(_devcb, _from_bit) \
- devcb = &latch8_device::set_read_0(*device, DEVCB_##_devcb, _from_bit);
-
-#define MCFG_LATCH8_READ_1(_devcb, _from_bit) \
- devcb = &latch8_device::set_read_1(*device, DEVCB_##_devcb, _from_bit);
-
-#define MCFG_LATCH8_READ_2(_devcb, _from_bit) \
- devcb = &latch8_device::set_read_2(*device, DEVCB_##_devcb, _from_bit);
-
-#define MCFG_LATCH8_READ_3(_devcb, _from_bit) \
- devcb = &latch8_device::set_read_3(*device, DEVCB_##_devcb, _from_bit);
-
-#define MCFG_LATCH8_READ_4(_devcb, _from_bit) \
- devcb = &latch8_device::set_read_4(*device, DEVCB_##_devcb, _from_bit);
-
-#define MCFG_LATCH8_READ_5(_devcb, _from_bit) \
- devcb = &latch8_device::set_read_5(*device, DEVCB_##_devcb, _from_bit);
-
-#define MCFG_LATCH8_READ_6(_devcb, _from_bit) \
- devcb = &latch8_device::set_read_6(*device, DEVCB_##_devcb, _from_bit);
-
-#define MCFG_LATCH8_READ_7(_devcb, _from_bit) \
- devcb = &latch8_device::set_read_7(*device, DEVCB_##_devcb, _from_bit);
-
-
-/* Accessor macros */
-
-#define AM_LATCH8_READ(_tag) \
- AM_DEVREAD(_tag, latch8_device, read)
-
-#define AM_LATCH8_READBIT(_tag, _bit) \
- AM_DEVREAD(_tag, latch8_device, bit ## _bit ## _q_r)
-
-#define AM_LATCH8_WRITE(_tag) \
- AM_DEVWRITE(_tag, latch8_device, write)
-
-#define AM_LATCH8_READWRITE(_tag) \
- AM_DEVREADWRITE(_tag, latch8_device, read, write)
-
-#endif /* __LATCH8_H_ */
diff --git a/src/emu/machine/lc89510.c b/src/emu/machine/lc89510.c
deleted file mode 100644
index 9ad9f4cb37a..00000000000
--- a/src/emu/machine/lc89510.c
+++ /dev/null
@@ -1,26 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* LC89510 CD Controller
- based off old NeoCD emulator code, adapted to SegaCD, needs reworking to work with NeoCD again
-
-*/
-
-
-#include "emu.h"
-#include "lc89510.h"
-
-const device_type LC89510 = &device_creator<lc89510_device>;
-
-lc89510_device::lc89510_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, LC89510, "lc89510_device", tag, owner, clock, "lc89510", __FILE__)
-{
-}
-
-
-void lc89510_device::device_start()
-{
-}
-
-void lc89510_device::device_reset()
-{
-}
diff --git a/src/emu/machine/lc89510.h b/src/emu/machine/lc89510.h
deleted file mode 100644
index 4866cb24f76..00000000000
--- a/src/emu/machine/lc89510.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-
-
-
-class lc89510_device : public device_t
-{
-public:
- lc89510_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
-private:
-
-
-};
-
-
-extern const device_type LC89510;
diff --git a/src/emu/machine/ldpr8210.c b/src/emu/machine/ldpr8210.c
deleted file mode 100644
index 967dac974e7..00000000000
--- a/src/emu/machine/ldpr8210.c
+++ /dev/null
@@ -1,1107 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- ldpr8210.c
-
- Pioneer PR-8210 laserdisc emulation.
-
-**************************************************************************
-
- Still to do:
-
- * implement SLOW TRG
- * figure out Simutrek without jump hack
- * figure out serial protocol issues (current hack works nicely)
- * determine actual slow/fast speeds
-
-*************************************************************************/
-
-
-#include "emu.h"
-#include "ldpr8210.h"
-
-
-
-//**************************************************************************
-// DEBUGGING
-//**************************************************************************
-
-#define LOG_VBLANK_VBI 0
-#define LOG_SERIAL 0
-#define LOG_SIMUTREK 0
-
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-// Overlay constants, related to 720-pixel wide capture
-#define OVERLAY_GROUP0_X (82.0f / 720.0f)
-#define OVERLAY_GROUP1_X (162.0f / 720.0f)
-#define OVERLAY_GROUP2_X (322.0f / 720.0f)
-#define OVERLAY_GROUP3_X (483.0f / 720.0f)
-#define OVERLAY_Y (104/2)
-#define OVERLAY_PIXEL_WIDTH (4.5f / 720.0f)
-#define OVERLAY_PIXEL_HEIGHT 2
-#define OVERLAY_X_PIXELS 5
-#define OVERLAY_Y_PIXELS 7
-
-// scanning speeds
-#define SCAN_SPEED (2000 / 30) // 2000 frames/second
-#define SEEK_FAST_SPEED (4000 / 30) // 4000 frames/second
-
-// serial timing, mostly from the service manual, derived from the XTAL
-#define SERIAL_CLOCK XTAL_455kHz
-#define SERIAL_0_BIT_TIME attotime::from_hz((double)SERIAL_CLOCK / 512)
-#define SERIAL_1_BIT_TIME attotime::from_hz((double)SERIAL_CLOCK / 1024)
-#define SERIAL_MIDPOINT_TIME attotime::from_hz((double)SERIAL_CLOCK / 600)
-#define SERIAL_MAX_BIT_TIME attotime::from_hz((double)SERIAL_CLOCK / 4096)
-#define SERIAL_MAX_WORD_TIME attotime::from_hz((double)SERIAL_CLOCK / 11520)
-#define SERIAL_REJECT_DUPLICATE_TIME attotime::from_hz((double)SERIAL_CLOCK / 11520 / 4)
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// devices
-const device_type PIONEER_PR8210 = &device_creator<pioneer_pr8210_device>;
-const device_type SIMUTREK_SPECIAL = &device_creator<simutrek_special_device>;
-
-
-// bitmaps for the characters
-static const UINT8 text_bitmap[0x40][7] =
-{
- { 0 }, // @
- { 0x20,0x50,0x88,0x88,0xf8,0x88,0x88 }, // A
- { 0 }, // B
- { 0x70,0x88,0x80,0x80,0x80,0x88,0x70 }, // C
- { 0 }, // D
- { 0xf8,0x80,0x80,0xf0,0x80,0x80,0xf8 }, // E
- { 0xf8,0x80,0x80,0xf0,0x80,0x80,0x80 }, // F
- { 0 }, // G
- { 0x88,0x88,0x88,0xf8,0x88,0x88,0x88 }, // H
- { 0 }, // I
- { 0 }, // J
- { 0 }, // K
- { 0 }, // L
- { 0x88,0xd8,0xa8,0xa8,0xa8,0x88,0x88 }, // M
- { 0 }, // N
- { 0 }, // O
- { 0xf0,0x88,0x88,0xf0,0x80,0x80,0x80 }, // P
- { 0 }, // Q
- { 0xf0,0x88,0x88,0xf0,0xa0,0x90,0x88 }, // R
- { 0x70,0x88,0x80,0x70,0x08,0x88,0x70 }, // S
- { 0 }, // T
- { 0 }, // U
- { 0 }, // V
- { 0 }, // W
- { 0 }, // X
- { 0 }, // Y
- { 0 }, // Z
- { 0 }, // [
- { 0 }, // <backslash>
- { 0 }, // ]
- { 0 }, // ^
- { 0 }, // _
-
- { 0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // <space>
- { 0 }, // !
- { 0 }, // "
- { 0 }, // #
- { 0 }, // $
- { 0 }, // %
- { 0 }, // &
- { 0 }, // '
- { 0 }, // (
- { 0 }, // )
- { 0 }, // *
- { 0 }, // +
- { 0 }, // ,
- { 0 }, // -
- { 0x00,0x00,0x00,0x00,0x00,0x00,0x40 }, // .
- { 0 }, // /
- { 0x70,0x88,0x88,0x88,0x88,0x88,0x70 }, // 0
- { 0x20,0x60,0x20,0x20,0x20,0x20,0x70 }, // 1
- { 0x70,0x88,0x08,0x70,0x80,0x80,0xf8 }, // 2
- { 0xf8,0x08,0x10,0x30,0x08,0x88,0x70 }, // 3
- { 0x10,0x30,0x50,0x90,0xf8,0x10,0x10 }, // 4
- { 0xf8,0x80,0xf0,0x08,0x08,0x88,0x70 }, // 5
- { 0x78,0x80,0x80,0xf0,0x88,0x88,0x70 }, // 6
- { 0xf8,0x08,0x08,0x10,0x20,0x40,0x80 }, // 7
- { 0x70,0x88,0x88,0x70,0x88,0x88,0x70 }, // 8
- { 0x70,0x88,0x88,0x78,0x08,0x08,0xf0 }, // 9
- { 0 }, // :
- { 0 }, // ;
- { 0 }, // <
- { 0 }, // =
- { 0 }, // >
- { 0 } // ?
-};
-
-
-
-//**************************************************************************
-// PR-8210 ROM AND MACHINE INTERFACES
-//**************************************************************************
-
-static ADDRESS_MAP_START( pr8210_portmap, AS_IO, 8, pioneer_pr8210_device )
- AM_RANGE(0x00, 0xff) AM_READWRITE(i8049_pia_r, i8049_pia_w)
- AM_RANGE(MCS48_PORT_BUS, MCS48_PORT_BUS) AM_READ(i8049_bus_r)
- AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(i8049_port1_w)
- AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(i8049_port2_w)
- AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_READ(i8049_t0_r)
- AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(i8049_t1_r)
-ADDRESS_MAP_END
-
-
-static MACHINE_CONFIG_FRAGMENT( pr8210 )
- MCFG_CPU_ADD("pr8210", I8049, XTAL_4_41MHz)
- MCFG_CPU_IO_MAP(pr8210_portmap)
-MACHINE_CONFIG_END
-
-
-ROM_START( pr8210 )
- ROM_REGION( 0x800, "pr8210", 0 )
- ROM_LOAD( "pr-8210_mcu_ud6005a.bin", 0x000, 0x800, CRC(120fa83b) SHA1(b514326ca1f52d6d89056868f9d17eabd4e3f31d) )
-ROM_END
-
-
-
-//**************************************************************************
-// PIONEER PR-8210 IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// pioneer_pr8210_device - constructor
-//-------------------------------------------------
-
-pioneer_pr8210_device::pioneer_pr8210_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : laserdisc_device(mconfig, PIONEER_PR8210, "Pioneer PR-8210", tag, owner, clock, "pr8210", __FILE__),
- m_control(0),
- m_lastcommand(0),
- m_accumulator(0),
- m_lastcommandtime(attotime::zero),
- m_lastbittime(attotime::zero),
- m_firstbittime(attotime::zero),
- m_i8049_cpu(*this, "pr8210"),
- m_slowtrg(attotime::zero),
- m_vsync(false),
- m_i8049_port1(0),
- m_i8049_port2(0)
-{
-}
-
-pioneer_pr8210_device::pioneer_pr8210_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : laserdisc_device(mconfig, type, name, tag, owner, clock, shortname, source),
- m_control(0),
- m_lastcommand(0),
- m_accumulator(0),
- m_lastcommandtime(attotime::zero),
- m_lastbittime(attotime::zero),
- m_firstbittime(attotime::zero),
- m_i8049_cpu(*this, "pr8210"),
- m_slowtrg(attotime::zero),
- m_vsync(false),
- m_i8049_port1(0),
- m_i8049_port2(0)
-{
-}
-
-
-//-------------------------------------------------
-// control_w - write callback when the CONTROL
-// line is toggled
-//-------------------------------------------------
-
-void pioneer_pr8210_device::control_w(UINT8 data)
-{
- // set the new value and remember the last
- UINT8 prev = m_control;
- m_control = data;
-
- // handle rising edge
- if (prev != ASSERT_LINE && data == ASSERT_LINE)
- {
- // get the time difference from the last assert
- // and update our internal command time
- attotime curtime = machine().time();
- attotime delta = curtime - m_lastbittime;
- m_lastbittime = curtime;
-
- // if we timed out since the first bit, reset the accumulator
- attotime overalldelta = curtime - m_firstbittime;
- if (overalldelta > SERIAL_MAX_WORD_TIME || delta > SERIAL_MAX_BIT_TIME)
- {
- m_firstbittime = curtime;
- m_accumulator = 0x5555;
- if (LOG_SERIAL)
- printf("Reset accumulator\n");
- }
-
- // 0 bit delta is 1.05 msec, 1 bit delta is 2.11 msec
- int longpulse = (delta < SERIAL_MIDPOINT_TIME) ? 0 : 1;
- m_accumulator = (m_accumulator << 1) | longpulse;
-
- // log the deltas for debugging
- if (LOG_SERIAL)
- {
- int usecdiff = (int)(delta.attoseconds() / ATTOSECONDS_IN_USEC(1));
- printf("bitdelta = %5d (%d) - accum = %04X\n", usecdiff, longpulse, m_accumulator);
- }
-
- // if we have a complete command, signal it
- // a complete command is 0,0,1 followed by 5 bits, followed by 0,0
- if ((m_accumulator & 0x383) == 0x80)
- {
- // data is stored to the PIA in bit-reverse order
- UINT8 newcommand = (m_accumulator >> 2) & 0x1f;
- m_pia.porta = BITSWAP8(newcommand, 0,1,2,3,4,5,6,7);
-
- // the MCU logic requires a 0 to execute many commands; however, nobody
- // consistently sends a 0, whereas they do tend to send duplicate commands...
- // if we assume that each duplicate causes a 0, we get the correct results
- attotime rejectuntil = m_lastcommandtime + SERIAL_REJECT_DUPLICATE_TIME;
- m_lastcommandtime = curtime;
- if (m_pia.porta == m_lastcommand && curtime < rejectuntil)
- m_pia.porta = 0x00;
- else
- m_lastcommand = m_pia.porta;
-
- // log the command and wait for a keypress
- if (LOG_SERIAL)
- printf("--- Command = %02X\n", m_pia.porta >> 3);
-
- // reset the first bit time so that the accumulator clears on the next write
- m_firstbittime = curtime - SERIAL_MAX_WORD_TIME;
- }
- }
-}
-
-
-//-------------------------------------------------
-// device_start - device initialization
-//-------------------------------------------------
-
-void pioneer_pr8210_device::device_start()
-{
- // pass through to the parent
- laserdisc_device::device_start();
-}
-
-
-//-------------------------------------------------
-// device_reset - device reset
-//-------------------------------------------------
-
-void pioneer_pr8210_device::device_reset()
-{
- // pass through to the parent
- laserdisc_device::device_reset();
-
- // reset our state
- attotime curtime = machine().time();
- m_lastcommandtime = curtime;
- m_firstbittime = curtime;
- m_lastbittime = curtime;
- m_slowtrg = curtime;
-}
-
-
-//-------------------------------------------------
-// device_timer - handle timers set by this
-// device
-//-------------------------------------------------
-
-void pioneer_pr8210_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- // update the VBI data in the PIA as soon as it is ready;
- // this must happen early in the frame because the player
- // logic relies on fetching it here
- case TID_VBI_DATA_FETCH:
-
- // logging
- if (LOG_VBLANK_VBI)
- {
- UINT32 line1718 = get_field_code(LASERDISC_CODE_LINE1718, FALSE);
- if ((line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE)
- printf("%3d:VBI(%05d)\n", screen().vpos(), VBI_CAV_PICTURE(line1718));
- else
- printf("%3d:VBI()\n", screen().vpos());
- }
-
- // update PIA registers based on vbi code
- m_pia.vbi1 = 0xff;
- m_pia.vbi2 = 0xff;
- if (focus_on() && laser_on())
- {
- UINT32 line16 = get_field_code(LASERDISC_CODE_LINE16, FALSE);
- UINT32 line1718 = get_field_code(LASERDISC_CODE_LINE1718, FALSE);
- if (line1718 == VBI_CODE_LEADIN)
- m_pia.vbi1 &= ~0x01;
- if (line1718 == VBI_CODE_LEADOUT)
- m_pia.vbi1 &= ~0x02;
- if (line16 == VBI_CODE_STOP)
- m_pia.vbi1 &= ~0x04;
- // unsure what this bit means: m_pia.vbi1 &= ~0x08;
- if ((line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE)
- {
- m_pia.vbi1 &= ~0x10;
- m_pia.frame[2] = 0xf0 | ((line1718 >> 16) & 0x07);
- m_pia.frame[3] = 0xf0 | ((line1718 >> 12) & 0x0f);
- m_pia.frame[4] = 0xf0 | ((line1718 >> 8) & 0x0f);
- m_pia.frame[5] = 0xf0 | ((line1718 >> 4) & 0x0f);
- m_pia.frame[6] = 0xf0 | ((line1718 >> 0) & 0x0f);
- }
- if ((line1718 & VBI_MASK_CHAPTER) == VBI_CODE_CHAPTER)
- {
- m_pia.vbi2 &= ~0x01;
- m_pia.frame[0] = 0xf0 | ((line1718 >> 16) & 0x07);
- m_pia.frame[1] = 0xf0 | ((line1718 >> 12) & 0x0f);
- }
- }
- break;
-
- // clear the VSYNC flag
- case TID_VSYNC_OFF:
- m_vsync = false;
- break;
-
- // pass everything else onto the parent
- default:
- laserdisc_device::device_timer(timer, id, param, ptr);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// device_rom_region - return a pointer to our
-// ROM region definitions
-//-------------------------------------------------
-
-const rom_entry *pioneer_pr8210_device::device_rom_region() const
-{
- return ROM_NAME(pr8210);
-}
-
-
-//-------------------------------------------------
-// device_mconfig_additions - return a pointer to
-// our machine config fragment
-//-------------------------------------------------
-
-machine_config_constructor pioneer_pr8210_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME(pr8210);
-}
-
-
-//-------------------------------------------------
-// player_vsync - VSYNC callback, called at the
-// start of the blanking period
-//-------------------------------------------------
-
-void pioneer_pr8210_device::player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime)
-{
- // logging
- if (LOG_VBLANK_VBI)
- {
- if ((vbi.line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE)
- printf("%3d:VSYNC(%d,%05d)\n", screen().vpos(), fieldnum, VBI_CAV_PICTURE(vbi.line1718));
- else
- printf("%3d:VSYNC(%d)\n", screen().vpos(), fieldnum);
- }
-
- // signal VSYNC and set a timer to turn it off
- m_vsync = true;
- timer_set(screen().scan_period() * 4, TID_VSYNC_OFF);
-
- // also set a timer to fetch the VBI data when it is ready
- timer_set(screen().time_until_pos(19*2), TID_VBI_DATA_FETCH);
-}
-
-
-//-------------------------------------------------
-// player_update - update callback, called on the
-// first visible line of the frame
-//-------------------------------------------------
-
-INT32 pioneer_pr8210_device::player_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime)
-{
- // logging
- if (LOG_VBLANK_VBI)
- printf("%3d:Update(%d)\n", screen().vpos(), fieldnum);
-
- // if the spindle is on, we advance by 1 track after completing field #1
- return spdl_on() ? fieldnum : 0;
-}
-
-
-//-------------------------------------------------
-// player_overlay - overlay callback, called
-// during frame processing in update to overlay
-// player data
-//-------------------------------------------------
-
-void pioneer_pr8210_device::player_overlay(bitmap_yuy16 &bitmap)
-{
- // custom display
- if (m_pia.display)
- {
- overlay_draw_group(bitmap, &m_pia.text[2], 5, OVERLAY_GROUP1_X);
- overlay_draw_group(bitmap, &m_pia.text[7], 5, OVERLAY_GROUP2_X);
- overlay_draw_group(bitmap, &m_pia.text[12], 5, OVERLAY_GROUP3_X);
- }
-
- // chapter/frame display
- else
- {
- // frame display
- if (m_pia.latchdisplay & 2)
- overlay_draw_group(bitmap, &m_pia.text[2], 5, OVERLAY_GROUP1_X);
-
- // chapter overlay
- if (m_pia.latchdisplay & 1)
- overlay_draw_group(bitmap, &m_pia.text[0], 2, OVERLAY_GROUP0_X);
- }
- m_pia.latchdisplay = 0;
-}
-
-
-//-------------------------------------------------
-// i8049_pia_r - handle reads from the mystery
-// Pioneer PIA
-//-------------------------------------------------
-
-READ8_MEMBER( pioneer_pr8210_device::i8049_pia_r )
-{
- UINT8 result = 0xff;
- switch (offset)
- {
- // (20-26) 7 characters for the chapter/frame
- case 0x20: case 0x21:
- case 0x22: case 0x23: case 0x24: case 0x25: case 0x26:
- result = m_pia.frame[offset - 0x20];
- break;
-
- // (1D-1F,27) invalid read but normal
- case 0x1d: case 0x1e: case 0x1f:
- case 0x27:
- break;
-
- // (A0) port A value (from serial decoder)
- case 0xa0:
- result = m_pia.porta;
- break;
-
- // (C0) VBI decoding state 1
- case 0xc0:
- if (LOG_VBLANK_VBI)
- printf("%3d:PIA(C0)\n", screen().vpos());
- result = m_pia.vbi1;
- break;
-
- // (E0) VBI decoding state 2
- case 0xe0:
- if (LOG_VBLANK_VBI)
- printf("%3d:PIA(E0)\n", screen().vpos());
- result = m_pia.vbi2;
- break;
-
- default:
- osd_printf_debug("%03X:Unknown PR-8210 PIA read from offset %02X\n", space.device().safe_pc(), offset);
- break;
- }
- return result;
-}
-
-
-//-------------------------------------------------
-// i8049_pia_w - handle writes to the mystery
-// Pioneer PIA
-//-------------------------------------------------
-
-WRITE8_MEMBER( pioneer_pr8210_device::i8049_pia_w )
-{
- UINT8 value;
- switch (offset)
- {
- // (20-30) 17 characters for the display
- case 0x20: case 0x21:
- case 0x22: case 0x23: case 0x24: case 0x25: case 0x26:
- case 0x27: case 0x28: case 0x29: case 0x2a: case 0x2b:
- case 0x2c: case 0x2d: case 0x2e: case 0x2f: case 0x30:
- m_pia.text[offset - 0x20] = data;
- break;
-
- // (40) control lines
- case 0x40:
-
- // toggle bit 0 to latch chapter number into display area
- if (!(data & 0x01) && (m_pia.control & 0x01))
- {
- memcpy(&m_pia.text[0], &m_pia.frame[0], 2);
- m_pia.latchdisplay |= 1;
- }
-
- // toggle bit 1 to latch frame number into display area
- if (!(data & 0x02) && (m_pia.control & 0x02))
- {
- memcpy(&m_pia.text[2], &m_pia.frame[2], 5);
- m_pia.latchdisplay |= 2;
- }
- m_pia.control = data;
- break;
-
- // (60) port B value (LEDs)
- case 0x60:
-
- // these 4 are direct-connect
- output_set_value("pr8210_audio1", (data & 0x01) != 0);
- output_set_value("pr8210_audio2", (data & 0x02) != 0);
- output_set_value("pr8210_clv", (data & 0x04) != 0);
- output_set_value("pr8210_cav", (data & 0x08) != 0);
-
- // remaining 3 bits select one of 5 LEDs via a mux
- value = ((data & 0x40) >> 6) | ((data & 0x20) >> 4) | ((data & 0x10) >> 2);
- output_set_value("pr8210_srev", (value == 0));
- output_set_value("pr8210_sfwd", (value == 1));
- output_set_value("pr8210_play", (value == 2));
- output_set_value("pr8210_step", (value == 3));
- output_set_value("pr8210_pause", (value == 4));
-
- m_pia.portb = data;
- update_audio_squelch();
- break;
-
- // (80) display enable
- case 0x80:
- m_pia.display = data & 0x01;
- break;
-
- // no other writes known
- default:
- osd_printf_debug("%03X:Unknown PR-8210 PIA write to offset %02X = %02X\n", space.device().safe_pc(), offset, data);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// i8049_bus_r - handle reads from the 8049 BUS
-// input, which is enabled via the PIA above
-//-------------------------------------------------
-
-READ8_MEMBER( pioneer_pr8210_device::i8049_bus_r )
-{
- /*
- $80 = n/c
- $40 = (in) slider pot interrupt source (slider position limit detector, inside and outside)
- $20 = n/c
- $10 = (in) /FOCUS LOCK
- $08 = (in) /SPDL LOCK
- $04 = (in) SIZE 8/12
- $02 = (in) FG via op-amp (spindle motor stop detector)
- $01 = (in) SLOW TIMER OUT
- */
-
- UINT8 result = 0x00;
-
- // bus bit 6: slider position limit detector, inside and outside
- slider_position sliderpos = get_slider_position();
- if (sliderpos != SLIDER_MINIMUM && sliderpos != SLIDER_MAXIMUM)
- result |= 0x40;
-
- // bus bit 4: /FOCUS LOCK
- if (!focus_on())
- result |= 0x10;
-
- // bus bit 3: /SPDL LOCK
- if (!spdl_on())
- result |= 0x08;
-
- // bus bit 1: spindle motor stop detector
- if (!spdl_on())
- result |= 0x02;
-
- // bus bit 0: SLOW TIMER OUT
-
- // loop at beginning waits for $40=0, $02=1
- return result;
-}
-
-
-//-------------------------------------------------
-// i8049_port1_w - handle writes to the 8049
-// port #1
-//-------------------------------------------------
-
-WRITE8_MEMBER( pioneer_pr8210_device::i8049_port1_w )
-{
- /*
- $80 = (out) SCAN C (F/R)
- $40 = (out) AUDIO SQ
- $20 = (out) VIDEO SQ
- $10 = (out) /SPDL ON
- $08 = (out) /FOCUS ON
- $04 = (out) SCAN B (L/H)
- $02 = (out) SCAN A (/SCAN)
- $01 = (out) JUMP TRG (jump back trigger, clock on high->low)
- */
-
- // set the new value
- UINT8 prev = m_i8049_port1;
- m_i8049_port1 = data;
-
- // bit 7 selects the direction of slider movement for JUMP TRG and scanning
- int direction = (data & 0x80) ? 1 : -1;
-
- // on the falling edge of bit 0, jump one track in either direction
- if (!(data & 0x01) && (prev & 0x01))
- {
- // special override for the Simutrek, which takes over control of this is some situations
- if (!override_control())
- {
- if (LOG_SIMUTREK)
- printf("%3d:JUMP TRG\n", screen().vpos());
- advance_slider(direction);
- }
- else if (LOG_SIMUTREK)
- printf("%3d:Skipped JUMP TRG\n", screen().vpos());
- }
-
- // bit 1 low enables scanning
- if (!(data & 0x02))
- {
- // bit 2 selects the speed
- int delta = (data & 0x04) ? SCAN_SPEED : SEEK_FAST_SPEED;
- set_slider_speed(delta * direction);
- }
-
- // bit 1 high stops scanning
- else
- set_slider_speed(0);
-
- // video squelch is controlled by bit 5; audio squelch is controlled by bit 6
- update_video_squelch();
- update_audio_squelch();
-}
-
-
-//-------------------------------------------------
-// i8049_port2_w - handle writes to the 8049
-// port #2
-//-------------------------------------------------
-
-WRITE8_MEMBER( pioneer_pr8210_device::i8049_port2_w )
-{
- /*
- $80 = (out) /CS on PIA
- $40 = (out) 0 to self-generate IRQ
- $20 = (out) SLOW TRG
- $10 = (out) STANDBY LED
- $08 = (out) TP2
- $04 = (out) TP1
- $02 = (out) ???
- $01 = (out) LASER ON
- */
-
- // set the new value
- UINT8 prev = m_i8049_port2;
- m_i8049_port2 = data;
-
- // on the falling edge of bit 5, start the slow timer
- if (!(data & 0x20) && (prev & 0x20))
- m_slowtrg = machine().time();
-
- // bit 6 when low triggers an IRQ on the MCU
- m_i8049_cpu->set_input_line(MCS48_INPUT_IRQ, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE);
-
- // standby LED is set accordingl to bit 4
- output_set_value("pr8210_standby", (data & 0x10) != 0);
-}
-
-
-//-------------------------------------------------
-// i8049_t0_r - return the state of the 8049
-// T0 input (connected to VSYNC)
-//-------------------------------------------------
-
-READ8_MEMBER( pioneer_pr8210_device::i8049_t0_r )
-{
- // returns VSYNC state
- return !m_vsync;
-}
-
-
-//-------------------------------------------------
-// i8049_t1_r - return the state of the 8049
-// T1 input (pulled high)
-//-------------------------------------------------
-
-READ8_MEMBER( pioneer_pr8210_device::i8049_t1_r )
-{
- return 1;
-}
-
-
-//-------------------------------------------------
-// overlay_draw_group - draw a single group of
-// characters
-//-------------------------------------------------
-
-void pioneer_pr8210_device::overlay_draw_group(bitmap_yuy16 &bitmap, const UINT8 *text, int count, float xstart)
-{
- // rease the background
- overlay_erase(bitmap, xstart, xstart + ((OVERLAY_X_PIXELS + 1) * count + 1) * OVERLAY_PIXEL_WIDTH);
-
- // draw each character, suppressing leading 0's
- bool skip = true;
- for (int x = 0; x < count; x++)
- if (!skip || x == count - 1 || (text[x] & 0x3f) != 0x30)
- {
- skip = false;
- overlay_draw_char(bitmap, text[x], xstart + ((OVERLAY_X_PIXELS + 1) * x + 1) * OVERLAY_PIXEL_WIDTH);
- }
-}
-
-
-//-------------------------------------------------
-// overlay_erase - erase the background area
-// where the text overlay will be displayed
-//-------------------------------------------------
-
-void pioneer_pr8210_device::overlay_erase(bitmap_yuy16 &bitmap, float xstart, float xend)
-{
- UINT32 xmin = (UINT32)(xstart * 256.0f * float(bitmap.width()));
- UINT32 xmax = (UINT32)(xend * 256.0f * float(bitmap.width()));
-
- for (UINT32 y = OVERLAY_Y; y < (OVERLAY_Y + (OVERLAY_Y_PIXELS + 2) * OVERLAY_PIXEL_HEIGHT); y++)
- {
- UINT16 *dest = &bitmap.pix16(y, xmin >> 8);
- UINT16 ymax = *dest >> 8;
- UINT16 ymin = ymax * 3 / 8;
- UINT16 yres = ymin + ((ymax - ymin) * (xmin & 0xff)) / 256;
- *dest = (yres << 8) | (*dest & 0xff);
- dest++;
-
- for (UINT32 x = (xmin | 0xff) + 1; x < xmax; x += 0x100)
- {
- yres = (*dest >> 8) * 3 / 8;
- *dest = (yres << 8) | (*dest & 0xff);
- dest++;
- }
-
- ymax = *dest >> 8;
- ymin = ymax * 3 / 8;
- yres = ymin + ((ymax - ymin) * (~xmax & 0xff)) / 256;
- *dest = (yres << 8) | (*dest & 0xff);
- dest++;
- }
-}
-
-
-//-------------------------------------------------
-// overlay_draw_char - draw a single character
-// of the text overlay
-//-------------------------------------------------
-
-void pioneer_pr8210_device::overlay_draw_char(bitmap_yuy16 &bitmap, UINT8 ch, float xstart)
-{
- UINT32 xminbase = (UINT32)(xstart * 256.0f * float(bitmap.width()));
- UINT32 xsize = (UINT32)(OVERLAY_PIXEL_WIDTH * 256.0f * float(bitmap.width()));
-
- // iterate over pixels
- const UINT8 *chdataptr = &text_bitmap[ch & 0x3f][0];
- for (UINT32 y = 0; y < OVERLAY_Y_PIXELS; y++)
- {
- UINT8 chdata = *chdataptr++;
-
- for (UINT32 x = 0; x < OVERLAY_X_PIXELS; x++, chdata <<= 1)
- if (chdata & 0x80)
- {
- UINT32 xmin = xminbase + x * xsize;
- UINT32 xmax = xmin + xsize;
- for (UINT32 yy = 0; yy < OVERLAY_PIXEL_HEIGHT; yy++)
- {
- UINT16 *dest = &bitmap.pix16(OVERLAY_Y + (y + 1) * OVERLAY_PIXEL_HEIGHT + yy, xmin >> 8);
- UINT16 ymax = 0xff;
- UINT16 ymin = *dest >> 8;
- UINT16 yres = ymin + ((ymax - ymin) * (~xmin & 0xff)) / 256;
- *dest = (yres << 8) | (*dest & 0xff);
- dest++;
-
- for (UINT32 xx = (xmin | 0xff) + 1; xx < xmax; xx += 0x100)
- *dest++ = 0xf080;
-
- ymax = 0xff;
- ymin = *dest >> 8;
- yres = ymin + ((ymax - ymin) * (xmax & 0xff)) / 256;
- *dest = (yres << 8) | (*dest & 0xff);
- dest++;
- }
- }
- }
-}
-
-
-
-//**************************************************************************
-// SIMUTREK ROM AND MACHINE INTERFACES
-//**************************************************************************
-
-static ADDRESS_MAP_START( simutrek_portmap, AS_IO, 8, simutrek_special_device )
- AM_RANGE(0x00, 0xff) AM_READ(i8748_data_r)
- AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READWRITE(i8748_port2_r, i8748_port2_w)
- AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_READ(i8748_t0_r)
-ADDRESS_MAP_END
-
-
-static MACHINE_CONFIG_FRAGMENT( simutrek )
- MCFG_CPU_ADD("simutrek", I8748, XTAL_6MHz)
- MCFG_CPU_IO_MAP(simutrek_portmap)
-
- MCFG_FRAGMENT_ADD(pr8210)
-MACHINE_CONFIG_END
-
-
-ROM_START( simutrek )
- ROM_REGION( 0x800, "pr8210", 0 )
- ROM_LOAD( "pr-8210_mcu_ud6005a.bin", 0x000, 0x800, CRC(120fa83b) SHA1(b514326ca1f52d6d89056868f9d17eabd4e3f31d) )
-
- ROM_REGION( 0x400, "simutrek", 0)
- ROM_LOAD( "laser_player_interface_d8748_a308.bin", 0x0000, 0x0400, CRC(eed3e728) SHA1(1eb3467f1c41553375b2c21952cd593b167f5416) )
-ROM_END
-
-
-
-//**************************************************************************
-// SIMUTREK IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// simutrek_special_device - constructor
-//-------------------------------------------------
-
-simutrek_special_device::simutrek_special_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pioneer_pr8210_device(mconfig, SIMUTREK_SPECIAL, "Simutrek Modified PR-8210", tag, owner, clock, "simutrek", __FILE__),
- m_i8748_cpu(*this, "simutrek"),
- m_audio_squelch(0),
- m_data(0),
- m_data_ready(false),
- m_i8748_port2(0),
- m_controlnext(0),
- m_controlthis(0)
-{
-}
-
-
-//-------------------------------------------------
-// data_w - write callback when the parallel data
-// port is written to
-//-------------------------------------------------
-
-void simutrek_special_device::data_w(UINT8 data)
-{
- synchronize(TID_LATCH_DATA, data);
- if (LOG_SIMUTREK)
- printf("%03d:**** Simutrek Command = %02X\n", screen().vpos(), data);
-}
-
-
-//-------------------------------------------------
-// set_external_audio_squelch - Simutrek-specific
-// command to enable/disable audio squelch
-//-------------------------------------------------
-
-void simutrek_special_device::set_external_audio_squelch(int state)
-{
- if (LOG_SIMUTREK && m_audio_squelch != (state == 0))
- printf("--> audio squelch = %d\n", state == 0);
- m_audio_squelch = (state == 0);
- update_audio_squelch();
-}
-
-
-//-------------------------------------------------
-// player_vsync - VSYNC callback, called at the
-// start of the blanking period
-//-------------------------------------------------
-
-void simutrek_special_device::player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime)
-{
- // latch the control state after the second field
- if (fieldnum == 1)
- {
- m_controlthis = m_controlnext;
- m_controlnext = 0;
- }
-
- // call the parent
- if (LOG_SIMUTREK)
- printf("%3d:VSYNC(%d)\n", screen().vpos(), fieldnum);
- pioneer_pr8210_device::player_vsync(vbi, fieldnum, curtime);
-
- // process data
- if (m_data_ready)
- {
- if (LOG_SIMUTREK)
- printf("%3d:VSYNC IRQ\n", screen().vpos());
- m_i8748_cpu->set_input_line(MCS48_INPUT_IRQ, ASSERT_LINE);
- timer_set(screen().scan_period(), TID_IRQ_OFF);
- }
-}
-
-
-//-------------------------------------------------
-// device_start - device initialization
-//-------------------------------------------------
-
-void simutrek_special_device::device_start()
-{
- // pass through to the parent
- pioneer_pr8210_device::device_start();
-}
-
-
-//-------------------------------------------------
-// device_reset - device reset
-//-------------------------------------------------
-
-void simutrek_special_device::device_reset()
-{
- // standard PR-8210 initialization
- pioneer_pr8210_device::device_reset();
-
- // initialize the Simutrek state
- // for proper synchronization of initial attract mode, this needs to be set
- m_data_ready = true;
-}
-
-
-//-------------------------------------------------
-// device_timer - handle timers set by this
-// device
-//-------------------------------------------------
-
-void simutrek_special_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- // clear the 8748 IRQ
- case TID_IRQ_OFF:
- m_i8748_cpu->set_input_line(MCS48_INPUT_IRQ, CLEAR_LINE);
- break;
-
- // latch data
- case TID_LATCH_DATA:
- m_data = param;
- m_data_ready = true;
- break;
-
- // pass everything else onto the parent
- default:
- pioneer_pr8210_device::device_timer(timer, id, param, ptr);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// device_rom_region - return a pointer to our
-// ROM region definitions
-//-------------------------------------------------
-
-const rom_entry *simutrek_special_device::device_rom_region() const
-{
- return ROM_NAME(simutrek);
-}
-
-
-//-------------------------------------------------
-// device_mconfig_additions - return a pointer to
-// our machine config fragment
-//-------------------------------------------------
-
-machine_config_constructor simutrek_special_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME(simutrek);
-}
-
-
-//-------------------------------------------------
-// i8748_port2_r - handle reads from the 8748
-// port #2
-//-------------------------------------------------
-
-READ8_MEMBER( simutrek_special_device::i8748_port2_r )
-{
- // bit $80 is the pr8210 video squelch
- return (m_i8049_port1 & 0x20) ? 0x00 : 0x80;
-}
-
-
-//-------------------------------------------------
-// i8748_port2_w - handle writes to the 8748
-// port #2
-//-------------------------------------------------
-
-WRITE8_MEMBER( simutrek_special_device::i8748_port2_w )
-{
- // update stat
- UINT8 prev = m_i8748_port2;
- m_i8748_port2 = data;
-
- // bit $20 goes to the serial line
- if ((data ^ prev) & 0x20)
- pioneer_pr8210_device::control_w((data & 0x20) ? ASSERT_LINE : CLEAR_LINE);
-
- // bit $10 goes to JUMP TRG
- // bit $08 controls direction
- if (!(data & 0x10) && (prev & 0x10))
- {
- int direction = (data & 0x08) ? 1 : -1;
- if (LOG_SIMUTREK)
- printf("%3d:JUMP TRG (Simutrek PC=%03X)\n", screen().vpos(), space.device().safe_pc());
- advance_slider(direction);
- }
-
- // bit $04 controls who owns the JUMP TRG command
- if (LOG_SIMUTREK && ((data ^ prev) & 0x04))
- printf("%3d:Simutrek ownership line = %d (Simutrek PC=%03X)\n", screen().vpos(), (data >> 2) & 1, space.device().safe_pc());
- m_controlnext = (~data >> 2) & 1;
-
- // bits $03 control something (status?)
- if (LOG_SIMUTREK && ((data ^ prev) & 0x03))
- printf("Simutrek Status = %d\n", data & 0x03);
-}
-
-
-//-------------------------------------------------
-// i8748_data_r - handle external 8748 data reads
-//-------------------------------------------------
-
-READ8_MEMBER( simutrek_special_device::i8748_data_r )
-{
- // acknowledge the read and clear the data ready flag
- m_data_ready = false;
- return m_data;
-}
-
-
-//-------------------------------------------------
-// i8748_t0_r - return the status of the 8748
-// T0 input
-//-------------------------------------------------
-
-READ8_MEMBER( simutrek_special_device::i8748_t0_r )
-{
- // return 1 if data is waiting from main CPU
- return m_data_ready;
-}
diff --git a/src/emu/machine/ldpr8210.h b/src/emu/machine/ldpr8210.h
deleted file mode 100644
index 96273dcb12a..00000000000
--- a/src/emu/machine/ldpr8210.h
+++ /dev/null
@@ -1,193 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- ldpr8210.h
-
- Pioneer PR-8210 laserdisc emulation.
-
-*************************************************************************/
-
-#pragma once
-
-#ifndef __LDPR8210_H__
-#define __LDPR8210_H__
-
-#include "laserdsc.h"
-#include "cpu/mcs48/mcs48.h"
-
-
-//**************************************************************************
-// DEVICE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_LASERDISC_PR8210_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, PIONEER_PR8210, 0)
-#define MCFG_LASERDISC_SIMUTREK_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SIMUTREK_SPECIAL, 0)
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-extern const device_type PIONEER_PR8210;
-extern const device_type SIMUTREK_SPECIAL;
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// pioneer PIA subclass
-class pioneer_pia
-{
-public:
- UINT8 frame[7]; // (20-26) 7 characters for the chapter/frame
- UINT8 text[17]; // (20-30) 17 characters for the display
- UINT8 control; // (40) control lines
- UINT8 latchdisplay; // flag: set if the display was latched
- UINT8 portb; // (60) port B value (LEDs)
- UINT8 display; // (80) display enable
- UINT8 porta; // (A0) port A value (from serial decoder)
- UINT8 vbi1; // (C0) VBI decoding state 1
- UINT8 vbi2; // (E0) VBI decoding state 2
-};
-
-
-// ======================> pioneer_pr8210_device
-
-// base pr8210 class
-class pioneer_pr8210_device : public laserdisc_device
-{
-public:
- // construction/destruction
- pioneer_pr8210_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- pioneer_pr8210_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- // input and output
- void control_w(UINT8 data);
-
-protected:
- // timer IDs
- enum
- {
- TID_VSYNC_OFF = TID_FIRST_PLAYER_TIMER,
- TID_VBI_DATA_FETCH,
- TID_FIRST_SUBCLASS_TIMER
- };
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual const rom_entry *device_rom_region() const;
- virtual machine_config_constructor device_mconfig_additions() const;
-
- // subclass overrides
- virtual void player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime);
- virtual INT32 player_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime);
- virtual void player_overlay(bitmap_yuy16 &bitmap);
-
- // internal helpers
- bool focus_on() const { return !(m_i8049_port1 & 0x08); }
- bool spdl_on() const { return !(m_i8049_port1 & 0x10); }
- bool laser_on() const { return !(m_i8049_port2 & 0x01); }
- virtual bool override_control() const { return false; }
- void update_video_squelch() { set_video_squelch((m_i8049_port1 & 0x20) != 0); }
- virtual void update_audio_squelch() { set_audio_squelch((m_i8049_port1 & 0x40) || !(m_pia.portb & 0x01), (m_i8049_port1 & 0x40) || !(m_pia.portb & 0x02)); }
-
-public:
- // internal read/write handlers
- DECLARE_READ8_MEMBER( i8049_pia_r );
- DECLARE_WRITE8_MEMBER( i8049_pia_w );
- DECLARE_READ8_MEMBER( i8049_bus_r );
- DECLARE_WRITE8_MEMBER( i8049_port1_w );
- DECLARE_WRITE8_MEMBER( i8049_port2_w );
- DECLARE_READ8_MEMBER( i8049_t0_r );
- DECLARE_READ8_MEMBER( i8049_t1_r );
-
-protected:
- // internal overlay helpers
- void overlay_draw_group(bitmap_yuy16 &bitmap, const UINT8 *text, int count, float xstart);
- void overlay_erase(bitmap_yuy16 &bitmap, float xstart, float xend);
- void overlay_draw_char(bitmap_yuy16 &bitmap, UINT8 ch, float xstart);
-
- // internal state
- UINT8 m_control; // control line state
- UINT8 m_lastcommand; // last command seen
- UINT16 m_accumulator; // bit accumulator
- attotime m_lastcommandtime; // time of the last command
- attotime m_lastbittime; // time of last bit received
- attotime m_firstbittime; // time of first bit in command
-
- // low-level emulation data
- required_device<i8049_device> m_i8049_cpu; // 8049 CPU device
- attotime m_slowtrg; // time of the last SLOW TRG
- pioneer_pia m_pia; // PIA state
- bool m_vsync; // live VSYNC state
- UINT8 m_i8049_port1; // 8049 port 1 state
- UINT8 m_i8049_port2; // 8049 port 2 state
-};
-
-
-// ======================> simutrek_special_device
-
-class simutrek_special_device : public pioneer_pr8210_device
-{
-public:
- // construction/destruction
- simutrek_special_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // input and output
- void data_w(UINT8 data);
- UINT8 ready_r() const { return !m_data_ready; }
- UINT8 status_r() const { return ((m_i8748_port2 & 0x03) == 0x03) ? ASSERT_LINE : CLEAR_LINE; }
-
- // external controls
- void set_external_audio_squelch(int state);
-
-protected:
- // timer IDs
- enum
- {
- TID_IRQ_OFF = TID_FIRST_SUBCLASS_TIMER,
- TID_LATCH_DATA
- };
-
- // subclass overrides
- virtual void player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime);
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual const rom_entry *device_rom_region() const;
- virtual machine_config_constructor device_mconfig_additions() const;
-
- // internal helpers
- virtual bool override_control() const { return m_controlthis; }
- virtual void update_audio_squelch() { set_audio_squelch(m_audio_squelch, m_audio_squelch); }
-
-public:
- // internal read/write handlers
- DECLARE_READ8_MEMBER( i8748_port2_r );
- DECLARE_WRITE8_MEMBER( i8748_port2_w );
- DECLARE_READ8_MEMBER( i8748_data_r );
- DECLARE_READ8_MEMBER( i8748_t0_r );
-
-protected:
- // internal state
- required_device<i8748_device> m_i8748_cpu;
- UINT8 m_audio_squelch; // audio squelch value
- UINT8 m_data; // parallel data for simutrek
- bool m_data_ready; // ready flag for simutrek data
- UINT8 m_i8748_port2; // 8748 port 2 state
- UINT8 m_controlnext; // latch to control next pair of fields
- UINT8 m_controlthis; // latched value for our control over the current pair of fields
-};
-
-
-#endif
diff --git a/src/emu/machine/ldstub.c b/src/emu/machine/ldstub.c
deleted file mode 100644
index 14dd42fdc2b..00000000000
--- a/src/emu/machine/ldstub.c
+++ /dev/null
@@ -1,22 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- ldstub.c
-
- Laserdisc player stubs.
-
-*************************************************************************/
-
-#include "emu.h"
-#include "ldstub.h"
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type SONY_LDP1450 = &device_creator<sony_ldp1450_device>;
-const device_type PIONEER_PR7820 = &device_creator<pioneer_pr7820_device>;
-const device_type PHILLIPS_22VP932 = &device_creator<phillips_22vp932_device>;
diff --git a/src/emu/machine/ldstub.h b/src/emu/machine/ldstub.h
deleted file mode 100644
index d10cd0313ea..00000000000
--- a/src/emu/machine/ldstub.h
+++ /dev/null
@@ -1,114 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- ldstub.h
-
- Laserdisc player stubs.
-
-*************************************************************************/
-
-#pragma once
-
-#ifndef __LDSTUB_H__
-#define __LDSTUB_H__
-
-#include "laserdsc.h"
-
-
-//**************************************************************************
-// DEVICE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_LASERDISC_LDP1450_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SONY_LDP1450, 0)
-#define MCFG_LASERDISC_PR7820_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, PIONEER_PR7820, 0)
-#define MCFG_LASERDISC_22VP932_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, PHILLIPS_22VP932, 0)
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-extern const device_type SONY_LDP1450;
-extern const device_type PIONEER_PR7820;
-extern const device_type PHILLIPS_22VP932;
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> sony_ldp1450_device
-
-class sony_ldp1450_device : public laserdisc_device
-{
-public:
- // construction/destruction
- sony_ldp1450_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : laserdisc_device(mconfig, SONY_LDP1450, "Sony LDP-1450", tag, owner, clock, "ldp1450", __FILE__) { }
-
- // input/output
- UINT8 data_available_r() { return CLEAR_LINE; }
- UINT8 data_r() { return 0; }
- void data_w(UINT8 data) { }
-
-protected:
- // subclass overrides
- virtual void player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime) { }
- virtual INT32 player_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime) { return fieldnum; }
- virtual void player_overlay(bitmap_yuy16 &bitmap) { }
-};
-
-
-// ======================> pioneer_pr7820_device
-
-class pioneer_pr7820_device : public laserdisc_device
-{
-public:
- // construction/destruction
- pioneer_pr7820_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : laserdisc_device(mconfig, PIONEER_PR7820, "Pioneer PR-7820", tag, owner, clock, "pr7820", __FILE__) { }
-
- // input/output
- UINT8 data_available_r() { return CLEAR_LINE; }
- UINT8 ready_r() { return ASSERT_LINE; }
- UINT8 data_r() { return 0; }
- void data_w(UINT8 data) { }
- void enter_w(UINT8 data) { }
-
-protected:
- // subclass overrides
- virtual void player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime) { }
- virtual INT32 player_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime) { return fieldnum; }
- virtual void player_overlay(bitmap_yuy16 &bitmap) { }
-};
-
-
-// ======================> phillips_22vp932_device
-
-class phillips_22vp932_device : public laserdisc_device
-{
-public:
- // construction/destruction
- phillips_22vp932_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : laserdisc_device(mconfig, PHILLIPS_22VP932, "Phillips 22VP932", tag, owner, clock, "22vp932", __FILE__) { }
-
- // input/output
- UINT8 data_r() { return 0; }
- void data_w(UINT8 data) { }
- void enter_w(UINT8 data) { }
-
-protected:
- // subclass overrides
- virtual void player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime) { }
- virtual INT32 player_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime) { return fieldnum; }
- virtual void player_overlay(bitmap_yuy16 &bitmap) { }
-};
-
-
-#endif
diff --git a/src/emu/machine/ldv1000.c b/src/emu/machine/ldv1000.c
deleted file mode 100644
index 18c8d86fc9a..00000000000
--- a/src/emu/machine/ldv1000.c
+++ /dev/null
@@ -1,656 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- ldv1000.c
-
- Pioneer LD-V1000 laserdisc emulation.
-
-**************************************************************************
-
- Still to do:
-
- * fix issues
- * add OSD
-
-*************************************************************************/
-
-
-#include "emu.h"
-#include "ldv1000.h"
-#include "machine/i8255.h"
-#include "machine/z80ctc.h"
-#include "cpu/z80/z80.h"
-#include "cpu/z80/z80daisy.h"
-
-
-
-//**************************************************************************
-// DEBUGGING
-//**************************************************************************
-
-#define LOG_PORT_IO 0
-#define LOG_STATUS_CHANGES 0
-#define LOG_FRAMES_SEEN 0
-#define LOG_COMMANDS 0
-
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-#define SCAN_SPEED (2000 / 30) // 2000 frames/second
-#define SEEK_FAST_SPEED (4000 / 30) // 4000 frames/second
-
-#define MULTIJUMP_TRACK_TIME attotime::from_usec(50)
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// devices
-const device_type PIONEER_LDV1000 = &device_creator<pioneer_ldv1000_device>;
-
-
-
-//**************************************************************************
-// LD-V1000 ROM AND MACHINE INTERFACES
-//**************************************************************************
-
-static ADDRESS_MAP_START( ldv1000_map, AS_PROGRAM, 8, pioneer_ldv1000_device )
- AM_RANGE(0x0000, 0x1fff) AM_MIRROR(0x6000) AM_ROM
- AM_RANGE(0x8000, 0x87ff) AM_MIRROR(0x3800) AM_RAM
- AM_RANGE(0xc000, 0xc003) AM_MIRROR(0x9ff0) AM_DEVREADWRITE("ldvppi0", i8255_device, read, write)
- AM_RANGE(0xc004, 0xc007) AM_MIRROR(0x9ff0) AM_DEVREADWRITE("ldvppi1", i8255_device, read, write)
-ADDRESS_MAP_END
-
-
-static ADDRESS_MAP_START( ldv1000_portmap, AS_IO, 8, pioneer_ldv1000_device )
- ADDRESS_MAP_GLOBAL_MASK(0xff)
- AM_RANGE(0x00, 0x07) AM_MIRROR(0x38) AM_READWRITE(z80_decoder_display_port_r, z80_decoder_display_port_w)
- AM_RANGE(0x40, 0x40) AM_MIRROR(0x3f) AM_READ(z80_controller_r)
- AM_RANGE(0x80, 0x80) AM_MIRROR(0x3f) AM_WRITE(z80_controller_w)
- AM_RANGE(0xc0, 0xc3) AM_MIRROR(0x3c) AM_DEVREADWRITE("ldvctc", z80ctc_device, read, write)
-ADDRESS_MAP_END
-
-
-static const z80_daisy_config daisy_chain[] =
-{
- { "ldvctc" },
- { NULL }
-};
-
-
-static MACHINE_CONFIG_FRAGMENT( ldv1000 )
- MCFG_CPU_ADD("ldv1000", Z80, XTAL_5MHz/2)
- MCFG_CPU_CONFIG(daisy_chain)
- MCFG_CPU_PROGRAM_MAP(ldv1000_map)
- MCFG_CPU_IO_MAP(ldv1000_portmap)
-
- MCFG_DEVICE_ADD("ldvctc", Z80CTC, XTAL_5MHz/2)
- MCFG_Z80CTC_INTR_CB(WRITELINE(pioneer_ldv1000_device, ctc_interrupt))
-
- MCFG_DEVICE_ADD("ldvppi0", I8255, 0)
- MCFG_I8255_OUT_PORTA_CB(WRITE8(pioneer_ldv1000_device, ppi0_porta_w))
- MCFG_I8255_IN_PORTB_CB(READ8(pioneer_ldv1000_device, ppi0_portb_r))
- MCFG_I8255_IN_PORTC_CB(READ8(pioneer_ldv1000_device, ppi0_portc_r))
- MCFG_I8255_OUT_PORTC_CB(WRITE8(pioneer_ldv1000_device, ppi0_portc_w))
-
- MCFG_DEVICE_ADD("ldvppi1", I8255, 0)
- MCFG_I8255_IN_PORTA_CB(READ8(pioneer_ldv1000_device, ppi1_porta_r))
- MCFG_I8255_OUT_PORTB_CB(WRITE8(pioneer_ldv1000_device, ppi1_portb_w))
- MCFG_I8255_OUT_PORTC_CB(WRITE8(pioneer_ldv1000_device, ppi1_portc_w))
-MACHINE_CONFIG_END
-
-
-ROM_START( ldv1000 )
- ROM_REGION( 0x2000, "ldv1000", 0 )
- ROM_LOAD( "z03_1001_vyw-053_v1-0.bin", 0x0000, 0x2000, CRC(31ec4687) SHA1(52f91c304a878ba02b2fa1cda1a9489d6dd5a34f) )
-ROM_END
-
-
-
-//**************************************************************************
-// PIONEER LD-V1000 IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// pioneer_ldv1000_device - constructor
-//-------------------------------------------------
-
-pioneer_ldv1000_device::pioneer_ldv1000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : laserdisc_device(mconfig, PIONEER_LDV1000, "Pioneer LD-V1000", tag, owner, clock, "ldv1000", __FILE__),
- m_z80_cpu(*this, "ldv1000"),
- m_z80_ctc(*this, "ldvctc"),
- m_multitimer(NULL),
- m_command(0),
- m_status(0),
- m_vsync(false),
- m_counter_start(0),
- m_counter(0),
- m_portc0(0),
- m_portb1(0),
- m_portc1(0),
- m_portselect(0),
- m_dispindex(0),
- m_vbiready(false),
- m_vbiindex(0)
-{
-}
-
-
-//-------------------------------------------------
-// data_w - handle a parallel data write to the
-// LD-V1000
-//-------------------------------------------------
-
-void pioneer_ldv1000_device::data_w(UINT8 data)
-{
- m_command = data;
- if (LOG_COMMANDS)
- printf("-> COMMAND = %02X (%s)\n", data, (m_portc1 & 0x10) ? "valid" : "invalid");
-}
-
-
-//-------------------------------------------------
-// enter_w - set the state of the ENTER strobe
-//-------------------------------------------------
-
-void pioneer_ldv1000_device::enter_w(UINT8 data)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device initialization
-//-------------------------------------------------
-
-void pioneer_ldv1000_device::device_start()
-{
- // pass through to the parent
- laserdisc_device::device_start();
-
- // allocate timers
- m_multitimer = timer_alloc(TID_MULTIJUMP);
-}
-
-
-//-------------------------------------------------
-// device_reset - device reset
-//-------------------------------------------------
-
-void pioneer_ldv1000_device::device_reset()
-{
- // pass through to the parent
- laserdisc_device::device_reset();
-
- // reset our state
- m_command = 0;
- m_status = 0;
- m_vsync = false;
- m_counter_start = 0;
- m_counter = 0;
- m_portc0 = 0;
- m_portb1 = 0;
- m_portc1 = 0;
- m_portselect = 0;
- m_dispindex = 0;
- m_vbiready = false;
- m_vbiindex = 0;
-}
-
-
-//-------------------------------------------------
-// device_timer - handle timers set by this
-// device
-//-------------------------------------------------
-
-void pioneer_ldv1000_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TID_MULTIJUMP:
- {
- // bit 5 of port B on PPI 1 selects the direction of slider movement
- int direction = (m_portb1 & 0x20) ? 1 : -1;
- advance_slider(direction);
-
- // update down counter and reschedule
- if (--m_counter != 0)
- timer.adjust(MULTIJUMP_TRACK_TIME);
- break;
- }
-
- case TID_VSYNC_OFF:
- m_vsync = false;
- break;
-
- case TID_VBI_DATA_FETCH:
- {
- // appears to return data in reverse order
- UINT32 lines[3];
- lines[0] = get_field_code(LASERDISC_CODE_LINE1718, false);
- lines[1] = get_field_code(LASERDISC_CODE_LINE17, false);
- lines[2] = get_field_code(LASERDISC_CODE_LINE16, false);
-
- // fill in the details
- memset(m_vbi, 0, sizeof(m_vbi));
- if (focus_on() && laser_on())
- {
- // loop over lines
- for (int line = 0; line < 3; line++)
- {
- UINT8 *dest = &m_vbi[line * 7];
- UINT32 data = lines[line];
-
- // the logic only processes leadin/leadout/frame number codes
- if (data == VBI_CODE_LEADIN || data == VBI_CODE_LEADOUT || (data & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE)
- {
- *dest++ = 0x09 | (((data & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE) ? 0x02 : 0x00);
- *dest++ = 0x08;
- *dest++ = (data >> 16) & 0x0f;
- *dest++ = (data >> 12) & 0x0f;
- *dest++ = (data >> 8) & 0x0f;
- *dest++ = (data >> 4) & 0x0f;
- *dest++ = (data >> 0) & 0x0f;
- }
- }
- }
-
- // signal that data is ready and reset the readback index
- m_vbiready = true;
- m_vbiindex = 0;
- break;
- }
-
- // pass everything else onto the parent
- default:
- laserdisc_device::device_timer(timer, id, param, ptr);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// device_rom_region - return a pointer to our
-// ROM region definitions
-//-------------------------------------------------
-
-const rom_entry *pioneer_ldv1000_device::device_rom_region() const
-{
- return ROM_NAME(ldv1000);
-}
-
-
-//-------------------------------------------------
-// device_mconfig_additions - return a pointer to
-// our machine config fragment
-//-------------------------------------------------
-
-machine_config_constructor pioneer_ldv1000_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME(ldv1000);
-}
-
-
-//-------------------------------------------------
-// player_vsync - VSYNC callback, called at the
-// start of the blanking period
-//-------------------------------------------------
-
-void pioneer_ldv1000_device::player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime)
-{
- // generate interrupts if we hit the edges
- slider_position sliderpos = get_slider_position();
- m_z80_ctc->trg1(sliderpos == SLIDER_MINIMUM);
- m_z80_ctc->trg2(sliderpos == SLIDER_MAXIMUM);
-
- // signal VSYNC and set a timer to turn it off
- m_vsync = true;
- timer_set(screen().scan_period() * 4, TID_VSYNC_OFF);
-
- // also set a timer to fetch the VBI data when it is ready
- timer_set(screen().time_until_pos(19*2), TID_VBI_DATA_FETCH);
-
- // boost interleave for the first 1ms to improve communications
- machine().scheduler().boost_interleave(attotime::zero, attotime::from_msec(1));
-}
-
-
-//-------------------------------------------------
-// player_update - update callback, called on
-// the first visible line of the frame
-//-------------------------------------------------
-
-INT32 pioneer_ldv1000_device::player_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime)
-{
- if (LOG_FRAMES_SEEN)
- {
- int frame = frame_from_metadata(vbi);
- if (frame != FRAME_NOT_PRESENT) printf("== %d\n", frame);
- }
- return fieldnum;
-}
-
-
-//-------------------------------------------------
-// ctc_interrupt - called when the CTC triggers
-// an interrupt in the daisy chain
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( pioneer_ldv1000_device::ctc_interrupt )
-{
- m_z80_cpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE);
-}
-
-
-//-------------------------------------------------
-// z80_decoder_display_port_w - handle writes to
-// the decoder/display chips
-//-------------------------------------------------
-
-WRITE8_MEMBER( pioneer_ldv1000_device::z80_decoder_display_port_w )
-{
- /*
- TX/RX = /A0 (A0=0 -> TX, A0=1 -> RX)
-
- Display is 6-bit
- Decoder is 4-bit
- */
-
- // writes to offset 0 select the target for reads/writes of actual data
- if (offset == 0)
- {
- m_portselect = data;
- m_dispindex = 0;
- }
-
- // writes to offset 2 constitute actual writes targeted toward the display and decoder chips
- else if (offset == 2)
- {
- // selections 0 and 1 represent the two display lines; only 6 bits are transferred
- if (m_portselect < 2)
- m_display[m_portselect][m_dispindex++ % 20] = data & 0x3f;
- }
-}
-
-
-//-------------------------------------------------
-// z80_decoder_display_port_r - handle reads from the
-// decoder/display chips
-//-------------------------------------------------
-
-READ8_MEMBER( pioneer_ldv1000_device::z80_decoder_display_port_r )
-{
- // reads from offset 3 constitute actual reads from the display and decoder chips
- UINT8 result = 0;
- if (offset == 3)
- {
- // selection 4 represents the VBI data reading
- if (m_portselect == 4)
- {
- m_vbiready = false;
- result = m_vbi[m_vbiindex++ % ARRAY_LENGTH(m_vbi)];
- }
- }
- return result;
-}
-
-
-//-------------------------------------------------
-// z80_controller_r - handle read of the data from
-// the controlling system
-//-------------------------------------------------
-
-READ8_MEMBER( pioneer_ldv1000_device::z80_controller_r )
-{
- // note that this is a cheesy implementation; the real thing relies on exquisite timing
- UINT8 result = m_command ^ 0xff;
- m_command = 0xff;
- return result;
-}
-
-
-//-------------------------------------------------
-// z80_controller_w - handle status latch writes
-//-------------------------------------------------
-
-WRITE8_MEMBER( pioneer_ldv1000_device::z80_controller_w )
-{
- if (LOG_STATUS_CHANGES && data != m_status)
- printf("%04X:CONTROLLER.W=%02X\n", space.device().safe_pc(), data);
- m_status = data;
-}
-
-
-//-------------------------------------------------
-// ppi0_porta_w - handle writes to port A of
-// PPI #0
-//-------------------------------------------------
-
-WRITE8_MEMBER( pioneer_ldv1000_device::ppi0_porta_w )
-{
- m_counter_start = data;
- if (LOG_PORT_IO)
- printf("%s:PORTA.0=%02X\n", machine().describe_context(), data);
-}
-
-
-//-------------------------------------------------
-// ppi0_portb_r - handle reads from port B of
-// PPI #0
-//-------------------------------------------------
-
-READ8_MEMBER( pioneer_ldv1000_device::ppi0_portb_r )
-{
- return m_counter;
-}
-
-
-//-------------------------------------------------
-// ppi0_portc_r - handle reads from port C of
-// PPI #0
-//-------------------------------------------------
-
-READ8_MEMBER( pioneer_ldv1000_device::ppi0_portc_r )
-{
- /*
- $10 = /VSYNC
- $20 = IRQ from decoder chip
- $40 = TRKG LOOP (N24-1)
- $80 = DUMP (N20-1) -- code reads the state and waits for it to change
- */
-
- UINT8 result = 0x00;
- if (!m_vsync)
- result |= 0x10;
- if (!m_vbiready)
- result |= 0x20;
- return result;
-}
-
-
-//-------------------------------------------------
-// ppi0_portc_w - handle writes to port C of
-// PPI #0
-//-------------------------------------------------
-
-WRITE8_MEMBER( pioneer_ldv1000_device::ppi0_portc_w )
-{
- /*
- $01 = preload on up/down counters
- $02 = /MULTI JUMP TRIG
- $04 = SCAN MODE
- $08 = n/c
- */
-
- // set the new value
- UINT8 prev = m_portc0;
- m_portc0 = data;
- if (LOG_PORT_IO && ((data ^ prev) & 0x0f) != 0)
- {
- printf("%s:PORTC.0=%02X", machine().describe_context(), data);
- if (data & 0x01) printf(" PRELOAD");
- if (!(data & 0x02)) printf(" /MULTIJUMP");
- if (data & 0x04) printf(" SCANMODE");
- printf("\n");
- }
-
- // on the rising edge of bit 0, clock the down counter load
- if ((data & 0x01) && !(prev & 0x01))
- m_counter = m_counter_start;
-
- // on the falling edge of bit 1, start the multi-jump timer
- if (!(data & 0x02) && (prev & 0x02))
- m_multitimer->adjust(MULTIJUMP_TRACK_TIME);
-}
-
-
-//-------------------------------------------------
-// ppi1_porta_r - handle reads from port A of
-// PPI #1
-//-------------------------------------------------
-
-READ8_MEMBER( pioneer_ldv1000_device::ppi1_porta_r )
-{
- /*
- $01 = /FOCS LOCK
- $02 = /SPDL LOCK
- $04 = INSIDE
- $08 = OUTSIDE
- $10 = MOTOR STOP
- $20 = +5V/test point
- $40 = /INT LOCK
- $80 = 8 INCH CHK
- */
-
- slider_position sliderpos = get_slider_position();
- UINT8 result = 0x00;
-
- // bit 0: /FOCUS LOCK
- if (!focus_on())
- result |= 0x01;
-
- // bit 1: /SPDL LOCK
- if (!spdl_on())
- result |= 0x02;
-
- // bit 2: INSIDE signal
- if (sliderpos == SLIDER_MINIMUM)
- result |= 0x04;
-
- // bit 3: OUTSIDE signal
- if (sliderpos == SLIDER_MAXIMUM)
- result |= 0x08;
-
- // bit 4: MOTOR STOP
-
- // bit 5: +5V/test point
- result |= 0x20;
-
- // bit 6: /INT LOCK
-
- // bit 7: 8 INCH CHK
-
- return result;
-}
-
-
-//-------------------------------------------------
-// ppi1_portb_w - handle writes to port B of
-// PPI #1
-//-------------------------------------------------
-
-WRITE8_MEMBER( pioneer_ldv1000_device::ppi1_portb_w )
-{
- /*
- $01 = /FOCS ON
- $02 = /SPDL RUN
- $04 = /JUMP TRIG
- $08 = /SCAN A
- $10 = SCAN B
- $20 = SCAN C
- $40 = /LASER ON
- $80 = /SYNC ST0
- */
-
- // set the new value
- UINT8 prev = m_portb1;
- m_portb1 = data;
- if (LOG_PORT_IO && ((data ^ prev) & 0xff) != 0)
- {
- printf("%s:PORTB.1=%02X:", machine().describe_context(), data);
- if (!(data & 0x01)) printf(" FOCSON");
- if (!(data & 0x02)) printf(" SPDLRUN");
- if (!(data & 0x04)) printf(" JUMPTRIG");
- if (!(data & 0x08)) printf(" SCANA (%c %c)", (data & 0x10) ? 'L' : 'H', (data & 0x20) ? 'F' : 'R');
- if ( (data & 0x40)) printf(" LASERON");
- if (!(data & 0x80)) printf(" SYNCST0");
- printf("\n");
- }
-
- // bit 5 selects the direction of slider movement for JUMP TRG and scanning
- int direction = (data & 0x20) ? 1 : -1;
-
- // on the falling edge of bit 2, jump one track in either direction
- if (!(data & 0x04) && (prev & 0x04))
- advance_slider(direction);
-
- // bit 3 low enables scanning
- if (!(data & 0x08))
- {
- // bit 4 selects the speed
- int delta = (data & 0x10) ? SCAN_SPEED : SEEK_FAST_SPEED;
- set_slider_speed(delta * direction);
- }
-
- // bit 3 high stops scanning
- else
- set_slider_speed(0);
-}
-
-
-//-------------------------------------------------
-// ppi1_portc_w - handle writes to port C of
-// PPI #1
-//-------------------------------------------------
-
-WRITE8_MEMBER( pioneer_ldv1000_device::ppi1_portc_w )
-{
- /*
- $01 = AUD 1
- $02 = AUD 2
- $04 = AUDIO ENABLE
- $08 = /VIDEO SQ
- $10 = COMMAND
- $20 = STATUS
- $40 = SIZE 8/12
- $80 = /LED CAV
- */
-
- // set the new value
- UINT8 prev = m_portc1;
- m_portc1 = data;
- if (LOG_PORT_IO && ((data ^ prev) & 0xcf) != 0)
- {
- printf("%s:PORTC.1=%02X", machine().describe_context(), data);
- if (data & 0x01) printf(" AUD1");
- if (data & 0x02) printf(" AUD2");
- if (data & 0x04) printf(" AUDEN");
- if (!(data & 0x08)) printf(" VIDEOSQ");
- if (data & 0x10) printf(" COMMAND");
- if (data & 0x20) printf(" STATUS");
- if (data & 0x40) printf(" SIZE8");
- if (!(data & 0x80)) printf(" CAV");
- printf("\n");
- }
-
- // video squelch is controlled by bit 3
- set_video_squelch((data & 0x08) == 0);
-
- // audio squelch is controlled by bits 0-2
- set_audio_squelch(!(data & 0x04) || !(data & 0x01), !(data & 0x04) || !(data & 0x02));
-}
diff --git a/src/emu/machine/ldv1000.h b/src/emu/machine/ldv1000.h
deleted file mode 100644
index bb65a24515e..00000000000
--- a/src/emu/machine/ldv1000.h
+++ /dev/null
@@ -1,128 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- ldv1000.h
-
- Pioneer LD-V1000 laserdisc emulation.
-
-*************************************************************************/
-
-#pragma once
-
-#ifndef __LDV1000_H__
-#define __LDV1000_H__
-
-#include "laserdsc.h"
-#include "cpu/z80/z80.h"
-#include "cpu/mcs48/mcs48.h"
-#include "machine/z80ctc.h"
-
-
-//**************************************************************************
-// DEVICE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_LASERDISC_LDV1000_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, PIONEER_LDV1000, 0)
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-extern const device_type PIONEER_LDV1000;
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> pioneer_ldv1000_device
-
-// base ldv1000 class
-class pioneer_ldv1000_device : public laserdisc_device
-{
-public:
- // construction/destruction
- pioneer_ldv1000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // input and output
- void data_w(UINT8 data);
- void enter_w(UINT8 data);
- UINT8 status_r() const { return m_status; }
- UINT8 status_strobe_r() const { return (m_portc1 & 0x20) ? ASSERT_LINE : CLEAR_LINE; }
- UINT8 command_strobe_r() const { return (m_portc1 & 0x10) ? ASSERT_LINE : CLEAR_LINE; }
-
-protected:
- // timer IDs
- enum
- {
- TID_MULTIJUMP = TID_FIRST_PLAYER_TIMER,
- TID_VSYNC_OFF,
- TID_VBI_DATA_FETCH
- };
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual const rom_entry *device_rom_region() const;
- virtual machine_config_constructor device_mconfig_additions() const;
-
- // subclass overrides
- virtual void player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime);
- virtual INT32 player_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime);
- virtual void player_overlay(bitmap_yuy16 &bitmap) { }
-
- // internal helpers
- bool focus_on() const { return !(m_portb1 & 0x01); }
- bool spdl_on() const { return !(m_portb1 & 0x02); }
- bool laser_on() const { return (m_portb1 & 0x40); }
-
-public:
- // internal read/write handlers
- DECLARE_WRITE_LINE_MEMBER( ctc_interrupt );
- DECLARE_WRITE8_MEMBER( z80_decoder_display_port_w );
- DECLARE_READ8_MEMBER( z80_decoder_display_port_r );
- DECLARE_READ8_MEMBER( z80_controller_r );
- DECLARE_WRITE8_MEMBER( z80_controller_w );
- DECLARE_WRITE8_MEMBER( ppi0_porta_w );
- DECLARE_READ8_MEMBER( ppi0_portb_r );
- DECLARE_READ8_MEMBER( ppi0_portc_r );
- DECLARE_WRITE8_MEMBER( ppi0_portc_w );
- DECLARE_READ8_MEMBER( ppi1_porta_r );
- DECLARE_WRITE8_MEMBER( ppi1_portb_w );
- DECLARE_WRITE8_MEMBER( ppi1_portc_w );
-
-protected:
- // internal state
- required_device<z80_device> m_z80_cpu; /* CPU index of the Z80 */
- required_device<z80ctc_device> m_z80_ctc; /* CTC device */
- emu_timer * m_multitimer; /* multi-jump timer device */
-
- /* communication status */
- UINT8 m_command; /* command byte to the player */
- UINT8 m_status; /* status byte from the player */
- bool m_vsync; /* VSYNC state */
-
- /* I/O port states */
- UINT8 m_counter_start; /* starting value for counter */
- UINT8 m_counter; /* current counter value */
- UINT8 m_portc0; /* port C on PPI 0 */
- UINT8 m_portb1; /* port B on PPI 1 */
- UINT8 m_portc1; /* port C on PPI 1 */
-
- /* display/decode circuit emulation */
- UINT8 m_portselect; /* selection of which port to access */
- UINT8 m_display[2][20]; /* display lines */
- UINT8 m_dispindex; /* index within the display line */
- UINT8 m_vbi[7*3]; /* VBI data */
- bool m_vbiready; /* VBI ready flag */
- UINT8 m_vbiindex; /* index within the VBI data */
-};
-
-
-#endif
diff --git a/src/emu/machine/ldvp931.c b/src/emu/machine/ldvp931.c
deleted file mode 100644
index 0d927fed665..00000000000
--- a/src/emu/machine/ldvp931.c
+++ /dev/null
@@ -1,653 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- ldvp931.c
-
- Philips 22VP931 laserdisc emulation.
-
-**************************************************************************
-
- Still to do:
-
- * determine actual slow/fast speeds
- *
-
-*************************************************************************/
-
-
-#include "emu.h"
-#include "ldvp931.h"
-
-
-
-//**************************************************************************
-// DEBUGGING
-//**************************************************************************
-
-#define LOG_COMMANDS 0
-#define LOG_PORTS 0
-
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-// scanning speeds
-#define SCAN_SPEED (2000 / 30) // 2000 frames/second
-#define SCAN_FAST_SPEED (4000 / 30) // 4000 frames/second
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// devices
-const device_type PHILLIPS_22VP931 = &device_creator<phillips_22vp931_device>;
-
-
-
-//**************************************************************************
-// 22VP931 ROM AND MACHINE INTERFACES
-//**************************************************************************
-
-static ADDRESS_MAP_START( vp931_portmap, AS_IO, 8, phillips_22vp931_device )
- AM_RANGE(0x00, 0x00) AM_MIRROR(0xcf) AM_READWRITE(i8049_keypad_r, i8049_output0_w)
- AM_RANGE(0x10, 0x10) AM_MIRROR(0xcf) AM_READWRITE(i8049_unknown_r, i8049_output1_w)
- AM_RANGE(0x20, 0x20) AM_MIRROR(0xcf) AM_READWRITE(i8049_datic_r, i8049_lcd_w)
- AM_RANGE(0x30, 0x30) AM_MIRROR(0xcf) AM_READWRITE(i8049_from_controller_r, i8049_to_controller_w)
- AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(i8049_port1_r, i8049_port1_w)
- AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READWRITE(i8049_port2_r, i8049_port2_w)
- AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_READ(i8049_t0_r)
- AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(i8049_t1_r)
-ADDRESS_MAP_END
-
-
-static MACHINE_CONFIG_FRAGMENT( vp931 )
- MCFG_CPU_ADD("vp931", I8049, XTAL_11MHz)
- MCFG_CPU_IO_MAP(vp931_portmap)
-MACHINE_CONFIG_END
-
-
-ROM_START( vp931 )
- ROM_REGION( 0x800, "vp931", 0 )
- ROM_LOAD( "at-6-1_a.bin", 0x000, 0x800, CRC(e11b3c8d) SHA1(ea2d7f6a044ed085ce5e09d8b1b1a21c37f0e9b8) )
-ROM_END
-
-
-
-//**************************************************************************
-// PHILLIPS 22VP931 IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// phillips_22vp931_device - constructor
-//-------------------------------------------------
-
-phillips_22vp931_device::phillips_22vp931_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : laserdisc_device(mconfig, PHILLIPS_22VP931, "Phillips 22VP931", tag, owner, clock, "22vp931", __FILE__),
- m_i8049_cpu(*this, "vp931"),
- m_tracktimer(NULL),
- m_i8049_out0(0),
- m_i8049_out1(0),
- m_i8049_port1(0),
- m_daticval(0),
- m_daticerp(0),
- m_datastrobe(0),
- m_fromcontroller(0),
- m_fromcontroller_pending(false),
- m_tocontroller(0),
- m_tocontroller_pending(false),
- m_trackdir(0),
- m_trackstate(0),
- m_cmdcount(0),
- m_advanced(0)
-{
-}
-
-
-//-------------------------------------------------
-// reset_w - write to the reset line
-//-------------------------------------------------
-
-void phillips_22vp931_device::reset_w(UINT8 data)
-{
- // control the CPU state
- m_i8049_cpu->set_input_line(INPUT_LINE_RESET, data);
-
- // on an assert, reset the device state as well
- if (data == ASSERT_LINE)
- reset();
-}
-
-
-//-------------------------------------------------
-// data_r - handle a parallel data read from the
-// 22VP931
-//-------------------------------------------------
-
-UINT8 phillips_22vp931_device::data_r()
-{
- // if data is pending, clear the pending flag and notify any callbacks
- if (m_tocontroller_pending)
- {
- m_tocontroller_pending = false;
- if (!m_data_ready.isnull())
- m_data_ready(*this, false);
- }
-
- // also boost interleave for 4 scanlines to ensure proper communications
- machine().scheduler().boost_interleave(attotime::zero, screen().scan_period() * 4);
- return m_tocontroller;
-}
-
-
-//-------------------------------------------------
-// device_start - device initialization
-//-------------------------------------------------
-
-void phillips_22vp931_device::device_start()
-{
- // pass through to the parent
- laserdisc_device::device_start();
-
- // allocate a timer
- m_tracktimer = timer_alloc(TID_HALF_TRACK);
-}
-
-
-//-------------------------------------------------
-// device_reset - device reset
-//-------------------------------------------------
-
-void phillips_22vp931_device::device_reset()
-{
- // pass through to the parent
- laserdisc_device::device_reset();
-
- // reset our state
- m_i8049_out0 = 0;
- m_i8049_out1 = 0;
- m_i8049_port1 = 0;
-
- m_daticval = 0;
- m_daticerp = 0;
- m_datastrobe = 0;
-
- m_fromcontroller = 0;
- m_fromcontroller_pending = false;
- m_tocontroller = 0;
- m_tocontroller_pending = false;
-
- m_trackdir = 0;
- m_trackstate = 0;
-
- m_cmdcount = 0;
- m_advanced = 0;
-}
-
-
-//-------------------------------------------------
-// device_timer - handle timers set by this
-// device
-//-------------------------------------------------
-
-void phillips_22vp931_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TID_VBI_DATA_FETCH:
- {
- UINT32 line = param >> 2;
- int which = param & 3;
- UINT32 code = 0;
-
- // fetch the code and compute the DATIC latched value
- if (line >= LASERDISC_CODE_LINE16 && line <= LASERDISC_CODE_LINE18)
- code = get_field_code(laserdisc_field_code(line), false);
-
- // at the start of each line, signal an interrupt and use a timer to turn it off
- if (which == 0)
- {
- m_i8049_cpu->set_input_line(MCS48_INPUT_IRQ, ASSERT_LINE);
- timer_set(attotime::from_nsec(5580), TID_IRQ_OFF);
- }
-
- // clock the data strobe on each subsequent callback
- else if (code != 0)
- {
- m_daticval = code >> (8 * (3 - which));
- m_datastrobe = 1;
- timer_set(attotime::from_nsec(5000), TID_DATA_STROBE_OFF);
- }
-
- // determine the next bit to fetch and reprime ourself
- if (++which == 4)
- {
- which = 0;
- line++;
- }
- if (line <= LASERDISC_CODE_LINE18 + 1)
- timer_set(screen().time_until_pos(line*2, which * 2 * screen().width() / 4), TID_VBI_DATA_FETCH, (line << 2) + which);
- break;
- }
-
- case TID_DEFERRED_DATA:
- // set the value and mark it pending
- if (LOG_COMMANDS && m_fromcontroller_pending)
- printf("Dropped previous command byte\n");
- m_fromcontroller = param;
- m_fromcontroller_pending = true;
-
- // track the commands for debugging purposes
- if (m_cmdcount < ARRAY_LENGTH(m_cmdbuf))
- {
- m_cmdbuf[m_cmdcount++ % 3] = param;
- if (LOG_COMMANDS && m_cmdcount % 3 == 0)
- printf("Cmd: %02X %02X %02X\n", m_cmdbuf[0], m_cmdbuf[1], m_cmdbuf[2]);
- }
- break;
-
- case TID_IRQ_OFF:
- m_i8049_cpu->set_input_line(MCS48_INPUT_IRQ, CLEAR_LINE);
- break;
-
- case TID_DATA_STROBE_OFF:
- m_datastrobe = 0;
- break;
-
- case TID_ERP_OFF:
- m_daticerp = 0;
- break;
-
- case TID_HALF_TRACK:
- // advance by the count and toggle the state
- m_trackstate ^= 1;
- if ((m_trackdir < 0 && !m_trackstate) || (m_trackdir > 0 && m_trackstate))
- {
- advance_slider(m_trackdir);
- m_advanced += m_trackdir;
- }
- break;
-
- // pass everything else onto the parent
- default:
- laserdisc_device::device_timer(timer, id, param, ptr);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// device_rom_region - return a pointer to our
-// ROM region definitions
-//-------------------------------------------------
-
-const rom_entry *phillips_22vp931_device::device_rom_region() const
-{
- return ROM_NAME(vp931);
-}
-
-
-//-------------------------------------------------
-// device_mconfig_additions - return a pointer to
-// our machine config fragment
-//-------------------------------------------------
-
-machine_config_constructor phillips_22vp931_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME(vp931);
-}
-
-
-//-------------------------------------------------
-// player_vsync - VSYNC callback, called at the
-// start of the blanking period
-//-------------------------------------------------
-
-void phillips_22vp931_device::player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime)
-{
- // reset our command counter (debugging only)
- m_cmdcount = 0;
-
- // set the ERP signal to 1 to indicate start of frame, and set a timer to turn it off
- m_daticerp = 1;
- timer_set(screen().time_until_pos(15*2), TID_ERP_OFF);
-}
-
-
-//-------------------------------------------------
-// player_update - update callback, called on
-// the first visible line of the frame
-//-------------------------------------------------
-
-INT32 phillips_22vp931_device::player_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime)
-{
- // set the first VBI timer to go at the start of line 16
- timer_set(screen().time_until_pos(16*2), TID_VBI_DATA_FETCH, LASERDISC_CODE_LINE16 << 2);
-
- // play forward by default
- return fieldnum;
-}
-
-
-//-------------------------------------------------
-// i8049_output0_w - controls audio/video squelch
-// and other bits
-//-------------------------------------------------
-
-WRITE8_MEMBER( phillips_22vp931_device::i8049_output0_w )
-{
- /*
- $80 = n/c
- $40 = LED (?) -> C335
- $20 = LED (?)
- $10 = LED (?) -> CX
- $08 = EJECT
- $04 = inverted -> AUDIO MUTE II
- $02 = inverted -> AUDIO MUTE I
- $01 = inverted -> VIDEO MUTE
- */
-
- if (LOG_PORTS && (m_i8049_out0 ^ data) & 0xff)
- {
- printf("%03X:out0:", space.device().safe_pc());
- if ( (data & 0x80)) printf(" ???");
- if ( (data & 0x40)) printf(" LED1");
- if ( (data & 0x20)) printf(" LED2");
- if ( (data & 0x10)) printf(" LED3");
- if ( (data & 0x08)) printf(" EJECT");
- if (!(data & 0x04)) printf(" AUDMUTE2");
- if (!(data & 0x02)) printf(" AUDMUTE1");
- if (!(data & 0x01)) printf(" VIDMUTE");
- printf("\n");
- m_i8049_out0 = data;
- }
-
- // update a/v squelch
- set_audio_squelch(!(data & 0x02), !(data & 0x04));
- set_video_squelch(!(data & 0x01));
-}
-
-
-//-------------------------------------------------
-// i8049_output1_w - controls scanning behaviors
-//-------------------------------------------------
-
-WRITE8_MEMBER( phillips_22vp931_device::i8049_output1_w )
-{
- /*
- $80 = n/c
- $40 = n/c
- $20 = n/c
- $10 = n/c
- $08 = inverted -> SMS
- $04 = inverted -> SSS
- $02 = inverted -> SCAN CMD
- $01 = OSM
- */
-
- INT32 speed = 0;
-
- if (LOG_PORTS && (m_i8049_out1 ^ data) & 0x08)
- {
- osd_printf_debug("%03X:out1:", space.device().safe_pc());
- if (!(data & 0x08)) osd_printf_debug(" SMS");
- osd_printf_debug("\n");
- m_i8049_out1 = data;
- }
-
- // speed is 0 unless SCAN CMD is clear
- speed = 0;
- if (!(data & 0x02))
- {
- // fast/slow is based on bit 2
- speed = (data & 0x04) ? SCAN_FAST_SPEED : SCAN_SPEED;
-
- // direction is based on bit 0
- if (data & 0x01)
- speed = -speed;
- }
-
- // update the speed
- set_slider_speed(speed);
-}
-
-
-//-------------------------------------------------
-// i8049_lcd_w - vestigial LCD frame display
-//-------------------------------------------------
-
-WRITE8_MEMBER( phillips_22vp931_device::i8049_lcd_w )
-{
- /*
- Frame number is written as 5 digits here; however, it is not actually
- connected
- */
-}
-
-
-//-------------------------------------------------
-// i8049_unknown_r - unknown input port
-//-------------------------------------------------
-
-READ8_MEMBER( phillips_22vp931_device::i8049_unknown_r )
-{
- // only bit $80 is checked and its effects are minor
- return 0x00;
-}
-
-
-//-------------------------------------------------
-// i8049_keypad_r - vestigial keypad/button
-// controls
-//-------------------------------------------------
-
-READ8_MEMBER( phillips_22vp931_device::i8049_keypad_r )
-{
- /*
- From the code, this is apparently a vestigial keypad with basic controls:
- $01 = play
- $02 = still
- $04 = jump 25 frames backward
- $08 = jump 25 frames forward
- $10 = search for frame 50(?)
- $20 = search for frame 350(?)
- $40 = reset
- $80 = play reverse
- */
- return 0x00;
-}
-
-
-//-------------------------------------------------
-// i8049_datic_r - read the latched value from the
-// DATIC circuit
-//-------------------------------------------------
-
-READ8_MEMBER( phillips_22vp931_device::i8049_datic_r )
-{
- return m_daticval;
-}
-
-
-//-------------------------------------------------
-// i8049_from_controller_r - read the value the
-// external controller wrote
-//-------------------------------------------------
-
-READ8_MEMBER( phillips_22vp931_device::i8049_from_controller_r )
-{
- // clear the pending flag and return the data
- m_fromcontroller_pending = false;
- return m_fromcontroller;
-}
-
-
-//-------------------------------------------------
-// i8049_to_controller_w - write a value back to
-// the external controller
-//-------------------------------------------------
-
-WRITE8_MEMBER( phillips_22vp931_device::i8049_to_controller_w )
-{
- // set the pending flag and stash the data
- m_tocontroller_pending = TRUE;
- m_tocontroller = data;
-
- // signal to the callback if provided
- if (!m_data_ready.isnull())
- m_data_ready(*this, true);
-
- // also boost interleave for 4 scanlines to ensure proper communications
- machine().scheduler().boost_interleave(attotime::zero, screen().scan_period() * 4);
-}
-
-
-//-------------------------------------------------
-// i8049_port1_r - read the 8048 I/O port 1
-//-------------------------------------------------
-
-READ8_MEMBER( phillips_22vp931_device::i8049_port1_r )
-{
- /*
- $80 = P17 = (in) unsure
- $40 = P16 = (in) /ERP from datic circuit
- $20 = P15 = (in) D105
- */
-
- UINT8 result = 0x00;
- if (!m_daticerp)
- result |= 0x40;
- return result;
-}
-
-
-//-------------------------------------------------
-// i8049_port1_w - write the 8048 I/O port 1
-//-------------------------------------------------
-
-WRITE8_MEMBER( phillips_22vp931_device::i8049_port1_w )
-{
- /*
- $10 = P14 = (out) D104 -> /SPEED
- $08 = P13 = (out) D103 -> /TIMER ENABLE
- $04 = P12 = (out) D102 -> /REV
- $02 = P11 = (out) D101 -> /FORW
- $01 = P10 = (out) D100 -> some op-amp then to C334, B56, B332
- */
-
- if (LOG_PORTS && (m_i8049_port1 ^ data) & 0x1f)
- {
- printf("%03X:port1:", space.device().safe_pc());
- if (!(data & 0x10)) printf(" SPEED");
- if (!(data & 0x08)) printf(" TIMENABLE");
- if (!(data & 0x04)) printf(" REV");
- if (!(data & 0x02)) printf(" FORW");
- if (!(data & 0x01)) printf(" OPAMP");
- printf("\n");
- }
-
- // if bit 0 is set, we are not tracking
- if (data & 0x01)
- m_trackdir = 0;
-
- // if bit 0 is clear and we weren't tracking before, initialize the state
- else if (m_trackdir == 0)
- {
- m_advanced = 0;
-
- // if bit 2 is clear, we are moving backwards
- if (!(data & 0x04))
- {
- m_trackdir = -1;
- m_trackstate = 1;
- }
-
- // if bit 1 is clear, we are moving forward
- else if (!(data & 0x02))
- {
- m_trackdir = 1;
- m_trackstate = 0;
- }
- }
-
- // if we have a timer, adjust it
- if (m_tracktimer != NULL)
- {
- // turn it off if we're not tracking
- if (m_trackdir == 0)
- m_tracktimer->reset();
-
- // if we just started tracking, or if the speed was changed, reprime the timer
- else if (((m_i8049_port1 ^ data) & 0x11) != 0)
- {
- // speeds here are just guesses, but work with the player logic; this is the time per half-track
- attotime speed = (data & 0x10) ? attotime::from_usec(60) : attotime::from_usec(10);
-
- // always start with an initial long delay; the code expects this
- m_tracktimer->adjust(attotime::from_usec(100), 0, speed);
- }
- }
-
- m_i8049_port1 = data;
-}
-
-
-//-------------------------------------------------
-// i8049_port2_r - read from the 8048 I/O port 2
-//-------------------------------------------------
-
-READ8_MEMBER( phillips_22vp931_device::i8049_port2_r )
-{
- /*
- $80 = P27 = (in) set/reset latch; set by FOC LS, reset by IGR
- $20 = P25 = (in) D125 -> 0 when data written to controller is preset, reset to 1 when read
- $10 = P24 = (in) D124 -> 0 when data from controller is present, reset to 1 on a read
- */
-
- UINT8 result = 0x00;
- if (!m_tocontroller_pending)
- result |= 0x20;
- if (!m_fromcontroller_pending)
- result |= 0x10;
- return result;
-}
-
-
-//-------------------------------------------------
-// i8049_port2_w - write the 8048 I/O port 2
-//-------------------------------------------------
-
-WRITE8_MEMBER( phillips_22vp931_device::i8049_port2_w )
-{
- /*
- $40 = P26 = (out) cleared while data is sent back & forth; set afterwards
- [Not actually connected, but this is done in the code]
- */
-}
-
-
-//-------------------------------------------------
-// i8049_t0_r - return the T0 line status, which is
-// connected to the DATIC's data strobe line
-//-------------------------------------------------
-
-READ8_MEMBER( phillips_22vp931_device::i8049_t0_r )
-{
- return m_datastrobe;
-}
-
-
-//-------------------------------------------------
-// i8049_t1_r - return the T1 line status, which
-// is connected to the tracking state and is used
-// to count the number of tracks advanced
-//-------------------------------------------------
-
-READ8_MEMBER( phillips_22vp931_device::i8049_t1_r )
-{
- return m_trackstate;
-}
diff --git a/src/emu/machine/ldvp931.h b/src/emu/machine/ldvp931.h
deleted file mode 100644
index 636f4529d6b..00000000000
--- a/src/emu/machine/ldvp931.h
+++ /dev/null
@@ -1,138 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- ldvp931.h
-
- Philips 22VP931 laserdisc emulation.
-
-*************************************************************************/
-
-#pragma once
-
-#ifndef __LDVP931_H__
-#define __LDVP931_H__
-
-#include "laserdsc.h"
-#include "cpu/mcs48/mcs48.h"
-
-
-//**************************************************************************
-// DEVICE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_LASERDISC_22VP931_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, PHILLIPS_22VP931, 0)
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-extern const device_type PHILLIPS_22VP931;
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> phillips_22vp931_device
-
-// base _22vp931 class
-class phillips_22vp931_device : public laserdisc_device
-{
-public:
- // types
- typedef delegate<void (phillips_22vp931_device &, int)> data_ready_delegate;
-
- // construction/destruction
- phillips_22vp931_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // input and output
- void data_w(UINT8 data) { synchronize(TID_DEFERRED_DATA, data); }
- void reset_w(UINT8 data);
- UINT8 data_r();
- UINT8 ready_r() { return m_fromcontroller_pending ? CLEAR_LINE : ASSERT_LINE; }
- UINT8 data_available_r() { return m_tocontroller_pending ? ASSERT_LINE : CLEAR_LINE; }
-
- // configuration
- void set_data_ready_callback(data_ready_delegate callback) { m_data_ready = callback; }
-
-protected:
- // timer IDs
- enum
- {
- TID_IRQ_OFF = TID_FIRST_PLAYER_TIMER,
- TID_DATA_STROBE_OFF,
- TID_ERP_OFF,
- TID_HALF_TRACK,
- TID_VBI_DATA_FETCH,
- TID_DEFERRED_DATA
- };
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual const rom_entry *device_rom_region() const;
- virtual machine_config_constructor device_mconfig_additions() const;
-
- // subclass overrides
- virtual void player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime);
- virtual INT32 player_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime);
- virtual void player_overlay(bitmap_yuy16 &bitmap) { }
-
-public:
- // internal read/write handlers
- DECLARE_WRITE8_MEMBER( i8049_output0_w );
- DECLARE_WRITE8_MEMBER( i8049_output1_w );
- DECLARE_WRITE8_MEMBER( i8049_lcd_w );
- DECLARE_READ8_MEMBER( i8049_unknown_r );
- DECLARE_READ8_MEMBER( i8049_keypad_r );
- DECLARE_READ8_MEMBER( i8049_datic_r );
- DECLARE_READ8_MEMBER( i8049_from_controller_r );
- DECLARE_WRITE8_MEMBER( i8049_to_controller_w );
- DECLARE_READ8_MEMBER( i8049_port1_r );
- DECLARE_WRITE8_MEMBER( i8049_port1_w );
- DECLARE_READ8_MEMBER( i8049_port2_r );
- DECLARE_WRITE8_MEMBER( i8049_port2_w );
- DECLARE_READ8_MEMBER( i8049_t0_r );
- DECLARE_READ8_MEMBER( i8049_t1_r );
-
-protected:
- // internal state
- required_device<i8049_device> m_i8049_cpu; // CPU index of the 8049
- emu_timer * m_tracktimer; // timer device
- data_ready_delegate m_data_ready; // data ready callback
-
- // I/O port states
- UINT8 m_i8049_out0; // output 0 state
- UINT8 m_i8049_out1; // output 1 state
- UINT8 m_i8049_port1; // port 1 state
-
- // DATIC circuit implementation
- UINT8 m_daticval; // latched DATIC value
- UINT8 m_daticerp; // /ERP value from DATIC
- UINT8 m_datastrobe; // DATA STROBE line from DATIC
-
- // communication status
- UINT8 m_reset_state; // state of the reset input
- UINT8 m_fromcontroller; // command byte from the controller
- bool m_fromcontroller_pending; // true if data is pending
- UINT8 m_tocontroller; // command byte to the controller
- bool m_tocontroller_pending; // true if data is pending
-
- // tracking
- INT8 m_trackdir; // direction of tracking
- UINT8 m_trackstate; // state of tracking
-
- // debugging
- UINT8 m_cmdbuf[3]; // 3 bytes worth of commands
- UINT8 m_cmdcount; // number of command bytes seen
- INT16 m_advanced; // number of frames advanced
-};
-
-
-#endif
diff --git a/src/emu/machine/legscsi.c b/src/emu/machine/legscsi.c
deleted file mode 100644
index 4071ccf8c3a..00000000000
--- a/src/emu/machine/legscsi.c
+++ /dev/null
@@ -1,152 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "legscsi.h"
-
-legacy_scsi_host_adapter::legacy_scsi_host_adapter(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_scsi_port(*this)
-{
-}
-
-void legacy_scsi_host_adapter::device_start()
-{
-}
-
-void legacy_scsi_host_adapter::reset_bus()
-{
- for (int i = 0; i <= 7; i++)
- {
- scsihle_device *scsidev = get_device(i);
- if (scsidev != NULL)
- {
- scsidev->reset();
- }
- }
-}
-
-bool legacy_scsi_host_adapter::select(int id)
-{
- m_selected = id;
-
- scsihle_device *scsidev = get_device(m_selected);
- if (scsidev != NULL)
- {
- return true;
- }
-
- return false;
-}
-
-void legacy_scsi_host_adapter::send_command(UINT8 *data, int bytes)
-{
- scsihle_device *scsidev = get_device(m_selected);
- if (scsidev != NULL)
- {
- scsidev->SetCommand(data, bytes);
- scsidev->ExecCommand();
- }
- else
- {
- logerror("%s: send_command unknown SCSI id %d\n", tag(), m_selected);
- }
-}
-
-int legacy_scsi_host_adapter::get_length(void)
-{
- scsihle_device *scsidev = get_device(m_selected);
- if (scsidev != NULL)
- {
- int length;
- scsidev->GetLength(&length);
- return length;
- }
- else
- {
- logerror("%s: get_length unknown SCSI id %d\n", tag(), m_selected);
- return 0;
- }
-}
-
-int legacy_scsi_host_adapter::get_phase(void)
-{
- scsihle_device *scsidev = get_device(m_selected);
- if (scsidev != NULL)
- {
- int phase;
- scsidev->GetPhase(&phase);
- return phase;
- }
- else
- {
- logerror("%s: get_phase unknown SCSI id %d\n", tag(), m_selected);
- return 0;
- }
-}
-
-void legacy_scsi_host_adapter::read_data(UINT8 *data, int bytes)
-{
- scsihle_device *scsidev = get_device(m_selected);
- if (scsidev != NULL)
- {
- scsidev->ReadData(data, bytes);
- }
- else
- {
- logerror("%s: read_data unknown SCSI id %d\n", tag(), m_selected);
- }
-}
-
-void legacy_scsi_host_adapter::write_data(UINT8 *data, int bytes)
-{
- scsihle_device *scsidev = get_device(m_selected);
- if (scsidev != NULL)
- {
- scsidev->WriteData(data, bytes);
- }
- else
- {
- logerror("%s: write_data unknown SCSI id %d\n", tag(), m_selected);
- }
-}
-
-UINT8 legacy_scsi_host_adapter::get_status()
-{
- scsihle_device *scsidev = get_device(m_selected);
- if (scsidev != NULL)
- {
- void *image;
-
- scsidev->GetDevice(&image);
- if (image != NULL)
- return 0x00;
-
- return 0x02;
- }
- else
- {
- logerror("%s: get_status unknown SCSI id %d\n", tag(), m_selected);
- return 0;
- }
-}
-
-scsihle_device *legacy_scsi_host_adapter::get_device(int id)
-{
- // steal scsi devices from bus
- for (device_t *device = m_scsi_port->first_subdevice(); device != NULL; device = device->next())
- {
- SCSI_PORT_SLOT_device *slot = dynamic_cast<SCSI_PORT_SLOT_device *>(device);
- if (slot != NULL)
- {
- scsihle_device *scsidev = dynamic_cast<scsihle_device *>(slot->dev());
- if (scsidev != NULL)
- {
- if (scsidev->GetDeviceID() == id)
- {
- return scsidev;
- }
- }
- }
- }
-
- return NULL;
-}
diff --git a/src/emu/machine/legscsi.h b/src/emu/machine/legscsi.h
deleted file mode 100644
index c7382fa9ad0..00000000000
--- a/src/emu/machine/legscsi.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#ifndef _LEGSCSI_H_
-#define _LEGSCSI_H_
-
-#pragma once
-
-#include "bus/scsi/scsihle.h"
-
-#define MCFG_LEGACY_SCSI_PORT(_tag) \
- legacy_scsi_host_adapter::set_scsi_port(*device, "^" _tag);
-
-class legacy_scsi_host_adapter : public device_t
-{
-public:
- legacy_scsi_host_adapter(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- static void set_scsi_port(device_t &device, const char *tag) { downcast<legacy_scsi_host_adapter &>(device).m_scsi_port.set_tag(tag); }
-
-protected:
- virtual void device_start();
-
- void reset_bus();
- bool select(int id);
- void send_command(UINT8 *data, int bytes);
- int get_length();
- int get_phase();
- void read_data(UINT8 *data, int bytes);
- void write_data(UINT8 *data, int bytes);
- UINT8 get_status();
-
-private:
- int m_selected;
- scsihle_device *get_device(int id);
-
- required_device<SCSI_PORT_DEVICE> m_scsi_port;
-};
-
-#endif
diff --git a/src/emu/machine/lh5810.c b/src/emu/machine/lh5810.c
deleted file mode 100644
index 296a28a60ec..00000000000
--- a/src/emu/machine/lh5810.c
+++ /dev/null
@@ -1,171 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Sandro Ronco
-/**********************************************************************
-
- LH5810/LH5811 Input/Output Port Controller
-
- TODO:
- - serial data transfer
- - data transfer to the cassette tape
-
-**********************************************************************/
-
-#include "emu.h"
-#include "lh5810.h"
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-const device_type LH5810 = &device_creator<lh5810_device>;
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// lh5810_device - constructor
-//-------------------------------------------------
-
-lh5810_device::lh5810_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, LH5810, "LH5810", tag, owner, clock, "lh5810", __FILE__),
- m_porta_r_cb(*this),
- m_porta_w_cb(*this),
- m_portb_r_cb(*this),
- m_portb_w_cb(*this),
- m_portc_w_cb(*this),
- m_out_int_cb(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void lh5810_device::device_start()
-{
- // resolve callbacks
- m_porta_r_cb.resolve_safe(0);
- m_porta_w_cb.resolve_safe();
- m_portb_r_cb.resolve_safe(0);
- m_portb_w_cb.resolve_safe();
- m_portc_w_cb.resolve_safe();
- m_out_int_cb.resolve_safe();
-
- // register for state saving
- save_item(NAME(m_irq));
- save_item(NAME(m_reg));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void lh5810_device::device_reset()
-{
- memset(m_reg, 0, sizeof(m_reg));
- m_irq = 0;
-}
-
-
-//-------------------------------------------------
-// data_r - data read
-//-------------------------------------------------
-
-READ8_MEMBER( lh5810_device::data_r )
-{
- switch (offset)
- {
- case LH5810_U:
- case LH5810_L:
- case LH5810_G:
- case LH5810_DDA:
- case LH5810_DDB:
- case LH5810_OPC:
- case LH5820_F:
- return m_reg[offset];
-
- case LH5810_IF:
- if (BIT(m_portb_r_cb(0) & ~m_reg[LH5810_DDB], 7))
- m_reg[offset] |= 2;
- else
- m_reg[offset] &= 0xfd;
-
- return m_reg[offset];
-
- case LH5810_MSK:
- return (m_reg[offset]&0x0f) | (m_irq<<4) | (BIT(m_reg[LH5810_OPB],7)<<5);
-
- case LH5810_OPA:
- m_reg[offset] = (m_reg[offset] & m_reg[LH5810_DDA]) | (m_porta_r_cb(0) & ~m_reg[LH5810_DDA]);
- return m_reg[offset];
-
- case LH5810_OPB:
- m_reg[offset] = (m_reg[offset] & m_reg[LH5810_DDB]) | (m_portb_r_cb(0) & ~m_reg[LH5810_DDB]);
- m_out_int_cb((m_reg[offset] & 0x80 && m_reg[LH5810_MSK] & 0x02) ? ASSERT_LINE : CLEAR_LINE);
- return m_reg[offset];
-
- default:
- return 0x00;
- }
-}
-
-
-//-------------------------------------------------
-// data_w - data write
-//-------------------------------------------------
-
-WRITE8_MEMBER( lh5810_device::data_w )
-{
- switch (offset)
- {
- case LH5810_RESET:
- break;
-
- case LH5810_G:
- case LH5820_F:
- case LH5810_DDA:
- case LH5810_DDB:
- m_reg[offset] = data;
- break;
-
- case LH5810_U:
- //writing on U register clear the RD flag of IF register
- m_reg[LH5810_IF] &= 0xfb;
- m_reg[offset] = data;
- break;
-
- case LH5810_L:
- //writing on L register clear the TD flag of IF register
- m_reg[LH5810_IF] &= 0xf7;
- m_reg[offset] = data;
- break;
-
- case LH5810_MSK:
- m_reg[offset] = data & 0x0f;
- break;
-
- case LH5810_IF:
- //only bit 0 and 1 are writable
- m_reg[offset] = (m_reg[offset] & 0xfc) | (data & 0x03);
- break;
-
- case LH5810_OPA:
- m_reg[offset] = (data & m_reg[LH5810_DDA]) | (m_reg[offset] & ~m_reg[LH5810_DDA]);
- m_porta_w_cb((offs_t)0, m_reg[offset]);
- break;
-
- case LH5810_OPB:
- m_reg[offset] = (data & m_reg[LH5810_DDB]) | (m_reg[offset] & ~m_reg[LH5810_DDB]);
- m_portb_w_cb((offs_t)0, m_reg[offset]);
- m_out_int_cb((m_reg[offset] & 0x80 && m_reg[LH5810_MSK] & 0x02) ? ASSERT_LINE : CLEAR_LINE);
- break;
-
- case LH5810_OPC:
- m_reg[offset] = data;
- m_portc_w_cb((offs_t)0, m_reg[offset]);
- break;
- }
-}
diff --git a/src/emu/machine/lh5810.h b/src/emu/machine/lh5810.h
deleted file mode 100644
index d78458ca172..00000000000
--- a/src/emu/machine/lh5810.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Sandro Ronco
-/**********************************************************************
-
- LH5810/LH5811 Input/Output Port Controller
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __LH5810__
-#define __LH5810__
-
-#include "emu.h"
-
-//*************************************************************************
-// MACROS / CONSTANTS
-//*************************************************************************
-
-enum
-{
- LH5810_RESET = 4,
- LH5810_U,
- LH5810_L,
- LH5820_F,
- LH5810_OPC,
- LH5810_G,
- LH5810_MSK,
- LH5810_IF,
- LH5810_DDA,
- LH5810_DDB,
- LH5810_OPA,
- LH5810_OPB
-};
-
-
-//*************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//*************************************************************************
-
-#define MCFG_LH5810_PORTA_R_CB(_devcb) \
- devcb = &lh5810_device::set_porta_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_LH5810_PORTA_W_CB(_devcb) \
- devcb = &lh5810_device::set_porta_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_LH5810_PORTB_R_CB(_devcb) \
- devcb = &lh5810_device::set_portb_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_LH5810_PORTB_W_CB(_devcb) \
- devcb = &lh5810_device::set_portb_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_LH5810_PORTC_W_CB(_devcb) \
- devcb = &lh5810_device::set_portc_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_LH5810_OUT_INT_CB(_devcb) \
- devcb = &lh5810_device::set_out_int_callback(*device, DEVCB_##_devcb); //currently unused
-
-
-
-//*************************************************************************
-// TYPE DEFINITIONS
-//*************************************************************************
-
-// ======================> lh5810_device
-
-class lh5810_device : public device_t
-{
-public:
- // construction/destruction
- lh5810_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_porta_r_callback(device_t &device, _Object object) { return downcast<lh5810_device &>(device).m_porta_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_porta_w_callback(device_t &device, _Object object) { return downcast<lh5810_device &>(device).m_porta_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_portb_r_callback(device_t &device, _Object object) { return downcast<lh5810_device &>(device).m_portb_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_portb_w_callback(device_t &device, _Object object) { return downcast<lh5810_device &>(device).m_portb_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_portc_w_callback(device_t &device, _Object object) { return downcast<lh5810_device &>(device).m_portc_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_int_callback(device_t &device, _Object object) { return downcast<lh5810_device &>(device).m_out_int_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( data_r );
- DECLARE_WRITE8_MEMBER( data_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
-
- devcb_read8 m_porta_r_cb; //port A read
- devcb_write8 m_porta_w_cb; //port A write
- devcb_read8 m_portb_r_cb; //port B read
- devcb_write8 m_portb_w_cb; //port B write
- devcb_write8 m_portc_w_cb; //port C write
-
- devcb_write_line m_out_int_cb; //IRQ callback
-
- UINT8 m_reg[0x10];
- UINT8 m_irq;
-};
-
-
-// device type definition
-extern const device_type LH5810;
-
-#endif
diff --git a/src/emu/machine/linflash.c b/src/emu/machine/linflash.c
deleted file mode 100644
index fe72efa921d..00000000000
--- a/src/emu/machine/linflash.c
+++ /dev/null
@@ -1,208 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "linflash.h"
-
-linear_flash_pccard_device::linear_flash_pccard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock,const char *shortname, const char *source) :
- device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_memory_interface(mconfig, *this),
- device_slot_card_interface(mconfig, *this)
-{
-}
-
-void linear_flash_pccard_device::device_start()
-{
- m_space = &space(AS_0);
-}
-
-const address_space_config *linear_flash_pccard_device::memory_space_config( address_spacenum spacenum ) const
-{
- return ( spacenum == AS_0 ) ? &m_space_config : NULL;
-}
-
-READ16_MEMBER( linear_flash_pccard_device::read_memory )
-{
- UINT16 data = m_space->read_word(offset * 2, mem_mask);
- //printf( "<%08x %04x %04x\n", offset, data, mem_mask );
- return data;
-}
-
-WRITE16_MEMBER( linear_flash_pccard_device::write_memory )
-{
- //printf( ">%08x %04x %04x\n", offset, data, mem_mask );
- m_space->write_word(offset * 2, data, mem_mask);
-}
-
-
-const device_type LINEAR_FLASH_PCCARD_16MB = &device_creator<linear_flash_pccard_16mb_device>;
-
-static ADDRESS_MAP_START(linear_flash_pccard_16mb, AS_0, 16, linear_flash_pccard_16mb_device)
- ADDRESS_MAP_UNMAP_HIGH
- AM_RANGE(0x00000000, 0x003fffff) AM_DEVREADWRITE8("1l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x00000000, 0x003fffff) AM_DEVREADWRITE8("1u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x00400000, 0x007fffff) AM_DEVREADWRITE8("2l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x00400000, 0x007fffff) AM_DEVREADWRITE8("2u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x00800000, 0x00bfffff) AM_DEVREADWRITE8("3l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x00800000, 0x00bfffff) AM_DEVREADWRITE8("3u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x00c00000, 0x00ffffff) AM_DEVREADWRITE8("4l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x00c00000, 0x00ffffff) AM_DEVREADWRITE8("4u", intelfsh8_device, read, write, 0xff00)
-ADDRESS_MAP_END
-
-linear_flash_pccard_16mb_device::linear_flash_pccard_16mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- linear_flash_pccard_device(mconfig, LINEAR_FLASH_PCCARD_16MB, "Linear Flash PCCARD (16MB)", tag, owner, clock, "linearflash16mb", __FILE__)
-{
- m_space_config = address_space_config("memory", ENDIANNESS_LITTLE, 16, 26, 0, *ADDRESS_MAP_NAME( linear_flash_pccard_16mb ) );
-}
-
-static MACHINE_CONFIG_FRAGMENT( linear_flash_pccard_16mb )
- MCFG_FUJITSU_29F016A_ADD("1l")
- MCFG_FUJITSU_29F016A_ADD("1u")
- MCFG_FUJITSU_29F016A_ADD("2l")
- MCFG_FUJITSU_29F016A_ADD("2u")
- MCFG_FUJITSU_29F016A_ADD("3l")
- MCFG_FUJITSU_29F016A_ADD("3u")
- MCFG_FUJITSU_29F016A_ADD("4l")
- MCFG_FUJITSU_29F016A_ADD("4u")
-MACHINE_CONFIG_END
-
-machine_config_constructor linear_flash_pccard_16mb_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( linear_flash_pccard_16mb );
-}
-
-
-const device_type LINEAR_FLASH_PCCARD_32MB = &device_creator<linear_flash_pccard_32mb_device>;
-
-static ADDRESS_MAP_START(linear_flash_pccard_32mb, AS_0, 16, linear_flash_pccard_32mb_device)
- ADDRESS_MAP_UNMAP_HIGH
- AM_RANGE(0x00000000, 0x003fffff) AM_DEVREADWRITE8("1l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x00000000, 0x003fffff) AM_DEVREADWRITE8("1u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x00400000, 0x007fffff) AM_DEVREADWRITE8("2l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x00400000, 0x007fffff) AM_DEVREADWRITE8("2u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x00800000, 0x00bfffff) AM_DEVREADWRITE8("3l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x00800000, 0x00bfffff) AM_DEVREADWRITE8("3u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x00c00000, 0x00ffffff) AM_DEVREADWRITE8("4l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x00c00000, 0x00ffffff) AM_DEVREADWRITE8("4u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x01000000, 0x013fffff) AM_DEVREADWRITE8("5l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x01000000, 0x013fffff) AM_DEVREADWRITE8("5u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x01400000, 0x017fffff) AM_DEVREADWRITE8("6l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x01400000, 0x017fffff) AM_DEVREADWRITE8("6u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x01800000, 0x01bfffff) AM_DEVREADWRITE8("7l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x01800000, 0x01bfffff) AM_DEVREADWRITE8("7u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x01c00000, 0x01ffffff) AM_DEVREADWRITE8("8l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x01c00000, 0x01ffffff) AM_DEVREADWRITE8("8u", intelfsh8_device, read, write, 0xff00)
-ADDRESS_MAP_END
-
-linear_flash_pccard_32mb_device::linear_flash_pccard_32mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- linear_flash_pccard_device(mconfig, LINEAR_FLASH_PCCARD_32MB, "Linear Flash PCCARD (32MB)", tag, owner, clock, "linearflash32mb", __FILE__)
-{
- m_space_config = address_space_config("memory", ENDIANNESS_LITTLE, 16, 26, 0, *ADDRESS_MAP_NAME( linear_flash_pccard_32mb ) );
-}
-
-static MACHINE_CONFIG_FRAGMENT( linear_flash_pccard_32mb )
- MCFG_FUJITSU_29F016A_ADD("1l")
- MCFG_FUJITSU_29F016A_ADD("1u")
- MCFG_FUJITSU_29F016A_ADD("2l")
- MCFG_FUJITSU_29F016A_ADD("2u")
- MCFG_FUJITSU_29F016A_ADD("3l")
- MCFG_FUJITSU_29F016A_ADD("3u")
- MCFG_FUJITSU_29F016A_ADD("4l")
- MCFG_FUJITSU_29F016A_ADD("4u")
- MCFG_FUJITSU_29F016A_ADD("5l")
- MCFG_FUJITSU_29F016A_ADD("5u")
- MCFG_FUJITSU_29F016A_ADD("6l")
- MCFG_FUJITSU_29F016A_ADD("6u")
- MCFG_FUJITSU_29F016A_ADD("7l")
- MCFG_FUJITSU_29F016A_ADD("7u")
- MCFG_FUJITSU_29F016A_ADD("8l")
- MCFG_FUJITSU_29F016A_ADD("8u")
-MACHINE_CONFIG_END
-
-machine_config_constructor linear_flash_pccard_32mb_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( linear_flash_pccard_32mb );
-}
-
-
-const device_type LINEAR_FLASH_PCCARD_64MB = &device_creator<linear_flash_pccard_64mb_device>;
-
-static ADDRESS_MAP_START(linear_flash_pccard_64mb, AS_0, 16, linear_flash_pccard_64mb_device)
- ADDRESS_MAP_UNMAP_HIGH
- AM_RANGE(0x00000000, 0x003fffff) AM_DEVREADWRITE8("1l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x00000000, 0x003fffff) AM_DEVREADWRITE8("1u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x00400000, 0x007fffff) AM_DEVREADWRITE8("2l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x00400000, 0x007fffff) AM_DEVREADWRITE8("2u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x00800000, 0x00bfffff) AM_DEVREADWRITE8("3l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x00800000, 0x00bfffff) AM_DEVREADWRITE8("3u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x00c00000, 0x00ffffff) AM_DEVREADWRITE8("4l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x00c00000, 0x00ffffff) AM_DEVREADWRITE8("4u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x01000000, 0x013fffff) AM_DEVREADWRITE8("5l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x01000000, 0x013fffff) AM_DEVREADWRITE8("5u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x01400000, 0x017fffff) AM_DEVREADWRITE8("6l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x01400000, 0x017fffff) AM_DEVREADWRITE8("6u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x01800000, 0x01bfffff) AM_DEVREADWRITE8("7l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x01800000, 0x01bfffff) AM_DEVREADWRITE8("7u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x01c00000, 0x01ffffff) AM_DEVREADWRITE8("8l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x01c00000, 0x01ffffff) AM_DEVREADWRITE8("8u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x02000000, 0x023fffff) AM_DEVREADWRITE8("9l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x02000000, 0x023fffff) AM_DEVREADWRITE8("9u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x02400000, 0x027fffff) AM_DEVREADWRITE8("10l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x02400000, 0x027fffff) AM_DEVREADWRITE8("10u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x02800000, 0x02bfffff) AM_DEVREADWRITE8("11l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x02800000, 0x02bfffff) AM_DEVREADWRITE8("11u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x02c00000, 0x02ffffff) AM_DEVREADWRITE8("12l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x02c00000, 0x02ffffff) AM_DEVREADWRITE8("12u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x03000000, 0x033fffff) AM_DEVREADWRITE8("13l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x03000000, 0x033fffff) AM_DEVREADWRITE8("13u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x03400000, 0x037fffff) AM_DEVREADWRITE8("14l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x03400000, 0x037fffff) AM_DEVREADWRITE8("14u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x03800000, 0x03bfffff) AM_DEVREADWRITE8("15l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x03800000, 0x03bfffff) AM_DEVREADWRITE8("15u", intelfsh8_device, read, write, 0xff00)
- AM_RANGE(0x03c00000, 0x03ffffff) AM_DEVREADWRITE8("16l", intelfsh8_device, read, write, 0x00ff)
- AM_RANGE(0x03c00000, 0x03ffffff) AM_DEVREADWRITE8("16u", intelfsh8_device, read, write, 0xff00)
-ADDRESS_MAP_END
-
-linear_flash_pccard_64mb_device::linear_flash_pccard_64mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- linear_flash_pccard_device(mconfig, LINEAR_FLASH_PCCARD_64MB, "Linear Flash PCCARD (64MB)", tag, owner, clock, "linearflash64mb", __FILE__)
-{
- m_space_config = address_space_config("memory", ENDIANNESS_LITTLE, 16, 26, 0, *ADDRESS_MAP_NAME( linear_flash_pccard_64mb ) );
-}
-
-static MACHINE_CONFIG_FRAGMENT( linear_flash_pccard_64mb )
- MCFG_FUJITSU_29F016A_ADD("1l")
- MCFG_FUJITSU_29F016A_ADD("1u")
- MCFG_FUJITSU_29F016A_ADD("2l")
- MCFG_FUJITSU_29F016A_ADD("2u")
- MCFG_FUJITSU_29F016A_ADD("3l")
- MCFG_FUJITSU_29F016A_ADD("3u")
- MCFG_FUJITSU_29F016A_ADD("4l")
- MCFG_FUJITSU_29F016A_ADD("4u")
- MCFG_FUJITSU_29F016A_ADD("5l")
- MCFG_FUJITSU_29F016A_ADD("5u")
- MCFG_FUJITSU_29F016A_ADD("6l")
- MCFG_FUJITSU_29F016A_ADD("6u")
- MCFG_FUJITSU_29F016A_ADD("7l")
- MCFG_FUJITSU_29F016A_ADD("7u")
- MCFG_FUJITSU_29F016A_ADD("8l")
- MCFG_FUJITSU_29F016A_ADD("8u")
- MCFG_FUJITSU_29F016A_ADD("9l")
- MCFG_FUJITSU_29F016A_ADD("9u")
- MCFG_FUJITSU_29F016A_ADD("10l")
- MCFG_FUJITSU_29F016A_ADD("10u")
- MCFG_FUJITSU_29F016A_ADD("11l")
- MCFG_FUJITSU_29F016A_ADD("11u")
- MCFG_FUJITSU_29F016A_ADD("12l")
- MCFG_FUJITSU_29F016A_ADD("12u")
- MCFG_FUJITSU_29F016A_ADD("13l")
- MCFG_FUJITSU_29F016A_ADD("13u")
- MCFG_FUJITSU_29F016A_ADD("14l")
- MCFG_FUJITSU_29F016A_ADD("14u")
- MCFG_FUJITSU_29F016A_ADD("15l")
- MCFG_FUJITSU_29F016A_ADD("15u")
- MCFG_FUJITSU_29F016A_ADD("16l")
- MCFG_FUJITSU_29F016A_ADD("16u")
-MACHINE_CONFIG_END
-
-machine_config_constructor linear_flash_pccard_64mb_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( linear_flash_pccard_64mb );
-}
diff --git a/src/emu/machine/linflash.h b/src/emu/machine/linflash.h
deleted file mode 100644
index b4bd488d55d..00000000000
--- a/src/emu/machine/linflash.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#pragma once
-
-#ifndef __LINFLASH_H__
-#define __LINFLASH_H__
-
-#include "emu.h"
-#include "intelfsh.h"
-#include "machine/pccard.h"
-
-class linear_flash_pccard_device : public device_t,
- public pccard_interface,
- public device_memory_interface,
- public device_slot_card_interface
-{
-public:
- virtual DECLARE_READ16_MEMBER(read_memory);
- virtual DECLARE_WRITE16_MEMBER(write_memory);
-
-protected:
- linear_flash_pccard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock,const char *shortname, const char *source);
-
- // device-level overrides
- virtual void device_start();
-
- // device_memory_interface overrides
- virtual const address_space_config *memory_space_config( address_spacenum spacenum = AS_0 ) const;
-
- address_space_config m_space_config;
- address_space *m_space;
-};
-
-
-extern const device_type LINEAR_FLASH_PCCARD_16MB;
-
-class linear_flash_pccard_16mb_device : public linear_flash_pccard_device
-{
-public:
- linear_flash_pccard_16mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- // device-level overrides
- virtual machine_config_constructor device_mconfig_additions() const;
-};
-
-
-extern const device_type LINEAR_FLASH_PCCARD_32MB;
-
-class linear_flash_pccard_32mb_device : public linear_flash_pccard_device
-{
-public:
- linear_flash_pccard_32mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- // device-level overrides
- virtual machine_config_constructor device_mconfig_additions() const;
-};
-
-extern const device_type LINEAR_FLASH_PCCARD_64MB;
-
-class linear_flash_pccard_64mb_device : public linear_flash_pccard_device
-{
-public:
- linear_flash_pccard_64mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- // device-level overrides
- virtual machine_config_constructor device_mconfig_additions() const;
-};
-
-#endif
diff --git a/src/emu/machine/lpc-acpi.c b/src/emu/machine/lpc-acpi.c
deleted file mode 100644
index 72d066affaa..00000000000
--- a/src/emu/machine/lpc-acpi.c
+++ /dev/null
@@ -1,368 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "lpc-acpi.h"
-
-const device_type LPC_ACPI = &device_creator<lpc_acpi_device>;
-
-DEVICE_ADDRESS_MAP_START(map, 32, lpc_acpi_device)
- AM_RANGE(0x00, 0x03) AM_READWRITE16(pm1_sts_r, pm1_sts_w, 0x0000ffff)
- AM_RANGE(0x00, 0x03) AM_READWRITE16(pm1_en_r, pm1_en_w, 0xffff0000)
- AM_RANGE(0x04, 0x07) AM_READWRITE (pm1_cnt_r, pm1_cnt_w)
- AM_RANGE(0x08, 0x0b) AM_READ (pm1_tmr_r)
- AM_RANGE(0x10, 0x13) AM_READWRITE (proc_cnt_r, proc_cnt_w)
- AM_RANGE(0x14, 0x17) AM_READ8 (lv2_r, 0x000000ff)
- AM_RANGE(0x28, 0x2b) AM_READWRITE (gpe0_sts_r, gpe0_sts_w)
- AM_RANGE(0x2c, 0x2f) AM_READWRITE (gpe0_en_r, gpe0_en_w)
- AM_RANGE(0x30, 0x33) AM_READWRITE (smi_en_r, smi_en_w)
- AM_RANGE(0x34, 0x37) AM_READWRITE (smi_sts_r, smi_sts_w)
- AM_RANGE(0x38, 0x3b) AM_READWRITE16(alt_gp_smi_en_r, alt_gp_smi_en_w, 0x0000ffff)
- AM_RANGE(0x38, 0x3b) AM_READWRITE16(alt_gp_smi_sts_r, alt_gp_smi_sts_w, 0xffff0000)
- AM_RANGE(0x44, 0x47) AM_READWRITE16(devact_sts_r, devact_sts_w, 0x0000ffff)
- AM_RANGE(0x48, 0x4b) AM_READWRITE16(devtrap_en_r, devtrap_en_w, 0x0000ffff)
- AM_RANGE(0x4c, 0x4f) AM_READ16 (bus_addr_track_r, 0x0000ffff)
- AM_RANGE(0x4c, 0x4f) AM_READ8 (bus_cyc_track_r, 0x00ff0000)
-
- AM_RANGE(0x60, 0x63) AM_READWRITE8 (tco_rld_r, tco_rld_w, 0x000000ff)
- AM_RANGE(0x60, 0x63) AM_READWRITE8 (tco_tmr_r, tco_tmr_w, 0x0000ff00)
- AM_RANGE(0x60, 0x63) AM_READWRITE8 (tco_dat_in_r, tco_dat_in_w, 0x00ff0000)
- AM_RANGE(0x60, 0x63) AM_READWRITE8 (tco_dat_out_r, tco_dat_out_w, 0xff000000)
- AM_RANGE(0x64, 0x67) AM_READWRITE16(tco1_sts_r, tco1_sts_w, 0x0000ffff)
- AM_RANGE(0x64, 0x67) AM_READWRITE16(tco2_sts_r, tco2_sts_w, 0xffff0000)
- AM_RANGE(0x68, 0x6b) AM_READWRITE16(tco1_cnt_r, tco1_cnt_w, 0x0000ffff)
- AM_RANGE(0x68, 0x6b) AM_READWRITE16(tco2_cnt_r, tco2_cnt_w, 0xffff0000)
- AM_RANGE(0x6c, 0x6f) AM_READWRITE8 (tco_message1_r, tco_message1_w, 0x000000ff)
- AM_RANGE(0x6c, 0x6f) AM_READWRITE8 (tco_message2_r, tco_message2_w, 0x0000ff00)
- AM_RANGE(0x6c, 0x6f) AM_READWRITE8 (tco_wdstatus_r, tco_wdstatus_w, 0x00ff0000)
- AM_RANGE(0x70, 0x73) AM_READWRITE8 (sw_irq_gen_r, sw_irq_gen_w, 0x000000ff)
-ADDRESS_MAP_END
-
-lpc_acpi_device::lpc_acpi_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : lpc_device(mconfig, LPC_ACPI, "LPC ACPI", tag, owner, clock, "lpc_acpi", __FILE__)
-{
-}
-
-void lpc_acpi_device::map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space)
-{
- io_space->install_device(io_offset, io_window_end, *this, &lpc_acpi_device::map);
-}
-
-void lpc_acpi_device::device_start()
-{
-}
-
-void lpc_acpi_device::device_reset()
-{
- pm1_sts = 0;
- pm1_en = 0;
- pm1_cnt = 0;
- proc_cnt = 0;
- gpe0_sts = 0;
- gpe0_en = 0;
- smi_en = 0;
- smi_sts = 0;
- alt_gp_smi_en = 0;
- alt_gp_smi_sts = 0;
- devact_sts = 0;
- devtrap_en = 0;
-
- tco_rld = 0;
- tco_tmr = 0;
- tco_dat_in = 0;
- tco_dat_out = 0;
- tco1_sts = 0;
- tco2_sts = 0;
- tco1_cnt = 0;
- tco2_cnt = 0;
- tco_message1 = 0;
- tco_message2 = 0;
- tco_wdstatus = 0;
- sw_irq_gen = 0;
-}
-
-READ16_MEMBER( lpc_acpi_device::pm1_sts_r)
-{
- return pm1_sts;
-}
-
-WRITE16_MEMBER(lpc_acpi_device::pm1_sts_w)
-{
- pm1_sts &= ~data;
- logerror("%s: pm1_sts = %04x\n", tag(), pm1_sts);
-}
-
-READ16_MEMBER( lpc_acpi_device::pm1_en_r)
-{
- return pm1_en;
-}
-
-WRITE16_MEMBER(lpc_acpi_device::pm1_en_w)
-{
- COMBINE_DATA(&pm1_en);
- logerror("%s: pm1_en = %04x\n", tag(), pm1_en);
-}
-
-READ32_MEMBER( lpc_acpi_device::pm1_cnt_r)
-{
- return pm1_cnt;
-}
-
-WRITE32_MEMBER(lpc_acpi_device::pm1_cnt_w)
-{
- COMBINE_DATA(&pm1_cnt);
- logerror("%s: pm1_cnt = %08x\n", tag(), pm1_cnt);
-}
-
-READ32_MEMBER(lpc_acpi_device::pm1_tmr_r)
-{
- return machine().time().as_ticks(3579545) & 0xffffff;
-}
-
-READ32_MEMBER( lpc_acpi_device::proc_cnt_r)
-{
- return proc_cnt;
-}
-
-WRITE32_MEMBER(lpc_acpi_device::proc_cnt_w)
-{
- COMBINE_DATA(&proc_cnt);
- logerror("%s: proc_cnt = %08x\n", tag(), proc_cnt);
-}
-
-READ8_MEMBER( lpc_acpi_device::lv2_r)
-{
- return 0x00;
-}
-
-READ32_MEMBER( lpc_acpi_device::gpe0_sts_r)
-{
- return gpe0_sts;
-}
-
-WRITE32_MEMBER(lpc_acpi_device::gpe0_sts_w)
-{
- COMBINE_DATA(&gpe0_sts);
- logerror("%s: gpe0_sts = %08x\n", tag(), gpe0_sts);
-}
-
-READ32_MEMBER( lpc_acpi_device::gpe0_en_r)
-{
- return gpe0_en;
-}
-
-WRITE32_MEMBER(lpc_acpi_device::gpe0_en_w)
-{
- COMBINE_DATA(&gpe0_en);
- logerror("%s: gpe0_en = %08x\n", tag(), gpe0_en);
-}
-
-READ32_MEMBER( lpc_acpi_device::smi_en_r)
-{
- return smi_en;
-}
-
-WRITE32_MEMBER(lpc_acpi_device::smi_en_w)
-{
- COMBINE_DATA(&smi_en);
- logerror("%s: smi_en = %08x\n", tag(), smi_en);
-}
-
-READ32_MEMBER( lpc_acpi_device::smi_sts_r)
-{
- return smi_sts;
-}
-
-WRITE32_MEMBER(lpc_acpi_device::smi_sts_w)
-{
- COMBINE_DATA(&smi_sts);
- logerror("%s: smi_sts = %08x\n", tag(), smi_sts);
-}
-
-READ16_MEMBER( lpc_acpi_device::alt_gp_smi_en_r)
-{
- return alt_gp_smi_en;
-}
-
-WRITE16_MEMBER(lpc_acpi_device::alt_gp_smi_en_w)
-{
- COMBINE_DATA(&alt_gp_smi_en);
- logerror("%s: alt_gp_smi_en = %04x\n", tag(), alt_gp_smi_en);
-}
-
-READ16_MEMBER( lpc_acpi_device::alt_gp_smi_sts_r)
-{
- return alt_gp_smi_sts;
-}
-
-WRITE16_MEMBER(lpc_acpi_device::alt_gp_smi_sts_w)
-{
- COMBINE_DATA(&alt_gp_smi_sts);
- logerror("%s: alt_gp_smi_sts = %04x\n", tag(), alt_gp_smi_sts);
-}
-
-READ16_MEMBER( lpc_acpi_device::devact_sts_r)
-{
- return devact_sts;
-}
-
-WRITE16_MEMBER(lpc_acpi_device::devact_sts_w)
-{
- COMBINE_DATA(&devact_sts);
- logerror("%s: devact_sts = %04x\n", tag(), devact_sts);
-}
-
-READ16_MEMBER( lpc_acpi_device::devtrap_en_r)
-{
- return devtrap_en;
-}
-
-WRITE16_MEMBER(lpc_acpi_device::devtrap_en_w)
-{
- COMBINE_DATA(&devtrap_en);
- logerror("%s: devtrap_en = %04x\n", tag(), devtrap_en);
-}
-
-READ16_MEMBER( lpc_acpi_device::bus_addr_track_r)
-{
- logerror("%s: read bus_addr_track\n", tag());
- return 0;
-}
-
-READ8_MEMBER( lpc_acpi_device::bus_cyc_track_r)
-{
- logerror("%s: read bus_cyc_track\n", tag());
- return 0;
-}
-
-
-READ8_MEMBER( lpc_acpi_device::tco_rld_r)
-{
- return tco_rld;
-}
-
-WRITE8_MEMBER( lpc_acpi_device::tco_rld_w)
-{
- tco_rld = data;
- logerror("%s: tco_rld = %02x\n", tag(), tco_rld);
-}
-
-READ8_MEMBER( lpc_acpi_device::tco_tmr_r)
-{
- return tco_tmr;
-}
-
-WRITE8_MEMBER( lpc_acpi_device::tco_tmr_w)
-{
- tco_tmr = data;
- logerror("%s: tco_tmr = %02x\n", tag(), tco_tmr);
-}
-
-READ8_MEMBER( lpc_acpi_device::tco_dat_in_r)
-{
- return tco_dat_in;
-}
-
-WRITE8_MEMBER( lpc_acpi_device::tco_dat_in_w)
-{
- tco_dat_in = data;
- logerror("%s: tco_dat_in = %02x\n", tag(), tco_dat_in);
-}
-
-READ8_MEMBER( lpc_acpi_device::tco_dat_out_r)
-{
- return tco_dat_out;
-}
-
-WRITE8_MEMBER( lpc_acpi_device::tco_dat_out_w)
-{
- tco_dat_out = data;
- logerror("%s: tco_dat_out = %02x\n", tag(), tco_dat_out);
-}
-
-READ16_MEMBER( lpc_acpi_device::tco1_sts_r)
-{
- return tco1_sts;
-}
-
-WRITE16_MEMBER(lpc_acpi_device::tco1_sts_w)
-{
- COMBINE_DATA(&tco1_sts);
- logerror("%s: tco1_sts = %04x\n", tag(), tco1_sts);
-}
-
-READ16_MEMBER( lpc_acpi_device::tco2_sts_r)
-{
- return tco2_sts;
-}
-
-WRITE16_MEMBER(lpc_acpi_device::tco2_sts_w)
-{
- COMBINE_DATA(&tco2_sts);
- logerror("%s: tco2_sts = %04x\n", tag(), tco2_sts);
-}
-
-READ16_MEMBER( lpc_acpi_device::tco1_cnt_r)
-{
- return tco1_cnt;
-}
-
-WRITE16_MEMBER(lpc_acpi_device::tco1_cnt_w)
-{
- COMBINE_DATA(&tco1_cnt);
- logerror("%s: tco1_cnt = %04x\n", tag(), tco1_cnt);
-}
-
-READ16_MEMBER( lpc_acpi_device::tco2_cnt_r)
-{
- return tco2_cnt;
-}
-
-WRITE16_MEMBER(lpc_acpi_device::tco2_cnt_w)
-{
- COMBINE_DATA(&tco2_cnt);
- logerror("%s: tco2_cnt = %04x\n", tag(), tco2_cnt);
-}
-
-READ8_MEMBER( lpc_acpi_device::tco_message1_r)
-{
- return tco_message1;
-}
-
-WRITE8_MEMBER( lpc_acpi_device::tco_message1_w)
-{
- tco_message1 = data;
- logerror("%s: tco_message1 = %02x\n", tag(), tco_message1);
-}
-
-READ8_MEMBER( lpc_acpi_device::tco_message2_r)
-{
- return tco_message2;
-}
-
-WRITE8_MEMBER( lpc_acpi_device::tco_message2_w)
-{
- tco_message2 = data;
- logerror("%s: tco_message2 = %02x\n", tag(), tco_message2);
-}
-
-READ8_MEMBER( lpc_acpi_device::tco_wdstatus_r)
-{
- return tco_wdstatus;
-}
-
-WRITE8_MEMBER( lpc_acpi_device::tco_wdstatus_w)
-{
- tco_wdstatus = data;
- logerror("%s: tco_wdstatus = %02x\n", tag(), tco_wdstatus);
-}
-
-READ8_MEMBER( lpc_acpi_device::sw_irq_gen_r)
-{
- return sw_irq_gen;
-}
-
-WRITE8_MEMBER( lpc_acpi_device::sw_irq_gen_w)
-{
- sw_irq_gen = data;
- logerror("%s: sw_irq_gen = %02x\n", tag(), sw_irq_gen);
-}
diff --git a/src/emu/machine/lpc-acpi.h b/src/emu/machine/lpc-acpi.h
deleted file mode 100644
index 2abf019d408..00000000000
--- a/src/emu/machine/lpc-acpi.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef LPC_ACPI_H
-#define LPC_ACPI_H
-
-#include "lpc.h"
-
-#define MCFG_LPC_ACPI_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, LPC_ACPI, 0)
-
-class lpc_acpi_device : public lpc_device {
-public:
- lpc_acpi_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual void map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space);
-
- DECLARE_READ16_MEMBER( pm1_sts_r);
- DECLARE_WRITE16_MEMBER(pm1_sts_w);
- DECLARE_READ16_MEMBER( pm1_en_r);
- DECLARE_WRITE16_MEMBER(pm1_en_w);
- DECLARE_READ32_MEMBER( pm1_cnt_r);
- DECLARE_WRITE32_MEMBER(pm1_cnt_w);
- DECLARE_READ32_MEMBER( pm1_tmr_r);
- DECLARE_READ32_MEMBER( proc_cnt_r);
- DECLARE_WRITE32_MEMBER(proc_cnt_w);
- DECLARE_READ8_MEMBER( lv2_r);
- DECLARE_READ32_MEMBER( gpe0_sts_r);
- DECLARE_WRITE32_MEMBER(gpe0_sts_w);
- DECLARE_READ32_MEMBER( gpe0_en_r);
- DECLARE_WRITE32_MEMBER(gpe0_en_w);
- DECLARE_READ32_MEMBER( smi_en_r);
- DECLARE_WRITE32_MEMBER(smi_en_w);
- DECLARE_READ32_MEMBER( smi_sts_r);
- DECLARE_WRITE32_MEMBER(smi_sts_w);
- DECLARE_READ16_MEMBER( alt_gp_smi_en_r);
- DECLARE_WRITE16_MEMBER(alt_gp_smi_en_w);
- DECLARE_READ16_MEMBER( alt_gp_smi_sts_r);
- DECLARE_WRITE16_MEMBER(alt_gp_smi_sts_w);
- DECLARE_READ16_MEMBER( devact_sts_r);
- DECLARE_WRITE16_MEMBER(devact_sts_w);
- DECLARE_READ16_MEMBER( devtrap_en_r);
- DECLARE_WRITE16_MEMBER(devtrap_en_w);
- DECLARE_READ16_MEMBER( bus_addr_track_r);
- DECLARE_READ8_MEMBER( bus_cyc_track_r);
-
- DECLARE_READ8_MEMBER( tco_rld_r);
- DECLARE_WRITE8_MEMBER( tco_rld_w);
- DECLARE_READ8_MEMBER( tco_tmr_r);
- DECLARE_WRITE8_MEMBER( tco_tmr_w);
- DECLARE_READ8_MEMBER( tco_dat_in_r);
- DECLARE_WRITE8_MEMBER( tco_dat_in_w);
- DECLARE_READ8_MEMBER( tco_dat_out_r);
- DECLARE_WRITE8_MEMBER( tco_dat_out_w);
- DECLARE_READ16_MEMBER( tco1_sts_r);
- DECLARE_WRITE16_MEMBER(tco1_sts_w);
- DECLARE_READ16_MEMBER( tco2_sts_r);
- DECLARE_WRITE16_MEMBER(tco2_sts_w);
- DECLARE_READ16_MEMBER( tco1_cnt_r);
- DECLARE_WRITE16_MEMBER(tco1_cnt_w);
- DECLARE_READ16_MEMBER( tco2_cnt_r);
- DECLARE_WRITE16_MEMBER(tco2_cnt_w);
- DECLARE_READ8_MEMBER( tco_message1_r);
- DECLARE_WRITE8_MEMBER( tco_message1_w);
- DECLARE_READ8_MEMBER( tco_message2_r);
- DECLARE_WRITE8_MEMBER( tco_message2_w);
- DECLARE_READ8_MEMBER( tco_wdstatus_r);
- DECLARE_WRITE8_MEMBER( tco_wdstatus_w);
- DECLARE_READ8_MEMBER( sw_irq_gen_r);
- DECLARE_WRITE8_MEMBER( sw_irq_gen_w);
-
-protected:
- void device_start();
- void device_reset();
-
-private:
- UINT32 pm1_cnt, proc_cnt, gpe0_sts, gpe0_en, smi_en, smi_sts;
- UINT16 pm1_sts, pm1_en, alt_gp_smi_en, alt_gp_smi_sts, devact_sts, devtrap_en;
- UINT16 tco1_sts, tco2_sts, tco1_cnt, tco2_cnt;
- UINT8 tco_rld, tco_tmr, tco_dat_in, tco_dat_out, tco_message1, tco_message2;
- UINT8 tco_wdstatus, sw_irq_gen;
-
- DECLARE_ADDRESS_MAP(map, 32);
-};
-
-extern const device_type LPC_ACPI;
-
-#endif
diff --git a/src/emu/machine/lpc-pit.c b/src/emu/machine/lpc-pit.c
deleted file mode 100644
index 19a07373ec5..00000000000
--- a/src/emu/machine/lpc-pit.c
+++ /dev/null
@@ -1,47 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "lpc-pit.h"
-
-const device_type LPC_PIT = &device_creator<lpc_pit_device>;
-
-DEVICE_ADDRESS_MAP_START(map, 32, lpc_pit_device)
- AM_RANGE(0x40, 0x43) AM_READWRITE8(status_r, access_w, 0x00ffffff)
- AM_RANGE(0x40, 0x43) AM_WRITE8 ( control_w, 0xff000000)
- AM_RANGE(0x50, 0x53) AM_READWRITE8(status_r, access_w, 0x00ffffff)
- AM_RANGE(0x50, 0x53) AM_WRITE8 ( control_w, 0xff000000)
-ADDRESS_MAP_END
-
-lpc_pit_device::lpc_pit_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : lpc_device(mconfig, LPC_PIT, "LPC PIT", tag, owner, clock, "lpc_pit", __FILE__)
-{
-}
-
-void lpc_pit_device::map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space)
-{
- io_space->install_device(io_offset, io_window_end, *this, &lpc_pit_device::map);
-}
-
-void lpc_pit_device::device_start()
-{
-}
-
-void lpc_pit_device::device_reset()
-{
-}
-
-READ8_MEMBER( lpc_pit_device::status_r)
-{
- logerror("%s: status_r %d\n", tag(), offset);
- return 0xff;
-}
-
-WRITE8_MEMBER(lpc_pit_device::access_w)
-{
- logerror("%s: access_w %d, %02x\n", tag(), offset, data);
-}
-
-WRITE8_MEMBER(lpc_pit_device::control_w)
-{
- logerror("%s: control_w %02x\n", tag(), data);
-}
diff --git a/src/emu/machine/lpc-pit.h b/src/emu/machine/lpc-pit.h
deleted file mode 100644
index 4a49a76c10c..00000000000
--- a/src/emu/machine/lpc-pit.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef LPC_PIT_H
-#define LPC_PIT_H
-
-#include "lpc.h"
-
-#define MCFG_LPC_PIT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, LPC_PIT, 0)
-
-class lpc_pit_device : public lpc_device {
-public:
- lpc_pit_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual void map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space);
-
- DECLARE_READ8_MEMBER( status_r);
- DECLARE_WRITE8_MEMBER(access_w);
- DECLARE_WRITE8_MEMBER(control_w);
-
-protected:
- void device_start();
- void device_reset();
-
-private:
- DECLARE_ADDRESS_MAP(map, 32);
-};
-
-extern const device_type LPC_PIT;
-
-#endif
diff --git a/src/emu/machine/lpc-rtc.c b/src/emu/machine/lpc-rtc.c
deleted file mode 100644
index d92d7b515d0..00000000000
--- a/src/emu/machine/lpc-rtc.c
+++ /dev/null
@@ -1,83 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "lpc-rtc.h"
-
-const device_type LPC_RTC = &device_creator<lpc_rtc_device>;
-
-DEVICE_ADDRESS_MAP_START(map, 32, lpc_rtc_device)
- AM_RANGE(0x70, 0x77) AM_READWRITE8(index_r, index_w, 0x00ff00ff)
- AM_RANGE(0x70, 0x77) AM_READWRITE8(target_r, target_w, 0xff00ff00)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(extmap, 32, lpc_rtc_device)
- AM_RANGE(0x70, 0x77) AM_READWRITE8(extindex_r, extindex_w, 0x00ff0000)
- AM_RANGE(0x70, 0x77) AM_READWRITE8(exttarget_r, exttarget_w, 0xff000000)
-ADDRESS_MAP_END
-
-lpc_rtc_device::lpc_rtc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : lpc_device(mconfig, LPC_RTC, "LPC RTC", tag, owner, clock, "lpc_rtc", __FILE__)
-{
-}
-
-void lpc_rtc_device::map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space)
-{
- io_space->install_device(io_offset, io_window_end, *this, &lpc_rtc_device::map);
-}
-
-void lpc_rtc_device::map_extdevice(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space)
-{
- io_space->install_device(io_offset, io_window_end, *this, &lpc_rtc_device::extmap);
-}
-
-void lpc_rtc_device::device_start()
-{
- memset(ram, 0, 256);
-}
-
-void lpc_rtc_device::device_reset()
-{
-}
-
-READ8_MEMBER( lpc_rtc_device::index_r)
-{
- return cur_index;
-}
-
-WRITE8_MEMBER( lpc_rtc_device::index_w)
-{
- cur_index = data & 0x7f;
-}
-
-READ8_MEMBER( lpc_rtc_device::target_r)
-{
- return ram[cur_index];
-}
-
-WRITE8_MEMBER( lpc_rtc_device::target_w)
-{
- ram[cur_index] = data;
- logerror("%s: ram[%02x] = %02x\n", tag(), cur_index, data);
-}
-
-READ8_MEMBER( lpc_rtc_device::extindex_r)
-{
- return cur_extindex;
-}
-
-WRITE8_MEMBER( lpc_rtc_device::extindex_w)
-{
- cur_extindex = data & 0x7f;
-}
-
-READ8_MEMBER( lpc_rtc_device::exttarget_r)
-{
- return ram[cur_extindex|128];
-}
-
-WRITE8_MEMBER( lpc_rtc_device::exttarget_w)
-{
- ram[cur_extindex|128] = data;
- logerror("%s: ram[%02x] = %02x\n", tag(), cur_extindex|128, data);
-}
diff --git a/src/emu/machine/lpc-rtc.h b/src/emu/machine/lpc-rtc.h
deleted file mode 100644
index f85c6c5cd11..00000000000
--- a/src/emu/machine/lpc-rtc.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef LPC_RTC_H
-#define LPC_RTC_H
-
-#include "lpc.h"
-
-#define MCFG_LPC_RTC_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, LPC_RTC, 0)
-
-class lpc_rtc_device : public lpc_device {
-public:
- lpc_rtc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual void map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space);
-
- virtual void map_extdevice(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space);
-
- DECLARE_READ8_MEMBER( index_r);
- DECLARE_WRITE8_MEMBER( index_w);
- DECLARE_READ8_MEMBER( target_r);
- DECLARE_WRITE8_MEMBER( target_w);
- DECLARE_READ8_MEMBER( extindex_r);
- DECLARE_WRITE8_MEMBER( extindex_w);
- DECLARE_READ8_MEMBER( exttarget_r);
- DECLARE_WRITE8_MEMBER( exttarget_w);
-
-protected:
- void device_start();
- void device_reset();
-
-private:
- DECLARE_ADDRESS_MAP(map, 32);
- DECLARE_ADDRESS_MAP(extmap, 32);
-
- UINT8 cur_index, cur_extindex;
- UINT8 ram[256];
-};
-
-extern const device_type LPC_RTC;
-
-#endif
diff --git a/src/emu/machine/lpc.c b/src/emu/machine/lpc.c
deleted file mode 100644
index afb51435f23..00000000000
--- a/src/emu/machine/lpc.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "lpc.h"
-
-lpc_device::lpc_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- device_t(mconfig, type, name, tag, owner, clock, shortname, source)
-{
-}
diff --git a/src/emu/machine/lpc.h b/src/emu/machine/lpc.h
deleted file mode 100644
index 6ade06d03ff..00000000000
--- a/src/emu/machine/lpc.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef LPC_H
-#define LPC_H
-
-#include "emu.h"
-
-class lpc_device : public device_t {
-public:
- lpc_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- virtual void map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space) = 0;
-};
-
-#endif
diff --git a/src/emu/machine/lpci.c b/src/emu/machine/lpci.c
deleted file mode 100644
index 913dd915184..00000000000
--- a/src/emu/machine/lpci.c
+++ /dev/null
@@ -1,291 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-/***************************************************************************
-
- machine/lpci.c
-
- Legacy PCI bus
-
- The PCI bus is a 32-bit bus introduced by Intel, so it is little endian
-
- Control word:
- bit 31: Enable bit
- bits 30-24: Reserved
- bits 23-16: PCI bus number
- bits 15-11: PCI device number
- bits 10- 8: PCI function number
- bits 7- 0: Offset address
-
- Standard PCI registers:
- 0x00 2 Vendor ID
- 0x02 2 Device ID
- 0x04 2 PCI Command
- 0x06 2 PCI Status
- 0x08 1 Revision ID
- 0x09 1 Programming Interface
- 0x0A 1 Subclass Code
- 0x0B 1 Class Code
-
- Class Code/Subclass Code/Programming Interface
- 0x00XXXX Pre-PCI 2.0 devices
- 0x000000 Non-VGA device
- 0x000101 VGA device
- 0x01XXXX Storage Controller
- 0x010000 SCSI
- 0x0101XX IDE
- 0x0102XX Floppy
- 0x0103XX IPI
- 0x0104XX RAID
- 0x0180XX Other
- 0x02XXXX Network Card
- 0x020000 Ethernet
- 0x020100 Tokenring
- 0x020200 FDDI
- 0x020300 ATM
- 0x028000 Other
- 0x03XXXX Display Controller
- 0x030000 VGA
- 0x030001 8514 Compatible
- 0x030100 XGA
- 0x038000 Other
- 0x04XXXX Multimedia
- 0x040000 Video
- 0x040100 Audio
- 0x048000 Other
- 0x05XXXX Memory Controller
- 0x050000 RAM
- 0x050100 Flash
- 0x058000 Other
- 0x06XXXX Bridge
- 0x060000 Host/PCI
- 0x060100 PCI/ISA
- 0x060200 PCI/EISA
- 0x060300 PCI/Micro Channel
- 0x060400 PCI/PCI
- 0x060500 PCI/PCMCIA
- 0x060600 PCI/NuBus
- 0x060700 PCI/CardBus
- 0x068000 Other
-
- Information on PCI vendors can be found at http://www.pcidatabase.com/
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/lpci.h"
-
-#define LOG_PCI 0
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-const device_type PCI_BUS_LEGACY = &device_creator<pci_bus_legacy_device>;
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// pci_bus_legacy_device - constructor
-//-------------------------------------------------
-pci_bus_legacy_device::pci_bus_legacy_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, PCI_BUS_LEGACY, "PCI Bus Legacy", tag, owner, clock, "pci_bus_legacy", __FILE__),
- m_father(NULL)
-{
- for (int i = 0; i < ARRAY_LENGTH(m_devtag); i++) {
- m_devtag[i]= NULL;
- m_read_callback[i] = NULL;
- m_write_callback[i] = NULL;
- }
- m_siblings_count = 0;
-}
-
-/***************************************************************************
- INLINE FUNCTIONS
-***************************************************************************/
-
-READ32_MEMBER( pci_bus_legacy_device::read )
-{
- UINT32 result = 0xffffffff;
- int function, reg;
-
- offset %= 2;
-
- switch (offset)
- {
- case 0:
- result = m_address;
- break;
-
- case 1:
- if (m_devicenum != -1)
- {
- pci_read_func read = m_busnumaddr->m_read_callback[m_devicenum];
- if (read != NULL)
- {
- function = (m_address >> 8) & 0x07;
- reg = (m_address >> 0) & 0xfc;
- result = (*read)(m_busnumaddr, m_busnumaddr->m_device[m_devicenum], function, reg, mem_mask);
- }
- }
- break;
- }
-
- if (LOG_PCI)
- logerror("read('%s'): offset=%d result=0x%08X\n", tag(), offset, result);
-
- return result;
-}
-
-
-
-pci_bus_legacy_device *pci_bus_legacy_device::pci_search_bustree(int busnum, int devicenum, pci_bus_legacy_device *pcibus)
-{
- int a;
- pci_bus_legacy_device *ret;
-
- if (pcibus->m_busnum == busnum)
- {
- return pcibus;
- }
- for (a = 0; a < pcibus->m_siblings_count; a++)
- {
- ret = pci_search_bustree(busnum, devicenum, pcibus->m_siblings[a]);
- if (ret != NULL)
- return ret;
- }
- return NULL;
-}
-
-
-
-WRITE32_MEMBER( pci_bus_legacy_device::write )
-{
- offset %= 2;
-
- if (LOG_PCI)
- logerror("write('%s'): offset=%d data=0x%08X\n", tag(), offset, data);
-
- switch (offset)
- {
- case 0:
- m_address = data;
-
- /* lookup current device */
- if (m_address & 0x80000000)
- {
- int busnum = (m_address >> 16) & 0xff;
- int devicenum = (m_address >> 11) & 0x1f;
- m_busnumaddr = pci_search_bustree(busnum, devicenum, this);
- if (m_busnumaddr != NULL)
- {
- m_busnumber = busnum;
- m_devicenum = devicenum;
- }
- else
- m_devicenum = -1;
- if (LOG_PCI)
- logerror(" bus:%d device:%d\n", busnum, devicenum);
- }
- break;
-
- case 1:
- if (m_devicenum != -1)
- {
- pci_write_func write = m_busnumaddr->m_write_callback[m_devicenum];
- if (write != NULL)
- {
- int function = (m_address >> 8) & 0x07;
- int reg = (m_address >> 0) & 0xfc;
- (*write)(m_busnumaddr, m_busnumaddr->m_device[m_devicenum], function, reg, data, mem_mask);
- }
- if (LOG_PCI)
- logerror(" function:%d register:%d\n", (m_address >> 8) & 0x07, (m_address >> 0) & 0xfc);
- }
- break;
- }
-}
-
-
-
-READ64_MEMBER(pci_bus_legacy_device::read_64be)
-{
- UINT64 result = 0;
- mem_mask = FLIPENDIAN_INT64(mem_mask);
- if (ACCESSING_BITS_0_31)
- result |= (UINT64)read(space, offset * 2 + 0, mem_mask >> 0) << 0;
- if (ACCESSING_BITS_32_63)
- result |= (UINT64)read(space, offset * 2 + 1, mem_mask >> 32) << 32;
- return FLIPENDIAN_INT64(result);
-}
-
-WRITE64_MEMBER(pci_bus_legacy_device::write_64be)
-{
- data = FLIPENDIAN_INT64(data);
- mem_mask = FLIPENDIAN_INT64(mem_mask);
- if (ACCESSING_BITS_0_31)
- write(space, offset * 2 + 0, data >> 0, mem_mask >> 0);
- if (ACCESSING_BITS_32_63)
- write(space, offset * 2 + 1, data >> 32, mem_mask >> 32);
-}
-
-
-void pci_bus_legacy_device::add_sibling(pci_bus_legacy_device *sibling, int busnum)
-{
- m_siblings[m_siblings_count] = sibling;
- m_siblings_busnum[m_siblings_count] = busnum;
- m_siblings_count++;
-}
-
-
-//-------------------------------------------------
-// device_post_load - handle updating after a
-// restore
-//-------------------------------------------------
-
-void pci_bus_legacy_device::device_post_load()
-{
- if (m_devicenum != -1)
- {
- m_busnumaddr = pci_search_bustree(m_busnumber, m_devicenum, this);
- }
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void pci_bus_legacy_device::device_start()
-{
- /* store a pointer back to the device */
- m_devicenum = -1;
-
- /* find all our devices */
- for (int i = 0; i < ARRAY_LENGTH(m_devtag); i++)
- if (m_devtag[i] != NULL)
- m_device[i] = machine().device(m_devtag[i]);
-
- if (m_father != NULL) {
- pci_bus_legacy_device *father = machine().device<pci_bus_legacy_device>(m_father);
- if (father)
- father->add_sibling(this, m_busnum);
- }
-
- /* register pci states */
- save_item(NAME(m_address));
- save_item(NAME(m_devicenum));
- save_item(NAME(m_busnum));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void pci_bus_legacy_device::device_reset()
-{
- /* reset the drive state */
- m_devicenum = -1;
- m_address = 0;
-}
diff --git a/src/emu/machine/lpci.h b/src/emu/machine/lpci.h
deleted file mode 100644
index 8d420d28a07..00000000000
--- a/src/emu/machine/lpci.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-/***************************************************************************
-
- machine/lpci.h
-
- Legacy PCI bus
-
-***************************************************************************/
-
-#ifndef LPCI_H
-#define LPCI_H
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-typedef UINT32 (*pci_read_func)(device_t *pcibus, device_t *device, int function, int reg, UINT32 mem_mask);
-typedef void (*pci_write_func)(device_t *pcibus, device_t *device, int function, int reg, UINT32 data, UINT32 mem_mask);
-
-// ======================> pci_bus_legacy_device
-
-class pci_bus_legacy_device : public device_t
-{
-public:
- // construction/destruction
- pci_bus_legacy_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ32_MEMBER( read );
- DECLARE_WRITE32_MEMBER( write );
-
- DECLARE_READ64_MEMBER( read_64be );
- DECLARE_WRITE64_MEMBER( write_64be );
-
- void set_busnum(int busnum) { m_busnum = busnum; }
- void set_father(const char *father) { m_father = father; }
- void set_device(int num, const char *tag, pci_read_func read_func, pci_write_func write_func) {
- m_devtag[num] = tag; m_read_callback[num] = read_func; m_write_callback[num] = write_func; }
-
- pci_bus_legacy_device *pci_search_bustree(int busnum, int devicenum, pci_bus_legacy_device *pcibus);
- void add_sibling(pci_bus_legacy_device *sibling, int busnum);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_post_load();
-
-private:
- UINT8 m_busnum;
- const char * m_devtag[32];
- pci_read_func m_read_callback[32];
- pci_write_func m_write_callback[32];
- const char * m_father;
- device_t * m_device[32];
- pci_bus_legacy_device * m_siblings[8];
- UINT8 m_siblings_busnum[8];
- int m_siblings_count;
-
- offs_t m_address;
- INT8 m_devicenum; // device number we are addressing
- INT8 m_busnumber; // pci bus number we are addressing
- pci_bus_legacy_device * m_busnumaddr; // pci bus we are addressing
-};
-
-// device type definition
-extern const device_type PCI_BUS_LEGACY;
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_PCI_BUS_LEGACY_ADD(_tag, _busnum) \
- MCFG_DEVICE_ADD(_tag, PCI_BUS_LEGACY, 0) \
- downcast<pci_bus_legacy_device *>(device)->set_busnum(_busnum);
-#define MCFG_PCI_BUS_LEGACY_DEVICE(_devnum, _devtag, _configread, _configwrite) \
- downcast<pci_bus_legacy_device *>(device)->set_device(_devnum, _devtag,_configread,_configwrite);
-#define MCFG_PCI_BUS_LEGACY_SIBLING(_father_tag) \
- downcast<pci_bus_legacy_device *>(device)->set_father(_father_tag);
-
-
-#endif /* PCI_H */
diff --git a/src/emu/machine/m6m80011ap.c b/src/emu/machine/m6m80011ap.c
deleted file mode 100644
index 776cbcae6e7..00000000000
--- a/src/emu/machine/m6m80011ap.c
+++ /dev/null
@@ -1,232 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Angelo Salese
-/***************************************************************************
-
-Template for skeleton device
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/m6m80011ap.h"
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type M6M80011AP = &device_creator<m6m80011ap_device>;
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// m6m80011ap_device - constructor
-//-------------------------------------------------
-
-m6m80011ap_device::m6m80011ap_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, M6M80011AP, "M6M80011AP EEPROM", tag, owner, clock, "m6m80011ap", __FILE__),
- device_nvram_interface(mconfig, *this)
-{
-}
-
-
-//-------------------------------------------------
-// device_validity_check - perform validity checks
-// on this device
-//-------------------------------------------------
-
-void m6m80011ap_device::device_validity_check(validity_checker &valid) const
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void m6m80011ap_device::device_start()
-{
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void m6m80011ap_device::device_reset()
-{
-}
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void m6m80011ap_device::nvram_default()
-{
- for (offs_t offs = 0; offs < 0x80; offs++)
- m_eeprom_data[offs] = 0xffff;
-}
-
-
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void m6m80011ap_device::nvram_read(emu_file &file)
-{
- file.read(m_eeprom_data, 0x100);
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void m6m80011ap_device::nvram_write(emu_file &file)
-{
- file.write(m_eeprom_data, 0x100);
-}
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-
-READ_LINE_MEMBER( m6m80011ap_device::read_bit )
-{
- return m_read_latch;
-}
-
-READ_LINE_MEMBER( m6m80011ap_device::ready_line )
-{
- return 1; // TODO
-}
-
-WRITE_LINE_MEMBER( m6m80011ap_device::set_cs_line )
-{
- m_reset_line = state;
-
- if (m_reset_line != CLEAR_LINE)
- {
- m_eeprom_state = EEPROM_GET_CMD;
- m_cmd_stream_pos = 0;
- m_current_cmd = 0;
- }
-}
-
-
-WRITE_LINE_MEMBER( m6m80011ap_device::write_bit )
-{
- m_latch = state;
-}
-
-WRITE_LINE_MEMBER( m6m80011ap_device::set_clock_line )
-{
- if (m_reset_line == CLEAR_LINE)
- {
- if(state == 1)
- {
- switch(m_eeprom_state)
- {
- case EEPROM_GET_CMD:
- m_current_cmd = (m_current_cmd >> 1) | ((m_latch & 1)<< 7);
- m_cmd_stream_pos++;
-
- if (m_cmd_stream_pos==8)
- {
- m_cmd_stream_pos = 0;
- switch(m_current_cmd)
- {
- case 0xc5: m_eeprom_state = EEPROM_WRITE_ENABLE; break;
- case 0x05: m_eeprom_state = EEPROM_WRITE_DISABLE; break;
- case 0x25: m_eeprom_state = EEPROM_WRITE; break;
- case 0x15: m_eeprom_state = EEPROM_READ; break;
- case 0x95: m_eeprom_state = EEPROM_STATUS_OUTPUT; break;
- default:
- printf("Write M6M80011 unknown %02x cmd\n",m_current_cmd );
- break;
- }
- }
- break;
-
- case EEPROM_READ:
- m_current_cmd = (m_current_cmd >> 1) | ((m_latch & 1)<< 23);
- m_cmd_stream_pos++;
-
- if (m_cmd_stream_pos==8)
- {
- m_current_addr = m_current_cmd >> 16;
- }
-
- if(m_cmd_stream_pos>=8)
- {
- m_read_latch = (m_eeprom_data[m_current_addr] >> (23-m_cmd_stream_pos)) & 1;
- //printf("%d %04x <- %04x %d\n",m_read_latch,m_eeprom_data[m_current_addr],m_current_addr,m_cmd_stream_pos-8);
- }
-
- if(m_cmd_stream_pos==24)
- {
- m_eeprom_state = EEPROM_GET_CMD;
- m_cmd_stream_pos = 0;
- }
- break;
-
- case EEPROM_WRITE:
- m_current_cmd = (m_current_cmd >> 1) | ((m_latch & 1)<< 23);
- m_cmd_stream_pos++;
-
- if (m_cmd_stream_pos==8)
- {
- m_current_addr = m_current_cmd >> 16;
- }
-
- if(m_cmd_stream_pos==24)
- {
- if(m_eeprom_we)
- m_eeprom_data[m_current_addr] = (m_current_cmd >> 8) & 0xffff;
-
- //printf("%04x %04x -> %04x\n",m_eeprom_data[m_current_addr],m_current_addr,m_current_cmd >> 8);
-
- m_eeprom_state = EEPROM_GET_CMD;
- m_cmd_stream_pos = 0;
- }
- break;
-
- case EEPROM_WRITE_ENABLE:
- case EEPROM_WRITE_DISABLE:
- m_current_cmd = (m_current_cmd >> 1) | ((m_latch & 1)<< 7);
- m_cmd_stream_pos++;
-
- if (m_cmd_stream_pos==8)
- {
- m_eeprom_we = (m_eeprom_state == EEPROM_WRITE_ENABLE) ? 1 : 0;
- m_eeprom_state = EEPROM_GET_CMD;
- m_cmd_stream_pos = 0;
- }
-
- break;
-
- case EEPROM_STATUS_OUTPUT:
- m_current_cmd = (m_current_cmd >> 1) | ((m_latch & 1)<< 7);
- m_cmd_stream_pos++;
-
- if (m_cmd_stream_pos==8)
- {
- printf("Status output\n");
- m_eeprom_state = EEPROM_GET_CMD;
- m_cmd_stream_pos = 0;
- }
- break;
- }
- }
- }
-}
diff --git a/src/emu/machine/m6m80011ap.h b/src/emu/machine/m6m80011ap.h
deleted file mode 100644
index 196617f2339..00000000000
--- a/src/emu/machine/m6m80011ap.h
+++ /dev/null
@@ -1,91 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Angelo Salese
-/***************************************************************************
-
-Template for skeleton device
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __M6M80011APDEV_H__
-#define __M6M80011APDEV_H__
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-/* TODO: frequency */
-#define MCFG_M6M80011AP_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, M6M80011AP, XTAL_32_768kHz)
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-enum eeprom_cmd_t
-{
- EEPROM_GET_CMD = 0,
- EEPROM_READ,
- EEPROM_WRITE,
- EEPROM_WRITE_ENABLE,
- EEPROM_WRITE_DISABLE,
- EEPROM_STATUS_OUTPUT
-};
-
-
-// ======================> m6m80011ap_device
-
-class m6m80011ap_device : public device_t,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- m6m80011ap_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // I/O operations
- DECLARE_READ_LINE_MEMBER( read_bit );
- DECLARE_READ_LINE_MEMBER( ready_line );
- DECLARE_WRITE_LINE_MEMBER( set_cs_line );
- DECLARE_WRITE_LINE_MEMBER( set_clock_line );
- DECLARE_WRITE_LINE_MEMBER( write_bit );
-
-protected:
- // device-level overrides
- virtual void device_validity_check(validity_checker &valid) const;
- virtual void device_start();
- virtual void device_reset();
-
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
-private:
- UINT8 m_latch;
- UINT8 m_reset_line;
- UINT8 m_cmd_stream_pos;
- UINT32 m_current_cmd;
- UINT8 m_read_latch;
- UINT8 m_current_addr;
- UINT8 m_eeprom_we;
-
- eeprom_cmd_t m_eeprom_state;
- UINT16 m_eeprom_data[0x80];
-
-};
-
-
-// device type definition
-extern const device_type M6M80011AP;
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-
-
-#endif
diff --git a/src/emu/machine/matsucd.c b/src/emu/machine/matsucd.c
deleted file mode 100644
index 6c12c5950d1..00000000000
--- a/src/emu/machine/matsucd.c
+++ /dev/null
@@ -1,757 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf, Mariusz Wojcieszek
-/***************************************************************************
-
- Matsushita/Panasonic CDR521/522 type CDROM drive emulation
-
-Notes:
-This version implements the drive found in Amiga CDTV. There are
-different drives supporting this command-set (look in the sbpcd driver
-in Linux for examples). Most drives support the exact same command
-structure, but the command numbers differ. Eventually this driver
-can be expanded with support for the other drives as needed.
-
-***************************************************************************/
-
-
-#include "emu.h"
-#include "imagedev/chd_cd.h"
-#include "sound/cdda.h"
-#include "machine/matsucd.h"
-
-
-#define MATSU_STATUS_READY ( 1 << 0 ) /* driver ready */
-#define MATSU_STATUS_DOORLOCKED ( 1 << 1 ) /* door locked */
-#define MATSU_STATUS_PLAYING ( 1 << 2 ) /* drive playing */
-#define MATSU_STATUS_SUCCESS ( 1 << 3 ) /* last command was successful */
-#define MATSU_STATUS_ERROR ( 1 << 4 ) /* last command failed */
-#define MATSU_STATUS_MOTOR ( 1 << 5 ) /* spinning */
-#define MATSU_STATUS_MEDIA ( 1 << 6 ) /* media present (in caddy or tray) */
-#define MATSU_STATUS_DOORCLOSED ( 1 << 7 ) /* tray status */
-
-struct matsucd
-{
- UINT8 enabled; /* /ENABLE - Unit enabled */
- UINT8 cmd_signal; /* /CMD - Command mode */
- UINT8 stch_signal; /* /STCH - Status Changed */
- UINT8 sten_signal; /* /STEN - Status Enabled */
- UINT8 scor_signal; /* /STEN - Subcode Ready */
- UINT8 input[16];
- UINT8 input_pos;
- UINT8 output[16];
- UINT8 output_pos;
- UINT8 output_len;
- UINT8 status;
- UINT8 motor;
- UINT16 sector_size;
- UINT32 lba;
- UINT16 num_blocks;
- UINT16 xfer_offset;
- UINT8 sector_buffer[CD_MAX_SECTOR_DATA];
- UINT8 cdda_set;
- void (*sten_cb)( running_machine &machine, int level ); /* Status enabled callback */
- void (*stch_cb)( running_machine &machine, int level ); /* Status changed callback */
- void (*scor_cb)( running_machine &machine, int level ); /* Subcode ready callback */
- cdrom_file *cdrom;
- cdda_device *cdda;
- emu_timer *frame_timer;
-};
-
-static matsucd cd;
-
-#define MSF2LBA(msf) (((msf >> 16) & 0xff) * 60 * 75 + ((msf >> 8) & 0xff) * 75 + ((msf >> 0) & 0xff))
-#define LBA2MSF(lba) (((lba / (75 * 60)) << 16) | (((lba / 75) % 60) << 8) | (lba % 75))
-
-static TIMER_CALLBACK(matsu_subcode_proc);
-
-void matsucd_init( cdrom_image_device *cdrom_device, const char *cdda_tag )
-{
- memset(&cd, 0, sizeof( matsucd ) );
-
- cd.cdrom = cdrom_device->get_cdrom_file();
- cd.cdda = cdrom_device->machine().device<cdda_device>(cdda_tag);
-
- cd.frame_timer = cdrom_device->machine().scheduler().timer_alloc(FUNC(matsu_subcode_proc));
-
- cd.stch_signal = 1;
-}
-
-void matsucd_set_status_enabled_callback( void (*sten_cb)( running_machine &machine, int level ) )
-{
- /* add the callback for status enabled signal */
- cd.sten_cb = sten_cb;
-}
-
-void matsucd_set_status_changed_callback( void (*stch_cb)( running_machine &machine, int level ) )
-{
- /* add the callback for status changed signal */
- cd.stch_cb = stch_cb;
-}
-
-void matsucd_set_subcode_ready_callback( void (*scor_cb)( running_machine &machine, int level ) )
-{
- /* add the callback for subcode ready signal */
- cd.scor_cb = scor_cb;
-}
-
-static int matsucd_getsector_type( void )
-{
- switch( cd.sector_size )
- {
- case 2048: return CD_TRACK_MODE1;
- case 2324: return CD_TRACK_MODE2_FORM2;
- case 2336: return CD_TRACK_MODE2;
- case 2352: return CD_TRACK_MODE2_RAW;
-
- default: logerror( "MATSUCD: Sector size %d unsupported!\n", cd.sector_size ); break;
- }
-
- return CD_TRACK_RAW_DONTCARE;
-}
-
-void matsucd_read_next_block( void )
-{
- cd.xfer_offset = 0;
-
- if ( cd.num_blocks )
- {
- cd.lba++;
- cd.num_blocks--;
-
- if (!cdrom_read_data(cd.cdrom, cd.lba, cd.sector_buffer, matsucd_getsector_type()))
- {
- logerror( "MATSUCD - Warning: Read error on CD!\n" );
- }
- }
-}
-
-int matsucd_get_next_byte( UINT8 *data )
-{
- /* no more data to read on this sector */
- if ( cd.xfer_offset >= cd.sector_size )
- return -1;
-
- if ( data )
- *data = cd.sector_buffer[cd.xfer_offset++];
-
- return 0;
-}
-
-static void matsucd_cdda_stop( running_machine &machine )
-{
- if (cd.cdda != NULL)
- {
- cd.cdda->stop_audio();
- cd.frame_timer->reset( );
- }
-}
-
-static void matsucd_cdda_play( running_machine &machine, UINT32 lba, UINT32 num_blocks )
-{
- if (cd.cdda != NULL)
- {
- cd.cdda->start_audio(lba, num_blocks);
- cd.frame_timer->adjust(attotime::from_hz( 75 ));
- }
-}
-
-static void matsucd_cdda_pause( running_machine &machine, int pause )
-{
- if (cd.cdda != NULL)
- {
- cd.cdda->pause_audio(pause);
-
- if ( pause )
- {
- cd.frame_timer->reset( );
- }
- else
- {
- cd.frame_timer->adjust(attotime::from_hz( 75 ));
- }
- }
-}
-
-static UINT8 matsucd_cdda_getstatus( running_machine &machine, UINT32 *lba )
-{
- if ( lba ) *lba = 0;
-
- if (cd.cdda != NULL)
- {
- if (cd.cdda->audio_active())
- {
- if ( lba ) *lba = cd.cdda->get_audio_lba();
-
- if (cd.cdda->audio_paused())
- {
- return 0x12; /* audio paused */
- }
- else
- {
- return 0x11; /* audio in progress */
- }
- }
- else if (cd.cdda->audio_ended())
- {
- return 0x13; /* audio ended */
- }
- }
-
- return 0x15; /* no audio status */
-}
-
-void matsucd_enable_w( int level )
-{
- cd.enabled = ( level ) ? 0 : 1;
-}
-
-void matsucd_cmd_w( int level )
-{
- cd.cmd_signal = ( level ) ? 0 : 1;
-}
-
-int matsucd_stch_r( void )
-{
- return cd.stch_signal ? 0 : 1;
-}
-
-int matsucd_sten_r( void )
-{
- return cd.sten_signal ? 0 : 1;
-}
-
-int matsucd_scor_r( void )
-{
- return cd.scor_signal ? 0 : 1;
-}
-
-static void update_status_enable( running_machine &machine, int level )
-{
- cd.sten_signal = level;
-
- if ( cd.sten_cb )
- {
- (*cd.sten_cb)(machine, cd.sten_signal);
- }
-}
-
-static void update_status_changed( running_machine &machine, int level )
-{
- cd.stch_signal = level;
-
- if ( cd.stch_cb )
- {
- (*cd.stch_cb)(machine, cd.stch_signal);
- }
-}
-
-static void update_subcode_ready( running_machine &machine, int level )
-{
- cd.scor_signal = level;
-
- if ( cd.scor_cb )
- {
- (*cd.scor_cb)(machine, cd.scor_signal);
- }
-}
-
-static TIMER_CALLBACK(matsucd_set_status_end)
-{
- update_status_changed( machine, 1 );
-}
-
-static void matsucd_set_status( running_machine &machine, UINT8 status )
-{
- if ( status != cd.status )
- {
- cd.status = status;
-
- if ( cd.stch_signal != 0 )
- {
- update_status_changed( machine, 0 );
- machine.scheduler().timer_set(attotime::from_msec(1), FUNC(matsucd_set_status_end));
- }
- }
-}
-
-static TIMER_CALLBACK(matsu_subcode_proc)
-{
- (void)param;
-
- if (cd.cdda != NULL)
- {
- UINT8 s = matsucd_cdda_getstatus(machine, NULL);
- UINT8 newstatus = cd.status;
-
- if ( s == 0x11 || s == 0x12 )
- {
- if ( s == 0x11 )
- {
- update_subcode_ready( machine, 1 );
- update_subcode_ready( machine, 0 );
- }
-
- newstatus |= MATSU_STATUS_PLAYING;
-
- cd.frame_timer->adjust(attotime::from_hz( 75 ));
- }
- else
- {
- newstatus &= ~MATSU_STATUS_PLAYING;
- }
-
- matsucd_set_status( machine, newstatus );
- }
-}
-
-static void matsucd_command_error( running_machine &machine )
-{
- UINT8 newstatus = cd.status;
-
- newstatus &= ~MATSU_STATUS_SUCCESS;
- newstatus |= MATSU_STATUS_ERROR;
-
- matsucd_set_status( machine, newstatus );
-}
-
-static void matsucd_complete_cmd( running_machine &machine, UINT8 len )
-{
- UINT8 newstatus = cd.status;
-
- cd.input_pos = 0;
- cd.output_pos = 0;
- cd.output_len = len;
-
- newstatus &= ~MATSU_STATUS_ERROR;
- newstatus |= MATSU_STATUS_SUCCESS;
-
- matsucd_set_status( machine, newstatus );
-
- update_status_enable( machine, 1 );
- update_status_enable( machine, 0 );
-}
-
-UINT8 matsucd_response_r( running_machine &machine )
-{
- UINT8 v = cd.output[cd.output_pos++];
-
- if ( cd.output_pos < cd.output_len )
- {
- update_status_enable( machine, 1 );
- update_status_enable( machine, 0 );
- }
-
- return v;
-}
-
-void matsucd_command_w( running_machine &machine, UINT8 data )
-{
- UINT8 cmd;
-
- /* make sure we're enabled */
- if ( cd.enabled == 0 )
- return;
-
- /* make sure /CMD is asserted */
- if ( cd.cmd_signal == 0 )
- return;
-
- if ( cd.cdda_set == 0 )
- {
- if ( cd.cdrom )
- cd.cdda->set_cdrom(cd.cdrom);
-
- cd.cdda_set = 1;
- }
-
- cd.input[cd.input_pos++] = data;
-
- cmd = cd.input[0];
-
- switch( cmd )
- {
- case 0x01: /* seek */
- {
- if ( cd.input_pos < 7 )
- return;
-
- /* stop CDDA audio if necessary */
- matsucd_cdda_stop(machine);
-
- cd.motor = 1;
-
- memset( cd.output, 0, 6 );
- matsucd_complete_cmd( machine, 0 );
- }
- break;
-
- case 0x02: /* read sectors */
- {
- if ( cd.input_pos < 7 )
- return;
-
- /* stop CDDA audio if necessary */
- matsucd_cdda_stop(machine);
-
- /* LBA */
- cd.lba = cd.input[1];
- cd.lba <<= 8;
- cd.lba |= cd.input[2];
- cd.lba <<= 8;
- cd.lba |= cd.input[3];
-
- /* Number of blocks */
- cd.num_blocks = cd.input[4];
- cd.num_blocks <<= 8;
- cd.num_blocks |= cd.input[5];
-
- /* Reset transfer count */
- cd.xfer_offset = 0;
-
- /* go ahead and cache the first block */
- if (!cdrom_read_data(cd.cdrom, cd.lba, cd.sector_buffer, matsucd_getsector_type()))
- {
- logerror( "MATSUCD - Warning: Read error on CD!\n" );
- matsucd_command_error( machine );
- return;
- }
-
- cd.motor = 1;
-
- memset( cd.output, 0, 6 );
- matsucd_complete_cmd( machine, 0 );
- }
- break;
-
- case 0x04: /* motor on */
- {
- if ( cd.input_pos < 7 )
- return;
-
- cd.motor = 1;
-
- memset( cd.output, 0, 6 );
- matsucd_complete_cmd( machine, 0 );
- }
- break;
-
- case 0x05: /* motor off */
- {
- if ( cd.input_pos < 7 )
- return;
-
- /* stop CDDA audio if necessary */
- matsucd_cdda_stop(machine);
-
- cd.motor = 0;
-
- memset( cd.output, 0, 6 );
- matsucd_complete_cmd( machine, 0 );
- }
- break;
-
- case 0x09: /* play audio cd, LBA mode */
- {
- UINT32 lba, numblocks;
-
- if ( cd.input_pos < 7 )
- return;
-
- lba = cd.input[1];
- lba <<= 8;
- lba |= cd.input[2];
- lba <<= 8;
- lba |= cd.input[3];
-
- numblocks = cd.input[4];
- numblocks <<= 8;
- numblocks |= cd.input[5];
- numblocks <<= 8;
- numblocks |= cd.input[6];
-
- matsucd_cdda_play( machine, lba, numblocks );
-
- cd.motor = 1;
-
- memset( cd.output, 0, 6 );
- matsucd_complete_cmd( machine, 0 );
- }
- break;
-
- case 0x0a: /* play audio cd, MSF mode */
- {
- UINT32 start, end, lba_start, lba_end;
-
- if ( cd.input_pos < 7 )
- return;
-
- start = cd.input[1];
- start <<= 8;
- start |= cd.input[2];
- start <<= 8;
- start |= cd.input[3];
-
- end = cd.input[4];
- end <<= 8;
- end |= cd.input[5];
- end <<= 8;
- end |= cd.input[6];
-
- lba_start = MSF2LBA( start );
- lba_end = MSF2LBA( end );
-
- if ( end == 0xffffff )
- {
- lba_end = cdrom_get_track_start(cd.cdrom,cdrom_get_last_track(cd.cdrom)-1);
- lba_end += cdrom_get_toc(cd.cdrom)->tracks[cdrom_get_last_track(cd.cdrom)-1].frames;
- }
-
- if ( lba_end <= lba_start )
- {
- matsucd_cdda_stop(machine);
- }
- else
- {
- matsucd_cdda_play( machine, lba_start, lba_end - lba_start );
- cd.motor = 1;
- }
-
- memset( cd.output, 0, 6 );
- matsucd_complete_cmd( machine, 0 );
- }
- break;
-
- case 0x0b: /* play audio track and index */
- {
- UINT8 track_start = cd.input[1];
- UINT8 index_start = cd.input[2];
- UINT8 track_end = cd.input[3];
- UINT8 index_end = cd.input[4];
- UINT32 lba_start, lba_end;
-
- /* TODO: Add index support once the CDDA engine supports it */
- (void)index_start;
- (void)index_end;
-
- /* sanitize values */
- if ( track_start == 0 ) track_start++;
- if ( track_end == 0 ) track_end++;
- if ( track_end > cdrom_get_last_track(cd.cdrom) )
- track_end = cdrom_get_last_track(cd.cdrom);
-
- /* find the start and stop positions */
- lba_start = cdrom_get_track_start(cd.cdrom,track_start-1);
- lba_end = cdrom_get_track_start(cd.cdrom,track_end-1);
-
- lba_end += cdrom_get_toc(cd.cdrom)->tracks[track_end-1].frames;
-
- if ( lba_end <= lba_start )
- {
- matsucd_cdda_stop(machine);
- }
- else
- {
- matsucd_cdda_play( machine, lba_start, lba_end - lba_start );
- cd.motor = 1;
- }
-
- memset( cd.output, 0, 6 );
- matsucd_complete_cmd( machine, 0 );
- }
- break;
-
- case 0x81: /* status read */
- {
- UINT8 newstatus = cd.status;
-
- newstatus &= MATSU_STATUS_SUCCESS | MATSU_STATUS_ERROR | MATSU_STATUS_PLAYING;
- newstatus |= MATSU_STATUS_READY;
-
- if (cd.cdrom)
- {
- newstatus |= MATSU_STATUS_MEDIA;
- }
-
- if (cd.motor)
- newstatus |= MATSU_STATUS_MOTOR;
-
- cd.output[0] = newstatus;
-
- matsucd_set_status( machine, newstatus );
-
- matsucd_complete_cmd( machine, 1 );
- }
- break;
-
- case 0x82: /* error read */
- {
- if ( cd.input_pos < 7 )
- return;
-
- memset( cd.output, 0, 6 );
- matsucd_complete_cmd( machine, 6 );
- }
- break;
-
- case 0x84: /* set mode */
- {
- if ( cd.input_pos < 7 )
- return;
-
- cd.sector_size = cd.input[2];
- cd.sector_size <<= 8;
- cd.sector_size |= cd.input[3];
-
- memset( cd.output, 0, 6 );
- matsucd_complete_cmd( machine, 0 );
- }
- break;
-
- case 0x87: /* read SUBQ */
- {
- int msfmode;
- UINT32 lba;
- UINT8 track;
-
- if ( cd.input_pos < 7 )
- return;
-
- msfmode = (cd.input[1] & 0x02) ? 1 : 0;
-
- memset( cd.output, 0, 13 );
-
- cd.output[0] = matsucd_cdda_getstatus( machine, &lba );
-
- if ( lba > 0 )
- {
- UINT32 disk_pos;
- UINT32 track_pos;
-
- track = cdrom_get_track(cd.cdrom, lba);
-
- cd.output[1] = cdrom_get_adr_control(cd.cdrom, track);
- cd.output[2] = track+1;
- cd.output[3] = 0; /* index */
-
- disk_pos = lba;
- if ( msfmode ) disk_pos = LBA2MSF(disk_pos);
-
- cd.output[4] = (disk_pos >> 24) & 0xff;
- cd.output[5] = (disk_pos >> 16) & 0xff;
- cd.output[6] = (disk_pos >> 8) & 0xff;
- cd.output[7] = (disk_pos) & 0xff;
-
- track_pos = lba - cdrom_get_track_start(cd.cdrom, track);
- if ( msfmode ) track_pos = LBA2MSF(track_pos);
-
- cd.output[8] = (track_pos >> 24) & 0xff;
- cd.output[9] = (track_pos >> 16) & 0xff;
- cd.output[10] = (track_pos >> 8) & 0xff;
- cd.output[11] = (track_pos) & 0xff;
-
- /* TODO: UPC flag at offset 12 */
- cd.output[12] = 0;
- }
-
- matsucd_complete_cmd( machine, 13 );
- }
- break;
-
- case 0x89: /* read disk info */
- {
- UINT32 end;
-
- if ( cd.input_pos < 7 )
- return;
-
- memset( cd.output, 0, 5 );
-
- cd.output[0] = cdrom_get_last_track(cd.cdrom) ? 1 : 0;
- cd.output[1] = cdrom_get_last_track(cd.cdrom);
- end = cdrom_get_track_start(cd.cdrom,cd.output[1]-1);
- end += cdrom_get_toc(cd.cdrom)->tracks[cd.output[1]-1].frames;
- end = LBA2MSF(end);
- cd.output[2] = (end >> 16) & 0xff;
- cd.output[3] = (end >> 8) & 0xff;
- cd.output[4] = (end) & 0xff;
-
- matsucd_complete_cmd( machine, 5 );
- }
- break;
-
- case 0x8a: /* read toc */
- {
- UINT8 track;
- int msfmode;
- UINT32 track_start;
-
- if ( cd.input_pos < 7 )
- return;
-
- /* stop CDDA audio if necessary */
- matsucd_cdda_stop(machine);
-
- track = cd.input[2];
- msfmode = (cd.input[1] & 0x02) ? 1 : 0;
-
- if ( cd.cdrom == NULL )
- {
- logerror( "MATSUCD - Warning: Reading TOC without a CD!\n" );
- matsucd_command_error( machine );
- return;
- }
-
- if ( track > cdrom_get_last_track(cd.cdrom) )
- {
- logerror( "MATSUCD - Warning: Reading invalid track entry from TOC!\n" );
- matsucd_command_error( machine );
- return;
- }
-
- memset( cd.output, 0, 7 );
-
- track_start = cdrom_get_track_start(cd.cdrom, track > 0 ? (track-1) : track );
- if ( msfmode ) track_start = LBA2MSF( track_start );
-
- cd.output[1] = cdrom_get_adr_control(cd.cdrom, track > 0 ? (track-1) : track);
- cd.output[2] = track;
- cd.output[3] = (track == 0 ) ? cdrom_get_last_track(cd.cdrom) : 0;
- cd.output[4] = (track_start >> 24) & 0xff;
- cd.output[5] = (track_start >> 16) & 0xff;
- cd.output[6] = (track_start >> 8) & 0xff;
- cd.output[7] = (track_start) & 0xff;
-
- cd.motor = 1;
-
- matsucd_complete_cmd( machine, 8 );
- }
- break;
-
- case 0x8b: /* pause audio */
- {
- if ( cd.input_pos < 7 )
- return;
-
- matsucd_cdda_pause( machine, (cd.input[1] == 0) ? 1 : 0 );
- memset( cd.output, 0, 7 );
- matsucd_complete_cmd( machine, 0 );
- }
- break;
-
- case 0xa3: /* front panel */
- {
- if ( cd.input_pos < 7 )
- return;
-
- /* TODO: ??? */
-
- memset( cd.output, 0, 7 );
- matsucd_complete_cmd( machine, 0 );
- }
- break;
-
- default:
- logerror( "MATSUCD: Unknown/inimplemented command %08x\n", cmd );
- break;
- }
-}
diff --git a/src/emu/machine/matsucd.h b/src/emu/machine/matsucd.h
deleted file mode 100644
index 19a456760a6..00000000000
--- a/src/emu/machine/matsucd.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf, Mariusz Wojcieszek
-/***************************************************************************
-
- Matsushita/Panasonic CDR521/522 type CDROM drive emulation
-
-***************************************************************************/
-
-/* initialization */
-void matsucd_init( cdrom_image_device *cdrom_device, const char *cdda_tag );
-
-
-/* signaling */
-extern void matsucd_enable_w( int level ); /* /ENABLE pin */
-extern void matsucd_cmd_w( int level ); /* /CMD pin */
-extern int matsucd_stch_r( void ); /* /STCH pin */
-extern int matsucd_sten_r( void ); /* /STEN pin */
-extern int matsucd_scor_r( void ); /* /SCOR pin */
-
-/* callback for signal changes */
-extern void matsucd_set_status_enabled_callback( void (*sten_cb)( running_machine &machine, int level ) );
-extern void matsucd_set_status_changed_callback( void (*stch_cb)( running_machine &machine, int level ) );
-extern void matsucd_set_subcode_ready_callback( void (*scor_cb)( running_machine &machine, int level ) );
-
-/* data transfer routines */
-extern void matsucd_read_next_block( void );
-extern int matsucd_get_next_byte( UINT8 *data );
-
-/* main command interface */
-extern void matsucd_command_w( running_machine &machine, UINT8 data );
-extern UINT8 matsucd_response_r( running_machine &machine );
diff --git a/src/emu/machine/mb14241.c b/src/emu/machine/mb14241.c
deleted file mode 100644
index 732dccf8e1d..00000000000
--- a/src/emu/machine/mb14241.c
+++ /dev/null
@@ -1,73 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Fabio Priuli
-/***************************************************************************
-
- Midway 8080-based black and white hardware
-
-****************************************************************************/
-
-#include "emu.h"
-#include "machine/mb14241.h"
-
-
-//-------------------------------------------------
-// mb14241_device - constructor
-//-------------------------------------------------
-
-
-const device_type MB14241 = &device_creator<mb14241_device>;
-
-mb14241_device::mb14241_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MB14241, "MB14241 Data Shifter", tag, owner, clock, "mb14241", __FILE__)
-{
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void mb14241_device::device_config_complete()
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mb14241_device::device_start()
-{
- save_item(NAME(m_shift_data));
- save_item(NAME(m_shift_count));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mb14241_device::device_reset()
-{
- m_shift_data = 0;
- m_shift_count = 0;
-}
-
-
-/*****************************************************************************
- IMPLEMENTATION
-*****************************************************************************/
-
-WRITE8_MEMBER( mb14241_device::shift_count_w )
-{
- m_shift_count = ~data & 0x07;
-}
-
-WRITE8_MEMBER( mb14241_device::shift_data_w )
-{
- m_shift_data = (m_shift_data >> 8) | ((UINT16)data << 7);
-}
-
-READ8_MEMBER( mb14241_device::shift_result_r )
-{
- return m_shift_data >> m_shift_count;
-}
diff --git a/src/emu/machine/mb14241.h b/src/emu/machine/mb14241.h
deleted file mode 100644
index 68a85c583ec..00000000000
--- a/src/emu/machine/mb14241.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Fabio Priuli
-/*****************************************************************************
-
- MB14241 shifter IC emulation
-
- *****************************************************************************/
-
-#ifndef __MB14241_H__
-#define __MB14241_H__
-
-
-class mb14241_device : public device_t
-{
-public:
- mb14241_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_WRITE8_MEMBER ( shift_count_w );
- DECLARE_WRITE8_MEMBER ( shift_data_w );
- DECLARE_READ8_MEMBER( shift_result_r );
-
-protected:
- // device-level overrides
- virtual void device_config_complete();
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
-
- UINT16 m_shift_data; /* 15 bits only */
- UINT8 m_shift_count; /* 3 bits */
-};
-
-extern const device_type MB14241;
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_MB14241_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, MB14241, 0)
-
-#endif /* __MB14241_H__ */
diff --git a/src/emu/machine/mb3773.c b/src/emu/machine/mb3773.c
deleted file mode 100644
index b2093787338..00000000000
--- a/src/emu/machine/mb3773.c
+++ /dev/null
@@ -1,76 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- Fujitsu MB3773
-
- Power Supply Monitor with Watch Dog Timer (i.e. Reset IC)
-
-
- Todo:
- Calculate the timeout from parameters.
-
-***************************************************************************/
-
-#include "emu.h"
-#include "mb3773.h"
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type MB3773 = &device_creator<mb3773_device>;
-
-//-------------------------------------------------
-// mb3773_device - constructor
-//-------------------------------------------------
-
-mb3773_device::mb3773_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
- : device_t(mconfig, MB3773, "MB3773 Power Supply Monitor", tag, owner, clock, "mb3773", __FILE__)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mb3773_device::device_start()
-{
- m_watchdog_timer = timer_alloc();
- reset_timer();
-
- save_item( NAME(m_ck) );
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mb3773_device::device_reset()
-{
- m_ck = 0;
-}
-
-void mb3773_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- machine().schedule_soft_reset();
-}
-
-void mb3773_device::reset_timer()
-{
- m_watchdog_timer->adjust( attotime::from_seconds( 5 ) );
-}
-
-WRITE_LINE_MEMBER( mb3773_device::write_line_ck )
-{
- if( state == 0 && m_ck != 0 )
- {
- reset_timer();
- }
-
- m_ck = state;
-}
diff --git a/src/emu/machine/mb3773.h b/src/emu/machine/mb3773.h
deleted file mode 100644
index 3199f545bf7..00000000000
--- a/src/emu/machine/mb3773.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- Fujistu MB3773
-
- Power Supply Monitor with Watch Dog Timer (i.e. Reset IC)
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __MB3773_H__
-#define __MB3773_H__
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MB3773_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, MB3773, 0)
-
-
-// ======================> mb3773_device
-
-class mb3773_device :
- public device_t
-{
-public:
- // construction/destruction
- mb3773_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock );
-
- // I/O operations
- WRITE_LINE_MEMBER( write_line_ck );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- void reset_timer();
-
- // internal state
- emu_timer *m_watchdog_timer;
- int m_ck;
-};
-
-
-// device type definition
-extern const device_type MB3773;
-
-#endif
diff --git a/src/emu/machine/mb8421.c b/src/emu/machine/mb8421.c
deleted file mode 100644
index 0d3cb819a66..00000000000
--- a/src/emu/machine/mb8421.c
+++ /dev/null
@@ -1,94 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:hap
-/**********************************************************************
-
- Fujitsu MB8421/22/31/32-90/-90L/-90LL/-12/-12L/-12LL
- CMOS 16K-bit (2KB) dual-port SRAM
-
- MB84x2 lacks interrupt pins, it's basically as simple as AM_RAM AM_SHARE("x")
- MB843x is same as MB842x, except that it supports slave mode. It makes
- sure there are no clashes, with the _BUSY pin.
-
-**********************************************************************/
-
-#include "machine/mb8421.h"
-
-
-const device_type MB8421 = &device_creator<mb8421_device>;
-
-//-------------------------------------------------
-// mb8421_device - constructor
-//-------------------------------------------------
-
-mb8421_device::mb8421_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MB8421, "MB8421 DPSRAM", tag, owner, clock, "mb8421", __FILE__),
- m_intl_handler(*this),
- m_intr_handler(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mb8421_device::device_start()
-{
- memset(m_ram, 0, 0x800);
-
- // resolve callbacks
- m_intl_handler.resolve_safe();
- m_intr_handler.resolve_safe();
-
- // state save
- save_item(NAME(m_ram));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mb8421_device::device_reset()
-{
- m_intl_handler(0);
- m_intr_handler(0);
-}
-
-
-
-WRITE8_MEMBER(mb8421_device::left_w)
-{
- offset &= 0x7ff;
- m_ram[offset] = data;
-
- if (offset == 0x7ff)
- m_intr_handler(1);
-}
-
-READ8_MEMBER(mb8421_device::left_r)
-{
- offset &= 0x7ff;
-
- if (offset == 0x7fe && !space.debugger_access())
- m_intl_handler(0);
-
- return m_ram[offset];
-}
-
-WRITE8_MEMBER(mb8421_device::right_w)
-{
- offset &= 0x7ff;
- m_ram[offset] = data;
-
- if (offset == 0x7fe)
- m_intl_handler(1);
-}
-
-READ8_MEMBER(mb8421_device::right_r)
-{
- offset &= 0x7ff;
-
- if (offset == 0x7ff && !space.debugger_access())
- m_intr_handler(0);
-
- return m_ram[offset];
-}
diff --git a/src/emu/machine/mb8421.h b/src/emu/machine/mb8421.h
deleted file mode 100644
index 92300e45946..00000000000
--- a/src/emu/machine/mb8421.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:hap
-/**********************************************************************
-
- Fujitsu MB8421/22/31/32-90/-90L/-90LL/-12/-12L/-12LL
- CMOS 16K-bit (2KB) dual-port SRAM
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef _MB8421_H
-#define _MB8421_H
-
-#include "emu.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-// note: INT pins are only available on MB84x1
-// INTL is for the CPU on the left side, INTR for the one on the right
-#define MCFG_MB8421_INTL_HANDLER(_devcb) \
- devcb = &mb8421_device::set_intl_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MB8421_INTR_HANDLER(_devcb) \
- devcb = &mb8421_device::set_intr_handler(*device, DEVCB_##_devcb);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mb8421_device
-
-class mb8421_device : public device_t
-{
-public:
- mb8421_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_intl_handler(device_t &device, _Object object) { return downcast<mb8421_device &>(device).m_intl_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_intr_handler(device_t &device, _Object object) { return downcast<mb8421_device &>(device).m_intr_handler.set_callback(object); }
-
- DECLARE_READ_LINE_MEMBER( busy_r ) { return 0; } // _BUSY pin - not emulated
- UINT8 peek(offs_t offset) { return m_ram[offset & 0x7ff]; }
-
- DECLARE_WRITE8_MEMBER( left_w );
- DECLARE_READ8_MEMBER( left_r );
- DECLARE_WRITE8_MEMBER( right_w );
- DECLARE_READ8_MEMBER( right_r );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- UINT8 m_ram[0x800];
-
- devcb_write_line m_intl_handler;
- devcb_write_line m_intr_handler;
-};
-
-// device type definition
-extern const device_type MB8421;
-
-
-#endif /* _MB8421_H */
diff --git a/src/emu/machine/mb87078.c b/src/emu/machine/mb87078.c
deleted file mode 100644
index a94380456f5..00000000000
--- a/src/emu/machine/mb87078.c
+++ /dev/null
@@ -1,247 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Fabio Priuli,Philip Bennett
-/*****************************************************************************
-
- Fujitsu MB87078 6-bit, 4-channel electronic volume controller emulator
-
- An excerpt from the datasheet about the chip functionality:
- "A digital signal input controls gain every 0.5 dB step from 0dB to -32dB.
- - Gain variable range: 0 dB to -32 dB by 0.5dB or -infinity
- - Gain variable range is expanded to connect two channels serially (0 dB to -64 dB)
- - Each channel gain can be set respectively
- - Test function is provided (to confirm internal data)
- - Data is initialized by reset signal (all channels are set to 0dB)
- - Logic I/O is TTL comatible"
-
- There are 6 digital data input/output pins and DSEL pin that selects
- the group (there are two) of internal registers to be read/written.
-
- Group 0 is 6-bit gain latch
- Group 1 is 5-bit control latch (2-bits are channel select and 3-bits are volume control)
-
- Digital I/O Setting:
- /TC DSEL D0 D1 D2 D3 D4 D5 I/O MODES (when /TC==H ->write)
- H H DSC1 DSC2 EN C0 C32 X Input mode
- H L GD0 GD1 GD2 GD3 GD4 GD5 (set)
- L H DSC1 DSC2 EN C0 C32 L Output mode
- L L GD0 GD1 GD2 GD3 GD4 GD5 (check)
-
- Channel Setting:
- DSC2 DSC1 CHANNEL
- L L 0
- L H 1
- H L 2
- H H 3
-
- Electrical Volume Setting:
- DATA* GAIN
- GD5 GD4 GD3 GD2 GD1 GD0 EN C0 C32 (dB)
- 1 1 1 1 1 1 1 0 0 0
- 1 1 1 1 1 0 1 0 0 -0.5
- 1 1 1 1 0 1 1 0 0 -1
- 1 1 1 1 0 0 1 0 0 -1.5
- 1 1 1 0 1 1 1 0 0 -2
- [..........................................]
- 0 0 0 0 0 1 1 0 0 -31
- 0 0 0 0 0 0 1 0 0 -31.5
- X X X X X X 1 X 1 -32
- X X X X X X 1 1 0 0
- X X X X X X 0 X X -infinity
-
- X=don't care
- * When reset, DATA is set to 0 dB (code 111111 100)
-
-
- MB87078 pins and assigned interface variables/functions
-
- /[ 1] D0 /TC [24]
- | [ 2] D1 /WR [23]
- MB87078_data_w()| [ 3] D2 /CE [22]
- MB87078_data_r()| [ 4] D3 DSEL [21]-MB87078_data_w()/data_r() parameter
- | [ 5] D4 /RESET [20]-MB87078_reset_comp_w()
- \[ 6] D5 /PD [19]
- [ 7] DGND VDD [18]
- [ 8] AGND 1/2 VDD [17]
- [ 9] AIN0 AOUT3 [16]
- [10] AOUT0 AIN3 [15]
- [11] AIN1 AOUT2 [14]
- [12] AOUT1 AIN2 [13]
-
-
- *****************************************************************************/
-
-#include "emu.h"
-#include "machine/mb87078.h"
-
-
-static const float mb87078_gain_decibel[66] = {
- 0.0, -0.5, -1.0, -1.5, -2.0, -2.5, -3.0, -3.5,
- -4.0, -4.5, -5.0, -5.5, -6.0, -6.5, -7.0, -7.5,
- -8.0, -8.5, -9.0, -9.5,-10.0,-10.5,-11.0,-11.5,
- -12.0,-12.5,-13.0,-13.5,-14.0,-14.5,-15.0,-15.5,
- -16.0,-16.5,-17.0,-17.5,-18.0,-18.5,-19.0,-19.5,
- -20.0,-20.5,-21.0,-21.5,-22.0,-22.5,-23.0,-23.5,
- -24.0,-24.5,-25.0,-25.5,-26.0,-26.5,-27.0,-27.5,
- -28.0,-28.5,-29.0,-29.5,-30.0,-30.5,-31.0,-31.5,
- -32.0, -256.0
- };
-
-static const int mb87078_gain_percent[66] = {
- 100,94,89,84,79,74,70,66,
- 63,59,56,53,50,47,44,42,
- 39,37,35,33,31,29,28,26,
- 25,23,22,21,19,18,17,16,
- 15,14,14,13,12,11,11,10,
- 10, 9, 8, 8, 7, 7, 7, 6,
- 6, 5, 5, 5, 5, 4, 4, 4,
- 3, 3, 3, 3, 3, 2, 2, 2,
- 2, 0
-};
-
-/*****************************************************************************
- DEVICE INTERFACE
-*****************************************************************************/
-
-const device_type MB87078 = &device_creator<mb87078_device>;
-
-mb87078_device::mb87078_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MB87078, "MB87078 Volume Controller", tag, owner, clock, "mb87078", __FILE__),
- m_channel_latch(0),
- m_reset_comp(0),
- m_gain_changed_cb(*this)
-{
- m_gain[0] = m_gain[1] = m_gain[2] = m_gain[3] = 0;
- memset(m_latch, 0, sizeof(m_latch));
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mb87078_device::device_start()
-{
- m_gain_changed_cb.resolve_safe();
-
- save_item(NAME(m_channel_latch));
- save_item(NAME(m_reset_comp));
- save_item(NAME(m_latch[0]));
- save_item(NAME(m_latch[1]));
- save_item(NAME(m_gain));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mb87078_device::device_reset()
-{
- m_channel_latch = 0;
-
- /* reset chip */
- reset_comp_w(0);
- reset_comp_w(1);
-}
-
-/*****************************************************************************
- IMPLEMENTATION
-*****************************************************************************/
-
-#define GAIN_MAX_INDEX 64
-#define GAIN_INFINITY_INDEX 65
-
-
-static int calc_gain_index( int data0, int data1 )
-{
-//data 0: GD0-GD5
-//data 1: 1 2 4 8 16
-// c1 c2 EN C0 C32
-
- if (!(data1 & 0x04))
- {
- return GAIN_INFINITY_INDEX;
- }
- else
- {
- if (data1 & 0x10)
- {
- return GAIN_MAX_INDEX;
- }
- else
- {
- if (data1 & 0x08)
- {
- return 0;
- }
- else
- {
- return (data0 ^ 0x3f);
- }
- }
- }
-}
-
-
-void mb87078_device::gain_recalc()
-{
- int i;
-
- for (i = 0; i < 4; i++)
- {
- int old_index = m_gain[i];
- m_gain[i] = calc_gain_index(m_latch[0][i], m_latch[1][i]);
- if (old_index != m_gain[i])
- m_gain_changed_cb((offs_t)i, mb87078_gain_percent[m_gain[i]]);
- }
-}
-
-
-
-void mb87078_device::data_w( int data, int dsel )
-{
- if (m_reset_comp == 0)
- return;
-
- if (dsel == 0) /* gd0 - gd5 */
- {
- m_latch[0][m_channel_latch] = data & 0x3f;
- }
- else /* dcs1, dsc2, en, c0, c32, X */
- {
- m_channel_latch = data & 3;
- m_latch[1][m_channel_latch] = data & 0x1f; //always zero bit 5
- }
- gain_recalc();
-}
-
-
-float mb87078_device::gain_decibel_r( int channel )
-{
- return mb87078_gain_decibel[m_gain[channel]];
-}
-
-
-int mb87078_device::gain_percent_r( int channel )
-{
- return mb87078_gain_percent[m_gain[channel]];
-}
-
-void mb87078_device::reset_comp_w( int level )
-{
- m_reset_comp = level;
-
- /*this seems to be true, according to the datasheets*/
- if (level == 0)
- {
- m_latch[0][0] = 0x3f;
- m_latch[0][1] = 0x3f;
- m_latch[0][2] = 0x3f;
- m_latch[0][3] = 0x3f;
-
- m_latch[1][0] = 0x0 | 0x4;
- m_latch[1][1] = 0x1 | 0x4;
- m_latch[1][2] = 0x2 | 0x4;
- m_latch[1][3] = 0x3 | 0x4;
- }
-
- gain_recalc();
-}
diff --git a/src/emu/machine/mb87078.h b/src/emu/machine/mb87078.h
deleted file mode 100644
index 15e68b83b22..00000000000
--- a/src/emu/machine/mb87078.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Fabio Priuli,Philip Bennett
-/*****************************************************************************
-
- MB87078 6-bit,4-channel electronic volume controller emulator
-
-
-*****************************************************************************/
-
-#ifndef __MB87078_H__
-#define __MB87078_H__
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_MB87078_GAIN_CHANGED_CB(_devcb) \
- devcb = &mb87078_device::set_gain_changed_callback(*device, DEVCB_##_devcb);
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-class mb87078_device : public device_t
-{
-public:
- mb87078_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~mb87078_device() {}
-
- template<class _Object> static devcb_base &set_gain_changed_callback(device_t &device, _Object object) { return downcast<mb87078_device &>(device).m_gain_changed_cb.set_callback(object); }
-
- void data_w(int data, int dsel);
- void reset_comp_w(int level);
-
-
- /* gain_decibel_r will return 'channel' gain on the device.
- Returned value represents channel gain expressed in decibels,
- Range from 0 to -32.0 (or -256.0 for -infinity) */
- float gain_decibel_r(int channel);
-
-
- /* gain_percent_r will return 'channel' gain on the device.
- Returned value represents channel gain expressed in percents of maximum volume.
- Range from 100 to 0. (100 = 0dB; 50 = -6dB; 0 = -infinity)
- This function is designed for use with MAME mixer_xxx() functions. */
- int gain_percent_r(int channel);
-
- void gain_recalc();
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
- int m_gain[4]; /* gain index 0-63,64,65 */
- int m_channel_latch; /* current channel */
- UINT8 m_latch[2][4]; /* 6bit+3bit 4 data latches */
- UINT8 m_reset_comp;
-
- devcb_write8 m_gain_changed_cb;
-};
-
-extern const device_type MB87078;
-
-#endif /* __MB87078_H__ */
diff --git a/src/emu/machine/mb8795.c b/src/emu/machine/mb8795.c
deleted file mode 100644
index 3a83f02af94..00000000000
--- a/src/emu/machine/mb8795.c
+++ /dev/null
@@ -1,335 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-
-#include "emu.h"
-#include "mb8795.h"
-
-const device_type MB8795 = &device_creator<mb8795_device>;
-
-DEVICE_ADDRESS_MAP_START(map, 8, mb8795_device)
- AM_RANGE(0x0, 0x0) AM_READWRITE(txstat_r, txstat_w)
- AM_RANGE(0x1, 0x1) AM_READWRITE(txmask_r, txmask_w)
- AM_RANGE(0x2, 0x2) AM_READWRITE(rxstat_r, rxstat_w)
- AM_RANGE(0x3, 0x3) AM_READWRITE(rxmask_r, rxmask_w)
- AM_RANGE(0x4, 0x4) AM_READWRITE(txmode_r, txmode_w)
- AM_RANGE(0x5, 0x5) AM_READWRITE(rxmode_r, rxmode_w)
- AM_RANGE(0x6, 0x6) AM_WRITE(reset_w)
- AM_RANGE(0x7, 0x7) AM_READ(tdc_lsb_r)
- AM_RANGE(0x8, 0xf) AM_READWRITE(mac_r, mac_w) // Mapping limitation, real is up to 0xd
-ADDRESS_MAP_END
-
-mb8795_device::mb8795_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, MB8795, "Fujitsu MB8795", tag, owner, clock, "mb8795", __FILE__),
- device_network_interface(mconfig, *this, 10),
- irq_tx_cb(*this),
- irq_rx_cb(*this),
- drq_tx_cb(*this),
- drq_rx_cb(*this)
-{
-}
-
-void mb8795_device::check_irq()
-{
- bool old_irq_tx = irq_tx;
- bool old_irq_rx = irq_rx;
- irq_tx = txstat & txmask;
- irq_rx = rxstat & rxmask;
- if(irq_tx != old_irq_tx && !irq_tx_cb.isnull())
- irq_tx_cb(irq_tx);
- if(irq_rx != old_irq_rx && !irq_rx_cb.isnull())
- irq_rx_cb(irq_rx);
-}
-
-void mb8795_device::device_start()
-{
- irq_tx_cb.resolve();
- irq_rx_cb.resolve();
- drq_tx_cb.resolve();
- drq_rx_cb.resolve();
-
- memset(mac, 0, 6);
- timer_tx = timer_alloc(TIMER_TX);
- timer_rx = timer_alloc(TIMER_RX);
-}
-
-void mb8795_device::device_reset()
-{
- txstat = EN_TXS_READY;
- txmask = 0x00;
- rxstat = 0x00;
- rxmask = 0x00;
- txmode = 0x00;
- rxmode = 0x00;
-
- drq_tx = drq_rx = false;
- irq_tx = irq_rx = false;
-
- txlen = rxlen = txcount = 0;
-
- set_promisc(true);
-
- start_send();
-}
-
-void mb8795_device::recv_cb(UINT8 *buf, int len)
-{
- memcpy(rxbuf, buf, len);
- rxlen = len;
- receive();
-}
-
-READ8_MEMBER(mb8795_device::txstat_r)
-{
- // logerror("%s: txstat_r %02x (%08x)\n", tag(), txstat, space.device().safe_pc());
- return txstat;
-}
-
-WRITE8_MEMBER(mb8795_device::txstat_w)
-{
- txstat = txstat & (0xf0 | ~data);
- check_irq();
- logerror("%s: txstat_w %02x (%08x)\n", tag(), txstat, space.device().safe_pc());
-}
-
-READ8_MEMBER(mb8795_device::txmask_r)
-{
- logerror("%s: txmask_r %02x (%08x)\n", tag(), txmask, space.device().safe_pc());
- return txmask;
-}
-
-WRITE8_MEMBER(mb8795_device::txmask_w)
-{
- txmask = data & 0xaf;
- check_irq();
- logerror("%s: txmask_w %02x (%08x)\n", tag(), txmask, space.device().safe_pc());
-}
-
-READ8_MEMBER(mb8795_device::rxstat_r)
-{
- logerror("%s: rxstat_r %02x (%08x)\n", tag(), rxstat, space.device().safe_pc());
- return rxstat;
-}
-
-WRITE8_MEMBER(mb8795_device::rxstat_w)
-{
- rxstat = rxstat & (0x70 | ~data);
- check_irq();
- logerror("%s: rxstat_w %02x (%08x)\n", tag(), rxstat, space.device().safe_pc());
-}
-
-READ8_MEMBER(mb8795_device::rxmask_r)
-{
- logerror("%s: rxmask_r %02x (%08x)\n", tag(), rxmask, space.device().safe_pc());
- return rxmask;
-}
-
-WRITE8_MEMBER(mb8795_device::rxmask_w)
-{
- rxmask = data & 0x9f;
- check_irq();
- logerror("%s: rxmask_w %02x (%08x)\n", tag(), rxmask, space.device().safe_pc());
-}
-
-READ8_MEMBER(mb8795_device::txmode_r)
-{
- logerror("%s: txmode_r %02x (%08x)\n", tag(), txmode, space.device().safe_pc());
- return txmode;
-}
-
-WRITE8_MEMBER(mb8795_device::txmode_w)
-{
- txmode = data;
- logerror("%s: txmode_w %02x (%08x)\n", tag(), txmode, space.device().safe_pc());
-}
-
-READ8_MEMBER(mb8795_device::rxmode_r)
-{
- logerror("%s: rxmode_r %02x (%08x)\n", tag(), rxmode, space.device().safe_pc());
- return rxmode;
-}
-
-WRITE8_MEMBER(mb8795_device::rxmode_w)
-{
- rxmode = data;
- logerror("%s: rxmode_w %02x (%08x)\n", tag(), rxmode, space.device().safe_pc());
-}
-
-WRITE8_MEMBER(mb8795_device::reset_w)
-{
- if(data & EN_RST_RESET)
- device_reset();
-}
-
-READ8_MEMBER(mb8795_device::tdc_lsb_r)
-{
- logerror("%s: tdc_lsb_r %02x (%08x)\n", tag(), txcount & 0xff, space.device().safe_pc());
- return txcount;
-}
-
-READ8_MEMBER(mb8795_device::mac_r)
-{
- if(offset < 6)
- return mac[offset];
- if(offset == 7) {
- logerror("%s: tdc_msb_r %02x (%08x)\n", tag(), txcount >> 8, space.device().safe_pc());
- return (txcount >> 8) & 0x3f;
- }
- return 0;
-}
-
-WRITE8_MEMBER(mb8795_device::mac_w)
-{
- if(offset < 6) {
- mac[offset] = data;
- set_mac((const char *)mac);
- }
-}
-
-void mb8795_device::start_send()
-{
- timer_tx->adjust(attotime::zero);
-}
-
-void mb8795_device::tx_dma_w(UINT8 data, bool eof)
-{
- txbuf[txlen++] = data;
- if(txstat & EN_TXS_READY) {
- txstat &= ~EN_TXS_READY;
- check_irq();
- }
-
- drq_tx = false;
- if(!drq_tx_cb.isnull())
- drq_tx_cb(drq_tx);
-
- if(eof) {
- logerror("%s: send packet, dest=%02x.%02x.%02x.%02x.%02x.%02x len=%04x loopback=%s\n", tag(),
- txbuf[0], txbuf[1], txbuf[2], txbuf[3], txbuf[4], txbuf[5],
- txlen,
- txmode & EN_TMD_LB_DISABLE ? "off" : "on");
-
- if(txlen > 1500)
- txlen = 1500; // Weird packet send on loopback test in the next
-
- if(!(txmode & EN_TMD_LB_DISABLE)) {
- memcpy(rxbuf, txbuf, txlen);
- rxlen = txlen;
- receive();
- }
- send(txbuf, txlen);
- txlen = 0;
- txstat |= EN_TXS_READY;
- txcount++;
- start_send();
- } else
- timer_tx->adjust(attotime::from_nsec(800));
-}
-
-void mb8795_device::rx_dma_r(UINT8 &data, bool &eof)
-{
- drq_rx = false;
- if(!drq_rx_cb.isnull())
- drq_rx_cb(drq_rx);
-
- if(rxlen) {
- data = rxbuf[0];
- rxlen--;
- memmove(rxbuf, rxbuf+1, rxlen);
- } else
- data = 0;
-
- if(rxlen) {
- timer_rx->adjust(attotime::from_nsec(800));
- eof = false;
- } else
- eof = true;
-}
-
-void mb8795_device::receive()
-{
- bool keep = false;
- switch(rxmode & EN_RMD_WHATRECV) {
- case EN_RMD_RECV_NONE:
- keep = false;
- break;
- case EN_RMD_RECV_NORMAL:
- keep = recv_is_broadcast() || recv_is_me() || recv_is_local_multicast();
- break;
- case EN_RMD_RECV_MULTI:
- keep = recv_is_broadcast() || recv_is_me() || recv_is_multicast();
- break;
- case EN_RMD_RECV_PROMISC:
- keep = true;
- break;
- }
- logerror("%s: received packet for %02x.%02x.%02x.%02x.%02x.%02x len=%04x, mode=%d -> %s\n", tag(),
- rxbuf[0], rxbuf[1], rxbuf[2], rxbuf[3], rxbuf[4], rxbuf[5],
- rxlen, rxmode & 3, keep ? "kept" : "dropped");
- if(!keep)
- rxlen = 0;
- else {
- // Minimal ethernet packet size
- if(rxlen < 64) {
- memset(rxbuf+rxlen, 0, 64-rxlen);
- rxlen = 64;
- }
- // Checksum? In any case, it's there
- memset(rxbuf+rxlen, 0, 4);
- rxlen += 4;
-
- rxstat |= EN_RXS_OK;
- check_irq();
- timer_rx->adjust(attotime::zero);
- }
-}
-
-bool mb8795_device::recv_is_broadcast()
-{
- return
- rxbuf[0] == 0xff &&
- rxbuf[1] == 0xff &&
- rxbuf[2] == 0xff &&
- rxbuf[3] == 0xff &&
- rxbuf[4] == 0xff &&
- rxbuf[5] == 0xff;
-}
-
-bool mb8795_device::recv_is_me()
-{
- return
- rxbuf[0] == mac[0] &&
- rxbuf[1] == mac[1] &&
- rxbuf[2] == mac[2] &&
- rxbuf[3] == mac[3] &&
- rxbuf[4] == mac[4] &&
- ((rxmode & EN_RMD_ADDRSIZE) || rxbuf[5] == mac[5]);
-}
-
-bool mb8795_device::recv_is_local_multicast()
-{
- return
- (rxbuf[0] & 0x01) &&
- (rxbuf[0] & 0xfe) == mac[0] &&
- rxbuf[1] == mac[1] &&
- rxbuf[2] == mac[2];
-}
-
-bool mb8795_device::recv_is_multicast()
-{
- return rxbuf[0] & 0x01;
-}
-
-void mb8795_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if(id == TIMER_TX) {
- drq_tx = true;
- if(!drq_tx_cb.isnull())
- drq_tx_cb(drq_tx);
- }
-
- if(id == TIMER_RX && rxlen) {
- drq_rx = true;
- if(!drq_rx_cb.isnull())
- drq_rx_cb(drq_rx);
- }
-}
diff --git a/src/emu/machine/mb8795.h b/src/emu/machine/mb8795.h
deleted file mode 100644
index 478d9487263..00000000000
--- a/src/emu/machine/mb8795.h
+++ /dev/null
@@ -1,124 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef MB8795_H
-#define MB8795_H
-
-#define MCFG_MB8795_ADD(_tag, _tx_irq, _rx_irq, _tx_drq, _rx_drq) \
- MCFG_DEVICE_ADD(_tag, MB8795, 0) \
- downcast<mb8795_device *>(device)->set_irq_cb(_tx_irq, _rx_irq); \
- downcast<mb8795_device *>(device)->set_drq_cb(_tx_drq, _rx_drq);
-
-#define MCFG_MB8795_TX_IRQ_CALLBACK(_write) \
- devcb = &mb8795_device::set_tx_irq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MB8795_RX_IRQ_CALLBACK(_write) \
- devcb = &mb8795_device::set_rx_irq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MB8795_TX_DRQ_CALLBACK(_write) \
- devcb = &mb8795_device::set_tx_drq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MB8795_RX_DRQ_CALLBACK(_write) \
- devcb = &mb8795_device::set_rx_drq_wr_callback(*device, DEVCB_##_write);
-
-class mb8795_device : public device_t,
- public device_network_interface
-{
-public:
- mb8795_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_tx_irq_wr_callback(device_t &device, _Object object) { return downcast<mb8795_device &>(device).irq_tx_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_rx_irq_wr_callback(device_t &device, _Object object) { return downcast<mb8795_device &>(device).irq_rx_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_tx_drq_wr_callback(device_t &device, _Object object) { return downcast<mb8795_device &>(device).drq_tx_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_rx_drq_wr_callback(device_t &device, _Object object) { return downcast<mb8795_device &>(device).drq_rx_cb.set_callback(object); }
-
- DECLARE_ADDRESS_MAP(map, 8);
-
- DECLARE_READ8_MEMBER(txstat_r);
- DECLARE_WRITE8_MEMBER(txstat_w);
- DECLARE_READ8_MEMBER(txmask_r);
- DECLARE_WRITE8_MEMBER(txmask_w);
- DECLARE_READ8_MEMBER(rxstat_r);
- DECLARE_WRITE8_MEMBER(rxstat_w);
- DECLARE_READ8_MEMBER(rxmask_r);
- DECLARE_WRITE8_MEMBER(rxmask_w);
- DECLARE_READ8_MEMBER(txmode_r);
- DECLARE_WRITE8_MEMBER(txmode_w);
- DECLARE_READ8_MEMBER(rxmode_r);
- DECLARE_WRITE8_MEMBER(rxmode_w);
- DECLARE_WRITE8_MEMBER(reset_w);
- DECLARE_READ8_MEMBER(tdc_lsb_r);
- DECLARE_READ8_MEMBER(mac_r);
- DECLARE_WRITE8_MEMBER(mac_w);
-
- void tx_dma_w(UINT8 data, bool eof);
- void rx_dma_r(UINT8 &data, bool &eof);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- virtual void recv_cb(UINT8 *buf, int len);
-
-private:
- enum { TIMER_TX, TIMER_RX };
-
- // Lifted from netbsd
- enum {
- EN_TXS_READY = 0x80, /* ready for packet */
- EN_TXS_BUSY = 0x40, /* receive carrier detect */
- EN_TXS_TXRECV = 0x20, /* transmission received */
- EN_TXS_SHORTED = 0x10, /* possible coax short */
- EN_TXS_UNDERFLOW = 0x08, /* underflow on xmit */
- EN_TXS_COLLERR = 0x04, /* collision detected */
- EN_TXS_COLLERR16 = 0x02, /* 16th collision error */
- EN_TXS_PARERR = 0x01, /* parity error in tx data */
-
- EN_RXS_OK = 0x80, /* packet received ok */
- EN_RXS_RESET = 0x10, /* reset packet received */
- EN_RXS_SHORT = 0x08, /* < minimum length */
- EN_RXS_ALIGNERR = 0x04, /* alignment error */
- EN_RXS_CRCERR = 0x02, /* CRC error */
- EN_RXS_OVERFLOW = 0x01, /* receiver FIFO overflow */
-
- EN_TMD_COLLMASK = 0xf0, /* collision count */
- EN_TMD_COLLSHIFT = 4,
- EN_TMD_PARIGNORE = 0x08, /* ignore parity */
- EN_TMD_TURBO1 = 0x04,
- EN_TMD_LB_DISABLE = 0x02, /* loop back disabled */
- EN_TMD_DISCONTENT = 0x01, /* disable contention (rx carrier) */
-
- EN_RMD_TEST = 0x80, /* must be zero */
- EN_RMD_ADDRSIZE = 0x10, /* reduces NODE match to 5 chars */
- EN_RMD_SHORTENABLE = 0x08, /* "rx packets >= 10 bytes" - <? */
- EN_RMD_RESETENABLE = 0x04, /* detect "reset" ethernet frames */
- EN_RMD_WHATRECV = 0x03, /* controls what packets are received */
- EN_RMD_RECV_PROMISC = 0x03, /* all packets */
- EN_RMD_RECV_MULTI = 0x02, /* accept broad/multicasts */
- EN_RMD_RECV_NORMAL = 0x01, /* accept broad/limited multicasts */
- EN_RMD_RECV_NONE = 0x00, /* accept no packets */
-
- EN_RST_RESET = 0x80 /* reset interface */
- };
-
- UINT8 mac[6];
- UINT8 txbuf[2000], rxbuf[2000];
- UINT8 txstat, txmask, rxstat, rxmask, txmode, rxmode;
- UINT16 txlen, rxlen, txcount;
- bool drq_tx, drq_rx, irq_tx, irq_rx;
- emu_timer *timer_tx, *timer_rx;
-
- devcb_write_line irq_tx_cb, irq_rx_cb, drq_tx_cb, drq_rx_cb;
-
- void check_irq();
- void start_send();
- void receive();
- bool recv_is_broadcast();
- bool recv_is_me();
- bool recv_is_multicast();
- bool recv_is_local_multicast();
-};
-
-extern const device_type MB8795;
-
-#endif
diff --git a/src/emu/machine/mb89352.c b/src/emu/machine/mb89352.c
deleted file mode 100644
index 1b0894c2007..00000000000
--- a/src/emu/machine/mb89352.c
+++ /dev/null
@@ -1,619 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Barry Rodewald
-/*
- * Fujitsu MB89352A SCSI Protocol Controller
- *
- * Should be compatible with the MB87030/31, and MB89351
- *
- * Used on the Sharp X68000 Super, X68000 XVI and X68030 (internal), and on SCSI expansion cards for any X680x0 (external)
- *
- * Registers (based on datasheet):
- *
- * 0: BDID (Bus Device ID)
- * bit = device ID (ie: bit 2 = device 2) (read)
- * bit 0 = ID1, bit 1 = ID2, bit 2 = ID4 (write)
- *
- * 1: SCTL (SPC Control)
- * (all read/write)
- * bit 0 = INT Enable
- * bit 1 = Reselect Enable
- * bit 2 = Select Enable
- * bit 3 = Parity Enable
- * bit 4 = Arbitration Phase Enable
- * bit 5 = Diag Mode
- * bit 6 = Control Reset
- * bit 7 = Reset and Disable
- *
- * 2: SCMD (Command)
- * bits 0-2 = Transfer Modifier (read)
- * bit 0 = Term Mode (write)
- * bit 2 = PRG Xfer (write)
- * bit 3 = Intercept Xfer (read/write)
- * bit 4 = RST Out (read/write)
- * bits 5-7 = Command code (read/write) (would have been nice if these codes were mentioned in the datasheet...)
- * 000 = Bus release
- * 001 = Selection
- * 010 = Reset ATN
- * 011 = Set ATN
- * 100 = Transfer
- * 101 = Transfer Pause
- * 110 = Reset ACK/REQ
- * 111 = Set ACK/REQ
- *
- * 3: Unused
- *
- * 4: INTS (Interrupt Sense)
- * on write, clear interrupt
- * on read:
- * bit 0 = Reset Condition
- * bit 1 = SPC Hard Error
- * bit 2 = Timeout
- * bit 3 = Service Required
- * bit 4 = Command Complete
- * bit 5 = Disconnect
- * bit 6 = Reselected
- * bit 7 = Selected
- *
- * 5: PSNS (Phase Sense) (read-only)
- * b7 b0
- * | REQ | ACK | ATN | SEL | BSY | MSG | C/D | I/O |
- * SDGC (SPC Diag. Control) (write-only)
- * bit 5 = Xfer Enable
- * bit 4 = Unused
- * all other bits are Diag. of the matching inputs above.
- *
- * 6: SSTS (SPC Status) (read-only)
- * bit 0 = DREG Empty
- * bit 1 = DREG Full
- * bit 2 = TC=0
- * bit 3 = SCSI RST
- * bit 4 = Xfer in progress
- * bit 5 = SPC BSY
- * bit 6 = Connected to Target
- * bit 7 = Connected to Initiator
- *
- * 7: SERR (SCSI Error Status) (read-only)
- * bit 1 = Short Transfer Period
- * bit 3 = TC Parity Error
- * bit 5 = Xfer Out (related to SDGC bit 5)
- * bits 6,7 = Data error (10 = undefined, 00 = no error, 01 and 11 = parity error)
- *
- * 8: PCTL (Phase Control)
- * (read/write)
- * bits 0-2 = transfer phase ( | MSG | C/D | I/O | )
- * bits 7 = Bus Free interrupt enable
- * other bits read 0
- *
- * 9: MBC (Modified Byte Counter)
- * (read-only)
- * bits 0-3 = MBC bits 0-3
- * other bits read 0
- *
- * A: DREG (Data Register)
- * 8-bit FIFO
- *
- * B: TEMP (Temporary Register)
- * on read, from SCSI
- * on write, to SCSI
- *
- * C, D, E: TCH, TCM, TCL (Transfer Counter High, Mid, Low)
- * 24-bit transfer counter
- *
- */
-
-#include "emu.h"
-#include "mb89352.h"
-
-/*
- * Device config
- */
-
-const device_type MB89352A = &device_creator<mb89352_device>;
-
-
-/*
- * Device
- */
-
-mb89352_device::mb89352_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- legacy_scsi_host_adapter(mconfig, MB89352A, "MB89352A", tag, owner, clock, "mb89352", __FILE__),
- m_irq_cb(*this),
- m_drq_cb(*this)
-{
-}
-
-void mb89352_device::device_start()
-{
- legacy_scsi_host_adapter::device_start();
-
- m_phase = SCSI_PHASE_BUS_FREE;
- m_target = 0;
- m_command_index = 0;
- m_line_status = 0x00;
- m_spc_status = 0x01; // presumably the data reg is empty to start with
- m_error_status = 0x00;
- m_transfer_count = 0;
- if(m_transfer_count == 0)
- m_spc_status |= SSTS_TC_ZERO;
- m_ints = 0x00;
-
- m_irq_cb.resolve_safe();
- m_drq_cb.resolve_safe();
-
- // allocate read timer
- m_transfer_timer = timer_alloc(TIMER_TRANSFER);
-}
-
-void mb89352_device::device_reset()
-{
- m_phase = SCSI_PHASE_BUS_FREE;
- m_target = 0;
- m_command_index = 0;
- m_line_status = 0x00;
- m_error_status = 0x00;
- m_transfer_count = 0;
- m_spc_status = 0x05; // presumably the data reg is empty to start with
- m_busfree_int_enable = 0;
-}
-
-void mb89352_device::device_stop()
-{
-}
-
-// get the length of a SCSI command based on it's command byte type
-int mb89352_device::get_scsi_cmd_len(UINT8 cbyte)
-{
- int group;
-
- group = (cbyte>>5) & 7;
-
- if (group == 0) return 6;
- if (group == 1 || group == 2) return 10;
- if (group == 5) return 12;
-
- fatalerror("MB89352: Unknown SCSI command group %d\n", group);
-
- // never executed
- //return 6;
-}
-
-void mb89352_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch(id)
- {
- case TIMER_TRANSFER:
- // TODO: check interrupts are actually enabled
- {
- m_drq_cb(1);
- }
- break;
- }
-}
-
-void mb89352_device::set_phase(int phase)
-{
- m_phase = phase;
- switch(phase)
- {
- case SCSI_PHASE_BUS_FREE:
- m_line_status = 0;
- m_spc_status &= ~SSTS_XFER_IN_PROGRESS;
- break;
- case SCSI_PHASE_COMMAND:
- m_line_status |= MB89352_LINE_REQ;
- m_line_status &= ~MB89352_LINE_ACK;
- m_line_status &= ~MB89352_LINE_MSG;
- m_line_status |= MB89352_LINE_CD;
- m_line_status &= ~MB89352_LINE_IO;
- break;
- case SCSI_PHASE_STATUS:
-// m_line_status |= MB89352_LINE_REQ;
-// m_line_status &= ~MB89352_LINE_ACK;
- m_line_status &= ~MB89352_LINE_MSG;
- m_line_status |= MB89352_LINE_CD;
- m_line_status |= MB89352_LINE_IO;
- break;
- case SCSI_PHASE_DATAIN:
-// m_line_status |= MB89352_LINE_REQ;
-// m_line_status &= ~MB89352_LINE_ACK;
- m_line_status &= ~MB89352_LINE_MSG;
- m_line_status &= ~MB89352_LINE_CD;
- m_line_status |= MB89352_LINE_IO;
- break;
- case SCSI_PHASE_DATAOUT:
-// m_line_status |= MB89352_LINE_REQ;
-// m_line_status &= ~MB89352_LINE_ACK;
- m_line_status &= ~MB89352_LINE_MSG;
- m_line_status &= ~MB89352_LINE_CD;
- m_line_status &= ~MB89352_LINE_IO;
- break;
- case SCSI_PHASE_MESSAGE_IN:
-// m_line_status |= MB89352_LINE_REQ;
-// m_line_status &= ~MB89352_LINE_ACK;
- m_line_status |= MB89352_LINE_MSG;
- m_line_status |= MB89352_LINE_CD;
- m_line_status |= MB89352_LINE_IO;
- break;
- case SCSI_PHASE_MESSAGE_OUT:
-// m_line_status |= MB89352_LINE_REQ;
-// m_line_status &= ~MB89352_LINE_ACK;
- m_line_status |= MB89352_LINE_MSG;
- m_line_status |= MB89352_LINE_CD;
- m_line_status &= ~MB89352_LINE_IO;
- break;
- }
- logerror("MB89352: phase set to %i\n",m_phase);
-}
-
-READ8_MEMBER( mb89352_device::mb89352_r )
-{
- UINT8 ret;
- switch(offset & 0x0f)
- {
- case 0x00: // BDID - Bus Device ID
- return (1 << m_bdid);
- case 0x01: // SCTL - SPC Control
- ret = 0x00;
- if(m_arbit_enable)
- ret |= 0x10;
- if(m_parity_enable)
- ret |= 0x08;
- if(m_sel_enable)
- ret |= 0x04;
- if(m_resel_enable)
- ret |= 0x02;
- if(m_int_enable)
- ret |= 0x01;
- return ret;
- case 0x02: // SCMD - Command
- return m_scmd;
- case 0x03: // Unused
- return 0xff;
- case 0x04: // INTS - Interrupt Sense
- return m_ints;
- case 0x05: // PSNS - Phase Sense
- return m_line_status; // active low -- but Human68k expects it to be zero?
- case 0x06: // SSTS - SPC Status
- return m_spc_status;
- case 0x07: // SERR - SPC Error Status
- /* #define SERR_SCSI_PAR 0x80
- #define SERR_SPC_PAR 0x40
- #define SERR_TC_PAR 0x08
- #define SERR_PHASE_ERR 0x04
- #define SERR_SHORT_XFR 0x02
- #define SERR_OFFSET 0x01*/
- return 0;
- case 0x08: // PCTL - Phase Control
- return ((m_busfree_int_enable) ? (m_line_status & 0x07) | 0x80 : (m_line_status & 0x07));
- case 0x0a: // DREG - Data register (for data transfers)
- if(m_spc_status & SSTS_XFER_IN_PROGRESS)
- {
- m_data = m_buffer[m_transfer_index % 512];
- m_transfer_index++;
- m_transfer_count--;
- if(m_transfer_index % 512 == 0)
- read_data(m_buffer, 512);
- if(m_transfer_count == 0)
- {
- // End of transfer
- m_spc_status &= ~SSTS_XFER_IN_PROGRESS;
- m_spc_status |= SSTS_DREG_EMPTY;
- m_ints |= INTS_COMMAND_COMPLETE;
- if(m_int_enable != 0)
- m_irq_cb(1);
- if(m_phase == SCSI_PHASE_MESSAGE_IN)
- set_phase(SCSI_PHASE_BUS_FREE);
- else if(m_phase == SCSI_PHASE_DATAIN)
- set_phase(SCSI_PHASE_STATUS);
- }
- }
- return m_data;
- case 0x0b: // TEMP - Temporary
- logerror("mb89352: read temporary register.\n");
- return m_temp;
- case 0x0c: // TCH - Transfer Counter High
- return (m_transfer_count & 0x00ff0000) >> 16;
- case 0x0d: // TCM - Transfer Counter Mid
- return (m_transfer_count & 0x0000ff00) >> 8;
- case 0x0e: // TCL - Transfer Counter Low
- return (m_transfer_count & 0x000000ff);
- default:
- logerror("mb89352: read from register %02x\n",offset & 0x0f);
- }
- return 0xff;
-}
-
-WRITE8_MEMBER( mb89352_device::mb89352_w )
-{
- switch(offset & 0x0f)
- {
- case 0x00: // BDID - Bus Device ID
- m_bdid = data;
- m_spc_status &= ~SSTS_TARG_CONNECTED;
- m_spc_status |= SSTS_INIT_CONNECTED;
- logerror("mb89352: BDID set to %i\n",data);
- break;
- case 0x01: // SCTL - SPC Control
- if(data & 0x80) // reset and disable
- {
- device_reset();
- logerror("mb89352: SCTL: Reset and disable.\n");
- }
- if(data & 0x10)
- {
- m_arbit_enable = 1;
- logerror("mb89352: SCTL: Arbitration enabled.\n");
- }
- else
- m_arbit_enable = 0;
- if(data & 0x08)
- {
- m_parity_enable = 1;
- logerror("mb89352: SCTL: Parity enabled.\n");
- }
- else
- m_parity_enable = 0;
- if(data & 0x04)
- {
- m_sel_enable = 1;
- logerror("mb89352: SCTL: Selection enabled.\n");
- }
- else
- m_sel_enable = 0;
- if(data & 0x02)
- {
- m_resel_enable = 1;
- logerror("mb89352: SCTL: Reselection enabled.\n");
- }
- else
- m_resel_enable = 0;
- if(data & 0x01)
- {
- m_int_enable = 1;
- logerror("mb89352: SCTL: Interrupts enabled.\n");
- }
- else
- {
- m_int_enable = 0;
- logerror("mb89352: SCTL: Interrupts disabled.\n");
- }
- break;
- case 0x02: // SCMD - Command
- /* From NetBSD/x68k source
- #define SCMD_BUS_REL 0x00
- #define SCMD_SELECT 0x20
- #define SCMD_RST_ATN 0x40
- #define SCMD_SET_ATN 0x60
- #define SCMD_XFR 0x80
- #define SCMD_XFR_PAUSE 0xa0
- #define SCMD_RST_ACK 0xc0
- #define SCMD_SET_ACK 0xe0
- */
- m_scmd = data;
- switch((data & 0xe0) >> 5)
- {
- case 0x00:
- // Bus Free
- m_line_status = 0;
- m_spc_status &= ~SSTS_TARG_CONNECTED;
- m_spc_status &= ~SSTS_INIT_CONNECTED;
- m_spc_status &= ~SSTS_XFER_IN_PROGRESS;
- set_phase(SCSI_PHASE_BUS_FREE);
- if(m_busfree_int_enable)
- {
- if(m_int_enable != 0)
- m_irq_cb(1);
- }
- logerror("mb89352: SCMD: Bus free\n");
- break;
- case 0x01:
- // Selection
- m_target = m_temp;
- m_target &= ~(1 << m_bdid); // mask off the bit relating to initiator
- switch(m_target)
- {
- case 0x01: m_target = 0; break;
- case 0x02: m_target = 1; break;
- case 0x04: m_target = 2; break;
- case 0x08: m_target = 3; break;
- case 0x10: m_target = 4; break;
- case 0x20: m_target = 5; break;
- case 0x40: m_target = 6; break;
- case 0x80: m_target = 7; break;
- }
- if(m_sel_enable != 0)
- {
- //m_ints |= INTS_SELECTION;
- }
- select(m_target);
- set_phase(SCSI_PHASE_COMMAND); // straight to command phase, may need a delay between selection and command phases
- m_line_status |= MB89352_LINE_SEL;
- m_line_status |= MB89352_LINE_BSY;
- m_spc_status &= ~SSTS_TARG_CONNECTED;
- m_spc_status |= SSTS_INIT_CONNECTED;
- m_spc_status |= SSTS_SPC_BSY;
- m_ints |= INTS_COMMAND_COMPLETE;
- if(m_int_enable != 0)
- m_irq_cb(1);
- logerror("mb89352: SCMD: Selection (SCSI ID%i)\n",m_target);
- break;
- case 0x02: // Reset ATN
- m_line_status &= ~MB89352_LINE_ATN;
- logerror("mb89352: SCMD: Reset ATN\n");
- break;
- case 0x03: // Set ATN
- m_line_status |= MB89352_LINE_ATN;
- logerror("mb89352: SCMD: Set ATN\n");
- break;
- case 0x04: // Transfer
- m_transfer_index = 0;
- m_spc_status |= SSTS_XFER_IN_PROGRESS;
- if(m_phase == SCSI_PHASE_DATAIN) // if we are reading data...
- {
- m_spc_status &= ~SSTS_DREG_EMPTY; // DREG is no longer empty
- read_data(m_buffer, 512);
- }
- if(m_phase == SCSI_PHASE_MESSAGE_IN)
- {
- m_spc_status &= ~SSTS_DREG_EMPTY; // DREG is no longer empty
- m_data = 0;
- m_temp = 0x00;
- set_phase(SCSI_PHASE_BUS_FREE);
- m_spc_status &= ~SSTS_XFER_IN_PROGRESS;
- m_command_index = 0;
- }
- logerror("mb89352: SCMD: Start Transfer\n");
- break;
- case 0x05: // Transfer pause
- logerror("mb89352: SCMD: Pause Transfer\n");
- break;
- case 0x06: // reset REQ/ACK
- m_line_status &= ~MB89352_LINE_ACK;
- if(m_phase != SCSI_PHASE_BUS_FREE)
- {
- m_line_status |= MB89352_LINE_REQ;
- }
- else
- {
- m_spc_status &= ~SSTS_INIT_CONNECTED;
- m_spc_status &= ~SSTS_TARG_CONNECTED;
- m_spc_status &= ~SSTS_SPC_BSY;
- }
- logerror("mb89352: SCMD: Reset REQ/ACK\n");
- break;
- case 0x07: // set REQ/ACK
- m_line_status &= ~MB89352_LINE_REQ;
- m_line_status |= MB89352_LINE_ACK;
- logerror("mb89352: SCMD: Set REQ/ACK\n");
- if(m_phase == SCSI_PHASE_COMMAND)
- {
- m_command[m_command_index++] = m_temp; // temp register puts data onto the SCSI bus
- if(m_command_index >= get_scsi_cmd_len(m_command[0]))
- {
- int x;
- int phase;
- // execute SCSI command
- send_command(m_command, m_command_index);
- phase = get_phase();
- if(m_command[0] == 1) // Rezero Unit - not implemented in SCSI code
- set_phase(SCSI_PHASE_STATUS);
- else
- set_phase(phase);
- logerror("Command executed: ");
- for(x=0;x<m_command_index;x++)
- logerror(" %02x",m_command[x]);
- logerror("\n");
- }
- return;
- }
- if(m_phase == SCSI_PHASE_STATUS)
- {
- m_temp = get_status();
- set_phase(SCSI_PHASE_MESSAGE_IN);
- return;
- }
- if(m_phase == SCSI_PHASE_MESSAGE_IN)
- {
- m_temp = 0x00;
- set_phase(SCSI_PHASE_BUS_FREE);
- m_command_index = 0;
- return;
- }
- break;
- default:
- logerror("mb89352: SCMD: Unimplemented command %02x\n",(data & 0xe0) >> 5);
- break;
- }
- break;
- case 0x04: // INTS - Interrupt Sense
- m_ints &= ~data; // resets relevant status bits to zero
- m_irq_cb(0); // clear IRQ
- logerror("mb89352: Reset INTS status bits %02x\n",data);
- break;
- case 0x08: // PCTL - Phase control
- if((data & 0x80) == 0 && (m_phase == SCSI_PHASE_SELECT)) // if writing 0 to bit 7, selection phase is reset
- {
- m_ints &= ~INTS_SELECTION;
- m_target = 0;
- logerror("mb89352: PCTL selection cancelled\n");
- }
- // writing to the low 3 bits sets the phase
- if((m_phase & 0x07) != (data & 0x07))
- set_phase(data & 0x07);
- m_busfree_int_enable = data & 0x80;
- logerror("mb89352: PCTL write %02x\n",data);
- break;
- case 0x0a: // DREG - Data register
- if(m_phase == SCSI_PHASE_COMMAND)
- {
- m_command[m_command_index++] = data;
- if(m_command_index >= get_scsi_cmd_len(m_command[0]))
- {
- int x;
- int phase;
- // execute SCSI command
- send_command(m_command, m_command_index);
- phase = get_phase();
- if(m_command[0] == 1) // Rezero Unit - not implemented in SCSI code
- set_phase(SCSI_PHASE_STATUS);
- else
- set_phase(phase);
- logerror("Command executed: ");
- for(x=0;x<m_command_index;x++)
- logerror(" %02x",m_command[x]);
- logerror("\n");
- }
- return;
- }
- if(m_spc_status & SSTS_XFER_IN_PROGRESS)
- {
- m_buffer[m_transfer_index % 512] = data;
- m_spc_status |= SSTS_DREG_EMPTY; // DREG is empty once sent
- m_transfer_index++;
- m_transfer_count--;
- if(m_transfer_index % 512 == 0)
- write_data(m_buffer, 512);
- if(m_transfer_count == 0)
- {
- // End of transfer
- m_spc_status &= ~SSTS_XFER_IN_PROGRESS;
- m_spc_status |= SSTS_DREG_EMPTY;
- m_ints |= INTS_COMMAND_COMPLETE;
- if(m_int_enable != 0)
- m_irq_cb(1);
- set_phase(SCSI_PHASE_STATUS);
- }
- }
- break;
- case 0x0b: // TEMP - Temporary
- m_temp = data;
- logerror("mb89352: Write %02x to temporary register\n",data);
- break;
- case 0x0c: // TCH - Transfer Counter High
- m_transfer_count = (m_transfer_count & 0x0000ffff) | (data << 16);
- if(m_transfer_count == 0)
- m_spc_status |= SSTS_TC_ZERO;
- else
- m_spc_status &= ~SSTS_TC_ZERO;
- logerror("mb89352: TCH: Write %02x [%06x]\n",data,m_transfer_count);
- break;
- case 0x0d: // TCM - Transfer Counter Mid
- m_transfer_count = (m_transfer_count & 0x00ff00ff) | (data << 8);
- if(m_transfer_count == 0)
- m_spc_status |= SSTS_TC_ZERO;
- else
- m_spc_status &= ~SSTS_TC_ZERO;
- logerror("mb89352: TCM: Write %02x [%06x]\n",data,m_transfer_count);
- break;
- case 0x0e: // TCL - Transfer Counter Low
- m_transfer_count = (m_transfer_count & 0x00ffff00) | data;
- if(m_transfer_count == 0)
- m_spc_status |= SSTS_TC_ZERO;
- else
- m_spc_status &= ~SSTS_TC_ZERO;
- logerror("mb89352: TCL: Write %02x [%06x]\n",data,m_transfer_count);
- break;
- default:
- logerror("mb89352: write %02x to register %02x\n",data,offset & 0x0f);
- }
-}
diff --git a/src/emu/machine/mb89352.h b/src/emu/machine/mb89352.h
deleted file mode 100644
index 05776ca4e34..00000000000
--- a/src/emu/machine/mb89352.h
+++ /dev/null
@@ -1,118 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Barry Rodewald
-/*
- * mb89352.h
- *
- * Created on: 16/01/2011
- */
-
-#ifndef MB89352_H_
-#define MB89352_H_
-
-#include "legscsi.h"
-
-// SCSI lines readable via PSNS register (reg 5)
-#define MB89352_LINE_REQ 0x80
-#define MB89352_LINE_ACK 0x40
-#define MB89352_LINE_ATN 0x20
-#define MB89352_LINE_SEL 0x10
-#define MB89352_LINE_BSY 0x08
-#define MB89352_LINE_MSG 0x04
-#define MB89352_LINE_CD 0x02
-#define MB89352_LINE_IO 0x01
-
-// INTS bits
-#define INTS_RESET 0x01
-#define INTS_HARD_ERROR 0x02
-#define INTS_TIMEOUT 0x04
-#define INTS_SERVICE_REQUIRED 0x08
-#define INTS_COMMAND_COMPLETE 0x10
-#define INTS_DISCONNECTED 0x20
-#define INTS_RESELECTION 0x40
-#define INTS_SELECTION 0x80
-
-// SSTS status bits
-#define SSTS_DREG_EMPTY 0x01
-#define SSTS_DREG_FULL 0x02
-#define SSTS_TC_ZERO 0x04
-#define SSTS_SCSI_RST 0x08
-#define SSTS_XFER_IN_PROGRESS 0x10
-#define SSTS_SPC_BSY 0x20
-#define SSTS_TARG_CONNECTED 0x40
-#define SSTS_INIT_CONNECTED 0x80
-
-// SERR error status bits
-#define SERR_OFFSET 0x01
-#define SERR_SHORT_XFR 0x02
-#define SERR_PHASE_ERR 0x04
-#define SERR_TC_PAR 0x08
-#define SERR_SPC_PAR 0x40
-#define SERR_SCSI_PAR 0x80
-
-
-#define MCFG_MB89352A_IRQ_CB(_devcb) \
- devcb = &mb89352_device::set_irq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MB89352A_DRQ_CB(_devcb) \
- devcb = &mb89352_device::set_drq_callback(*device, DEVCB_##_devcb);
-
-class mb89352_device : public legacy_scsi_host_adapter
-{
-public:
- // construction/destruction
- mb89352_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<mb89352_device &>(device).m_irq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_drq_callback(device_t &device, _Object object) { return downcast<mb89352_device &>(device).m_drq_cb.set_callback(object); }
-
- // any publically accessible interfaces needed for runtime
- DECLARE_READ8_MEMBER( mb89352_r );
- DECLARE_WRITE8_MEMBER( mb89352_w );
-
- void set_phase(int phase);
-
-protected:
- // device-level overrides (none are required, but these are common)
- virtual void device_start();
- virtual void device_reset();
- virtual void device_stop();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- // internal device state goes here
- static const device_timer_id TIMER_TRANSFER = 0;
-
- int get_scsi_cmd_len(UINT8 cbyte);
- //void set_ints(UINT8 flag);
-
- devcb_write_line m_irq_cb; /* irq callback */
- devcb_write_line m_drq_cb; /* drq callback */
-
- UINT8 m_phase; // current SCSI phase
- UINT8 m_target; // current SCSI target
- UINT8 m_bdid; // Bus device ID (SCSI ID of the bus?)
- UINT8 m_ints; // Interrupt Sense
- UINT8 m_temp; // Temporary register (To/From SCSI bus)
- UINT8 m_data; // Data register
- UINT8 m_scmd; // SPC Command register
- UINT32 m_transfer_count; // byte transfer counter, also used as a timeout counter for selection.
- UINT8 m_int_enable;
- UINT8 m_sel_enable;
- UINT8 m_resel_enable;
- UINT8 m_parity_enable;
- UINT8 m_arbit_enable;
- UINT8 m_busfree_int_enable;
- UINT8 m_line_status;
- UINT8 m_spc_status;
- UINT8 m_error_status;
- UINT8 m_command_index;
- UINT8 m_command[16];
- UINT32 m_transfer_index;
- UINT8 m_buffer[512];
-
- emu_timer* m_transfer_timer;
-};
-
-extern const device_type MB89352A;
-
-#endif /* MB89352_H_ */
diff --git a/src/emu/machine/mb89363b.c b/src/emu/machine/mb89363b.c
deleted file mode 100644
index 2e4f210a865..00000000000
--- a/src/emu/machine/mb89363b.c
+++ /dev/null
@@ -1,181 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/*
- (this acts as a trampoline to 2x i8255 chips)
-
-
- Manufacturer: Fujitsu
- Part Number: MB89363 / MB89363B / MB89363R
- Package: Surface Mount QFP80 / QFP64P (MB89363R)
- Description: 8-bit x 3 x 2 (6 x 8-bit) parallel data I/O port VLSI chip
- Parallel Communication Interface
- Extended I/O
-
- Note: MB89363B is compatible with 8255
-
- Pin Assignment:
- +5v
- P P P P P P P P P V P P P P P P P P P
- N N 5 4 4 4 4 4 4 4 4 C N 1 1 1 1 1 1 1 1 2 N N
- C C 3 0 1 2 3 4 5 6 7 C C 7 6 5 4 3 2 1 0 3 C C
-
- | | ^ ^ ^ ^ ^ ^ ^ ^ ^ | | ^ ^ ^ ^ ^ ^ ^ ^ ^ | |
- | | | | | | | | | | | | | | | | | | | | | | | |
- | | v v v v v v v v v | | v v v v v v v v v | |
- .-------------------------------------------------------.
- | 6 6 6 6 6 5 5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 |
- | 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 |
- P52 <-> | 65 40 | <-> P22
- P51 <-> | 66 39 | <-> P21
- P50 <-> | 67 38 | <-> P20
- P54 <-> | 68 37 | <-> P24
- P55 <-> | 69 36 | <-> P25
- P56 <-> | 70 35 | <-> P26
- P57 <-> | 71 34 | <-> P27
- NC --- | 72 MB89363B 33 | --- NC
- NC --- | 73 32 | <-- RSLCT1
- GND --> | 74 31 | <-- RSLCT0
- CS2 --> | 75 30 | <-- GND
- R --> | 76 29 | <-- CS1
- P30 <-> | 77 28 | <-> P00
- P31 <-> | 78 27 | <-> P01
- P32 <-> | 79 26 | <-> P02
- P33 <-> | 80 25 | <-> P03
- \ 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 |
- \ 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 |
- -----------------------------------------------------'
- ^ ^ ^ ^ ^ ^ | | ^ | ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ |
- | | | | | | | | | | | | | | | | | | | | | | | |
- v v v v | | | | | | | v v v v v v v v v v v v |
-
- P P P P W R N N R N O D D D D D D D D P P P P N
- 3 3 3 3 S C C H C U B B B B B B B B 0 0 0 0 C
- 4 5 6 7 T / S 0 1 2 3 4 5 6 7 7 6 5 4
- R /
- L I
- N
- S
-
- Block Diagram / Pin Descriptions:
- http://www.mess.org/_media/datasheets/fujitsu/mb89363b_partial.pdf
-
- D.C. Characteristics:
- (Recommended operating conditions unless otherwise noted)
- (VCC = +5V +- 10%, GND = 0V, TA = -40o C to 85o C)
- Value
- Parameter Symbol Min Max Unit Test Condition
- ----------------------------------------------------------------------------------
- Input Low Voltage ViL -0.3 0.8 V
- Input High Voltage ViH 2.2 VCC +0.3 V
- Output Low Voltage VoL - 0.4 V IoL = 2.5mA
- Output High Voltage VoH 3.0 - V IoH =-2.5mA
-
- Sources:
- http://www.emb-tech.co.jp/pc104/96dio.pdf
- http://www.pb5800.com/resources/2350ser01.pdf
- http://www.diagramasde.com/diagramas/otros2/TS-850S%20Service%20Manual%20.pdf
-*/
-
-#include "emu.h"
-#include "machine/mb89363b.h"
-
-
-
-extern const device_type MB89363B = &device_creator<mb89363b_device>;
-
-
-mb89363b_device::mb89363b_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MB89363B, "MB89363 I/O", tag, owner, clock, "mb89363b", __FILE__),
- m_i8255_a(*this, "i8255_a"),
- m_i8255_b(*this, "i8255_b"),
- m_in_a_pa_cb(*this),
- m_in_a_pb_cb(*this),
- m_in_a_pc_cb(*this),
- m_out_a_pa_cb(*this),
- m_out_a_pb_cb(*this),
- m_out_a_pc_cb(*this),
- m_in_b_pa_cb(*this),
- m_in_b_pb_cb(*this),
- m_in_b_pc_cb(*this),
- m_out_b_pa_cb(*this),
- m_out_b_pb_cb(*this),
- m_out_b_pc_cb(*this)
-{
-}
-
-
-READ8_MEMBER(mb89363b_device::i8255_a_port_a_r) { return m_in_a_pa_cb(space, offset); }
-READ8_MEMBER(mb89363b_device::i8255_a_port_b_r) { return m_in_a_pb_cb(space, offset); }
-READ8_MEMBER(mb89363b_device::i8255_a_port_c_r) { return m_in_a_pc_cb(space, offset); }
-WRITE8_MEMBER(mb89363b_device::i8255_a_port_a_w) { m_out_a_pa_cb(space, offset, data); }
-WRITE8_MEMBER(mb89363b_device::i8255_a_port_b_w) { m_out_a_pb_cb(space, offset, data); }
-WRITE8_MEMBER(mb89363b_device::i8255_a_port_c_w) { m_out_a_pc_cb(space, offset, data); }
-READ8_MEMBER(mb89363b_device::i8255_b_port_a_r) { return m_in_b_pa_cb(space, offset); }
-READ8_MEMBER(mb89363b_device::i8255_b_port_b_r) { return m_in_b_pb_cb(space, offset); }
-READ8_MEMBER(mb89363b_device::i8255_b_port_c_r) { return m_in_b_pc_cb(space, offset); }
-WRITE8_MEMBER(mb89363b_device::i8255_b_port_a_w) { m_out_b_pa_cb(space, offset, data); }
-WRITE8_MEMBER(mb89363b_device::i8255_b_port_b_w) { m_out_b_pb_cb(space, offset, data); }
-WRITE8_MEMBER(mb89363b_device::i8255_b_port_c_w) { m_out_b_pc_cb(space, offset, data); }
-
-
-READ8_MEMBER( mb89363b_device::read )
-{
- if (offset & 4)
- return m_i8255_b->read(space, offset & 3);
- else
- return m_i8255_a->read(space, offset & 3);
-}
-
-WRITE8_MEMBER( mb89363b_device::write )
-{
- if (offset & 4)
- m_i8255_b->write(space, offset & 3, data);
- else
- m_i8255_a->write(space, offset & 3, data);
-}
-
-
-static MACHINE_CONFIG_FRAGMENT( mb89363b )
- MCFG_DEVICE_ADD("i8255_a", I8255, 0)
- MCFG_I8255_IN_PORTA_CB(READ8(mb89363b_device, i8255_a_port_a_r))
- MCFG_I8255_IN_PORTB_CB(READ8(mb89363b_device, i8255_a_port_b_r))
- MCFG_I8255_IN_PORTC_CB(READ8(mb89363b_device, i8255_a_port_c_r))
- MCFG_I8255_OUT_PORTA_CB(WRITE8(mb89363b_device, i8255_a_port_a_w))
- MCFG_I8255_OUT_PORTB_CB(WRITE8(mb89363b_device, i8255_a_port_b_w))
- MCFG_I8255_OUT_PORTC_CB(WRITE8(mb89363b_device, i8255_a_port_c_w))
-
- MCFG_DEVICE_ADD("i8255_b", I8255, 0)
- MCFG_I8255_IN_PORTA_CB(READ8(mb89363b_device, i8255_b_port_a_r))
- MCFG_I8255_IN_PORTB_CB(READ8(mb89363b_device, i8255_b_port_b_r))
- MCFG_I8255_IN_PORTC_CB(READ8(mb89363b_device, i8255_b_port_c_r))
- MCFG_I8255_OUT_PORTA_CB(WRITE8(mb89363b_device, i8255_b_port_a_w))
- MCFG_I8255_OUT_PORTB_CB(WRITE8(mb89363b_device, i8255_b_port_b_w))
- MCFG_I8255_OUT_PORTC_CB(WRITE8(mb89363b_device, i8255_b_port_c_w))
-MACHINE_CONFIG_END
-
-machine_config_constructor mb89363b_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( mb89363b );
-}
-
-void mb89363b_device::device_start()
-{
- m_in_a_pa_cb.resolve_safe(0xff);
- m_in_a_pb_cb.resolve_safe(0xff);
- m_in_a_pc_cb.resolve_safe(0xff);
- m_out_a_pa_cb.resolve_safe();
- m_out_a_pb_cb.resolve_safe();
- m_out_a_pc_cb.resolve_safe();
-
- m_in_b_pa_cb.resolve_safe(0xff);
- m_in_b_pb_cb.resolve_safe(0xff);
- m_in_b_pc_cb.resolve_safe(0xff);
- m_out_b_pa_cb.resolve_safe();
- m_out_b_pb_cb.resolve_safe();
- m_out_b_pc_cb.resolve_safe();
-
-}
-
-void mb89363b_device::device_reset()
-{
-}
diff --git a/src/emu/machine/mb89363b.h b/src/emu/machine/mb89363b.h
deleted file mode 100644
index e29f75fda41..00000000000
--- a/src/emu/machine/mb89363b.h
+++ /dev/null
@@ -1,134 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/***************************************************************************
-
- Fujitsu MB89363 Parallel Communication Interface
- (this acts as a trampoline to 2x i8255 chips)
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __MB89363B__
-#define __MB89363B__
-
-
-#include "machine/i8255.h"
-
-
-extern const device_type MB89363B;
-
-#define MCFG_MB89363B_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, MB89363B, 0)
-
-
-
-#define MCFG_MB89363B_IN_PORTA_CB(_devcb) \
- devcb = &mb89363b_device::set_in_a_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MB89363B_IN_PORTB_CB(_devcb) \
- devcb = &mb89363b_device::set_in_a_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MB89363B_IN_PORTC_CB(_devcb) \
- devcb = &mb89363b_device::set_in_a_pc_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MB89363B_OUT_PORTA_CB(_devcb) \
- devcb = &mb89363b_device::set_out_a_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MB89363B_OUT_PORTB_CB(_devcb) \
- devcb = &mb89363b_device::set_out_a_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MB89363B_OUT_PORTC_CB(_devcb) \
- devcb = &mb89363b_device::set_out_a_pc_callback(*device, DEVCB_##_devcb);
-
-
-#define MCFG_MB89363B_IN_PORTD_CB(_devcb) \
- devcb = &mb89363b_device::set_in_b_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MB89363B_IN_PORTE_CB(_devcb) \
- devcb = &mb89363b_device::set_in_b_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MB89363B_IN_PORTF_CB(_devcb) \
- devcb = &mb89363b_device::set_in_b_pc_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MB89363B_OUT_PORTD_CB(_devcb) \
- devcb = &mb89363b_device::set_out_b_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MB89363B_OUT_PORTE_CB(_devcb) \
- devcb = &mb89363b_device::set_out_b_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MB89363B_OUT_PORTF_CB(_devcb) \
- devcb = &mb89363b_device::set_out_b_pc_callback(*device, DEVCB_##_devcb);
-
-
-
-class mb89363b_device : public device_t
-{
-public:
- // construction/destruction
- mb89363b_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- DECLARE_READ8_MEMBER(i8255_a_port_a_r);
- DECLARE_READ8_MEMBER(i8255_a_port_b_r);
- DECLARE_READ8_MEMBER(i8255_a_port_c_r);
- DECLARE_WRITE8_MEMBER(i8255_a_port_a_w);
- DECLARE_WRITE8_MEMBER(i8255_a_port_b_w);
- DECLARE_WRITE8_MEMBER(i8255_a_port_c_w);
- DECLARE_READ8_MEMBER(i8255_b_port_a_r);
- DECLARE_READ8_MEMBER(i8255_b_port_b_r);
- DECLARE_READ8_MEMBER(i8255_b_port_c_r);
- DECLARE_WRITE8_MEMBER(i8255_b_port_a_w);
- DECLARE_WRITE8_MEMBER(i8255_b_port_b_w);
- DECLARE_WRITE8_MEMBER(i8255_b_port_c_w);
-
-
- template<class _Object> static devcb_base &set_in_a_pa_callback(device_t &device, _Object object) { return downcast<mb89363b_device &>(device).m_in_a_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_a_pb_callback(device_t &device, _Object object) { return downcast<mb89363b_device &>(device).m_in_a_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_a_pc_callback(device_t &device, _Object object) { return downcast<mb89363b_device &>(device).m_in_a_pc_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_a_pa_callback(device_t &device, _Object object) { return downcast<mb89363b_device &>(device).m_out_a_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_a_pb_callback(device_t &device, _Object object) { return downcast<mb89363b_device &>(device).m_out_a_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_a_pc_callback(device_t &device, _Object object) { return downcast<mb89363b_device &>(device).m_out_a_pc_cb.set_callback(object); }
-
- template<class _Object> static devcb_base &set_in_b_pa_callback(device_t &device, _Object object) { return downcast<mb89363b_device &>(device).m_in_b_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_b_pb_callback(device_t &device, _Object object) { return downcast<mb89363b_device &>(device).m_in_b_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_b_pc_callback(device_t &device, _Object object) { return downcast<mb89363b_device &>(device).m_in_b_pc_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_b_pa_callback(device_t &device, _Object object) { return downcast<mb89363b_device &>(device).m_out_b_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_b_pb_callback(device_t &device, _Object object) { return downcast<mb89363b_device &>(device).m_out_b_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_b_pc_callback(device_t &device, _Object object) { return downcast<mb89363b_device &>(device).m_out_b_pc_cb.set_callback(object); }
-
-
- required_device<i8255_device> m_i8255_a;
- required_device<i8255_device> m_i8255_b;
-
-protected:
- virtual machine_config_constructor device_mconfig_additions() const;
- virtual void device_start();
- virtual void device_reset();
-
-
-
-private:
-
- devcb_read8 m_in_a_pa_cb;
- devcb_read8 m_in_a_pb_cb;
- devcb_read8 m_in_a_pc_cb;
-
- devcb_write8 m_out_a_pa_cb;
- devcb_write8 m_out_a_pb_cb;
- devcb_write8 m_out_a_pc_cb;
-
- devcb_read8 m_in_b_pa_cb;
- devcb_read8 m_in_b_pb_cb;
- devcb_read8 m_in_b_pc_cb;
-
- devcb_write8 m_out_b_pa_cb;
- devcb_write8 m_out_b_pb_cb;
- devcb_write8 m_out_b_pc_cb;
-
-
-};
-
-#endif
diff --git a/src/emu/machine/mb89371.c b/src/emu/machine/mb89371.c
deleted file mode 100644
index 1188f295725..00000000000
--- a/src/emu/machine/mb89371.c
+++ /dev/null
@@ -1,31 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
- * MB89371
- *
- * Fujitsu
- * Dual Serial UART
- *
- */
-
-#include "mb89371.h"
-
-const device_type MB89371 = &device_creator<mb89371_device>;
-
-mb89371_device::mb89371_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
- : device_t(mconfig, MB89371, "MB89371 Dual Serial UART", tag, owner, clock, "mb89371", __FILE__)
-{
-}
-
-void mb89371_device::device_start()
-{
-}
-
-WRITE8_MEMBER(mb89371_device::write)
-{
-}
-
-READ8_MEMBER(mb89371_device::read)
-{
- return 0xff;
-}
diff --git a/src/emu/machine/mb89371.h b/src/emu/machine/mb89371.h
deleted file mode 100644
index 2f0aa11fc4f..00000000000
--- a/src/emu/machine/mb89371.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
- * MB89371
- *
- * Fujitsu
- * Dual Serial UART
- *
- */
-
-#ifndef __MB89371_H__
-#define __MB89371_H__
-
-#include "emu.h"
-
-class mb89371_device : public device_t
-{
-public:
- // construction/destruction
- mb89371_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_READ8_MEMBER( read );
-
-protected:
-
- // device-level overrides
- virtual void device_start();
-};
-
-
-// device type definition
-extern const device_type MB89371;
-
-#endif
diff --git a/src/emu/machine/mc146818.c b/src/emu/machine/mc146818.c
deleted file mode 100644
index 6639710cec6..00000000000
--- a/src/emu/machine/mc146818.c
+++ /dev/null
@@ -1,593 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/*********************************************************************
-
- mc146818.c
-
- Implementation of the MC146818 chip
-
- Real time clock chip with CMOS battery backed ram
- Used in IBM PC/AT, several PC clones, Amstrad NC200, Apollo workstations
-
-*********************************************************************/
-
-#include "coreutil.h"
-#include "machine/mc146818.h"
-
-
-//**************************************************************************
-// DEBUGGING
-//**************************************************************************
-
-#define LOG_MC146818 0
-
-
-
-// device type definition
-const device_type MC146818 = &device_creator<mc146818_device>;
-
-//-------------------------------------------------
-// mc146818_device - constructor
-//-------------------------------------------------
-
-mc146818_device::mc146818_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MC146818, "MC146818 RTC", tag, owner, clock, "mc146818", __FILE__),
- device_nvram_interface(mconfig, *this),
- m_index(0),
- m_last_refresh(attotime::zero),
- m_write_irq(*this),
- m_century_index(-1),
- m_use_utc(false)
-{
-}
-
-mc146818_device::mc146818_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_nvram_interface(mconfig, *this),
- m_index(0),
- m_last_refresh(attotime::zero),
- m_write_irq(*this),
- m_century_index(-1),
- m_use_utc(false)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mc146818_device::device_start()
-{
- m_data.resize(data_size());
- m_last_refresh = machine().time();
- m_clock_timer = timer_alloc(TIMER_CLOCK);
- m_periodic_timer = timer_alloc(TIMER_PERIODIC);
-
- m_write_irq.resolve_safe();
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mc146818_device::device_reset()
-{
- m_data[REG_B] &= ~(REG_B_UIE | REG_B_AIE | REG_B_PIE | REG_B_SQWE);
- m_data[REG_C] = 0;
-
- update_irq();
-}
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void mc146818_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_PERIODIC:
- m_data[REG_C] |= REG_C_PF;
- update_irq();
- break;
-
- case TIMER_CLOCK:
- if (!(m_data[REG_B] & REG_B_SET))
- {
- /// TODO: find out how the real chip deals with updates when binary/bcd values are already outside the normal range
- int seconds = get_seconds() + 1;
- if (seconds < 60)
- {
- set_seconds(seconds);
- }
- else
- {
- set_seconds(0);
-
- int minutes = get_minutes() + 1;
- if (minutes < 60)
- {
- set_minutes(minutes);
- }
- else
- {
- set_minutes(0);
-
- int hours = get_hours() + 1;
- if (hours < 24)
- {
- set_hours(hours);
- }
- else
- {
- set_hours(0);
-
- int dayofweek = get_dayofweek() + 1;
- if (dayofweek <= 7)
- {
- set_dayofweek(dayofweek);
- }
- else
- {
- set_dayofweek(1);
- }
-
- int dayofmonth = get_dayofmonth() + 1;
- if (dayofmonth <= gregorian_days_in_month(get_month(), get_year() + 2000))
- {
- set_dayofmonth(dayofmonth);
- }
- else
- {
- set_dayofmonth(1);
-
- int month = get_month() + 1;
- if (month <= 12)
- {
- set_month(month);
- }
- else
- {
- set_month(1);
-
- set_year((get_year() + 1) % 100);
- }
- }
- }
- }
- }
-
- if ((m_data[REG_ALARM_SECONDS] == m_data[REG_SECONDS] || (m_data[REG_ALARM_SECONDS] & ALARM_DONTCARE) == ALARM_DONTCARE) &&
- (m_data[REG_ALARM_MINUTES] == m_data[REG_MINUTES] || (m_data[REG_ALARM_MINUTES] & ALARM_DONTCARE) == ALARM_DONTCARE) &&
- (m_data[REG_ALARM_HOURS] == m_data[REG_HOURS] || (m_data[REG_ALARM_HOURS] & ALARM_DONTCARE) == ALARM_DONTCARE))
- {
- // set the alarm interrupt flag AF
- m_data[REG_C] |= REG_C_AF;
- }
-
- // set the update-ended interrupt Flag UF
- m_data[REG_C] |= REG_C_UF;
- update_irq();
-
- m_last_refresh = machine().time();
- }
- break;
- }
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void mc146818_device::nvram_default()
-{
- // populate from a memory region if present
- if (m_region != NULL)
- {
- UINT32 bytes = m_region->bytes();
-
- if (bytes > data_size())
- bytes = data_size();
-
- memcpy(&m_data[0], m_region->base(), bytes);
- }
- else
- {
- memset(&m_data[0], 0, data_size());
- }
-
- set_base_datetime();
- update_timer();
- update_irq();
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void mc146818_device::nvram_read(emu_file &file)
-{
- file.read(&m_data[0], data_size());
-
- set_base_datetime();
- update_timer();
- update_irq();
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void mc146818_device::nvram_write(emu_file &file)
-{
- file.write(&m_data[0], data_size());
-}
-
-
-//-------------------------------------------------
-// to_ram - convert value to current ram format
-//-------------------------------------------------
-
-int mc146818_device::to_ram(int a)
-{
- if (!(m_data[REG_B] & REG_B_DM))
- return dec_2_bcd(a);
-
- return a;
-}
-
-
-//-------------------------------------------------
-// from_ram - convert value from current ram format
-//-------------------------------------------------
-
-int mc146818_device::from_ram(int a)
-{
- if (!(m_data[REG_B] & REG_B_DM))
- return bcd_2_dec(a);
-
- return a;
-}
-
-
-int mc146818_device::get_seconds()
-{
- return from_ram(m_data[REG_SECONDS]);
-}
-
-void mc146818_device::set_seconds(int seconds)
-{
- m_data[REG_SECONDS] = to_ram(seconds);
-}
-
-int mc146818_device::get_minutes()
-{
- return from_ram(m_data[REG_MINUTES]);
-}
-
-void mc146818_device::set_minutes(int minutes)
-{
- m_data[REG_MINUTES] = to_ram(minutes);
-}
-
-int mc146818_device::get_hours()
-{
- if (!(m_data[REG_B] & REG_B_24_12))
- {
- int hours = from_ram(m_data[REG_HOURS] & ~HOURS_PM);
-
- if (hours == 12)
- {
- hours = 0;
- }
-
- if (m_data[REG_HOURS] & HOURS_PM)
- {
- hours += 12;
- }
-
- return hours;
- }
- else
- {
- return from_ram(m_data[REG_HOURS]);
- }
-}
-
-void mc146818_device::set_hours(int hours)
-{
- if (!(m_data[REG_B] & REG_B_24_12))
- {
- int pm = 0;
-
- if (hours >= 12)
- {
- hours -= 12;
- pm = HOURS_PM;
- }
-
- if (hours == 0)
- {
- hours = 12;
- }
-
- m_data[REG_HOURS] = to_ram(hours) | pm;
- }
- else
- {
- m_data[REG_HOURS] = to_ram(hours);
- }
-}
-
-int mc146818_device::get_dayofweek()
-{
- return from_ram(m_data[REG_DAYOFWEEK]);
-}
-
-void mc146818_device::set_dayofweek(int dayofweek)
-{
- m_data[REG_DAYOFWEEK] = to_ram(dayofweek);
-}
-
-int mc146818_device::get_dayofmonth()
-{
- return from_ram(m_data[REG_DAYOFMONTH]);
-}
-
-void mc146818_device::set_dayofmonth(int dayofmonth)
-{
- m_data[REG_DAYOFMONTH] = to_ram(dayofmonth);
-}
-
-int mc146818_device::get_month()
-{
- return from_ram(m_data[REG_MONTH]);
-}
-
-void mc146818_device::set_month(int month)
-{
- m_data[REG_MONTH] = to_ram(month);
-}
-
-int mc146818_device::get_year()
-{
- return from_ram(m_data[REG_YEAR]);
-}
-
-void mc146818_device::set_year(int year)
-{
- m_data[REG_YEAR] = to_ram(year);
-}
-
-
-
-//-------------------------------------------------
-// set_base_datetime - update clock with real time
-//-------------------------------------------------
-
-void mc146818_device::set_base_datetime()
-{
- system_time systime;
- system_time::full_time current_time;
-
- machine().base_datetime(systime);
-
- current_time = (m_use_utc) ? systime.utc_time: systime.local_time;
-
-// logerror("mc146818_set_base_datetime %02d/%02d/%02d %02d:%02d:%02d\n",
-// current_time.year % 100, current_time.month + 1, current_time.mday,
-// current_time.hour,current_time.minute, current_time.second);
-
- set_seconds(current_time.second);
- set_minutes(current_time.minute);
- set_hours(current_time.hour);
- set_dayofweek(current_time.weekday + 1);
- set_dayofmonth(current_time.mday);
- set_month(current_time.month + 1);
- set_year(current_time.year % 100);
-
- if (m_century_index >= 0)
- m_data[m_century_index] = to_ram(current_time.year / 100);
-}
-
-
-//-------------------------------------------------
-// update_timer - update timer based on A register
-//-------------------------------------------------
-
-void mc146818_device::update_timer()
-{
- int bypass;
-
- switch (m_data[REG_A] & (REG_A_DV2 | REG_A_DV1 | REG_A_DV0))
- {
- case 0:
- bypass = 0;
- break;
-
- case REG_A_DV0:
- bypass = 2;
- break;
-
- case REG_A_DV1:
- bypass = 7;
- break;
-
- case REG_A_DV2 | REG_A_DV1:
- case REG_A_DV2 | REG_A_DV1 | REG_A_DV0:
- bypass = 22;
- break;
-
- default:
- // TODO: other combinations of divider bits are used for test purposes only
- bypass = 22;
- break;
- }
-
-
- attotime update_period = attotime::never;
- attotime update_interval = attotime::never;
- attotime periodic_period = attotime::never;
- attotime periodic_interval = attotime::never;
-
- if (bypass < 22)
- {
- int shift = 22 - bypass;
-
- double update_hz = (double) clock() / (1 << shift);
-
- // TODO: take the time since last timer into account
- update_period = attotime::from_hz(update_hz * 2);
- update_interval = attotime::from_hz(update_hz);
-
- int rate_select = m_data[REG_A] & (REG_A_RS3 | REG_A_RS2 | REG_A_RS1 | REG_A_RS0);
- if (rate_select != 0)
- {
- shift = (rate_select + 6) - bypass;
- if (shift <= 1)
- shift += 7;
-
- double periodic_hz = (double) clock() / (1 << shift);
-
- // TODO: take the time since last timer into account
- periodic_period = attotime::from_hz(periodic_hz * 2);
- periodic_interval = attotime::from_hz(periodic_hz);
- }
- }
-
- m_clock_timer->adjust(update_period, 0, update_interval);
- m_periodic_timer->adjust(periodic_period, 0, periodic_interval);
-}
-
-
-//-------------------------------------------------
-// update_irq - Update irq based on B & C register
-//-------------------------------------------------
-
-void mc146818_device::update_irq()
-{
- // IRQ line is active low
- if (((m_data[REG_C] & REG_C_UF) && (m_data[REG_B] & REG_B_UIE)) ||
- ((m_data[REG_C] & REG_C_AF) && (m_data[REG_B] & REG_B_AIE)) ||
- ((m_data[REG_C] & REG_C_PF) && (m_data[REG_B] & REG_B_PIE)))
- {
- m_data[REG_C] |= REG_C_IRQF;
- m_write_irq(CLEAR_LINE);
- }
- else
- {
- m_data[REG_C] &= REG_C_IRQF;
- m_write_irq(ASSERT_LINE);
- }
-}
-
-
-
-//-------------------------------------------------
-// read - I/O handler for reading
-//-------------------------------------------------
-
-READ8_MEMBER( mc146818_device::read )
-{
- UINT8 data = 0;
- switch (offset)
- {
- case 0:
- data = m_index;
- break;
-
- case 1:
- switch (m_index)
- {
- case REG_A:
- data = m_data[REG_A];
- // Update In Progress (UIP) time for 32768 Hz is 244+1984usec
- /// TODO: support other dividers
- /// TODO: don't set this if update is stopped
- if ((space.machine().time() - m_last_refresh) < attotime::from_usec(244+1984))
- data |= REG_A_UIP;
- break;
-
- case REG_C:
- // the unused bits b0 ... b3 are always read as 0
- data = m_data[REG_C] & (REG_C_IRQF | REG_C_PF | REG_C_AF | REG_C_UF);
- // read 0x0c will clear all IRQ flags in register 0x0c
- m_data[REG_C] &= ~(REG_C_IRQF | REG_C_PF | REG_C_AF | REG_C_UF);
- update_irq();
- break;
-
- case REG_D:
- /* battery ok */
- data = m_data[REG_D] | REG_D_VRT;
- break;
-
- default:
- data = m_data[m_index];
- break;
- }
- break;
- }
-
- if (LOG_MC146818)
- logerror("mc146818_port_r(): index=0x%02x data=0x%02x\n", m_index, data);
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write - I/O handler for writing
-//-------------------------------------------------
-
-WRITE8_MEMBER( mc146818_device::write )
-{
- if (LOG_MC146818)
- logerror("mc146818_port_w(): index=0x%02x data=0x%02x\n", m_index, data);
-
- switch (offset)
- {
- case 0:
- m_index = data % data_size();
- break;
-
- case 1:
- switch (m_index)
- {
- case REG_SECONDS:
- // top bit of SECONDS is read only
- m_data[REG_SECONDS] = data & ~0x80;
- break;
-
- case REG_A:
- // top bit of A is read only
- m_data[REG_A] = data & ~REG_A_UIP;
- update_timer();
- break;
-
- case REG_B:
- if ((data & REG_B_SET) && !(m_data[REG_B] & REG_B_SET))
- data &= ~REG_B_UIE;
-
- m_data[REG_B] = data;
- update_irq();
- break;
-
- case REG_C:
- case REG_D:
- // register C & D is readonly
- break;
-
- default:
- m_data[m_index] = data;
- break;
- }
- break;
- }
-}
diff --git a/src/emu/machine/mc146818.h b/src/emu/machine/mc146818.h
deleted file mode 100644
index 3db19ec533e..00000000000
--- a/src/emu/machine/mc146818.h
+++ /dev/null
@@ -1,177 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/*********************************************************************
-
- mc146818.h
-
- Implementation of the MC146818 chip
-
- Real time clock chip with CMOS battery backed ram
- Used in IBM PC/AT, several PC clones, Amstrad NC200, Apollo workstations
-
-*********************************************************************/
-
-#ifndef __MC146818_H__
-#define __MC146818_H__
-
-#include "emu.h"
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MC146818_ADD(_tag, _xtal) \
- MCFG_DEVICE_ADD(_tag, MC146818, _xtal)
-
-#define MCFG_MC146818_IRQ_HANDLER(_irq) \
- downcast<mc146818_device *>(device)->set_irq_callback(DEVCB_##_irq);
-
-// The MC146818 doesn't have century support, but when syncing the date & time at startup we can optionally store the century.
-#define MCFG_MC146818_CENTURY_INDEX(_century_index) \
- downcast<mc146818_device *>(device)->set_century_index(_century_index);
-
-// The MC146818 doesn't have UTC support, but when syncing the data & time at startup we can use UTC instead of local time.
-#define MCFG_MC146818_UTC(_utc) \
- downcast<mc146818_device *>(device)->set_use_utc(_utc);
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mc146818_device
-
-class mc146818_device : public device_t,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- mc146818_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- mc146818_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- // callbacks
- template<class _irq> void set_irq_callback(_irq irq) { m_write_irq.set_callback(irq); }
- void set_century_index(int century_index) { m_century_index = century_index; }
- void set_use_utc(bool use_utc) { m_use_utc = use_utc; }
-
- // read/write access
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
- static const unsigned char ALARM_DONTCARE = 0xc0;
- static const unsigned char HOURS_PM = 0x80;
-
- virtual int data_size() { return 64; }
-
-private:
- enum
- {
- REG_SECONDS = 0,
- REG_ALARM_SECONDS = 1,
- REG_MINUTES = 2,
- REG_ALARM_MINUTES = 3,
- REG_HOURS = 4,
- REG_ALARM_HOURS = 5,
- REG_DAYOFWEEK = 6,
- REG_DAYOFMONTH = 7,
- REG_MONTH = 8,
- REG_YEAR = 9,
- REG_A = 0xa,
- REG_B = 0xb,
- REG_C = 0xc,
- REG_D = 0xd
- };
-
- enum
- {
- REG_A_RS0 = 1,
- REG_A_RS1 = 2,
- REG_A_RS2 = 4,
- REG_A_RS3 = 8,
- REG_A_DV0 = 16,
- REG_A_DV1 = 32,
- REG_A_DV2 = 64,
- REG_A_UIP = 128
- };
-
- enum
- {
- REG_B_DSE = 1, // TODO: When set the chip will adjust the clock by an hour at start and end of DST
- REG_B_24_12 = 2,
- REG_B_DM = 4,
- REG_B_SQWE = 8, // TODO: When set the chip will output a square wave on SQW pin
- REG_B_UIE = 16,
- REG_B_AIE = 32,
- REG_B_PIE = 64,
- REG_B_SET = 128
- };
-
- enum
- {
- REG_C_UF = 16,
- REG_C_AF = 32,
- REG_C_PF = 64,
- REG_C_IRQF = 128
- };
-
- enum
- {
- REG_D_VRT = 128
- };
-
- // internal helpers
- int to_ram(int a);
- int from_ram(int a);
- void set_base_datetime();
- void update_irq();
- void update_timer();
-
- int get_seconds();
- void set_seconds(int seconds);
- int get_minutes();
- void set_minutes(int minutes);
- int get_hours();
- void set_hours(int hours);
- int get_dayofweek();
- void set_dayofweek(int dayofweek);
- int get_dayofmonth();
- void set_dayofmonth(int dayofmonth);
- int get_month();
- void set_month(int month);
- int get_year();
- void set_year(int year);
-
- // internal state
-
- UINT8 m_index;
- dynamic_buffer m_data;
-
- attotime m_last_refresh;
-
- static const device_timer_id TIMER_CLOCK = 0;
- static const device_timer_id TIMER_PERIODIC = 1;
-
- emu_timer *m_clock_timer;
- emu_timer *m_periodic_timer;
-
- devcb_write_line m_write_irq;
- int m_century_index;
- bool m_use_utc;
-};
-
-
-// device type definition
-extern const device_type MC146818;
-
-
-#endif /* __MC146818_H__ */
diff --git a/src/emu/machine/mc2661.c b/src/emu/machine/mc2661.c
deleted file mode 100644
index f93dc1b5ab1..00000000000
--- a/src/emu/machine/mc2661.c
+++ /dev/null
@@ -1,499 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- Motorola MC2661/MC68661 Enhanced Programmable Communications Interface
-
-***************************************************************************/
-
-#include "mc2661.h"
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type MC2661 = &device_creator<mc2661_device>;
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-UINT32 baud_rates[16] =
-{
- 50, 75, 110, 135 /*134.5*/, 150, 300, 600, 1200, 1800, 2000, 2400, 3600, 4800, 7200, 9600, 19200
-};
-
-enum
-{
- REGISTER_HOLDING = 0,
- REGISTER_STATUS,
- REGISTER_SYNC = REGISTER_STATUS,
- REGISTER_MODE,
- REGISTER_COMMAND
-};
-
-
-#define MODE_BAUD_RATE (m_mr[0] & 0x03)
-#define MODE_CHARACTER ((m_mr[0] >> 2) & 0x03)
-#define MODE_PARITY BIT(m_mr[0], 4)
-#define MODE_PARITY_EVEN BIT(m_mr[0], 5)
-#define MODE_TRANSPARENT BIT(m_mr[0], 6)
-#define MODE_SINGLE_SYN BIT(m_mr[0], 7)
-#define MODE_STOP_BITS ((m_mr[0] >> 6) & 0x03)
-
-
-#define SYN1 m_sync[0]
-#define SYN2 m_sync[1]
-#define DLE m_sync[2]
-
-
-#define COMMAND_TXEN BIT(m_cr, 0)
-#define COMMAND_DTR BIT(m_cr, 1)
-#define COMMAND_RXEN BIT(m_cr, 2)
-#define COMMAND_BREAK BIT(m_cr, 3)
-#define COMMAND_DLE BIT(m_cr, 3)
-#define COMMAND_RESET BIT(m_cr, 4)
-#define COMMAND_RTS BIT(m_cr, 5)
-#define COMMAND_MODE (m_cr >> 6)
-
-
-enum
-{
- MODE_NORMAL = 0,
- MODE_ASYNC,
- MODE_LOCAL_LOOP_BACK,
- MODE_REMOTE_LOOP_BACK
-};
-
-
-#define STATUS_TXRDY 0x01
-#define STATUS_RXRDY 0x02
-#define STATUS_TXEMT 0x04
-#define STATUS_PE 0x08
-#define STATUS_DLE 0x08
-#define STATUS_OVERRUN 0x10
-#define STATUS_FE 0x20
-#define STATUS_SYN 0x20
-#define STATUS_DCD 0x40
-#define STATUS_DSR 0x80
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mc2661_device - constructor
-//-------------------------------------------------
-
-mc2661_device::mc2661_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, MC2661, "MC2661", tag, owner, clock, "mc2661", __FILE__),
- device_serial_interface(mconfig, *this),
- m_write_txd(*this),
- m_write_rxrdy(*this),
- m_write_txrdy(*this),
- m_write_rts(*this),
- m_write_dtr(*this),
- m_write_txemt_dschg(*this),
- m_write_bkdet(*this),
- m_write_xsync(*this),
- m_rxc(0),
- m_txc(0),
- m_sr(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mc2661_device::device_start()
-{
- // resolve callbacks
- m_write_txd.resolve_safe();
- m_write_rxrdy.resolve_safe();
- m_write_txrdy.resolve_safe();
- m_write_rts.resolve_safe();
- m_write_dtr.resolve_safe();
- m_write_txemt_dschg.resolve_safe();
- m_write_bkdet.resolve_safe();
- m_write_xsync.resolve_safe();
-
- // create the timers
- if (m_rxc > 0)
- {
- set_rcv_rate(m_rxc);
- }
-
- if (m_txc > 0)
- {
- set_tra_rate(m_txc);
- }
-
- // save state
- save_item(NAME(m_rhr));
- save_item(NAME(m_thr));
- save_item(NAME(m_cr));
- save_item(NAME(m_sr));
- save_item(NAME(m_mr));
- save_item(NAME(m_sync));
- save_item(NAME(m_mode_index));
- save_item(NAME(m_sync_index));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mc2661_device::device_reset()
-{
- receive_register_reset();
- transmit_register_reset();
-
- m_mr[0] = m_mr[1] = 0;
- m_sync[0] = m_sync[1] = m_sync[2] = 0;
- m_cr = 0;
- m_sr = 0;
-
- m_mode_index = 0;
- m_sync_index = 0;
-
- m_write_txd(1);
- m_write_rxrdy(CLEAR_LINE);
- m_write_txrdy(CLEAR_LINE);
- m_write_rts(1);
- m_write_dtr(1);
- m_write_txemt_dschg(CLEAR_LINE);
- m_write_bkdet(0);
- m_write_xsync(0);
-}
-
-
-//-------------------------------------------------
-// tra_callback -
-//-------------------------------------------------
-
-void mc2661_device::tra_callback()
-{
- m_write_txd(transmit_register_get_data_bit());
-}
-
-
-//-------------------------------------------------
-// tra_complete -
-//-------------------------------------------------
-
-void mc2661_device::tra_complete()
-{
- // TODO
- m_sr |= STATUS_TXRDY;
- m_write_txrdy(ASSERT_LINE);
-}
-
-
-//-------------------------------------------------
-// rcv_complete -
-//-------------------------------------------------
-
-void mc2661_device::rcv_complete()
-{
- // TODO
- receive_register_extract();
- m_rhr = get_received_char();
- m_sr |= STATUS_RXRDY;
- m_write_rxrdy(ASSERT_LINE);
-}
-
-
-//-------------------------------------------------
-// read - register read
-//-------------------------------------------------
-
-READ8_MEMBER( mc2661_device::read )
-{
- UINT8 data = 0;
-
- switch (offset & 0x03)
- {
- case REGISTER_HOLDING:
- data = m_rhr;
- m_sr &= ~STATUS_RXRDY;
- m_write_rxrdy(CLEAR_LINE);
- break;
-
- case REGISTER_STATUS:
- data = m_sr;
- break;
-
- case REGISTER_MODE:
- data = m_mr[m_mode_index];
-
- m_mode_index++;
- m_mode_index &= 0x01;
-
- break;
-
- case REGISTER_COMMAND:
- m_mode_index = 0;
- m_sync_index = 0;
-
- data = m_cr;
- break;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write - register write
-//-------------------------------------------------
-
-WRITE8_MEMBER( mc2661_device::write )
-{
- switch (offset & 0x03)
- {
- case REGISTER_HOLDING:
- if (LOG) logerror("MC2661 '%s' Transmit Holding Register: %02x\n", tag(), data);
-
- m_thr = data;
- if(COMMAND_TXEN)
- {
- if(COMMAND_MODE != 0x02)
- transmit_register_setup(m_thr);
- m_sr &= ~STATUS_TXRDY;
- m_write_txrdy(CLEAR_LINE);
- }
- if(COMMAND_MODE == 0x02) // loopback - the Wicat will set this after enabling the transmitter
- {
- m_rhr = data;
- m_sr |= STATUS_RXRDY; // pcd expects this
- m_write_rxrdy(ASSERT_LINE);
- }
- break;
-
- case REGISTER_SYNC:
- if (LOG) logerror("MC2661 '%s' Sync Register %u: %02x\n", tag(), m_sync_index + 1, data);
-
- m_sync[m_sync_index] = data;
-
- m_sync_index++;
- if (m_sync_index == 3) m_sync_index = 0;
- break;
-
- case REGISTER_MODE:
- if (LOG) logerror("MC2661 '%s' Mode Register %u: %02x\n", tag(), m_mode_index + 1, data);
-
- m_mr[m_mode_index] = data;
-
- if (m_mode_index == 0)
- {
- int data_bit_count = 5 + MODE_CHARACTER;
- parity_t parity;
-
- if (!MODE_PARITY) parity = PARITY_NONE;
- else if (MODE_PARITY_EVEN) parity = PARITY_EVEN;
- else parity = PARITY_ODD;
-
- stop_bits_t stop_bits;
-
- switch (MODE_STOP_BITS)
- {
- case 0:
- default:
- stop_bits = STOP_BITS_0;
- break;
-
- case 1:
- stop_bits = STOP_BITS_1;
- break;
-
- case 2:
- stop_bits = STOP_BITS_1_5;
- break;
-
- case 3:
- stop_bits = STOP_BITS_2;
- break;
- }
-
- set_data_frame(1, data_bit_count, parity, stop_bits);
- }
- if(m_mode_index == 1)
- {
- UINT32 rx_baud = baud_rates[data & 0x0f];
- UINT32 tx_baud = baud_rates[data & 0x0f];
- if(data & 0x10) // internal receiver clock
- {
-// if((m_mr[0] & 0x03) != 0)
-// rx_baud *= 16;
- }
- else // external receiver clock
- {
- switch(m_mr[0] & 0x03)
- {
- case 0x02:
- rx_baud *= 16;
- break;
- case 0x03:
- rx_baud *= 64;
- break;
- default:
- // x1
- break;
- }
- }
- if(data & 0x20) // internal transmitter clock
- {
-// if((m_mr[0] & 0x03) != 0)
-// tx_baud *= 16;
- }
- else // external transmitter clock
- {
- switch(m_mr[0] & 0x03)
- {
- case 0x02:
- tx_baud *= 16;
- break;
- case 0x03:
- tx_baud *= 64;
- break;
- default:
- // x1
- break;
- }
- }
-
- set_rcv_rate(rx_baud);
- set_tra_rate(tx_baud);
- }
-
- m_mode_index++;
- m_mode_index &= 0x01;
- break;
-
- case REGISTER_COMMAND:
- if (LOG) logerror("MC2661 '%s' Command Register: %02x\n", tag(), data);
-
- m_cr = data & 0xef;
-
- m_write_dtr(!COMMAND_DTR);
- m_write_rts(!COMMAND_RTS);
-
- if (COMMAND_MODE == 0x02) // local loopback
- {
- if(COMMAND_DTR && COMMAND_RTS) // CR1 and CR5 must be set to 1 to use local loopback
- {
- // probably much more to it that this, but this is enough for the Wicat to be happy
- m_rhr = m_thr;
- m_sr |= STATUS_RXRDY;
- m_write_rxrdy(ASSERT_LINE);
- return;
- }
- }
-
- if (COMMAND_TXEN)
- {
- m_sr |= STATUS_TXRDY;
- m_write_txrdy(ASSERT_LINE);
- }
- else
- {
- m_sr &= ~STATUS_TXRDY;
- m_write_txrdy(CLEAR_LINE);
- }
- if (!COMMAND_RXEN)
- {
- m_sr &= ~STATUS_RXRDY;
- m_write_rxrdy(CLEAR_LINE);
- }
- if (COMMAND_RESET)
- {
- m_sr &= ~(STATUS_FE | STATUS_OVERRUN | STATUS_PE);
- }
- break;
- }
-}
-
-//-------------------------------------------------
-// dsr_w - data set ready
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mc2661_device::dsr_w )
-{
- if (LOG) logerror("MC2661 '%s' Data Set Ready: %u\n", tag(), state);
-
- if (state)
- {
- m_sr &= ~STATUS_DSR;
- }
- else
- {
- m_sr |= STATUS_DSR;
- }
-}
-
-
-//-------------------------------------------------
-// dcd_w - data carrier detect
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mc2661_device::dcd_w )
-{
- if (LOG) logerror("MC2661 '%s' Data Carrier Detect: %u\n", tag(), state);
-
- if (state)
- {
- m_sr &= ~STATUS_DCD;
- }
- else
- {
- m_sr |= STATUS_DCD;
- }
-}
-
-
-//-------------------------------------------------
-// cts_w - clear to send
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mc2661_device::cts_w )
-{
- if (LOG) logerror("MC2661 '%s' Clear to Send: %u\n", tag(), state);
-}
-
-
-//-------------------------------------------------
-// rxrdy_r - receiver ready
-//-------------------------------------------------
-
-READ_LINE_MEMBER( mc2661_device::rxrdy_r )
-{
- return (m_sr & STATUS_RXRDY) ? ASSERT_LINE : CLEAR_LINE;
-}
-
-
-//-------------------------------------------------
-// txemt_r - transmitter empty
-//-------------------------------------------------
-
-READ_LINE_MEMBER( mc2661_device::txemt_r )
-{
- return (m_sr & STATUS_TXEMT) ? ASSERT_LINE : CLEAR_LINE;
-}
-
-
-void mc2661_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- device_serial_interface::device_timer(timer, id, param, ptr);
-}
diff --git a/src/emu/machine/mc2661.h b/src/emu/machine/mc2661.h
deleted file mode 100644
index 5cc2f3e27fc..00000000000
--- a/src/emu/machine/mc2661.h
+++ /dev/null
@@ -1,149 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- Motorola MC2661/MC68661 Enhanced Programmable Communications Interface
-
-****************************************************************************
- _____ _____
- D2 1 |* \_/ | 28 D1
- D3 2 | | 27 D0
- RxD 3 | | 26 Vcc
- GND 4 | | 25 _RxC/BKDET
- D4 5 | | 24 _DTR
- D5 6 | | 23 _RTS
- D6 7 | MC2661 | 22 _DSR
- D7 8 | MC68661 | 21 RESET
- _TxC/XSYNC 9 | | 20 BRCLK
- A1 10 | | 19 TxD
- _CE 11 | | 18 _TxEMT/DSCHG
- A0 12 | | 17 _CTS
- _R/W 13 | | 16 _DCD
- _RxRDY 14 |_____________| 15 _TxRDY
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __MC2661__
-#define __MC2661__
-
-#include "emu.h"
-
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_MC2661_RXC(_clock) \
- mc2661_device::static_set_rxc(*device, _clock);
-
-#define MCFG_MC2661_TXC(_clock) \
- mc2661_device::static_set_txc(*device, _clock);
-
-#define MCFG_MC2661_TXD_HANDLER(_write) \
- devcb = &mc2661_device::set_txd_callback(*device, DEVCB_##_write);
-
-#define MCFG_MC2661_RXRDY_HANDLER(_write) \
- devcb = &mc2661_device::set_rxrdy_callback(*device, DEVCB_##_write);
-
-#define MCFG_MC2661_TXRDY_HANDLER(_write) \
- devcb = &mc2661_device::set_txrdy_callback(*device, DEVCB_##_write);
-
-#define MCFG_MC2661_RTS_HANDLER(_write) \
- devcb = &mc2661_device::set_rts_callback(*device, DEVCB_##_write);
-
-#define MCFG_MC2661_DTR_HANDLER(_write) \
- devcb = &mc2661_device::set_dtr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MC2661_TXEMT_DSCHG_HANDLER(_write) \
- devcb = &mc2661_device::set_txemt_dschg_callback(*device, DEVCB_##_write);
-
-#define MCFG_MC2661_BKDET_HANDLER(_write) \
- devcb = &mc2661_device::set_bkdet_callback(*device, DEVCB_##_write);
-
-#define MCFG_MC2661_XSYNC_HANDLER(_write) \
- devcb = &mc2661_device::set_xsync_callback(*device, DEVCB_##_write);
-
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-// ======================> mc2661_device
-
-class mc2661_device : public device_t,
- public device_serial_interface
-{
-public:
- // construction/destruction
- mc2661_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void static_set_rxc(device_t &device, int clock) { downcast<mc2661_device &>(device).m_rxc = clock; }
- static void static_set_txc(device_t &device, int clock) { downcast<mc2661_device &>(device).m_txc = clock; }
-
- template<class _Object> static devcb_base &set_txd_callback(device_t &device, _Object object) { return downcast<mc2661_device &>(device).m_write_txd.set_callback(object); }
- template<class _Object> static devcb_base &set_rxrdy_callback(device_t &device, _Object object) { return downcast<mc2661_device &>(device).m_write_rxrdy.set_callback(object); }
- template<class _Object> static devcb_base &set_txrdy_callback(device_t &device, _Object object) { return downcast<mc2661_device &>(device).m_write_txrdy.set_callback(object); }
- template<class _Object> static devcb_base &set_rts_callback(device_t &device, _Object object) { return downcast<mc2661_device &>(device).m_write_rts.set_callback(object); }
- template<class _Object> static devcb_base &set_dtr_callback(device_t &device, _Object object) { return downcast<mc2661_device &>(device).m_write_dtr.set_callback(object); }
- template<class _Object> static devcb_base &set_txemt_dschg_callback(device_t &device, _Object object) { return downcast<mc2661_device &>(device).m_write_txemt_dschg.set_callback(object); }
- template<class _Object> static devcb_base &set_bkdet_callback(device_t &device, _Object object) { return downcast<mc2661_device &>(device).m_write_bkdet.set_callback(object); }
- template<class _Object> static devcb_base &set_xsync_callback(device_t &device, _Object object) { return downcast<mc2661_device &>(device).m_write_xsync.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( dsr_w );
- DECLARE_WRITE_LINE_MEMBER( dcd_w );
- DECLARE_WRITE_LINE_MEMBER( cts_w );
-
- DECLARE_READ_LINE_MEMBER( rxrdy_r );
- DECLARE_READ_LINE_MEMBER( txemt_r );
-
- DECLARE_WRITE_LINE_MEMBER( rx_w ) { device_serial_interface::rx_w(state); }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_serial_interface overrides
- virtual void tra_callback();
- virtual void tra_complete();
- virtual void rcv_complete();
-
-private:
- devcb_write_line m_write_txd;
- devcb_write_line m_write_rxrdy;
- devcb_write_line m_write_txrdy;
- devcb_write_line m_write_rts;
- devcb_write_line m_write_dtr;
- devcb_write_line m_write_txemt_dschg;
- devcb_write_line m_write_bkdet;
- devcb_write_line m_write_xsync;
-
- int m_rxc;
- int m_txc;
-
- UINT8 m_rhr;
- UINT8 m_thr;
- UINT8 m_cr;
- UINT8 m_sr;
- UINT8 m_mr[2];
- UINT8 m_sync[3];
-
- int m_mode_index;
- int m_sync_index;
-};
-
-
-// device type definition
-extern const device_type MC2661;
-
-
-
-#endif
diff --git a/src/emu/machine/mc68328.c b/src/emu/machine/mc68328.c
deleted file mode 100644
index c97e0aea815..00000000000
--- a/src/emu/machine/mc68328.c
+++ /dev/null
@@ -1,2871 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Ryan Holtz
-/**********************************************************************
-
- Motorola 68328 ("DragonBall") System-on-a-Chip implementation
-
- By MooglyGuy
- contact mooglyguy@gmail.com with licensing and usage questions.
-
-**********************************************************************/
-
-#include "emu.h"
-#include "cpu/m68000/m68000.h"
-#include "machine/mc68328.h"
-#include "machine/ram.h"
-
-#define VERBOSE_LEVEL (0)
-
-INLINE void ATTR_PRINTF(3,4) verboselog(running_machine &machine, int n_level, const char *s_fmt, ...)
-{
- if (VERBOSE_LEVEL >= n_level)
- {
- va_list v;
- char buf[32768];
- va_start(v, s_fmt);
- vsprintf(buf, s_fmt, v);
- va_end(v);
- logerror("%s: %s", machine.describe_context(), buf);
- }
-}
-
-const device_type MC68328 = &device_creator<mc68328_device>;
-
-
-mc68328_device::mc68328_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MC68328, "MC68328 (DragonBall) Integrated Processor", tag, owner, clock, "mc68328", __FILE__),
- m_out_port_a_cb(*this),
- m_out_port_b_cb(*this),
- m_out_port_c_cb(*this),
- m_out_port_d_cb(*this),
- m_out_port_e_cb(*this),
- m_out_port_f_cb(*this),
- m_out_port_g_cb(*this),
- m_out_port_j_cb(*this),
- m_out_port_k_cb(*this),
- m_out_port_m_cb(*this),
- m_in_port_a_cb(*this),
- m_in_port_b_cb(*this),
- m_in_port_c_cb(*this),
- m_in_port_d_cb(*this),
- m_in_port_e_cb(*this),
- m_in_port_f_cb(*this),
- m_in_port_g_cb(*this),
- m_in_port_j_cb(*this),
- m_in_port_k_cb(*this),
- m_in_port_m_cb(*this),
- m_out_pwm_cb(*this),
- m_out_spim_cb(*this),
- m_in_spim_cb(*this),
- m_spim_xch_trigger_cb(*this),
- m_cpu(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mc68328_device::device_start()
-{
- m_out_port_a_cb.resolve();
- m_out_port_b_cb.resolve();
- m_out_port_c_cb.resolve();
- m_out_port_d_cb.resolve();
- m_out_port_e_cb.resolve();
- m_out_port_f_cb.resolve();
- m_out_port_g_cb.resolve();
- m_out_port_j_cb.resolve();
- m_out_port_k_cb.resolve();
- m_out_port_m_cb.resolve();
-
- m_in_port_a_cb.resolve();
- m_in_port_b_cb.resolve();
- m_in_port_c_cb.resolve();
- m_in_port_d_cb.resolve();
- m_in_port_e_cb.resolve();
- m_in_port_f_cb.resolve();
- m_in_port_g_cb.resolve();
- m_in_port_j_cb.resolve();
- m_in_port_k_cb.resolve();
- m_in_port_m_cb.resolve();
-
- m_out_pwm_cb.resolve();
-
- m_out_spim_cb.resolve();
- m_in_spim_cb.resolve();
-
- m_spim_xch_trigger_cb.resolve();
-
- m_gptimer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc68328_device::timer1_hit),this));
- m_gptimer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc68328_device::timer2_hit),this));
- m_rtc = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc68328_device::rtc_tick),this));
- m_pwm = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc68328_device::pwm_transition),this));
-
- register_state_save();
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mc68328_device::device_reset()
-{
- m_regs.scr = 0x0c;
- m_regs.grpbasea = 0x0000;
- m_regs.grpbaseb = 0x0000;
- m_regs.grpbasec = 0x0000;
- m_regs.grpbased = 0x0000;
- m_regs.grpmaska = 0x0000;
- m_regs.grpmaskb = 0x0000;
- m_regs.grpmaskc = 0x0000;
- m_regs.grpmaskd = 0x0000;
- m_regs.csa0 = 0x00010006;
- m_regs.csa1 = 0x00010006;
- m_regs.csa2 = 0x00010006;
- m_regs.csa3 = 0x00010006;
- m_regs.csb0 = 0x00010006;
- m_regs.csb1 = 0x00010006;
- m_regs.csb2 = 0x00010006;
- m_regs.csb3 = 0x00010006;
- m_regs.csc0 = 0x00010006;
- m_regs.csc1 = 0x00010006;
- m_regs.csc2 = 0x00010006;
- m_regs.csc3 = 0x00010006;
- m_regs.csd0 = 0x00010006;
- m_regs.csd1 = 0x00010006;
- m_regs.csd2 = 0x00010006;
- m_regs.csd3 = 0x00010006;
-
- m_regs.pllcr = 0x2400;
- m_regs.pllfsr = 0x0123;
- m_regs.pctlr = 0x1f;
-
- m_regs.ivr = 0x00;
- m_regs.icr = 0x0000;
- m_regs.imr = 0x00ffffff;
- m_regs.iwr = 0x00ffffff;
- m_regs.isr = 0x00000000;
- m_regs.ipr = 0x00000000;
-
- m_regs.padir = 0x00;
- m_regs.padata = 0x00;
- m_regs.pasel = 0x00;
- m_regs.pbdir = 0x00;
- m_regs.pbdata = 0x00;
- m_regs.pbsel = 0x00;
- m_regs.pcdir = 0x00;
- m_regs.pcdata = 0x00;
- m_regs.pcsel = 0x00;
- m_regs.pddir = 0x00;
- m_regs.pddata = 0x00;
- m_regs.pdpuen = 0xff;
- m_regs.pdpol = 0x00;
- m_regs.pdirqen = 0x00;
- m_regs.pddataedge = 0x00;
- m_regs.pdirqedge = 0x00;
- m_regs.pedir = 0x00;
- m_regs.pedata = 0x00;
- m_regs.pepuen = 0x80;
- m_regs.pesel = 0x80;
- m_regs.pfdir = 0x00;
- m_regs.pfdata = 0x00;
- m_regs.pfpuen = 0xff;
- m_regs.pfsel = 0xff;
- m_regs.pgdir = 0x00;
- m_regs.pgdata = 0x00;
- m_regs.pgpuen = 0xff;
- m_regs.pgsel = 0xff;
- m_regs.pjdir = 0x00;
- m_regs.pjdata = 0x00;
- m_regs.pjsel = 0x00;
- m_regs.pkdir = 0x00;
- m_regs.pkdata = 0x00;
- m_regs.pkpuen = 0xff;
- m_regs.pksel = 0xff;
- m_regs.pmdir = 0x00;
- m_regs.pmdata = 0x00;
- m_regs.pmpuen = 0xff;
- m_regs.pmsel = 0xff;
-
- m_regs.pwmc = 0x0000;
- m_regs.pwmp = 0x0000;
- m_regs.pwmw = 0x0000;
- m_regs.pwmcnt = 0x0000;
-
- m_regs.tctl[0] = m_regs.tctl[1] = 0x0000;
- m_regs.tprer[0] = m_regs.tprer[1] = 0x0000;
- m_regs.tcmp[0] = m_regs.tcmp[1] = 0xffff;
- m_regs.tcr[0] = m_regs.tcr[1] = 0x0000;
- m_regs.tcn[0] = m_regs.tcn[1] = 0x0000;
- m_regs.tstat[0] = m_regs.tstat[1] = 0x0000;
- m_regs.wctlr = 0x0000;
- m_regs.wcmpr = 0xffff;
- m_regs.wcn = 0x0000;
-
- m_regs.spisr = 0x0000;
-
- m_regs.spimdata = 0x0000;
- m_regs.spimcont = 0x0000;
-
- m_regs.ustcnt = 0x0000;
- m_regs.ubaud = 0x003f;
- m_regs.urx = 0x0000;
- m_regs.utx = 0x0000;
- m_regs.umisc = 0x0000;
-
- m_regs.lssa = 0x00000000;
- m_regs.lvpw = 0xff;
- m_regs.lxmax = 0x03ff;
- m_regs.lymax = 0x01ff;
- m_regs.lcxp = 0x0000;
- m_regs.lcyp = 0x0000;
- m_regs.lcwch = 0x0101;
- m_regs.lblkc = 0x7f;
- m_regs.lpicf = 0x00;
- m_regs.lpolcf = 0x00;
- m_regs.lacdrc = 0x00;
- m_regs.lpxcd = 0x00;
- m_regs.lckcon = 0x40;
- m_regs.llbar = 0x3e;
- m_regs.lotcr = 0x3f;
- m_regs.lposr = 0x00;
- m_regs.lfrcm = 0xb9;
- m_regs.lgpmr = 0x1073;
-
- m_regs.hmsr = 0x00000000;
- m_regs.alarm = 0x00000000;
- m_regs.rtcctl = 0x00;
- m_regs.rtcisr = 0x00;
- m_regs.rtcienr = 0x00;
- m_regs.stpwtch = 0x00;
-
- m_rtc->adjust(attotime::from_hz(1), 0, attotime::from_hz(1));
-}
-
-
-void mc68328_device::set_interrupt_line(UINT32 line, UINT32 active)
-{
- if (active)
- {
- m_regs.ipr |= line;
-
- if (!(m_regs.imr & line) && !(m_regs.isr & line))
- {
- m_regs.isr |= line;
-
- if (m_regs.isr & INT_M68K_LINE7)
- {
- m_cpu->set_input_line_and_vector(M68K_IRQ_7, ASSERT_LINE, m_regs.ivr | 0x07);
- }
- else if (m_regs.isr & INT_M68K_LINE6)
- {
- m_cpu->set_input_line_and_vector(M68K_IRQ_6, ASSERT_LINE, m_regs.ivr | 0x06);
- }
- else if (m_regs.isr & INT_M68K_LINE5)
- {
- m_cpu->set_input_line_and_vector(M68K_IRQ_5, ASSERT_LINE, m_regs.ivr | 0x05);
- }
- else if (m_regs.isr & INT_M68K_LINE4)
- {
- m_cpu->set_input_line_and_vector(M68K_IRQ_4, ASSERT_LINE, m_regs.ivr | 0x04);
- }
- else if (m_regs.isr & INT_M68K_LINE3)
- {
- m_cpu->set_input_line_and_vector(M68K_IRQ_3, ASSERT_LINE, m_regs.ivr | 0x03);
- }
- else if (m_regs.isr & INT_M68K_LINE2)
- {
- m_cpu->set_input_line_and_vector(M68K_IRQ_2, ASSERT_LINE, m_regs.ivr | 0x02);
- }
- else if (m_regs.isr & INT_M68K_LINE1)
- {
- m_cpu->set_input_line_and_vector(M68K_IRQ_1, ASSERT_LINE, m_regs.ivr | 0x01);
- }
- }
- }
- else
- {
- m_regs.isr &= ~line;
-
- if ((line & INT_M68K_LINE7) && !(m_regs.isr & INT_M68K_LINE7))
- {
- m_cpu->set_input_line(M68K_IRQ_7, CLEAR_LINE);
- }
- if ((line & INT_M68K_LINE6) && !(m_regs.isr & INT_M68K_LINE6))
- {
- m_cpu->set_input_line(M68K_IRQ_6, CLEAR_LINE);
- }
- if ((line & INT_M68K_LINE5) && !(m_regs.isr & INT_M68K_LINE5))
- {
- m_cpu->set_input_line(M68K_IRQ_5, CLEAR_LINE);
- }
- if ((line & INT_M68K_LINE4) && !(m_regs.isr & INT_M68K_LINE4))
- {
- m_cpu->set_input_line(M68K_IRQ_4, CLEAR_LINE);
- }
- if ((line & INT_M68K_LINE3) && !(m_regs.isr & INT_M68K_LINE3))
- {
- m_cpu->set_input_line(M68K_IRQ_3, CLEAR_LINE);
- }
- if ((line & INT_M68K_LINE2) && !(m_regs.isr & INT_M68K_LINE2))
- {
- m_cpu->set_input_line(M68K_IRQ_2, CLEAR_LINE);
- }
- if ((line & INT_M68K_LINE1) && !(m_regs.isr & INT_M68K_LINE1))
- {
- m_cpu->set_input_line(M68K_IRQ_1, CLEAR_LINE);
- }
- }
-}
-
-void mc68328_device::poll_port_d_interrupts()
-{
- UINT8 line_transitions = m_regs.pddataedge & m_regs.pdirqedge;
- UINT8 line_holds = m_regs.pddata &~ m_regs.pdirqedge;
- UINT8 line_interrupts = (line_transitions | line_holds) & m_regs.pdirqen;
-
- if (line_interrupts)
- {
- set_interrupt_line(line_interrupts << 8, 1);
- }
- else
- {
- set_interrupt_line(INT_KBDINTS, 0);
- }
-}
-
-WRITE_LINE_MEMBER( mc68328_device::set_penirq_line )
-{
- if (state)
- {
- set_interrupt_line(INT_PEN, 1);
- }
- else
- {
- m_regs.ipr &= ~INT_PEN;
- set_interrupt_line(INT_PEN, 0);
- }
-}
-
-void mc68328_device::set_port_d_lines(UINT8 state, int bit)
-{
- UINT8 old_button_state = m_regs.pddata;
-
- if (state & (1 << bit))
- {
- m_regs.pddata |= (1 << bit);
- }
- else
- {
- m_regs.pddata &= ~(1 << bit);
- }
-
- m_regs.pddataedge |= ~old_button_state & m_regs.pddata;
-
- poll_port_d_interrupts();
-}
-
-UINT32 mc68328_device::get_timer_frequency(UINT32 index)
-{
- UINT32 frequency = 0;
-
- switch (m_regs.tctl[index] & TCTL_CLKSOURCE)
- {
- case TCTL_CLKSOURCE_SYSCLK:
- frequency = 32768 * 506;
- break;
-
- case TCTL_CLKSOURCE_SYSCLK16:
- frequency = (32768 * 506) / 16;
- break;
-
- case TCTL_CLKSOURCE_32KHZ4:
- case TCTL_CLKSOURCE_32KHZ5:
- case TCTL_CLKSOURCE_32KHZ6:
- case TCTL_CLKSOURCE_32KHZ7:
- frequency = 32768;
- break;
- }
- frequency /= (m_regs.tprer[index] + 1);
-
- return frequency;
-}
-
-void mc68328_device::maybe_start_timer(UINT32 index, UINT32 new_enable)
-{
- if ((m_regs.tctl[index] & TCTL_TEN) == TCTL_TEN_ENABLE && (m_regs.tctl[index] & TCTL_CLKSOURCE) > TCTL_CLKSOURCE_STOP)
- {
- if ((m_regs.tctl[index] & TCTL_CLKSOURCE) == TCTL_CLKSOURCE_TIN)
- {
- m_gptimer[index]->adjust(attotime::never);
- }
- else if (m_regs.tcmp[index] == 0)
- {
- m_gptimer[index]->adjust(attotime::never);
- }
- else
- {
- UINT32 frequency = get_timer_frequency(index);
- attotime period = (attotime::from_hz(frequency) * m_regs.tcmp[index]);
-
- if (new_enable)
- {
- m_regs.tcn[index] = 0x0000;
- }
-
- m_gptimer[index]->adjust(period);
- }
- }
- else
- {
- m_gptimer[index]->adjust(attotime::never);
- }
-}
-
-void mc68328_device::timer_compare_event(UINT32 index)
-{
- m_regs.tcn[index] = m_regs.tcmp[index];
- m_regs.tstat[index] |= TSTAT_COMP;
-
- if ((m_regs.tctl[index] & TCTL_FRR) == TCTL_FRR_RESTART)
- {
- UINT32 frequency = get_timer_frequency(index);
-
- if (frequency > 0)
- {
- attotime period = attotime::from_hz(frequency) * m_regs.tcmp[index];
-
- m_regs.tcn[index] = 0x0000;
-
- m_gptimer[index]->adjust(period);
- }
- else
- {
- m_gptimer[index]->adjust(attotime::never);
- }
- }
- else
- {
- UINT32 frequency = get_timer_frequency(index);
-
- if (frequency > 0)
- {
- attotime period = attotime::from_hz(frequency) * 0x10000;
-
- m_gptimer[index]->adjust(period);
- }
- else
- {
- m_gptimer[index]->adjust(attotime::never);
- }
- }
- if ((m_regs.tctl[index] & TCTL_IRQEN) == TCTL_IRQEN_ENABLE)
- {
- set_interrupt_line((index == 0) ? INT_TIMER1 : INT_TIMER2, 1);
- }
-}
-
-TIMER_CALLBACK_MEMBER( mc68328_device::timer1_hit )
-{
- timer_compare_event(0);
-}
-
-TIMER_CALLBACK_MEMBER( mc68328_device::timer2_hit )
-{
- timer_compare_event(1);
-}
-
-TIMER_CALLBACK_MEMBER( mc68328_device::pwm_transition )
-{
- if (m_regs.pwmw >= m_regs.pwmp || m_regs.pwmw == 0 || m_regs.pwmp == 0)
- {
- m_pwm->adjust(attotime::never);
- return;
- }
-
- if (((m_regs.pwmc & PWMC_POL) == 0 && (m_regs.pwmc & PWMC_PIN) != 0) ||
- ((m_regs.pwmc & PWMC_POL) != 0 && (m_regs.pwmc & PWMC_PIN) == 0))
- {
- UINT32 frequency = 32768 * 506;
- UINT32 divisor = 4 << (m_regs.pwmc & PWMC_CLKSEL); // ?? Datasheet says 2 <<, but then we're an octave higher than CoPilot.
- attotime period;
-
- frequency /= divisor;
- period = attotime::from_hz(frequency) * (m_regs.pwmp - m_regs.pwmw);
-
- m_pwm->adjust(period);
-
- if (m_regs.pwmc & PWMC_IRQEN)
- {
- set_interrupt_line(INT_PWM, 1);
- }
- }
- else
- {
- UINT32 frequency = 32768 * 506;
- UINT32 divisor = 4 << (m_regs.pwmc & PWMC_CLKSEL); // ?? Datasheet says 2 <<, but then we're an octave higher than CoPilot.
- attotime period;
-
- frequency /= divisor;
- period = attotime::from_hz(frequency) * m_regs.pwmw;
-
- m_pwm->adjust(period);
- }
-
- m_regs.pwmc ^= PWMC_PIN;
-
- if (!m_out_pwm_cb.isnull())
- {
- m_out_pwm_cb((offs_t)0, (m_regs.pwmc & PWMC_PIN) ? 1 : 0);
- }
-}
-
-TIMER_CALLBACK_MEMBER( mc68328_device::rtc_tick )
-{
- if (m_regs.rtcctl & RTCCTL_ENABLE)
- {
- UINT32 set_int = 0;
-
- m_regs.hmsr++;
-
- if (m_regs.rtcienr & RTCINT_SECOND)
- {
- set_int = 1;
- m_regs.rtcisr |= RTCINT_SECOND;
- }
-
- if ((m_regs.hmsr & 0x0000003f) == 0x0000003c)
- {
- m_regs.hmsr &= 0xffffffc0;
- m_regs.hmsr += 0x00010000;
-
- if (m_regs.rtcienr & RTCINT_MINUTE)
- {
- set_int = 1;
- m_regs.rtcisr |= RTCINT_MINUTE;
- }
-
- if ((m_regs.hmsr & 0x003f0000) == 0x003c0000)
- {
- m_regs.hmsr &= 0xffc0ffff;
- m_regs.hmsr += 0x0100000;
-
- if ((m_regs.hmsr & 0x1f000000) == 0x18000000)
- {
- m_regs.hmsr &= 0xe0ffffff;
-
- if (m_regs.rtcienr & RTCINT_DAY)
- {
- set_int = 1;
- m_regs.rtcisr |= RTCINT_DAY;
- }
- }
- }
-
- if (m_regs.stpwtch != 0x003f)
- {
- m_regs.stpwtch--;
- m_regs.stpwtch &= 0x003f;
-
- if (m_regs.stpwtch == 0x003f)
- {
- if (m_regs.rtcienr & RTCINT_STOPWATCH)
- {
- set_int = 1;
- m_regs.rtcisr |= RTCINT_STOPWATCH;
- }
- }
- }
- }
-
- if (m_regs.hmsr == m_regs.alarm)
- {
- if (m_regs.rtcienr & RTCINT_ALARM)
- {
- set_int = 1;
- m_regs.rtcisr |= RTCINT_STOPWATCH;
- }
- }
-
- if (set_int)
- {
- set_interrupt_line(INT_RTC, 1);
- }
- else
- {
- set_interrupt_line(INT_RTC, 0);
- }
- }
-}
-
-WRITE16_MEMBER( mc68328_device::write )
-{
- UINT32 address = offset << 1;
- UINT16 temp16[4] = { 0 };
- UINT32 imr_old = m_regs.imr, imr_diff;
-
- switch (address)
- {
- case 0x000:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfff001) = %02x\n", data & 0x00ff);
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: SCR = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0x100:
- verboselog(machine(), 2, "mc68328_w: GRPBASEA = %04x\n", data);
- m_regs.grpbasea = data;
- break;
-
- case 0x102:
- verboselog(machine(), 2, "mc68328_w: GRPBASEB = %04x\n", data);
- m_regs.grpbaseb = data;
- break;
-
- case 0x104:
- verboselog(machine(), 2, "mc68328_w: GRPBASEC = %04x\n", data);
- m_regs.grpbasec = data;
- break;
-
- case 0x106:
- verboselog(machine(), 2, "mc68328_w: GRPBASED = %04x\n", data);
- m_regs.grpbased = data;
- break;
-
- case 0x108:
- verboselog(machine(), 2, "mc68328_w: GRPMASKA = %04x\n", data);
- m_regs.grpmaska = data;
- break;
-
- case 0x10a:
- verboselog(machine(), 2, "mc68328_w: GRPMASKB = %04x\n", data);
- m_regs.grpmaskb = data;
- break;
-
- case 0x10c:
- verboselog(machine(), 2, "mc68328_w: GRPMASKC = %04x\n", data);
- m_regs.grpmaskc = data;
- break;
-
- case 0x10e:
- verboselog(machine(), 2, "mc68328_w: GRPMASKD = %04x\n", data);
- m_regs.grpmaskd = data;
- break;
-
- case 0x110:
- verboselog(machine(), 5, "mc68328_w: CSA0(0) = %04x\n", data);
- m_regs.csa0 &= 0xffff0000 | (~mem_mask);
- m_regs.csa0 |= data & mem_mask;
- break;
-
- case 0x112:
- verboselog(machine(), 5, "mc68328_w: CSA0(16) = %04x\n", data);
- m_regs.csa0 &= ~(mem_mask << 16);
- m_regs.csa0 |= (data & mem_mask) << 16;
- break;
-
- case 0x114:
- verboselog(machine(), 5, "mc68328_w: CSA1(0) = %04x\n", data);
- m_regs.csa1 &= 0xffff0000 | (~mem_mask);
- m_regs.csa1 |= data & mem_mask;
- break;
-
- case 0x116:
- verboselog(machine(), 5, "mc68328_w: CSA1(16) = %04x\n", data);
- m_regs.csa1 &= ~(mem_mask << 16);
- m_regs.csa1 |= (data & mem_mask) << 16;
- break;
-
- case 0x118:
- verboselog(machine(), 5, "mc68328_w: CSA2(0) = %04x\n", data);
- m_regs.csa2 &= 0xffff0000 | (~mem_mask);
- m_regs.csa2 |= data & mem_mask;
- break;
-
- case 0x11a:
- verboselog(machine(), 5, "mc68328_w: CSA2(16) = %04x\n", data);
- m_regs.csa2 &= ~(mem_mask << 16);
- m_regs.csa2 |= (data & mem_mask) << 16;
- break;
-
- case 0x11c:
- verboselog(machine(), 5, "mc68328_w: CSA3(0) = %04x\n", data);
- m_regs.csa3 &= 0xffff0000 | (~mem_mask);
- m_regs.csa3 |= data & mem_mask;
- break;
-
- case 0x11e:
- verboselog(machine(), 5, "mc68328_w: CSA3(16) = %04x\n", data);
- m_regs.csa3 &= ~(mem_mask << 16);
- m_regs.csa3 |= (data & mem_mask) << 16;
- break;
-
- case 0x120:
- verboselog(machine(), 5, "mc68328_w: CSB0(0) = %04x\n", data);
- m_regs.csb0 &= 0xffff0000 | (~mem_mask);
- m_regs.csb0 |= data & mem_mask;
- break;
-
- case 0x122:
- verboselog(machine(), 5, "mc68328_w: CSB0(16) = %04x\n", data);
- m_regs.csb0 &= ~(mem_mask << 16);
- m_regs.csb0 |= (data & mem_mask) << 16;
- break;
-
- case 0x124:
- verboselog(machine(), 5, "mc68328_w: CSB1(0) = %04x\n", data);
- m_regs.csb1 &= 0xffff0000 | (~mem_mask);
- m_regs.csb1 |= data & mem_mask;
- break;
-
- case 0x126:
- verboselog(machine(), 5, "mc68328_w: CSB1(16) = %04x\n", data);
- m_regs.csb1 &= ~(mem_mask << 16);
- m_regs.csb1 |= (data & mem_mask) << 16;
- break;
-
- case 0x128:
- verboselog(machine(), 5, "mc68328_w: CSB2(0) = %04x\n", data);
- m_regs.csb2 &= 0xffff0000 | (~mem_mask);
- m_regs.csb2 |= data & mem_mask;
- break;
-
- case 0x12a:
- verboselog(machine(), 5, "mc68328_w: CSB2(16) = %04x\n", data);
- m_regs.csb2 &= ~(mem_mask << 16);
- m_regs.csb2 |= (data & mem_mask) << 16;
- break;
-
- case 0x12c:
- verboselog(machine(), 5, "mc68328_w: CSB3(0) = %04x\n", data);
- m_regs.csb3 &= 0xffff0000 | (~mem_mask);
- m_regs.csb3 |= data & mem_mask;
- break;
-
- case 0x12e:
- verboselog(machine(), 5, "mc68328_w: CSB3(16) = %04x\n", data);
- m_regs.csb3 &= ~(mem_mask << 16);
- m_regs.csb3 |= (data & mem_mask) << 16;
- break;
-
- case 0x130:
- verboselog(machine(), 5, "mc68328_w: CSC0(0) = %04x\n", data);
- m_regs.csc0 &= 0xffff0000 | (~mem_mask);
- m_regs.csc0 |= data & mem_mask;
- break;
-
- case 0x132:
- verboselog(machine(), 5, "mc68328_w: CSC0(16) = %04x\n", data);
- m_regs.csc0 &= ~(mem_mask << 16);
- m_regs.csc0 |= (data & mem_mask) << 16;
- break;
-
- case 0x134:
- verboselog(machine(), 5, "mc68328_w: CSC1(0) = %04x\n", data);
- m_regs.csc1 &= 0xffff0000 | (~mem_mask);
- m_regs.csc1 |= data & mem_mask;
- break;
-
- case 0x136:
- verboselog(machine(), 5, "mc68328_w: CSC1(16) = %04x\n", data);
- m_regs.csc1 &= ~(mem_mask << 16);
- m_regs.csc1 |= (data & mem_mask) << 16;
- break;
-
- case 0x138:
- verboselog(machine(), 5, "mc68328_w: CSC2(0) = %04x\n", data);
- m_regs.csc2 &= 0xffff0000 | (~mem_mask);
- m_regs.csc2 |= data & mem_mask;
- break;
-
- case 0x13a:
- verboselog(machine(), 5, "mc68328_w: CSC2(16) = %04x\n", data);
- m_regs.csc2 &= ~(mem_mask << 16);
- m_regs.csc2 |= (data & mem_mask) << 16;
- break;
-
- case 0x13c:
- verboselog(machine(), 5, "mc68328_w: CSC3(0) = %04x\n", data);
- m_regs.csc3 &= 0xffff0000 | (~mem_mask);
- m_regs.csc3 |= data & mem_mask;
- break;
-
- case 0x13e:
- verboselog(machine(), 5, "mc68328_w: CSC3(16) = %04x\n", data);
- m_regs.csc3 &= ~(mem_mask << 16);
- m_regs.csc3 |= (data & mem_mask) << 16;
- break;
-
- case 0x140:
- verboselog(machine(), 5, "mc68328_w: CSD0(0) = %04x\n", data);
- m_regs.csd0 &= 0xffff0000 | (~mem_mask);
- m_regs.csd0 |= data & mem_mask;
- break;
-
- case 0x142:
- verboselog(machine(), 5, "mc68328_w: CSD0(16) = %04x\n", data);
- m_regs.csd0 &= ~(mem_mask << 16);
- m_regs.csd0 |= (data & mem_mask) << 16;
- break;
-
- case 0x144:
- verboselog(machine(), 5, "mc68328_w: CSD1(0) = %04x\n", data);
- m_regs.csd1 &= 0xffff0000 | (~mem_mask);
- m_regs.csd1 |= data & mem_mask;
- break;
-
- case 0x146:
- verboselog(machine(), 5, "mc68328_w: CSD1(16) = %04x\n", data);
- m_regs.csd1 &= ~(mem_mask << 16);
- m_regs.csd1 |= (data & mem_mask) << 16;
- break;
-
- case 0x148:
- verboselog(machine(), 5, "mc68328_w: CSD2(0) = %04x\n", data);
- m_regs.csd2 &= 0xffff0000 | (~mem_mask);
- m_regs.csd2 |= data & mem_mask;
- break;
-
- case 0x14a:
- verboselog(machine(), 5, "mc68328_w: CSD2(16) = %04x\n", data);
- m_regs.csd2 &= ~(mem_mask << 16);
- m_regs.csd2 |= (data & mem_mask) << 16;
- break;
-
- case 0x14c:
- verboselog(machine(), 5, "mc68328_w: CSD3(0) = %04x\n", data);
- m_regs.csd3 &= 0xffff0000 | (~mem_mask);
- m_regs.csd3 |= data & mem_mask;
- break;
-
- case 0x14e:
- verboselog(machine(), 5, "mc68328_w: CSD3(16) = %04x\n", data);
- m_regs.csd3 &= ~(mem_mask << 16);
- m_regs.csd3 |= (data & mem_mask) << 16;
- break;
-
- case 0x200:
- verboselog(machine(), 2, "mc68328_w: PLLCR = %04x\n", data);
- m_regs.pllcr = data;
- break;
-
- case 0x202:
- verboselog(machine(), 2, "mc68328_w: PLLFSR = %04x\n", data);
- m_regs.pllfsr = data;
- break;
-
- case 0x206:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PCTLR = %02x\n", data & 0x00ff);
- m_regs.pctlr = data & 0x00ff;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfff206) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0x300:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfff301) = %02x\n", data & 0x00ff);
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: IVR = %02x\n", (data >> 8) & 0x00ff);
- m_regs.ivr = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x302:
- verboselog(machine(), 2, "mc68328_w: ICR = %04x\n", data);
- m_regs.icr = data;
- break;
-
- case 0x304:
- verboselog(machine(), 2, "mc68328_w: IMR(16) = %04x\n", data);
- m_regs.imr &= ~(mem_mask << 16);
- m_regs.imr |= (data & mem_mask) << 16;
- m_regs.isr &= ~((data & mem_mask) << 16);
-
- imr_diff = imr_old ^ m_regs.imr;
- set_interrupt_line(imr_diff, 0);
- break;
-
- case 0x306:
- verboselog(machine(), 2, "mc68328_w: IMR(0) = %04x\n", data);
- m_regs.imr &= 0xffff0000 | (~mem_mask);
- m_regs.imr |= data & mem_mask;
- m_regs.isr &= ~(data & mem_mask);
-
- imr_diff = imr_old ^ m_regs.imr;
- set_interrupt_line(imr_diff, 0);
- break;
-
- case 0x308:
- verboselog(machine(), 2, "mc68328_w: IWR(16) = %04x\n", data);
- m_regs.iwr &= ~(mem_mask << 16);
- m_regs.iwr |= (data & mem_mask) << 16;
- break;
-
- case 0x30a:
- verboselog(machine(), 2, "mc68328_w: IWR(0) = %04x\n", data);
- m_regs.iwr &= 0xffff0000 | (~mem_mask);
- m_regs.iwr |= data & mem_mask;
- break;
-
- case 0x30c:
- verboselog(machine(), 2, "mc68328_w: ISR(16) = %04x\n", data);
- // Clear edge-triggered IRQ1
- if ((m_regs.icr & ICR_ET1) == ICR_ET1 && (data & INT_IRQ1_SHIFT) == INT_IRQ1_SHIFT)
- {
- m_regs.isr &= ~INT_IRQ1;
- }
-
- // Clear edge-triggered IRQ2
- if ((m_regs.icr & ICR_ET2) == ICR_ET2 && (data & INT_IRQ2_SHIFT) == INT_IRQ2_SHIFT)
- {
- m_regs.isr &= ~INT_IRQ2;
- }
-
- // Clear edge-triggered IRQ3
- if ((m_regs.icr & ICR_ET3) == ICR_ET3 && (data & INT_IRQ3_SHIFT) == INT_IRQ3_SHIFT)
- {
- m_regs.isr &= ~INT_IRQ3;
- }
-
- // Clear edge-triggered IRQ6
- if ((m_regs.icr & ICR_ET6) == ICR_ET6 && (data & INT_IRQ6_SHIFT) == INT_IRQ6_SHIFT)
- {
- m_regs.isr &= ~INT_IRQ6;
- }
-
- // Clear edge-triggered IRQ7
- if ((data & INT_IRQ7_SHIFT) == INT_IRQ7_SHIFT)
- {
- m_regs.isr &= ~INT_IRQ7;
- }
- break;
-
- case 0x30e:
- verboselog(machine(), 2, "mc68328_w: ISR(0) = %04x (Ignored)\n", data);
- break;
-
- case 0x310:
- verboselog(machine(), 2, "mc68328_w: IPR(16) = %04x (Ignored)\n", data);
- break;
-
- case 0x312:
- verboselog(machine(), 2, "mc68328_w: IPR(0) = %04x (Ignored)\n", data);
- break;
-
- case 0x400:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PADATA = %02x\n", data & 0x00ff);
- m_regs.padata = data & 0x00ff;
- if (!m_out_port_a_cb.isnull())
- {
- m_out_port_a_cb((offs_t)0, data & 0x00ff);
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PADIR = %02x\n", (data >> 8) & 0x00ff);
- m_regs.padir = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x402:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PASEL = %02x\n", data & 0x00ff);
- m_regs.pasel = data & 0x00ff;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfff402) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0x408:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PBDATA = %02x\n", data & 0x00ff);
- m_regs.pbdata = data & 0x00ff;
- if (!m_out_port_b_cb.isnull())
- {
- m_out_port_b_cb((offs_t)0, data & 0x00ff);
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PBDIR = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pbdir = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x40a:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PBSEL = %02x\n", data & 0x00ff);
- m_regs.pbsel = data & 0x00ff;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfff40a) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0x410:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PCDATA = %02x\n", data & 0x00ff);
- m_regs.pcdata = data & 0x00ff;
- if (!m_out_port_c_cb.isnull())
- {
- m_out_port_c_cb((offs_t)0, data & 0x00ff);
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PCDIR = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pcdir = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x412:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PCSEL = %02x\n", data & 0x00ff);
- m_regs.pcsel = data & 0x00ff;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfff412) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0x418:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PDDATA = %02x\n", data & 0x00ff);
-
- m_regs.pddataedge &= ~(data & 0x00ff);
- poll_port_d_interrupts();
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PDDIR = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pddir = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x41a:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfff41b) = %02x\n", data & 0x00ff);
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PDPUEN = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pdpuen = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x41c:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PDIRQEN = %02x\n", data & 0x00ff);
- m_regs.pdirqen = data & 0x00ff;
-
- poll_port_d_interrupts();
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PDPOL = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pdpol = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x41e:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PDIRQEDGE = %02x\n", data & 0x00ff);
- m_regs.pdirqedge = data & 0x00ff;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfff41e) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0x420:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PEDATA = %02x\n", data & 0x00ff);
- m_regs.pedata = data & 0x00ff;
- if (!m_out_port_e_cb.isnull())
- {
- m_out_port_e_cb((offs_t)0, data & 0x00ff);
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PEDIR = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pedir = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x422:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PESEL = %02x\n", data & 0x00ff);
- m_regs.pesel = data & 0x00ff;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PEPUEN = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pepuen = (data >> 8) & 0x00ff;
- m_regs.pedata |= m_regs.pepuen;
- }
- break;
-
- case 0x428:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PFDATA = %02x\n", data & 0x00ff);
- m_regs.pfdata = data & 0x00ff;
- if (!m_out_port_f_cb.isnull())
- {
- m_out_port_f_cb((offs_t)0, data & 0x00ff);
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PFDIR = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pfdir = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x42a:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PFSEL = %02x\n", data & 0x00ff);
- m_regs.pfsel = data & 0x00ff;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PFPUEN = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pfpuen = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x430:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PGDATA = %02x\n", data & 0x00ff);
- m_regs.pgdata = data & 0x00ff;
- if (!m_out_port_g_cb.isnull())
- {
- m_out_port_g_cb((offs_t)0, data & 0x00ff);
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PGDIR = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pgdir = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x432:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PGSEL = %02x\n", data & 0x00ff);
- m_regs.pgsel = data & 0x00ff;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PGPUEN = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pgpuen = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x438:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PJDATA = %02x\n", data & 0x00ff);
- m_regs.pjdata = data & 0x00ff;
- if (!m_out_port_j_cb.isnull())
- {
- m_out_port_j_cb((offs_t)0, data & 0x00ff);
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PJDIR = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pjdir = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x43a:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PJSEL = %02x\n", data & 0x00ff);
- m_regs.pjsel = data & 0x00ff;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfff43a) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0x440:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PKDATA = %02x\n", data & 0x00ff);
- m_regs.pkdata = data & 0x00ff;
- if (!m_out_port_k_cb.isnull())
- {
- m_out_port_k_cb((offs_t)0, data & 0x00ff);
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PKDIR = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pkdir = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x442:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PKSEL = %02x\n", data & 0x00ff);
- m_regs.pksel = data & 0x00ff;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PKPUEN = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pgpuen = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x448:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PMDATA = %02x\n", data & 0x00ff);
- m_regs.pmdata = data & 0x00ff;
- if (!m_out_port_m_cb.isnull())
- {
- m_out_port_m_cb((offs_t)0, data & 0x00ff);
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PMDIR = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pmdir = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x44a:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: PMSEL = %02x\n", data & 0x00ff);
- m_regs.pmsel = data & 0x00ff;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: PMPUEN = %02x\n", (data >> 8) & 0x00ff);
- m_regs.pmpuen = (data >> 8) & 0x00ff;
- }
- break;
-
- case 0x500:
- verboselog(machine(), 2, "mc68328_w: PWMC = %04x\n", data);
-
- m_regs.pwmc = data;
-
- if (m_regs.pwmc & PWMC_PWMIRQ)
- {
- set_interrupt_line(INT_PWM, 1);
- }
-
- m_regs.pwmc &= ~PWMC_LOAD;
-
- if ((m_regs.pwmc & PWMC_PWMEN) != 0 && m_regs.pwmw != 0 && m_regs.pwmp != 0)
- {
- UINT32 frequency = 32768 * 506;
- UINT32 divisor = 4 << (m_regs.pwmc & PWMC_CLKSEL); // ?? Datasheet says 2 <<, but then we're an octave higher than CoPilot.
- attotime period;
- frequency /= divisor;
- period = attotime::from_hz(frequency) * m_regs.pwmw;
- m_pwm->adjust(period);
- if (m_regs.pwmc & PWMC_IRQEN)
- {
- set_interrupt_line(INT_PWM, 1);
- }
- m_regs.pwmc ^= PWMC_PIN;
- }
- else
- {
- m_pwm->adjust(attotime::never);
- }
- break;
-
- case 0x502:
- verboselog(machine(), 2, "mc68328_w: PWMP = %04x\n", data);
- m_regs.pwmp = data;
- break;
-
- case 0x504:
- verboselog(machine(), 2, "mc68328_w: PWMW = %04x\n", data);
- m_regs.pwmw = data;
- break;
-
- case 0x506:
- verboselog(machine(), 2, "mc68328_w: PWMCNT = %04x\n", data);
- m_regs.pwmcnt = 0;
- break;
-
- case 0x600:
- verboselog(machine(), 2, "mc68328_w: TCTL1 = %04x\n", data);
- temp16[0] = m_regs.tctl[0];
- m_regs.tctl[0] = data;
- if ((temp16[0] & TCTL_TEN) == (m_regs.tctl[0] & TCTL_TEN))
- {
- maybe_start_timer(0, 0);
- }
- else if ((temp16[0] & TCTL_TEN) != TCTL_TEN_ENABLE && (m_regs.tctl[0] & TCTL_TEN) == TCTL_TEN_ENABLE)
- {
- maybe_start_timer(0, 1);
- }
- break;
-
- case 0x602:
- verboselog(machine(), 2, "mc68328_w: TPRER1 = %04x\n", data);
- m_regs.tprer[0] = data;
- maybe_start_timer(0, 0);
- break;
-
- case 0x604:
- verboselog(machine(), 2, "mc68328_w: TCMP1 = %04x\n", data);
- m_regs.tcmp[0] = data;
- maybe_start_timer(0, 0);
- break;
-
- case 0x606:
- verboselog(machine(), 2, "mc68328_w: TCR1 = %04x (Ignored)\n", data);
- break;
-
- case 0x608:
- verboselog(machine(), 2, "mc68328_w: TCN1 = %04x (Ignored)\n", data);
- break;
-
- case 0x60a:
- verboselog(machine(), 5, "mc68328_w: TSTAT1 = %04x\n", data);
- m_regs.tstat[0] &= ~m_regs.tclear[0];
- if (!(m_regs.tstat[0] & TSTAT_COMP))
- {
- set_interrupt_line(INT_TIMER1, 0);
- }
- break;
-
- case 0x60c:
- verboselog(machine(), 2, "mc68328_w: TCTL2 = %04x\n", data);
- temp16[0] = m_regs.tctl[1];
- m_regs.tctl[1] = data;
- if ((temp16[0] & TCTL_TEN) == (m_regs.tctl[1] & TCTL_TEN))
- {
- maybe_start_timer(1, 0);
- }
- else if ((temp16[0] & TCTL_TEN) != TCTL_TEN_ENABLE && (m_regs.tctl[1] & TCTL_TEN) == TCTL_TEN_ENABLE)
- {
- maybe_start_timer(1, 1);
- }
- break;
-
- case 0x60e:
- verboselog(machine(), 2, "mc68328_w: TPRER2 = %04x\n", data);
- m_regs.tprer[1] = data;
- maybe_start_timer(1, 0);
- break;
-
- case 0x610:
- verboselog(machine(), 2, "mc68328_w: TCMP2 = %04x\n", data);
- m_regs.tcmp[1] = data;
- maybe_start_timer(1, 0);
- break;
-
- case 0x612:
- verboselog(machine(), 2, "mc68328_w: TCR2 = %04x (Ignored)\n", data);
- break;
-
- case 0x614:
- verboselog(machine(), 2, "mc68328_w: TCN2 = %04x (Ignored)\n", data);
- break;
-
- case 0x616:
- verboselog(machine(), 2, "mc68328_w: TSTAT2 = %04x\n", data);
- m_regs.tstat[1] &= ~m_regs.tclear[1];
- if (!(m_regs.tstat[1] & TSTAT_COMP))
- {
- set_interrupt_line(INT_TIMER2, 0);
- }
- break;
-
- case 0x618:
- verboselog(machine(), 2, "mc68328_w: WCTLR = %04x\n", data);
- m_regs.wctlr = data;
- break;
-
- case 0x61a:
- verboselog(machine(), 2, "mc68328_w: WCMPR = %04x\n", data);
- m_regs.wcmpr = data;
- break;
-
- case 0x61c:
- verboselog(machine(), 2, "mc68328_w: WCN = %04x (Ignored)\n", data);
- break;
-
- case 0x700:
- verboselog(machine(), 2, "mc68328_w: SPISR = %04x\n", data);
- m_regs.spisr = data;
- break;
-
- case 0x800:
- verboselog(machine(), 2, "mc68328_w: SPIMDATA = %04x\n", data);
- if (!m_out_spim_cb.isnull())
- {
- m_out_spim_cb(0, data, 0xffff);
- }
- else
- {
- m_regs.spimdata = data;
- }
- break;
-
- case 0x802:
- verboselog(machine(), 2, "mc68328_w: SPIMCONT = %04x\n", data);
- verboselog(machine(), 3, " Count = %d\n", data & SPIM_CLOCK_COUNT);
- verboselog(machine(), 3, " Polarity = %s\n", (data & SPIM_POL) ? "Inverted" : "Active-high");
- verboselog(machine(), 3, " Phase = %s\n", (data & SPIM_PHA) ? "Opposite" : "Normal");
- verboselog(machine(), 3, " IRQ Enable = %s\n", (data & SPIM_IRQEN) ? "Enable" : "Disable");
- verboselog(machine(), 3, " IRQ Pending = %s\n", (data & SPIM_SPIMIRQ) ? "Yes" : "No");
- verboselog(machine(), 3, " Exchange = %s\n", (data & SPIM_XCH) ? "Initiate" : "Idle");
- verboselog(machine(), 3, " SPIM Enable = %s\n", (data & SPIM_SPMEN) ? "Enable" : "Disable");
- verboselog(machine(), 3, " Data Rate = Divide By %d\n", 1 << ((((data & SPIM_RATE) >> 13) & 0x0007) + 2) );
- m_regs.spimcont = data;
- // $$HACK$$ We should probably emulate the ADS7843 A/D device properly.
- if (data & SPIM_XCH)
- {
- m_regs.spimcont &= ~SPIM_XCH;
- if (!m_spim_xch_trigger_cb.isnull())
- {
- m_spim_xch_trigger_cb(0);
- }
- if (data & SPIM_IRQEN)
- {
- m_regs.spimcont |= SPIM_SPIMIRQ;
- verboselog(machine(), 3, "Triggering SPIM Interrupt\n" );
- set_interrupt_line(INT_SPIM, 1);
- }
- }
- if (!(data & SPIM_IRQEN))
- {
- set_interrupt_line(INT_SPIM, 0);
- }
- break;
-
- case 0x900:
- verboselog(machine(), 2, "mc68328_w: USTCNT = %04x\n", data);
- m_regs.ustcnt = data;
- break;
-
- case 0x902:
- verboselog(machine(), 2, "mc68328_w: UBAUD = %04x\n", data);
- m_regs.ubaud = data;
- break;
-
- case 0x904:
- verboselog(machine(), 2, "mc68328_w: URX = %04x\n", data);
- break;
-
- case 0x906:
- verboselog(machine(), 2, "mc68328_w: UTX = %04x\n", data);
- break;
-
- case 0x908:
- verboselog(machine(), 2, "mc68328_w: UMISC = %04x\n", data);
- m_regs.umisc = data;
- break;
-
- case 0xa00:
- verboselog(machine(), 2, "mc68328_w: LSSA(16) = %04x\n", data);
- m_regs.lssa &= ~(mem_mask << 16);
- m_regs.lssa |= (data & mem_mask) << 16;
- verboselog(machine(), 3, " Address: %08x\n", m_regs.lssa);
- break;
-
- case 0xa02:
- verboselog(machine(), 2, "mc68328_w: LSSA(0) = %04x\n", data);
- m_regs.lssa &= 0xffff0000 | (~mem_mask);
- m_regs.lssa |= data & mem_mask;
- verboselog(machine(), 3, " Address: %08x\n", m_regs.lssa);
- break;
-
- case 0xa04:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: LVPW = %02x\n", data & 0x00ff);
- m_regs.lvpw = data & 0x00ff;
- verboselog(machine(), 3, " Page Width: %d\n", (m_regs.lvpw + 1) * ((m_regs.lpicf & 0x01) ? 8 : 16));
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfffa04) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0xa08:
- verboselog(machine(), 2, "mc68328_w: LXMAX = %04x\n", data);
- m_regs.lxmax = data;
- verboselog(machine(), 3, " Width: %d\n", (data & 0x03ff) + 1);
- break;
-
- case 0xa0a:
- verboselog(machine(), 2, "mc68328_w: LYMAX = %04x\n", data);
- m_regs.lymax = data;
- verboselog(machine(), 3, " Height: %d\n", (data & 0x03ff) + 1);
- break;
-
- case 0xa18:
- verboselog(machine(), 2, "mc68328_w: LCXP = %04x\n", data);
- m_regs.lcxp = data;
- verboselog(machine(), 3, " X Position: %d\n", data & 0x03ff);
- switch (m_regs.lcxp >> 14)
- {
- case 0:
- verboselog(machine(), 3, " Cursor Control: Transparent\n");
- break;
-
- case 1:
- verboselog(machine(), 3, " Cursor Control: Black\n");
- break;
-
- case 2:
- verboselog(machine(), 3, " Cursor Control: Reverse\n");
- break;
-
- case 3:
- verboselog(machine(), 3, " Cursor Control: Invalid\n");
- break;
- }
- break;
-
- case 0xa1a:
- verboselog(machine(), 2, "mc68328_w: LCYP = %04x\n", data);
- m_regs.lcyp = data;
- verboselog(machine(), 3, " Y Position: %d\n", data & 0x01ff);
- break;
-
- case 0xa1c:
- verboselog(machine(), 2, "mc68328_w: LCWCH = %04x\n", data);
- m_regs.lcwch = data;
- verboselog(machine(), 3, " Width: %d\n", (data >> 8) & 0x1f);
- verboselog(machine(), 3, " Height: %d\n", data & 0x1f);
- break;
-
- case 0xa1e:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: LBLKC = %02x\n", data & 0x00ff);
- m_regs.lblkc = data & 0x00ff;
- verboselog(machine(), 3, " Blink Enable: %d\n", m_regs.lblkc >> 7);
- verboselog(machine(), 3, " Blink Divisor: %d\n", m_regs.lblkc & 0x7f);
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfffa1e) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0xa20:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: LPOLCF = %02x\n", data & 0x00ff);
- m_regs.lpolcf = data & 0x00ff;
- verboselog(machine(), 3, " LCD Shift Clock Polarity: %s\n", (m_regs.lpicf & 0x08) ? "Active positive edge of LCLK" : "Active negative edge of LCLK");
- verboselog(machine(), 3, " First-line marker polarity: %s\n", (m_regs.lpicf & 0x04) ? "Active Low" : "Active High");
- verboselog(machine(), 3, " Line-pulse polarity: %s\n", (m_regs.lpicf & 0x02) ? "Active Low" : "Active High");
- verboselog(machine(), 3, " Pixel polarity: %s\n", (m_regs.lpicf & 0x01) ? "Active Low" : "Active High");
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: LPICF = %02x\n", (data >> 8) & 0x00ff);
- m_regs.lpicf = (data >> 8) & 0x00ff;
- switch((m_regs.lpicf >> 1) & 0x03)
- {
- case 0:
- verboselog(machine(), 3, " Bus Size: 1-bit\n");
- break;
-
- case 1:
- verboselog(machine(), 3, " Bus Size: 2-bit\n");
- break;
-
- case 2:
- verboselog(machine(), 3, " Bus Size: 4-bit\n");
- break;
-
- case 3:
- verboselog(machine(), 3, " Bus Size: unused\n");
- break;
- }
- verboselog(machine(), 3, " Gray scale enable: %d\n", m_regs.lpicf & 0x01);
- }
- break;
-
- case 0xa22:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: LACDRC = %02x\n", data & 0x00ff);
- m_regs.lacdrc = data & 0x00ff;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfffa22) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0xa24:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: LPXCD = %02x\n", data & 0x00ff);
- m_regs.lpxcd = data & 0x00ff;
- verboselog(machine(), 3, " Clock Divisor: %d\n", m_regs.lpxcd + 1);
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfffa24) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0xa26:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: LCKCON = %02x\n", data & 0x00ff);
- m_regs.lckcon = data & 0x00ff;
- verboselog(machine(), 3, " LCDC Enable: %d\n", (m_regs.lckcon >> 7) & 0x01);
- verboselog(machine(), 3, " DMA Burst Length: %d\n", ((m_regs.lckcon >> 6) & 0x01) ? 16 : 8);
- verboselog(machine(), 3, " DMA Bursting Clock Control: %d\n", ((m_regs.lckcon >> 4) & 0x03) + 1);
- verboselog(machine(), 3, " Bus Width: %d\n", ((m_regs.lckcon >> 1) & 0x01) ? 8 : 16);
- verboselog(machine(), 3, " Pixel Clock Divider Source: %s\n", (m_regs.lckcon & 0x01) ? "PIX" : "SYS");
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfffa26) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0xa28:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: LLBAR = %02x\n", data & 0x00ff);
- m_regs.llbar = data & 0x00ff;
- verboselog(machine(), 3, " Address: %d\n", (m_regs.llbar & 0x7f) * ((m_regs.lpicf & 0x01) ? 8 : 16));
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfffa28) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0xa2a:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: LOTCR = %02x\n", data & 0x00ff);
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfffa2a) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0xa2c:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: LPOSR = %02x\n", data & 0x00ff);
- m_regs.lposr = data & 0x00ff;
- verboselog(machine(), 3, " Byte Offset: %d\n", (m_regs.lposr >> 3) & 0x01);
- verboselog(machine(), 3, " Pixel Offset: %d\n", m_regs.lposr & 0x07);
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfffa2c) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0xa30:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_w: LFRCM = %02x\n", data & 0x00ff);
- m_regs.lfrcm = data & 0x00ff;
- verboselog(machine(), 3, " X Modulation: %d\n", (m_regs.lfrcm >> 4) & 0x0f);
- verboselog(machine(), 3, " Y Modulation: %d\n", m_regs.lfrcm & 0x0f);
- }
- else
- {
- verboselog(machine(), 2, "mc68328_w: Unknown address (0xfffa30) = %02x\n", (data >> 8) & 0x00ff);
- }
- break;
-
- case 0xa32:
- verboselog(machine(), 2, "mc68328_w: LGPMR = %04x\n", data);
- m_regs.lgpmr = data;
- verboselog(machine(), 3, " Palette 0: %d\n", (m_regs.lgpmr >> 8) & 0x07);
- verboselog(machine(), 3, " Palette 1: %d\n", (m_regs.lgpmr >> 12) & 0x07);
- verboselog(machine(), 3, " Palette 2: %d\n", (m_regs.lgpmr >> 0) & 0x07);
- verboselog(machine(), 3, " Palette 3: %d\n", (m_regs.lgpmr >> 4) & 0x07);
- break;
-
- case 0xb00:
- verboselog(machine(), 2, "mc68328_w: HMSR(0) = %04x\n", data);
- m_regs.hmsr &= ~(mem_mask << 16);
- m_regs.hmsr |= (data & mem_mask) << 16;
- m_regs.hmsr &= 0x1f3f003f;
- break;
-
- case 0xb02:
- verboselog(machine(), 2, "mc68328_w: HMSR(16) = %04x\n", data);
- m_regs.hmsr &= 0xffff0000 | (~mem_mask);
- m_regs.hmsr |= data & mem_mask;
- m_regs.hmsr &= 0x1f3f003f;
- break;
-
- case 0xb04:
- verboselog(machine(), 2, "mc68328_w: ALARM(0) = %04x\n", data);
- m_regs.alarm &= ~(mem_mask << 16);
- m_regs.alarm |= (data & mem_mask) << 16;
- m_regs.alarm &= 0x1f3f003f;
- break;
-
- case 0xb06:
- verboselog(machine(), 2, "mc68328_w: ALARM(16) = %04x\n", data);
- m_regs.alarm &= 0xffff0000 | (~mem_mask);
- m_regs.alarm |= data & mem_mask;
- m_regs.alarm &= 0x1f3f003f;
- break;
-
- case 0xb0c:
- verboselog(machine(), 2, "mc68328_w: RTCCTL = %04x\n", data);
- m_regs.rtcctl = data & 0x00a0;
- break;
-
- case 0xb0e:
- verboselog(machine(), 2, "mc68328_w: RTCISR = %04x\n", data);
- m_regs.rtcisr &= ~data;
- if (m_regs.rtcisr == 0)
- {
- set_interrupt_line(INT_RTC, 0);
- }
- break;
-
- case 0xb10:
- verboselog(machine(), 2, "mc68328_w: RTCIENR = %04x\n", data);
- m_regs.rtcienr = data & 0x001f;
- break;
-
- case 0xb12:
- verboselog(machine(), 2, "mc68328_w: STPWTCH = %04x\n", data);
- m_regs.stpwtch = data & 0x003f;
- break;
-
- default:
- verboselog(machine(), 0, "mc68328_w: Unknown address (0x%06x) = %04x (%04x)\n", 0xfff000 + address, data, mem_mask);
- break;
- }
-}
-
-READ16_MEMBER( mc68328_device::read )
-{
- UINT16 temp16 = 0;
- UINT32 address = offset << 1;
-
- switch (address)
- {
- case 0x000:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfff001)\n", mem_mask);
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): SCR = %02x\n", mem_mask, m_regs.scr);
- return m_regs.scr << 8;
- }
- break;
-
- case 0x100:
- verboselog(machine(), 2, "mc68328_r (%04x): GRPBASEA = %04x\n", mem_mask, m_regs.grpbasea);
- return m_regs.grpbasea;
-
- case 0x102:
- verboselog(machine(), 2, "mc68328_r (%04x): GRPBASEB = %04x\n", mem_mask, m_regs.grpbaseb);
- return m_regs.grpbaseb;
-
- case 0x104:
- verboselog(machine(), 2, "mc68328_r (%04x): GRPBASEC = %04x\n", mem_mask, m_regs.grpbasec);
- return m_regs.grpbasec;
-
- case 0x106:
- verboselog(machine(), 2, "mc68328_r (%04x): GRPBASED = %04x\n", mem_mask, m_regs.grpbased);
- return m_regs.grpbased;
-
- case 0x108:
- verboselog(machine(), 2, "mc68328_r (%04x): GRPMASKA = %04x\n", mem_mask, m_regs.grpmaska);
- return m_regs.grpmaska;
-
- case 0x10a:
- verboselog(machine(), 2, "mc68328_r (%04x): GRPMASKB = %04x\n", mem_mask, m_regs.grpmaskb);
- return m_regs.grpmaskb;
-
- case 0x10c:
- verboselog(machine(), 2, "mc68328_r (%04x): GRPMASKC = %04x\n", mem_mask, m_regs.grpmaskc);
- return m_regs.grpmaskc;
-
- case 0x10e:
- verboselog(machine(), 2, "mc68328_r (%04x): GRPMASKD = %04x\n", mem_mask, m_regs.grpmaskd);
- return m_regs.grpmaskd;
-
- case 0x110:
- verboselog(machine(), 5, "mc68328_r (%04x): CSA0(0) = %04x\n", mem_mask, m_regs.csa0 & 0x0000ffff);
- return m_regs.csa0 & 0x0000ffff;
-
- case 0x112:
- verboselog(machine(), 5, "mc68328_r (%04x): CSA0(16) = %04x\n", mem_mask, m_regs.csa0 >> 16);
- return m_regs.csa0 >> 16;
-
- case 0x114:
- verboselog(machine(), 5, "mc68328_r (%04x): CSA1(0) = %04x\n", mem_mask, m_regs.csa1 & 0x0000ffff);
- return m_regs.csa1 & 0x0000ffff;
-
- case 0x116:
- verboselog(machine(), 5, "mc68328_r (%04x): CSA1(16) = %04x\n", mem_mask, m_regs.csa1 >> 16);
- return m_regs.csa1 >> 16;
-
- case 0x118:
- verboselog(machine(), 5, "mc68328_r (%04x): CSA2(0) = %04x\n", mem_mask, m_regs.csa2 & 0x0000ffff);
- return m_regs.csa2 & 0x0000ffff;
-
- case 0x11a:
- verboselog(machine(), 5, "mc68328_r (%04x): CSA2(16) = %04x\n", mem_mask, m_regs.csa2 >> 16);
- return m_regs.csa2 >> 16;
-
- case 0x11c:
- verboselog(machine(), 5, "mc68328_r (%04x): CSA3(0) = %04x\n", mem_mask, m_regs.csa3 & 0x0000ffff);
- return m_regs.csa3 & 0x0000ffff;
-
- case 0x11e:
- verboselog(machine(), 5, "mc68328_r (%04x): CSA3(16) = %04x\n", mem_mask, m_regs.csa3 >> 16);
- return m_regs.csa3 >> 16;
-
- case 0x120:
- verboselog(machine(), 5, "mc68328_r (%04x): CSB0(0) = %04x\n", mem_mask, m_regs.csb0 & 0x0000ffff);
- return m_regs.csb0 & 0x0000ffff;
-
- case 0x122:
- verboselog(machine(), 5, "mc68328_r (%04x): CSB0(16) = %04x\n", mem_mask, m_regs.csb0 >> 16);
- return m_regs.csb0 >> 16;
-
- case 0x124:
- verboselog(machine(), 5, "mc68328_r (%04x): CSB1(0) = %04x\n", mem_mask, m_regs.csb1 & 0x0000ffff);
- return m_regs.csb1 & 0x0000ffff;
-
- case 0x126:
- verboselog(machine(), 5, "mc68328_r (%04x): CSB1(16) = %04x\n", mem_mask, m_regs.csb1 >> 16);
- return m_regs.csb1 >> 16;
-
- case 0x128:
- verboselog(machine(), 5, "mc68328_r (%04x): CSB2(0) = %04x\n", mem_mask, m_regs.csb2 & 0x0000ffff);
- return m_regs.csb2 & 0x0000ffff;
-
- case 0x12a:
- verboselog(machine(), 5, "mc68328_r (%04x): CSB2(16) = %04x\n", mem_mask, m_regs.csb2 >> 16);
- return m_regs.csb2 >> 16;
-
- case 0x12c:
- verboselog(machine(), 5, "mc68328_r (%04x): CSB3(0) = %04x\n", mem_mask, m_regs.csb3 & 0x0000ffff);
- return m_regs.csb3 & 0x0000ffff;
-
- case 0x12e:
- verboselog(machine(), 5, "mc68328_r (%04x): CSB3(16) = %04x\n", mem_mask, m_regs.csb3 >> 16);
- return m_regs.csb3 >> 16;
-
- case 0x130:
- verboselog(machine(), 5, "mc68328_r (%04x): CSC0(0) = %04x\n", mem_mask, m_regs.csc0 & 0x0000ffff);
- return m_regs.csc0 & 0x0000ffff;
-
- case 0x132:
- verboselog(machine(), 5, "mc68328_r (%04x): CSC0(16) = %04x\n", mem_mask, m_regs.csc0 >> 16);
- return m_regs.csc0 >> 16;
-
- case 0x134:
- verboselog(machine(), 5, "mc68328_r (%04x): CSC1(0) = %04x\n", mem_mask, m_regs.csc1 & 0x0000ffff);
- return m_regs.csc1 & 0x0000ffff;
-
- case 0x136:
- verboselog(machine(), 5, "mc68328_r (%04x): CSC1(16) = %04x\n", mem_mask, m_regs.csc1 >> 16);
- return m_regs.csc1 >> 16;
-
- case 0x138:
- verboselog(machine(), 5, "mc68328_r (%04x): CSC2(0) = %04x\n", mem_mask, m_regs.csc2 & 0x0000ffff);
- return m_regs.csc2 & 0x0000ffff;
-
- case 0x13a:
- verboselog(machine(), 5, "mc68328_r (%04x): CSC2(16) = %04x\n", mem_mask, m_regs.csc2 >> 16);
- return m_regs.csc2 >> 16;
-
- case 0x13c:
- verboselog(machine(), 5, "mc68328_r (%04x): CSC3(0) = %04x\n", mem_mask, m_regs.csc3 & 0x0000ffff);
- return m_regs.csc3 & 0x0000ffff;
-
- case 0x13e:
- verboselog(machine(), 5, "mc68328_r (%04x): CSC3(16) = %04x\n", mem_mask, m_regs.csc3 >> 16);
- return m_regs.csc3 >> 16;
-
- case 0x140:
- verboselog(machine(), 5, "mc68328_r (%04x): CSD0(0) = %04x\n", mem_mask, m_regs.csd0 & 0x0000ffff);
- return m_regs.csd0 & 0x0000ffff;
-
- case 0x142:
- verboselog(machine(), 5, "mc68328_r (%04x): CSD0(16) = %04x\n", mem_mask, m_regs.csd0 >> 16);
- return m_regs.csd0 >> 16;
-
- case 0x144:
- verboselog(machine(), 5, "mc68328_r (%04x): CSD1(0) = %04x\n", mem_mask, m_regs.csd1 & 0x0000ffff);
- return m_regs.csd1 & 0x0000ffff;
-
- case 0x146:
- verboselog(machine(), 5, "mc68328_r (%04x): CSD1(16) = %04x\n", mem_mask, m_regs.csd1 >> 16);
- return m_regs.csd1 >> 16;
-
- case 0x148:
- verboselog(machine(), 5, "mc68328_r (%04x): CSD2(0) = %04x\n", mem_mask, m_regs.csd2 & 0x0000ffff);
- return m_regs.csd2 & 0x0000ffff;
-
- case 0x14a:
- verboselog(machine(), 5, "mc68328_r (%04x): CSD2(16) = %04x\n", mem_mask, m_regs.csd2 >> 16);
- return m_regs.csd2 >> 16;
-
- case 0x14c:
- verboselog(machine(), 5, "mc68328_r (%04x): CSD3(0) = %04x\n", mem_mask, m_regs.csd3 & 0x0000ffff);
- return m_regs.csd3 & 0x0000ffff;
-
- case 0x14e:
- verboselog(machine(), 5, "mc68328_r (%04x): CSD3(16) = %04x\n", mem_mask, m_regs.csd3 >> 16);
- return m_regs.csd3 >> 16;
-
- case 0x200:
- verboselog(machine(), 2, "mc68328_r (%04x): PLLCR = %04x\n", mem_mask, m_regs.pllcr);
- return m_regs.pllcr;
-
- case 0x202:
- verboselog(machine(), 2, "mc68328_r (%04x): PLLFSR = %04x\n", mem_mask, m_regs.pllfsr);
- m_regs.pllfsr ^= 0x8000;
- return m_regs.pllfsr;
-
- case 0x206:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfff206)\n", mem_mask);
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PCTLR = %02x\n", mem_mask, m_regs.pctlr);
- return m_regs.pctlr << 8;
- }
- break;
-
- case 0x300:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfff301)\n", mem_mask);
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): IVR = %02x\n", mem_mask, m_regs.ivr);
- return m_regs.ivr << 8;
- }
- break;
-
- case 0x302:
- verboselog(machine(), 2, "mc68328_r (%04x): ICR = %04x\n", mem_mask, m_regs.icr);
- return m_regs.icr;
-
- case 0x304:
- verboselog(machine(), 2, "mc68328_r (%04x): IMR(16) = %04x\n", mem_mask, m_regs.imr >> 16);
- return m_regs.imr >> 16;
-
- case 0x306:
- verboselog(machine(), 2, "mc68328_r (%04x): IMR(0) = %04x\n", mem_mask, m_regs.imr & 0x0000ffff);
- return m_regs.imr & 0x0000ffff;
-
- case 0x308:
- verboselog(machine(), 2, "mc68328_r (%04x): IWR(16) = %04x\n", mem_mask, m_regs.iwr >> 16);
- return m_regs.iwr >> 16;
-
- case 0x30a:
- verboselog(machine(), 2, "mc68328_r (%04x): IWR(0) = %04x\n", mem_mask, m_regs.iwr & 0x0000ffff);
- return m_regs.iwr & 0x0000ffff;
-
- case 0x30c:
- verboselog(machine(), 2, "mc68328_r (%04x): ISR(16) = %04x\n", mem_mask, m_regs.isr >> 16);
- return m_regs.isr >> 16;
-
- case 0x30e:
- verboselog(machine(), 2, "mc68328_r (%04x): ISR(0) = %04x\n", mem_mask, m_regs.isr & 0x0000ffff);
- return m_regs.isr & 0x0000ffff;
-
- case 0x310:
- verboselog(machine(), 2, "mc68328_r (%04x): IPR(16) = %04x\n", mem_mask, m_regs.ipr >> 16);
- return m_regs.ipr >> 16;
-
- case 0x312:
- verboselog(machine(), 2, "mc68328_r (%04x): IPR(0) = %04x\n", mem_mask, m_regs.ipr & 0x0000ffff);
- return m_regs.ipr & 0x0000ffff;
-
- case 0x400:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PADATA = %02x\n", mem_mask, m_regs.padata);
- if (!m_in_port_a_cb.isnull())
- {
- return m_in_port_a_cb(0);
- }
- else
- {
- return m_regs.padata;
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PADIR = %02x\n", mem_mask, m_regs.padir);
- return m_regs.padir << 8;
- }
-
- case 0x402:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PASEL = %02x\n", mem_mask, m_regs.pasel);
- return m_regs.pasel;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfff402)\n", mem_mask);
- }
- break;
-
- case 0x408:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PBDATA = %02x\n", mem_mask, m_regs.pbdata);
- if (!m_in_port_b_cb.isnull())
- {
- return m_in_port_b_cb(0);
- }
- else
- {
- return m_regs.pbdata;
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PBDIR = %02x\n", mem_mask, m_regs.pbdir);
- return m_regs.pbdir << 8;
- }
-
- case 0x40a:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PBSEL = %02x\n", mem_mask, m_regs.pbsel);
- return m_regs.pbsel;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfff40a)\n", mem_mask);
- }
- break;
-
- case 0x410:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PCDATA = %02x\n", mem_mask, m_regs.pcdata);
- if (!m_in_port_c_cb.isnull())
- {
- return m_in_port_c_cb(0);
- }
- else
- {
- return m_regs.pcdata;
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PCDIR = %02x\n", mem_mask, m_regs.pcdir);
- return m_regs.pcdir << 8;
- }
-
- case 0x412:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PCSEL = %02x\n", mem_mask, m_regs.pcsel);
- return m_regs.pcsel;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfff412)\n", mem_mask);
- }
- break;
-
- case 0x418:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PDDATA = %02x\n", mem_mask, m_regs.pddata);
- if (!m_in_port_d_cb.isnull())
- {
- return m_in_port_d_cb(0);
- }
- else
- {
- return m_regs.pddata;
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PDDIR = %02x\n", mem_mask, m_regs.pddir);
- return m_regs.pddir << 8;
- }
-
- case 0x41a:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfff41b)\n", mem_mask);
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PDPUEN = %02x\n", mem_mask, m_regs.pdpuen);
- return m_regs.pdpuen << 8;
- }
- break;
-
- case 0x41c:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PDIRQEN = %02x\n", mem_mask, m_regs.pdirqen);
- return m_regs.pdirqen;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PDPOL = %02x\n", mem_mask, m_regs.pdpol);
- return m_regs.pdpol << 8;
- }
-
- case 0x41e:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PDIRQEDGE = %02x\n", mem_mask, m_regs.pdirqedge);
- return m_regs.pdirqedge;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfff41e)\n", mem_mask);
- }
- break;
-
- case 0x420:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PEDATA = %02x\n", mem_mask, m_regs.pedata);
- if (!m_in_port_e_cb.isnull())
- {
- return m_in_port_e_cb(0);
- }
- else
- {
- return m_regs.pedata;
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PEDIR = %02x\n", mem_mask, m_regs.pedir);
- return m_regs.pedir << 8;
- }
-
- case 0x422:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PESEL = %02x\n", mem_mask, m_regs.pesel);
- return m_regs.pesel;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PEPUEN = %02x\n", mem_mask, m_regs.pepuen);
- return m_regs.pepuen << 8;
- }
-
- case 0x428:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PFDATA = %02x\n", mem_mask, m_regs.pfdata);
- if (!m_in_port_f_cb.isnull())
- {
- return m_in_port_f_cb(0);
- }
- else
- {
- return m_regs.pfdata;
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PFDIR = %02x\n", mem_mask, m_regs.pfdir);
- return m_regs.pfdir << 8;
- }
-
- case 0x42a:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PFSEL = %02x\n", mem_mask, m_regs.pfsel);
- return m_regs.pfsel;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PFPUEN = %02x\n", mem_mask, m_regs.pfpuen);
- return m_regs.pfpuen << 8;
- }
-
- case 0x430:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PGDATA = %02x\n", mem_mask, m_regs.pgdata);
- if (!m_in_port_g_cb.isnull())
- {
- return m_in_port_g_cb(0);
- }
- else
- {
- return m_regs.pgdata;
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PGDIR = %02x\n", mem_mask, m_regs.pgdir);
- return m_regs.pgdir << 8;
- }
-
- case 0x432:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PGSEL = %02x\n", mem_mask, m_regs.pgsel);
- return m_regs.pgsel;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PGPUEN = %02x\n", mem_mask, m_regs.pgpuen);
- return m_regs.pgpuen << 8;
- }
-
- case 0x438:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PJDATA = %02x\n", mem_mask, m_regs.pjdata);
- if (!m_in_port_j_cb.isnull())
- {
- return m_in_port_j_cb(0);
- }
- else
- {
- return m_regs.pjdata;
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PJDIR = %02x\n", mem_mask, m_regs.pjdir);
- return m_regs.pjdir << 8;
- }
-
- case 0x43a:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PJSEL = %02x\n", mem_mask, m_regs.pjsel);
- return m_regs.pjsel;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfff43a)\n", mem_mask);
- }
- break;
-
- case 0x440:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PKDATA = %02x\n", mem_mask, m_regs.pkdata);
- if (!m_in_port_k_cb.isnull())
- {
- return m_in_port_k_cb(0);
- }
- else
- {
- return m_regs.pkdata;
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PKDIR = %02x\n", mem_mask, m_regs.pkdir);
- return m_regs.pkdir << 8;
- }
-
- case 0x442:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PKSEL = %02x\n", mem_mask, m_regs.pksel);
- return m_regs.pksel;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PKPUEN = %02x\n", mem_mask, m_regs.pkpuen);
- return m_regs.pkpuen << 8;
- }
-
- case 0x448:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PMDATA = %02x\n", mem_mask, m_regs.pmdata);
- if (!m_in_port_m_cb.isnull())
- {
- return m_in_port_m_cb(0);
- }
- else
- {
- return m_regs.pmdata;
- }
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PMDIR = %02x\n", mem_mask, m_regs.pmdir);
- return m_regs.pmdir << 8;
- }
-
- case 0x44a:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PMSEL = %02x\n", mem_mask, m_regs.pmsel);
- return m_regs.pmsel;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): PMPUEN = %02x\n", mem_mask, m_regs.pmpuen);
- return m_regs.pmpuen << 8;
- }
-
- case 0x500:
- verboselog(machine(), 2, "mc68328_r (%04x): PWMC = %04x\n", mem_mask, m_regs.pwmc);
- temp16 = m_regs.pwmc;
- if (m_regs.pwmc & PWMC_PWMIRQ)
- {
- m_regs.pwmc &= ~PWMC_PWMIRQ;
- set_interrupt_line(INT_PWM, 0);
- }
- return temp16;
-
- case 0x502:
- verboselog(machine(), 2, "mc68328_r (%04x): PWMP = %04x\n", mem_mask, m_regs.pwmp);
- return m_regs.pwmp;
-
- case 0x504:
- verboselog(machine(), 2, "mc68328_r (%04x): PWMW = %04x\n", mem_mask, m_regs.pwmw);
- return m_regs.pwmw;
-
- case 0x506:
- verboselog(machine(), 2, "mc68328_r (%04x): PWMCNT = %04x\n", mem_mask, m_regs.pwmcnt);
- return m_regs.pwmcnt;
-
- case 0x600:
- verboselog(machine(), 2, "mc68328_r (%04x): TCTL1 = %04x\n", mem_mask, m_regs.tctl[0]);
- return m_regs.tctl[0];
-
- case 0x602:
- verboselog(machine(), 2, "mc68328_r (%04x): TPRER1 = %04x\n", mem_mask, m_regs.tprer[0]);
- return m_regs.tprer[0];
-
- case 0x604:
- verboselog(machine(), 2, "mc68328_r (%04x): TCMP1 = %04x\n", mem_mask, m_regs.tcmp[0]);
- return m_regs.tcmp[0];
-
- case 0x606:
- verboselog(machine(), 2, "mc68328_r (%04x): TCR1 = %04x\n", mem_mask, m_regs.tcr[0]);
- return m_regs.tcr[0];
-
- case 0x608:
- verboselog(machine(), 2, "mc68328_r (%04x): TCN1 = %04x\n", mem_mask, m_regs.tcn[0]);
- return m_regs.tcn[0];
-
- case 0x60a:
- verboselog(machine(), 5, "mc68328_r (%04x): TSTAT1 = %04x\n", mem_mask, m_regs.tstat[0]);
- m_regs.tclear[0] |= m_regs.tstat[0];
- return m_regs.tstat[0];
-
- case 0x60c:
- verboselog(machine(), 2, "mc68328_r (%04x): TCTL2 = %04x\n", mem_mask, m_regs.tctl[1]);
- return m_regs.tctl[1];
-
- case 0x60e:
- verboselog(machine(), 2, "mc68328_r (%04x): TPREP2 = %04x\n", mem_mask, m_regs.tprer[1]);
- return m_regs.tprer[1];
-
- case 0x610:
- verboselog(machine(), 2, "mc68328_r (%04x): TCMP2 = %04x\n", mem_mask, m_regs.tcmp[1]);
- return m_regs.tcmp[1];
-
- case 0x612:
- verboselog(machine(), 2, "mc68328_r (%04x): TCR2 = %04x\n", mem_mask, m_regs.tcr[1]);
- return m_regs.tcr[1];
-
- case 0x614:
- verboselog(machine(), 2, "mc68328_r (%04x): TCN2 = %04x\n", mem_mask, m_regs.tcn[1]);
- return m_regs.tcn[1];
-
- case 0x616:
- verboselog(machine(), 2, "mc68328_r (%04x): TSTAT2 = %04x\n", mem_mask, m_regs.tstat[1]);
- m_regs.tclear[1] |= m_regs.tstat[1];
- return m_regs.tstat[1];
-
- case 0x618:
- verboselog(machine(), 2, "mc68328_r (%04x): WCTLR = %04x\n", mem_mask, m_regs.wctlr);
- return m_regs.wctlr;
-
- case 0x61a:
- verboselog(machine(), 2, "mc68328_r (%04x): WCMPR = %04x\n", mem_mask, m_regs.wcmpr);
- return m_regs.wcmpr;
-
- case 0x61c:
- verboselog(machine(), 2, "mc68328_r (%04x): WCN = %04x\n", mem_mask, m_regs.wcn);
- return m_regs.wcn;
-
- case 0x700:
- verboselog(machine(), 2, "mc68328_r (%04x): SPISR = %04x\n", mem_mask, m_regs.spisr);
- return m_regs.spisr;
-
- case 0x800:
- verboselog(machine(), 2, "mc68328_r (%04x): SPIMDATA = %04x\n", mem_mask, m_regs.spimdata);
- if (!m_in_spim_cb.isnull())
- {
- return m_in_spim_cb(0, 0xffff);
- }
- return m_regs.spimdata;
-
- case 0x802:
- verboselog(machine(), 2, "mc68328_r (%04x): SPIMCONT = %04x\n", mem_mask, m_regs.spimcont);
- if (m_regs.spimcont & SPIM_XCH)
- {
- m_regs.spimcont &= ~SPIM_XCH;
- m_regs.spimcont |= SPIM_SPIMIRQ;
- return ((m_regs.spimcont | SPIM_XCH) &~ SPIM_SPIMIRQ);
- }
- return m_regs.spimcont;
-
- case 0x900:
- verboselog(machine(), 2, "mc68328_r (%04x): USTCNT = %04x\n", mem_mask, m_regs.ustcnt);
- return m_regs.ustcnt;
-
- case 0x902:
- verboselog(machine(), 2, "mc68328_r (%04x): UBAUD = %04x\n", mem_mask, m_regs.ubaud);
- return m_regs.ubaud;
-
- case 0x904:
- verboselog(machine(), 5, "mc68328_r (%04x): URX = %04x\n", mem_mask, m_regs.urx);
- return m_regs.urx;
-
- case 0x906:
- verboselog(machine(), 5, "mc68328_r (%04x): UTX = %04x\n", mem_mask, m_regs.utx);
- return m_regs.utx | UTX_FIFO_EMPTY | UTX_FIFO_HALF | UTX_TX_AVAIL;
-
- case 0x908:
- verboselog(machine(), 2, "mc68328_r (%04x): UMISC = %04x\n", mem_mask, m_regs.umisc);
- return m_regs.umisc;
-
- case 0xa00:
- verboselog(machine(), 2, "mc68328_r (%04x): LSSA(16) = %04x\n", mem_mask, m_regs.lssa >> 16);
- return m_regs.lssa >> 16;
-
- case 0xa02:
- verboselog(machine(), 2, "mc68328_r (%04x): LSSA(0) = %04x\n", mem_mask, m_regs.lssa & 0x0000ffff);
- return m_regs.lssa & 0x0000ffff;
-
- case 0xa04:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): LVPW = %02x\n", mem_mask, m_regs.lvpw);
- return m_regs.lvpw;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfffa04)\n", mem_mask);
- }
- break;
-
- case 0xa08:
- verboselog(machine(), 2, "mc68328_r (%04x): LXMAX = %04x\n", mem_mask, m_regs.lxmax);
- return m_regs.lxmax;
-
- case 0xa0a:
- verboselog(machine(), 2, "mc68328_r (%04x): LYMAX = %04x\n", mem_mask, m_regs.lymax);
- return m_regs.lymax;
-
- case 0xa18:
- verboselog(machine(), 2, "mc68328_r (%04x): LCXP = %04x\n", mem_mask, m_regs.lcxp);
- return m_regs.lcxp;
-
- case 0xa1a:
- verboselog(machine(), 2, "mc68328_r (%04x): LCYP = %04x\n", mem_mask, m_regs.lcyp);
- return m_regs.lcyp;
-
- case 0xa1c:
- verboselog(machine(), 2, "mc68328_r (%04x): LCWCH = %04x\n", mem_mask, m_regs.lcwch);
- return m_regs.lcwch;
-
- case 0xa1e:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): LBLKC = %02x\n", mem_mask, m_regs.lblkc);
- return m_regs.lblkc;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfffa1e)\n", mem_mask);
- }
- break;
-
- case 0xa20:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): LPOLCF = %02x\n", mem_mask, m_regs.lpolcf);
- return m_regs.lpolcf;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): LPICF = %02x\n", mem_mask, m_regs.lpicf);
- return m_regs.lpicf << 8;
- }
-
- case 0xa22:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): LACDRC = %02x\n", mem_mask, m_regs.lacdrc);
- return m_regs.lacdrc;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfffa22)\n", mem_mask);
- }
- break;
-
- case 0xa24:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): LPXCD = %02x\n", mem_mask, m_regs.lpxcd);
- return m_regs.lpxcd;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfffa24)\n", mem_mask);
- }
- break;
-
- case 0xa26:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): LCKCON = %02x\n", mem_mask, m_regs.lckcon);
- return m_regs.lckcon;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfffa26)\n", mem_mask);
- }
- break;
-
- case 0xa28:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): LLBAR = %02x\n", mem_mask, m_regs.llbar);
- return m_regs.llbar;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfffa28)\n", mem_mask);
- }
- break;
-
- case 0xa2a:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): LOTCR = %02x\n", mem_mask, m_regs.lotcr);
- return m_regs.lotcr;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfffa2a)\n", mem_mask);
- }
- break;
-
- case 0xa2c:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): LPOSR = %02x\n", mem_mask, m_regs.lposr);
- return m_regs.lposr;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfffa2c)\n", mem_mask);
- }
- break;
-
- case 0xa30:
- if (mem_mask & 0x00ff)
- {
- verboselog(machine(), 2, "mc68328_r (%04x): LFRCM = %02x\n", mem_mask, m_regs.lfrcm);
- return m_regs.lfrcm;
- }
- else
- {
- verboselog(machine(), 2, "mc68328_r (%04x): Unknown address (0xfffa30)\n", mem_mask);
- }
- break;
-
- case 0xa32:
- verboselog(machine(), 2, "mc68328_r (%04x): LGPMR = %04x\n", mem_mask, m_regs.lgpmr);
- return m_regs.lgpmr;
-
- case 0xb00:
- verboselog(machine(), 2, "mc68328_r (%04x): HMSR(0) = %04x\n", mem_mask, m_regs.hmsr & 0x0000ffff);
- return m_regs.hmsr & 0x0000ffff;
-
- case 0xb02:
- verboselog(machine(), 2, "mc68328_r (%04x): HMSR(16) = %04x\n", mem_mask, m_regs.hmsr >> 16);
- return m_regs.hmsr >> 16;
-
- case 0xb04:
- verboselog(machine(), 2, "mc68328_r (%04x): ALARM(0) = %04x\n", mem_mask, m_regs.alarm & 0x0000ffff);
- return m_regs.alarm & 0x0000ffff;
-
- case 0xb06:
- verboselog(machine(), 2, "mc68328_r (%04x): ALARM(16) = %04x\n", mem_mask, m_regs.alarm >> 16);
- return m_regs.alarm >> 16;
-
- case 0xb0c:
- verboselog(machine(), 2, "mc68328_r (%04x): RTCCTL = %04x\n", mem_mask, m_regs.rtcctl);
- return m_regs.rtcctl;
-
- case 0xb0e:
- verboselog(machine(), 2, "mc68328_r (%04x): RTCISR = %04x\n", mem_mask, m_regs.rtcisr);
- return m_regs.rtcisr;
-
- case 0xb10:
- verboselog(machine(), 2, "mc68328_r (%04x): RTCIENR = %04x\n", mem_mask, m_regs.rtcienr);
- return m_regs.rtcienr;
-
- case 0xb12:
- verboselog(machine(), 2, "mc68328_r (%04x): STPWTCH = %04x\n", mem_mask, m_regs.stpwtch);
- return m_regs.stpwtch;
-
- default:
- verboselog(machine(), 0, "mc68328_r (%04x): Unknown address (0x%06x)\n", mem_mask, 0xfff000 + address);
- break;
- }
- return 0;
-}
-
-/* THIS IS PRETTY MUCH TOTALLY WRONG AND DOESN'T REFLECT THE MC68328'S INTERNAL FUNCTIONALITY AT ALL! */
-UINT32 mc68328_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
-{
- UINT16 *video_ram = (UINT16 *)(machine().device<ram_device>(RAM_TAG)->pointer() + (m_regs.lssa & 0x00ffffff));
- UINT16 word;
- UINT16 *line;
- int y, x, b;
-
- if (m_regs.lckcon & LCKCON_LCDC_EN)
- {
- for (y = 0; y < 160; y++)
- {
- line = &bitmap.pix16(y);
-
- for (x = 0; x < 160; x += 16)
- {
- word = *(video_ram++);
- for (b = 0; b < 16; b++)
- {
- line[x + b] = (word >> (15 - b)) & 0x0001;
- }
- }
- }
- }
- else
- {
- for (y = 0; y < 160; y++)
- {
- line = &bitmap.pix16(y);
-
- for (x = 0; x < 160; x++)
- {
- line[x] = 0;
- }
- }
- }
- return 0;
-}
-
-
-void mc68328_device::register_state_save()
-{
- save_item(NAME(m_regs.scr));
- save_item(NAME(m_regs.grpbasea));
- save_item(NAME(m_regs.grpbaseb));
- save_item(NAME(m_regs.grpbasec));
- save_item(NAME(m_regs.grpbased));
- save_item(NAME(m_regs.grpmaska));
- save_item(NAME(m_regs.grpmaskb));
- save_item(NAME(m_regs.grpmaskc));
- save_item(NAME(m_regs.grpmaskd));
- save_item(NAME(m_regs.csa0));
- save_item(NAME(m_regs.csa1));
- save_item(NAME(m_regs.csa2));
- save_item(NAME(m_regs.csa3));
- save_item(NAME(m_regs.csb0));
- save_item(NAME(m_regs.csb1));
- save_item(NAME(m_regs.csb2));
- save_item(NAME(m_regs.csb3));
- save_item(NAME(m_regs.csc0));
- save_item(NAME(m_regs.csc1));
- save_item(NAME(m_regs.csc2));
- save_item(NAME(m_regs.csc3));
- save_item(NAME(m_regs.csd0));
- save_item(NAME(m_regs.csd1));
- save_item(NAME(m_regs.csd2));
- save_item(NAME(m_regs.csd3));
-
- save_item(NAME(m_regs.pllcr));
- save_item(NAME(m_regs.pllfsr));
- save_item(NAME(m_regs.pctlr));
-
- save_item(NAME(m_regs.ivr));
- save_item(NAME(m_regs.icr));
- save_item(NAME(m_regs.imr));
- save_item(NAME(m_regs.iwr));
- save_item(NAME(m_regs.isr));
- save_item(NAME(m_regs.ipr));
-
- save_item(NAME(m_regs.padir));
- save_item(NAME(m_regs.padata));
- save_item(NAME(m_regs.pasel));
- save_item(NAME(m_regs.pbdir));
- save_item(NAME(m_regs.pbdata));
- save_item(NAME(m_regs.pbsel));
- save_item(NAME(m_regs.pcdir));
- save_item(NAME(m_regs.pcdata));
- save_item(NAME(m_regs.pcsel));
- save_item(NAME(m_regs.pddir));
- save_item(NAME(m_regs.pddata));
- save_item(NAME(m_regs.pdpuen));
- save_item(NAME(m_regs.pdpol));
- save_item(NAME(m_regs.pdirqen));
- save_item(NAME(m_regs.pddataedge));
- save_item(NAME(m_regs.pdirqedge));
- save_item(NAME(m_regs.pedir));
- save_item(NAME(m_regs.pedata));
- save_item(NAME(m_regs.pepuen));
- save_item(NAME(m_regs.pesel));
- save_item(NAME(m_regs.pfdir));
- save_item(NAME(m_regs.pfdata));
- save_item(NAME(m_regs.pfpuen));
- save_item(NAME(m_regs.pfsel));
- save_item(NAME(m_regs.pgdir));
- save_item(NAME(m_regs.pgdata));
- save_item(NAME(m_regs.pgpuen));
- save_item(NAME(m_regs.pgsel));
- save_item(NAME(m_regs.pjdir));
- save_item(NAME(m_regs.pjdata));
- save_item(NAME(m_regs.pjsel));
- save_item(NAME(m_regs.pkdir));
- save_item(NAME(m_regs.pkdata));
- save_item(NAME(m_regs.pkpuen));
- save_item(NAME(m_regs.pksel));
- save_item(NAME(m_regs.pmdir));
- save_item(NAME(m_regs.pmdata));
- save_item(NAME(m_regs.pmpuen));
- save_item(NAME(m_regs.pmsel));
-
- save_item(NAME(m_regs.pwmc));
- save_item(NAME(m_regs.pwmp));
- save_item(NAME(m_regs.pwmw));
- save_item(NAME(m_regs.pwmcnt));
-
- save_item(NAME(m_regs.tctl[0]));
- save_item(NAME(m_regs.tctl[1]));
- save_item(NAME(m_regs.tprer[0]));
- save_item(NAME(m_regs.tprer[1]));
- save_item(NAME(m_regs.tcmp[0]));
- save_item(NAME(m_regs.tcmp[1]));
- save_item(NAME(m_regs.tcr[0]));
- save_item(NAME(m_regs.tcr[1]));
- save_item(NAME(m_regs.tcn[0]));
- save_item(NAME(m_regs.tcn[1]));
- save_item(NAME(m_regs.tstat[0]));
- save_item(NAME(m_regs.tstat[1]));
- save_item(NAME(m_regs.wctlr));
- save_item(NAME(m_regs.wcmpr));
- save_item(NAME(m_regs.wcn));
-
- save_item(NAME(m_regs.spisr));
-
- save_item(NAME(m_regs.spimdata));
- save_item(NAME(m_regs.spimcont));
-
- save_item(NAME(m_regs.ustcnt));
- save_item(NAME(m_regs.ubaud));
- save_item(NAME(m_regs.urx));
- save_item(NAME(m_regs.utx));
- save_item(NAME(m_regs.umisc));
-
- save_item(NAME(m_regs.lssa));
- save_item(NAME(m_regs.lvpw));
- save_item(NAME(m_regs.lxmax));
- save_item(NAME(m_regs.lymax));
- save_item(NAME(m_regs.lcxp));
- save_item(NAME(m_regs.lcyp));
- save_item(NAME(m_regs.lcwch));
- save_item(NAME(m_regs.lblkc));
- save_item(NAME(m_regs.lpicf));
- save_item(NAME(m_regs.lpolcf));
- save_item(NAME(m_regs.lacdrc));
- save_item(NAME(m_regs.lpxcd));
- save_item(NAME(m_regs.lckcon));
- save_item(NAME(m_regs.llbar));
- save_item(NAME(m_regs.lotcr));
- save_item(NAME(m_regs.lposr));
- save_item(NAME(m_regs.lfrcm));
- save_item(NAME(m_regs.lgpmr));
-
- save_item(NAME(m_regs.hmsr));
- save_item(NAME(m_regs.alarm));
- save_item(NAME(m_regs.rtcctl));
- save_item(NAME(m_regs.rtcisr));
- save_item(NAME(m_regs.rtcienr));
- save_item(NAME(m_regs.stpwtch));
-}
diff --git a/src/emu/machine/mc68328.h b/src/emu/machine/mc68328.h
deleted file mode 100644
index da680dae32b..00000000000
--- a/src/emu/machine/mc68328.h
+++ /dev/null
@@ -1,784 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Ryan Holtz
-/**********************************************************************
-
- Motorola 68328 ("DragonBall") System-on-a-Chip implementation
-
- By MooglyGuy
- contact mooglyguy@gmail.com with licensing and usage questions.
-
- **********************************************************************/
-
-/*****************************************************************************************************************
-
- P P P P P P P P P P P P P P
- E E E E E E E J J J J J J J
- 1 2 3 4 5 6 7 0 1 2 3 4 5 6
- D D D D D / / / / / / / / / / / / / /
- 3 4 5 6 7 ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
- / / / / / ! ! C C C C C C C C C C C C C C C
- P V P P P P D D G D D D D T T L U V S S S S S S S S G S S S S S S S
- B C B B B B D D 1 1 N 1 1 1 1 M C W W C A A A A B B B B N C C C C D D D
- 3 C 4 5 6 7 8 9 0 1 D 2 3 4 5 S K E E C 0 1 2 3 0 1 2 3 D 0 1 2 3 0 1 2
- | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
- +-------------------------------------------------------------------------------+
- | |
- | |
- | |
- | |
- | |
- D2/PB2--| |--PJ7/!CSD3
- D1/PB1--| |--VCC
- D0/PB0--| |--PD0/!KBD0/!INT0
- TDO--| |--PD1/!KBD1/!INT1
- TDI--| |--PD2/!KBD2/!INT2
- GND--| |--PD3/!KBD3/!INT3
- !OE--| |--PD4/!KBD4/!INT4
- !UDS/PC1--| |--PD5/!KBD5/!INT5
- !AS--| |--PD6/!KBD6/!INT6
- A0--| |--PD7/!KBD7/!INT7
- !LDS--| |--GND
- R/!W--| |--LD0
- !DTACK/PC5--| |--LD1
- !RESET--| |--LD2
- VCC--| |--LD3
- !WE/PC6--| |--LFRM
- !JTAGRST--| |--LLP
- BBUSW--| MC68328PV |--LCLK
- A1--| TOP VIEW |--LACD
- A2--| |--VCC
- A3--| |--PK0/SPMTXD0
- A4--| |--PK1/SPMRXD0
- A5--| |--PK2/SPMCLK0
- A6--| |--PK3/SPSEN
- GND--| |--PK4/SPSRXD1
- A7--| |--PK5/SPSCLK1
- A8--| |--PK6/!CE2
- A9--| |--PK7/!CE1
- A10--| |--GND
- A11--| |--PM0/!CTS
- A12--| |--PM1/!RTS
- A13--| |--PM2/!IRQ6
- A14--| |--PM3/!IRQ3
- VCC--| |--PM4/!IRQ2
- A15--| |--PM5/!IRQ1
- A16/PA0--| |--PM6/!PENIRQ
- | |
- | _ |
- | (_) |
- |\ |
- | \ |
- +-------------------------------------------------------------------------------+
- | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
- P P P P P G P P P P P P P P V P P P P P P P P G P P P V C G P P P E X P
- A A A A A N A A F F F F F F C F F G G G G G G N G G C C L N C M L X T L
- 1 2 3 4 5 D 6 7 0 1 2 3 4 5 C 6 7 7 6 5 4 3 2 D 1 0 0 C K D 4 7 L T A L
- / / / / / / / / / / / / / / / / / / / / / / / / O / / G A L V
- A A A A A A A A A A A A A A A R T ! T ! P R T M ! U N L C
- 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 T I T I T W X X O I A D C
- 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 C N O N O M D D C R R
- O 1 U 2 U O L Q T
- T T K 7 G
- 1 2 P
- I
- O
-
- Figure 12-1. MC68328 144-Lead Plastic Thin-Quad Flat Pack Pin Assignment
-
- Source: MC68328 (DragonBall)(tm) Integrated Processor User's Manual
-
- *****************************************************************************************************************/
-
-#ifndef __MC68328_H__
-#define __MC68328_H__
-
-
-#define SCR_BETO 0x80
-#define SCR_WPV 0x40
-#define SCR_PRV 0x20
-#define SCR_BETEN 0x10
-#define SCR_SO 0x08
-#define SCR_DMAP 0x04
-#define SCR_WDTH8 0x01
-
-#define ICR_POL6 0x0100
-#define ICR_POL3 0x0200
-#define ICR_POL2 0x0400
-#define ICR_POL1 0x0800
-#define ICR_ET6 0x1000
-#define ICR_ET3 0x2000
-#define ICR_ET2 0x4000
-#define ICR_ET1 0x8000
-
-#define INT_SPIM 0x000001
-#define INT_TIMER2 0x000002
-#define INT_UART 0x000004
-#define INT_WDT 0x000008
-#define INT_RTC 0x000010
-#define INT_RESERVED 0x000020
-#define INT_KB 0x000040
-#define INT_PWM 0x000080
-#define INT_INT0 0x000100
-#define INT_INT1 0x000200
-#define INT_INT2 0x000400
-#define INT_INT3 0x000800
-#define INT_INT4 0x001000
-#define INT_INT5 0x002000
-#define INT_INT6 0x004000
-#define INT_INT7 0x008000
-#define INT_KBDINTS 0x00ff00
-#define INT_IRQ1 0x010000
-#define INT_IRQ2 0x020000
-#define INT_IRQ3 0x040000
-#define INT_IRQ6 0x080000
-#define INT_PEN 0x100000
-#define INT_SPIS 0x200000
-#define INT_TIMER1 0x400000
-#define INT_IRQ7 0x800000
-
-#define INT_M68K_LINE1 (INT_IRQ1)
-#define INT_M68K_LINE2 (INT_IRQ2)
-#define INT_M68K_LINE3 (INT_IRQ3)
-#define INT_M68K_LINE4 (INT_INT0 | INT_INT1 | INT_INT2 | INT_INT3 | INT_INT4 | INT_INT5 | INT_INT6 | INT_INT7 | \
- INT_PWM | INT_KB | INT_RTC | INT_WDT | INT_UART | INT_TIMER2 | INT_SPIM)
-#define INT_M68K_LINE5 (INT_PEN)
-#define INT_M68K_LINE6 (INT_IRQ6 | INT_TIMER1 | INT_SPIS)
-#define INT_M68K_LINE7 (INT_IRQ7)
-#define INT_M68K_LINE67 (INT_M68K_LINE6 | INT_M68K_LINE7)
-#define INT_M68K_LINE567 (INT_M68K_LINE5 | INT_M68K_LINE6 | INT_M68K_LINE7)
-#define INT_M68K_LINE4567 (INT_M68K_LINE4 | INT_M68K_LINE5 | INT_M68K_LINE6 | INT_M68K_LINE7)
-#define INT_M68K_LINE34567 (INT_M68K_LINE3 | INT_M68K_LINE4 | INT_M68K_LINE5 | INT_M68K_LINE6 | INT_M68K_LINE7)
-#define INT_M68K_LINE234567 (INT_M68K_LINE2 | INT_M68K_LINE3 | INT_M68K_LINE4 | INT_M68K_LINE5 | INT_M68K_LINE6 | INT_M68K_LINE7)
-
-#define INT_IRQ1_SHIFT 0x000001
-#define INT_IRQ2_SHIFT 0x000002
-#define INT_IRQ3_SHIFT 0x000004
-#define INT_IRQ6_SHIFT 0x000008
-#define INT_PEN_SHIFT 0x000010
-#define INT_SPIS_SHIFT 0x000020
-#define INT_TIMER1_SHIFT 0x000040
-#define INT_IRQ7_SHIFT 0x000080
-
-#define INT_ACTIVE 1
-#define INT_INACTIVE 0
-
-#define GRPBASE_BASE_ADDR 0xfff0
-#define GRPBASE_VALID 0x0001
-
-#define GRPMASK_BASE_MASK 0xfff0
-
-#define CSAB_COMPARE 0xff000000
-#define CSAB_BSW 0x00010000
-#define CSAB_MASK 0x0000ff00
-#define CSAB_RO 0x00000008
-#define CSAB_WAIT 0x00000007
-
-#define CSCD_COMPARE 0xfff00000
-#define CSCD_BSW 0x00010000
-#define CSCD_MASK 0x0000fff0
-#define CSCD_RO 0x00000008
-#define CSCD_WAIT 0x00000007
-
-#define PLLCR_PIXCLK_SEL 0x3800
-#define PLLCR_PIXCLK_SEL_DIV2 0x0000
-#define PLLCR_PIXCLK_SEL_DIV4 0x0800
-#define PLLCR_PIXCLK_SEL_DIV8 0x1000
-#define PLLCR_PIXCLK_SEL_DIV16 0x1800
-#define PLLCR_PIXCLK_SEL_DIV1_0 0x2000
-#define PLLCR_PIXCLK_SEL_DIV1_1 0x2800
-#define PLLCR_PIXCLK_SEL_DIV1_2 0x3000
-#define PLLCR_PIXCLK_SEL_DIV1_3 0x3800
-#define PLLCR_SYSCLK_SEL 0x0700
-#define PLLCR_SYSCLK_SEL_DIV2 0x0000
-#define PLLCR_SYSCLK_SEL_DIV4 0x0100
-#define PLLCR_SYSCLK_SEL_DIV8 0x0200
-#define PLLCR_SYSCLK_SEL_DIV16 0x0300
-#define PLLCR_SYSCLK_SEL_DIV1_0 0x0400
-#define PLLCR_SYSCLK_SEL_DIV1_1 0x0500
-#define PLLCR_SYSCLK_SEL_DIV1_2 0x0600
-#define PLLCR_SYSCLK_SEL_DIV1_3 0x0700
-#define PLLCR_CLKEN 0x0010
-#define PLLCR_DISPLL 0x0008
-
-#define PLLFSR_CLK32 0x8000
-#define PLLFSR_PROT 0x4000
-#define PLLFSR_QCNT 0x0f00
-#define PLLFSR_PCNT 0x00ff
-
-#define PCTLR_PC_EN 0x80
-#define PCTLR_STOP 0x40
-#define PCTLR_WIDTH 0x1f
-
-#define CXP_CC 0xc000
-#define CXP_CC_XLU 0x0000
-#define CXP_CC_BLACK 0x4000
-#define CXP_CC_INVERSE 0x8000
-#define CXP_CC_INVALID 0xc000
-#define CXP_MASK 0x03ff
-
-#define CYP_MASK 0x01ff
-
-#define CWCH_CW 0x1f00
-#define CWCH_CH 0x001f
-
-#define BLKC_BKEN 0x80
-#define BLKC_BD 0x7f
-
-#define LPICF_PBSIZ 0x06
-#define LPICF_PBSIZ_1 0x00
-#define LPICF_PBSIZ_2 0x02
-#define LPICF_PBSIZ_4 0x04
-#define LPICF_PBSIZ_INVALID 0x06
-
-#define LPOLCF_LCKPOL 0x08
-#define LPOLCF_FLMPOL 0x04
-#define LPOLCF_LPPOL 0x02
-#define LPOLCF_PIXPOL 0x01
-
-#define LACDRC_MASK 0x0f
-
-#define LPXCD_MASK 0x3f
-
-#define LCKCON_LCDC_EN 0x80
-#define LCKCON_LCDON 0x80
-#define LCKCON_DMA16 0x40
-#define LCKCON_WS 0x30
-#define LCKCON_WS_1 0x00
-#define LCKCON_WS_2 0x10
-#define LCKCON_WS_3 0x20
-#define LCKCON_WS_4 0x30
-#define LCKCON_DWIDTH 0x02
-#define LCKCON_PCDS 0x01
-
-#define LBAR_MASK 0x7f
-
-#define LPOSR_BOS 0x08
-#define LPOSR_POS 0x07
-
-#define LFRCM_XMOD 0xf0
-#define LFRCM_YMOD 0x0f
-
-#define LGPMR_PAL1 0x7000
-#define LGPMR_PAL0 0x0700
-#define LGPMR_PAL3 0x0070
-#define LGPMR_PAL2 0x0007
-
-#define RTCHMSR_HOURS 0x1f000000
-#define RTCHMSR_MINUTES 0x003f0000
-#define RTCHMSR_SECONDS 0x0000003f
-
-#define RTCCTL_38_4 0x0020
-#define RTCCTL_ENABLE 0x0080
-
-#define RTCINT_STOPWATCH 0x0001
-#define RTCINT_MINUTE 0x0002
-#define RTCINT_ALARM 0x0004
-#define RTCINT_DAY 0x0008
-#define RTCINT_SECOND 0x0010
-
-#define RTCSTPWTCH_MASK 0x003f
-
-#define TCTL_TEN 0x0001
-#define TCTL_TEN_ENABLE 0x0001
-#define TCTL_CLKSOURCE 0x000e
-#define TCTL_CLKSOURCE_STOP 0x0000
-#define TCTL_CLKSOURCE_SYSCLK 0x0002
-#define TCTL_CLKSOURCE_SYSCLK16 0x0004
-#define TCTL_CLKSOURCE_TIN 0x0006
-#define TCTL_CLKSOURCE_32KHZ4 0x0008
-#define TCTL_CLKSOURCE_32KHZ5 0x000a
-#define TCTL_CLKSOURCE_32KHZ6 0x000c
-#define TCTL_CLKSOURCE_32KHZ7 0x000e
-#define TCTL_IRQEN 0x0010
-#define TCTL_IRQEN_ENABLE 0x0010
-#define TCTL_OM 0x0020
-#define TCTL_OM_ACTIVELOW 0x0000
-#define TCTL_OM_TOGGLE 0x0020
-#define TCTL_CAPTURE 0x00c0
-#define TCTL_CAPTURE_NOINT 0x0000
-#define TCTL_CAPTURE_RISING 0x0040
-#define TCTL_CAPTURE_FALLING 0x0080
-#define TCTL_CAPTURE_BOTH 0x00c0
-#define TCTL_FRR 0x0100
-#define TCTL_FRR_RESTART 0x0000
-#define TCTL_FRR_FREERUN 0x0100
-
-#define TSTAT_COMP 0x0001
-#define TSTAT_CAPT 0x0002
-
-#define WCTLR_WDRST 0x0008
-#define WCTLR_LOCK 0x0004
-#define WCTLR_FI 0x0002
-#define WCTLR_WDEN 0x0001
-
-#define USTCNT_UART_EN 0x8000
-#define USTCNT_RX_EN 0x4000
-#define USTCNT_TX_EN 0x2000
-#define USTCNT_RX_CLK_CONT 0x1000
-#define USTCNT_PARITY_EN 0x0800
-#define USTCNT_ODD_EVEN 0x0400
-#define USTCNT_STOP_BITS 0x0200
-#define USTCNT_8_7 0x0100
-#define USTCNT_GPIO_DELTA_EN 0x0080
-#define USTCNT_CTS_DELTA_EN 0x0040
-#define USTCNT_RX_FULL_EN 0x0020
-#define USTCNT_RX_HALF_EN 0x0010
-#define USTCNT_RX_RDY_EN 0x0008
-#define USTCNT_TX_EMPTY_EN 0x0004
-#define USTCNT_TX_HALF_EN 0x0002
-#define USTCNT_TX_AVAIL_EN 0x0001
-
-#define UBAUD_GPIO_DELTA 0x8000
-#define UBAUD_GPIO 0x4000
-#define UBAUD_GPIO_DIR 0x2000
-#define UBAUD_GPIO_SRC 0x1000
-#define UBAUD_BAUD_SRC 0x0800
-#define UBAUD_DIVIDE 0x0700
-#define UBAUD_DIVIDE_1 0x0000
-#define UBAUD_DIVIDE_2 0x0100
-#define UBAUD_DIVIDE_4 0x0200
-#define UBAUD_DIVIDE_8 0x0300
-#define UBAUD_DIVIDE_16 0x0400
-#define UBAUD_DIVIDE_32 0x0500
-#define UBAUD_DIVIDE_64 0x0600
-#define UBAUD_DIVIDE_128 0x0700
-#define UBAUD_PRESCALER 0x00ff
-
-#define URX_FIFO_FULL 0x8000
-#define URX_FIFO_HALF 0x4000
-#define URX_DATA_READY 0x2000
-#define URX_OVRUN 0x0800
-#define URX_FRAME_ERROR 0x0400
-#define URX_BREAK 0x0200
-#define URX_PARITY_ERROR 0x0100
-
-#define UTX_FIFO_EMPTY 0x8000
-#define UTX_FIFO_HALF 0x4000
-#define UTX_TX_AVAIL 0x2000
-#define UTX_SEND_BREAK 0x1000
-#define UTX_IGNORE_CTS 0x0800
-#define UTX_CTS_STATUS 0x0200
-#define UTX_CTS_DELTA 0x0100
-
-#define UMISC_CLK_SRC 0x4000
-#define UMISC_FORCE_PERR 0x2000
-#define UMISC_LOOP 0x1000
-#define UMISC_RTS_CONT 0x0080
-#define UMISC_RTS 0x0040
-#define UMISC_IRDA_ENABLE 0x0020
-#define UMISC_IRDA_LOOP 0x0010
-
-#define SPIS_SPIS_IRQ 0x8000
-#define SPIS_IRQEN 0x4000
-#define SPIS_ENPOL 0x2000
-#define SPIS_DATA_RDY 0x1000
-#define SPIS_OVRWR 0x0800
-#define SPIS_PHA 0x0400
-#define SPIS_POL 0x0200
-#define SPIS_SPISEN 0x0100
-
-#define SPIM_CLOCK_COUNT 0x000f
-#define SPIM_POL 0x0010
-#define SPIM_POL_HIGH 0x0000
-#define SPIM_POL_LOW 0x0010
-#define SPIM_PHA 0x0020
-#define SPIM_PHA_NORMAL 0x0000
-#define SPIM_PHA_OPPOSITE 0x0020
-#define SPIM_IRQEN 0x0040
-#define SPIM_SPIMIRQ 0x0080
-#define SPIM_XCH 0x0100
-#define SPIM_XCH_IDLE 0x0000
-#define SPIM_XCH_INIT 0x0100
-#define SPIM_SPMEN 0x0200
-#define SPIM_SPMEN_DISABLE 0x0000
-#define SPIM_SPMEN_ENABLE 0x0200
-#define SPIM_RATE 0xe000
-#define SPIM_RATE_4 0x0000
-#define SPIM_RATE_8 0x2000
-#define SPIM_RATE_16 0x4000
-#define SPIM_RATE_32 0x6000
-#define SPIM_RATE_64 0x8000
-#define SPIM_RATE_128 0xa000
-#define SPIM_RATE_256 0xc000
-#define SPIM_RATE_512 0xe000
-
-#define PWMC_PWMIRQ 0x8000
-#define PWMC_IRQEN 0x4000
-#define PWMC_LOAD 0x0100
-#define PWMC_PIN 0x0080
-#define PWMC_POL 0x0040
-#define PWMC_PWMEN 0x0010
-#define PWMC_CLKSEL 0x0007
-
-struct mc68328_regs_t
-{
- // $(FF)FFF000
- UINT8 scr; // System Control Register
- UINT8 unused0[255];
-
- // $(FF)FFF100
- UINT16 grpbasea; // Chip Select Group A Base Register
- UINT16 grpbaseb; // Chip Select Group B Base Register
- UINT16 grpbasec; // Chip Select Group C Base Register
- UINT16 grpbased; // Chip Select Group D Base Register
- UINT16 grpmaska; // Chip Select Group A Mask Register
- UINT16 grpmaskb; // Chip Select Group B Mask Register
- UINT16 grpmaskc; // Chip Select Group C Mask Register
- UINT16 grpmaskd; // Chip Select Group D Mask Register
- UINT32 csa0; // Group A Chip Select 0 Register
- UINT32 csa1; // Group A Chip Select 1 Register
- UINT32 csa2; // Group A Chip Select 2 Register
- UINT32 csa3; // Group A Chip Select 3 Register
- UINT32 csb0; // Group B Chip Select 0 Register
- UINT32 csb1; // Group B Chip Select 1 Register
- UINT32 csb2; // Group B Chip Select 2 Register
- UINT32 csb3; // Group B Chip Select 3 Register
- UINT32 csc0; // Group C Chip Select 0 Register
- UINT32 csc1; // Group C Chip Select 1 Register
- UINT32 csc2; // Group C Chip Select 2 Register
- UINT32 csc3; // Group C Chip Select 3 Register
- UINT32 csd0; // Group D Chip Select 0 Register
- UINT32 csd1; // Group D Chip Select 1 Register
- UINT32 csd2; // Group D Chip Select 2 Register
- UINT32 csd3; // Group D Chip Select 3 Register
- UINT8 unused1[176];
-
- // $(FF)FFF200
- UINT16 pllcr; // PLL Control Register
- UINT16 pllfsr; // PLL Frequency Select Register
- UINT8 pad2[3];
- UINT8 pctlr; // Power Control Register
- UINT8 unused3[248];
-
- // $(FF)FFF300
- UINT8 ivr; // Interrupt Vector Register
- UINT8 unused4[1];
- UINT16 icr; // Interrupt Control Register
- UINT32 imr; // Interrupt Mask Register
- UINT32 iwr; // Interrupt Wakeup Enable Register
- UINT32 isr; // Interrupt Status Register
- UINT32 ipr; // Interrupt Pending Register
- UINT8 unused5[236];
-
- // $(FF)FFF400
- UINT8 padir; // Port A Direction Register
- UINT8 padata; // Port A Data Register
- UINT8 unused6[1];
- UINT8 pasel; // Port A Select Register
- UINT8 unused7[4];
-
- UINT8 pbdir; // Port B Direction Register
- UINT8 pbdata; // Port B Data Register
- UINT8 unused8[1];
- UINT8 pbsel; // Port B Select Register
- UINT8 unused9[4];
-
- UINT8 pcdir; // Port C Direction Register
- UINT8 pcdata; // Port C Data Register
- UINT8 unused10[1];
- UINT8 pcsel; // Port C Select Register
- UINT8 unused11[4];
-
- UINT8 pddir; // Port D Direction Register
- UINT8 pddata; // Port D Data Register
- UINT8 pdpuen; // Port D Pullup Enable Register
- UINT8 unused12[1];
- UINT8 pdpol; // Port D Polarity Register
- UINT8 pdirqen; // Port D IRQ Enable Register
- UINT8 pddataedge; // Port D Data Edge Level
- UINT8 pdirqedge; // Port D IRQ Edge Register
-
- UINT8 pedir; // Port E Direction Register
- UINT8 pedata; // Port E Data Register
- UINT8 pepuen; // Port E Pullup Enable Register
- UINT8 pesel; // Port E Select Register
- UINT8 unused14[4];
-
- UINT8 pfdir; // Port F Direction Register
- UINT8 pfdata; // Port F Data Register
- UINT8 pfpuen; // Port F Pullup Enable Register
- UINT8 pfsel; // Port F Select Register
- UINT8 unused15[4];
-
- UINT8 pgdir; // Port G Direction Register
- UINT8 pgdata; // Port G Data Register
- UINT8 pgpuen; // Port G Pullup Enable Register
- UINT8 pgsel; // Port G Select Register
- UINT8 unused16[4];
-
- UINT8 pjdir; // Port J Direction Register
- UINT8 pjdata; // Port J Data Register
- UINT8 unused17[1];
- UINT8 pjsel; // Port J Select Register
- UINT8 unused18[4];
- UINT8 pkdir; // Port K Direction Register
- UINT8 pkdata; // Port K Data Register
- UINT8 pkpuen; // Port K Pullup Enable Register
- UINT8 pksel; // Port K Select Register
- UINT8 unused19[4];
-
- UINT8 pmdir; // Port M Direction Register
- UINT8 pmdata; // Port M Data Register
- UINT8 pmpuen; // Port M Pullup Enable Register
- UINT8 pmsel; // Port M Select Register
- UINT8 unused20[180];
-
- // $(FF)FFF500
- UINT16 pwmc; // PWM Control Register
- UINT16 pwmp; // PWM Period Register
- UINT16 pwmw; // PWM Width Register
- UINT16 pwmcnt; // PWN Counter
- UINT8 unused21[248];
-
- // $(FF)FFF600
- UINT16 tctl[2]; // Timer Control Register
- UINT16 tprer[2]; // Timer Prescaler Register
- UINT16 tcmp[2]; // Timer Compare Register
- UINT16 tcr[2]; // Timer Capture Register
- UINT16 tcn[2]; // Timer Counter
- UINT16 tstat[2]; // Timer Status
- UINT16 wctlr; // Watchdog Control Register
- UINT16 wcmpr; // Watchdog Compare Register
- UINT16 wcn; // Watchdog Counter
- UINT8 tclear[2]; // Timer Clearable Status
- UINT8 unused22[224];
-
- // $(FF)FFF700
- UINT16 spisr; // SPIS Register
- UINT8 unused23[254];
-
- // $(FF)FFF800
- UINT16 spimdata; // SPIM Data Register
- UINT16 spimcont; // SPIM Control/Status Register
- UINT8 unused24[252];
-
- // $(FF)FFF900
- UINT16 ustcnt; // UART Status/Control Register
- UINT16 ubaud; // UART Baud Control Register
- UINT16 urx; // UART RX Register
- UINT16 utx; // UART TX Register
- UINT16 umisc; // UART Misc Register
- UINT8 unused25[246];
-
- // $(FF)FFFA00
- UINT32 lssa; // Screen Starting Address Register
- UINT8 unused26[1];
- UINT8 lvpw; // Virtual Page Width Register
- UINT8 unused27[2];
- UINT16 lxmax; // Screen Width Register
- UINT16 lymax; // Screen Height Register
- UINT8 unused28[12];
- UINT16 lcxp; // Cursor X Position
- UINT16 lcyp; // Cursor Y Position
- UINT16 lcwch; // Cursor Width & Height Register
- UINT8 unused29[1];
- UINT8 lblkc; // Blink Control Register
- UINT8 lpicf; // Panel Interface Config Register
- UINT8 lpolcf; // Polarity Config Register
- UINT8 unused30[1];
- UINT8 lacdrc; // ACD (M) Rate Control Register
- UINT8 unused31[1];
- UINT8 lpxcd; // Pixel Clock Divider Register
- UINT8 unused32[1];
- UINT8 lckcon; // Clocking Control Register
- UINT8 unused33[1];
- UINT8 llbar; // Last Buffer Address Register
- UINT8 unused34[1];
- UINT8 lotcr; // Octet Terminal Count Register
- UINT8 unused35[1];
- UINT8 lposr; // Panning Offset Register
- UINT8 unused36[3];
- UINT8 lfrcm; // Frame Rate Control Modulation Register
- UINT16 lgpmr; // Gray Palette Mapping Register
- UINT8 unused37[204];
-
- // $(FF)FFFB00
- UINT32 hmsr; // RTC Hours Minutes Seconds Register
- UINT32 alarm; // RTC Alarm Register
- UINT8 unused38[4];
- UINT16 rtcctl; // RTC Control Register
- UINT16 rtcisr; // RTC Interrupt Status Register
- UINT16 rtcienr; // RTC Interrupt Enable Register
- UINT16 stpwtch; // Stopwatch Minutes
- UINT8 unused42[1260];
-};
-
-
-class mc68328_device : public device_t
-{
-public:
- mc68328_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~mc68328_device() {}
-
- static void static_set_cpu_tag(device_t &device, const char *tag) { downcast<mc68328_device &>(device).m_cpu.set_tag(tag); }
- template<class _Object> static devcb_base &set_out_port_a_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_a_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_port_b_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_b_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_port_c_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_c_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_port_d_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_d_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_port_e_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_e_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_port_f_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_f_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_port_g_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_g_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_port_j_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_j_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_port_k_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_k_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_port_m_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_m_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_port_a_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_a_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_port_b_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_b_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_port_c_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_c_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_port_d_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_d_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_port_e_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_e_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_port_f_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_f_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_port_g_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_g_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_port_j_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_j_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_port_k_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_k_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_port_m_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_m_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pwm_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_pwm_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_spim_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_spim_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_spim_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_spim_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_spim_xch_trigger_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_spim_xch_trigger_cb.set_callback(object); }
-
-
- DECLARE_WRITE16_MEMBER(write);
- DECLARE_READ16_MEMBER(read);
- DECLARE_WRITE_LINE_MEMBER(set_penirq_line);
- void set_port_d_lines(UINT8 state, int bit);
-
- UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
- void set_interrupt_line(UINT32 line, UINT32 active);
- void poll_port_d_interrupts();
- UINT32 get_timer_frequency(UINT32 index);
- void maybe_start_timer(UINT32 index, UINT32 new_enable);
- void timer_compare_event(UINT32 index);
-
- void register_state_save();
-
- TIMER_CALLBACK_MEMBER(timer1_hit);
- TIMER_CALLBACK_MEMBER(timer2_hit);
- TIMER_CALLBACK_MEMBER(pwm_transition);
- TIMER_CALLBACK_MEMBER(rtc_tick);
-
- mc68328_regs_t m_regs;
-
- emu_timer *m_gptimer[2];
- emu_timer *m_rtc;
- emu_timer *m_pwm;
-
- devcb_write8 m_out_port_a_cb; /* 8-bit output */
- devcb_write8 m_out_port_b_cb; /* 8-bit output */
- devcb_write8 m_out_port_c_cb; /* 8-bit output */
- devcb_write8 m_out_port_d_cb; /* 8-bit output */
- devcb_write8 m_out_port_e_cb; /* 8-bit output */
- devcb_write8 m_out_port_f_cb; /* 8-bit output */
- devcb_write8 m_out_port_g_cb; /* 8-bit output */
- devcb_write8 m_out_port_j_cb; /* 8-bit output */
- devcb_write8 m_out_port_k_cb; /* 8-bit output */
- devcb_write8 m_out_port_m_cb; /* 8-bit output */
-
- devcb_read8 m_in_port_a_cb; /* 8-bit input */
- devcb_read8 m_in_port_b_cb; /* 8-bit input */
- devcb_read8 m_in_port_c_cb; /* 8-bit input */
- devcb_read8 m_in_port_d_cb; /* 8-bit input */
- devcb_read8 m_in_port_e_cb; /* 8-bit input */
- devcb_read8 m_in_port_f_cb; /* 8-bit input */
- devcb_read8 m_in_port_g_cb; /* 8-bit input */
- devcb_read8 m_in_port_j_cb; /* 8-bit input */
- devcb_read8 m_in_port_k_cb; /* 8-bit input */
- devcb_read8 m_in_port_m_cb; /* 8-bit input */
-
- devcb_write8 m_out_pwm_cb; /* 1-bit output */
-
- devcb_write16 m_out_spim_cb; /* 16-bit output */
- devcb_read16 m_in_spim_cb; /* 16-bit input */
-
- devcb_write_line m_spim_xch_trigger_cb; /* SPIM exchange trigger */ /*todo: not really a write line, fix*/
-
- required_device<cpu_device> m_cpu;
-};
-
-
-extern const device_type MC68328;
-
-#define MCFG_MC68328_CPU(_tag) \
- mc68328_device::static_set_cpu_tag(*device, "^" _tag);
-
-#define MCFG_MC68328_OUT_PORT_A_CB(_devcb) \
- devcb = &mc68328_device::set_out_port_a_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_OUT_PORT_B_CB(_devcb) \
- devcb = &mc68328_device::set_out_port_b_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_OUT_PORT_C_CB(_devcb) \
- devcb = &mc68328_device::set_out_port_c_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_OUT_PORT_D_CB(_devcb) \
- devcb = &mc68328_device::set_out_port_d_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_OUT_PORT_E_CB(_devcb) \
- devcb = &mc68328_device::set_out_port_e_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_OUT_PORT_F_CB(_devcb) \
- devcb = &mc68328_device::set_out_port_f_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_OUT_PORT_G_CB(_devcb) \
- devcb = &mc68328_device::set_out_port_g_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_OUT_PORT_J_CB(_devcb) \
- devcb = &mc68328_device::set_out_port_j_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_OUT_PORT_K_CB(_devcb) \
- devcb = &mc68328_device::set_out_port_k_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_OUT_PORT_M_CB(_devcb) \
- devcb = &mc68328_device::set_out_port_m_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_IN_PORT_A_CB(_devcb) \
- devcb = &mc68328_device::set_in_port_a_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_IN_PORT_B_CB(_devcb) \
- devcb = &mc68328_device::set_in_port_b_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_IN_PORT_C_CB(_devcb) \
- devcb = &mc68328_device::set_in_port_c_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_IN_PORT_D_CB(_devcb) \
- devcb = &mc68328_device::set_in_port_d_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_IN_PORT_E_CB(_devcb) \
- devcb = &mc68328_device::set_in_port_e_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_IN_PORT_F_CB(_devcb) \
- devcb = &mc68328_device::set_in_port_f_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_IN_PORT_G_CB(_devcb) \
- devcb = &mc68328_device::set_in_port_g_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_IN_PORT_J_CB(_devcb) \
- devcb = &mc68328_device::set_in_port_j_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_IN_PORT_K_CB(_devcb) \
- devcb = &mc68328_device::set_in_port_k_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_IN_PORT_M_CB(_devcb) \
- devcb = &mc68328_device::set_in_port_m_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_OUT_PWM_CB(_devcb) \
- devcb = &mc68328_device::set_out_pwm_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_OUT_SPIM_CB(_devcb) \
- devcb = &mc68328_device::set_out_spim_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_IN_SPIM_CB(_devcb) \
- devcb = &mc68328_device::set_in_spim_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68328_SPIM_XCH_TRIGGER_CB(_devcb) \
- devcb = &mc68328_device::set_spim_xch_trigger_callback(*device, DEVCB_##_devcb);
-
-
-#endif
diff --git a/src/emu/machine/mc6843.c b/src/emu/machine/mc6843.c
deleted file mode 100644
index f30dafde916..00000000000
--- a/src/emu/machine/mc6843.c
+++ /dev/null
@@ -1,827 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Antoine Mine
-/**********************************************************************
-
- Copyright (C) Antoine Mine' 2007
-
- Motorola 6843 Floppy Disk Controller emulation.
-
-**********************************************************************/
-
-/*
- Main MC 6843 features are:
- - single density floppies
- - IBM 3740 compatible
- - DMA-able
- - high-level commands (including multi-sector read/write)
-
- CLONES: HD 46503S seems to be a clone of MC 6843
-
- BUGS
- The driver was designed with Thomson computer emulation in mind
- (CD 90-015 5"1/4 floppy controller) and works in this context.
- It might work in other contexts but has currently shortcomings:
- - DMA is not emulated
- - Free-Format Read is not emulated
- - Free-Format Write only supports track formatting, in a specific
- format (FWF=1, Thomson-like sector formats)
- - very rough timing: basically, there is a fixed delay between
- a command request (CMR write) and its response (first byte
- available, seek complete, etc.); there is no delay between
- read / write
- */
-
-
-#include "emu.h"
-#include "mc6843.h"
-
-
-/******************* parameters ******************/
-
-#define VERBOSE 0
-
-/* macro-command numbers */
-#define CMD_STZ 0x2 /* seek track zero */
-#define CMD_SEK 0x3 /* seek */
-#define CMD_SSR 0x4 /* single sector read */
-#define CMD_SSW 0x5 /* single sector write */
-#define CMD_RCR 0x6 /* read CRC */
-#define CMD_SWD 0x7 /* single sector write with delete data mark */
-#define CMD_MSW 0xd /* multiple sector write */
-#define CMD_MSR 0xc /* multiple sector read */
-#define CMD_FFW 0xb /* free format write */
-#define CMD_FFR 0xa /* free format read */
-
-/* coarse delays */
-#define DELAY_SEEK attotime::from_usec( 100 ) /* track seek time */
-#define DELAY_ADDR attotime::from_usec( 100 ) /* search-address time */
-
-
-
-static const char *const mc6843_cmd[16] =
-{
- "---", "---", "STZ", "SEK", "SSR", "SSW", "RCR", "SWD",
- "---", "---", "FFR", "FFW", "MSR", "MSW", "---", "---",
-};
-
-
-/******************* utility function and macros ********************/
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-
-
-
-const device_type MC6843 = &device_creator<mc6843_device>;
-
-mc6843_device::mc6843_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MC6843, "MC6843 floppy controller", tag, owner, clock, "mc6843", __FILE__),
- m_write_irq(*this),
- m_CTAR(0),
- m_CMR(0),
- m_ISR(0),
- m_SUR(0),
- m_STRA(0),
- m_STRB(0),
- m_SAR(0),
- m_GCR(0),
- m_CCR(0),
- m_LTAR(0),
- m_drive(0),
- m_side(0),
- m_data_size(0),
- m_data_idx(0),
- m_data_id(0),
- m_index_pulse(0),
- m_timer_cont(NULL)
-{
- for (int i = 0; i < 128; i++)
- {
- m_data[i] = 0;
- }
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mc6843_device::device_start()
-{
- m_write_irq.resolve_safe();
-
- m_timer_cont = timer_alloc(TIMER_CONT);
-
- save_item(NAME(m_CTAR));
- save_item(NAME(m_CMR));
- save_item(NAME(m_ISR));
- save_item(NAME(m_SUR));
- save_item(NAME(m_STRA));
- save_item(NAME(m_STRB));
- save_item(NAME(m_SAR));
- save_item(NAME(m_GCR));
- save_item(NAME(m_CCR));
- save_item(NAME(m_LTAR));
- save_item(NAME(m_drive));
- save_item(NAME(m_side));
- save_item(NAME(m_data));
- save_item(NAME(m_data_size));
- save_item(NAME(m_data_idx));
- save_item(NAME(m_data_id));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mc6843_device::device_reset()
-{
- int i;
- LOG (( "mc6843 reset\n" ));
-
- /* setup/reset floppy drive */
- for ( i = 0; i < 4; i++ )
- {
- legacy_floppy_image_device * img = floppy_image( i );
- img->floppy_mon_w(CLEAR_LINE);
- img->floppy_drive_set_ready_state(FLOPPY_DRIVE_READY, 0 );
- img->floppy_drive_set_rpm( 300. );
- }
-
- /* reset registers */
- m_CMR &= 0xf0; /* zero only command */
- m_ISR = 0;
- m_STRA &= 0x5c;
- m_SAR = 0;
- m_STRB &= 0x20;
- status_update( );
-
- m_data_size = 0;
- m_data_idx = 0;
- m_timer_cont->adjust( attotime::never );
-}
-
-/************************** floppy interface ****************************/
-
-
-
-legacy_floppy_image_device* mc6843_device::floppy_image( UINT8 drive )
-{
- legacy_floppy_image_device *img = floppy_get_device( machine(), drive );
- if (!img && owner()) {
- // For slot devices, drives are typically attached to the slot rather than the machine
- const char *floppy_name = NULL;
- switch (drive) {
- case 0:
- floppy_name = FLOPPY_0;
- break;
- case 1:
- floppy_name = FLOPPY_1;
- break;
- case 2:
- floppy_name = FLOPPY_2;
- break;
- case 3:
- floppy_name = FLOPPY_3;
- break;
- }
- img = owner()->subdevice<legacy_floppy_image_device>(floppy_name);
- }
- return img;
-}
-
-
-legacy_floppy_image_device* mc6843_device::floppy_image( )
-{
- return floppy_image( m_drive );
-}
-
-
-void mc6843_device::set_drive( int drive )
-{
- m_drive = drive;
-}
-
-
-
-void mc6843_device::set_side( int side )
-{
- m_side = side;
-}
-
-
-
-/* called after ISR or STRB has changed */
-void mc6843_device::status_update( )
-{
- int irq = 0;
-
- /* ISR3 */
- if ( (m_CMR & 0x40) || ! m_STRB )
- m_ISR &= ~8;
- else
- m_ISR |= 8;
-
- /* interrupts */
- if ( m_ISR & 4 )
- irq = 1; /* unmaskable */
- if ( ! (m_CMR & 0x80) )
- {
- /* maskable */
- if ( m_ISR & ~4 )
- irq = 1;
- }
-
- m_write_irq( irq );
- LOG(( "status_update: irq=%i (CMR=%02X, ISR=%02X)\n", irq, m_CMR, m_ISR ));
-}
-
-
-void mc6843_device::set_index_pulse( int index_pulse )
-{
- m_index_pulse = index_pulse;
-}
-
-
-/* called at end of command */
-void mc6843_device::cmd_end( )
-{
- int cmd = m_CMR & 0x0f;
- if ( ( cmd == CMD_STZ ) || ( cmd == CMD_SEK ) )
- {
- m_ISR |= 0x02; /* set Settling Time Complete */
- }
- else
- {
- m_ISR |= 0x01; /* set Macro Command Complete */
- }
- m_STRA &= ~0x80; /* clear Busy */
- m_CMR &= 0xf0; /* clear command */
- status_update( );
-}
-
-
-
-/* Seek Track Zero bottom half */
-void mc6843_device::finish_STZ( )
-{
- legacy_floppy_image_device* img = floppy_image( );
- int i;
-
- /* seek to track zero */
- for ( i=0; i<83; i++ )
- {
- if (img->floppy_tk00_r() == CLEAR_LINE)
- break;
- img->floppy_drive_seek( -1 );
- }
-
- LOG(( "%f mc6843_finish_STZ: actual=%i\n", machine().time().as_double(), img->floppy_drive_get_current_track() ));
-
- /* update state */
- m_CTAR = 0;
- m_GCR = 0;
- m_SAR = 0;
- m_STRB |= img->floppy_tk00_r() << 4;
-
- cmd_end( );
-}
-
-
-
-/* Seek bottom half */
-void mc6843_device::finish_SEK( )
-{
- legacy_floppy_image_device* img = floppy_image( );
-
- /* seek to track */
- // TODO: not sure how CTAR bit 7 is handled here, but this is the safest approach for now
- img->floppy_drive_seek( m_GCR - (m_CTAR & 0x7F) );
-
- LOG(( "%f mc6843_finish_SEK: from %i to %i (actual=%i)\n", machine().time().as_double(), (m_CTAR & 0x7F), m_GCR, img->floppy_drive_get_current_track() ));
-
- /* update state */
- m_CTAR = m_GCR;
- m_SAR = 0;
- cmd_end( );
-}
-
-
-
-/* preamble to all sector read / write commands, returns 1 if found */
-int mc6843_device::address_search( chrn_id* id )
-{
- legacy_floppy_image_device* img = floppy_image( );
- int r = 0;
-
- while ( 1 )
- {
- if ( ( ! img->floppy_drive_get_next_id( m_side, id ) ) || ( id->flags & ID_FLAG_CRC_ERROR_IN_ID_FIELD ) || ( id->N != 0 ) )
- {
- /* read address error */
- LOG(( "%f mc6843_address_search: get_next_id failed\n", machine().time().as_double() ));
- m_STRB |= 0x0a; /* set CRC error & Sector Address Undetected */
- cmd_end( );
- return 0;
- }
-
- if ( id->C != m_LTAR )
- {
- /* track mismatch */
- LOG(( "%f mc6843_address_search: track mismatch: logical=%i real=%i\n", machine().time().as_double(), m_LTAR, id->C ));
- m_data[0] = id->C; /* make the track number available to the CPU */
- m_STRA |= 0x20; /* set Track Not Equal */
- cmd_end( );
- return 0;
- }
-
- if ( id->R == m_SAR )
- {
- /* found! */
- LOG(( "%f mc6843_address_search: sector %i found on track %i\n", machine().time().as_double(), id->R, id->C ));
- if ( ! (m_CMR & 0x20) )
- {
- m_ISR |= 0x04; /* if no DMA, set Status Sense */
- }
- return 1;
- }
-
- if ( img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) )
- {
- r++;
- if ( r >= 4 )
- {
- /* time-out after 3 full revolutions */
- LOG(( "%f mc6843_address_search: no sector %i found after 3 revolutions\n", machine().time().as_double(), m_SAR ));
- m_STRB |= 0x08; /* set Sector Address Undetected */
- cmd_end( );
- return 0;
- }
- }
- }
-
- //return 0; /* unreachable */
-}
-
-
-
-/* preamble specific to read commands (adds extra checks) */
-int mc6843_device::address_search_read( chrn_id* id )
-{
- if ( ! address_search( id ) )
- return 0;
-
- if ( id->flags & ID_FLAG_CRC_ERROR_IN_DATA_FIELD )
- {
- LOG(( "%f mc6843_address_search_read: data CRC error\n", machine().time().as_double() ));
- m_STRB |= 0x06; /* set CRC error & Data Mark Undetected */
- cmd_end( );
- return 0;
- }
-
- if ( id->flags & ID_FLAG_DELETED_DATA )
- {
- LOG(( "%f mc6843_address_search_read: deleted data\n", machine().time().as_double() ));
- m_STRA |= 0x02; /* set Delete Data Mark Detected */
- }
-
- return 1;
-}
-
-
-
-
-/* Read CRC bottom half */
-void mc6843_device::finish_RCR( )
-{
- chrn_id id;
- if ( ! address_search_read( &id ) )
- return;
- cmd_end( );
-}
-
-
-
-/* Single / Multiple Sector Read bottom half */
-void mc6843_device::cont_SR( )
-{
- chrn_id id;
- legacy_floppy_image_device* img = floppy_image( );
-
- /* sector seek */
- if ( ! address_search_read( &id ) )
- return;
-
- /* sector read */
- img->floppy_drive_read_sector_data( m_side, id.data_id, m_data, 128 );
- m_data_idx = 0;
- m_data_size = 128;
- m_STRA |= 0x01; /* set Data Transfer Request */
- status_update( );
-}
-
-
-
-/* Single / Multiple Sector Write bottom half */
-void mc6843_device::cont_SW( )
-{
- chrn_id id;
-
- /* sector seek */
- if ( ! address_search( &id ) )
- return;
-
- /* setup sector write buffer */
- m_data_idx = 0;
- m_data_size = 128;
- m_STRA |= 0x01; /* set Data Transfer Request */
- m_data_id = id.data_id; /* for subsequent write sector command */
- status_update( );
-}
-
-
-
-/* bottom halves, called to continue / finish a command after some delay */
-void mc6843_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_CONT:
- {
- int cmd = m_CMR & 0x0f;
-
- LOG(( "%f mc6843_cont: timer called for cmd=%s(%i)\n", machine().time().as_double(), mc6843_cmd[cmd], cmd ));
-
- m_timer_cont->adjust( attotime::never );
-
- switch ( cmd )
- {
- case CMD_STZ: finish_STZ( ); break;
- case CMD_SEK: finish_SEK( ); break;
- case CMD_SSR: cont_SR( ); break;
- case CMD_SSW: cont_SW( ); break;
- case CMD_RCR: finish_RCR( ); break;
- case CMD_SWD: cont_SW( ); break;
- case CMD_MSW: cont_SW( ); break;
- case CMD_MSR: cont_SR( ); break;
- }
- }
- break;
-
- default:
- break;
- }
-}
-
-
-
-/************************** CPU interface ****************************/
-
-
-
-READ8_MEMBER( mc6843_device::read )
-{
- UINT8 data = 0;
-
- switch ( offset ) {
- case 0: /* Data Input Register (DIR) */
- {
- int cmd = m_CMR & 0x0f;
-
- LOG(( "%f %s mc6843_r: data input cmd=%s(%i), pos=%i/%i, GCR=%i, ",
- machine().time().as_double(), machine().describe_context(),
- mc6843_cmd[cmd], cmd, m_data_idx,
- m_data_size, m_GCR ));
-
- if ( cmd == CMD_SSR || cmd == CMD_MSR )
- {
- /* sector read */
- assert( m_data_size > 0 );
- assert( m_data_idx < m_data_size );
- assert( m_data_idx < sizeof(m_data) );
- data = m_data[ m_data_idx ];
- m_data_idx++;
-
- if ( m_data_idx >= m_data_size )
- {
- /* end of sector read */
-
- m_STRA &= ~0x01; /* clear Data Transfer Request */
-
- if ( cmd == CMD_MSR )
- {
- /* schedule next sector in multiple sector read */
- m_GCR--;
- m_SAR++;
- if ( m_GCR == 0xff )
- {
- cmd_end( );
- }
- else if ( m_SAR > 26 )
-
- {
- m_STRB |= 0x08; /* set Sector Address Undetected */
- cmd_end( );
- }
- else
- {
- m_timer_cont->adjust( DELAY_ADDR );
- }
- }
- else
- {
- cmd_end( );
- }
- }
- }
- else if ( cmd == 0 )
- {
- data = m_data[0];
- }
- else
- {
- /* XXX TODO: other read modes */
- data = m_data[0];
- logerror( "%s mc6843 read in unsupported command mode %i\n", machine().describe_context(), cmd );
- }
-
- LOG(( "data=%02X\n", data ));
-
- break;
- }
-
- case 1: /* Current-Track Address Register (CTAR) */
- data = m_CTAR;
- LOG(( "%f %s mc6843_r: read CTAR %i (actual=%i)\n",
- machine().time().as_double(), machine().describe_context(), data,
- floppy_image()->floppy_drive_get_current_track()));
- break;
-
- case 2: /* Interrupt Status Register (ISR) */
- data = m_ISR;
- LOG(( "%f %s mc6843_r: read ISR %02X: cmd=%scomplete settle=%scomplete sense-rq=%i STRB=%i\n",
- machine().time().as_double(), machine().describe_context(), data,
- (data & 1) ? "" : "not-" , (data & 2) ? "" : "not-",
- (data >> 2) & 1, (data >> 3) & 1 ));
-
- /* reset */
- m_ISR &= 8; /* keep STRB */
- status_update( );
- break;
-
- case 3: /* Status Register A (STRA) */
- {
- /* update */
- legacy_floppy_image_device* img = floppy_image( );
- int flag = img->floppy_drive_get_flag_state( FLOPPY_DRIVE_READY);
- m_STRA &= 0xa3;
- if ( flag & FLOPPY_DRIVE_READY )
- m_STRA |= 0x04;
-
- m_STRA |= !img->floppy_tk00_r() << 3;
- m_STRA |= !img->floppy_wpt_r() << 4;
-
- if ( m_index_pulse )
- m_STRA |= 0x40;
-
- data = m_STRA;
- LOG(( "%f %s mc6843_r: read STRA %02X: data-rq=%i del-dta=%i ready=%i t0=%i wp=%i trk-dif=%i idx=%i busy=%i\n",
- machine().time().as_double(), machine().describe_context(), data,
- data & 1, (data >> 1) & 1, (data >> 2) & 1, (data >> 3) & 1,
- (data >> 4) & 1, (data >> 5) & 1, (data >> 6) & 1, (data >> 7) & 1 ));
- break;
- }
-
- case 4: /* Status Register B (STRB) */
- data = m_STRB;
- LOG(( "%f %s mc6843_r: read STRB %02X: data-err=%i CRC-err=%i dta--mrk-err=%i sect-mrk-err=%i seek-err=%i fi=%i wr-err=%i hard-err=%i\n",
- machine().time().as_double(), machine().describe_context(), data,
- data & 1, (data >> 1) & 1, (data >> 2) & 1, (data >> 3) & 1,
- (data >> 4) & 1, (data >> 5) & 1, (data >> 6) & 1, (data >> 7) & 1 ));
-
- /* (partial) reset */
- m_STRB &= ~0xfb;
- status_update( );
- break;
-
- case 7: /* Logical-Track Address Register (LTAR) */
- data = m_LTAR;
- LOG(( "%f %s mc6843_r: read LTAR %i (actual=%i)\n",
- machine().time().as_double(), machine().describe_context(), data,
- floppy_image()->floppy_drive_get_current_track()));
- break;
-
- default:
- logerror( "%s mc6843 invalid read offset %i\n", machine().describe_context(), offset );
- }
-
- return data;
-}
-
-WRITE8_MEMBER( mc6843_device::write )
-{
- switch ( offset ) {
- case 0: /* Data Output Register (DOR) */
- {
- int cmd = m_CMR & 0x0f;
- int FWF = (m_CMR >> 4) & 1;
-
- LOG(( "%f %s mc6843_w: data output cmd=%s(%i), pos=%i/%i, GCR=%i, data=%02X\n",
- machine().time().as_double(), machine().describe_context(),
- mc6843_cmd[cmd], cmd, m_data_idx,
- m_data_size, m_GCR, data ));
-
- if ( cmd == CMD_SSW || cmd == CMD_MSW || cmd == CMD_SWD )
- {
- /* sector write */
- assert( m_data_size > 0 );
- assert( m_data_idx < m_data_size );
- assert( m_data_idx < sizeof(m_data) );
- m_data[ m_data_idx ] = data;
- m_data_idx++;
- if ( m_data_idx >= m_data_size )
- {
- /* end of sector write */
- legacy_floppy_image_device* img = floppy_image( );
-
- LOG(( "%f %s mc6843_w: write sector %i\n", machine().time().as_double(), machine().describe_context(), m_data_id ));
-
- img->floppy_drive_write_sector_data(
- m_side, m_data_id,
- m_data, m_data_size,
- (cmd == CMD_SWD) ? ID_FLAG_DELETED_DATA : 0 );
-
- m_STRA &= ~0x01; /* clear Data Transfer Request */
-
- if ( cmd == CMD_MSW )
- {
- m_GCR--;
- m_SAR++;
- if ( m_GCR == 0xff )
- {
- cmd_end( );
- }
- else if ( m_SAR > 26 )
-
- {
- m_STRB |= 0x08; /* set Sector Address Undetected */
- cmd_end( );
- }
- else
- {
- m_timer_cont->adjust( DELAY_ADDR );
- }
- }
- else
- {
- cmd_end( );
- }
- }
- }
- else if ( (cmd == CMD_FFW) && FWF )
- {
- /* assume we are formatting */
- UINT8 nibble;
- nibble =
- (data & 0x01) |
- ((data & 0x04) >> 1 )|
- ((data & 0x10) >> 2 )|
- ((data & 0x40) >> 3 );
-
- assert( m_data_idx < sizeof(m_data) );
-
- m_data[m_data_idx / 2] =
- (m_data[m_data_idx / 2] << 4) | nibble;
-
- if ( (m_data_idx == 0) && (m_data[0] == 0xfe ) )
- {
- /* address mark detected */
- m_data_idx = 2;
- }
- else if ( m_data_idx == 9 )
- {
- /* address id field complete */
- if ( (m_data[2] == 0) && (m_data[4] == 0) )
- {
- /* valid address id field */
- legacy_floppy_image_device* img = floppy_image( );
- UINT8 track = m_data[1];
- UINT8 sector = m_data[3];
- UINT8 filler = 0xe5; /* standard Thomson filler */
- LOG(( "%f %s mc6843_w: address id detected track=%i sector=%i\n", machine().time().as_double(), machine().describe_context(), track, sector));
- img->floppy_drive_format_sector( m_side, sector, track, 0, sector, 0, filler );
- }
- else
- {
- /* abort */
- m_data_idx = 0;
- }
- }
- else if ( m_data_idx > 0 )
- {
- /* accumulate address id field */
- m_data_idx++;
- }
- }
- else if ( cmd == 0 )
- {
- /* nothing */
- }
- else
- {
- /* XXX TODO: other write modes */
- logerror( "%s mc6843 write %02X in unsupported command mode %i (FWF=%i)\n", machine().describe_context(), data, cmd, FWF );
- }
- break;
- }
-
- case 1: /* Current-Track Address Register (CTAR) */
- m_CTAR = data;
- LOG(( "%f %s mc6843_w: set CTAR to %i %02X (actual=%i) \n",
- machine().time().as_double(), machine().describe_context(), m_CTAR, data,
- floppy_image()->floppy_drive_get_current_track()));
- break;
-
- case 2: /* Command Register (CMR) */
- {
- int cmd = data & 15;
-
- LOG(( "%f %s mc6843_w: set CMR to $%02X: cmd=%s(%i) FWF=%i DMA=%i ISR3-intr=%i fun-intr=%i\n",
- machine().time().as_double(), machine().describe_context(),
- data, mc6843_cmd[cmd], cmd, (data >> 4) & 1, (data >> 5) & 1,
- (data >> 6) & 1, (data >> 7) & 1 ));
-
- /* sanitize state */
- m_STRA &= ~0x81; /* clear Busy & Data Transfer Request */
- m_data_idx = 0;
- m_data_size = 0;
-
- /* commands are initiated by updating some flags and scheduling
- a bottom-half (mc6843_cont) after some delay */
-
- switch (cmd)
- {
- case CMD_SSW:
- case CMD_SSR:
- case CMD_SWD:
- case CMD_RCR:
- case CMD_MSR:
- case CMD_MSW:
- m_STRA |= 0x80; /* set Busy */
- m_STRA &= ~0x22; /* clear Track Not Equal & Delete Data Mark Detected */
- m_STRB &= ~0x04; /* clear Data Mark Undetected */
- m_timer_cont->adjust( DELAY_ADDR );
- break;
- case CMD_STZ:
- case CMD_SEK:
- m_STRA |= 0x80; /* set Busy */
- m_timer_cont->adjust( DELAY_SEEK );
- break;
- case CMD_FFW:
- case CMD_FFR:
- m_data_idx = 0;
- m_STRA |= 0x01; /* set Data Transfer Request */
- break;
- }
-
- m_CMR = data;
- status_update( );
- break;
- }
-
- case 3: /* Set-Up Register (SUR) */
- m_SUR = data;
-
- /* assume CLK freq = 1MHz (IBM 3740 compatibility) */
- LOG(( "%f %s mc6843_w: set SUR to $%02X: head settling time=%fms, track-to-track seek time=%f\n",
- machine().time().as_double(), machine().describe_context(),
- data, 4.096 * (data & 15), 1.024 * ((data >> 4) & 15) ));
- break;
-
- case 4: /* Sector Address Register (SAR) */
- m_SAR = data & 0x1f;
- LOG(( "%f %s mc6843_w: set SAR to %i (%02X)\n", machine().time().as_double(), machine().describe_context(), m_SAR, data ));
- break;
-
- case 5: /* General Count Register (GCR) */
- m_GCR = data & 0x7f;
- LOG(( "%f %s mc6843_w: set GCR to %i (%02X)\n", machine().time().as_double(), machine().describe_context(), m_GCR, data ));
- break;
-
- case 6: /* CRC Control Register (CCR) */
- m_CCR = data & 3;
- LOG(( "%f %s mc6843_w: set CCR to %02X: CRC=%s shift=%i\n",
- machine().time().as_double(), machine().describe_context(), data,
- (data & 1) ? "enabled" : "disabled", (data >> 1) & 1 ));
- break;
-
- case 7: /* Logical-Track Address Register (LTAR) */
- m_LTAR = data & 0x7f;
- LOG(( "%f %s mc6843_w: set LTAR to %i %02X (actual=%i)\n",
- machine().time().as_double(), machine().describe_context(), m_LTAR, data,
- floppy_image()->floppy_drive_get_current_track()));
- break;
-
- default:
- logerror( "%s mc6843 invalid write offset %i (data=$%02X)\n", machine().describe_context(), offset, data );
- }
-}
diff --git a/src/emu/machine/mc6843.h b/src/emu/machine/mc6843.h
deleted file mode 100644
index 3a855d1c196..00000000000
--- a/src/emu/machine/mc6843.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Antoine Mine
-/**********************************************************************
-
- Copyright (C) Antoine Mine' 2007
-
- Motorola 6843 Floppy Disk Controller emulation.
-
-**********************************************************************/
-
-#ifndef MC6843_H
-#define MC6843_H
-
-#include "imagedev/flopdrv.h"
-
-#define MCFG_MC6843_IRQ_CALLBACK(_write) \
- devcb = &mc6843_device::set_irq_wr_callback(*device, DEVCB_##_write);
-
-class mc6843_device : public device_t
-{
-public:
- mc6843_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~mc6843_device() {}
-
- template<class _Object> static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<mc6843_device &>(device).m_write_irq.set_callback(object); }
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- void set_drive(int drive);
- void set_side(int side);
- void set_index_pulse(int index_pulse);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- enum
- {
- TIMER_CONT
- };
-
- devcb_write_line m_write_irq;
-
- /* registers */
- UINT8 m_CTAR; /* current track */
- UINT8 m_CMR; /* command */
- UINT8 m_ISR; /* interrupt status */
- UINT8 m_SUR; /* set-up */
- UINT8 m_STRA; /* status */
- UINT8 m_STRB; /* status */
- UINT8 m_SAR; /* sector address */
- UINT8 m_GCR; /* general count */
- UINT8 m_CCR; /* CRC control */
- UINT8 m_LTAR; /* logical address track (=track destination) */
-
- /* internal state */
- UINT8 m_drive;
- UINT8 m_side;
- UINT8 m_data[128]; /* sector buffer */
- UINT32 m_data_size; /* size of data */
- UINT32 m_data_idx; /* current read/write position in data */
- UINT32 m_data_id; /* chrd_id for sector write */
- UINT8 m_index_pulse;
-
- /* trigger delayed actions (bottom halves) */
- emu_timer* m_timer_cont;
-
- legacy_floppy_image_device* floppy_image(UINT8 drive);
- legacy_floppy_image_device* floppy_image();
- void status_update();
- void cmd_end();
- void finish_STZ();
- void finish_SEK();
- int address_search(chrn_id* id);
- int address_search_read(chrn_id* id);
- void finish_RCR();
- void cont_SR();
- void cont_SW();
-
-};
-
-extern const device_type MC6843;
-
-#endif
diff --git a/src/emu/machine/mc6846.c b/src/emu/machine/mc6846.c
deleted file mode 100644
index 18b9f723bfb..00000000000
--- a/src/emu/machine/mc6846.c
+++ /dev/null
@@ -1,568 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Antoine Mine
-/**********************************************************************
-
- Copyright (C) Antoine Mine' 2006
-
- Motorola 6846 emulation.
-
- The MC6846 chip provides ROM (2048 bytes), I/O (8-bit directional data port +
- 2 control lines) and a programmable timer.
- It may be interfaced with a M6809 cpu.
- It is used in some Thomson computers.
-
- Not yet implemented:
- - external clock (CTC)
- - latching of port on CP1
- - gate input (CTG)
- - timer comparison modes (frequency and pulse width)
- - CP2 acknowledge modes
-
-**********************************************************************/
-
-#include "emu.h"
-#include "mc6846.h"
-
-#define VERBOSE 0
-
-
-/******************* utility function and macros ********************/
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-#define PORT \
- ((m_pdr & m_ddr) | \
- ((!m_in_port_cb.isnull() ? m_in_port_cb( 0 ) : 0) & \
- ~m_ddr))
-
-#define CTO \
- ((MODE == 0x30 || (m_tcr & 0x80)) ? m_cto : 0)
-
-#define MODE (m_tcr & 0x38)
-
-#define FACTOR ((m_tcr & 4) ? 8 : 1)
-
-
-const device_type MC6846 = &device_creator<mc6846_device>;
-
-mc6846_device::mc6846_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MC6846, "MC6846 Programmable Timer", tag, owner, clock, "mc6846", __FILE__),
- m_out_port_cb(*this),
- m_out_cp1_cb(*this),
- m_out_cp2_cb(*this),
- m_in_port_cb(*this),
- m_out_cto_cb(*this),
- m_irq_cb(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mc6846_device::device_start()
-{
- m_interval = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc6846_device::timer_expire), this));
- m_one_shot = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc6846_device::timer_one_shot), this));
-
- m_out_port_cb.resolve(); /* 8-bit output */
- m_out_cp1_cb.resolve_safe(); /* 1-bit output */
- m_out_cp2_cb.resolve(); /* 1-bit output */
-
- /* CPU read from the outside through chip */
- m_in_port_cb.resolve(); /* 8-bit input */
-
- /* asynchronous timer output to outside world */
- m_out_cto_cb.resolve(); /* 1-bit output */
-
- /* timer interrupt */
- m_irq_cb.resolve();
-
- save_item(NAME(m_csr));
- save_item(NAME(m_pcr));
- save_item(NAME(m_ddr));
- save_item(NAME(m_pdr));
- save_item(NAME(m_tcr));
- save_item(NAME(m_cp1));
- save_item(NAME(m_cp2));
- save_item(NAME(m_cp2_cpu));
- save_item(NAME(m_cto));
- save_item(NAME(m_time_MSB));
- save_item(NAME(m_csr0_to_be_cleared));
- save_item(NAME(m_csr1_to_be_cleared));
- save_item(NAME(m_csr2_to_be_cleared));
- save_item(NAME(m_latch));
- save_item(NAME(m_preset));
- save_item(NAME(m_timer_started));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mc6846_device::device_reset()
-{
- m_cto = 0;
- m_csr = 0;
- m_pcr = 0x80;
- m_ddr = 0;
- m_pdr = 0;
- m_tcr = 1;
- m_cp1 = 0;
- m_cp2 = 0;
- m_cp2_cpu = 0;
- m_latch = 0xffff;
- m_preset = 0xffff;
- m_time_MSB = 0;
- m_csr0_to_be_cleared = 0;
- m_csr1_to_be_cleared = 0;
- m_csr2_to_be_cleared = 0;
- m_timer_started = 0;
- m_old_cif = 0;
- m_old_cto = 0;
- m_interval->reset();
- m_one_shot->reset();
-}
-
-
-inline UINT16 mc6846_device::counter()
-{
- if ( m_timer_started )
- {
- attotime delay = m_interval ->remaining( );
- return delay.as_ticks(1000000) / FACTOR;
- }
- else
- return m_preset;
-}
-
-
-
-inline void mc6846_device::update_irq()
-{
- int cif = 0;
- /* composite interrupt flag */
- if ( ( (m_csr & 1) && (m_tcr & 0x40) ) ||
- ( (m_csr & 2) && (m_pcr & 1) ) ||
- ( (m_csr & 4) && (m_pcr & 8) && ! (m_pcr & 0x20) ) )
- cif = 1;
- if ( m_old_cif != cif )
- {
- LOG (( "%f: mc6846 interrupt %i (time=%i cp1=%i cp2=%i)\n",
- machine().time().as_double(), cif,
- m_csr & 1, (m_csr >> 1 ) & 1, (m_csr >> 2 ) & 1 ));
- m_old_cif = cif;
- }
- if ( cif )
- {
- m_csr |= 0x80;
- if ( !m_irq_cb.isnull() )
- m_irq_cb( 1 );
- }
- else
- {
- m_csr &= ~0x80;
- if ( !m_irq_cb.isnull() )
- m_irq_cb( 0 );
- }
-}
-
-
-
-inline void mc6846_device::update_cto()
-{
- int cto = CTO;
- if ( cto != m_old_cto )
- {
- LOG (( "%f: mc6846 CTO set to %i\n", machine().time().as_double(), cto ));
- m_old_cto = cto;
- }
- if ( !m_out_cto_cb.isnull() )
- m_out_cto_cb( (offs_t) 0, cto );
-}
-
-
-
-inline void mc6846_device::timer_launch()
-{
- int delay = FACTOR * (m_preset+1);
- LOG (( "%f: mc6846 timer launch called, mode=%i, preset=%i (x%i)\n", machine().time().as_double(), MODE, m_preset, FACTOR ));
-
- if ( ! (m_tcr & 2) )
- {
- logerror( "mc6846 external clock CTC not implemented\n" );
- }
-
- switch( MODE )
- {
- case 0x00:
- case 0x10: /* continuous */
- m_cto = 0;
- break;
-
- case 0x20: /* single-shot */
- m_cto = 0;
- m_one_shot->reset( attotime::from_usec(FACTOR) );
- break;
-
- case 0x30: /* cascaded single-shot */
- break;
-
- default:
- logerror( "mc6846 timer mode %i not implemented\n", MODE );
- m_interval->reset();
- m_timer_started = 0;
- return;
- }
-
- m_interval->reset( attotime::from_usec(delay) );
- m_timer_started = 1;
-
- m_csr &= ~1;
- update_cto();
- update_irq();
-}
-
-
-
-/******************* timer callbacks *********************************/
-
-TIMER_CALLBACK_MEMBER( mc6846_device::timer_expire )
-{
- int delay = FACTOR * (m_latch+1);
-
- LOG (( "%f: mc6846 timer expire called, mode=%i, latch=%i (x%i)\n", machine().time().as_double(), MODE, m_latch, FACTOR ));
-
- /* latch => counter */
- m_preset = m_latch;
-
- if ( ! (m_tcr & 2) )
- logerror( "mc6846 external clock CTC not implemented\n" );
-
- switch ( MODE )
- {
- case 0x00:
- case 0x10: /* continuous */
- m_cto = 1 ^ m_cto;
- break;
-
- case 0x20: /* single-shot */
- m_cto = 0;
- break;
-
- case 0x30: /* cascaded single-shot */
- m_cto = ( m_tcr & 0x80 ) ? 1 : 0;
- break;
-
- default:
- logerror( "mc6846 timer mode %i not implemented\n", MODE );
- m_interval->reset( );
- m_timer_started = 0;
- return;
- }
-
- m_interval->reset( attotime::from_usec(delay) );
-
- m_csr |= 1;
- update_cto();
- update_irq();
-}
-
-
-
-TIMER_CALLBACK_MEMBER( mc6846_device::timer_one_shot )
-{
- LOG (( "%f: mc6846 timer one shot called\n", machine().time().as_double() ));
-
- /* 1 micro second after one-shot launch, we put cto to high */
- m_cto = 1;
- update_cto();
-}
-
-
-
-/************************** CPU interface ****************************/
-
-
-READ8_MEMBER(mc6846_device::read)
-{
- switch ( offset )
- {
- case 0:
- case 4:
- LOG (( "%s %f: mc6846 CSR read $%02X intr=%i (timer=%i, cp1=%i, cp2=%i)\n",
- machine().describe_context(), space.machine().time().as_double(),
- m_csr, (m_csr >> 7) & 1,
- m_csr & 1, (m_csr >> 1) & 1, (m_csr >> 2) & 1 ));
- m_csr0_to_be_cleared = m_csr & 1;
- m_csr1_to_be_cleared = m_csr & 2;
- m_csr2_to_be_cleared = m_csr & 4;
- return m_csr;
-
- case 1:
- LOG (( "%s %f: mc6846 PCR read $%02X\n", machine().describe_context(), space.machine().time().as_double(), m_pcr ));
- return m_pcr;
-
- case 2:
- LOG (( "%s %f: mc6846 DDR read $%02X\n", machine().describe_context(), space.machine().time().as_double(), m_ddr ));
- return m_ddr;
-
- case 3:
- LOG (( "%s %f: mc6846 PORT read $%02X\n", machine().describe_context(), space.machine().time().as_double(), PORT ));
- if ( ! (m_pcr & 0x80) )
- {
- if ( m_csr1_to_be_cleared )
- m_csr &= ~2;
- if ( m_csr2_to_be_cleared )
- m_csr &= ~4;
- update_irq();
- m_csr1_to_be_cleared = 0;
- m_csr2_to_be_cleared = 0;
- }
- return PORT;
-
- case 5:
- LOG (( "%s %f: mc6846 TCR read $%02X\n",machine().describe_context(), space.machine().time().as_double(), m_tcr ));
- return m_tcr;
-
- case 6:
- LOG (( "%s %f: mc6846 COUNTER hi read $%02X\n", machine().describe_context(), space.machine().time().as_double(), counter() >> 8 ));
- if ( m_csr0_to_be_cleared )
- {
- m_csr &= ~1;
- update_irq();
- }
- m_csr0_to_be_cleared = 0;
- return counter() >> 8;
-
- case 7:
- LOG (( "%s %f: mc6846 COUNTER low read $%02X\n", machine().describe_context(), space.machine().time().as_double(), counter() & 0xff ));
- if ( m_csr0_to_be_cleared )
- {
- m_csr &= ~1;
- update_irq();
- }
- m_csr0_to_be_cleared = 0;
- return counter() & 0xff;
-
- default:
- logerror( "%s mc6846 invalid read offset %i\n", machine().describe_context(), offset );
- }
- return 0;
-}
-
-
-
-WRITE8_MEMBER(mc6846_device::write)
-{
- switch ( offset )
- {
- case 0:
- case 4:
- /* CSR is read-only */
- break;
-
- case 1:
- {
- static const char *const cp2[8] =
- {
- "in,neg-edge", "in,neg-edge,intr", "in,pos-edge", "in,pos-edge,intr",
- "out,intr-ack", "out,i/o-ack", "out,0", "out,1"
- };
- static const char *const cp1[8] =
- {
- "neg-edge", "neg-edge,intr", "pos-edge", "pos-edge,intr",
- "latched,neg-edge", "latched,neg-edge,intr",
- "latcged,pos-edge", "latcged,pos-edge,intr"
- };
- LOG (( "%s %f: mc6846 PCR write $%02X reset=%i cp2=%s cp1=%s\n",
- machine().describe_context(), space.machine().time().as_double(), data,
- (data >> 7) & 1, cp2[ (data >> 3) & 7 ], cp1[ data & 7 ] ));
-
- }
- m_pcr = data;
- if ( data & 0x80 )
- { /* data reset */
- m_pdr = 0;
- m_ddr = 0;
- m_csr &= ~6;
- update_irq();
- }
- if ( data & 4 )
- logerror( "%s mc6846 CP1 latching not implemented\n", machine().describe_context() );
- if (data & 0x20)
- {
- if (data & 0x10)
- {
- m_cp2_cpu = (data >> 3) & 1;
- if ( !m_out_cp2_cb.isnull() )
- m_out_cp2_cb( (offs_t) 0, m_cp2_cpu );
- }
- else
- logerror( "%s mc6846 acknowledge not implemented\n", machine().describe_context() );
- }
- break;
-
- case 2:
- LOG (( "%s %f: mc6846 DDR write $%02X\n", machine().describe_context(), space.machine().time().as_double(), data ));
- if ( ! (m_pcr & 0x80) )
- {
- m_ddr = data;
- if ( !m_out_port_cb.isnull() )
- m_out_port_cb( (offs_t) 0, m_pdr & m_ddr );
- }
- break;
-
- case 3:
- LOG (( "%s %f: mc6846 PORT write $%02X (mask=$%02X)\n", machine().describe_context(), space.machine().time().as_double(), data,m_ddr ));
- if ( ! (m_pcr & 0x80) )
- {
- m_pdr = data;
- if ( !m_out_port_cb.isnull() )
- m_out_port_cb( (offs_t) 0, m_pdr & m_ddr );
- if ( m_csr1_to_be_cleared && (m_csr & 2) )
- {
- m_csr &= ~2;
- LOG (( "%s %f: mc6846 CP1 intr reset\n", machine().describe_context(), space.machine().time().as_double() ));
- }
- if ( m_csr2_to_be_cleared && (m_csr & 4) )
- {
- m_csr &= ~4;
- LOG (( "%s %f: mc6846 CP2 intr reset\n", machine().describe_context(), space.machine().time().as_double() ));
- }
- m_csr1_to_be_cleared = 0;
- m_csr2_to_be_cleared = 0;
- update_irq();
- }
- break;
-
- case 5:
- {
- static const char *const mode[8] =
- {
- "continuous", "cascaded", "continuous", "one-shot",
- "freq-cmp", "freq-cmp", "pulse-cmp", "pulse-cmp"
- };
- LOG (( "%s %f: mc6846 TCR write $%02X reset=%i clock=%s scale=%i mode=%s out=%s\n",
- machine().describe_context(), space.machine().time().as_double(), data,
- (data >> 7) & 1, (data & 0x40) ? "extern" : "sys",
- (data & 0x40) ? 1 : 8, mode[ (data >> 1) & 7 ],
- (data & 1) ? "enabled" : "0" ));
-
- m_tcr = data;
- if ( m_tcr & 1 )
- {
- /* timer preset = initialization without launch */
- m_preset = m_latch;
- m_csr &= ~1;
- if ( MODE != 0x30 )
- m_cto = 0;
- update_cto();
- m_interval->reset();
- m_one_shot->reset();
- m_timer_started = 0;
- }
- else
- {
- /* timer launch */
- if ( ! m_timer_started )
- timer_launch();
- }
- update_irq();
- }
- break;
-
- case 6:
- m_time_MSB = data;
- break;
-
- case 7:
- m_latch = ( ((UINT16) m_time_MSB) << 8 ) + data;
- LOG (( "%s %f: mc6846 COUNT write %i\n", machine().describe_context(), space.machine().time().as_double(), m_latch ));
- if (!(m_tcr & 0x38))
- {
- /* timer initialization */
- m_preset = m_latch;
- m_csr &= ~1;
- update_irq();
- m_cto = 0;
- update_cto();
- /* launch only if started */
- if (!(m_tcr & 1))
- timer_launch();
- }
- break;
-
- default:
- logerror( "%s mc6846 invalid write offset %i\n", machine().describe_context(), offset );
- }
-}
-
-
-
-/******************** outside world interface ************************/
-
-
-
-void mc6846_device::set_input_cp1(int data)
-{
- data = (data != 0 );
- if ( data == m_cp1 )
- return;
- m_cp1 = data;
- LOG (( "%f: mc6846 input CP1 set to %i\n", machine().time().as_double(), data ));
- if (( data && (m_pcr & 2)) || (!data && !(m_pcr & 2)))
- {
- m_csr |= 2;
- update_irq();
- }
-}
-
-void mc6846_device::set_input_cp2(int data)
-{
- data = (data != 0 );
- if ( data == m_cp2 )
- return;
- m_cp2 = data;
- LOG (( "%f: mc6846 input CP2 set to %i\n", machine().time().as_double(), data ));
- if (m_pcr & 0x20)
- {
- if (( data && (m_pcr & 0x10)) || (!data && !(m_pcr & 0x10)))
- {
- m_csr |= 4;
- update_irq();
- }
- }
-}
-
-
-
-/************************ accessors **********************************/
-
-
-
-UINT8 mc6846_device::get_output_port()
-{
- return PORT;
-}
-
-
-
-UINT8 mc6846_device::get_output_cto()
-{
- return CTO;
-}
-
-
-
-UINT8 mc6846_device::get_output_cp2()
-{
- return m_cp2_cpu;
-}
-
-
-
-UINT16 mc6846_device::get_preset()
-{
- return m_preset;
-}
diff --git a/src/emu/machine/mc6846.h b/src/emu/machine/mc6846.h
deleted file mode 100644
index 0bf6b84658f..00000000000
--- a/src/emu/machine/mc6846.h
+++ /dev/null
@@ -1,125 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Antoine Mine
-/**********************************************************************
-
- Copyright (C) Antoine Mine' 2006
-
- Motorola 6846 timer emulation.
-
-**********************************************************************/
-
-#ifndef MC6846_H
-#define MC6846_H
-
-
-#define MCFG_MC6846_OUT_PORT_CB(_devcb) \
- devcb = &mc6846_device::set_out_port_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC6846_OUT_CP1_CB(_devcb) \
- devcb = &mc6846_device::set_out_cp1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC6846_OUT_CP2_CB(_devcb) \
- devcb = &mc6846_device::set_out_cp2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC6846_IN_PORT_CB(_devcb) \
- devcb = &mc6846_device::set_in_port_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC6846_OUT_CTO_CB(_devcb) \
- devcb = &mc6846_device::set_out_cto_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC6846_IRQ_CB(_devcb) \
- devcb = &mc6846_device::set_irq_callback(*device, DEVCB_##_devcb);
-
-
-class mc6846_device : public device_t
-{
-public:
- mc6846_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~mc6846_device() {}
-
- template<class _Object> static devcb_base &set_out_port_callback(device_t &device, _Object object) { return downcast<mc6846_device &>(device).m_out_port_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_cp1_callback(device_t &device, _Object object) { return downcast<mc6846_device &>(device).m_out_cp1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_cp2_callback(device_t &device, _Object object) { return downcast<mc6846_device &>(device).m_out_cp2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_port_callback(device_t &device, _Object object) { return downcast<mc6846_device &>(device).m_in_port_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_cto_callback(device_t &device, _Object object) { return downcast<mc6846_device &>(device).m_out_cto_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<mc6846_device &>(device).m_irq_cb.set_callback(object); }
-
- /* interface to CPU via address/data bus*/
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- /* asynchronous write from outside world into interrupt-generating pins */
- void set_input_cp1(int data);
- void set_input_cp2(int data);
-
- /* polling from outside world */
- UINT8 get_output_port();
- UINT8 get_output_cto();
- UINT8 get_output_cp2();
-
- /* partial access to internal state */
- UINT16 get_preset(); /* timer interval - 1 in us */
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
-
- /* registers */
- UINT8 m_csr; /* 0,4: combination status register */
- UINT8 m_pcr; /* 1: peripheral control register */
- UINT8 m_ddr; /* 2: data direction register */
- UINT8 m_pdr; /* 3: peripheral data register (last cpu write) */
- UINT8 m_tcr; /* 5: timer control register */
-
- /* lines */
- UINT8 m_cp1; /* 1-bit input */
- UINT8 m_cp2; /* 1-bit input/output: last external write */
- UINT8 m_cp2_cpu; /* last cpu write */
- UINT8 m_cto; /* 1-bit timer output (unmasked) */
-
- /* internal state */
- UINT8 m_time_MSB; /* MSB buffer register */
- UINT8 m_csr0_to_be_cleared;
- UINT8 m_csr1_to_be_cleared;
- UINT8 m_csr2_to_be_cleared;
- UINT16 m_latch; /* timer latch */
- UINT16 m_preset; /* preset value */
- UINT8 m_timer_started;
-
- /* timers */
- emu_timer *m_interval; /* interval programmable timer */
- emu_timer *m_one_shot; /* 1-us x factor one-shot timer */
-
- /* CPU write to the outside through chip */
- devcb_write8 m_out_port_cb; /* 8-bit output */
- devcb_write8 m_out_cp1_cb; /* 1-bit output */
- devcb_write8 m_out_cp2_cb; /* 1-bit output */
-
- /* CPU read from the outside through chip */
- devcb_read8 m_in_port_cb; /* 8-bit input */
-
- /* asynchronous timer output to outside world */
- devcb_write8 m_out_cto_cb; /* 1-bit output */
-
- /* timer interrupt */
- devcb_write_line m_irq_cb;
-
- int m_old_cif;
- int m_old_cto;
-
- inline UINT16 counter();
- inline void update_irq();
- inline void update_cto();
- inline void timer_launch();
-
- TIMER_CALLBACK_MEMBER(timer_expire);
- TIMER_CALLBACK_MEMBER(timer_one_shot);
-};
-
-extern const device_type MC6846;
-
-#endif
diff --git a/src/emu/machine/mc6852.c b/src/emu/machine/mc6852.c
deleted file mode 100644
index b0cf1ff9ca9..00000000000
--- a/src/emu/machine/mc6852.c
+++ /dev/null
@@ -1,302 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Motorola MC6852 Synchronous Serial Data Adapter emulation
-
-**********************************************************************/
-
-/*
-
- TODO:
-
- - FIFO
- - receive
- - transmit
- - parity
- - 1-sync-character mode
- - 2-sync-character mode
- - external sync mode
- - interrupts
-
-*/
-
-#include "mc6852.h"
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type MC6852 = &device_creator<mc6852_device>;
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-#define S_RDA 0x01
-#define S_TDRA 0x02
-#define S_DCD 0x04
-#define S_CTS 0x08
-#define S_TUF 0x10
-#define S_RX_OVRN 0x20
-#define S_PE 0x40
-#define S_IRQ 0x80
-
-
-#define C1_RX_RS 0x01
-#define C1_TX_RS 0x02
-#define C1_STRIP_SYNC 0x04
-#define C1_CLEAR_SYNC 0x08
-#define C1_TIE 0x10
-#define C1_RIE 0x20
-#define C1_AC_MASK 0xc0
-#define C1_AC_C2 0x00
-#define C1_AC_C3 0x40
-#define C1_AC_SYNC 0x80
-#define C1_AC_TX_FIFO 0xc0
-
-
-#define C2_PC1 0x01
-#define C2_PC2 0x02
-#define C2_1_2_BYTE 0x04
-#define C2_WS_MASK 0x38
-#define C2_WS_6_E 0x00
-#define C2_WS_6_O 0x08
-#define C2_WS_7 0x10
-#define C2_WS_8 0x18
-#define C2_WS_7_E 0x20
-#define C2_WS_7_O 0x28
-#define C2_WS_8_E 0x30
-#define C2_WS_8_O 0x38
-#define C2_TX_SYNC 0x40
-#define C2_EIE 0x80
-
-
-#define C3_E_I_SYNC 0x01
-#define C3_1_2_SYNC 0x02
-#define C3_CLEAR_CTS 0x04
-#define C3_CTUF 0x08
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mc6852_device - constructor
-//-------------------------------------------------
-
-mc6852_device::mc6852_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, MC6852, "MC6852", tag, owner, clock, "mc6852", __FILE__),
- device_serial_interface(mconfig, *this),
- m_write_tx_data(*this),
- m_write_irq(*this),
- m_write_sm_dtr(*this),
- m_write_tuf(*this),
- m_rx_clock(0),
- m_tx_clock(0),
- m_cts(1),
- m_dcd(1),
- m_sm_dtr(0),
- m_tuf(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mc6852_device::device_start()
-{
- // resolve callbacks
- m_write_tx_data.resolve_safe();
- m_write_irq.resolve_safe();
- m_write_sm_dtr.resolve_safe();
- m_write_tuf.resolve_safe();
-
- // register for state saving
- save_item(NAME(m_status));
- save_item(NAME(m_cr));
- save_item(NAME(m_scr));
- save_item(NAME(m_tdr));
- save_item(NAME(m_tsr));
- save_item(NAME(m_rdr));
- save_item(NAME(m_rsr));
- save_item(NAME(m_cts));
- save_item(NAME(m_dcd));
- save_item(NAME(m_sm_dtr));
- save_item(NAME(m_tuf));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mc6852_device::device_reset()
-{
- m_rx_fifo = std::queue<UINT8>();
- m_tx_fifo = std::queue<UINT8>();
-
- transmit_register_reset();
- receive_register_reset();
-
- set_rcv_rate(m_rx_clock);
- set_tra_rate(m_tx_clock);
-
- /* set receiver shift register to all 1's */
- m_rsr = 0xff;
-
- /* reset and inhibit receiver/transmitter sections */
- m_cr[0] |= (C1_TX_RS | C1_RX_RS);
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void mc6852_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- device_serial_interface::device_timer(timer, id, param, ptr);
-}
-
-
-//-------------------------------------------------
-// tra_callback -
-//-------------------------------------------------
-
-void mc6852_device::tra_callback()
-{
- m_write_tx_data(transmit_register_get_data_bit());
-}
-
-
-//-------------------------------------------------
-// tra_complete -
-//-------------------------------------------------
-
-void mc6852_device::tra_complete()
-{
- // TODO
-}
-
-
-//-------------------------------------------------
-// rcv_complete -
-//-------------------------------------------------
-
-void mc6852_device::rcv_complete()
-{
- // TODO
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( mc6852_device::read )
-{
- UINT8 data = 0;
-
- if (BIT(offset, 0))
- {
- if (m_rx_fifo.size() > 0)
- {
- data = m_rx_fifo.front();
- m_rx_fifo.pop();
- }
- }
- else
- {
- data = m_status;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( mc6852_device::write )
-{
- if (BIT(offset, 0))
- {
- switch (m_cr[0] & C1_AC_MASK)
- {
- case C1_AC_C2:
- /* control 2 */
- m_cr[1] = data;
- break;
-
- case C1_AC_C3:
- /* control 3 */
- m_cr[2] = data;
- break;
-
- case C1_AC_SYNC:
- /* sync code */
- m_scr = data;
- break;
-
- case C1_AC_TX_FIFO:
- /* transmit data FIFO */
- if (m_tx_fifo.size() < 3)
- {
- m_tx_fifo.push(data);
- }
- break;
- }
- }
- else
- {
- /* receiver reset */
- if (data & C1_RX_RS)
- {
- /* When Rx Rs is set, it clears the receiver
- control logic, sync logic, error logic, Rx Data FIFO Control,
- Parity Error status bit, and DCD interrupt. The Receiver Shift
- Register is set to ones.
- */
-
- if (LOG) logerror("MC6852 '%s' Receiver Reset\n", tag());
-
- m_status &= ~(S_RX_OVRN | S_PE | S_DCD | S_RDA);
- m_rsr = 0xff;
- }
-
- /* transmitter reset */
- if (data & C1_TX_RS)
- {
- /* When Tx Rs is set, it clears the transmitter
- control section, Transmitter Shift Register, Tx Data FIFO
- Control (the Tx Data FIFO can be reloaded after one E clock
- pulse), the Transmitter Underflow status bit, and the CTS interrupt,
- and inhibits the TDRA status bit (in the one-sync-character
- and two-sync-character modes).*/
-
- if (LOG) logerror("MC6852 '%s' Transmitter Reset\n", tag());
-
- m_status &= ~(S_TUF | S_CTS | S_TDRA);
- }
-
- if (LOG)
- {
- if (data & C1_STRIP_SYNC) logerror("MC6852 '%s' Strip Synchronization Characters\n", tag());
- if (data & C1_CLEAR_SYNC) logerror("MC6852 '%s' Clear Synchronization\n", tag());
- }
-
- m_cr[0] = data;
- }
-}
diff --git a/src/emu/machine/mc6852.h b/src/emu/machine/mc6852.h
deleted file mode 100644
index 859d9e8bef2..00000000000
--- a/src/emu/machine/mc6852.h
+++ /dev/null
@@ -1,132 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Motorola MC6852 Synchronous Serial Data Adapter emulation
-
-**********************************************************************
- _____ _____
- Vss 1 |* \_/ | 24 _CTS
- Rx DATA 2 | | 23 _DCD
- Rx CLK 3 | | 22 D0
- Tx CLK 4 | | 21 D1
- SM/_DTR 5 | | 20 D2
- Tx DATA 6 | MC6852 | 19 D3
- _IRQ 7 | | 18 D4
- TUF 8 | | 17 D5
- _RESET 9 | | 16 D6
- _CS 9 | | 15 D7
- RS 9 | | 14 E
- Vcc 10 |_____________| 13 R/_W
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MC6852__
-#define __MC6852__
-
-#include "emu.h"
-#include <queue>
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MC6852_RX_CLOCK(_clock) \
- mc6852_device::set_rx_clock(*device, _clock);
-
-#define MCFG_MC6852_TX_CLOCK(_clock) \
- mc6852_device::set_tx_clock(*device, _clock);
-
-#define MCFG_MC6852_TX_DATA_CALLBACK(_write) \
- devcb = &mc6852_device::set_tx_data_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MC6852_IRQ_CALLBACK(_write) \
- devcb = &mc6852_device::set_irq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MC6852_SM_DTR_CALLBACK(_write) \
- devcb = &mc6852_device::set_sm_dtr_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MC6852_TUF_CALLBACK(_write) \
- devcb = &mc6852_device::set_tuf_wr_callback(*device, DEVCB_##_write);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mc6852_device
-
-class mc6852_device : public device_t,
- public device_serial_interface
-{
-public:
- // construction/destruction
- mc6852_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void set_rx_clock(device_t &device, int clock) { downcast<mc6852_device &>(device).m_rx_clock = clock; }
- static void set_tx_clock(device_t &device, int clock) { downcast<mc6852_device &>(device).m_tx_clock = clock; }
- template<class _Object> static devcb_base &set_tx_data_wr_callback(device_t &device, _Object object) { return downcast<mc6852_device &>(device).m_write_tx_data.set_callback(object); }
- template<class _Object> static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<mc6852_device &>(device).m_write_irq.set_callback(object); }
- template<class _Object> static devcb_base &set_sm_dtr_wr_callback(device_t &device, _Object object) { return downcast<mc6852_device &>(device).m_write_sm_dtr.set_callback(object); }
- template<class _Object> static devcb_base &set_tuf_wr_callback(device_t &device, _Object object) { return downcast<mc6852_device &>(device).m_write_tuf.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( rx_data_w ) { device_serial_interface::rx_w(state); }
- DECLARE_WRITE_LINE_MEMBER( rx_clk_w ) { rx_clock_w(state); }
- DECLARE_WRITE_LINE_MEMBER( tx_clk_w ) { tx_clock_w(state); }
- DECLARE_WRITE_LINE_MEMBER( cts_w ) { m_cts = state; }
- DECLARE_WRITE_LINE_MEMBER( dcd_w ) { m_dcd = state; }
-
- DECLARE_READ_LINE_MEMBER( sm_dtr_r ) { return m_sm_dtr; }
- DECLARE_READ_LINE_MEMBER( tuf_r ) { return m_tuf; }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int m_param, void *ptr);
-
- // device_serial_interface overrides
- virtual void tra_callback();
- virtual void tra_complete();
- virtual void rcv_complete();
-
-private:
- devcb_write_line m_write_tx_data;
- devcb_write_line m_write_irq;
- devcb_write_line m_write_sm_dtr;
- devcb_write_line m_write_tuf;
-
- UINT8 m_status; // status register
- UINT8 m_cr[3]; // control registers
- UINT8 m_scr; // sync code register
- UINT8 m_tdr; // transmit data register
- UINT8 m_tsr; // transmit shift register
- UINT8 m_rdr; // receive data register
- UINT8 m_rsr; // receive shift register
-
- std::queue<UINT8> m_rx_fifo;
- std::queue<UINT8> m_tx_fifo;
-
- int m_rx_clock;
- int m_tx_clock;
- int m_cts; // clear to send
- int m_dcd; // data carrier detect
- int m_sm_dtr; // sync match/data terminal ready
- int m_tuf; // transmitter underflow
-};
-
-
-// device type definition
-extern const device_type MC6852;
-
-
-
-#endif
diff --git a/src/emu/machine/mc6854.c b/src/emu/machine/mc6854.c
deleted file mode 100644
index 7ed16885b19..00000000000
--- a/src/emu/machine/mc6854.c
+++ /dev/null
@@ -1,989 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Antoine Mine
-/**********************************************************************
-
- Copyright (C) Antoine Mine' 2006
-
- Motorola 6854 emulation.
-
- The MC6854 chip is an Advanced Data-Link Controller (ADLC).
- It provides a high-level network interface that can transimit frames with
- arbitrary data and address length, and is compatible with the following
- standards:
- - ADCCP (Advanced Data Communication Control Procedure)
- - HDLC (High-Level Data-Link Control)
- - SDLC (Synchronous Data-Link Control)
- It is designed to be interfaced with a M6800-family CPU.
-
- It is used in the "Nano-network" extension of the Thomson computers to
- link up to 32 computers at 500 Kbps.
- Many networks involving one PC server and several MO5 or TO7/70 computers
- were build in French schools in the 1980's to teach computer science.
-
- TODO:
- - CRC
- - DMA mode
- - loop mode
- - status prioritization
- - NRZI vs. NRZ coding
- - FD output
-
-**********************************************************************/
-
-
-#include "emu.h"
-#include "mc6854.h"
-
-
-/******************* parameters ******************/
-
-
-
-#define VERBOSE 0
-
-
-#define FLAG 0x7e
-/* flag value, as defined by HDLC protocol: 01111110 */
-
-#define BIT_LENGTH attotime::from_hz( 500000 )
-
-
-/******************* utility function and macros ********************/
-
-
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-
-
-/* control register 1 */
-
-#define AC ( m_cr1 & 1 )
-#define FCTDRA ( m_cr2 & 8 )
-/* extra register select bits */
-
-#define RRESET ( m_cr1 & 0x40 )
-#define TRESET ( m_cr1 & 0x80 )
-/* transmit / reset condition */
-
-#define RIE ( m_cr1 & 2 )
-#define TIE ( m_cr1 & 4 )
-/* interrupt enable */
-
-#define DISCONTINUE ( m_cr1 & 0x20 )
-/* discontinue received frame */
-
-
-
-/* control register 2 */
-
-#define PSE ( m_cr2 & 1 )
-/* prioritize status bits (TODO) */
-
-#define TWOBYTES ( m_cr2 & 2 )
-/* two-bytes mode */
-
-#define FMIDLE ( m_cr2 & 4 )
-/* flag time fill (vs. mark idle) */
-
-#define TLAST ( m_cr2 & 0x10 )
-/* transmit last byte of frame */
-
-#define RTS ( m_cr2 & 0x80 )
-/* request-to-send */
-
-
-
-/* control register 3 */
-
-#define LCF ( m_cr3 & 1 )
-/* logical control field select */
-
-#define CEX ( m_cr3 & 2 )
-/* control field is 16 bits instead of 8 */
-
-#define AEX ( m_cr3 & 4 )
-/* extended address mode (vs normal 8-bit address mode) */
-
-#define IDL0 ( m_cr3 & 8 )
-/* idle condition begins with a '0' instead of a '1" */
-
-#define FDSE ( m_cr3 & 0x10 )
-/* enable the flag detect status in SR1 */
-
-#define LOOP ( m_cr3 & 0x20 )
-/* loop mode */
-
-#define TST ( m_cr3 & 0x40 )
-/* test mode (or go active on poll) */
-
-#define DTR ( m_cr3 & 0x80 )
-/* data-transmit-ready (or loop on-line control) */
-
-
-
-/* control register 4 */
-
-#define TWOINTER ( m_cr4 & 1 )
-/* both an openning and a closing inter-frame are sent */
-
-static const int word_length[4] = { 5, 6, 7, 8 };
-#define TWL word_length[ ( m_cr4 >> 1 ) & 3 ]
-#define RWL word_length[ ( m_cr4 >> 3 ) & 3 ]
-/* transmit / receive word length */
-
-#define ABT ( m_cr4 & 0x20 )
-/* aborts */
-
-#define ABTEX ( m_cr4 & 0x40 )
-/* abort generates 16 '1' bits instead of 8 */
-
-#define NRZ ( m_cr4 & 0x80 )
-/* zero complement / non-zero complement data format */
-
-
-
-/* status register 1 */
-#define RDA 0x01 /* receiver data available */
-#define S2RQ 0x02 /* status register #2 read request */
-#define FD 0x04 /* flag detect */
-#define CTS 0x10 /* clear-to-send */
-#define TU 0x20 /* transmitter underrun */
-#define TDRA 0x40 /* transmitter data register available */
-#define IRQ 0x80 /* interrupt request */
-
-
-/* status register 2 */
-#define AP 0x01 /* address present */
-#define FV 0x02 /* frame valid */
-#define RIDLE 0x04 /* receiver idle */
-#define RABT 0x08 /* receiver abort */
-#define ERR 0x10 /* invalid frame error */
-#define DCD 0x20 /* data carrier detect (ignored) */
-#define OVRN 0x40 /* receiver overrun */
-#define RDA2 0x80 /* copy of RDA */
-
-
-
-const device_type MC6854 = &device_creator<mc6854_device>;
-
-mc6854_device::mc6854_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MC6854, "MC6854 ADLC", tag, owner, clock, "mc6854", __FILE__),
- m_out_irq_cb(*this),
- m_out_txd_cb(*this),
- m_out_rts_cb(*this),
- m_out_dtr_cb(*this),
- m_cr1(0),
- m_cr2(0),
- m_cr3(0),
- m_cr4(0),
- m_sr1(0),
- m_sr2(0),
- m_cts(0),
- m_dcd(0),
- m_tstate(0),
- m_tones(0),
- m_ttimer(NULL),
- m_rstate(0),
- m_rreg(0),
- m_rones(0),
- m_rsize(0),
- m_flen(0),
- m_fpos(0)
-{
- for (int i = 0; i < MC6854_FIFO_SIZE; i++)
- {
- m_tfifo[i] = 0;
- m_rfifo[i] = 0;
- }
-
- for (int i = 0; i < MAX_FRAME_LENGTH; i++)
- {
- m_frame[i] = 0;
- }
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mc6854_device::device_start()
-{
- m_out_irq_cb.resolve_safe();
- m_out_txd_cb.resolve();
- m_out_frame_cb.bind_relative_to(*owner());
- m_out_rts_cb.resolve_safe();
- m_out_dtr_cb.resolve_safe();
-
- m_ttimer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc6854_device::tfifo_cb), this));
-
- save_item(NAME(m_cr1));
- save_item(NAME(m_cr2));
- save_item(NAME(m_cr3));
- save_item(NAME(m_cr4));
- save_item(NAME(m_sr1));
- save_item(NAME(m_sr2));
- save_item(NAME(m_cts));
- save_item(NAME(m_dcd));
- save_item(NAME(m_tstate));
- save_item(NAME(m_tfifo));
- save_item(NAME(m_tones));
- save_item(NAME(m_rstate));
- save_item(NAME(m_rreg));
- save_item(NAME(m_rones));
- save_item(NAME(m_rsize));
- save_item(NAME(m_rfifo));
- save_item(NAME(m_frame));
- save_item(NAME(m_flen));
- save_item(NAME(m_fpos));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mc6854_device::device_reset()
-{
- LOG (( "mc6854 reset\n" ));
- m_cr1 = 0xc0; /* reset condition */
- m_cr2 = 0;
- m_cr3 = 0;
- m_cr4 = 0;
- m_sr1 = 0;
- m_sr2 = 0;
- m_cts = 0;
- m_dcd = 0;
- tfifo_clear( );
- rfifo_clear( );
-}
-
-/*********************** transmit ***********************/
-
-
-
-/* MC6854 fills bit queue */
-void mc6854_device::send_bits( UINT32 data, int len, int zi )
-{
- attotime expire;
- int i;
- if ( zi )
- {
- /* zero-insertion mode */
- UINT32 d = 0;
- int l = 0;
- for ( i = 0; i < len; i++, data >>= 1, l++ )
- {
- if ( data & 1 )
- {
- d |= 1 << l;
- m_tones++;
- if ( m_tones == 5 )
- {
- /* insert a '0' after 5 consecutive '1" */
- m_tones = 0;
- l++;
- }
- }
- else
- m_tones = 0;
- }
- data = d;
- len = l;
- }
- else
- m_tones = 0;
-
- /* send bits */
- if ( !m_out_txd_cb.isnull() )
- {
- for ( i = 0; i < len; i++, data >>= 1 )
- m_out_txd_cb( data & 1 );
- }
-
- /* schedule when to ask the MC6854 for more bits */
- expire = m_ttimer ->remaining( );
- if ( expire== attotime::never )
- expire = attotime::zero;
- m_ttimer->reset( expire + (BIT_LENGTH * len));
-}
-
-
-
-/* CPU push -> tfifo[0] -> ... -> tfifo[MC6854_FIFO_SIZE-1] -> pop */
-void mc6854_device::tfifo_push( UINT8 data )
-{
- int i;
-
- if ( TRESET )
- return;
-
- /* push towards the rightmost free entry */
- for ( i = MC6854_FIFO_SIZE - 1; i >= 0; i-- )
- {
- if ( ! ( m_tfifo[ i ] & 0x100 ) )
- break;
- }
-
- if ( i >= 0 )
- m_tfifo[ i ] = data | 0x100;
- else
- logerror( "%f mc6854_tfifo_push: FIFO overrun\n", machine().time().as_double() );
-
- /* start frame, if needed */
- if ( ! m_tstate )
- {
- LOG(( "%f mc6854_tfifo_push: start frame\n", machine().time().as_double() ));
- m_tstate = 2;
- send_bits( FLAG, 8, 0 );
- }
-}
-
-
-
-/* CPU asks for normal frame termination */
-void mc6854_device::tfifo_terminate( )
-{
- /* mark most recently pushed byte as the last one of the frame */
- int i;
- for ( i = 0; i < MC6854_FIFO_SIZE; i++ )
- {
- if ( m_tfifo[ i ] & 0x100 )
- {
- m_tfifo[ i ] |= 0x200;
- break;
- }
- }
-}
-
-
-
-/* call-back to refill the bit-stream from the FIFO */
-TIMER_CALLBACK_MEMBER(mc6854_device::tfifo_cb)
-{
- int i, data = m_tfifo[ MC6854_FIFO_SIZE - 1 ];
-
- if ( ! m_tstate )
- return;
-
- /* shift FIFO to the right */
- for ( i = MC6854_FIFO_SIZE - 1; i > 0; i-- )
- m_tfifo[ i ] = m_tfifo[ i - 1 ];
- m_tfifo[ 0 ] = 0;
-
- if ( data & 0x100 )
- {
- /* got data */
-
- int blen = 8;
-
- switch ( m_tstate )
- {
- case 2: /* 8-bit address field */
- if ( ( data & 1 ) || ( ! AEX ) )
- m_tstate = 3;
- LOG(( "%f mc6854_tfifo_cb: address field $%02X\n", machine().time().as_double(), data & 0xff ));
- break;
-
- case 3: /* 8-bit control field */
- if ( CEX )
- m_tstate = 4;
- else if ( LCF )
- m_tstate = 5;
- else
- m_tstate = 6;
- LOG(( "%f mc6854_tfifo_cb: control field $%02X\n", machine().time().as_double(), data & 0xff ));
- break;
-
- case 4: /* 8-bit extended control field (optional) */
- if ( LCF )
- m_tstate = 5;
- else
- m_tstate = 6;
- LOG(( "%f mc6854_tfifo_cb: control field $%02X\n", machine().time().as_double(), data & 0xff ));
- break;
-
- case 5: /* 8-bit logical control (optional) */
- if ( ! ( data & 0x80 ) )
- m_tstate = 6;
- LOG(( "%f mc6854_tfifo_cb: logical control field $%02X\n", machine().time().as_double(), data & 0xff ));
- break;
-
- case 6: /* variable-length data */
- blen = TWL;
- LOG(( "%f mc6854_tfifo_cb: data field $%02X, %i bits\n", machine().time().as_double(), data & 0xff, blen ));
- break;
-
- default:
- LOG(( "%f mc6854_tfifo_cb: state=%i\n", machine().time().as_double(), m_tstate));
- }
-
- if ( m_flen < MAX_FRAME_LENGTH )
- m_frame[ m_flen++ ] = data;
- else
- logerror( "mc6854_tfifo_cb: truncated frame, max=%i\n", MAX_FRAME_LENGTH );
-
- send_bits( data, blen, 1 );
- }
- else
- {
- /* data underrun => abort */
- logerror( "%f mc6854_tfifo_cb: FIFO underrun\n", machine().time().as_double() );
- m_sr1 |= TU;
- m_tstate = 0;
- send_bits( 0xffff, ABTEX ? 16 : 8, 0 );
- m_flen = 0;
- }
-
- /* close frame, if needed */
- if ( data & 0x200 )
- {
- int len = m_flen;
-
- LOG(( "%f mc6854_tfifo_cb: end frame\n", machine().time().as_double() ));
- send_bits( 0xdeadbeef, 16, 1 ); /* send check-sum: TODO */
- send_bits( FLAG, 8, 0 ); /* send closing flag */
-
- if ( m_tfifo[ MC6854_FIFO_SIZE - 1 ] & 0x100 )
- {
- /* re-open frame asap */
- LOG(( "%f mc6854_tfifo_cb: start frame\n", machine().time().as_double() ));
- if ( TWOINTER )
- send_bits( FLAG, 8, 0 );
- }
- else
- m_tstate = 0;
-
- m_flen = 0;
- if ( !m_out_frame_cb.isnull() )
- m_out_frame_cb( m_frame, len );
- }
-}
-
-
-
-void mc6854_device::tfifo_clear( )
-{
- memset( m_tfifo, 0, sizeof( m_tfifo ) );
- m_tstate = 0;
- m_flen = 0;
- m_ttimer->reset( );
-}
-
-
-
-/*********************** receive ***********************/
-
-
-
-/* MC6854 pushes a field in the FIFO */
-void mc6854_device::rfifo_push( UINT8 d )
-{
- int i, blen = 8;
- unsigned data = d;
-
- switch ( m_rstate )
- {
- case 0:
- case 1:
- case 2: /* 8-bit address field */
- if ( ( data & 1 ) || ( ! AEX ) )
- m_rstate = 3;
- else
- m_rstate = 2;
- LOG(( "%f mc6854_rfifo_push: address field $%02X\n", machine().time().as_double(), data ));
- data |= 0x400; /* address marker */
- break;
-
- case 3: /* 8-bit control field */
- if ( CEX )
- m_rstate = 4;
- else if ( LCF )
- m_rstate = 5;
- else
- m_rstate = 6;
- LOG(( "%f mc6854_rfifo_push: control field $%02X\n", machine().time().as_double(), data ));
- break;
-
- case 4: /* 8-bit extended control field (optional) */
- if ( LCF )
- m_rstate = 5;
- else
- m_rstate = 6;
- LOG(( "%f mc6854_rfifo_push: control field $%02X\n", machine().time().as_double(), data ));
- break;
-
- case 5: /* 8-bit logical control (optional) */
- if ( ! ( data & 0x80 ) )
- m_rstate = 6;
- LOG(( "%f mc6854_rfifo_push: logical control field $%02X\n", machine().time().as_double(), data ));
- break;
-
- case 6: /* variable-length data */
- blen = RWL;
- data >>= 8 - blen;
- LOG(( "%f mc6854_rfifo_push: data field $%02X, %i bits\n", machine().time().as_double(), data, blen ));
- break;
- }
-
- /* no further FIFO fill until FV is cleared! */
- if ( m_sr2 & FV )
- {
- LOG(( "%f mc6854_rfifo_push: field not pushed\n", machine().time().as_double() ));
- return;
- }
-
- data |= 0x100; /* entry full marker */
-
- /* push towards the rightmost free entry */
- for ( i = MC6854_FIFO_SIZE - 1; i >= 0; i-- )
- {
- if ( ! ( m_rfifo[ i ] & 0x100 ) )
- break;
- }
-
- if ( i >= 0 )
- m_rfifo[ i ] = data | 0x100;
- else
- {
- /* FIFO full */
- m_sr2 |= OVRN;
- m_rfifo[ 0 ] = data;
- logerror( "%f mc6854_rfifo_push: FIFO overrun\n", machine().time().as_double() );
- }
-
- m_rsize -= blen;
-}
-
-
-
-void mc6854_device::rfifo_terminate( )
-{
- /* mark most recently pushed byte as the last one of the frame */
- int i;
- for ( i = 0; i < MC6854_FIFO_SIZE; i++ )
- {
- if ( m_rfifo[ i ] & 0x100 )
- {
- m_tfifo[ i ] |= 0x200;
- break;
- }
-
- }
-
- m_flen = 0;
- m_rstate = 1;
-}
-
-
-
-/* CPU pops the FIFO */
-UINT8 mc6854_device::rfifo_pop( )
-{
- int i, data = m_rfifo[ MC6854_FIFO_SIZE - 1 ];
-
- /* shift FIFO to the right */
- for ( i = MC6854_FIFO_SIZE - 1; i > 0; i -- )
- m_rfifo[ i ] = m_rfifo[ i - 1 ];
- m_rfifo[ 0 ] = 0;
-
- if ( m_rfifo[ MC6854_FIFO_SIZE - 1 ] & 0x200 )
- {
- /* last byte in frame */
- m_sr2 |= FV; /* TODO: check CRC & set ERR instead of FV if error*/
- }
-
- /* auto-refill in frame mode */
- if ( m_flen > 0 )
- {
- rfifo_push( m_frame[ m_fpos++ ] );
- if ( m_fpos == m_flen )
- rfifo_terminate( );
- }
-
- return data;
-}
-
-
-/* MC6854 makes fields from bits */
-WRITE_LINE_MEMBER( mc6854_device::set_rx )
-{
- int fieldlen = ( m_rstate < 6 ) ? 8 : RWL;
-
- if ( RRESET || (m_sr2 & DCD) )
- return;
-
- if ( state )
- {
- m_rones++;
- m_rreg = (m_rreg >> 1) | 0x80000000;
- if ( m_rones >= 8 )
- {
- /* abort */
- m_rstate = 0;
- m_rsize = 0;
- if ( m_rstate > 1 )
- {
- /* only in-frame abort */
- m_sr2 |= RABT;
- LOG(( "%f mc6854_receive_bit: abort\n", machine().time().as_double() ));
- }
- }
- else
- {
- m_rsize++;
- if ( m_rstate && m_rsize >= fieldlen + 24 )
- rfifo_push( m_rreg );
- }
- }
- else if ( m_rones == 5 )
- {
- /* discards '0' inserted after 5 '1' */
- m_rones = 0;
- return;
- }
- else if ( m_rones == 6 )
- {
- /* flag */
- if ( FDSE )
- m_sr1 |= FD;
-
- if ( m_rstate > 1 )
- {
- /* end of frame */
- m_rreg >>= 1;
- m_rsize++;
- if ( m_rsize >= fieldlen + 24 ) /* last field */
- rfifo_push( m_rreg );
- rfifo_terminate( );
- LOG(( "%f mc6854_receive_bit: end of frame\n", machine().time().as_double() ));
- }
- m_rones = 0;
- m_rstate = 1;
- m_rsize = 0;
- } else
- {
- m_rones = 0;
- m_rreg >>= 1;
- m_rsize++;
- if ( m_rstate && m_rsize >= fieldlen + 24 )
- rfifo_push( m_rreg );
- }
-}
-
-
-
-void mc6854_device::rfifo_clear( )
-{
- memset( m_rfifo, 0, sizeof( m_rfifo ) );
- m_rstate = 0;
- m_rreg = 0;
- m_rsize = 0;
- m_rones = 0;
- m_flen = 0;
-}
-
-
-
-int mc6854_device::send_frame( UINT8* data, int len )
-{
- if ( m_rstate > 1 || m_tstate > 1 || RTS )
- return -1; /* busy */
-
- if ( len > MAX_FRAME_LENGTH )
- {
- logerror( "mc6854_send_frame: truncated frame, size=%i, max=%i\n", len, MAX_FRAME_LENGTH );
- len = MAX_FRAME_LENGTH;
- }
- else if ( len < 2 )
- {
- logerror( "mc6854_send_frame: frame too short, size=%i, min=2\n", len );
- len = 2;
- }
- memcpy( m_frame, data, len );
- if ( FDSE )
- m_sr1 |= FD;
- m_flen = len;
- m_fpos = 0;
- rfifo_push( m_frame[ m_fpos++ ] );
- rfifo_push( m_frame[ m_fpos++ ] );
- if ( m_fpos == m_flen )
- rfifo_terminate( );
- return 0;
-}
-
-
-
-/************************** CPU interface ****************************/
-
-
-
-WRITE_LINE_MEMBER( mc6854_device::set_cts )
-{
- if ( ! m_cts && state )
- m_sr1 |= CTS;
- m_cts = state;
-
- if ( m_cts )
- m_sr1 |= CTS;
- else
- m_sr1 &= ~CTS;
-}
-
-
-
-WRITE_LINE_MEMBER( mc6854_device::set_dcd )
-{
- if ( ! m_dcd && state )
- {
- m_sr2 |= DCD;
- /* partial reset */
- m_rstate = 0;
- m_rreg = 0;
- m_rsize = 0;
- m_rones = 0;
- }
- m_dcd = state;
-}
-
-
-
-void mc6854_device::update_sr2( )
-{
- /* update RDA */
- m_sr2 |= RDA2;
- if ( ! (m_rfifo[ MC6854_FIFO_SIZE - 1 ] & 0x100) )
- m_sr2 &= ~RDA2;
- else if ( TWOBYTES && ! (m_tfifo[ MC6854_FIFO_SIZE - 2 ] & 0x100) )
- m_sr2 &= ~RDA2;
-
- /* update AP */
- if ( m_rfifo[ MC6854_FIFO_SIZE - 1 ] & 0x400 )
- m_sr2 |= AP;
- else
- m_sr2 &= ~AP;
-}
-
-
-
-void mc6854_device::update_sr1( )
-{
- update_sr2( );
-
- /* update S2RQ */
- if ( m_sr2 & 0x7f )
- m_sr1 |= S2RQ;
- else
- m_sr1 &= ~S2RQ;
-
- /* update TRDA (always prioritized by CTS) */
- if ( TRESET || ( m_sr1 & CTS ) )
- m_sr1 &= ~TDRA;
- else
- {
- m_sr1 |= TDRA;
- if ( m_tfifo[ 0 ] & 0x100 )
- m_sr1 &= ~TDRA;
- else if ( TWOBYTES && (m_tfifo[ 1 ] & 0x100) )
- m_sr1 &= ~TDRA;
- }
-
- /* update RDA */
- if ( m_sr2 & RDA2 )
- m_sr1 |= RDA;
- else
- m_sr1 &= ~RDA;
-
- /* update IRQ */
- m_sr1 &= ~IRQ;
- if ( RIE && (m_sr1 & (TU | TDRA) ) )
- m_sr1 |= IRQ;
- if ( TIE )
- {
- if ( m_sr1 & (S2RQ | RDA | CTS) )
- m_sr1 |= IRQ;
- if ( m_sr2 & (ERR | FV | DCD | OVRN | RABT | RIDLE | AP) )
- m_sr1 |= IRQ;
- }
-
- m_out_irq_cb((m_sr1 & IRQ) ? ASSERT_LINE : CLEAR_LINE);
-}
-
-
-
-READ8_MEMBER( mc6854_device::read )
-{
- switch ( offset )
- {
- case 0: /* status register 1 */
- update_sr1( );
- LOG(( "%f %s mc6854_r: get SR1=$%02X (rda=%i,s2rq=%i,fd=%i,cts=%i,tu=%i,tdra=%i,irq=%i)\n",
- space.machine().time().as_double(), machine().describe_context(), m_sr1,
- ( m_sr1 & RDA) ? 1 : 0, ( m_sr1 & S2RQ) ? 1 : 0,
- ( m_sr1 & FD ) ? 1 : 0, ( m_sr1 & CTS ) ? 1 : 0,
- ( m_sr1 & TU ) ? 1 : 0, ( m_sr1 & TDRA) ? 1 : 0,
- ( m_sr1 & IRQ) ? 1 : 0 ));
- return m_sr1;
-
- case 1: /* status register 2 */
- update_sr2( );
- LOG(( "%f %s mc6854_r: get SR2=$%02X (ap=%i,fv=%i,ridle=%i,rabt=%i,err=%i,dcd=%i,ovrn=%i,rda2=%i)\n",
- space.machine().time().as_double(), machine().describe_context(), m_sr2,
- ( m_sr2 & AP ) ? 1 : 0, ( m_sr2 & FV ) ? 1 : 0,
- ( m_sr2 & RIDLE) ? 1 : 0, ( m_sr2 & RABT) ? 1 : 0,
- ( m_sr2 & ERR ) ? 1 : 0, ( m_sr2 & DCD ) ? 1 : 0,
- ( m_sr2 & OVRN ) ? 1 : 0, ( m_sr2 & RDA2) ? 1 : 0 ));
- return m_sr2;
-
- case 2: /* receiver data register */
- case 3:
- {
- UINT8 data = rfifo_pop( );
- LOG(( "%f %s mc6854_r: get data $%02X\n",
- space.machine().time().as_double(), machine().describe_context(), data ));
- return data;
- }
-
- default:
- logerror( "%s mc6854 invalid read offset %i\n", machine().describe_context(), offset );
- }
- return 0;
-}
-
-
-
-WRITE8_MEMBER( mc6854_device::write )
-{
- switch ( offset )
- {
- case 0: /* control register 1 */
- m_cr1 = data;
- LOG(( "%f %s mc6854_w: set CR1=$%02X (ac=%i,irq=%c%c,%sreset=%c%c)\n",
- space.machine().time().as_double(), machine().describe_context(), m_cr1,
- AC ? 1 : 0,
- RIE ? 'r' : '-', TIE ? 't' : '-',
- DISCONTINUE ? "discontinue," : "",
- RRESET ? 'r' : '-', TRESET ? 't' : '-'
- ));
- if ( m_cr1 & 0xc )
- logerror( "%s mc6854 DMA not handled (CR1=$%02X)\n",
- machine().describe_context(), m_cr1 );
- if ( DISCONTINUE )
- {
- /* abort receive FIFO but keeps shift register & synchro */
- m_rstate = 0;
- memset( m_rfifo, 0, sizeof( m_rfifo ) );
- }
- if ( RRESET )
- {
- /* abort FIFO & synchro */
- rfifo_clear( );
- m_sr1 &= ~FD;
- m_sr2 &= ~(AP | FV | RIDLE | RABT | ERR | OVRN | DCD);
- if ( m_dcd ) m_sr2 |= DCD;
- }
- if ( TRESET )
- {
- tfifo_clear( );
- m_sr1 &= ~(TU | TDRA | CTS);
- if ( m_cts ) m_sr1 |= CTS;
- }
- break;
-
- case 1:
- if ( AC )
- {
- /* control register 3 */
- m_cr3 = data;
- LOG(( "%f %s mc6854_w: set CR3=$%02X (lcf=%i,aex=%i,idl=%i,fdse=%i,loop=%i,tst=%i,dtr=%i)\n",
- space.machine().time().as_double(), machine().describe_context(), m_cr3,
- LCF ? (CEX ? 16 : 8) : 0, AEX ? 1 : 0,
- IDL0 ? 0 : 1, FDSE ? 1 : 0, LOOP ? 1 : 0,
- TST ? 1 : 0, DTR ? 1 : 0
- ));
- if ( LOOP )
- logerror( "%s mc6854 loop mode not handled (CR3=$%02X)\n", machine().describe_context(), m_cr3 );
- if ( TST )
- logerror( "%s mc6854 test mode not handled (CR3=$%02X)\n", machine().describe_context(), m_cr3 );
-
- m_out_dtr_cb( DTR ? 1 : 0 );
-
- }
- else
- {
- /* control register 2 */
- m_cr2 = data;
- LOG(( "%f %s mc6854_w: set CR2=$%02X (pse=%i,bytes=%i,fmidle=%i,%s,tlast=%i,clr=%c%c,rts=%i)\n",
- space.machine().time().as_double(), machine().describe_context(), m_cr2,
- PSE ? 1 : 0, TWOBYTES ? 2 : 1, FMIDLE ? 1 : 0,
- FCTDRA ? "fc" : "tdra", TLAST ? 1 : 0,
- data & 0x20 ? 'r' : '-', data & 0x40 ? 't' : '-',
- RTS ? 1 : 0 ));
- if ( PSE )
- logerror( "%s mc6854 status prioritization not handled (CR2=$%02X)\n", machine().describe_context(), m_cr2 );
- if ( TLAST )
- tfifo_terminate( );
- if ( data & 0x20 )
- {
- /* clear receiver status */
- m_sr1 &= ~FD;
- m_sr2 &= ~(AP | FV | RIDLE | RABT | ERR | OVRN | DCD);
- if ( m_dcd )
- m_sr2 |= DCD;
- }
- if ( data & 0x40 )
- {
- /* clear transmitter status */
- m_sr1 &= ~(TU | TDRA | CTS);
- if ( m_cts )
- m_sr1 |= CTS;
- }
-
- m_out_rts_cb( RTS ? 1 : 0 );
- }
- break;
-
- case 2: /* transmitter data: continue data */
- LOG(( "%f %smc6854_w: push data=$%02X\n", space.machine().time().as_double(), machine().describe_context(), data ));
- tfifo_push( data );
- break;
-
- case 3:
- if ( AC )
- {
- /* control register 4 */
- m_cr4 = data;
- LOG(( "%f %s mc6854_w: set CR4=$%02X (interframe=%i,tlen=%i,rlen=%i,%s%s)\n", space.machine().time().as_double(), machine().describe_context(), m_cr4,
- TWOINTER ? 2 : 1,
- TWL, RWL,
- ABT ? ( ABTEX ? "abort-ext," : "abort,") : "",
- NRZ ? "nrz" : "nrzi" ));
- if ( ABT )
- {
- m_tstate = 0;
- send_bits( 0xffff, ABTEX ? 16 : 8, 0 );
- m_flen = 0;
- }
- }
- else
- {
- /* transmitter data: last data */
- LOG(( "%f %s mc6854_w: push last-data=$%02X\n", space.machine().time().as_double(), machine().describe_context(), data ));
- tfifo_push( data );
- tfifo_terminate( );
- }
- break;
-
- default:
- logerror( "%s mc6854 invalid write offset %i (data=$%02X)\n", machine().describe_context(), offset, data );
- }
-}
-
-WRITE_LINE_MEMBER( mc6854_device::rxc_w )
-{
- // TODO
-}
-
-WRITE_LINE_MEMBER( mc6854_device::txc_w )
-{
- // TODO
-}
diff --git a/src/emu/machine/mc6854.h b/src/emu/machine/mc6854.h
deleted file mode 100644
index 2808255c0f6..00000000000
--- a/src/emu/machine/mc6854.h
+++ /dev/null
@@ -1,161 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Antoine Mine
-/**********************************************************************
-
- Copyright (C) Antoine Mine' 2006
-
- Motorola 6854 emulation (network interface).
-
-**********************************************************************/
-
-#ifndef MC6854_H
-#define MC6854_H
-
-
-#define MAX_FRAME_LENGTH 65536
-/* arbitrary value, you may need to enlarge it if you get truncated frames */
-
-#define MC6854_FIFO_SIZE 3
-/* hardcoded size of the 6854 FIFO (this is a hardware limit) */
-
-typedef device_delegate<void (UINT8 *data, int length)> mc6854_out_frame_delegate;
-#define MC6854_OUT_FRAME_CB(name) void name(UINT8 * data, int length)
-
-
-#define MCFG_MC6854_OUT_IRQ_CB(_devcb) \
- devcb = &mc6854_device::set_out_irq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC6854_OUT_TXD_CB(_devcb) \
- devcb = &mc6854_device::set_out_txd_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC6854_OUT_FRAME_CB(_class, _method) \
- mc6854_device::set_out_frame_callback(*device, mc6854_out_frame_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_MC6854_OUT_RTS_CB(_devcb) \
- devcb = &mc6854_device::set_out_rts_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC6854_OUT_DTR_CB(_devcb) \
- devcb = &mc6854_device::set_out_dtr_callback(*device, DEVCB_##_devcb);
-
-
-class mc6854_device : public device_t
-{
-public:
- mc6854_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~mc6854_device() {}
-
- template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<mc6854_device &>(device).m_out_irq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_txd_callback(device_t &device, _Object object) { return downcast<mc6854_device &>(device).m_out_txd_cb.set_callback(object); }
- static void set_out_frame_callback(device_t &device, mc6854_out_frame_delegate callback) { downcast<mc6854_device &>(device).m_out_frame_cb = callback; }
- template<class _Object> static devcb_base &set_out_rts_callback(device_t &device, _Object object) { return downcast<mc6854_device &>(device).m_out_rts_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dtr_callback(device_t &device, _Object object) { return downcast<mc6854_device &>(device).m_out_dtr_cb.set_callback(object); }
-
- /* interface to CPU via address/data bus*/
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- /* low-level, bit-based interface */
- DECLARE_WRITE_LINE_MEMBER( set_rx );
-
- /* high-level, frame-based interface */
- int send_frame( UINT8* data, int length ); /* ret -1 if busy */
-
- /* control lines */
- DECLARE_WRITE_LINE_MEMBER( set_cts ); /* 1 = clear-to-send, 0 = busy */
- DECLARE_WRITE_LINE_MEMBER( set_dcd ); /* 1 = carrier, 0 = no carrier */
-
- /* clock */
- DECLARE_WRITE_LINE_MEMBER( rxc_w );
- DECLARE_WRITE_LINE_MEMBER( txc_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
- devcb_write_line m_out_irq_cb; /* interrupt request */
-
- /* low-level, bit-based interface */
- devcb_write_line m_out_txd_cb; /* transmit bit */
-
- /* high-level, frame-based interface */
- mc6854_out_frame_delegate m_out_frame_cb;
-
- /* control lines */
- devcb_write_line m_out_rts_cb; /* 1 = transmitting, 0 = idle */
- devcb_write_line m_out_dtr_cb; /* 1 = data transmit ready, 0 = busy */
-
- /* registers */
- UINT8 m_cr1, m_cr2, m_cr3, m_cr4; /* control registers */
- UINT8 m_sr1, m_sr2; /* status registers */
-
- UINT8 m_cts, m_dcd;
-
- /* transmit state */
- UINT8 m_tstate;
- UINT16 m_tfifo[MC6854_FIFO_SIZE]; /* X x 8-bit FIFO + full & last marker bits */
- UINT8 m_tones; /* counter for zero-insertion */
- emu_timer *m_ttimer; /* when to ask for more data */
-
- /* receive state */
- UINT8 m_rstate;
- UINT32 m_rreg; /* shift register */
- UINT8 m_rones; /* count '1 bits */
- UINT8 m_rsize; /* bits in the shift register */
- UINT16 m_rfifo[MC6854_FIFO_SIZE]; /* X x 8-bit FIFO + full & addr marker bits */
-
- /* frame-based interface*/
- UINT8 m_frame[MAX_FRAME_LENGTH];
- UINT32 m_flen, m_fpos;
-
-
- /* meaning of tstate / rtate:
- 0 = idle / waiting for frame flag
- 1 = flag sync
- 2 = 8-bit address field(s)
- 3-4 = 8-bit control field(s)
- 5 = 8-bit logical control field(s)
- 6 = variable-length data field(s)
- */
-
- void send_bits( UINT32 data, int len, int zi );
- void tfifo_push( UINT8 data );
- void tfifo_terminate( );
- TIMER_CALLBACK_MEMBER(tfifo_cb);
- void tfifo_clear( );
-
- void rfifo_push( UINT8 d );
- void rfifo_terminate( );
- UINT8 rfifo_pop( );
- void rfifo_clear( );
-
- void update_sr2( );
- void update_sr1( );
-};
-
-extern const device_type MC6854;
-
-
-/* we provide two interfaces:
- - a bit-based interface: out_tx, set_rx
- - a frame-based interface: out_frame, send_frame
-
- The bit-based interface is low-level and slow.
- Use it to simulate the actual bits sent into the wires, e.g., to connect
- the emulator to another bit-based emulated network device, or an actual
- device.
-
- The frame-based interface is higher-level and faster.
- It passes bytes directly from one end to the other without bothering with
- the actual bit-encoding, synchronization, and CRC.
- Once completed, a frame is sent through out_frame. Aborted frames are not
- transmitted at all. No start flag, stop flag, or crc bits are trasmitted.
- send_frame makes a frame available to the CPU through the 6854 (it may
- fail and return -1 if the 6854 is not ready to accept the frame; even
- if the frame is accepted and 0 is returned, the CPU may abort it). Ony
- full frames are accepted.
-*/
-
-#endif
diff --git a/src/emu/machine/mc68681.c b/src/emu/machine/mc68681.c
deleted file mode 100644
index 8b40488de24..00000000000
--- a/src/emu/machine/mc68681.c
+++ /dev/null
@@ -1,1152 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Mariusz Wojcieszek, R. Belmont
-/*
- 68681 DUART
-
- Written by Mariusz Wojcieszek
- Updated by Jonathan Gevaryahu AKA Lord Nightmare
- Improved interrupt handling by R. Belmont
- Rewrite and modernization in progress by R. Belmont
-*/
-
-#include "emu.h"
-#include "mc68681.h"
-
-#define VERBOSE 0
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-static const char *const duart68681_reg_read_names[0x10] =
-{
- "MRA", "SRA", "BRG Test", "RHRA", "IPCR", "ISR", "CTU", "CTL", "MRB", "SRB", "1X/16X Test", "RHRB", "IVR", "Input Ports", "Start Counter", "Stop Counter"
-};
-
-static const char *const duart68681_reg_write_names[0x10] =
-{
- "MRA", "CSRA", "CRA", "THRA", "ACR", "IMR", "CRUR", "CTLR", "MRB", "CSRB", "CRB", "THRB", "IVR", "OPCR", "Set OP Bits", "Reset OP Bits"
-};
-
-static const int baud_rate_ACR_0[] = { 50, 110, 134, 200, 300, 600, 1200, 1050, 2400, 4800, 7200, 9600, 38400, 0, 0, 0 };
-static const int baud_rate_ACR_1[] = { 75, 110, 134, 150, 300, 600, 1200, 2000, 2400, 4800, 1800, 9600, 19200, 0, 0, 0 };
-
-#define INT_INPUT_PORT_CHANGE 0x80
-#define INT_DELTA_BREAK_B 0x40
-#define INT_RXRDY_FFULLB 0x20
-#define INT_TXRDYB 0x10
-#define INT_COUNTER_READY 0x08
-#define INT_DELTA_BREAK_A 0x04
-#define INT_RXRDY_FFULLA 0x02
-#define INT_TXRDYA 0x01
-
-#define STATUS_RECEIVED_BREAK 0x80
-#define STATUS_FRAMING_ERROR 0x40
-#define STATUS_PARITY_ERROR 0x20
-#define STATUS_OVERRUN_ERROR 0x10
-#define STATUS_TRANSMITTER_EMPTY 0x08
-#define STATUS_TRANSMITTER_READY 0x04
-#define STATUS_FIFO_FULL 0x02
-#define STATUS_RECEIVER_READY 0x01
-
-#define MODE_RX_INT_SELECT_BIT 0x40
-
-#define CHANA_TAG "cha"
-#define CHANB_TAG "chb"
-
-// device type definition
-const device_type MC68681 = &device_creator<mc68681_device>;
-const device_type MC68681_CHANNEL = &device_creator<mc68681_channel>;
-
-MACHINE_CONFIG_FRAGMENT( duart68681 )
- MCFG_DEVICE_ADD(CHANA_TAG, MC68681_CHANNEL, 0)
- MCFG_DEVICE_ADD(CHANB_TAG, MC68681_CHANNEL, 0)
-MACHINE_CONFIG_END
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-mc68681_device::mc68681_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MC68681, "MC68681 DUART", tag, owner, clock, "mc68681", __FILE__),
- m_chanA(*this, CHANA_TAG),
- m_chanB(*this, CHANB_TAG),
- write_irq(*this),
- write_a_tx(*this),
- write_b_tx(*this),
- read_inport(*this),
- write_outport(*this),
- ip3clk(0),
- ip4clk(0),
- ip5clk(0),
- ip6clk(0),
- ACR(0),
- m_read_vector(false),
- IP_last_state(0)
-{
-}
-
-//-------------------------------------------------
-// static_set_clocks - configuration helper to set
-// the external clocks
-//-------------------------------------------------
-
-void mc68681_device::static_set_clocks(device_t &device, int clk3, int clk4, int clk5, int clk6)
-{
- mc68681_device &duart = downcast<mc68681_device &>(device);
- duart.ip3clk = clk3;
- duart.ip4clk = clk4;
- duart.ip5clk = clk5;
- duart.ip6clk = clk6;
-}
-
-/*-------------------------------------------------
- device start callback
--------------------------------------------------*/
-
-void mc68681_device::device_start()
-{
- write_irq.resolve_safe();
- write_a_tx.resolve_safe();
- write_b_tx.resolve_safe();
- read_inport.resolve();
- write_outport.resolve_safe();
-
- duart_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc68681_device::duart_timer_callback),this), NULL);
-
- save_item(NAME(ACR));
- save_item(NAME(IMR));
- save_item(NAME(ISR));
- save_item(NAME(IVR));
- save_item(NAME(OPCR));
- save_item(NAME(CTR));
- save_item(NAME(IP_last_state));
- save_item(NAME(half_period));
-}
-
-/*-------------------------------------------------
- device reset callback
--------------------------------------------------*/
-
-void mc68681_device::device_reset()
-{
- ACR = 0; /* Interrupt Vector Register */
- IVR = 0x0f; /* Interrupt Vector Register */
- IMR = 0; /* Interrupt Mask Register */
- ISR = 0; /* Interrupt Status Register */
- OPCR = 0; /* Output Port Conf. Register */
- OPR = 0; /* Output Port Register */
- CTR.d = 0; /* Counter/Timer Preset Value */
- m_read_vector = false;
- // "reset clears internal registers (SRA, SRB, IMR, ISR, OPR, OPCR) puts OP0-7 in the high state, stops the counter/timer, and puts channels a/b in the inactive state"
- IPCR = 0;
-
- write_outport(OPR ^ 0xff);
-}
-
-machine_config_constructor mc68681_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( duart68681 );
-}
-
-void mc68681_device::update_interrupts()
-{
- /* update SR state and update interrupt ISR state for the following bits:
- SRn: bits 7-4: handled elsewhere.
- SRn: bit 3 (TxEMTn) (we can assume since we're not actually emulating the delay/timing of sending bits, that as long as TxRDYn is set, TxEMTn is also set since the transmit byte has 'already happened', therefore TxEMTn is always 1 assuming tx is enabled on channel n and the MSR2n mode is 0 or 2; in mode 1 it is explicitly zeroed, and mode 3 is undefined)
- SRn: bit 2 (TxRDYn) (we COULD assume since we're not emulating delay and timing output, that as long as tx is enabled on channel n, TxRDY is 1 for channel n and the MSR2n mode is 0 or 2; in mode 1 it is explicitly zeroed, and mode 3 is undefined; however, tx_ready is already nicely handled for us elsewhere, so we can use that instead for now, though we may need to retool that code as well)
- SRn: bit 1 (FFULLn) (this bit we actually emulate; if the receive fifo for channel n is full, this bit is 1, otherwise it is 0. the receive fifo should be three words long.)
- SRn: bit 0 (RxRDYn) (this bit we also emulate; the bit is always asserted if the receive fifo is not empty)
- ISR: bit 7: Input Port change; this should be handled elsewhere, on the input port handler
- ISR: bit 6: Delta Break B; this should be handled elsewhere, on the data receive handler
- ISR: bit 5: RxRDYB/FFULLB: this is handled here; depending on whether MSR1B bit 6 is 0 or 1, this bit holds the state of SRB bit 0 or bit 1 respectively
- ISR: bit 4: TxRDYB: this is handled here; it mirrors SRB bit 2
- ISR: bit 3: Counter ready; this should be handled by the timer generator
- ISR: bit 2: Delta Break A; this should be handled elsewhere, on the data receive handler
- ISR: bit 1: RxRDYA/FFULLA: this is handled here; depending on whether MSR1A bit 6 is 0 or 1, this bit holds the state of SRA bit 0 or bit 1 respectively
- ISR: bit 0: TxRDYA: this is handled here; it mirrors SRA bit 2
- */
- if ( (ISR & IMR) != 0 )
- {
- LOG(( "68681: Interrupt line active (IMR & ISR = %02X)\n", (ISR & IMR) ));
- write_irq(ASSERT_LINE);
- }
- else
- {
- LOG(( "68681: Interrupt line not active (IMR & ISR = %02X)\n", ISR & IMR));
- write_irq(CLEAR_LINE);
- m_read_vector = false; // clear IACK too
- }
-}
-
-double mc68681_device::duart68681_get_ct_rate()
-{
- double rate = 0.0f;
-
- if (ACR & 0x40)
- {
- // Timer mode
- switch ((ACR >> 4) & 3)
- {
- case 0: // IP2
- case 1: // IP2 / 16
- //logerror( "68681 (%s): Unhandled timer/counter mode %d\n", duart68681->tag(), (duart68681->ACR >> 4) & 3);
- rate = clock();
- break;
- case 2: // X1/CLK
- rate = clock();
- break;
- case 3: // X1/CLK / 16
- rate = clock() / 16;
- break;
- }
- }
- else
- {
- // Counter mode
- switch ((ACR >> 4) & 3)
- {
- case 0: // IP2
- case 1: // TxCA
- case 2: // TxCB
- //logerror( "68681 (%s): Unhandled timer/counter mode %d\n", device->tag(), (duart68681->ACR >> 4) & 3);
- rate = clock();
- break;
- case 3: // X1/CLK / 16
- rate = clock() / 16;
- break;
- }
- }
-
- return rate;
-}
-
-UINT16 mc68681_device::duart68681_get_ct_count()
-{
- double clock = duart68681_get_ct_rate();
- return (duart_timer->remaining() * clock).as_double();
-}
-
-void mc68681_device::duart68681_start_ct(int count)
-{
- double clock = duart68681_get_ct_rate();
- duart_timer->adjust(attotime::from_hz(clock) * count, 0);
-}
-
-TIMER_CALLBACK_MEMBER( mc68681_device::duart_timer_callback )
-{
- if (ACR & 0x40)
- {
- // Timer mode
- half_period ^= 1;
-
- // timer output to bit 3?
- if ((OPCR & 0xc) == 0x4)
- {
- OPR ^= 0x8;
- write_outport(OPR ^ 0xff);
- }
-
- // timer driving any serial channels?
- if (BIT(ACR, 7) == 1)
- {
- UINT8 csr = m_chanA->get_chan_CSR();
-
- if ((csr & 0xf0) == 0xd0) // tx is timer driven
- {
- m_chanA->tx_clock_w(half_period);
- }
- if ((csr & 0x0f) == 0x0d) // rx is timer driven
- {
- m_chanA->rx_clock_w(half_period);
- }
-
- csr = m_chanB->get_chan_CSR();
- if ((csr & 0xf0) == 0xd0) // tx is timer driven
- {
- m_chanB->tx_clock_w(half_period);
- }
- if ((csr & 0x0f) == 0x0d) // rx is timer driven
- {
- m_chanB->rx_clock_w(half_period);
- }
- }
-
- if (!half_period)
- {
- ISR |= INT_COUNTER_READY;
- update_interrupts();
- }
-
- int count = MAX(CTR.w.l, 1);
- duart68681_start_ct(count);
- }
- else
- {
- // Counter mode
- ISR |= INT_COUNTER_READY;
- update_interrupts();
- duart68681_start_ct(0xffff);
- }
-
-}
-
-READ8_MEMBER( mc68681_device::read )
-{
- UINT8 r = 0xff;
-
- offset &= 0xf;
-
- LOG(( "Reading 68681 (%s) reg %x (%s) ", tag(), offset, duart68681_reg_read_names[offset] ));
-
- switch (offset)
- {
- case 0x00: /* MR1A/MR2A */
- case 0x01: /* SRA */
- case 0x03: /* Rx Holding Register A */
- r = m_chanA->read_chan_reg(offset & 3);
- break;
-
- case 0x04: /* IPCR */
- {
- r = IPCR;
-
- // reading this clears all the input change bits
- IPCR &= 0x0f;
- ISR &= ~INT_INPUT_PORT_CHANGE;
- update_interrupts();
- }
- break;
-
- case 0x05: /* ISR */
- r = ISR;
- break;
-
- case 0x06: /* CUR */
- r = duart68681_get_ct_count() >> 8;
- break;
-
- case 0x07: /* CLR */
- r = duart68681_get_ct_count() & 0xff;
- break;
-
- case 0x08: /* MR1B/MR2B */
- case 0x09: /* SRB */
- case 0x0b: /* RHRB */
- r = m_chanB->read_chan_reg(offset & 3);
- break;
-
- case 0x0a: /* 1X/16X Test */
- r = 0x61; // the old 68681 returned this and it makes Apollo happy
- break;
-
- case 0x0d: /* IP */
- if (!read_inport.isnull())
- {
- r = read_inport(); // TODO: go away
- }
- else
- {
- r = IP_last_state;
- }
-
- r |= 0x80; // bit 7 is always set
-
- // bit 6 is /IACK (note the active-low)
- if (m_read_vector)
- {
- r &= ~0x40;
- }
- else
- {
- r |= 0x40;
- }
- break;
-
- case 0x0e: /* Start counter command */
- {
- if (ACR & 0x40)
- {
- // Reset the timer
- half_period = 0;
- }
-
- int count = MAX(CTR.w.l, 1);
- duart68681_start_ct(count);
- break;
- }
-
- case 0x0f: /* Stop counter command */
- ISR &= ~INT_COUNTER_READY;
-
- // Stop the counter only
- if (!(ACR & 0x40))
- duart_timer->adjust(attotime::never);
-
- update_interrupts();
- break;
-
- default:
- LOG(( "Reading unhandled 68681 reg %x\n", offset ));
- break;
- }
- LOG(("returned %02x\n", r));
-
- return r;
-}
-
-WRITE8_MEMBER( mc68681_device::write )
-{
- offset &= 0x0f;
- LOG(( "Writing 68681 (%s) reg %x (%s) with %04x\n", tag(), offset, duart68681_reg_write_names[offset], data ));
- switch(offset)
- {
- case 0x00: /* MRA */
- case 0x01: /* CSRA */
- case 0x02: /* CRA */
- case 0x03: /* THRA */
- m_chanA->write_chan_reg(offset&3, data);
- break;
-
- case 0x04: /* ACR */
- {
- UINT8 old_acr = ACR;
- ACR = data;
-
- // bits 6-4: Counter/Timer Mode And Clock Source Select
- // bits 3-0: IP3-0 Change-Of-State Interrupt Enable
- if ((old_acr ^ data) & 0x40)
- {
- if (data & 0x40)
- {
- // Entering timer mode
- UINT16 count = MAX(CTR.w.l, 1);
- half_period = 0;
-
- duart68681_start_ct(count);
- }
- else
- {
- // Leaving timer mode (TODO: is this correct?)
- duart_timer->adjust(attotime::never);
- }
- }
-
- // check for pending input port delta interrupts
- if ((((IPCR>>4) & data) & 0x0f) != 0)
- {
- ISR |= INT_INPUT_PORT_CHANGE;
- }
-
- m_chanA->ACR_updated();
- m_chanB->ACR_updated();
- m_chanA->update_interrupts();
- m_chanB->update_interrupts();
- update_interrupts();
- break;
- }
- case 0x05: /* IMR */
- IMR = data;
- update_interrupts();
- break;
-
- case 0x06: /* CTUR */
- CTR.b.h = data;
- break;
-
- case 0x07: /* CTLR */
- CTR.b.l = data;
- break;
-
- case 0x08: /* MRB */
- case 0x09: /* CSRB */
- case 0x0a: /* CRB */
- case 0x0b: /* THRB */
- m_chanB->write_chan_reg(offset&3, data);
- break;
-
- case 0x0c: /* IVR */
- IVR = data;
- break;
-
- case 0x0d: /* OPCR */
- if ((data != 0x00) && ((data & 0xc) != 0x4))
- logerror( "68681 (%s): Unhandled OPCR value: %02x\n", tag(), data);
- OPCR = data;
- break;
-
- case 0x0e: /* Set Output Port Bits */
- OPR |= data;
- write_outport(OPR ^ 0xff);
- break;
-
- case 0x0f: /* Reset Output Port Bits */
- OPR &= ~data;
- write_outport(OPR ^ 0xff);
- break;
- }
-}
-
-WRITE_LINE_MEMBER( mc68681_device::ip0_w )
-{
- UINT8 newIP = (IP_last_state & ~0x01) | ((state == ASSERT_LINE) ? 1 : 0);
-
- if (newIP != IP_last_state)
- {
- IPCR &= ~0x0f;
- IPCR |= (newIP & 0x0f);
- IPCR |= 0x10;
-
- if (ACR & 1)
- {
- ISR |= INT_INPUT_PORT_CHANGE;
- update_interrupts();
- }
- }
-
- IP_last_state = newIP;
-}
-
-WRITE_LINE_MEMBER( mc68681_device::ip1_w )
-{
- UINT8 newIP = (IP_last_state & ~0x02) | ((state == ASSERT_LINE) ? 2 : 0);
-
- if (newIP != IP_last_state)
- {
- IPCR &= ~0x0f;
- IPCR |= (newIP & 0x0f);
- IPCR |= 0x20;
-
- if (ACR & 2)
- {
- ISR |= INT_INPUT_PORT_CHANGE;
- update_interrupts();
- }
- }
-
- IP_last_state = newIP;
-}
-
-WRITE_LINE_MEMBER( mc68681_device::ip2_w )
-{
- UINT8 newIP = (IP_last_state & ~0x04) | ((state == ASSERT_LINE) ? 4 : 0);
-
- if (newIP != IP_last_state)
- {
- IPCR &= ~0x0f;
- IPCR |= (newIP & 0x0f);
- IPCR |= 0x40;
-
- if (ACR & 4)
- {
- ISR |= INT_INPUT_PORT_CHANGE;
- update_interrupts();
- }
- }
-
- IP_last_state = newIP;
-}
-
-WRITE_LINE_MEMBER( mc68681_device::ip3_w )
-{
- UINT8 newIP = (IP_last_state & ~0x08) | ((state == ASSERT_LINE) ? 8 : 0);
-
- if (newIP != IP_last_state)
- {
- IPCR &= ~0x0f;
- IPCR |= (newIP & 0x0f);
- IPCR |= 0x80;
-
- if (ACR & 8)
- {
- ISR |= INT_INPUT_PORT_CHANGE;
- update_interrupts();
- }
- }
-
- IP_last_state = newIP;
-}
-
-WRITE_LINE_MEMBER( mc68681_device::ip4_w )
-{
- UINT8 newIP = (IP_last_state & ~0x10) | ((state == ASSERT_LINE) ? 0x10 : 0);
-// TODO: special mode for ip4 (Ch. A Rx clock)
- IP_last_state = newIP;
-}
-
-WRITE_LINE_MEMBER( mc68681_device::ip5_w )
-{
- UINT8 newIP = (IP_last_state & ~0x20) | ((state == ASSERT_LINE) ? 0x20 : 0);
-// TODO: special mode for ip5 (Ch. B Tx clock)
- IP_last_state = newIP;
-}
-
-mc68681_channel *mc68681_device::get_channel(int chan)
-{
- if (chan == 0)
- {
- return m_chanA;
- }
-
- return m_chanB;
-}
-
-int mc68681_device::calc_baud(int ch, UINT8 data)
-{
- int baud_rate = 0;
-
- if ( BIT(ACR, 7) == 0 )
- {
- baud_rate = baud_rate_ACR_0[data & 0x0f];
-
- if (ch == 0)
- {
- if ((data & 0xf) == 0xe)
- {
- baud_rate = ip3clk/16;
- }
- else if ((data & 0xf) == 0xf)
- {
- baud_rate = ip3clk;
- }
- }
- else if (ch == 1)
- {
- if ((data & 0xf) == 0xe)
- {
- baud_rate = ip5clk/16;
- }
- else if ((data & 0xf) == 0xf)
- {
- baud_rate = ip5clk;
- }
- }
- }
- else
- {
- baud_rate = baud_rate_ACR_1[data & 0x0f];
- }
-
- if ((baud_rate == 0) && ((data & 0xf) != 0xd))
- {
- LOG(( "Unsupported transmitter clock: channel %d, clock select = %02x\n", ch, data ));
- }
-
- return baud_rate;
-}
-
-void mc68681_device::clear_ISR_bits(int mask)
-{
- ISR &= ~mask;
-}
-
-void mc68681_device::set_ISR_bits(int mask)
-{
- ISR |= mask;
-}
-
-// DUART channel class stuff
-
-mc68681_channel::mc68681_channel(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MC68681_CHANNEL, "MC68681 DUART CHANNEL", tag, owner, clock, "mc68681_channel", __FILE__),
- device_serial_interface(mconfig, *this),
- MR1(0),
- MR2(0),
- SR(0),
- rx_enabled(0),
- rx_fifo_num(0),
- tx_enabled(0)
-{
-}
-
-void mc68681_channel::device_start()
-{
- m_uart = downcast<mc68681_device *>(owner());
- m_ch = m_uart->get_ch(this); // get our channel number
-
- save_item(NAME(CR));
- save_item(NAME(CSR));
- save_item(NAME(MR1));
- save_item(NAME(MR2));
- save_item(NAME(MR_ptr));
- save_item(NAME(SR));
- save_item(NAME(rx_baud_rate));
- save_item(NAME(tx_baud_rate));
- save_item(NAME(rx_enabled));
- save_item(NAME(rx_fifo));
- save_item(NAME(rx_fifo_read_ptr));
- save_item(NAME(rx_fifo_write_ptr));
- save_item(NAME(rx_fifo_num));
- save_item(NAME(tx_enabled));
- save_item(NAME(tx_data));
- save_item(NAME(tx_ready));
-}
-
-void mc68681_channel::device_reset()
-{
- write_CR(0x10); // reset MR
- write_CR(0x20); // reset Rx
- write_CR(0x30); // reset Tx
- write_CR(0x40); // reset errors
-
- set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1);
-
- tx_baud_rate = rx_baud_rate = 0;
- CSR = 0;
-}
-
-void mc68681_channel::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- device_serial_interface::device_timer(timer, id, param, ptr);
-}
-
-// serial device virtual overrides
-void mc68681_channel::rcv_complete()
-{
- receive_register_extract();
-
-// printf("%s ch %d rcv complete\n", tag(), m_ch);
-
- if ( rx_enabled )
- {
- if ( rx_fifo_num >= MC68681_RX_FIFO_SIZE )
- {
- logerror("68681: FIFO overflow\n");
- SR |= STATUS_OVERRUN_ERROR;
- return;
- }
- rx_fifo[rx_fifo_write_ptr++] = get_received_char();
- if ( rx_fifo_write_ptr == MC68681_RX_FIFO_SIZE )
- {
- rx_fifo_write_ptr = 0;
- }
- rx_fifo_num++;
- update_interrupts();
- }
-}
-
-void mc68681_channel::tra_complete()
-{
-// printf("%s ch %d Tx complete\n", tag(), m_ch);
- tx_ready = 1;
- SR |= STATUS_TRANSMITTER_READY;
-
- if (m_ch == 0)
- m_uart->clear_ISR_bits(INT_TXRDYA);
- else
- m_uart->clear_ISR_bits(INT_TXRDYB);
-
- // if local loopback is on, write the transmitted data as if a byte had been received
- if ((MR2 & 0xC0) == 0x80)
- {
- if (rx_fifo_num >= MC68681_RX_FIFO_SIZE)
- {
- LOG(( "68681: FIFO overflow\n" ));
- SR |= STATUS_OVERRUN_ERROR;
- }
- else
- {
- rx_fifo[rx_fifo_write_ptr++]= tx_data;
- if (rx_fifo_write_ptr == MC68681_RX_FIFO_SIZE)
- {
- rx_fifo_write_ptr = 0;
- }
- rx_fifo_num++;
- }
- }
-
- update_interrupts();
-}
-
-void mc68681_channel::tra_callback()
-{
- // don't actually send in loopback mode
- if ((MR2&0xC0) != 0x80)
- {
- int bit = transmit_register_get_data_bit();
-// printf("%s ch %d transmit %d\n", tag(), m_ch, bit);
- if (m_ch == 0)
- {
- m_uart->write_a_tx(bit);
- }
- else
- {
- m_uart->write_b_tx(bit);
- }
- }
- else // must call this to advance the transmitter
- {
- transmit_register_get_data_bit();
- }
-}
-
-void mc68681_channel::update_interrupts()
-{
- if (rx_enabled)
- {
- if (rx_fifo_num > 0)
- {
- SR |= STATUS_RECEIVER_READY;
- }
- else
- {
- SR &= ~STATUS_RECEIVER_READY;
- }
- if ( rx_fifo_num == MC68681_RX_FIFO_SIZE )
- {
- SR |= STATUS_FIFO_FULL;
- }
- else
- {
- SR &= ~STATUS_FIFO_FULL;
- }
- }
-
- // Handle the TxEMT and TxRDY bits based on mode
- switch(MR2&0xC0) // what mode are we in?
- {
- case 0x00: // normal mode
- if ( tx_enabled )
- {
- SR |= STATUS_TRANSMITTER_EMPTY;
- }
- else
- {
- SR &= ~STATUS_TRANSMITTER_EMPTY;
- }
- break;
- case 0x40: // automatic echo mode
- SR &= ~STATUS_TRANSMITTER_EMPTY;
- SR &= ~STATUS_TRANSMITTER_READY;
- break;
- case 0x80: // local loopback mode
- if ( tx_enabled )
- {
- SR |= STATUS_TRANSMITTER_EMPTY;
- }
- else
- {
- SR &= ~STATUS_TRANSMITTER_EMPTY;
- }
- break;
- case 0xC0: // remote loopback mode
- // write me, what the txrdy/txemt regs do for remote loopback mode is undocumented afaik, for now just clear both
- SR &= ~STATUS_TRANSMITTER_EMPTY;
- SR &= ~STATUS_TRANSMITTER_READY;
- break;
- }
- // now handle the ISR bits
- if ( SR & STATUS_TRANSMITTER_READY )
- {
- if (m_ch == 0)
- m_uart->set_ISR_bits(INT_TXRDYA);
- else
- m_uart->set_ISR_bits(INT_TXRDYB);
- }
- else
- {
- if (m_ch == 0)
- m_uart->clear_ISR_bits(INT_TXRDYA);
- else
- m_uart->clear_ISR_bits(INT_TXRDYB);
- }
- //logerror("DEBUG: 68681 int check: before receiver test, SR%c is %02X, ISR is %02X\n", (ch+0x41), duart68681->channel[ch].SR, duart68681->ISR);
- if ( MR1 & MODE_RX_INT_SELECT_BIT )
- {
- if ( SR & STATUS_FIFO_FULL )
- {
- m_uart->set_ISR_bits((m_ch == 0) ? INT_RXRDY_FFULLA : INT_RXRDY_FFULLB);
- }
- else
- {
- m_uart->clear_ISR_bits((m_ch == 0) ? INT_RXRDY_FFULLA : INT_RXRDY_FFULLB);
- }
- }
- else
- {
- if ( SR & STATUS_RECEIVER_READY )
- {
- m_uart->set_ISR_bits((m_ch == 0) ? INT_RXRDY_FFULLA : INT_RXRDY_FFULLB);
- }
- else
- {
- m_uart->clear_ISR_bits((m_ch == 0) ? INT_RXRDY_FFULLA : INT_RXRDY_FFULLB);
- }
- }
-
- m_uart->update_interrupts();
-
- //logerror("DEBUG: 68681 int check: after receiver test, SR%c is %02X, ISR is %02X\n", (ch+0x41), duart68681->channel[ch].SR, duart68681->ISR);
-}
-
-UINT8 mc68681_channel::read_rx_fifo()
-{
- UINT8 rv = 0;
-
-// printf("read_rx_fifo: rx_fifo_num %d\n", rx_fifo_num);
-
- if ( rx_fifo_num == 0 )
- {
- LOG(( "68681 channel: rx fifo underflow\n" ));
- update_interrupts();
- return 0;
- }
-
- rv = rx_fifo[rx_fifo_read_ptr++];
- if ( rx_fifo_read_ptr == MC68681_RX_FIFO_SIZE )
- {
- rx_fifo_read_ptr = 0;
- }
-
- rx_fifo_num--;
- update_interrupts();
-
-// printf("Rx read %02x\n", rv);
-
- return rv;
-}
-
-UINT8 mc68681_channel::read_chan_reg(int reg)
-{
- UINT8 rv = 0xff;
-
- switch (reg)
- {
- case 0: // MR1/MR2
- if ( MR_ptr == 0 )
- {
- rv = MR1;
- MR_ptr = 1;
- }
- else
- {
- rv = MR2;
- }
- break;
-
- case 1: // SRA
- rv = SR;
- break;
-
- case 2: // CSRA: reading this is prohibited
- break;
-
- case 3: // Rx holding register A
- rv = read_rx_fifo();
- break;
- }
-
- return rv;
-}
-
-void mc68681_channel::write_chan_reg(int reg, UINT8 data)
-{
- switch (reg)
- {
- case 0x00: /* MRA */
- write_MR(data);
- break;
-
- case 0x01: /* CSR */
- CSR = data;
- tx_baud_rate = m_uart->calc_baud(m_ch, data & 0xf);
- rx_baud_rate = m_uart->calc_baud(m_ch, (data>>4) & 0xf);
-// printf("%s ch %d CSR %02x Tx baud %d Rx baud %d\n", tag(), m_ch, data, tx_baud_rate, rx_baud_rate);
- set_rcv_rate(rx_baud_rate);
- set_tra_rate(tx_baud_rate);
- break;
-
- case 0x02: /* CR */
- write_CR(data);
- break;
-
- case 0x03: /* THR */
- write_TX(data);
- break;
- }
-}
-
-void mc68681_channel::write_MR(UINT8 data)
-{
- if ( MR_ptr == 0 )
- {
- MR1 = data;
- MR_ptr = 1;
- }
- else
- {
- MR2 = data;
- }
- recalc_framing();
- update_interrupts();
-}
-
-void mc68681_channel::recalc_framing()
-{
- parity_t parity = PARITY_NONE;
- switch ((MR1>>3) & 3)
- {
- case 0: // with parity
- if (MR1 & 4)
- {
- parity = PARITY_ODD;
- }
- else
- {
- parity = PARITY_EVEN;
- }
- break;
-
- case 1: // force parity
- if (MR1 & 4)
- {
- parity = PARITY_MARK;
- }
- else
- {
- parity = PARITY_SPACE;
- }
- break;
-
- case 2: // no parity
- parity = PARITY_NONE;
- break;
-
- case 3: // multidrop mode
- // fatalerror("68681: multidrop parity not supported\n");
- // Apollo DEX CPU will test this; omit to abort the emulation
- logerror("68681: multidrop parity not supported\n");
- break;
- }
-
- stop_bits_t stopbits = STOP_BITS_0;
- switch ((MR2 >> 2) & 3)
- {
- case 0:
- case 1:
- stopbits = STOP_BITS_1;
- break;
-
- case 2: // "1.5 async, 2 sync"
- stopbits = STOP_BITS_1_5;
- break;
-
- case 3:
- stopbits = STOP_BITS_2;
- break;
- }
-
-// printf("%s ch %d MR1 %02x MR2 %02x => %d bits / char, %d stop bits, parity %d\n", tag(), m_ch, MR1, MR2, (MR1 & 3)+5, stopbits, parity);
-
- set_data_frame(1, (MR1 & 3)+5, parity, stopbits);
-}
-
-void mc68681_channel::write_CR(UINT8 data)
-{
- CR = data;
-
- switch( (data >> 4) & 0x07 )
- {
- case 0: /* No command */
- break;
- case 1: /* Reset MR pointer. Causes the channel MR pointer to point to MR1 */
- MR_ptr = 0;
- break;
- case 2: /* Reset channel receiver (disable receiver and flush fifo) */
- rx_enabled = 0;
- SR &= ~STATUS_RECEIVER_READY;
- SR &= ~STATUS_OVERRUN_ERROR; // is this correct?
- rx_fifo_read_ptr = 0;
- rx_fifo_write_ptr = 0;
- rx_fifo_num = 0;
- receive_register_reset();
- break;
- case 3: /* Reset channel transmitter */
- tx_enabled = 0;
- SR &= ~STATUS_TRANSMITTER_READY;
- if (m_ch == 0)
- m_uart->clear_ISR_bits(INT_TXRDYA);
- else
- m_uart->clear_ISR_bits(INT_TXRDYB);
- transmit_register_reset();
- break;
- case 4: /* Reset Error Status */
- SR &= ~(STATUS_RECEIVED_BREAK | STATUS_FRAMING_ERROR | STATUS_PARITY_ERROR | STATUS_OVERRUN_ERROR);
- break;
- case 5: /* Reset Channel break change interrupt */
- if ( m_ch == 0 )
- {
- m_uart->clear_ISR_bits(INT_DELTA_BREAK_A);
- }
- else
- {
- m_uart->clear_ISR_bits(INT_DELTA_BREAK_B);
- }
- break;
- /* TODO: case 6 and case 7 are start break and stop break respectively, which start or stop holding the TxDA or TxDB line low (space) after whatever data is in the buffer finishes transmitting (following the stop bit?), or after two bit-times if no data is being transmitted */
- default:
- LOG(( "68681: Unhandled command (%x) in CR%d\n", (data >> 4) & 0x07, m_ch ));
- break;
- }
-
- if (BIT(data, 0)) {
- rx_enabled = 1;
- }
- if (BIT(data, 1)) {
- rx_enabled = 0;
- SR &= ~STATUS_RECEIVER_READY;
- }
-
- if (BIT(data, 2)) {
- tx_enabled = 1;
- tx_ready = 1;
- SR |= STATUS_TRANSMITTER_READY;
- if (m_ch == 0)
- m_uart->set_ISR_bits(INT_TXRDYA);
- else
- m_uart->set_ISR_bits(INT_TXRDYB);
- }
- if (BIT(data, 3)) {
- tx_enabled = 0;
- tx_ready = 0;
- SR &= ~STATUS_TRANSMITTER_READY;
- if (m_ch == 0)
- m_uart->clear_ISR_bits(INT_TXRDYA);
- else
- m_uart->clear_ISR_bits(INT_TXRDYB);
- }
-
- update_interrupts();
-}
-
-void mc68681_channel::write_TX(UINT8 data)
-{
- tx_data = data;
-
-/* if (!tx_ready)
- {
- printf("Write %02x to TX when TX not ready!\n", data);
- }*/
-
-// printf("%s ch %d Tx %02x\n", tag(), m_ch, data);
-
- tx_ready = 0;
- SR &= ~STATUS_TRANSMITTER_READY;
-
- if (m_ch == 0)
- m_uart->clear_ISR_bits(INT_TXRDYA);
- else
- m_uart->clear_ISR_bits(INT_TXRDYB);
-
- // send tx_data
- transmit_register_setup(tx_data);
-
- update_interrupts();
-}
-
-void mc68681_channel::ACR_updated()
-{
- write_chan_reg(1, CSR);
-}
-
-UINT8 mc68681_channel::get_chan_CSR()
-{
- return CSR;
-}
diff --git a/src/emu/machine/mc68681.h b/src/emu/machine/mc68681.h
deleted file mode 100644
index 3e4d0b9f256..00000000000
--- a/src/emu/machine/mc68681.h
+++ /dev/null
@@ -1,180 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Mariusz Wojcieszek, R. Belmont
-#ifndef _MC68681_H
-#define _MC68681_H
-
-
-#define MCFG_MC68681_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, MC68681, _clock)
-
-#define MCFG_MC68681_REPLACE(_tag, _clock) \
- MCFG_DEVICE_REPLACE(_tag, MC68681, _clock)
-
-#define MCFG_MC68681_IRQ_CALLBACK(_cb) \
- devcb = &mc68681_device::set_irq_cb(*device, DEVCB_##_cb);
-
-#define MCFG_MC68681_A_TX_CALLBACK(_cb) \
- devcb = &mc68681_device::set_a_tx_cb(*device, DEVCB_##_cb);
-
-#define MCFG_MC68681_B_TX_CALLBACK(_cb) \
- devcb = &mc68681_device::set_b_tx_cb(*device, DEVCB_##_cb);
-
-// deprecated: use ipX_w() instead
-#define MCFG_MC68681_INPORT_CALLBACK(_cb) \
- devcb = &mc68681_device::set_inport_cb(*device, DEVCB_##_cb);
-
-#define MCFG_MC68681_OUTPORT_CALLBACK(_cb) \
- devcb = &mc68681_device::set_outport_cb(*device, DEVCB_##_cb);
-
-#define MCFG_MC68681_SET_EXTERNAL_CLOCKS(_a, _b, _c, _d) \
- mc68681_device::static_set_clocks(*device, _a, _b, _c, _d);
-
-#define MC68681_RX_FIFO_SIZE 3
-
-// forward declaration
-class mc68681_device;
-
-// mc68681_channel class
-class mc68681_channel : public device_t, public device_serial_interface
-{
-public:
- mc68681_channel(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_serial overrides
- virtual void rcv_complete(); // Rx completed receiving byte
- virtual void tra_complete(); // Tx completed sending byte
- virtual void tra_callback(); // Tx send bit
-
- UINT8 read_chan_reg(int reg);
- void write_chan_reg(int reg, UINT8 data);
- void update_interrupts();
-
- UINT8 read_rx_fifo();
-
- void ACR_updated();
-
- UINT8 get_chan_CSR();
-
-private:
- /* Registers */
- UINT8 CR; /* Command register */
- UINT8 CSR; /* Clock select register */
- UINT8 MR1; /* Mode register 1 */
- UINT8 MR2; /* Mode register 2 */
- UINT8 MR_ptr; /* Mode register pointer */
- UINT8 SR; /* Status register */
-
- /* State */
- int tx_baud_rate, rx_baud_rate;
-
- /* Receiver */
- UINT8 rx_enabled;
- UINT8 rx_fifo[MC68681_RX_FIFO_SIZE];
- int rx_fifo_read_ptr;
- int rx_fifo_write_ptr;
- int rx_fifo_num;
-
- int m_ch;
-
- /* Transmitter */
- UINT8 tx_enabled;
- UINT8 tx_data;
- UINT8 tx_ready;
-
- mc68681_device *m_uart;
-
- void write_MR(UINT8 data);
- void write_CR(UINT8 data);
- void write_TX(UINT8 data);
- void recalc_framing();
-};
-
-class mc68681_device : public device_t
-{
- friend class mc68681_channel;
-
-public:
- mc68681_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- required_device<mc68681_channel> m_chanA;
- required_device<mc68681_channel> m_chanB;
-
- // inline configuration helpers
- static void static_set_clocks(device_t &device, int clk3, int clk4, int clk5, int clk6);
-
- // API
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
- UINT8 get_irq_vector() { m_read_vector = true; return IVR; }
-
- DECLARE_WRITE_LINE_MEMBER( rx_a_w ) { m_chanA->device_serial_interface::rx_w((UINT8)state); }
- DECLARE_WRITE_LINE_MEMBER( rx_b_w ) { m_chanB->device_serial_interface::rx_w((UINT8)state); }
-
- template<class _Object> static devcb_base &set_irq_cb(device_t &device, _Object object) { return downcast<mc68681_device &>(device).write_irq.set_callback(object); }
- template<class _Object> static devcb_base &set_a_tx_cb(device_t &device, _Object object) { return downcast<mc68681_device &>(device).write_a_tx.set_callback(object); }
- template<class _Object> static devcb_base &set_b_tx_cb(device_t &device, _Object object) { return downcast<mc68681_device &>(device).write_b_tx.set_callback(object); }
- template<class _Object> static devcb_base &set_inport_cb(device_t &device, _Object object) { return downcast<mc68681_device &>(device).read_inport.set_callback(object); }
- template<class _Object> static devcb_base &set_outport_cb(device_t &device, _Object object) { return downcast<mc68681_device &>(device).write_outport.set_callback(object); }
-
- devcb_write_line write_irq, write_a_tx, write_b_tx;
- devcb_read8 read_inport;
- devcb_write8 write_outport;
- INT32 ip3clk, ip4clk, ip5clk, ip6clk;
-
- // new-style push handlers for input port bits
- DECLARE_WRITE_LINE_MEMBER( ip0_w );
- DECLARE_WRITE_LINE_MEMBER( ip1_w );
- DECLARE_WRITE_LINE_MEMBER( ip2_w );
- DECLARE_WRITE_LINE_MEMBER( ip3_w );
- DECLARE_WRITE_LINE_MEMBER( ip4_w );
- DECLARE_WRITE_LINE_MEMBER( ip5_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual machine_config_constructor device_mconfig_additions() const;
-
-private:
- TIMER_CALLBACK_MEMBER( duart_timer_callback );
-
- /* registers */
- UINT8 ACR; /* Auxiliary Control Register */
- UINT8 IMR; /* Interrupt Mask Register */
- UINT8 ISR; /* Interrupt Status Register */
- UINT8 IVR; /* Interrupt Vector Register */
- UINT8 OPCR; /* Output Port Conf. Register */
- UINT8 OPR; /* Output Port Register */
- PAIR CTR; /* Counter/Timer Preset Value */
- UINT8 IPCR; /* Input Port Control Register */
-
- bool m_read_vector; // if this is read and IRQ is active, it counts as pulling IACK
-
- /* state */
- UINT8 IP_last_state; /* last state of IP bits */
-
- /* timer */
- UINT8 half_period;
- emu_timer *duart_timer;
-
- double duart68681_get_ct_rate();
- UINT16 duart68681_get_ct_count();
- void duart68681_start_ct(int count);
- int calc_baud(int ch, UINT8 data);
- int get_ch(mc68681_channel *ch) { return (ch == m_chanA) ? 0 : 1; }
- void clear_ISR_bits(int mask);
- void set_ISR_bits(int mask);
- void update_interrupts();
-
- mc68681_channel *get_channel(int chan);
-};
-
-extern const device_type MC68681;
-extern const device_type MC68681_CHANNEL;
-
-#endif //_N68681_H
diff --git a/src/emu/machine/mc68901.c b/src/emu/machine/mc68901.c
deleted file mode 100644
index 4d35d2a2c44..00000000000
--- a/src/emu/machine/mc68901.c
+++ /dev/null
@@ -1,1134 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Motorola MC68901 Multi Function Peripheral emulation
-
-**********************************************************************/
-
-/*
-
- TODO:
-
- - daisy chaining
- - disable GPIO3/4 interrupts when timer A/B in pulse mode
- - spurious interrupt
-
- If you look at the MFP datasheet it is obvious that it can generate the conditions for a spurious interrupt.
- However the fact that they indeed happen in the ST is quite interesting.
-
- The MFP will generate a spurious interrupt if interrupts are disabled (by changing the IERA/IERB registers)
- at the 'precise point'. The precise point would be after the system (but not necessarily the CPU, see below)
- triggered an MFP interrupt, and before the CPU drives the interrupt acknowledge cycle.
-
- If the MFP was connected directly to the CPU, spurious interrupts probably couldn't happen. However in the
- ST, GLUE seats in the middle and handles all the interrupt timing. It is possible that GLUE introduces a
- delay between detecting a change in the MFP interrupt request signal and actually propagating the change to
- the CPU IPL signals (it is even possible that GLUE make some kind of latching). This would create a window
- long enough for the 'precise point' described above.
-
- "yes, the spurious interrupt occurs when i mask a timer. i did not notice an occurance of the SPI when changing data and control registers.
- if i kill interrupts with the status reg before masking the timer interrupt, then the SPI occurs as soon as the status register is set to re-enable interrupts."
-
- Well, more experiments show that it's somewhat incorrect, and
- the GLUE is essentially invisible w.r.t IPL. The CPU and the
- MFP manage to add the delays all by themselves.
-
- - divide serial clock by 16
- - synchronous mode
- - 1.5/2 stop bits
- - interrupt on receiver break end
- - interrupt on character boundaries during break transmission
- - loopback mode
-
-*/
-
-#include "emu.h"
-#include "mc68901.h"
-#include "cpu/m68000/m68000.h"
-
-
-// device type definition
-const device_type MC68901 = &device_creator<mc68901_device>;
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-
-#define AER_GPIP_0 0x01
-#define AER_GPIP_1 0x02
-#define AER_GPIP_2 0x04
-#define AER_GPIP_3 0x08
-#define AER_GPIP_4 0x10
-#define AER_GPIP_5 0x20
-#define AER_GPIP_6 0x40
-#define AER_GPIP_7 0x80
-
-
-#define VR_S 0x08
-
-
-#define IR_GPIP_0 0x0001
-#define IR_GPIP_1 0x0002
-#define IR_GPIP_2 0x0004
-#define IR_GPIP_3 0x0008
-#define IR_TIMER_D 0x0010
-#define IR_TIMER_C 0x0020
-#define IR_GPIP_4 0x0040
-#define IR_GPIP_5 0x0080
-#define IR_TIMER_B 0x0100
-#define IR_XMIT_ERROR 0x0200
-#define IR_XMIT_BUFFER_EMPTY 0x0400
-#define IR_RCV_ERROR 0x0800
-#define IR_RCV_BUFFER_FULL 0x1000
-#define IR_TIMER_A 0x2000
-#define IR_GPIP_6 0x4000
-#define IR_GPIP_7 0x8000
-
-
-#define TCR_TIMER_STOPPED 0x00
-#define TCR_TIMER_DELAY_4 0x01
-#define TCR_TIMER_DELAY_10 0x02
-#define TCR_TIMER_DELAY_16 0x03
-#define TCR_TIMER_DELAY_50 0x04
-#define TCR_TIMER_DELAY_64 0x05
-#define TCR_TIMER_DELAY_100 0x06
-#define TCR_TIMER_DELAY_200 0x07
-#define TCR_TIMER_EVENT 0x08
-#define TCR_TIMER_PULSE_4 0x09
-#define TCR_TIMER_PULSE_10 0x0a
-#define TCR_TIMER_PULSE_16 0x0b
-#define TCR_TIMER_PULSE_50 0x0c
-#define TCR_TIMER_PULSE_64 0x0d
-#define TCR_TIMER_PULSE_100 0x0e
-#define TCR_TIMER_PULSE_200 0x0f
-#define TCR_TIMER_RESET 0x10
-
-
-#define UCR_PARITY_ENABLED 0x04
-#define UCR_PARITY_EVEN 0x02
-#define UCR_PARITY_ODD 0x00
-#define UCR_WORD_LENGTH_8 0x00
-#define UCR_WORD_LENGTH_7 0x20
-#define UCR_WORD_LENGTH_6 0x40
-#define UCR_WORD_LENGTH_5 0x60
-#define UCR_START_STOP_0_0 0x00
-#define UCR_START_STOP_1_1 0x08
-#define UCR_START_STOP_1_15 0x10
-#define UCR_START_STOP_1_2 0x18
-#define UCR_CLOCK_DIVIDE_16 0x80
-#define UCR_CLOCK_DIVIDE_1 0x00
-
-
-#define RSR_RCV_ENABLE 0x01
-#define RSR_SYNC_STRIP_ENABLE 0x02
-#define RSR_MATCH 0x04
-#define RSR_CHAR_IN_PROGRESS 0x04
-#define RSR_FOUND_SEARCH 0x08
-#define RSR_BREAK 0x08
-#define RSR_FRAME_ERROR 0x10
-#define RSR_PARITY_ERROR 0x20
-#define RSR_OVERRUN_ERROR 0x40
-#define RSR_BUFFER_FULL 0x80
-
-#define TSR_XMIT_ENABLE 0x01
-#define TSR_OUTPUT_HI_Z 0x00
-#define TSR_OUTPUT_LOW 0x02
-#define TSR_OUTPUT_HIGH 0x04
-#define TSR_OUTPUT_LOOP 0x06
-#define TSR_OUTPUT_MASK 0x06
-#define TSR_BREAK 0x08
-#define TSR_END_OF_XMIT 0x10
-#define TSR_AUTO_TURNAROUND 0x20
-#define TSR_UNDERRUN_ERROR 0x40
-#define TSR_BUFFER_EMPTY 0x80
-
-#define DIVISOR PRESCALER[data & 0x07]
-
-
-const int mc68901_device::INT_MASK_GPIO[] =
-{
- IR_GPIP_0, IR_GPIP_1, IR_GPIP_2, IR_GPIP_3,
- IR_GPIP_4, IR_GPIP_5, IR_GPIP_6, IR_GPIP_7
-};
-
-
-const int mc68901_device::INT_MASK_TIMER[] =
-{
- IR_TIMER_A, IR_TIMER_B, IR_TIMER_C, IR_TIMER_D
-};
-
-
-const int mc68901_device::GPIO_TIMER[] =
-{
- GPIP_4, GPIP_3
-};
-
-
-const int mc68901_device::PRESCALER[] = { 0, 4, 10, 16, 50, 64, 100, 200 };
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-inline void mc68901_device::check_interrupts()
-{
- if (m_ipr & m_imr)
- {
- m_out_irq_cb(ASSERT_LINE);
- }
- else
- {
- m_out_irq_cb(CLEAR_LINE);
- }
-}
-
-inline void mc68901_device::take_interrupt(UINT16 mask)
-{
- m_ipr |= mask;
-
- check_interrupts();
-}
-
-inline void mc68901_device::rx_buffer_full()
-{
- if (m_ier & IR_RCV_BUFFER_FULL)
- {
- take_interrupt(IR_RCV_BUFFER_FULL);
- }
-}
-
-inline void mc68901_device::rx_error()
-{
- if (m_ier & IR_RCV_ERROR)
- {
- take_interrupt(IR_RCV_ERROR);
- }
- else
- {
- rx_buffer_full();
- }
-}
-
-inline void mc68901_device::timer_count(int index)
-{
- if (m_tmc[index] == 0x01)
- {
- /* toggle timer output signal */
- m_to[index] = !m_to[index];
-
- switch (index)
- {
- case TIMER_A: m_out_tao_cb(m_to[index]); break;
- case TIMER_B: m_out_tbo_cb(m_to[index]); break;
- case TIMER_C: m_out_tco_cb(m_to[index]); break;
- case TIMER_D: m_out_tdo_cb(m_to[index]); break;
- }
-
- if (m_ier & INT_MASK_TIMER[index])
- {
- /* signal timer elapsed interrupt */
- take_interrupt(INT_MASK_TIMER[index]);
- }
-
- /* load main counter */
- m_tmc[index] = m_tdr[index];
- }
- else
- {
- /* count down */
- m_tmc[index]--;
- }
-}
-
-
-inline void mc68901_device::timer_input(int index, int value)
-{
- int bit = GPIO_TIMER[index];
- int aer = BIT(m_aer, bit);
- int cr = index ? m_tbcr : m_tacr;
-
- switch (cr & 0x0f)
- {
- case TCR_TIMER_EVENT:
- if (((m_ti[index] ^ aer) == 1) && ((value ^ aer) == 0))
- {
- timer_count(index);
- }
-
- m_ti[index] = value;
- break;
-
- case TCR_TIMER_PULSE_4:
- case TCR_TIMER_PULSE_10:
- case TCR_TIMER_PULSE_16:
- case TCR_TIMER_PULSE_50:
- case TCR_TIMER_PULSE_64:
- case TCR_TIMER_PULSE_100:
- case TCR_TIMER_PULSE_200:
- m_timer[index]->enable((value == aer));
-
- if (((m_ti[index] ^ aer) == 0) && ((value ^ aer) == 1))
- {
- if (m_ier & INT_MASK_GPIO[bit])
- {
- take_interrupt(INT_MASK_GPIO[bit]);
- }
- }
-
- m_ti[index] = value;
- break;
- }
-}
-
-
-inline void mc68901_device::gpio_input(int bit, int state)
-{
- if (state != BIT(m_gpio_input, bit))
- {
- if (state == BIT(m_aer, bit))
- {
- if (LOG) logerror("MC68901 '%s' Edge Transition Detected on GPIO%u\n", tag(), bit);
-
- if (m_ier & INT_MASK_GPIO[bit]) // AND interrupt enabled bit is set...
- {
- if (LOG) logerror("MC68901 '%s' Interrupt Pending for GPIO%u\n", tag(), bit);
-
- take_interrupt(INT_MASK_GPIO[bit]); // set interrupt pending bit
- }
- }
-
-
- if (state)
- m_gpio_input |= (1 << bit);
- else
- m_gpio_input &= ~(1 << bit);
- }
-}
-
-
-void mc68901_device::gpio_output()
-{
- UINT8 new_gpio_output = m_gpip & m_ddr;
-
- if (m_gpio_output != new_gpio_output)
- {
- m_gpio_output = new_gpio_output;
- m_out_gpio_cb((offs_t)0, m_gpio_output);
- }
-}
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mc68901_device - constructor
-//-------------------------------------------------
-
-mc68901_device::mc68901_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MC68901, "MC68901 MFP", tag, owner, clock, "mc68901", __FILE__),
- device_serial_interface(mconfig, *this),
- m_timer_clock(0),
- m_rx_clock(0),
- m_tx_clock(0),
- m_out_irq_cb(*this),
- m_out_gpio_cb(*this),
- m_out_tao_cb(*this),
- m_out_tbo_cb(*this),
- m_out_tco_cb(*this),
- m_out_tdo_cb(*this),
- m_out_so_cb(*this),
- //m_out_rr_cb(*this),
- //m_out_tr_cb(*this),
- m_aer(0),
- m_ier(0),
- m_gpio_input(0),
- m_gpio_output(0xff)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mc68901_device::device_start()
-{
- m_start_bit_hack_for_external_clocks = true;
-
- /* resolve callbacks */
- m_out_irq_cb.resolve_safe();
- m_out_gpio_cb.resolve_safe();
- m_out_tao_cb.resolve_safe();
- m_out_tbo_cb.resolve_safe();
- m_out_tco_cb.resolve_safe();
- m_out_tdo_cb.resolve_safe();
- m_out_so_cb.resolve_safe();
- //m_out_rr_cb.resolve_safe();
- //m_out_tr_cb.resolve_safe();
-
- /* create the timers */
- m_timer[TIMER_A] = timer_alloc(TIMER_A);
- m_timer[TIMER_B] = timer_alloc(TIMER_B);
- m_timer[TIMER_C] = timer_alloc(TIMER_C);
- m_timer[TIMER_D] = timer_alloc(TIMER_D);
-
- if (m_rx_clock > 0)
- {
- set_rcv_rate(m_rx_clock);
- }
-
- if (m_tx_clock > 0)
- {
- set_tra_rate(m_tx_clock);
- }
-
- /* register for state saving */
- save_item(NAME(m_gpip));
- save_item(NAME(m_aer));
- save_item(NAME(m_ddr));
- save_item(NAME(m_ier));
- save_item(NAME(m_ipr));
- save_item(NAME(m_isr));
- save_item(NAME(m_imr));
- save_item(NAME(m_vr));
- save_item(NAME(m_tacr));
- save_item(NAME(m_tbcr));
- save_item(NAME(m_tcdcr));
- save_item(NAME(m_tdr));
- save_item(NAME(m_tmc));
- save_item(NAME(m_to));
- save_item(NAME(m_ti));
- save_item(NAME(m_scr));
- save_item(NAME(m_ucr));
- save_item(NAME(m_rsr));
- save_item(NAME(m_tsr));
- save_item(NAME(m_transmit_buffer));
- save_item(NAME(m_transmit_pending));
- save_item(NAME(m_receive_buffer));
- save_item(NAME(m_receive_pending));
- save_item(NAME(m_gpio_input));
- save_item(NAME(m_gpio_output));
- save_item(NAME(m_rsr_read));
- save_item(NAME(m_next_rsr));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mc68901_device::device_reset()
-{
- m_tsr = 0;
- m_transmit_pending = 0;
-
- // Avoid read-before-write
- m_ipr = m_imr = 0;
-
- m_next_rsr = 0;
-
- memset(m_tmc, 0, sizeof(m_tmc));
- memset(m_ti, 0, sizeof(m_ti));
- memset(m_to, 0, sizeof(m_to));
-
- register_w(REGISTER_GPIP, 0);
- register_w(REGISTER_AER, 0);
- register_w(REGISTER_DDR, 0);
- register_w(REGISTER_IERA, 0);
- register_w(REGISTER_IERB, 0);
- register_w(REGISTER_IPRA, 0);
- register_w(REGISTER_IPRB, 0);
- register_w(REGISTER_ISRA, 0);
- register_w(REGISTER_ISRB, 0);
- register_w(REGISTER_IMRA, 0);
- register_w(REGISTER_IMRB, 0);
- register_w(REGISTER_VR, 0);
- register_w(REGISTER_TACR, 0);
- register_w(REGISTER_TBCR, 0);
- register_w(REGISTER_TCDCR, 0);
- register_w(REGISTER_SCR, 0);
- register_w(REGISTER_UCR, 0);
- register_w(REGISTER_RSR, 0);
-
- transmit_register_reset();
- receive_register_reset();
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void mc68901_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if(id >= TIMER_A && id <= TIMER_D)
- timer_count(id);
- else
- device_serial_interface::device_timer(timer, id, param, ptr);
-}
-
-
-//-------------------------------------------------
-// tra_callback -
-//-------------------------------------------------
-
-void mc68901_device::tra_callback()
-{
- m_out_so_cb(transmit_register_get_data_bit());
-}
-
-
-//-------------------------------------------------
-// tra_complete -
-//-------------------------------------------------
-
-void mc68901_device::tra_complete()
-{
- if (m_tsr & TSR_XMIT_ENABLE)
- {
- if (m_transmit_pending)
- {
- transmit_register_setup(m_transmit_buffer);
- m_transmit_pending = 0;
- m_tsr |= TSR_BUFFER_EMPTY;
-
- if (m_ier & IR_XMIT_BUFFER_EMPTY)
- {
- take_interrupt(IR_XMIT_BUFFER_EMPTY);
- }
- }
- else
- {
- m_tsr |= TSR_UNDERRUN_ERROR;
- // TODO: transmit error?
- }
- }
- else
- {
- m_tsr |= TSR_END_OF_XMIT;
- }
-}
-
-
-//-------------------------------------------------
-// rcv_complete -
-//-------------------------------------------------
-
-void mc68901_device::rcv_complete()
-{
- receive_register_extract();
- m_receive_buffer = get_received_char();
- //if (m_receive_pending) TODO: error?
-
- m_receive_pending = 1;
- rx_buffer_full();
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( mc68901_device::read )
-{
- switch (offset)
- {
- case REGISTER_GPIP: return (m_gpio_input & ~m_ddr) | (m_gpip & m_ddr);
-
- case REGISTER_AER: return m_aer;
- case REGISTER_DDR: return m_ddr;
-
- case REGISTER_IERA: return m_ier >> 8;
- case REGISTER_IERB: return m_ier & 0xff;
- case REGISTER_IPRA: return m_ipr >> 8;
- case REGISTER_IPRB: return m_ipr & 0xff;
- case REGISTER_ISRA: return m_isr >> 8;
- case REGISTER_ISRB: return m_isr & 0xff;
- case REGISTER_IMRA: return m_imr >> 8;
- case REGISTER_IMRB: return m_imr & 0xff;
- case REGISTER_VR: return m_vr;
-
- case REGISTER_TACR: return m_tacr;
- case REGISTER_TBCR: return m_tbcr;
- case REGISTER_TCDCR: return m_tcdcr;
- case REGISTER_TADR: return m_tmc[TIMER_A];
- case REGISTER_TBDR: return m_tmc[TIMER_B];
- case REGISTER_TCDR: return m_tmc[TIMER_C];
- case REGISTER_TDDR: return m_tmc[TIMER_D];
-
- case REGISTER_SCR: return m_scr;
- case REGISTER_UCR: return m_ucr;
- case REGISTER_RSR: return m_rsr;
-
- case REGISTER_TSR:
- {
- /* clear UE bit (in reality, this won't be cleared until one full clock cycle of the transmitter has passed since the bit was set) */
- UINT8 tsr = m_tsr;
- m_tsr &= ~TSR_UNDERRUN_ERROR;
-
- return tsr;
- }
-
- case REGISTER_UDR:
- m_receive_pending = 0;
- return m_receive_buffer;
-
- default: return 0;
- }
-}
-
-
-
-//-------------------------------------------------
-// register_w -
-//-------------------------------------------------
-
-void mc68901_device::register_w(offs_t offset, UINT8 data)
-{
- switch (offset)
- {
- case REGISTER_GPIP:
- if (LOG) logerror("MC68901 '%s' General Purpose I/O : %x\n", tag(), data);
- m_gpip = data;
- gpio_output();
- break;
-
- case REGISTER_AER:
- if (LOG) logerror("MC68901 '%s' Active Edge Register : %x\n", tag(), data);
- m_aer = data;
- break;
-
- case REGISTER_DDR:
- if (LOG) logerror("MC68901 '%s' Data Direction Register : %x\n", tag(), data);
- m_ddr = data;
- gpio_output();
- break;
-
- case REGISTER_IERA:
- if (LOG) logerror("MC68901 '%s' Interrupt Enable Register A : %x\n", tag(), data);
- m_ier = (data << 8) | (m_ier & 0xff);
- m_ipr &= m_ier;
- check_interrupts();
- break;
-
- case REGISTER_IERB:
- if (LOG) logerror("MC68901 '%s' Interrupt Enable Register B : %x\n", tag(), data);
- m_ier = (m_ier & 0xff00) | data;
- m_ipr &= m_ier;
- check_interrupts();
- break;
-
- case REGISTER_IPRA:
- if (LOG) logerror("MC68901 '%s' Interrupt Pending Register A : %x\n", tag(), data);
- m_ipr &= (data << 8) | (m_ipr & 0xff);
- check_interrupts();
- break;
-
- case REGISTER_IPRB:
- if (LOG) logerror("MC68901 '%s' Interrupt Pending Register B : %x\n", tag(), data);
- m_ipr &= (m_ipr & 0xff00) | data;
- check_interrupts();
- break;
-
- case REGISTER_ISRA:
- if (LOG) logerror("MC68901 '%s' Interrupt In-Service Register A : %x\n", tag(), data);
- m_isr &= (data << 8) | (m_isr & 0xff);
- break;
-
- case REGISTER_ISRB:
- if (LOG) logerror("MC68901 '%s' Interrupt In-Service Register B : %x\n", tag(), data);
- m_isr &= (m_isr & 0xff00) | data;
- break;
-
- case REGISTER_IMRA:
- if (LOG) logerror("MC68901 '%s' Interrupt Mask Register A : %x\n", tag(), data);
- m_imr = (data << 8) | (m_imr & 0xff);
- m_isr &= m_imr;
- check_interrupts();
- break;
-
- case REGISTER_IMRB:
- if (LOG) logerror("MC68901 '%s' Interrupt Mask Register B : %x\n", tag(), data);
- m_imr = (m_imr & 0xff00) | data;
- m_isr &= m_imr;
- check_interrupts();
- break;
-
- case REGISTER_VR:
- if (LOG) logerror("MC68901 '%s' Interrupt Vector : %x\n", tag(), data & 0xf0);
-
- m_vr = data & 0xf8;
-
- if (m_vr & VR_S)
- {
- if (LOG) logerror("MC68901 '%s' Software End-Of-Interrupt Mode\n", tag());
- }
- else
- {
- if (LOG) logerror("MC68901 '%s' Automatic End-Of-Interrupt Mode\n", tag());
-
- m_isr = 0;
- }
- break;
-
- case REGISTER_TACR:
- m_tacr = data & 0x1f;
-
- switch (m_tacr & 0x0f)
- {
- case TCR_TIMER_STOPPED:
- if (LOG) logerror("MC68901 '%s' Timer A Stopped\n", tag());
- m_timer[TIMER_A]->enable(false);
- break;
-
- case TCR_TIMER_DELAY_4:
- case TCR_TIMER_DELAY_10:
- case TCR_TIMER_DELAY_16:
- case TCR_TIMER_DELAY_50:
- case TCR_TIMER_DELAY_64:
- case TCR_TIMER_DELAY_100:
- case TCR_TIMER_DELAY_200:
- {
- int divisor = PRESCALER[m_tacr & 0x07];
- if (LOG) logerror("MC68901 '%s' Timer A Delay Mode : %u Prescale\n", tag(), divisor);
- m_timer[TIMER_A]->adjust(attotime::from_hz(m_timer_clock / divisor), 0, attotime::from_hz(m_timer_clock / divisor));
- }
- break;
-
- case TCR_TIMER_EVENT:
- if (LOG) logerror("MC68901 '%s' Timer A Event Count Mode\n", tag());
- m_timer[TIMER_A]->enable(false);
- break;
-
- case TCR_TIMER_PULSE_4:
- case TCR_TIMER_PULSE_10:
- case TCR_TIMER_PULSE_16:
- case TCR_TIMER_PULSE_50:
- case TCR_TIMER_PULSE_64:
- case TCR_TIMER_PULSE_100:
- case TCR_TIMER_PULSE_200:
- {
- int divisor = PRESCALER[m_tacr & 0x07];
- if (LOG) logerror("MC68901 '%s' Timer A Pulse Width Mode : %u Prescale\n", tag(), divisor);
- m_timer[TIMER_A]->adjust(attotime::never, 0, attotime::from_hz(m_timer_clock / divisor));
- m_timer[TIMER_A]->enable(false);
- }
- break;
- }
-
- if (m_tacr & TCR_TIMER_RESET)
- {
- if (LOG) logerror("MC68901 '%s' Timer A Reset\n", tag());
-
- m_to[TIMER_A] = 0;
-
- m_out_tao_cb(m_to[TIMER_A]);
- }
- break;
-
- case REGISTER_TBCR:
- m_tbcr = data & 0x1f;
-
- switch (m_tbcr & 0x0f)
- {
- case TCR_TIMER_STOPPED:
- if (LOG) logerror("MC68901 '%s' Timer B Stopped\n", tag());
- m_timer[TIMER_B]->enable(false);
- break;
-
- case TCR_TIMER_DELAY_4:
- case TCR_TIMER_DELAY_10:
- case TCR_TIMER_DELAY_16:
- case TCR_TIMER_DELAY_50:
- case TCR_TIMER_DELAY_64:
- case TCR_TIMER_DELAY_100:
- case TCR_TIMER_DELAY_200:
- {
- int divisor = PRESCALER[m_tbcr & 0x07];
- if (LOG) logerror("MC68901 '%s' Timer B Delay Mode : %u Prescale\n", tag(), divisor);
- m_timer[TIMER_B]->adjust(attotime::from_hz(m_timer_clock / divisor), 0, attotime::from_hz(m_timer_clock / divisor));
- }
- break;
-
- case TCR_TIMER_EVENT:
- if (LOG) logerror("MC68901 '%s' Timer B Event Count Mode\n", tag());
- m_timer[TIMER_B]->enable(false);
- break;
-
- case TCR_TIMER_PULSE_4:
- case TCR_TIMER_PULSE_10:
- case TCR_TIMER_PULSE_16:
- case TCR_TIMER_PULSE_50:
- case TCR_TIMER_PULSE_64:
- case TCR_TIMER_PULSE_100:
- case TCR_TIMER_PULSE_200:
- {
- int divisor = PRESCALER[m_tbcr & 0x07];
- if (LOG) logerror("MC68901 '%s' Timer B Pulse Width Mode : %u Prescale\n", tag(), DIVISOR);
- m_timer[TIMER_B]->adjust(attotime::never, 0, attotime::from_hz(m_timer_clock / divisor));
- m_timer[TIMER_B]->enable(false);
- }
- break;
- }
-
- if (m_tacr & TCR_TIMER_RESET)
- {
- if (LOG) logerror("MC68901 '%s' Timer B Reset\n", tag());
-
- m_to[TIMER_B] = 0;
-
- m_out_tbo_cb(m_to[TIMER_B]);
- }
- break;
-
- case REGISTER_TCDCR:
- m_tcdcr = data & 0x6f;
-
- switch (m_tcdcr & 0x07)
- {
- case TCR_TIMER_STOPPED:
- if (LOG) logerror("MC68901 '%s' Timer D Stopped\n", tag());
- m_timer[TIMER_D]->enable(false);
- break;
-
- case TCR_TIMER_DELAY_4:
- case TCR_TIMER_DELAY_10:
- case TCR_TIMER_DELAY_16:
- case TCR_TIMER_DELAY_50:
- case TCR_TIMER_DELAY_64:
- case TCR_TIMER_DELAY_100:
- case TCR_TIMER_DELAY_200:
- {
- int divisor = PRESCALER[m_tcdcr & 0x07];
- if (LOG) logerror("MC68901 '%s' Timer D Delay Mode : %u Prescale\n", tag(), divisor);
- m_timer[TIMER_D]->adjust(attotime::from_hz(m_timer_clock / divisor), 0, attotime::from_hz(m_timer_clock / divisor));
- }
- break;
- }
-
- switch ((m_tcdcr >> 4) & 0x07)
- {
- case TCR_TIMER_STOPPED:
- if (LOG) logerror("MC68901 '%s' Timer C Stopped\n", tag());
- m_timer[TIMER_C]->enable(false);
- break;
-
- case TCR_TIMER_DELAY_4:
- case TCR_TIMER_DELAY_10:
- case TCR_TIMER_DELAY_16:
- case TCR_TIMER_DELAY_50:
- case TCR_TIMER_DELAY_64:
- case TCR_TIMER_DELAY_100:
- case TCR_TIMER_DELAY_200:
- {
- int divisor = PRESCALER[(m_tcdcr >> 4) & 0x07];
- if (LOG) logerror("MC68901 '%s' Timer C Delay Mode : %u Prescale\n", tag(), divisor);
- m_timer[TIMER_C]->adjust(attotime::from_hz(m_timer_clock / divisor), 0, attotime::from_hz(m_timer_clock / divisor));
- }
- break;
- }
- break;
-
- case REGISTER_TADR:
- if (LOG) logerror("MC68901 '%s' Timer A Data Register : %x\n", tag(), data);
-
- m_tdr[TIMER_A] = data;
-
- if (!m_timer[TIMER_A]->enabled())
- {
- m_tmc[TIMER_A] = data;
- }
- break;
-
- case REGISTER_TBDR:
- if (LOG) logerror("MC68901 '%s' Timer B Data Register : %x\n", tag(), data);
-
- m_tdr[TIMER_B] = data;
-
- if (!m_timer[TIMER_B]->enabled())
- {
- m_tmc[TIMER_B] = data;
- }
- break;
-
- case REGISTER_TCDR:
- if (LOG) logerror("MC68901 '%s' Timer C Data Register : %x\n", tag(), data);
-
- m_tdr[TIMER_C] = data;
-
- if (!m_timer[TIMER_C]->enabled())
- {
- m_tmc[TIMER_C] = data;
- }
- break;
-
- case REGISTER_TDDR:
- if (LOG) logerror("MC68901 '%s' Timer D Data Register : %x\n", tag(), data);
-
- m_tdr[TIMER_D] = data;
-
- if (!m_timer[TIMER_D]->enabled())
- {
- m_tmc[TIMER_D] = data;
- }
- break;
-
- case REGISTER_SCR:
- if (LOG) logerror("MC68901 '%s' Sync Character : %x\n", tag(), data);
-
- m_scr = data;
- break;
-
- case REGISTER_UCR:
- {
- int data_bit_count;
-
- switch (data & 0x60)
- {
- case UCR_WORD_LENGTH_8: default: data_bit_count = 8; break;
- case UCR_WORD_LENGTH_7: data_bit_count = 7; break;
- case UCR_WORD_LENGTH_6: data_bit_count = 6; break;
- case UCR_WORD_LENGTH_5: data_bit_count = 5; break;
- }
-
- parity_t parity;
-
- if (data & UCR_PARITY_ENABLED)
- {
- if (data & UCR_PARITY_EVEN)
- {
- if (LOG) logerror("MC68901 '%s' Parity : Even\n", tag());
-
- parity = PARITY_EVEN;
- }
- else
- {
- if (LOG) logerror("MC68901 '%s' Parity : Odd\n", tag());
-
- parity = PARITY_ODD;
- }
- }
- else
- {
- if (LOG) logerror("MC68901 '%s' Parity : Disabled\n", tag());
-
- parity = PARITY_NONE;
- }
-
- if (LOG) logerror("MC68901 '%s' Word Length : %u bits\n", tag(), data_bit_count);
-
-
- int start_bits;
- stop_bits_t stop_bits;
-
- switch (data & 0x18)
- {
- case UCR_START_STOP_0_0:
- default:
- start_bits = 0;
- stop_bits = STOP_BITS_0;
- if (LOG) logerror("MC68901 '%s' Start Bits : 0, Stop Bits : 0, Format : synchronous\n", tag());
- break;
-
- case UCR_START_STOP_1_1:
- start_bits = 1;
- stop_bits = STOP_BITS_1;
- if (LOG) logerror("MC68901 '%s' Start Bits : 1, Stop Bits : 1, Format : asynchronous\n", tag());
- break;
-
- case UCR_START_STOP_1_15:
- start_bits = 1;
- stop_bits = STOP_BITS_1_5;
- if (LOG) logerror("MC68901 '%s' Start Bits : 1, Stop Bits : 1.5, Format : asynchronous\n", tag());
- break;
-
- case UCR_START_STOP_1_2:
- start_bits = 1;
- stop_bits = STOP_BITS_2;
- if (LOG) logerror("MC68901 '%s' Start Bits : 1, Stop Bits : 2, Format : asynchronous\n", tag());
- break;
- }
-
- if (data & UCR_CLOCK_DIVIDE_16)
- {
- if (LOG) logerror("MC68901 '%s' Rx/Tx Clock Divisor : 16\n", tag());
- }
- else
- {
- if (LOG) logerror("MC68901 '%s' Rx/Tx Clock Divisor : 1\n", tag());
- }
-
- set_data_frame(start_bits, data_bit_count, parity, stop_bits);
-
- m_ucr = data;
- }
- break;
-
- case REGISTER_RSR:
- if ((data & RSR_RCV_ENABLE) == 0)
- {
- if (LOG) logerror("MC68901 '%s' Receiver Disabled\n", tag());
- m_rsr = 0;
- }
- else
- {
- if (LOG) logerror("MC68901 '%s' Receiver Enabled\n", tag());
-
- if (data & RSR_SYNC_STRIP_ENABLE)
- {
- if (LOG) logerror("MC68901 '%s' Sync Strip Enabled\n", tag());
- }
- else
- {
- if (LOG) logerror("MC68901 '%s' Sync Strip Disabled\n", tag());
- }
-
- if (data & RSR_FOUND_SEARCH)
- if (LOG) logerror("MC68901 '%s' Receiver Search Mode Enabled\n", tag());
-
- m_rsr = data & 0x0b;
- }
- break;
-
- case REGISTER_TSR:
- m_tsr = (m_tsr & (TSR_BUFFER_EMPTY | TSR_UNDERRUN_ERROR | TSR_END_OF_XMIT)) | (data & ~(TSR_BUFFER_EMPTY | TSR_UNDERRUN_ERROR | TSR_END_OF_XMIT));
-
- if ((data & TSR_XMIT_ENABLE) == 0)
- {
- if (LOG) logerror("MC68901 '%s' Transmitter Disabled\n", tag());
-
- m_tsr &= ~TSR_UNDERRUN_ERROR;
-
- if (is_transmit_register_empty())
- m_tsr |= TSR_END_OF_XMIT;
- }
- else
- {
- if (LOG) logerror("MC68901 '%s' Transmitter Enabled\n", tag());
-
- switch (data & 0x06)
- {
- case TSR_OUTPUT_HI_Z:
- if (LOG) logerror("MC68901 '%s' Transmitter Disabled Output State : Hi-Z\n", tag());
- break;
- case TSR_OUTPUT_LOW:
- if (LOG) logerror("MC68901 '%s' Transmitter Disabled Output State : 0\n", tag());
- break;
- case TSR_OUTPUT_HIGH:
- if (LOG) logerror("MC68901 '%s' Transmitter Disabled Output State : 1\n", tag());
- break;
- case TSR_OUTPUT_LOOP:
- if (LOG) logerror("MC68901 '%s' Transmitter Disabled Output State : Loop\n", tag());
- break;
- }
-
- if (data & TSR_BREAK)
- {
- if (LOG) logerror("MC68901 '%s' Transmitter Break Enabled\n", tag());
- }
- else
- {
- if (LOG) logerror("MC68901 '%s' Transmitter Break Disabled\n", tag());
- }
-
- if (data & TSR_AUTO_TURNAROUND)
- {
- if (LOG) logerror("MC68901 '%s' Transmitter Auto Turnaround Enabled\n", tag());
- }
- else
- {
- if (LOG) logerror("MC68901 '%s' Transmitter Auto Turnaround Disabled\n", tag());
- }
-
- m_tsr &= ~TSR_END_OF_XMIT;
-
- if (m_transmit_pending && is_transmit_register_empty())
- {
- transmit_register_setup(m_transmit_buffer);
- m_transmit_pending = 0;
- m_tsr |= TSR_BUFFER_EMPTY;
- }
- }
- break;
-
- case REGISTER_UDR:
- if (LOG) logerror("MC68901 '%s' UDR %x\n", tag(), data);
- m_transmit_buffer = data;
- m_transmit_pending = 1;
- m_tsr &= ~TSR_BUFFER_EMPTY;
-
- if ((m_tsr & TSR_XMIT_ENABLE) && is_transmit_register_empty())
- {
- transmit_register_setup(m_transmit_buffer);
- m_transmit_pending = 0;
- m_tsr |= TSR_BUFFER_EMPTY;
- }
- break;
- }
-}
-
-WRITE8_MEMBER( mc68901_device::write )
-{
- register_w(offset, data);
-}
-
-
-int mc68901_device::get_vector()
-{
- int ch;
-
- for (ch = 15; ch >= 0; ch--)
- {
- if (BIT(m_imr, ch) && BIT(m_ipr, ch))
- {
- if (m_vr & VR_S)
- {
- /* set interrupt-in-service bit */
- m_isr |= (1 << ch);
- }
-
- /* clear interrupt pending bit */
- m_ipr &= ~(1 << ch);
-
- check_interrupts();
-
- return (m_vr & 0xf0) | ch;
- }
- }
-
- return M68K_INT_ACK_SPURIOUS;
-}
-
-WRITE_LINE_MEMBER( mc68901_device::i0_w ) { gpio_input(0, state); }
-WRITE_LINE_MEMBER( mc68901_device::i1_w ) { gpio_input(1, state); }
-WRITE_LINE_MEMBER( mc68901_device::i2_w ) { gpio_input(2, state); }
-WRITE_LINE_MEMBER( mc68901_device::i3_w ) { gpio_input(3, state); }
-WRITE_LINE_MEMBER( mc68901_device::i4_w ) { gpio_input(4, state); }
-WRITE_LINE_MEMBER( mc68901_device::i5_w ) { gpio_input(5, state); }
-WRITE_LINE_MEMBER( mc68901_device::i6_w ) { gpio_input(6, state); }
-WRITE_LINE_MEMBER( mc68901_device::i7_w ) { gpio_input(7, state); }
-
-
-WRITE_LINE_MEMBER( mc68901_device::tai_w )
-{
- timer_input(TIMER_A, state);
-}
-
-
-WRITE_LINE_MEMBER( mc68901_device::tbi_w )
-{
- timer_input(TIMER_B, state);
-}
-
-WRITE_LINE_MEMBER(mc68901_device::write_rx)
-{
- device_serial_interface::rx_w(state);
-}
diff --git a/src/emu/machine/mc68901.h b/src/emu/machine/mc68901.h
deleted file mode 100644
index 7147af2a478..00000000000
--- a/src/emu/machine/mc68901.h
+++ /dev/null
@@ -1,311 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Motorola MC68901 Multi Function Peripheral emulation
-
-**********************************************************************
- _____ _____
- R/_W 1 |* \_/ | 48 _CS
- RS1 2 | | 47 _DS
- RS2 3 | | 46 _DTACK
- RS3 4 | | 45 _IACK
- RS4 5 | | 44 D7
- RS5 6 | | 43 D6
- TC 7 | | 42 D5
- SO 8 | | 41 D4
- SI 9 | | 40 D3
- RC 10 | | 39 D2
- Vcc 11 | | 38 D1
- NC 12 | MC68901 | 37 D0
- TAO 13 | MK68901 | 36 GND
- TBO 14 | | 35 CLK
- TCO 15 | | 34 _IEI
- TDO 16 | | 33 _IEO
- XTAL1 17 | | 32 _IRQ
- XTAL2 18 | | 31 _RR
- TAI 19 | | 30 _TR
- TBI 20 | | 29 I7
- _RESET 21 | | 28 I6
- I0 22 | | 27 I5
- I1 23 | | 26 I4
- I2 24 |_____________| 25 I3
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MC68901__
-#define __MC68901__
-
-#include "emu.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MC68901_TIMER_CLOCK(_clk) \
- mc68901_device::set_timer_clock(*device, _clk);
-
-#define MCFG_MC68901_RX_CLOCK(_clk) \
- mc68901_device::set_rx_clock(*device, _clk);
-
-#define MCFG_MC68901_TX_CLOCK(_clk) \
- mc68901_device::set_tx_clock(*device, _clk);
-
-#define MCFG_MC68901_OUT_IRQ_CB(_devcb) \
- devcb = &mc68901_device::set_out_irq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68901_OUT_GPIO_CB(_devcb) \
- devcb = &mc68901_device::set_out_gpio_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68901_OUT_TAO_CB(_devcb) \
- devcb = &mc68901_device::set_out_tao_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68901_OUT_TBO_CB(_devcb) \
- devcb = &mc68901_device::set_out_tbo_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68901_OUT_TCO_CB(_devcb) \
- devcb = &mc68901_device::set_out_tco_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68901_OUT_TDO_CB(_devcb) \
- devcb = &mc68901_device::set_out_tdo_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68901_OUT_SO_CB(_devcb) \
- devcb = &mc68901_device::set_out_so_callback(*device, DEVCB_##_devcb);
-
-/*#define MCFG_MC68901_OUT_RR_CB(_devcb) \
- devcb = &mc68901_device::set_out_rr_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MC68901_OUT_TR_CB(_devcb) \
- devcb = &mc68901_device::set_out_tr_callback(*device, DEVCB_##_devcb);*/
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-// ======================> mc68901_device
-
-class mc68901_device : public device_t,
- public device_serial_interface
-{
-public:
- // construction/destruction
- mc68901_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void set_timer_clock(device_t &device, int timer_clock) { downcast<mc68901_device &>(device).m_timer_clock = timer_clock; }
- static void set_rx_clock(device_t &device, int rx_clock) { downcast<mc68901_device &>(device).m_rx_clock = rx_clock; }
- static void set_tx_clock(device_t &device, int tx_clock) { downcast<mc68901_device &>(device).m_tx_clock = tx_clock; }
- template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<mc68901_device &>(device).m_out_irq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_gpio_callback(device_t &device, _Object object) { return downcast<mc68901_device &>(device).m_out_gpio_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_tao_callback(device_t &device, _Object object) { return downcast<mc68901_device &>(device).m_out_tao_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_tbo_callback(device_t &device, _Object object) { return downcast<mc68901_device &>(device).m_out_tbo_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_tco_callback(device_t &device, _Object object) { return downcast<mc68901_device &>(device).m_out_tco_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_tdo_callback(device_t &device, _Object object) { return downcast<mc68901_device &>(device).m_out_tdo_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_so_callback(device_t &device, _Object object) { return downcast<mc68901_device &>(device).m_out_so_cb.set_callback(object); }
- //template<class _Object> static devcb_base &set_rr_callback(device_t &device, _Object object) { return downcast<mc68901_device &>(device).m_out_rr_cb.set_callback(object); }
- //template<class _Object> static devcb_base &set_tr_callback(device_t &device, _Object object) { return downcast<mc68901_device &>(device).m_out_tr_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- int get_vector();
-
- DECLARE_WRITE_LINE_MEMBER( i0_w );
- DECLARE_WRITE_LINE_MEMBER( i1_w );
- DECLARE_WRITE_LINE_MEMBER( i2_w );
- DECLARE_WRITE_LINE_MEMBER( i3_w );
- DECLARE_WRITE_LINE_MEMBER( i4_w );
- DECLARE_WRITE_LINE_MEMBER( i5_w );
- DECLARE_WRITE_LINE_MEMBER( i6_w );
- DECLARE_WRITE_LINE_MEMBER( i7_w );
-
- DECLARE_WRITE_LINE_MEMBER( tai_w );
- DECLARE_WRITE_LINE_MEMBER( tbi_w );
-
- DECLARE_WRITE_LINE_MEMBER( write_rx );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_serial_interface overrides
- virtual void tra_callback();
- virtual void tra_complete();
- virtual void rcv_complete();
-
- void check_interrupts();
- void take_interrupt(UINT16 mask);
- void rx_buffer_full();
- void rx_error();
- void timer_count(int index);
- void timer_input(int index, int value);
- void gpio_input(int bit, int state);
- void gpio_output();
- void register_w(offs_t offset, UINT8 data);
-
-private:
- enum
- {
- TIMER_A = 0,
- TIMER_B,
- TIMER_C,
- TIMER_D
- };
-
- enum
- {
- REGISTER_GPIP = 0,
- REGISTER_AER,
- REGISTER_DDR,
- REGISTER_IERA,
- REGISTER_IERB,
- REGISTER_IPRA,
- REGISTER_IPRB,
- REGISTER_ISRA,
- REGISTER_ISRB,
- REGISTER_IMRA,
- REGISTER_IMRB,
- REGISTER_VR,
- REGISTER_TACR,
- REGISTER_TBCR,
- REGISTER_TCDCR,
- REGISTER_TADR,
- REGISTER_TBDR,
- REGISTER_TCDR,
- REGISTER_TDDR,
- REGISTER_SCR,
- REGISTER_UCR,
- REGISTER_RSR,
- REGISTER_TSR,
- REGISTER_UDR
- };
-
- enum
- {
- INT_GPI0 = 0,
- INT_GPI1,
- INT_GPI2,
- INT_GPI3,
- INT_TIMER_D,
- INT_TIMER_C,
- INT_GPI4,
- INT_GPI5,
- INT_TIMER_B,
- INT_XMIT_ERROR,
- INT_XMIT_BUFFER_EMPTY,
- INT_RCV_ERROR,
- INT_RCV_BUFFER_FULL,
- INT_TIMER_A,
- INT_GPI6,
- INT_GPI7
- };
-
- enum
- {
- GPIP_0 = 0,
- GPIP_1,
- GPIP_2,
- GPIP_3,
- GPIP_4,
- GPIP_5,
- GPIP_6,
- GPIP_7
- };
-
- enum
- {
- SERIAL_START = 0,
- SERIAL_DATA,
- SERIAL_PARITY,
- SERIAL_STOP
- };
-
- enum
- {
- XMIT_OFF = 0,
- XMIT_STARTING,
- XMIT_ON,
- XMIT_BREAK,
- XMIT_STOPPING
- };
-
- static const int INT_MASK_GPIO[];
- static const int INT_MASK_TIMER[];
- static const int GPIO_TIMER[];
- static const int PRESCALER[];
-
- int m_timer_clock; /* timer clock */
- int m_rx_clock; /* serial receive clock */
- int m_tx_clock; /* serial transmit clock */
-
- devcb_write_line m_out_irq_cb;
-
- devcb_write8 m_out_gpio_cb;
-
- devcb_write_line m_out_tao_cb;
- devcb_write_line m_out_tbo_cb;
- devcb_write_line m_out_tco_cb;
- devcb_write_line m_out_tdo_cb;
-
- devcb_write_line m_out_so_cb;
- //devcb_write_line m_out_rr_cb;
- //devcb_write_line m_out_tr_cb;
-
- //int m_device_type; /* device type */
-
- /* registers */
- UINT8 m_gpip; /* general purpose I/O register */
- UINT8 m_aer; /* active edge register */
- UINT8 m_ddr; /* data direction register */
-
- UINT16 m_ier; /* interrupt enable register */
- UINT16 m_ipr; /* interrupt pending register */
- UINT16 m_isr; /* interrupt in-service register */
- UINT16 m_imr; /* interrupt mask register */
- UINT8 m_vr; /* vector register */
-
- UINT8 m_tacr; /* timer A control register */
- UINT8 m_tbcr; /* timer B control register */
- UINT8 m_tcdcr; /* timers C and D control register */
- UINT8 m_tdr[4]; /* timer data registers */
-
- UINT8 m_scr; /* synchronous character register */
- UINT8 m_ucr; /* USART control register */
- UINT8 m_tsr; /* transmitter status register */
- UINT8 m_rsr; /* receiver status register */
- UINT8 m_transmit_buffer; /* USART data register */
- int m_transmit_pending;
- UINT8 m_receive_buffer;
- int m_receive_pending;
- UINT8 m_gpio_input;
- UINT8 m_gpio_output;
-
- /* counter timer state */
- UINT8 m_tmc[4]; /* timer main counters */
- int m_ti[4]; /* timer in latch */
- int m_to[4]; /* timer out latch */
-
- /* interrupt state */
- //int m_irqlevel; /* interrupt level latch */
-
- /* serial state */
- UINT8 m_next_rsr; /* receiver status register latch */
- int m_rsr_read; /* receiver status register read flag */
-
- // timers
- emu_timer *m_timer[4]; /* counter timers */
-};
-
-
-// device type definition
-extern const device_type MC68901;
-
-
-
-#endif
diff --git a/src/emu/machine/mccs1850.c b/src/emu/machine/mccs1850.c
deleted file mode 100644
index b037f184bfc..00000000000
--- a/src/emu/machine/mccs1850.c
+++ /dev/null
@@ -1,584 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Motorola MCCS1850 Serial Real-Time Clock emulation
-
-*********************************************************************/
-
-/*
-
- TODO:
-
- - auto restart
- - test mode
-
-*/
-
-#include "mccs1850.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-#define RAM_SIZE 0x80
-
-
-// serial state
-enum
-{
- STATE_ADDRESS,
- STATE_DATA
-};
-
-
-// registers
-enum
-{
- REGISTER_COUNTER_LATCH = 0x20,
- REGISTER_ALARM_LATCH = 0x24,
- REGISTER_STATUS = 0x30,
- REGISTER_CONTROL = 0x31,
- REGISTER_TEST_1 = 0x3e,
- REGISTER_TEST_2 = 0x3f,
- REGISTER_TEST_KICK_START_COUNTER = 0x40,
- REGISTER_TEST_PRESCALE_COUNTER = 0x43,
- REGISTER_TEST_COUNTER_INCREMENT = 0x4f
-};
-
-
-// clock status/interrupt register
-#define STATUS_TM 0x20 // test mode
-#define STATUS_FTU 0x10 // first time up
-#define STATUS_IT 0x08 // interrupt true
-#define STATUS_LB 0x04 // low battery
-#define STATUS_AI 0x02 // alarm
-#define STATUS_RPD 0x01 // request to power down
-
-
-// clock control register
-#define CONTROL_STR_STP 0x80 // start/stop
-#define CONTROL_PD 0x40 // power down
-#define CONTROL_AR 0x20 // auto restart
-#define CONTROL_AE 0x10 // alarm enable
-#define CONTROL_AC 0x08 // alarm clear
-#define CONTROL_FTUC 0x04 // first time up clear
-#define CONTROL_LBE 0x02 // low battery enable
-#define CONTROL_RPCD 0x01 // request to power down clear
-
-
-// test register 1
-#define TEST1_DIV1 0x80 // divide by 1
-#define TEST1_VOVR 0x40 // Vdd override
-#define TEST1_VDDUP 0x20 // Vdd up
-#define TEST1_VDDON 0x10 // Vdd on
-#define TEST1_VRT 0x08 // valid RAM and time
-#define TEST1_LOW_BAT 0x08 // low battery
-#define TEST1_PCC 0x04 // programmable capacitor C (10.0 pF)
-#define TEST1_PCB 0x02 // programmable capacitor B (5.0 pF)
-#define TEST1_PCA 0x01 // programmable capacitor A (2.5 pF)
-
-
-// test register 2
-#define TEST2_OSCBY 0x80 // oscillator bypass
-#define TEST2_COMPOVR 0x40 // comparator override
-#define TEST2_POR 0x20 // power on reset
-#define TEST2_SELTCK 0x10 // select test clock
-#define TEST2_FRZ 0x08 // freeze mode
-#define TEST2_DV_MASK 0x07 // divider bits select
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type MCCS1850 = &device_creator<mccs1850_device>;
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// check_interrupt -
-//-------------------------------------------------
-
-inline void mccs1850_device::check_interrupt()
-{
- UINT8 status = m_ram[REGISTER_STATUS];
- UINT8 control = m_ram[REGISTER_CONTROL];
-
- bool interrupt = (((status & STATUS_AI) && (control & CONTROL_AE)) // alarm interrupt
- || ((status & STATUS_LB) && (control & CONTROL_LBE)) // low battery
- || (status & STATUS_FTU) // first time up
- || (status & STATUS_RPD)); // request to power down
-
- if (interrupt)
- {
- m_ram[REGISTER_STATUS] |= STATUS_IT;
- }
- else
- {
- m_ram[REGISTER_STATUS] &= ~STATUS_IT;
- }
-
- if(!int_cb.isnull())
- int_cb(interrupt);
-}
-
-
-//-------------------------------------------------
-// set_pse_line -
-//-------------------------------------------------
-
-inline void mccs1850_device::set_pse_line(bool state)
-{
- m_pse = state;
-
- if(!pse_cb.isnull())
- pse_cb(m_pse);
-}
-
-
-//-------------------------------------------------
-// read_register -
-//-------------------------------------------------
-
-inline UINT8 mccs1850_device::read_register(offs_t offset)
-{
- switch (offset)
- {
- case REGISTER_COUNTER_LATCH:
- case REGISTER_COUNTER_LATCH+3: // Required by the NeXT power on test
- // load counter value into latch
- m_ram[REGISTER_COUNTER_LATCH] = m_counter >> 24;
- m_ram[REGISTER_COUNTER_LATCH + 1] = m_counter >> 16;
- m_ram[REGISTER_COUNTER_LATCH + 2] = m_counter >> 8;
- m_ram[REGISTER_COUNTER_LATCH + 3] = m_counter;
- break;
-
- case REGISTER_TEST_1:
- case REGISTER_TEST_2:
- case REGISTER_TEST_KICK_START_COUNTER:
- case REGISTER_TEST_PRESCALE_COUNTER:
- case REGISTER_TEST_COUNTER_INCREMENT:
- logerror("MCCS1850 '%s' Unsupported read from test register %02x!\n", tag(), offset);
- break;
- }
-
- return m_ram[offset];
-}
-
-
-//-------------------------------------------------
-// write_register -
-//-------------------------------------------------
-
-inline void mccs1850_device::write_register(offs_t offset, UINT8 data)
-{
- switch (offset)
- {
- case REGISTER_STATUS:
- // read only
- break;
-
- case REGISTER_CONTROL:
- if (LOG) logerror("MCCS1850 '%s' Counter %s\n", tag(), (data & CONTROL_STR_STP) ? "Start" : "Stop");
- m_clock_timer->enable(data & CONTROL_STR_STP);
-
- if (data & CONTROL_PD)
- {
- if (LOG) logerror("MCCS1850 '%s' Power Down\n", tag());
- set_pse_line(false);
- }
-
- if (data & CONTROL_AR)
- {
- if (LOG) logerror("MCCS1850 '%s' Auto Restart\n", tag());
- }
-
- if (data & CONTROL_AC)
- {
- if (LOG) logerror("MCCS1850 '%s' Alarm Clear\n", tag());
- m_ram[REGISTER_STATUS] &= ~STATUS_AI;
- }
-
- if (data & CONTROL_FTUC)
- {
- if (LOG) logerror("MCCS1850 '%s' First Time Up Clear\n", tag());
- m_ram[REGISTER_STATUS] &= ~STATUS_FTU;
- }
-
- if (data & CONTROL_RPCD)
- {
- if (LOG) logerror("MCCS1850 '%s' Request to Power Down Clear\n", tag());
- m_ram[REGISTER_STATUS] &= ~STATUS_RPD;
- }
-
- m_ram[REGISTER_CONTROL] = data & 0xb2;
-
- check_interrupt();
- break;
-
- case REGISTER_TEST_1:
- case REGISTER_TEST_2:
- case REGISTER_TEST_KICK_START_COUNTER:
- case REGISTER_TEST_PRESCALE_COUNTER:
- case REGISTER_TEST_COUNTER_INCREMENT:
- logerror("MCCS1850 '%s' Unsupported write to test register %02x!\n", tag(), offset);
- break;
-
- default:
- m_ram[offset] = data;
- }
-}
-
-
-//-------------------------------------------------
-// advance_seconds -
-//-------------------------------------------------
-
-inline void mccs1850_device::advance_seconds()
-{
- UINT32 alarm = (m_ram[REGISTER_ALARM_LATCH] << 24) | (m_ram[REGISTER_ALARM_LATCH + 1] << 16) | (m_ram[REGISTER_ALARM_LATCH + 2] << 8) | m_ram[REGISTER_ALARM_LATCH + 3];
-
- m_counter++;
-
- if (m_counter == alarm)
- {
- if (m_pse)
- {
- // trigger alarm
- m_ram[REGISTER_STATUS] |= STATUS_AI;
-
- check_interrupt();
- }
- else
- {
- // wake up
- set_pse_line(true);
- }
- }
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mccs1850_device - constructor
-//-------------------------------------------------
-
-mccs1850_device::mccs1850_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, MCCS1850, "MCCS1850", tag, owner, clock, "mccs1850", __FILE__),
- device_rtc_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this),
- int_cb(*this),
- pse_cb(*this),
- nuc_cb(*this),
- m_pse(1),
- m_counter(0),
- m_ce(0),
- m_sck(0),
- m_sdo(1),
- m_sdi(0),
- m_state(STATE_ADDRESS),
- m_bits(0)
-{
-}
-
-
-//-------------------------------------------------
-// set_counter - set the counter at startup time
-//-------------------------------------------------
-
-void mccs1850_device::set_counter(UINT32 value)
-{
- m_counter = value;
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mccs1850_device::device_start()
-{
- // resolve callbacks
- int_cb.resolve();
- pse_cb.resolve();
- nuc_cb.resolve();
-
- // allocate timers
- m_clock_timer = timer_alloc(TIMER_CLOCK);
- m_clock_timer->adjust(attotime::from_hz(clock() / 32768), 0, attotime::from_hz(clock() / 32768));
-
- // state saving
- save_item(NAME(m_pse));
- save_item(NAME(m_counter));
- save_item(NAME(m_ce));
- save_item(NAME(m_sck));
- save_item(NAME(m_sdo));
- save_item(NAME(m_sdi));
- save_item(NAME(m_state));
- save_item(NAME(m_address));
- save_item(NAME(m_bits));
- save_item(NAME(m_shift));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mccs1850_device::device_reset()
-{
- if(!m_counter)
- m_ram[REGISTER_STATUS] = 0x80 | STATUS_FTU;
- else
- m_ram[REGISTER_STATUS] = 0x80;
- m_ram[REGISTER_CONTROL] = 0x00;
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void mccs1850_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_CLOCK:
- advance_seconds();
- break;
- }
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void mccs1850_device::nvram_default()
-{
- memset(m_ram, 0xff, RAM_SIZE);
-
- if (machine().root_device().memregion(tag()) != NULL)
- {
- UINT8 *nvram = machine().root_device().memregion(tag())->base();
-
- // initialize NVRAM
- memcpy(m_ram, nvram, 0x20);
- }
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void mccs1850_device::nvram_read(emu_file &file)
-{
- file.read(m_ram, RAM_SIZE);
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void mccs1850_device::nvram_write(emu_file &file)
-{
- file.write(m_ram, RAM_SIZE);
-}
-
-
-//-------------------------------------------------
-// ce_w - chip enable write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mccs1850_device::ce_w )
-{
- m_ce = state;
-
- if (!m_ce)
- {
- m_state = STATE_ADDRESS;
- m_bits = 0;
- }
-}
-
-
-//-------------------------------------------------
-// sck_w - serial clock write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mccs1850_device::sck_w )
-{
- if (!m_ce) return;
-
- switch (m_state)
- {
- case STATE_ADDRESS:
- if (m_sck && !state)
- {
- m_address <<= 1;
- m_address |= m_sdi;
- m_bits++;
-
- if (m_bits == 8)
- {
- if (LOG) logerror("MCCS1850 '%s' %s Address %02x\n", tag(), BIT(m_address, 7) ? "Write" : "Read", m_address & 0x7f);
-
- m_bits = 0;
- m_state = STATE_DATA;
-
- if (!BIT(m_address, 7))
- {
- m_shift = read_register(m_address & 0x7f);
-
- if (LOG) logerror("MCCS1850 '%s' Data Out %02x\n", tag(), m_shift);
- }
- }
- }
- break;
-
- case STATE_DATA:
- if (BIT(m_address, 7) && m_sck && !state)
- {
- // shift data in
- m_shift <<= 1;
- m_shift |= m_sdi;
- m_bits++;
-
- if (m_bits == 8)
- {
- if (LOG) logerror("MCCS1850 '%s' Data In %02x\n", tag(), m_shift);
-
- write_register(m_address & 0x7f, m_shift);
-
- m_bits = 0;
-
- // increment address counter
- m_address++;
- m_address |= 0x80;
- }
- }
- else if (!BIT(m_address, 7) && !m_sck && state)
- {
- // shift data out
- m_sdo = BIT(m_shift, 7);
- m_shift <<= 1;
- m_bits++;
-
- if (m_bits == 8)
- {
- m_bits = 0;
-
- // increment address counter
- m_address++;
- m_address &= 0x7f;
- m_shift = read_register(m_address & 0x7f);
- if (LOG) logerror("MCCS1850 '%s' Data Out %02x\n", tag(), m_shift);
- }
- }
- break;
- }
-
- m_sck = state;
-}
-
-
-//-------------------------------------------------
-// sdo_r - serial data out read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( mccs1850_device::sdo_r )
-{
- if (!m_ce || BIT(m_address, 7))
- {
- // Hi-Z
- return 1;
- }
- else
- {
- return m_sdo;
- }
-}
-
-
-//-------------------------------------------------
-// sdi_w - serial data in write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mccs1850_device::sdi_w )
-{
- m_sdi = state;
-}
-
-
-//-------------------------------------------------
-// pwrsw_w - power switch write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mccs1850_device::pwrsw_w )
-{
- if (!state)
- {
- if (m_pse)
- {
- // request to power down
- m_ram[REGISTER_STATUS] |= STATUS_RPD;
- check_interrupt();
- }
-
- set_pse_line(true);
- }
-}
-
-
-//-------------------------------------------------
-// por_w - power on reset write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mccs1850_device::por_w )
-{
- if (!state)
- {
- device_reset();
- }
-}
-
-
-//-------------------------------------------------
-// test_w - test mode write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mccs1850_device::test_w )
-{
- if (state)
- {
- if (LOG) logerror("MCCS1850 '%s' Test Mode\n", tag());
-
- m_ram[REGISTER_STATUS] |= STATUS_TM;
- }
- else
- {
- if (LOG) logerror("MCCS1850 '%s' Normal Operation\n", tag());
-
- m_ram[REGISTER_STATUS] &= ~STATUS_TM;
- }
-}
diff --git a/src/emu/machine/mccs1850.h b/src/emu/machine/mccs1850.h
deleted file mode 100644
index 933e67a5f8f..00000000000
--- a/src/emu/machine/mccs1850.h
+++ /dev/null
@@ -1,123 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Motorola MCCS1850 Serial Real-Time Clock emulation
-
-**********************************************************************
- _____ _____
- Vbat 1 |* \_/ | 16 Vdd
- _POR 2 | | 15 TEST
- _INT 3 | | 14 XTAL1
- SCK 4 | MCCS1850 | 13 XTAL2
- SDI 5 | | 12 _PWRSW
- SDO 6 | | 11 NUC
- CE 7 | | 10 _PSE
- Vss 8 |_____________| 9 PSE
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MCCS1850__
-#define __MCCS1850__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MCCS1850_INT_CALLBACK(_write) \
- devcb = &mccs1850_device::set_int_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MCCS1850_PSE_CALLBACK(_write) \
- devcb = &mccs1850_device::set_pse_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MCCS1850_NUC_CALLBACK(_write) \
- devcb = &mccs1850_device::set_nuc_wr_callback(*device, DEVCB_##_write);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mccs1850_device
-
-class mccs1850_device : public device_t,
- public device_rtc_interface,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- mccs1850_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_int_wr_callback(device_t &device, _Object object) { return downcast<mccs1850_device &>(device).int_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pse_wr_callback(device_t &device, _Object object) { return downcast<mccs1850_device &>(device).pse_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_nuc_wr_callback(device_t &device, _Object object) { return downcast<mccs1850_device &>(device).nuc_cb.set_callback(object); }
-
- DECLARE_WRITE_LINE_MEMBER( ce_w );
- DECLARE_WRITE_LINE_MEMBER( sck_w );
- DECLARE_READ_LINE_MEMBER( sdo_r );
- DECLARE_WRITE_LINE_MEMBER( sdi_w );
- DECLARE_WRITE_LINE_MEMBER( pwrsw_w );
- DECLARE_WRITE_LINE_MEMBER( por_w );
- DECLARE_WRITE_LINE_MEMBER( test_w );
-
- // For setting the time at startup
- void set_counter(UINT32 value);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
-private:
- inline void check_interrupt();
- inline void set_pse_line(bool state);
- inline UINT8 read_register(offs_t offset);
- inline void write_register(offs_t offset, UINT8 data);
- inline void advance_seconds();
-
- static const device_timer_id TIMER_CLOCK = 0;
-
- devcb_write_line int_cb, pse_cb, nuc_cb;
-
- UINT8 m_ram[0x80]; // RAM
-
- // power supply
- int m_pse; // power supply enable
-
- // counter
- UINT32 m_counter; // seconds counter
-
- // serial interface
- int m_ce; // chip enable
- int m_sck; // serial clock
- int m_sdo; // serial data out
- int m_sdi; // serial data in
- int m_state; // serial interface state
- UINT8 m_address; // address counter
- int m_bits; // bit counter
- UINT8 m_shift; // shift register
-
- // timers
- emu_timer *m_clock_timer;
-};
-
-
-// device type definition
-extern const device_type MCCS1850;
-
-
-
-#endif
diff --git a/src/emu/machine/mcf5206e.c b/src/emu/machine/mcf5206e.c
deleted file mode 100644
index d993c7235e4..00000000000
--- a/src/emu/machine/mcf5206e.c
+++ /dev/null
@@ -1,1118 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/* Modern device for the MCF5206e Peripherals
- this can be hooked properly to the CPU once the CPU is a modern device too
-*/
-
-#include "emu.h"
-#include "mcf5206e.h"
-
-static void CLIB_DECL ATTR_PRINTF(1,2) nolog(const char *format, ...) {}
-
-//#define debuglog printf
-#define debuglog logerror
-
-#define invalidlog printf
-//#define invalidlog logerror
-
-//#define debuglogtimer printf
-//#define debuglogtimer logerror
-#define debuglogtimer nolog
-
-static ADDRESS_MAP_START( coldfire_regs_map, AS_0, 32, mcf5206e_peripheral_device )
-
-
- AM_RANGE(0x014, 0x017) AM_READWRITE8(ICR1_ICR2_ICR3_ICR4_r, ICR1_ICR2_ICR3_ICR4_w, 0xffffffff)
-
- AM_RANGE(0x01c, 0x01f) AM_READWRITE8(ICR9_ICR10_ICR11_ICR12_r, ICR9_ICR10_ICR11_ICR12_w, 0xffffffff)
- AM_RANGE(0x020, 0x023) AM_READWRITE8(ICR13_r, ICR13_w, 0xffffffff)
-
- AM_RANGE(0x034, 0x037) AM_READWRITE16(IMR_r, IMR_w, 0xffffffff)
-
- /* Chip Select registers */
- AM_RANGE(0x064, 0x067) AM_READWRITE16(CSAR0_r, CSAR0_w, 0xffffffff)
- AM_RANGE(0x068, 0x06b) AM_READWRITE (CSMR0_r, CSMR0_w)
- AM_RANGE(0x06c, 0x06f) AM_READWRITE16(CSCR0_r, CSCR0_w, 0xffffffff)
- AM_RANGE(0x070, 0x073) AM_READWRITE16(CSAR1_r, CSAR1_w, 0xffffffff)
- AM_RANGE(0x074, 0x077) AM_READWRITE (CSMR1_r, CSMR1_w)
- AM_RANGE(0x078, 0x07b) AM_READWRITE16(CSCR1_r, CSCR1_w, 0xffffffff)
- AM_RANGE(0x07c, 0x07f) AM_READWRITE16(CSAR2_r, CSAR2_w, 0xffffffff)
- AM_RANGE(0x080, 0x083) AM_READWRITE (CSMR2_r, CSMR2_w)
- AM_RANGE(0x084, 0x087) AM_READWRITE16(CSCR2_r, CSCR2_w, 0xffffffff)
- AM_RANGE(0x088, 0x08b) AM_READWRITE16(CSAR3_r, CSAR3_w, 0xffffffff)
- AM_RANGE(0x08c, 0x08f) AM_READWRITE (CSMR3_r, CSMR3_w)
- AM_RANGE(0x090, 0x093) AM_READWRITE16(CSCR3_r, CSCR3_w, 0xffffffff)
- AM_RANGE(0x094, 0x097) AM_READWRITE16(CSAR4_r, CSAR4_w, 0xffffffff)
- AM_RANGE(0x098, 0x09b) AM_READWRITE (CSMR4_r, CSMR4_w)
- AM_RANGE(0x09c, 0x09f) AM_READWRITE16(CSCR4_r, CSCR4_w, 0xffffffff)
- AM_RANGE(0x0a0, 0x0a3) AM_READWRITE16(CSAR5_r, CSAR5_w, 0xffffffff)
- AM_RANGE(0x0a4, 0x0a7) AM_READWRITE (CSMR5_r, CSMR5_w)
- AM_RANGE(0x0a8, 0x0ab) AM_READWRITE16(CSCR5_r, CSCR5_w, 0xffffffff)
- AM_RANGE(0x0ac, 0x0af) AM_READWRITE16(CSAR6_r, CSAR6_w, 0xffffffff)
- AM_RANGE(0x0b0, 0x0b3) AM_READWRITE (CSMR6_r, CSMR6_w)
- AM_RANGE(0x0b4, 0x0b7) AM_READWRITE16(CSCR6_r, CSCR6_w, 0xffffffff)
- AM_RANGE(0x0b8, 0x0bb) AM_READWRITE16(CSAR7_r, CSAR7_w, 0xffffffff)
- AM_RANGE(0x0bc, 0x0bf) AM_READWRITE (CSMR7_r, CSMR7_w)
- AM_RANGE(0x0c0, 0x0c3) AM_READWRITE16(CSCR7_r, CSCR7_w, 0xffffffff)
-
- AM_RANGE(0x0c4, 0x0c7) AM_READWRITE16(DMCR_r, DMCR_w, 0xffffffff)
- AM_RANGE(0x0c8, 0x0cb) AM_READWRITE16(PAR_r, PAR_w, 0xffffffff)
-
- AM_RANGE(0x100, 0x103) AM_READWRITE16(TMR1_r, TMR1_w, 0xffffffff)
- AM_RANGE(0x104, 0x107) AM_READWRITE16(TRR1_r, TRR1_w, 0xffffffff)
- AM_RANGE(0x10c, 0x10f) AM_READWRITE16(TCN1_r, TCN1_w, 0xffffffff)
- AM_RANGE(0x110, 0x113) AM_READWRITE8(TER1_r, TER1_w, 0xffffffff)
-
-
- AM_RANGE(0x1c4, 0x1c7) AM_READWRITE8(PPDDR_r, PPDDR_w, 0xffffffff)
- AM_RANGE(0x1c8, 0x1cb) AM_READWRITE8(PPDAT_r, PPDAT_w, 0xffffffff)
-
- AM_RANGE(0x1e4, 0x1e7) AM_READWRITE8(MFDR_r, MFDR_w, 0xffffffff)
- AM_RANGE(0x1e8, 0x1eb) AM_READWRITE8(MBCR_r, MBCR_w, 0xffffffff)
- AM_RANGE(0x1ec, 0x1ef) AM_READWRITE8(MBSR_r, MBSR_w, 0xffffffff)
- AM_RANGE(0x1f0, 0x1f3) AM_READWRITE8(MBDR_r, MBDR_w, 0xffffffff)
-ADDRESS_MAP_END
-
-
-
-READ8_MEMBER( mcf5206e_peripheral_device::ICR1_ICR2_ICR3_ICR4_r )
-{
- switch (offset)
- {
- case 0: // 0x014
- debuglog("%s: (External IRQ1/IPL1 Interrupt Vector) ICR1_r\n", this->machine().describe_context());
- return m_ICR[ICR1];
- case 1: // 0x015
- debuglog("%s: (External IPL2 Interrupt Vector) ICR2_r\n", this->machine().describe_context());
- return m_ICR[ICR2];
- case 2: // 0x016
- debuglog("%s: (External IPL3 Interrupt Vector) ICR3_r\n", this->machine().describe_context());
- return m_ICR[ICR3];
- case 3: // 0x017
- debuglog("%s: (External IRQ4/IPL4 Interrupt Vector) ICR4_r\n", this->machine().describe_context());
- return m_ICR[ICR4];
- }
-
- return 0;
-}
-
-WRITE8_MEMBER( mcf5206e_peripheral_device::ICR1_ICR2_ICR3_ICR4_w )
-{
- switch (offset)
- {
- case 0: // 0x014
- m_ICR[ICR1] = data;
- debuglog("%s: (External IRQ1/IPL1 Interrupt Vector) ICR1_w %02x\n", this->machine().describe_context(), data);
- ICR_info(m_ICR[ICR1]);
- break;
- case 1: // 0x015
- m_ICR[ICR2] = data;
- debuglog("%s: (External IPL2 Interrupt Vector) ICR2_w %02x\n", this->machine().describe_context(), data);
- ICR_info(m_ICR[ICR2]);
- break;
- case 2: // 0x016
- m_ICR[ICR3] = data;
- debuglog("%s: (External IPL3 Interrupt Vector) ICR3_w %02x\n", this->machine().describe_context(), data);
- ICR_info(m_ICR[ICR3]);
- break;
- case 3: // 0x017
- m_ICR[ICR4] = data;
- debuglog("%s: (External IRQ4/IPL4 Interrupt Vector) ICR4_w %02x\n", this->machine().describe_context(), data);
- ICR_info(m_ICR[ICR4]);
- break;
- }
-}
-
-READ8_MEMBER( mcf5206e_peripheral_device::ICR9_ICR10_ICR11_ICR12_r )
-{
- switch (offset)
- {
- case 0: // 0x01c
- debuglog("%s: (Timer 1 Interrupt Vector) ICR9_r\n", this->machine().describe_context());
- return m_ICR[ICR9];
- case 1: // 0x01d
- debuglog("%s: (Timer 2 Interrupt Vector) ICR10_r\n", this->machine().describe_context());
- return m_ICR[ICR10];
- case 2: // 0x01e
- debuglog("%s: (MBUS Interrupt Vector) ICR11_r\n", this->machine().describe_context());
- return m_ICR[ICR11];
- case 3: // 0x01f
- debuglog("%s: (UART1 Interrupt Vector) ICR12_r\n", this->machine().describe_context());
- return m_ICR[ICR12];
- }
-
- return 0;
-}
-
-WRITE8_MEMBER( mcf5206e_peripheral_device::ICR9_ICR10_ICR11_ICR12_w )
-{
- switch (offset)
- {
- case 0: // 0x01c
- m_ICR[ICR9] = data;
- debuglog("%s: (Timer 1 Interrupt Vector) ICR9_w %02x\n", this->machine().describe_context(), data);
- ICR_info(m_ICR[ICR9]);
- break;
- case 1: // 0x01d
- m_ICR[ICR10] = data;
- debuglog("%s: (Timer 2 Interrupt Vector) ICR10_w %02x\n", this->machine().describe_context(), data);
- ICR_info(m_ICR[ICR10]);
- break;
- case 2: // 0x01e
- m_ICR[ICR11] = data;
- debuglog("%s: (MBUS Interrupt Vector) ICR11_w %02x\n", this->machine().describe_context(), data);
- ICR_info(m_ICR[ICR11]);
- break;
- case 3: // 0x01f
- m_ICR[ICR12] = data;
- debuglog("%s: (UART1 Interrupt Vector) ICR12_w %02x\n", this->machine().describe_context(), data);
- ICR_info(m_ICR[ICR12]);
- break;
- }
-}
-
-READ8_MEMBER( mcf5206e_peripheral_device::ICR13_r )
-{
- switch (offset)
- {
- case 0: // 0x020
- debuglog("%s: (UART2 Interrupt Vector) ICR13_r\n", this->machine().describe_context());
- return m_ICR[ICR13];
- case 1:
- case 2:
- case 3:
- invalidlog("%s: invalid ICR13_r %d\n", this->machine().describe_context(), offset);
- return 0;
- }
-
- return 0;
-}
-
-WRITE8_MEMBER( mcf5206e_peripheral_device::ICR13_w )
-{
- switch (offset)
- {
- case 0: // 0x020
- m_ICR[ICR13] = data;
- debuglog("%s: (UART2 Interrupt Vector) ICR13_w %02x\n", this->machine().describe_context(), data);
- ICR_info(m_ICR[ICR13]);
- break;
- case 1:
- case 2:
- case 3:
- invalidlog("%s: invalid ICR13_w %d, %02x\n", this->machine().describe_context(), offset, data);
- break;
- }
-}
-
-
-inline UINT16 mcf5206e_peripheral_device::CSAR_r(int which, int offset, UINT16 mem_mask)
-{
- if (offset==0)
- {
- debuglog("%s: CSAR%d_r\n", this->machine().describe_context(), which);
- return m_CSAR[which];
- }
- else
- {
- invalidlog("%s: invalid CSAR%d_r with offset %d\n", this->machine().describe_context(), which, offset);
- return 0;
- }
-}
-
-inline void mcf5206e_peripheral_device::CSAR_w(int which, int offset, UINT16 data, UINT16 mem_mask)
-{
- if (offset==0)
- {
- COMBINE_DATA( &m_CSAR[which] );
- debuglog("%s: CSAR%d_w %04x\n", this->machine().describe_context(), which, data);
- }
- else
- {
- invalidlog("%s: invalid CSAR%d_w with offset %d %04x\n", this->machine().describe_context(), which, offset, data);
- }
-}
-
-inline UINT32 mcf5206e_peripheral_device::CSMR_r(int which, UINT32 mem_mask)
-{
- debuglog("%s: CSMR%d_r\n", this->machine().describe_context(), which);
- return m_CSMR[0];
-}
-
-inline void mcf5206e_peripheral_device::CSMR_w(int which, UINT32 data, UINT32 mem_mask)
-{
- COMBINE_DATA( &m_CSMR[0] );
- debuglog("%s: CSMR%d_w %08x\n", this->machine().describe_context(), which, data);
-}
-
-inline UINT16 mcf5206e_peripheral_device::CSCR_r(int which, int offset, UINT16 mem_mask)
-{
- if (offset==1)
- {
- debuglog("%s: CSCR%d_r\n", this->machine().describe_context(), which);
- return m_CSCR[which];
- }
- else
- {
- invalidlog("%s: invalid CSCR%d_r with offset %d\n", this->machine().describe_context(), which, offset);
- return 0;
- }
-}
-
-inline void mcf5206e_peripheral_device::CSCR_w(int which, int offset, UINT16 data, UINT16 mem_mask)
-{
- if (offset==1)
- {
- COMBINE_DATA( &m_CSCR[which] );
- debuglog("%s: CSCR%d_w %04x\n", this->machine().describe_context(), which, data);
- }
- else
- {
- invalidlog("%s: invalid CSCR%d_r with offset %d %04x\n", this->machine().describe_context(), which, offset, data);
- }
-}
-
-
-
-
-READ16_MEMBER( mcf5206e_peripheral_device::CSAR0_r) { return CSAR_r(0, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSAR0_w) { CSAR_w(0, offset, data, mem_mask); }
-READ32_MEMBER( mcf5206e_peripheral_device::CSMR0_r) { return CSMR_r(0, mem_mask); }
-WRITE32_MEMBER( mcf5206e_peripheral_device::CSMR0_w) { CSMR_w(0, data, mem_mask); }
-READ16_MEMBER( mcf5206e_peripheral_device::CSCR0_r) { return CSCR_r(0, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSCR0_w) { CSCR_w(0, offset, data, mem_mask); }
-
-READ16_MEMBER( mcf5206e_peripheral_device::CSAR1_r) { return CSAR_r(1, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSAR1_w) { CSAR_w(1, offset, data, mem_mask); }
-READ32_MEMBER( mcf5206e_peripheral_device::CSMR1_r) { return CSMR_r(1, mem_mask); }
-WRITE32_MEMBER( mcf5206e_peripheral_device::CSMR1_w) { CSMR_w(1, data, mem_mask); }
-READ16_MEMBER( mcf5206e_peripheral_device::CSCR1_r) { return CSCR_r(1, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSCR1_w) { CSCR_w(1, offset, data, mem_mask); }
-
-READ16_MEMBER( mcf5206e_peripheral_device::CSAR2_r) { return CSAR_r(2, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSAR2_w) { CSAR_w(2, offset, data, mem_mask); }
-READ32_MEMBER( mcf5206e_peripheral_device::CSMR2_r) { return CSMR_r(2, mem_mask); }
-WRITE32_MEMBER( mcf5206e_peripheral_device::CSMR2_w) { CSMR_w(2, data, mem_mask); }
-READ16_MEMBER( mcf5206e_peripheral_device::CSCR2_r) { return CSCR_r(2, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSCR2_w) { CSCR_w(2, offset, data, mem_mask); }
-
-READ16_MEMBER( mcf5206e_peripheral_device::CSAR3_r) { return CSAR_r(3, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSAR3_w) { CSAR_w(3, offset, data, mem_mask); }
-READ32_MEMBER( mcf5206e_peripheral_device::CSMR3_r) { return CSMR_r(3, mem_mask); }
-WRITE32_MEMBER( mcf5206e_peripheral_device::CSMR3_w) { CSMR_w(3, data, mem_mask); }
-READ16_MEMBER( mcf5206e_peripheral_device::CSCR3_r) { return CSCR_r(3, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSCR3_w) { CSCR_w(3, offset, data, mem_mask); }
-
-READ16_MEMBER( mcf5206e_peripheral_device::CSAR4_r) { return CSAR_r(4, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSAR4_w) { CSAR_w(4, offset, data, mem_mask); }
-READ32_MEMBER( mcf5206e_peripheral_device::CSMR4_r) { return CSMR_r(4, mem_mask); }
-WRITE32_MEMBER( mcf5206e_peripheral_device::CSMR4_w) { CSMR_w(4, data, mem_mask); }
-READ16_MEMBER( mcf5206e_peripheral_device::CSCR4_r) { return CSCR_r(4, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSCR4_w) { CSCR_w(4, offset, data, mem_mask); }
-
-READ16_MEMBER( mcf5206e_peripheral_device::CSAR5_r) { return CSAR_r(5, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSAR5_w) { CSAR_w(5, offset, data, mem_mask); }
-READ32_MEMBER( mcf5206e_peripheral_device::CSMR5_r) { return CSMR_r(5, mem_mask); }
-WRITE32_MEMBER( mcf5206e_peripheral_device::CSMR5_w) { CSMR_w(5, data, mem_mask); }
-READ16_MEMBER( mcf5206e_peripheral_device::CSCR5_r) { return CSCR_r(5, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSCR5_w) { CSCR_w(5, offset, data, mem_mask); }
-
-READ16_MEMBER( mcf5206e_peripheral_device::CSAR6_r) { return CSAR_r(6, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSAR6_w) { CSAR_w(6, offset, data, mem_mask); }
-READ32_MEMBER( mcf5206e_peripheral_device::CSMR6_r) { return CSMR_r(6, mem_mask); }
-WRITE32_MEMBER( mcf5206e_peripheral_device::CSMR6_w) { CSMR_w(6, data, mem_mask); }
-READ16_MEMBER( mcf5206e_peripheral_device::CSCR6_r) { return CSCR_r(6, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSCR6_w) { CSCR_w(6, offset, data, mem_mask); }
-
-READ16_MEMBER( mcf5206e_peripheral_device::CSAR7_r) { return CSAR_r(7, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSAR7_w) { CSAR_w(7, offset, data, mem_mask); }
-READ32_MEMBER( mcf5206e_peripheral_device::CSMR7_r) { return CSMR_r(7, mem_mask); }
-WRITE32_MEMBER( mcf5206e_peripheral_device::CSMR7_w) { CSMR_w(7, data, mem_mask); }
-READ16_MEMBER( mcf5206e_peripheral_device::CSCR7_r) { return CSCR_r(7, offset, mem_mask); }
-WRITE16_MEMBER( mcf5206e_peripheral_device::CSCR7_w) { CSCR_w(7, offset, data, mem_mask); }
-
-
-READ16_MEMBER( mcf5206e_peripheral_device::DMCR_r)
-{
- switch (offset)
- {
- case 1:
- debuglog("%s: DMCR_r %04x\n", this->machine().describe_context(), mem_mask);
- return m_DMCR;
- case 0:
- invalidlog("%s: invalid DMCR_r %d %04x\n", this->machine().describe_context(), offset, mem_mask);
- return 0;
- }
-
- return 0;
-}
-
-WRITE16_MEMBER( mcf5206e_peripheral_device::DMCR_w)
-{
- switch (offset)
- {
- case 1:
- COMBINE_DATA(&m_DMCR);
- debuglog("%s: DMCR_w %04x %04x\n", this->machine().describe_context(), data, mem_mask);
- break;
- case 0:
- invalidlog("%s: invalid DMCR_w %d, %04x %04x\n", this->machine().describe_context(), offset, data, mem_mask);
- break;
-
- }
-}
-
-
-READ16_MEMBER( mcf5206e_peripheral_device::PAR_r)
-{
- switch (offset)
- {
- case 1:
- debuglog("%s: PAR_r %04x\n", this->machine().describe_context(), mem_mask);
- return m_PAR;
- case 0:
- invalidlog("%s: invalid PAR_r %d %04x\n", this->machine().describe_context(), offset, mem_mask);
- return 0;
- }
-
- return 0;
-}
-
-WRITE16_MEMBER( mcf5206e_peripheral_device::PAR_w)
-{
- switch (offset)
- {
- case 1:
- COMBINE_DATA(&m_PAR);
- debuglog("%s: PAR_w %04x %04x\n", this->machine().describe_context(), data, mem_mask);
- break;
- case 0:
- invalidlog("%s: invalid PAR_w %d, %04x %04x\n", this->machine().describe_context(), offset, data, mem_mask);
- break;
-
- }
-}
-
-
-
-READ8_MEMBER( mcf5206e_peripheral_device::PPDDR_r)
-{
- switch (offset)
- {
- case 0:
- case 2:
- case 3:
- invalidlog("%s: invalid PPDDR_r %d\n", this->machine().describe_context(), offset);
- return 0;
- case 1: // '$1C5'
- debuglog("%s: (Port A Data Direction Register) PPDDR_r\n", this->machine().describe_context());
- return m_PPDDR;
- }
-
- return 0;
-}
-
-WRITE8_MEMBER( mcf5206e_peripheral_device::PPDDR_w)
-{
- switch (offset)
- {
- case 0:
- case 2:
- case 3:
- invalidlog("%s: invalid PPDDR_w %d %02x\n", this->machine().describe_context(), offset, data);
- break;
- case 1: // '$1C5'
- m_PPDDR = data;
- debuglog("%s: (Port A Data Direction Register) PPDDR_w %02x\n", this->machine().describe_context(), data);
- break;
- }
-}
-
-READ8_MEMBER( mcf5206e_peripheral_device::PPDAT_r)
-{
- switch (offset)
- {
- case 0:
- case 2:
- case 3:
- invalidlog("%s: invalid PPDAT_r %d\n", this->machine().describe_context(), offset);
- return 0;
- case 1: // '$1C9'
- debuglog("%s: (Port A Data Register) PPDAT_r\n", this->machine().describe_context());
- return m_PPDAT; // should use a callback.
- }
-
- return 0;
-}
-
-WRITE8_MEMBER( mcf5206e_peripheral_device::PPDAT_w)
-{
- switch (offset)
- {
- case 0:
- case 2:
- case 3:
- invalidlog("%s: invalid PPDAT_w %d, %02x\n", this->machine().describe_context(), offset, data);
- break;
- case 1: // '$1C9'
- m_PPDAT = data; // should use a callback.
- debuglog("%s: (Port A Data Register) PPDAT_w %02x\n", this->machine().describe_context(), data);
- break;
- }
-
-}
-
-
-READ8_MEMBER( mcf5206e_peripheral_device::MBCR_r)
-{
- switch (offset)
- {
- case 0:
- debuglog("%s: (M-Bus Control Register) MBCR_r\n", this->machine().describe_context());
- return m_MBCR;
- case 1:
- case 2:
- case 3:
- invalidlog("%s: invalid MBCR_r %d\n", this->machine().describe_context(), offset);
- return 0;
- }
-
- return 0;
-}
-
-WRITE8_MEMBER( mcf5206e_peripheral_device::MBCR_w)
-{
- switch (offset)
- {
- case 0:
- m_MBCR = data;
- debuglog("%s: (M-Bus Control Register) MBCR_w %02x\n", this->machine().describe_context(), data);
- break;
- case 1:
- case 2:
- case 3:
- invalidlog("%s: invalid MBCR_w %d, %02x\n", this->machine().describe_context(), offset, data);
- break;
-
- }
-}
-
-READ8_MEMBER( mcf5206e_peripheral_device::MFDR_r)
-{
- switch (offset)
- {
- case 0:
- debuglog("%s: (M-Bus Frequency Divider Register) MFDR_r\n", this->machine().describe_context());
- return m_MFDR;
- case 1:
- case 2:
- case 3:
- invalidlog("%s: invalid MFDR_r %d\n", this->machine().describe_context(), offset);
- return 0;
- }
-
- return 0;
-}
-
-WRITE8_MEMBER( mcf5206e_peripheral_device::MFDR_w)
-{
- switch (offset)
- {
- case 0:
- m_MFDR = data;
- debuglog("%s: (M-Bus Frequency Divider Register) MFDR_w %02x\n", this->machine().describe_context(), data);
- break;
- case 1:
- case 2:
- case 3:
- invalidlog("%s: invalid MFDR_w %d, %02x\n", this->machine().describe_context(), offset, data);
- break;
-
- }
-}
-
-
-
-
-
-
-READ8_MEMBER( mcf5206e_peripheral_device::MBSR_r)
-{
- int hack = 0x00;
-
- switch (offset)
- {
- case 0:
- {
- hack ^= (machine().rand()&0xff);
- debuglog("%s: (M-Bus Status Register) MBSR_r\n", this->machine().describe_context());
- return m_MBSR ^ hack; // will loop on this after a while
- }
- case 1:
- case 2:
- case 3:
- invalidlog("%s: invalid MBSR_r %d\n", this->machine().describe_context(), offset);
- return 0;
- }
-
- return 0;
-}
-
-WRITE8_MEMBER( mcf5206e_peripheral_device::MBSR_w)
-{
- switch (offset)
- {
- case 0:
- m_MBSR = data;
- debuglog("%s: (M-Bus Status Register) MBSR_w %02x\n", this->machine().describe_context(), data);
- break;
- case 1:
- case 2:
- case 3:
- invalidlog("%s: invalid MBSR_w %d, %02x\n", this->machine().describe_context(), offset, data);
- break;
-
- }
-}
-
-
-
-
-READ8_MEMBER( mcf5206e_peripheral_device::MBDR_r)
-{
- int hack = 0x00;
-
- switch (offset)
- {
- case 0:
- {
- hack ^= (machine().rand()&0xff);
- debuglog("%s: (M-Bus Data I/O Register) MBDR_r\n", this->machine().describe_context());
- return m_MBDR ^ hack;
- }
- case 1:
- case 2:
- case 3:
- invalidlog("%s: invalid MBDR_r %d\n", this->machine().describe_context(), offset);
- return 0;
- }
-
- return 0;
-}
-
-WRITE8_MEMBER( mcf5206e_peripheral_device::MBDR_w)
-{
- switch (offset)
- {
- case 0:
- m_MBDR = data;
- debuglog("%s: (M-Bus Data I/O Register) MBDR_w %02x\n", this->machine().describe_context(), data);
- break;
- case 1:
- case 2:
- case 3:
- invalidlog("%s: invalid MBDR_w %d, %02x\n", this->machine().describe_context(), offset, data);
- break;
-
- }
-}
-
-
-
-READ16_MEMBER( mcf5206e_peripheral_device::IMR_r)
-{
- switch (offset)
- {
- case 1:
- debuglog("%s: (Interrupt Mask Register) IMR_r %04x\n", this->machine().describe_context(), mem_mask);
- return m_IMR;
- case 0:
- invalidlog("%s: invalid IMR_r %d %04x\n", this->machine().describe_context(), offset, mem_mask);
- return 0;
- }
-
- return 0;
-}
-
-WRITE16_MEMBER( mcf5206e_peripheral_device::IMR_w)
-{
- switch (offset)
- {
- case 1:
- COMBINE_DATA(&m_IMR);
- debuglog("%s: (Interrupt Mask Register) IMR_w %04x %04x\n", this->machine().describe_context(), data, mem_mask);
- break;
- case 0:
- invalidlog("%s: invalid IMR_w %d, %04x %04x\n", this->machine().describe_context(), offset, data, mem_mask);
- break;
-
- }
-}
-
-void mcf5206e_peripheral_device::ICR_info(UINT8 ICR)
-{
- debuglog(" (AutoVector) AVEC : %01x | ", (ICR&0x80)>>7);
- debuglog("(Interrupt Level) IL : %01x | ", (ICR&0x1c)>>2); // if autovector (AVEC) is used then the vectors referenced are at +24 (+0x18) + IL, ie the standard 68k autovectors, otherwise vector must be provided by device
- debuglog("(Interrupt Priority) IP : %01x |", (ICR&0x03)>>0);
- debuglog("(Unused bits) : %01x\n", (ICR&0x60)>>5);
-}
-
-
-
-TIMER_CALLBACK_MEMBER(mcf5206e_peripheral_device::timer1_callback)
-{
- UINT8 ICR = m_ICR[ICR9];
-
- // technically we should do the vector check in the IRQ callback as well as various checks based on the IRQ masks before asserting the interrupt
- if (ICR & 0x80) // AVEC
- {
- if (!(m_IMR & 0x0200)) m_cpu->set_input_line((ICR&0x1c)>>2, HOLD_LINE);
- }
-
- debuglogtimer("timer1_callback\n");
- m_TER1 |= 0x02;
-
- m_timer1->adjust(attotime::from_msec(10)); // completely made up value just to fire our timers for now
-}
-
-
-READ16_MEMBER( mcf5206e_peripheral_device::TMR1_r)
-{
- switch (offset)
- {
- case 0:
- debuglogtimer("%s: (Timer 1 Mode Register) TMR1_r %04x\n", this->machine().describe_context(), mem_mask);
- return m_TMR1;
- case 1:
- invalidlog("%s: invalid TMR1_r %d %04x\n", this->machine().describe_context(), offset, mem_mask);
- return 0;
- }
-
- return 0;
-}
-
-WRITE16_MEMBER( mcf5206e_peripheral_device::TMR1_w)
-{
- switch (offset)
- {
- case 0:
- COMBINE_DATA(&m_TMR1);
- debuglogtimer("%s: (Timer 1 Mode Register) TMR1_w %04x %04x\n", this->machine().describe_context(), data, mem_mask);
-
- debuglogtimer(" (Prescale) PS : %02x (Capture Edge/Interrupt) CE : %01x (Output Mode) OM : %01x (Output Reference Interrupt En) ORI : %01x Free Run (FRR) : %01x Input Clock Source (ICLK) : %01x (Reset Timer) RST : %01x \n", (m_TMR1 & 0xff00)>>8, (m_TMR1 & 0x00c0)>>6, (m_TMR1 & 0x0020)>>5, (m_TMR1 & 0x0010)>>4, (m_TMR1 & 0x0008)>>3, (m_TMR1 & 0x0006)>>1, (m_TMR1 & 0x0001)>>0);
-
- if (m_TMR1 & 0x0001)
- {
- m_timer1->adjust(attotime::from_seconds(1)); // completely made up value just to fire our timers for now
- }
- else
- {
- m_timer1->adjust(attotime::never);
- }
-
-
- break;
- case 1:
- invalidlog("%s: invalid TMR1_w %d, %04x %04x\n", this->machine().describe_context(), offset, data, mem_mask);
- break;
-
- }
-}
-
-READ16_MEMBER( mcf5206e_peripheral_device::TRR1_r)
-{
- switch (offset)
- {
- case 0:
- debuglogtimer("%s: (Timer 1 Reference Register) TRR1_r %04x\n", this->machine().describe_context(), mem_mask);
- return m_TRR1;
- case 1:
- invalidlog("%s: invalid TRR1_r %d %04x\n", this->machine().describe_context(), offset, mem_mask);
- return 0;
- }
-
- return 0;
-}
-
-WRITE16_MEMBER( mcf5206e_peripheral_device::TRR1_w)
-{
- switch (offset)
- {
- case 0:
- COMBINE_DATA(&m_TRR1);
- debuglogtimer("%s: (Timer 1 Reference Register) TRR1_w %04x %04x\n", this->machine().describe_context(), data, mem_mask);
- break;
- case 1:
- debuglog("%s: invalid TRR1_w %d, %04x %04x\n", this->machine().describe_context(), offset, data, mem_mask);
- break;
-
- }
-}
-
-
-
-READ8_MEMBER( mcf5206e_peripheral_device::TER1_r)
-{
- switch (offset)
- {
- case 1:
- debuglogtimer("%s: TER1_r\n", this->machine().describe_context());
- return m_TER1; // set on timer events, cleared by writing below
- case 0:
- case 2:
- case 3:
- invalidlog("%s: invalid TER1_r %d\n", this->machine().describe_context(), offset);
- return 0;
- }
-
- return 0;
-}
-
-WRITE8_MEMBER( mcf5206e_peripheral_device::TER1_w)
-{
- switch (offset)
- {
- case 1:
- m_TER1 &= ~data; // writes should clear the bits..
- debuglogtimer("%s: TER1_w %02x\n", this->machine().describe_context(), data);
- break;
- case 0:
- case 2:
- case 3:
- invalidlog("%s: invalid TER1_w %d, %02x\n", this->machine().describe_context(), offset, data);
- break;
-
- }
-}
-
-READ16_MEMBER( mcf5206e_peripheral_device::TCN1_r)
-{
- switch (offset)
- {
- case 0:
- debuglogtimer("%s: (Timer 1 Counter) TCN1_r %04x\n", this->machine().describe_context(), mem_mask);
- // return 0x9c40;
- return 0x8ca0 -1;// m_TCN1; // this should be the counter, code has a hardcoded >= check against 8ca0.
- case 1:
- invalidlog("%s: invalid TCN1_r %d %04x\n", this->machine().describe_context(), offset, mem_mask);
- return 0;
- }
-
- return 0;
-}
-
-WRITE16_MEMBER( mcf5206e_peripheral_device::TCN1_w)
-{
- switch (offset)
- {
- case 0:
- COMBINE_DATA(&m_TCN1);
- debuglogtimer("%s: (Timer 1 Counter) TCN1_w %04x %04x\n", this->machine().describe_context(), data, mem_mask);
- break;
- case 1:
- invalidlog("%s: invalid TCN1_w %d, %04x %04x\n", this->machine().describe_context(), offset, data, mem_mask);
- break;
-
- }
-}
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type MCF5206E_PERIPHERAL = &device_creator<mcf5206e_peripheral_device>;
-
-//-------------------------------------------------
-// mcf5206e_peripheral_device - constructor
-//-------------------------------------------------
-
-mcf5206e_peripheral_device::mcf5206e_peripheral_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MCF5206E_PERIPHERAL, "MCF5206E Peripheral", tag, owner, clock, "mcf5206e_peripheral", __FILE__),
- device_memory_interface(mconfig, *this),
- m_space_config("coldfire_regs", ENDIANNESS_BIG, 32,10, 0, NULL, *ADDRESS_MAP_NAME(coldfire_regs_map))
-
-{
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void mcf5206e_peripheral_device::device_config_complete()
-{
-}
-
-const address_space_config *mcf5206e_peripheral_device::memory_space_config(address_spacenum spacenum) const
-{
- return (spacenum == AS_0) ? &m_space_config : NULL;
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mcf5206e_peripheral_device::device_start()
-{
- init_regs(true);
-
- m_timer1 = machine().scheduler().timer_alloc( timer_expired_delegate( FUNC( mcf5206e_peripheral_device::timer1_callback ), this) );
-
- save_item(NAME(m_ICR));
- save_item(NAME(m_CSAR));
- save_item(NAME(m_CSMR));
- save_item(NAME(m_CSCR));
- save_item(NAME(m_DMCR));
- save_item(NAME(m_PAR));
- save_item(NAME(m_TMR1));
- save_item(NAME(m_TRR1));
- save_item(NAME(m_TER1));
- save_item(NAME(m_TCN1));
- save_item(NAME(m_PPDDR));
- save_item(NAME(m_PPDAT));
- save_item(NAME(m_IMR));
- save_item(NAME(m_MBCR));
- save_item(NAME(m_MBSR));
- save_item(NAME(m_MFDR));
- save_item(NAME(m_MBDR));
- save_item(NAME(m_coldfire_regs));
-}
-
-void mcf5206e_peripheral_device::device_reset()
-{
- m_cpu = (cpu_device*)machine().device(":maincpu"); // hack. this device should really be attached to a modern CPU core
-
- init_regs(false);
- m_timer1->adjust(attotime::never);
-}
-
-READ32_MEMBER(mcf5206e_peripheral_device::dev_r)
-{
- address_space &reg_space = this->space();
- return reg_space.read_dword(offset*4, mem_mask);
-}
-
-WRITE32_MEMBER(mcf5206e_peripheral_device::dev_w)
-{
- address_space &reg_space = this->space();
- reg_space.write_dword(offset*4, data, mem_mask);
-}
-
-
-// ColdFire peripherals
-
-enum {
- CF_PPDAT = 0x1c8/4,
- CF_MBSR = 0x1ec/4
-};
-
-WRITE32_MEMBER(mcf5206e_peripheral_device::seta2_coldfire_regs_w)
-{
- COMBINE_DATA( &m_coldfire_regs[offset] );
-}
-
-READ32_MEMBER(mcf5206e_peripheral_device::seta2_coldfire_regs_r)
-{
- switch( offset )
- {
- case CF_MBSR:
- return machine().rand();
-
- case CF_PPDAT:
- return ioport(":BATTERY")->read() << 16;
- }
-
- return m_coldfire_regs[offset];
-}
-
-#define UNINIT 0
-#define UNINIT_NOTE 0
-
-void mcf5206e_peripheral_device::init_regs(bool first_init)
-{
- m_ICR[ICR1] = 0x04;
- m_ICR[ICR2] = 0x08;
- m_ICR[ICR3] = 0x0C;
- m_ICR[ICR4] = 0x10;
- m_ICR[ICR5] = 0x14;
- m_ICR[ICR6] = 0x18;
- m_ICR[ICR7] = 0x1C;
- m_ICR[ICR8] = 0x1C;
- m_ICR[ICR9] = 0x80;
- m_ICR[ICR10] = 0x80;
- m_ICR[ICR11] = 0x80;
- m_ICR[ICR12] = 0x00;
- m_ICR[ICR13] = 0x00;
-
- m_CSAR[0] = 0x0000;
- m_CSMR[0] = 0x00000000;
- m_CSCR[0] = 0x3C1F; /* 3C1F, 3C5F, 3C9F, 3CDF, 3D1F, 3D5F, 3D9F, 3DDF | AA set by IRQ 7 at reset, PS1 set by IRQ 4 at reset, PS0 set by IRQ 1 at reset*/
-
- if (first_init)
- {
- for (int x=1;x<8;x++)
- {
- m_CSAR[1] = UNINIT;
- m_CSMR[1] = UNINIT;
- m_CSCR[1] = UNINIT_NOTE; // except BRST=ASET=WRAH=RDAH=WR=RD=0
- }
- }
-
- m_DMCR = 0x0000;
- m_PAR = 0x0000;
-
- m_TMR1 = 0x0000;
- m_TRR1 = 0xffff;
- m_TER1 = 0x00;
- m_TCN1 = 0x0000;
-
- m_PPDDR = 0x00;
- m_PPDAT = 0x00;
-
- m_IMR = 0x3FFE;
-
- m_MFDR = 0x00;
- m_MBCR = 0x00;
- m_MBSR = 0x00;
- m_MBDR = 0x00;
-}
-
-/*
-
-ADDRESS (LE) REG WIDTH NAME/DESCRIPTION INIT VALUE (MR=Master Reset, NR=Normal Reset) Read or Write access
-* = inited
-- = skeleton handler
-
-op MOVEC with $C0F MBAR 32 Module Base Address Register uninit (except V=0) W
-$003 SIMR 8 SIM Configuration Register C0 R/W
-$014*- ICR1 8 Interrupt Control Register 1 - External IRQ1/IPL1 04 R/W
-$015*- ICR2 8 Interrupt Control Register 2 - External IPL2 08 R/W
-$016*- ICR3 8 Interrupt Control Register 3 - External IPL3 0C R/W
-$017*- ICR4 8 Interrupt Control Register 4 - External IRQ4/IPL4 10 R/W
-$018* ICR5 8 Interrupt Control Register 5 - External IPL5 14 R/W
-$019* ICR6 8 Interrupt Control Register 6 - External IPL6 18 R/W
-$01A* ICR7 8 Interrupt Control Register 7 - External IRQ7/IPL7 1C R/W
-$01B* ICR8 8 Interrupt Control Register 8 - SWT 1C R/W
-$01C*- ICR9 8 Interrupt Control Register 9 - Timer 1 Interrupt 80 R/W
-$01D*- ICR10 8 Interrupt Control Register 10 - Timer 2 Interrupt 80 R/W
-$01E*- ICR11 8 Interrupt Control Register 11 - MBUS Interrupt 80 R/W
-$01F*- ICR12 8 Interrupt Control Register 12 - UART 1 Interrupt 00 R/W
-$020*- ICR13 8 Interrupt Control Register 13 - UART 2 Interrupt 00 R/W
-$036*- IMR 16 Interrupt Mask Register 3FFE R/W
-$03A IPR 16 Interrupt Pending Register 0000 R
-$040 RSR 8 Reset Status Register 80 / 20 R/W
-$041 SYPCR 8 System Protection Control Register 00 R/W
-$042 SWIVR 8 Software Watchdog Interrupt Vector Register 0F R/W
-$043 SWSR 8 Software Watchdog Service Register uninit W
-$046 DCRR 16 DRAM Controller Refresh MR 0000 - NR uninit R/W
-$04A DCTR 16 DRAM Controller Timing Register MR 0000 - NR uninit R/W
-$04C DCAR0 16 DRAM Controller 0 Address Register MR uninit - NR uninit R/W
-$050 DCMR0 32 DRAM Controller 0 Mask Register MR uninit - NR uninit R/W
-$057 DCCR0 8 DRAM Controller 0 Control Register MR 00 - NR 00 R/W
-$058 DCAR1 16 DRAM Controller 1 Address Register MR uninit - NR uninit R/W
-$05C DCMR1 32 DRAM Controller 1 Mask Register MR uninit - NR uninit R/W
-$063 DCCR1 8 DRAM Controller 1 Control Register MR 00 - NR 00 R/W
---------- CHIP SELECTS -----------
-$064*- CSAR0 16 Chip-Select 0 Address Register 0000 R/W
-$068*- CSMR0 32 Chip-Select 0 Mask Register 00000000 R/W
-$06E*- CSCR0 16 Chip-Select 0 Control Register 3C1F, 3C5F, 3C9F, 3CDF, 3D1F, 3D5F, 3D9F, 3DDF R/W
- AA set by IRQ 7 at reset
- PS1 set by IRQ 4 at reset
- PS0 set by IRQ 1 at reset
-$070*- CSAR1 16 Chip-Select 1 Address Register uninit R/W
-$074*- CSMR1 32 Chip-Select 1 Mask Register uninit R/W
-$07A*- CSCR1 16 Chip-Select 1 Control Register uninit *1 R/W
-$07C*- CSAR2 16 Chip-Select 2 Address Register uninit R/W
-$080*- CSMR2 32 Chip-Select 2 Mask Register uninit R/W
-$086*- CSCR2 16 Chip-Select 2 Control Register uninit *1 R/W
-$088*- CSAR3 16 Chip-Select 3 Address Register uninit R/W
-$08C*- CSMR3 32 Chip-Select 3 Mask Register uninit R/W
-$092*- CSCR3 16 Chip-Select 3 Control Register uninit *1 R/W
-$094*- CSAR4 16 Chip-Select 4 Address Register uninit R/W
-$098*- CSMR4 32 Chip-Select 4 Mask Register uninit R/W
-$09E*- CSCR4 16 Chip-Select 4 Control Register uninit *1 R/W
-$0A0*- CSAR5 16 Chip-Select 5 Address Register uninit R/W
-$0A4*- CSMR5 32 Chip-Select 5 Mask Register uninit R/W
-$0AA*- CSCR5 16 Chip-Select 5 Control Register uninit *1 R/W
-$0AC*- CSAR6 16 Chip-Select 6 Address Register uninit R/W
-$0B0*- CSMR6 32 Chip-Select 6 Mask Register uninit R/W
-$0B6*- CSCR6 16 Chip-Select 6 Control Register uninit *1 R/W
-$0B8*- CSAR7 16 Chip-Select 7 Address Register uninit R/W
-$0BC*- CSMR7 32 Chip-Select 7 Mask Register uninit R/W
-$0C2*- CSCR7 16 Chip-Select 7 Control Register uninit *1 R/W
-$0C6*- DMCR 16 Default Memory Control Register 0000 R/W
-$0CA*- PAR 16 Pin Assignment Register 00 R/W
---------- TIMER MODULE -----------
-$100*- TMR1 16 Timer 1 Mode Register 0000 R/W
-$104*- TRR1 16 Timer 1 Reference Register FFFF R/W
-$108 TCR1 16 Timer 1 Capture Register 0000 R
-$10C*- TCN1 16 Timer 1 Counter 0000 R/W
-$111*- TER1 8 Timer 1 Event Register 00 R/W
-$120 TMR2 16 Timer 2 Mode Register 0000 R/W
-$124 TRR2 16 Timer 2 Reference Register FFFF R/W
-$128 TCR2 16 Timer 2 Capture Register 0000 R
-$12C TCN2 16 Timer 2 Counter 0000 R/W
-$131 TER2 8 Timer 2 Event Register 00 R/W
------------- UART SERIAL PORTS -----------
-$140 UMR1,2 8 UART 1 Mode Registers 00 R/W
-$144 USR 8 UART 1 Status Register 00 R
- UCSR 8 UART 1 Clock-Select Register DD W
-$148 UCR 8 UART 1 Command Register 00 W
-$14C URB 8 UART 1 Receive Buffer FF R
- UTB 8 UART 1 Transmit Buffer 00 W
-$150 UIPCR 8 UART Input Port Change Register 0F R
- UACR 8 UART 1 Auxilary Control Register 00 W
-$154 UISR 8 UART 1 Interrupt Status Register 00 R
- UIMR 8 UART 1 Interrupt Mask Register 00 W
-$158 UBG1 8 UART 1 Baud Rate Generator Prescale MSB uninit W
-$15C UBG2 8 UART 1 Baud Rate Generator Prescale LSB uninit W
-$170 UIVR 8 UART 1 Interrupt Vector Register 0F R/W
-$174 UIP 8 UART 1 Input Port Register FF R
-$178 UOP1 8 UART 1 Output Port Bit Set CMD UOP1[7-1]=undef; UOP1=0 W
-$17C UOP0 8 UART 1 Output Port Bit Reset CMD uninit W
-
-$180 UMR1,2 8 UART 2 Mode Registers 00 R/W
-$184 USR 8 UART 2 Status Register 00 R
- UCSR 8 UART 2 Clock-Select Register DD W
-$188 UCR 8 UART 2 Command Register 00 W
-$18C URB 8 UART 2 Receive Buffer FF R
- UTB 8 UART 2 Transmit Buffer 00 W
-$190 UIPCR 8 UART 2 Input Port Change Register 0F R
- UACR 8 UART 2 Auxilary Control Register 00 W
-$194 UISR 8 UART 2 Interrupt Status Register 00 R
- UIMR 8 UART 2 Interrupt Mask Register 00 W
-$198 UBG1 8 UART 2 Baud Rate Generator Prescale MSB uninit R/W
-$19C UBG2 8 UART 2 Barud Rate Generator Prescale LSB uninit R/W
-$1B0 UIVR 8 UART 2 Interrupt Vector Register 0F R/W
-$1B4 UIP 8 UART 2 Input Port Register FF R
-$1B8 UOP1 8 UART 2 Output Port Bit Set CMD UOP1[7-1]=undef; UOP1=0 W
-$1BC UOP0 8 UART 2 Output Port Bit Reset CMD uninit W
-
-$1C5*- PPDDR 8 Port A Data Direction Register 00 R/W
-$1C9*- PPDAT 8 Port A Data Register 00 R/W
------------- MBUS -----------
-$1E0 MADR 8 M-Bus Address Register 00 R/W
-$1E4*- MFDR 8 M-Bus Frequency Divider Register 00 R/W
-$1E8*- MBCR 8 M-Bus Control Register 00 R/W
-$1EC*- MBSR 8 M-Bus Status Register 00 R/W
-$1F0*- MBDR 8 M-Bus Data I/O Register 00 R/W
------------- DMA Controller -----------
-$200 DMASAR0 32 Source Address Register 0 00 R/W
-$204 DMADAR0 32 Destination Address Register 0 00 R/W
-$208 DCR0 16 DMA Control Register 0 00 R/W
-$20C BCR0 16 Byte Count Register 0 00 R/W
-$210 DSR0 8 Status Register 0 00 R/W
-$214 DIVR0 8 Interrupt Vector Register 0 0F R/W
-$240 DMASAR1 32 Source Address Register 1 00 R/W
-$244 DMADAR1 32 Destination Address Register 1 00 R/W
-$248 DCR1 16 DMA Control Register 1 00 R/W
-$24C BCR1 16 Byte Count Register 1 00 R/W
-$250 DSR1 8 Status Register 1 00 R/W
-$254 DIVR1 8 Interrupt Vector Register 1 0F R/W
-
-*1 - uninit except BRST=ASET=WRAH=RDAH=WR=RD=0
-
-*/
diff --git a/src/emu/machine/mcf5206e.h b/src/emu/machine/mcf5206e.h
deleted file mode 100644
index d49b88119d3..00000000000
--- a/src/emu/machine/mcf5206e.h
+++ /dev/null
@@ -1,215 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood
-/***************************************************************************
-
- MCF5206E Peripherals
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __MCF5206E_PERIPHERAL_H__
-#define __MCF5206E_PERIPHERAL_H__
-
-#include "emu.h"
-
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_MCF5206E_PERIPHERAL_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, MCF5206E_PERIPHERAL, 0)
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-// ======================> mcf5206e_peripheral_device
-
-enum
-{
- ICR1 = 0,
- ICR2,
- ICR3,
- ICR4,
- ICR5,
- ICR6,
- ICR7,
- ICR8,
- ICR9,
- ICR10,
- ICR11,
- ICR12,
- ICR13,
- MAX_ICR
-};
-
-class mcf5206e_peripheral_device : public device_t,
- public device_memory_interface
-{
-public:
- // construction/destruction
- mcf5206e_peripheral_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- void ICR_info(UINT8 ICR);
-
- DECLARE_READ32_MEMBER( dev_r );
- DECLARE_WRITE32_MEMBER( dev_w );
- DECLARE_READ32_MEMBER( seta2_coldfire_regs_r );
- DECLARE_WRITE32_MEMBER( seta2_coldfire_regs_w );
-
- DECLARE_READ8_MEMBER( ICR1_ICR2_ICR3_ICR4_r );
- DECLARE_WRITE8_MEMBER( ICR1_ICR2_ICR3_ICR4_w );
-
- DECLARE_READ8_MEMBER( ICR9_ICR10_ICR11_ICR12_r );
- DECLARE_WRITE8_MEMBER( ICR9_ICR10_ICR11_ICR12_w );
- DECLARE_READ8_MEMBER( ICR13_r );
- DECLARE_WRITE8_MEMBER( ICR13_w );
-
- UINT16 CSAR_r(int which, int offset, UINT16 mem_mask);
- void CSAR_w(int which, int offset, UINT16 data, UINT16 mem_mask);
- UINT32 CSMR_r(int which, UINT32 mem_mask);
- void CSMR_w(int which, UINT32 data, UINT32 mem_mask);
- UINT16 CSCR_r(int which, int offset, UINT16 mem_mask);
- void CSCR_w(int which, int offset, UINT16 data, UINT16 mem_mask);
-
- DECLARE_READ16_MEMBER( CSAR0_r );
- DECLARE_WRITE16_MEMBER( CSAR0_w );
- DECLARE_READ32_MEMBER( CSMR0_r );
- DECLARE_WRITE32_MEMBER( CSMR0_w );
- DECLARE_READ16_MEMBER( CSCR0_r );
- DECLARE_WRITE16_MEMBER( CSCR0_w );
- DECLARE_READ16_MEMBER( CSAR1_r );
- DECLARE_WRITE16_MEMBER( CSAR1_w );
- DECLARE_READ32_MEMBER( CSMR1_r );
- DECLARE_WRITE32_MEMBER( CSMR1_w );
- DECLARE_READ16_MEMBER( CSCR1_r );
- DECLARE_WRITE16_MEMBER( CSCR1_w );
- DECLARE_READ16_MEMBER( CSAR2_r );
- DECLARE_WRITE16_MEMBER( CSAR2_w );
- DECLARE_READ32_MEMBER( CSMR2_r );
- DECLARE_WRITE32_MEMBER( CSMR2_w );
- DECLARE_READ16_MEMBER( CSCR2_r );
- DECLARE_WRITE16_MEMBER( CSCR2_w );
- DECLARE_READ16_MEMBER( CSAR3_r );
- DECLARE_WRITE16_MEMBER( CSAR3_w );
- DECLARE_READ32_MEMBER( CSMR3_r );
- DECLARE_WRITE32_MEMBER( CSMR3_w );
- DECLARE_READ16_MEMBER( CSCR3_r );
- DECLARE_WRITE16_MEMBER( CSCR3_w );
- DECLARE_READ16_MEMBER( CSAR4_r );
- DECLARE_WRITE16_MEMBER( CSAR4_w );
- DECLARE_READ32_MEMBER( CSMR4_r );
- DECLARE_WRITE32_MEMBER( CSMR4_w );
- DECLARE_READ16_MEMBER( CSCR4_r );
- DECLARE_WRITE16_MEMBER( CSCR4_w );
- DECLARE_READ16_MEMBER( CSAR5_r );
- DECLARE_WRITE16_MEMBER( CSAR5_w );
- DECLARE_READ32_MEMBER( CSMR5_r );
- DECLARE_WRITE32_MEMBER( CSMR5_w );
- DECLARE_READ16_MEMBER( CSCR5_r );
- DECLARE_WRITE16_MEMBER( CSCR5_w );
- DECLARE_READ16_MEMBER( CSAR6_r );
- DECLARE_WRITE16_MEMBER( CSAR6_w );
- DECLARE_READ32_MEMBER( CSMR6_r );
- DECLARE_WRITE32_MEMBER( CSMR6_w );
- DECLARE_READ16_MEMBER( CSCR6_r );
- DECLARE_WRITE16_MEMBER( CSCR6_w );
- DECLARE_READ16_MEMBER( CSAR7_r );
- DECLARE_WRITE16_MEMBER( CSAR7_w );
- DECLARE_READ32_MEMBER( CSMR7_r );
- DECLARE_WRITE32_MEMBER( CSMR7_w );
- DECLARE_READ16_MEMBER( CSCR7_r );
- DECLARE_WRITE16_MEMBER( CSCR7_w );
-
- DECLARE_READ16_MEMBER( DMCR_r );
- DECLARE_WRITE16_MEMBER( DMCR_w );
- DECLARE_READ16_MEMBER( PAR_r );
- DECLARE_WRITE16_MEMBER( PAR_w );
-
- DECLARE_READ16_MEMBER( TMR1_r );
- DECLARE_WRITE16_MEMBER( TMR1_w );
- DECLARE_READ16_MEMBER( TRR1_r );
- DECLARE_WRITE16_MEMBER( TRR1_w );
- DECLARE_READ8_MEMBER( TER1_r );
- DECLARE_WRITE8_MEMBER(TER1_w );
- DECLARE_READ16_MEMBER( TCN1_r );
- DECLARE_WRITE16_MEMBER( TCN1_w );
-
- DECLARE_READ8_MEMBER( PPDDR_r );
- DECLARE_WRITE8_MEMBER( PPDDR_w );
- DECLARE_READ8_MEMBER( PPDAT_r );
- DECLARE_WRITE8_MEMBER( PPDAT_w );
-
- DECLARE_READ16_MEMBER( IMR_r );
- DECLARE_WRITE16_MEMBER( IMR_w );
-
-
- DECLARE_READ8_MEMBER( MBCR_r );
- DECLARE_WRITE8_MEMBER( MBCR_w );
- DECLARE_READ8_MEMBER( MBSR_r );
- DECLARE_WRITE8_MEMBER( MBSR_w );
- DECLARE_READ8_MEMBER( MFDR_r );
- DECLARE_WRITE8_MEMBER( MFDR_w );
- DECLARE_READ8_MEMBER( MBDR_r );
- DECLARE_WRITE8_MEMBER( MBDR_w );
-
-
-
-
- cpu_device* m_cpu;
-
-protected:
- // device-level overrides
- virtual void device_config_complete();
- virtual void device_start();
- virtual void device_reset();
- virtual void device_post_load() { }
- virtual void device_clock_changed() { }
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
- address_space_config m_space_config;
-
-
-private:
-
- void init_regs(bool first_init);
-
- UINT8 m_ICR[MAX_ICR];
-
- UINT16 m_CSAR[8];
- UINT32 m_CSMR[8];
- UINT16 m_CSCR[8];
-
- UINT16 m_DMCR;
- UINT16 m_PAR;
-
- emu_timer *m_timer1;
- UINT16 m_TMR1;
- UINT16 m_TRR1;
- UINT8 m_TER1;
- UINT16 m_TCN1;
- TIMER_CALLBACK_MEMBER(timer1_callback);
-
-
- UINT8 m_PPDDR;
- UINT8 m_PPDAT;
-
- UINT16 m_IMR;
-
- UINT8 m_MBCR;
- UINT8 m_MBSR;
- UINT8 m_MFDR;
- UINT8 m_MBDR;
-
- UINT32 m_coldfire_regs[0x400/4];
-
-private:
-};
-
-
-// device type definition
-extern const device_type MCF5206E_PERIPHERAL;
-
-#endif /* __MCF5206E_PERIPHERAL_H__ */
diff --git a/src/emu/machine/microtch.c b/src/emu/machine/microtch.c
deleted file mode 100644
index eee87447495..00000000000
--- a/src/emu/machine/microtch.c
+++ /dev/null
@@ -1,307 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Mariusz Wojcieszek
-/*
- Microtouch touch screen controller
-
- Written by Mariusz Wojcieszek
-
- Notes/ToDo:
- - calibration mode (command CX)
- - only tablet format and decimal format are supported for returning touch screen state
-
-*/
-
-#include "microtch.h"
-
-#define LOG 0
-
-const device_type MICROTOUCH = &device_creator<microtouch_device>;
-
-microtouch_device::microtouch_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, MICROTOUCH, "Microtouch Touchscreen", tag, owner, clock, "microtouch", __FILE__),
- device_serial_interface(mconfig, *this),
- m_out_stx_func(*this),
- m_touch(*this, "TOUCH"),
- m_touchx(*this, "TOUCH_X"),
- m_touchy(*this, "TOUCH_Y")
-{
-}
-
-int microtouch_device::check_command( const char* commandtocheck, int command_len, UINT8* command_data )
-{
- if ( (command_len == (strlen(commandtocheck) + 2)) &&
- (command_data[0] == 0x01) &&
- (strncmp(commandtocheck, (const char*)command_data + 1, strlen(commandtocheck)) == 0) &&
- (command_data[command_len-1] == 0x0d) )
- {
- return 1;
- }
- else
- {
- return 0;
- }
-}
-
-void microtouch_device::send_format_table_packet(UINT8 flag, int x, int y)
-{
- m_tx_buffer[m_tx_buffer_num++] = flag;
- // lower byte (7bits) of x coordinate
- m_tx_buffer[m_tx_buffer_num++] = x & 0x7f;
- // higher byte (7bits) of x coordinate
- m_tx_buffer[m_tx_buffer_num++] = (x >> 7) & 0x7f;
- // lower byte (7bits) of y coordinate
- m_tx_buffer[m_tx_buffer_num++] = y & 0x7f;
- // higher byte (7bits) of y coordinate
- m_tx_buffer[m_tx_buffer_num++] = (y >> 7) & 0x7f;
-}
-
-void microtouch_device::send_format_decimal_packet(int x, int y)
-{
- int decx, decy;
-
- decx = x / 16;
- if ( decx > 999 )
- decx = 999;
- decy = y / 16;
- if ( decy > 999 )
- decy = 999;
-
- // header byte
- m_tx_buffer[m_tx_buffer_num++] = 0x01;
- // x coordinate in decimal mode
- m_tx_buffer[m_tx_buffer_num++] = (decx / 100) + '0';
- m_tx_buffer[m_tx_buffer_num++] = ((decx / 10) % 10) + '0';
- m_tx_buffer[m_tx_buffer_num++] = (decx % 10) + '0';
- // comma (separator)
- m_tx_buffer[m_tx_buffer_num++] = ',';
- // y coordinate in decimal mode
- m_tx_buffer[m_tx_buffer_num++] = (decy / 100) + '0';
- m_tx_buffer[m_tx_buffer_num++] = ((decy / 10) % 10) + '0';
- m_tx_buffer[m_tx_buffer_num++] = (decy % 10) + '0';
- // terminator
- m_tx_buffer[m_tx_buffer_num++] = 0x0d;
-}
-
-void microtouch_device::send_touch_packet()
-{
- int tx = m_touchx->read();
- int ty = m_touchy->read();
-
- if ( m_out_touch_cb.isnull() ||
- m_out_touch_cb( &tx, &ty ) != 0 )
- {
- ty = 0x4000 - ty;
-
- switch( m_format )
- {
- case FORMAT_TABLET:
- send_format_table_packet(0xc8, tx, ty);
- break;
- case FORMAT_DECIMAL:
- send_format_decimal_packet(tx, ty);
- break;
- case FORMAT_UNKNOWN:
- break;
- }
- m_last_touch_state = 1;
- m_last_x = tx;
- m_last_y = ty;
- }
-}
-
-void microtouch_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if(id)
- {
- device_serial_interface::device_timer(timer, id, param, ptr);
- return;
- }
-
- if ( m_tx_buffer_ptr < m_tx_buffer_num )
- {
- m_output = m_tx_buffer[m_tx_buffer_ptr++];
- m_output_valid = true;
- if(is_transmit_register_empty())
- tra_complete();
-
- if ( m_tx_buffer_ptr == m_tx_buffer_num )
- {
- m_tx_buffer_ptr = m_tx_buffer_num = 0;
- }
- return;
- }
-
- if ( (m_reset_done == 0) ||
- (m_format == FORMAT_UNKNOWN) ||
- (m_mode != MODE_STREAM))
- {
- return;
- }
-
- // send format tablet packet
- if (m_touch->read())
- {
- send_touch_packet();
- }
- else
- {
- if ( m_last_touch_state == 1 )
- {
- m_last_touch_state = 0;
- switch( m_format )
- {
- case FORMAT_TABLET:
- send_format_table_packet(0x88, m_last_x, m_last_y);
- break;
- case FORMAT_DECIMAL:
- send_format_decimal_packet(m_last_x, m_last_y);
- break;
- case FORMAT_UNKNOWN:
- break;
- }
- }
- }
-}
-
-void microtouch_device::device_start()
-{
- memset(m_rx_buffer, 0, sizeof(m_rx_buffer));
- memset(m_tx_buffer, 0, sizeof(m_tx_buffer));
- m_rx_buffer_ptr = 0;
- m_tx_buffer_ptr = 0;
- m_tx_buffer_num = 0;
- m_reset_done = 0;
- m_format = 0;
- m_mode = 0;
- m_last_x = 0;
- m_last_y = 0;
- m_last_touch_state = -1;
-
- m_timer = timer_alloc();
- m_timer->adjust(attotime::from_hz(167*5), 0, attotime::from_hz(167*5));
-
- m_format = FORMAT_UNKNOWN;
- m_mode = MODE_INACTIVE;
-
- save_item(NAME(m_reset_done));
- save_item(NAME(m_last_touch_state));
- save_item(NAME(m_last_x));
- save_item(NAME(m_last_y));
- save_item(NAME(m_rx_buffer));
- save_item(NAME(m_rx_buffer_ptr));
- save_item(NAME(m_tx_buffer));
- save_item(NAME(m_tx_buffer_num));
- save_item(NAME(m_tx_buffer_ptr));
- save_item(NAME(m_format));
- save_item(NAME(m_mode));
- set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1); //8N1?
- set_tra_rate(clock());
- set_rcv_rate(clock());
- m_out_stx_func.resolve_safe();
- m_output_valid = false;
-
- save_item(NAME(m_output_valid));
- save_item(NAME(m_output));
-}
-
-
-void microtouch_device::rcv_complete()
-{
- receive_register_extract();
- m_rx_buffer[m_rx_buffer_ptr] = get_received_char();
- m_rx_buffer_ptr++;
- if(m_rx_buffer_ptr == 16)
- return;
-
- if (m_rx_buffer_ptr > 0 && (m_rx_buffer[m_rx_buffer_ptr-1] == 0x0d))
- {
- if (LOG)
- {
- char command[16];
- memset(command, 0, sizeof(command));
- strncpy( command, (const char*)m_rx_buffer + 1, m_rx_buffer_ptr - 2 );
- logerror("Microtouch: received command %s\n", command);
- }
- // check command
- if ( check_command( "MS", m_rx_buffer_ptr, m_rx_buffer ) )
- {
- m_mode = MODE_STREAM;
- }
- else if ( check_command( "MI", m_rx_buffer_ptr, m_rx_buffer ) )
- {
- m_mode = MODE_INACTIVE;
- }
- else if ( check_command( "MP", m_rx_buffer_ptr, m_rx_buffer ) )
- {
- m_mode = MODE_POINT;
- }
- else if ( check_command( "R", m_rx_buffer_ptr, m_rx_buffer ) )
- {
- m_tx_buffer_num = 0;
- m_reset_done = 1;
- }
- else if ( check_command( "FT", m_rx_buffer_ptr, m_rx_buffer ) )
- {
- m_format = FORMAT_TABLET;
- }
- else if ( check_command( "FD", m_rx_buffer_ptr, m_rx_buffer ) )
- {
- m_format = FORMAT_DECIMAL;
- }
- else if ( check_command("OI", m_rx_buffer_ptr, m_rx_buffer ) )
- {
- // output identity - SMT3, ver 01.00
- m_tx_buffer[m_tx_buffer_num++] = 0x01;
- m_tx_buffer[m_tx_buffer_num++] = 'Q';
- m_tx_buffer[m_tx_buffer_num++] = '1';
- m_tx_buffer[m_tx_buffer_num++] = '0';
- m_tx_buffer[m_tx_buffer_num++] = '1';
- m_tx_buffer[m_tx_buffer_num++] = '0';
- m_tx_buffer[m_tx_buffer_num++] = '0';
- m_tx_buffer[m_tx_buffer_num++] = 0x0d;
- m_rx_buffer_ptr = 0;
- return;
- }
- // send response
- m_tx_buffer[m_tx_buffer_num++] = 0x01;
- m_tx_buffer[m_tx_buffer_num++] = 0x30;
- m_tx_buffer[m_tx_buffer_num++] = 0x0d;
- m_rx_buffer_ptr = 0;
- }
-}
-
-INPUT_CHANGED_MEMBER( microtouch_device::touch )
-{
- if ( newval && ( m_mode == MODE_POINT ) )
- {
- send_touch_packet();
- }
-}
-
-static INPUT_PORTS_START(microtouch)
- PORT_START("TOUCH")
- PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME( "Touch screen" ) PORT_CHANGED_MEMBER( DEVICE_SELF,microtouch_device, touch, 0 )
- PORT_START("TOUCH_X")
- PORT_BIT( 0x3fff, 0x2000, IPT_LIGHTGUN_X ) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(45) PORT_KEYDELTA(15)
- PORT_START("TOUCH_Y")
- PORT_BIT( 0x3fff, 0x2000, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(45) PORT_KEYDELTA(15)
-INPUT_PORTS_END
-
-ioport_constructor microtouch_device::device_input_ports() const
-{
- return INPUT_PORTS_NAME(microtouch);
-}
-
-void microtouch_device::tra_callback()
-{
- m_out_stx_func(transmit_register_get_data_bit());
-}
-
-void microtouch_device::tra_complete()
-{
- if(m_output_valid)
- {
- transmit_register_setup(m_output);
- m_output_valid = false;
- }
-}
diff --git a/src/emu/machine/microtch.h b/src/emu/machine/microtch.h
deleted file mode 100644
index c7ba5a3c00b..00000000000
--- a/src/emu/machine/microtch.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Mariusz Wojcieszek
-#ifndef _MICROTOUCH_H
-#define _MICROTOUCH_H
-
-#include "emu.h"
-
-
-class microtouch_device :
- public device_t,
- public device_serial_interface
-{
-public:
- microtouch_device(const machine_config &mconfig, device_type type, const char* name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
- microtouch_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- template<class _Object> static devcb_base &static_set_stx_callback(device_t &device, _Object object) { return downcast<microtouch_device &>(device).m_out_stx_func.set_callback(object); }
-
- virtual ioport_constructor device_input_ports() const;
- DECLARE_WRITE_LINE_MEMBER(rx) { device_serial_interface::rx_w(state); }
- DECLARE_INPUT_CHANGED_MEMBER(touch);
-
- typedef delegate<int (int *, int *)> touch_cb;
- static void static_set_touch_callback(device_t &device, touch_cb object) { downcast<microtouch_device &>(device).m_out_touch_cb = object; }
-protected:
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual void tra_callback();
- virtual void tra_complete();
- virtual void rcv_complete();
-private:
- int check_command( const char* commandtocheck, int command_len, UINT8* command_data );
- void send_format_table_packet(UINT8 flag, int x, int y);
- void send_format_decimal_packet(int x, int y);
- void send_touch_packet();
-
- enum
- {
- FORMAT_UNKNOWN,
- FORMAT_TABLET,
- FORMAT_DECIMAL
- };
- enum
- {
- MODE_INACTIVE,
- MODE_STREAM,
- MODE_POINT
- };
- UINT8 m_rx_buffer[16];
- int m_rx_buffer_ptr;
- UINT8 m_tx_buffer[16];
- UINT8 m_tx_buffer_num;
- UINT8 m_tx_buffer_ptr;
- int m_reset_done;
- int m_format;
- int m_mode;
- int m_last_touch_state;
- int m_last_x;
- int m_last_y;
- touch_cb m_out_touch_cb;
- devcb_write_line m_out_stx_func;
- required_ioport m_touch;
- required_ioport m_touchx;
- required_ioport m_touchy;
- emu_timer* m_timer;
- bool m_output_valid;
- UINT8 m_output;
-};
-
-extern const device_type MICROTOUCH;
-
-#define MCFG_MICROTOUCH_ADD(_tag, _clock, _devcb) \
- MCFG_DEVICE_ADD(_tag, MICROTOUCH, _clock) \
- devcb = &microtouch_device::static_set_stx_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MICROTOUCH_TOUCH_CB(_class, _touch_cb) \
- microtouch_device::static_set_touch_callback(*device, microtouch_device::touch_cb(FUNC(_class::_touch_cb), (_class *)owner));
-
-
-#endif //_MICROTOUCH_H
diff --git a/src/emu/machine/mm58167.c b/src/emu/machine/mm58167.c
deleted file mode 100644
index 74572770710..00000000000
--- a/src/emu/machine/mm58167.c
+++ /dev/null
@@ -1,261 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/**********************************************************************
-
- mm58167.c - National Semiconductor MM58167 real-time clock emulation
-
- TODO: standby interrupt
-
-**********************************************************************/
-
-#include "mm58167.h"
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type MM58167 = &device_creator<mm58167_device>;
-
-// registers (0-7 are the live data, 8-f are the setting for the compare IRQ)
-typedef enum
-{
- R_CNT_MILLISECONDS = 0, // 0 = milliseconds
- R_CNT_HUNDTENTHS, // 1 = hundreds and tenths of seconds
- R_CNT_SECONDS, // 2 = seconds
- R_CNT_MINUTES, // 3 = minutes
- R_CNT_HOURS, // 4 = hours
- R_CNT_DAYOFWEEK, // 5 = day of the week
- R_CNT_DAYOFMONTH, // 6 = day of the month
- R_CNT_MONTH, // 7 = month
- R_RAM_MILLISECONDS, // 8 = milliseconds
- R_RAM_HUNDTENTHS, // 9 = hundreds and tenths of seconds
- R_RAM_SECONDS, // a = seconds
- R_RAM_MINUTES, // b = minutes
- R_RAM_HOURS, // c = hours
- R_RAM_DAYOFWEEK, // d = day of the week
- R_RAM_DAYOFMONTH, // e = day of the month
- R_RAM_MONTH, // f = month
- R_CTL_IRQSTATUS, // 10 = IRQ status (b7 = compare, b6 = 10th sec, b5 = sec, b4 = min, b3 = hour, b2 = day, b1 = week, b0 = month)
- R_CTL_IRQCONTROL, // 11 = IRQ control (same bit layout as status, but write here to enable/disable/clear)
- R_CTL_RESETCOUNTERS, // 12 = reset counters
- R_CTL_RESETRAM, // 13 = reset RAM
- R_CTL_STATUS, // 14 = status bit
- R_CTL_GOCMD, // 15 = GO Command
- R_CTL_STANDBYIRQ, // 16 = standby IRQ
- R_CTL_TESTMODE // 17 = test mode
-} mm58167_regs_t;
-
-//-------------------------------------------------
-// mm58167_device - constructor
-//-------------------------------------------------
-
-mm58167_device::mm58167_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MM58167, "National Semiconductor MM58167", tag, owner, clock, "mm58167", __FILE__),
- device_rtc_interface(mconfig, *this),
- m_irq_w(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mm58167_device::device_start()
-{
- // allocate timers
- m_clock_timer = timer_alloc();
- m_clock_timer->adjust(attotime::from_hz(clock() / 32.768f), 0, attotime::from_hz(clock() / 32.768f));
-
- m_irq_w.resolve_safe();
-
- // state saving
- save_item(NAME(m_regs));
- save_item(NAME(m_milliseconds));
- save_item(NAME(m_comparator_state));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mm58167_device::device_reset()
-{
- set_current_time(machine());
-
- m_regs[R_CTL_STATUS] = 0; // not busy
- m_regs[R_CTL_IRQSTATUS] = 0;
- m_regs[R_CTL_IRQCONTROL] = 0;
- m_milliseconds = 0;
- m_comparator_state = false;
-}
-
-
-INLINE UINT8 make_bcd(UINT8 data)
-{
- return ((data / 10) << 4) | (data % 10);
-}
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void mm58167_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- m_milliseconds++;
-
- if (m_milliseconds >= 999)
- {
- int old_seconds = m_regs[R_CNT_SECONDS];
- int old_minutes = m_regs[R_CNT_MINUTES];
- int old_hours = m_regs[R_CNT_HOURS];
- int old_dayofmonth = m_regs[R_CNT_DAYOFMONTH];
- int old_dayofweek = m_regs[R_CNT_DAYOFWEEK];
- int old_month = m_regs[R_CNT_MONTH];
-
- advance_seconds();
- m_milliseconds = 0;
-
- if ((m_regs[R_CTL_IRQCONTROL] & 0x04) && m_regs[R_CNT_SECONDS] != old_seconds) set_irq(2); // every second
- if ((m_regs[R_CTL_IRQCONTROL] & 0x08) && m_regs[R_CNT_MINUTES] != old_minutes) set_irq(3); // every minute
- if ((m_regs[R_CTL_IRQCONTROL] & 0x10) && m_regs[R_CNT_HOURS] != old_hours) set_irq(4); // every hour
- if ((m_regs[R_CTL_IRQCONTROL] & 0x20) && m_regs[R_CNT_DAYOFMONTH] != old_dayofmonth) set_irq(5); // every day
- if ((m_regs[R_CTL_IRQCONTROL] & 0x40) && m_regs[R_CNT_DAYOFWEEK] < old_dayofweek) set_irq(6); // every week
- if ((m_regs[R_CTL_IRQCONTROL] & 0x80) && m_regs[R_CNT_MONTH] != old_month) set_irq(7); // every month
- }
-
- m_regs[R_CNT_MILLISECONDS] = make_bcd(m_milliseconds % 10);
- m_regs[R_CNT_HUNDTENTHS] = make_bcd(m_milliseconds / 10);
-
- // 10Hz IRQ
- if ((m_regs[R_CTL_IRQCONTROL] & 0x02) && (m_milliseconds % 100) == 0)
- set_irq(1);
-
- // comparator IRQ
- bool new_state = true;
- for (int i = R_CNT_MILLISECONDS; i <= R_CNT_MONTH; i++)
- {
- // nibbles that have the 2 MSB set always compares true
- // Milliseconds use only the high nibble and Day of Week only the low nibble
- if ((i != R_CNT_MILLISECONDS && (m_regs[i + 8] & 0x0c) != 0x0c && (m_regs[i + 8] & 0x0f) != (m_regs[i] & 0x0f)) ||
- (i != R_CNT_DAYOFWEEK && (m_regs[i + 8] & 0xc0) != 0xc0 && (m_regs[i + 8] & 0xf0) != (m_regs[i] & 0xf0)))
- {
- new_state = false;
- break;
- }
- }
-
- if ((m_regs[R_CTL_IRQCONTROL] & 0x01) && !m_comparator_state && new_state) // positive-edge-triggered
- set_irq(0);
-
- m_comparator_state = new_state;
-}
-
-
-//-------------------------------------------------
-// rtc_clock_updated -
-//-------------------------------------------------
-
-void mm58167_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
- m_regs[R_CNT_SECONDS] = make_bcd(second); // seconds (BCD)
- m_regs[R_CNT_MINUTES] = make_bcd(minute); // minutes (BCD)
- m_regs[R_CNT_HOURS] = make_bcd(hour); // hour (BCD)
- m_regs[R_CNT_DAYOFWEEK] = make_bcd(day_of_week); // day of the week (BCD)
- m_regs[R_CNT_DAYOFMONTH] = make_bcd(day); // day of the month (BCD)
- m_regs[R_CNT_MONTH] = make_bcd(month); // month (BCD)
-}
-
-void mm58167_device::set_irq(int bit)
-{
- m_regs[R_CTL_IRQSTATUS] |= (1 << bit);
- m_irq_w(ASSERT_LINE);
-}
-
-void mm58167_device::update_rtc()
-{
- set_clock_register(RTC_SECOND, bcd_to_integer(m_regs[R_CNT_SECONDS]));
- set_clock_register(RTC_MINUTE, bcd_to_integer(m_regs[R_CNT_MINUTES]));
- set_clock_register(RTC_HOUR, bcd_to_integer(m_regs[R_CNT_HOURS]));
- set_clock_register(RTC_DAY, bcd_to_integer(m_regs[R_CNT_DAYOFMONTH]));
- set_clock_register(RTC_DAY_OF_WEEK, bcd_to_integer(m_regs[R_CNT_DAYOFWEEK]));
- set_clock_register(RTC_MONTH, bcd_to_integer(m_regs[R_CNT_MONTH]));
- m_milliseconds = (bcd_to_integer(m_regs[R_CNT_HUNDTENTHS]) * 10) + (bcd_to_integer(m_regs[R_CNT_MILLISECONDS] >> 4) % 10);
-}
-
-READ8_MEMBER(mm58167_device::read)
-{
-// printf("read reg %x = %02x\n", offset, m_regs[offset]);
-
- if (offset == R_CTL_IRQSTATUS && !space.debugger_access())
- {
- // reading the IRQ status clears IRQ line and IRQ status
- UINT8 data = m_regs[offset];
- m_regs[R_CTL_IRQSTATUS] = 0;
- m_irq_w(CLEAR_LINE);
- return data;
- }
-
- return m_regs[offset];
-}
-
-WRITE8_MEMBER(mm58167_device::write)
-{
-// printf("%02x to reg %x\n", data, offset);
-
- if ((offset >= R_RAM_MILLISECONDS) && (offset != R_CTL_IRQSTATUS))
- {
- m_regs[offset] = data;
- }
-
- switch (offset)
- {
- case R_CNT_MILLISECONDS:
- case R_CNT_HUNDTENTHS:
- case R_CNT_SECONDS:
- case R_CNT_MINUTES:
- case R_CNT_HOURS:
- case R_CNT_DAYOFWEEK:
- case R_CNT_DAYOFMONTH:
- case R_CNT_MONTH:
- m_regs[offset] = data;
- update_rtc();
- break;
-
- // any write to this starts at the current time and zero milliseconds
- case R_CTL_GOCMD:
- m_milliseconds = 0;
- break;
-
- case R_CTL_RESETCOUNTERS:
- if (data == 0xff)
- {
- for (int i = R_CNT_MILLISECONDS; i <= R_CNT_MONTH; i++)
- {
- m_regs[i] = 0;
- }
-
- update_rtc();
- }
- break;
-
- case R_CTL_RESETRAM:
- if (data == 0xff)
- {
- for (int i = R_RAM_MILLISECONDS; i < R_CTL_IRQSTATUS; i++)
- {
- m_regs[i] = 0;
- }
- }
- break;
-
- case R_CTL_IRQCONTROL:
- if (data != 0)
- {
- logerror("MM58167: IRQs not implemented\n");
- }
- break;
- }
-}
diff --git a/src/emu/machine/mm58167.h b/src/emu/machine/mm58167.h
deleted file mode 100644
index 83714042433..00000000000
--- a/src/emu/machine/mm58167.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/**********************************************************************
-
- mm58167.h - National Semiconductor MM58167 real-time clock emulation
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MM58167_H__
-#define __MM58167_H__
-
-#include "emu.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MM58167_IRQ_CALLBACK(_cb) \
- devcb = &mm58167_device::set_irq_cb(*device, DEVCB_##_cb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mm58167_device
-
-class mm58167_device : public device_t,
- public device_rtc_interface
-{
-public:
- // construction/destruction
- mm58167_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- template<class _Object> static devcb_base &set_irq_cb(device_t &device, _Object wr) { return downcast<mm58167_device &>(device).m_irq_w.set_callback(wr); }
-
- devcb_write_line m_irq_w;
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_rtc_interface overrides
- virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
- virtual bool rtc_feature_leap_year() { return true; }
-
- void set_irq(int bit);
- void update_rtc();
-
-private:
- int m_regs[32];
- int m_milliseconds;
- bool m_comparator_state;
-
- // timers
- emu_timer *m_clock_timer;
-};
-
-// device type definition
-extern const device_type MM58167;
-
-#endif
diff --git a/src/emu/machine/mm58274c.c b/src/emu/machine/mm58274c.c
deleted file mode 100644
index 0690f775b5d..00000000000
--- a/src/emu/machine/mm58274c.c
+++ /dev/null
@@ -1,470 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Raphael Nabet
-/***************************************************************************
-
- mm58274c.c
-
- mm58274c emulation
-
- Reference:
- * National Semiconductor MM58274C Microprocessor Compatible Real Time Clock
- <http://www.national.com/ds/MM/MM58274C.pdf>
-
- Todo:
- * Clock initialization will only work with the BwG: we need to provide
- a way to customize it.
- * Save the config to NVRAM?
- * Support interrupt pin output
-
- Raphael Nabet, 2002
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/mm58274c.h"
-
-enum
-{
- st_dcf = 0x8, /* data-changed flag */
- st_if = 0x1, /* interrupt flag */
-
- ctl_test = 0x8, /* test mode (0=normal, 1=test) (not emulated) */
- ctl_clkstop = 0x4, /* clock start/stop (0=run, 1=stop) */
- ctl_intsel = 0x2, /* interrupt select (0=clock setting register, 1=interrupt register) */
- ctl_intstop = 0x1, /* interrupt start stop (0=interrupt run, 1=interrupt stop) */
-
- clk_set_leap = 0xc, /* leap year counter (0 indicates a leap year) */
- clk_set_leap_inc = 0x4, /* leap year increment */
- clk_set_pm = 0x2, /* am/pm indicator (0 = am, 1 = pm, 0 in 24-hour mode) */
- clk_set_24 = 0x1, /* 12/24-hour select bit (1= 24-hour mode) */
-
- int_ctl_rpt = 0x8, /* 1 for repeated interrupt */
- int_ctl_dly = 0x7 /* 0 no interrupt, 1 = .1 second, 2=.5, 3=1, 4=5, 5=10, 6=30, 7=60 */
-};
-
-
-
-const device_type MM58274C = &device_creator<mm58274c_device>;
-
-
-mm58274c_device::mm58274c_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MM58274C, "National Semiconductor MM58274C", tag, owner, clock, "mm58274c", __FILE__),
- m_mode24(0),
- m_day1(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mm58274c_device::device_start()
-{
- m_increment_rtc = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mm58274c_device::rtc_increment_cb),this));
- m_increment_rtc->adjust(attotime::zero, 0, attotime::from_msec(100));
- m_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mm58274c_device::rtc_interrupt_cb),this));
-
- // register for state saving
- save_item(NAME(m_status));
- save_item(NAME(m_control));
- save_item(NAME(m_clk_set));
- save_item(NAME(m_int_ctl));
- save_item(NAME(m_wday));
- save_item(NAME(m_years1));
- save_item(NAME(m_years2));
- save_item(NAME(m_months1));
- save_item(NAME(m_months2));
- save_item(NAME(m_days1));
- save_item(NAME(m_days2));
- save_item(NAME(m_hours1));
- save_item(NAME(m_hours2));
- save_item(NAME(m_minutes1));
- save_item(NAME(m_minutes2));
- save_item(NAME(m_seconds1));
- save_item(NAME(m_seconds2));
- save_item(NAME(m_tenths));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mm58274c_device::device_reset()
-{
- system_time systime;
-
- /* get the current date/time from the core */
- machine().current_datetime(systime);
-
- m_clk_set = systime.local_time.year & 3 << 2;
- if (m_mode24)
- m_clk_set |= clk_set_24;
-
- /* The clock count starts on 1st January 1900 */
- m_wday = 1 + ((systime.local_time.weekday - m_day1) % 7);
- m_years1 = (systime.local_time.year / 10) % 10;
- m_years2 = systime.local_time.year % 10;
- m_months1 = (systime.local_time.month + 1) / 10;
- m_months2 = (systime.local_time.month + 1) % 10;
- m_days1 = systime.local_time.mday / 10;
- m_days2 = systime.local_time.mday % 10;
- if (!m_mode24)
- {
- /* 12-hour mode */
- if (systime.local_time.hour > 12)
- {
- systime.local_time.hour -= 12;
- m_clk_set |= clk_set_pm;
- }
- if (systime.local_time.hour == 0)
- systime.local_time.hour = 12;
- }
- m_hours1 = systime.local_time.hour / 10;
- m_hours2 = systime.local_time.hour % 10;
- m_minutes1 = systime.local_time.minute / 10;
- m_minutes2 = systime.local_time.minute % 10;
- m_seconds1 = systime.local_time.second / 10;
- m_seconds2 = systime.local_time.second % 10;
- m_tenths = 0;
- m_status = 0;
- m_control = 0;
-}
-
-
-
-attotime mm58274c_device::interrupt_period_table(int val)
-{
- switch(val)
- {
- case 0: return attotime::from_msec(0);
- case 1: return attotime::from_msec(100);
- case 2: return attotime::from_msec(500);
- case 3: return attotime::from_seconds(1);
- case 4: return attotime::from_seconds(5);
- case 5: return attotime::from_seconds(10);
- case 6: return attotime::from_seconds(30);
- case 7: return attotime::from_seconds(60);
- default: fatalerror("out of range\n");
- }
-}
-
-READ8_MEMBER( mm58274c_device::read )
-{
- int reply;
-
- offset &= 0xf;
-
- switch (offset)
- {
- case 0x00: /* Control Register */
- reply = m_status;
- m_status = 0;
- break;
-
- case 0x01: /* Tenths of Seconds */
- reply = m_tenths;
- break;
-
- case 0x02: /* Units Seconds */
- reply = m_seconds2;
- break;
-
- case 0x03: /* Tens Seconds */
- reply = m_seconds1;
- break;
-
- case 0x04: /* Units Minutes */
- reply = m_minutes2;
- break;
-
- case 0x05: /* Tens Minutes */
- reply = m_minutes1;
- break;
-
- case 0x06: /* Units Hours */
- reply = m_hours2;
- break;
-
- case 0x07: /* Tens Hours */
- reply = m_hours1;
- break;
-
- case 0x08: /* Units Days */
- reply = m_days2;
- break;
-
- case 0x09: /* Tens Days */
- reply = m_days1;
- break;
-
- case 0x0a: /* Units Months */
- reply = m_months2;
- break;
-
- case 0x0b: /* Tens Months */
- reply = m_months1;
- break;
-
- case 0x0c: /* Units Years */
- reply = m_years2;
- break;
-
- case 0x0d: /* Tens Years */
- reply = m_years1;
- break;
-
- case 0x0e: /* Day of Week */
- reply = m_wday;
- break;
-
- case 0x0f: /* Clock Setting & Interrupt Registers */
- if (m_control & ctl_intsel) /* interrupt register */
- reply = m_int_ctl;
- else /* clock setting register */
- {
- if (m_clk_set & clk_set_24) /* 24-hour mode */
- reply = m_clk_set & ~clk_set_pm;
- else /* 12-hour mode */
- reply = m_clk_set;
- }
- break;
-
- default:
- reply = 0;
- break;
- }
-
- return reply;
-}
-
-
-WRITE8_MEMBER( mm58274c_device::write )
-{
- offset &= 0xf;
- data &= 0xf;
-
- switch (offset)
- {
- case 0x00: /* Control Register (test mode and interrupt not emulated) */
- if ((!(m_control & ctl_intstop)) && (data & ctl_intstop)) /* interrupt stop */
- m_interrupt_timer->enable(0);
- else if ((m_control & ctl_intstop) && (!(data & ctl_intstop))) /* interrupt run */
- {
- attotime period = interrupt_period_table(m_int_ctl & int_ctl_dly);
-
- m_interrupt_timer->adjust(period, 0, m_int_ctl & int_ctl_rpt ? period : attotime::zero);
- }
- if (data & ctl_clkstop) /* stopping the clock clears the tenth counter */
- m_tenths = 0;
- m_control = data;
- break;
-
- case 0x01: /* Tenths of Seconds: cannot be written */
- break;
-
- case 0x02: /* Units Seconds */
- m_seconds2 = data;
- break;
-
- case 0x03: /* Tens Seconds */
- m_seconds1 = data;
- break;
-
- case 0x04: /* Units Minutes */
- m_minutes2 = data;
- break;
-
- case 0x05: /* Tens Minutes */
- m_minutes1 = data;
- break;
-
- case 0x06: /* Units Hours */
- m_hours2 = data;
- break;
-
- case 0x07: /* Tens Hours */
- m_hours1 = data;
- break;
-
- case 0x08: /* Units Days */
- m_days2 = data;
- break;
-
- case 0x09: /* Tens Days */
- m_days1 = data;
- break;
-
- case 0x0a: /* Units Months */
- m_months2 = data;
- break;
-
- case 0x0b: /* Tens Months */
- m_months1 = data;
- break;
-
- case 0x0c: /* Units Years */
- m_years2 = data;
- break;
-
- case 0x0d: /* Tens Years */
- m_years1 = data;
- break;
-
- case 0x0e: /* Day of Week */
- m_wday = data;
- break;
-
- case 0x0f: /* Clock Setting & Interrupt Registers */
- if (m_control & ctl_intsel) /* interrupt register (not emulated) */
- {
- m_int_ctl = data;
- if (!(m_control & ctl_intstop)) /* interrupt run */
- {
- attotime period = interrupt_period_table(m_int_ctl & int_ctl_dly);
-
- m_interrupt_timer->adjust(period, 0, m_int_ctl & int_ctl_rpt ? period : attotime::zero);
- }
- }
- else /* clock setting register */
- {
- m_clk_set = data;
-#if 0
- if (m_clk_set & clk_set_24) /* 24-hour mode */
- m_clk_set &= ~clk_set_pm;
-#endif
- }
- break;
- }
-}
-
-
-// Set RTC interrupt flag
-TIMER_CALLBACK_MEMBER(mm58274c_device::rtc_interrupt_cb)
-{
- m_status |= st_if;
-}
-
-
-// Increment RTC clock (timed interrupt every 1/10s)
-TIMER_CALLBACK_MEMBER(mm58274c_device::rtc_increment_cb)
-{
- if (!(m_control & ctl_clkstop))
- {
- m_status |= st_dcf;
-
- if ((++m_tenths) == 10)
- {
- m_tenths = 0;
-
- if ((++m_seconds2) == 10)
- {
- m_seconds2 = 0;
-
- if ((++m_seconds1) == 6)
- {
- m_seconds1 = 0;
-
- if ((++m_minutes2) == 10)
- {
- m_minutes2 = 0;
-
- if ((++m_minutes1) == 6)
- {
- m_minutes1 = 0;
-
- if ((++m_hours2) == 10)
- {
- m_hours2 = 0;
-
- m_hours1++;
- }
-
- /* handle wrap-around */
- if ((!(m_clk_set & clk_set_24))
- && ((m_hours1*10 + m_hours2) == 12))
- {
- m_clk_set ^= clk_set_pm;
- }
- if ((!(m_clk_set & clk_set_24))
- && ((m_hours1*10 + m_hours2) == 13))
- {
- m_hours1 = 0;
- m_hours2 = 1;
- }
-
- if ((m_clk_set & clk_set_24)
- && ((m_hours1*10 + m_hours2) == 24))
- {
- m_hours1 = m_hours2 = 0;
- }
-
- /* increment day if needed */
- if ((m_clk_set & clk_set_24)
- ? ((m_hours1*10 + m_hours2) == 0)
- : (((m_hours1*10 + m_hours2) == 12)
- && (!(m_clk_set & clk_set_pm))))
- {
- int days_in_month;
-
- if ((++m_days2) == 10)
- {
- m_days2 = 0;
-
- m_days1++;
- }
-
- if ((++m_wday) == 8)
- m_wday = 1;
-
- {
- static const int days_in_month_array[] =
- {
- 31,28,31, 30,31,30,
- 31,31,30, 31,30,31
- };
-
- if (((m_months1*10 + m_months2) != 2) || (m_clk_set & clk_set_leap))
- days_in_month = days_in_month_array[m_months1*10 + m_months2 - 1];
- else
- days_in_month = 29;
- }
-
-
- if ((m_days1*10 + m_days2) == days_in_month+1)
- {
- m_days1 = 0;
- m_days2 = 1;
-
- if ((++m_months2) == 10)
- {
- m_months2 = 0;
-
- m_months1++;
- }
-
- if ((m_months1*10 + m_months2) == 13)
- {
- m_months1 = 0;
- m_months2 = 1;
-
- m_clk_set = (m_clk_set & ~clk_set_leap)
- | ((m_clk_set + clk_set_leap_inc) & clk_set_leap);
-
- if ((++m_years2) == 10)
- {
- m_years2 = 0;
-
- if ((++m_years1) == 10)
- m_years1 = 0;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
diff --git a/src/emu/machine/mm58274c.h b/src/emu/machine/mm58274c.h
deleted file mode 100644
index 225340721ea..00000000000
--- a/src/emu/machine/mm58274c.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Raphael Nabet
-#ifndef __MM58274C_H__
-#define __MM58274C_H__
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-class mm58274c_device : public device_t
-{
-public:
- mm58274c_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~mm58274c_device() {}
-
- static void set_mode24(device_t &device, int mode) { downcast<mm58274c_device &>(device).m_mode24 = mode; }
- static void set_day1(device_t &device, int day) { downcast<mm58274c_device &>(device).m_day1 = day; }
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- TIMER_CALLBACK_MEMBER(rtc_increment_cb);
- TIMER_CALLBACK_MEMBER(rtc_interrupt_cb);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
-
- // Initializion the clock chip:
- // m_day1 must be set to a value from 0 (sunday), 1 (monday)...
- // to 6 (saturday) and is needed to correctly retrieve the
- // day-of-week from the host system clock.
- int m_mode24; /* 24/12 mode */
- int m_day1; /* first day of week */
-
- attotime interrupt_period_table(int val);
-
- int m_status; /* status register (*read* from address 0 = control register) */
- int m_control; /* control register (*write* to address 0) */
-
- int m_clk_set; /* clock setting register */
- int m_int_ctl; /* interrupt control register */
-
- int m_wday; /* day of the week (1-7 (1=day1 as set in init)) */
- int m_years1; /* years (BCD: 0-99) */
- int m_years2;
- int m_months1; /* months (BCD: 1-12) */
- int m_months2;
- int m_days1; /* days (BCD: 1-31) */
- int m_days2;
- int m_hours1; /* hours (BCD : 0-23) */
- int m_hours2;
- int m_minutes1; /* minutes (BCD : 0-59) */
- int m_minutes2;
- int m_seconds1; /* seconds (BCD : 0-59) */
- int m_seconds2;
- int m_tenths; /* tenths of second (BCD : 0-9) */
-
- emu_timer *m_increment_rtc;
- emu_timer *m_interrupt_timer;
-};
-
-extern const device_type MM58274C;
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_MM58274C_MODE24(_mode) \
- mm58274c_device::set_mode24(*device, _mode);
-
-#define MCFG_MM58274C_DAY1(_day) \
- mm58274c_device::set_day1(*device, _day);
-
-
-#endif
diff --git a/src/emu/machine/mm74c922.c b/src/emu/machine/mm74c922.c
deleted file mode 100644
index 6b7f9b50d53..00000000000
--- a/src/emu/machine/mm74c922.c
+++ /dev/null
@@ -1,190 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MM74C922/MM74C923 16/20-Key Encoder emulation
-
-**********************************************************************/
-
-#include "mm74c922.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 1
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type MM74C922 = &device_creator<mm74c922_device>;
-const device_type MM74C923 = &device_creator<mm74c922_device>;
-
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mm74c922_device - constructor
-//-------------------------------------------------
-
-mm74c922_device::mm74c922_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, MM74C922, "MM74C922", tag, owner, clock, "mm74c922", __FILE__),
- m_write_da(*this),
- m_read_x1(*this),
- m_read_x2(*this),
- m_read_x3(*this),
- m_read_x4(*this),
- m_read_x5(*this),
- m_max_y(5), // TODO 4 for 74C922, 5 for 74C923
- m_inhibit(0),
- m_x(0),
- m_y(0),
- m_da(0),
- m_next_da(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mm74c922_device::device_start()
-{
- // resolve callbacks
- m_write_da.resolve_safe();
- m_read_x1.resolve_safe(0);
- m_read_x2.resolve_safe(0);
- m_read_x3.resolve_safe(0);
- m_read_x4.resolve_safe(0);
- m_read_x5.resolve_safe(0);
-
- // set initial values
- change_output_lines();
-
- // allocate timers
- m_scan_timer = timer_alloc();
- m_scan_timer->adjust(attotime::zero, 0, attotime::from_hz(50));
-
- // register for state saving
- save_item(NAME(m_inhibit));
- save_item(NAME(m_x));
- save_item(NAME(m_y));
- save_item(NAME(m_data));
- save_item(NAME(m_da));
- save_item(NAME(m_next_da));
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void mm74c922_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- change_output_lines();
- clock_scan_counters();
- detect_keypress();
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-UINT8 mm74c922_device::read()
-{
- if (LOG) logerror("MM74C922 '%s' Data Read: %02x\n", tag(), m_data);
-
- return m_data;
-}
-
-
-//-------------------------------------------------
-// change_output_lines -
-//-------------------------------------------------
-
-void mm74c922_device::change_output_lines()
-{
- if (m_next_da != m_da)
- {
- m_da = m_next_da;
-
- if (LOG) logerror("MM74C922 '%s' Data Available: %u\n", tag(), m_da);
-
- m_write_da(m_da);
- }
-}
-
-
-//-------------------------------------------------
-// clock_scan_counters -
-//-------------------------------------------------
-
-void mm74c922_device::clock_scan_counters()
-{
- if (!m_inhibit)
- {
- m_x++;
- m_x &= 0x03;
- }
-}
-
-
-//-------------------------------------------------
-// detect_keypress -
-//-------------------------------------------------
-
-void mm74c922_device::detect_keypress()
-{
- UINT8 data = 0xff;
-
- switch (m_x)
- {
- case 0: data = m_read_x1(0); break;
- case 1: data = m_read_x2(0); break;
- case 2: data = m_read_x3(0); break;
- case 3: data = m_read_x4(0); break;
- case 4: data = m_read_x5(0); break;
- }
-
- if (m_inhibit)
- {
- if (BIT(data, m_y))
- {
- // key released
- m_inhibit = 0;
- m_next_da = 0;
- m_data = 0xff; // high-Z
-
- if (LOG) logerror("MM74C922 '%s' Key Released\n", tag());
- }
- }
- else
- {
- for (int y = 0; y < m_max_y; y++)
- {
- if (!BIT(data, y))
- {
- // key depressed
- m_inhibit = 1;
- m_next_da = 1;
- m_y = y;
-
- m_data = (y << 2) | m_x;
-
- if (LOG) logerror("MM74C922 '%s' Key Depressed: X %u Y %u = %02x\n", tag(), m_x, y, m_data);
- return;
- }
- }
- }
-}
diff --git a/src/emu/machine/mm74c922.h b/src/emu/machine/mm74c922.h
deleted file mode 100644
index 88a7bfde186..00000000000
--- a/src/emu/machine/mm74c922.h
+++ /dev/null
@@ -1,138 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MM74C922/MM74C923 16/20-Key Encoder emulation
-
-**********************************************************************
- _____ _____
- ROW Y1 1 |* \_/ | 18 Vcc
- ROW Y2 2 | | 17 DATA OUT A
- ROW Y3 3 | | 16 DATA OUT B
- ROW Y4 4 | | 15 DATA OUT C
- OSCILLATOR 5 | MM74C922 | 14 DATA OUT D
- KEYBOUNCE MASK 6 | | 13 _OUTPUT ENABLE
- COLUMN X4 7 | | 12 DATA AVAILABLE
- COLUMN X3 8 | | 11 COLUMN X1
- GND 9 |_____________| 10 COLUMN X2
-
- _____ _____
- ROW Y1 1 |* \_/ | 20 Vcc
- ROW Y2 2 | | 19 DATA OUT A
- ROW Y3 3 | | 18 DATA OUT B
- ROW Y4 4 | | 17 DATA OUT C
- ROW Y5 5 | MM74C923 | 16 DATA OUT D
- OSCILLATOR 6 | | 15 DATA OUT E
- KEYBOUNCE MASK 7 | | 14 _OUTPUT ENABLE
- COLUMN X4 8 | | 13 DATA AVAILABLE
- COLUMN X3 9 | | 12 COLUMN X1
- GND 10 |_____________| 11 COLUMN X2
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MM74C922__
-#define __MM74C922__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MM74C922_OSC(_value) \
- mm74c922_device::static_set_cap_osc(*device, _value);
-
-#define MCFG_MM74C922_DEBOUNCE(_value) \
- mm74c922_device::static_set_cap_debounce(*device, _value);
-
-#define MCFG_MM74C922_DA_CALLBACK(_write) \
- devcb = &mm74c922_device::set_da_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MM74C922_X1_CALLBACK(_read) \
- devcb = &mm74c922_device::set_x1_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MM74C922_X2_CALLBACK(_read) \
- devcb = &mm74c922_device::set_x2_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MM74C922_X3_CALLBACK(_read) \
- devcb = &mm74c922_device::set_x3_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MM74C922_X4_CALLBACK(_read) \
- devcb = &mm74c922_device::set_x4_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MM74C922_X5_CALLBACK(_read) \
- devcb = &mm74c922_device::set_x5_rd_callback(*device, DEVCB_##_read);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mm74c922_device
-
-class mm74c922_device : public device_t
-{
-public:
- // construction/destruction
- mm74c922_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void static_set_cap_osc(device_t &device, double value) { downcast<mm74c922_device &>(device).m_cap_osc = value; }
- static void static_set_cap_debounce(device_t &device, double value) { downcast<mm74c922_device &>(device).m_cap_debounce = value; }
-
- template<class _Object> static devcb_base &set_da_wr_callback(device_t &device, _Object object) { return downcast<mm74c922_device &>(device).m_write_da.set_callback(object); }
- template<class _Object> static devcb_base &set_x1_rd_callback(device_t &device, _Object object) { return downcast<mm74c922_device &>(device).m_read_x1.set_callback(object); }
- template<class _Object> static devcb_base &set_x2_rd_callback(device_t &device, _Object object) { return downcast<mm74c922_device &>(device).m_read_x2.set_callback(object); }
- template<class _Object> static devcb_base &set_x3_rd_callback(device_t &device, _Object object) { return downcast<mm74c922_device &>(device).m_read_x3.set_callback(object); }
- template<class _Object> static devcb_base &set_x4_rd_callback(device_t &device, _Object object) { return downcast<mm74c922_device &>(device).m_read_x4.set_callback(object); }
- template<class _Object> static devcb_base &set_x5_rd_callback(device_t &device, _Object object) { return downcast<mm74c922_device &>(device).m_read_x5.set_callback(object); }
-
- UINT8 read();
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- void change_output_lines();
- void clock_scan_counters();
- void detect_keypress();
-
- devcb_write_line m_write_da;
- devcb_read8 m_read_x1;
- devcb_read8 m_read_x2;
- devcb_read8 m_read_x3;
- devcb_read8 m_read_x4;
- devcb_read8 m_read_x5;
-
- double m_cap_osc;
- double m_cap_debounce;
-
- int m_max_y;
-
- int m_inhibit; // scan counter clock inhibit
- int m_x; // currently scanned column
- int m_y; // latched row
-
- UINT8 m_data; // data latch
-
- int m_da; // data available flag
- int m_next_da; // next value of data available flag
-
- // timers
- emu_timer *m_scan_timer; // keyboard scan timer
-};
-
-
-// device type definition
-extern const device_type MM74C922;
-extern const device_type MM74C923;
-
-
-
-#endif
diff --git a/src/emu/machine/mos6526.c b/src/emu/machine/mos6526.c
deleted file mode 100644
index 3d9561b36f7..00000000000
--- a/src/emu/machine/mos6526.c
+++ /dev/null
@@ -1,1178 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS 6526/8520 Complex Interface Adapter emulation
-
-**********************************************************************/
-
-/*
-
- TODO:
-
- - pass Lorenz test suite 2.15
- - ICR01
- - IMR
- - CIA1TA/TB
- - CIA2TA/TB
- - pass VICE cia tests
- - 8520 read/write
- - 5710 read/write
- - optimize
-
-*/
-
-#include "mos6526.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-// registers
-enum
-{
- PRA = 0,
- PRB,
- DDRA,
- DDRB,
- TA_LO,
- TA_HI,
- TB_LO,
- TB_HI,
- TOD_10THS,
- TOD_SEC,
- TOD_MIN,
- TOD_HR,
- SDR,
- ICR, IMR = ICR,
- CRA,
- CRB
-};
-
-
-// interrupt control register
-#define ICR_TA 0x01
-#define ICR_TB 0x02
-#define ICR_ALARM 0x04
-#define ICR_SP 0x08
-#define ICR_FLAG 0x10
-
-
-// interrupt mask register
-#define IMR_TA BIT(m_imr, 0)
-#define IMR_TB BIT(m_imr, 1)
-#define IMR_ALARM BIT(m_imr, 2)
-#define IMR_SP BIT(m_imr, 3)
-#define IMR_FLAG BIT(m_imr, 4)
-#define IMR_SET BIT(data, 7)
-
-
-// control register A
-enum
-{
- CRA_INMODE_PHI2 = 0,
- CRA_INMODE_CNT
-};
-
-#define CRA_START 0x01
-#define CRA_STARTED BIT(m_cra, 0)
-#define CRA_PBON BIT(m_cra, 1)
-#define CRA_OUTMODE BIT(m_cra, 2)
-#define CRA_RUNMODE BIT(m_cra, 3)
-#define CRA_LOAD BIT(m_cra, 4)
-#define CRA_INMODE BIT(m_cra, 5)
-#define CRA_SPMODE BIT(m_cra, 6)
-#define CRA_TODIN BIT(m_cra, 7)
-
-
-// control register B
-enum
-{
- CRB_INMODE_PHI2 = 0,
- CRB_INMODE_CNT,
- CRB_INMODE_TA,
- CRB_INMODE_CNT_TA
-};
-
-#define CRB_START 0x01
-#define CRB_STARTED BIT(m_crb, 0)
-#define CRB_PBON BIT(m_crb, 1)
-#define CRB_OUTMODE BIT(m_crb, 2)
-#define CRB_RUNMODE BIT(m_crb, 3)
-#define CRB_LOAD BIT(m_crb, 4)
-#define CRB_INMODE ((m_crb & 0x60) >> 5)
-#define CRB_ALARM BIT(m_crb, 7)
-
-
-
-//**************************************************************************
-// DEVICE TYPE DEFINITIONS
-//**************************************************************************
-
-const device_type MOS6526 = &device_creator<mos6526_device>;
-const device_type MOS6526A = &device_creator<mos6526a_device>;
-const device_type MOS8520 = &device_creator<mos8520_device>;
-const device_type MOS5710 = &device_creator<mos5710_device>;
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// update_pa - update port A
-//-------------------------------------------------
-
-inline void mos6526_device::update_pa()
-{
- UINT8 pa = m_pra | (m_pa_in & ~m_ddra);
-
- if (m_pa != pa)
- {
- m_pa = pa;
- m_write_pa((offs_t)0, pa);
- }
-}
-
-
-//-------------------------------------------------
-// update_pb - update port B
-//-------------------------------------------------
-
-inline void mos6526_device::update_pb()
-{
- UINT8 pb = m_prb | (m_pb_in & ~m_ddrb);
-
- if (CRA_PBON)
- {
- int pb6 = CRA_OUTMODE ? m_ta_pb6 : m_ta_out;
-
- pb &= ~0x40;
- pb |= pb6 << 6;
- }
-
- if (CRB_PBON)
- {
- int pb7 = CRB_OUTMODE ? m_tb_pb7 : m_tb_out;
-
- pb &= ~0x80;
- pb |= pb7 << 7;
- }
-
- if (m_pb != pb)
- {
- m_write_pb((offs_t)0, pb);
- m_pb = pb;
- }
-}
-
-
-//-------------------------------------------------
-// set_cra - control register A write
-//-------------------------------------------------
-
-inline void mos6526_device::set_cra(UINT8 data)
-{
- if (!CRA_STARTED && (data & CRA_START))
- {
- m_ta_pb6 = 1;
- }
-
- // switching to serial output mode causes sp to go high?
- if (!CRA_SPMODE && BIT(data, 6))
- {
- m_bits = 0;
- m_write_sp(1);
- }
-
- // lower sp again when switching back to input?
- if (CRA_SPMODE && !BIT(data, 6))
- {
- m_bits = 0;
- m_write_sp(0);
- }
-
- m_cra = data;
- update_pb();
-}
-
-
-//-------------------------------------------------
-// set_crb - control register B write
-//-------------------------------------------------
-
-inline void mos6526_device::set_crb(UINT8 data)
-{
- if (!CRB_STARTED && (data & CRB_START))
- {
- m_tb_pb7 = 1;
- }
-
- m_crb = data;
- update_pb();
-}
-
-
-//-------------------------------------------------
-// bcd_increment -
-//-------------------------------------------------
-
-inline UINT8 mos6526_device::bcd_increment(UINT8 value)
-{
- value++;
-
- if ((value & 0x0f) >= 0x0a)
- value += 0x10 - 0x0a;
-
- return value;
-}
-
-
-//-------------------------------------------------
-// clock_tod - time-of-day clock pulse
-//-------------------------------------------------
-
-inline void mos6526_device::clock_tod()
-{
- UINT8 subsecond = (UINT8) (m_tod >> 0);
- UINT8 second = (UINT8) (m_tod >> 8);
- UINT8 minute = (UINT8) (m_tod >> 16);
- UINT8 hour = (UINT8) (m_tod >> 24);
-
- m_tod_count++;
-
- if (m_tod_count == (CRA_TODIN ? 5 : 6))
- {
- m_tod_count = 0;
-
- subsecond = bcd_increment(subsecond);
-
- if (subsecond >= 0x10)
- {
- subsecond = 0x00;
- second = bcd_increment(second);
-
- if (second >= 60)
- {
- second = 0x00;
- minute = bcd_increment(minute);
-
- if (minute >= 0x60)
- {
- minute = 0x00;
-
- int pm = hour & 0x80;
- hour &= 0x1f;
-
- if (hour == 11) pm ^= 0x80;
- if (hour == 12) hour = 0;
-
- hour = bcd_increment(hour);
-
- hour |= pm;
- }
- }
- }
- }
-
- m_tod = (((UINT32) subsecond) << 0)
- | (((UINT32) second) << 8)
- | (((UINT32) minute) << 16)
- | (((UINT32) hour) << 24);
-}
-
-
-//-------------------------------------------------
-// clock_tod - time-of-day clock pulse
-//-------------------------------------------------
-
-inline void mos8520_device::clock_tod()
-{
- m_tod++;
- m_tod &= 0xffffff;
-}
-
-
-//-------------------------------------------------
-// read_tod - time-of-day read
-//-------------------------------------------------
-
-inline UINT8 mos6526_device::read_tod(int offset)
-{
- int shift = 8 * offset;
-
- if (m_tod_latched)
- {
- return m_tod_latch >> shift;
- }
- else
- {
- return m_tod >> shift;
- }
-}
-
-
-//-------------------------------------------------
-// write_tod - time-of-day write
-//-------------------------------------------------
-
-inline void mos6526_device::write_tod(int offset, UINT8 data)
-{
- int shift = 8 * offset;
-
- if (CRB_ALARM)
- {
- m_alarm = (m_alarm & ~(0xff << shift)) | (data << shift);
- }
- else
- {
- m_tod = (m_tod & ~(0xff << shift)) | (data << shift);
- }
-}
-
-
-//-------------------------------------------------
-// serial_input -
-//-------------------------------------------------
-
-inline void mos6526_device::serial_input()
-{
- m_shift <<= 1;
- m_bits++;
-
- m_shift |= m_sp;
-
- if (m_bits == 8)
- {
- m_sdr = m_shift;
- m_bits = 0;
-
- m_icr |= ICR_SP;
- }
-}
-
-
-//-------------------------------------------------
-// clock_ta - clock timer A
-//-------------------------------------------------
-
-inline void mos6526_device::clock_ta()
-{
- if (m_count_a3)
- {
- m_ta--;
- }
-
- m_ta_out = (m_count_a2 && !m_ta);
-
- if (m_ta_out)
- {
- m_ta_pb6 = !m_ta_pb6;
-
- if (CRA_RUNMODE || m_oneshot_a0)
- {
- m_cra &= ~CRA_START;
- m_count_a0 = m_count_a1 = m_count_a2 = 0;
- }
-
- m_load_a1 = 1;
- }
-
- if (m_load_a1)
- {
- m_count_a2 = 0;
- m_ta = m_ta_latch;
- }
-}
-
-
-//-------------------------------------------------
-// serial_output -
-//-------------------------------------------------
-
-inline void mos6526_device::serial_output()
-{
- if (m_ta_out && CRA_SPMODE)
- {
- if (!m_sdr_empty || m_bits)
- {
- if (m_cnt)
- {
- if (m_bits == 0)
- {
- m_sdr_empty = true;
- m_shift = m_sdr;
- }
-
- m_sp = BIT(m_shift, 7);
- m_write_sp(m_sp);
-
- m_shift <<= 1;
- m_bits++;
-
- if (m_bits == 8)
- {
- m_icr |= ICR_SP;
- }
- }
- else
- {
- if (m_bits == 8)
- {
- m_bits = 0;
- }
- }
-
- m_cnt = !m_cnt;
- m_write_cnt(m_cnt);
- }
- }
-}
-
-
-//-------------------------------------------------
-// clock_tb - clock timer B
-//-------------------------------------------------
-
-inline void mos6526_device::clock_tb()
-{
- if (m_count_b3)
- {
- m_tb--;
- }
-
- m_tb_out = (m_count_b2 && !m_tb);
-
- if (m_tb_out)
- {
- m_tb_pb7 = !m_tb_pb7;
-
- if (CRB_RUNMODE || m_oneshot_b0)
- {
- m_crb &= ~CRB_START;
- m_count_b0 = m_count_b1 = m_count_b2 = 0;
- }
-
- m_load_b1 = 1;
- }
-
- if (m_load_b1)
- {
- m_count_b2 = 0;
- m_tb = m_tb_latch;
- }
-}
-
-
-//-------------------------------------------------
-// update_interrupt -
-//-------------------------------------------------
-
-inline void mos6526_device::update_interrupt()
-{
- if (!m_irq && m_ir1)
- {
- m_write_irq(ASSERT_LINE);
- m_irq = true;
- }
-
- if (m_ta_out)
- {
- m_icr |= ICR_TA;
- }
-
- if (m_tb_out && !m_icr_read)
- {
- m_icr |= ICR_TB;
- }
-
- m_icr_read = false;
-}
-
-
-//-------------------------------------------------
-// clock_pipeline - clock pipeline
-//-------------------------------------------------
-
-inline void mos6526_device::clock_pipeline()
-{
- // timer A pipeline
- m_count_a3 = m_count_a2;
-
- if (CRA_INMODE == CRA_INMODE_PHI2)
- m_count_a2 = 1;
-
- m_count_a2 &= CRA_STARTED;
- m_count_a1 = m_count_a0;
- m_count_a0 = 0;
-
- m_load_a2 = m_load_a1;
- m_load_a1 = m_load_a0;
- m_load_a0 = CRA_LOAD;
- m_cra &= ~0x10;
-
- m_oneshot_a0 = CRA_RUNMODE;
-
- // timer B pipeline
- m_count_b3 = m_count_b2;
-
- switch (CRB_INMODE)
- {
- case CRB_INMODE_PHI2:
- m_count_b2 = 1;
- break;
-
- case CRB_INMODE_TA:
- m_count_b2 = m_ta_out;
- break;
-
- case CRB_INMODE_CNT_TA:
- m_count_b2 = m_ta_out && m_cnt;
- break;
- }
-
- m_count_b2 &= CRB_STARTED;
- m_count_b1 = m_count_b0;
- m_count_b0 = 0;
-
- m_load_b2 = m_load_b1;
- m_load_b1 = m_load_b0;
- m_load_b0 = CRB_LOAD;
- m_crb &= ~0x10;
-
- m_oneshot_b0 = CRB_RUNMODE;
-
- // interrupt pipeline
- if (m_ir0) m_ir1 = 1;
- m_ir0 = (m_icr & m_imr) ? 1 : 0;
-}
-
-
-//-------------------------------------------------
-// synchronize -
-//-------------------------------------------------
-
-inline void mos6526_device::synchronize()
-{
- if (!m_pc)
- {
- m_pc = 1;
- m_write_pc(m_pc);
- }
-
- clock_ta();
-
- serial_output();
-
- clock_tb();
-
- update_pb();
-
- update_interrupt();
-
- clock_pipeline();
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mos6526_device - constructor
-//-------------------------------------------------
-
-mos6526_device::mos6526_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_execute_interface(mconfig, *this),
- m_icount(0),
- m_variant(variant),
- m_tod_clock(0),
- m_write_irq(*this),
- m_write_pc(*this),
- m_write_cnt(*this),
- m_write_sp(*this),
- m_read_pa(*this),
- m_write_pa(*this),
- m_read_pb(*this),
- m_write_pb(*this)
-{
-}
-
-mos6526_device::mos6526_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MOS6526, "MOS6526", tag, owner, clock, "mos6526", __FILE__),
- device_execute_interface(mconfig, *this),
- m_icount(0),
- m_variant(TYPE_6526),
- m_tod_clock(0),
- m_write_irq(*this),
- m_write_pc(*this),
- m_write_cnt(*this),
- m_write_sp(*this),
- m_read_pa(*this),
- m_write_pa(*this),
- m_read_pb(*this),
- m_write_pb(*this)
-{ }
-
-mos6526a_device::mos6526a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : mos6526_device(mconfig, MOS6526A, "MOS6526A", tag, owner, clock, TYPE_6526A, "mos6526a", __FILE__) { }
-
-mos8520_device::mos8520_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : mos6526_device(mconfig, MOS8520, "MOS8520", tag, owner, clock, TYPE_8520, "mos8520", __FILE__) { }
-
-mos5710_device::mos5710_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : mos6526_device(mconfig, MOS5710, "MOS5710", tag, owner, clock, TYPE_5710, "mos5710", __FILE__) { }
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mos6526_device::device_start()
-{
- // set our instruction counter
- m_icountptr = &m_icount;
-
- m_flag = 1;
- m_cnt = 1;
- m_cra = 0;
-
- // resolve callbacks
- m_write_irq.resolve_safe();
- m_write_pc.resolve_safe();
- m_write_cnt.resolve_safe();
- m_write_sp.resolve_safe();
- m_read_pa.resolve_safe(0xff);
- m_write_pa.resolve_safe();
- m_read_pb.resolve_safe(0xff);
- m_write_pb.resolve_safe();
-
- // allocate timer
- if (m_tod_clock > 0)
- {
- m_tod_timer = timer_alloc();
- m_tod_timer->adjust(attotime::from_hz(m_tod_clock), 0, attotime::from_hz(m_tod_clock));
- }
-
- // state saving
- save_item(NAME(m_ir0));
- save_item(NAME(m_ir1));
- save_item(NAME(m_icr));
- save_item(NAME(m_imr));
- save_item(NAME(m_pc));
- save_item(NAME(m_flag));
- save_item(NAME(m_pra));
- save_item(NAME(m_prb));
- save_item(NAME(m_ddra));
- save_item(NAME(m_ddrb));
- save_item(NAME(m_sp));
- save_item(NAME(m_cnt));
- save_item(NAME(m_sdr));
- save_item(NAME(m_shift));
- save_item(NAME(m_sdr_empty));
- save_item(NAME(m_bits));
-
- save_item(NAME(m_ta_out));
- save_item(NAME(m_tb_out));
- save_item(NAME(m_ta_pb6));
- save_item(NAME(m_tb_pb7));
- save_item(NAME(m_ta));
- save_item(NAME(m_tb));
- save_item(NAME(m_ta_latch));
- save_item(NAME(m_tb_latch));
- save_item(NAME(m_cra));
- save_item(NAME(m_crb));
-
- save_item(NAME(m_tod_count));
- save_item(NAME(m_tod));
- save_item(NAME(m_tod_latch));
- save_item(NAME(m_alarm));
- save_item(NAME(m_tod_stopped));
- save_item(NAME(m_tod_latched));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mos6526_device::device_reset()
-{
- m_irq = false;
- m_ir0 = 0;
- m_ir1 = 0;
- m_icr = 0;
- m_imr = 0;
- m_icr_read = false;
-
- m_pc = 1;
- m_flag = 1;
- m_pra = 0;
- m_prb = 0;
- m_ddra = 0;
- m_ddrb = 0;
- m_pa = 0xff;
- m_pb = 0xff;
- m_pa_in = 0;
- m_pb_in = 0;
-
- m_sp = 1;
- m_cnt = 1;
- m_sdr = 0;
- m_shift = 0;
- m_sdr_empty = true;
- m_bits = 0;
-
- m_ta_out = 0;
- m_tb_out = 0;
- m_ta_pb6 = 0;
- m_tb_pb7 = 0;
- m_count_a0 = 0;
- m_count_a1 = 0;
- m_count_a2 = 0;
- m_count_a3 = 0;
- m_load_a0 = 0;
- m_load_a1 = 0;
- m_load_a2 = 0;
- m_oneshot_a0 = 0;
- m_count_b0 = 0;
- m_count_b1 = 0;
- m_count_b2 = 0;
- m_count_b3 = 0;
- m_load_b0 = 0;
- m_load_b1 = 0;
- m_load_b2 = 0;
- m_oneshot_b0 = 0;
- m_ta = 0;
- m_tb = 0;
- m_ta_latch = 0xffff;
- m_tb_latch = 0xffff;
- m_cra = 0;
- m_crb = 0;
-
- m_tod_count = 0;
- m_tod = 0x01000000L;
- m_tod_latch = 0;
- m_alarm = 0;
- m_tod_stopped = true;
- m_tod_latched = false;
-
- m_write_irq(CLEAR_LINE);
- m_write_pc(m_pc);
- m_write_sp(m_sp);
- m_write_cnt(m_cnt);
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void mos6526_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- tod_w(1);
- tod_w(0);
-}
-
-
-//-------------------------------------------------
-// execute_run -
-//-------------------------------------------------
-
-void mos6526_device::execute_run()
-{
- do
- {
- synchronize();
-
- m_icount--;
- } while (m_icount > 0);
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( mos6526_device::read )
-{
- if (space.debugger_access())
- return 0xff;
-
- UINT8 data = 0;
-
- switch (offset & 0x0f)
- {
- case PRA:
- if (m_ddra != 0xff)
- data = (m_read_pa(0) & ~m_ddra) | (m_pra & m_ddra);
- else
- data = m_read_pa(0) & m_pra;
- m_pa_in = data;
- break;
-
- case PRB:
- if (m_ddrb != 0xff)
- data = (m_read_pb(0) & ~m_ddrb) | (m_prb & m_ddrb);
- else
- data = m_read_pb(0) & m_prb;
- m_pb_in = data;
-
- if (CRA_PBON)
- {
- int pb6 = CRA_OUTMODE ? m_ta_pb6 : m_ta_out;
-
- data &= ~0x40;
- data |= pb6 << 6;
- }
-
- if (CRB_PBON)
- {
- int pb7 = CRB_OUTMODE ? m_tb_pb7 : m_tb_out;
-
- data &= ~0x80;
- data |= pb7 << 7;
- }
-
- m_pc = 0;
- m_write_pc(m_pc);
- break;
-
- case DDRA:
- data = m_ddra;
- break;
-
- case DDRB:
- data = m_ddrb;
- break;
-
- case TA_LO:
- data = m_ta & 0xff;
- break;
-
- case TA_HI:
- data = m_ta >> 8;
- break;
-
- case TB_LO:
- data = m_tb & 0xff;
- break;
-
- case TB_HI:
- data = m_tb >> 8;
- break;
-
- case TOD_10THS:
- data = read_tod(0);
-
- m_tod_latched = false;
- break;
-
- case TOD_SEC:
- data = read_tod(1);
- break;
-
- case TOD_MIN:
- data = read_tod(2);
- break;
-
- case TOD_HR:
- if (!m_tod_latched)
- {
- m_tod_latched = true;
- m_tod_latch = m_tod;
- }
-
- data = read_tod(3);
- break;
-
- case SDR:
- data = m_sdr;
- break;
-
- case ICR:
- data = (m_ir1 << 7) | m_icr;
-
- m_icr_read = true;
-
- m_ir0 = 0;
- m_ir1 = 0;
- m_icr = 0;
- m_irq = false;
- m_write_irq(CLEAR_LINE);
- break;
-
- case CRA:
- data = m_cra;
- break;
-
- case CRB:
- data = m_crb;
- break;
- }
-
- return data;
-}
-
-READ8_MEMBER( mos8520_device::read )
-{
- UINT8 data = 0;
-
- switch (offset & 0x0f)
- {
- case TOD_MIN:
- if (!m_tod_latched)
- {
- m_tod_latched = true;
- m_tod_latch = m_tod;
- }
-
- data = read_tod(2);
- break;
-
- case TOD_HR:
- data = read_tod(3);
- break;
-
- default:
- data = mos6526_device::read(space, offset);
- }
-
- return data;
-}
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( mos6526_device::write )
-{
- switch (offset & 0x0f)
- {
- case PRA:
- m_pra = data;
- update_pa();
- break;
-
- case PRB:
- m_prb = data;
- update_pb();
-
- m_pc = 0;
- m_write_pc(m_pc);
- break;
-
- case DDRA:
- m_ddra = data;
- update_pa();
- break;
-
- case DDRB:
- m_ddrb = data;
- update_pb();
- break;
-
- case TA_LO:
- m_ta_latch = (m_ta_latch & 0xff00) | data;
-
- if (m_load_a2)
- {
- m_ta = (m_ta & 0xff00) | data;
- }
- break;
-
- case TA_HI:
- m_ta_latch = (data << 8) | (m_ta_latch & 0xff);
-
- if (!CRA_STARTED)
- {
- m_load_a0 = 1;
- }
-
- if (CRA_RUNMODE)
- {
- m_ta = m_ta_latch;
- set_cra(m_cra | CRA_START);
- }
-
- if (m_load_a2)
- {
- m_ta = (data << 8) | (m_ta & 0xff);
- }
- break;
-
- case TB_LO:
- m_tb_latch = (m_tb_latch & 0xff00) | data;
-
- if (m_load_b2)
- {
- m_tb = (m_tb & 0xff00) | data;
- }
- break;
-
- case TB_HI:
- m_tb_latch = (data << 8) | (m_tb_latch & 0xff);
-
- if (!CRB_STARTED)
- {
- m_load_b0 = 1;
- }
-
- if (CRB_RUNMODE)
- {
- m_tb = m_tb_latch;
- set_crb(m_crb | CRB_START);
- }
-
- if (m_load_b2)
- {
- m_tb = (data << 8) | (m_tb & 0xff);
- }
- break;
-
- case TOD_10THS:
- write_tod(0, data);
-
- m_tod_stopped = false;
- break;
-
- case TOD_SEC:
- write_tod(1, data);
- break;
-
- case TOD_MIN:
- write_tod(2, data);
- break;
-
- case TOD_HR:
- m_tod_stopped = true;
-
- if (((data & 0x1f) == 0x12) && !CRB_ALARM)
- {
- // toggle AM/PM flag
- data ^= 0x80;
- }
-
- write_tod(3, data);
- break;
-
- case SDR:
- m_sdr = data;
- m_sdr_empty = false;
- break;
-
- case IMR:
- if (IMR_SET)
- {
- m_imr |= (data & 0x1f);
- }
- else
- {
- m_imr &= ~(data & 0x1f);
- }
-
- if (!m_irq && (m_icr & m_imr))
- {
- m_ir0 = 1;
- }
- break;
-
- case CRA:
- set_cra(data);
- break;
-
- case CRB:
- set_crb(data);
- break;
- }
-}
-
-WRITE8_MEMBER( mos8520_device::write )
-{
- switch (offset & 0x0f)
- {
- default:
- mos6526_device::write(space, offset, data);
- break;
-
- case TOD_MIN:
- m_tod_stopped = true;
- write_tod(2, data);
- break;
-
- case TOD_HR:
- write_tod(3, data);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// sp_w - serial port write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mos6526_device::sp_w )
-{
- m_sp = state;
-}
-
-
-//-------------------------------------------------
-// cnt_w - serial counter write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mos6526_device::cnt_w )
-{
- if (CRA_SPMODE) return;
-
- if (!m_cnt && state)
- {
- serial_input();
-
- if (CRA_INMODE == CRA_INMODE_CNT)
- m_ta--;
-
- if (CRB_INMODE == CRB_INMODE_CNT)
- m_tb--;
- }
-
- m_cnt = state;
-}
-
-
-//-------------------------------------------------
-// flag_w - flag write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mos6526_device::flag_w )
-{
- if (m_flag && !state)
- {
- m_icr |= ICR_FLAG;
- }
-
- m_flag = state;
-}
-
-
-//-------------------------------------------------
-// tod_w - time-of-day clock write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mos6526_device::tod_w )
-{
- if (state && !m_tod_stopped)
- {
- clock_tod();
-
- if (m_tod == m_alarm)
- {
- m_icr |= ICR_ALARM;
- }
- }
-}
diff --git a/src/emu/machine/mos6526.h b/src/emu/machine/mos6526.h
deleted file mode 100644
index da54967e080..00000000000
--- a/src/emu/machine/mos6526.h
+++ /dev/null
@@ -1,296 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS 6526/8520 Complex Interface Adapter emulation
-
-**********************************************************************
- _____ _____
- Vss 1 |* \_/ | 40 CNT
- PA0 2 | | 39 SP
- PA1 3 | | 38 RS0
- PA2 4 | | 37 RS1
- PA3 5 | | 36 RS2
- PA4 6 | | 35 RS3
- PA5 7 | | 34 _RES
- PA6 8 | | 33 DB0
- PA7 9 | | 32 DB1
- PB0 10 | MOS6526 | 31 DB2
- PB1 11 | MOS8520 | 30 DB3
- PB2 12 | | 29 DB4
- PB3 13 | | 28 DB5
- PB4 14 | | 27 DB6
- PB5 15 | | 26 DB7
- PB6 16 | | 25 phi2
- PB7 17 | | 24 _FLAG
- _PC 18 | | 23 _CS
- TOD 19 | | 22 R/W
- Vcc 20 |_____________| 21 _IRQ
-
- _____ _____
- FCO* 1 |* \_/ | 48 FDO*
- TED 2 | | 47 FCI*
- phi0 3 | | 46 FDI*
- CLKIN 4 | | 45 IRQ
- CTRLO 5 | | 44 RSET
- CTRLI 6 | | 43
- phi2 7 | | 42
- D7 8 | | 41 INDEX*
- D6 9 | | 40 WG2*
- D5 10 | | 39 WPRT*
- D4 11 | | 38 RPULSE
- GND 12 | MOS5710 | 37 Q
- Vcc 13 | | 36 Vcc
- D3 14 | | 35 GND
- D2 15 | | 34 CS3*
- D1 16 | | 33 CS2*
- D0 17 | | 32 CS1*
- A15 18 | | 31 R/W*
- A14 19 | | 30 OSC
- A13 20 | | 29 XTL1
- A12 21 | | 28 XTL2
- A10 22 | | 27 A0
- A4 23 | | 26 A1
- A3 24 |_____________| 25 A2
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MOS6526__
-#define __MOS6526__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MOS6526_TOD(_clock) \
- mos6526_device::static_set_tod_clock(*device, _clock);
-
-#define MCFG_MOS6526_IRQ_CALLBACK(_write) \
- devcb = &mos6526_device::set_irq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6526_CNT_CALLBACK(_write) \
- devcb = &mos6526_device::set_cnt_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6526_SP_CALLBACK(_write) \
- devcb = &mos6526_device::set_sp_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6526_PA_INPUT_CALLBACK(_read) \
- devcb = &mos6526_device::set_pa_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6526_PA_OUTPUT_CALLBACK(_write) \
- devcb = &mos6526_device::set_pa_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6526_PB_INPUT_CALLBACK(_read) \
- devcb = &mos6526_device::set_pb_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6526_PB_OUTPUT_CALLBACK(_write) \
- devcb = &mos6526_device::set_pb_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6526_PC_CALLBACK(_write) \
- devcb = &mos6526_device::set_pc_wr_callback(*device, DEVCB_##_write);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mos6526_device
-
-class mos6526_device : public device_t,
- public device_execute_interface
-{
-public:
- // construction/destruction
- mos6526_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source);
- mos6526_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void static_set_tod_clock(device_t &device, int clock) { downcast<mos6526_device &>(device).m_tod_clock = clock; }
-
- template<class _Object> static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<mos6526_device &>(device).m_write_irq.set_callback(object); }
- template<class _Object> static devcb_base &set_cnt_wr_callback(device_t &device, _Object object) { return downcast<mos6526_device &>(device).m_write_cnt.set_callback(object); }
- template<class _Object> static devcb_base &set_sp_wr_callback(device_t &device, _Object object) { return downcast<mos6526_device &>(device).m_write_sp.set_callback(object); }
- template<class _Object> static devcb_base &set_pa_rd_callback(device_t &device, _Object object) { return downcast<mos6526_device &>(device).m_read_pa.set_callback(object); }
- template<class _Object> static devcb_base &set_pa_wr_callback(device_t &device, _Object object) { return downcast<mos6526_device &>(device).m_write_pa.set_callback(object); }
- template<class _Object> static devcb_base &set_pb_rd_callback(device_t &device, _Object object) { return downcast<mos6526_device &>(device).m_read_pb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb_wr_callback(device_t &device, _Object object) { return downcast<mos6526_device &>(device).m_write_pb.set_callback(object); }
- template<class _Object> static devcb_base &set_pc_wr_callback(device_t &device, _Object object) { return downcast<mos6526_device &>(device).m_write_pc.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- UINT8 pa_r() { return m_pa; }
- DECLARE_READ8_MEMBER( pa_r ) { return pa_r(); }
- UINT8 pb_r() { return m_pb; }
- DECLARE_READ8_MEMBER( pb_r ) { return pb_r(); }
-
- DECLARE_READ_LINE_MEMBER( sp_r ) { return m_sp; }
- DECLARE_WRITE_LINE_MEMBER( sp_w );
- DECLARE_READ_LINE_MEMBER( cnt_r ) { return m_cnt; }
- DECLARE_WRITE_LINE_MEMBER( cnt_w );
- DECLARE_WRITE_LINE_MEMBER( flag_w );
- DECLARE_READ_LINE_MEMBER( irq_r ) { return m_irq; }
- DECLARE_WRITE_LINE_MEMBER( tod_w );
-
-protected:
- enum
- {
- TYPE_6526,
- TYPE_6526A,
- TYPE_8520,
- TYPE_5710
- };
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual void execute_run();
-
- int m_icount;
- int m_variant;
- int m_tod_clock;
-
- inline void update_interrupt();
- inline void update_pa();
- inline void update_pb();
- inline void set_cra(UINT8 data);
- inline void set_crb(UINT8 data);
- inline void serial_input();
- inline void serial_output();
- inline void clock_ta();
- inline void clock_tb();
- inline void clock_pipeline();
- inline UINT8 bcd_increment(UINT8 value);
- virtual inline void clock_tod();
- inline UINT8 read_tod(int offset);
- inline void write_tod(int offset, UINT8 data);
- inline void synchronize();
-
- devcb_write_line m_write_irq;
- devcb_write_line m_write_pc;
- devcb_write_line m_write_cnt;
- devcb_write_line m_write_sp;
- devcb_read8 m_read_pa;
- devcb_write8 m_write_pa;
- devcb_read8 m_read_pb;
- devcb_write8 m_write_pb;
-
- // interrupts
- bool m_irq;
- int m_ir0;
- int m_ir1;
- UINT8 m_icr;
- UINT8 m_imr;
- bool m_icr_read;
-
- // peripheral ports
- int m_pc;
- int m_flag;
- UINT8 m_pra;
- UINT8 m_prb;
- UINT8 m_ddra;
- UINT8 m_ddrb;
- UINT8 m_pa;
- UINT8 m_pb;
- UINT8 m_pa_in;
- UINT8 m_pb_in;
-
- // serial
- int m_sp;
- int m_cnt;
- UINT8 m_sdr;
- UINT8 m_shift;
- bool m_sdr_empty;
- int m_bits;
-
- // timers
- int m_ta_out;
- int m_tb_out;
- int m_ta_pb6;
- int m_tb_pb7;
- int m_count_a0;
- int m_count_a1;
- int m_count_a2;
- int m_count_a3;
- int m_load_a0;
- int m_load_a1;
- int m_load_a2;
- int m_oneshot_a0;
- int m_count_b0;
- int m_count_b1;
- int m_count_b2;
- int m_count_b3;
- int m_load_b0;
- int m_load_b1;
- int m_load_b2;
- int m_oneshot_b0;
- UINT16 m_ta;
- UINT16 m_tb;
- UINT16 m_ta_latch;
- UINT16 m_tb_latch;
- UINT8 m_cra;
- UINT8 m_crb;
-
- // time-of-day
- int m_tod_count;
- UINT32 m_tod;
- UINT32 m_tod_latch;
- UINT32 m_alarm;
- bool m_tod_stopped;
- bool m_tod_latched;
- emu_timer *m_tod_timer;
-};
-
-
-// ======================> mos6526a_device
-
-class mos6526a_device : public mos6526_device
-{
-public:
- mos6526a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-
-// ======================> mos8520_device
-
-class mos8520_device : public mos6526_device
-{
-public:
- mos8520_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
-protected:
- virtual inline void clock_tod();
-};
-
-
-// ======================> mos5710_device
-
-class mos5710_device : public mos6526_device
-{
-public:
- mos5710_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- //DECLARE_READ8_MEMBER( read );
- //DECLARE_WRITE8_MEMBER( write );
-};
-
-
-// device type definition
-extern const device_type MOS6526;
-extern const device_type MOS6526A;
-extern const device_type MOS8520;
-extern const device_type MOS5710;
-
-
-
-#endif
diff --git a/src/emu/machine/mos6529.c b/src/emu/machine/mos6529.c
deleted file mode 100644
index ebae2ca6f5a..00000000000
--- a/src/emu/machine/mos6529.c
+++ /dev/null
@@ -1,95 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS Technology 6529 Single Port Interface Adapter emulation
-
-**********************************************************************/
-
-#include "mos6529.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-// device type definition
-const device_type MOS6529 = &device_creator<mos6529_device>;
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mos6529_device - constructor
-//-------------------------------------------------
-
-mos6529_device::mos6529_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MOS6529, "MOS6529", tag, owner, clock, "mos6529", __FILE__),
- m_input(0),
- m_p0_handler(*this),
- m_p1_handler(*this),
- m_p2_handler(*this),
- m_p3_handler(*this),
- m_p4_handler(*this),
- m_p5_handler(*this),
- m_p6_handler(*this),
- m_p7_handler(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mos6529_device::device_start()
-{
- // resolve callbacks
- m_p0_handler.resolve_safe();
- m_p1_handler.resolve_safe();
- m_p2_handler.resolve_safe();
- m_p3_handler.resolve_safe();
- m_p4_handler.resolve_safe();
- m_p5_handler.resolve_safe();
- m_p6_handler.resolve_safe();
- m_p7_handler.resolve_safe();
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( mos6529_device::read )
-{
- return m_input;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( mos6529_device::write )
-{
- m_p0_handler((data>>0)&1);
- m_p1_handler((data>>1)&1);
- m_p2_handler((data>>2)&1);
- m_p3_handler((data>>3)&1);
- m_p4_handler((data>>4)&1);
- m_p5_handler((data>>5)&1);
- m_p6_handler((data>>6)&1);
- m_p7_handler((data>>7)&1);
-}
diff --git a/src/emu/machine/mos6529.h b/src/emu/machine/mos6529.h
deleted file mode 100644
index 0e6f00f4dd0..00000000000
--- a/src/emu/machine/mos6529.h
+++ /dev/null
@@ -1,113 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS Technology 6529 Single Port Interface Adapter emulation
-
-**********************************************************************
- _____ _____
- R/W 1 |* \_/ | 20 Vdd
- P0 2 | | 19 _CS
- P1 3 | | 18 D0
- P2 4 | | 17 D1
- P3 5 | MOS6529 | 16 D2
- P4 6 | | 15 D3
- P5 7 | | 14 D4
- P6 8 | | 13 D5
- P7 9 | | 12 D6
- Vss 10 |_____________| 11 D7
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MOS6529__
-#define __MOS6529__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MOS6529_P0_HANDLER(_devcb) \
- devcb = &mos6529_device::set_p0_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6529_P1_HANDLER(_devcb) \
- devcb = &mos6529_device::set_p1_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6529_P2_HANDLER(_devcb) \
- devcb = &mos6529_device::set_p2_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6529_P3_HANDLER(_devcb) \
- devcb = &mos6529_device::set_p3_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6529_P4_HANDLER(_devcb) \
- devcb = &mos6529_device::set_p4_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6529_P5_HANDLER(_devcb) \
- devcb = &mos6529_device::set_p5_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6529_P6_HANDLER(_devcb) \
- devcb = &mos6529_device::set_p6_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6529_P7_HANDLER(_devcb) \
- devcb = &mos6529_device::set_p7_handler(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mos6529_device
-
-class mos6529_device : public device_t
-{
-public:
- // construction/destruction
- mos6529_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_p0_handler(device_t &device, _Object object) { return downcast<mos6529_device &>(device).m_p0_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_p1_handler(device_t &device, _Object object) { return downcast<mos6529_device &>(device).m_p1_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_p2_handler(device_t &device, _Object object) { return downcast<mos6529_device &>(device).m_p2_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_p3_handler(device_t &device, _Object object) { return downcast<mos6529_device &>(device).m_p3_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_p4_handler(device_t &device, _Object object) { return downcast<mos6529_device &>(device).m_p4_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_p5_handler(device_t &device, _Object object) { return downcast<mos6529_device &>(device).m_p5_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_p6_handler(device_t &device, _Object object) { return downcast<mos6529_device &>(device).m_p6_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_p7_handler(device_t &device, _Object object) { return downcast<mos6529_device &>(device).m_p7_handler.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( write_p0 ) { if (state) m_input |= 1; else m_input &= ~1; }
- DECLARE_WRITE_LINE_MEMBER( write_p1 ) { if (state) m_input |= 2; else m_input &= ~2; }
- DECLARE_WRITE_LINE_MEMBER( write_p2 ) { if (state) m_input |= 4; else m_input &= ~4; }
- DECLARE_WRITE_LINE_MEMBER( write_p3 ) { if (state) m_input |= 8; else m_input &= ~8; }
- DECLARE_WRITE_LINE_MEMBER( write_p4 ) { if (state) m_input |= 16; else m_input &= ~16; }
- DECLARE_WRITE_LINE_MEMBER( write_p5 ) { if (state) m_input |= 32; else m_input &= ~32; }
- DECLARE_WRITE_LINE_MEMBER( write_p6 ) { if (state) m_input |= 64; else m_input &= ~64; }
- DECLARE_WRITE_LINE_MEMBER( write_p7 ) { if (state) m_input |= 128; else m_input &= ~128; }
-
-protected:
- // device-level overrides
- virtual void device_start();
-
- UINT8 m_input;
-
- devcb_write_line m_p0_handler;
- devcb_write_line m_p1_handler;
- devcb_write_line m_p2_handler;
- devcb_write_line m_p3_handler;
- devcb_write_line m_p4_handler;
- devcb_write_line m_p5_handler;
- devcb_write_line m_p6_handler;
- devcb_write_line m_p7_handler;
-};
-
-
-// device type definition
-extern const device_type MOS6529;
-
-#endif
diff --git a/src/emu/machine/mos6530.c b/src/emu/machine/mos6530.c
deleted file mode 100644
index a32383fcbda..00000000000
--- a/src/emu/machine/mos6530.c
+++ /dev/null
@@ -1,382 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- MIOT 6530 emulation
-
-The timer seems to follow these rules:
-- When the timer flag changes from 0 to 1 the timer continues to count
- down at a 1 cycle rate.
-- When the timer is being read or written the timer flag is reset.
-- When the timer flag is set and the timer contents are 0, the counting
- stops.
-
-From the operation of the KIM1 it expects the irqflag to be set whenever
-the unit is reset. This is something that is not clear from the datasheet
-and should be verified against real hardware.
-
-***************************************************************************/
-
-#include "emu.h"
-#include "mos6530.h"
-
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-enum
-{
- TIMER_IDLE,
- TIMER_COUNTING,
- TIMER_FINISHING
-};
-
-#define TIMER_FLAG 0x80
-
-/***************************************************************************
- DEVICE INTERFACE
-***************************************************************************/
-
-const device_type MOS6530 = &device_creator<mos6530_device>;
-
-mos6530_device::mos6530_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MOS6530, "MOS6530 RRIOT", tag, owner, clock, "mos6530", __FILE__),
- m_in_pa_cb(*this),
- m_out_pa_cb(*this),
- m_in_pb_cb(*this),
- m_out_pb_cb(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mos6530_device::device_start()
-{
- /* set static values */
- m_clock = clock();
-
- /* resolve callbacks */
- m_in_pa_cb.resolve_safe(0);
- m_out_pa_cb.resolve_safe();
- m_in_pb_cb.resolve_safe(0);
- m_out_pb_cb.resolve_safe();
-
- /* allocate timers */
- m_timer = timer_alloc(TIMER_END_CALLBACK);
-
- /* register for save states */
- save_item(NAME(m_port[0].m_in));
- save_item(NAME(m_port[0].m_out));
- save_item(NAME(m_port[0].m_ddr));
- save_item(NAME(m_port[1].m_in));
- save_item(NAME(m_port[1].m_out));
- save_item(NAME(m_port[1].m_ddr));
-
- save_item(NAME(m_irqstate));
- save_item(NAME(m_irqenable));
-
- save_item(NAME(m_timershift));
- save_item(NAME(m_timerstate));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mos6530_device::device_reset()
-{
- /* reset I/O states */
- m_port[0].m_out = 0;
- m_port[0].m_ddr = 0;
- m_port[1].m_out = 0;
- m_port[1].m_ddr = 0;
-
- /* reset IRQ states */
- m_irqenable = 0;
- m_irqstate = TIMER_FLAG;
- update_irqstate();
-
- /* reset timer states */
- m_timershift = 0;
- m_timerstate = TIMER_IDLE;
- m_timer->adjust(attotime::never);
-}
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-
-/*-------------------------------------------------
- update_irqstate - update the IRQ state
- based on interrupt enables
--------------------------------------------------*/
-
-void mos6530_device::update_irqstate()
-{
- UINT8 out = m_port[1].m_out;
-
- if (m_irqenable)
- out = ((m_irqstate & TIMER_FLAG) ? 0x00 : 0x80) | (out & 0x7F);
-
- m_out_pb_cb((offs_t)0, out);
-}
-
-
-/*-------------------------------------------------
- get_timer - return the current timer value
--------------------------------------------------*/
-
-UINT8 mos6530_device::get_timer()
-{
- /* if idle, return 0 */
- if (m_timerstate == TIMER_IDLE)
- return 0;
-
- /* if counting, return the number of ticks remaining */
- else if (m_timerstate == TIMER_COUNTING)
- return m_timer->remaining().as_ticks(m_clock) >> m_timershift;
-
- /* if finishing, return the number of ticks without the shift */
- else
- return m_timer->remaining().as_ticks(m_clock);
-}
-
-
-/***************************************************************************
- INTERNAL FUNCTIONS
-***************************************************************************/
-
-/*-------------------------------------------------
- timer_end_callback - callback to process the
- timer
--------------------------------------------------*/
-
-void mos6530_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- // deferred reset
- case TIMER_END_CALLBACK:
- assert(m_timerstate != TIMER_IDLE);
-
- /* if we finished counting, switch to the finishing state */
- if (m_timerstate == TIMER_COUNTING)
- {
- m_timerstate = TIMER_FINISHING;
- m_timer->adjust(attotime::from_ticks(256, m_clock));
-
- /* signal timer IRQ as well */
- m_irqstate |= TIMER_FLAG;
- update_irqstate();
- }
-
- /* if we finished finishing, switch to the idle state */
- else if (m_timerstate == TIMER_FINISHING)
- {
- m_timerstate = TIMER_IDLE;
- m_timer->adjust(attotime::never);
- }
- break;
- }
-}
-
-/***************************************************************************
- I/O ACCESS
-***************************************************************************/
-
-/*-------------------------------------------------
- mos6530_w - master I/O write access
--------------------------------------------------*/
-
-WRITE8_MEMBER( mos6530_device::write )
-{
- /* if A2 == 1, we are writing to the timer */
- if (offset & 0x04)
- {
- static const UINT8 timershift[4] = { 0, 3, 6, 10 };
- attotime curtime = space.machine().time();
- INT64 target;
-
- /* A0-A1 contain the timer divisor */
- m_timershift = timershift[offset & 3];
-
- /* A3 contains the timer IRQ enable */
- if (offset & 8)
- m_irqenable |= TIMER_FLAG;
- else
- m_irqenable &= ~TIMER_FLAG;
-
- /* writes here clear the timer flag */
- if (m_timerstate != TIMER_FINISHING || get_timer() != 0xff)
- m_irqstate &= ~TIMER_FLAG;
- update_irqstate();
-
- /* update the timer */
- m_timerstate = TIMER_COUNTING;
- target = curtime.as_ticks(m_clock) + 1 + (data << m_timershift);
- m_timer->adjust(attotime::from_ticks(target, m_clock) - curtime);
- }
-
- /* if A2 == 0, we are writing to the I/O section */
- else
- {
- /* A1 selects the port */
- mos6530_port *port = &m_port[BIT(offset, 1)];
-
- /* if A0 == 1, we are writing to the port's DDR */
- if (offset & 1)
- port->m_ddr = data;
-
- /* if A0 == 0, we are writing to the port's output */
- else
- {
- UINT8 olddata = port->m_out;
- port->m_out = data;
-
- if ((offset & 2) && m_irqenable)
- {
- olddata = ((m_irqstate & TIMER_FLAG) ? 0x00 : 0x80) | (olddata & 0x7F);
- data = ((m_irqstate & TIMER_FLAG) ? 0x00 : 0x80) | (data & 0x7F);
- }
-
- if (!BIT(offset, 1))
- m_out_pa_cb((offs_t)0, data);
- else
- m_out_pb_cb((offs_t)0, data);
- }
- }
-}
-
-
-/*-------------------------------------------------
- mos6530_r - master I/O read access
--------------------------------------------------*/
-
-READ8_MEMBER( mos6530_device::read )
-{
- UINT8 val = 0;
-
- /* if A2 == 1 and A0 == 1, we are reading interrupt flags */
- if ((offset & 0x05) == 0x05)
- {
- val = m_irqstate;
- }
-
- /* if A2 == 1 and A0 == 0, we are reading the timer */
- else if ((offset & 0x05) == 0x04)
- {
- val = get_timer();
-
- /* A3 contains the timer IRQ enable */
- if (offset & 8)
- m_irqenable |= TIMER_FLAG;
- else
- m_irqenable &= ~TIMER_FLAG;
-
- /* implicitly clears the timer flag */
- if (m_timerstate != TIMER_FINISHING || val != 0xff)
- m_irqstate &= ~TIMER_FLAG;
- update_irqstate();
- }
-
- /* if A2 == 0 and A0 == anything, we are reading from ports */
- else
- {
- /* A1 selects the port */
- mos6530_port *port = &m_port[BIT(offset, 1)];
-
- /* if A0 == 1, we are reading the port's DDR */
- if (offset & 1)
- val = port->m_ddr;
-
- /* if A0 == 0, we are reading the port as an input */
- else
- {
- UINT8 out = port->m_out;
-
- if ((offset & 2) && m_irqenable)
- out = ((m_irqstate & TIMER_FLAG) ? 0x00 : 0x80) | (out & 0x7F);
-
- /* call the input callback if it exists */
- if (!BIT(offset, 1))
- port->m_in = m_in_pa_cb(0);
- else
- port->m_in = m_in_pb_cb(0);
-
- /* apply the DDR to the result */
- val = (out & port->m_ddr) | (port->m_in & ~port->m_ddr);
- }
- }
- return val;
-}
-
-
-/*-------------------------------------------------
- mos6530_porta_in_set - set port A input
- value
--------------------------------------------------*/
-
-void mos6530_device::porta_in_set(UINT8 data, UINT8 mask)
-{
- m_port[0].m_in = (m_port[0].m_in & ~mask) | (data & mask);
-}
-
-
-/*-------------------------------------------------
- mos6530_portb_in_set - set port B input
- value
--------------------------------------------------*/
-
-void mos6530_device::portb_in_set(UINT8 data, UINT8 mask)
-{
- m_port[1].m_in = (m_port[1].m_in & ~mask) | (data & mask);
-}
-
-
-/*-------------------------------------------------
- mos6530_porta_in_get - return port A input
- value
--------------------------------------------------*/
-
-UINT8 mos6530_device::porta_in_get()
-{
- return m_port[0].m_in;
-}
-
-
-/*-------------------------------------------------
- mos6530_portb_in_get - return port B input
- value
--------------------------------------------------*/
-
-UINT8 mos6530_device::portb_in_get()
-{
- return m_port[1].m_in;
-}
-
-
-/*-------------------------------------------------
- mos6530_porta_in_get - return port A output
- value
--------------------------------------------------*/
-
-UINT8 mos6530_device::porta_out_get()
-{
- return m_port[0].m_out;
-}
-
-
-/*-------------------------------------------------
- mos6530_portb_in_get - return port B output
- value
--------------------------------------------------*/
-
-UINT8 mos6530_device::portb_out_get()
-{
- return m_port[1].m_out;
-}
diff --git a/src/emu/machine/mos6530.h b/src/emu/machine/mos6530.h
deleted file mode 100644
index d63fdd95a12..00000000000
--- a/src/emu/machine/mos6530.h
+++ /dev/null
@@ -1,124 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS Technology 6530 Memory, I/O, Timer Array emulation
-
-**********************************************************************
- _____ _____
- Vss 1 |* \_/ | 40 PA1
- PA0 2 | | 39 PA2
- phi2 3 | | 38 PA3
- RS0 4 | | 37 PA4
- A9 5 | | 36 PA5
- A8 6 | | 35 PA6
- A7 7 | | 34 PA7
- A6 8 | | 33 DB0
- R/W 9 | | 32 DB1
- A5 10 | MCS6530 | 31 DB2
- A4 11 | | 30 DB3
- A3 12 | | 29 DB4
- A2 13 | | 28 DB5
- A1 14 | | 27 DB6
- A0 15 | | 26 DB7
- _RES 16 | | 25 PB0
- IRQ/PB7 17 | | 24 PB1
- CS1/PB6 18 | | 23 PB2
- CS2/PB5 19 | | 22 PB3
- Vcc 20 |_____________| 21 PB4
-
-**********************************************************************/
-
-#ifndef __MIOT6530_H__
-#define __MIOT6530_H__
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-struct mos6530_port
-{
- UINT8 m_in;
- UINT8 m_out;
- UINT8 m_ddr;
-};
-
-/***************************************************************************
- MACROS / CONSTANTS
-***************************************************************************/
-
-class mos6530_device : public device_t
-{
-public:
- mos6530_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~mos6530_device() {}
-
- template<class _Object> static devcb_base &set_in_pa_callback(device_t &device, _Object object) { return downcast<mos6530_device &>(device).m_in_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pa_callback(device_t &device, _Object object) { return downcast<mos6530_device &>(device).m_out_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_pb_callback(device_t &device, _Object object) { return downcast<mos6530_device &>(device).m_in_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pb_callback(device_t &device, _Object object) { return downcast<mos6530_device &>(device).m_out_pb_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- UINT8 porta_in_get();
- UINT8 portb_in_get();
-
- UINT8 porta_out_get();
- UINT8 portb_out_get();
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- // internal state
- devcb_read8 m_in_pa_cb;
- devcb_write8 m_out_pa_cb;
-
- devcb_read8 m_in_pb_cb;
- devcb_write8 m_out_pb_cb;
-
- mos6530_port m_port[2];
-
- UINT8 m_irqstate;
- UINT8 m_irqenable;
-
- UINT8 m_timershift;
- UINT8 m_timerstate;
- emu_timer * m_timer;
-
- UINT32 m_clock;
-
- void update_irqstate();
- UINT8 get_timer();
-
- void porta_in_set(UINT8 data, UINT8 mask);
- void portb_in_set(UINT8 data, UINT8 mask);
-
- enum
- {
- TIMER_END_CALLBACK
- };
-};
-
-extern const device_type MOS6530;
-
-
-#define MCFG_MOS6530_IN_PA_CB(_devcb) \
- devcb = &mos6530_device::set_in_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6530_OUT_PA_CB(_devcb) \
- devcb = &mos6530_device::set_out_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6530_IN_PB_CB(_devcb) \
- devcb = &mos6530_device::set_in_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6530_OUT_PB_CB(_devcb) \
- devcb = &mos6530_device::set_out_pb_callback(*device, DEVCB_##_devcb);
-
-
-#endif
diff --git a/src/emu/machine/mos6530n.c b/src/emu/machine/mos6530n.c
deleted file mode 100644
index 58f279f5437..00000000000
--- a/src/emu/machine/mos6530n.c
+++ /dev/null
@@ -1,844 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS Technology 6530 Memory, I/O, Timer Array emulation
- MOS Technology 6532 RAM, I/O, Timer Array emulation
-
-**********************************************************************/
-
-#include "mos6530n.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-#define LOG_TIMER 0
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type MOS6530n = &device_creator<mos6530_t>;
-const device_type MOS6532n = &device_creator<mos6532_t>;
-
-
-DEVICE_ADDRESS_MAP_START( rom_map, 8, mos6530_t )
- ADDRESS_MAP_GLOBAL_MASK(0x3ff)
- AM_RANGE(0x000, 0x3ff) AM_READ(rom_r)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START( ram_map, 8, mos6530_t )
- ADDRESS_MAP_GLOBAL_MASK(0x3f)
- AM_RANGE(0x00, 0x3f) AM_READWRITE(ram_r, ram_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START( io_map, 8, mos6530_t )
- ADDRESS_MAP_GLOBAL_MASK(0xf)
- AM_RANGE(0x00, 0x00) AM_MIRROR(0x8) AM_READWRITE(pa_data_r, pa_data_w)
- AM_RANGE(0x01, 0x01) AM_MIRROR(0x8) AM_READWRITE(pa_ddr_r, pa_ddr_w)
- AM_RANGE(0x02, 0x02) AM_MIRROR(0x8) AM_READWRITE(pb_data_r, pb_data_w)
- AM_RANGE(0x03, 0x03) AM_MIRROR(0x8) AM_READWRITE(pb_ddr_r, pb_ddr_w)
- AM_RANGE(0x04, 0x07) AM_WRITE(timer_off_w)
- AM_RANGE(0x0c, 0x0f) AM_WRITE(timer_on_w)
- AM_RANGE(0x04, 0x04) AM_MIRROR(0x2) AM_READ(timer_off_r)
- AM_RANGE(0x0c, 0x0c) AM_MIRROR(0x2) AM_READ(timer_on_r)
- AM_RANGE(0x05, 0x05) AM_MIRROR(0xa) AM_READ(irq_r)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START( ram_map, 8, mos6532_t )
- ADDRESS_MAP_GLOBAL_MASK(0x7f)
- AM_RANGE(0x00, 0x7f) AM_READWRITE(ram_r, ram_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START( io_map, 8, mos6532_t )
- ADDRESS_MAP_GLOBAL_MASK(0x1f)
- AM_RANGE(0x00, 0x00) AM_MIRROR(0x18) AM_READWRITE(pa_data_r, pa_data_w)
- AM_RANGE(0x01, 0x01) AM_MIRROR(0x18) AM_READWRITE(pa_ddr_r, pa_ddr_w)
- AM_RANGE(0x02, 0x02) AM_MIRROR(0x18) AM_READWRITE(pb_data_r, pb_data_w)
- AM_RANGE(0x03, 0x03) AM_MIRROR(0x18) AM_READWRITE(pb_ddr_r, pb_ddr_w)
- AM_RANGE(0x14, 0x17) AM_WRITE(timer_off_w)
- AM_RANGE(0x1c, 0x1f) AM_WRITE(timer_on_w)
- AM_RANGE(0x04, 0x04) AM_MIRROR(0x12) AM_READ(timer_off_r)
- AM_RANGE(0x0c, 0x0c) AM_MIRROR(0x12) AM_READ(timer_on_r)
- AM_RANGE(0x05, 0x05) AM_MIRROR(0x1a) AM_READ(irq_r)
- AM_RANGE(0x04, 0x07) AM_MIRROR(0x8) AM_WRITE(edge_w)
-ADDRESS_MAP_END
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mos6530_base_t - constructor
-//-------------------------------------------------
-
-mos6530_base_t::mos6530_base_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_ram(*this),
- m_irq_cb(*this),
- m_in_pa_cb(*this),
- m_out_pa_cb(*this),
- m_in_pb_cb(*this),
- m_out_pb_cb(*this),
- m_in_pa0_cb(*this),
- m_in_pa1_cb(*this),
- m_in_pa2_cb(*this),
- m_in_pa3_cb(*this),
- m_in_pa4_cb(*this),
- m_in_pa5_cb(*this),
- m_in_pa6_cb(*this),
- m_in_pa7_cb(*this),
- m_out_pa0_cb(*this),
- m_out_pa1_cb(*this),
- m_out_pa2_cb(*this),
- m_out_pa3_cb(*this),
- m_out_pa4_cb(*this),
- m_out_pa5_cb(*this),
- m_out_pa6_cb(*this),
- m_out_pa7_cb(*this),
- m_in_pb0_cb(*this),
- m_in_pb1_cb(*this),
- m_in_pb2_cb(*this),
- m_in_pb3_cb(*this),
- m_in_pb4_cb(*this),
- m_in_pb5_cb(*this),
- m_in_pb6_cb(*this),
- m_in_pb7_cb(*this),
- m_out_pb0_cb(*this),
- m_out_pb1_cb(*this),
- m_out_pb2_cb(*this),
- m_out_pb3_cb(*this),
- m_out_pb4_cb(*this),
- m_out_pb5_cb(*this),
- m_out_pb6_cb(*this),
- m_out_pb7_cb(*this),
- m_pa_in(0xff),
- m_pa_out(0),
- m_pa_ddr(0),
- m_pa7(0),
- m_pa7_dir(0),
- m_pb_in(0xff),
- m_pb_out(0),
- m_pb_ddr(0),
- m_ie_timer(false),
- m_irq_timer(true),
- m_ie_edge(false),
- m_irq_edge(false)
-{
- cur_live.tm = attotime::never;
- cur_live.state = IDLE;
- cur_live.next_state = -1;
-}
-
-
-//-------------------------------------------------
-// mos6530_t - constructor
-//-------------------------------------------------
-
-mos6530_t::mos6530_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : mos6530_base_t(mconfig, MOS6530n, "MOS6530n", tag, owner, clock, "mos6530n", __FILE__) { }
-
-
-//-------------------------------------------------
-// mos6532_t - constructor
-//-------------------------------------------------
-
-mos6532_t::mos6532_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : mos6530_base_t(mconfig, MOS6532n, "MOS6532n", tag, owner, clock, "mos6532n", __FILE__) { }
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mos6530_base_t::device_start()
-{
- // resolve callbacks
- m_irq_cb.resolve_safe();
- m_in_pa_cb.resolve();
- m_out_pa_cb.resolve();
- m_in_pb_cb.resolve();
- m_out_pb_cb.resolve();
- m_in_pa0_cb.resolve();
- m_in_pa1_cb.resolve();
- m_in_pa2_cb.resolve();
- m_in_pa3_cb.resolve();
- m_in_pa4_cb.resolve();
- m_in_pa5_cb.resolve();
- m_in_pa6_cb.resolve();
- m_in_pa7_cb.resolve();
- m_out_pa0_cb.resolve_safe();
- m_out_pa1_cb.resolve_safe();
- m_out_pa2_cb.resolve_safe();
- m_out_pa3_cb.resolve_safe();
- m_out_pa4_cb.resolve_safe();
- m_out_pa5_cb.resolve_safe();
- m_out_pa6_cb.resolve_safe();
- m_out_pa7_cb.resolve_safe();
- m_in_pb0_cb.resolve();
- m_in_pb1_cb.resolve();
- m_in_pb2_cb.resolve();
- m_in_pb3_cb.resolve();
- m_in_pb4_cb.resolve();
- m_in_pb5_cb.resolve();
- m_in_pb6_cb.resolve();
- m_in_pb7_cb.resolve();
- m_out_pb0_cb.resolve_safe();
- m_out_pb1_cb.resolve_safe();
- m_out_pb2_cb.resolve_safe();
- m_out_pb3_cb.resolve_safe();
- m_out_pb4_cb.resolve_safe();
- m_out_pb5_cb.resolve_safe();
- m_out_pb6_cb.resolve_safe();
- m_out_pb7_cb.resolve_safe();
-
- // allocate timer
- t_gen = timer_alloc(0);
-
- // state saving
- save_item(NAME(m_pa_in));
- save_item(NAME(m_pa_out));
- save_item(NAME(m_pa_ddr));
- save_item(NAME(m_pa7));
- save_item(NAME(m_pa7_dir));
- save_item(NAME(m_pb_in));
- save_item(NAME(m_pb_out));
- save_item(NAME(m_pb_ddr));
- save_item(NAME(m_ie_timer));
- save_item(NAME(m_irq_timer));
- save_item(NAME(m_ie_edge));
- save_item(NAME(m_irq_edge));
- save_item(NAME(m_prescale));
- save_item(NAME(m_timer));
-}
-
-void mos6530_t::device_start()
-{
- mos6530_base_t::device_start();
-
- // allocate RAM
- m_ram.allocate(0x40);
-}
-
-void mos6532_t::device_start()
-{
- mos6530_base_t::device_start();
-
- // allocate RAM
- m_ram.allocate(0x80);
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mos6530_base_t::device_reset()
-{
- m_pa_out = 0;
- m_pa_ddr = 0;
- m_pb_out = 0;
- m_pb_ddr = 0;
-
- m_ie_timer = false;
- m_irq_timer = false;
- m_ie_edge = false;
- m_irq_edge = false;
- m_pa7_dir = 0;
-
- update_pa();
- update_pb();
- update_irq();
- edge_detect();
-
- m_timer = 0xff;
- m_prescale = 1024;
-
- if (cur_live.state != IDLE) {
- live_abort();
- }
-
- live_start();
- live_run();
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void mos6530_base_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- live_sync();
- live_run();
-}
-
-
-//-------------------------------------------------
-// update_pa -
-//-------------------------------------------------
-
-void mos6530_base_t::update_pa()
-{
- UINT8 out = m_pa_out;
- UINT8 ddr = m_pa_ddr;
- UINT8 data = (out & ddr) | (ddr ^ 0xff);
-
- if (m_out_pa_cb.isnull())
- {
- m_out_pa0_cb(BIT(data, 0));
- m_out_pa1_cb(BIT(data, 1));
- m_out_pa2_cb(BIT(data, 2));
- m_out_pa3_cb(BIT(data, 3));
- m_out_pa4_cb(BIT(data, 4));
- m_out_pa5_cb(BIT(data, 5));
- m_out_pa6_cb(BIT(data, 6));
- m_out_pa7_cb(BIT(data, 7));
- }
- else
- {
- m_out_pa_cb(data);
- }
-}
-
-
-//-------------------------------------------------
-// update_pb -
-//-------------------------------------------------
-
-void mos6530_base_t::update_pb()
-{
- UINT8 out = m_pb_out;
- UINT8 ddr = m_pb_ddr;
- UINT8 data = (out & ddr) | (ddr ^ 0xff);
-
- if (m_out_pb_cb.isnull())
- {
- m_out_pb0_cb(BIT(data, 0));
- m_out_pb1_cb(BIT(data, 1));
- m_out_pb2_cb(BIT(data, 2));
- m_out_pb3_cb(BIT(data, 3));
- m_out_pb4_cb(BIT(data, 4));
- m_out_pb5_cb(BIT(data, 5));
- m_out_pb6_cb(BIT(data, 6));
- m_out_pb7_cb(BIT(data, 7));
- }
- else
- {
- m_out_pb_cb(data);
- }
-}
-
-void mos6530_t::update_pb()
-{
- UINT8 out = m_pb_out;
- UINT8 ddr = m_pb_ddr;
- UINT8 data = (out & ddr) | (ddr ^ 0xff);
-
- if (m_ie_timer)
- {
- if (m_irq_timer) {
- data |= IRQ_TIMER;
- } else {
- data &= ~IRQ_TIMER;
- }
- }
-
- if (m_out_pb_cb.isnull())
- {
- m_out_pb0_cb(BIT(data, 0));
- m_out_pb1_cb(BIT(data, 1));
- m_out_pb2_cb(BIT(data, 2));
- m_out_pb3_cb(BIT(data, 3));
- m_out_pb4_cb(BIT(data, 4));
- m_out_pb5_cb(BIT(data, 5));
- m_out_pb6_cb(BIT(data, 6));
- m_out_pb7_cb(BIT(data, 7));
- }
- else
- {
- m_out_pb_cb(data);
- }
-}
-
-
-//-------------------------------------------------
-// update_irq -
-//-------------------------------------------------
-
-void mos6530_base_t::update_irq()
-{
- int state = CLEAR_LINE;
-
- if (m_ie_timer && m_irq_timer) state = ASSERT_LINE;
- if (m_ie_edge && m_irq_edge) state = ASSERT_LINE;
-
- m_irq_cb(state);
-}
-
-void mos6530_t::update_irq()
-{
- update_pb();
-}
-
-
-//-------------------------------------------------
-// get_irq_flags -
-//-------------------------------------------------
-
-UINT8 mos6530_base_t::get_irq_flags()
-{
- UINT8 data = 0;
-
- if (m_irq_timer) data |= IRQ_TIMER;
- if (m_irq_edge) data |= IRQ_EDGE;
-
- return data;
-}
-
-UINT8 mos6530_t::get_irq_flags()
-{
- UINT8 data = 0;
-
- if (m_irq_timer) data |= IRQ_TIMER;
-
- return data;
-}
-
-
-//-------------------------------------------------
-// edge_detect -
-//-------------------------------------------------
-
-void mos6530_base_t::edge_detect()
-{
- UINT8 ddr_out = m_pa_ddr;
- UINT8 ddr_in = m_pa_ddr ^ 0xff;
- UINT8 data = (m_pa_out & ddr_out) | (m_pa_in & ddr_in);
- int state = BIT(data, 7);
-
- if ((m_pa7 ^ state) && (m_pa7_dir ^ state) == 0)
- {
- if (LOG) logerror("%s %s '%s' edge-detect IRQ\n", machine().time().as_string(), name(), tag());
-
- m_irq_edge = true;
- update_irq();
- }
-
- m_pa7 = state;
-}
-
-
-//-------------------------------------------------
-// pa_w -
-//-------------------------------------------------
-
-void mos6530_base_t::pa_w(int bit, int state)
-{
- if (LOG) logerror("%s %s %s '%s' Port A Data Bit %u State %u\n", machine().time().as_string(), machine().describe_context(), name(), tag(), bit, state);
-
- m_pa_in &= ~(1 << bit);
- m_pa_in |= (state << bit);
-
- edge_detect();
-}
-
-
-//-------------------------------------------------
-// pb_w -
-//-------------------------------------------------
-
-void mos6530_base_t::pb_w(int bit, int state)
-{
- if (LOG) logerror("%s %s %s '%s' Port B Data Bit %u State %u\n", machine().time().as_string(), machine().describe_context(), name(), tag(), bit, state);
-
- m_pb_in &= ~(1 << bit);
- m_pb_in |= (state << bit);
-}
-
-
-//-------------------------------------------------
-// pa_data_r -
-//-------------------------------------------------
-
-READ8_MEMBER( mos6530_base_t::pa_data_r )
-{
- UINT8 in = 0;
-
- if (m_in_pa_cb.isnull())
- {
- in |= (m_in_pa0_cb.isnull() ? BIT(m_pa_in, 0) : m_in_pa0_cb());
- in |= (m_in_pa1_cb.isnull() ? BIT(m_pa_in, 1) : m_in_pa1_cb()) << 1;
- in |= (m_in_pa2_cb.isnull() ? BIT(m_pa_in, 2) : m_in_pa2_cb()) << 2;
- in |= (m_in_pa3_cb.isnull() ? BIT(m_pa_in, 3) : m_in_pa3_cb()) << 3;
- in |= (m_in_pa4_cb.isnull() ? BIT(m_pa_in, 4) : m_in_pa4_cb()) << 4;
- in |= (m_in_pa5_cb.isnull() ? BIT(m_pa_in, 5) : m_in_pa5_cb()) << 5;
- in |= (m_in_pa6_cb.isnull() ? BIT(m_pa_in, 6) : m_in_pa6_cb()) << 6;
- in |= (m_in_pa7_cb.isnull() ? BIT(m_pa_in, 7) : m_in_pa7_cb()) << 7;
- }
- else
- {
- in = m_in_pa_cb();
- }
-
- UINT8 out = m_pa_out;
- UINT8 ddr_out = m_pa_ddr;
- UINT8 ddr_in = m_pa_ddr ^ 0xff;
- UINT8 data = (out & ddr_out) | (in & ddr_in);
-
- if (LOG) logerror("%s %s %s '%s' Port A Data In %02x\n", machine().time().as_string(), machine().describe_context(), name(), tag(), data);
-
- return data;
-}
-
-
-//-------------------------------------------------
-// pa_data_w -
-//-------------------------------------------------
-
-WRITE8_MEMBER( mos6530_base_t::pa_data_w )
-{
- m_pa_out = data;
-
- if (LOG) logerror("%s %s %s '%s' Port A Data Out %02x\n", machine().time().as_string(), machine().describe_context(), name(), tag(), data);
-
- update_pa();
- edge_detect();
-}
-
-
-//-------------------------------------------------
-// pa_ddr_w -
-//-------------------------------------------------
-
-WRITE8_MEMBER( mos6530_base_t::pa_ddr_w )
-{
- m_pa_ddr = data;
-
- if (LOG) logerror("%s %s %s '%s' Port A DDR %02x\n", machine().time().as_string(), machine().describe_context(), name(), tag(), data);
-
- update_pa();
- edge_detect();
-}
-
-
-//-------------------------------------------------
-// pb_data_r -
-//-------------------------------------------------
-
-READ8_MEMBER( mos6530_base_t::pb_data_r )
-{
- UINT8 in = 0;
-
- if (m_in_pb_cb.isnull())
- {
- in |= (m_in_pb0_cb.isnull() ? BIT(m_pb_in, 0) : m_in_pb0_cb());
- in |= (m_in_pb1_cb.isnull() ? BIT(m_pb_in, 1) : m_in_pb1_cb()) << 1;
- in |= (m_in_pb2_cb.isnull() ? BIT(m_pb_in, 2) : m_in_pb2_cb()) << 2;
- in |= (m_in_pb3_cb.isnull() ? BIT(m_pb_in, 3) : m_in_pb3_cb()) << 3;
- in |= (m_in_pb4_cb.isnull() ? BIT(m_pb_in, 4) : m_in_pb4_cb()) << 4;
- in |= (m_in_pb5_cb.isnull() ? BIT(m_pb_in, 5) : m_in_pb5_cb()) << 5;
- in |= (m_in_pb6_cb.isnull() ? BIT(m_pb_in, 6) : m_in_pb6_cb()) << 6;
- in |= (m_in_pb7_cb.isnull() ? BIT(m_pb_in, 7) : m_in_pb7_cb()) << 7;
- }
- else
- {
- in = m_in_pb_cb();
- }
-
- UINT8 out = m_pb_out;
- UINT8 ddr_out = m_pb_ddr;
- UINT8 ddr_in = m_pb_ddr ^ 0xff;
- UINT8 data = (out & ddr_out) | (in & ddr_in);
-
- if (LOG) logerror("%s %s %s '%s' Port B Data In %02x\n", machine().time().as_string(), machine().describe_context(), name(), tag(), data);
-
- return data;
-}
-
-
-//-------------------------------------------------
-// pb_data_w -
-//-------------------------------------------------
-
-WRITE8_MEMBER( mos6530_base_t::pb_data_w )
-{
- m_pb_out = data;
-
- if (LOG) logerror("%s %s %s '%s' Port B Data Out %02x\n", machine().time().as_string(), machine().describe_context(), name(), tag(), data);
-
- update_pb();
-}
-
-
-//-------------------------------------------------
-// pb_ddr_w -
-//-------------------------------------------------
-
-WRITE8_MEMBER( mos6530_base_t::pb_ddr_w )
-{
- m_pb_ddr = data;
-
- if (LOG) logerror("%s %s %s '%s' Port B DDR %02x\n", machine().time().as_string(), machine().describe_context(), name(), tag(), data);
-
- update_pb();
-}
-
-
-//-------------------------------------------------
-// timer_r -
-//-------------------------------------------------
-
-READ8_MEMBER( mos6530_base_t::timer_off_r )
-{
- if (space.debugger_access())
- return 0;
-
- return timer_r(false);
-}
-
-READ8_MEMBER( mos6530_base_t::timer_on_r )
-{
- if (space.debugger_access())
- return 0;
-
- return timer_r(true);
-}
-
-UINT8 mos6530_base_t::timer_r(bool ie)
-{
- UINT8 data = 0;
-
- live_sync();
-
- m_ie_timer = ie;
- if (cur_live.tm_irq != machine().time()) {
- m_irq_timer = false;
- }
- update_irq();
-
- data = cur_live.value;
-
- if (LOG_TIMER) logerror("%s %s %s '%s' Timer read %02x IE %u\n", machine().time().as_string(), machine().describe_context(), name(), tag(), data, m_ie_timer ? 1 : 0);
-
- checkpoint();
- live_run();
-
- return data;
-}
-
-
-//-------------------------------------------------
-// irq_r -
-//-------------------------------------------------
-
-READ8_MEMBER( mos6530_base_t::irq_r )
-{
- UINT8 data = get_irq_flags();
-
- if (!space.debugger_access()) {
- if (m_irq_edge) {
- m_irq_edge = false;
- update_irq();
- }
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// timer_w -
-//-------------------------------------------------
-
-WRITE8_MEMBER( mos6530_base_t::timer_off_w )
-{
- timer_w(offset, data, false);
-}
-
-WRITE8_MEMBER( mos6530_base_t::timer_on_w )
-{
- timer_w(offset, data, true);
-}
-
-void mos6530_base_t::timer_w(offs_t offset, UINT8 data, bool ie)
-{
- live_sync();
-
- m_timer = data;
-
- switch (offset & 0x03) {
- case 0: m_prescale = 1; break;
- case 1: m_prescale = 8; break;
- case 2: m_prescale = 64; break;
- case 3: m_prescale = 1024; break;
- }
-
- m_ie_timer = ie;
- if (cur_live.tm_irq != machine().time()) {
- m_irq_timer = false;
- }
- update_irq();
-
- if (LOG_TIMER) logerror("%s %s %s '%s' Timer value %02x prescale %u IE %u\n", machine().time().as_string(), machine().describe_context(), name(), tag(), data, m_prescale, m_ie_timer ? 1 : 0);
-
- checkpoint();
-
- if (cur_live.state != IDLE) {
- live_abort();
- }
-
- live_start();
- live_run();
-}
-
-
-//-------------------------------------------------
-// edge_w -
-//-------------------------------------------------
-
-WRITE8_MEMBER( mos6530_base_t::edge_w )
-{
- m_pa7_dir = BIT(data, 0);
- m_ie_edge = BIT(data, 1) ? false : true;
-
- if (LOG) logerror("%s %s %s '%s' %s edge-detect, %s interrupt\n", machine().time().as_string(), machine().describe_context(), name(), tag(), m_pa7_dir ? "positive" : "negative", m_ie_edge ? "enable" : "disable");
-}
-
-
-//-------------------------------------------------
-// live_start -
-//-------------------------------------------------
-
-void mos6530_base_t::live_start()
-{
- cur_live.period = attotime::from_ticks(m_prescale, clock());
- cur_live.tm = machine().time() + attotime::from_hz(clock());
- cur_live.state = RUNNING;
- cur_live.next_state = -1;
-
- cur_live.value = m_timer;
-
- checkpoint();
-
- live_run();
-}
-
-void mos6530_base_t::checkpoint()
-{
- checkpoint_live = cur_live;
-}
-
-void mos6530_base_t::rollback()
-{
- cur_live = checkpoint_live;
-}
-
-void mos6530_base_t::live_delay(int state)
-{
- cur_live.next_state = state;
- if(cur_live.tm != machine().time())
- t_gen->adjust(cur_live.tm - machine().time());
- else
- live_sync();
-}
-
-void mos6530_base_t::live_sync()
-{
- if(!cur_live.tm.is_never()) {
- if(cur_live.tm > machine().time()) {
- rollback();
- live_run(machine().time());
- } else {
- if(cur_live.next_state != -1) {
- cur_live.state = cur_live.next_state;
- cur_live.next_state = -1;
- }
- if(cur_live.state == IDLE) {
- cur_live.tm = attotime::never;
- }
- }
- cur_live.next_state = -1;
- checkpoint();
- }
-}
-
-void mos6530_base_t::live_abort()
-{
- if(!cur_live.tm.is_never() && cur_live.tm > machine().time()) {
- rollback();
- live_run(machine().time());
- }
-
- cur_live.tm = attotime::never;
- cur_live.state = IDLE;
- cur_live.next_state = -1;
- cur_live.tm_irq = attotime::never;
-}
-
-void mos6530_base_t::live_run(const attotime &limit)
-{
- if(cur_live.state == IDLE || cur_live.next_state != -1)
- return;
-
- for(;;) {
- switch(cur_live.state) {
- case RUNNING: {
- if (cur_live.tm > limit)
- return;
-
- cur_live.value--;
-
- if (cur_live.value == 0xff) {
- live_delay(RUNNING_SYNCPOINT);
- return;
- } else {
- if (LOG_TIMER) logerror("%s %s '%s' timer %02x\n", cur_live.tm.as_string(), name(), tag(), cur_live.value);
-
- cur_live.tm += cur_live.period;
- }
- break;
- }
-
- case RUNNING_SYNCPOINT: {
- if (LOG_TIMER) logerror("%s %s '%s' timer %02x interrupt\n", cur_live.tm.as_string(), name(), tag(), cur_live.value);
-
- cur_live.tm_irq = cur_live.tm;
- m_irq_timer = true;
- update_irq();
-
- checkpoint();
-
- cur_live.state = RUNNING_AFTER_INTERRUPT;
- cur_live.period = attotime::from_hz(clock());
- cur_live.tm += cur_live.period;
- break;
- }
-
- case RUNNING_AFTER_INTERRUPT: {
- if (cur_live.tm > limit)
- return;
-
- cur_live.value--;
-
- if (LOG_TIMER) logerror("%s %s '%s' timer %02x\n", cur_live.tm.as_string(), name(), tag(), cur_live.value);
-
- if (!cur_live.value) {
- cur_live.state = IDLE;
- return;
- }
-
- cur_live.tm += cur_live.period;
- break;
- }
- }
- }
-}
diff --git a/src/emu/machine/mos6530n.h b/src/emu/machine/mos6530n.h
deleted file mode 100644
index 01044ac7c7b..00000000000
--- a/src/emu/machine/mos6530n.h
+++ /dev/null
@@ -1,415 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS Technology 6530 Memory, I/O, Timer Array emulation
- MOS Technology 6532 RAM, I/O, Timer Array emulation
-
-**********************************************************************
- _____ _____
- Vss 1 |* \_/ | 40 PA1
- PA0 2 | | 39 PA2
- phi2 3 | | 38 PA3
- RS0 4 | | 37 PA4
- A9 5 | | 36 PA5
- A8 6 | | 35 PA6
- A7 7 | | 34 PA7
- A6 8 | | 33 DB0
- R/W 9 | | 32 DB1
- A5 10 | MCS6530 | 31 DB2
- A4 11 | | 30 DB3
- A3 12 | | 29 DB4
- A2 13 | | 28 DB5
- A1 14 | | 27 DB6
- A0 15 | | 26 DB7
- _RES 16 | | 25 PB0
- IRQ/PB7 17 | | 24 PB1
- CS1/PB6 18 | | 23 PB2
- CS2/PB5 19 | | 22 PB3
- Vcc 20 |_____________| 21 PB4
-
- _____ _____
- Vss 1 |* \_/ | 40 A6
- A5 2 | | 39 phi2
- A4 3 | | 38 CS1
- A3 4 | | 37 _CS2
- A2 5 | | 36 _RS
- A1 6 | | 35 R/W
- A0 7 | | 34 _RES
- PA0 8 | | 33 D0
- PA1 9 | | 32 D1
- PA2 10 | MCS6532 | 31 D2
- PA3 11 | | 30 D3
- PA4 12 | | 29 D4
- PA5 13 | | 28 D5
- PA6 14 | | 27 D6
- PA7 15 | | 26 D7
- PB7 16 | | 25 _IRQ
- PB6 17 | | 24 PB0
- PB5 18 | | 23 PB1
- PB4 19 | | 22 PB2
- Vcc 20 |_____________| 21 PB3
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MOS6530n__
-#define __MOS6530n__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MOS6530n_IRQ_CB(_write) \
- devcb = &mos6530_base_t::set_irq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_IN_PA_CB(_read) \
- devcb = &mos6530_base_t::set_pa_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_OUT_PA_CB(_write) \
- devcb = &mos6530_base_t::set_pa_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_IN_PB_CB(_read) \
- devcb = &mos6530_base_t::set_pb_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_OUT_PB_CB(_write) \
- devcb = &mos6530_base_t::set_pb_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_IN_PA0_CB(_read) \
- devcb = &mos6530_base_t::set_pa0_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PA1_CB(_read) \
- devcb = &mos6530_base_t::set_pa1_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PA2_CB(_read) \
- devcb = &mos6530_base_t::set_pa2_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PA3_CB(_read) \
- devcb = &mos6530_base_t::set_pa3_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PA4_CB(_read) \
- devcb = &mos6530_base_t::set_pa4_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PA5_CB(_read) \
- devcb = &mos6530_base_t::set_pa5_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PA6_CB(_read) \
- devcb = &mos6530_base_t::set_pa6_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PA7_CB(_read) \
- devcb = &mos6530_base_t::set_pa7_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_OUT_PA0_CB(_write) \
- devcb = &mos6530_base_t::set_pa0_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PA1_CB(_write) \
- devcb = &mos6530_base_t::set_pa1_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PA2_CB(_write) \
- devcb = &mos6530_base_t::set_pa2_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PA3_CB(_write) \
- devcb = &mos6530_base_t::set_pa3_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PA4_CB(_write) \
- devcb = &mos6530_base_t::set_pa4_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PA5_CB(_write) \
- devcb = &mos6530_base_t::set_pa5_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PA6_CB(_write) \
- devcb = &mos6530_base_t::set_pa6_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PA7_CB(_write) \
- devcb = &mos6530_base_t::set_pa7_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_IN_PB0_CB(_read) \
- devcb = &mos6530_base_t::set_pb0_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PB1_CB(_read) \
- devcb = &mos6530_base_t::set_pb1_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PB2_CB(_read) \
- devcb = &mos6530_base_t::set_pb2_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PB3_CB(_read) \
- devcb = &mos6530_base_t::set_pb3_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PB4_CB(_read) \
- devcb = &mos6530_base_t::set_pb4_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PB5_CB(_read) \
- devcb = &mos6530_base_t::set_pb5_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PB6_CB(_read) \
- devcb = &mos6530_base_t::set_pb6_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_IN_PB7_CB(_read) \
- devcb = &mos6530_base_t::set_pb7_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS6530n_OUT_PB0_CB(_write) \
- devcb = &mos6530_base_t::set_pb0_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PB1_CB(_write) \
- devcb = &mos6530_base_t::set_pb1_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PB2_CB(_write) \
- devcb = &mos6530_base_t::set_pb2_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PB3_CB(_write) \
- devcb = &mos6530_base_t::set_pb3_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PB4_CB(_write) \
- devcb = &mos6530_base_t::set_pb4_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PB5_CB(_write) \
- devcb = &mos6530_base_t::set_pb5_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PB6_CB(_write) \
- devcb = &mos6530_base_t::set_pb6_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS6530n_OUT_PB7_CB(_write) \
- devcb = &mos6530_base_t::set_pb7_wr_callback(*device, DEVCB_##_write);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mos6530_base_t
-
-class mos6530_base_t : public device_t
-{
-public:
- // construction/destruction
- mos6530_base_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- template<class _Object> static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_irq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa0_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pa0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa1_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pa1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa2_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pa2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa3_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pa3_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa4_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pa4_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa5_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pa5_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa6_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pa6_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa7_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pa7_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa0_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pa0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa1_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pa1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa2_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pa2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa3_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pa3_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa4_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pa4_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa5_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pa5_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa6_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pa6_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pa7_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pa7_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb0_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pb0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb1_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pb1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb2_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pb2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb3_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pb3_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb4_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pb4_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb5_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pb5_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb6_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pb6_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb7_rd_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_in_pb7_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb0_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pb0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb1_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pb1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb2_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pb2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb3_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pb3_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb4_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pb4_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb5_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pb5_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb6_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pb6_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb7_wr_callback(device_t &device, _Object object) { return downcast<mos6530_base_t &>(device).m_out_pb7_cb.set_callback(object); }
-
- DECLARE_WRITE_LINE_MEMBER( pa0_w ) { pa_w(0, state); }
- DECLARE_WRITE_LINE_MEMBER( pa1_w ) { pa_w(1, state); }
- DECLARE_WRITE_LINE_MEMBER( pa2_w ) { pa_w(2, state); }
- DECLARE_WRITE_LINE_MEMBER( pa3_w ) { pa_w(3, state); }
- DECLARE_WRITE_LINE_MEMBER( pa4_w ) { pa_w(4, state); }
- DECLARE_WRITE_LINE_MEMBER( pa5_w ) { pa_w(5, state); }
- DECLARE_WRITE_LINE_MEMBER( pa6_w ) { pa_w(6, state); }
- DECLARE_WRITE_LINE_MEMBER( pa7_w ) { pa_w(7, state); }
-
- DECLARE_WRITE_LINE_MEMBER( pb0_w ) { pb_w(0, state); }
- DECLARE_WRITE_LINE_MEMBER( pb1_w ) { pb_w(1, state); }
- DECLARE_WRITE_LINE_MEMBER( pb2_w ) { pb_w(2, state); }
- DECLARE_WRITE_LINE_MEMBER( pb3_w ) { pb_w(3, state); }
- DECLARE_WRITE_LINE_MEMBER( pb4_w ) { pb_w(4, state); }
- DECLARE_WRITE_LINE_MEMBER( pb5_w ) { pb_w(5, state); }
- DECLARE_WRITE_LINE_MEMBER( pb6_w ) { pb_w(6, state); }
- DECLARE_WRITE_LINE_MEMBER( pb7_w ) { pb_w(7, state); }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- enum
- {
- IRQ_EDGE = 0x40,
- IRQ_TIMER = 0x80
- };
-
- void update_pa();
- virtual void update_pb();
- virtual void update_irq();
- virtual UINT8 get_irq_flags();
- void edge_detect();
- void pa_w(int bit, int state);
- void pb_w(int bit, int state);
- void timer_w(offs_t offset, UINT8 data, bool ie);
- UINT8 timer_r(bool ie);
-
- DECLARE_READ8_MEMBER( rom_r ) { return m_region->base()[offset]; }
- DECLARE_READ8_MEMBER( ram_r ) { return m_ram[offset]; }
- DECLARE_WRITE8_MEMBER( ram_w ) { m_ram[offset] = data; }
- DECLARE_READ8_MEMBER( pa_data_r );
- DECLARE_WRITE8_MEMBER( pa_data_w );
- DECLARE_READ8_MEMBER( pb_data_r );
- DECLARE_WRITE8_MEMBER( pb_data_w );
- DECLARE_READ8_MEMBER( pa_ddr_r ) { return m_pa_ddr; }
- DECLARE_WRITE8_MEMBER( pa_ddr_w );
- DECLARE_READ8_MEMBER( pb_ddr_r ) { return m_pb_ddr; }
- DECLARE_WRITE8_MEMBER( pb_ddr_w );
- DECLARE_READ8_MEMBER( timer_off_r );
- DECLARE_READ8_MEMBER( timer_on_r );
- DECLARE_READ8_MEMBER( irq_r );
- DECLARE_WRITE8_MEMBER( timer_off_w );
- DECLARE_WRITE8_MEMBER( timer_on_w );
- DECLARE_WRITE8_MEMBER( edge_w );
-
- optional_shared_ptr<UINT8> m_ram;
-
- devcb_write_line m_irq_cb;
- devcb_read8 m_in_pa_cb;
- devcb_write8 m_out_pa_cb;
- devcb_read8 m_in_pb_cb;
- devcb_write8 m_out_pb_cb;
- devcb_read_line m_in_pa0_cb;
- devcb_read_line m_in_pa1_cb;
- devcb_read_line m_in_pa2_cb;
- devcb_read_line m_in_pa3_cb;
- devcb_read_line m_in_pa4_cb;
- devcb_read_line m_in_pa5_cb;
- devcb_read_line m_in_pa6_cb;
- devcb_read_line m_in_pa7_cb;
- devcb_write_line m_out_pa0_cb;
- devcb_write_line m_out_pa1_cb;
- devcb_write_line m_out_pa2_cb;
- devcb_write_line m_out_pa3_cb;
- devcb_write_line m_out_pa4_cb;
- devcb_write_line m_out_pa5_cb;
- devcb_write_line m_out_pa6_cb;
- devcb_write_line m_out_pa7_cb;
- devcb_read_line m_in_pb0_cb;
- devcb_read_line m_in_pb1_cb;
- devcb_read_line m_in_pb2_cb;
- devcb_read_line m_in_pb3_cb;
- devcb_read_line m_in_pb4_cb;
- devcb_read_line m_in_pb5_cb;
- devcb_read_line m_in_pb6_cb;
- devcb_read_line m_in_pb7_cb;
- devcb_write_line m_out_pb0_cb;
- devcb_write_line m_out_pb1_cb;
- devcb_write_line m_out_pb2_cb;
- devcb_write_line m_out_pb3_cb;
- devcb_write_line m_out_pb4_cb;
- devcb_write_line m_out_pb5_cb;
- devcb_write_line m_out_pb6_cb;
- devcb_write_line m_out_pb7_cb;
-
- UINT8 m_pa_in;
- UINT8 m_pa_out;
- UINT8 m_pa_ddr;
- int m_pa7;
- int m_pa7_dir;
-
- UINT8 m_pb_in;
- UINT8 m_pb_out;
- UINT8 m_pb_ddr;
-
- bool m_ie_timer;
- bool m_irq_timer;
- bool m_ie_edge;
- bool m_irq_edge;
-
- int m_prescale;
- UINT8 m_timer;
-
- enum {
- IDLE,
- RUNNING,
- RUNNING_SYNCPOINT,
- RUNNING_AFTER_INTERRUPT
- };
-
- struct live_info {
- attotime tm, tm_irq;
- attotime period;
- int state, next_state;
- UINT8 value;
- };
-
- live_info cur_live, checkpoint_live;
- emu_timer *t_gen;
-
- void live_start();
- void checkpoint();
- void rollback();
- void live_delay(int state);
- void live_sync();
- void live_abort();
- void live_run(const attotime &limit = attotime::never);
-};
-
-
-class mos6530_t : public mos6530_base_t
-{
-public:
- // construction/destruction
- mos6530_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(rom_map, 8);
- virtual DECLARE_ADDRESS_MAP(ram_map, 8);
- virtual DECLARE_ADDRESS_MAP(io_map, 8);
-
-protected:
- // device-level overrides
- virtual void device_start();
-
- void update_pb();
- void update_irq();
- UINT8 get_irq_flags();
-};
-
-
-class mos6532_t : public mos6530_base_t
-{
-public:
- // construction/destruction
- mos6532_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(ram_map, 8);
- virtual DECLARE_ADDRESS_MAP(io_map, 8);
-
-protected:
- // device-level overrides
- virtual void device_start();
-};
-
-
-// device type definition
-extern const device_type MOS6530n;
-extern const device_type MOS6532n;
-
-
-
-#endif
diff --git a/src/emu/machine/mos6551.c b/src/emu/machine/mos6551.c
deleted file mode 100644
index 6f240799af2..00000000000
--- a/src/emu/machine/mos6551.c
+++ /dev/null
@@ -1,833 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/**********************************************************************
-
- MOS Technology 6551 Asynchronous Communication Interface Adapter
-
-**********************************************************************/
-
-#include "mos6551.h"
-
-#define LOG 0
-
-const device_type MOS6551 = &device_creator<mos6551_device>;
-
-mos6551_device::mos6551_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, MOS6551, "MOS6551", tag, owner, clock, "mos6551", __FILE__),
- m_internal_clock(*this, "clock"),
- m_irq_handler(*this),
- m_txd_handler(*this),
- m_rxc_handler(*this),
- m_rts_handler(*this),
- m_dtr_handler(*this),
- m_control(0),
- m_status(0),
- m_tdr(0),
- m_irq_state(0),
- m_irq(0),
- m_txd(0),
- m_rxc(0),
- m_rts(0),
- m_dtr(0),
- m_xtal(0),
- m_divide(0),
- m_cts(1),
- m_dsr(1),
- m_dcd(1),
- m_rxd(1),
- m_rx_state(STATE_START),
- m_rx_clock(0),
- m_rx_counter(0),
- m_rx_internal_clock(0),
- m_tx_state(STATE_START),
- m_tx_output(OUTPUT_MARK),
- m_tx_clock(0),
- m_tx_counter(0)
-{
-}
-
-const int mos6551_device::internal_divider[] =
-{
- 1, 2304, 1536, 1048, 856, 768, 384, 192, 96, 64, 48, 32, 24, 16, 12, 6
-};
-
-const int mos6551_device::transmitter_controls[4][3] =
-{
- //tx irq, tx ena, brk
- {0, 0, 0},
- {1, 1, 0},
- {0, 1, 0},
- {0, 1, 1}
-};
-
-static MACHINE_CONFIG_FRAGMENT( mos6551 )
- MCFG_DEVICE_ADD("clock", CLOCK, 0)
- MCFG_CLOCK_SIGNAL_HANDLER(WRITELINE(mos6551_device, internal_clock))
-MACHINE_CONFIG_END
-
-machine_config_constructor mos6551_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( mos6551 );
-}
-
-void mos6551_device::device_start()
-{
- // resolve callbacks
- m_irq_handler.resolve_safe();
- m_txd_handler.resolve_safe();
- m_rxc_handler.resolve_safe();
- m_rts_handler.resolve_safe();
- m_dtr_handler.resolve_safe();
-
- // state saving
- save_item(NAME(m_control));
- save_item(NAME(m_command));
- save_item(NAME(m_status));
- save_item(NAME(m_tdr));
- save_item(NAME(m_rdr));
-
- save_item(NAME(m_irq_state));
-
- save_item(NAME(m_irq));
- save_item(NAME(m_txd));
- save_item(NAME(m_rxc));
- save_item(NAME(m_rts));
- save_item(NAME(m_dtr));
-
- save_item(NAME(m_xtal));
- save_item(NAME(m_divide));
- save_item(NAME(m_cts));
- save_item(NAME(m_dsr));
- save_item(NAME(m_dcd));
- save_item(NAME(m_rxd));
-
- save_item(NAME(m_wordlength));
- save_item(NAME(m_extrastop));
- save_item(NAME(m_brk));
- save_item(NAME(m_echo_mode));
- save_item(NAME(m_parity));
-
- save_item(NAME(m_rx_state));
- save_item(NAME(m_rx_clock));
- save_item(NAME(m_rx_bits));
- save_item(NAME(m_rx_shift));
- save_item(NAME(m_rx_parity));
- save_item(NAME(m_rx_counter));
- save_item(NAME(m_rx_irq_enable));
- save_item(NAME(m_rx_internal_clock));
-
- save_item(NAME(m_tx_state));
- save_item(NAME(m_tx_output));
- save_item(NAME(m_tx_clock));
- save_item(NAME(m_tx_bits));
- save_item(NAME(m_tx_shift));
- save_item(NAME(m_tx_parity));
- save_item(NAME(m_tx_counter));
- save_item(NAME(m_tx_enable));
- save_item(NAME(m_tx_irq_enable));
- save_item(NAME(m_tx_internal_clock));
-
- m_internal_clock->set_unscaled_clock(m_xtal);
-
- output_irq(1);
- output_txd(1);
- output_rxc(1);
- output_rts(1);
- output_dtr(1);
-}
-
-void mos6551_device::device_reset()
-{
- m_status = SR_TDRE;
-
- if (m_dsr)
- {
- m_status |= SR_DSR;
- }
-
- if (m_dcd)
- {
- m_status |= SR_DCD;
- }
-
- m_rx_state = STATE_START;
- m_rx_counter = 0;
-
- write_command(0);
- write_control(0);
-}
-
-void mos6551_device::output_irq(int irq)
-{
- if (m_irq != irq)
- {
- m_irq = irq;
-
- if (m_irq)
- {
- m_status &= ~SR_IRQ;
- }
- else
- {
- m_status |= SR_IRQ;
- }
-
- m_irq_handler(!m_irq);
- }
-}
-
-void mos6551_device::output_txd(int txd)
-{
- switch (m_tx_output)
- {
- case OUTPUT_MARK:
- txd = 1;
- break;
-
- case OUTPUT_BREAK:
- txd = 0;
- break;
- }
-
- if (m_txd != txd)
- {
- m_txd = txd;
- m_txd_handler(m_txd);
- }
-}
-
-void mos6551_device::output_rxc(int rxc)
-{
- if (m_rxc != rxc)
- {
- m_rxc = rxc;
- m_rxc_handler(m_rxc);
- }
-}
-
-void mos6551_device::output_rts(int rts)
-{
- if (m_rts != rts)
- {
- m_rts = rts;
- m_rts_handler(m_rts);
- }
-}
-
-void mos6551_device::output_dtr(int dtr)
-{
- if (m_dtr != dtr)
- {
- m_dtr = dtr;
- m_dtr_handler(m_dtr);
- }
-}
-
-void mos6551_device::update_irq()
-{
- if (m_irq_state != 0)
- {
- output_irq(0);
- }
- else
- {
- output_irq(1);
- }
-}
-
-void mos6551_device::update_divider()
-{
- // bits 0-3
- double scale = internal_divider[(m_control >> 0) & 0xf];
-
- // The 6551 allows an external clock (hooked up to xtal1 with xtal2 floating) with the internal clock generator,
- // it is unknown whether it allows a xtal (hooked up to xtal1 & xtal2) to be used as an external clock. It is
- // allowed here for performance reasons.
- if (m_xtal != 0)
- {
- m_tx_internal_clock = true;
-
- m_divide = 16;
-
- if (!m_dtr || m_rx_state != STATE_START)
- {
- scale = (double) 1 / scale;
- }
- else
- {
- scale = 0;
- }
- }
- else
- {
- m_tx_internal_clock = false;
-
- m_divide = scale * 16;
- scale = 0;
- }
-
- m_internal_clock->set_clock_scale(scale);
-}
-
-UINT8 mos6551_device::read_rdr()
-{
- m_status &= ~(SR_PARITY_ERROR | SR_FRAMING_ERROR | SR_OVERRUN | SR_RDRF);
- return m_rdr;
-}
-
-UINT8 mos6551_device::read_status()
-{
- UINT8 status = m_status;
-
- if (m_cts)
- {
- status &= ~SR_TDRE;
- }
-
- if (m_irq_state != 0)
- {
- m_irq_state = 0;
- update_irq();
- }
-
- return status;
-}
-
-UINT8 mos6551_device::read_command()
-{
- return m_command;
-}
-
-UINT8 mos6551_device::read_control()
-{
- return m_control;
-}
-
-void mos6551_device::write_tdr(UINT8 data)
-{
- m_tdr = data;
- m_status &= ~SR_TDRE;
-}
-
-void mos6551_device::write_reset(UINT8 data)
-{
- m_status &= ~SR_OVERRUN;
- m_irq_state &= ~(IRQ_DCD | IRQ_DSR);
-
- write_command(m_command & ~0x1f);
-}
-
-void mos6551_device::write_control(UINT8 data)
-{
- m_control = data;
-
- update_divider();
-
- // bit 4
- m_rx_internal_clock = (m_control >> 4) & 1;
-
- // bits 5-6
- m_wordlength = 8 - ((m_control >> 5) & 3);
-
- // bit 7
- m_extrastop = (m_control >> 7) & 1;
-
- if (!m_rx_internal_clock)
- {
- output_rxc(1);
- }
-}
-
-void mos6551_device::write_command(UINT8 data)
-{
- m_command = data;
-
- // bit 0
- output_dtr(!((m_command >> 0) & 1));
-
- // bit 1
- m_rx_irq_enable = !((m_command >> 1) & 1) && !m_dtr;
-
- // bits 2-3
- int transmitter_control = (m_command >> 2) & 3;
- m_tx_irq_enable = transmitter_controls[transmitter_control][0] && !m_dtr;
- m_tx_enable = transmitter_controls[transmitter_control][1];
- m_brk = transmitter_controls[transmitter_control][2];
-
- // bit 4
- m_echo_mode = (m_command >> 4) & 1;
-
- // bits 5-7
- m_parity = (m_command >> 5) & 7;
- if (!(m_parity & 1))
- {
- m_parity = PARITY_NONE;
- }
-
- output_rts(!(m_tx_enable || m_echo_mode));
-
- if (m_dtr || m_rts)
- {
- m_tx_output = OUTPUT_MARK;
- output_txd(1);
- }
-
- update_divider();
-}
-
-READ8_MEMBER( mos6551_device::read )
-{
- if (space.debugger_access())
- return 0xff;
-
- switch (offset & 0x03)
- {
- case 0:
- return read_rdr();
-
- case 1:
- return read_status();
-
- case 2:
- return read_command();
-
- case 3:
- default:
- return read_control();
- }
-}
-
-WRITE8_MEMBER( mos6551_device::write )
-{
- switch (offset & 0x03)
- {
- case 0:
- write_tdr(data);
- break;
-
- case 1:
- write_reset(data);
- break;
-
- case 2:
- write_command(data);
- break;
-
- case 3:
- write_control(data);
- break;
- }
-}
-
-int mos6551_device::stoplength()
-{
- if (m_extrastop == 1)
- {
- if (m_wordlength == 5 && m_parity == PARITY_NONE)
- {
- return m_divide + (m_divide / 2);
- }
-
- if (m_wordlength < 8 || m_parity == PARITY_NONE)
- {
- return m_divide * 2;
- }
- }
-
- return m_divide;
-}
-
-void mos6551_device::set_xtal(UINT32 xtal)
-{
- m_xtal = xtal;
-
- if (started())
- {
- m_internal_clock->set_unscaled_clock(m_xtal);
- update_divider();
- }
-}
-
-WRITE_LINE_MEMBER( mos6551_device::internal_clock )
-{
- if (m_tx_internal_clock)
- {
- transmitter_clock(state);
- }
-}
-
-WRITE_LINE_MEMBER(mos6551_device::write_xtal1)
-{
- if (!m_tx_internal_clock)
- {
- transmitter_clock(state);
- }
-}
-
-WRITE_LINE_MEMBER( mos6551_device::write_rxd )
-{
- m_rxd = state;
-}
-
-WRITE_LINE_MEMBER( mos6551_device::write_rxc )
-{
- if (!m_rx_internal_clock)
- {
- receiver_clock(state);
- }
-}
-
-WRITE_LINE_MEMBER( mos6551_device::write_cts )
-{
- if (m_cts != state)
- {
- m_cts = state;
-
- if (m_cts)
- {
- if (m_tx_output == OUTPUT_TXD)
- {
- m_tx_output = OUTPUT_MARK;
- output_txd(1);
- }
- }
- }
-}
-
-WRITE_LINE_MEMBER( mos6551_device::write_dsr )
-{
- if (m_dsr != state)
- {
- m_dsr = state;
- }
-}
-
-WRITE_LINE_MEMBER( mos6551_device::write_dcd )
-{
- if (m_dcd != state)
- {
- m_dcd = state;
- }
-}
-
-WRITE_LINE_MEMBER(mos6551_device::receiver_clock)
-{
- if (m_rx_clock != state)
- {
- m_rx_clock = state;
-
- if (m_rx_clock)
- {
- /// TODO: find out whether this should be here or in write_dcd
- if ((m_irq_state & IRQ_DCD) == 0 && !m_dcd != !(m_status & SR_DCD))
- {
- m_status ^= SR_DCD;
-
- if (!m_dtr)
- {
- m_irq_state |= IRQ_DCD;
- update_irq();
- }
- }
-
- /// TODO: find out whether this should be here or in write_dsr
- if ((m_irq_state & IRQ_DSR) == 0 && !m_dsr != !(m_status & SR_DSR))
- {
- m_status ^= SR_DSR;
-
- if (!m_dtr)
- {
- m_irq_state |= IRQ_DSR;
- update_irq();
- }
- }
-
- m_rx_counter++;
-
- switch (m_rx_state)
- {
- case STATE_START:
- if (m_rx_counter == 1)
- {
- if (!m_rxd && !m_dtr)
- {
- if (LOG) logerror("MOS6551 '%s': RX START BIT\n", tag());
- }
- else
- {
- m_rx_counter = 0;
- }
- }
-
- if (m_rx_counter >= m_divide / 2)
- {
- if (!m_rxd)
- {
- m_rx_state = STATE_DATA;
- m_rx_counter = 0;
- m_rx_shift = 0;
- m_rx_parity = 0;
- m_rx_bits = 0;
- }
- else
- {
- m_rx_counter = 0;
-
- if (LOG) logerror("MOS6551 '%s': RX FALSE START BIT\n", tag());
- }
- }
- break;
-
- case STATE_DATA:
- if (m_rx_counter == m_divide)
- {
- m_rx_counter = 0;
-
- if (m_rx_bits < m_wordlength)
- {
- if (LOG) logerror("MOS6551 '%s': RX DATA BIT %d %d\n", tag(), m_rx_bits, m_rxd);
- }
- else
- {
- if (LOG) logerror("MOS6551 '%s': RX PARITY BIT %x\n", tag(), m_rxd);
- }
-
- if (m_rxd)
- {
- m_rx_shift |= 1 << m_rx_bits;
- }
-
- m_rx_bits++;
-
- m_rx_parity ^= m_rxd;
-
- if ((m_rx_bits == m_wordlength && m_parity == PARITY_NONE) ||
- (m_rx_bits == (m_wordlength + 1) && m_parity != PARITY_NONE))
- {
- m_rx_state = STATE_STOP;
- }
- }
- break;
-
- case STATE_STOP:
- if (m_rx_counter >= stoplength())
- {
- m_rx_counter = 0;
-
- if (LOG) logerror("MOS6551 '%s': RX STOP BIT\n", tag());
-
- if (!(m_status & SR_RDRF))
- {
- if (!m_rxd)
- {
- m_status |= SR_FRAMING_ERROR;
- }
-
- if ((m_parity == PARITY_ODD && !m_rx_parity) ||
- (m_parity == PARITY_EVEN && m_rx_parity))
- {
- m_status |= SR_PARITY_ERROR;
- }
-
- m_rdr = m_rx_shift;
-
- if (m_wordlength == 7 && m_parity != PARITY_NONE)
- {
- m_rdr &= 0x7f;
- }
-
- m_status |= SR_RDRF;
- }
- else
- {
- m_status |= SR_OVERRUN;
- }
-
- if (m_rx_irq_enable)
- {
- m_irq_state |= IRQ_RDRF;
- update_irq();
- }
-
- m_rx_state = STATE_START;
-
- if (m_dtr)
- {
- update_divider();
- }
- }
- break;
- }
- }
- }
-}
-
-WRITE_LINE_MEMBER(mos6551_device::transmitter_clock)
-{
- if (m_rx_internal_clock)
- {
- output_rxc(state);
- receiver_clock(state);
- }
-
- if (m_tx_clock != state)
- {
- m_tx_clock = state;
-
- if (!m_tx_clock && !m_dtr)
- {
- if (m_echo_mode)
- {
- if (!(m_status & SR_OVERRUN))
- {
- output_txd(m_rxd);
- }
- else
- {
- output_txd(1);
- }
- }
-
- if (m_tx_enable)
- {
- if (!m_cts && m_tx_output == OUTPUT_MARK && !(m_status & SR_TDRE))
- {
- m_tx_state = STATE_START;
- m_tx_counter = 0;
- }
-
- m_tx_counter++;
-
- switch (m_tx_state)
- {
- case STATE_START:
- m_tx_counter = 0;
-
- m_tx_state = STATE_DATA;
- m_tx_shift = m_tdr;
- m_tx_bits = 0;
- m_tx_parity = 0;
-
- if (m_cts)
- {
- m_tx_output = OUTPUT_MARK;
- }
- else if (!(m_status & SR_TDRE))
- {
- if (LOG) logerror("MOS6551 '%s': TX DATA %x\n", tag(), m_tdr);
-
- m_tx_output = OUTPUT_TXD;
-
- if (LOG) logerror("MOS6551 '%s': TX START BIT\n", tag());
-
- m_status |= SR_TDRE;
- }
- else if (m_brk)
- {
- m_tx_output = OUTPUT_BREAK;
-
- if (LOG) logerror("MOS6551 '%s': TX BREAK START\n", tag());
- }
- else
- {
- m_tx_output = OUTPUT_MARK;
- }
-
- if (m_tx_irq_enable && m_tx_output != OUTPUT_BREAK)
- {
- m_irq_state |= IRQ_TDRE;
- update_irq();
- }
-
- output_txd(0);
- break;
-
- case STATE_DATA:
- if (m_tx_counter == m_divide)
- {
- m_tx_counter = 0;
-
- if (m_tx_bits < m_wordlength)
- {
- output_txd((m_tx_shift >> m_tx_bits) & 1);
-
- m_tx_bits++;
- m_tx_parity ^= m_txd;
-
- if (m_tx_output == OUTPUT_TXD)
- {
- if (LOG) logerror("MOS6551 '%s': TX DATA BIT %d %d\n", tag(), m_tx_bits, m_txd);
- }
- }
- else if (m_tx_bits == m_wordlength && m_parity != PARITY_NONE)
- {
- m_tx_bits++;
-
- switch (m_parity)
- {
- case PARITY_ODD:
- m_tx_parity = !m_tx_parity;
- break;
-
- case PARITY_MARK:
- m_tx_parity = 1;
- break;
-
- case PARITY_SPACE:
- m_tx_parity = 0;
- break;
- }
-
- output_txd(m_tx_parity);
-
- if (m_tx_output == OUTPUT_TXD)
- {
- if (LOG) logerror("MOS6551 '%s': TX PARITY BIT %d\n", tag(), m_txd);
- }
- }
- else
- {
- m_tx_state = STATE_STOP;
-
- output_txd(1);
-
- if (m_tx_output == OUTPUT_TXD)
- {
- if (LOG) logerror("MOS6551 '%s': TX STOP BIT\n", tag());
- }
- }
- }
- break;
-
- case STATE_STOP:
- if (m_tx_counter >= stoplength())
- {
- if (m_tx_output == OUTPUT_BREAK)
- {
- if (!m_brk)
- {
- if (LOG) logerror("MOS6551 '%s': TX BREAK END\n", tag());
-
- m_tx_counter = 0;
- m_tx_state = STATE_STOP;
- m_tx_output = OUTPUT_TXD;
-
- output_txd(1);
- }
- else
- {
- m_tx_counter--;
- }
- }
- else
- {
- m_tx_state = STATE_START;
- m_tx_counter = 0;
- }
- }
- break;
- }
- }
- }
- }
-}
diff --git a/src/emu/machine/mos6551.h b/src/emu/machine/mos6551.h
deleted file mode 100644
index 7ba7d6bc7f3..00000000000
--- a/src/emu/machine/mos6551.h
+++ /dev/null
@@ -1,212 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/**********************************************************************
-
- MOS Technology 6551 Asynchronous Communication Interface Adapter
-
-**********************************************************************
- _____ _____
- GND 1 |* \_/ | 28 R/_W
- CS0 2 | | 27 phi2
- _CS1 3 | | 26 _IRQ
- _RES 4 | | 25 DB7
- RxC 5 | | 24 DB6
- XTAL1 6 | | 23 DB5
- XTAL2 7 | MOS6551 | 22 DB4
- _RTS 8 | | 21 DB3
- _CTS 9 | | 20 DB2
- TxD 10 | | 19 DB1
- _DTR 11 | | 18 DB0
- RxD 12 | | 17 _DBR
- RS0 13 | | 16 _DCD
- RS1 14 |_____________| 15 Vcc
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MOS6551__
-#define __MOS6551__
-
-#include "emu.h"
-#include "machine/clock.h"
-
-#define MCFG_MOS6551_XTAL(_xtal) \
- mos6551_device::set_xtal(*device, _xtal);
-
-#define MCFG_MOS6551_IRQ_HANDLER(_devcb) \
- devcb = &mos6551_device::set_irq_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6551_TXD_HANDLER(_devcb) \
- devcb = &mos6551_device::set_txd_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6551_RXC_HANDLER(_devcb) \
- devcb = &mos6551_device::set_rxc_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6551_RTS_HANDLER(_devcb) \
- devcb = &mos6551_device::set_rts_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MOS6551_DTR_HANDLER(_devcb) \
- devcb = &mos6551_device::set_dtr_handler(*device, DEVCB_##_devcb);
-
-class mos6551_device : public device_t
-{
-public:
- mos6551_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- static void set_xtal(device_t &device, UINT32 xtal) { downcast<mos6551_device &>(device).set_xtal(xtal); }
- template<class _Object> static devcb_base &set_irq_handler(device_t &device, _Object object) { return downcast<mos6551_device &>(device).m_irq_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_txd_handler(device_t &device, _Object object) { return downcast<mos6551_device &>(device).m_txd_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_rxc_handler(device_t &device, _Object object) { return downcast<mos6551_device &>(device).m_rxc_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_rts_handler(device_t &device, _Object object) { return downcast<mos6551_device &>(device).m_rts_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_dtr_handler(device_t &device, _Object object) { return downcast<mos6551_device &>(device).m_dtr_handler.set_callback(object); }
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- DECLARE_WRITE_LINE_MEMBER(write_xtal1); // txc
- DECLARE_WRITE_LINE_MEMBER(write_rxd);
- DECLARE_WRITE_LINE_MEMBER(write_rxc);
- DECLARE_WRITE_LINE_MEMBER(write_cts);
- DECLARE_WRITE_LINE_MEMBER(write_dsr);
- DECLARE_WRITE_LINE_MEMBER(write_dcd);
-
- DECLARE_WRITE_LINE_MEMBER(internal_clock);
-
- void set_xtal(UINT32 clock);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual machine_config_constructor device_mconfig_additions() const;
-
-private:
- enum
- {
- SR_PARITY_ERROR = 0x01,
- SR_FRAMING_ERROR = 0x02,
- SR_OVERRUN = 0x04,
- SR_RDRF = 0x08,
- SR_TDRE = 0x10,
- SR_DCD = 0x20,
- SR_DSR = 0x40,
- SR_IRQ = 0x80
- };
-
- enum
- {
- PARITY_NONE = 0,
- PARITY_ODD = 1,
- PARITY_EVEN = 3,
- PARITY_MARK = 5,
- PARITY_SPACE = 7
- };
-
- enum
- {
- IRQ_DCD = 1,
- IRQ_DSR = 2,
- IRQ_RDRF = 4,
- IRQ_TDRE = 8,
- IRQ_CTS = 16
- };
-
- enum
- {
- STATE_START,
- STATE_DATA,
- STATE_STOP
- };
-
- enum
- {
- OUTPUT_TXD,
- OUTPUT_MARK,
- OUTPUT_BREAK
- };
-
- void output_irq(int irq);
- void output_txd(int txd);
- void output_rxc(int rxc);
- void output_rts(int rts);
- void output_dtr(int dtr);
-
- void update_irq();
- void update_divider();
-
- UINT8 read_rdr();
- UINT8 read_status();
- UINT8 read_command();
- UINT8 read_control();
-
- void write_tdr(UINT8 data);
- void write_reset(UINT8 data);
- void write_command(UINT8 data);
- void write_control(UINT8 data);
-
- int stoplength();
-
- DECLARE_WRITE_LINE_MEMBER(receiver_clock);
- DECLARE_WRITE_LINE_MEMBER(transmitter_clock);
-
- static const int internal_divider[16];
- static const int transmitter_controls[4][3];
-
- required_device<clock_device> m_internal_clock;
- devcb_write_line m_irq_handler;
- devcb_write_line m_txd_handler;
- devcb_write_line m_rxc_handler;
- devcb_write_line m_rts_handler;
- devcb_write_line m_dtr_handler;
-
- UINT8 m_control;
- UINT8 m_command;
- UINT8 m_status;
- UINT8 m_tdr;
- UINT8 m_rdr;
-
- UINT8 m_irq_state;
-
- int m_irq;
- int m_txd;
- int m_rxc;
- int m_rts;
- int m_dtr;
-
- UINT32 m_xtal;
- int m_divide;
- int m_cts;
- int m_dsr;
- int m_dcd;
- int m_rxd;
-
- int m_wordlength;
- int m_extrastop;
- int m_brk;
- int m_echo_mode;
- int m_parity;
-
- int m_rx_state;
- int m_rx_clock;
- int m_rx_bits;
- int m_rx_shift;
- int m_rx_parity;
- int m_rx_counter;
- int m_rx_irq_enable;
- int m_rx_internal_clock;
-
- int m_tx_state;
- int m_tx_output;
- int m_tx_clock;
- int m_tx_bits;
- int m_tx_shift;
- int m_tx_parity;
- int m_tx_counter;
- int m_tx_enable;
- int m_tx_irq_enable;
- int m_tx_internal_clock;
-};
-
-extern const device_type MOS6551;
-
-#endif
diff --git a/src/emu/machine/mos6702.c b/src/emu/machine/mos6702.c
deleted file mode 100644
index 9dc11e24af9..00000000000
--- a/src/emu/machine/mos6702.c
+++ /dev/null
@@ -1,68 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS Technology 6702 Mystery Device emulation
-
-**********************************************************************/
-
-#include "mos6702.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type MOS6702 = &device_creator<mos6702_device>;
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mos6702_device - constructor
-//-------------------------------------------------
-
-mos6702_device::mos6702_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MOS6702, "MOS6702", tag, owner, clock, "mos6702", __FILE__)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mos6702_device::device_start()
-{
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( mos6702_device::read )
-{
- return 0;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( mos6702_device::write )
-{
-}
diff --git a/src/emu/machine/mos6702.h b/src/emu/machine/mos6702.h
deleted file mode 100644
index d0675e5140b..00000000000
--- a/src/emu/machine/mos6702.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS Technology 6702 Mystery Device emulation
-
-**********************************************************************
- _____ _____
- R/_W 1 |* \_/ | 20 Vcc
- D7 2 | | 19 CS0
- D6 3 | | 18 CS1
- D5 4 | | 17 CS2
- D4 5 | MOS6702 | 16 CS3
- D3 6 | | 15 _CS4
- D2 7 | | 14 _CS5
- D1 8 | | 13 _CS5
- D0 9 | | 12 _RTS
- Vss 10 |_____________| 11 phi2
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MOS6702__
-#define __MOS6702__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MOS6702_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, MOS6702, _clock)
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mos6702_device
-
-class mos6702_device : public device_t
-{
-public:
- // construction/destruction
- mos6702_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
-protected:
- // device-level overrides
- virtual void device_start();
-};
-
-
-// device type definition
-extern const device_type MOS6702;
-
-
-
-#endif
diff --git a/src/emu/machine/mos8706.c b/src/emu/machine/mos8706.c
deleted file mode 100644
index ca07506423b..00000000000
--- a/src/emu/machine/mos8706.c
+++ /dev/null
@@ -1,78 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS 8706 Speech Glue Logic ASIC emulation
-
-**********************************************************************/
-
-#include "mos8706.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-// device type definition
-const device_type MOS8706 = &device_creator<mos8706_device>;
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mos8706_device - constructor
-//-------------------------------------------------
-
-mos8706_device::mos8706_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MOS8706, "MOS8706", tag, owner, clock, "mos8706", __FILE__)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mos8706_device::device_start()
-{
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mos8706_device::device_reset()
-{
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( mos8706_device::read )
-{
- return 0;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( mos8706_device::write )
-{
-}
diff --git a/src/emu/machine/mos8706.h b/src/emu/machine/mos8706.h
deleted file mode 100644
index 070c592b9fe..00000000000
--- a/src/emu/machine/mos8706.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS 8706 Speech Glue Logic ASIC emulation
-
-**********************************************************************
- _____ _____
- _RES 1 |* \_/ | 28 Vdd
- _IRQ 2 | | 27 D0
- R/_W 3 | | 26 T6721A D0
- phi0 4 | | 25 D1
- _CS 5 | | 24 T6721A D1
- A0 6 | | 23 D2
- A1 7 | MOS8706 | 22 T6721A D2
- 8 | | 21 D3
- _EOS 9 | | 20 T6721A D3
- APD 10 | | 19 D4
- phi2 11 | | 18 D5
- DI 12 | | 17 D6
- DTRD 13 | | 16 D7
- GND 14 |_____________| 15 _WR
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MOS8706__
-#define __MOS8706__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MOS8706_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD((_tag), MOS8706, _clock)
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mos8706_device
-
-class mos8706_device : public device_t
-{
-public:
- mos8706_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-};
-
-
-// device type definition
-extern const device_type MOS8706;
-
-
-
-#endif
diff --git a/src/emu/machine/mos8722.c b/src/emu/machine/mos8722.c
deleted file mode 100644
index 31b2beb1f27..00000000000
--- a/src/emu/machine/mos8722.c
+++ /dev/null
@@ -1,366 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS Technology 8722 Memory Management Unit emulation
-
-**********************************************************************/
-
-#include "mos8722.h"
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type MOS8722 = &device_creator<mos8722_device>;
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-#define CR_IO BIT(m_reg[CR], 0)
-#define CR_ROM_LO BIT(m_reg[CR], 1)
-#define CR_ROM_MID ((m_reg[CR] >> 2) & 0x03)
-#define CR_ROM_HI ((m_reg[CR] >> 4) & 0x03)
-#define CR_A16 BIT(m_reg[CR], 6)
-
-
-// mode configuration register
-#define MCR_8500 BIT(m_reg[MCR], 0)
-#define MCR_FSDIR BIT(m_reg[MCR], 3)
-#define MCR_GAME BIT(m_reg[MCR], 4)
-#define MCR_EXROM BIT(m_reg[MCR], 5)
-#define MCR_C64 BIT(m_reg[MCR], 6)
-#define MCR_40_80 BIT(m_reg[MCR], 7)
-
-
-// RAM configuration register
-static const offs_t RCR_BOTTOM_ADDRESS[4] = { 0x0400, 0x1000, 0x0400, 0x1000 };
-static const offs_t RCR_TOP_ADDRESS[4] = { 0xf000, 0xf000, 0xe000, 0xc000 };
-
-#define RCR_SHARE (m_reg[RCR] & 0x03)
-#define RCR_BOTTOM BIT(m_reg[RCR], 2)
-#define RCR_TOP BIT(m_reg[RCR], 3)
-#define RCR_VA16 BIT(m_reg[RCR], 6)
-
-
-// page 0 pointer register
-#define P0H_A16 BIT(m_reg[P0H], 0)
-
-
-// page 1 pointer register
-#define P1H_A16 BIT(m_reg[P1H], 0)
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mos8722_device - constructor
-//-------------------------------------------------
-
-mos8722_device::mos8722_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, MOS8722, "MOS8722", tag, owner, clock, "mos8722", __FILE__),
- m_write_z80en(*this),
- m_write_fsdir(*this),
- m_read_game(*this),
- m_read_exrom(*this),
- m_read_sense40(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mos8722_device::device_start()
-{
- // resolve callbacks
- m_write_z80en.resolve_safe();
- m_write_fsdir.resolve_safe();
- m_read_game.resolve_safe(1);
- m_read_exrom.resolve_safe(1);
- m_read_sense40.resolve_safe(1);
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mos8722_device::device_reset()
-{
- for (int i = 0; i < 16; i++)
- {
- m_reg[i] = 0;
- }
-
- m_reg[P1L] = 0x01;
-
- m_p0h_latch = 0;
- m_p1h_latch = 0;
-
- m_write_z80en(MCR_8500);
- m_write_fsdir(MCR_FSDIR);
-}
-
-
-//-------------------------------------------------
-// read - register read
-//-------------------------------------------------
-
-UINT8 mos8722_device::read(offs_t offset, UINT8 data)
-{
- if (MCR_C64) return data;
-
- if (!CR_IO && offset >= 0xd500 && offset < 0xd50c)
- {
- switch (offset & 0x0f)
- {
- case CR:
- data = m_reg[CR] | 0x80;
- break;
-
- case MCR:
- data = m_reg[MCR] | 0x06;
-
- data &= ((m_read_game() << 4) | ~0x10);
- data &= ((m_read_exrom() << 5) | ~0x20);
- data &= ((m_read_sense40() << 7) | ~0x80);
- break;
-
- case VR:
- data = 0x20;
- break;
-
- default:
- data = m_reg[offset & 0x0f];
- break;
- }
- }
- else if (offset >= 0xff00 && offset < 0xff05)
- {
- switch (offset & 0x0f)
- {
- case CR:
- data = m_reg[CR] | 0x80;
- break;
-
- default:
- data = m_reg[offset & 0x0f];
- break;
- }
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write - register write
-//-------------------------------------------------
-
-WRITE8_MEMBER( mos8722_device::write )
-{
- if (MCR_C64) return;
-
- if (!CR_IO && offset >= 0xd500 && offset < 0xd50c)
- {
- if (LOG) logerror("MOS8722 '%s' Write %01x : %02x\n", tag(), offset & 0x0f, data);
-
- switch (offset & 0x0f)
- {
- case CR:
- m_reg[CR] = data & 0x7f;
- break;
-
- case PCRA:
- case PCRB:
- case PCRC:
- case PCRD:
- m_reg[offset & 0x0f] = data & 0x7f;
- break;
-
- case MCR:
- {
- int _8500 = MCR_8500;
- int fsdir = MCR_FSDIR;
-
- m_reg[MCR] = data;
-
- if (_8500 != MCR_8500) m_write_z80en(MCR_8500);
- if (fsdir != MCR_FSDIR) m_write_fsdir(MCR_FSDIR);
- break;
- }
-
- case RCR:
- m_reg[RCR] = data & 0x4f;
- break;
-
- case P0L:
- m_reg[P0L] = data;
- m_reg[P0H] = m_p0h_latch;
- break;
-
- case P0H:
- m_p0h_latch = data & 0x01;
- break;
-
- case P1L:
- m_reg[P1L] = data;
- m_reg[P1H] = m_p1h_latch;
- break;
-
- case P1H:
- m_p1h_latch = data & 0x01;
- break;
-
- default:
- m_reg[offset & 0x0f] = data;
- }
- }
- else if (offset >= 0xff00 && offset < 0xff05)
- {
- if (LOG) logerror("MOS8722 '%s' Write %01x : %02x\n", tag(), offset & 0x0f, data);
-
- switch (offset & 0x0f)
- {
- case CR:
- m_reg[CR] = data & 0x7f;
- break;
-
- default:
- m_reg[CR] = m_reg[offset & 0x0f];
- break;
- }
- }
-}
-
-
-//-------------------------------------------------
-// fsdir_r - fast serial direction read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( mos8722_device::fsdir_r )
-{
- return MCR_FSDIR;
-}
-
-
-//-------------------------------------------------
-// ta_r - translated address read
-//-------------------------------------------------
-
-offs_t mos8722_device::ta_r(offs_t offset, int aec, int *ms0, int *ms1, int *ms2, int *ms3, int *cas0, int *cas1)
-{
- offs_t ta;
-
- *ms0 = 1;
- *ms1 = 1;
- *ms2 = CR_IO;
- *ms3 = !MCR_C64;
-
- if (aec)
- {
- // CPU access
- ta = offset & 0xff00;
-
- *cas0 = CR_A16;
- *cas1 = !*cas0;
-
- if (!MCR_C64)
- {
- if (offset >= 0xff00 && offset < 0xff05)
- {
- // MMU registers
- *cas0 = 1;
- *cas1 = 1;
- }
- else if (!MCR_8500 && !CR_A16 && offset < 0x1000)
- {
- // Z80 ROM
- ta = 0xd000 | (offset & 0xf00);
-
- *ms0 = 0;
- *ms1 = 0;
- }
- else
- {
- if (offset < 0x0100)
- {
- // page 0 pointer
- ta = m_reg[P0L] << 8;
-
- *cas0 = P0H_A16;
- *cas1 = !*cas0;
- }
- else if (offset < 0x0200)
- {
- // page 1 pointer
- ta = m_reg[P1L] << 8;
-
- *cas0 = P1H_A16;
- *cas1 = !*cas0;
- }
- else if (offset >= 0x4000 && offset < 0x8000)
- {
- // low ROM
- *ms0 = CR_ROM_LO;
- *ms1 = CR_ROM_LO;
- }
- else if (offset >= 0x8000 && offset < 0xc000)
- {
- // middle ROM
- *ms0 = BIT(CR_ROM_MID, 1);
- *ms1 = BIT(CR_ROM_MID, 0);
- }
- else if (offset >= 0xc000)
- {
- // high ROM
- *ms0 = BIT(CR_ROM_HI, 1);
- *ms1 = BIT(CR_ROM_HI, 0);
- }
-
- if (*ms0 && *ms1)
- {
- if ((offset >> 8) == m_reg[P0L])
- {
- ta = 0x0000;
- }
- else if ((offset >> 8) == m_reg[P1L])
- {
- ta = 0x0100;
- }
- }
-
- if ((RCR_BOTTOM && offset < RCR_BOTTOM_ADDRESS[RCR_SHARE]) ||
- (RCR_TOP && offset >= RCR_TOP_ADDRESS[RCR_SHARE]))
- {
- // RAM sharing
- *cas0 = 0;
- *cas1 = !*cas0;
- }
- }
- }
- }
- else
- {
- // VIC access
- ta = 0xf000 | (offset & 0xf00);
-
- *cas0 = RCR_VA16;
- *cas1 = !*cas0;
- }
-
- return ta;
-}
diff --git a/src/emu/machine/mos8722.h b/src/emu/machine/mos8722.h
deleted file mode 100644
index d342781fc4e..00000000000
--- a/src/emu/machine/mos8722.h
+++ /dev/null
@@ -1,154 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS Technology 8722 Memory Management Unit emulation
-
-**********************************************************************
- _____ _____
- Vdd 1 |* \_/ | 48 SENSE40
- _RESET 2 | | 47 (MS3) 128/64
- TA15 3 | | 46 _EXROM
- TA14 4 | | 45 _GAME
- TA13 5 | | 44 FSDIR
- TA12 6 | | 43 _Z80EN
- TA11 7 | | 42 D7
- TA10 8 | | 41 D6
- TA9 9 | | 40 D5
- TA8 10 | | 39 D4
- _CAS1 11 | | 38 D3
- _CAS0 12 | MOS8722 | 37 D2
- I/O SEL (MS2) 13 | | 36 D1
- ROMBANK1 (MS1) 14 | | 35 D0
- ROMBANK0 (MS0) 15 | | 34 Vss
- AEC 16 | | 33 phi0
- MUX 17 | | 32 R/_W
- A0 18 | | 31 A15
- A1 19 | | 30 A14
- A2 20 | | 29 A13
- A3 21 | | 28 A12
- A4/A5 22 | | 27 A11
- A6/A7 23 | | 26 A10
- A8 24 |_____________| 25 A9
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MOS8722__
-#define __MOS8722__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MOS8722_Z80EN_CALLBACK(_write) \
- devcb = &mos8722_device::set_z80en_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS8722_FSDIR_CALLBACK(_write) \
- devcb = &mos8722_device::set_fsdir_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_MOS8722_GAME_CALLBACK(_read) \
- devcb = &mos8722_device::set_game_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS8722_EXROM_CALLBACK(_read) \
- devcb = &mos8722_device::set_exrom_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_MOS8722_SENSE40_CALLBACK(_read) \
- devcb = &mos8722_device::set_sense40_rd_callback(*device, DEVCB_##_read);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mos8722_device
-
-class mos8722_device : public device_t
-{
-public:
- // construction/destruction
- mos8722_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_z80en_wr_callback(device_t &device, _Object object) { return downcast<mos8722_device &>(device).m_write_z80en.set_callback(object); }
- template<class _Object> static devcb_base &set_fsdir_wr_callback(device_t &device, _Object object) { return downcast<mos8722_device &>(device).m_write_fsdir.set_callback(object); }
- template<class _Object> static devcb_base &set_game_rd_callback(device_t &device, _Object object) { return downcast<mos8722_device &>(device).m_read_game.set_callback(object); }
- template<class _Object> static devcb_base &set_exrom_rd_callback(device_t &device, _Object object) { return downcast<mos8722_device &>(device).m_read_exrom.set_callback(object); }
- template<class _Object> static devcb_base &set_sense40_rd_callback(device_t &device, _Object object) { return downcast<mos8722_device &>(device).m_read_sense40.set_callback(object); }
-
-
- UINT8 read(offs_t offset, UINT8 data);
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_READ_LINE_MEMBER( fsdir_r );
-
- offs_t ta_r(offs_t offset, int aec, int *ms0, int *ms1, int *ms2, int *ms3, int *cas0, int *cas1);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- enum
- {
- CR = 0,
- PCRA, LCRA = PCRA,
- PCRB, LCRB = PCRB,
- PCRC, LCRC = PCRC,
- PCRD, LCRD = PCRD,
- MCR,
- RCR,
- P0L,
- P0H,
- P1L,
- P1H,
- VR
- };
-
- enum
- {
- CR_IO_SYSTEM_IO = 0,
- CR_IO_HI_ROM
- };
-
- enum
- {
- CR_ROM_SYSTEM_ROM = 0,
- CR_ROM_INT_FUNC_ROM,
- CR_ROM_EXT_FUNC_ROM,
- CR_ROM_RAM
- };
-
- enum
- {
- RCR_SHARE_1K = 0,
- RCR_SHARE_4K,
- RCR_SHARE_8K,
- RCR_SHARE_16K
- };
-
- devcb_write_line m_write_z80en;
- devcb_write_line m_write_fsdir;
- devcb_read_line m_read_game;
- devcb_read_line m_read_exrom;
- devcb_read_line m_read_sense40;
-
- UINT8 m_reg[16];
-
- UINT8 m_p0h_latch;
- UINT8 m_p1h_latch;
-};
-
-
-// device type definition
-extern const device_type MOS8722;
-
-
-
-#endif
diff --git a/src/emu/machine/mos8726.c b/src/emu/machine/mos8726.c
deleted file mode 100644
index eca6ada5187..00000000000
--- a/src/emu/machine/mos8726.c
+++ /dev/null
@@ -1,125 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS 8726R1 DMA Controller emulation
-
-**********************************************************************/
-
-/*
-
- TODO:
-
- - all
-
-*/
-
-#include "mos8726.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-
-
-//**************************************************************************
-// DEVICE TYPE DEFINITIONS
-//**************************************************************************
-
-const device_type MOS8726 = &device_creator<mos8726_device>;
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mos8726_device - constructor
-//-------------------------------------------------
-
-mos8726_device::mos8726_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MOS8726, "MOS8726", tag, owner, clock, "mos8726", __FILE__),
- device_execute_interface(mconfig, *this),
- m_icount(0),
- m_bs(1)
-{ }
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mos8726_device::device_start()
-{
- // set our instruction counter
- m_icountptr = &m_icount;
-
- // save state
- save_item(NAME(m_bs));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mos8726_device::device_reset()
-{
-}
-
-
-//-------------------------------------------------
-// execute_run -
-//-------------------------------------------------
-
-void mos8726_device::execute_run()
-{
- do
- {
- m_icount--;
- } while (m_icount > 0);
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( mos8726_device::read )
-{
- UINT8 data = 0;
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( mos8726_device::write )
-{
-}
-
-
-//-------------------------------------------------
-// bs_w - bank select write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( mos8726_device::bs_w )
-{
- m_bs = state;
-}
-
-
-//-------------------------------------------------
-// romsel_r - ROM select read
-//-------------------------------------------------
-
-int mos8726_device::romsel_r(int roml, int romh)
-{
- return roml && romh;
-}
diff --git a/src/emu/machine/mos8726.h b/src/emu/machine/mos8726.h
deleted file mode 100644
index 324d99794de..00000000000
--- a/src/emu/machine/mos8726.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- MOS 8726R1 DMA Controller emulation
-
-**********************************************************************
- _____ _____
- /RESET 1 |* \_/ | 64 Vcc
- /IRQ 2 | | 63 BS
- DOTCLK 3 | | 62 CAS1
- R/W 4 | | 61 CAS0
- 1 MHz 5 | | 60 RAS1
- /CS 6 | | 59 RAS0
- /BA 7 | | 58 /DWE
- /DMA 8 | | 57 DD0
- D7 9 | | 56 DD1
- D6 10 | | 55 DD2
- D5 11 | | 54 DD3
- D4 12 | | 53 DD4
- D3 13 | | 52 DD5
- D2 14 | | 51 DD6
- D1 15 | MOS8726 | 50 DD7
- D0 16 | MOS8726R1 | 49 Vss
- Vss 17 | | 48 MA8
- A15 18 | | 47 MA7
- A14 19 | | 46 MA6
- A13 20 | | 45 MA5
- A12 21 | | 44 MA4
- A11 22 | | 43 MA3
- A10 23 | | 42 MA2
- A9 24 | | 41 MA1
- A8 25 | | 40 MA0
- A7 26 | | 39 TEST
- A6 27 | | 38 Vss
- A5 28 | | 37 Vcc
- A4 29 | | 36 /ROMSEL
- A3 30 | | 35 /ROML
- A2 31 | | 34 /ROMH
- A1 32 |_____________| 33 A0
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MOS8726__
-#define __MOS8726__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MOS8726_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, MOS8726, 1000000) // dummy clock
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> mos8726_device
-
-class mos8726_device : public device_t,
- public device_execute_interface
-{
-public:
- // construction/destruction
- mos8726_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( bs_w );
-
- int romsel_r(int roml, int romh);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void execute_run();
-
- int m_icount;
- int m_bs;
-};
-
-
-// device type definition
-extern const device_type MOS8726;
-
-
-
-#endif
diff --git a/src/emu/machine/mpu401.c b/src/emu/machine/mpu401.c
deleted file mode 100644
index 5a2933380df..00000000000
--- a/src/emu/machine/mpu401.c
+++ /dev/null
@@ -1,289 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/***************************************************************************
-
- Roland MPU-401 core
-
- This emulates the MPU-401 external box with the 6801, ASIC, and RAM in it.
-
- We do it this way to facilitate the various PC, Apple II, C64, and other
- possible hookups.
-
- 6801 GPIO port hookups (from the schematics)
-
- P10 / P11 / P12: drive the metronome and speaker
- P13 / P14 / P15: drive 3 pins on the SYNC OUT connector
- P16: to DSRD on gate array
- P17: to DRRD on gate array
-
- P20: to SYC OUT on gate array
- P21: to SYC IN on gate array, pulled up to Vcc via 4.7K resistor
- programmed as output of timer (OLVL)
- P22: to SRCK on gate array, inverted
- P23: MIDI IN serial data (SCI in)
- P24: MIDI OUT serial data (SCI out)
-
- ASIC addresses from the 6801:
- 0x20: (r) read pending byte from the PC (w) apparently nothing
- 0x21: (r) ASIC status, see STAT_xxx bits below (w) send new byte to PC data port
-
- Theory of operation: 6801's timer/counter is set up to drive a pulse stream
- out P21 to the ASIC's SYC IN pin. The ASIC in turn generates the MIDI baud
- rate (times 8) and returns that on pin P22.
-
- The 6801 is believed to run in mode 2, based on a combination of the
- schematics and the behavior (ie, internal RAM from 80-FF is clearly
- present from the program's behavior, and ports 3/4 are obviously external
- address/data buses)
-
-***************************************************************************/
-
-#include "machine/mpu401.h"
-#include "bus/midi/midi.h"
-
-#define M6801_TAG "mpu6801"
-#define ROM_TAG "mpurom"
-#define MIDIIN_TAG "mdin"
-#define MIDIOUT_TAG "mdout"
-
-#define P2_SYNC_OUT (0x01)
-#define P2_SYNC_IN (0x02)
-#define P2_SRCK_OUT (0x04)
-#define P2_MIDI_IN (0x08)
-#define P2_MIDI_OUT (0x10)
-
-#define STAT_CMD_PORT (0x01) // set if the new byte indicated by TX FULL was written to the command port, clear for data port
-#define STAT_TX_FULL (0x40) // indicates the PC has written a new byte we haven't read yet
-#define STAT_RX_EMPTY (0x80) // indicates we've written a new byte the PC hasn't read yet
-
-static ADDRESS_MAP_START( mpu401_map, AS_PROGRAM, 8, mpu401_device )
- AM_RANGE(0x0000, 0x001f) AM_READWRITE(regs_mode2_r, regs_mode2_w)
- AM_RANGE(0x0020, 0x0021) AM_READWRITE(asic_r, asic_w)
- AM_RANGE(0x0080, 0x00ff) AM_RAM // on-chip RAM
- AM_RANGE(0x0800, 0x0fff) AM_RAM // external RAM
- AM_RANGE(0xf000, 0xffff) AM_ROM AM_REGION(ROM_TAG, 0)
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( mpu401_io_map, AS_IO, 8, mpu401_device )
- AM_RANGE(M6801_PORT1, M6801_PORT1) AM_READWRITE(port1_r, port1_w)
- AM_RANGE(M6801_PORT2, M6801_PORT2) AM_READWRITE(port2_r, port2_w)
-ADDRESS_MAP_END
-
-MACHINE_CONFIG_FRAGMENT( mpu401 )
- MCFG_CPU_ADD(M6801_TAG, M6801, 4000000) /* 4 MHz as per schematics */
- MCFG_CPU_PROGRAM_MAP(mpu401_map)
- MCFG_CPU_IO_MAP(mpu401_io_map)
- MCFG_M6801_SER_TX(DEVWRITELINE(MIDIOUT_TAG, midi_port_device, write_txd))
-
- MCFG_MIDI_PORT_ADD(MIDIIN_TAG, midiin_slot, "midiin")
- MCFG_MIDI_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, mpu401_device, midi_rx_w))
-
- MCFG_MIDI_PORT_ADD(MIDIOUT_TAG, midiout_slot, "midiout")
-MACHINE_CONFIG_END
-
-ROM_START( mpu401 )
- ROM_REGION(0x1000, ROM_TAG, 0)
- ROM_LOAD( "roland_6801v0b55p.bin", 0x000000, 0x001000, CRC(65d3a151) SHA1(00efbfb96aeb997b69bb16981c6751d3c784bb87) )
-ROM_END
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-const device_type MPU401 = &device_creator<mpu401_device>;
-
-//-------------------------------------------------
-// machine_config_additions - device-specific
-// machine configurations
-//-------------------------------------------------
-
-machine_config_constructor mpu401_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( mpu401 );
-}
-
-//-------------------------------------------------
-// rom_region - device-specific ROM region
-//-------------------------------------------------
-
-const rom_entry *mpu401_device::device_rom_region() const
-{
- return ROM_NAME( mpu401 );
-}
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// mpu401_device - constructor
-//-------------------------------------------------
-
-mpu401_device::mpu401_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, MPU401, "Roland MPU-401 I/O box", tag, owner, clock, "mpu401", __FILE__),
- m_ourcpu(*this, M6801_TAG),
- write_irq(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mpu401_device::device_start()
-{
- write_irq.resolve_safe();
- m_timer = timer_alloc(0, NULL);
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void mpu401_device::device_reset()
-{
- m_port2 = 0xff & ~(P2_SRCK_OUT | P2_MIDI_IN); // prevent spurious reception
- m_command = 0;
- m_mpudata = 0;
- m_gatearrstat = 0;
-
- m_timer->adjust(attotime::zero, 0, attotime::from_hz(31250*8));
-}
-
-//-------------------------------------------------
-// device_timer - called when our device timer expires
-//-------------------------------------------------
-
-void mpu401_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
-{
- m_ourcpu->m6801_clock_serial();
-}
-
-READ8_MEMBER(mpu401_device::regs_mode2_r)
-{
- switch (offset)
- {
- case 4:
- case 5:
- case 6:
- case 7:
- case 0xf:
-// printf("MPU401: read @ unk %x (PC=%x)\n", offset, space.device().safe_pc());
- break;
-
- default:
- return m_ourcpu->m6801_io_r(space, offset);
- }
-
- return 0xff;
-}
-
-WRITE8_MEMBER(mpu401_device::regs_mode2_w)
-{
- switch (offset)
- {
- case 4:
- case 5:
- case 6:
- case 7:
- case 0xf:
-// printf("MPU401: %02x @ unk %x (PC=%x)\n", data, offset, space.device().safe_pc());
- break;
-
- default:
- return m_ourcpu->m6801_io_w(space, offset, data);
- }
-}
-
-READ8_MEMBER(mpu401_device::port1_r)
-{
- return 0xff;
-}
-
-WRITE8_MEMBER(mpu401_device::port1_w)
-{
-// printf("port1_w: %02x met %x syncout %x DSRD %d DRRD %d\n", data, data & 3, (data>>3) & 3, (data>>6) & 1, (data>>7) & 1);
-}
-
-READ8_MEMBER(mpu401_device::port2_r)
-{
-// printf("Read P2 (PC=%x)\n", space.device().safe_pc());
- return m_port2;
-}
-
-WRITE8_MEMBER(mpu401_device::port2_w)
-{
-// printf("port2_w: %02x SYCOUT %d SYCIN %d SRCK %d MIDI OUT %d\n", data, (data & 1), (data>>1) & 1, (data>>2) & 1, (data>>4) & 1);
-}
-
-READ8_MEMBER(mpu401_device::mpu_r)
-{
-// printf("mpu_r @ %d\n", offset);
-
- if (offset == 1) // status
- {
- return m_gatearrstat;
- }
- else // data
- {
- write_irq(CLEAR_LINE);
- m_gatearrstat |= STAT_RX_EMPTY;
- return m_mpudata;
- }
-}
-
-WRITE8_MEMBER(mpu401_device::mpu_w)
-{
-// printf("%02x to MPU-401 @ %d\n", data, offset);
- m_command = data;
- m_gatearrstat |= STAT_TX_FULL;
-
- if (offset == 1)
- {
- m_gatearrstat |= STAT_CMD_PORT;
- }
- else
- {
- m_gatearrstat &= ~STAT_CMD_PORT;
- }
-}
-
-READ8_MEMBER(mpu401_device::asic_r)
-{
- if (offset == 0)
- {
- m_gatearrstat &= ~STAT_TX_FULL;
- return m_command;
- }
- else if (offset == 1)
- {
- return m_gatearrstat;
- }
-
- return 0xff;
-}
-
-WRITE8_MEMBER(mpu401_device::asic_w)
-{
-// printf("MPU401: %02x to gate array @ %d\n", data, offset);
-
- if (offset == 1)
- {
- m_mpudata = data;
- m_gatearrstat &= ~STAT_RX_EMPTY;
- write_irq(ASSERT_LINE);
- }
-}
-
-// MIDI receive
-WRITE_LINE_MEMBER( mpu401_device::midi_rx_w )
-{
- if (state == ASSERT_LINE)
- {
- m_port2 |= P2_MIDI_IN;
- }
- else
- {
- m_port2 &= ~P2_MIDI_IN;
- }
-}
diff --git a/src/emu/machine/mpu401.h b/src/emu/machine/mpu401.h
deleted file mode 100644
index 58acb3ab98e..00000000000
--- a/src/emu/machine/mpu401.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-#pragma once
-
-#ifndef __MPU401_H__
-#define __MPU401_H__
-
-#include "emu.h"
-#include "cpu/m6800/m6800.h"
-
-#define MCFG_MPU401_ADD(_tag, _irqf ) \
- MCFG_DEVICE_ADD(_tag, MPU401, 0) \
- MCFG_IRQ_FUNC(_irqf)
-
-#define MCFG_IRQ_FUNC(_irqf) \
- downcast<mpu401_device *>(device)->set_irqf(DEVCB_##_irqf);
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-class mpu401_device : public device_t
-{
-public:
- // construction/destruction
- mpu401_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // optional information overrides
- virtual machine_config_constructor device_mconfig_additions() const;
-
- required_device<m6801_cpu_device> m_ourcpu;
-
- template<class _write> void set_irqf(_write wr)
- {
- write_irq.set_callback(wr);
- }
-
- devcb_write_line write_irq;
-
- DECLARE_READ8_MEMBER(regs_mode2_r);
- DECLARE_WRITE8_MEMBER(regs_mode2_w);
- DECLARE_READ8_MEMBER(asic_r);
- DECLARE_WRITE8_MEMBER(asic_w);
- DECLARE_READ8_MEMBER(port1_r);
- DECLARE_WRITE8_MEMBER(port1_w);
- DECLARE_READ8_MEMBER(port2_r);
- DECLARE_WRITE8_MEMBER(port2_w);
- DECLARE_WRITE_LINE_MEMBER(midi_rx_w);
-
- // public API - call for reads/writes at I/O 330/331 on PC, C0n0/C0n1 on Apple II, etc.
- DECLARE_READ8_MEMBER(mpu_r);
- DECLARE_WRITE8_MEMBER(mpu_w);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual const rom_entry *device_rom_region() const;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- UINT8 m_port2;
- UINT8 m_command;
- UINT8 m_mpudata;
- UINT8 m_gatearrstat;
- emu_timer *m_timer;
-};
-
-// device type definition
-extern const device_type MPU401;
-
-#endif /* __MPU401_H__ */
diff --git a/src/emu/machine/msm5832.c b/src/emu/machine/msm5832.c
deleted file mode 100644
index 7bc6fa70bfa..00000000000
--- a/src/emu/machine/msm5832.c
+++ /dev/null
@@ -1,306 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- OKI MSM5832 Real Time Clock/Calendar emulation
-
-**********************************************************************/
-
-/*
-
- TODO:
-
- - 12/24 hour
- - AM/PM
- - leap year
- - test input
- - reference signal output
-
-*/
-
-#include "msm5832.h"
-
-
-// device type definition
-const device_type MSM5832 = &device_creator<msm5832_device>;
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-// registers
-enum
-{
- REGISTER_S1 = 0,
- REGISTER_S10,
- REGISTER_MI1,
- REGISTER_MI10,
- REGISTER_H1,
- REGISTER_H10,
- REGISTER_W,
- REGISTER_D1,
- REGISTER_D10,
- REGISTER_MO1,
- REGISTER_MO10,
- REGISTER_Y1,
- REGISTER_Y10,
- REGISTER_REF = 15
-};
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// read_counter -
-//-------------------------------------------------
-
-inline int msm5832_device::read_counter(int counter)
-{
- return (m_reg[counter + 1] * 10) + m_reg[counter];
-}
-
-
-//-------------------------------------------------
-// write_counter -
-//-------------------------------------------------
-
-inline void msm5832_device::write_counter(int counter, int value)
-{
- m_reg[counter] = value % 10;
- m_reg[counter + 1] = value / 10;
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// msm5832_device - constructor
-//-------------------------------------------------
-
-msm5832_device::msm5832_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MSM5832, "MSM5832", tag, owner, clock, "msm5832", __FILE__),
- device_rtc_interface(mconfig, *this),
- m_hold(0),
- m_address(0),
- m_read(0),
- m_write(0),
- m_cs(0)
-{
- for (int i = 0; i < 13; i++)
- m_reg[i] = 0;
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void msm5832_device::device_start()
-{
- // allocate timers
- m_clock_timer = timer_alloc(TIMER_CLOCK);
- m_clock_timer->adjust(attotime::from_hz(clock() / 32768), 0, attotime::from_hz(clock() / 32768));
-
- // state saving
- save_item(NAME(m_reg));
- save_item(NAME(m_hold));
- save_item(NAME(m_address));
- save_item(NAME(m_read));
- save_item(NAME(m_write));
- save_item(NAME(m_cs));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void msm5832_device::device_reset()
-{
- set_current_time(machine());
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void msm5832_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_CLOCK:
- if (!m_hold)
- {
- advance_seconds();
- }
- break;
- }
-}
-
-
-//-------------------------------------------------
-// rtc_clock_updated -
-//-------------------------------------------------
-
-void msm5832_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
- write_counter(REGISTER_Y1, year);
- write_counter(REGISTER_MO1, month);
- write_counter(REGISTER_D1, day);
- m_reg[REGISTER_W] = day_of_week-1;
- write_counter(REGISTER_H1, hour);
- write_counter(REGISTER_MI1, minute);
- write_counter(REGISTER_S1, second);
-}
-
-
-//-------------------------------------------------
-// data_r -
-//-------------------------------------------------
-
-READ8_MEMBER( msm5832_device::data_r )
-{
- UINT8 data = 0;
-
- if (m_cs && m_read)
- {
- if (m_address == REGISTER_REF)
- {
- // TODO reference output
- }
- else if (m_address <= REGISTER_Y10)
- {
- data = m_reg[m_address];
- }
- else
- {
- // Otrona Attache CP/M BIOS checks unused registers to detect it
- data = 0x0f;
- }
- }
-
- if (LOG) logerror("MSM5832 '%s' Register Read %01x: %01x\n", tag(), m_address, data & 0x0f);
-
- return data & 0x0f;
-}
-
-
-//-------------------------------------------------
-// data_w -
-//-------------------------------------------------
-
-WRITE8_MEMBER( msm5832_device::data_w )
-{
- if (LOG) logerror("MSM5832 '%s' Register Write %01x: %01x\n", tag(), m_address, data & 0x0f);
-
- if (m_cs && m_write)
- {
- if (m_address == REGISTER_REF)
- {
- // TODO reference output
- }
- else if (m_address <= REGISTER_Y10)
- {
- m_reg[m_address] = data & 0x0f;
-
- set_time(false, read_counter(REGISTER_Y1), read_counter(REGISTER_MO1), read_counter(REGISTER_D1), m_reg[REGISTER_W],
- read_counter(REGISTER_H1), read_counter(REGISTER_MI1), read_counter(REGISTER_S1));
- }
- }
-}
-
-
-//-------------------------------------------------
-// address_w -
-//-------------------------------------------------
-
-void msm5832_device::address_w(UINT8 data)
-{
- if (LOG) logerror("MSM5832 '%s' Address: %01x\n", tag(), data & 0x0f);
-
- m_address = data & 0x0f;
-}
-
-
-//-------------------------------------------------
-// adj_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm5832_device::adj_w )
-{
- if (LOG) logerror("MSM5832 '%s' 30 ADJ: %u\n", tag(), state);
-
- if (state)
- {
- adjust_seconds();
- }
-}
-
-
-//-------------------------------------------------
-// test_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm5832_device::test_w )
-{
- if (LOG) logerror("MSM5832 '%s' TEST: %u\n", tag(), state);
-}
-
-
-//-------------------------------------------------
-// hold_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm5832_device::hold_w )
-{
- if (LOG) logerror("MSM5832 '%s' HOLD: %u\n", tag(), state);
-
- m_hold = state;
-}
-
-
-//-------------------------------------------------
-// read_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm5832_device::read_w )
-{
- if (LOG) logerror("MSM5832 '%s' READ: %u\n", tag(), state);
-
- m_read = state;
-}
-
-
-//-------------------------------------------------
-// write_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm5832_device::write_w )
-{
- if (LOG) logerror("MSM5832 '%s' WR: %u\n", tag(), state);
-
- m_write = state;
-}
-
-
-//-------------------------------------------------
-// cs_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm5832_device::cs_w )
-{
- if (LOG) logerror("MSM5832 '%s' CS: %u\n", tag(), state);
-
- m_cs = state;
-}
diff --git a/src/emu/machine/msm5832.h b/src/emu/machine/msm5832.h
deleted file mode 100644
index 68b72a3f8bf..00000000000
--- a/src/emu/machine/msm5832.h
+++ /dev/null
@@ -1,99 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- OKI MSM5832 Real Time Clock/Calendar emulation
-
-**********************************************************************
- _____ _____
- Vdd 1 |* \_/ | 18 HOLD
- WRITE 2 | | 17 _XT
- READ 3 | | 16 XT
- A0 4 | | 15 +- 30 ADJ
- A1 5 | MSM5832 | 14 TEST
- A2 6 | | 13 GND
- A3 7 | | 12 D3
- CS 8 | | 11 D2
- D0 9 |_____________| 10 D1
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MSM5832__
-#define __MSM5832__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MSM5832_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, MSM5832, _clock)
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> msm5832_device
-
-class msm5832_device : public device_t,
- public device_rtc_interface
-{
-public:
- // construction/destruction
- msm5832_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER( data_r );
- DECLARE_WRITE8_MEMBER( data_w );
-
- void address_w(UINT8 data);
-
- DECLARE_WRITE_LINE_MEMBER( adj_w );
- DECLARE_WRITE_LINE_MEMBER( test_w );
- DECLARE_WRITE_LINE_MEMBER( hold_w );
-
- DECLARE_WRITE_LINE_MEMBER( read_w );
- DECLARE_WRITE_LINE_MEMBER( write_w );
- DECLARE_WRITE_LINE_MEMBER( cs_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_rtc_interface overrides
- virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
-
-private:
- static const device_timer_id TIMER_CLOCK = 0;
-
- inline int read_counter(int counter);
- inline void write_counter(int counter, int value);
-
- UINT8 m_reg[13]; // registers
-
- int m_hold; // counter hold
- int m_address; // address
-
- int m_read;
- int m_write;
- int m_cs;
-
- // timers
- emu_timer *m_clock_timer;
-};
-
-
-// device type definition
-extern const device_type MSM5832;
-
-
-
-#endif
diff --git a/src/emu/machine/msm58321.c b/src/emu/machine/msm58321.c
deleted file mode 100644
index 679b85584ff..00000000000
--- a/src/emu/machine/msm58321.c
+++ /dev/null
@@ -1,646 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- OKI MSM58321RS Real Time Clock/Calendar emulation
-
-**********************************************************************/
-
-/*
-
- TODO:
-
- - leap year
- - test
- - reference registers
-
-*/
-
-#include "msm58321.h"
-
-
-// device type definition
-const device_type MSM58321 = &device_creator<msm58321_device>;
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-// registers
-enum
-{
- REGISTER_S1 = 0,
- REGISTER_S10,
- REGISTER_MI1,
- REGISTER_MI10,
- REGISTER_H1,
- REGISTER_H10,
- REGISTER_W,
- REGISTER_D1,
- REGISTER_D10,
- REGISTER_MO1,
- REGISTER_MO10,
- REGISTER_Y1,
- REGISTER_Y10,
- REGISTER_RESET,
- REGISTER_REF0,
- REGISTER_REF1
-};
-
-static const char *reg_name(UINT8 address)
-{
- switch(address)
- {
- case REGISTER_S1: return "S1";
- case REGISTER_S10: return "S10";
- case REGISTER_MI1: return "MI1";
- case REGISTER_MI10: return "MI10";
- case REGISTER_H1: return "H1";
- case REGISTER_H10: return "H10";
- case REGISTER_W: return "W";
- case REGISTER_D1: return "D1";
- case REGISTER_D10: return "D10";
- case REGISTER_MO1: return "MO1";
- case REGISTER_MO10: return "MO10";
- case REGISTER_Y1: return "Y1";
- case REGISTER_Y10: return "Y10";
- case REGISTER_RESET: return "RESET";
- case REGISTER_REF0: return "REF0";
- case REGISTER_REF1: return "REF1";
- }
-
- return "INVALID REGISTER";
-}
-
-enum
-{
- H10_PM = 4,
- H10_24 = 8
-};
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// read_counter -
-//-------------------------------------------------
-
-inline int msm58321_device::read_counter(int counter)
-{
- int data = m_reg[counter];
-
- if (counter == REGISTER_H1)
- {
- int h10 = m_reg[REGISTER_H10];
-
- if (h10 & H10_24)
- {
- data += (h10 & 3) * 10;
- }
- else
- {
- data += (h10 & 1) * 10;
-
- if (h10 & H10_PM)
- {
- if (data != 12)
- {
- data += 12;
- }
- }
- else if (data == 12)
- {
- data = 0;
- }
- }
- }
- else
- {
- data += (m_reg[counter + 1] * 10);
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write_counter -
-//-------------------------------------------------
-
-inline void msm58321_device::write_counter(int address, int data)
-{
- int flag = 0;
-
- switch (address)
- {
- case REGISTER_H1:
- flag = m_reg[REGISTER_H10] & H10_24;
- if (!flag)
- {
- if (data >= 12)
- {
- data -= 12;
- flag = H10_PM;
- }
-
- if (data == 0)
- {
- data = 12;
- }
- }
- break;
-
- case REGISTER_D1:
- flag = (m_reg[REGISTER_D10] & ~3);
- break;
- }
-
- m_reg[address] = data % 10;
- m_reg[address + 1] = (data / 10) | flag;
-}
-
-
-
-//-------------------------------------------------
-// msm58321_device - constructor
-//-------------------------------------------------
-
-msm58321_device::msm58321_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MSM58321, "MSM58321", tag, owner, clock, "msm58321", __FILE__),
- device_rtc_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this),
- m_year0(0),
- m_default_24h(false),
- m_d0_handler(*this),
- m_d1_handler(*this),
- m_d2_handler(*this),
- m_d3_handler(*this),
- m_busy_handler(*this),
- m_cs2(0),
- m_write(0),
- m_read(0),
- m_d0_in(0),
- m_d0_out(0),
- m_d1_in(0),
- m_d1_out(0),
- m_d2_in(0),
- m_d2_out(0),
- m_d3_in(0),
- m_d3_out(0),
- m_address_write(0),
- m_busy(0),
- m_stop(0),
- m_test(0),
- m_cs1(0),
- m_address(0xf)
-{
- memset(m_reg, 0x00, sizeof(m_reg));
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void msm58321_device::device_start()
-{
- // resolve callbacks
- m_d0_handler.resolve_safe();
- m_d1_handler.resolve_safe();
- m_d2_handler.resolve_safe();
- m_d3_handler.resolve_safe();
- m_busy_handler.resolve_safe();
-
- // allocate timers
- m_clock_timer = timer_alloc(TIMER_CLOCK);
- m_clock_timer->adjust(attotime::from_hz(clock() / 32768), 0, attotime::from_hz(clock() / 32768));
-
- m_busy_timer = timer_alloc(TIMER_BUSY);
- m_busy_timer->adjust(attotime::from_hz(clock() / 16384), 0, attotime::from_hz(clock() / 16384));
-
- // state saving
- save_item(NAME(m_cs2));
- save_item(NAME(m_write));
- save_item(NAME(m_read));
- save_item(NAME(m_d0_in));
- save_item(NAME(m_d0_out));
- save_item(NAME(m_d1_in));
- save_item(NAME(m_d1_out));
- save_item(NAME(m_d2_in));
- save_item(NAME(m_d2_out));
- save_item(NAME(m_d3_in));
- save_item(NAME(m_d3_out));
- save_item(NAME(m_address_write));
- save_item(NAME(m_busy));
- save_item(NAME(m_stop));
- save_item(NAME(m_test));
- save_item(NAME(m_cs1));
- save_item(NAME(m_address));
- save_item(NAME(m_reg));
-
- set_current_time(machine());
-
- update_output();
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void msm58321_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_CLOCK:
- if (!m_stop)
- advance_seconds();
- break;
-
- case TIMER_BUSY:
- if (!m_cs1 || !m_cs2 || !m_write || m_address != REGISTER_RESET)
- {
- m_busy = !m_busy;
- m_busy_handler(m_busy);
- }
- break;
- }
-}
-
-
-//-------------------------------------------------
-// rtc_clock_updated -
-//-------------------------------------------------
-
-void msm58321_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
- write_counter(REGISTER_Y1, (year - m_year0) % 100);
- write_counter(REGISTER_MO1, month);
- write_counter(REGISTER_D1, day);
- m_reg[REGISTER_W] = day_of_week;
- write_counter(REGISTER_H1, hour);
- write_counter(REGISTER_MI1, minute);
- write_counter(REGISTER_S1, second);
-
- update_output();
-}
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void msm58321_device::nvram_default()
-{
- for (int i = 0; i < 13; i++)
- m_reg[i] = 0;
-
- if (m_default_24h)
- m_reg[REGISTER_H10] = H10_24;
-
- clock_updated();
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void msm58321_device::nvram_read(emu_file &file)
-{
- file.read(m_reg, sizeof(m_reg));
-
- clock_updated();
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void msm58321_device::nvram_write(emu_file &file)
-{
- file.write(m_reg, sizeof(m_reg));
-}
-
-//-------------------------------------------------
-// update_output -
-//-------------------------------------------------
-
-void msm58321_device::update_output()
-{
- UINT8 data = 0xf;
-
- if (m_cs1 && m_cs2 && m_read)
- {
- switch (m_address)
- {
- case REGISTER_RESET:
- data = 0;
- break;
-
- case REGISTER_REF0:
- case REGISTER_REF1:
- // TODO: output reference values
- data = 0;
- break;
-
- default:
- data = m_reg[m_address];
- break;
- }
-
- if (LOG) logerror("MSM58321 '%s' Register Read %s (%01x): %01x\n", tag(), reg_name(m_address), m_address, data & 0x0f);
- }
-
- int d0 = (data >> 0) & 1;
- if (m_d0_out != d0)
- {
- m_d0_out = d0;
- m_d0_handler(d0);
- }
-
- int d1 = (data >> 1) & 1;
- if (m_d1_out != d1)
- {
- m_d1_out = d1;
- m_d1_handler(d1);
- }
-
- int d2 = (data >> 2) & 1;
- if (m_d2_out != d2)
- {
- m_d2_out = d2;
- m_d2_handler(d2);
- }
-
- int d3 = (data >> 3) & 1;
- if (m_d3_out != d3)
- {
- m_d3_out = d3;
- m_d3_handler(d3);
- }
-}
-
-
-//-------------------------------------------------
-// update_input() -
-//-------------------------------------------------
-
-void msm58321_device::update_input()
-{
- if (m_cs1 && m_cs2)
- {
- UINT8 data = m_d0_in | (m_d1_in << 1) | (m_d2_in << 2) | (m_d3_in << 3);
-
- if (m_address_write)
- {
- if (LOG) logerror("MSM58321 '%s' Latch Address %01x\n", tag(), data);
-
- // latch address
- m_address = data;
- }
-
- if (m_write)
- {
- switch(m_address)
- {
- case REGISTER_RESET:
- if (LOG) logerror("MSM58321 '%s' Reset\n", tag());
-
- if (!m_busy)
- {
- m_busy = 1;
- m_busy_handler(m_busy);
- }
- break;
-
- case REGISTER_REF0:
- case REGISTER_REF1:
- if (LOG) logerror("MSM58321 '%s' Reference Signal\n", tag());
- break;
-
- default:
- if (LOG) logerror("MSM58321 '%s' Register Write %s (%01x): %01x\n", tag(), reg_name(m_address), m_address, data);
-
- switch (m_address)
- {
- case REGISTER_S10:
- case REGISTER_MI10:
- case REGISTER_W:
- m_reg[m_address] = data & 7;
- break;
-
- case REGISTER_H10:
- if (data & H10_24)
- {
- // "When D3 = 1 is written, the D2 bit is reset inside the IC."
- // but it doesn't say if this is done immediately or on the next update
- m_reg[m_address] = data & ~H10_PM;
- }
- else
- {
- m_reg[m_address] = data;
- }
- break;
-
- case REGISTER_MO10:
- m_reg[m_address] = data & 1;
- break;
-
- default:
- m_reg[m_address] = data;
- break;
- }
-
- set_time(false, read_counter(REGISTER_Y1) + m_year0, read_counter(REGISTER_MO1), read_counter(REGISTER_D1), m_reg[REGISTER_W],
- read_counter(REGISTER_H1), read_counter(REGISTER_MI1), read_counter(REGISTER_S1));
- break;
- }
- }
- }
-}
-
-//-------------------------------------------------
-// cs2_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm58321_device::cs2_w )
-{
- if (m_cs2 != state)
- {
- if (LOG) logerror("MSM58321 '%s' CS2: %u\n", tag(), state);
-
- m_cs2 = state;
-
- update_input();
- }
-}
-
-
-//-------------------------------------------------
-// write_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm58321_device::write_w )
-{
- if (m_write != state)
- {
- if (LOG) logerror("MSM58321 '%s' WRITE: %u\n", tag(), state);
-
- m_write = state;
-
- update_input();
- }
-}
-
-
-//-------------------------------------------------
-// read_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm58321_device::read_w )
-{
- if (m_read != state)
- {
- if (LOG) logerror("MSM58321 '%s' READ: %u\n", tag(), state);
-
- m_read = state;
-
- update_output();
- }
-}
-
-
-
-//-------------------------------------------------
-// d0_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm58321_device::d0_w )
-{
- if (m_d0_in != state)
- {
- m_d0_in = state;
-
- update_input();
- }
-}
-
-
-//-------------------------------------------------
-// d1_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm58321_device::d1_w )
-{
- if (m_d1_in != state)
- {
- m_d1_in = state;
-
- update_input();
- }
-}
-
-
-//-------------------------------------------------
-// d2_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm58321_device::d2_w )
-{
- if (m_d2_in != state)
- {
- m_d2_in = state;
-
- update_input();
- }
-}
-
-
-//-------------------------------------------------
-// d3_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm58321_device::d3_w )
-{
- if (m_d3_in != state)
- {
- m_d3_in = state;
-
- update_input();
- }
-}
-
-
-//-------------------------------------------------
-// address_write_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm58321_device::address_write_w )
-{
- if (m_address_write != state)
- {
- if (LOG) logerror("MSM58321 '%s' ADDRESS WRITE: %u\n", tag(), state);
-
- m_address_write = state;
-
- update_input();
- }
-}
-
-
-//-------------------------------------------------
-// stop_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm58321_device::stop_w )
-{
- if (m_stop != state)
- {
- if (LOG) logerror("MSM58321 '%s' STOP: %u\n", tag(), state);
-
- m_stop = state;
- }
-}
-
-
-//-------------------------------------------------
-// test_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm58321_device::test_w )
-{
- if (m_test != state)
- {
- if (LOG) logerror("MSM58321 '%s' TEST: %u\n", tag(), state);
-
- m_test = state;
- }
-}
-
-
-
-//-------------------------------------------------
-// cs1_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( msm58321_device::cs1_w )
-{
- if (m_cs1 != state)
- {
- if (LOG) logerror("MSM58321 '%s' CS1: %u\n", tag(), state);
-
- m_cs1 = state;
-
- update_input();
- }
-}
diff --git a/src/emu/machine/msm58321.h b/src/emu/machine/msm58321.h
deleted file mode 100644
index 8b1ad54edd9..00000000000
--- a/src/emu/machine/msm58321.h
+++ /dev/null
@@ -1,146 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- OKI MSM58321RS Real Time Clock/Calendar emulation
-
-**********************************************************************
- _____ _____
- CS2 1 |* \_/ | 16 Vdd
- WRITE 2 | | 15 XT
- READ 3 | | 14 _XT
- D0 4 | MSM58321 | 13 CS1
- D1 5 | RTC58321 | 12 TEST
- D2 6 | | 11 STOP
- D3 7 | | 10 _BUSY
- GND 8 |_____________| 9 ADDRESS WRITE
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __MSM58321__
-#define __MSM58321__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_MSM58321_D0_HANDLER(_devcb) \
- devcb = &msm58321_device::set_d0_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MSM58321_D1_HANDLER(_devcb) \
- devcb = &msm58321_device::set_d1_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MSM58321_D2_HANDLER(_devcb) \
- devcb = &msm58321_device::set_d2_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MSM58321_D3_HANDLER(_devcb) \
- devcb = &msm58321_device::set_d3_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MSM58321_BUSY_HANDLER(_devcb) \
- devcb = &msm58321_device::set_busy_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_MSM58321_YEAR0(_year0) \
- msm58321_device::set_year0(*device, _year0);
-
-#define MCFG_MSM58321_DEFAULT_24H(_default_24h) \
- msm58321_device::set_default_24h(*device, _default_24h);
-
-// ======================> msm58321_device
-
-class msm58321_device : public device_t,
- public device_rtc_interface,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- msm58321_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_d0_handler(device_t &device, _Object object) { return downcast<msm58321_device &>(device).m_d0_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_d1_handler(device_t &device, _Object object) { return downcast<msm58321_device &>(device).m_d1_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_d2_handler(device_t &device, _Object object) { return downcast<msm58321_device &>(device).m_d2_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_d3_handler(device_t &device, _Object object) { return downcast<msm58321_device &>(device).m_d3_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_busy_handler(device_t &device, _Object object) { return downcast<msm58321_device &>(device).m_busy_handler.set_callback(object); }
- static void set_year0(device_t &device, int year0) { downcast<msm58321_device &>(device).m_year0 = year0; }
- static void set_default_24h(device_t &device, bool default_24h) { downcast<msm58321_device &>(device).m_default_24h = default_24h; }
-
- DECLARE_WRITE_LINE_MEMBER( cs2_w );
- DECLARE_WRITE_LINE_MEMBER( write_w );
- DECLARE_WRITE_LINE_MEMBER( read_w );
- DECLARE_WRITE_LINE_MEMBER( d0_w );
- DECLARE_WRITE_LINE_MEMBER( d1_w );
- DECLARE_WRITE_LINE_MEMBER( d2_w );
- DECLARE_WRITE_LINE_MEMBER( d3_w );
- DECLARE_WRITE_LINE_MEMBER( address_write_w );
- DECLARE_WRITE_LINE_MEMBER( stop_w );
- DECLARE_WRITE_LINE_MEMBER( test_w );
- DECLARE_WRITE_LINE_MEMBER( cs1_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_rtc_interface overrides
- virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
- virtual bool rtc_feature_y2k() { return m_year0 != 0; }
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
-private:
- static const device_timer_id TIMER_CLOCK = 0;
- static const device_timer_id TIMER_BUSY = 1;
-
- void update_input();
- void update_output();
-
- inline int read_counter(int counter);
- inline void write_counter(int counter, int value);
-
- int m_year0;
- bool m_default_24h;
- devcb_write_line m_d0_handler;
- devcb_write_line m_d1_handler;
- devcb_write_line m_d2_handler;
- devcb_write_line m_d3_handler;
- devcb_write_line m_busy_handler;
-
- int m_cs2; // chip select 2
- int m_write; // write data
- int m_read; // read data
- int m_d0_in; // d0
- int m_d0_out; // d0
- int m_d1_in; // d1
- int m_d1_out; // d1
- int m_d2_in; // d2
- int m_d2_out; // d2
- int m_d3_in; // d3
- int m_d3_out; // d3
- int m_address_write; // write address
- int m_busy; // busy flag
- int m_stop; // stop flag
- int m_test; // test flag
- int m_cs1; // chip select 1
-
- UINT8 m_address; // address latch
- UINT8 m_reg[13]; // registers
-
- // timers
- emu_timer *m_clock_timer;
- emu_timer *m_busy_timer;
-};
-
-
-// device type definition
-extern const device_type MSM58321;
-
-#endif
diff --git a/src/emu/machine/msm6242.c b/src/emu/machine/msm6242.c
deleted file mode 100644
index a4a188cbcb6..00000000000
--- a/src/emu/machine/msm6242.c
+++ /dev/null
@@ -1,557 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Nathan Woods
-/***************************************************************************
-
- MSM6242 / Epson RTC 62421 / 62423 Real Time Clock
-
- TODO:
- - Stop timer callbacks on every single tick
- - HOLD mechanism
- - IRQs are grossly mapped
- - STOP / RESET mechanism
- - why skns.c games try to read uninitialized registers?
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/msm6242.h"
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-enum
-{
- MSM6242_REG_S1 = 0,
- MSM6242_REG_S10,
- MSM6242_REG_MI1,
- MSM6242_REG_MI10,
- MSM6242_REG_H1,
- MSM6242_REG_H10,
- MSM6242_REG_D1,
- MSM6242_REG_D10,
- MSM6242_REG_MO1,
- MSM6242_REG_MO10,
- MSM6242_REG_Y1,
- MSM6242_REG_Y10,
- MSM6242_REG_W,
- MSM6242_REG_CD,
- MSM6242_REG_CE,
- MSM6242_REG_CF
-};
-
-#define TIMER_RTC_CALLBACK 1
-
-#define LOG_UNMAPPED 0
-#define LOG_IRQ 0
-#define LOG_IRQ_ENABLE 0
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type MSM6242 = &device_creator<msm6242_device>;
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// msm6242_device - constructor
-//-------------------------------------------------
-
-msm6242_device::msm6242_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MSM6242, "MSM6242 RTC", tag, owner, clock, "msm6242", __FILE__),
- device_rtc_interface(mconfig, *this),
- m_out_int_handler(*this)
-{
-}
-
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void msm6242_device::device_start()
-{
- m_out_int_handler.resolve();
-
- // let's call the timer callback every tick
- m_timer = timer_alloc(TIMER_RTC_CALLBACK);
- m_timer->adjust(attotime::zero);
-
- // get real time from system
- set_current_time(machine());
-
- // set up registers
- m_tick = 0;
- m_irq_flag = 0;
- m_irq_type = 0;
-
- // TODO: skns writes 0x4 to D then expects E == 6 and F == 4, perhaps those are actually saved in the RTC CMOS?
- m_reg[0] = 0;
- m_reg[1] = 0x6;
- m_reg[2] = 0x4;
-
- // save states
- save_item(NAME(m_reg));
- save_item(NAME(m_irq_flag));
- save_item(NAME(m_irq_type));
- save_item(NAME(m_tick));
- save_item(NAME(m_last_update_time));
-}
-
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void msm6242_device::device_reset()
-{
- if (!m_out_int_handler.isnull())
- m_out_int_handler(CLEAR_LINE);
-}
-
-
-
-//-------------------------------------------------
-// device_pre_save - called prior to saving the
-// state, so that registered variables can be
-// properly normalized
-//-------------------------------------------------
-
-void msm6242_device::device_pre_save()
-{
- // update the RTC registers so that we can get the right values
- update_rtc_registers();
-}
-
-
-
-//-------------------------------------------------
-// device_post_load - called after the loading a
-// saved state, so that registered variables can
-// be expaneded as necessary
-//-------------------------------------------------
-
-void msm6242_device::device_post_load()
-{
- // this is probably redundant, because the timer state is saved; but it isn't
- // a terribly bad idea
- update_timer();
-}
-
-
-
-//-------------------------------------------------
-// device_timer - called whenever a device timer
-// fires
-//-------------------------------------------------
-
-void msm6242_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch(id)
- {
- case TIMER_RTC_CALLBACK:
- rtc_timer_callback();
- break;
- }
-}
-
-
-
-//-------------------------------------------------
-// irq
-//-------------------------------------------------
-
-void msm6242_device::irq(UINT8 irq_type)
-{
- // are we actually raising this particular IRQ?
- if (m_irq_flag == 1 && m_irq_type == irq_type)
- {
- // log if appropriate
- if (LOG_IRQ)
- logerror("%s: MSM6242 logging IRQ #%d\n", machine().describe_context(), (int) irq_type);
-
- // ...and assert the output line
- if (!m_out_int_handler.isnull())
- m_out_int_handler(ASSERT_LINE);
- }
-}
-
-
-
-//-------------------------------------------------
-// bump
-//-------------------------------------------------
-
-UINT64 msm6242_device::bump(int rtc_register, UINT64 delta, UINT64 register_min, UINT64 register_range)
-{
- UINT64 carry = 0;
-
- if (delta > 0)
- {
- // get the register value
- UINT64 register_value = (rtc_register == RTC_TICKS)
- ? m_tick
- : get_clock_register(rtc_register);
-
- // increment the value
- UINT64 new_register_value = ((register_value - register_min + delta) % register_range) + register_min;
-
- // calculate the cary
- carry = ((register_value - register_min) + delta) / register_range;
-
- // store the new register value
- if (rtc_register == RTC_TICKS)
- m_tick = (UINT16) new_register_value;
- else
- set_clock_register(rtc_register, (int) new_register_value);
- }
-
- return carry;
-}
-
-
-
-//-------------------------------------------------
-// current_time
-//-------------------------------------------------
-
-UINT64 msm6242_device::current_time()
-{
- return machine().time().as_ticks(clock());
-}
-
-
-
-//-------------------------------------------------
-// update_rtc_registers
-//-------------------------------------------------
-
-void msm6242_device::update_rtc_registers()
-{
- // get the absolute current time, in ticks
- UINT64 curtime = current_time();
-
- // how long as it been since we last updated?
- UINT64 delta = curtime - m_last_update_time;
-
- // set current time
- m_last_update_time = curtime;
-
- // no delta? just return
- if (delta == 0)
- return;
-
- // ticks
- if ((m_tick % 200) != (int)((delta + m_tick) % 0x200))
- irq(IRQ_64THSECOND);
- delta = bump(RTC_TICKS, delta, 0, 0x8000);
- if (delta == 0)
- return;
-
- // seconds
- irq(IRQ_SECOND);
- delta = bump(RTC_SECOND, delta, 0, 60);
- if (delta == 0)
- return;
-
- // minutes
- irq(IRQ_MINUTE);
- delta = bump(RTC_MINUTE, delta, 0, 60);
- if (delta == 0)
- return;
-
- // hours
- irq(IRQ_HOUR);
- delta = bump(RTC_HOUR, delta, 0, 24);
- if (delta == 0)
- return;
-
- // days
- while(delta--)
- advance_days();
-}
-
-
-
-//-------------------------------------------------
-// update_timer
-//-------------------------------------------------
-
-void msm6242_device::update_timer()
-{
- UINT64 callback_ticks = 0;
- attotime callback_time = attotime::never;
-
- // we only need to call back if the IRQ flag is on, and we have a handler
- if (!m_out_int_handler.isnull() && m_irq_flag == 1)
- {
- switch(m_irq_type)
- {
- case IRQ_HOUR:
- callback_ticks += (59 - get_clock_register(RTC_MINUTE)) * (0x8000 * 60);
- // fall through
-
- case IRQ_MINUTE:
- callback_ticks += (59 - get_clock_register(RTC_SECOND)) * 0x8000;
- // fall through
-
- case IRQ_SECOND:
- callback_ticks += 0x8000 - m_tick;
- break;
-
- case IRQ_64THSECOND:
- callback_ticks += 0x200 - (m_tick % 0x200);
- break;
- }
- }
-
- // if set, convert ticks to an attotime
- if (callback_ticks > 0)
- {
- // get the current time
- UINT64 curtime = current_time();
-
- // we need the absolute callback time, in ticks
- UINT64 absolute_callback_ticks = curtime + callback_ticks;
-
- // convert that to an attotime
- attotime absolute_callback_time = attotime::from_ticks(absolute_callback_ticks, clock());
-
- // and finally get the delta as an attotime
- callback_time = absolute_callback_time - machine().time();
- }
-
- m_timer->adjust(callback_time);
-}
-
-
-
-//-------------------------------------------------
-// rtc_clock_updated
-//-------------------------------------------------
-
-void msm6242_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
- m_last_update_time = current_time();
-}
-
-
-
-//-------------------------------------------------
-// rtc_timer_callback
-//-------------------------------------------------
-
-void msm6242_device::rtc_timer_callback()
-{
- update_rtc_registers();
- update_timer();
-}
-
-
-
-//-------------------------------------------------
-// get_clock_nibble
-//-------------------------------------------------
-
-UINT8 msm6242_device::get_clock_nibble(int rtc_register, bool high)
-{
- int value = get_clock_register(rtc_register);
- value /= high ? 10 : 1;
- return (UINT8) ((value % 10) & 0x0F);
-}
-
-
-
-//-------------------------------------------------
-// get_clock_nibble
-//-------------------------------------------------
-
-const char *msm6242_device::irq_type_string(UINT8 irq_type)
-{
- switch(irq_type)
- {
- case IRQ_64THSECOND: return "1/64th second";
- case IRQ_SECOND: return "second";
- case IRQ_MINUTE: return "minute";
- case IRQ_HOUR: return "hour";
- default: return "???";
- }
-}
-
-
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-//-------------------------------------------------
-// read
-//-------------------------------------------------
-
-READ8_MEMBER( msm6242_device::read )
-{
- int hour, pm;
- UINT8 result;
-
- // update the registers; they may have changed
- update_rtc_registers();
-
- switch(offset)
- {
- case MSM6242_REG_S1:
- result = get_clock_nibble(RTC_SECOND, false);
- break;
-
- case MSM6242_REG_S10:
- result = get_clock_nibble(RTC_SECOND, true);
- break;
-
- case MSM6242_REG_MI1:
- result = get_clock_nibble(RTC_MINUTE, false);
- break;
-
- case MSM6242_REG_MI10:
- result = get_clock_nibble(RTC_MINUTE, true);
- break;
-
- case MSM6242_REG_H1:
- case MSM6242_REG_H10:
- pm = 0;
- hour = get_clock_register(RTC_HOUR);
-
- // check for 12/24 hour mode
- if ((m_reg[2] & 0x04) == 0) // 12 hour mode?
- {
- if (hour >= 12)
- pm = 1;
-
- hour %= 12;
-
- if ( hour == 0 )
- hour = 12;
- }
-
- if ( offset == MSM6242_REG_H1 )
- result = hour % 10;
- else
- result = (hour / 10) | (pm <<2);
- break;
-
- case MSM6242_REG_D1:
- result = get_clock_nibble(RTC_DAY, false);
- break;
-
- case MSM6242_REG_D10:
- result = get_clock_nibble(RTC_DAY, true);
- break;
-
- case MSM6242_REG_MO1:
- result = get_clock_nibble(RTC_MONTH, false);
- break;
-
- case MSM6242_REG_MO10:
- result = get_clock_nibble(RTC_MONTH, true);
- break;
-
- case MSM6242_REG_Y1:
- result = get_clock_nibble(RTC_YEAR, false);
- break;
-
- case MSM6242_REG_Y10:
- result = get_clock_nibble(RTC_YEAR, true);
- break;
-
- case MSM6242_REG_W:
- result = (UINT8) (get_clock_register(RTC_DAY_OF_WEEK) - 1);
- break;
-
- case MSM6242_REG_CD:
- case MSM6242_REG_CE:
- case MSM6242_REG_CF:
- result = m_reg[offset - MSM6242_REG_CD];
- break;
-
- default:
- result = 0x00;
- if (LOG_UNMAPPED)
- logerror("%s: MSM6242 unmapped offset %02x read\n", machine().describe_context(), offset);
- break;
- }
-
- return result;
-}
-
-
-
-//-------------------------------------------------
-// write
-//-------------------------------------------------
-
-WRITE8_MEMBER( msm6242_device::write )
-{
- switch(offset)
- {
- case MSM6242_REG_CD:
- // x--- 30s ADJ
- // -x-- IRQ FLAG
- // --x- BUSY
- // ---x HOLD
- m_reg[0] = data & 0x0f;
- break;
-
- case MSM6242_REG_CE:
- // xx-- t0,t1 (timing irq)
- // --x- STD
- // ---x MASK
- m_reg[1] = data & 0x0f;
- if((data & 3) == 0) // MASK & STD = 0
- {
- m_irq_flag = 1;
- m_irq_type = (data & 0xc) >> 2;
-
- if (LOG_IRQ_ENABLE)
- logerror("%s: MSM6242 enabling irq '%s'\n", machine().describe_context(), irq_type_string(m_irq_type));
- }
- else
- {
- m_irq_flag = 0;
- if ( !m_out_int_handler.isnull() )
- m_out_int_handler( CLEAR_LINE );
-
- if (LOG_IRQ_ENABLE)
- logerror("%s: MSM6242 disabling irq\n", machine().describe_context());
- }
- break;
-
- case MSM6242_REG_CF:
- // x--- TEST
- // -x-- 24/12
- // --x- STOP
- // ---x RESET
-
- // the 12/24 mode bit can only be changed when RESET does a 1 -> 0 transition
- if (((data & 0x01) == 0x00) && (m_reg[2] & 0x01))
- m_reg[2] = (m_reg[2] & ~0x04) | (data & 0x04);
- else
- m_reg[2] = (data & 0x0b) | (m_reg[2] & 4);
- break;
-
- default:
- if (LOG_UNMAPPED)
- logerror("%s: MSM6242 unmapped offset %02x written with %02x\n", machine().describe_context(), offset, data);
- break;
- }
-
- // update the timer variable in response to potential changes
- update_timer();
-}
diff --git a/src/emu/machine/msm6242.h b/src/emu/machine/msm6242.h
deleted file mode 100644
index 4d44fd1b860..00000000000
--- a/src/emu/machine/msm6242.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Nathan Woods
-/***************************************************************************
-
- MSM6242 Real Time Clock
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __MSM6242DEV_H__
-#define __MSM6242DEV_H__
-
-#include "emu.h"
-
-
-#define MCFG_MSM6242_OUT_INT_HANDLER(_devcb) \
- devcb = &msm6242_device::set_out_int_handler(*device, DEVCB_##_devcb);
-
-
-// ======================> msm6242_device
-
-class msm6242_device : public device_t,
- public device_rtc_interface
-{
-public:
- // construction/destruction
- msm6242_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-
- template<class _Object> static devcb_base &set_out_int_handler(device_t &device, _Object object) { return downcast<msm6242_device &>(device).m_out_int_handler.set_callback(object); }
-
- // I/O operations
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_READ8_MEMBER( read );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_pre_save();
- virtual void device_post_load();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // rtc overrides
- virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
-
-private:
- static const int RTC_TICKS = ~0;
-
- static const UINT8 IRQ_64THSECOND = 0;
- static const UINT8 IRQ_SECOND = 1;
- static const UINT8 IRQ_MINUTE = 2;
- static const UINT8 IRQ_HOUR = 3;
-
- // state
- UINT8 m_reg[3];
- UINT8 m_irq_flag;
- UINT8 m_irq_type;
- UINT16 m_tick;
-
- // incidentals
- devcb_write_line m_out_int_handler;
- emu_timer * m_timer;
- UINT64 m_last_update_time; // last update time, in clock cycles
-
- // methods
- void rtc_timer_callback();
- UINT64 current_time();
- void irq(UINT8 irq_type);
- UINT64 bump(int rtc_register, UINT64 delta, UINT64 register_min, UINT64 register_range);
- void update_rtc_registers();
- void update_timer();
- UINT8 get_clock_nibble(int rtc_register, bool high);
- static const char *irq_type_string(UINT8 irq_type);
-};
-
-
-// device type definition
-extern const device_type MSM6242;
-
-
-#endif /* __MSM6242DEV_H__ */
diff --git a/src/emu/machine/ncr5380.c b/src/emu/machine/ncr5380.c
deleted file mode 100644
index 175e9130c1c..00000000000
--- a/src/emu/machine/ncr5380.c
+++ /dev/null
@@ -1,424 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*
- * ncr5380.c
- *
- * NCR 5380 SCSI controller, as seen in many 680x0 Macs,
- * official Apple add-on cards for the Apple II series,
- * and probably some PC and Amiga cards as well.
- *
- * Emulation by R. Belmont.
- *
- * References:
- * Zilog 5380 manual
- * "Inside Macintosh: Devices" (formerly online at http://www.manolium.org/dev/techsupport/insidemac/Devices/Devices-2.html )
- *
- * NOTES:
- * This implementation is tied closely to the drivers found in the Mac Plus ROM and the routines in Mac
- * System 6 and 7 that it patches out the ROM traps with. While attempts have been made to
- * have the behavior work according to the manual and not the specific Apple driver code,
- * there are almost certainly areas where that is true.
- *
- */
-
-#include "emu.h"
-#include "ncr5380.h"
-
-#define VERBOSE (0)
-
-static const char *const rnames[] =
-{
- "Current data",
- "Initiator cmd",
- "Mode",
- "Target cmd",
- "Bus status",
- "Bus and status",
- "Input data",
- "Reset parity"
-};
-
-static const char *const wnames[] =
-{
- "Output data",
- "Initiator cmd",
- "Mode",
- "Target cmd",
- "Select enable",
- "Start DMA",
- "DMA target",
- "DMA initiator rec"
-};
-
-// get the length of a SCSI command based on it's command byte type
-static int get_cmd_len(int cbyte)
-{
- int group;
-
- group = (cbyte>>5) & 7;
-
- if (group == 0) return 6;
- if (group == 1 || group == 2) return 10;
- if (group == 5) return 12;
-
- fatalerror("NCR5380: Unknown SCSI command group %d\n", group);
-
- // never executed
- //return 6;
-}
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-const device_type NCR5380 = &device_creator<ncr5380_device>;
-
-//-------------------------------------------------
-// ncr5380_device - constructor/destructor
-//-------------------------------------------------
-
-ncr5380_device::ncr5380_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- legacy_scsi_host_adapter(mconfig, NCR5380, "5380 SCSI", tag, owner, clock, "ncr5380", __FILE__),
- m_irq_cb(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ncr5380_device::device_start()
-{
- legacy_scsi_host_adapter::device_start();
-
- memset(m_5380_Registers, 0, sizeof(m_5380_Registers));
- memset(m_5380_Data, 0, sizeof(m_5380_Data));
-
- m_next_req_flag = 0;
- m_irq_cb.resolve_safe();
-
- save_item(NAME(m_5380_Registers));
- save_item(NAME(m_5380_Command));
- save_item(NAME(m_5380_Data));
- save_item(NAME(m_last_id));
- save_item(NAME(m_cmd_ptr));
- save_item(NAME(m_d_ptr));
- save_item(NAME(m_d_limit));
- save_item(NAME(m_next_req_flag));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ncr5380_device::device_reset()
-{
- memset(m_5380_Registers, 0, sizeof(m_5380_Registers));
- memset(m_5380_Data, 0, sizeof(m_5380_Data));
-
- m_next_req_flag = 0;
- m_cmd_ptr = 0;
- m_d_ptr = 0;
- m_d_limit = 0;
- m_last_id = 0;
-}
-
-//-------------------------------------------------
-// device_stop - device-specific stop/shutdown
-//-------------------------------------------------
-void ncr5380_device::device_stop()
-{
-}
-
-//-------------------------------------------------
-// Public API
-//-------------------------------------------------
-UINT8 ncr5380_device::ncr5380_read_reg(UINT32 offset)
-{
- int reg = offset & 7;
- UINT8 rv = 0;
-
- switch( reg )
- {
- case R5380_CURDATA:
- case R5380_INPUTDATA:
- rv = m_5380_Registers[reg];
-
- // if we're in the data transfer phase or DMA, readback device data instead
- if (((m_5380_Registers[R5380_BUSSTATUS] & 0x1c) == 0x04) || (m_5380_Registers[R5380_BUSSTATUS] & 0x40))
- {
- rv = m_5380_Data[m_d_ptr];
-
- // if the limit's less than 512, only read "limit" bytes
- if (m_d_limit < 512)
- {
- if (m_d_ptr < (m_d_limit-1))
- {
- m_d_ptr++;
- }
- else
- {
- m_next_req_flag = 1;
- }
- }
- else
- {
- if (m_d_ptr < 511)
- {
- m_d_ptr++;
- }
- else
- {
- m_d_limit -= 512;
- m_d_ptr = 0;
-
- m_next_req_flag = 1;
-
- // don't issue a "false" read
- if (m_d_limit > 0)
- {
- read_data(m_5380_Data, (m_d_limit < 512) ? m_d_limit : 512);
- }
- else
- {
- // if this is DMA, signal DMA end
- if (m_5380_Registers[R5380_BUSSTATUS] & 0x40)
- {
- m_5380_Registers[R5380_BUSSTATUS] |= 0x80;
- }
-
- // drop /REQ
- m_5380_Registers[R5380_BUSSTATUS] &= ~0x20;
-
- // clear phase match
- m_5380_Registers[R5380_BUSANDSTAT] &= ~0x08;
- }
- }
- }
-
- }
- break;
-
- default:
- rv = m_5380_Registers[reg];
-
- // temporarily drop /REQ
- if ((reg == R5380_BUSSTATUS) && (m_next_req_flag))
- {
- rv &= ~0x20;
- m_next_req_flag = 0;
- }
- break;
- }
-
- if (VERBOSE)
- logerror("%s NCR5380: read %s (reg %d) = %02x\n", machine().describe_context(), rnames[reg], reg, rv);
-
- return rv;
-}
-
-void ncr5380_device::ncr5380_write_reg(UINT32 offset, UINT8 data)
-{
- int reg = offset & 7;
-
- if (VERBOSE)
- logerror("%s NCR5380: %02x to %s (reg %d)\n", machine().describe_context(), data, wnames[reg], reg);
-
- switch( reg )
- {
- case R5380_OUTDATA:
- // if we're in the command phase, collect the command bytes
- if ((m_5380_Registers[R5380_BUSSTATUS] & 0x1c) == 0x08)
- {
- m_5380_Command[m_cmd_ptr++] = data;
- }
-
- // if we're in the select phase, this is the target id
- if (m_5380_Registers[R5380_INICOMMAND] == 0x04)
- {
- data &= 0x7f; // clear the high bit
- if (data == 0x40)
- {
- m_last_id = 6;
- }
- else if (data == 0x20)
- {
- m_last_id = 5;
- }
- else if (data == 0x10)
- {
- m_last_id = 4;
- }
- else if (data == 0x08)
- {
- m_last_id = 3;
- }
- else if (data == 0x04)
- {
- m_last_id = 2;
- }
- else if (data == 0x02)
- {
- m_last_id = 1;
- }
- else if (data == 0x01)
- {
- m_last_id = 0;
- }
- }
-
- // if this is a write, accumulate accordingly
- if (((m_5380_Registers[R5380_BUSSTATUS] & 0x1c) == 0x00) && (m_5380_Registers[R5380_INICOMMAND] == 1))
- {
- m_5380_Data[m_d_ptr] = data;
-
- // if we've hit a sector, flush
- if (m_d_ptr == 511)
- {
- write_data(&m_5380_Data[0], 512);
-
- m_d_limit -= 512;
- m_d_ptr = 0;
-
- // no more data? set DMA END flag
- if (m_d_limit <= 0)
- {
- m_5380_Registers[R5380_BUSANDSTAT] = 0xc8;
- }
- }
- else
- {
- m_d_ptr++;
- }
-
- // make sure we don't upset the status readback
- data = 0;
- }
- break;
-
- case R5380_INICOMMAND:
- if (data == 0) // dropping the bus
- {
- // make sure it's not busy
- m_5380_Registers[R5380_BUSSTATUS] &= ~0x40;
-
- // are we in the command phase?
- if ((m_5380_Registers[R5380_BUSSTATUS] & 0x1c) == 0x08)
- {
- // is the current command complete?
- if (get_cmd_len(m_5380_Command[0]) == m_cmd_ptr)
- {
- if (VERBOSE)
- logerror("%s NCR5380: Command (to ID %d): %x %x %x %x %x %x %x %x %x %x\n", machine().describe_context(), m_last_id, m_5380_Command[0], m_5380_Command[1], m_5380_Command[2], m_5380_Command[3], m_5380_Command[4], m_5380_Command[5], m_5380_Command[6], m_5380_Command[7], m_5380_Command[8], m_5380_Command[9]);
-
- send_command(&m_5380_Command[0], 16);
- m_d_limit = get_length();
-
- if (VERBOSE)
- logerror("NCR5380: Command returned %d bytes\n", m_d_limit);
-
- m_d_ptr = 0;
-
- // is data available?
- if (m_d_limit > 0)
- {
- // make sure for transfers under 512 bytes that we always pad with a zero
- if (m_d_limit < 512)
- {
- m_5380_Data[m_d_limit] = 0;
- }
-
- // read back the amount available, or 512 bytes, whichever is smaller
- read_data(m_5380_Data, (m_d_limit < 512) ? m_d_limit : 512);
-
- // raise REQ to indicate data is available
- m_5380_Registers[R5380_BUSSTATUS] |= 0x20;
- }
- }
- }
-
- }
-
- if (data == 5) // want the bus?
- {
- // if the device exists, make the bus busy.
- // otherwise don't.
-
- if (select(m_last_id))
- {
- if (VERBOSE)
- logerror("NCR5380: Giving the bus for ID %d\n", m_last_id);
- m_5380_Registers[R5380_BUSSTATUS] |= 0x40;
- }
- else
- {
- if (VERBOSE)
- logerror("NCR5380: Rejecting the bus for ID %d\n", m_last_id);
- m_5380_Registers[R5380_BUSSTATUS] &= ~0x40;
- }
- }
-
- if (data == 1) // data bus (prelude to command?)
- {
- // raise REQ
- m_5380_Registers[R5380_BUSSTATUS] |= 0x20;
- }
-
- if (data & 0x10) // ACK drops REQ
- {
- // drop REQ
- m_5380_Registers[R5380_BUSSTATUS] &= ~0x20;
- }
- break;
-
- case R5380_MODE:
- if (data == 2) // DMA
- {
- // put us in DMA mode
- m_5380_Registers[R5380_BUSANDSTAT] |= 0x40;
- }
-
- if (data == 1) // arbitrate?
- {
- m_5380_Registers[R5380_INICOMMAND] |= 0x40; // set arbitration in progress
- m_5380_Registers[R5380_INICOMMAND] &= ~0x20; // clear "lost arbitration"
- }
-
- if (data == 0)
- {
- // drop DMA mode
- m_5380_Registers[R5380_BUSANDSTAT] &= ~0x40;
- }
- break;
-
- case R5380_TARGETCMD:
- // sync the bus phase with what was just written
- m_5380_Registers[R5380_BUSSTATUS] &= ~0x1c;
- m_5380_Registers[R5380_BUSSTATUS] |= (data & 7)<<2;
-
- // and set the "phase match" flag
- m_5380_Registers[R5380_BUSANDSTAT] |= 0x08;
-
- // and set /REQ
- m_5380_Registers[R5380_BUSSTATUS] |= 0x20;
-
- // if we're entering the command phase, start accumulating the data
- if ((m_5380_Registers[R5380_BUSSTATUS] & 0x1c) == 0x08)
- {
- m_cmd_ptr = 0;
- }
- break;
-
- default:
- break;
- }
-
- m_5380_Registers[reg] = data;
-
- // note: busandstat overlaps startdma, so we need to do this here!
- if (reg == R5380_STARTDMA)
- {
- m_5380_Registers[R5380_BUSANDSTAT] = 0x48;
- }
-}
diff --git a/src/emu/machine/ncr5380.h b/src/emu/machine/ncr5380.h
deleted file mode 100644
index 678460f6133..00000000000
--- a/src/emu/machine/ncr5380.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*
- * ncr5380.h SCSI controller
- *
- */
-
-#ifndef _NCR5380_H_
-#define _NCR5380_H_
-
-#include "legscsi.h"
-
-// 5380 registers
-enum
-{
- R5380_CURDATA = 0, // current SCSI data (read only)
- R5380_OUTDATA = 0, // output data (write only)
- R5380_INICOMMAND, // initiator command
- R5380_MODE, // mode
- R5380_TARGETCMD, // target command
- R5380_SELENABLE, // select enable (write only)
- R5380_BUSSTATUS = R5380_SELENABLE, // bus status (read only)
- R5380_STARTDMA, // start DMA send (write only)
- R5380_BUSANDSTAT = R5380_STARTDMA, // bus and status (read only)
- R5380_DMATARGET, // DMA target (write only)
- R5380_INPUTDATA = R5380_DMATARGET, // input data (read only)
- R5380_DMAINIRECV, // DMA initiator receive (write only)
- R5380_RESETPARITY = R5380_DMAINIRECV // reset parity/interrupt (read only)
-};
-
-// special Mac Plus registers - they implemented it weird
-#define R5380_OUTDATA_DTACK (R5380_OUTDATA | 0x10)
-#define R5380_CURDATA_DTACK (R5380_CURDATA | 0x10)
-
-// device stuff
-
-#define MCFG_NCR5380_IRQ_CB(_devcb) \
- devcb = &ncr5380_device::set_irq_callback(*device, DEVCB_##_devcb);
-
-class ncr5380_device : public legacy_scsi_host_adapter
-{
-public:
- // construction/destruction
- ncr5380_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<ncr5380_device &>(device).m_irq_cb.set_callback(object); }
-
- // our API
- UINT8 ncr5380_read_reg(UINT32 offset);
- void ncr5380_write_reg(UINT32 offset, UINT8 data);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_stop();
-
-private:
- UINT8 m_5380_Registers[8];
- UINT8 m_last_id;
- UINT8 m_5380_Command[32];
- INT32 m_cmd_ptr, m_d_ptr, m_d_limit, m_next_req_flag;
- UINT8 m_5380_Data[512];
- devcb_write_line m_irq_cb; /* irq callback */
-};
-
-// device type definition
-extern const device_type NCR5380;
-
-#endif
diff --git a/src/emu/machine/ncr5380n.c b/src/emu/machine/ncr5380n.c
deleted file mode 100644
index ed2270ba097..00000000000
--- a/src/emu/machine/ncr5380n.c
+++ /dev/null
@@ -1,586 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont, Olivier Galibert
-/*********************************************************************
-
- ncr5380n.c
-
- Implementation of the NCR 5380, aka the Zilog Z5380
-
- TODO:
- - IRQs
- - Target mode
-
- 40801766 - IIx ROM waiting point for "next read fails"
-
-*********************************************************************/
-
-#include "emu.h"
-#include "ncr5380n.h"
-
-const device_type NCR5380N = &device_creator<ncr5380n_device>;
-
-DEVICE_ADDRESS_MAP_START(map, 8, ncr5380n_device)
- AM_RANGE(0x0, 0x0) AM_READWRITE(scsidata_r, outdata_w)
- AM_RANGE(0x1, 0x1) AM_READWRITE(icmd_r, icmd_w)
- AM_RANGE(0x2, 0x2) AM_READWRITE(mode_r, mode_w)
- AM_RANGE(0x3, 0x3) AM_READWRITE(command_r, command_w)
- AM_RANGE(0x4, 0x4) AM_READWRITE(status_r, selenable_w)
- AM_RANGE(0x5, 0x5) AM_READWRITE(busandstatus_r, startdmasend_w)
- AM_RANGE(0x6, 0x6) AM_READWRITE(indata_r, startdmatargetrx_w)
- AM_RANGE(0x7, 0x7) AM_READWRITE(resetparityirq_r, startdmainitrx_w)
-ADDRESS_MAP_END
-
-ncr5380n_device::ncr5380n_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : nscsi_device(mconfig, NCR5380N, "5380 SCSI (new)", tag, owner, clock, "ncr5380", __FILE__),
- m_irq_handler(*this),
- m_drq_handler(*this)
-{
-}
-
-void ncr5380n_device::device_start()
-{
- save_item(NAME(m_tcommand));
- save_item(NAME(m_icommand));
- save_item(NAME(status));
- save_item(NAME(istatus));
- save_item(NAME(m_busstatus));
- save_item(NAME(tcount));
- save_item(NAME(mode));
- save_item(NAME(irq));
- save_item(NAME(drq));
- save_item(NAME(clock_conv));
- save_item(NAME(m_dmalatch));
-
- m_irq_handler.resolve_safe();
- m_drq_handler.resolve_safe();
-
- tcount = 0;
- status = 0;
- bus_id = 0;
- select_timeout = 0;
- tm = timer_alloc(0);
-}
-
-void ncr5380n_device::device_reset()
-{
- clock_conv = 2;
- sync_period = 5;
- sync_offset = 0;
- seq = 0;
- status = 0;
- m_tcommand = 0;
- m_icommand = 0;
- istatus = 0;
- m_busstatus = 0;
- irq = false;
- m_irq_handler(irq);
- reset_soft();
-}
-
-void ncr5380n_device::reset_soft()
-{
- state = IDLE;
- scsi_bus->ctrl_w(scsi_refid, 0, S_ALL); // clear any signals we're driving
- scsi_bus->ctrl_wait(scsi_refid, S_ALL, S_ALL);
- status = 0;
- drq = false;
- m_drq_handler(drq);
- reset_disconnect();
-}
-
-void ncr5380n_device::reset_disconnect()
-{
- mode = MODE_D;
-}
-
-//static int last_phase = -1;
-
-void ncr5380n_device::scsi_ctrl_changed()
-{
- UINT32 ctrl = scsi_bus->ctrl_r();
-
-// printf("scsi_ctrl_changed: lines now %x\n", ctrl);
-
-/* if ((ctrl & (S_PHASE_MASK|S_SEL|S_BSY)) != last_phase)
- {
- printf("phase now %d, REQ %x SEL %x BSY %x\n", ctrl & S_PHASE_MASK, ctrl & S_REQ, ctrl & S_SEL, ctrl & S_BSY);
- last_phase = (S_PHASE_MASK|S_SEL|S_BSY);
- }*/
-
- // recalculate phase match
- m_busstatus &= ~BAS_PHASEMATCH;
- if ((ctrl & S_PHASE_MASK) == (m_tcommand & S_PHASE_MASK))
- {
- m_busstatus |= BAS_PHASEMATCH;
- }
-
- if (m_mode & MODE_DMA)
- {
- // if BSY drops or the phase goes mismatch, that terminates the DMA
- if ((!(ctrl & S_BSY)) || !(m_busstatus & BAS_PHASEMATCH))
- {
-// printf("BSY dropped or phase mismatch during DMA, ending DMA\n");
- m_mode &= ~MODE_DMA;
- m_busstatus |= BAS_ENDOFDMA;
- drq_clear();
- }
- }
-
- if(ctrl & S_RST) {
- logerror("%s: scsi bus reset\n", tag());
- return;
- }
-
- step(false);
-}
-
-void ncr5380n_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- step(true);
-}
-
-void ncr5380n_device::step(bool timeout)
-{
- UINT32 ctrl = scsi_bus->ctrl_r();
- UINT32 data = scsi_bus->data_r();
-
- if(0)
- printf("%s: state=%d.%d %s\n",
- tag(), state & STATE_MASK, (state & SUB_MASK) >> SUB_SHIFT,
- timeout ? "timeout" : "change");
-
- if(mode == MODE_I && !(ctrl & S_BSY)) {
- state = IDLE;
- reset_disconnect();
- check_irq();
- }
- switch(state & SUB_MASK ? state & SUB_MASK : state & STATE_MASK) {
- case IDLE:
- break;
-
- case ARB_COMPLETE << SUB_SHIFT: {
- if(!timeout)
- break;
-
- int win;
- for(win=7; win>=0 && !(data & (1<<win)); win--);
-// printf("arb complete: data %02x win %02x scsi_id %02x\n", data, win, scsi_id);
- if(win != scsi_id) {
- scsi_bus->data_w(scsi_refid, 0);
- scsi_bus->ctrl_w(scsi_refid, 0, S_ALL);
- fatalerror("need to wait for bus free\n");
- }
-
- state &= STATE_MASK;
- step(true);
- break;
- }
-
- case SEND_WAIT_SETTLE << SUB_SHIFT:
- if(!timeout)
- break;
-
- state = (state & STATE_MASK) | (SEND_WAIT_REQ_0 << SUB_SHIFT);
- step(false);
- break;
-
- case SEND_WAIT_REQ_0 << SUB_SHIFT:
- if(ctrl & S_REQ)
- break;
- state = state & STATE_MASK;
- scsi_bus->data_w(scsi_refid, 0);
- scsi_bus->ctrl_w(scsi_refid, 0, S_ACK);
- step(false);
-
- // byte's done, ask for another if the target hasn't said otherwise
- if (m_mode & MODE_DMA)
- {
- drq_set();
- }
- break;
-
- case RECV_WAIT_REQ_1 << SUB_SHIFT:
- if(!(ctrl & S_REQ))
- break;
-
- state = (state & STATE_MASK) | (RECV_WAIT_SETTLE << SUB_SHIFT);
- delay_cycles(sync_period);
- break;
-
- case RECV_WAIT_SETTLE << SUB_SHIFT:
- if(!timeout)
- break;
-
- m_dmalatch = scsi_bus->data_r();
- scsi_bus->ctrl_w(scsi_refid, S_ACK, S_ACK);
- state = (state & STATE_MASK) | (RECV_WAIT_REQ_0 << SUB_SHIFT);
- step(false);
- break;
-
- case RECV_WAIT_REQ_0 << SUB_SHIFT:
- if(ctrl & S_REQ)
- break;
- state = state & STATE_MASK;
- step(false);
-
- drq_set(); // raise DRQ now that we've completed
- break;
-
- default:
- printf("%s: step() unexpected state %d.%d\n",
- tag(),
- state & STATE_MASK, (state & SUB_MASK) >> SUB_SHIFT);
- exit(0);
- }
-}
-
-void ncr5380n_device::send_byte()
-{
- state = (state & STATE_MASK) | (SEND_WAIT_SETTLE << SUB_SHIFT);
- scsi_bus->data_w(scsi_refid, m_dmalatch);
-
- scsi_bus->ctrl_w(scsi_refid, S_ACK, S_ACK);
- scsi_bus->ctrl_wait(scsi_refid, S_REQ, S_REQ);
- delay_cycles(sync_period);
-}
-
-void ncr5380n_device::recv_byte()
-{
- state = (state & STATE_MASK) | (RECV_WAIT_REQ_1 << SUB_SHIFT);
- step(false);
-}
-
-void ncr5380n_device::function_bus_complete()
-{
- state = IDLE;
-// istatus |= I_FUNCTION|I_BUS;
- check_irq();
-}
-
-void ncr5380n_device::function_complete()
-{
- state = IDLE;
-// istatus |= I_FUNCTION;
- check_irq();
-}
-
-void ncr5380n_device::bus_complete()
-{
- state = IDLE;
-// istatus |= I_BUS;
- check_irq();
-}
-
-void ncr5380n_device::delay(int cycles)
-{
- if(!clock_conv)
- return;
- cycles *= clock_conv;
- tm->adjust(clocks_to_attotime(cycles));
-}
-
-void ncr5380n_device::delay_cycles(int cycles)
-{
- tm->adjust(clocks_to_attotime(cycles));
-}
-
-READ8_MEMBER(ncr5380n_device::scsidata_r)
-{
- return scsi_bus->data_r();
-}
-
-WRITE8_MEMBER(ncr5380n_device::outdata_w)
-{
- m_outdata = data;
-
- // are we driving the data bus?
- if (m_icommand & IC_DBUS)
- {
- scsi_bus->data_w(scsi_refid, data);
- }
-}
-
-READ8_MEMBER(ncr5380n_device::icmd_r)
-{
- return m_icommand;
-}
-
-WRITE8_MEMBER(ncr5380n_device::icmd_w)
-{
- // asserting to drive the data bus?
- if ((data & IC_DBUS) && !(m_icommand & IC_DBUS))
- {
-// printf("%s: driving data bus with %02x\n", tag(), m_outdata);
- scsi_bus->data_w(scsi_refid, m_outdata);
- delay(2);
- }
-
- // any control lines changing?
- UINT8 mask = (data & IC_PHASEMASK) ^ (m_icommand & IC_PHASEMASK);
- if (mask)
- {
- // translate data to nscsi
- UINT8 newdata = 0;
-
- newdata = (data & IC_RST ? S_RST : 0) |
- (data & IC_ACK ? S_ACK : 0) |
- (data & IC_BSY ? S_BSY : 0) |
- (data & IC_SEL ? S_SEL : 0) |
- (data & IC_ATN ? S_ATN : 0);
-
-// printf("%s: changing control lines %04x\n", tag(), newdata);
- scsi_bus->ctrl_w(scsi_refid, newdata, S_RST|S_ACK|S_BSY|S_SEL|S_ATN);
- }
-
- m_icommand = (data & IC_WRITEMASK);
- delay(2);
-}
-
-READ8_MEMBER(ncr5380n_device::mode_r)
-{
- return m_mode;
-}
-
-WRITE8_MEMBER(ncr5380n_device::mode_w)
-{
-// printf("%s: mode_w %02x (%08x)\n", tag(), data, space.device().safe_pc());
- // arbitration bit being set?
- if ((data & MODE_ARBITRATE) && !(m_mode & MODE_ARBITRATE))
- {
- // if SEL is selected and the assert SEL bit in the initiator
- // command register is clear, fail
- if ((scsi_bus->ctrl_r() & S_SEL) && !(m_icommand & IC_SEL))
- {
- m_icommand |= IC_ARBLOST;
- }
- else
- {
- seq = 0;
-// state = DISC_SEL_ARBITRATION;
- arbitrate();
- }
- }
- else if (!(data & MODE_ARBITRATE) && (m_mode & MODE_ARBITRATE))
- {
- // arbitration in progress bit ONLY clears when the host disables arbitration. (thanks, Zilog Z8530 manual!)
- // the Apple II High Speed SCSI Card boot code explicitly requires this.
- m_icommand &= ~ IC_ARBITRATION;
- }
- m_mode = data;
-}
-
-READ8_MEMBER(ncr5380n_device::command_r)
-{
-// logerror("%s: command_r %02x (%08x)\n", tag(), m_tcommand, space.device().safe_pc());
- return m_tcommand;
-}
-
-WRITE8_MEMBER(ncr5380n_device::command_w)
-{
-// printf("%s: command_w %02x (%08x)\n", tag(), data, space.device().safe_pc());
- m_tcommand = data;
-
- // recalculate phase match
- m_busstatus &= ~BAS_PHASEMATCH;
- if ((scsi_bus->ctrl_r() & S_PHASE_MASK) == (m_tcommand & S_PHASE_MASK))
- {
- m_busstatus |= BAS_PHASEMATCH;
- }
-}
-
-void ncr5380n_device::arbitrate()
-{
- m_icommand &= ~IC_ARBLOST;
- m_icommand |= IC_ARBITRATION; // set in progress flag
- state = (state & STATE_MASK) | (ARB_COMPLETE << SUB_SHIFT);
- scsi_bus->data_w(scsi_refid, m_outdata);
- scsi_bus->ctrl_w(scsi_refid, S_BSY, S_BSY);
- m_icommand |= IC_BSY; // make sure BSY shows in icommand (Zilog 5380 manual suggests this behavior, Apple II High-Speed SCSI Card firmware requires it)
- delay(11);
-}
-
-void ncr5380n_device::check_irq()
-{
- #if 0
- bool oldirq = irq;
- irq = istatus != 0;
- if(irq != oldirq)
- m_irq_handler(irq);
- #endif
-}
-
-READ8_MEMBER(ncr5380n_device::status_r)
-{
- UINT32 ctrl = scsi_bus->ctrl_r();
- UINT8 res = status |
- (ctrl & S_RST ? ST_RST : 0) |
- (ctrl & S_BSY ? ST_BSY : 0) |
- (ctrl & S_REQ ? ST_REQ : 0) |
- (ctrl & S_MSG ? ST_MSG : 0) |
- (ctrl & S_CTL ? ST_CD : 0) |
- (ctrl & S_INP ? ST_IO : 0) |
- (ctrl & S_SEL ? ST_SEL : 0);
-
-// printf("%s: status_r %02x (%08x)\n", tag(), res, space.device().safe_pc());
- return res;
-}
-
-WRITE8_MEMBER(ncr5380n_device::selenable_w)
-{
-}
-
-READ8_MEMBER(ncr5380n_device::busandstatus_r)
-{
- UINT32 ctrl = scsi_bus->ctrl_r();
- UINT8 res = m_busstatus |
- (ctrl & S_ATN ? BAS_ATN : 0) |
- (ctrl & S_ACK ? BAS_ACK : 0);
-
-// printf("%s: busandstatus_r %02x (%08x)\n", tag(), res, space.device().safe_pc());
-
- return res;
-}
-
-WRITE8_MEMBER(ncr5380n_device::startdmasend_w)
-{
- printf("%02x to start dma send\n", data);
- drq_set();
-}
-
-READ8_MEMBER(ncr5380n_device::indata_r)
-{
- return dma_r();
-}
-
-WRITE8_MEMBER(ncr5380n_device::startdmatargetrx_w)
-{
- printf("%02x to start dma target Rx\n", data);
-}
-
-READ8_MEMBER(ncr5380n_device::resetparityirq_r)
-{
- return 0;
-}
-
-WRITE8_MEMBER(ncr5380n_device::startdmainitrx_w)
-{
-// printf("%02x to start dma initiator Rx\n", data);
- recv_byte();
-}
-
-void ncr5380n_device::dma_w(UINT8 val)
-{
- // drop DRQ until we're ready for another byte
- drq_clear();
-
- if (m_mode & MODE_DMA)
- {
- m_dmalatch = val;
- send_byte();
- }
-}
-
-UINT8 ncr5380n_device::dma_r()
-{
- // drop DRQ
- drq_clear();
-
- // set up to receive our next byte if still in DMA mode
- scsi_bus->ctrl_w(scsi_refid, 0, S_ACK);
- if (m_mode & MODE_DMA)
- {
- recv_byte();
- }
- return m_dmalatch;
-}
-
-void ncr5380n_device::drq_set()
-{
- if(!drq)
- {
- drq = true;
- m_busstatus |= BAS_DMAREQUEST;
- m_drq_handler(drq);
- }
-}
-
-void ncr5380n_device::drq_clear()
-{
- if(drq)
- {
- drq = false;
- m_busstatus &= ~BAS_DMAREQUEST;
- m_drq_handler(drq);
- }
-}
-
-READ8_MEMBER(ncr5380n_device::read)
-{
- switch (offset & 7)
- {
- case 0:
- return scsidata_r(space, offset);
-
- case 1:
- return icmd_r(space, offset);
-
- case 2:
- return mode_r(space, offset);
-
- case 3:
- return command_r(space, offset);
-
- case 4:
- return status_r(space, offset);
-
- case 5:
- return busandstatus_r(space, offset);
-
- case 6:
- return indata_r(space, offset);
-
- case 7:
- return resetparityirq_r(space, offset);
- }
-
- return 0xff;
-}
-
-WRITE8_MEMBER(ncr5380n_device::write)
-{
-// printf("%x to 5380 @ %x\n", data, offset);
- switch (offset & 7)
- {
- case 0:
- outdata_w(space, offset, data);
- break;
-
- case 1:
- icmd_w(space, offset, data);
- break;
-
- case 2:
- mode_w(space, offset, data);
- break;
-
- case 3:
- command_w(space, offset, data);
- break;
-
- case 4:
- selenable_w(space, offset, data);
- break;
-
- case 5:
- startdmasend_w(space, offset, data);
- break;
-
- case 6:
- startdmatargetrx_w(space, offset, data);
- break;
-
- case 7:
- startdmainitrx_w(space, offset, data);
- break;
- }
-}
diff --git a/src/emu/machine/ncr5380n.h b/src/emu/machine/ncr5380n.h
deleted file mode 100644
index e9a142d78e5..00000000000
--- a/src/emu/machine/ncr5380n.h
+++ /dev/null
@@ -1,227 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont, Olivier Galibert
-/*********************************************************************
-
- ncr5380n.c
-
- Implementation of the NCR 5380
-
-*********************************************************************/
-
-#ifndef NCR5380N_H
-#define NCR5380N_H
-
-#include "machine/nscsi_bus.h"
-
-#define MCFG_NCR5380N_IRQ_HANDLER(_devcb) \
- devcb = &ncr5380n_device::set_irq_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_NCR5380N_DRQ_HANDLER(_devcb) \
- devcb = &ncr5380n_device::set_drq_handler(*device, DEVCB_##_devcb);
-
-class ncr5380n_device : public nscsi_device
-{
-public:
- ncr5380n_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_irq_handler(device_t &device, _Object object) { return downcast<ncr5380n_device &>(device).m_irq_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_drq_handler(device_t &device, _Object object) { return downcast<ncr5380n_device &>(device).m_drq_handler.set_callback(object); }
-
- DECLARE_ADDRESS_MAP(map, 8);
-
- DECLARE_READ8_MEMBER(scsidata_r);
- DECLARE_WRITE8_MEMBER(outdata_w);
- DECLARE_READ8_MEMBER(icmd_r);
- DECLARE_WRITE8_MEMBER(icmd_w);
- DECLARE_READ8_MEMBER(mode_r);
- DECLARE_WRITE8_MEMBER(mode_w);
- DECLARE_READ8_MEMBER(command_r);
- DECLARE_WRITE8_MEMBER(command_w);
- DECLARE_READ8_MEMBER(status_r);
- DECLARE_WRITE8_MEMBER(selenable_w);
- DECLARE_READ8_MEMBER(busandstatus_r);
- DECLARE_WRITE8_MEMBER(startdmasend_w);
- DECLARE_READ8_MEMBER(indata_r);
- DECLARE_WRITE8_MEMBER(startdmatargetrx_w);
- DECLARE_READ8_MEMBER(resetparityirq_r);
- DECLARE_WRITE8_MEMBER(startdmainitrx_w);
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- virtual void scsi_ctrl_changed();
-
- UINT8 dma_r();
- void dma_w(UINT8 val);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- enum { MODE_D, MODE_T, MODE_I };
- enum { IDLE };
-
- enum {
- // Bus initiated sequences
- BUSINIT_SETTLE_DELAY = 1,
- BUSINIT_ASSERT_BUS_SEL,
- BUSINIT_MSG_OUT,
- BUSINIT_RECV_BYTE,
- BUSINIT_ASSERT_BUS_RESEL,
- BUSINIT_WAIT_REQ,
- BUSINIT_RECV_BYTE_NACK,
-
- // Bus SCSI Reset
- BUSRESET_WAIT_INT,
- BUSRESET_RESET_BOARD,
-
- // Disconnected state commands
- DISC_SEL_ARBITRATION,
- DISC_SEL_ATN_WAIT_REQ,
- DISC_SEL_ATN_SEND_BYTE,
- DISC_SEL_WAIT_REQ,
- DISC_SEL_SEND_BYTE,
- DISC_REC_ARBITRATION,
- DISC_REC_MSG_IN,
- DISC_REC_SEND_BYTE,
- DISC_RESET,
-
- // Command sequence
- CMDSEQ_CMD_PHASE,
- CMDSEQ_RECV_BYTE,
-
- // Target commands
- TARGET_SEND_BYTE,
- TARGET_CMD_RECV_BYTE,
- TARGET_MSG_RECV_BYTE,
- TARGET_MSG_RECV_PAD,
- TARGET_DISC_SEND_BYTE,
- TARGET_DISC_MSG_IN,
- TARGET_DISC_SEND_BYTE_2,
-
- // Initiator commands
- INIT_MSG_WAIT_REQ,
- INIT_XFR,
- INIT_XFR_SEND_BYTE,
- INIT_XFR_SEND_PAD_WAIT_REQ,
- INIT_XFR_SEND_PAD,
- INIT_XFR_RECV_PAD_WAIT_REQ,
- INIT_XFR_RECV_PAD,
- INIT_XFR_RECV_BYTE_ACK,
- INIT_XFR_RECV_BYTE_NACK,
- INIT_XFR_WAIT_REQ,
- INIT_CPT_RECV_BYTE_ACK,
- INIT_CPT_RECV_WAIT_REQ,
- INIT_CPT_RECV_BYTE_NACK
- };
-
- enum {
- // Arbitration
- ARB_WAIT_BUS_FREE = 1,
- ARB_COMPLETE,
- ARB_ASSERT_SEL,
- ARB_SET_DEST,
- ARB_RELEASE_BUSY,
- ARB_TIMEOUT_BUSY,
- ARB_TIMEOUT_ABORT,
- ARB_DESKEW_WAIT,
-
- // Send/receive byte
- SEND_WAIT_SETTLE,
- SEND_WAIT_REQ_0,
- RECV_WAIT_REQ_1,
- RECV_WAIT_SETTLE,
- RECV_WAIT_REQ_0
- };
-
- enum {
- STATE_MASK = 0x00ff,
- SUB_SHIFT = 8,
- SUB_MASK = 0xff00
- };
-
- enum { BUS_BUSY, BUS_FREE_WAIT, BUS_FREE };
-
- enum {
- ST_RST = 0x80,
- ST_BSY = 0x40,
- ST_REQ = 0x20,
- ST_MSG = 0x10,
- ST_CD = 0x08,
- ST_IO = 0x04,
- ST_SEL = 0x02,
- ST_DBP = 0x01,
-
- BAS_ENDOFDMA = 0x80,
- BAS_DMAREQUEST = 0x40,
- BAS_PARITYERROR = 0x20,
- BAS_IRQACTIVE = 0x10,
- BAS_PHASEMATCH = 0x08,
- BAS_BUSYERROR = 0x04,
- BAS_ATN = 0x02,
- BAS_ACK = 0x01,
-
- IC_RST = 0x80,
- IC_ARBITRATION = 0x40,
- IC_ARBLOST = 0x20,
- IC_ACK = 0x10,
- IC_BSY = 0x08,
- IC_SEL = 0x04,
- IC_ATN = 0x02,
- IC_DBUS = 0x01,
- IC_PHASEMASK = 0x9e,
- IC_WRITEMASK = 0x9f,
-
- MODE_BLOCKDMA = 0x80,
- MODE_TARGET = 0x40,
- MODE_PARITYCHK = 0x20,
- MODE_PARITYIRQ = 0x10,
- MODE_EOPIRQ = 0x08,
- MODE_BSYIRQ = 0x04,
- MODE_DMA = 0x02,
- MODE_ARBITRATE = 0x01
- };
-
- enum { DMA_NONE, DMA_IN, DMA_OUT };
-
- emu_timer *tm;
-
- UINT8 status, istatus, m_mode, m_outdata, m_busstatus, m_dmalatch;
- UINT8 m_icommand, m_tcommand;
- UINT8 clock_conv, sync_offset, sync_period, bus_id, select_timeout, seq;
- UINT16 tcount;
- int mode;
- int state/*, xfr_phase*/;
-
- bool irq, drq;
-
- void drq_set();
- void drq_clear();
-
- void step(bool timeout);
- void function_complete();
- void function_bus_complete();
- void bus_complete();
-
- void arbitrate();
- void check_irq();
-
- void reset_soft();
- void reset_disconnect();
-
- void send_byte();
- void recv_byte();
-
- void delay(int cycles);
- void delay_cycles(int cycles);
-
- devcb_write_line m_irq_handler;
- devcb_write_line m_drq_handler;
-};
-
-extern const device_type NCR5380N;
-
-#endif
diff --git a/src/emu/machine/ncr5390.c b/src/emu/machine/ncr5390.c
deleted file mode 100644
index 26e4218b226..00000000000
--- a/src/emu/machine/ncr5390.c
+++ /dev/null
@@ -1,862 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-
-#include "emu.h"
-#include "ncr5390.h"
-
-#define DELAY_HACK
-
-const device_type NCR5390 = &device_creator<ncr5390_device>;
-
-DEVICE_ADDRESS_MAP_START(map, 8, ncr5390_device)
- AM_RANGE(0x0, 0x0) AM_READWRITE(tcount_lo_r, tcount_lo_w)
- AM_RANGE(0x1, 0x1) AM_READWRITE(tcount_hi_r, tcount_hi_w)
- AM_RANGE(0x2, 0x2) AM_READWRITE(fifo_r, fifo_w)
- AM_RANGE(0x3, 0x3) AM_READWRITE(command_r, command_w)
- AM_RANGE(0x4, 0x4) AM_READWRITE(status_r, bus_id_w)
- AM_RANGE(0x5, 0x5) AM_READWRITE(istatus_r, timeout_w)
- AM_RANGE(0x6, 0x6) AM_READWRITE(seq_step_r, sync_period_w)
- AM_RANGE(0x7, 0x7) AM_READWRITE(fifo_flags_r, sync_offset_w)
- AM_RANGE(0x8, 0x8) AM_READWRITE(conf_r, conf_w)
- AM_RANGE(0x9, 0x9) AM_WRITE(clock_w)
-ADDRESS_MAP_END
-
-ncr5390_device::ncr5390_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : nscsi_device(mconfig, NCR5390, "5390 SCSI", tag, owner, clock, "ncr5390", __FILE__),
- m_irq_handler(*this),
- m_drq_handler(*this)
-{
-}
-
-void ncr5390_device::device_start()
-{
- nscsi_device::device_start();
-
- save_item(NAME(command));
- save_item(NAME(config));
- save_item(NAME(status));
- save_item(NAME(istatus));
- save_item(NAME(clock_conv));
- save_item(NAME(sync_offset));
- save_item(NAME(sync_period));
- save_item(NAME(bus_id));
- save_item(NAME(select_timeout));
- save_item(NAME(seq));
- save_item(NAME(fifo));
- save_item(NAME(tcount));
- save_item(NAME(mode));
- save_item(NAME(fifo_pos));
- save_item(NAME(command_pos));
- save_item(NAME(state));
- save_item(NAME(xfr_phase));
- save_item(NAME(command_length));
- save_item(NAME(dma_dir));
- save_item(NAME(irq));
- save_item(NAME(drq));
-
- m_irq_handler.resolve_safe();
- m_drq_handler.resolve_safe();
-
- tcount = 0;
- config = 0;
- status = 0;
- bus_id = 0;
- select_timeout = 0;
- tm = timer_alloc(0);
-}
-
-void ncr5390_device::device_reset()
-{
- fifo_pos = 0;
- memset(fifo, 0, sizeof(fifo));
-
- clock_conv = 2;
- sync_period = 5;
- sync_offset = 0;
- seq = 0;
- config &= 7;
- status &= 0x90;
- istatus = 0;
- irq = false;
- m_irq_handler(irq);
- reset_soft();
-}
-
-void ncr5390_device::reset_soft()
-{
- state = IDLE;
- scsi_bus->ctrl_wait(scsi_refid, S_SEL|S_BSY|S_RST, S_ALL);
- status &= 0xef;
- drq = false;
- m_drq_handler(drq);
- reset_disconnect();
-}
-
-void ncr5390_device::reset_disconnect()
-{
- command_pos = 0;
- command_length = 0;
- memset(command, 0, sizeof(command));
- mode = MODE_D;
-}
-
-void ncr5390_device::scsi_ctrl_changed()
-{
- UINT32 ctrl = scsi_bus->ctrl_r();
- if(ctrl & S_RST) {
- logerror("%s: scsi bus reset\n", tag());
- return;
- }
-
- step(false);
-}
-
-void ncr5390_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- step(true);
-}
-
-void ncr5390_device::step(bool timeout)
-{
- UINT32 ctrl = scsi_bus->ctrl_r();
- UINT32 data = scsi_bus->data_r();
- UINT8 c = command[0] & 0x7f;
-
- if(0)
- logerror("%s: state=%d.%d %s\n",
- tag(), state & STATE_MASK, (state & SUB_MASK) >> SUB_SHIFT,
- timeout ? "timeout" : "change");
-
- if(mode == MODE_I && !(ctrl & S_BSY)) {
- state = IDLE;
- istatus |= I_DISCONNECT;
- reset_disconnect();
- check_irq();
- }
- switch(state & SUB_MASK ? state & SUB_MASK : state & STATE_MASK) {
- case IDLE:
- break;
-
- case ARB_COMPLETE << SUB_SHIFT: {
- if(!timeout)
- break;
-
- int win;
- for(win=7; win>=0 && !(data & (1<<win)); win--);
- if(win != scsi_id) {
- scsi_bus->data_w(scsi_refid, 0);
- scsi_bus->ctrl_w(scsi_refid, 0, S_ALL);
- fatalerror("need to wait for bus free\n");
- }
- state = (state & STATE_MASK) | (ARB_ASSERT_SEL << SUB_SHIFT);
- scsi_bus->ctrl_w(scsi_refid, S_SEL, S_SEL);
- delay(6);
- break;
- }
-
- case ARB_ASSERT_SEL << SUB_SHIFT:
- if(!timeout)
- break;
-
- scsi_bus->data_w(scsi_refid, (1<<scsi_id) | (1<<bus_id));
- state = (state & STATE_MASK) | (ARB_SET_DEST << SUB_SHIFT);
- delay_cycles(4);
- break;
-
- case ARB_SET_DEST << SUB_SHIFT:
- if(!timeout)
- break;
-
- state = (state & STATE_MASK) | (ARB_RELEASE_BUSY << SUB_SHIFT);
- scsi_bus->ctrl_w(scsi_refid, c == CD_SELECT_ATN || c == CD_SELECT_ATN_STOP ? S_ATN : 0, S_ATN|S_BSY);
- delay(2);
- break;
-
- case ARB_RELEASE_BUSY << SUB_SHIFT:
- if(!timeout)
- break;
-
- if(ctrl & S_BSY) {
- state = (state & STATE_MASK) | (ARB_DESKEW_WAIT << SUB_SHIFT);
- if(c == CD_RESELECT)
- scsi_bus->ctrl_w(scsi_refid, S_BSY, S_BSY);
- delay_cycles(2);
- } else {
- state = (state & STATE_MASK) | (ARB_TIMEOUT_BUSY << SUB_SHIFT);
-#ifdef DELAY_HACK
- delay(1);
-#else
- delay(8192*select_timeout);
-#endif
- }
- break;
-
- case ARB_DESKEW_WAIT << SUB_SHIFT:
- if(!timeout)
- break;
-
- scsi_bus->data_w(scsi_refid, 0);
- scsi_bus->ctrl_w(scsi_refid, 0, S_SEL);
-
- if(c == CD_RESELECT) {
- logerror("%s: mode switch to Target\n", tag());
- mode = MODE_T;
- } else {
- logerror("%s: mode switch to Initiator\n", tag());
- mode = MODE_I;
- }
- state &= STATE_MASK;
- step(true);
- break;
-
- case ARB_TIMEOUT_BUSY << SUB_SHIFT:
- if(timeout) {
- scsi_bus->data_w(scsi_refid, 0);
- logerror("%s: select timeout\n", tag());
- state = (state & STATE_MASK) | (ARB_TIMEOUT_ABORT << SUB_SHIFT);
- delay(1000);
- } else if(ctrl & S_BSY) {
- state = (state & STATE_MASK) | (ARB_DESKEW_WAIT << SUB_SHIFT);
- if(c == CD_RESELECT)
- scsi_bus->ctrl_w(scsi_refid, S_BSY, S_BSY);
- delay_cycles(2);
- }
- break;
-
- case ARB_TIMEOUT_ABORT << SUB_SHIFT:
- if(!timeout)
- break;
-
- if(ctrl & S_BSY) {
- state = (state & STATE_MASK) | (ARB_DESKEW_WAIT << SUB_SHIFT);
- if(c == CD_RESELECT)
- scsi_bus->ctrl_w(scsi_refid, S_BSY, S_BSY);
- delay_cycles(2);
- } else {
- scsi_bus->ctrl_w(scsi_refid, 0, S_ALL);
- state = IDLE;
- istatus |= I_DISCONNECT;
- reset_disconnect();
- check_irq();
- }
- break;
-
- case SEND_WAIT_SETTLE << SUB_SHIFT:
- if(!timeout)
- break;
-
- state = (state & STATE_MASK) | (SEND_WAIT_REQ_0 << SUB_SHIFT);
- step(false);
- break;
-
- case SEND_WAIT_REQ_0 << SUB_SHIFT:
- if(ctrl & S_REQ)
- break;
- state = state & STATE_MASK;
- scsi_bus->data_w(scsi_refid, 0);
- scsi_bus->ctrl_w(scsi_refid, 0, S_ACK);
- step(false);
- break;
-
- case RECV_WAIT_REQ_1 << SUB_SHIFT:
- if(!(ctrl & S_REQ))
- break;
-
- state = (state & STATE_MASK) | (RECV_WAIT_SETTLE << SUB_SHIFT);
- delay_cycles(sync_period);
- break;
-
- case RECV_WAIT_SETTLE << SUB_SHIFT:
- if(!timeout)
- break;
-
- if((state & STATE_MASK) != INIT_XFR_RECV_PAD)
- fifo_push(scsi_bus->data_r());
- scsi_bus->ctrl_w(scsi_refid, S_ACK, S_ACK);
- state = (state & STATE_MASK) | (RECV_WAIT_REQ_0 << SUB_SHIFT);
- step(false);
- break;
-
- case RECV_WAIT_REQ_0 << SUB_SHIFT:
- if(ctrl & S_REQ)
- break;
- state = state & STATE_MASK;
- step(false);
- break;
-
- case DISC_SEL_ARBITRATION:
- if(c == CD_SELECT) {
- state = DISC_SEL_WAIT_REQ;
- command_length = derive_msg_size(fifo[0]);
- } else
- state = DISC_SEL_ATN_WAIT_REQ;
-
- scsi_bus->ctrl_wait(scsi_refid, S_REQ, S_REQ);
- if(ctrl & S_REQ)
- step(false);
- break;
-
- case DISC_SEL_ATN_WAIT_REQ:
- if(!(ctrl & S_REQ))
- break;
- if((ctrl & S_PHASE_MASK) != S_PHASE_MSG_OUT) {
- function_complete();
- break;
- }
- if(c == CD_SELECT_ATN)
- scsi_bus->ctrl_w(scsi_refid, 0, S_ATN);
- state = DISC_SEL_ATN_SEND_BYTE;
- send_byte();
- break;
-
- case DISC_SEL_ATN_SEND_BYTE:
- if(c == CD_SELECT_ATN_STOP) {
- seq = 1;
- function_complete();
- } else {
- command_length = derive_msg_size(fifo[0]);
- state = DISC_SEL_WAIT_REQ;
- }
- break;
-
- case DISC_SEL_WAIT_REQ:
- if(!(ctrl & S_REQ))
- break;
- if((ctrl & S_PHASE_MASK) != S_PHASE_COMMAND) {
- if(!command_length)
- seq = 4;
- scsi_bus->ctrl_wait(scsi_refid, 0, S_REQ);
- function_bus_complete();
- break;
- }
- if(seq < 3)
- seq = 3;
- state = DISC_SEL_SEND_BYTE;
- send_byte();
- break;
-
- case DISC_SEL_SEND_BYTE:
- if(command_length) {
- command_length--;
- if(!command_length)
- seq = 4;
- }
-
- state = DISC_SEL_WAIT_REQ;
- break;
-
- case INIT_CPT_RECV_BYTE_ACK:
- state = INIT_CPT_RECV_WAIT_REQ;
- scsi_bus->ctrl_w(scsi_refid, 0, S_ACK);
- break;
-
- case INIT_CPT_RECV_WAIT_REQ:
- if(!(ctrl & S_REQ))
- break;
-
- if((ctrl & S_PHASE_MASK) != S_PHASE_MSG_IN) {
- command_pos = 0;
- bus_complete();
- } else {
- state = INIT_CPT_RECV_BYTE_NACK;
- recv_byte();
- }
- break;
-
- case INIT_CPT_RECV_BYTE_NACK:
- scsi_bus->ctrl_wait(scsi_refid, 0, S_REQ);
- function_complete();
- break;
-
- case INIT_MSG_WAIT_REQ:
- if((ctrl & (S_REQ|S_BSY)) == S_BSY)
- break;
- bus_complete();
- break;
-
- case INIT_XFR:
- switch(xfr_phase) {
- case S_PHASE_DATA_OUT:
- dma_set(DMA_OUT);
- if(tcount == 0 && fifo_pos == 1)
- scsi_bus->ctrl_w(scsi_refid, 0, S_ATN);
- state = INIT_XFR_SEND_BYTE;
- send_byte();
- break;
-
- case S_PHASE_DATA_IN:
- dma_set(DMA_IN);
- state = tcount == fifo_pos+1 ?
- INIT_XFR_RECV_BYTE_NACK : INIT_XFR_RECV_BYTE_ACK;
- recv_byte();
- break;
-
- default:
- logerror("%s: xfer on phase %d\n", tag(), scsi_bus->ctrl_r() & S_PHASE_MASK);
- function_complete();
- break;
- }
- break;
-
- case INIT_XFR_WAIT_REQ:
- if(!(ctrl & S_REQ))
- break;
-
- if((ctrl & S_PHASE_MASK) != xfr_phase) {
- command_pos = 0;
- bus_complete();
- } else {
- state = INIT_XFR;
- step(false);
- }
- break;
-
- case INIT_XFR_SEND_BYTE:
- if(tcount == 0 && fifo_pos == 0)
- bus_complete();
- else
- state = INIT_XFR_WAIT_REQ;
- break;
-
- case INIT_XFR_RECV_BYTE_ACK:
- state = INIT_XFR_WAIT_REQ;
- scsi_bus->ctrl_w(scsi_refid, 0, S_ACK);
- break;
-
- case INIT_XFR_RECV_BYTE_NACK:
- function_complete();
- break;
-
- case INIT_XFR_SEND_PAD_WAIT_REQ:
- if(!(ctrl & S_REQ))
- break;
-
- if((ctrl & S_PHASE_MASK) != xfr_phase) {
- command_pos = 0;
- bus_complete();
- } else {
- state = INIT_XFR_SEND_PAD;
- send_byte();
- }
- break;
-
- case INIT_XFR_SEND_PAD:
- tcount--;
- if(tcount) {
- state = INIT_XFR_SEND_PAD_WAIT_REQ;
- step(false);
- } else
- function_complete();
- break;
-
- case INIT_XFR_RECV_PAD_WAIT_REQ:
- if(!(ctrl & S_REQ))
- break;
-
- if((ctrl & S_PHASE_MASK) != xfr_phase) {
- command_pos = 0;
- bus_complete();
- } else {
- state = INIT_XFR_RECV_PAD;
- recv_byte();
- }
- break;
-
- case INIT_XFR_RECV_PAD:
- tcount--;
- if(tcount) {
- state = INIT_XFR_RECV_PAD_WAIT_REQ;
- scsi_bus->ctrl_w(scsi_refid, 0, S_ACK);
- step(false);
- } else
- function_complete();
- break;
-
- default:
- logerror("%s: step() unexpected state %d.%d\n",
- tag(),
- state & STATE_MASK, (state & SUB_MASK) >> SUB_SHIFT);
- exit(0);
- }
-}
-
-void ncr5390_device::send_byte()
-{
- if(!fifo_pos)
- fatalerror("ncr5390_device::send_byte - !fifo_pos\n");
-
- state = (state & STATE_MASK) | (SEND_WAIT_SETTLE << SUB_SHIFT);
- if((state & STATE_MASK) != INIT_XFR_SEND_PAD &&
- ((state & STATE_MASK) != DISC_SEL_SEND_BYTE ||
- command_length))
- scsi_bus->data_w(scsi_refid, fifo_pop());
- else
- scsi_bus->data_w(scsi_refid, 0);
-
- scsi_bus->ctrl_w(scsi_refid, S_ACK, S_ACK);
- scsi_bus->ctrl_wait(scsi_refid, S_REQ, S_REQ);
- delay_cycles(sync_period);
-}
-
-void ncr5390_device::recv_byte()
-{
- scsi_bus->ctrl_wait(scsi_refid, S_REQ, S_REQ);
- state = (state & STATE_MASK) | (RECV_WAIT_REQ_1 << SUB_SHIFT);
- step(false);
-}
-
-void ncr5390_device::function_bus_complete()
-{
- state = IDLE;
- istatus |= I_FUNCTION|I_BUS;
- dma_set(DMA_NONE);
- check_irq();
-}
-
-void ncr5390_device::function_complete()
-{
- state = IDLE;
- istatus |= I_FUNCTION;
- dma_set(DMA_NONE);
- check_irq();
-}
-
-void ncr5390_device::bus_complete()
-{
- state = IDLE;
- istatus |= I_BUS;
- dma_set(DMA_NONE);
- check_irq();
-}
-
-void ncr5390_device::delay(int cycles)
-{
- if(!clock_conv)
- return;
- cycles *= clock_conv;
- tm->adjust(clocks_to_attotime(cycles));
-}
-
-void ncr5390_device::delay_cycles(int cycles)
-{
- tm->adjust(clocks_to_attotime(cycles));
-}
-
-READ8_MEMBER(ncr5390_device::tcount_lo_r)
-{
- logerror("%s: tcount_lo_r %02x (%08x)\n", tag(), tcount & 0xff, space.device().safe_pc());
- return tcount;
-}
-
-WRITE8_MEMBER(ncr5390_device::tcount_lo_w)
-{
- tcount = (tcount & 0xff00) | data;
- status &= ~S_TC0;
- logerror("%s: tcount_lo_w %02x (%08x)\n", tag(), data, space.device().safe_pc());
-}
-
-READ8_MEMBER(ncr5390_device::tcount_hi_r)
-{
- logerror("%s: tcount_hi_r %02x (%08x)\n", tag(), tcount >> 8, space.device().safe_pc());
- return tcount >> 8;
-}
-
-WRITE8_MEMBER(ncr5390_device::tcount_hi_w)
-{
- tcount = (tcount & 0x00ff) | (data << 8);
- status &= ~S_TC0;
- logerror("%s: tcount_hi_w %02x (%08x)\n", tag(), data, space.device().safe_pc());
-}
-
-UINT8 ncr5390_device::fifo_pop()
-{
- UINT8 r = fifo[0];
- fifo_pos--;
- memmove(fifo, fifo+1, fifo_pos);
- if((!fifo_pos) && tcount && dma_dir == DMA_OUT)
- drq_set();
- return r;
-}
-
-void ncr5390_device::fifo_push(UINT8 val)
-{
- fifo[fifo_pos++] = val;
- if(!drq && dma_dir == DMA_IN)
- drq_set();
-}
-
-READ8_MEMBER(ncr5390_device::fifo_r)
-{
- UINT8 r;
- if(fifo_pos) {
- r = fifo[0];
- fifo_pos--;
- memmove(fifo, fifo+1, fifo_pos);
- } else
- r = 0;
- return r;
-}
-
-WRITE8_MEMBER(ncr5390_device::fifo_w)
-{
- if(fifo_pos != 16)
- fifo[fifo_pos++] = data;
-}
-
-READ8_MEMBER(ncr5390_device::command_r)
-{
- logerror("%s: command_r (%08x)\n", tag(), space.device().safe_pc());
- return command[0];
-}
-
-WRITE8_MEMBER(ncr5390_device::command_w)
-{
- // logerror("%s: command_w %02x (%08x)\n", tag(), data, space.device().safe_pc());
- if(command_pos == 2) {
- status |= S_GROSS_ERROR;
- check_irq();
- return;
- }
- command[command_pos++] = data;
- if(command_pos == 1)
- start_command();
-}
-
-void ncr5390_device::command_pop_and_chain()
-{
- if(command_pos) {
- command_pos--;
- if(command_pos) {
- command[0] = command[1];
- start_command();
- }
- }
-}
-
-void ncr5390_device::start_command()
-{
- UINT8 c = command[0] & 0x7f;
- if(!check_valid_command(c)) {
- logerror("%s: invalid command %02x\n", tag(), command[0]);
- istatus |= I_ILLEGAL;
- check_irq();
- return;
- }
-
- switch(c) {
- case CM_NOP:
- command_pop_and_chain();
- break;
-
- case CM_FLUSH_FIFO:
- fifo_pos = 0;
- command_pop_and_chain();
- break;
-
- case CM_RESET:
- device_reset();
- break;
-
- case CM_RESET_BUS:
- reset_soft();
- break;
-
- case CD_RESELECT:
- state = DISC_REC_ARBITRATION;
- arbitrate();
- break;
-
- case CD_SELECT:
- case CD_SELECT_ATN:
- case CD_SELECT_ATN_STOP:
- seq = 0;
- state = DISC_SEL_ARBITRATION;
- arbitrate();
- break;
-
- case CD_ENABLE_SEL:
- command_pop_and_chain();
- break;
-
- case CI_XFER:
- state = INIT_XFR;
- xfr_phase = scsi_bus->ctrl_r() & S_PHASE_MASK;
- step(false);
- break;
-
- case CI_COMPLETE:
- state = INIT_CPT_RECV_BYTE_ACK;
- recv_byte();
- break;
-
- case CI_MSG_ACCEPT:
- state = INIT_MSG_WAIT_REQ;
- scsi_bus->ctrl_w(scsi_refid, 0, S_ACK);
- step(false);
- break;
-
- case CI_PAD:
- xfr_phase = scsi_bus->ctrl_r() & S_PHASE_MASK;
- if(xfr_phase & S_INP)
- state = INIT_XFR_RECV_PAD_WAIT_REQ;
- else
- state = INIT_XFR_SEND_PAD_WAIT_REQ;
- scsi_bus->ctrl_w(scsi_refid, 0, S_ACK);
- step(false);
- break;
-
- default:
- logerror("%s: start unimplemented command %02x\n", tag(), c);
- exit(0);
- }
-}
-
-bool ncr5390_device::check_valid_command(UINT8 cmd)
-{
- int subcmd = cmd & 15;
- switch((cmd >> 4) & 7) {
- case 0: return subcmd <= 3;
- case 4: return mode == MODE_D && subcmd <= 5;
- case 2: return mode == MODE_T && subcmd <= 13 && subcmd != 6;
- case 1: return mode == MODE_I && (subcmd <= 2 || subcmd == 8 || subcmd == 10);
- }
- return false;
-}
-
-int ncr5390_device::derive_msg_size(UINT8 msg_id)
-{
- const static int sizes[8] = { 6, 10, 6, 6, 6, 12, 6, 10 };
- return sizes[msg_id >> 5];
-}
-
-void ncr5390_device::arbitrate()
-{
- state = (state & STATE_MASK) | (ARB_COMPLETE << SUB_SHIFT);
- scsi_bus->data_w(scsi_refid, 1 << scsi_id);
- scsi_bus->ctrl_w(scsi_refid, S_BSY, S_BSY);
- delay(11);
-}
-
-void ncr5390_device::check_irq()
-{
- bool oldirq = irq;
- irq = istatus != 0;
- if(irq != oldirq)
- m_irq_handler(irq);
-
-}
-
-READ8_MEMBER(ncr5390_device::status_r)
-{
- UINT32 ctrl = scsi_bus->ctrl_r();
- UINT8 res = status | (ctrl & S_MSG ? 4 : 0) | (ctrl & S_CTL ? 2 : 0) | (ctrl & S_INP ? 1 : 0);
- logerror("%s: status_r %02x (%08x)\n", tag(), res, space.device().safe_pc());
- if(irq)
- status &= ~(S_GROSS_ERROR|S_PARITY|S_TCC);
- return res;
-}
-
-WRITE8_MEMBER(ncr5390_device::bus_id_w)
-{
- bus_id = data & 7;
- logerror("%s: bus_id=%d\n", tag(), bus_id);
-}
-
-READ8_MEMBER(ncr5390_device::istatus_r)
-{
- UINT8 res = istatus;
- istatus = 0;
- seq = 0;
- check_irq();
- if(res)
- command_pop_and_chain();
-
- logerror("%s: istatus_r %02x (%08x)\n", tag(), res, space.device().safe_pc());
- return res;
-}
-
-WRITE8_MEMBER(ncr5390_device::timeout_w)
-{
- select_timeout = data;
-}
-
-READ8_MEMBER(ncr5390_device::seq_step_r)
-{
- logerror("%s: seq_step_r %d (%08x)\n", tag(), seq, space.device().safe_pc());
- return seq;
-}
-
-WRITE8_MEMBER(ncr5390_device::sync_period_w)
-{
- sync_period = data & 0x1f;
-}
-
-READ8_MEMBER(ncr5390_device::fifo_flags_r)
-{
- return fifo_pos;
-}
-
-WRITE8_MEMBER(ncr5390_device::sync_offset_w)
-{
- sync_offset = data & 0x0f;
-}
-
-READ8_MEMBER(ncr5390_device::conf_r)
-{
- return config;
-}
-
-WRITE8_MEMBER(ncr5390_device::conf_w)
-{
- config = data;
- scsi_id = data & 7;
-}
-
-WRITE8_MEMBER(ncr5390_device::clock_w)
-{
- clock_conv = data & 0x07;
-}
-
-void ncr5390_device::dma_set(int dir)
-{
- dma_dir = dir;
- if(dma_dir == DMA_OUT && fifo_pos != 16 && tcount != 0)
- drq_set();
-}
-
-void ncr5390_device::dma_w(UINT8 val)
-{
- fifo_push(val);
- tcount--;
- if(fifo_pos == 16 || tcount == 0)
- drq_clear();
-}
-
-UINT8 ncr5390_device::dma_r()
-{
- UINT8 r = fifo_pop();
- if(!fifo_pos)
- drq_clear();
- tcount--;
- if(tcount == 0) {
- status |= S_TC0;
- step(false);
- }
- return r;
-}
-
-void ncr5390_device::drq_set()
-{
- if(!drq) {
- drq = true;
- m_drq_handler(drq);
- }
-}
-
-void ncr5390_device::drq_clear()
-{
- if(drq) {
- drq = false;
- m_drq_handler(drq);
- }
-}
diff --git a/src/emu/machine/ncr5390.h b/src/emu/machine/ncr5390.h
deleted file mode 100644
index 93cf76a5486..00000000000
--- a/src/emu/machine/ncr5390.h
+++ /dev/null
@@ -1,232 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef NCR5390_H
-#define NCR5390_H
-
-#include "machine/nscsi_bus.h"
-
-#define MCFG_NCR5390_IRQ_HANDLER(_devcb) \
- devcb = &ncr5390_device::set_irq_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_NCR5390_DRQ_HANDLER(_devcb) \
- devcb = &ncr5390_device::set_drq_handler(*device, DEVCB_##_devcb);
-
-class ncr5390_device : public nscsi_device
-{
-public:
- ncr5390_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_irq_handler(device_t &device, _Object object) { return downcast<ncr5390_device &>(device).m_irq_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_drq_handler(device_t &device, _Object object) { return downcast<ncr5390_device &>(device).m_drq_handler.set_callback(object); }
-
- DECLARE_ADDRESS_MAP(map, 8);
-
- DECLARE_READ8_MEMBER(tcount_lo_r);
- DECLARE_WRITE8_MEMBER(tcount_lo_w);
- DECLARE_READ8_MEMBER(tcount_hi_r);
- DECLARE_WRITE8_MEMBER(tcount_hi_w);
- DECLARE_READ8_MEMBER(fifo_r);
- DECLARE_WRITE8_MEMBER(fifo_w);
- DECLARE_READ8_MEMBER(command_r);
- DECLARE_WRITE8_MEMBER(command_w);
- DECLARE_READ8_MEMBER(status_r);
- DECLARE_WRITE8_MEMBER(bus_id_w);
- DECLARE_READ8_MEMBER(istatus_r);
- DECLARE_WRITE8_MEMBER(timeout_w);
- DECLARE_READ8_MEMBER(seq_step_r);
- DECLARE_WRITE8_MEMBER(sync_period_w);
- DECLARE_READ8_MEMBER(fifo_flags_r);
- DECLARE_WRITE8_MEMBER(sync_offset_w);
- DECLARE_READ8_MEMBER(conf_r);
- DECLARE_WRITE8_MEMBER(conf_w);
- DECLARE_WRITE8_MEMBER(clock_w);
-
- virtual void scsi_ctrl_changed();
-
- UINT8 dma_r();
- void dma_w(UINT8 val);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- enum { MODE_D, MODE_T, MODE_I };
- enum { IDLE };
-
- enum {
- // Bus initiated sequences
- BUSINIT_SETTLE_DELAY = 1,
- BUSINIT_ASSERT_BUS_SEL,
- BUSINIT_MSG_OUT,
- BUSINIT_RECV_BYTE,
- BUSINIT_ASSERT_BUS_RESEL,
- BUSINIT_WAIT_REQ,
- BUSINIT_RECV_BYTE_NACK,
-
- // Bus SCSI Reset
- BUSRESET_WAIT_INT,
- BUSRESET_RESET_BOARD,
-
- // Disconnected state commands
- DISC_SEL_ARBITRATION,
- DISC_SEL_ATN_WAIT_REQ,
- DISC_SEL_ATN_SEND_BYTE,
- DISC_SEL_WAIT_REQ,
- DISC_SEL_SEND_BYTE,
- DISC_REC_ARBITRATION,
- DISC_REC_MSG_IN,
- DISC_REC_SEND_BYTE,
- DISC_RESET,
-
- // Command sequence
- CMDSEQ_CMD_PHASE,
- CMDSEQ_RECV_BYTE,
-
- // Target commands
- TARGET_SEND_BYTE,
- TARGET_CMD_RECV_BYTE,
- TARGET_MSG_RECV_BYTE,
- TARGET_MSG_RECV_PAD,
- TARGET_DISC_SEND_BYTE,
- TARGET_DISC_MSG_IN,
- TARGET_DISC_SEND_BYTE_2,
-
- // Initiator commands
- INIT_MSG_WAIT_REQ,
- INIT_XFR,
- INIT_XFR_SEND_BYTE,
- INIT_XFR_SEND_PAD_WAIT_REQ,
- INIT_XFR_SEND_PAD,
- INIT_XFR_RECV_PAD_WAIT_REQ,
- INIT_XFR_RECV_PAD,
- INIT_XFR_RECV_BYTE_ACK,
- INIT_XFR_RECV_BYTE_NACK,
- INIT_XFR_WAIT_REQ,
- INIT_CPT_RECV_BYTE_ACK,
- INIT_CPT_RECV_WAIT_REQ,
- INIT_CPT_RECV_BYTE_NACK
- };
-
- enum {
- // Arbitration
- ARB_WAIT_BUS_FREE = 1,
- ARB_COMPLETE,
- ARB_ASSERT_SEL,
- ARB_SET_DEST,
- ARB_RELEASE_BUSY,
- ARB_TIMEOUT_BUSY,
- ARB_TIMEOUT_ABORT,
- ARB_DESKEW_WAIT,
-
- // Send/receive byte
- SEND_WAIT_SETTLE,
- SEND_WAIT_REQ_0,
- RECV_WAIT_REQ_1,
- RECV_WAIT_SETTLE,
- RECV_WAIT_REQ_0
- };
-
- enum {
- STATE_MASK = 0x00ff,
- SUB_SHIFT = 8,
- SUB_MASK = 0xff00
- };
-
- enum { BUS_BUSY, BUS_FREE_WAIT, BUS_FREE };
-
- enum {
- S_GROSS_ERROR = 0x40,
- S_PARITY = 0x20,
- S_TC0 = 0x10,
- S_TCC = 0x08,
-
- I_SCSI_RESET = 0x80,
- I_ILLEGAL = 0x40,
- I_DISCONNECT = 0x20,
- I_BUS = 0x10,
- I_FUNCTION = 0x08,
- I_RESELECTED = 0x04,
- I_SELECT_ATN = 0x02,
- I_SELECTED = 0x01,
-
- CM_NOP = 0x00,
- CM_FLUSH_FIFO = 0x01,
- CM_RESET = 0x02,
- CM_RESET_BUS = 0x03,
- CD_RESELECT = 0x40,
- CD_SELECT = 0x41,
- CD_SELECT_ATN = 0x42,
- CD_SELECT_ATN_STOP = 0x43,
- CD_ENABLE_SEL = 0x44,
- CD_DISABLE_SEL = 0x45,
- CT_SEND_MSG = 0x20,
- CT_SEND_STATUS = 0x21,
- CT_SEND_DATA = 0x22,
- CT_DISCONNECT_SEQ = 0x23,
- CT_TERMINATE = 0x24,
- CT_COMPLETE = 0x25,
- CT_DISCONNECT = 0x27,
- CT_RECV_MSG = 0x28,
- CT_RECV_CMD = 0x29,
- CT_RECV_DATA = 0x2a,
- CT_RECV_CMD_SEQ = 0x2b,
- CI_XFER = 0x10,
- CI_COMPLETE = 0x11,
- CI_MSG_ACCEPT = 0x12,
- CI_PAD = 0x18,
- CI_SET_ATN = 0x1a
- };
-
- enum { DMA_NONE, DMA_IN, DMA_OUT };
-
- emu_timer *tm;
-
- UINT8 command[2], config, status, istatus;
- UINT8 clock_conv, sync_offset, sync_period, bus_id, select_timeout, seq;
- UINT8 fifo[16];
- UINT16 tcount;
- int mode, fifo_pos, command_pos;
- int state, xfr_phase;
- int command_length;
-
- int dma_dir;
-
- bool irq, drq;
-
- void dma_set(int dir);
- void drq_set();
- void drq_clear();
-
- void start_command();
- void step(bool timeout);
- bool check_valid_command(UINT8 cmd);
- int derive_msg_size(UINT8 msg_id);
- void function_complete();
- void function_bus_complete();
- void bus_complete();
-
- void arbitrate();
- void command_pop_and_chain();
- void check_irq();
-
- void reset_soft();
- void reset_disconnect();
-
- UINT8 fifo_pop();
- void fifo_push(UINT8 val);
- void send_byte();
- void recv_byte();
-
- void delay(int cycles);
- void delay_cycles(int cycles);
-
- devcb_write_line m_irq_handler;
- devcb_write_line m_drq_handler;
-};
-
-extern const device_type NCR5390;
-
-#endif
diff --git a/src/emu/machine/ncr539x.c b/src/emu/machine/ncr539x.c
deleted file mode 100644
index fe1fd9919e1..00000000000
--- a/src/emu/machine/ncr539x.c
+++ /dev/null
@@ -1,831 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*
- * ncr539x.c
- *
- * NCR 53(CF)94/53(CF)96 SCSI controller
- * Includes enhanced features of the AMD 53CF94/96 and compatibles
- *
- * All new emulation in 2011 by R. Belmont.
- *
- */
-
-#include "emu.h"
-#include "ncr539x.h"
-
-#define VERBOSE (0)
-#define VERBOSE_READS (0)
-
-enum
-{
- TIMER_539X_COMMAND,
-
- TIMER_539X_END
-};
-
-#define MAIN_STATUS_INTERRUPT 0x80
-#define MAIN_STATUS_ILLEGAL_OPER 0x40
-#define MAIN_STATUS_PARITY_ERROR 0x20
-#define MAIN_STATUS_COUNT_TO_ZERO 0x10
-#define MAIN_STATUS_GROUP_VALID 0x08
-#define MAIN_STATUS_MESSAGE 0x04
-#define MAIN_STATUS_CMD_DATA 0x02
-#define MAIN_STATUS_IO 0x01
-
-#define IRQ_STATUS_RESET 0x80
-#define IRQ_STATUS_INVALID_COMMAND 0x40
-#define IRQ_STATUS_DISCONNECTED 0x20
-#define IRQ_STATUS_SERVICE_REQUEST 0x10
-#define IRQ_STATUS_SUCCESS 0x08
-#define IRQ_STATUS_RESELECTED 0x04 // we were reselected as a target
-#define IRQ_STATUS_SELECTED_WITH_ATN 0x02 // we were selected as a target with ATN steps
-#define IRQ_STATUS_SELECTED 0x01 // we were selected as a target
-
-#define CR2_ALIGN_ENABLE 0x80
-#define CR2_FEATURES_ENABLE 0x40
-#define CR2_BYTE_ORDER 0x20
-#define CR2_TRISTATE_DMA 0x10
-#define CR2_SCSI2_ENABLE 0x08
-#define CR2_ABORT_ON_PARITY_ERROR 0x04
-#define CR2_GENERATE_REGISTER_PARITY 0x02
-#define CR2_GENERATE_DATA_PARITY 0x01
-
-#if VERBOSE
-#if VERBOSE_READS
-static const char *rdregs[16] = {
- "Transfer count LSB", // 0
- "Transfer count MSB", // 1
- "FIFO", // 2
- "Command", // 3
- "Status", // 4
- "Interrupt Status", // 5
- "Internal State", // 6
- "Current FIFO/Internal State", // 7
- "Control Register 1", // 8
- "0x9",
- "0xA",
- "Control Register 2",
- "Control Register 3",
- "Control Register 4",
- "Transfer count HSB/Chip ID",
- "0xF"
-};
-#endif
-
-static const char *wrregs[16] = {
- "Start Transfer count LSB",
- "Start Transfer count MSB",
- "FIFO",
- "Command",
- "SCSI Destination ID",
- "SCSI Timeout",
- "Synchronous Transfer Period",
- "Synchronous Offset",
- "Control Register 1",
- "Clock Factor",
- "Forced Test Mode",
- "Control Register 2",
- "Control Register 3",
- "Control Register 4",
- "Start Transfer count HSB",
- "Data Alignment"
-};
-#endif
-
-// get the length of a SCSI command based on its command byte type
-static int get_cmd_len(int cbyte)
-{
- int group;
-
- group = (cbyte>>5) & 7;
-
- if (group == 0) return 6;
- if (group == 1 || group == 2) return 10;
- if (group == 5) return 12;
-
- return 6;
-}
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-const device_type NCR539X = &device_creator<ncr539x_device>;
-
-//-------------------------------------------------
-// ncr539x_device - constructor/destructor
-//-------------------------------------------------
-
-ncr539x_device::ncr539x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- legacy_scsi_host_adapter(mconfig, NCR539X, "539x SCSI", tag, owner, clock, "ncr539x", __FILE__),
- m_out_irq_cb(*this),
- m_out_drq_cb(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ncr539x_device::device_start()
-{
- legacy_scsi_host_adapter::device_start();
-
- // resolve line callbacks
- m_out_irq_cb.resolve_safe();
- m_out_drq_cb.resolve_safe();
-
- m_operation_timer = timer_alloc(0, NULL);
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void ncr539x_device::device_reset()
-{
- m_fifo_ptr = 0;
- m_fifo_read_ptr = 0;
- m_irq_status = 0;
- m_status = SCSI_PHASE_STATUS;
- m_internal_state = 0;
- m_buffer_offset = 512;
- m_buffer_remaining = 0;
- m_dma_size = 0;
- m_xfer_count = 0;
- m_total_data = 0;
- m_selected = false;
- m_control1 = m_control2 = m_control3 = m_control4 = 0;
- m_chipid_available = false;
- m_chipid_lock = false;
-
- m_out_irq_cb(CLEAR_LINE);
- m_out_drq_cb(CLEAR_LINE);
-}
-
-void ncr539x_device::dma_read_data(int bytes, UINT8 *pData)
-{
- read_data(pData, bytes);
-}
-
-
-void ncr539x_device::dma_write_data(int bytes, UINT8 *pData)
-{
- write_data(pData, bytes);
-}
-
-void ncr539x_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
-{
- //printf("539X: device_timer expired, param = %d, m_command = %02x\n", param, m_command);
-
- switch (param)
- {
- case TIMER_539X_COMMAND:
- // if this is a DMA command, raise DRQ now
- if (m_command & 0x80)
- {
- m_out_drq_cb(ASSERT_LINE);
- }
-
- switch (m_command & 0x7f)
- {
- case 0x41: // select without ATN steps
- if (select(m_last_id))
- {
- m_irq_status |= IRQ_STATUS_SERVICE_REQUEST | IRQ_STATUS_SUCCESS;
- // we should now be in the command phase
- m_status &= ~7; // clear bus phases
- m_status |= MAIN_STATUS_INTERRUPT | SCSI_PHASE_COMMAND;
- m_fifo_ptr = 0;
- m_selected = true;
-
- #if VERBOSE
- printf("Selecting w/o ATN, irq_status = %02x, status = %02x!\n", m_irq_status, m_status);
- #endif
-
- // if DMA is not enabled, there should already be a command loaded into the FIFO
- if (!(m_command & 0x80))
- {
- exec_fifo();
- }
- update_fifo_internal_state(0);
- }
- else
- {
- #if VERBOSE
- printf("Select failed, no device @ ID %d!\n", m_last_id);
- #endif
- m_status |= MAIN_STATUS_INTERRUPT;
- m_irq_status |= IRQ_STATUS_DISCONNECTED;
- }
- m_out_irq_cb(ASSERT_LINE);
- break;
-
- case 0x42: // Select with ATN steps
- if (select(m_last_id))
- {
- m_irq_status |= IRQ_STATUS_SERVICE_REQUEST | IRQ_STATUS_SUCCESS;
- // we should now be in the command phase
- m_status &= ~7; // clear bus phases
- m_status |= MAIN_STATUS_INTERRUPT | SCSI_PHASE_COMMAND;
- m_fifo_ptr = 0;
- m_selected = true;
- #if VERBOSE
- printf("Selecting with ATN, irq_status = %02x, status = %02x!\n", m_irq_status, m_status);
- #endif
-
- // if DMA is not enabled, there should already be a command loaded into the FIFO
- if (!(m_command & 0x80))
- {
- exec_fifo();
- }
- update_fifo_internal_state(0);
- }
- else
- {
- #if VERBOSE
- printf("Select failed, no device @ ID %d!\n", m_last_id);
- #endif
- m_status |= MAIN_STATUS_INTERRUPT;
- m_irq_status |= IRQ_STATUS_DISCONNECTED;
- }
- m_out_irq_cb(ASSERT_LINE);
- break;
-
- case 0x11: // initiator command complete
- #if VERBOSE
- printf("Initiator command complete\n");
- #endif
- m_irq_status = IRQ_STATUS_SERVICE_REQUEST;
- m_status &= ~7; // clear phase bits
- m_status |= MAIN_STATUS_INTERRUPT | SCSI_PHASE_DATAIN; // go to data in phase (?)
- m_out_irq_cb(ASSERT_LINE);
-
- // this puts status and message bytes into the FIFO (todo: what are these?)
- m_fifo_ptr = 0;
- m_xfer_count = 2;
- m_buffer_remaining = m_total_data = 0;
- m_fifo[0] = 0; // status byte
- m_fifo[1] = 0; // message byte
- m_selected = false;
- update_fifo_internal_state(2);
- break;
-
- case 0x12: // message accepted
- #if VERBOSE
- printf("Message accepted\n");
- #endif
- m_irq_status = IRQ_STATUS_SERVICE_REQUEST;
- m_status |= MAIN_STATUS_INTERRUPT;
- m_out_irq_cb(ASSERT_LINE);
- break;
-
- default:
- fatalerror("539x: Unhandled command %02x\n", m_command);
- }
- break;
-
- default:
- break;
- }
-}
-
-READ8_MEMBER( ncr539x_device::read )
-{
- UINT8 rv = 0;
-
- #if VERBOSE
- #if VERBOSE_READS
- printf("539x: Read @ %s (%02x) (PC=%x) (status %02x irq_status %02x)\n", rdregs[offset], offset, space.device().safe_pc(), m_status, m_irq_status);
- #endif
- #endif
-
- switch (offset)
- {
- case 0:
- rv = m_xfer_count & 0xff;
- break;
-
- case 1:
- rv = (m_xfer_count>>8) & 0xff;
- break;
-
- case 2: // FIFO
- {
- UINT8 fifo_bytes = m_fifo_internal_state & 0x1f;
-
- if (!fifo_bytes)
- {
- rv = 0;
- }
- else
- {
- rv = m_fifo[m_fifo_read_ptr++];
- m_fifo_read_ptr &= (m_fifo_size-1);
-
- fifo_bytes--;
- m_xfer_count--;
- update_fifo_internal_state(fifo_bytes);
-
- #if VERBOSE
- printf("Read %02x from FIFO[%d], FIFO now contains %d bytes (PC=%x, m_buffer_remaining %x)\n", rv, m_fifo_read_ptr-1, fifo_bytes, space.device().safe_pc(), m_buffer_remaining);
- #endif
-
- if (fifo_bytes == 0)
- {
- // the last transfer command has more data for us
- if (m_xfer_count > 0)
- {
- int fifo_fill_size = m_fifo_size;
- if (m_xfer_count < fifo_fill_size)
- {
- fifo_fill_size = m_xfer_count;
- }
- assert(m_buffer_offset < m_buffer_size);
- assert((m_buffer_offset + fifo_fill_size) <= m_buffer_size);
- memcpy(m_fifo, &m_buffer[m_buffer_offset], fifo_fill_size);
- m_buffer_offset += fifo_fill_size;
- m_buffer_remaining -= fifo_fill_size;
- m_fifo_ptr = 0;
- update_fifo_internal_state(fifo_fill_size);
- #if VERBOSE
- printf("Refreshing FIFO (%x remaining from transfer, %x in buffer, %x in total)\n", m_xfer_count, m_buffer_remaining, m_total_data);
- #endif
- }
- else
- {
- #if VERBOSE
- printf("FIFO empty, asserting service request (buffer_remaining %x)\n", m_buffer_remaining);
- #endif
- m_irq_status = IRQ_STATUS_SERVICE_REQUEST;
- m_status &= 0x7; // clear everything but the phase bits
- m_status |= MAIN_STATUS_INTERRUPT | MAIN_STATUS_COUNT_TO_ZERO;
- m_out_irq_cb(ASSERT_LINE);
-
- // if no data at all, drop the phase
- if ((m_buffer_remaining + m_total_data) == 0)
- {
- #if VERBOSE
- printf("Out of data, setting phase STATUS\n");
- #endif
- m_status &= ~0x7;
- m_status |= SCSI_PHASE_STATUS;
- }
- }
- }
- }
- }
- break;
-
- case 3:
- rv = m_command;
- break;
-
- case 4:
- rv = m_status;
- break;
-
- case 5:
- rv = m_irq_status;
- // clear the interrupt state
- m_status &= ~MAIN_STATUS_INTERRUPT;
- m_out_irq_cb(CLEAR_LINE);
- break;
-
- case 6:
- rv = m_internal_state;
- break;
-
- case 7:
- rv = m_fifo_internal_state;
- break;
-
- case 8:
- rv = m_control1;
- break;
-
- case 0xb:
- rv = m_control2;
- break;
-
- case 0xc:
- rv = m_control3;
- break;
-
- case 0xd:
- rv = m_control4;
- break;
-
- case 0xe:
- if (m_control2 & CR2_FEATURES_ENABLE)
- {
- if (m_chipid_available)
- {
- rv = 0xa2; // 0x12 for CF94, 0xa2 for CF96
- }
- else
- {
- rv = (m_xfer_count>>16) & 0xff;
- }
- }
- break;
-
- }
- return rv;
-}
-
-WRITE8_MEMBER( ncr539x_device::write )
-{
- #if VERBOSE
- //if (offset != 2)
- printf("539x: Write %02x @ %s (%02x) (PC=%x)\n", data, wrregs[offset], offset, space.device().safe_pc());
- #endif
-
- switch (offset)
- {
- case 0:
- m_dma_size &= 0xff00;
- m_dma_size |= data;
- break;
-
- case 1:
- m_dma_size &= 0x00ff;
- m_dma_size |= (data<<8);
- break;
-
- case 2: // FIFO
- fifo_write(data);
- break;
-
- case 3:
- m_command = data;
-
- // clear status bits (OK to do here?)
- m_status &= ~MAIN_STATUS_INTERRUPT;
- m_irq_status = 0;
-
- switch (data & 0x7f)
- {
- case 0x00: // NOP
- m_irq_status = IRQ_STATUS_SUCCESS;
- m_status |= MAIN_STATUS_INTERRUPT;
- m_out_irq_cb(ASSERT_LINE);
-
- // DMA NOP? allow chip ID
- if ((m_command == 0x80) && (!m_chipid_lock))
- {
- m_chipid_available = true;
- }
- break;
-
- case 0x01: // Clear FIFO (must not change buffer state)
- m_fifo_ptr = 0;
- update_fifo_internal_state(0);
- m_irq_status = IRQ_STATUS_SUCCESS;
- m_status |= MAIN_STATUS_INTERRUPT;
- m_out_irq_cb(ASSERT_LINE);
- break;
-
- case 0x02: // Reset device
- device_reset();
-
- m_irq_status = IRQ_STATUS_SUCCESS;
- m_status |= MAIN_STATUS_INTERRUPT;
- m_out_irq_cb(ASSERT_LINE);
- break;
-
- case 0x03: // Reset SCSI bus
- m_status = 0;
- m_irq_status = IRQ_STATUS_SUCCESS;
- m_status |= MAIN_STATUS_INTERRUPT;
- m_out_irq_cb(ASSERT_LINE);
- break;
-
- case 0x10: // information transfer (must happen immediately)
- m_status &= 0x7; // clear everything but the phase bits
- m_status |= MAIN_STATUS_INTERRUPT;
- m_irq_status = IRQ_STATUS_SUCCESS;
-
- int phase;
- phase = get_phase();
-
- #if VERBOSE
- printf("Information transfer: phase %d buffer remaining %x\n", phase, m_buffer_remaining);
- #endif
-
- if (phase == SCSI_PHASE_DATAIN) // target -> initiator transfer
- {
- int amtToGet = m_buffer_size;
-
- // fill the internal sector buffer
- if (m_buffer_remaining <= 0)
- {
- if (m_total_data < m_buffer_size)
- {
- amtToGet = m_total_data;
- }
-
- #if VERBOSE
- printf("amtToGet = %x\n", amtToGet);
- #endif
-
- if (amtToGet > 0)
- {
- read_data(m_buffer, amtToGet);
-
- m_total_data -= amtToGet;
- m_buffer_offset = 0;
- m_buffer_remaining = amtToGet;
- }
- }
-
- // copy the requested amount into the FIFO
- if (amtToGet > 0)
- {
- if (m_buffer_remaining < m_dma_size)
- {
- m_dma_size = m_buffer_remaining;
- }
-
- int fifo_fill_size = m_fifo_size;
-
- if (m_dma_size < fifo_fill_size)
- {
- fifo_fill_size = m_dma_size;
- }
-
- #if VERBOSE
- printf("filling FIFO from buffer[%x] for %x bytes\n", m_buffer_offset, fifo_fill_size);
- #endif
-
- memcpy(m_fifo, &m_buffer[m_buffer_offset], fifo_fill_size);
- m_buffer_offset += fifo_fill_size;
- m_buffer_remaining -= fifo_fill_size;
-
- m_xfer_count = m_dma_size;
- m_fifo_ptr = 0;
- update_fifo_internal_state(fifo_fill_size);
- m_out_drq_cb(ASSERT_LINE);
- }
-
- m_status |= MAIN_STATUS_COUNT_TO_ZERO;
-
- #if VERBOSE
- printf("Information transfer: put %02x bytes into FIFO (dma size %x) (buffer remaining %x)\n", m_fifo_internal_state & 0x1f, m_dma_size, m_buffer_remaining);
- #endif
- }
- else if (phase == SCSI_PHASE_DATAOUT)
- {
- m_xfer_count = m_dma_size;
- if (m_xfer_count == 0)
- {
- m_xfer_count = 0x10000;
- }
- #if VERBOSE
- printf("dma_size %x, xfer_count %x\n", m_dma_size, m_xfer_count);
- #endif
- m_status &= ~MAIN_STATUS_COUNT_TO_ZERO;
- m_fifo_ptr = 0;
- m_buffer_offset = 0;
- m_buffer_remaining = 0;
- }
- m_out_irq_cb(ASSERT_LINE);
- break;
-
- case 0x24: // Terminate steps
- #if VERBOSE
- printf("Terminate steps\n");
- #endif
- m_irq_status = IRQ_STATUS_SUCCESS | IRQ_STATUS_DISCONNECTED;
- m_status |= MAIN_STATUS_INTERRUPT;
- m_out_irq_cb(ASSERT_LINE);
- m_fifo_ptr = 0;
- update_fifo_internal_state(0);
- break;
-
- case 0x27: // Disconnect
- #if VERBOSE
- printf("Disconnect\n");
- #endif
- m_irq_status = IRQ_STATUS_SUCCESS;
- m_status |= MAIN_STATUS_INTERRUPT;
- m_out_irq_cb(ASSERT_LINE);
- break;
-
- case 0x44: // Enable selection/reselection
- #if VERBOSE
- printf("Enable selection/reselection\n");
- #endif
- m_irq_status = IRQ_STATUS_SUCCESS;
- m_status |= MAIN_STATUS_INTERRUPT;
- m_out_irq_cb(ASSERT_LINE);
- break;
-
- case 0x47: // Reselect with ATN3 steps
- if (select(m_last_id))
- {
- m_irq_status |= IRQ_STATUS_SERVICE_REQUEST | IRQ_STATUS_SUCCESS;
- // we should now be in the command phase
- m_status &= ~7; // clear bus phases
- m_status |= MAIN_STATUS_INTERRUPT | SCSI_PHASE_COMMAND;
- m_fifo_ptr = 0;
- m_selected = true;
- #if VERBOSE
- printf("Reselecting with ATN3, irq_status = %02x, status = %02x!\n", m_irq_status, m_status);
- #endif
-
- // if DMA is not enabled, there should already be a command loaded into the FIFO
- if (!(m_command & 0x80))
- {
- exec_fifo();
- }
- update_fifo_internal_state(0);
- }
- else
- {
- #if VERBOSE
- printf("Reselect with ATN3 failed, no device @ ID %d!\n", m_last_id);
- #endif
- m_status |= MAIN_STATUS_INTERRUPT;
- m_irq_status |= IRQ_STATUS_DISCONNECTED;
- }
- m_out_irq_cb(ASSERT_LINE);
- break;
-
- default: // other commands are not instantaneous
- #if VERBOSE
- printf("Setting timer for command %02x\n", data);
- #endif
- // 1x commands happen much faster
- if ((m_command & 0x70) == 0x10)
- {
- m_operation_timer->adjust(attotime::from_hz(65536), TIMER_539X_COMMAND);
- }
- else
- {
- m_operation_timer->adjust(attotime::from_hz(16384), TIMER_539X_COMMAND);
- }
- break;
- }
- break;
-
- case 4:
- m_last_id = data;
- break;
-
- case 5:
- m_timeout = data;
- break;
-
- case 6:
- m_sync_xfer_period = data;
- break;
-
- case 7:
- m_sync_offset = data;
- break;
-
- case 8:
- m_control1 = data;
- break;
-
- case 9:
- m_clock_factor = data;
- break;
-
- case 0xa:
- m_forced_test = data;
- break;
-
- case 0xb:
- m_control2 = data;
- break;
-
- case 0xc:
- m_control3 = data;
- break;
-
- case 0xd:
- m_control4 = data;
- break;
-
- case 0xe:
- if (m_control2 & CR2_FEATURES_ENABLE)
- {
- m_dma_size &= 0xffff;
- m_dma_size |= (data<<16);
- m_chipid_available = false;
- m_chipid_lock = true;
- }
- break;
-
- case 0xf:
- m_data_alignment = data;
- break;
- }
-}
-
-void ncr539x_device::exec_fifo()
-{
- int length, phase;
-
- send_command(&m_fifo[0], 12);
- length = get_length();
- phase = get_phase();
-
- #if VERBOSE
- printf("Command executed (id %d), new phase %d, length %x\n", m_last_id, phase, length);
- #endif
-
- m_buffer_offset = m_buffer_size;
- m_buffer_remaining = 0;
- m_total_data = length;
-
- m_status &= ~7; // clear bus phases
- m_status |= (phase & 7); // set the phase reported by the device
-}
-
-void ncr539x_device::check_fifo_executable()
-{
- if (get_cmd_len(m_fifo[0]) == m_fifo_ptr)
- {
- exec_fifo();
- }
-}
-
-void ncr539x_device::fifo_write(UINT8 data)
-{
- int phase = (m_status & 7);
-
- if (phase != SCSI_PHASE_DATAOUT)
- {
- #if VERBOSE
- printf("539x: Write %02x @ FIFO[%x]\n", data, m_fifo_ptr);
- #endif
- m_fifo[m_fifo_ptr++] = data;
- update_fifo_internal_state(m_fifo_ptr);
-
- if (m_selected)
- {
- check_fifo_executable();
- }
- }
- else // phase is DATAOUT
- {
- m_buffer[m_buffer_offset++] = data;
- m_xfer_count--;
- m_total_data--;
- #if VERBOSE
- printf("539x: Write %02x @ buffer[%x], xfer_count %x, total %x\n", data, m_buffer_offset-1, m_xfer_count, m_total_data);
- #endif
-
- // default to flushing our entire buffer
- int flush_size = m_buffer_size;
-
- // if the actual size is less than the buffer size, flush that instead
- if (m_dma_size < m_buffer_size)
- {
- flush_size = m_dma_size;
- }
-
- if ((m_buffer_offset == flush_size) || (m_xfer_count == 0))
- {
- #if VERBOSE
- printf("Flushing buffer to device, %x bytes left in buffer (%x total)\n", m_xfer_count, m_total_data);
- #endif
- write_data(m_buffer, flush_size);
- m_buffer_offset = 0;
-
- // need a service request here too
- m_irq_status = IRQ_STATUS_SERVICE_REQUEST;
- m_status &= 7;
- m_status |= MAIN_STATUS_INTERRUPT;
- m_out_irq_cb(ASSERT_LINE);
- }
-
- if ((m_xfer_count == 0) && (m_total_data == 0))
- {
- #if VERBOSE
- printf("End of write, asserting service request\n");
- #endif
-
- m_buffer_offset = 0;
- m_irq_status = IRQ_STATUS_SERVICE_REQUEST;
- m_status = MAIN_STATUS_INTERRUPT | SCSI_PHASE_STATUS;
- m_out_irq_cb(ASSERT_LINE);
- }
- }
-}
-
-void ncr539x_device::update_fifo_internal_state(int bytes)
-{
- if (bytes >= 0x1f)
- {
- m_fifo_internal_state |= 0x1f;
- }
- else
- {
- m_fifo_internal_state &= ~0x1f;
- m_fifo_internal_state |= (bytes & 0x1f);
- }
-}
diff --git a/src/emu/machine/ncr539x.h b/src/emu/machine/ncr539x.h
deleted file mode 100644
index 2280613d22f..00000000000
--- a/src/emu/machine/ncr539x.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*
- * ncr5394/5396.h SCSI controller
- *
- */
-
-#ifndef _NCR539x_H_
-#define _NCR539x_H_
-
-#include "legscsi.h"
-
-//// 539x registers
-//enum
-//{
-//};
-
-// device stuff
-
-#define MCFG_NCR539X_OUT_IRQ_CB(_devcb) \
- devcb = &ncr539x_device::set_out_irq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_NCR539X_OUT_DRQ_CB(_devcb) \
- devcb = &ncr539x_device::set_out_drq_callback(*device, DEVCB_##_devcb);
-
-class ncr539x_device : public legacy_scsi_host_adapter
-{
-public:
- // construction/destruction
- ncr539x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<ncr539x_device &>(device).m_out_irq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_drq_callback(device_t &device, _Object object) { return downcast<ncr539x_device &>(device).m_out_drq_cb.set_callback(object); }
-
- // our API
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- void dma_read_data(int bytes, UINT8 *pData);
- void dma_write_data(int bytes, UINT8 *pData);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- void fifo_write(UINT8 data);
- void check_fifo_executable();
- void exec_fifo();
- void update_fifo_internal_state(int bytes);
-
- UINT32 m_xfer_count;
- UINT32 m_dma_size;
- UINT8 m_command;
- UINT8 m_last_id;
- UINT8 m_timeout;
- UINT8 m_sync_xfer_period;
- UINT8 m_sync_offset;
- UINT8 m_control1, m_control2, m_control3, m_control4;
- UINT8 m_clock_factor;
- UINT8 m_forced_test;
- UINT8 m_data_alignment;
-
- bool m_selected;
- bool m_chipid_available, m_chipid_lock;
-
- static const int m_fifo_size = 16;
- UINT8 m_fifo_ptr, m_fifo_read_ptr, m_fifo[m_fifo_size];
-
- //int m_xfer_remaining; // amount in the FIFO when we're in data in phase
-
- // read-only registers
- UINT8 m_status, m_irq_status, m_internal_state, m_fifo_internal_state;
-
- static const int m_buffer_size = 2048;
-
- UINT8 m_buffer[m_buffer_size];
- int m_buffer_offset, m_buffer_remaining, m_total_data;
-
- emu_timer *m_operation_timer;
-
- devcb_write_line m_out_irq_cb; /* IRQ line */
- devcb_write_line m_out_drq_cb; /* DRQ line */
-};
-
-// device type definition
-extern const device_type NCR539X;
-#endif
diff --git a/src/emu/machine/netlist.c b/src/emu/machine/netlist.c
deleted file mode 100644
index cdbfe89d91b..00000000000
--- a/src/emu/machine/netlist.c
+++ /dev/null
@@ -1,660 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Couriersud
-/***************************************************************************
-
- netlist.c
-
- Discrete netlist implementation.
-
-****************************************************************************/
-
-#include "emu.h"
-#include "netlist.h"
-#include "netlist/nl_base.h"
-#include "netlist/nl_setup.h"
-#include "netlist/nl_factory.h"
-#include "netlist/nl_parser.h"
-#include "netlist/devices/net_lib.h"
-#include "debugger.h"
-
-//#define LOG_DEV_CALLS(x) printf x
-#define LOG_DEV_CALLS(x) do { } while (0)
-
-const device_type NETLIST_CORE = &device_creator<netlist_mame_device_t>;
-const device_type NETLIST_CPU = &device_creator<netlist_mame_cpu_device_t>;
-const device_type NETLIST_SOUND = &device_creator<netlist_mame_sound_device_t>;
-
-/* subdevices */
-
-const device_type NETLIST_ANALOG_INPUT = &device_creator<netlist_mame_analog_input_t>;
-const device_type NETLIST_LOGIC_INPUT = &device_creator<netlist_mame_logic_input_t>;
-const device_type NETLIST_STREAM_INPUT = &device_creator<netlist_mame_stream_input_t>;
-
-const device_type NETLIST_ANALOG_OUTPUT = &device_creator<netlist_mame_analog_output_t>;
-const device_type NETLIST_STREAM_OUTPUT = &device_creator<netlist_mame_stream_output_t>;
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_analog_input_t
-// ----------------------------------------------------------------------------------------
-
-void netlist_mame_sub_interface::static_set_mult_offset(device_t &device, const double mult, const double offset)
-{
- netlist_mame_sub_interface &netlist = dynamic_cast<netlist_mame_sub_interface &>(device);
- netlist.m_mult = mult;
- netlist.m_offset = offset;
-}
-
-
-netlist_mame_analog_input_t::netlist_mame_analog_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, NETLIST_ANALOG_INPUT, "Netlist Analog Input", tag, owner, clock, "netlist_analog_input", __FILE__),
- netlist_mame_sub_interface(*owner),
- m_param(0),
- m_auto_port(true),
- m_param_name("")
-{
-}
-
-void netlist_mame_analog_input_t::static_set_name(device_t &device, const char *param_name)
-{
- netlist_mame_analog_input_t &netlist = downcast<netlist_mame_analog_input_t &>(device);
- netlist.m_param_name = param_name;
-}
-
-void netlist_mame_analog_input_t::device_start()
-{
- LOG_DEV_CALLS(("start %s\n", tag()));
- netlist::param_t *p = this->nl_owner().setup().find_param(m_param_name);
- m_param = dynamic_cast<netlist::param_double_t *>(p);
- if (m_param == NULL)
- {
- fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr());
- }
- if (m_mult != 1.0 || m_offset != 0.0)
- {
- // disable automatic scaling for ioports
- m_auto_port = false;
- }
-
-}
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_analog_output_t
-// ----------------------------------------------------------------------------------------
-
-netlist_mame_analog_output_t::netlist_mame_analog_output_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, NETLIST_ANALOG_INPUT, "Netlist Analog Output", tag, owner, clock, "netlist_analog_output", __FILE__),
- netlist_mame_sub_interface(*owner),
- m_in("")
-{
-}
-
-void netlist_mame_analog_output_t::static_set_params(device_t &device, const char *in_name, netlist_analog_output_delegate adelegate)
-{
- netlist_mame_analog_output_t &netlist = downcast<netlist_mame_analog_output_t &>(device);
- netlist.m_in = in_name;
- netlist.m_delegate = adelegate;
-}
-
-void netlist_mame_analog_output_t::custom_netlist_additions(netlist::setup_t &setup)
-{
- pstring dname = "OUT_" + m_in;
- m_delegate.bind_relative_to(owner()->machine().root_device());
- NETLIB_NAME(analog_callback) *dev = downcast<NETLIB_NAME(analog_callback) *>(
- setup.register_dev("NETDEV_CALLBACK", dname));
-
- dev->register_callback(m_delegate);
- setup.register_link(dname + ".IN", m_in);
-}
-
-void netlist_mame_analog_output_t::device_start()
-{
- LOG_DEV_CALLS(("start %s\n", tag()));
-}
-
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_logic_input_t
-// ----------------------------------------------------------------------------------------
-
-netlist_mame_logic_input_t::netlist_mame_logic_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, NETLIST_ANALOG_INPUT, "Netlist Logic Input", tag, owner, clock, "netlist_logic_input", __FILE__),
- netlist_mame_sub_interface(*owner),
- m_param(0),
- m_mask(0xffffffff),
- m_shift(0),
- m_param_name("")
-{
-}
-
-void netlist_mame_logic_input_t::static_set_params(device_t &device, const char *param_name, const UINT32 mask, const UINT32 shift)
-{
- netlist_mame_logic_input_t &netlist = downcast<netlist_mame_logic_input_t &>(device);
- netlist.m_param_name = param_name;
- netlist.m_shift = shift;
- netlist.m_mask = mask;
-}
-
-void netlist_mame_logic_input_t::device_start()
-{
- LOG_DEV_CALLS(("start %s\n", tag()));
- netlist::param_t *p = downcast<netlist_mame_device_t *>(this->owner())->setup().find_param(m_param_name);
- m_param = dynamic_cast<netlist::param_int_t *>(p);
- if (m_param == NULL)
- {
- fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr());
- }
-}
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_stream_input_t
-// ----------------------------------------------------------------------------------------
-
-netlist_mame_stream_input_t::netlist_mame_stream_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, NETLIST_ANALOG_INPUT, "Netlist Stream Input", tag, owner, clock, "netlist_stream_input", __FILE__),
- netlist_mame_sub_interface(*owner),
- m_channel(0),
- m_param_name("")
-{
-}
-
-void netlist_mame_stream_input_t::static_set_params(device_t &device, int channel, const char *param_name)
-{
- netlist_mame_stream_input_t &netlist = downcast<netlist_mame_stream_input_t &>(device);
- netlist.m_param_name = param_name;
- netlist.m_channel = channel;
-}
-
-void netlist_mame_stream_input_t::device_start()
-{
- LOG_DEV_CALLS(("start %s\n", tag()));
-}
-
-void netlist_mame_stream_input_t::custom_netlist_additions(netlist::setup_t &setup)
-{
- NETLIB_NAME(sound_in) *snd_in = setup.netlist().get_first_device<NETLIB_NAME(sound_in)>();
- if (snd_in == NULL)
- snd_in = dynamic_cast<NETLIB_NAME(sound_in) *>(setup.register_dev("NETDEV_SOUND_IN", "STREAM_INPUT"));
-
- pstring sparam = pfmt("STREAM_INPUT.CHAN{1}")(m_channel);
- setup.register_param(sparam, m_param_name);
- sparam = pfmt("STREAM_INPUT.MULT{1}")(m_channel);
- setup.register_param(sparam, m_mult);
- sparam = pfmt("STREAM_INPUT.OFFSET{1}")(m_channel);
- setup.register_param(sparam, m_offset);
-}
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_stream_output_t
-// ----------------------------------------------------------------------------------------
-
-netlist_mame_stream_output_t::netlist_mame_stream_output_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, NETLIST_ANALOG_INPUT, "Netlist Stream Output", tag, owner, clock, "netlist_stream_output", __FILE__),
- netlist_mame_sub_interface(*owner),
- m_channel(0),
- m_out_name("")
-{
-}
-
-void netlist_mame_stream_output_t::static_set_params(device_t &device, int channel, const char *out_name)
-{
- netlist_mame_stream_output_t &netlist = downcast<netlist_mame_stream_output_t &>(device);
- netlist.m_out_name = out_name;
- netlist.m_channel = channel;
-}
-
-void netlist_mame_stream_output_t::device_start()
-{
- LOG_DEV_CALLS(("start %s\n", tag()));
-}
-
-void netlist_mame_stream_output_t::custom_netlist_additions(netlist::setup_t &setup)
-{
- //NETLIB_NAME(sound_out) *snd_out;
- pstring sname = pfmt("STREAM_OUT_{1}")(m_channel);
-
- //snd_out = dynamic_cast<NETLIB_NAME(sound_out) *>(setup.register_dev("nld_sound_out", sname));
- setup.register_dev("NETDEV_SOUND_OUT", sname);
-
- setup.register_param(sname + ".CHAN" , m_channel);
- setup.register_param(sname + ".MULT", m_mult);
- setup.register_param(sname + ".OFFSET", m_offset);
- setup.register_link(sname + ".IN", m_out_name);
-}
-
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_t
-// ----------------------------------------------------------------------------------------
-
-void netlist_mame_t::vlog(const plog_level &l, const pstring &ls) const
-{
- pstring errstr = ls;
-
- switch (l)
- {
- case DEBUG:
- logerror("netlist DEBUG: %s\n", errstr.cstr());
- break;
- case INFO:
- logerror("netlist INFO: %s\n", errstr.cstr());
- break;
- case VERBOSE:
- logerror("netlist VERBOSE: %s\n", errstr.cstr());
- break;
- case WARNING:
- logerror("netlist WARNING: %s\n", errstr.cstr());
- break;
- case ERROR:
- logerror("netlist ERROR: %s\n", errstr.cstr());
- break;
- case FATAL:
- emu_fatalerror error("netlist ERROR: %s\n", errstr.cstr());
- throw error;
- }
-}
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_device_t
-// ----------------------------------------------------------------------------------------
-
-static ADDRESS_MAP_START(program_dummy, AS_PROGRAM, 8, netlist_mame_device_t)
- AM_RANGE(0x000, 0x3ff) AM_ROM
-ADDRESS_MAP_END
-
-netlist_mame_device_t::netlist_mame_device_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, NETLIST_CORE, "Netlist core device", tag, owner, clock, "netlist_core", __FILE__),
- m_icount(0),
- m_old(netlist::netlist_time::zero),
- m_netlist(NULL),
- m_setup(NULL),
- m_setup_func(NULL)
-{
-}
-
-netlist_mame_device_t::netlist_mame_device_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *file)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, file),
- m_icount(0),
- m_old(netlist::netlist_time::zero),
- m_netlist(NULL),
- m_setup(NULL),
- m_setup_func(NULL)
-{
-}
-
-void netlist_mame_device_t::static_set_constructor(device_t &device, void (*setup_func)(netlist::setup_t &))
-{
- LOG_DEV_CALLS(("static_set_constructor\n"));
- netlist_mame_device_t &netlist = downcast<netlist_mame_device_t &>(device);
- netlist.m_setup_func = setup_func;
-}
-
-void netlist_mame_device_t::device_config_complete()
-{
- LOG_DEV_CALLS(("device_config_complete\n"));
-}
-
-void netlist_mame_device_t::device_start()
-{
- LOG_DEV_CALLS(("device_start %s\n", tag()));
-
- //printf("clock is %d\n", clock());
-
- m_netlist = global_alloc(netlist_mame_t(*this));
- m_setup = global_alloc(netlist::setup_t(m_netlist));
- netlist().init_object(*m_netlist, "netlist");
- m_setup->init();
-
- // register additional devices
-
- nl_register_devices();
-
- m_setup_func(*m_setup);
-
- /* let sub-devices tweak the netlist */
- for( device_t *d = this->first_subdevice(); d != NULL; d = d->next() )
- {
- netlist_mame_sub_interface *sdev = dynamic_cast<netlist_mame_sub_interface *>(d);
- if( sdev != NULL )
- {
- LOG_DEV_CALLS(("Found subdevice %s/%s\n", d->name(), d->shortname()));
- sdev->custom_netlist_additions(*m_setup);
- }
- }
-
- m_setup->start_devices();
- m_setup->resolve_inputs();
-
- netlist().save(NAME(m_rem));
- netlist().save(NAME(m_div));
- netlist().save(NAME(m_old));
-
- save_state();
-
- m_old = netlist::netlist_time::zero;
- m_rem = netlist::netlist_time::zero;
-
-}
-
-void netlist_mame_device_t::device_clock_changed()
-{
- m_div = netlist::netlist_time::from_hz(clock());
- netlist().log().debug("Setting clock {1} and divisor {2}\n", clock(), m_div.as_double());
-}
-
-
-void netlist_mame_device_t::device_reset()
-{
- LOG_DEV_CALLS(("device_reset\n"));
- m_old = netlist::netlist_time::zero;
- m_rem = netlist::netlist_time::zero;
- netlist().do_reset();
-}
-
-void netlist_mame_device_t::device_stop()
-{
- LOG_DEV_CALLS(("device_stop\n"));
- m_setup->print_stats();
-
- m_netlist->stop();
-
- global_free(m_setup);
- m_setup = NULL;
- global_free(m_netlist);
- m_netlist = NULL;
-}
-
-ATTR_COLD void netlist_mame_device_t::device_post_load()
-{
- LOG_DEV_CALLS(("device_post_load\n"));
-
- netlist().post_load();
- netlist().rebuild_lists();
-}
-
-ATTR_COLD void netlist_mame_device_t::device_pre_save()
-{
- LOG_DEV_CALLS(("device_pre_save\n"));
-
- netlist().pre_save();
-}
-
-void netlist_mame_device_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
-}
-
-ATTR_HOT ATTR_ALIGN void netlist_mame_device_t::update_time_x()
-{
- const netlist::netlist_time newt = netlist().time();
- const netlist::netlist_time delta = newt - m_old + m_rem;
- const UINT64 d = delta / m_div;
- m_old = newt;
- m_rem = delta - (m_div * d);
- m_icount -= d;
-}
-
-ATTR_HOT ATTR_ALIGN void netlist_mame_device_t::check_mame_abort_slice()
-{
- if (m_icount <= 0)
- netlist().abort_current_queue_slice();
-}
-
-ATTR_COLD void netlist_mame_device_t::save_state()
-{
- for (int i=0; i< netlist().save_list().size(); i++)
- {
- pstate_entry_t *s = netlist().save_list()[i];
- netlist().log().debug("saving state for {1}\n", s->m_name.cstr());
- switch (s->m_dt)
- {
- case DT_DOUBLE:
- {
- double *td = s->resolved<double>();
- if (td != NULL) save_pointer(td, s->m_name.cstr(), s->m_count);
- }
- break;
- case DT_FLOAT:
- {
- float *td = s->resolved<float>();
- if (td != NULL) save_pointer(td, s->m_name.cstr(), s->m_count);
- }
- break;
-#if (PHAS_INT128)
- case DT_INT128:
- // FIXME: we are cheating here
- save_pointer((char *) s->m_ptr, s->m_name.cstr(), s->m_count * sizeof(INT128));
- break;
-#endif
- case DT_INT64:
- save_pointer((INT64 *) s->m_ptr, s->m_name.cstr(), s->m_count);
- break;
- case DT_INT16:
- save_pointer((INT16 *) s->m_ptr, s->m_name.cstr(), s->m_count);
- break;
- case DT_INT8:
- save_pointer((INT8 *) s->m_ptr, s->m_name.cstr(), s->m_count);
- break;
- case DT_INT:
- save_pointer((int *) s->m_ptr, s->m_name.cstr(), s->m_count);
- break;
- case DT_BOOLEAN:
- save_pointer((bool *) s->m_ptr, s->m_name.cstr(), s->m_count);
- break;
- case DT_CUSTOM:
- break;
- case NOT_SUPPORTED:
- default:
- netlist().log().fatal("found unsupported save element %s\n", s->m_name);
- break;
- }
- }
-
-}
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_cpu_device_t
-// ----------------------------------------------------------------------------------------
-
-netlist_mame_cpu_device_t::netlist_mame_cpu_device_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : netlist_mame_device_t(mconfig, NETLIST_CPU, "Netlist CPU Device", tag, owner, clock, "netlist_cpu", __FILE__),
- device_execute_interface(mconfig, *this),
- device_state_interface(mconfig, *this),
- device_disasm_interface(mconfig, *this),
- device_memory_interface(mconfig, *this),
- m_program_config("program", ENDIANNESS_LITTLE, 8, 12, 0, ADDRESS_MAP_NAME(program_dummy))
-{
-}
-
-
-void netlist_mame_cpu_device_t::device_start()
-{
- netlist_mame_device_t::device_start();
-
- LOG_DEV_CALLS(("cpu device_start %s\n", tag()));
-
- // State support
-
- state_add(STATE_GENPC, "curpc", m_genPC).noshow();
-
- for (int i=0; i < netlist().m_nets.size(); i++)
- {
- netlist::net_t *n = netlist().m_nets[i];
- if (n->isFamily(netlist::object_t::LOGIC))
- {
- state_add(i*2, n->name().cstr(), downcast<netlist::logic_net_t *>(n)->Q_state_ptr());
- }
- else
- {
- state_add(i*2+1, n->name().cstr(), downcast<netlist::analog_net_t *>(n)->Q_Analog_state_ptr()).formatstr("%20s");
- }
- }
-
- // set our instruction counter
- m_icountptr = &m_icount;
-}
-
-
-void netlist_mame_cpu_device_t::nl_register_devices()
-{
- setup().factory().register_device<nld_analog_callback>( "NETDEV_CALLBACK", "nld_analog_callback", "-");
-}
-
-ATTR_COLD UINT64 netlist_mame_cpu_device_t::execute_clocks_to_cycles(UINT64 clocks) const
-{
- return clocks;
-}
-
-ATTR_COLD UINT64 netlist_mame_cpu_device_t::execute_cycles_to_clocks(UINT64 cycles) const
-{
- return cycles;
-}
-
-ATTR_COLD offs_t netlist_mame_cpu_device_t::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options)
-{
- //char tmp[16];
- unsigned startpc = pc;
- int relpc = pc - m_genPC;
- if (relpc >= 0 && relpc < netlist().queue().count())
- {
- int dpc = netlist().queue().count() - relpc - 1;
- // FIXME: 50 below fixes crash in mame-debugger. It's based on try on error.
- snprintf(buffer, 50, "%c %s @%10.7f", (relpc == 0) ? '*' : ' ', netlist().queue()[dpc].object()->name().cstr(),
- netlist().queue()[dpc].exec_time().as_double());
- }
- else
- sprintf(buffer, "%s", "");
-
- pc+=1;
- return (pc - startpc);
-}
-
-ATTR_HOT void netlist_mame_cpu_device_t::execute_run()
-{
- bool check_debugger = ((device_t::machine().debug_flags & DEBUG_FLAG_ENABLED) != 0);
- // debugging
- //m_ppc = m_pc; // copy PC to previous PC
- if (check_debugger)
- {
- while (m_icount > 0)
- {
- m_genPC++;
- m_genPC &= 255;
- debugger_instruction_hook(this, m_genPC);
- netlist().process_queue(m_div);
- update_time_x();
- }
- }
- else
- {
- netlist().process_queue(m_div * m_icount);
- update_time_x();
- }
-}
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_sound_device_t
-// ----------------------------------------------------------------------------------------
-
-netlist_mame_sound_device_t::netlist_mame_sound_device_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : netlist_mame_device_t(mconfig, NETLIST_CPU, "Netlist Sound Device", tag, owner, clock, "netlist_sound", __FILE__),
- device_sound_interface(mconfig, *this)
-{
-}
-
-void netlist_mame_sound_device_t::device_start()
-{
- netlist_mame_device_t::device_start();
-
- LOG_DEV_CALLS(("sound device_start %s\n", tag()));
-
- // Configure outputs
-
- plist_t<nld_sound_out *> outdevs = netlist().get_device_list<nld_sound_out>();
- if (outdevs.size() == 0)
- fatalerror("No output devices");
-
- m_num_outputs = outdevs.size();
-
- /* resort channels */
- for (int i=0; i < MAX_OUT; i++) m_out[i] = NULL;
- for (int i=0; i < m_num_outputs; i++)
- {
- int chan = outdevs[i]->m_channel.Value();
-
- netlist().log().verbose("Output %d on channel %d", i, chan);
-
- if (chan < 0 || chan >= MAX_OUT || chan >= outdevs.size())
- fatalerror("illegal channel number");
- m_out[chan] = outdevs[i];
- m_out[chan]->m_sample = netlist::netlist_time::from_hz(clock());
- m_out[chan]->m_buffer = NULL;
- }
-
- // Configure inputs
-
- m_num_inputs = 0;
- m_in = NULL;
-
- plist_t<nld_sound_in *> indevs = netlist().get_device_list<nld_sound_in>();
- if (indevs.size() > 1)
- fatalerror("A maximum of one input device is allowed!");
- if (indevs.size() == 1)
- {
- m_in = indevs[0];
- m_num_inputs = m_in->resolve();
- m_in->m_inc = netlist::netlist_time::from_hz(clock());
- }
-
- /* initialize the stream(s) */
- m_stream = machine().sound().stream_alloc(*this, m_num_inputs, m_num_outputs, clock());
-
-}
-
-void netlist_mame_sound_device_t::nl_register_devices()
-{
- setup().factory().register_device<nld_sound_out>("NETDEV_SOUND_OUT", "nld_sound_out", "+CHAN");
- setup().factory().register_device<nld_sound_in>("NETDEV_SOUND_IN", "nld_sound_in", "-");
-}
-
-
-void netlist_mame_sound_device_t::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
-{
- for (int i=0; i < m_num_outputs; i++)
- {
- m_out[i]->m_buffer = outputs[i];
- }
-
- if (m_num_inputs)
- m_in->buffer_reset();
-
- for (int i=0; i < m_num_inputs; i++)
- {
- m_in->m_buffer[i] = inputs[i];
- }
-
- netlist::netlist_time cur = netlist().time();
-
- netlist().process_queue(m_div * samples);
-
- cur += (m_div * samples);
-
- for (int i=0; i < m_num_outputs; i++)
- {
- m_out[i]->sound_update(cur);
- m_out[i]->buffer_reset(cur);
- }
-}
-
-// ----------------------------------------------------------------------------------------
-// memregion source support
-// ----------------------------------------------------------------------------------------
-
-bool netlist_source_memregion_t::parse(netlist::setup_t &setup, const pstring &name)
-{
- // FIXME: preprocessor should be a stream!
- memory_region *mem = downcast<netlist_mame_t &>(setup.netlist()).machine().root_device().memregion(m_name.cstr());
- pimemstream istrm(mem->base(),mem->bytes() );
- pomemstream ostrm;
-
- pimemstream istrm2(ppreprocessor().process(istrm, ostrm));
- return netlist::parser_t(istrm2, setup).parse(name);
-}
diff --git a/src/emu/machine/netlist.h b/src/emu/machine/netlist.h
deleted file mode 100644
index 32b19070d4e..00000000000
--- a/src/emu/machine/netlist.h
+++ /dev/null
@@ -1,725 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Couriersud
-/***************************************************************************
-
- netlist.h
-
- Discrete netlist implementation.
-
-****************************************************************************/
-
-#ifndef NETLIST_H
-#define NETLIST_H
-
-#include "emu.h"
-#include "tagmap.h"
-
-#include "netlist/nl_base.h"
-#include "netlist/nl_setup.h"
-
-// MAME specific configuration
-
-
-#define MCFG_NETLIST_SETUP(_setup) \
- netlist_mame_device_t::static_set_constructor(*device, NETLIST_NAME(_setup));
-
-#define MCFG_NETLIST_ANALOG_INPUT(_basetag, _tag, _name) \
- MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_ANALOG_INPUT, 0) \
- netlist_mame_analog_input_t::static_set_name(*device, _name);
-
-#define MCFG_NETLIST_ANALOG_MULT_OFFSET(_mult, _offset) \
- netlist_mame_sub_interface::static_set_mult_offset(*device, _mult, _offset);
-
-#define MCFG_NETLIST_ANALOG_OUTPUT(_basetag, _tag, _IN, _class, _member, _class_tag) \
- MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_ANALOG_OUTPUT, 0) \
- netlist_mame_analog_output_t::static_set_params(*device, _IN, \
- netlist_analog_output_delegate(& _class :: _member, \
- # _class "::" # _member, _class_tag, (_class *) 0) );
-
-#define MCFG_NETLIST_LOGIC_INPUT(_basetag, _tag, _name, _shift, _mask) \
- MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_LOGIC_INPUT, 0) \
- netlist_mame_logic_input_t::static_set_params(*device, _name, _mask, _shift);
-
-#define MCFG_NETLIST_STREAM_INPUT(_basetag, _chan, _name) \
- MCFG_DEVICE_ADD(_basetag ":cin" # _chan, NETLIST_STREAM_INPUT, 0) \
- netlist_mame_stream_input_t::static_set_params(*device, _chan, _name);
-
-#define MCFG_NETLIST_STREAM_OUTPUT(_basetag, _chan, _name) \
- MCFG_DEVICE_ADD(_basetag ":cout" # _chan, NETLIST_STREAM_OUTPUT, 0) \
- netlist_mame_stream_output_t::static_set_params(*device, _chan, _name);
-
-
-#define NETLIST_LOGIC_PORT_CHANGED(_base, _tag) \
- PORT_CHANGED_MEMBER(_base ":" _tag, netlist_mame_logic_input_t, input_changed, 0)
-
-#define NETLIST_ANALOG_PORT_CHANGED(_base, _tag) \
- PORT_CHANGED_MEMBER(_base ":" _tag, netlist_mame_analog_input_t, input_changed, 0)
-
-
-// ----------------------------------------------------------------------------------------
-// Extensions to interface netlist with MAME code ....
-// ----------------------------------------------------------------------------------------
-
-class netlist_source_memregion_t : public netlist::setup_t::source_t
-{
-public:
- netlist_source_memregion_t(pstring name)
- : netlist::setup_t::source_t(), m_name(name)
- {
- }
-
- bool parse(netlist::setup_t &setup, const pstring &name);
-private:
- pstring m_name;
-};
-
-#define MEMREGION_SOURCE(_name) \
- setup.register_source(palloc(netlist_source_memregion_t(_name)));
-
-#define NETDEV_ANALOG_CALLBACK_MEMBER(_name) \
- void _name(const double data, const attotime &time)
-
-class netlist_mame_device_t;
-
-class netlist_mame_t : public netlist::netlist_t
-{
-public:
-
- netlist_mame_t(netlist_mame_device_t &parent)
- : netlist::netlist_t(),
- m_parent(parent)
- {}
- virtual ~netlist_mame_t() { };
-
- inline running_machine &machine();
-
- netlist_mame_device_t &parent() { return m_parent; }
-
-protected:
-
- void vlog(const plog_level &l, const pstring &ls) const;
-
-private:
- netlist_mame_device_t &m_parent;
-};
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_device_t
-// ----------------------------------------------------------------------------------------
-
-class netlist_mame_device_t : public device_t
-{
-public:
-
- // construction/destruction
- netlist_mame_device_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- netlist_mame_device_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *file);
- virtual ~netlist_mame_device_t() {}
-
- static void static_set_constructor(device_t &device, void (*setup_func)(netlist::setup_t &));
-
- ATTR_HOT inline netlist::setup_t &setup() { return *m_setup; }
- ATTR_HOT inline netlist_mame_t &netlist() { return *m_netlist; }
-
- ATTR_HOT inline netlist::netlist_time last_time_update() { return m_old; }
- ATTR_HOT void update_time_x();
- ATTR_HOT void check_mame_abort_slice();
-
- int m_icount;
-
-protected:
- // Custom to netlist ...
-
- virtual void nl_register_devices() { };
-
- // device_t overrides
- virtual void device_config_complete();
- virtual void device_start();
- virtual void device_stop();
- virtual void device_reset();
- virtual void device_post_load();
- virtual void device_pre_save();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- //virtual void device_debug_setup();
- virtual void device_clock_changed();
-
- netlist::netlist_time m_div;
-
-private:
- void save_state();
-
- /* timing support here - so sound can hijack it ... */
- netlist::netlist_time m_rem;
- netlist::netlist_time m_old;
-
- netlist_mame_t * m_netlist;
- netlist::setup_t * m_setup;
-
- void (*m_setup_func)(netlist::setup_t &);
-};
-
-inline running_machine &netlist_mame_t::machine()
-{
- return m_parent.machine();
-}
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_cpu_device_t
-// ----------------------------------------------------------------------------------------
-
-class netlist_mame_cpu_device_t : public netlist_mame_device_t,
- public device_execute_interface,
- public device_state_interface,
- public device_disasm_interface,
- public device_memory_interface
-{
-public:
-
- // construction/destruction
- netlist_mame_cpu_device_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- virtual ~netlist_mame_cpu_device_t() {}
-
- static void static_set_constructor(device_t &device, void (*setup_func)(netlist::setup_t &));
-
-protected:
- // netlist_mame_device_t
- virtual void nl_register_devices();
-
- // device_t overrides
-
- //virtual void device_config_complete();
- virtual void device_start();
- //virtual void device_stop();
- //virtual void device_reset();
- //virtual void device_post_load();
- //virtual void device_pre_save();
- //virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_execute_interface overrides
-
- virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const;
- virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const;
-
- ATTR_HOT virtual void execute_run();
-
- // device_disasm_interface overrides
- ATTR_COLD virtual UINT32 disasm_min_opcode_bytes() const { return 1; }
- ATTR_COLD virtual UINT32 disasm_max_opcode_bytes() const { return 1; }
- ATTR_COLD virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
-
- // device_memory_interface overrides
-
- address_space_config m_program_config;
-
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const
- {
- switch (spacenum)
- {
- case AS_PROGRAM: return &m_program_config;
- case AS_IO: return NULL;
- default: return NULL;
- }
- }
-
- // device_state_interface overrides
-
- virtual void state_string_export(const device_state_entry &entry, std::string &str)
- {
- if (entry.index() >= 0)
- {
- if (entry.index() & 1)
- strprintf(str,"%10.6f", *((double *)entry.dataptr()));
- else
- strprintf(str, "%d", *((netlist_sig_t *)entry.dataptr()));
- }
- }
-
-private:
-
- int m_genPC;
-
-};
-
-class nld_sound_out;
-class nld_sound_in;
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_sound_device_t
-// ----------------------------------------------------------------------------------------
-
-class netlist_mame_sound_device_t : public netlist_mame_device_t,
- public device_sound_interface
-{
-public:
-
- // construction/destruction
- netlist_mame_sound_device_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- virtual ~netlist_mame_sound_device_t() {}
-
- static void static_set_constructor(device_t &device, void (*setup_func)(netlist::setup_t &));
-
- inline sound_stream *get_stream() { return m_stream; }
-
-
- // device_sound_interface overrides
-
- virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
-
-protected:
- // netlist_mame_device_t
- virtual void nl_register_devices();
-
- // device_t overrides
-
- //virtual void device_config_complete();
- virtual void device_start();
- //virtual void device_stop();
- //virtual void device_reset();
- //virtual void device_post_load();
- //virtual void device_pre_save();
- //virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
-
- static const int MAX_OUT = 10;
- nld_sound_out *m_out[MAX_OUT];
- nld_sound_in *m_in;
- sound_stream *m_stream;
- int m_num_inputs;
- int m_num_outputs;
-
-};
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_sub_interface
-// ----------------------------------------------------------------------------------------
-
-class netlist_mame_sub_interface
-{
-public:
- // construction/destruction
- netlist_mame_sub_interface(device_t &aowner)
- : m_offset(0.0), m_mult(1.0)
- {
- m_owner = dynamic_cast<netlist_mame_device_t *>(&aowner);
- m_sound = dynamic_cast<netlist_mame_sound_device_t *>(&aowner);
- }
- virtual ~netlist_mame_sub_interface() { }
-
- virtual void custom_netlist_additions(netlist::setup_t &setup) { }
-
- inline netlist_mame_device_t &nl_owner() const { return *m_owner; }
-
- inline bool is_sound_device() const { return (m_sound != NULL); }
-
- inline void update_to_current_time()
- {
- m_sound->get_stream()->update();
- }
-
- static void static_set_mult_offset(device_t &device, const double mult, const double offset);
-
-protected:
- double m_offset;
- double m_mult;
-
-private:
- netlist_mame_device_t *m_owner;
- netlist_mame_sound_device_t *m_sound;
-};
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_analog_input_t
-// ----------------------------------------------------------------------------------------
-
-class netlist_mame_analog_input_t : public device_t,
- public netlist_mame_sub_interface
-{
-public:
-
- // construction/destruction
- netlist_mame_analog_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- virtual ~netlist_mame_analog_input_t() { }
-
- static void static_set_name(device_t &device, const char *param_name);
-
- inline void write(const double val)
- {
- if (is_sound_device())
- {
- update_to_current_time();
- m_param->setTo(val * m_mult + m_offset);
- }
- else
- {
- // FIXME: use device timer ....
- m_param->setTo(val * m_mult + m_offset);
- }
- }
-
- inline DECLARE_INPUT_CHANGED_MEMBER(input_changed)
- {
- if (m_auto_port)
- write(((double) newval - (double) field.minval())/((double) (field.maxval()-field.minval()) ) );
- else
- write(newval);
- }
- inline DECLARE_WRITE_LINE_MEMBER(write_line) { write(state); }
- inline DECLARE_WRITE8_MEMBER(write8) { write(data); }
- inline DECLARE_WRITE16_MEMBER(write16) { write(data); }
- inline DECLARE_WRITE32_MEMBER(write32) { write(data); }
- inline DECLARE_WRITE64_MEMBER(write64) { write(data); }
-
-protected:
- // device-level overrides
- virtual void device_start();
-
-private:
- netlist::param_double_t *m_param;
- bool m_auto_port;
- pstring m_param_name;
-};
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_analog_output_t
-// ----------------------------------------------------------------------------------------
-
-typedef device_delegate<void (const double, const attotime &)> netlist_analog_output_delegate;
-
-class netlist_mame_analog_output_t : public device_t,
- public netlist_mame_sub_interface
-{
-public:
-
- // construction/destruction
- netlist_mame_analog_output_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- virtual ~netlist_mame_analog_output_t() { }
-
- static void static_set_params(device_t &device, const char *in_name, netlist_analog_output_delegate adelegate);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void custom_netlist_additions(netlist::setup_t &setup);
-
-private:
- pstring m_in;
- netlist_analog_output_delegate m_delegate;
-};
-
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_logic_input_t
-// ----------------------------------------------------------------------------------------
-
-class netlist_mame_logic_input_t : public device_t,
- public netlist_mame_sub_interface
-{
-public:
-
- // construction/destruction
- netlist_mame_logic_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- virtual ~netlist_mame_logic_input_t() { }
-
- static void static_set_params(device_t &device, const char *param_name, const UINT32 mask, const UINT32 shift);
-
- inline void write(const UINT32 val)
- {
- const UINT32 v = (val >> m_shift) & m_mask;
- if (v != m_param->Value())
- synchronize(0, v);
- }
-
- inline DECLARE_INPUT_CHANGED_MEMBER(input_changed) { write(newval); }
- DECLARE_WRITE_LINE_MEMBER(write_line) { write(state); }
- DECLARE_WRITE8_MEMBER(write8) { write(data); }
- DECLARE_WRITE16_MEMBER(write16) { write(data); }
- DECLARE_WRITE32_MEMBER(write32) { write(data); }
- DECLARE_WRITE64_MEMBER(write64) { write(data); }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
- {
- if (is_sound_device())
- update_to_current_time();
- m_param->setTo(param);
- }
-
-private:
- netlist::param_int_t *m_param;
- UINT32 m_mask;
- UINT32 m_shift;
- pstring m_param_name;
-};
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_stream_input_t
-// ----------------------------------------------------------------------------------------
-
-class netlist_mame_stream_input_t : public device_t,
- public netlist_mame_sub_interface
-{
-public:
-
- // construction/destruction
- netlist_mame_stream_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- virtual ~netlist_mame_stream_input_t() { }
-
- static void static_set_params(device_t &device, int channel, const char *param_name);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void custom_netlist_additions(netlist::setup_t &setup);
-private:
- UINT32 m_channel;
- pstring m_param_name;
-};
-
-// ----------------------------------------------------------------------------------------
-// netlist_mame_stream_output_t
-// ----------------------------------------------------------------------------------------
-
-class netlist_mame_stream_output_t : public device_t,
- public netlist_mame_sub_interface
-{
-public:
-
- // construction/destruction
- netlist_mame_stream_output_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- virtual ~netlist_mame_stream_output_t() { }
-
- static void static_set_params(device_t &device, int channel, const char *out_name);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void custom_netlist_additions(netlist::setup_t &setup);
-private:
- UINT32 m_channel;
- pstring m_out_name;
-};
-// ----------------------------------------------------------------------------------------
-// netdev_callback
-// ----------------------------------------------------------------------------------------
-
-class NETLIB_NAME(analog_callback) : public netlist::device_t
-{
-public:
- NETLIB_NAME(analog_callback)()
- : device_t(), m_cpu_device(NULL), m_last(0) { }
-
- ATTR_COLD void start()
- {
- register_input("IN", m_in);
- m_cpu_device = downcast<netlist_mame_cpu_device_t *>(&downcast<netlist_mame_t &>(netlist()).parent());
- save(NLNAME(m_last));
- }
-
- ATTR_COLD void reset()
- {
- m_last = 0.0;
- }
-
- ATTR_COLD void register_callback(netlist_analog_output_delegate callback)
- {
- m_callback = callback;
- }
-
- ATTR_HOT void update()
- {
- nl_double cur = INPANALOG(m_in);
-
- // FIXME: make this a parameter
- // avoid calls due to noise
- if (fabs(cur - m_last) > 1e-6)
- {
- m_cpu_device->update_time_x();
- m_callback(cur, m_cpu_device->local_time());
- m_cpu_device->check_mame_abort_slice();
- m_last = cur;
- }
- }
-
-private:
- netlist::analog_input_t m_in;
- netlist_analog_output_delegate m_callback;
- netlist_mame_cpu_device_t *m_cpu_device;
- nl_double m_last;
-};
-
-// ----------------------------------------------------------------------------------------
-// sound_out
-// ----------------------------------------------------------------------------------------
-
-class NETLIB_NAME(sound_out) : public netlist::device_t
-{
-public:
- NETLIB_NAME(sound_out)()
- : netlist::device_t() { }
-
- static const int BUFSIZE = 2048;
-
- ATTR_COLD void start()
- {
- register_input("IN", m_in);
- register_param("CHAN", m_channel, 0);
- register_param("MULT", m_mult, 1000.0);
- register_param("OFFSET", m_offset, 0.0);
- m_sample = netlist::netlist_time::from_hz(1); //sufficiently big enough
- save(NAME(m_last_buffer));
- }
-
- ATTR_COLD void reset()
- {
- m_cur = 0.0;
- m_last_pos = 0;
- m_last_buffer = netlist::netlist_time::zero;
- }
-
- ATTR_HOT void sound_update(const netlist::netlist_time upto)
- {
- int pos = (upto - m_last_buffer) / m_sample;
- if (pos >= BUFSIZE)
- netlist().log().fatal("sound {1}: exceeded BUFSIZE\n", name().cstr());
- while (m_last_pos < pos )
- {
- m_buffer[m_last_pos++] = (stream_sample_t) m_cur;
- }
- }
-
- ATTR_HOT void update()
- {
- nl_double val = INPANALOG(m_in) * m_mult.Value() + m_offset.Value();
- sound_update(netlist().time());
- /* ignore spikes */
- if (std::abs(val) < 32767.0)
- m_cur = val;
- else if (val > 0.0)
- m_cur = 32767.0;
- else
- m_cur = -32767.0;
-
- }
-
- ATTR_HOT void buffer_reset(netlist::netlist_time upto)
- {
- m_last_pos = 0;
- m_last_buffer = upto;
- m_cur = 0.0;
- }
-
- netlist::param_int_t m_channel;
- netlist::param_double_t m_mult;
- netlist::param_double_t m_offset;
- stream_sample_t *m_buffer;
- netlist::netlist_time m_sample;
-
-private:
- netlist::analog_input_t m_in;
- double m_cur;
- int m_last_pos;
- netlist::netlist_time m_last_buffer;
-};
-
-// ----------------------------------------------------------------------------------------
-// sound_in
-// ----------------------------------------------------------------------------------------
-
-class NETLIB_NAME(sound_in) : public netlist::device_t
-{
-public:
- NETLIB_NAME(sound_in)()
- : netlist::device_t() { }
-
- static const int MAX_INPUT_CHANNELS = 10;
-
- ATTR_COLD void start()
- {
- // clock part
- register_output("Q", m_Q);
- register_input("FB", m_feedback);
-
- connect_late(m_feedback, m_Q);
- m_inc = netlist::netlist_time::from_nsec(1);
-
-
- for (int i = 0; i < MAX_INPUT_CHANNELS; i++)
- {
- register_param(pfmt("CHAN{1}")(i), m_param_name[i], "");
- register_param(pfmt("MULT{1}")(i), m_param_mult[i], 1.0);
- register_param(pfmt("OFFSET{1}")(i), m_param_offset[i], 0.0);
- }
- m_num_channel = 0;
- }
-
- ATTR_COLD void reset()
- {
- m_pos = 0;
- for (int i = 0; i < MAX_INPUT_CHANNELS; i++)
- m_buffer[i] = NULL;
- }
-
- ATTR_COLD int resolve()
- {
- m_pos = 0;
- for (int i = 0; i < MAX_INPUT_CHANNELS; i++)
- {
- if (m_param_name[i].Value() != "")
- {
- if (i != m_num_channel)
- netlist().log().fatal("sound input numbering has to be sequential!");
- m_num_channel++;
- m_param[i] = dynamic_cast<netlist::param_double_t *>(setup().find_param(m_param_name[i].Value(), true));
- }
- }
- return m_num_channel;
- }
-
- ATTR_HOT void update()
- {
- for (int i=0; i<m_num_channel; i++)
- {
- if (m_buffer[i] == NULL)
- break; // stop, called outside of stream_update
- const nl_double v = m_buffer[i][m_pos];
- m_param[i]->setTo(v * m_param_mult[i].Value() + m_param_offset[i].Value());
- }
- m_pos++;
- OUTLOGIC(m_Q, !m_Q.net().as_logic().new_Q(), m_inc );
- }
-
- ATTR_HOT void buffer_reset()
- {
- m_pos = 0;
- }
-
- netlist::param_str_t m_param_name[MAX_INPUT_CHANNELS];
- netlist::param_double_t *m_param[MAX_INPUT_CHANNELS];
- stream_sample_t *m_buffer[MAX_INPUT_CHANNELS];
- netlist::param_double_t m_param_mult[MAX_INPUT_CHANNELS];
- netlist::param_double_t m_param_offset[MAX_INPUT_CHANNELS];
- netlist::netlist_time m_inc;
-
-private:
- netlist::logic_input_t m_feedback;
- netlist::logic_output_t m_Q;
-
- int m_pos;
- int m_num_channel;
-};
-
-// device type definition
-extern const device_type NETLIST_CORE;
-extern const device_type NETLIST_CPU;
-extern const device_type NETLIST_SOUND;
-extern const device_type NETLIST_ANALOG_INPUT;
-extern const device_type NETLIST_LOGIC_INPUT;
-
-extern const device_type NETLIST_ANALOG_OUTPUT;
-extern const device_type NETLIST_STREAM_INPUT;
-extern const device_type NETLIST_STREAM_OUTPUT;
-
-#endif
diff --git a/src/emu/machine/nmc9306.c b/src/emu/machine/nmc9306.c
deleted file mode 100644
index 0b23eda21d7..00000000000
--- a/src/emu/machine/nmc9306.c
+++ /dev/null
@@ -1,322 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- National Semiconductor NMC9306 256-Bit Serial EEPROM emulation
-
-**********************************************************************/
-
-#include "emu.h"
-#include "nmc9306.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 1
-
-#define RAM_SIZE 32
-
-
-// instructions
-enum
-{
- OTHER = 0,
- WRITE, // write register A3A2A1A0
- READ, // read register A3A2A1A0
- ERASE // erase register A3A2A1A0
-};
-
-// other instructions
-enum
-{
- EWDS = 0, // erase/write disable
- WRAL, // write all registers
- ERAL, // erase all registers
- EWEN // erase/write enable
-};
-
-// states
-enum
-{
- STATE_IDLE = 0,
- STATE_COMMAND,
- STATE_ADDRESS,
- STATE_DATA_IN,
- STATE_DATA_OUT,
- STATE_ERASE
-};
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-// device type definition
-const device_type NMC9306 = &device_creator<nmc9306_device>;
-
-//-------------------------------------------------
-// nmc9306_device - constructor
-//-------------------------------------------------
-
-inline UINT16 nmc9306_device::read(offs_t offset)
-{
- return m_register[offset];
-}
-
-
-//-------------------------------------------------
-// nmc9306_device - constructor
-//-------------------------------------------------
-
-inline void nmc9306_device::write(offs_t offset, UINT16 data)
-{
- if (m_ewen)
- {
- m_register[offset] &= data;
- }
-}
-
-
-//-------------------------------------------------
-// nmc9306_device - constructor
-//-------------------------------------------------
-
-inline void nmc9306_device::erase(offs_t offset)
-{
- if (m_ewen)
- {
- m_register[offset] = 0xffff;
- }
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// nmc9306_device - constructor
-//-------------------------------------------------
-
-nmc9306_device::nmc9306_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, NMC9306, "NMC9306", tag, owner, clock, "nmc9306", __FILE__),
- device_nvram_interface(mconfig, *this),
- m_state(STATE_IDLE),
- m_ewen(false)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void nmc9306_device::device_start()
-{
- memset(m_register, 0, sizeof(m_register));
-
- // state saving
- save_item(NAME(m_bits));
- save_item(NAME(m_state));
- save_item(NAME(m_command));
- save_item(NAME(m_address));
- save_item(NAME(m_data));
- save_item(NAME(m_ewen));
- save_item(NAME(m_cs));
- save_item(NAME(m_sk));
- save_item(NAME(m_do));
- save_item(NAME(m_di));
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void nmc9306_device::nvram_default()
-{
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void nmc9306_device::nvram_read(emu_file &file)
-{
- file.read(m_register, RAM_SIZE);
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void nmc9306_device::nvram_write(emu_file &file)
-{
- file.write(m_register, RAM_SIZE);
-}
-
-
-//-------------------------------------------------
-// cs_w - chip select input
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( nmc9306_device::cs_w )
-{
- m_cs = state;
-}
-
-
-//-------------------------------------------------
-// ck_w - serial clock input
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( nmc9306_device::sk_w )
-{
- m_sk = state;
-
- if (!m_cs || !m_sk) return;
-
- switch (m_state)
- {
- case STATE_IDLE:
- if (LOG) logerror("NMC9306 '%s' Idle %u\n", tag(), m_di);
-
- if (m_di)
- {
- // start bit received
- m_state = STATE_COMMAND;
- m_bits = 0;
- }
- break;
-
- case STATE_COMMAND:
- if (LOG) logerror("NMC9306 '%s' Command Bit %u\n", tag(), m_di);
-
- m_command <<= 1;
- m_command |= m_di;
- m_bits++;
-
- if (m_bits == 4)
- {
- m_state = STATE_ADDRESS;
- m_bits = 0;
- }
- break;
-
- case STATE_ADDRESS:
- if (LOG) logerror("NMC9306 '%s' Address Bit %u\n", tag(), m_di);
-
- m_address <<= 1;
- m_address |= m_di;
- m_bits++;
-
- if (m_bits == 4)
- {
- switch ((m_command >> 2) & 0x03)
- {
- case OTHER:
- switch (m_command & 0x03)
- {
- case EWDS:
- if (LOG) logerror("NMC9306 '%s' EWDS\n", tag());
- m_ewen = false;
- m_state = STATE_IDLE;
- break;
-
- case WRAL:
- if (LOG) logerror("NMC9306 '%s' WRAL\n", tag());
- break;
-
- case ERAL:
- if (LOG) logerror("NMC9306 '%s' ERAL\n", tag());
- break;
-
- case EWEN:
- if (LOG) logerror("NMC9306 '%s' EWEN\n", tag());
- m_ewen = true;
- m_state = STATE_IDLE;
- break;
- }
- break;
-
- case WRITE:
- if (LOG) logerror("NMC9306 '%s' WRITE %u\n", tag(), m_address & 0x0f);
- m_state = STATE_DATA_IN;
- break;
-
- case READ:
- if (LOG) logerror("NMC9306 '%s' READ %u\n", tag(), m_address & 0x0f);
- m_data = read(m_address & 0x0f);
- m_state = STATE_DATA_OUT;
- break;
-
- case ERASE:
- if (LOG) logerror("NMC9306 '%s' ERASE %u\n", tag(), m_address & 0x0f);
- erase(m_address & 0x0f);
- m_state = STATE_ERASE;
- break;
- }
-
- m_bits = 0;
- }
- break;
-
- case STATE_DATA_IN:
- if (LOG) logerror("NMC9306 '%s' Data Bit IN %u\n", tag(), m_di);
-
- m_data <<= 1;
- m_data |= m_di;
- m_bits++;
-
- if (m_bits == 16)
- {
- write(m_address & 0x0f, m_data);
-
- m_state = STATE_IDLE;
- }
- break;
-
- case STATE_DATA_OUT:
- if (LOG) logerror("NMC9306 '%s' Data Bit OUT %u\n", tag(), m_di);
-
- m_do = BIT(m_data, 15);
- m_data <<= 1;
- m_bits++;
-
- if (m_bits == 16)
- {
- m_state = STATE_IDLE;
- }
- break;
- }
-}
-
-
-//-------------------------------------------------
-// di_w - serial data input
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( nmc9306_device::di_w )
-{
- m_di = state;
-}
-
-
-//-------------------------------------------------
-// do_r - serial data output
-//-------------------------------------------------
-
-READ_LINE_MEMBER( nmc9306_device::do_r )
-{
- return m_do;
-}
diff --git a/src/emu/machine/nmc9306.h b/src/emu/machine/nmc9306.h
deleted file mode 100644
index 95db0133025..00000000000
--- a/src/emu/machine/nmc9306.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- National Semiconductor NMC9306 256-Bit Serial EEPROM emulation
-
-**********************************************************************
- _____ _____
- CS 1 |* \_/ | 8 Vcc
- SK 2 | | 7 NC
- DI 3 | | 6 NC
- DO 4 |_____________| 5 GND
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __NMC9306__
-#define __NMC9306__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_NMC9306_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, NMC9306, 0)
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-// ======================> nmc9306_device
-
-class nmc9306_device : public device_t,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- nmc9306_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_WRITE_LINE_MEMBER( cs_w );
- DECLARE_WRITE_LINE_MEMBER( sk_w );
- DECLARE_WRITE_LINE_MEMBER( di_w );
- DECLARE_READ_LINE_MEMBER( do_r );
-
-protected:
- // device-level overrides
- virtual void device_start();
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
-private:
- inline UINT16 read(offs_t offset);
- inline void write(offs_t offset, UINT16 data);
- inline void erase(offs_t offset);
-
- UINT16 m_register[16];
-
- int m_bits;
- int m_state;
- UINT8 m_command;
- UINT8 m_address;
- UINT16 m_data;
- bool m_ewen;
- int m_cs;
- int m_sk;
- int m_do;
- int m_di;
-};
-
-
-// device type definition
-extern const device_type NMC9306;
-
-
-#endif
diff --git a/src/emu/machine/nsc810.c b/src/emu/machine/nsc810.c
deleted file mode 100644
index 51aec5cf654..00000000000
--- a/src/emu/machine/nsc810.c
+++ /dev/null
@@ -1,312 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Barry Rodewald
-/*
- * nsc810.c
- *
- * Created on: 10/03/2014
- *
- * TODO:
- * - 128 byte RAM
- * - other timer modes (only mode 1 - event counter - is implemented currently)
- * - port bit set/clear
- * - and lots of other stuff
- */
-
-#include "nsc810.h"
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-#define LOG (1)
-
-const device_type NSC810 = &device_creator<nsc810_device>;
-
-nsc810_device::nsc810_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, NSC810, "National Semiconductor NSC810", tag, owner, clock, "nsc810", __FILE__),
- m_portA_r(*this),
- m_portB_r(*this),
- m_portC_r(*this),
- m_portA_w(*this),
- m_portB_w(*this),
- m_portC_w(*this),
- m_timer0_out(*this),
- m_timer1_out(*this)
-{
-}
-
-void nsc810_device::device_start()
-{
- m_portA_r.resolve_safe(0);
- m_portB_r.resolve_safe(0);
- m_portC_r.resolve_safe(0);
- m_portA_w.resolve_safe();
- m_portB_w.resolve_safe();
- m_portC_w.resolve_safe();
- m_timer0_out.resolve_safe();
- m_timer1_out.resolve_safe();
-
- m_portA_w(0);
- m_portB_w(0);
- m_portC_w(0);
- m_timer0_out(0);
- m_timer1_out(0);
-
- m_timer0 = timer_alloc(TIMER0_CLOCK);
- m_timer1 = timer_alloc(TIMER1_CLOCK);
-}
-
-void nsc810_device::device_reset()
-{
- m_portA_latch = 0;
- m_portB_latch = 0;
- m_portC_latch = 0;
- m_ddrA = 0;
- m_ddrB = 0;
- m_ddrC = 0;
- m_mode = 0;
- m_timer0_mode = 0;
- m_timer1_mode = 0;
- m_timer0_counter = 0;
- m_timer1_counter = 0;
- m_timer0_running = false;
- m_timer1_running = false;
- m_ramselect = false;
-}
-
-void nsc810_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch(id)
- {
- case TIMER0_CLOCK:
- m_timer0_counter--;
- if((m_timer0_mode & 0x07) == 0x01 || (m_timer0_mode & 0x07) == 0x02)
- {
- if(m_timer0_counter == 0)
- {
- m_timer0_out(ASSERT_LINE);
- m_timer0_counter = m_timer0_base;
- if(LOG) logerror("NSC810 '%s': Timer 0 output set\n",tag());
- }
- }
- break;
- case TIMER1_CLOCK:
- m_timer1_counter--;
- if((m_timer1_mode & 0x07) == 0x01 || (m_timer1_mode & 0x07) == 0x02)
- {
- if(m_timer1_counter == 0)
- {
- m_timer1_out(ASSERT_LINE);
- m_timer1_counter = m_timer1_base;
- if(LOG) logerror("NSC810 '%s': Timer 1 output set\n",tag());
- }
- }
- break;
- }
-}
-
-READ8_MEMBER(nsc810_device::read)
-{
- UINT8 res = 0xff;
-
- if(m_ramselect)
- {
- // TODO: 128 byte RAM access
- }
- else
- {
- // Register access
- switch(offset & 0x1f)
- {
- case REG_PORTA:
- res = m_portA_latch &= m_ddrA;
- res |= (m_portA_r() & ~m_ddrA);
- //if(LOG) logerror("NSC810 '%s': Port A data read %02x\n",tag(),res);
- break;
- case REG_PORTB:
- res = m_portB_latch &= m_ddrB;
- res |= (m_portB_r() & ~m_ddrB);
- //if(LOG) logerror("NSC810 '%s': Port B data read %02x\n",tag(),res);
- break;
- case REG_PORTC:
- res = m_portC_latch &= m_ddrC;
- res |= (m_portC_r() & ~m_ddrC);
- //if(LOG) logerror("NSC810 '%s': Port C data read %02x\n",tag(),res);
- break;
- case REG_MODE_TIMER0:
- res = m_timer0_mode;
- break;
- case REG_MODE_TIMER1:
- res = m_timer1_mode;
- break;
- case REG_TIMER0_LOW:
- res = m_timer0_counter & 0xff;
- if((m_timer0_mode & 0x07) == 0x01 || (m_timer0_mode & 0x07) == 0x02)
- {
- m_timer0_out(CLEAR_LINE);
- if(LOG) logerror("NSC810 '%s': Timer 0 output reset\n",tag());
- }
- break;
- case REG_TIMER0_HIGH:
- res = m_timer0_counter >> 8;
- if((m_timer0_mode & 0x07) == 0x01 || (m_timer0_mode & 0x07) == 0x02)
- {
- m_timer0_out(CLEAR_LINE);
- if(LOG) logerror("NSC810 '%s': Timer 0 output reset\n",tag());
- }
- break;
- case REG_TIMER1_LOW:
- res = m_timer1_counter & 0xff;
- if((m_timer1_mode & 0x07) == 0x01 || (m_timer1_mode & 0x07) == 0x02)
- {
- m_timer1_out(0);
- if(LOG) logerror("NSC810 '%s': Timer 1 output reset\n",tag());
- }
- break;
- case REG_TIMER1_HIGH:
- res = m_timer1_counter >> 8;
- if((m_timer1_mode & 0x07) == 0x01 || (m_timer1_mode & 0x07) == 0x02)
- {
- m_timer1_out(0);
- if(LOG) logerror("NSC810 '%s': Timer 1 output reset\n",tag());
- }
- break;
- default:
- if(LOG) logerror("NSC810 '%s': unused port %02x read\n",tag(),offset);
- }
- }
- return res;
-}
-
-WRITE8_MEMBER(nsc810_device::write)
-{
- UINT32 rate;
-
- if(m_ramselect)
- {
- // TODO: 128 byte RAM access
- }
- else
- {
- // Register access
- switch(offset & 0x1f)
- {
- case REG_PORTA:
- m_portA_latch = data & ~m_ddrA;
- m_portA_w((0xff & ~m_ddrA) | (data & m_ddrA));
- if(LOG) logerror("NSC810 '%s': Port A data write %02x\n",tag(),data);
- break;
- case REG_PORTB:
- m_portB_latch = data & ~m_ddrB;
- m_portB_w((0xff & ~m_ddrB) | (data & m_ddrB));
- if(LOG) logerror("NSC810 '%s': Port B data write %02x\n",tag(),data);
- break;
- case REG_PORTC:
- m_portC_latch = data & ~m_ddrC;
- m_portC_w((0xff & ~m_ddrC) | (data & m_ddrC));
- if(LOG) logerror("NSC810 '%s': Port C data write %02x\n",tag(),data);
- break;
- case REG_DDRA:
- m_ddrA = data;
- if(LOG) logerror("NSC810 '%s': Port A direction write %02x\n",tag(),data);
- break;
- case REG_DDRB:
- m_ddrB = data;
- if(LOG) logerror("NSC810 '%s': Port B direction write %02x\n",tag(),data);
- break;
- case REG_DDRC:
- m_ddrC = data;
- if(LOG) logerror("NSC810 '%s': Port C direction write %02x\n",tag(),data);
- break;
- case REG_MODE_DEF:
- if(LOG) logerror("NSC810 '%s': Mode Definition write %02x\n",tag(),data);
- break;
- case REG_PORTA_BITCLR:
- if(LOG) logerror("NSC810 '%s': Port A bit-clear write %02x\n",tag(),data);
- break;
- case REG_PORTB_BITCLR:
- if(LOG) logerror("NSC810 '%s': Port B bit-clear write %02x\n",tag(),data);
- break;
- case REG_PORTC_BITCLR:
- if(LOG) logerror("NSC810 '%s': Port C bit-clear write %02x\n",tag(),data);
- break;
- case REG_PORTA_BITSET:
- if(LOG) logerror("NSC810 '%s': Port A bit-set write %02x\n",tag(),data);
- break;
- case REG_PORTB_BITSET:
- if(LOG) logerror("NSC810 '%s': Port B bit-set write %02x\n",tag(),data);
- break;
- case REG_PORTC_BITSET:
- if(LOG) logerror("NSC810 '%s': Port C bit-set write %02x\n",tag(),data);
- break;
- case REG_TIMER0_LOW:
- m_timer0_base = (m_timer0_base & 0xff00) | data;
- m_timer0_counter = (m_timer0_counter & 0xff00) | data;
- if(LOG) logerror("NSC810 '%s': Timer 0 low-byte write %02x (base=%04x)\n",tag(),data,m_timer0_base);
- break;
- case REG_TIMER0_HIGH:
- m_timer0_base = (m_timer0_base & 0x00ff) | (data << 8);
- m_timer0_counter = (m_timer0_counter & 0x00ff) | (data << 8);
- if(LOG) logerror("NSC810 '%s': Timer 0 high-byte write %02x (base=%04x)\n",tag(),data,m_timer0_base);
- break;
- case REG_TIMER1_LOW:
- m_timer1_base = (m_timer1_base & 0xff00) | data;
- m_timer1_counter = (m_timer1_counter & 0xff00) | data;
- if(LOG) logerror("NSC810 '%s': Timer 1 low-byte write %02x (base=%04x)\n",tag(),data,m_timer1_base);
- break;
- case REG_TIMER1_HIGH:
- m_timer1_base = (m_timer1_base & 0x00ff) | (data << 8);
- m_timer1_counter = (m_timer1_counter & 0x00ff) | (data << 8);
- if(LOG) logerror("NSC810 '%s': Timer 1 high-byte write %02x (base=%04x)\n",tag(),data,m_timer1_base);
- break;
- case REG_TIMER0_STOP:
- m_timer0_running = false;
- m_timer0->reset();
- if(LOG) logerror("NSC810 '%s': Timer 0 Stop write %02x\n",tag(),data);
- break;
- case REG_TIMER0_START:
- if((m_timer0_mode & 0x07) != 0x00 && (m_timer0_mode & 0x07) != 0x07)
- {
- m_timer0_running = true;
- if(m_timer0_mode & 0x10)
- rate = m_timer0_clock / 64;
- else
- if(m_timer0_mode & 0x08)
- rate = m_timer0_clock / 2;
- else
- rate = m_timer0_clock;
- m_timer0->adjust(attotime::zero,0,attotime::from_hz(rate));
- }
- if(LOG) logerror("NSC810 '%s': Timer 0 Start write %02x\n",tag(),data);
- break;
- case REG_TIMER1_STOP:
- m_timer1_running = false;
- m_timer1->reset();
- if(LOG) logerror("NSC810 '%s': Timer 1 Stop write %02x\n",tag(),data);
- break;
- case REG_TIMER1_START:
- if((m_timer1_mode & 0x07) != 0x00 && (m_timer1_mode & 0x07) != 0x07)
- {
- m_timer1_running = true;
- // no /64 prescaler on timer 1
- if(m_timer0_mode & 0x08)
- rate = m_timer0_clock / 2;
- else
- rate = m_timer0_clock;
- m_timer1->adjust(attotime::zero,0,attotime::from_hz(rate));
- }
- if(LOG) logerror("NSC810 '%s': Timer 1 Start write %02x\n",tag(),data);
- break;
- case REG_MODE_TIMER0:
- m_timer0_mode = data;
- if(LOG) logerror("NSC810 '%s': Timer 0 Mode write %02x\n",tag(),data);
- break;
- case REG_MODE_TIMER1:
- m_timer1_mode = data;
- if(LOG) logerror("NSC810 '%s': Timer 1 Mode write %02x\n",tag(),data);
- break;
- default:
- logerror("NSC810 '%s': Unused register %02x write %02x\n",tag(),offset,data);
- }
- }
-}
diff --git a/src/emu/machine/nsc810.h b/src/emu/machine/nsc810.h
deleted file mode 100644
index f7aea895f0b..00000000000
--- a/src/emu/machine/nsc810.h
+++ /dev/null
@@ -1,135 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Barry Rodewald
-/*
- * nsc810.h
- *
- * Created on: 10/03/2014
- */
-
-#ifndef NSC810_H_
-#define NSC810_H_
-
-#include "emu.h"
-
-class nsc810_device : public device_t
-{
-public:
- // construction/destruction
- nsc810_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_portA_read_callback(device_t &device, _Object object) { return downcast<nsc810_device &>(device).m_portA_r.set_callback(object); }
- template<class _Object> static devcb_base &set_portB_read_callback(device_t &device, _Object object) { return downcast<nsc810_device &>(device).m_portB_r.set_callback(object); }
- template<class _Object> static devcb_base &set_portC_read_callback(device_t &device, _Object object) { return downcast<nsc810_device &>(device).m_portC_r.set_callback(object); }
- template<class _Object> static devcb_base &set_portA_write_callback(device_t &device, _Object object) { return downcast<nsc810_device &>(device).m_portA_w.set_callback(object); }
- template<class _Object> static devcb_base &set_portB_write_callback(device_t &device, _Object object) { return downcast<nsc810_device &>(device).m_portB_w.set_callback(object); }
- template<class _Object> static devcb_base &set_portC_write_callback(device_t &device, _Object object) { return downcast<nsc810_device &>(device).m_portC_w.set_callback(object); }
- template<class _Object> static devcb_base &set_timer0_callback(device_t &device, _Object object) { return downcast<nsc810_device &>(device).m_timer0_out.set_callback(object); }
- template<class _Object> static devcb_base &set_timer1_callback(device_t &device, _Object object) { return downcast<nsc810_device &>(device).m_timer1_out.set_callback(object); }
-
- void set_timer0_clock(UINT32 clk) { m_timer0_clock = clk; }
- void set_timer1_clock(UINT32 clk) { m_timer1_clock = clk; }
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- UINT8 m_portA_latch;
- UINT8 m_portB_latch;
- UINT8 m_portC_latch;
- UINT8 m_ddrA;
- UINT8 m_ddrB;
- UINT8 m_ddrC;
- UINT8 m_mode;
- emu_timer* m_timer0;
- emu_timer* m_timer1;
- UINT8 m_timer0_mode;
- UINT8 m_timer1_mode;
- UINT16 m_timer0_counter;
- UINT16 m_timer1_counter;
- UINT16 m_timer0_base;
- UINT16 m_timer1_base;
- bool m_timer0_running;
- bool m_timer1_running;
- UINT32 m_timer0_clock;
- UINT32 m_timer1_clock;
- bool m_ramselect;
-
- devcb_read8 m_portA_r;
- devcb_read8 m_portB_r;
- devcb_read8 m_portC_r;
- devcb_write8 m_portA_w;
- devcb_write8 m_portB_w;
- devcb_write8 m_portC_w;
- devcb_write_line m_timer0_out;
- devcb_write_line m_timer1_out;
-
- static const device_timer_id TIMER0_CLOCK = 0;
- static const device_timer_id TIMER1_CLOCK = 1;
-
- enum
- {
- REG_PORTA = 0x00,
- REG_PORTB,
- REG_PORTC,
- REG_DDRA = 0x04,
- REG_DDRB,
- REG_DDRC,
- REG_MODE_DEF,
- REG_PORTA_BITCLR,
- REG_PORTB_BITCLR,
- REG_PORTC_BITCLR,
- REG_PORTA_BITSET = 0x0c,
- REG_PORTB_BITSET,
- REG_PORTC_BITSET,
- REG_TIMER0_LOW = 0x10,
- REG_TIMER0_HIGH,
- REG_TIMER1_LOW,
- REG_TIMER1_HIGH,
- REG_TIMER0_STOP,
- REG_TIMER0_START,
- REG_TIMER1_STOP,
- REG_TIMER1_START,
- REG_MODE_TIMER0,
- REG_MODE_TIMER1
- };
-};
-
-#define MCFG_NSC810_ADD(_tag, _t0clk, _t1clk) \
- MCFG_DEVICE_ADD(_tag, NSC810, 0) \
- downcast<nsc810_device *>(device)->set_timer0_clock(_t0clk); \
- downcast<nsc810_device *>(device)->set_timer1_clock(_t1clk);
-
-#define MCFG_NSC810_PORTA_READ(_read) \
- devcb = &nsc810_device::set_portA_read_callback(*device, DEVCB_##_read);
-
-#define MCFG_NSC810_PORTB_READ(_read) \
- devcb = &nsc810_device::set_portB_read_callback(*device, DEVCB_##_read);
-
-#define MCFG_NSC810_PORTC_READ(_read) \
- devcb = &nsc810_device::set_portC_read_callback(*device, DEVCB_##_read);
-
-#define MCFG_NSC810_PORTA_WRITE(_write) \
- devcb = &nsc810_device::set_portA_write_callback(*device, DEVCB_##_write);
-
-#define MCFG_NSC810_PORTB_WRITE(_write) \
- devcb = &nsc810_device::set_portB_write_callback(*device, DEVCB_##_write);
-
-#define MCFG_NSC810_PORTC_WRITE(_write) \
- devcb = &nsc810_device::set_portC_write_callback(*device, DEVCB_##_write);
-
-#define MCFG_NSC810_TIMER0_OUT(_write) \
- devcb = &nsc810_device::set_timer0_callback(*device, DEVCB_##_write);
-
-#define MCFG_NSC810_TIMER1_OUT(_write) \
- devcb = &nsc810_device::set_timer1_callback(*device, DEVCB_##_write);
-
-// device type definition
-extern const device_type NSC810;
-
-
-#endif /* NSC810_H_ */
diff --git a/src/emu/machine/nscsi_bus.c b/src/emu/machine/nscsi_bus.c
deleted file mode 100644
index 182fe98e0aa..00000000000
--- a/src/emu/machine/nscsi_bus.c
+++ /dev/null
@@ -1,741 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "nscsi_bus.h"
-
-const device_type NSCSI_BUS = &device_creator<nscsi_bus_device>;
-const device_type NSCSI_CONNECTOR = &device_creator<nscsi_connector>;
-
-nscsi_bus_device::nscsi_bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, NSCSI_BUS, "NSCSI Bus", tag, owner, clock, "nscsi_bus", __FILE__)
-{
- devcnt = 0;
- memset(dev, 0, sizeof(dev));
-}
-
-void nscsi_bus_device::device_start()
-{
- data = 0;
- ctrl = 0;
- save_item(NAME(data));
- save_item(NAME(ctrl));
- for(int i=0; i<devcnt; i++) {
- save_item(NAME(dev[i].data), i);
- save_item(NAME(dev[i].ctrl), i);
- save_item(NAME(dev[i].wait_ctrl), i);
- }
-}
-
-void nscsi_bus_device::device_reset()
-{
-}
-
-void nscsi_bus_device::regen_data()
-{
- data = 0;
- for(int i=0; i<devcnt; i++)
- data |= dev[i].data;
-}
-
-void nscsi_bus_device::regen_ctrl(int refid)
-{
- static const char *phase[8] = {
- "dout", "din ", "cmd ", "stat", "4 ", "5 ", "mout", "min "
- };
-
- UINT32 octrl = ctrl;
- ctrl = 0;
- for(int i=0; i<devcnt; i++)
- ctrl |= dev[i].ctrl;
-
- if(0) {
- logerror("%s: ctrl %c%c%c%c%c%c%c%c%c %s %04x -",
- tag(),
- ctrl & nscsi_device::S_RST ? 'R' : '.',
- ctrl & nscsi_device::S_ATN ? 'A' : '.',
- ctrl & nscsi_device::S_ACK ? 'K' : '.',
- ctrl & nscsi_device::S_REQ ? 'Q' : '.',
- ctrl & nscsi_device::S_SEL ? 'S' : '.',
- ctrl & nscsi_device::S_BSY ? 'B' : '.',
- ctrl & nscsi_device::S_MSG ? 'M' : '.',
- ctrl & nscsi_device::S_CTL ? 'C' : '.',
- ctrl & nscsi_device::S_INP ? 'I' : '.',
- phase[ctrl & 7],
- data);
- for(int i=0; i<devcnt; i++)
- if(dev[i].ctrl) {
- logerror(" %d=", i);
- logerror("%s%s%s%s%s%s%s%s%s",
- dev[i].ctrl & nscsi_device::S_RST ? "R" : "",
- dev[i].ctrl & nscsi_device::S_ATN ? "A" : "",
- dev[i].ctrl & nscsi_device::S_ACK ? "K" : "",
- dev[i].ctrl & nscsi_device::S_REQ ? "Q" : "",
- dev[i].ctrl & nscsi_device::S_MSG ? "M" : "",
- dev[i].ctrl & nscsi_device::S_INP ? "I" : "",
- dev[i].ctrl & nscsi_device::S_CTL ? "C" : "",
- dev[i].ctrl & nscsi_device::S_SEL ? "S" : "",
- dev[i].ctrl & nscsi_device::S_BSY ? "B" : "");
- }
- logerror("\n");
- }
-
- octrl = octrl ^ ctrl;
- if(octrl)
- for(int i=0; i<devcnt; i++)
- if(i != refid && (dev[i].wait_ctrl & octrl))
- dev[i].dev->scsi_ctrl_changed();
-}
-
-UINT32 nscsi_bus_device::data_r() const
-{
- return data;
-}
-
-UINT32 nscsi_bus_device::ctrl_r() const
-{
- return ctrl;
-}
-
-void nscsi_bus_device::ctrl_w(int refid, UINT32 lines, UINT32 mask)
-{
- UINT32 c = dev[refid].ctrl;
- dev[refid].ctrl = (c & ~mask) | (lines & mask);
- regen_ctrl(refid);
-}
-
-void nscsi_bus_device::data_w(int refid, UINT32 lines)
-{
- dev[refid].data = lines;
- regen_data();
-}
-
-void nscsi_bus_device::ctrl_wait(int refid, UINT32 lines, UINT32 mask)
-{
- UINT32 w = dev[refid].wait_ctrl;
- dev[refid].wait_ctrl = (w & ~mask) | (lines & mask);
-}
-
-void nscsi_bus_device::device_config_complete()
-{
- char id[3];
- for(int i=0; i<16; i++) {
- sprintf(id, "%d", i);
- nscsi_connector *conn = downcast<nscsi_connector *>(subdevice(id));
- if(conn) {
- nscsi_device *sdev = conn->get_device();
- if(sdev) {
- int rid = devcnt++;
- dev[rid].dev = sdev;
- sdev->connect_to_bus(this, rid, i);
- }
- }
- }
-}
-
-
-nscsi_connector::nscsi_connector(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, NSCSI_CONNECTOR, "NSCSI Connector Abstraction", tag, owner, clock, "nscsi_connector", __FILE__),
- device_slot_interface(mconfig, *this)
-{
-}
-
-nscsi_connector::~nscsi_connector()
-{
-}
-
-void nscsi_connector::device_start()
-{
-}
-
-nscsi_device *nscsi_connector::get_device()
-{
- return dynamic_cast<nscsi_device *>(get_card_device());
-}
-
-nscsi_device::nscsi_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_slot_card_interface(mconfig, *this)
-{
- scsi_id = scsi_refid = -1;
- scsi_bus = 0;
-}
-
-void nscsi_device::connect_to_bus(nscsi_bus_device *bus, int refid, int default_scsi_id)
-{
- scsi_bus = bus;
- scsi_refid = refid;
- scsi_id = default_scsi_id;
-}
-
-void nscsi_device::scsi_ctrl_changed()
-{
-}
-
-void nscsi_device::device_start()
-{
- save_item(NAME(scsi_id));
-}
-
-nscsi_full_device::nscsi_full_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- nscsi_device(mconfig, type, name, tag, owner, clock, shortname, source)
-{
-}
-
-
-const char *const nscsi_full_device::command_names[256] = {
- /* 00 */ "TEST_UNIT_READY", "REZERO", "?", "REQUEST_SENSE", "FORMAT_UNIT", "?", "?", "REASSIGN_BLOCKS",
- /* 08 */ "READ_6/RECIEVE", "?", "WRITE_6/SEND", "SEEK", "?", "?", "?", "?",
- /* 10 */ "?", "?", "INQUIRY", "?", "?", "MODE_SELECT_6", "RESERVE_6", "RELEASE_6",
- /* 18 */ "?", "?", "MODE_SENSE_6", "START_STOP_UNIT", "RECIEVE_DIAG_RES", "SEND_DIAGNOSTICS", "PREVENT_ALLOW_MEDIUM_REMOVAL", "?",
- /* 20 */ "?", "?", "?", "READ_FORMAT_CAPACITIES", "?", "READ_CAPACITY", "?", "?",
-
- /* 28 */ "READ_10", "READ_GENERATION", "WRITE_10", "SEEK_10", "ERASE_10", "READ_UPDATED_BLOCK_10", "WRITE_VERIFY", "VERIFY",
- /* 30 */ "SEARCH_DATA_HIGH_10", "SEARCH_DATA_EQUAL_10", "SEARCH_DATA_LOW_10", "SET_LIMITS_10", "PREFETCH", "SYNC_CACHE", "LOCK_UNLOCK_CACHE", "READ_DEFECT_DATA",
- /* 38 */ "MEDIUM_SCAN", "COMPARE", "COPY_AND_VERIFY", "WRITE_BUFFER", "READ_DATA_BUFFER", "UPDATE_BLOCK", "READ_LONG", "WRITE_LONG",
- /* 40 */ "CHANGE_DEFINITION", "WRITE_SAME", "READ_SUB_CHANNEL", "READ_TOC_PMA_ATIP", "READ_HEADER", "PLAY_AUDIO_10", "GET_CONFIGURATION", "PLAY_AUDIO_MSF",
- /* 48 */ "PLAY_AUDIO_TRACK_INDEX", "PLAY_RELATIVE_10", "GET_EVENT_STATUS_NOTIFICATION", "PAUSE_RESUME", "LOG_SELECT", "LOG_SENSE", "STOP_PLAY_SCAN", "?",
- /* 50 */ "XDWRITE", "READ_DISC_INFORMATION/XPWRITE", "READ_TRACK_INFORMATION/XDREAD", "RESERVE_TRACK", "SEND_OPC_INFORMATION", "MODE_SELECT_10", "RESERVE_10", "RELEASE_10",
- /* 58 */ "REPAIR_TRACK", "READ_MASTER_CUE", "MODE_SENSE_10", "CLOSE_TRACK_SESSION", "READ_BUFFER_CAPACITY", "SEND_CUE_SHEET", "PERSISTENT_RESERVE_IN", "PERSISTENT_RESERVE_OUT",
- /* 80 */ "XDWRITE_EXTENDED", "REBUILD", "REGENERATE", "EXTENDED_COPY", "RECEIVE_COPY_RESULTS", "?", "?", "?",
- /* 88 */ "?", "?", "?", "?", "?", "?", "?", "?",
- /* 90 */ "?", "?", "?", "?", "?", "?", "?", "?",
- /* 98 */ "?", "?", "?", "?", "?", "?", "?", "?",
- /* a0 */ "REPORT_LUNS", "BLANK", "SEND_EVENT", "REPORT_DEVICE_IDENTIFIER/SEND_KEY", "SET_DEVICE_IDENTIFIER/REPORT_KEY", "PLAY_AUDIO_12", "LOAD_UNLOAD_MEDIUM", "MOVE_MEDIUM_ATTACHED/SET_READ_AHEAD",
- /* a8 */ "READ_12", "PLAY_RELATIVE_12", "WRITE_12", "?", "ERASE_12/GET_PERFORMANCE", "READ_DVD_STRUCTURE", "WRITE_AND_VERIFY_12", "VERIFY_12",
- /* b0 */ "SEARCH_DATA_HIGH_12", "SEARCH_DATA_EQUAL_12", "SEARCH_DATA_LOW_12", "SET_LIMITS_12", "READ_ELEMENT_STATUS_ATTACHED", "?", "SET_STREAMING", "READ_DEFECT_DATA_12",
- /* b8 */ "?", "READ_CD_MSF", "SCAN_MMC", "SET_CD_SPEED", "PLAY_CD", "MECHANISM_STATUS", "READ_CD", "SEND_DVD_STRUCTURE",
- /* c0 */ "?", "?", "?", "?", "?", "?", "?", "?",
- /* c8 */ "?", "?", "?", "?", "?", "?", "?", "?",
- /* d0 */ "?", "?", "?", "?", "?", "?", "?", "?",
- /* d8 */ "?", "?", "?", "?", "?", "?", "?", "?",
- /* e0 */ "?", "?", "?", "?", "?", "?", "?", "?",
- /* e8 */ "?", "?", "?", "?", "?", "?", "?", "?",
- /* f0 */ "?", "?", "?", "?", "?", "?", "?", "?",
- /* f8 */ "?", "?", "?", "?", "?", "?", "?", "?",
-};
-
-void nscsi_full_device::device_start()
-{
- nscsi_device::device_start();
- scsi_timer = timer_alloc(SCSI_TIMER);
- save_item(NAME(scsi_cmdbuf));
- save_item(NAME(scsi_sense_buffer));
- save_item(NAME(scsi_cmdsize));
- save_item(NAME(scsi_identify));
- save_item(NAME(scsi_state));
- save_item(NAME(scsi_substate));
- save_item(NAME(scsi_initiator_id));
- save_item(NAME(data_buffer_id));
- save_item(NAME(data_buffer_size));
- save_item(NAME(data_buffer_pos));
- save_item(NAME(buf_control_rpos));
- save_item(NAME(buf_control_wpos));
- for(int i=0; i<32; i++) {
- save_item(NAME(buf_control[i].action), i);
- save_item(NAME(buf_control[i].param1), i);
- save_item(NAME(buf_control[i].param2), i);
- }
-}
-
-void nscsi_full_device::device_reset()
-{
- scsi_state = scsi_substate = IDLE;
- buf_control_rpos = buf_control_wpos = 0;
- scsi_identify = 0;
- scsi_bus->data_w(scsi_refid, 0);
- scsi_bus->ctrl_w(scsi_refid, 0, S_ALL);
- scsi_bus->ctrl_wait(scsi_refid, S_SEL|S_BSY|S_RST, S_ALL);
-}
-
-void nscsi_full_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if(id != SCSI_TIMER)
- return;
-
- step(true);
-
-}
-
-void nscsi_full_device::scsi_ctrl_changed()
-{
- step(false);
-}
-
-void nscsi_full_device::step(bool timeout)
-{
- UINT32 ctrl = scsi_bus->ctrl_r();
- UINT32 data = scsi_bus->data_r();
- if(ctrl & S_RST) {
- scsi_bus->data_w(scsi_refid, 0);
- scsi_bus->ctrl_w(scsi_refid, 0, S_ALL);
- scsi_state = IDLE;
- logerror("%s: scsi bus reset\n", tag());
- return;
- }
-
- if(0)
- logerror("%s: state=%d.%d %s\n",
- tag(), scsi_state & STATE_MASK, (scsi_state & SUB_MASK) >> SUB_SHIFT,
- timeout ? "timeout" : "change");
-
- switch(scsi_state & SUB_MASK ? scsi_state & SUB_MASK : scsi_state & STATE_MASK) {
- case IDLE:
- if(((ctrl & (S_SEL|S_BSY)) == S_SEL) && (scsi_id != -1) && ((data & (1 << scsi_id)) != 0)) {
- for(scsi_initiator_id = 0; scsi_initiator_id != 16 && (scsi_initiator_id == scsi_id || (data & (1 << scsi_initiator_id))); scsi_initiator_id++);
- if(scsi_initiator_id == 16)
- scsi_initiator_id = -1;
- scsi_state = TARGET_SELECT_WAIT_BUS_SETTLE;
- scsi_timer->adjust(scsi_bus_settle_delay());
- }
- break;
-
- case TARGET_SELECT_WAIT_BUS_SETTLE:
- if((ctrl & (S_SEL|S_BSY)) == S_SEL) {
- scsi_state = TARGET_SELECT_WAIT_SEL_0;
- scsi_bus->ctrl_w(scsi_refid, S_BSY, S_BSY);
- } else
- scsi_state = IDLE;
- break;
-
- case TARGET_SELECT_WAIT_SEL_0:
- if(ctrl & S_SEL)
- break;
- buf_control_push()->action = BC_MSG_OR_COMMAND;
- scsi_state = TARGET_NEXT_CONTROL;
- step(false);
- break;
-
- case RECV_BYTE_T_WAIT_ACK_1 << SUB_SHIFT:
- if(ctrl & S_ACK) {
- scsi_put_data(data_buffer_id, data_buffer_pos++, scsi_bus->data_r());
- scsi_state = (scsi_state & STATE_MASK) | (RECV_BYTE_T_WAIT_ACK_0 << SUB_SHIFT);
- scsi_bus->ctrl_w(scsi_refid, 0, S_REQ);
- }
- break;
-
- case RECV_BYTE_T_WAIT_ACK_0 << SUB_SHIFT:
- if(!(ctrl & S_ACK)) {
- scsi_state &= STATE_MASK;
- scsi_bus->ctrl_wait(scsi_refid, 0, S_ACK);
- step(false);
- }
- break;
-
- case SEND_BYTE_T_WAIT_ACK_1 << SUB_SHIFT:
- if(ctrl & S_ACK) {
- scsi_state = (scsi_state & STATE_MASK) | (SEND_BYTE_T_WAIT_ACK_0 << SUB_SHIFT);
- scsi_bus->data_w(scsi_refid, 0);
- scsi_bus->ctrl_w(scsi_refid, 0, S_REQ);
- }
- break;
-
- case SEND_BYTE_T_WAIT_ACK_0 << SUB_SHIFT:
- if(!(ctrl & S_ACK)) {
- scsi_state &= STATE_MASK;
- scsi_bus->ctrl_wait(scsi_refid, 0, S_ACK);
- step(false);
- }
- break;
-
- case TARGET_NEXT_CONTROL: {
- control *ctl = buf_control_pop();
- switch(ctl->action) {
- case BC_MSG_OR_COMMAND:
- data_buffer_id = SBUF_MAIN;
- data_buffer_pos = 0;
- if(ctrl & S_ATN) {
- scsi_state = TARGET_WAIT_MSG_BYTE;
- scsi_bus->ctrl_w(scsi_refid, S_PHASE_MSG_OUT, S_PHASE_MASK);
- } else {
- scsi_state = TARGET_WAIT_CMD_BYTE;
- scsi_bus->ctrl_w(scsi_refid, S_PHASE_COMMAND, S_PHASE_MASK);
- }
- target_recv_byte();
- break;
-
- case BC_STATUS:
- scsi_bus->ctrl_w(scsi_refid, S_PHASE_STATUS, S_PHASE_MASK);
- target_send_byte(ctl->param1);
- break;
-
- case BC_DATA_IN:
- scsi_bus->ctrl_w(scsi_refid, S_PHASE_DATA_IN, S_PHASE_MASK);
- data_buffer_id = ctl->param1;
- data_buffer_size = ctl->param2;
- data_buffer_pos = 0;
- scsi_state = TARGET_WAIT_DATA_IN_BYTE;
- target_send_buffer_byte();
- break;
-
- case BC_DATA_OUT:
- scsi_bus->ctrl_w(scsi_refid, S_PHASE_DATA_OUT, S_PHASE_MASK);
- data_buffer_id = ctl->param1;
- data_buffer_size = ctl->param2;
- data_buffer_pos = 0;
- scsi_state = TARGET_WAIT_DATA_OUT_BYTE;
- target_recv_byte();
- break;
-
- case BC_MESSAGE_1:
- scsi_bus->ctrl_w(scsi_refid, S_PHASE_MSG_IN, S_PHASE_MASK);
- target_send_byte(ctl->param1);
- break;
-
- case BC_BUS_FREE:
- scsi_bus->data_w(scsi_refid, 0);
- scsi_bus->ctrl_wait(scsi_refid, S_BSY|S_SEL|S_RST, S_ALL);
- scsi_bus->ctrl_w(scsi_refid, 0, S_ALL);
- scsi_state = IDLE;
- break;
- };
- break;
- }
-
- case TARGET_WAIT_DATA_IN_BYTE:
- if(data_buffer_pos == data_buffer_size-1)
- scsi_state = TARGET_NEXT_CONTROL;
- target_send_buffer_byte();
- break;
-
- case TARGET_WAIT_DATA_OUT_BYTE:
- if(data_buffer_pos == data_buffer_size-1)
- scsi_state = TARGET_NEXT_CONTROL;
- target_recv_byte();
- break;
-
- case TARGET_WAIT_MSG_BYTE:
- if(ctrl & S_SEL)
- return;
- if(!(ctrl & S_ATN)) {
- scsi_cmdsize = data_buffer_pos;
- scsi_message();
- data_buffer_id = SBUF_MAIN;
- data_buffer_pos = 0;
- scsi_state = TARGET_WAIT_CMD_BYTE;
- scsi_bus->ctrl_w(scsi_refid, S_PHASE_COMMAND, S_PHASE_MASK);
- }
- target_recv_byte();
- break;
-
- case TARGET_WAIT_CMD_BYTE:
- if(ctrl & S_SEL)
- return;
- if(ctrl & S_ATN) {
- logerror("%s: Parity error? Say what?\n", tag());
- scsi_state = IDLE;
- break;
- }
-
- if(command_done()) {
- scsi_cmdsize = data_buffer_pos;
- scsi_bus->ctrl_wait(scsi_refid, 0, S_ACK);
- scsi_command();
- scsi_state = TARGET_NEXT_CONTROL;
- step(false);
- } else
- target_recv_byte();
- break;
-
- default:
- logerror("%s: step() unexpected state %d.%d\n",
- tag(),
- scsi_state & STATE_MASK, (scsi_state & SUB_MASK) >> SUB_SHIFT);
- exit(0);
- }
-}
-
-void nscsi_full_device::target_recv_byte()
-{
- scsi_bus->ctrl_wait(scsi_refid, S_ACK, S_ACK);
- scsi_state = (scsi_state & STATE_MASK) | (RECV_BYTE_T_WAIT_ACK_1 << SUB_SHIFT);
- scsi_bus->ctrl_w(scsi_refid, S_REQ, S_REQ);
- step(false);
-}
-
-void nscsi_full_device::target_send_byte(UINT8 val)
-{
- scsi_bus->ctrl_wait(scsi_refid, S_ACK, S_ACK);
- scsi_state = (scsi_state & STATE_MASK) | (SEND_BYTE_T_WAIT_ACK_1 << SUB_SHIFT);
- scsi_bus->data_w(scsi_refid, val);
- scsi_bus->ctrl_w(scsi_refid, S_REQ, S_REQ);
- step(false);
-}
-
-UINT8 nscsi_full_device::scsi_get_data(int id, int pos)
-{
- switch(id) {
- case SBUF_MAIN:
- return scsi_cmdbuf[pos];
- case SBUF_SENSE:
- return scsi_sense_buffer[pos];
- default:
- fatalerror("nscsi_full_device::scsi_get_data - unknown id\n");
- }
-}
-
-void nscsi_full_device::scsi_put_data(int id, int pos, UINT8 data)
-{
- switch(id) {
- case SBUF_MAIN:
- scsi_cmdbuf[pos] = data;
- break;
- case SBUF_SENSE:
- scsi_sense_buffer[pos] = data;
- break;
- default:
- fatalerror("nscsi_full_device::scsi_put_data - unknown id\n");
- }
-}
-
-void nscsi_full_device::target_send_buffer_byte()
-{
- target_send_byte(scsi_get_data(data_buffer_id, data_buffer_pos++));
-}
-
-bool nscsi_full_device::command_done()
-{
- if(!data_buffer_pos)
- return false;
- UINT8 h = scsi_cmdbuf[0];
- switch(h >> 5) {
- case 0: return data_buffer_pos == 6;
- case 1: return data_buffer_pos == 10;
- case 2: return data_buffer_pos == 10;
- case 3: return true;
- case 4: return true;
- case 5: return data_buffer_pos == 12;
- case 6: return true;
- case 7: return true;
- }
- return true;
-}
-
-nscsi_full_device::control *nscsi_full_device::buf_control_push()
-{
- if(buf_control_wpos == int(ARRAY_LENGTH(buf_control)))
- throw emu_fatalerror("%s: buf_control overflow\n", tag());
-
- control *c = buf_control + buf_control_wpos;
- buf_control_wpos++;
- return c;
-}
-
-nscsi_full_device::control *nscsi_full_device::buf_control_pop()
-{
- if(buf_control_rpos == buf_control_wpos)
- throw emu_fatalerror("%s: buf_control underflow\n", tag());
-
- control *c = buf_control + buf_control_rpos;
- buf_control_rpos++;
- if(buf_control_rpos == buf_control_wpos)
- buf_control_rpos = buf_control_wpos = 0;
- return c;
-}
-
-void nscsi_full_device::scsi_status_complete(UINT8 st)
-{
- control *c;
- c = buf_control_push();
- c->action = BC_STATUS;
- c->param1 = st;
- c = buf_control_push();
- c->action = BC_MESSAGE_1;
- c->param1 = SM_COMMAND_COMPLETE;
- c = buf_control_push();
- c->action = BC_BUS_FREE;
-}
-
-void nscsi_full_device::scsi_data_in(int buf, int size)
-{
- control *c;
- c = buf_control_push();
- c->action = BC_DATA_IN;
- c->param1 = buf;
- c->param2 = size;
-}
-
-void nscsi_full_device::scsi_data_out(int buf, int size)
-{
- control *c;
- c = buf_control_push();
- c->action = BC_DATA_OUT;
- c->param1 = buf;
- c->param2 = size;
-}
-
-void nscsi_full_device::sense(bool deferred, UINT8 key)
-{
- memset(scsi_sense_buffer, 0, sizeof(scsi_sense_buffer));
- scsi_sense_buffer[0] = deferred ? 0x71 : 0x70;
- scsi_sense_buffer[2] = key;
-}
-
-void nscsi_full_device::scsi_unknown_command()
-{
- logerror("%s: Unhandled command %s", tag(), command_names[scsi_cmdbuf[0]]);
- for(int i=0; i != scsi_cmdsize; i++)
- logerror(" %02x", scsi_cmdbuf[i]);
- logerror("\n");
-
- scsi_status_complete(SS_CHECK_CONDITION);
- sense(false, 5);
-}
-
-void nscsi_full_device::scsi_command()
-{
- switch(scsi_cmdbuf[0]) {
- case SC_REQUEST_SENSE:
- logerror("%s: command REQUEST SENSE\n", tag());
- scsi_data_in(SBUF_SENSE, 8);
- scsi_status_complete(SS_GOOD);
- break;
- default:
- scsi_unknown_command();
- break;
- }
-}
-
-void nscsi_full_device::scsi_message()
-{
- if(scsi_cmdbuf[0] & 0x80) {
- scsi_identify = scsi_cmdbuf[0];
- return;
- }
-
- logerror("%s: Unknown message", tag());
- for(int i=0; i != scsi_cmdsize; i++)
- logerror(" %02x", scsi_cmdbuf[i]);
- logerror("\n");
-}
-
-int nscsi_full_device::get_lun(int def)
-{
- if(scsi_identify & 0x80)
- return scsi_identify & 0x7f;
- return def;
-}
-
-void nscsi_full_device::bad_lun()
-{
- scsi_status_complete(SS_CHECK_CONDITION);
- sense(false, 2);
-}
-
-// Arbitration delay (2.4us)
-attotime nscsi_full_device::scsi_arbitation_delay()
-{
- return attotime::from_nsec(2400);
-}
-
-// Assertion period (90ns)
-attotime nscsi_full_device::scsi_assertion_period()
-{
- return attotime::from_nsec(90);
-}
-
-// Bus clear delay (800ns)
-attotime nscsi_full_device::scsi_bus_clear_delay()
-{
- return attotime::from_nsec(800);
-}
-
-// Bus free delay (800ns)
-attotime nscsi_full_device::scsi_bus_free_delay()
-{
- return attotime::from_nsec(800);
-}
-
-// Bus set delay (1.8us)
-attotime nscsi_full_device::scsi_bus_set_delay()
-{
- return attotime::from_nsec(1800);
-}
-
-// Bus settle delay (400ns)
-attotime nscsi_full_device::scsi_bus_settle_delay()
-{
- return attotime::from_nsec(400);
-}
-
-// Cable skew delay (10ns)
-attotime nscsi_full_device::scsi_cable_skew_delay()
-{
- return attotime::from_nsec(10);
-}
-
-// Data release delay (400ns)
-attotime nscsi_full_device::scsi_data_release_delay()
-{
- return attotime::from_nsec(40);
-}
-
-// Deskew delay (45ns)
-attotime nscsi_full_device::scsi_deskew_delay()
-{
- return attotime::from_nsec(45);
-}
-
-// Disconnection delay (200us)
-attotime nscsi_full_device::scsi_disconnection_delay()
-{
- return attotime::from_usec(200);
-}
-
-// Hold time (45ns)
-attotime nscsi_full_device::scsi_hold_time()
-{
- return attotime::from_nsec(45);
-}
-
-// Negation period (90ns)
-attotime nscsi_full_device::scsi_negation_period()
-{
- return attotime::from_nsec(90);
-}
-
-// Reset hold time (25us)
-attotime nscsi_full_device::scsi_reset_hold_time()
-{
- return attotime::from_usec(25);
-}
-
-// Selection abort time (200us)
-attotime nscsi_full_device::scsi_selection_abort_time()
-{
- return attotime::from_usec(200);
-}
-
-// Selection timeout delay (250ms)
-attotime nscsi_full_device::scsi_selection_timeout_delay()
-{
- return attotime::from_msec(250);
-}
-
-// Fast assertion period (30ns)
-attotime nscsi_full_device::scsi_fast_assertion_period()
-{
- return attotime::from_nsec(30);
-}
-
-// Fast cable skew delay (5ns)
-attotime nscsi_full_device::scsi_fast_cable_skew_delay()
-{
- return attotime::from_nsec(5);
-}
-
-// Fast deskew delay (20ns)
-attotime nscsi_full_device::scsi_fast_deskew_delay()
-{
- return attotime::from_nsec(20);
-}
-
-// Fast hold time (10ns)
-attotime nscsi_full_device::scsi_fast_hold_time()
-{
- return attotime::from_nsec(10);
-}
-
-// Fast negation period (30ns)
-attotime nscsi_full_device::scsi_fast_negation_period()
-{
- return attotime::from_nsec(30);
-}
diff --git a/src/emu/machine/nscsi_bus.h b/src/emu/machine/nscsi_bus.h
deleted file mode 100644
index 2aa4a57db7e..00000000000
--- a/src/emu/machine/nscsi_bus.h
+++ /dev/null
@@ -1,428 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef __NSCSI_BUS_H__
-#define __NSCSI_BUS_H__
-
-#include "emu.h"
-
-#define MCFG_NSCSI_BUS_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, NSCSI_BUS, 0)
-
-#define MCFG_NSCSI_ADD(_tag, _slot_intf, _def_slot, _fixed) \
- MCFG_DEVICE_ADD(_tag, NSCSI_CONNECTOR, 0) \
- MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _fixed)
-
-class nscsi_device;
-
-class nscsi_bus_device : public device_t
-{
-public:
- nscsi_bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- void ctrl_w(int refid, UINT32 lines, UINT32 mask);
- void data_w(int refid, UINT32 lines);
- void ctrl_wait(int refid, UINT32 lines, UINT32 mask);
-
- UINT32 ctrl_r() const;
- UINT32 data_r() const;
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_config_complete();
-
-private:
- struct dev_t {
- nscsi_device *dev;
- UINT32 ctrl, wait_ctrl;
- UINT32 data;
- };
-
- dev_t dev[16];
- int devcnt;
-
- UINT32 data, ctrl;
-
- void regen_data();
- void regen_ctrl(int refid);
-};
-
-class nscsi_connector: public device_t,
- public device_slot_interface
-{
-public:
- nscsi_connector(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- virtual ~nscsi_connector();
-
- nscsi_device *get_device();
-
-protected:
- virtual void device_start();
-};
-
-class nscsi_device : public device_t,
- public device_slot_card_interface
-{
-public:
- // Here because the biggest users are the devices, not the bus
- enum {
- S_INP = 0x0001,
- S_CTL = 0x0002,
- S_MSG = 0x0004,
- S_BSY = 0x0008,
- S_SEL = 0x0010,
- S_REQ = 0x0020,
- S_ACK = 0x0040,
- S_ATN = 0x0080,
- S_RST = 0x0100,
- S_ALL = 0x01ff,
-
- S_PHASE_DATA_OUT = 0,
- S_PHASE_DATA_IN = S_INP,
- S_PHASE_COMMAND = S_CTL,
- S_PHASE_STATUS = S_CTL|S_INP,
- S_PHASE_MSG_OUT = S_MSG|S_CTL,
- S_PHASE_MSG_IN = S_MSG|S_CTL|S_INP,
- S_PHASE_MASK = S_MSG|S_CTL|S_INP
- };
-
- nscsi_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- void connect_to_bus(nscsi_bus_device *bus, int refid, int default_scsi_id);
- virtual void scsi_ctrl_changed();
-protected:
- int scsi_id;
- int scsi_refid;
- nscsi_bus_device *scsi_bus;
-
- virtual void device_start();
-};
-
-class nscsi_full_device : public nscsi_device
-{
-public:
- nscsi_full_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- virtual void scsi_ctrl_changed();
-protected:
- enum { SCSI_TIMER = 100 };
-
- // SCSI status returns
- enum {
- SS_GOOD = 0x00,
- SS_CHECK_CONDITION = 0x02,
- SS_CONDITION_MET = 0x04,
- SS_BUSY = 0x08,
- SS_INT_GOOD = 0x10,
- SS_INT_CONDITION_MET = 0x14,
- SS_RESV_CONFLICT = 0x18,
- SS_TERMINATED = 0x22,
- SS_QUEUE_FULL = 0x28
- };
-
- // SCSI commands
- static const char *const command_names[256];
- enum {
- SC_TEST_UNIT_READY = 0x00,
- SC_REZERO = 0x01,
- SC_REQUEST_SENSE = 0x03,
- SC_FORMAT_UNIT = 0x04,
- SC_REASSIGN_BLOCKS = 0x07,
- SC_READ_6 = 0x08,
- SC_RECIEVE = 0x08,
- SC_WRITE_6 = 0x0a,
- SC_SEND = 0x0a,
- SC_SEEK = 0x0b,
- SC_INQUIRY = 0x12,
- SC_MODE_SELECT_6 = 0x15,
- SC_RESERVE_6 = 0x16,
- SC_RELEASE_6 = 0x17,
- SC_MODE_SENSE_6 = 0x1a,
- SC_START_STOP_UNIT = 0x1b,
- SC_RECIEVE_DIAG_RES = 0x1c,
- SC_SEND_DIAGNOSTICS = 0x1d,
- SC_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1e,
- SC_READ_FORMAT_CAPACITIES = 0x23,
- SC_READ_CAPACITY = 0x25,
- SC_READ_10 = 0x28,
- SC_READ_GENERATION = 0x29,
- SC_WRITE_10 = 0x2a,
- SC_SEEK_10 = 0x2b,
- SC_ERASE_10 = 0x2c,
- SC_READ_UPDATED_BLOCK_10 = 0x2d,
- SC_WRITE_VERIFY = 0x2e,
- SC_VERIFY = 0x2f,
- SC_SEARCH_DATA_HIGH_10 = 0x30,
- SC_SEARCH_DATA_EQUAL_10 = 0x31,
- SC_SEARCH_DATA_LOW_10 = 0x32,
- SC_SET_LIMITS_10 = 0x33,
- SC_PREFETCH = 0x34,
- SC_SYNC_CACHE = 0x35,
- SC_LOCK_UNLOCK_CACHE = 0x36,
- SC_READ_DEFECT_DATA = 0x37,
- SC_MEDIUM_SCAN = 0x38,
- SC_COMPARE = 0x39,
- SC_COPY_AND_VERIFY = 0x3a,
- SC_WRITE_BUFFER = 0x3b,
- SC_READ_DATA_BUFFER = 0x3c,
- SC_UPDATE_BLOCK = 0x3d,
- SC_READ_LONG = 0x3e,
- SC_WRITE_LONG = 0x3f,
- SC_CHANGE_DEFINITION = 0x40,
- SC_WRITE_SAME = 0x41,
- SC_READ_SUB_CHANNEL = 0x42,
- SC_READ_TOC_PMA_ATIP = 0x43,
- SC_READ_HEADER = 0x44,
- SC_PLAY_AUDIO_10 = 0x45,
- SC_GET_CONFIGURATION = 0x46,
- SC_PLAY_AUDIO_MSF = 0x47,
- SC_PLAY_AUDIO_TRACK_INDEX = 0x48,
- SC_PLAY_RELATIVE_10 = 0x49,
- SC_GET_EVENT_STATUS_NOTIFICATION = 0x4a,
- SC_PAUSE_RESUME = 0x4b,
- SC_LOG_SELECT = 0x4c,
- SC_LOG_SENSE = 0x4d,
- SC_STOP_PLAY_SCAN = 0x4e,
- SC_XDWRITE = 0x50,
- SC_XPWRITE = 0x51,
- SC_READ_DISC_INFORMATION = 0x51,
- SC_READ_TRACK_INFORMATION = 0x52,
- SC_XDREAD = 0x52,
- SC_RESERVE_TRACK = 0x53,
- SC_SEND_OPC_INFORMATION = 0x54,
- SC_MODE_SELECT_10 = 0x55,
- SC_RESERVE_10 = 0x56,
- SC_RELEASE_10 = 0x57,
- SC_REPAIR_TRACK = 0x58,
- SC_READ_MASTER_CUE = 0x59,
- SC_MODE_SENSE_10 = 0x5a,
- SC_CLOSE_TRACK_SESSION = 0x5b,
- SC_READ_BUFFER_CAPACITY = 0x5c,
- SC_SEND_CUE_SHEET = 0x5d,
- SC_PERSISTENT_RESERVE_IN = 0x5e,
- SC_PERSISTENT_RESERVE_OUT = 0x5f,
- SC_XDWRITE_EXTENDED = 0x80,
- SC_REBUILD = 0x81,
- SC_REGENERATE = 0x82,
- SC_EXTENDED_COPY = 0x83,
- SC_RECEIVE_COPY_RESULTS = 0x84,
- SC_REPORT_LUNS = 0xa0,
- SC_BLANK = 0xa1,
- SC_SEND_EVENT = 0xa2,
- SC_REPORT_DEVICE_IDENTIFIER = 0xa3,
- SC_SEND_KEY = 0xa3,
- SC_REPORT_KEY = 0xa4,
- SC_SET_DEVICE_IDENTIFIER = 0xa4,
- SC_PLAY_AUDIO_12 = 0xa5,
- SC_LOAD_UNLOAD_MEDIUM = 0xa6,
- SC_MOVE_MEDIUM_ATTACHED = 0xa7,
- SC_SET_READ_AHEAD = 0xa7,
- SC_READ_12 = 0xa8,
- SC_PLAY_RELATIVE_12 = 0xa9,
- SC_WRITE_12 = 0xaa,
- SC_ERASE_12 = 0xac,
- SC_GET_PERFORMANCE = 0xac,
- SC_READ_DVD_STRUCTURE = 0xad,
- SC_WRITE_AND_VERIFY_12 = 0xae,
- SC_VERIFY_12 = 0xaf,
- SC_SEARCH_DATA_HIGH_12 = 0xb0,
- SC_SEARCH_DATA_EQUAL_12 = 0xb1,
- SC_SEARCH_DATA_LOW_12 = 0xb2,
- SC_SET_LIMITS_12 = 0xb3,
- SC_READ_ELEMENT_STATUS_ATTACHED = 0xb4,
- SC_SET_STREAMING = 0xb6,
- SC_READ_DEFECT_DATA_12 = 0xb7,
- SC_READ_CD_MSF = 0xb9,
- SC_SCAN_MMC = 0xba,
- SC_SET_CD_SPEED = 0xbb,
- SC_PLAY_CD = 0xbc,
- SC_MECHANISM_STATUS = 0xbd,
- SC_READ_CD = 0xbe,
- SC_SEND_DVD_STRUCTURE = 0xbf
- };
-
- // SCSI Messages
- enum {
- SM_COMMAND_COMPLETE = 0x00,
- SM_EXTENDED_MSG = 0x01,
- SM_SAVE_DATA_PTR = 0x02,
- SM_RESTORE_PTR = 0x03,
- SM_DISCONNECT = 0x04,
- SM_INITIATOR_ERROR = 0x05,
- SM_ABORT = 0x06,
- SM_MSG_REJECT = 0x07,
- SM_NOP = 0x08,
- SM_MSG_PARITY = 0x09,
- SM_LCMD_COMPLETE = 0x0a,
- SM_LCMD_COMPLETE_F = 0x0b,
- SM_BUS_DEVICE_RESET = 0x0c,
- SM_ABORT_TAG = 0x0d,
- SM_CLEAR_QUEUE = 0x0e,
- SM_INIT_RECOVERY = 0x0f,
- SM_RELEASE_RECOVERY = 0x10,
- SM_TERMINATE_IO = 0x11,
- SM_SIMPLE_QUEUE = 0x20,
- SM_HEAD_QUEUE = 0x21,
- SM_ORDERED_QUEUE = 0x22,
- SM_IGNORE_WIDE_RES = 0x23
- };
-
- enum {
- SBUF_MAIN,
- SBUF_SENSE
- };
-
- UINT8 scsi_cmdbuf[4096], scsi_sense_buffer[8];
- int scsi_cmdsize;
- UINT8 scsi_identify;
-
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- virtual void scsi_message();
- virtual void scsi_command();
-
- void scsi_unknown_command();
- void scsi_status_complete(UINT8 st);
- void scsi_data_in(int buf, int size);
- void scsi_data_out(int buf, int size);
-
- void sense(bool deferred, UINT8 key);
- int get_lun(int def = 0);
- void bad_lun();
-
- virtual UINT8 scsi_get_data(int buf, int offset);
- virtual void scsi_put_data(int buf, int offset, UINT8 data);
-
- // Default delays:
-
- // Arbitration delay (2.4us)
- virtual attotime scsi_arbitation_delay();
-
- // Assertion period (90ns)
- virtual attotime scsi_assertion_period();
-
- // Bus clear delay (800ns)
- virtual attotime scsi_bus_clear_delay();
-
- // Bus free delay (800ns)
- virtual attotime scsi_bus_free_delay();
-
- // Bus set delay (1.8us)
- virtual attotime scsi_bus_set_delay();
-
- // Bus settle delay (400ns)
- virtual attotime scsi_bus_settle_delay();
-
- // Cable skew delay (10ns)
- virtual attotime scsi_cable_skew_delay();
-
- // Data release delay (400ns)
- virtual attotime scsi_data_release_delay();
-
- // Deskew delay (45ns)
- virtual attotime scsi_deskew_delay();
-
- // Disconnection delay (200us)
- virtual attotime scsi_disconnection_delay();
-
- // Hold time (45ns)
- virtual attotime scsi_hold_time();
-
- // Negation period (90ns)
- virtual attotime scsi_negation_period();
-
- // Reset hold time (25us)
- virtual attotime scsi_reset_hold_time();
-
- // Selection abort time (200us)
- virtual attotime scsi_selection_abort_time();
-
- // Selection timeout delay (250ms)
- virtual attotime scsi_selection_timeout_delay();
-
- // Fast assertion period (30ns)
- virtual attotime scsi_fast_assertion_period();
-
- // Fast cable skew delay (5ns)
- virtual attotime scsi_fast_cable_skew_delay();
-
- // Fast deskew delay (20ns)
- virtual attotime scsi_fast_deskew_delay();
-
- // Fast hold time (10ns)
- virtual attotime scsi_fast_hold_time();
-
- // Fast negation period (30ns)
- virtual attotime scsi_fast_negation_period();
-
-private:
- enum {
- IDLE
- };
-
- enum {
- TARGET_SELECT_WAIT_BUS_SETTLE = 1,
- TARGET_SELECT_WAIT_SEL_0,
-
- TARGET_NEXT_CONTROL,
- TARGET_WAIT_MSG_BYTE,
- TARGET_WAIT_CMD_BYTE,
- TARGET_WAIT_DATA_IN_BYTE,
- TARGET_WAIT_DATA_OUT_BYTE
- };
-
- enum {
- RECV_BYTE_T_WAIT_ACK_0 = 1,
- RECV_BYTE_T_WAIT_ACK_1,
- SEND_BYTE_T_WAIT_ACK_0,
- SEND_BYTE_T_WAIT_ACK_1
- };
-
- enum {
- STATE_MASK = 0x00ff,
- SUB_SHIFT = 8,
- SUB_MASK = 0xff00
- };
-
- enum {
- BC_MSG_OR_COMMAND,
- BC_STATUS,
- BC_MESSAGE_1,
- BC_MESSAGE_2,
- BC_DATA_IN,
- BC_DATA_OUT,
- BC_BUS_FREE
- };
-
- struct control {
- int action;
- int param1, param2;
- };
-
- emu_timer *scsi_timer;
-
- int scsi_state, scsi_substate;
- int scsi_initiator_id;
- int data_buffer_id, data_buffer_size, data_buffer_pos;
-
- control buf_control[32];
- int buf_control_rpos;
- int buf_control_wpos;
-
- control *buf_control_push();
- control *buf_control_pop();
-
- void step(bool timeout);
- void target_recv_byte();
- void target_send_byte(UINT8 val);
- void target_send_buffer_byte();
- bool command_done();
-};
-
-
-extern const device_type NSCSI_BUS;
-extern const device_type NSCSI_CONNECTOR;
-
-#endif
diff --git a/src/emu/machine/nscsi_cb.c b/src/emu/machine/nscsi_cb.c
deleted file mode 100644
index 5c3c12e8a34..00000000000
--- a/src/emu/machine/nscsi_cb.c
+++ /dev/null
@@ -1,57 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "nscsi_cb.h"
-
-const device_type NSCSI_CB = &device_creator<nscsi_callback_device>;
-
-nscsi_callback_device::nscsi_callback_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : nscsi_device(mconfig, NSCSI_CB, "SCSI callback (new)", tag, owner, clock, "nscsi_cb", __FILE__),
- m_write_rst(*this),
- m_write_atn(*this),
- m_write_ack(*this),
- m_write_req(*this),
- m_write_msg(*this),
- m_write_io(*this),
- m_write_cd(*this),
- m_write_sel(*this),
- m_write_bsy(*this)
-{
-}
-
-void nscsi_callback_device::device_start()
-{
- // resolve callbacks
- m_write_rst.resolve_safe();
- m_write_atn.resolve_safe();
- m_write_ack.resolve_safe();
- m_write_req.resolve_safe();
- m_write_msg.resolve_safe();
- m_write_io.resolve_safe();
- m_write_cd.resolve_safe();
- m_write_sel.resolve_safe();
- m_write_bsy.resolve_safe();
-
- // state saving
- save_item(NAME(m_ctrl));
-}
-
-void nscsi_callback_device::device_reset()
-{
- scsi_bus->ctrl_w(scsi_refid, 0, S_ALL);
- scsi_bus->ctrl_wait(scsi_refid, S_ALL, S_ALL);
-}
-
-void nscsi_callback_device::scsi_ctrl_changed()
-{
- m_ctrl = scsi_bus->ctrl_r();
-
- m_write_rst((m_ctrl & S_RST) ? 1 : 0);
- m_write_atn((m_ctrl & S_ATN) ? 1 : 0);
- m_write_ack((m_ctrl & S_ACK) ? 1 : 0);
- m_write_req((m_ctrl & S_REQ) ? 1 : 0);
- m_write_msg((m_ctrl & S_MSG) ? 1 : 0);
- m_write_io((m_ctrl & S_INP) ? 1 : 0);
- m_write_cd((m_ctrl & S_CTL) ? 1 : 0);
- m_write_sel((m_ctrl & S_SEL) ? 1 : 0);
- m_write_bsy((m_ctrl & S_BSY) ? 1 : 0);
-}
diff --git a/src/emu/machine/nscsi_cb.h b/src/emu/machine/nscsi_cb.h
deleted file mode 100644
index 9152ddaf8f9..00000000000
--- a/src/emu/machine/nscsi_cb.h
+++ /dev/null
@@ -1,97 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef NSCSI_CB_H
-#define NSCSI_CB_H
-
-#include "emu.h"
-#include "machine/nscsi_bus.h"
-
-#define MCFG_NSCSICB_RST_HANDLER(_line) \
- downcast<nscsi_callback_device *>(device)->set_rst_callback(DEVCB_##_line);
-
-#define MCFG_NSCSICB_ATN_HANDLER(_line) \
- downcast<nscsi_callback_device *>(device)->set_atn_callback(DEVCB_##_line);
-
-#define MCFG_NSCSICB_ACK_HANDLER(_line) \
- downcast<nscsi_callback_device *>(device)->set_ack_callback(DEVCB_##_line);
-
-#define MCFG_NSCSICB_REQ_HANDLER(_line) \
- downcast<nscsi_callback_device *>(device)->set_req_callback(DEVCB_##_line);
-
-#define MCFG_NSCSICB_MSG_HANDLER(_line) \
- downcast<nscsi_callback_device *>(device)->set_msg_callback(DEVCB_##_line);
-
-#define MCFG_NSCSICB_IO_HANDLER(_line) \
- downcast<nscsi_callback_device *>(device)->set_io_callback(DEVCB_##_line);
-
-#define MCFG_NSCSICB_CD_HANDLER(_line) \
- downcast<nscsi_callback_device *>(device)->set_cd_callback(DEVCB_##_line);
-
-#define MCFG_NSCSICB_SEL_HANDLER(_line) \
- downcast<nscsi_callback_device *>(device)->set_sel_callback(DEVCB_##_line);
-
-#define MCFG_NSCSICB_BSY_HANDLER(_line) \
- downcast<nscsi_callback_device *>(device)->set_bsy_callback(DEVCB_##_line);
-
-class nscsi_callback_device : public nscsi_device
-{
-public:
- nscsi_callback_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _line> void set_rst_callback(_line line) { m_write_rst.set_callback(line); }
- template<class _line> void set_atn_callback(_line line) { m_write_atn.set_callback(line); }
- template<class _line> void set_ack_callback(_line line) { m_write_ack.set_callback(line); }
- template<class _line> void set_req_callback(_line line) { m_write_req.set_callback(line); }
- template<class _line> void set_msg_callback(_line line) { m_write_msg.set_callback(line); }
- template<class _line> void set_io_callback(_line line) { m_write_io.set_callback(line); }
- template<class _line> void set_cd_callback(_line line) { m_write_cd.set_callback(line); }
- template<class _line> void set_sel_callback(_line line) { m_write_sel.set_callback(line); }
- template<class _line> void set_bsy_callback(_line line) { m_write_bsy.set_callback(line); }
-
- virtual void scsi_ctrl_changed();
-
- UINT8 read() { return scsi_bus->data_r(); }
- DECLARE_READ8_MEMBER( read ) { return read(); }
- void write(UINT8 data) { scsi_bus->data_w(scsi_refid, data); }
- DECLARE_WRITE8_MEMBER( write ) { write(data); }
-
- DECLARE_READ_LINE_MEMBER( rst_r ) { return (m_ctrl & S_RST) ? 1 : 0; }
- DECLARE_READ_LINE_MEMBER( atn_r ) { return (m_ctrl & S_ATN) ? 1 : 0; }
- DECLARE_READ_LINE_MEMBER( ack_r ) { return (m_ctrl & S_ACK) ? 1 : 0; }
- DECLARE_READ_LINE_MEMBER( req_r ) { return (m_ctrl & S_REQ) ? 1 : 0; }
- DECLARE_READ_LINE_MEMBER( msg_r ) { return (m_ctrl & S_MSG) ? 1 : 0; }
- DECLARE_READ_LINE_MEMBER( io_r ) { return (m_ctrl & S_INP) ? 1 : 0; }
- DECLARE_READ_LINE_MEMBER( cd_r ) { return (m_ctrl & S_CTL) ? 1 : 0; }
- DECLARE_READ_LINE_MEMBER( sel_r ) { return (m_ctrl & S_SEL) ? 1 : 0; }
- DECLARE_READ_LINE_MEMBER( bsy_r ) { return (m_ctrl & S_BSY) ? 1 : 0; }
-
- DECLARE_WRITE_LINE_MEMBER( rst_w ) { scsi_bus->ctrl_w(scsi_refid, state ? S_RST : 0, S_RST); }
- DECLARE_WRITE_LINE_MEMBER( atn_w ) { scsi_bus->ctrl_w(scsi_refid, state ? S_ATN : 0, S_ATN); }
- DECLARE_WRITE_LINE_MEMBER( ack_w ) { scsi_bus->ctrl_w(scsi_refid, state ? S_ACK : 0, S_ACK); }
- DECLARE_WRITE_LINE_MEMBER( req_w ) { scsi_bus->ctrl_w(scsi_refid, state ? S_REQ : 0, S_REQ); }
- DECLARE_WRITE_LINE_MEMBER( msg_w ) { scsi_bus->ctrl_w(scsi_refid, state ? S_MSG : 0, S_MSG); }
- DECLARE_WRITE_LINE_MEMBER( io_w ) { scsi_bus->ctrl_w(scsi_refid, state ? S_INP : 0, S_INP); }
- DECLARE_WRITE_LINE_MEMBER( cd_w ) { scsi_bus->ctrl_w(scsi_refid, state ? S_CTL : 0, S_CTL); }
- DECLARE_WRITE_LINE_MEMBER( sel_w ) { scsi_bus->ctrl_w(scsi_refid, state ? S_SEL : 0, S_SEL); }
- DECLARE_WRITE_LINE_MEMBER( bsy_w ) { scsi_bus->ctrl_w(scsi_refid, state ? S_BSY : 0, S_BSY); }
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
- devcb_write_line m_write_rst;
- devcb_write_line m_write_atn;
- devcb_write_line m_write_ack;
- devcb_write_line m_write_req;
- devcb_write_line m_write_msg;
- devcb_write_line m_write_io;
- devcb_write_line m_write_cd;
- devcb_write_line m_write_sel;
- devcb_write_line m_write_bsy;
-
- UINT32 m_ctrl;
-};
-
-extern const device_type NSCSI_CB;
-
-#endif
diff --git a/src/emu/machine/nscsi_cd.c b/src/emu/machine/nscsi_cd.c
deleted file mode 100644
index c8d8440b3ce..00000000000
--- a/src/emu/machine/nscsi_cd.c
+++ /dev/null
@@ -1,251 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "machine/nscsi_cd.h"
-#include "imagedev/chd_cd.h"
-
-const device_type NSCSI_CDROM = &device_creator<nscsi_cdrom_device>;
-
-nscsi_cdrom_device::nscsi_cdrom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- nscsi_full_device(mconfig, NSCSI_CDROM, "SCSI CDROM", tag, owner, clock, "scsi_cdrom", __FILE__)
-{
-}
-
-void nscsi_cdrom_device::device_start()
-{
- nscsi_full_device::device_start();
- bytes_per_sector = 2048;
- save_item(NAME(block));
- save_item(NAME(lba));
- save_item(NAME(cur_lba));
- save_item(NAME(blocks));
- save_item(NAME(bytes_per_sector));
-}
-
-void nscsi_cdrom_device::device_reset()
-{
- nscsi_full_device::device_reset();
- cdrom = subdevice<cdrom_image_device>("image")->get_cdrom_file();
- lba = 0;
- blocks = 0;
- cur_lba = -1;
-}
-
-static MACHINE_CONFIG_FRAGMENT(scsi_cdrom)
- MCFG_CDROM_ADD("image")
- MCFG_CDROM_INTERFACE("cdrom")
-MACHINE_CONFIG_END
-
-machine_config_constructor nscsi_cdrom_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME(scsi_cdrom);
-}
-
-UINT8 nscsi_cdrom_device::scsi_get_data(int id, int pos)
-{
- if(id != 2)
- return nscsi_full_device::scsi_get_data(id, pos);
- int clba = lba + pos / bytes_per_sector;
- if(clba != cur_lba) {
- cur_lba = clba;
- if(!cdrom_read_data(cdrom, cur_lba, block, CD_TRACK_MODE1)) {
- logerror("%s: CD READ ERROR !\n", tag());
- memset(block, 0, sizeof(block));
- }
- }
- return block[pos & (bytes_per_sector - 1)];
-}
-
-void nscsi_cdrom_device::return_no_cd()
-{
- sense(false, 3);
- scsi_status_complete(SS_CHECK_CONDITION);
-}
-
-void nscsi_cdrom_device::scsi_command()
-{
- switch(scsi_cmdbuf[0]) {
- case SC_TEST_UNIT_READY:
- logerror("%s: command TEST UNIT READY\n", tag());
- if(cdrom)
- scsi_status_complete(SS_GOOD);
- else
- return_no_cd();
- break;
-
- case SC_READ_6:
- if(!cdrom) {
- return_no_cd();
- break;
- }
-
- lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3];
- blocks = scsi_cmdbuf[4];
- if(!blocks)
- blocks = 256;
-
- logerror("%s: command READ start=%08x blocks=%04x\n",
- tag(), lba, blocks);
-
- scsi_data_in(2, blocks*bytes_per_sector);
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_INQUIRY: {
- int lun = get_lun(scsi_cmdbuf[1] >> 5);
- logerror("%s: command INQUIRY lun=%d EVPD=%d page=%d alloc=%02x link=%02x\n",
- tag(),
- lun, scsi_cmdbuf[1] & 1, scsi_cmdbuf[2], scsi_cmdbuf[4], scsi_cmdbuf[5]);
- if(lun) {
- bad_lun();
- return;
- }
-
- int page = scsi_cmdbuf[2];
- int size = scsi_cmdbuf[4];
- switch(page) {
- case 0:
- memset(scsi_cmdbuf, 0, 148);
- scsi_cmdbuf[0] = 0x05; // device is present, device is CD/DVD (MMC-3)
- scsi_cmdbuf[1] = 0x80; // media is removable
- scsi_cmdbuf[2] = 0x05; // device complies with SPC-3 standard
- scsi_cmdbuf[3] = 0x02; // response data format = SPC-3 standard
- // some Konami games freak out if this isn't "Sony", so we'll lie
- // this is the actual drive on my Nagano '98 board
- strcpy((char *)&scsi_cmdbuf[8], "Sony");
- strcpy((char *)&scsi_cmdbuf[16], "CDU-76S");
- strcpy((char *)&scsi_cmdbuf[32], "1.0");
- if(size > 148)
- size = 148;
- scsi_data_in(SBUF_MAIN, size);
- break;
- }
- scsi_status_complete(SS_GOOD);
- break;
- }
-
- case SC_START_STOP_UNIT:
- logerror("%s: command START STOP UNIT\n", tag());
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_READ_CAPACITY: {
- if(!cdrom) {
- return_no_cd();
- break;
- }
-
- logerror("%s: command READ CAPACITY\n", tag());
-
- UINT32 temp = cdrom_get_track_start(cdrom, 0xaa);
- temp--; // return the last used block on the disc
-
- scsi_cmdbuf[0] = (temp>>24) & 0xff;
- scsi_cmdbuf[1] = (temp>>16) & 0xff;
- scsi_cmdbuf[2] = (temp>>8) & 0xff;
- scsi_cmdbuf[3] = (temp & 0xff);
- scsi_cmdbuf[4] = 0;
- scsi_cmdbuf[5] = 0;
- scsi_cmdbuf[6] = (bytes_per_sector>>8)&0xff;
- scsi_cmdbuf[7] = (bytes_per_sector & 0xff);
-
- scsi_data_in(SBUF_MAIN, 8);
- scsi_status_complete(SS_GOOD);
- break;
- }
-
- case SC_READ_10:
- if(!cdrom) {
- return_no_cd();
- break;
- }
-
- lba = (scsi_cmdbuf[2]<<24) | (scsi_cmdbuf[3]<<16) | (scsi_cmdbuf[4]<<8) | scsi_cmdbuf[5];
- blocks = (scsi_cmdbuf[7] << 8) | scsi_cmdbuf[8];
-
- logerror("%s: command READ EXTENDED start=%08x blocks=%04x\n",
- tag(), lba, blocks);
-
- scsi_data_in(2, blocks*bytes_per_sector);
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_MODE_SENSE_6: {
- int lun = get_lun(scsi_cmdbuf[1] >> 5);
- logerror("%s: command MODE SENSE 6 lun=%d page=%02x alloc=%02x link=%02x\n",
- tag(),
- lun, scsi_cmdbuf[2] & 0x3f, scsi_cmdbuf[4], scsi_cmdbuf[5]);
- if(lun) {
- bad_lun();
- return;
- }
-
- int page = scsi_cmdbuf[2] & 0x3f;
- int size = scsi_cmdbuf[4];
- int pos = 1;
- scsi_cmdbuf[pos++] = 0x00; // medium type
- scsi_cmdbuf[pos++] = 0x80; // WP, cache
-
- UINT32 temp = cdrom_get_track_start(cdrom, 0xaa);
- temp--; // return the last used block on the disc
- scsi_cmdbuf[pos++] = 0x08; // Block descriptor length
-
- scsi_cmdbuf[pos++] = (temp>>24) & 0xff;
- scsi_cmdbuf[pos++] = (temp>>16) & 0xff;
- scsi_cmdbuf[pos++] = (temp>>8) & 0xff;
- scsi_cmdbuf[pos++] = (temp & 0xff);
- scsi_cmdbuf[pos++] = 0;
- scsi_cmdbuf[pos++] = 0;
- scsi_cmdbuf[pos++] = (bytes_per_sector>>8)&0xff;
- scsi_cmdbuf[pos++] = (bytes_per_sector & 0xff);
-
- int pmax = page == 0x3f ? 0x3e : page;
- int pmin = page == 0x3f ? 0x00 : page;
- for(int page=pmax; page >= pmin; page--) {
- switch(page) {
- case 0x00: // Unit attention parameters page (weird)
- scsi_cmdbuf[pos++] = 0x80; // PS, page id
- scsi_cmdbuf[pos++] = 0x02; // Page length
- scsi_cmdbuf[pos++] = 0x00; // Meh
- scsi_cmdbuf[pos++] = 0x00; // Double meh
- break;
-
- case 0x02: // Disconnect/reconnect control parameters (guessed)
- scsi_cmdbuf[pos++] = 0x82; // PS, page id
- scsi_cmdbuf[pos++] = 0x0e; // Page length
- scsi_cmdbuf[pos++] = 0xe6; // Buffer full ratio, 90%
- scsi_cmdbuf[pos++] = 0x1a; // Buffer empty ratio, 10%
- scsi_cmdbuf[pos++] = 0x00; // Bus inactivity limit, 0
- scsi_cmdbuf[pos++] = 0x00;
- scsi_cmdbuf[pos++] = 0x00; // Disconnect time limit, 0
- scsi_cmdbuf[pos++] = 0x00;
- scsi_cmdbuf[pos++] = 0x00; // Connect time limit, 0
- scsi_cmdbuf[pos++] = 0x00;
- scsi_cmdbuf[pos++] = 0x00; // Maximum burst size, 0
- scsi_cmdbuf[pos++] = 0x00;
- scsi_cmdbuf[pos++] = 0x00; // EMDP, Dimm, DTDC
- scsi_cmdbuf[pos++] = 0x00; // Reserved
- scsi_cmdbuf[pos++] = 0x00; // Reserved
- scsi_cmdbuf[pos++] = 0x00; // Reserved
- break;
-
- default:
- logerror("%s: mode sense page %02x unhandled\n", tag(), page);
- break;
- }
- }
- scsi_cmdbuf[0] = pos;
- if(pos > size)
- pos = size;
-
- scsi_data_in(0, pos);
- scsi_status_complete(SS_GOOD);
- break;
- }
-
- default:
- fprintf(stderr, "scsi %02x\n", scsi_cmdbuf[0]);
-
- nscsi_full_device::scsi_command();
- break;
- }
-}
diff --git a/src/emu/machine/nscsi_cd.h b/src/emu/machine/nscsi_cd.h
deleted file mode 100644
index a890848152d..00000000000
--- a/src/emu/machine/nscsi_cd.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef __NSCSI_CD_H__
-#define __NSCSI_CD_H__
-
-#include "machine/nscsi_bus.h"
-#include "cdrom.h"
-
-class nscsi_cdrom_device : public nscsi_full_device
-{
-public:
- nscsi_cdrom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- virtual machine_config_constructor device_mconfig_additions() const;
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
- virtual void scsi_command();
- virtual UINT8 scsi_get_data(int id, int pos);
-
-private:
- UINT8 block[2048];
- cdrom_file *cdrom;
- int bytes_per_sector;
- int lba, cur_lba, blocks;
-
- void return_no_cd();
-};
-
-extern const device_type NSCSI_CDROM;
-
-#endif
diff --git a/src/emu/machine/nscsi_hd.c b/src/emu/machine/nscsi_hd.c
deleted file mode 100644
index 96aec81979c..00000000000
--- a/src/emu/machine/nscsi_hd.c
+++ /dev/null
@@ -1,369 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "machine/nscsi_hd.h"
-#include "imagedev/harddriv.h"
-
-const device_type NSCSI_HARDDISK = &device_creator<nscsi_harddisk_device>;
-
-nscsi_harddisk_device::nscsi_harddisk_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- nscsi_full_device(mconfig, NSCSI_HARDDISK, "SCSI HARDDISK", tag, owner, clock, "scsi_harddisk", __FILE__)
-{
-}
-
-nscsi_harddisk_device::nscsi_harddisk_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- nscsi_full_device(mconfig, type, name, tag, owner, clock, shortname, source)
-{
-}
-
-void nscsi_harddisk_device::device_start()
-{
- nscsi_full_device::device_start();
- save_item(NAME(block));
- save_item(NAME(lba));
- save_item(NAME(cur_lba));
- save_item(NAME(blocks));
- save_item(NAME(bytes_per_sector));
-}
-
-void nscsi_harddisk_device::device_reset()
-{
- nscsi_full_device::device_reset();
- harddisk_image_device *hd = subdevice<harddisk_image_device>("image");
- harddisk = hd->get_hard_disk_file();
- if(!harddisk) {
- scsi_id = -1;
- bytes_per_sector = 0;
- } else {
- const hard_disk_info *hdinfo = hard_disk_get_info(harddisk);
- bytes_per_sector = hdinfo->sectorbytes;
- }
- cur_lba = -1;
-}
-
-static MACHINE_CONFIG_FRAGMENT(scsi_harddisk)
- MCFG_HARDDISK_ADD("image")
- MCFG_HARDDISK_INTERFACE("scsi_hdd")
-MACHINE_CONFIG_END
-
-machine_config_constructor nscsi_harddisk_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME(scsi_harddisk);
-}
-
-UINT8 nscsi_harddisk_device::scsi_get_data(int id, int pos)
-{
- if(id != 2)
- return nscsi_full_device::scsi_get_data(id, pos);
- int clba = lba + pos / bytes_per_sector;
- if(clba != cur_lba) {
- cur_lba = clba;
- if(!hard_disk_read(harddisk, cur_lba, block)) {
- logerror("%s: HD READ ERROR !\n", tag());
- memset(block, 0, sizeof(block));
- }
- }
- return block[pos % bytes_per_sector];
-}
-
-void nscsi_harddisk_device::scsi_put_data(int id, int pos, UINT8 data)
-{
- if(id != 2) {
- nscsi_full_device::scsi_put_data(id, pos, data);
- return;
- }
-
- int offset = pos % bytes_per_sector;
- block[offset] = data;
- int clba = lba + pos / bytes_per_sector;
- if(offset == bytes_per_sector-1) {
- if(!hard_disk_write(harddisk, clba, block))
- logerror("%s: HD WRITE ERROR !\n", tag());
- }
-}
-
-void nscsi_harddisk_device::scsi_command()
-{
- #if 0
- if (scsi_cmdbuf[0] != SC_READ)
- {
- logerror("%s: ", tag());
- for (int i = 0; i < 6; i++)
- {
- logerror("%02x ", scsi_cmdbuf[i]);
- }
- logerror("\n");
- }
- #endif
-
- switch(scsi_cmdbuf[0]) {
- case SC_TEST_UNIT_READY:
- logerror("%s: command TEST UNIT READY\n", tag());
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_READ_6:
- lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3];
- blocks = scsi_cmdbuf[4];
- if(!blocks)
- blocks = 256;
-
- logerror("%s: command READ start=%08x blocks=%04x\n",
- tag(), lba, blocks);
-
- scsi_data_in(2, blocks*bytes_per_sector);
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_WRITE_6:
- lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3];
- blocks = scsi_cmdbuf[4];
- if(!blocks)
- blocks = 256;
-
- logerror("%s: command WRITE start=%08x blocks=%04x\n",
- tag(), lba, blocks);
-
- scsi_data_out(2, blocks*bytes_per_sector);
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_INQUIRY: {
- int lun = get_lun(scsi_cmdbuf[1] >> 5);
- logerror("%s: command INQUIRY lun=%d EVPD=%d page=%d alloc=%02x link=%02x\n",
- tag(),
- lun, scsi_cmdbuf[1] & 1, scsi_cmdbuf[2], scsi_cmdbuf[4], scsi_cmdbuf[5]);
- if(lun) {
- bad_lun();
- return;
- }
-
- int page = scsi_cmdbuf[2];
- int size = scsi_cmdbuf[4];
- switch(page) {
- case 0:
- memset(scsi_cmdbuf, 0, 148);
- scsi_cmdbuf[0] = 0x00; // device is direct-access (e.g. hard disk)
- scsi_cmdbuf[1] = 0x00; // media is not removable
- scsi_cmdbuf[2] = 0x05; // device complies with SPC-3 standard
- scsi_cmdbuf[3] = 0x01; // response data format = CCS
- // Apple HD SC setup utility needs to see this
- strcpy((char *)&scsi_cmdbuf[8], " SEAGATE");
- strcpy((char *)&scsi_cmdbuf[15], " ST225N");
- strcpy((char *)&scsi_cmdbuf[31], "1.00");
- scsi_cmdbuf[36] = 0x00; // # of extents high
- scsi_cmdbuf[37] = 0x08; // # of extents low
- scsi_cmdbuf[38] = 0x00; // group 0 commands 0-1f
- scsi_cmdbuf[39] = 0x99; // commands 0,3,4,7
- scsi_cmdbuf[40] = 0xa0; // commands 8, a
- scsi_cmdbuf[41] = 0x27; // commands 12,15,16,17
- scsi_cmdbuf[42] = 0x34; // commands 1a,1b,1d
- scsi_cmdbuf[43] = 0x01; // group 1 commands 20-3f
- scsi_cmdbuf[44] = 0x04;
- scsi_cmdbuf[45] = 0xa0;
- scsi_cmdbuf[46] = 0x01;
- scsi_cmdbuf[47] = 0x18;
- scsi_cmdbuf[48] = 0x07; // group 7 commands e0-ff
- scsi_cmdbuf[49] = 0x00;
- scsi_cmdbuf[50] = 0xa0; // commands 8, a
- scsi_cmdbuf[51] = 0x00;
- scsi_cmdbuf[52] = 0x00;
- scsi_cmdbuf[53] = 0xff; // end of list
- if(size > 54)
- size = 54;
- scsi_data_in(0, size);
- break;
- }
- scsi_status_complete(SS_GOOD);
- break;
- }
-
- case SC_MODE_SENSE_6: {
- int lun = get_lun(scsi_cmdbuf[1] >> 5);
- logerror("%s: command MODE SENSE 6 lun=%d page=%02x alloc=%02x link=%02x\n",
- tag(),
- lun, scsi_cmdbuf[2] & 0x3f, scsi_cmdbuf[4], scsi_cmdbuf[5]);
- if(lun) {
- bad_lun();
- return;
- }
-
- int page = scsi_cmdbuf[2] & 0x3f;
- int size = scsi_cmdbuf[4];
- int pos = 1;
- scsi_cmdbuf[pos++] = 0x00; // medium type
- scsi_cmdbuf[pos++] = 0x00; // WP, cache
-
- hard_disk_info *info = hard_disk_get_info(harddisk);
- UINT32 dsize = info->cylinders * info->heads * info->sectors - 1;
- scsi_cmdbuf[pos++] = 0x08; // Block descriptor length
- scsi_cmdbuf[pos++] = 0x00;
- scsi_cmdbuf[pos++] = (dsize>>16) & 0xff;
- scsi_cmdbuf[pos++] = (dsize>>8) & 0xff;
- scsi_cmdbuf[pos++] = (dsize & 0xff);
- scsi_cmdbuf[pos++] = 0x00;
- scsi_cmdbuf[pos++] = (info->sectorbytes>>16)&0xff;
- scsi_cmdbuf[pos++] = (info->sectorbytes>>8)&0xff;
- scsi_cmdbuf[pos++] = (info->sectorbytes & 0xff);
-
- int pmax = page == 0x3f ? 0x3e : page;
- int pmin = page == 0x3f ? 0x00 : page;
- for(int page=pmax; page >= pmin; page--) {
- switch(page) {
- case 0x00: // Unit attention parameters page (weird)
- scsi_cmdbuf[pos++] = 0x80; // PS, page id
- scsi_cmdbuf[pos++] = 0x02; // Page length
- scsi_cmdbuf[pos++] = 0x00; // Meh
- scsi_cmdbuf[pos++] = 0x00; // Double meh
- break;
-
- case 0x03: { // Format parameters page
- scsi_cmdbuf[pos++] = 0x83; // PS, page id
- scsi_cmdbuf[pos++] = 0x16; // Page length
- scsi_cmdbuf[pos++] = (info->cylinders * info->heads) >> 8; // Track/zone
- scsi_cmdbuf[pos++] = info->cylinders * info->heads; // Track/zone
- scsi_cmdbuf[pos++] = 0x00; // Alt sect/zone
- scsi_cmdbuf[pos++] = 0x00; // Alt sect/zone
- scsi_cmdbuf[pos++] = 0x00; // Alt track/zone
- scsi_cmdbuf[pos++] = 0x00; // Alt track/zone
- scsi_cmdbuf[pos++] = 0x00; // Alt track/volume
- scsi_cmdbuf[pos++] = 0x00; // Alt track/volume
- scsi_cmdbuf[pos++] = info->sectors >> 8; // Sectors/track
- scsi_cmdbuf[pos++] = info->sectors; // Sectors/track
- scsi_cmdbuf[pos++] = info->sectorbytes >> 8; // Bytes/sector
- scsi_cmdbuf[pos++] = info->sectorbytes; // Bytes/sector
- scsi_cmdbuf[pos++] = 0x00; // Interleave
- scsi_cmdbuf[pos++] = 0x00; // Interleave
- scsi_cmdbuf[pos++] = 0x00; // Track skew
- scsi_cmdbuf[pos++] = 0x00; // Track skew
- scsi_cmdbuf[pos++] = 0x00; // Cylinder skew
- scsi_cmdbuf[pos++] = 0x00; // Cylinder skew
- scsi_cmdbuf[pos++] = 0x00; // Sectoring type
- scsi_cmdbuf[pos++] = 0x00; // Reserved
- scsi_cmdbuf[pos++] = 0x00; // Reserved
- scsi_cmdbuf[pos++] = 0x00; // Reserved
- break;
- }
-
- case 0x04: { // Rigid drive geometry page
- scsi_cmdbuf[pos++] = 0x84; // PS, page id
- scsi_cmdbuf[pos++] = 0x16; // Page length
- scsi_cmdbuf[pos++] = info->cylinders >> 16; // Cylinders
- scsi_cmdbuf[pos++] = info->cylinders >> 8; // Cylinders
- scsi_cmdbuf[pos++] = info->cylinders; // Cylinders
- scsi_cmdbuf[pos++] = info->heads; // Heads
- scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - write precomp
- scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - write precomp
- scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - write precomp
- scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - reduced write current
- scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - reduced write current
- scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - reduced write current
- scsi_cmdbuf[pos++] = 0x00; // Drive step rate
- scsi_cmdbuf[pos++] = 0x00; // Drive step rate
- scsi_cmdbuf[pos++] = 0x00; // Landing zone cylinder
- scsi_cmdbuf[pos++] = 0x00; // Landing zone cylinder
- scsi_cmdbuf[pos++] = 0x00; // Landing zone cylinder
- scsi_cmdbuf[pos++] = 0x00; // RPL
- scsi_cmdbuf[pos++] = 0x00; // Rotational offset
- scsi_cmdbuf[pos++] = 0x00; // Reserved
- scsi_cmdbuf[pos++] = UINT8(10000 >> 8); // Medium rotation rate
- scsi_cmdbuf[pos++] = UINT8(10000); // Medium rotation rate
- scsi_cmdbuf[pos++] = 0x00; // Reserved
- scsi_cmdbuf[pos++] = 0x00; // Reserved
- break;
- }
-
- case 0x30: { // Apple firmware ID page
- scsi_cmdbuf[pos++] = 0xb0; // cPS, page id
- scsi_cmdbuf[pos++] = 0x16; // Page length
- scsi_cmdbuf[pos++] = 'A';
- scsi_cmdbuf[pos++] = 'P';
- scsi_cmdbuf[pos++] = 'P';
- scsi_cmdbuf[pos++] = 'L';
- scsi_cmdbuf[pos++] = 'E';
- scsi_cmdbuf[pos++] = ' ';
- scsi_cmdbuf[pos++] = 'C';
- scsi_cmdbuf[pos++] = 'O';
- scsi_cmdbuf[pos++] = 'M';
- scsi_cmdbuf[pos++] = 'P';
- scsi_cmdbuf[pos++] = 'U';
- scsi_cmdbuf[pos++] = 'T';
- scsi_cmdbuf[pos++] = 'E';
- scsi_cmdbuf[pos++] = 'R';
- scsi_cmdbuf[pos++] = ',';
- scsi_cmdbuf[pos++] = ' ';
- scsi_cmdbuf[pos++] = 'I';
- scsi_cmdbuf[pos++] = 'N';
- scsi_cmdbuf[pos++] = 'C';
- scsi_cmdbuf[pos++] = ' ';
- scsi_cmdbuf[pos++] = ' ';
- scsi_cmdbuf[pos++] = ' ';
- break;
- }
-
- default:
- logerror("%s: mode sense page %02x unhandled\n", tag(), page);
- break;
- }
- }
- scsi_cmdbuf[0] = pos;
- if(pos > size)
- pos = size;
-
- scsi_data_in(0, pos);
- scsi_status_complete(SS_GOOD);
- break;
- }
-
- case SC_START_STOP_UNIT:
- logerror("%s: command START STOP UNIT\n", tag());
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_READ_CAPACITY: {
- logerror("%s: command READ CAPACITY\n", tag());
-
- hard_disk_info *info = hard_disk_get_info(harddisk);
- UINT32 size = info->cylinders * info->heads * info->sectors - 1;
-
- scsi_cmdbuf[0] = (size>>24) & 0xff;
- scsi_cmdbuf[1] = (size>>16) & 0xff;
- scsi_cmdbuf[2] = (size>>8) & 0xff;
- scsi_cmdbuf[3] = (size & 0xff);
- scsi_cmdbuf[4] = (info->sectorbytes>>24)&0xff;
- scsi_cmdbuf[5] = (info->sectorbytes>>16)&0xff;
- scsi_cmdbuf[6] = (info->sectorbytes>>8)&0xff;
- scsi_cmdbuf[7] = (info->sectorbytes & 0xff);
-
- scsi_data_in(0, 8);
- scsi_status_complete(SS_GOOD);
- break;
- }
-
- case SC_READ_10:
- lba = (scsi_cmdbuf[2]<<24) | (scsi_cmdbuf[3]<<16) | (scsi_cmdbuf[4]<<8) | scsi_cmdbuf[5];
- blocks = (scsi_cmdbuf[7] << 8) | scsi_cmdbuf[8];
-
- logerror("%s: command READ EXTENDED start=%08x blocks=%04x\n",
- tag(), lba, blocks);
-
- scsi_data_in(2, blocks*bytes_per_sector);
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_WRITE_10:
- lba = (scsi_cmdbuf[2]<<24) | (scsi_cmdbuf[3]<<16) | (scsi_cmdbuf[4]<<8) | scsi_cmdbuf[5];
- blocks = (scsi_cmdbuf[7] << 8) | scsi_cmdbuf[8];
-
- logerror("%s: command WRITE EXTENDED start=%08x blocks=%04x\n",
- tag(), lba, blocks);
-
- scsi_data_out(2, blocks*bytes_per_sector);
- scsi_status_complete(SS_GOOD);
- break;
-
- default:
- logerror("%s: command %02x ***UNKNOWN***\n", tag(), scsi_cmdbuf[0]);
- nscsi_full_device::scsi_command();
- break;
- }
-}
diff --git a/src/emu/machine/nscsi_hd.h b/src/emu/machine/nscsi_hd.h
deleted file mode 100644
index 855c125294d..00000000000
--- a/src/emu/machine/nscsi_hd.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef __NSCSI_HD_H__
-#define __NSCSI_HD_H__
-
-#include "machine/nscsi_bus.h"
-#include "harddisk.h"
-
-class nscsi_harddisk_device : public nscsi_full_device
-{
-public:
- nscsi_harddisk_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- nscsi_harddisk_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- virtual machine_config_constructor device_mconfig_additions() const;
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
- virtual void scsi_command();
- virtual UINT8 scsi_get_data(int id, int pos);
- virtual void scsi_put_data(int buf, int offset, UINT8 data);
-
- UINT8 block[512];
- hard_disk_file *harddisk;
- int lba, cur_lba, blocks;
- int bytes_per_sector;
-};
-
-extern const device_type NSCSI_HARDDISK;
-
-#endif
diff --git a/src/emu/machine/nscsi_s1410.c b/src/emu/machine/nscsi_s1410.c
deleted file mode 100644
index b486b4994e9..00000000000
--- a/src/emu/machine/nscsi_s1410.c
+++ /dev/null
@@ -1,151 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "machine/nscsi_s1410.h"
-
-const device_type NSCSI_S1410 = &device_creator<nscsi_s1410_device>;
-
-nscsi_s1410_device::nscsi_s1410_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- nscsi_harddisk_device(mconfig, NSCSI_S1410, "S1410", tag, owner, clock, "scsi_s1410", __FILE__)
-{
-}
-
-void nscsi_s1410_device::device_reset()
-{
- nscsi_harddisk_device::device_reset();
-
- // initialize drive characteristics
- params[0] = 0;
- params[1] = 153;
- params[2] = 4;
- params[3] = 0;
- params[4] = 128;
- params[5] = 0;
- params[6] = 64;
- params[7] = 11;
-}
-
-void nscsi_s1410_device::scsi_command()
-{
- switch(scsi_cmdbuf[0]) {
- case SC_TEST_UNIT_READY:
- case SC_REZERO:
- case SC_REQUEST_SENSE:
- case SC_REASSIGN_BLOCKS:
- case SC_READ:
- case SC_WRITE:
- case SC_SEEK:
- if (scsi_cmdbuf[1] >> 5) {
- scsi_status_complete(SS_NOT_READY);
- } else {
- nscsi_harddisk_device::scsi_command();
- }
- break;
-
- case SC_FORMAT_UNIT:
- if (scsi_cmdbuf[1] >> 5) {
- scsi_status_complete(SS_NOT_READY);
- return;
- }
-
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_FORMAT_TRACK: {
- if (scsi_cmdbuf[1] >> 5) {
- scsi_status_complete(SS_NOT_READY);
- return;
- }
-
- lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3];
- blocks = (bytes_per_sector == 256) ? 32 : 17;
-
- int track_length = blocks*bytes_per_sector;
- dynamic_buffer data(track_length);
- memset(&data[0], 0xc6, track_length);
-
- if(!hard_disk_write(harddisk, lba, &data[0])) {
- logerror("%s: HD WRITE ERROR !\n", tag());
- scsi_status_complete(SS_FORMAT_ERROR);
- } else {
- scsi_status_complete(SS_GOOD);
- }
- }
- break;
-
- case SC_FORMAT_ALT_TRACK:
- if (scsi_cmdbuf[1] >> 5) {
- scsi_status_complete(SS_NOT_READY);
- return;
- }
-
- scsi_data_in(2, 3);
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_INIT_DRIVE_PARAMS:
- scsi_data_in(2, 8);
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_WRITE_SECTOR_BUFFER:
- scsi_data_in(2, 512);
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_READ_SECTOR_BUFFER:
- scsi_data_out(2, 512);
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_CHECK_TRACK_FORMAT:
- if (scsi_cmdbuf[1] >> 5) {
- scsi_status_complete(SS_NOT_READY);
- return;
- }
- scsi_status_complete(SS_GOOD);
- break;
-
- case SC_READ_ECC_BURST:
- case SC_RAM_DIAG:
- case SC_DRIVE_DIAG:
- case SC_CONTROLLER_DIAG:
- case SC_READ_LONG:
- case SC_WRITE_LONG:
- scsi_status_complete(SS_GOOD);
- break;
-
- default:
- logerror("%s: command %02x ***UNKNOWN***\n", tag(), scsi_cmdbuf[0]);
- break;
- }
-}
-
-UINT8 nscsi_s1410_device::scsi_get_data(int id, int pos)
-{
- switch(scsi_cmdbuf[0]) {
- case SC_READ_SECTOR_BUFFER:
- return block[pos];
-
- default:
- return nscsi_harddisk_device::scsi_get_data(id, pos);
- }
-}
-
-void nscsi_s1410_device::scsi_put_data(int id, int pos, UINT8 data)
-{
- switch(scsi_cmdbuf[0]) {
- case SC_FORMAT_ALT_TRACK:
- break;
-
- case SC_INIT_DRIVE_PARAMS:
- params[pos] = data;
- break;
-
- case SC_WRITE_SECTOR_BUFFER:
- block[pos] = data;
- break;
-
- default:
- return nscsi_harddisk_device::scsi_put_data(id, pos, data);
- }
-}
diff --git a/src/emu/machine/nscsi_s1410.h b/src/emu/machine/nscsi_s1410.h
deleted file mode 100644
index f9dc2707887..00000000000
--- a/src/emu/machine/nscsi_s1410.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef __NSCSI_S1410_H__
-#define __NSCSI_S1410_H__
-
-#include "machine/nscsi_bus.h"
-#include "machine/nscsi_hd.h"
-
-class nscsi_s1410_device : public nscsi_harddisk_device
-{
-public:
- nscsi_s1410_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- // SCSI status returns
- enum {
- SS_GOOD = 0x00,
- SS_NO_INDEX = 0x01,
- SS_NO_SEEK_COMPLETE = 0x02,
- SS_WRITE_FAULT = 0x03,
- SS_NOT_READY = 0x04,
- SS_TK00_NOT_FOUND = 0x06,
- SS_SEEK_IN_PROGRESS = 0x08,
- SS_ID_FIELD_ERROR = 0x10,
- SS_DATA_ERROR = 0x11,
- SS_SAM_NOT_FOUND = 0x12,
- SS_SECTOR_NOT_FOUND = 0x14,
- SS_SEEK_ERROR = 0x15,
- SS_ECC = 0x18,
- SS_BAD_TRACK = 0x19,
- SS_FORMAT_ERROR = 0x1a,
- SS_ALT_TRACK = 0x1c,
- SS_ALT_TRACK_DEFECT = 0x1d,
- SS_ALT_TRACK_NOT_FOUND = 0x1e,
- SS_ALT_TRACK_SAME = 0x1f,
- SS_RAM_ERROR = 0x30,
- SS_ROM_ERROR = 0x31,
- SS_ECC_CHECK_FAILURE = 0x32
- };
-
- // SCSI commands
- enum {
- SC_TEST_UNIT_READY = 0x00,
- SC_REZERO = 0x01,
- SC_REQUEST_SENSE = 0x03,
- SC_FORMAT_UNIT = 0x04,
- SC_CHECK_TRACK_FORMAT = 0x05,
- SC_FORMAT_TRACK = 0x06,
- SC_REASSIGN_BLOCKS = 0x07,
- SC_READ = 0x08,
- SC_WRITE = 0x0a,
- SC_SEEK = 0x0b,
- SC_INIT_DRIVE_PARAMS = 0x0c,
- SC_READ_ECC_BURST = 0x0d,
- SC_FORMAT_ALT_TRACK = 0x0e,
- SC_WRITE_SECTOR_BUFFER = 0x0f,
- SC_READ_SECTOR_BUFFER = 0x10,
- SC_RAM_DIAG = 0xe0,
- SC_DRIVE_DIAG = 0xe3,
- SC_CONTROLLER_DIAG = 0xe4,
- SC_READ_LONG = 0xe5,
- SC_WRITE_LONG = 0xe6
- };
-
- virtual void device_reset();
-
- virtual void scsi_command();
- virtual UINT8 scsi_get_data(int id, int pos);
- virtual void scsi_put_data(int buf, int offset, UINT8 data);
-
- UINT8 params[8];
-};
-
-extern const device_type NSCSI_S1410;
-
-#endif
diff --git a/src/emu/machine/nvram.c b/src/emu/machine/nvram.c
deleted file mode 100644
index a1c9d734e2e..00000000000
--- a/src/emu/machine/nvram.c
+++ /dev/null
@@ -1,181 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- nvram.c
-
- Generic non-volatile RAM.
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/nvram.h"
-
-
-// for now, make buggy GCC/Mingw STFU about I64FMT
-#if (defined(__MINGW32__) && (__GNUC__ >= 5))
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat"
-#pragma GCC diagnostic ignored "-Wformat-extra-args"
-#endif
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type NVRAM = &device_creator<nvram_device>;
-
-//-------------------------------------------------
-// nvram_device - constructor
-//-------------------------------------------------
-
-nvram_device::nvram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, NVRAM, "NVRAM", tag, owner, clock, "nvram", __FILE__),
- device_nvram_interface(mconfig, *this),
- m_default_value(DEFAULT_ALL_1),
- m_base(NULL),
- m_length(0)
-{
-}
-
-
-//-------------------------------------------------
-// static_set_interface - configuration helper
-// to set the interface
-//-------------------------------------------------
-
-void nvram_device::static_set_default_value(device_t &device, default_value value)
-{
- nvram_device &nvram = downcast<nvram_device &>(device);
- nvram.m_default_value = value;
-}
-
-
-//-------------------------------------------------
-// static_set_custom_handler - configuration
-// helper to set a custom callback
-//-------------------------------------------------
-
-void nvram_device::static_set_custom_handler(device_t &device, nvram_init_delegate handler)
-{
- nvram_device &nvram = downcast<nvram_device &>(device);
- nvram.m_default_value = DEFAULT_CUSTOM;
- nvram.m_custom_handler = handler;
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void nvram_device::device_start()
-{
- // bind our handler
- m_custom_handler.bind_relative_to(*owner());
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void nvram_device::nvram_default()
-{
- // make sure we have a valid base pointer
- determine_final_base();
-
- // region always wins
- if (m_region != NULL)
- {
- memcpy(m_base, m_region->base(), m_length);
- return;
- }
-
- // default values for other cases
- switch (m_default_value)
- {
- // all-0's
- case DEFAULT_ALL_0:
- memset(m_base, 0, m_length);
- break;
-
- // all 1's
- default:
- case DEFAULT_ALL_1:
- memset(m_base, 0xff, m_length);
- break;
-
- // random values
- case DEFAULT_RANDOM:
- {
- UINT8 *nvram = reinterpret_cast<UINT8 *>(m_base);
- for (int index = 0; index < m_length; index++)
- nvram[index] = machine().rand();
- break;
- }
-
- // custom handler
- case DEFAULT_CUSTOM:
- m_custom_handler(*this, m_base, m_length);
- break;
-
- // none - do nothing
- case DEFAULT_NONE:
- break;
- }
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void nvram_device::nvram_read(emu_file &file)
-{
- // make sure we have a valid base pointer
- determine_final_base();
-
- file.read(m_base, m_length);
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void nvram_device::nvram_write(emu_file &file)
-{
- file.write(m_base, m_length);
-}
-
-
-//-------------------------------------------------
-// determine_final_base - get the final base
-// pointer by looking up the memory share, unless
-// a pointer was provided to us
-//-------------------------------------------------
-
-void nvram_device::determine_final_base()
-{
- // find our shared pointer with the target RAM
- if (m_base == NULL)
- {
- memory_share *share = owner()->memshare(tag());
- if (share == NULL)
- throw emu_fatalerror("NVRAM device '%s' has no corresponding AM_SHARE region", tag());
- m_base = share->ptr();
- m_length = share->bytes();
- }
-
- // if we are region-backed for the default, find it now and make sure it's the right size
- if (m_region != NULL && m_region->bytes() != m_length)
- throw emu_fatalerror("NVRAM device '%s' has a default region, but it should be 0x%" SIZETFMT "X bytes", tag(), m_length);
-}
-
-#if (defined(__MINGW32__) && (__GNUC__ >= 5))
-#pragma GCC diagnostic pop
-#endif
diff --git a/src/emu/machine/nvram.h b/src/emu/machine/nvram.h
deleted file mode 100644
index 10c3954a83c..00000000000
--- a/src/emu/machine/nvram.h
+++ /dev/null
@@ -1,115 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/***************************************************************************
-
- nvram.h
-
- Generic non-volatile RAM.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __NVRAM_H__
-#define __NVRAM_H__
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_NVRAM_ADD_0FILL(_tag) \
- MCFG_DEVICE_ADD(_tag, NVRAM, 0) \
- nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_ALL_0);
-#define MCFG_NVRAM_ADD_1FILL(_tag) \
- MCFG_DEVICE_ADD(_tag, NVRAM, 0) \
- nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_ALL_1);
-#define MCFG_NVRAM_ADD_RANDOM_FILL(_tag) \
- MCFG_DEVICE_ADD(_tag, NVRAM, 0) \
- nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_RANDOM);
-#define MCFG_NVRAM_ADD_NO_FILL(_tag) \
- MCFG_DEVICE_ADD(_tag, NVRAM, 0) \
- nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_NONE);
-#define MCFG_NVRAM_ADD_CUSTOM_DRIVER(_tag, _class, _method) \
- MCFG_DEVICE_ADD(_tag, NVRAM, 0) \
- nvram_device::static_set_custom_handler(*device, nvram_init_delegate(&_class::_method, #_class "::" #_method, NULL, (_class *)0));
-
-#define MCFG_NVRAM_REPLACE_0FILL(_tag) \
- MCFG_DEVICE_REPLACE(_tag, NVRAM, 0) \
- nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_ALL_0);
-#define MCFG_NVRAM_REPLACE_1FILL(_tag) \
- MCFG_DEVICE_REPLACE(_tag, NVRAM, 0) \
- nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_ALL_1);
-#define MCFG_NVRAM_REPLACE_RANDOM_FILL(_tag) \
- MCFG_DEVICE_REPLACE(_tag, NVRAM, 0) \
- nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_RANDOM);
-#define MCFG_NVRAM_REPLACE_CUSTOM_DRIVER(_tag, _class, _method) \
- MCFG_DEVICE_REPLACE(_tag, NVRAM, 0) \
- nvram_device::static_set_custom_handler(*device, nvram_init_delegate(&_class::_method, #_class "::" #_method, NULL, (_class *)0));
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-class nvram_device;
-
-
-// custom initialization for default state
-typedef device_delegate<void (nvram_device &, void *, size_t)> nvram_init_delegate;
-
-
-// ======================> nvram_device
-
-class nvram_device : public device_t,
- public device_nvram_interface
-{
-public:
- // values
- enum default_value
- {
- DEFAULT_ALL_0,
- DEFAULT_ALL_1,
- DEFAULT_RANDOM,
- DEFAULT_CUSTOM,
- DEFAULT_NONE
- };
-
- // construction/destruction
- nvram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // inline configuration helpers
- static void static_set_default_value(device_t &device, default_value value);
- static void static_set_custom_handler(device_t &device, nvram_init_delegate callback);
-
- // controls
- void set_base(void *base, size_t length) { m_base = base; m_length = length; }
-
-protected:
- // device-level overrides
- virtual void device_start();
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
- // internal helpers
- void determine_final_base();
-
- // configuration state
- default_value m_default_value;
- nvram_init_delegate m_custom_handler;
-
- // runtime state
- void * m_base;
- size_t m_length;
-};
-
-
-// device type definition
-extern const device_type NVRAM;
-
-
-#endif
diff --git a/src/emu/machine/pc_fdc.c b/src/emu/machine/pc_fdc.c
deleted file mode 100644
index 5c56a53d3d6..00000000000
--- a/src/emu/machine/pc_fdc.c
+++ /dev/null
@@ -1,192 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol
-/**********************************************************************
-
- PC-style floppy disk controller emulation
-
- TODO:
- - check how the drive select from DOR register, and the drive select
- from the fdc are related !!!!
- - if all drives do not have a disk in them, and the fdc is reset, is a int generated?
- (if yes, indicates drives are ready without discs, if no indicates no drives are ready)
- - status register a, status register b
-
-**********************************************************************/
-
-#include "emu.h"
-#include "machine/pc_fdc.h"
-
-const device_type PC_FDC_XT = &device_creator<pc_fdc_xt_device>;
-const device_type PC_FDC_AT = &device_creator<pc_fdc_at_device>;
-
-static MACHINE_CONFIG_FRAGMENT( cfg )
- MCFG_UPD765A_ADD("upd765", false, false)
- MCFG_UPD765_INTRQ_CALLBACK(WRITELINE(pc_fdc_family_device, irq_w))
- MCFG_UPD765_DRQ_CALLBACK(WRITELINE(pc_fdc_family_device, drq_w))
-MACHINE_CONFIG_END
-
-DEVICE_ADDRESS_MAP_START(map, 8, pc_fdc_family_device)
-ADDRESS_MAP_END
-
-// The schematics show address decoding is minimal
-DEVICE_ADDRESS_MAP_START(map, 8, pc_fdc_xt_device)
- AM_RANGE(0x0, 0x0) AM_DEVREAD("upd765", upd765a_device, msr_r) AM_WRITE(dor_w)
- AM_RANGE(0x1, 0x1) AM_DEVREAD("upd765", upd765a_device, fifo_r) AM_WRITE(dor_fifo_w)
- AM_RANGE(0x2, 0x2) AM_WRITE(dor_w)
- AM_RANGE(0x3, 0x3) AM_WRITE(dor_w)
- AM_RANGE(0x4, 0x5) AM_DEVICE("upd765", upd765a_device, map)
-ADDRESS_MAP_END
-
-
-// Decoding is through a PAL, so presumably complete
-DEVICE_ADDRESS_MAP_START(map, 8, pc_fdc_at_device)
- AM_RANGE(0x2, 0x2) AM_READWRITE(dor_r, dor_w)
- AM_RANGE(0x4, 0x5) AM_DEVICE("upd765", upd765a_device, map)
- AM_RANGE(0x7, 0x7) AM_READWRITE(dir_r, ccr_w)
-ADDRESS_MAP_END
-
-pc_fdc_family_device::pc_fdc_family_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- pc_fdc_interface(mconfig, type, name, tag, owner, clock, shortname, source), fdc(*this, "upd765"),
- intrq_cb(*this),
- drq_cb(*this)
-{
-}
-
-void pc_fdc_family_device::tc_w(bool state)
-{
- fdc->tc_w(state);
-}
-
-UINT8 pc_fdc_family_device::dma_r()
-{
- return fdc->dma_r();
-}
-
-void pc_fdc_family_device::dma_w(UINT8 data)
-{
- fdc->dma_w(data);
-}
-
-machine_config_constructor pc_fdc_family_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME(cfg);
-}
-
-void pc_fdc_family_device::device_start()
-{
- intrq_cb.resolve();
- drq_cb.resolve();
-
- for(int i=0; i<4; i++) {
- char name[2] = {'0'+i, 0};
- floppy_connector *conn = subdevice<floppy_connector>(name);
- floppy[i] = conn ? conn->get_device() : NULL;
- }
-
- irq = drq = false;
- fdc_irq = fdc_drq = false;
- dor = 0x00;
-}
-
-void pc_fdc_family_device::device_reset()
-{
-}
-
-// Bits 0-1 select one of the 4 drives, but only if the associated
-// motor bit is on
-
-// Bit 2 is tied to the upd765 reset line
-
-// Bit 3 enables the irq and drq lines
-
-// Bit 4-7 control the drive motors
-
-WRITE8_MEMBER( pc_fdc_family_device::dor_w )
-{
- logerror("%s: dor = %02x\n", tag(), data);
- UINT8 pdor = dor;
- dor = data;
-
- for(int i=0; i<4; i++)
- if(floppy[i])
- floppy[i]->mon_w(!(dor & (0x10 << i)));
-
- int fid = dor & 3;
- if(dor & (0x10 << fid))
- fdc->set_floppy(floppy[fid]);
- else
- fdc->set_floppy(NULL);
-
- check_irq();
- check_drq();
- if((pdor^dor) & 4)
- fdc->reset();
-}
-
-READ8_MEMBER( pc_fdc_family_device::dor_r )
-{
- return dor;
-}
-
-READ8_MEMBER( pc_fdc_family_device::dir_r )
-{
- return do_dir_r();
-}
-
-WRITE8_MEMBER( pc_fdc_family_device::ccr_w )
-{
- static const int rates[4] = { 500000, 300000, 250000, 1000000 };
- logerror("%s: ccr = %02x\n", tag(), data);
- fdc->set_rate(rates[data & 3]);
-}
-
-UINT8 pc_fdc_family_device::do_dir_r()
-{
- if(floppy[dor & 3])
- return floppy[dor & 3]->dskchg_r() ? 0x00 : 0x80;
- return 0x00;
-}
-
-WRITE8_MEMBER( pc_fdc_xt_device::dor_fifo_w)
-{
- fdc->fifo_w(space, 0, data, mem_mask);
- dor_w(space, 0, data, mem_mask);
-}
-
-WRITE_LINE_MEMBER( pc_fdc_family_device::irq_w )
-{
- fdc_irq = state;
- check_irq();
-}
-
-WRITE_LINE_MEMBER( pc_fdc_family_device::drq_w )
-{
- fdc_drq = state;
- check_drq();
-}
-
-void pc_fdc_family_device::check_irq()
-{
- bool pirq = irq;
- irq = fdc_irq && (dor & 4) && (dor & 8);
- if(irq != pirq && !intrq_cb.isnull()) {
- logerror("%s: pc_irq = %d\n", tag(), irq);
- intrq_cb(irq);
- }
-}
-
-void pc_fdc_family_device::check_drq()
-{
- bool pdrq = drq;
- drq = fdc_drq && (dor & 4) && (dor & 8);
- if(drq != pdrq && !drq_cb.isnull())
- drq_cb(drq);
-}
-
-pc_fdc_xt_device::pc_fdc_xt_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : pc_fdc_family_device(mconfig, PC_FDC_XT, "PC FDC XT", tag, owner, clock, "pc_fdc_xt", __FILE__)
-{
-}
-
-pc_fdc_at_device::pc_fdc_at_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : pc_fdc_family_device(mconfig, PC_FDC_AT, "PC FDC AT", tag, owner, clock, "pc_fdc_at", __FILE__)
-{
-}
diff --git a/src/emu/machine/pc_fdc.h b/src/emu/machine/pc_fdc.h
deleted file mode 100644
index 159bb89a59b..00000000000
--- a/src/emu/machine/pc_fdc.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol
-/**********************************************************************
-
- PC-style floppy disk controller emulation
-
-**********************************************************************/
-
-#ifndef PC_FDC_H
-#define PC_FDC_H
-
-#include "emu.h"
-#include "machine/upd765.h"
-
-#define MCFG_PC_FDC_XT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, PC_FDC_XT, 0)
-
-#define MCFG_PC_FDC_AT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, PC_FDC_AT, 0)
-
-#define MCFG_PC_FDC_INTRQ_CALLBACK(_write) \
- devcb = &pc_fdc_family_device::set_intrq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_PC_FDC_DRQ_CALLBACK(_write) \
- devcb = &pc_fdc_family_device::set_drq_wr_callback(*device, DEVCB_##_write);
-
-class pc_fdc_family_device : public pc_fdc_interface {
-public:
- pc_fdc_family_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- template<class _Object> static devcb_base &set_intrq_wr_callback(device_t &device, _Object object) { return downcast<pc_fdc_family_device &>(device).intrq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_drq_wr_callback(device_t &device, _Object object) { return downcast<pc_fdc_family_device &>(device).drq_cb.set_callback(object); }
-
- required_device<upd765a_device> fdc;
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-
- virtual void tc_w(bool state);
- virtual UINT8 dma_r();
- virtual void dma_w(UINT8 data);
- virtual UINT8 do_dir_r();
-
- READ8_MEMBER(dor_r);
- WRITE8_MEMBER(dor_w);
- READ8_MEMBER(dir_r);
- WRITE8_MEMBER(ccr_w);
- DECLARE_WRITE_LINE_MEMBER( irq_w );
- DECLARE_WRITE_LINE_MEMBER( drq_w );
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual machine_config_constructor device_mconfig_additions() const;
-
- bool irq, drq, fdc_drq, fdc_irq;
- devcb_write_line intrq_cb, drq_cb;
- UINT8 dor;
-
- floppy_image_device *floppy[4];
-
- void check_irq();
- void check_drq();
-};
-
-class pc_fdc_xt_device : public pc_fdc_family_device {
-public:
- pc_fdc_xt_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
- WRITE8_MEMBER(dor_fifo_w);
-};
-
-class pc_fdc_at_device : public pc_fdc_family_device {
-public:
- pc_fdc_at_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-};
-
-extern const device_type PC_FDC_XT;
-extern const device_type PC_FDC_AT;
-
-#endif /* PC_FDC_H */
diff --git a/src/emu/machine/pc_lpt.c b/src/emu/machine/pc_lpt.c
deleted file mode 100644
index 319a5cb0a2c..00000000000
--- a/src/emu/machine/pc_lpt.c
+++ /dev/null
@@ -1,163 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- IBM-PC printer interface
-
-***************************************************************************/
-
-#include "emu.h"
-#include "pc_lpt.h"
-
-
-const device_type PC_LPT = &device_creator<pc_lpt_device>;
-
-pc_lpt_device::pc_lpt_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, PC_LPT, "PC-LPT", tag, owner, clock, "pc_lpt", __FILE__),
- m_irq(1),
- m_data(0xff),
- m_irq_enabled(1),
- m_centronics_ack(1),
- m_irq_handler(*this),
- m_cent_data_in(*this, "cent_data_in"),
- m_cent_data_out(*this, "cent_data_out"),
- m_cent_status_in(*this, "cent_status_in"),
- m_cent_ctrl_in(*this, "cent_ctrl_in"),
- m_cent_ctrl_out(*this, "cent_ctrl_out")
-{
-}
-
-void pc_lpt_device::device_start()
-{
- m_irq_handler.resolve_safe();
-
- save_item(NAME(m_irq));
- save_item(NAME(m_data));
- save_item(NAME(m_control));
- save_item(NAME(m_centronics_ack));
- save_item(NAME(m_irq_enabled));
-
- m_cent_data_out->write(m_data);
-}
-
-void pc_lpt_device::device_reset()
-{
- m_control = ~(0 ^ CONTROL_INIT);
- m_cent_ctrl_out->write(m_control);
-}
-
-static MACHINE_CONFIG_FRAGMENT( pc_lpt )
- MCFG_CENTRONICS_ADD("centronics", centronics_devices, "printer")
- MCFG_CENTRONICS_DATA_INPUT_BUFFER("cent_data_in")
- MCFG_CENTRONICS_FAULT_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit3))
- MCFG_CENTRONICS_SELECT_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit4))
- MCFG_CENTRONICS_PERROR_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit5))
- MCFG_CENTRONICS_ACK_HANDLER(WRITELINE(pc_lpt_device, write_centronics_ack))
- MCFG_CENTRONICS_BUSY_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit7))
-
- MCFG_CENTRONICS_STROBE_HANDLER(DEVWRITELINE("cent_ctrl_in", input_buffer_device, write_bit0))
- MCFG_CENTRONICS_AUTOFD_HANDLER(DEVWRITELINE("cent_ctrl_in", input_buffer_device, write_bit1))
- MCFG_CENTRONICS_INIT_HANDLER(DEVWRITELINE("cent_ctrl_in", input_buffer_device, write_bit2))
- MCFG_CENTRONICS_SELECT_IN_HANDLER(DEVWRITELINE("cent_ctrl_in", input_buffer_device, write_bit3))
-
- MCFG_DEVICE_ADD("cent_data_in", INPUT_BUFFER, 0)
- MCFG_DEVICE_ADD("cent_ctrl_in", INPUT_BUFFER, 0)
- MCFG_DEVICE_ADD("cent_status_in", INPUT_BUFFER, 0)
-
- MCFG_CENTRONICS_OUTPUT_LATCH_ADD("cent_data_out", "centronics")
-
- MCFG_DEVICE_ADD("cent_ctrl_out", OUTPUT_LATCH, 0)
- MCFG_OUTPUT_LATCH_BIT0_HANDLER(DEVWRITELINE("centronics", centronics_device, write_strobe))
- MCFG_OUTPUT_LATCH_BIT1_HANDLER(DEVWRITELINE("centronics", centronics_device, write_autofd))
- MCFG_OUTPUT_LATCH_BIT2_HANDLER(DEVWRITELINE("centronics", centronics_device, write_init))
- MCFG_OUTPUT_LATCH_BIT3_HANDLER(DEVWRITELINE("centronics", centronics_device, write_select_in))
- MCFG_OUTPUT_LATCH_BIT4_HANDLER(WRITELINE(pc_lpt_device, write_irq_enabled))
-MACHINE_CONFIG_END
-
-machine_config_constructor pc_lpt_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( pc_lpt );
-}
-
-READ8_MEMBER( pc_lpt_device::data_r )
-{
- // pull up mechanism for input lines, zeros are provided by peripheral
- return m_data & m_cent_data_in->read();
-}
-
-WRITE8_MEMBER( pc_lpt_device::data_w )
-{
- m_data = data;
- m_cent_data_out->write(m_data);
-}
-
-READ8_MEMBER( pc_lpt_device::status_r )
-{
- return m_cent_status_in->read() ^ STATUS_BUSY;
-}
-
-READ8_MEMBER( pc_lpt_device::control_r )
-{
- return ~((m_control & m_cent_ctrl_in->read() & 0x3f) ^ CONTROL_INIT);
-}
-
-WRITE8_MEMBER( pc_lpt_device::control_w )
-{
- // logerror("pc_lpt_control_w: 0x%02x\n", data);
-
- m_control = ~(data ^ CONTROL_INIT);
- m_cent_ctrl_out->write(m_control);
-}
-
-READ8_MEMBER( pc_lpt_device::read )
-{
- switch (offset)
- {
- case 0: return data_r(space, 0);
- case 1: return status_r(space, 0);
- case 2: return control_r(space, 0);
- }
-
- /* if we reach this its an error */
- logerror("PC-LPT %s: Read from invalid offset %x\n", tag(), offset);
-
- return 0xff;
-}
-
-WRITE8_MEMBER( pc_lpt_device::write )
-{
- switch (offset)
- {
- case 0: data_w(space, 0, data); break;
- case 1: break;
- case 2: control_w(space, 0, data); break;
- }
-}
-
-void pc_lpt_device::update_irq()
-{
- int irq = 1; // high impedance
- if (!m_irq_enabled)
- {
- irq = m_centronics_ack;
- }
-
- if (m_irq != irq)
- {
- m_irq = irq;
- m_irq_handler(!irq);
- }
-}
-
-WRITE_LINE_MEMBER( pc_lpt_device::write_irq_enabled )
-{
- m_irq_enabled = state;
- update_irq();
-}
-
-WRITE_LINE_MEMBER( pc_lpt_device::write_centronics_ack )
-{
- m_centronics_ack = state;
- m_cent_status_in->write_bit6(state);
- update_irq();
-}
diff --git a/src/emu/machine/pc_lpt.h b/src/emu/machine/pc_lpt.h
deleted file mode 100644
index 08de865ce94..00000000000
--- a/src/emu/machine/pc_lpt.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Dirk Best
-/***************************************************************************
-
- IBM-PC printer interface
-
-***************************************************************************/
-
-#ifndef __PC_LPT_H__
-#define __PC_LPT_H__
-
-#include "bus/centronics/ctronics.h"
-
-#define MCFG_PC_LPT_IRQ_HANDLER(_devcb) \
- devcb = &pc_lpt_device::set_irq_handler(*device, DEVCB_##_devcb);
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-class pc_lpt_device : public device_t
-{
-public:
- pc_lpt_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_irq_handler(device_t &device, _Object object) { return downcast<pc_lpt_device &>(device).m_irq_handler.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_READ8_MEMBER( data_r );
- DECLARE_WRITE8_MEMBER( data_w );
- DECLARE_READ8_MEMBER( status_r );
- DECLARE_READ8_MEMBER( control_r );
- DECLARE_WRITE8_MEMBER( control_w );
-
- DECLARE_WRITE_LINE_MEMBER( write_irq_enabled );
- DECLARE_WRITE_LINE_MEMBER( write_centronics_ack );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual machine_config_constructor device_mconfig_additions() const;
-
-private:
- void update_irq();
-
- enum
- {
- CONTROL_STROBE = 1,
- CONTROL_AUTOFD = 2,
- CONTROL_INIT = 4,
- CONTROL_SELECT = 8,
- CONTROL_IRQ_ENABLED = 16,
- CONTROL_OUTPUT_ENABLED = 32
- };
-
- enum
- {
- STATUS_FAULT = 8,
- STATUS_SELECT = 16,
- STATUS_PERROR = 32,
- STATUS_ACK = 64,
- STATUS_BUSY = 128
- };
-
- // internal state
-
- int m_irq;
- UINT8 m_data;
- UINT8 m_control;
- int m_irq_enabled;
- int m_centronics_ack;
-
- devcb_write_line m_irq_handler;
- required_device<input_buffer_device> m_cent_data_in;
- required_device<output_latch_device> m_cent_data_out;
- required_device<input_buffer_device> m_cent_status_in;
- required_device<input_buffer_device> m_cent_ctrl_in;
- required_device<output_latch_device> m_cent_ctrl_out;
-};
-
-extern const device_type PC_LPT;
-
-#endif /* __PC_LPT__ */
diff --git a/src/emu/machine/pccard.c b/src/emu/machine/pccard.c
deleted file mode 100644
index 0d9887fa15f..00000000000
--- a/src/emu/machine/pccard.c
+++ /dev/null
@@ -1,76 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "pccard.h"
-
-READ16_MEMBER( pccard_interface::read_memory )
-{
- return 0xffff;
-}
-
-WRITE16_MEMBER( pccard_interface::write_memory )
-{
-}
-
-READ16_MEMBER( pccard_interface::read_reg )
-{
- return 0xffff;
-}
-
-WRITE16_MEMBER( pccard_interface::write_reg )
-{
-}
-
-const device_type PCCARD_SLOT = &device_creator<pccard_slot_device>;
-
-pccard_slot_device::pccard_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, PCCARD_SLOT, "PCCARD SLOT", tag, owner, clock, "pccard", __FILE__),
- device_slot_interface(mconfig, *this),
- m_pccard(NULL)
-{
-}
-
-void pccard_slot_device::device_start()
-{
- m_pccard = dynamic_cast<pccard_interface *>(get_card_device());
-}
-
-READ_LINE_MEMBER(pccard_slot_device::read_line_inserted)
-{
- return m_pccard != NULL;
-}
-
-READ16_MEMBER( pccard_slot_device::read_memory )
-{
- if( m_pccard != NULL )
- {
- return m_pccard->read_memory( space, offset, mem_mask );
- }
-
- return 0xffff;
-}
-
-WRITE16_MEMBER( pccard_slot_device::write_memory )
-{
- if( m_pccard != NULL )
- {
- m_pccard->write_memory( space, offset, data, mem_mask );
- }
-}
-
-READ16_MEMBER( pccard_slot_device::read_reg )
-{
- if( m_pccard != NULL )
- {
- return m_pccard->read_reg( space, offset, mem_mask );
- }
-
- return 0xffff;
-}
-
-WRITE16_MEMBER( pccard_slot_device::write_reg )
-{
- if( m_pccard != NULL )
- {
- m_pccard->write_reg( space, offset, data, mem_mask );
- }
-}
diff --git a/src/emu/machine/pccard.h b/src/emu/machine/pccard.h
deleted file mode 100644
index 7a7b9abd1ab..00000000000
--- a/src/emu/machine/pccard.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#pragma once
-
-#ifndef __PCCARD_H__
-#define __PCCARD_H__
-
-#include "emu.h"
-
-class pccard_interface
-{
-public:
- virtual DECLARE_READ16_MEMBER(read_memory);
- virtual DECLARE_READ16_MEMBER(read_reg);
- virtual DECLARE_WRITE16_MEMBER(write_memory);
- virtual DECLARE_WRITE16_MEMBER(write_reg);
-
- virtual ~pccard_interface() {}
-};
-
-extern const device_type PCCARD_SLOT;
-
-class pccard_slot_device : public device_t,
- public device_slot_interface
-{
-public:
- pccard_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ_LINE_MEMBER(read_line_inserted);
- DECLARE_READ16_MEMBER(read_memory);
- DECLARE_READ16_MEMBER(read_reg);
- DECLARE_WRITE16_MEMBER(write_memory);
- DECLARE_WRITE16_MEMBER(write_reg);
-
-protected:
- virtual void device_start();
-
-private:
- // internal state
- pccard_interface *m_pccard;
-};
-
-#endif
diff --git a/src/emu/machine/pcf8593.c b/src/emu/machine/pcf8593.c
deleted file mode 100644
index 48e002fdf2d..00000000000
--- a/src/emu/machine/pcf8593.c
+++ /dev/null
@@ -1,285 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Schuerewegen
-/*********************************************************************
-
- Philips PCF8593 CMOS clock/calendar circuit
-
- (c) 2001-2007 Tim Schuerewegen
-
-*********************************************************************/
-
-#include "pcf8593.h"
-
-
-/***************************************************************************
- PARAMETERS/CONSTANTS/MACROS
-***************************************************************************/
-
-#define LOG_LEVEL 1
-#define _logerror(level,x) do { if (LOG_LEVEL > level) logerror x; } while (0)
-
-// get/set date
-#define RTC_GET_DATE_YEAR ((m_data[5] >> 6) & 3)
-#define RTC_SET_DATE_YEAR(x) m_data[5] = (m_data[5] & 0x3F) | (((x) % 4) << 6)
-#define RTC_GET_DATE_MONTH bcd_to_integer( m_data[6])
-#define RTC_SET_DATE_MONTH(x) m_data[6] = convert_to_bcd( x)
-#define RTC_GET_DATE_DAY (bcd_to_integer( m_data[5] & 0x3F))
-#define RTC_SET_DATE_DAY(x) m_data[5] = (m_data[5] & 0xC0) | convert_to_bcd( x)
-
-// get/set time
-#define RTC_GET_TIME_HOUR bcd_to_integer( m_data[4])
-#define RTC_SET_TIME_HOUR(x) m_data[4] = convert_to_bcd( x)
-#define RTC_GET_TIME_MINUTE bcd_to_integer( m_data[3])
-#define RTC_SET_TIME_MINUTE(x) m_data[3] = convert_to_bcd( x)
-#define RTC_GET_TIME_SECOND bcd_to_integer( m_data[2])
-#define RTC_SET_TIME_SECOND(x) m_data[2] = convert_to_bcd( x)
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-const device_type PCF8593 = &device_creator<pcf8593_device>;
-
-
-//-------------------------------------------------
-// pcf8593_device - constructor
-//-------------------------------------------------
-
-pcf8593_device::pcf8593_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, PCF8593, "PCF8593 RTC", tag, owner, clock, "pcf8593", __FILE__),
- device_rtc_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void pcf8593_device::device_start()
-{
- _logerror( 0, ("pcf8593_init\n"));
- memset(m_register, 0, sizeof(m_register));
- m_timer = timer_alloc(TIMER_UPDATE_COUNTER);
- m_timer->adjust(attotime::from_seconds(1), 0, attotime::from_seconds(1));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void pcf8593_device::device_reset()
-{
- _logerror( 0, ("pcf8593_reset\n"));
- m_pin_scl = 1;
- m_pin_sda = 1;
- m_active = FALSE;
- m_inp = 0;
- m_mode = RTC_MODE_RECV;
- m_bits = 0;
- m_pos = 0;
- clear_buffer_rx();
- set_time(true, RTC_GET_DATE_YEAR, RTC_GET_DATE_MONTH, RTC_GET_DATE_DAY, 0, RTC_GET_TIME_HOUR, RTC_GET_TIME_MINUTE, RTC_GET_TIME_SECOND);
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void pcf8593_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch(id)
- {
- case TIMER_UPDATE_COUNTER:
- _logerror( 2, ("pcf8593_timer_callback (%d)\n", param));
- // check if counting is enabled
- if (!(m_data[0] & 0x80))
- advance_seconds();
- break;
- }
-}
-
-
-//-------------------------------------------------
-// rtc_clock_updated -
-//-------------------------------------------------
-
-void pcf8593_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
- RTC_SET_TIME_SECOND(second);
- RTC_SET_TIME_MINUTE(minute);
- RTC_SET_TIME_HOUR(hour);
- RTC_SET_DATE_DAY(day);
- RTC_SET_DATE_MONTH(month);
- RTC_SET_DATE_YEAR(year);
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void pcf8593_device::nvram_default()
-{
- memset(m_data, 0, sizeof(m_data));
-}
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void pcf8593_device::nvram_read(emu_file &file)
-{
- file.read(m_data, sizeof(m_data));
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void pcf8593_device::nvram_write(emu_file &file)
-{
- file.write(m_data, sizeof(m_data));
-}
-
-
-
-/*-------------------------------------------------
- pcf8593_pin_scl
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER(pcf8593_device::scl_w)
-{
- // send bit
- if ((m_active) && (!m_pin_scl) && (state))
- {
- switch (m_mode)
- {
- // HOST -> RTC
- case RTC_MODE_RECV :
- {
- // get bit
- if (m_pin_sda) m_data_recv[m_data_recv_index] = m_data_recv[m_data_recv_index] | (0x80 >> m_bits);
- m_bits++;
- // bit 9 = end
- if (m_bits > 8)
- {
- _logerror( 2, ("pcf8593_write_byte(%02X)\n", m_data_recv[m_data_recv_index]));
- // enter receive mode when 1st byte = 0xA3
- if ((m_data_recv[0] == 0xA3) && (m_data_recv_index == 0))
- {
- m_mode = RTC_MODE_SEND;
- }
- // A2 + xx = "read from pos xx" command
- if ((m_data_recv[0] == 0xA2) && (m_data_recv_index == 1))
- {
- m_pos = m_data_recv[1];
- }
- // A2 + xx + .. = write byte
- if ((m_data_recv[0] == 0xA2) && (m_data_recv_index >= 2))
- {
- UINT8 rtc_pos, rtc_val;
- rtc_pos = m_data_recv[1] + (m_data_recv_index - 2);
- rtc_val = m_data_recv[m_data_recv_index];
- //if (rtc_pos == 0) rtc_val = rtc_val & 3; // what is this doing here?
- m_data[rtc_pos] = rtc_val;
- set_time(false, RTC_GET_DATE_YEAR, RTC_GET_DATE_MONTH, RTC_GET_DATE_DAY, 0, RTC_GET_TIME_HOUR, RTC_GET_TIME_MINUTE, RTC_GET_TIME_SECOND);
- }
- // next byte
- m_bits = 0;
- m_data_recv_index++;
- }
- }
- break;
- // RTC -> HOST
- case RTC_MODE_SEND :
- {
- // set bit
- m_inp = (m_data[m_pos] >> (7 - m_bits)) & 1;
- m_bits++;
- // bit 9 = end
- if (m_bits > 8)
- {
- _logerror( 2, ("pcf8593_read_byte(%02X)\n", m_data[m_pos]));
- // end ?
- if (m_pin_sda)
- {
- _logerror( 2, ("pcf8593 end\n"));
- m_mode = RTC_MODE_RECV;
- clear_buffer_rx();
- }
- // next byte
- m_bits = 0;
- m_pos++;
- }
- }
- break;
- }
- }
- // save scl
- m_pin_scl = state;
-}
-
-
-
-/*-------------------------------------------------
- pcf8593_pin_sda_w
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER(pcf8593_device::sda_w)
-{
- // clock is high
- if (m_pin_scl)
- {
- // log init I2C
- if (state) _logerror( 1, ("pcf8593 init i2c\n"));
- // start condition (high to low when clock is high)
- if ((!state) && (m_pin_sda))
- {
- _logerror( 1, ("pcf8593 start condition\n"));
- m_active = TRUE;
- m_bits = 0;
- m_data_recv_index = 0;
- clear_buffer_rx();
- //m_pos = 0;
- }
- // stop condition (low to high when clock is high)
- if ((state) && (!m_pin_sda))
- {
- _logerror( 1, ("pcf8593 stop condition\n"));
- m_active = FALSE;
- }
- }
- // save sda
- m_pin_sda = state;
-}
-
-
-
-/*-------------------------------------------------
- pcf8593_pin_sda_r
--------------------------------------------------*/
-
-READ_LINE_MEMBER(pcf8593_device::sda_r)
-{
- return m_inp;
-}
-
-
-
-/*-------------------------------------------------
- pcf8593_clear_buffer_rx
--------------------------------------------------*/
-
-void pcf8593_device::clear_buffer_rx()
-{
- memset(&m_data_recv[0], 0, sizeof( m_data_recv));
- m_data_recv_index = 0;
-}
diff --git a/src/emu/machine/pcf8593.h b/src/emu/machine/pcf8593.h
deleted file mode 100644
index 2475f0a2dfe..00000000000
--- a/src/emu/machine/pcf8593.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Schuerewegen
-/*********************************************************************
-
- Philips PCF8593 CMOS clock/calendar circuit
-
- (c) 2001-2007 Tim Schuerewegen
-
-*********************************************************************/
-
-#ifndef __PCF8593_H__
-#define __PCF8593_H__
-
-#include "emu.h"
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_PCF8593_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, PCF8593, 0)
-
-#define MCFG_PCF8593_REMOVE(_tag) \
- MCFG_DEVICE_REMOVE(_tag)
-
-
-// ======================> pcf8593_device
-
-class pcf8593_device : public device_t,
- public device_rtc_interface,
- public device_nvram_interface
-{
-public:
- pcf8593_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_WRITE_LINE_MEMBER(scl_w);
- DECLARE_WRITE_LINE_MEMBER(sda_w);
- DECLARE_READ_LINE_MEMBER(sda_r);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_rtc_interface overrides
- virtual bool rtc_feature_y2k() { return true; }
- virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
-private:
- void clear_buffer_rx();
-
- static const device_timer_id TIMER_UPDATE_COUNTER = 0;
-
- // internal state
- UINT8 m_data[16];
- int m_pin_scl;
- int m_pin_sda;
- int m_inp;
- int m_active;
- int m_bits;
- UINT8 m_data_recv_index;
- UINT8 m_data_recv[50];
- UINT8 m_mode;
- UINT8 m_pos;
- emu_timer * m_timer;
- enum { RTC_MODE_NONE, RTC_MODE_SEND, RTC_MODE_RECV };
-};
-
-// device type definition
-extern const device_type PCF8593;
-
-#endif /* __PCF8593_H__ */
diff --git a/src/emu/machine/pci-apic.c b/src/emu/machine/pci-apic.c
deleted file mode 100644
index ce32692c7e6..00000000000
--- a/src/emu/machine/pci-apic.c
+++ /dev/null
@@ -1,20 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "pci-apic.h"
-
-const device_type APIC = &device_creator<apic_device>;
-
-apic_device::apic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_device(mconfig, APIC, "I/O Advanced Programmable Interrupt Controller", tag, owner, clock, "apic", __FILE__)
-{
-}
-
-void apic_device::device_start()
-{
- pci_device::device_start();
-}
-
-void apic_device::device_reset()
-{
- pci_device::device_reset();
-}
diff --git a/src/emu/machine/pci-apic.h b/src/emu/machine/pci-apic.h
deleted file mode 100644
index 85b8de34b4d..00000000000
--- a/src/emu/machine/pci-apic.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef PCI_APIC_H
-#define PCI_APIC_H
-
-#include "pci.h"
-
-#define MCFG_APIC_ADD(_tag, _main_id, _revision, _subdevice_id) \
- MCFG_PCI_DEVICE_ADD(_tag, APIC, _main_id, _revision, 0x0c0320, _subdevice_id)
-
-class apic_device : public pci_device {
-public:
- apic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-};
-
-extern const device_type APIC;
-
-#endif
diff --git a/src/emu/machine/pci-sata.c b/src/emu/machine/pci-sata.c
deleted file mode 100644
index 65cc090848b..00000000000
--- a/src/emu/machine/pci-sata.c
+++ /dev/null
@@ -1,46 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "pci-sata.h"
-
-const device_type SATA = &device_creator<sata_device>;
-
-sata_device::sata_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_device(mconfig, SATA, "SATA AHCI interface", tag, owner, clock, "sata", __FILE__)
-{
-}
-
-DEVICE_ADDRESS_MAP_START(primary_command_map, 32, sata_device)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(primary_control_map, 32, sata_device)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(secondary_command_map, 32, sata_device)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(secondary_control_map, 32, sata_device)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(bus_master_map, 32, sata_device)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(ide_command_posting_map, 32, sata_device)
-ADDRESS_MAP_END
-
-
-void sata_device::device_start()
-{
- pci_device::device_start();
-
- add_map(8, M_IO, FUNC(sata_device::primary_command_map));
- add_map(4, M_IO, FUNC(sata_device::primary_control_map));
- add_map(8, M_IO, FUNC(sata_device::secondary_command_map));
- add_map(4, M_IO, FUNC(sata_device::secondary_control_map));
- add_map(16, M_IO, FUNC(sata_device::bus_master_map));
- add_map(1024, M_MEM, FUNC(sata_device::ide_command_posting_map));
-}
-
-void sata_device::device_reset()
-{
- pci_device::device_reset();
-}
diff --git a/src/emu/machine/pci-sata.h b/src/emu/machine/pci-sata.h
deleted file mode 100644
index 59b41635622..00000000000
--- a/src/emu/machine/pci-sata.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef PCI_SATA_H
-#define PCI_SATA_H
-
-#include "pci.h"
-
-#define MCFG_SATA_ADD(_tag, _main_id, _revision, _subdevice_id) \
- MCFG_PCI_DEVICE_ADD(_tag, SATA, _main_id, _revision, 0x01018a, _subdevice_id)
-
-class sata_device : public pci_device {
-public:
- sata_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
-private:
- DECLARE_ADDRESS_MAP(primary_command_map, 32);
- DECLARE_ADDRESS_MAP(primary_control_map, 32);
- DECLARE_ADDRESS_MAP(secondary_command_map, 32);
- DECLARE_ADDRESS_MAP(secondary_control_map, 32);
- DECLARE_ADDRESS_MAP(bus_master_map, 32);
- DECLARE_ADDRESS_MAP(ide_command_posting_map, 32);
-};
-
-extern const device_type SATA;
-
-#endif
diff --git a/src/emu/machine/pci-smbus.c b/src/emu/machine/pci-smbus.c
deleted file mode 100644
index 13d4d491570..00000000000
--- a/src/emu/machine/pci-smbus.c
+++ /dev/null
@@ -1,280 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "pci-smbus.h"
-
-const device_type SMBUS = &device_creator<smbus_device>;
-
-DEVICE_ADDRESS_MAP_START(map, 32, smbus_device)
- AM_RANGE(0x00, 0x03) AM_READWRITE8 (hst_sts_r, hst_sts_w, 0x000000ff)
- AM_RANGE(0x00, 0x03) AM_READWRITE8 (hst_cnt_r, hst_cnt_w, 0x00ff0000)
- AM_RANGE(0x00, 0x03) AM_READWRITE8 (hst_cmd_r, hst_cmd_w, 0xff000000)
- AM_RANGE(0x04, 0x07) AM_READWRITE8 (xmit_slva_r, xmit_slva_w, 0x000000ff)
- AM_RANGE(0x04, 0x07) AM_READWRITE8 (hst_d0_r, hst_d0_w, 0x0000ff00)
- AM_RANGE(0x04, 0x07) AM_READWRITE8 (hst_d1_r, hst_d1_w, 0x00ff0000)
- AM_RANGE(0x04, 0x07) AM_READWRITE8 (host_block_db_r, host_block_db_w, 0xff000000)
- AM_RANGE(0x08, 0x0b) AM_READWRITE8 (pec_r, pec_w, 0x000000ff)
- AM_RANGE(0x08, 0x0b) AM_READWRITE8 (rcv_slva_r, rcv_slva_w, 0x0000ff00)
- AM_RANGE(0x08, 0x0b) AM_READWRITE16(slv_data_r, slv_data_w, 0xffff0000)
- AM_RANGE(0x0c, 0x0f) AM_READWRITE8 (aux_sts_r, aux_sts_w, 0x000000ff)
- AM_RANGE(0x0c, 0x0f) AM_READWRITE8 (aux_ctl_r, aux_ctl_w, 0x0000ff00)
- AM_RANGE(0x0c, 0x0f) AM_READWRITE8 (smlink_pin_ctl_r, smlink_pin_ctl_w, 0x00ff0000)
- AM_RANGE(0x0c, 0x0f) AM_READWRITE8 (smbus_pin_ctl_r, smbus_pin_ctl_w, 0xff000000)
- AM_RANGE(0x10, 0x13) AM_READWRITE8 (slv_sts_r, slv_sts_w, 0x000000ff)
- AM_RANGE(0x10, 0x13) AM_READWRITE8 (slv_cmd_r, slv_cmd_w, 0x0000ff00)
- AM_RANGE(0x14, 0x17) AM_READ8 (notify_daddr_r, 0x000000ff)
- AM_RANGE(0x14, 0x17) AM_READ8 (notify_dlow_r, 0x00ff0000)
- AM_RANGE(0x14, 0x17) AM_READ8 (notify_dhigh_r, 0xff000000)
-ADDRESS_MAP_END
-
-smbus_device::smbus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_device(mconfig, SMBUS, "SMBUS interface", tag, owner, clock, "smbus", __FILE__)
-{
-}
-
-void smbus_device::device_start()
-{
- pci_device::device_start();
- skip_map_regs(4);
- add_map(32, M_IO, FUNC(smbus_device::map));
-}
-
-void smbus_device::device_reset()
-{
- pci_device::device_reset();
- hst_sts = 0x00;
- hst_cnt = 0x00;
- hst_cmd = 0x00;
- xmit_slva = 0x00;
- hst_d0 = 0x00;
- hst_d1 = 0x00;
- host_block_db = 0x00;
- pec = 0x00;
- rcv_slva = 0x44;
- slv_data = 0x0000;
- aux_sts = 0x00;
- aux_ctl = 0x00;
- smlink_pin_ctl = 0x00;
- smbus_pin_ctl = 0x00;
- slv_sts = 0x00;
- slv_cmd = 0x00;
- notify_daddr = 0x00;
- notify_dlow = 0x00;
- notify_dhigh = 0x00;
-}
-
-READ8_MEMBER (smbus_device::hst_sts_r)
-{
- return hst_sts;
-}
-
-WRITE8_MEMBER (smbus_device::hst_sts_w)
-{
- hst_sts &= ~data;
- logerror("%s: hst_sts = %02x\n", tag(), hst_sts);
-}
-
-READ8_MEMBER (smbus_device::hst_cnt_r)
-{
- return hst_cnt;
-}
-
-WRITE8_MEMBER (smbus_device::hst_cnt_w)
-{
- hst_cnt = data;
- logerror("%s: hst_cnt = %02x\n", tag(), hst_cnt);
-
- if(xmit_slva != 0xa1)
- hst_sts = 4;
- else {
- const UINT8 eeprom[256] = {
- 0x80, 0x08, 0x07, 0x0D, 0x0A, 0x02, 0x40, 0x00, 0x04, 0x50, 0x60, 0x00, 0x82, 0x08, 0x00, 0x01,
- 0x0E, 0x04, 0x08, 0x01, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x28, 0x3C, 0x28, 0x40,
- 0x60, 0x60, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x46, 0x28, 0x28, 0x55, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCE,
- 0x7F, 0x7F, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x56, 0x53, 0x35, 0x31, 0x32, 0x4D, 0x42,
- 0x34, 0x30, 0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
-
- hst_sts = 2;
- hst_d0 = eeprom[hst_cmd];
- }
-}
-
-READ8_MEMBER (smbus_device::hst_cmd_r)
-{
- return hst_cmd;
-}
-
-WRITE8_MEMBER (smbus_device::hst_cmd_w)
-{
- hst_cmd = data;
- logerror("%s: hst_cmd = %02x\n", tag(), hst_cmd);
-}
-
-READ8_MEMBER (smbus_device::xmit_slva_r)
-{
- return xmit_slva;
-}
-
-WRITE8_MEMBER (smbus_device::xmit_slva_w)
-{
- xmit_slva = data;
- logerror("%s: xmit_slva = %02x\n", tag(), xmit_slva);
-}
-
-READ8_MEMBER (smbus_device::hst_d0_r)
-{
- return hst_d0;
-}
-
-WRITE8_MEMBER (smbus_device::hst_d0_w)
-{
- hst_d0 = data;
- logerror("%s: hst_d0 = %02x\n", tag(), hst_d0);
-}
-
-READ8_MEMBER (smbus_device::hst_d1_r)
-{
- return hst_d1;
-}
-
-WRITE8_MEMBER (smbus_device::hst_d1_w)
-{
- hst_d1 = data;
- logerror("%s: hst_d1 = %02x\n", tag(), hst_d1);
-}
-
-READ8_MEMBER (smbus_device::host_block_db_r)
-{
- return host_block_db;
-}
-
-WRITE8_MEMBER (smbus_device::host_block_db_w)
-{
- host_block_db = data;
- logerror("%s: host_block_db = %02x\n", tag(), host_block_db);
-}
-
-READ8_MEMBER (smbus_device::pec_r)
-{
- return pec;
-}
-
-WRITE8_MEMBER (smbus_device::pec_w)
-{
- pec = data;
- logerror("%s: pec = %02x\n", tag(), pec);
-}
-
-READ8_MEMBER (smbus_device::rcv_slva_r)
-{
- return rcv_slva;
-}
-
-WRITE8_MEMBER (smbus_device::rcv_slva_w)
-{
- rcv_slva = data;
- logerror("%s: rcv_slva = %02x\n", tag(), rcv_slva);
-}
-
-READ16_MEMBER (smbus_device::slv_data_r)
-{
- return slv_data;
-}
-
-WRITE16_MEMBER(smbus_device::slv_data_w)
-{
- slv_data = data;
- logerror("%s: slv_data = %02x\n", tag(), slv_data);
-}
-
-READ8_MEMBER (smbus_device::aux_sts_r)
-{
- return aux_sts;
-}
-
-WRITE8_MEMBER (smbus_device::aux_sts_w)
-{
- aux_sts = data;
- logerror("%s: aux_sts = %02x\n", tag(), aux_sts);
-}
-
-READ8_MEMBER (smbus_device::aux_ctl_r)
-{
- return aux_ctl;
-}
-
-WRITE8_MEMBER (smbus_device::aux_ctl_w)
-{
- aux_ctl = data;
- logerror("%s: aux_ctl = %02x\n", tag(), aux_ctl);
-}
-
-READ8_MEMBER (smbus_device::smlink_pin_ctl_r)
-{
- return smlink_pin_ctl;
-}
-
-WRITE8_MEMBER (smbus_device::smlink_pin_ctl_w)
-{
- smlink_pin_ctl = data;
- logerror("%s: smlink_pin_ctl = %02x\n", tag(), smlink_pin_ctl);
-}
-
-READ8_MEMBER (smbus_device::smbus_pin_ctl_r)
-{
- return smbus_pin_ctl;
-}
-
-WRITE8_MEMBER (smbus_device::smbus_pin_ctl_w)
-{
- smbus_pin_ctl = data;
- logerror("%s: smbus_pin_ctl = %02x\n", tag(), smbus_pin_ctl);
-}
-
-READ8_MEMBER (smbus_device::slv_sts_r)
-{
- return slv_sts;
-}
-
-WRITE8_MEMBER (smbus_device::slv_sts_w)
-{
- slv_sts = data;
- logerror("%s: slv_sts = %02x\n", tag(), slv_sts);
-}
-
-READ8_MEMBER (smbus_device::slv_cmd_r)
-{
- return slv_cmd;
-}
-
-WRITE8_MEMBER (smbus_device::slv_cmd_w)
-{
- slv_cmd = data;
- logerror("%s: slv_cmd = %02x\n", tag(), slv_cmd);
-}
-
-READ8_MEMBER (smbus_device::notify_daddr_r)
-{
- return notify_daddr;
-}
-
-READ8_MEMBER (smbus_device::notify_dlow_r)
-{
- return notify_dlow;
-}
-
-READ8_MEMBER (smbus_device::notify_dhigh_r)
-{
- return notify_dhigh;
-}
diff --git a/src/emu/machine/pci-smbus.h b/src/emu/machine/pci-smbus.h
deleted file mode 100644
index e149e3e547c..00000000000
--- a/src/emu/machine/pci-smbus.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef PCI_SMBUS_H
-#define PCI_SMBUS_H
-
-#include "pci.h"
-
-#define MCFG_SMBUS_ADD(_tag, _main_id, _revision, _subdevice_id) \
- MCFG_PCI_DEVICE_ADD(_tag, SMBUS, _main_id, _revision, 0x0c0500, _subdevice_id)
-
-class smbus_device : public pci_device {
-public:
- smbus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER (hst_sts_r);
- DECLARE_WRITE8_MEMBER (hst_sts_w);
- DECLARE_READ8_MEMBER (hst_cnt_r);
- DECLARE_WRITE8_MEMBER (hst_cnt_w);
- DECLARE_READ8_MEMBER (hst_cmd_r);
- DECLARE_WRITE8_MEMBER (hst_cmd_w);
- DECLARE_READ8_MEMBER (xmit_slva_r);
- DECLARE_WRITE8_MEMBER (xmit_slva_w);
- DECLARE_READ8_MEMBER (hst_d0_r);
- DECLARE_WRITE8_MEMBER (hst_d0_w);
- DECLARE_READ8_MEMBER (hst_d1_r);
- DECLARE_WRITE8_MEMBER (hst_d1_w);
- DECLARE_READ8_MEMBER (host_block_db_r);
- DECLARE_WRITE8_MEMBER (host_block_db_w);
- DECLARE_READ8_MEMBER (pec_r);
- DECLARE_WRITE8_MEMBER (pec_w);
- DECLARE_READ8_MEMBER (rcv_slva_r);
- DECLARE_WRITE8_MEMBER (rcv_slva_w);
- DECLARE_READ16_MEMBER (slv_data_r);
- DECLARE_WRITE16_MEMBER(slv_data_w);
- DECLARE_READ8_MEMBER (aux_sts_r);
- DECLARE_WRITE8_MEMBER (aux_sts_w);
- DECLARE_READ8_MEMBER (aux_ctl_r);
- DECLARE_WRITE8_MEMBER (aux_ctl_w);
- DECLARE_READ8_MEMBER (smlink_pin_ctl_r);
- DECLARE_WRITE8_MEMBER (smlink_pin_ctl_w);
- DECLARE_READ8_MEMBER (smbus_pin_ctl_r);
- DECLARE_WRITE8_MEMBER (smbus_pin_ctl_w);
- DECLARE_READ8_MEMBER (slv_sts_r);
- DECLARE_WRITE8_MEMBER (slv_sts_w);
- DECLARE_READ8_MEMBER (slv_cmd_r);
- DECLARE_WRITE8_MEMBER (slv_cmd_w);
- DECLARE_READ8_MEMBER (notify_daddr_r);
- DECLARE_READ8_MEMBER (notify_dlow_r);
- DECLARE_READ8_MEMBER (notify_dhigh_r);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
-private:
- DECLARE_ADDRESS_MAP(map, 32);
-
- UINT16 slv_data;
-
- UINT8 hst_sts, hst_cnt, hst_cmd, xmit_slva, hst_d0, hst_d1;
- UINT8 host_block_db, pec, rcv_slva, aux_sts, aux_ctl;
- UINT8 smlink_pin_ctl, smbus_pin_ctl, slv_sts, slv_cmd, notify_daddr, notify_dlow, notify_dhigh;
-};
-
-extern const device_type SMBUS;
-
-#endif
diff --git a/src/emu/machine/pci-usb.c b/src/emu/machine/pci-usb.c
deleted file mode 100644
index 56789e12eb3..00000000000
--- a/src/emu/machine/pci-usb.c
+++ /dev/null
@@ -1,44 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "pci-usb.h"
-
-const device_type USB_UHCI = &device_creator<usb_uhci_device>;
-const device_type USB_EHCI = &device_creator<usb_ehci_device>;
-
-DEVICE_ADDRESS_MAP_START(map, 32, usb_uhci_device)
-ADDRESS_MAP_END
-
-usb_uhci_device::usb_uhci_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_device(mconfig, USB_UHCI, "USB 1.1 UHCI interface", tag, owner, clock, "usb_uhci", __FILE__)
-{
-}
-
-void usb_uhci_device::device_start()
-{
- pci_device::device_start();
- add_map(32, M_IO, FUNC(usb_uhci_device::map));
-}
-
-void usb_uhci_device::device_reset()
-{
- pci_device::device_reset();
-}
-
-DEVICE_ADDRESS_MAP_START(map, 32, usb_ehci_device)
-ADDRESS_MAP_END
-
-usb_ehci_device::usb_ehci_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_device(mconfig, USB_EHCI, "USB 2.0 EHCI interface", tag, owner, clock, "usb_ehci", __FILE__)
-{
-}
-
-void usb_ehci_device::device_start()
-{
- pci_device::device_start();
- add_map(1024, M_MEM, FUNC(usb_ehci_device::map));
-}
-
-void usb_ehci_device::device_reset()
-{
- pci_device::device_reset();
-}
diff --git a/src/emu/machine/pci-usb.h b/src/emu/machine/pci-usb.h
deleted file mode 100644
index e103e89d968..00000000000
--- a/src/emu/machine/pci-usb.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef PCI_USB_H
-#define PCI_USB_H
-
-#include "pci.h"
-
-#define MCFG_USB_UHCI_ADD(_tag, _main_id, _revision, _subdevice_id) \
- MCFG_PCI_DEVICE_ADD(_tag, USB_UHCI, _main_id, _revision, 0x0c0300, _subdevice_id)
-
-#define MCFG_USB_EHCI_ADD(_tag, _main_id, _revision, _subdevice_id) \
- MCFG_PCI_DEVICE_ADD(_tag, USB_EHCI, _main_id, _revision, 0x0c0320, _subdevice_id)
-
-class usb_uhci_device : public pci_device {
-public:
- usb_uhci_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
-private:
- DECLARE_ADDRESS_MAP(map, 32);
-};
-
-class usb_ehci_device : public pci_device {
-public:
- usb_ehci_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-
-private:
- DECLARE_ADDRESS_MAP(map, 32);
-};
-
-extern const device_type USB_UHCI;
-extern const device_type USB_EHCI;
-
-#endif
diff --git a/src/emu/machine/pci.c b/src/emu/machine/pci.c
deleted file mode 100644
index a5c95198c75..00000000000
--- a/src/emu/machine/pci.c
+++ /dev/null
@@ -1,908 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "pci.h"
-
-// for now, make buggy GCC/Mingw STFU about I64FMT
-#if (defined(__MINGW32__) && (__GNUC__ >= 5))
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat"
-#pragma GCC diagnostic ignored "-Wformat-extra-args"
-#endif
-
-const device_type PCI_ROOT = &device_creator<pci_root_device>;
-const device_type PCI_BRIDGE = &device_creator<pci_bridge_device>;
-
-DEVICE_ADDRESS_MAP_START(config_map, 32, pci_device)
- AM_RANGE(0x00, 0x03) AM_READ16 (vendor_r, 0x0000ffff)
- AM_RANGE(0x00, 0x03) AM_READ16 (device_r, 0xffff0000)
- AM_RANGE(0x04, 0x07) AM_READWRITE16(command_r, command_w, 0x0000ffff)
- AM_RANGE(0x04, 0x07) AM_READ16 (status_r, 0xffff0000)
- AM_RANGE(0x08, 0x0b) AM_READ (class_rev_r)
- AM_RANGE(0x0c, 0x0f) AM_READ8 (cache_line_size_r, 0x000000ff)
- AM_RANGE(0x0c, 0x0f) AM_READ8 (latency_timer_r, 0x0000ff00)
- AM_RANGE(0x0c, 0x0f) AM_READ8 (header_type_r, 0x00ff0000)
- AM_RANGE(0x0c, 0x0f) AM_READ8 (bist_r, 0xff000000)
- AM_RANGE(0x0c, 0x0f) AM_WRITENOP
- AM_RANGE(0x10, 0x27) AM_READWRITE (address_base_r, address_base_w)
- // Cardbus CIS pointer at 28
- AM_RANGE(0x2c, 0x2f) AM_READ16 (subvendor_r, 0x0000ffff)
- AM_RANGE(0x2c, 0x2f) AM_READ16 (subsystem_r, 0xffff0000)
- AM_RANGE(0x2c, 0x2f) AM_WRITENOP
- AM_RANGE(0x30, 0x33) AM_READWRITE (expansion_base_r, expansion_base_w)
- AM_RANGE(0x34, 0x37) AM_READ8 (capptr_r, 0x000000ff)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(config_map, 32, pci_bridge_device)
- AM_RANGE(0x00, 0x03) AM_READ16 (vendor_r, 0x0000ffff)
- AM_RANGE(0x00, 0x03) AM_READ16 (device_r, 0xffff0000)
- AM_RANGE(0x04, 0x07) AM_READWRITE16(command_r, command_w, 0x0000ffff)
- AM_RANGE(0x04, 0x07) AM_READ16 (status_r, 0xffff0000)
- AM_RANGE(0x08, 0x0b) AM_READ (class_rev_r)
- AM_RANGE(0x0c, 0x0f) AM_READ8 (cache_line_size_r, 0x000000ff)
- AM_RANGE(0x0c, 0x0f) AM_READ8 (latency_timer_r, 0x0000ff00)
- AM_RANGE(0x0c, 0x0f) AM_READ8 (header_type_r, 0x00ff0000)
- AM_RANGE(0x0c, 0x0f) AM_READ8 (bist_r, 0xff000000)
- AM_RANGE(0x10, 0x17) AM_READWRITE (b_address_base_r, b_address_base_w)
- AM_RANGE(0x18, 0x1b) AM_READWRITE8 (primary_bus_r, primary_bus_w, 0x000000ff)
- AM_RANGE(0x18, 0x1b) AM_READWRITE8 (secondary_bus_r, secondary_bus_w, 0x0000ff00)
- AM_RANGE(0x18, 0x1b) AM_READWRITE8 (subordinate_bus_r, subordinate_bus_w, 0x00ff0000)
- AM_RANGE(0x18, 0x1b) AM_READWRITE8 (secondary_latency_r, secondary_latency_w, 0xff000000)
- AM_RANGE(0x1c, 0x1f) AM_READWRITE8 (iobase_r, iobase_w, 0x000000ff)
- AM_RANGE(0x1c, 0x1f) AM_READWRITE8 (iolimit_r, iolimit_w, 0x0000ff00)
- AM_RANGE(0x1c, 0x1f) AM_READWRITE16(secondary_status_r, secondary_status_w, 0xffff0000)
- AM_RANGE(0x20, 0x23) AM_READWRITE16(memory_base_r, memory_base_w, 0x0000ffff)
- AM_RANGE(0x20, 0x23) AM_READWRITE16(memory_limit_r, memory_limit_w, 0xffff0000)
- AM_RANGE(0x24, 0x27) AM_READWRITE16(prefetch_base_r, prefetch_base_w, 0x0000ffff)
- AM_RANGE(0x24, 0x27) AM_READWRITE16(prefetch_limit_r, prefetch_limit_w, 0xffff0000)
- AM_RANGE(0x28, 0x2b) AM_READWRITE (prefetch_baseu_r, prefetch_baseu_w)
- AM_RANGE(0x2c, 0x2f) AM_READWRITE (prefetch_limitu_r, prefetch_limitu_w)
- AM_RANGE(0x30, 0x33) AM_READWRITE16(iobaseu_r, iobaseu_w, 0x0000ffff)
- AM_RANGE(0x30, 0x33) AM_READWRITE16(iolimitu_r, iolimitu_w, 0xffff0000)
- AM_RANGE(0x34, 0x37) AM_READ8 (capptr_r, 0x000000ff)
- AM_RANGE(0x38, 0x3b) AM_READWRITE (expansion_base_r, expansion_base_w)
- AM_RANGE(0x3c, 0x3f) AM_READWRITE8 (interrupt_line_r, interrupt_line_w, 0x000000ff)
- AM_RANGE(0x3c, 0x3f) AM_READWRITE8 (interrupt_pin_r, interrupt_pin_w, 0x0000ff00)
- AM_RANGE(0x3c, 0x3f) AM_READWRITE16(bridge_control_r, bridge_control_w, 0xffff0000)
-ADDRESS_MAP_END
-
-pci_device::pci_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source)
-{
- main_id = 0xffffffff;
- revision = 0x00;
- pclass = 0xffffff;
- subsystem_id = 0xffffffff;
- is_multifunction_device = false;
-}
-
-void pci_device::set_ids(UINT32 _main_id, UINT8 _revision, UINT32 _pclass, UINT32 _subsystem_id)
-{
- main_id = _main_id;
- revision = _revision;
- pclass = _pclass;
- subsystem_id = _subsystem_id;
-}
-
-void pci_device::device_start()
-{
- command = 0x0080;
- command_mask = 0x01bf;
- status = 0x0000;
-
- for(int i=0; i<6; i++) {
- bank_infos[i].adr = -1;
- bank_infos[i].size = 0;
- bank_infos[i].flags = 0;
- bank_reg_infos[i].bank = -1;
- bank_reg_infos[i].hi = 0;
- }
-
- bank_count = 0;
- bank_reg_count = 0;
-
- expansion_rom = 0;
- expansion_rom_size = 0;
- expansion_rom_base = 0;
-}
-
-void pci_device::device_reset()
-{
-}
-
-UINT32 pci_device::unmapped_r(offs_t offset, UINT32 mem_mask, int bank)
-{
- logerror("%s: unmapped read from %08x & %08x (%s)\n", machine().describe_context(), offset*4, mem_mask, bank_infos[bank].map.name());
- return 0;
-}
-
-void pci_device::unmapped_w(offs_t offset, UINT32 data, UINT32 mem_mask, int bank)
-{
- logerror("%s: unmapped write to %08x = %08x & %08x (%s)\n", machine().describe_context(), offset*4, data, mem_mask, bank_infos[bank].map.name());
-}
-
-READ32_MEMBER(pci_device::unmapped0_r) { return unmapped_r(offset, mem_mask, 0); }
-WRITE32_MEMBER(pci_device::unmapped0_w) { return unmapped_w(offset, data, mem_mask, 0); }
-READ32_MEMBER(pci_device::unmapped1_r) { return unmapped_r(offset, mem_mask, 1); }
-WRITE32_MEMBER(pci_device::unmapped1_w) { return unmapped_w(offset, data, mem_mask, 1); }
-READ32_MEMBER(pci_device::unmapped2_r) { return unmapped_r(offset, mem_mask, 2); }
-WRITE32_MEMBER(pci_device::unmapped2_w) { return unmapped_w(offset, data, mem_mask, 2); }
-READ32_MEMBER(pci_device::unmapped3_r) { return unmapped_r(offset, mem_mask, 3); }
-WRITE32_MEMBER(pci_device::unmapped3_w) { return unmapped_w(offset, data, mem_mask, 3); }
-READ32_MEMBER(pci_device::unmapped4_r) { return unmapped_r(offset, mem_mask, 4); }
-WRITE32_MEMBER(pci_device::unmapped4_w) { return unmapped_w(offset, data, mem_mask, 4); }
-READ32_MEMBER(pci_device::unmapped5_r) { return unmapped_r(offset, mem_mask, 5); }
-WRITE32_MEMBER(pci_device::unmapped5_w) { return unmapped_w(offset, data, mem_mask, 5); }
-
-
-READ32_MEMBER(pci_device::address_base_r)
-{
- if(bank_reg_infos[offset].bank == -1)
- return 0;
- int bid = bank_reg_infos[offset].bank;
- if(bank_reg_infos[offset].hi)
- return bank_infos[bid].adr >> 32;
- int flags = bank_infos[bid].flags;
- return (bank_infos[bid].adr & ~(bank_infos[bid].size - 1)) | (flags & M_IO ? 1 : 0) | (flags & M_64A ? 4 : 0) | (flags & M_PREF ? 8 : 0);
-}
-
-WRITE32_MEMBER(pci_device::address_base_w)
-{
- if(bank_reg_infos[offset].bank == -1) {
- logerror("%s: write to address base (%d, %08x) not linked to any bank\n", tag(), offset, data);
- return;
- }
-
- int bid = bank_reg_infos[offset].bank;
- if(bank_reg_infos[offset].hi)
- bank_infos[bid].adr = (bank_infos[bid].adr & 0xffffffff) | (UINT64(data) << 32);
- else {
- bank_infos[bid].adr = (bank_infos[bid].adr & U64(0xffffffff00000000)) | data;
- }
- remap_cb();
-}
-
-READ16_MEMBER(pci_device::vendor_r)
-{
- return main_id >> 16;
-}
-
-READ16_MEMBER(pci_device::device_r)
-{
- return main_id;
-}
-
-READ16_MEMBER(pci_device::command_r)
-{
- return command;
-}
-
-WRITE16_MEMBER(pci_device::command_w)
-{
- mem_mask &= command_mask;
- COMBINE_DATA(&command);
- logerror("%s: command = %04x\n", tag(), command);
-}
-
-READ16_MEMBER(pci_device::status_r)
-{
- return status;
-}
-
-READ32_MEMBER(pci_device::class_rev_r)
-{
- return (pclass << 8) | revision;
-}
-
-READ8_MEMBER(pci_device::cache_line_size_r)
-{
- return 0x00;
-}
-
-READ8_MEMBER(pci_device::latency_timer_r)
-{
- return 0x00;
-}
-
-void pci_device::set_multifunction_device(bool enable)
-{
- is_multifunction_device = enable;
-}
-
-READ8_MEMBER(pci_device::header_type_r)
-{
- return is_multifunction_device ? 0x80 : 0x00;
-}
-
-READ8_MEMBER(pci_device::bist_r)
-{
- return 0x00;
-}
-
-READ16_MEMBER(pci_device::subvendor_r)
-{
- return subsystem_id >> 16;
-}
-
-READ16_MEMBER(pci_device::subsystem_r)
-{
- return subsystem_id;
-}
-
-READ32_MEMBER(pci_device::expansion_base_r)
-{
- return expansion_rom_base;
-}
-
-
-WRITE32_MEMBER(pci_device::expansion_base_w)
-{
- COMBINE_DATA(&expansion_rom_base);
- if(!expansion_rom_size)
- expansion_rom_base = 0;
- else {
- // Trick to get an address resolution at expansion_rom_size with minimal granularity of 0x800, plus bit 1 set to keep the on/off information
- expansion_rom_base &= 0xfffff801 & (1-expansion_rom_size);
- }
- remap_cb();
-}
-
-READ8_MEMBER(pci_device::capptr_r)
-{
- return 0x00;
-}
-
-void pci_device::set_remap_cb(mapper_cb _remap_cb)
-{
- remap_cb = _remap_cb;
-}
-
-void pci_device::reset_all_mappings()
-{
-}
-
-void pci_device::map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space)
-{
- for(int i=0; i<bank_count; i++) {
- bank_info &bi = bank_infos[i];
- if(UINT32(bi.adr) == 0xffffffff)
- continue;
- if(!bi.size || (bi.flags & M_DISABLED))
- continue;
-
- address_space *space;
- UINT64 start = bi.adr & ~(bi.size - 1);
-
- if(bi.flags & M_IO) {
- space = io_space;
- start += io_offset;
- } else {
- space = memory_space;
- start += memory_offset;
- }
- UINT64 end = start + bi.size-1;
- switch(i) {
- case 0: space->install_readwrite_handler(start, end, 0, 0, read32_delegate(FUNC(pci_device::unmapped0_r), this), write32_delegate(FUNC(pci_device::unmapped0_w), this)); break;
- case 1: space->install_readwrite_handler(start, end, 0, 0, read32_delegate(FUNC(pci_device::unmapped1_r), this), write32_delegate(FUNC(pci_device::unmapped1_w), this)); break;
- case 2: space->install_readwrite_handler(start, end, 0, 0, read32_delegate(FUNC(pci_device::unmapped2_r), this), write32_delegate(FUNC(pci_device::unmapped2_w), this)); break;
- case 3: space->install_readwrite_handler(start, end, 0, 0, read32_delegate(FUNC(pci_device::unmapped3_r), this), write32_delegate(FUNC(pci_device::unmapped3_w), this)); break;
- case 4: space->install_readwrite_handler(start, end, 0, 0, read32_delegate(FUNC(pci_device::unmapped4_r), this), write32_delegate(FUNC(pci_device::unmapped4_w), this)); break;
- case 5: space->install_readwrite_handler(start, end, 0, 0, read32_delegate(FUNC(pci_device::unmapped5_r), this), write32_delegate(FUNC(pci_device::unmapped5_w), this)); break;
- }
-
- space->install_device_delegate(start, end, *this, bi.map);
- logerror("%s: map %s at %0*x-%0*x\n", tag(), bi.map.name(), bi.flags & M_IO ? 4 : 8, UINT32(start), bi.flags & M_IO ? 4 : 8, UINT32(end));
- }
-
- map_extra(memory_window_start, memory_window_end, memory_offset, memory_space,
- io_window_start, io_window_end, io_offset, io_space);
-
- if(expansion_rom_base & 1) {
- logerror("%s: map expansion rom at %08x-%08x\n", tag(), expansion_rom_base & ~1, (expansion_rom_base & ~1) + expansion_rom_size - 1);
- UINT32 start = (expansion_rom_base & ~1) + memory_offset;
- UINT32 end = start + expansion_rom_size - 1;
- if(end > memory_window_end)
- end = memory_window_end;
- memory_space->install_rom(start, end, (void *)expansion_rom);
- }
-}
-
-void pci_device::map_extra(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space)
-{
-}
-
-void pci_device::map_config(UINT8 device, address_space *config_space)
-{
- config_space->install_device(device << 12, (device << 12) | 0xfff, *this, &pci_device::config_map);
-}
-
-void pci_device::skip_map_regs(int count)
-{
- bank_reg_count += count;
- assert(bank_reg_count <= 6);
-}
-
-void pci_device::add_map(UINT64 size, int flags, address_map_delegate &map)
-{
- assert(bank_count < 6);
- int bid = bank_count++;
- bank_infos[bid].map = map;
- bank_infos[bid].adr = 0;
- bank_infos[bid].size = size;
- bank_infos[bid].flags = flags;
-
- if(flags & M_64A) {
- assert(bank_reg_count < 5);
- int breg = bank_reg_count;
- bank_reg_infos[breg].bank = bid;
- bank_reg_infos[breg].hi = 0;
- bank_reg_infos[breg+1].bank = bid;
- bank_reg_infos[breg+1].hi = 1;
- bank_reg_count += 2;
- } else {
- assert(bank_reg_count < 6);
- int breg = bank_reg_count++;
- bank_reg_infos[breg].bank = bid;
- bank_reg_infos[breg].hi = 0;
- }
-
- logerror("Device %s (%s) has 0x%" I64FMT "x bytes of %s named %s\n", tag(), name(), size, flags & M_IO ? "io" : "memory", bank_infos[bid].map.name());
-}
-
-void pci_device::add_rom(const UINT8 *rom, UINT32 size)
-{
- expansion_rom = rom;
- expansion_rom_size = size;
- logerror("Device %s (%s) has 0x%x bytes of expansion rom\n", tag(), name(), size);
-}
-
-void pci_device::add_rom_from_region()
-{
- add_rom(m_region->base(), m_region->bytes());
-}
-
-void pci_device::set_map_address(int id, UINT64 adr)
-{
- bank_infos[id].adr = adr;
- remap_cb();
-}
-
-void pci_device::set_map_size(int id, UINT64 size)
-{
- bank_infos[id].size = size;
- remap_cb();
-}
-
-void pci_device::set_map_flags(int id, int flags)
-{
- bank_infos[id].flags = flags;
- remap_cb();
-}
-
-agp_device::agp_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : pci_device(mconfig, type, name, tag, owner, clock, shortname, source)
-{
-}
-
-void agp_device::device_start()
-{
- pci_device::device_start();
-}
-
-void agp_device::device_reset()
-{
- pci_device::device_reset();
-}
-
-
-
-pci_bridge_device::pci_bridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_device(mconfig, PCI_BRIDGE, "PCI-PCI Bridge", tag, owner, clock, "pci_bridge", __FILE__),
- device_memory_interface(mconfig, *this),
- configure_space_config("configuration_space", ENDIANNESS_LITTLE, 32, 20)
-{
-}
-
-pci_bridge_device::pci_bridge_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : pci_device(mconfig, type, name, tag, owner, clock, shortname, source),
- device_memory_interface(mconfig, *this),
- configure_space_config("configuration_space", ENDIANNESS_LITTLE, 32, 20)
-{
-}
-
-READ8_MEMBER(pci_bridge_device::header_type_r)
-{
- return 0x01;
-}
-
-const address_space_config *pci_bridge_device::memory_space_config(address_spacenum spacenum) const
-{
- return spacenum == AS_PROGRAM ? &configure_space_config : NULL;
-}
-
-device_t *pci_bridge_device::bus_root()
-{
- return this;
-}
-
-void pci_bridge_device::set_remap_cb(mapper_cb _remap_cb)
-{
- remap_cb = _remap_cb;
- for(unsigned int i=0; i != all_devices.size(); i++)
- if(all_devices[i] != this)
- all_devices[i]->set_remap_cb(_remap_cb);
-}
-
-void pci_bridge_device::device_start()
-{
- pci_device::device_start();
-
- for(int i=0; i<32*8; i++)
- sub_devices[i] = NULL;
-
- for(device_t *d = bus_root()->first_subdevice(); d != NULL; d = d->next()) {
- const char *t = d->tag();
- int l = strlen(t);
- if(l <= 4 || t[l-5] != ':' || t[l-2] != '.')
- continue;
- int id = strtol(t+l-4, 0, 16);
- int fct = t[l-1] - '0';
- sub_devices[(id << 3) | fct] = downcast<pci_device *>(d);
- }
-
- mapper_cb cf_cb(FUNC(pci_bridge_device::regenerate_config_mapping), this);
-
- for(int i=0; i<32*8; i++)
- if(sub_devices[i]) {
- if((i & 7) && sub_devices[i & ~7])
- sub_devices[i & ~7]->set_multifunction_device(true);
-
- all_devices.push_back(sub_devices[i]);
- if(sub_devices[i] != this) {
- sub_devices[i]->remap_config_cb = cf_cb;
- sub_devices[i]->set_remap_cb(remap_cb);
- pci_bridge_device *bridge = dynamic_cast<pci_bridge_device *>(sub_devices[i]);
- if(bridge)
- all_bridges.push_back(bridge);
- }
- }
-}
-
-void pci_bridge_device::device_reset()
-{
- pci_device::device_reset();
-
- bridge_control = 0x0000;
- primary_bus = 0x00;
- secondary_bus = 0x00;
- subordinate_bus = 0x00;
- regenerate_config_mapping();
-}
-
-void pci_bridge_device::reset_all_mappings()
-{
- pci_device::reset_all_mappings();
-
- for(unsigned int i=0; i != all_devices.size(); i++)
- if(all_devices[i] != this)
- all_devices[i]->reset_all_mappings();
-
- prefetch_baseu = 0;
- prefetch_limitu = 0;
- memory_base = 0;
- memory_limit = 0;
- prefetch_base = 0;
- prefetch_limit = 0;
- iobaseu = 0;
- iolimitu = 0;
- iobase = 0;
- iolimit = 0;
-}
-
-void pci_bridge_device::map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space)
-{
- for(int i = int(all_devices.size())-1; i>=0; i--)
- if(all_devices[i] != this)
- all_devices[i]->map_device(memory_window_start, memory_window_end, memory_offset, memory_space,
- io_window_start, io_window_end, io_offset, io_space);
-
- map_extra(memory_window_start, memory_window_end, memory_offset, memory_space,
- io_window_start, io_window_end, io_offset, io_space);
-}
-
-
-void pci_bridge_device::regenerate_config_mapping()
-{
- address_space *config_space = &space(AS_PROGRAM);
- config_space->unmap_readwrite(0x00000, 0xfffff);
- for(int i=0; i<32*8; i++)
- if(sub_devices[i])
- sub_devices[i]->map_config(i, config_space);
-}
-
-UINT32 pci_bridge_device::do_config_read(UINT8 bus, UINT8 device, UINT16 reg, UINT32 mem_mask)
-{
- if(sub_devices[device]) {
- UINT32 data = space(AS_PROGRAM).read_dword((device << 12) | reg, mem_mask);
- logerror("%s: config_read %02x:%02x.%x:%02x %08x @ %08x\n", tag(), bus, device >> 3, device & 7, reg, data, mem_mask);
- return data;
- } else
- return 0xffffffff;
-}
-
-UINT32 pci_bridge_device::propagate_config_read(UINT8 bus, UINT8 device, UINT16 reg, UINT32 mem_mask)
-{
- UINT32 data = 0xffffffff;
- for(unsigned int i=0; i != all_bridges.size(); i++)
- data &= all_bridges[i]->config_read(bus, device, reg, mem_mask);
- return data;
-}
-
-UINT32 pci_bridge_device::config_read(UINT8 bus, UINT8 device, UINT16 reg, UINT32 mem_mask)
-{
- if(bus == secondary_bus)
- return do_config_read(bus, device, reg, mem_mask);
-
- if(bus > secondary_bus && bus <= subordinate_bus)
- return propagate_config_read(bus, device, reg, mem_mask);
-
- return 0xffffffff;
-}
-
-void pci_bridge_device::do_config_write(UINT8 bus, UINT8 device, UINT16 reg, UINT32 data, UINT32 mem_mask)
-{
- if(sub_devices[device]) {
- space(AS_PROGRAM).write_dword((device << 12) | reg, data, mem_mask);
- logerror("%s: config_write %02x:%02x.%x:%02x %08x @ %08x\n", tag(), bus, device >> 3, device & 7, reg, data, mem_mask);
- }
-}
-
-void pci_bridge_device::propagate_config_write(UINT8 bus, UINT8 device, UINT16 reg, UINT32 data, UINT32 mem_mask)
-{
- for(unsigned int i=0; i != all_bridges.size(); i++)
- all_bridges[i]->config_write(bus, device, reg, data, mem_mask);
-}
-
-void pci_bridge_device::config_write(UINT8 bus, UINT8 device, UINT16 reg, UINT32 data, UINT32 mem_mask)
-{
- if(bus == secondary_bus)
- do_config_write(bus, device, reg, data, mem_mask);
-
- else if(bus > secondary_bus && bus <= subordinate_bus)
- propagate_config_write(bus, device, reg, data, mem_mask);
-}
-
-READ32_MEMBER (pci_bridge_device::b_address_base_r)
-{
- logerror("%s: b_address_base_r %d\n", tag(), offset);
- return 0xffffffff;
-}
-
-WRITE32_MEMBER(pci_bridge_device::b_address_base_w)
-{
- logerror("%s: b_address_base_w %d, %08x\n", tag(), offset, data);
-}
-
-READ8_MEMBER (pci_bridge_device::primary_bus_r)
-{
- logerror("%s: primary_bus_r\n", tag());
- return primary_bus;
-}
-
-WRITE8_MEMBER (pci_bridge_device::primary_bus_w)
-{
- primary_bus = data;
- logerror("%s: primary_bus_w %02x\n", tag(), data);
-}
-
-READ8_MEMBER (pci_bridge_device::secondary_bus_r)
-{
- logerror("%s: secondary_bus_r\n", tag());
- return secondary_bus;
-}
-
-WRITE8_MEMBER (pci_bridge_device::secondary_bus_w)
-{
- secondary_bus = data;
- logerror("%s: secondary_bus_w %02x\n", tag(), data);
-}
-
-READ8_MEMBER (pci_bridge_device::subordinate_bus_r)
-{
- logerror("%s: subordinate_bus_r\n", tag());
- return subordinate_bus;
-}
-
-WRITE8_MEMBER (pci_bridge_device::subordinate_bus_w)
-{
- subordinate_bus = data;
- logerror("%s: subordinate_bus_w %02x\n", tag(), data);
-}
-
-READ8_MEMBER (pci_bridge_device::secondary_latency_r)
-{
- logerror("%s: secondary_latency_r\n", tag());
- return 0xff;
-}
-
-WRITE8_MEMBER (pci_bridge_device::secondary_latency_w)
-{
- logerror("%s: secondary_latency_w %02x\n", tag(), data);
-}
-
-READ8_MEMBER (pci_bridge_device::iobase_r)
-{
- return iobase;
-}
-
-WRITE8_MEMBER (pci_bridge_device::iobase_w)
-{
- iobase = data;
- logerror("%s: iobase_w %02x\n", tag(), data);
-}
-
-READ8_MEMBER (pci_bridge_device::iolimit_r)
-{
- return iolimit;
-}
-
-WRITE8_MEMBER (pci_bridge_device::iolimit_w)
-{
- iolimit = data;
- logerror("%s: iolimit_w %02x\n", tag(), data);
-}
-
-READ16_MEMBER (pci_bridge_device::secondary_status_r)
-{
- logerror("%s: secondary_status_r\n", tag());
- return 0xffff;
-}
-
-WRITE16_MEMBER(pci_bridge_device::secondary_status_w)
-{
- logerror("%s: secondary_status_w %04x\n", tag(), data);
-}
-
-READ16_MEMBER (pci_bridge_device::memory_base_r)
-{
- return memory_base;
-}
-
-WRITE16_MEMBER(pci_bridge_device::memory_base_w)
-{
- COMBINE_DATA(&memory_base);
- logerror("%s: memory_base_w %04x\n", tag(), memory_base);
-}
-
-READ16_MEMBER (pci_bridge_device::memory_limit_r)
-{
- return memory_limit;
-}
-
-WRITE16_MEMBER(pci_bridge_device::memory_limit_w)
-{
- COMBINE_DATA(&memory_limit);
- logerror("%s: memory_limit_w %04x\n", tag(), memory_limit);
-}
-
-READ16_MEMBER (pci_bridge_device::prefetch_base_r)
-{
- return prefetch_base;
-}
-
-WRITE16_MEMBER(pci_bridge_device::prefetch_base_w)
-{
- COMBINE_DATA(&prefetch_base);
- logerror("%s: prefetch_base_w %04x\n", tag(), prefetch_base);
-}
-
-READ16_MEMBER (pci_bridge_device::prefetch_limit_r)
-{
- return prefetch_limit;
-}
-
-WRITE16_MEMBER(pci_bridge_device::prefetch_limit_w)
-{
- COMBINE_DATA(&prefetch_limit);
- logerror("%s: prefetch_limit_w %04x\n", tag(), prefetch_limit);
-}
-
-READ32_MEMBER (pci_bridge_device::prefetch_baseu_r)
-{
- return prefetch_baseu;
-}
-
-WRITE32_MEMBER(pci_bridge_device::prefetch_baseu_w)
-{
- COMBINE_DATA(&prefetch_baseu);
- logerror("%s: prefetch_baseu_w %08x\n", tag(), prefetch_baseu);
-}
-
-READ32_MEMBER (pci_bridge_device::prefetch_limitu_r)
-{
- return prefetch_limitu;
-}
-
-WRITE32_MEMBER(pci_bridge_device::prefetch_limitu_w)
-{
- COMBINE_DATA(&prefetch_limitu);
- logerror("%s: prefetch_limitu_w %08x\n", tag(), prefetch_limitu);
-}
-
-READ16_MEMBER (pci_bridge_device::iobaseu_r)
-{
- return iobaseu;
-}
-
-WRITE16_MEMBER(pci_bridge_device::iobaseu_w)
-{
- COMBINE_DATA(&iobaseu);
- logerror("%s: iobaseu_w %04x\n", tag(), iobaseu);
-}
-
-READ16_MEMBER (pci_bridge_device::iolimitu_r)
-{
- return iolimitu;
-}
-
-WRITE16_MEMBER(pci_bridge_device::iolimitu_w)
-{
- COMBINE_DATA(&iolimitu);
- logerror("%s: iolimitu_w %04x\n", tag(), iolimitu);
-}
-
-READ8_MEMBER (pci_bridge_device::interrupt_line_r)
-{
- logerror("%s: interrupt_line_r\n", tag());
- return 0xff;
-}
-
-WRITE8_MEMBER (pci_bridge_device::interrupt_line_w)
-{
- logerror("%s: interrupt_line_w %02x\n", tag(), data);
-}
-
-READ8_MEMBER (pci_bridge_device::interrupt_pin_r)
-{
- logerror("%s: interrupt_pin_r\n", tag());
- return 0xff;
-}
-
-WRITE8_MEMBER (pci_bridge_device::interrupt_pin_w)
-{
- logerror("%s: interrupt_pin_w %02x\n", tag(), data);
-}
-
-READ16_MEMBER (pci_bridge_device::bridge_control_r)
-{
- return bridge_control;
-}
-
-WRITE16_MEMBER(pci_bridge_device::bridge_control_w)
-{
- COMBINE_DATA(&bridge_control);
- logerror("%s: bridge_control_w %04x\n", tag(), bridge_control);
-}
-
-
-agp_bridge_device::agp_bridge_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : pci_bridge_device(mconfig, type, name, tag, owner, clock, shortname, source)
-{
-}
-
-void agp_bridge_device::device_start()
-{
- pci_bridge_device::device_start();
-}
-
-void agp_bridge_device::device_reset()
-{
- pci_bridge_device::device_reset();
-}
-
-
-
-DEVICE_ADDRESS_MAP_START(io_configuration_access_map, 32, pci_host_device)
- AM_RANGE(0xcf8, 0xcfb) AM_READWRITE(config_address_r, config_address_w)
- AM_RANGE(0xcfc, 0xcff) AM_READWRITE(config_data_r, config_data_w)
-ADDRESS_MAP_END
-
-
-pci_host_device::pci_host_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : pci_bridge_device(mconfig, type, name, tag, owner, clock, shortname, source)
-{
-}
-
-device_t *pci_host_device::bus_root()
-{
- return owner();
-}
-
-void pci_host_device::device_start()
-{
- remap_cb = mapper_cb(FUNC(pci_host_device::regenerate_mapping), this);
-
- pci_bridge_device::device_start();
-
- memory_window_start = memory_window_end = memory_offset = 0;
- io_window_start = io_window_end = io_offset = 0;
-
- reset_all_mappings();
-}
-
-void pci_host_device::device_reset()
-{
- pci_bridge_device::device_reset();
- reset_all_mappings();
- regenerate_mapping();
-
- config_address = 0;
-}
-
-void pci_host_device::regenerate_mapping()
-{
- logerror("Regenerating mapping\n");
- memory_space->unmap_readwrite(memory_window_start, memory_window_end);
- io_space->unmap_readwrite(io_window_start, io_window_end);
-
- map_device(memory_window_start, memory_window_end, memory_offset, memory_space,
- io_window_start, io_window_end, io_offset, io_space);
-}
-
-READ32_MEMBER(pci_host_device::config_address_r)
-{
- return config_address;
-}
-
-WRITE32_MEMBER(pci_host_device::config_address_w)
-{
- COMBINE_DATA(&config_address);
-}
-
-READ32_MEMBER(pci_host_device::config_data_r)
-{
- return config_address & 0x80000000 ? root_config_read((config_address >> 16) & 0xff, (config_address >> 8) & 0xff, config_address & 0xfc, mem_mask) : 0xffffffff;
-}
-
-WRITE32_MEMBER(pci_host_device::config_data_w)
-{
- if(config_address & 0x80000000)
- root_config_write((config_address >> 16) & 0xff, (config_address >> 8) & 0xff, config_address & 0xfc, data, mem_mask);
-}
-
-UINT32 pci_host_device::root_config_read(UINT8 bus, UINT8 device, UINT16 reg, UINT32 mem_mask)
-{
- if(bus == 0x00)
- return do_config_read(bus, device, reg, mem_mask);
-
- return propagate_config_read(bus, device, reg, mem_mask);
-}
-
-void pci_host_device::root_config_write(UINT8 bus, UINT8 device, UINT16 reg, UINT32 data, UINT32 mem_mask)
-{
- if(bus == 0x00)
- do_config_write(bus, device, reg, data, mem_mask);
-
- else
- propagate_config_write(bus, device, reg, data, mem_mask);
-}
-
-
-pci_root_device::pci_root_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, PCI_ROOT,"PCI virtual root", tag, owner, clock, "pci_root", __FILE__)
-{
-}
-
-void pci_root_device::device_start()
-{
-}
-
-void pci_root_device::device_reset()
-{
-}
-
-#if (defined(__MINGW32__) && (__GNUC__ >= 5))
-#pragma GCC diagnostic pop
-#endif
diff --git a/src/emu/machine/pci.h b/src/emu/machine/pci.h
deleted file mode 100644
index 34566f5f1e6..00000000000
--- a/src/emu/machine/pci.h
+++ /dev/null
@@ -1,282 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef PCI_H
-#define PCI_H
-
-#include "emu.h"
-
-#define MCFG_PCI_ROOT_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, PCI_ROOT, 0)
-
-#define MCFG_PCI_DEVICE_ADD(_tag, _type, _main_id, _revision, _pclass, _subsystem_id) \
- MCFG_DEVICE_ADD(_tag, _type, 0) \
- downcast<pci_device *>(device)->set_ids(_main_id, _revision, _pclass, _subsystem_id);
-
-#define MCFG_AGP_DEVICE_ADD(_tag, _type, _main_id, _revision, _subsystem_id) \
- MCFG_PCI_DEVICE_ADD(_tag, _type, _main_id, _revision, 0x030000, _subsystem_id)
-
-#define MCFG_PCI_HOST_ADD(_tag, _type, _main_id, _revision, _subsystem_id) \
- MCFG_PCI_DEVICE_ADD(_tag, _type, _main_id, _revision, 0x060000, _subsystem_id)
-
-#define MCFG_PCI_BRIDGE_ADD(_tag, _main_id, _revision) \
- MCFG_PCI_DEVICE_ADD(_tag, PCI_BRIDGE, _main_id, _revision, 0x060400, 0x00000000)
-
-#define MCFG_AGP_BRIDGE_ADD(_tag, _type, _main_id, _revision) \
- MCFG_PCI_DEVICE_ADD(_tag, _type, _main_id, _revision, 0x060400, 0x00000000)
-
-class pci_device : public device_t {
-public:
- typedef delegate<void ()> mapper_cb;
-
- mapper_cb remap_cb, remap_config_cb;
-
- pci_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- void set_ids(UINT32 main_id, UINT8 revision, UINT32 pclass, UINT32 subsystem_id);
- void set_multifunction_device(bool enable);
-
- virtual void set_remap_cb(mapper_cb _remap_cb);
- virtual void reset_all_mappings();
- virtual void map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space);
- virtual void map_extra(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space);
-
- void map_config(UINT8 device, address_space *config_space);
-
- virtual DECLARE_ADDRESS_MAP(config_map, 32);
-
- UINT32 unmapped_r(offs_t offset, UINT32 mem_mask, int bank);
- void unmapped_w(offs_t offset, UINT32 data, UINT32 mem_mask, int bank);
-
- READ32_MEMBER (unmapped0_r);
- WRITE32_MEMBER(unmapped0_w);
- READ32_MEMBER (unmapped1_r);
- WRITE32_MEMBER(unmapped1_w);
- READ32_MEMBER (unmapped2_r);
- WRITE32_MEMBER(unmapped2_w);
- READ32_MEMBER (unmapped3_r);
- WRITE32_MEMBER(unmapped3_w);
- READ32_MEMBER (unmapped4_r);
- WRITE32_MEMBER(unmapped4_w);
- READ32_MEMBER (unmapped5_r);
- WRITE32_MEMBER(unmapped5_w);
-
-
- DECLARE_READ16_MEMBER(vendor_r);
- DECLARE_READ16_MEMBER(device_r);
- DECLARE_READ16_MEMBER(command_r);
- DECLARE_WRITE16_MEMBER(command_w);
- DECLARE_READ16_MEMBER(status_r);
- DECLARE_READ32_MEMBER(class_rev_r);
- virtual DECLARE_READ8_MEMBER(cache_line_size_r);
- virtual DECLARE_READ8_MEMBER(latency_timer_r);
- virtual DECLARE_READ8_MEMBER(header_type_r);
- virtual DECLARE_READ8_MEMBER(bist_r);
- DECLARE_READ32_MEMBER(address_base_r);
- DECLARE_WRITE32_MEMBER(address_base_w);
- DECLARE_READ16_MEMBER(subvendor_r);
- DECLARE_READ16_MEMBER(subsystem_r);
- DECLARE_READ32_MEMBER (expansion_base_r);
- DECLARE_WRITE32_MEMBER(expansion_base_w);
- virtual DECLARE_READ8_MEMBER(capptr_r);
-
-protected:
- enum {
- M_MEM = 0,
- M_IO = 1,
- M_64D = 2,
- M_64A = 4,
- M_PREF = 8,
- M_DISABLED = 16
- };
-
- struct bank_info {
- // One of the two
- address_map_delegate map;
-
- UINT64 adr;
- UINT32 size;
- int flags;
- };
-
- struct bank_reg_info {
- int bank, hi;
- };
-
- bank_info bank_infos[6];
- int bank_count, bank_reg_count;
- bank_reg_info bank_reg_infos[6];
-
- UINT32 main_id, subsystem_id;
- UINT32 pclass;
- UINT8 revision;
- UINT16 command, command_mask, status;
- const UINT8 *expansion_rom;
- UINT32 expansion_rom_size;
- UINT32 expansion_rom_base;
- bool is_multifunction_device;
-
- virtual void device_start();
- virtual void device_reset();
-
- void skip_map_regs(int count);
- void add_map(UINT64 size, int flags, address_map_delegate &map);
- template <typename T> void add_map(UINT64 size, int flags, void (T::*map)(address_map &map, device_t &device), const char *name) {
- address_map_delegate delegate(map, name, static_cast<T *>(this));
- add_map(size, flags, delegate);
- }
-
- void add_rom(const UINT8 *data, UINT32 size);
- void add_rom_from_region();
-
- void set_map_address(int id, UINT64 adr);
- void set_map_size(int id, UINT64 size);
- void set_map_flags(int id, int flags);
-
-private:
- void add_map_finish(int bid, UINT64 size, int flags);
-
-};
-
-class agp_device : public pci_device {
-public:
- agp_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-};
-
-class pci_bridge_device : public pci_device, public device_memory_interface {
-public:
- pci_bridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- pci_bridge_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- virtual void set_remap_cb(mapper_cb _remap_cb);
- virtual void map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space);
- virtual void reset_all_mappings();
-
- virtual DECLARE_READ8_MEMBER(header_type_r);
-
- virtual DECLARE_ADDRESS_MAP(config_map, 32);
-
- DECLARE_READ32_MEMBER (b_address_base_r);
- DECLARE_WRITE32_MEMBER(b_address_base_w);
- DECLARE_READ8_MEMBER (primary_bus_r);
- DECLARE_WRITE8_MEMBER (primary_bus_w);
- DECLARE_READ8_MEMBER (secondary_bus_r);
- DECLARE_WRITE8_MEMBER (secondary_bus_w);
- DECLARE_READ8_MEMBER (subordinate_bus_r);
- DECLARE_WRITE8_MEMBER (subordinate_bus_w);
- DECLARE_READ8_MEMBER (secondary_latency_r);
- DECLARE_WRITE8_MEMBER (secondary_latency_w);
- DECLARE_READ8_MEMBER (iobase_r);
- DECLARE_WRITE8_MEMBER (iobase_w);
- DECLARE_READ8_MEMBER (iolimit_r);
- DECLARE_WRITE8_MEMBER (iolimit_w);
- DECLARE_READ16_MEMBER (secondary_status_r);
- DECLARE_WRITE16_MEMBER(secondary_status_w);
- DECLARE_READ16_MEMBER (memory_base_r);
- DECLARE_WRITE16_MEMBER(memory_base_w);
- DECLARE_READ16_MEMBER (memory_limit_r);
- DECLARE_WRITE16_MEMBER(memory_limit_w);
- DECLARE_READ16_MEMBER (prefetch_base_r);
- DECLARE_WRITE16_MEMBER(prefetch_base_w);
- DECLARE_READ16_MEMBER (prefetch_limit_r);
- DECLARE_WRITE16_MEMBER(prefetch_limit_w);
- DECLARE_READ32_MEMBER (prefetch_baseu_r);
- DECLARE_WRITE32_MEMBER(prefetch_baseu_w);
- DECLARE_READ32_MEMBER (prefetch_limitu_r);
- DECLARE_WRITE32_MEMBER(prefetch_limitu_w);
- DECLARE_READ16_MEMBER (iobaseu_r);
- DECLARE_WRITE16_MEMBER(iobaseu_w);
- DECLARE_READ16_MEMBER (iolimitu_r);
- DECLARE_WRITE16_MEMBER(iolimitu_w);
- DECLARE_READ8_MEMBER (interrupt_line_r);
- DECLARE_WRITE8_MEMBER (interrupt_line_w);
- DECLARE_READ8_MEMBER (interrupt_pin_r);
- DECLARE_WRITE8_MEMBER (interrupt_pin_w);
- DECLARE_READ16_MEMBER (bridge_control_r);
- DECLARE_WRITE16_MEMBER(bridge_control_w);
-
-protected:
- pci_device *sub_devices[32*8];
- std::vector<pci_device *> all_devices;
- std::vector<pci_bridge_device *> all_bridges;
-
- UINT32 prefetch_baseu, prefetch_limitu;
- UINT16 bridge_control, memory_base, memory_limit, prefetch_base, prefetch_limit, iobaseu, iolimitu;
- UINT8 primary_bus, secondary_bus, subordinate_bus, iobase, iolimit;
-
- virtual void device_start();
- virtual void device_reset();
- virtual const address_space_config *memory_space_config(address_spacenum spacenum) const;
-
- virtual device_t *bus_root();
- virtual void regenerate_config_mapping();
-
- UINT32 do_config_read(UINT8 bus, UINT8 device, UINT16 reg, UINT32 mem_mask);
- UINT32 propagate_config_read(UINT8 bus, UINT8 device, UINT16 reg, UINT32 mem_mask);
- UINT32 config_read(UINT8 bus, UINT8 device, UINT16 reg, UINT32 mem_mask);
- void do_config_write(UINT8 bus, UINT8 device, UINT16 reg, UINT32 data, UINT32 mem_mask);
- void propagate_config_write(UINT8 bus, UINT8 device, UINT16 reg, UINT32 data, UINT32 mem_mask);
- void config_write(UINT8 bus, UINT8 device, UINT16 reg, UINT32 data, UINT32 mem_mask);
-
-private:
- address_space_config configure_space_config;
-};
-
-class agp_bridge_device : public pci_bridge_device {
-public:
- agp_bridge_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-};
-
-class pci_host_device : public pci_bridge_device {
-public:
- DECLARE_ADDRESS_MAP(io_configuration_access_map, 32);
-
- pci_host_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
-protected:
- address_space *memory_space, *io_space;
-
- UINT64 memory_window_start, memory_window_end, memory_offset;
- UINT64 io_window_start, io_window_end, io_offset;
-
- virtual void device_start();
- virtual void device_reset();
-
- virtual device_t *bus_root();
-
- UINT32 config_address;
-
- DECLARE_READ32_MEMBER(config_address_r);
- DECLARE_WRITE32_MEMBER(config_address_w);
- DECLARE_READ32_MEMBER(config_data_r);
- DECLARE_WRITE32_MEMBER(config_data_w);
-
- UINT32 root_config_read(UINT8 bus, UINT8 device, UINT16 reg, UINT32 mem_mask);
- void root_config_write(UINT8 bus, UINT8 device, UINT16 reg, UINT32 data, UINT32 mem_mask);
-
- void regenerate_mapping();
-};
-
-class pci_root_device : public device_t {
-public:
- pci_root_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
-};
-
-extern const device_type PCI_ROOT;
-extern const device_type PCI_BRIDGE;
-
-#endif
diff --git a/src/emu/machine/pci9050.c b/src/emu/machine/pci9050.c
deleted file mode 100644
index 2687966c718..00000000000
--- a/src/emu/machine/pci9050.c
+++ /dev/null
@@ -1,254 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*********************************************************************
-
- pci9050.c - PLX PCI9050 PCI to 4x Local Bus Bridge
-
- by R. Belmont
-
- PCI spaces:
- 0 - (config memory) not used
- 1 - (config I/O) config regs
- 2 - local bus 1 window
- 3 - local bus 2 window
- 4 - local bus 3 window
- 5 - local bus 4 window
-
- PCI9050 is located, mapped, and initialized at BFC00700.
-
- The boot ROM then copies ROM to RAM, jumps to RAM, and starts trying to
- access Zeus 2 video through the mapped windows.
-
-*********************************************************************/
-
-#include "pci9050.h"
-
-const device_type PCI9050 = &device_creator<pci9050_device>;
-
-DEVICE_ADDRESS_MAP_START(map, 32, pci9050_device)
- AM_RANGE(0x00, 0x0f) AM_READWRITE(lasrr_r, lasrr_w )
- AM_RANGE(0x10, 0x13) AM_READWRITE(eromrr_r, eromrr_w )
- AM_RANGE(0x14, 0x23) AM_READWRITE(lasba_r, lasba_w )
- AM_RANGE(0x24, 0x27) AM_READWRITE(eromba_r, eromba_w )
- AM_RANGE(0x28, 0x37) AM_READWRITE(lasbrd_r, lasbrd_w )
- AM_RANGE(0x38, 0x3b) AM_READWRITE(erombrd_r, erombrd_w)
- AM_RANGE(0x3c, 0x4b) AM_READWRITE(csbase_r, csbase_w )
- AM_RANGE(0x4c, 0x4f) AM_READWRITE(intcsr_r, intcsr_w )
- AM_RANGE(0x50, 0x53) AM_READWRITE(cntrl_r, cntrl_w )
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(empty, 32, pci9050_device)
-ADDRESS_MAP_END
-
-pci9050_device::pci9050_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_device(mconfig, PCI9050, "PLX PCI9050 PCI to Local Bus Bridge", tag, owner, clock, "pci9050", __FILE__)
-{
- for(int i=0; i<4; i++) {
- m_devices[i] = NULL;
- m_names[i] = NULL;
- }
-}
-
-void pci9050_device::set_map(int id, address_map_constructor map, const char *name, device_t *device)
-{
- m_maps[id] = map;
- m_names[id] = name;
- m_devices[id] = device;
-}
-
-void pci9050_device::device_start()
-{
- typedef void (pci9050_device::*tramp_t)(address_map &, device_t &);
- static const tramp_t trampolines[4] = {
- &pci9050_device::map_trampoline<0>,
- &pci9050_device::map_trampoline<1>,
- &pci9050_device::map_trampoline<2>,
- &pci9050_device::map_trampoline<3>
- };
-
- pci_device::device_start();
-
- add_map(0x100, M_MEM, FUNC(pci9050_device::map)); // map 0 is our config registers, mem space
- add_map(0x100, M_IO, FUNC(pci9050_device::map)); // map 1 is our config registers, i/o space
-
- for(int i=0; i<4; i++)
- if(m_names[i])
- // add_map(0, M_MEM | M_DISABLED, m_maps[i], m_names[i], m_devices[i]);
- add_map(0, M_MEM | M_DISABLED, trampolines[i], m_names[i]);
- else
- add_map(0, M_MEM | M_DISABLED, FUNC(pci9050_device::empty));
-}
-
-void pci9050_device::device_config_complete()
-{
-}
-
-void pci9050_device::device_reset()
-{
- pci_device::device_reset();
- set_map_address(0, 0);
- set_map_address(1, 0);
- for(int i=0; i<4; i++) {
- m_lasrr[i] = i ? 0 : 0x0ff00000;
- m_lasba[i] = 0;
- m_lasbrd[i] = 0x00800000;
- m_csbase[i] = 0;
- set_map_flags(i+2, M_MEM | M_DISABLED);
- }
- m_eromrr = 0x07ff8000;
- m_eromba = 0x00080000;
- m_erombrd = 0x00800000;
- m_intcsr = 0;
- m_cntrl = 0;
-}
-
-void pci9050_device::remap_local(int id)
-{
- UINT32 csbase = m_csbase[id];
- UINT32 lasrr = m_lasrr[id];
- logerror("%d csbase=%08x lasrr=%08x\n", id, csbase, lasrr);
-
- if(!(csbase & 1)) {
- set_map_flags(id+2, M_MEM | M_DISABLED);
- return;
- }
- int lsize;
- for(lsize=1; lsize<28 && !(csbase & (1<<lsize)); lsize++);
- if(lsize == 28) {
- set_map_flags(id+2, M_MEM | M_DISABLED);
- return;
- }
- int size = 2 << lsize;
- if(csbase & 0x0fffffff & ~(size-1)) {
- logerror("PCI9050 local bus %d disabled due to unimplemented post-decode remapping\n", id);
- // set_map_flags(id+2, M_MEM | M_DISABLED);
- // return;
- }
-
- UINT32 mask = ~(size - 1);
- if(lasrr & 1)
- mask &= 0x0ffffffc;
- else
- mask &= 0x0ffffff0;
-
- if((lasrr & mask) != mask) {
- logerror("PCI9050 local bus %d disabled due to unimplemented pci mirroring\n", id);
- // set_map_flags(id+2, M_MEM | M_DISABLED);
- // return;
- }
-
- set_map_size(id+2, size);
- set_map_flags(id+2, lasrr & 1 ? M_IO : lasrr & 8 ? M_MEM | M_PREF : M_MEM);
-}
-
-void pci9050_device::remap_rom()
-{
-}
-
-READ32_MEMBER (pci9050_device::lasrr_r)
-{
- return m_lasrr[offset];
-}
-
-WRITE32_MEMBER(pci9050_device::lasrr_w)
-{
- logerror("%06X:PCI9050 local bus %d range %08x: %s flags %d pf %d addr bits 27-4 %08x\n", space.device().safe_pc(), offset, data, (data & 1) ? "I/O" : "MEM", (data & 6)>>1, (data & 8)>>3, data & 0xfffffff);
- m_lasrr[offset] = data;
- remap_local(offset);
-}
-
-READ32_MEMBER (pci9050_device::eromrr_r)
-{
- return m_eromrr;
-}
-
-WRITE32_MEMBER(pci9050_device::eromrr_w)
-{
- logerror("%06X:PCI9050 ROM range %08x: addr bits 27-11 %08x\n", space.device().safe_pc(), data, data & 0xfffff800);
- m_eromrr = data;
- remap_rom();
-}
-
-READ32_MEMBER (pci9050_device::lasba_r)
-{
- return m_lasba[offset];
-}
-
-WRITE32_MEMBER(pci9050_device::lasba_w)
-{
- logerror("%06X:PCI9050 local bus %d base %08x: enable %d remap %08x\n", space.device().safe_pc(), offset, data, data&1, data & 0x0ffffffe);
- m_lasba[offset] = data;
- remap_local(offset);
-}
-
-READ32_MEMBER (pci9050_device::eromba_r)
-{
- return m_eromba;
-}
-
-WRITE32_MEMBER(pci9050_device::eromba_w)
-{
- logerror("%06X:PCI9050 ROM base %08x: remap %08x\n", space.device().safe_pc(), data, data & 0x0ffff800);
- m_eromba = data;
- remap_rom();
-}
-
-READ32_MEMBER (pci9050_device::lasbrd_r)
-{
- return m_lasbrd[offset];
-}
-
-WRITE32_MEMBER(pci9050_device::lasbrd_w)
-{
- logerror("%06X:PCI9050 local bus %d descriptors %08x: burst %d prefetch %d width %d, endian %s, endian mode %d\n", space.device().safe_pc(), offset, data, data&1, (data >> 5) & 1, (data >> 22) & 3, ((data >> 24) & 1) ? "BE" : "LE", (data >> 25) & 1);
- m_lasbrd[offset] = data;
- remap_local(offset);
-}
-
-READ32_MEMBER (pci9050_device::erombrd_r)
-{
- return m_erombrd;
-}
-
-WRITE32_MEMBER(pci9050_device::erombrd_w)
-{
- logerror("%06X:PCI9050 ROM descriptors %08x: burst %d prefetch %d bits %d, endian %s, endian mode %d\n", space.device().safe_pc(), data, data&1, (data >> 5) & 1, (data >> 22) & 3, ((data >> 24) & 1) ? "BE" : "LE", (data >> 25) & 1);
- m_erombrd = data;
- remap_rom();
-}
-
-READ32_MEMBER (pci9050_device::csbase_r)
-{
- return m_csbase[offset];
-}
-
-WRITE32_MEMBER(pci9050_device::csbase_w)
-{
- logerror("%06X:PCI9050 chip select %d base %08x: enable %d size %08x\n", space.device().safe_pc(), offset, data, data&1, data&0xfffffffe);
- m_csbase[offset] = data;
- remap_local(offset);
-}
-
-READ32_MEMBER (pci9050_device::intcsr_r)
-{
- return m_intcsr;
-}
-
-WRITE32_MEMBER(pci9050_device::intcsr_w)
-{
- logerror("%06X:PCI9050 IRQ control %08x\n", space.device().safe_pc(), data);
- m_intcsr = data;
- remap_rom();
-}
-
-READ32_MEMBER (pci9050_device::cntrl_r)
-{
- return m_cntrl;
-}
-
-WRITE32_MEMBER(pci9050_device::cntrl_w)
-{
- logerror("%06X:PCI9050 IRQ control %08x\n", space.device().safe_pc(), data);
- m_cntrl = data;
- remap_rom();
-}
diff --git a/src/emu/machine/pci9050.h b/src/emu/machine/pci9050.h
deleted file mode 100644
index 7915e46b9ea..00000000000
--- a/src/emu/machine/pci9050.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*********************************************************************
-
- pci9050.h - PLX PCI9050 PCI to 4x Local Bus Bridge
-
- by R. Belmont
-
-*********************************************************************/
-
-#ifndef _PCI9050_H
-#define _PCI9050_H
-
-#include "machine/pci.h"
-
-#define MCFG_PCI9050_ADD(_tag) \
- MCFG_PCI_DEVICE_ADD(_tag, PCI9050, 0x10b59050, 0x01, 0x06800000, 0x10b59050)
-
-#define MCFG_PCI9050_SET_MAP(id, map) \
- downcast<pci9050_device *>(device)->set_map(id, ADDRESS_MAP_NAME(map), #map, owner);
-
-class pci9050_device :
- public pci_device
-{
-public:
- pci9050_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // PCI9050 I/O register space handlers
- DECLARE_READ32_MEMBER( lasrr_r );
- DECLARE_WRITE32_MEMBER(lasrr_w );
- DECLARE_READ32_MEMBER( eromrr_r );
- DECLARE_WRITE32_MEMBER(eromrr_w );
- DECLARE_READ32_MEMBER( lasba_r );
- DECLARE_WRITE32_MEMBER(lasba_w );
- DECLARE_READ32_MEMBER( eromba_r );
- DECLARE_WRITE32_MEMBER(eromba_w );
- DECLARE_READ32_MEMBER( lasbrd_r );
- DECLARE_WRITE32_MEMBER(lasbrd_w );
- DECLARE_READ32_MEMBER( erombrd_r);
- DECLARE_WRITE32_MEMBER(erombrd_w);
- DECLARE_READ32_MEMBER( csbase_r );
- DECLARE_WRITE32_MEMBER(csbase_w );
- DECLARE_READ32_MEMBER( intcsr_r );
- DECLARE_WRITE32_MEMBER(intcsr_w );
- DECLARE_READ32_MEMBER( cntrl_r );
- DECLARE_WRITE32_MEMBER(cntrl_w );
-
- void set_map(int id, address_map_constructor map, const char *name, device_t *device);
-
-protected:
- virtual void device_start();
- virtual void device_config_complete();
- virtual void device_reset();
-
-private:
- DECLARE_ADDRESS_MAP(map, 32);
- DECLARE_ADDRESS_MAP(empty, 32);
-
- const char *m_names[4];
- device_t *m_devices[4];
- address_map_constructor m_maps[4];
-
- UINT32 m_lasrr[4], m_lasba[4], m_lasbrd[4], m_csbase[4];
- UINT32 m_eromrr, m_eromba, m_erombrd, m_intcsr, m_cntrl;
-
- void remap_local(int id);
- void remap_rom();
-
- template<int id> void map_trampoline(address_map &map, device_t &device) {
- m_maps[id](map, *m_devices[id]);
- }
-};
-
-extern const device_type PCI9050;
-
-#endif
diff --git a/src/emu/machine/pckeybrd.c b/src/emu/machine/pckeybrd.c
deleted file mode 100644
index f7a049e2469..00000000000
--- a/src/emu/machine/pckeybrd.c
+++ /dev/null
@@ -1,1305 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Peter Trauner, Kevin Thacker
-/**********************************************************************
-
- pckeybrd.c
-
- PC-style keyboard emulation
-
- This emulation is decoupled from the AT 8042 emulation used in the
- IBM ATs and above
-
-**********************************************************************/
-
-/* Todo: (added by KT 22-Jun-2000
- 1. Check scancodes I have added are the actual scancodes for set 2 or 3.
- 2. Check how codes are changed based on Shift/Control states for those sets
- that require it - info in Help PC!
-
-*/
-
-#include "emu.h"
-#include "pckeybrd.h"
-
-/* AT keyboard documentation comes from www.beyondlogic.org and HelpPC documentation */
-
-/* to enable logging of keyboard read/writes */
-#define LOG_KEYBOARD 0
-
-
-/*
- The PS/2 models have three make/break scan code sets. The first
- set matches the PC & XT make/break scan code set and is the one
- listed here. Scan code sets are selected by writing the value F0
- to the keyboard via the ~8042~ (port 60h). The following is a brief
- description of the scan code sets (see the PS/2 Technical Reference
- manuals for more information on scan code sets 2 and 3):
-
- * set 1, each key has a base scan code. Some keys generate
- extra scan codes to generate artificial shift states. This
- is similar to the standard scan code set used on the PC and XT.
- * set 2, each key sends one make scan code and two break scan
- codes bytes (F0 followed by the make code). This scan code
- set is available on the IBM AT also.
- * set 3, each key sends one make scan code and two break scan
- codes bytes (F0 followed by the make code) and no keys are
- altered by Shift/Alt/Ctrl keys.
- * typematic scan codes are the same as the make scan code
-
-*/
-
-
-/* using the already existing input port definitions, this table re-maps
-to scancode set 3.
-I don't have the details for scan-code set 2,3 but they sound very similar
-to the scancode set I have here. - KT 22/Jun/2000 */
-
-
-/* key set 3 */
-const int at_keyboard_device::m_scancode_set_2_3[]=
-{
- 0,
- 0x076,
- 0x016,
- 0x01e,
- 0x026,
- 0x025,
- 0x02e,
- 0x036,
- 0x03d,
- 0x03e,
- 0x046,
- 0x045,
- 0x04e,
- 0x055,
- 0x066,
- 0x00d,
- 0x015,
- 0x01d,
- 0x024,
- 0x02d,
- 0x02c,
- 0x035,
- 0x03c,
- 0x043,
- 0x044,
- 0x04d,
- 0x054,
- 0x05b,
- 0x05a,
- 0x014,
- 0x01c,
- 0x01b,
- 0x023,
- 0x02b,
- 0x034,
- 0x033,
- 0x03b,
- 0x042,
- 0x04b,
- 0x04c,
- 0x052,
- 0x00e,
- 0x012,
- 0x05d,
- 0x01a,
- 0x022,
- 0x021,
- 0x02a,
- 0x032,
- 0x031,
- 0x03a,
- 0x041,
- 0x049,
- 0x04a,
- 0x059,
- 0x000,
- 0x011,
- 0x029,
- 0x058,
- 0x05,
- 0x06,
- 0x04,
- 0x0c,
- 0x03,
- 0x0b,
- 0x083,
- 0x0a,
- 0x01,
- 0x09,
- 0x077,
- 0x07e,
- 0x06c,
- 0x075,
- 0x07d,
- 0x07b,
- 0x06b,
- 0x073,
- 0x074,
- 0x079,
- 0x069,
- 0x072,
- 0x07a,
- 0x070,
- 0x071,
- 0x00,
- 0x00,
- 0x078,
- 0x07,
- 0x05a,
- 0x014,
- 0x04a,
- 0x000,
- 0x011,
- 0x06c,
- 0x075,
- 0x07d,
- 0x06b,
- 0x074,
- 0x069,
- 0x072,
- 0x07a,
- 0x070,
- 0x071,
- 0x000,
- 0x000,
- 0x000
-};
-
-
-const at_keyboard_device::extended_keyboard_code at_keyboard_device::m_mf2_code[0x10][2/*numlock off, on*/]={
- { { "\xe0\x1c", "\xe0\x9c" } }, // keypad enter
- { { "\xe0\x1d", "\xe0\x9d" } }, // right control
- { { "\xe0\x35", "\xe0\xb5" } },
- { { "\xe0\x37", "\xe0\xb7" } },
- { { "\xe0\x38", "\xe0\xb8" } },
- { { "\xe0\x47", "\xe0\xc7" }, { "\xe0\x2a\xe0\x47", "\xe0\xc7\xe0\xaa" } },
- { { "\xe0\x48", "\xe0\xc8" }, { "\xe0\x2a\xe0\x48", "\xe0\xc8\xe0\xaa" } },
- { { "\xe0\x49", "\xe0\xc9" }, { "\xe0\x2a\xe0\x49", "\xe0\xc9\xe0\xaa" } },
- { { "\xe0\x4b", "\xe0\xcb" }, { "\xe0\x2a\xe0\x4b", "\xe0\xcb\xe0\xaa" } },
- { { "\xe0\x4d", "\xe0\xcd" }, { "\xe0\x2a\xe0\x4d", "\xe0\xcd\xe0\xaa" } },
- { { "\xe0\x4f", "\xe0\xcf" }, { "\xe0\x2a\xe0\x4f", "\xe0\xcf\xe0\xaa" } },
- { { "\xe0\x50", "\xe0\xd0" }, { "\xe0\x2a\xe0\x50", "\xe0\xd0\xe0\xaa" } },
- { { "\xe0\x51", "\xe0\xd1" }, { "\xe0\x2a\xe0\x51", "\xe0\xd1\xe0\xaa" } },
- { { "\xe0\x52", "\xe0\xd2" }, { "\xe0\x2a\xe0\x52", "\xe0\xd2\xe0\xaa" } },
- { { "\xe0\x53", "\xe0\xd3" }, { "\xe0\x2a\xe0\x53", "\xe0\xd3\xe0\xaa" } },
- { { "\xe1\x1d\x45\xe1\x9d\xc5" }, { "\xe0\x2a\xe1\x1d\x45\xe1\x9d\xc5" } }
-};
-
-/* I don't think these keys change if num-lock is active! */
-/* pc-at extended keyboard make/break codes for code set 3 */
-const at_keyboard_device::extended_keyboard_code at_keyboard_device::m_extended_codes_set_2_3[]=
-{
- /*keypad enter */
- {
- "\xe0\x5a",
- "\xe0\xf0\x5a"
- },
- /* right control */
- {
- "\xe0\x14",
- "\xe0\xf0\x14"
- },
- /* keypad slash */
- {
- "\xe0\x4a",
- "\xe0\xf0\x4a"
- },
- /* print screen */
- {
- "\xe0\x12\xe0\x7c",
- 0, /* I don't know the break sequence */
-
- },
- /* right alt */
- {
- "\xe0\x11",
- "\xe0\xf0\x11"
- },
- /* home */
- {
- "\xe0\x6c",
- "\xe0\xf0\x6c"
- },
- /* cursor up */
- {
- "\xe0\x75",
- "\xe0\xf0\x75"
- },
- /* page up */
- {
- "\xe0\x7d",
- "\xe0\xf0\x7d"
- },
- /* cursor left */
- {
- "\xe0\x6b",
- "\xe0\xf0\x6b",
- },
- /* cursor right */
- {
- "\xe0\x74",
- "\xe0\xf0\x74"
- },
- /* end */
- {
- "\xe0\x69",
- "\xe0\xf0\x69",
- },
- /* cursor down */
- {
- "\xe0\x72",
- "\xe0\xf0\x72"
- },
- /* page down */
- {
- "\xe0\x7a",
- "\xe0\xf0\x7a"
- },
- /* insert */
- {
- "\xe0\x70",
- "\xe0\xf0\x70",
- },
- /* delete */
- {
- "\xe0\x71",
- "\xe0\xf0\x71"
- },
- /* pause */
- {
- "\xe1\x14\x77\xe1\xf0\x14\xf0\x77",
- 0, /*?? I don't know the break sequence */
- }
-
-};
-
-const device_type PC_KEYB = &device_creator<pc_keyboard_device>;
-const device_type AT_KEYB = &device_creator<at_keyboard_device>;
-
-pc_keyboard_device::pc_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, PC_KEYB, "PC Keyboard", tag, owner, clock, "pc_keyb", __FILE__),
- m_type(KEYBOARD_TYPE_PC),
- m_ioport_0(*this, ":pc_keyboard_0"),
- m_ioport_1(*this, ":pc_keyboard_1"),
- m_ioport_2(*this, ":pc_keyboard_2"),
- m_ioport_3(*this, ":pc_keyboard_3"),
- m_ioport_4(*this, ":pc_keyboard_4"),
- m_ioport_5(*this, ":pc_keyboard_5"),
- m_ioport_6(*this, ":pc_keyboard_6"),
- m_ioport_7(*this, ":pc_keyboard_7"),
- m_out_keypress_func(*this)
-{
-}
-
-pc_keyboard_device::pc_keyboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_ioport_0(*this, ":pc_keyboard_0"),
- m_ioport_1(*this, ":pc_keyboard_1"),
- m_ioport_2(*this, ":pc_keyboard_2"),
- m_ioport_3(*this, ":pc_keyboard_3"),
- m_ioport_4(*this, ":pc_keyboard_4"),
- m_ioport_5(*this, ":pc_keyboard_5"),
- m_ioport_6(*this, ":pc_keyboard_6"),
- m_ioport_7(*this, ":pc_keyboard_7"),
- m_out_keypress_func(*this)
-{
-}
-
-at_keyboard_device::at_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- pc_keyboard_device(mconfig, AT_KEYB, "AT Keyboard", tag, owner, clock, "at_keyb", __FILE__),
- m_scan_code_set(1)
-{
- m_type = KEYBOARD_TYPE_AT;
-}
-
-
-void pc_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- polling();
- if(!charqueue_empty())
- m_out_keypress_func(1);
-}
-
-void pc_keyboard_device::device_start()
-{
- save_item(NAME(m_delay));
- save_item(NAME(m_repeat));
- save_item(NAME(m_numlock));
- save_item(NAME(m_on));
- save_item(NAME(m_head));
- save_item(NAME(m_tail));
- save_pointer(NAME(m_queue), ARRAY_LENGTH(m_queue));
- save_pointer(NAME(m_make), ARRAY_LENGTH(m_make));
-
- memset(m_make, 0, sizeof(m_make));
-
- machine().ioport().natkeyboard().configure(
- ioport_queue_chars_delegate(FUNC(pc_keyboard_device::queue_chars), this),
- ioport_accept_char_delegate(FUNC(pc_keyboard_device::accept_char), this),
- ioport_charqueue_empty_delegate(FUNC(pc_keyboard_device::charqueue_empty), this));
-
- m_out_keypress_func.resolve_safe();
- m_keyboard_timer = timer_alloc();
-}
-
-void at_keyboard_device::device_start()
-{
- save_item(NAME(m_scan_code_set));
- save_item(NAME(m_input_state));
- pc_keyboard_device::device_start();
-}
-
-void pc_keyboard_device::device_reset()
-{
- m_delay = 60;
- m_repeat = 8;
- m_numlock = 0;
- m_on = true;
- /* set default led state */
- set_led_status(machine(), 2, 0);
- set_led_status(machine(), 0, 0);
- set_led_status(machine(), 1, 0);
-
- m_head = m_tail = 0;
- queue_insert(0xaa);
- m_keyboard_timer->adjust(attotime::from_msec(5), 0, attotime::from_hz(60));
-}
-
-void at_keyboard_device::device_reset()
-{
- m_input_state = 0;
- pc_keyboard_device::device_reset();
-}
-
-WRITE_LINE_MEMBER(pc_keyboard_device::enable)
-{
- if(state && !m_on)
- {
- if(m_type == KEYBOARD_TYPE_PC)
- reset();
- else
- m_keyboard_timer->adjust(attotime::from_msec(5), 0, attotime::from_hz(60));
- }
- else if(!state)
- m_keyboard_timer->adjust(attotime::never);
-
- m_on = state ? true : false;
-}
-
-/* insert a code into the buffer */
-void pc_keyboard_device::queue_insert(UINT8 data)
-{
- if (LOG_KEYBOARD)
- logerror("keyboard queueing %.2x\n",data);
-
- m_queue[m_head] = data;
- m_head++;
- m_head %= ARRAY_LENGTH(m_queue);
-}
-
-
-int pc_keyboard_device::queue_size(void)
-{
- int queue_size;
- queue_size = m_head - m_tail;
- if (queue_size < 0)
- queue_size += ARRAY_LENGTH(m_queue);
- return queue_size;
-}
-
-void pc_keyboard_device::standard_scancode_insert(int our_code, int pressed)
-{
- if (!pressed)
- {
- /* adjust code for break code */
- our_code|=0x080;
- }
- queue_insert(our_code);
-}
-
-/* add codes for standard keys */
-void at_keyboard_device::standard_scancode_insert(int our_code, int pressed)
-{
- int scancode = our_code;
-
- switch (m_scan_code_set)
- {
- case 1:
- default:
- {
- /* the original code was designed for this set, and there is
- a 1:1 correspondance for the scancodes */
- scancode = our_code;
-
- if (!pressed)
- {
- /* adjust code for break code */
- scancode|=0x080;
- }
- }
- break;
-
- case 2:
- case 3:
- {
- /* lookup scancode */
- scancode = m_scancode_set_2_3[our_code];
-
- if (!pressed)
- {
- /* break code */
- queue_insert(0x0f0);
- }
-
- }
- break;
- }
-
- queue_insert(scancode);
-}
-
-void at_keyboard_device::extended_scancode_insert(int code, int pressed)
-{
- code = code - 0x060;
-
- switch (m_scan_code_set)
- {
- case 1:
- default:
- {
- if (pressed)
- {
- if (m_mf2_code[code][m_numlock].pressed)
- helper(m_mf2_code[code][m_numlock].pressed);
- else
- helper(m_mf2_code[code][0].pressed);
- }
- else
- {
- if (m_mf2_code[code][m_numlock].released)
- helper(m_mf2_code[code][m_numlock].released);
- else if (m_mf2_code[code][0].released)
- helper(m_mf2_code[code][0].released);
- }
- }
- break;
-
- case 2:
- case 3:
- {
- const extended_keyboard_code *key = &m_extended_codes_set_2_3[code];
-
- if (pressed)
- {
- if (key->pressed)
- {
- helper(key->pressed);
- }
- }
- else
- {
- if (key->released)
- {
- helper(key->released);
- }
- }
- }
- break;
- }
-
-}
-
-/* add a list of codes to the keyboard buffer */
-void at_keyboard_device::helper(const char *codes)
-{
- int i;
- for (i = 0; codes[i]; i++)
- queue_insert(codes[i]);
-}
-
-/**************************************************************************
- * scan keys and stuff make/break codes
- **************************************************************************/
-
-UINT32 pc_keyboard_device::readport(int port)
-{
- UINT32 result = 0;
- switch(port)
- {
- case 0:
- if(m_ioport_0)
- result = m_ioport_0->read();
- break;
- case 1:
- if(m_ioport_1)
- result = m_ioport_1->read();
- break;
- case 2:
- if(m_ioport_2)
- result = m_ioport_2->read();
- break;
- case 3:
- if(m_ioport_3)
- result = m_ioport_3->read();
- break;
- case 4:
- if(m_ioport_4)
- result = m_ioport_4->read();
- break;
- case 5:
- if(m_ioport_5)
- result = m_ioport_5->read();
- break;
- case 6:
- if(m_ioport_6)
- result = m_ioport_6->read();
- break;
- case 7:
- if(m_ioport_7)
- result = m_ioport_7->read();
- break;
- }
- return result;
-}
-
-void pc_keyboard_device::polling(void)
-{
- int i;
-
- if (m_on)
- {
- /* add codes for keys that are set */
- for( i = 0x01; i < 0x80; i++ )
- {
- if (i==0x60) i+=0x10; // keys 0x60..0x6f need special handling
-
- if( readport(i/16) & (1 << (i & 15)) )
- {
- if( m_make[i] == 0 )
- {
- m_make[i] = 1;
-
- if (i==0x45) m_numlock^=1;
-
- standard_scancode_insert(i,1);
- }
- else if((i != 0x45) && (i != 0x3a)) // don't send repeats for caps or num lock
- {
- m_make[i] += 1;
-
- if( m_make[i] == m_delay )
- {
- standard_scancode_insert(i, 1);
- }
- else
- {
- if( m_make[i] == m_delay + m_repeat )
- {
- m_make[i] = m_delay;
- standard_scancode_insert(i, 1);
- }
- }
- }
- }
- else
- {
- if( m_make[i] )
- {
- m_make[i] = 0;
-
- standard_scancode_insert(i, 0);
- }
- }
- }
-
- if(m_type != KEYBOARD_TYPE_PC)
- {
- /* extended scan-codes */
- for( i = 0x60; i < 0x70; i++ )
- {
- if( readport(i/16) & (1 << (i & 15)) )
- {
- if( m_make[i] == 0 )
- {
- m_make[i] = 1;
-
- extended_scancode_insert(i,1);
-
- }
- else
- {
- m_make[i] += 1;
- if( m_make[i] == m_delay )
- {
- extended_scancode_insert(i, 1);
- }
- else
- {
- if( m_make[i] == m_delay + m_repeat )
- {
- m_make[i]=m_delay;
-
- extended_scancode_insert(i, 1);
- }
- }
- }
- }
- else
- {
- if( m_make[i] )
- {
- m_make[i] = 0;
-
- extended_scancode_insert(i,0);
- }
- }
- }
- }
- }
-}
-
-READ8_MEMBER(pc_keyboard_device::read)
-{
- int data;
- if (m_tail == m_head)
- return 0;
-
- data = m_queue[m_tail];
-
- if (LOG_KEYBOARD)
- logerror("read(): Keyboard Read 0x%02x\n",data);
-
- m_tail++;
- m_tail %= ARRAY_LENGTH(m_queue);
- return data;
-}
-
-void pc_keyboard_device::clear_buffer(void)
-{
- m_head = m_tail = 0;
-}
-
-void at_keyboard_device::clear_buffer_and_acknowledge(void)
-{
- clear_buffer();
- queue_insert(0x0fa);
-}
-
-/* From Ralf Browns Interrupt list:
-
-Values for keyboard commands (data also goes to PORT 0060h):
-Value Count Description
- EDh double set/reset mode indicators Caps Num Scrl
- bit 2 = CapsLk, bit 1 = NumLk, bit 0 = ScrlLk
- all other bits must be zero.
- EEh sngl diagnostic echo. returns EEh.
- EFh sngl NOP (No OPeration). reserved for future use
- EF+26h double [Cherry MF2 G80-1501HAD] read 256 bytes of chipcard data
- keyboard must be disabled before this and has to
- be enabled after finished.
- F0h double get/set scan code set
- 00h get current set
- 01h scancode set 1 (PCs and PS/2 mod 30, except Type 2 ctrlr)
-
- 02h scancode set 2 (ATs, PS/2, default)
- 03h scancode set 3
- F2h sngl read keyboard ID (read two ID bytes)
- AT keyboards returns FA (ACK)
- MF2 returns AB 41 (translation) or
- AB 83 (pass through)
- F3h double set typematic rate/delay
- format of the second byte:
- bit7=0 : reserved
- bit6-5 : typemativ delay
- 00b=250ms 10b= 750ms
- 01b=500ms 11b=1000ms
- bit4-0 : typematic rate (see #P050)
- F4h sngl enable keyboard
- F5h sngl disable keyboard. set default parameters (no keyboard scanning)
- F6h sngl set default parameters
- F7h sngl [MCA] set all keys to typematic (scancode set 3)
-
- F8h sngl [MCA] set all keys to make/release
- F9h sngl [MCA] set all keys to make only
- FAh sngl [MCA] set all keys to typematic/make/release
- FBh sngl [MCA] set al keys to typematic
- FCh double [MCA] set specific key to make/release
- FDh double [MCA] set specific key to make only
- FEh sngl resend last scancode
- FFh sngl perform internal power-on reset function
-Note: each command is acknowledged by FAh (ACK), if not mentioned otherwise.
- See PORT 0060h-R for details.
-SeeAlso: #P046
-*/
-
-WRITE8_MEMBER(at_keyboard_device::write)
-{
- if (LOG_KEYBOARD)
- logerror("keyboard write %.2x\n",data);
-
- switch (m_input_state)
- {
- case 0:
- switch (data) {
- case 0xed: // leds schalten
- /* acknowledge */
- queue_insert(0x0fa);
- /* now waiting for code... */
- m_input_state=1;
- break;
- case 0xee: // echo
- /* echo code with no acknowledge */
- queue_insert(0xee);
- break;
- case 0xf0: // scancodes adjust
- /* acknowledge */
- clear_buffer_and_acknowledge();
- /* waiting for data */
- m_input_state=2;
- break;
- case 0xf2: // identify keyboard
- /* ack and two byte keyboard id */
- queue_insert(0xfa);
-
- /* send keyboard code */
- if (m_type == KEYBOARD_TYPE_MF2) {
- queue_insert(0xab);
- queue_insert(0x41);
- }
- else
- {
- /* from help-pc docs */
- queue_insert(0x0ab);
- queue_insert(0x083);
- }
-
- break;
- case 0xf3: // adjust rates
- /* acknowledge */
- queue_insert(0x0fa);
-
- m_input_state=3;
- break;
- case 0xf4: // activate
- clear_buffer_and_acknowledge();
-
- enable(1);
- break;
- case 0xf5:
- /* acknowledge */
- clear_buffer_and_acknowledge();
- // standardvalues
- enable(0);
- break;
- case 0xf6:
- clear_buffer_and_acknowledge();
- // standardvalues
- enable(1);
- break;
- case 0xfe: // resend
- // should not happen, for now send 0
- queue_insert(0); //m_last_code);
- break;
- case 0xff: // reset
- /* it doesn't state this in the docs I have read, but I assume
- that the keyboard input buffer is cleared. The PCW16 sends &ff,
- and requires that 0x0fa is the first byte to be read */
-
- reset();
- clear_buffer_and_acknowledge();
- queue_insert(0xaa);
- break;
- }
- break;
- case 1:
- /* code received */
- m_input_state=0;
-
- /* command? */
- if (data & 0x080)
- {
- /* command received instead of code - execute command */
- write(space, offset, data);
- }
- else
- {
- /* send acknowledge */
- queue_insert(0x0fa);
-
- /* led bits */
- /* bits: 0 scroll lock, 1 num lock, 2 capslock */
-
- /* led's in same order as my keyboard leds. */
- /* num lock, caps lock, scroll lock */
- set_led_status(machine(), 2, (data & 0x01));
- set_led_status(machine(), 0, ((data & 0x02)>>1));
- set_led_status(machine(), 1, ((data & 0x04)>>2));
-
- }
- break;
- case 2:
- m_input_state=0;
-
- /* command? */
- if (data & 0x080)
- {
- /* command received instead of code - execute command */
- write(space, offset, data);
- }
- else
- {
- /* 00 return byte indicating scan code set in use
- 01 select scan code set 1 (used on PC & XT)
- 02 select scan code set 2
- 03 select scan code set 3
- */
-
- if (data == 0x00)
- {
- queue_insert(m_scan_code_set);
- }
- else
- {
- if(data && (data <= 3))
- m_scan_code_set = data;
- }
- }
-
- break;
- case 3:
- /* 6,5: 250ms, 500ms, 750ms, 1s */
- /* 4..0: 30 26.7 .... 2 chars/s*/
-
- /* command? */
- m_input_state=0;
- if (data & 0x080)
- {
- /* command received instead of code - execute command */
- write(space, offset, data);
- }
- else
- {
- /* received keyboard repeat */
-
- }
-
- break;
- }
-}
-
-/***************************************************************************
- unicode_char_to_at_keycode
-***************************************************************************/
-
-UINT8 pc_keyboard_device::unicode_char_to_at_keycode(unicode_char ch)
-{
- UINT8 b;
- switch(ch)
- {
- case '\033': b = 1; break;
- case '1': b = 2; break;
- case '2': b = 3; break;
- case '3': b = 4; break;
- case '4': b = 5; break;
- case '5': b = 6; break;
- case '6': b = 7; break;
- case '7': b = 8; break;
- case '8': b = 9; break;
- case '9': b = 10; break;
- case '0': b = 11; break;
- case '-': b = 12; break;
- case '=': b = 13; break;
- case '\010': b = 14; break;
- case '\t': b = 15; break;
- case 'q': b = 16; break;
- case 'w': b = 17; break;
- case 'e': b = 18; break;
- case 'r': b = 19; break;
- case 't': b = 20; break;
- case 'y': b = 21; break;
- case 'u': b = 22; break;
- case 'i': b = 23; break;
- case 'o': b = 24; break;
- case 'p': b = 25; break;
- case '[': b = 26; break;
- case ']': b = 27; break;
- case '\r': b = 28; break;
- case UCHAR_MAMEKEY(CAPSLOCK): b = 29; break;
- case 'a': b = 30; break;
- case 's': b = 31; break;
- case 'd': b = 32; break;
- case 'f': b = 33; break;
- case 'g': b = 34; break;
- case 'h': b = 35; break;
- case 'j': b = 36; break;
- case 'k': b = 37; break;
- case 'l': b = 38; break;
- case ';': b = 39; break;
- case '\'': b = 40; break;
- case '`': b = 41; break;
- case '\\': b = 43; break;
- case 'z': b = 44; break;
- case 'x': b = 45; break;
- case 'c': b = 46; break;
- case 'v': b = 47; break;
- case 'b': b = 48; break;
- case 'n': b = 49; break;
- case 'm': b = 50; break;
- case ',': b = 51; break;
- case '.': b = 52; break;
- case '/': b = 53; break;
- case ' ': b = 0x39; break;
- case UCHAR_MAMEKEY(F1): b = 0x3b; break;
- case UCHAR_MAMEKEY(F2): b = 0x3c; break;
- case UCHAR_MAMEKEY(F3): b = 0x3d; break;
- case UCHAR_MAMEKEY(F4): b = 0x3e; break;
- case UCHAR_MAMEKEY(F5): b = 0x3f; break;
- case UCHAR_MAMEKEY(F6): b = 0x40; break;
- case UCHAR_MAMEKEY(F7): b = 0x41; break;
- case UCHAR_MAMEKEY(F8): b = 0x42; break;
- case UCHAR_MAMEKEY(F9): b = 0x43; break;
- case UCHAR_MAMEKEY(F10): b = 0x44; break;
- case UCHAR_MAMEKEY(NUMLOCK): b = 0x45; break;
- case UCHAR_MAMEKEY(SCRLOCK): b = 0x46; break;
- case UCHAR_MAMEKEY(7_PAD): b = 0x47; break;
- case UCHAR_MAMEKEY(8_PAD): b = 0x48; break;
- case UCHAR_MAMEKEY(9_PAD): b = 0x49; break;
- case UCHAR_MAMEKEY(MINUS_PAD): b = 0x4a; break;
- case UCHAR_MAMEKEY(4_PAD): b = 0x4b; break;
- case UCHAR_MAMEKEY(5_PAD): b = 0x4c; break;
- case UCHAR_MAMEKEY(6_PAD): b = 0x4d; break;
- case UCHAR_MAMEKEY(PLUS_PAD): b = 0x4e; break;
- case UCHAR_MAMEKEY(1_PAD): b = 0x4f; break;
- case UCHAR_MAMEKEY(2_PAD): b = 0x50; break;
- case UCHAR_MAMEKEY(3_PAD): b = 0x51; break;
- case UCHAR_MAMEKEY(0_PAD): b = 0x52; break;
- case UCHAR_MAMEKEY(DEL_PAD): b = 0x53; break;
- case UCHAR_MAMEKEY(F11): b = 0x57; break;
- case UCHAR_MAMEKEY(F12): b = 0x58; break;
- case '~': b = 0x81; break;
- case '!': b = 0x82; break;
- case '@': b = 0x83; break;
- case '#': b = 0x84; break;
- case '$': b = 0x85; break;
- case '%': b = 0x86; break;
- case '^': b = 0x87; break;
- case '&': b = 0x88; break;
- case '*': b = 0x89; break;
- case '(': b = 0x8a; break;
- case ')': b = 0x8b; break;
- case '_': b = 0x8c; break;
- case '+': b = 0x8d; break;
- case 'Q': b = 0x90; break;
- case 'W': b = 0x91; break;
- case 'E': b = 0x92; break;
- case 'R': b = 0x93; break;
- case 'T': b = 0x94; break;
- case 'Y': b = 0x95; break;
- case 'U': b = 0x96; break;
- case 'I': b = 0x97; break;
- case 'O': b = 0x98; break;
- case 'P': b = 0x99; break;
- case '{': b = 0x9a; break;
- case '}': b = 0x9b; break;
- case 'A': b = 0x9e; break;
- case 'S': b = 0x9f; break;
- case 'D': b = 0xa0; break;
- case 'F': b = 0xa1; break;
- case 'G': b = 0xa2; break;
- case 'H': b = 0xa3; break;
- case 'J': b = 0xa4; break;
- case 'K': b = 0xa5; break;
- case 'L': b = 0xa6; break;
- case ':': b = 0xa7; break;
- case '\"': b = 0xa8; break;
- case '|': b = 0xab; break;
- case 'Z': b = 0xac; break;
- case 'X': b = 0xad; break;
- case 'C': b = 0xae; break;
- case 'V': b = 0xaf; break;
- case 'B': b = 0xb0; break;
- case 'N': b = 0xb1; break;
- case 'M': b = 0xb2; break;
- case '<': b = 0xb3; break;
- case '>': b = 0xb4; break;
- case '?': b = 0xb5; break;
- default: b = 0; break;
- }
- return b;
-}
-
-/***************************************************************************
- queue_chars
-***************************************************************************/
-
-int pc_keyboard_device::queue_chars(const unicode_char *text, size_t text_len)
-{
- int i;
- UINT8 b;
-
- for (i = 0; (i < text_len) && ((queue_size()) + 4 < sizeof(m_queue)); i++)
- {
- b = unicode_char_to_at_keycode(text[i]);
- if (b)
- {
- if (b & 0x80)
- standard_scancode_insert(0x36, 1);
-
- standard_scancode_insert(b & 0x7f, 1);
- standard_scancode_insert(b & 0x7f, 0);
-
- if (b & 0x80)
- standard_scancode_insert(0x36, 0);
- }
- }
- return i;
-}
-
-
-
-/***************************************************************************
- Keyboard declaration
-***************************************************************************/
-
-INPUT_PORTS_START( pc_keyboard )
- PORT_START("pc_keyboard_0")
- PORT_BIT ( 0x0001, 0x0000, IPT_UNUSED ) /* unused scancode 0 */
- PORT_BIT( 0x0002, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC) PORT_CHAR(27) /* Esc 01 81 */
- PORT_BIT( 0x0004, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') /* 1 02 82 */
- PORT_BIT( 0x0008, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@') /* 2 03 83 */
- PORT_BIT( 0x0010, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') /* 3 04 84 */
- PORT_BIT( 0x0020, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') /* 4 05 85 */
- PORT_BIT( 0x0040, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') /* 5 06 86 */
- PORT_BIT( 0x0080, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^') /* 6 07 87 */
- PORT_BIT( 0x0100, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&') /* 7 08 88 */
- PORT_BIT( 0x0200, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*') /* 8 09 89 */
- PORT_BIT( 0x0400, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(') /* 9 0A 8A */
- PORT_BIT( 0x0800, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')') /* 0 0B 8B */
- PORT_BIT( 0x1000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_') /* - 0C 8C */
- PORT_BIT( 0x2000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+') /* = 0D 8D */
- PORT_BIT( 0x4000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) /* Backspace 0E 8E */
- PORT_BIT( 0x8000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR(9) /* Tab 0F 8F */
-
- PORT_START("pc_keyboard_1")
- PORT_BIT( 0x0001, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q') /* Q 10 90 */
- PORT_BIT( 0x0002, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('W') /* W 11 91 */
- PORT_BIT( 0x0004, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('E') /* E 12 92 */
- PORT_BIT( 0x0008, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('R') /* R 13 93 */
- PORT_BIT( 0x0010, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('T') /* T 14 94 */
- PORT_BIT( 0x0020, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') /* Y 15 95 */
- PORT_BIT( 0x0040, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('U') /* U 16 96 */
- PORT_BIT( 0x0080, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('I') /* I 17 97 */
- PORT_BIT( 0x0100, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('O') /* O 18 98 */
- PORT_BIT( 0x0200, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('P') /* P 19 99 */
- PORT_BIT( 0x0400, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{') /* [ 1A 9A */
- PORT_BIT( 0x0800, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}') /* ] 1B 9B */
- PORT_BIT( 0x1000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) /* Enter 1C 9C */
- PORT_BIT( 0x2000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL)) /* Left Ctrl 1D 9D */
- PORT_BIT( 0x4000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('A') /* A 1E 9E */
- PORT_BIT( 0x8000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('S') /* S 1F 9F */
-
- PORT_START("pc_keyboard_2")
- PORT_BIT( 0x0001, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('D') /* D 20 A0 */
- PORT_BIT( 0x0002, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('F') /* F 21 A1 */
- PORT_BIT( 0x0004, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('G') /* G 22 A2 */
- PORT_BIT( 0x0008, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('H') /* H 23 A3 */
- PORT_BIT( 0x0010, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('J') /* J 24 A4 */
- PORT_BIT( 0x0020, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('K') /* K 25 A5 */
- PORT_BIT( 0x0040, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('L') /* L 26 A6 */
- PORT_BIT( 0x0080, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':') /* ; 27 A7 */
- PORT_BIT( 0x0100, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('\"') /* ' 28 A8 */
- PORT_BIT( 0x0200, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~') /* ` 29 A9 */
- PORT_BIT( 0x0400, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_MAMEKEY(LSHIFT)) /* Left Shift 2A AA */
- PORT_BIT( 0x0800, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|') /* \ 2B AB */
- PORT_BIT( 0x1000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z') /* Z 2C AC */
- PORT_BIT( 0x2000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('X') /* X 2D AD */
- PORT_BIT( 0x4000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('C') /* C 2E AE */
- PORT_BIT( 0x8000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('V') /* V 2F AF */
-
- PORT_START("pc_keyboard_3")
- PORT_BIT( 0x0001, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('B') /* B 30 B0 */
- PORT_BIT( 0x0002, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('N') /* N 31 B1 */
- PORT_BIT( 0x0004, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('M') /* M 32 B2 */
- PORT_BIT( 0x0008, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') /* , 33 B3 */
- PORT_BIT( 0x0010, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') /* . 34 B4 */
- PORT_BIT( 0x0020, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') /* / 35 B5 */
- PORT_BIT( 0x0040, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_MAMEKEY(RSHIFT)) /* Right Shift 36 B6 */
- PORT_BIT( 0x0080, 0x0000, IPT_KEYBOARD) PORT_NAME("KP * (PrtScr)") PORT_CODE(KEYCODE_ASTERISK) /* Keypad * (PrtSc) 37 B7 */
- PORT_BIT( 0x0100, 0x0000, IPT_KEYBOARD) PORT_NAME("Alt") PORT_CODE(KEYCODE_LALT) /* Left Alt 38 B8 */
- PORT_BIT( 0x0200, 0x0000, IPT_KEYBOARD) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') /* Space 39 B9 */
- PORT_BIT( 0x0400, 0x0000, IPT_KEYBOARD) PORT_NAME("Caps") PORT_CODE(KEYCODE_CAPSLOCK) /* Caps Lock 3A BA */
- PORT_BIT( 0x0800, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) /* F1 3B BB */
- PORT_BIT( 0x1000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) /* F2 3C BC */
- PORT_BIT( 0x2000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) /* F3 3D BD */
- PORT_BIT( 0x4000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) /* F4 3E BE */
- PORT_BIT( 0x8000, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) /* F5 3F BF */
-
- PORT_START("pc_keyboard_4")
- PORT_BIT( 0x0001, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6)) /* F6 40 C0 */
- PORT_BIT( 0x0002, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7)) /* F7 41 C1 */
- PORT_BIT( 0x0004, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8)) /* F8 42 C2 */
- PORT_BIT( 0x0008, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9)) /* F9 43 C3 */
- PORT_BIT( 0x0010, 0x0000, IPT_KEYBOARD) PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10)) /* F10 44 C4 */
- PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("NumLock") PORT_CODE(KEYCODE_NUMLOCK) /* Num Lock 45 C5 */
- PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ScrLock") PORT_CODE(KEYCODE_SCRLOCK) /* Scroll Lock 46 C6 */
- PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 7 (Home)") PORT_CODE(KEYCODE_7_PAD) PORT_CODE(KEYCODE_HOME ) /* Keypad 7 (Home) 47 C7 */
- PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 8 (Up)") PORT_CODE(KEYCODE_8_PAD) PORT_CODE(KEYCODE_UP ) /* Keypad 8 (Up arrow) 48 C8 */
- PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 9 (PgUp)") PORT_CODE(KEYCODE_9_PAD) PORT_CODE(KEYCODE_PGUP) /* Keypad 9 (PgUp) 49 C9 */
- PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP -") PORT_CODE(KEYCODE_MINUS_PAD) /* Keypad - 4A CA */
- PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 4 (Left)") PORT_CODE(KEYCODE_4_PAD) PORT_CODE(KEYCODE_LEFT ) /* Keypad 4 (Left arrow) 4B CB */
- PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 5") PORT_CODE(KEYCODE_5_PAD) /* Keypad 5 4C CC */
- PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 6 (Right)") PORT_CODE(KEYCODE_6_PAD) PORT_CODE(KEYCODE_RIGHT ) /* Keypad 6 (Right arrow) 4D CD */
- PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP +") PORT_CODE(KEYCODE_PLUS_PAD) /* Keypad + 4E CE */
- PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 1 (End)") PORT_CODE(KEYCODE_1_PAD) PORT_CODE(KEYCODE_END ) /* Keypad 1 (End) 4F CF */
-
- PORT_START("pc_keyboard_5")
- PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 2 (Down)") PORT_CODE(KEYCODE_2_PAD) PORT_CODE(KEYCODE_DOWN ) /* Keypad 2 (Down arrow) 50 D0 */
- PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 3 (PgDn)") PORT_CODE(KEYCODE_3_PAD) PORT_CODE(KEYCODE_PGDN ) /* Keypad 3 (PgDn) 51 D1 */
- PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 0 (Ins)") PORT_CODE(KEYCODE_0_PAD) PORT_CODE(KEYCODE_INSERT ) /* Keypad 0 (Ins) 52 D2 */
- PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP . (Del)") PORT_CODE(KEYCODE_DEL_PAD) PORT_CODE(KEYCODE_DEL ) /* Keypad . (Del) 53 D3 */
- PORT_BIT ( 0x0030, 0x0000, IPT_UNUSED )
- PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(84/102)\\") PORT_CODE(KEYCODE_BACKSLASH2) /* Backslash 2 56 D6 */
- PORT_BIT ( 0xff80, 0x0000, IPT_UNUSED )
-INPUT_PORTS_END
-
-INPUT_PORTS_START( at_keyboard )
- PORT_START("pc_keyboard_0")
- PORT_BIT ( 0x0001, 0x0000, IPT_UNUSED ) /* unused scancode 0 */
- PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Esc") PORT_CODE(KEYCODE_ESC) /* Esc 01 81 */
- PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("1 !") PORT_CODE(KEYCODE_1) /* 1 02 82 */
- PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2 @") PORT_CODE(KEYCODE_2) /* 2 03 83 */
- PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3 #") PORT_CODE(KEYCODE_3) /* 3 04 84 */
- PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("4 $") PORT_CODE(KEYCODE_4) /* 4 05 85 */
- PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("5 %") PORT_CODE(KEYCODE_5) /* 5 06 86 */
- PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("6 ^") PORT_CODE(KEYCODE_6) /* 6 07 87 */
- PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("7 &") PORT_CODE(KEYCODE_7) /* 7 08 88 */
- PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("8 *") PORT_CODE(KEYCODE_8) /* 8 09 89 */
- PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9 (") PORT_CODE(KEYCODE_9) /* 9 0A 8A */
- PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0 )") PORT_CODE(KEYCODE_0) /* 0 0B 8B */
- PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("- _") PORT_CODE(KEYCODE_MINUS) /* - 0C 8C */
- PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("= +") PORT_CODE(KEYCODE_EQUALS) /* = 0D 8D */
- PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("<--") PORT_CODE(KEYCODE_BACKSPACE) /* Backspace 0E 8E */
- PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Tab") PORT_CODE(KEYCODE_TAB) /* Tab 0F 8F */
-
- PORT_START("pc_keyboard_1")
- PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) /* Q 10 90 */
- PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) /* W 11 91 */
- PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) /* E 12 92 */
- PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) /* R 13 93 */
- PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) /* T 14 94 */
- PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) /* Y 15 95 */
- PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) /* U 16 96 */
- PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) /* I 17 97 */
- PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) /* O 18 98 */
- PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) /* P 19 99 */
- PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("[ {") PORT_CODE(KEYCODE_OPENBRACE) /* [ 1A 9A */
- PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("] }") PORT_CODE(KEYCODE_CLOSEBRACE) /* ] 1B 9B */
- PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Enter") PORT_CODE(KEYCODE_ENTER) /* Enter 1C 9C */
- PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L-Ctrl") PORT_CODE(KEYCODE_LCONTROL) /* Left Ctrl 1D 9D */
- PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) /* A 1E 9E */
- PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) /* S 1F 9F */
-
- PORT_START("pc_keyboard_2")
- PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) /* D 20 A0 */
- PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) /* F 21 A1 */
- PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) /* G 22 A2 */
- PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) /* H 23 A3 */
- PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) /* J 24 A4 */
- PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) /* K 25 A5 */
- PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) /* L 26 A6 */
- PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("; :") PORT_CODE(KEYCODE_COLON) /* ; 27 A7 */
- PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("' \"") PORT_CODE(KEYCODE_QUOTE) /* ' 28 A8 */
- PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("` ~") PORT_CODE(KEYCODE_TILDE) /* ` 29 A9 */
- PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L-Shift") PORT_CODE(KEYCODE_LSHIFT) /* Left Shift 2A AA */
- PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("\\ |") PORT_CODE(KEYCODE_BACKSLASH) /* \ 2B AB */
- PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) /* Z 2C AC */
- PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) /* X 2D AD */
- PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) /* C 2E AE */
- PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) /* V 2F AF */
-
- PORT_START("pc_keyboard_3")
- PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) /* B 30 B0 */
- PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) /* N 31 B1 */
- PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) /* M 32 B2 */
- PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(", <") PORT_CODE(KEYCODE_COMMA) /* , 33 B3 */
- PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(". >") PORT_CODE(KEYCODE_STOP) /* . 34 B4 */
- PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("/ ?") PORT_CODE(KEYCODE_SLASH) /* / 35 B5 */
- PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R-Shift") PORT_CODE(KEYCODE_RSHIFT) /* Right Shift 36 B6 */
- PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP * (PrtScr)") PORT_CODE(KEYCODE_ASTERISK ) /* Keypad * (PrtSc) 37 B7 */
- PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Alt") PORT_CODE(KEYCODE_LALT) /* Left Alt 38 B8 */
- PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) /* Space 39 B9 */
- PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Caps") PORT_CODE(KEYCODE_CAPSLOCK) /* Caps Lock 3A BA */
- PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) /* F1 3B BB */
- PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) /* F2 3C BC */
- PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) /* F3 3D BD */
- PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) /* F4 3E BE */
- PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) /* F5 3F BF */
-
- PORT_START("pc_keyboard_4")
- PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) /* F6 40 C0 */
- PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) /* F7 41 C1 */
- PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) /* F8 42 C2 */
- PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F9") PORT_CODE(KEYCODE_F9) /* F9 43 C3 */
- PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F10") PORT_CODE(KEYCODE_F10) /* F10 44 C4 */
- PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("NumLock") PORT_CODE(KEYCODE_NUMLOCK) /* Num Lock 45 C5 */
- PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ScrLock") PORT_CODE(KEYCODE_SCRLOCK) /* Scroll Lock 46 C6 */
- PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 7 (Home)") PORT_CODE(KEYCODE_7_PAD ) /* Keypad 7 (Home) 47 C7 */
- PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 8 (Up)") PORT_CODE(KEYCODE_8_PAD ) /* Keypad 8 (Up arrow) 48 C8 */
- PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 9 (PgUp)") PORT_CODE(KEYCODE_9_PAD ) /* Keypad 9 (PgUp) 49 C9 */
- PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP -") PORT_CODE(KEYCODE_MINUS_PAD) /* Keypad - 4A CA */
- PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 4 (Left)") PORT_CODE(KEYCODE_4_PAD ) /* Keypad 4 (Left arrow) 4B CB */
- PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 5") PORT_CODE(KEYCODE_5_PAD) /* Keypad 5 4C CC */
- PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 6 (Right)") PORT_CODE(KEYCODE_6_PAD ) /* Keypad 6 (Right arrow) 4D CD */
- PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP +") PORT_CODE(KEYCODE_PLUS_PAD) /* Keypad + 4E CE */
- PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 1 (End)") PORT_CODE(KEYCODE_1_PAD ) /* Keypad 1 (End) 4F CF */
-
- PORT_START("pc_keyboard_5")
- PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 2 (Down)") PORT_CODE(KEYCODE_2_PAD ) /* Keypad 2 (Down arrow) 50 D0 */
- PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 3 (PgDn)") PORT_CODE(KEYCODE_3_PAD ) /* Keypad 3 (PgDn) 51 D1 */
- PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 0 (Ins)") PORT_CODE(KEYCODE_0_PAD ) /* Keypad 0 (Ins) 52 D2 */
- PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP . (Del)") PORT_CODE(KEYCODE_DEL_PAD ) /* Keypad . (Del) 53 D3 */
- PORT_BIT ( 0x0030, 0x0000, IPT_UNUSED )
- PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(84/102)\\") PORT_CODE(KEYCODE_BACKSLASH2) /* Backslash 2 56 D6 */
- PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)F11") PORT_CODE(KEYCODE_F11) /* F11 57 D7 */
- PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)F12") PORT_CODE(KEYCODE_F12) /* F12 58 D8 */
- PORT_BIT ( 0xfe00, 0x0000, IPT_UNUSED )
-
- PORT_START("pc_keyboard_6")
- PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)KP Enter") PORT_CODE(KEYCODE_ENTER_PAD) /* PAD Enter 60 e0 */
- PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)Right Control") PORT_CODE(KEYCODE_RCONTROL) /* Right Control 61 e1 */
- PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)KP /") PORT_CODE(KEYCODE_SLASH_PAD) /* PAD Slash 62 e2 */
- PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)PRTSCR") PORT_CODE(KEYCODE_PRTSCR) /* Print Screen 63 e3 */
- PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)ALTGR") PORT_CODE(KEYCODE_RALT) /* ALTGR 64 e4 */
- PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)Home") PORT_CODE(KEYCODE_HOME) /* Home 66 e6 */
- PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)Cursor Up") PORT_CODE(KEYCODE_UP) /* Up 67 e7 */
- PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)Page Up") PORT_CODE(KEYCODE_PGUP) /* Page Up 68 e8 */
- PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)Cursor Left") PORT_CODE(KEYCODE_LEFT) /* Left 69 e9 */
- PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)Cursor Right") PORT_CODE(KEYCODE_RIGHT) /* Right 6a ea */
- PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)End") PORT_CODE(KEYCODE_END) /* End 6b eb */
- PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)Cursor Down") PORT_CODE(KEYCODE_DOWN) /* Down 6c ec */
- PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)Page Down") PORT_CODE(KEYCODE_PGDN) /* Page Down 6d ed */
- PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)Insert") PORT_CODE(KEYCODE_INSERT) /* Insert 6e ee */
- PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)Delete") PORT_CODE(KEYCODE_DEL) /* Delete 6f ef */
- PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(MF2)Pause") PORT_CODE(KEYCODE_PAUSE) /* Pause 65 e5 */
-
- PORT_START("pc_keyboard_7")
- PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Print Screen") PORT_CODE(KEYCODE_PRTSCR) /* Print Screen alternate 77 f7 */
- PORT_BIT ( 0xfffe, 0x0000, IPT_UNUSED )
-INPUT_PORTS_END
-
-/***************************************************************************
- Inputx stuff
-***************************************************************************/
-
-bool pc_keyboard_device::accept_char(unicode_char ch)
-{
- return unicode_char_to_at_keycode(ch) != 0;
-}
-
-
-
-bool pc_keyboard_device::charqueue_empty()
-{
- return queue_size() == 0;
-}
diff --git a/src/emu/machine/pckeybrd.h b/src/emu/machine/pckeybrd.h
deleted file mode 100644
index 12ca33f0f4c..00000000000
--- a/src/emu/machine/pckeybrd.h
+++ /dev/null
@@ -1,137 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Peter Trauner, Kevin Thacker
-/**********************************************************************
-
- pckeybrd.h
-
- PC-style keyboard emulation
-
- This emulation is decoupled from the AT 8042 emulation used in the
- IBM ATs and above
-
-**********************************************************************/
-
-#ifndef PCKEYBRD_H
-#define PCKEYBRD_H
-
-#include "emu.h"
-
-class pc_keyboard_device : public device_t
-{
-public:
- pc_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- pc_keyboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE_LINE_MEMBER(enable);
-
- template<class _Object> static devcb_base &static_set_keypress_callback(device_t &device, _Object object)
- { return downcast<pc_keyboard_device &>(device).m_out_keypress_func.set_callback(object); }
-
- enum KEYBOARD_TYPE
- {
- KEYBOARD_TYPE_PC,
- KEYBOARD_TYPE_AT,
- KEYBOARD_TYPE_MF2
- };
-
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- void queue_insert(UINT8 data);
- void clear_buffer(void);
-
- int m_numlock;
- KEYBOARD_TYPE m_type;
-
-private:
- void polling(void);
- UINT32 readport(int port);
- UINT8 unicode_char_to_at_keycode(unicode_char ch);
-
- virtual void standard_scancode_insert(int our_code, int pressed);
- virtual void extended_scancode_insert(int code, int pressed) { }
- int queue_size(void);
- int queue_chars(const unicode_char *text, size_t text_len);
- bool accept_char(unicode_char ch);
- bool charqueue_empty();
-
- bool m_on;
- UINT8 m_delay; /* 240/60 -> 0,25s */
- UINT8 m_repeat; /* 240/ 8 -> 30/s */
-
- UINT8 m_queue[256];
- UINT8 m_head;
- UINT8 m_tail;
- UINT8 m_make[128];
-
- optional_ioport m_ioport_0;
- optional_ioport m_ioport_1;
- optional_ioport m_ioport_2;
- optional_ioport m_ioport_3;
- optional_ioport m_ioport_4;
- optional_ioport m_ioport_5;
- optional_ioport m_ioport_6;
- optional_ioport m_ioport_7;
-
- devcb_write_line m_out_keypress_func;
- emu_timer *m_keyboard_timer;
-};
-
-class at_keyboard_device : public pc_keyboard_device
-{
-public:
- at_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_WRITE8_MEMBER( write );
-
- static void static_set_type(device_t &device, KEYBOARD_TYPE type, int default_set)
- { downcast<at_keyboard_device &>(device).m_scan_code_set = default_set; downcast<at_keyboard_device &>(device).m_type = type; }
-
-protected:
- virtual void device_reset();
- virtual void device_start();
-
-private:
- virtual void standard_scancode_insert(int our_code, int pressed);
- virtual void extended_scancode_insert(int code, int pressed);
- void helper(const char *codes);
- void clear_buffer_and_acknowledge(void);
-
- struct extended_keyboard_code
- {
- const char *pressed;
- const char *released;
- };
-
- static const extended_keyboard_code m_extended_codes_set_2_3[];
- static const int m_scancode_set_2_3[];
- static const extended_keyboard_code m_mf2_code[0x10][2];
-
- int m_scan_code_set;
- int m_input_state;
-};
-
-INPUT_PORTS_EXTERN( pc_keyboard );
-INPUT_PORTS_EXTERN( at_keyboard );
-
-extern const device_type PC_KEYB;
-extern const device_type AT_KEYB;
-
-#define MCFG_PC_KEYB_ADD(_tag, _cb) \
- MCFG_DEVICE_ADD(_tag, PC_KEYB, 0) \
- devcb = &pc_keyboard_device::static_set_keypress_callback(*device, DEVCB_##_cb);
-
-#define MCFG_AT_KEYB_ADD(_tag, _def_set, _cb) \
- MCFG_DEVICE_ADD(_tag, AT_KEYB, 0) \
- at_keyboard_device::static_set_type(*device, pc_keyboard_device::KEYBOARD_TYPE_AT, _def_set); \
- devcb = &pc_keyboard_device::static_set_keypress_callback(*device, DEVCB_##_cb);
-
-#define MCFG_AT_MF2_KEYB_ADD(_tag, _def_set, _cb) \
- MCFG_DEVICE_ADD(_tag, AT_KEYB, 0) \
- at_keyboard_device::static_set_type(*device, pc_keyboard_device::KEYBOARD_TYPE_MF2, _def_set); \
- devcb = &pc_keyboard_device::static_set_keypress_callback(*device, DEVCB_##_cb);
-
-#endif /* PCKEYBRD_H */
diff --git a/src/emu/machine/pic8259.c b/src/emu/machine/pic8259.c
deleted file mode 100644
index 40fe6fd916c..00000000000
--- a/src/emu/machine/pic8259.c
+++ /dev/null
@@ -1,439 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol
-/**********************************************************************
-
- 8259 PIC interface and emulation
-
- The 8259 is a programmable interrupt controller used to multiplex
- interrupts for x86 and other computers. The chip is set up by
- writing a series of Initialization Command Words (ICWs) after which
- the chip is operational and capable of dispatching interrupts. After
- this, Operation Command Words (OCWs) can be written to control further
- behavior.
-
-**********************************************************************/
-
-#include "emu.h"
-#include "machine/pic8259.h"
-
-#define LOG_ICW 0
-#define LOG_OCW 0
-#define LOG_GENERAL 0
-
-ALLOW_SAVE_TYPE(pic8259_device::pic8259_state_t); // allow save_item on a non-fundamental type
-
-void pic8259_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- /* check the various IRQs */
- for (int n = 0, irq = m_prio; n < 8; n++, irq = (irq + 1) & 7)
- {
- UINT8 mask = 1 << irq;
-
- /* is this IRQ in service and not cascading and sfnm? */
- if ((m_isr & mask) && !(m_master && m_cascade && m_nested && (m_slave & mask)))
- {
- if (LOG_GENERAL)
- {
- logerror("pic8259_timerproc() %s: PIC IRQ #%d still in service\n", tag(), irq);
- }
- break;
- }
-
- /* is this IRQ pending and enabled? */
- if ((m_state == STATE_READY) && (m_irr & mask) && !(m_imr & mask))
- {
- if (LOG_GENERAL)
- {
- logerror("pic8259_timerproc() %s: PIC triggering IRQ #%d\n", tag(), irq);
- }
- m_out_int_func(1);
- return;
- }
- // if sfnm and in-service don't continue
- if((m_isr & mask) && m_master && m_cascade && m_nested && (m_slave & mask))
- break;
- }
- m_out_int_func(0);
-}
-
-
-void pic8259_device::set_irq_line(int irq, int state)
-{
- UINT8 mask = (1 << irq);
-
- if (state)
- {
- /* setting IRQ line */
- if (LOG_GENERAL)
- logerror("pic8259_set_irq_line() %s: PIC set IRQ line #%d\n", tag(), irq);
-
- if(m_level_trig_mode || (!m_level_trig_mode && !(m_irq_lines & mask)))
- {
- m_irr |= mask;
- }
- m_irq_lines |= mask;
- }
- else
- {
- /* clearing IRQ line */
- if (LOG_GENERAL)
- {
- logerror("pic8259_device::set_irq_line() %s: PIC cleared IRQ line #%d\n", tag(), irq);
- }
-
- m_irq_lines &= ~mask;
- m_irr &= ~mask;
- }
- set_timer();
-}
-
-
-UINT32 pic8259_device::acknowledge()
-{
- for (int n = 0, irq = m_prio; n < 8; n++, irq = (irq + 1) & 7)
- {
- UINT8 mask = 1 << irq;
-
- /* is this IRQ pending and enabled? */
- if ((m_irr & mask) && !(m_imr & mask))
- {
- if (LOG_GENERAL)
- {
- logerror("pic8259_acknowledge() %s: PIC acknowledge IRQ #%d\n", tag(), irq);
- }
- if (!m_level_trig_mode)
- {
- m_irr &= ~mask;
- }
-
- if (!m_auto_eoi)
- {
- m_isr |= mask;
- }
-
- set_timer();
-
- if ((m_cascade!=0) && (m_master!=0) && (mask & m_slave))
- {
- // it's from slave device
- return m_read_slave_ack_func(irq);
- }
- else
- {
- if (m_is_x86)
- {
- /* For x86 mode*/
- return irq + m_base;
- }
- else
- {
- /* in case of 8080/85) */
- return 0xcd0000 + (m_vector_addr_high << 8) + m_vector_addr_low + (irq << (3-m_vector_size));
- }
- }
- }
- }
- return 0;
-}
-
-
-IRQ_CALLBACK_MEMBER(pic8259_device::inta_cb)
-{
- return acknowledge();
-}
-
-
-READ8_MEMBER( pic8259_device::read )
-{
- /* NPW 18-May-2003 - Changing 0xFF to 0x00 as per Ruslan */
- UINT8 data = 0x00;
-
- switch(offset)
- {
- case 0: /* PIC acknowledge IRQ */
- if ( m_ocw3 & 0x04 )
- {
- /* Polling mode */
- if ( m_irr & ~m_imr )
- {
- /* check the various IRQs */
- for (int n = 0, irq = m_prio; n < 8; n++, irq = (irq + 1) & 7)
- {
- if ( ( 1 << irq ) & m_irr & ~m_imr )
- {
- data = 0x80 | irq;
- break;
- }
- }
- acknowledge();
- }
- }
- else
- {
- switch ( m_ocw3 & 0x03 )
- {
- case 2:
- data = m_irr;
- break;
- case 3:
- data = m_isr & ~m_imr;
- break;
- default:
- data = 0x00;
- break;
- }
- }
- break;
-
- case 1: /* PIC mask register */
- data = m_imr;
- break;
- }
- return data;
-}
-
-
-WRITE8_MEMBER( pic8259_device::write )
-{
- switch(offset)
- {
- case 0: /* PIC acknowledge IRQ */
- if (data & 0x10)
- {
- /* write ICW1 - this pretty much resets the chip */
- if (LOG_ICW)
- {
- logerror("pic8259_device::write() %s: ICW1; data=0x%02X\n", tag(), data);
- }
-
- m_imr = 0x00;
- m_isr = 0x00;
- m_irr = 0x00;
- m_level_trig_mode = (data & 0x08) ? 1 : 0;
- m_vector_size = (data & 0x04) ? 1 : 0;
- m_cascade = (data & 0x02) ? 0 : 1;
- m_icw4_needed = (data & 0x01) ? 1 : 0;
- m_vector_addr_low = (data & 0xe0);
- m_state = STATE_ICW2;
- m_out_int_func(0);
- }
- else if (m_state == STATE_READY)
- {
- if ((data & 0x98) == 0x08)
- {
- /* write OCW3 */
- if (LOG_OCW)
- {
- logerror("pic8259_device::write() %s: OCW3; data=0x%02X\n", tag(), data);
- }
-
- m_ocw3 = data;
- }
- else if ((data & 0x18) == 0x00)
- {
- int n = data & 7;
- UINT8 mask = 1 << n;
-
- /* write OCW2 */
- if (LOG_OCW)
- {
- logerror("pic8259_device::write() %s: OCW2; data=0x%02X\n", tag(), data);
- }
-
- switch (data & 0xe0)
- {
- case 0x00:
- m_prio = 0;
- break;
- case 0x20:
- for (n = 0, mask = 1<<m_prio; n < 8; n++, mask = (mask<<1) | (mask>>7))
- {
- if (m_isr & mask)
- {
- m_isr &= ~mask;
- break;
- }
- }
- break;
- case 0x40:
- break;
- case 0x60:
- if( m_isr & mask )
- {
- m_isr &= ~mask;
- }
- break;
- case 0x80:
- m_prio = (m_prio + 1) & 7;
- break;
- case 0xa0:
- for (n = 0, mask = 1<<m_prio; n < 8; n++, mask = (mask<<1) | (mask>>7))
- {
- if( m_isr & mask )
- {
- m_isr &= ~mask;
- m_prio = (m_prio + 1) & 7;
- break;
- }
- }
- break;
- case 0xc0:
- m_prio = (n + 1) & 7;
- break;
- case 0xe0:
- if( m_isr & mask )
- {
- m_isr &= ~mask;
- m_prio = (n + 1) & 7;
- }
- break;
- }
- }
- }
- break;
-
- case 1:
- switch(m_state)
- {
- case STATE_ICW1:
- break;
-
- case STATE_ICW2:
- /* write ICW2 */
- if (LOG_ICW)
- {
- logerror("pic8259_device::write() %s: ICW2; data=0x%02X\n", tag(), data);
- }
-
- m_base = data & 0xf8;
- m_vector_addr_high = data ;
- if (m_cascade)
- {
- m_state = STATE_ICW3;
- }
- else
- {
- m_state = m_icw4_needed ? STATE_ICW4 : STATE_READY;
- }
- break;
-
- case STATE_ICW3:
- /* write ICW3 */
- if (LOG_ICW)
- {
- logerror("pic8259_device::write() %s: ICW3; data=0x%02X\n", tag(), data);
- }
-
- m_slave = data;
- m_state = m_icw4_needed ? STATE_ICW4 : STATE_READY;
- break;
-
- case STATE_ICW4:
- /* write ICW4 */
- if (LOG_ICW)
- {
- logerror("pic8259_device::write() %s: ICW4; data=0x%02X\n", tag(), data);
- }
-
- m_nested = (data & 0x10) ? 1 : 0;
- m_mode = (data >> 2) & 3;
- m_auto_eoi = (data & 0x02) ? 1 : 0;
- m_is_x86 = (data & 0x01) ? 1 : 0;
- m_state = STATE_READY;
- break;
-
- case STATE_READY:
- /* write OCW1 - set interrupt mask register */
- if (LOG_OCW)
- {
- logerror("pic8259_device::write(): OCW1; data=0x%02X\n", data);
- }
-
- //printf("%s %02x\n",m_master ? "master pic8259 mask" : "slave pic8259 mask",data);
- m_imr = data;
- break;
- }
- break;
- }
- set_timer();
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void pic8259_device::device_start()
-{
- // resolve callbacks
- m_out_int_func.resolve();
- m_sp_en_func.resolve();
- m_read_slave_ack_func.resolve();
-
- // Register save state items
- save_item(NAME(m_state));
- save_item(NAME(m_isr));
- save_item(NAME(m_irr));
- save_item(NAME(m_prio));
- save_item(NAME(m_imr));
- save_item(NAME(m_irq_lines));
- save_item(NAME(m_input));
- save_item(NAME(m_ocw3));
- save_item(NAME(m_master));
- save_item(NAME(m_level_trig_mode));
- save_item(NAME(m_vector_size));
- save_item(NAME(m_cascade));
- save_item(NAME(m_icw4_needed));
- save_item(NAME(m_vector_addr_low));
- save_item(NAME(m_base));
- save_item(NAME(m_vector_addr_high));
- save_item(NAME(m_slave));
- save_item(NAME(m_nested));
- save_item(NAME(m_mode));
- save_item(NAME(m_auto_eoi));
- save_item(NAME(m_is_x86));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void pic8259_device::device_reset()
-{
- m_state = STATE_READY;
- m_isr = 0;
- m_irr = 0;
- m_irq_lines = 0;
- m_prio = 0;
- m_imr = 0;
- m_input = 0;
- m_ocw3 = 2;
- m_level_trig_mode = 0;
- m_vector_size = 0;
- m_cascade = 0;
- m_icw4_needed = 0;
- m_base = 0;
- m_slave = 0;
- m_nested = 0;
- m_mode = 0;
- m_auto_eoi = 0;
- m_is_x86 = 0;
- m_vector_addr_low = 0;
- m_vector_addr_high = 0;
-
- m_master = m_sp_en_func();
-}
-
-const device_type PIC8259 = &device_creator<pic8259_device>;
-
-pic8259_device::pic8259_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, PIC8259, "8259 PIC", tag, owner, clock, "pit8259", __FILE__)
- , m_out_int_func(*this)
- , m_sp_en_func(*this)
- , m_read_slave_ack_func(*this)
- , m_irr(0)
- , m_irq_lines(0)
- , m_level_trig_mode(0)
-{
-}
diff --git a/src/emu/machine/pic8259.h b/src/emu/machine/pic8259.h
deleted file mode 100644
index 48914c07fe9..00000000000
--- a/src/emu/machine/pic8259.h
+++ /dev/null
@@ -1,126 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol
-/***************************************************************************
-
- Intel 8259A
-
- Programmable Interrupt Controller
-
- _____ _____
- _CS 1 |* \_/ | 28 VCC
- _WR 2 | | 27 A0
- _RD 3 | | 26 _INTA
- D7 4 | | 25 IR7
- D6 5 | | 24 IR6
- D5 6 | | 23 IR5
- D4 7 | 8259A | 22 IR4
- D3 8 | | 21 IR3
- D2 9 | | 20 IR2
- D1 10 | | 19 IR1
- D0 11 | | 18 IR0
- CAS0 12 | | 17 INT
- CAS1 13 | | 16 _SP/_EN
- GND 14 |_____________| 15 CAS2
-
-***************************************************************************/
-
-#ifndef __PIC8259_H__
-#define __PIC8259_H__
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_PIC8259_ADD(_tag, _out_int, _sp_en, _read_slave_ack) \
- MCFG_DEVICE_ADD(_tag, PIC8259, 0) \
- devcb = &pic8259_device::static_set_out_int_callback( *device, DEVCB_##_out_int ); \
- devcb = &pic8259_device::static_set_sp_en_callback( *device, DEVCB_##_sp_en ); \
- devcb = &pic8259_device::static_set_read_slave_ack_callback( *device, DEVCB_##_read_slave_ack );
-
-
-class pic8259_device : public device_t
-{
-public:
- pic8259_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &static_set_out_int_callback(device_t &device, _Object object) { return downcast<pic8259_device &>(device).m_out_int_func.set_callback(object); }
- template<class _Object> static devcb_base &static_set_sp_en_callback(device_t &device, _Object object) { return downcast<pic8259_device &>(device).m_sp_en_func.set_callback(object); }
- template<class _Object> static devcb_base &static_set_read_slave_ack_callback(device_t &device, _Object object) { return downcast<pic8259_device &>(device).m_read_slave_ack_func.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
- UINT32 acknowledge();
-
- DECLARE_WRITE_LINE_MEMBER( ir0_w ) { set_irq_line(0, state); }
- DECLARE_WRITE_LINE_MEMBER( ir1_w ) { set_irq_line(1, state); }
- DECLARE_WRITE_LINE_MEMBER( ir2_w ) { set_irq_line(2, state); }
- DECLARE_WRITE_LINE_MEMBER( ir3_w ) { set_irq_line(3, state); }
- DECLARE_WRITE_LINE_MEMBER( ir4_w ) { set_irq_line(4, state); }
- DECLARE_WRITE_LINE_MEMBER( ir5_w ) { set_irq_line(5, state); }
- DECLARE_WRITE_LINE_MEMBER( ir6_w ) { set_irq_line(6, state); }
- DECLARE_WRITE_LINE_MEMBER( ir7_w ) { set_irq_line(7, state); }
-
- IRQ_CALLBACK_MEMBER(inta_cb);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- static const device_timer_id TIMER_CHECK_IRQ = 0;
-
- inline void set_timer() { timer_set(attotime::zero, TIMER_CHECK_IRQ); }
- void set_irq_line(int irq, int state);
-
-
- enum pic8259_state_t
- {
- STATE_ICW1,
- STATE_ICW2,
- STATE_ICW3,
- STATE_ICW4,
- STATE_READY
- };
-
- devcb_write_line m_out_int_func;
- devcb_read_line m_sp_en_func;
- devcb_read8 m_read_slave_ack_func;
-
- pic8259_state_t m_state;
-
- UINT8 m_isr;
- UINT8 m_irr;
- UINT8 m_prio;
- UINT8 m_imr;
- UINT8 m_irq_lines;
-
- UINT8 m_input;
- UINT8 m_ocw3;
-
- UINT8 m_master;
- /* ICW1 state */
- UINT8 m_level_trig_mode;
- UINT8 m_vector_size;
- UINT8 m_cascade;
- UINT8 m_icw4_needed;
- UINT32 m_vector_addr_low;
- /* ICW2 state */
- UINT8 m_base;
- UINT8 m_vector_addr_high;
-
- /* ICW3 state */
- UINT8 m_slave;
-
- /* ICW4 state */
- UINT8 m_nested;
- UINT8 m_mode;
- UINT8 m_auto_eoi;
- UINT8 m_is_x86;
-};
-
-extern const device_type PIC8259;
-
-#endif /* __PIC8259_H__ */
diff --git a/src/emu/machine/pit8253.c b/src/emu/machine/pit8253.c
deleted file mode 100644
index 1ad506686e0..00000000000
--- a/src/emu/machine/pit8253.c
+++ /dev/null
@@ -1,1135 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol, Nathan Woods
-/*****************************************************************************
- *
- * Programmable Interval Timer 8253/8254
- *
- * Three Independent Timers
- * (gate, clock, out pins)
- *
- * 8254 has an additional readback feature
- *
- * Revision History
- * 1-Apr-2008 - WFP: Changed the implementation into a device.
- * 8-Jul-2004 - AJ: Fixed some bugs. Styx now runs correctly.
- * Implemented 8254 features.
- * 1-Mar-2004 - NPW: Did an almost total rewrite and cleaned out much
- * of the ugliness in the previous design. Bug #430
- * seems to be fixed
- * 1-Jul-2000 - PeT: Split off from PC driver and componentized
- *
- *****************************************************************************/
-
-#include "emu.h"
-#include "machine/pit8253.h"
-
-// for now, make buggy GCC/Mingw STFU about I64FMT
-#if (defined(__MINGW32__) && (__GNUC__ >= 5))
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat"
-#pragma GCC diagnostic ignored "-Wformat-extra-args"
-#endif
-
-/* device types */
-enum
-{
- TYPE_PIT8253 = 0,
- TYPE_PIT8254
-};
-
-
-/***************************************************************************
-
- Structures & macros
-
-***************************************************************************/
-
-#define VERBOSE 0
-
-#define LOG1(msg) do { if (VERBOSE >= 1) logerror msg; } while (0)
-#define LOG2(msg) do { if (VERBOSE >= 2) logerror msg; } while (0)
-
-
-const device_type PIT8253 = &device_creator<pit8253_device>;
-
-
-pit8253_device::pit8253_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, PIT8253, "8253 PIT", tag, owner, clock, "pit8253", __FILE__),
- m_clk0(0),
- m_clk1(0),
- m_clk2(0),
- m_out0_handler(*this),
- m_out1_handler(*this),
- m_out2_handler(*this)
-{
-}
-
-pit8253_device::pit8253_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_clk0(0),
- m_clk1(0),
- m_clk2(0),
- m_out0_handler(*this),
- m_out1_handler(*this),
- m_out2_handler(*this)
-{
-}
-
-
-const device_type PIT8254 = &device_creator<pit8254_device>;
-
-pit8254_device::pit8254_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pit8253_device(mconfig, PIT8254, "8254 PIT", tag, owner, clock, "pit8254", __FILE__)
-{
-}
-
-
-pit8253_device::pit8253_timer *pit8253_device::get_timer(int which)
-{
- which &= 3;
- if (which < PIT8253_MAX_TIMER)
- return &m_timers[which];
-
- return NULL;
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void pit8253_device::device_start()
-{
- m_timers[0].clockin = m_clk0;
- m_timers[1].clockin = m_clk1;
- m_timers[2].clockin = m_clk2;
-
- m_out0_handler.resolve_safe();
- m_out1_handler.resolve_safe();
- m_out2_handler.resolve_safe();
-
- for (int timerno = 0; timerno < PIT8253_MAX_TIMER; timerno++)
- {
- pit8253_timer *timer = get_timer(timerno);
-
- /* initialize timer */
- timer->updatetimer = timer_alloc(timerno);
- timer->updatetimer->adjust(attotime::never, timerno);
-
- /* set up state save values */
- save_item(NAME(timer->clockin), timerno);
- save_item(NAME(timer->control), timerno);
- save_item(NAME(timer->status), timerno);
- save_item(NAME(timer->lowcount), timerno);
- save_item(NAME(timer->latch), timerno);
- save_item(NAME(timer->count), timerno);
- save_item(NAME(timer->value), timerno);
- save_item(NAME(timer->wmsb), timerno);
- save_item(NAME(timer->rmsb), timerno);
- save_item(NAME(timer->output), timerno);
- save_item(NAME(timer->gate), timerno);
- save_item(NAME(timer->latched_count), timerno);
- save_item(NAME(timer->latched_status), timerno);
- save_item(NAME(timer->null_count), timerno);
- save_item(NAME(timer->phase), timerno);
- save_item(NAME(timer->last_updated), timerno);
- save_item(NAME(timer->clock), timerno);
-
- /* zerofill */
- timer->gate = 1;
- timer->phase = 0;
- timer->clock = 0;
-
- timer->index = timerno;
- timer->control = timer->status = 0x30;
- timer->rmsb = timer->wmsb = 0;
- timer->count = timer->value = timer->latch = 0;
- timer->lowcount = 0;
-
- timer->output = 0;
- timer->latched_count = 0;
- timer->latched_status = 0;
- timer->null_count = 1;
-
- timer->last_updated = machine().time();
- }
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void pit8253_device::device_reset()
-{
- for (int i = 0; i < PIT8253_MAX_TIMER; i++)
- {
- pit8253_timer *timer = get_timer(i);
-
- /* According to Intel's 8254 docs, the state of a timer is undefined
- until the first mode control word is written. Here we define this
- undefined behaviour */
- timer->control = timer->status = 0x30;
- timer->rmsb = timer->wmsb = 0;
- timer->count = timer->value = timer->latch = 0;
- timer->lowcount = 0;
-
- timer->output = 2; /* output is undetermined */
- timer->latched_count = 0;
- timer->latched_status = 0;
- timer->null_count = 1;
-
- timer->last_updated = machine().time();
-
- update(timer);
- }
-}
-
-
-/***************************************************************************
-
- Functions
-
-***************************************************************************/
-
-#define CTRL_ACCESS(control) (((control) >> 4) & 0x03)
-#define CTRL_MODE(control) (((control) >> 1) & (((control) & 0x04) ? 0x03 : 0x07))
-#define CTRL_BCD(control) (((control) >> 0) & 0x01)
-
-
-inline UINT32 pit8253_device::adjusted_count(int bcd, UINT16 val)
-{
- if (!bcd)
- return (val == 0) ? 0x10000 : val;
- else if (val == 0)
- return 10000;
-
- /* In BCD mode, a nybble loaded with value A-F counts down the same as in
- binary mode, but wraps around to 9 instead of F after 0, so loading the
- count register with 0xFFFF gives a period of
- 0xF - for the units to count down to 0
- + 10*0xF - for the tens to count down to 0
- + 100*0xF - for the hundreds to count down to 0
- + 1000*0xF - for the thousands to count down to 0
- = 16665 cycles
- */
- return
- ((val>>12) & 0xF) * 1000 +
- ((val>> 8) & 0xF) * 100 +
- ((val>> 4) & 0xF) * 10 +
- ( val & 0xF);
-}
-
-
-/* This function subtracts 1 from timer->value "cycles" times, taking into
- account binary or BCD operation, and wrapping around from 0 to 0xFFFF or
- 0x9999 as necessary. */
-void pit8253_device::decrease_counter_value(pit8253_timer *timer, INT64 cycles)
-{
- UINT16 value;
- UINT8 units, tens, hundreds, thousands;
-
- if (CTRL_BCD(timer->control) == 0)
- {
- timer->value -= (cycles & 0xffff);
- return;
- }
-
- value = timer->value;
- units = value & 0xf;
- tens = (value >> 4) & 0xf;
- hundreds = (value >> 8) & 0xf;
- thousands = (value >> 12) & 0xf;
-
- if (cycles <= units)
- {
- units -= cycles;
- }
- else
- {
- cycles -= units;
- units = (10 - cycles % 10) % 10;
-
- cycles = (cycles + 9) / 10; /* the +9 is so we get a carry if cycles%10 wasn't 0 */
- if (cycles <= tens)
- {
- tens -= cycles;
- }
- else
- {
- cycles -= tens;
- tens = (10 - cycles % 10) % 10;
-
- cycles = (cycles + 9) / 10;
- if (cycles <= hundreds)
- {
- hundreds -= cycles;
- }
- else
- {
- cycles -= hundreds;
- hundreds = (10 - cycles % 10) % 10;
- cycles = (cycles + 9) / 10;
- thousands = (10 + thousands - cycles % 10) % 10;
- }
- }
- }
-
- timer->value = (thousands << 12) | (hundreds << 8) | (tens << 4) | units;
-}
-
-
-/* Counter loading: transfer of a count from the CR to the CE */
-void pit8253_device::load_counter_value(pit8253_timer *timer)
-{
- timer->value = timer->count;
- timer->null_count = 0;
-
- if (CTRL_MODE(timer->control) == 3 && timer->output == 0)
- timer->value &= 0xfffe;
-}
-
-
-void pit8253_device::set_output(pit8253_timer *timer, int output)
-{
- if (output != timer->output)
- {
- timer->output = output;
-
- switch (timer->index)
- {
- case 0:
- m_out0_handler(output);
- break;
-
- case 1:
- m_out1_handler(output);
- break;
-
- case 2:
- m_out2_handler(output);
- break;
- }
- }
-}
-
-
-/* This emulates timer "timer" for "elapsed_cycles" cycles and assumes no
- callbacks occur during that time. */
-void pit8253_device::simulate2(pit8253_timer *timer, INT64 elapsed_cycles)
-{
- UINT32 adjusted_value;
- int bcd = CTRL_BCD(timer->control);
- int mode = CTRL_MODE(timer->control);
- static const UINT32 CYCLES_NEVER = (0xffffffff);
- UINT32 cycles_to_output = 0;
-
- LOG2(("pit8253: simulate2(): simulating %d cycles for %d in mode %d, bcd = %d, phase = %d, gate = %d, output %d, value = 0x%04x\n",
- (int)elapsed_cycles, timer->index, mode, bcd, timer->phase, timer->gate, timer->output, timer->value));
-
- switch (mode)
- {
- case 0:
- /* Mode 0: (Interrupt on Terminal Count)
-
- +------------------
- |
- ----------+
- <- n+1 ->
-
- ^
- +- counter load
-
- phase|output|length |value|next|comment
- -----+------+--------+-----+----+----------------------------------
- 0|low |infinity| |1 |waiting for count
- 1|low |1 | |2 |internal delay when counter loaded
- 2|low |n |n..1 |3 |counting down
- 3|high |infinity|0..1 |3 |counting down
-
- Gate level sensitive only. Low disables counting, high enables it. */
-
- if (timer->phase == 0)
- {
- cycles_to_output = CYCLES_NEVER;
- }
- else
- {
- if (elapsed_cycles >= 0 && timer->phase == 1)
- {
- /* Counter load cycle */
- if (elapsed_cycles > 0)
- {
- --elapsed_cycles;
- timer->phase = 2;
- }
- load_counter_value(timer);
- }
-
- if (timer->gate == 0)
- {
- cycles_to_output = CYCLES_NEVER;
- }
- else
- {
- if (timer->phase == 2)
- {
- adjusted_value = adjusted_count(bcd, timer->value);
- if (elapsed_cycles >= adjusted_value)
- {
- /* Counter wrapped, output goes high */
- elapsed_cycles -= adjusted_value;
- timer->phase = 3;
- timer->value = 0;
- set_output(timer, 1);
- }
- }
-
- decrease_counter_value(timer, elapsed_cycles);
-
- switch (timer->phase)
- {
- case 1: cycles_to_output = 1; break;
- case 2: cycles_to_output = adjusted_count(bcd, timer->value); break;
- case 3: cycles_to_output = adjusted_count(bcd, timer->value); break;
- }
- }
- }
- break;
-
-
- case 1:
- /* Mode 1: (Hardware Retriggerable One-Shot a.k.a. Programmable One-Shot)
-
- -----+ +------------------
- | |
- +-------+
- <- n ->
-
- ^
- +- trigger
-
- phase|output|length |value|next|comment
- -----+------+--------+-----+----+----------------------------------
- 0|high |infinity| |1 |counting down
- 1|high |1 | |2 |internal delay to load counter
- 2|low |n |n..1 |3 |counting down
- 3|high |infinity|0..1 |3 |counting down
-
- Gate rising-edge sensitive only.
- Rising edge initiates counting and resets output after next clock. */
-
- if (elapsed_cycles >= 0 && timer->phase == 1)
- {
- /* Counter load cycle, output goes low */
- if (elapsed_cycles > 0)
- {
- --elapsed_cycles;
- timer->phase = 2;
- }
- load_counter_value(timer);
- set_output(timer, 0);
- }
-
- if (timer->phase == 2)
- {
- adjusted_value = adjusted_count(bcd, timer->value);
- if (elapsed_cycles >= adjusted_value)
- {
- /* Counter wrapped, output goes high */
- timer->phase = 3;
- set_output(timer, 1);
- }
- }
-
- decrease_counter_value(timer, elapsed_cycles);
-
- switch (timer->phase)
- {
- case 1: cycles_to_output = 1; break;
- case 2: cycles_to_output = adjusted_count(bcd, timer->value); break;
- default: cycles_to_output = CYCLES_NEVER; break;
- }
- break;
-
-
- case 2:
- /* Mode 2: (Rate Generator)
-
- --------------+ +---------+ +----
- | | | |
- +-+ +-+
- <- n -X- n ->
- <1>
- ^
- +- counter load or trigger
-
- phase|output|length |value|next|comment
- -----+------+--------+-----+----+----------------------------------
- 0|high |infinity| |1 |waiting for count
- 1|high |1 | |2 |internal delay to load counter
- 2|high |n |n..2 |3 |counting down
- 3|low |1 |1 |2 |reload counter
-
- Counter rewrite has no effect until repeated
-
- Gate rising-edge and level sensitive.
- Gate low disables counting and sets output immediately high.
- Rising-edge reloads count and initiates counting
- Gate high enables counting. */
-
- if (timer->gate == 0 || timer->phase == 0)
- {
- /* Gate low or mode control write forces output high */
- set_output(timer, 1);
- cycles_to_output = CYCLES_NEVER;
- }
- else
- {
- if (elapsed_cycles >= 0 && timer->phase == 1)
- {
- if (elapsed_cycles > 0)
- {
- --elapsed_cycles;
- timer->phase = 2;
- }
- load_counter_value(timer);
- }
-
- adjusted_value = adjusted_count(bcd, timer->value);
-
- do
- {
- if (timer->phase == 2)
- {
- if (elapsed_cycles + 1 >= adjusted_value)
- {
- /* Counter hits 1, output goes low */
- timer->phase = 3;
- set_output(timer, 0);
- }
- }
-
- if (elapsed_cycles > 0 && timer->phase == 3)
- {
- /* Reload counter, output goes high */
- elapsed_cycles -= adjusted_value;
- timer->phase = 2;
- load_counter_value(timer);
- adjusted_value = adjusted_count(bcd, timer->value);
- set_output(timer, 1);
- }
- }
- while (elapsed_cycles >= adjusted_value);
-
- /* Calculate counter value */
- decrease_counter_value(timer, elapsed_cycles);
-
- switch (timer->phase)
- {
- case 1: cycles_to_output = 1; break;
- default: cycles_to_output = (timer->value == 1) ? 1 : (adjusted_count(bcd, timer->value) - 1); break;
- }
- }
- break;
-
-
- case 3:
- /* Mode 3: (Square Wave Generator)
-
- ----------------+ +-----------+ +----
- | | | |
- +-----------+ +-----------+
- <- (n+1)/2 -X- n/2 ->
- ^
- +- counter load or trigger
-
- phase|output|length |value|next|comment
- -----+------+--------+-----+----+----------------------------------
- 0|high |infinity| |1 |waiting for count
- 1|high |1 | |2 |internal delay to load counter
- 2|high |n/2(+1) |n..0 |3 |counting down double speed, reload counter
- 3|low |n/2 |n..0 |2 |counting down double speed, reload counter
-
- Counter rewrite has no effect until repeated (output falling or rising)
-
- Gate rising-edge and level sensitive.
- Gate low disables counting and sets output immediately high.
- Rising-edge reloads count and initiates counting
- Gate high enables counting. */
-
- if (timer->gate == 0 || timer->phase == 0)
- {
- /* Gate low or mode control write forces output high */
- set_output(timer, 1);
- cycles_to_output = CYCLES_NEVER;
- }
- else
- {
- if (elapsed_cycles >= 0 && timer->phase == 1)
- {
- if (elapsed_cycles > 0)
- {
- --elapsed_cycles;
- timer->phase = 2;
- }
- load_counter_value(timer);
- }
-
- if (elapsed_cycles > 0)
- {
- adjusted_value = adjusted_count(bcd, timer->value);
-
- do
- {
- if (timer->phase == 2 && elapsed_cycles >= ((adjusted_value + 1) >> 1))
- {
- /* High phase expired, output goes low */
- elapsed_cycles -= ((adjusted_value + 1) >> 1);
- timer->phase = 3;
- load_counter_value(timer);
- adjusted_value = adjusted_count(bcd, timer->value);
- set_output(timer, 0);
- }
-
- if (timer->phase == 3 && elapsed_cycles >= (adjusted_value >> 1))
- {
- /* Low phase expired, output goes high */
- elapsed_cycles -= (adjusted_value >> 1);
- timer->phase = 2;
- load_counter_value(timer);
- adjusted_value = adjusted_count(bcd, timer->value);
- set_output(timer, 1);
- }
- }
- while ((timer->phase == 2 && elapsed_cycles >= ((adjusted_value + 1) >> 1)) ||
- (timer->phase == 3 && elapsed_cycles >= (adjusted_value >> 1)));
-
- decrease_counter_value(timer, elapsed_cycles * 2);
-
- switch (timer->phase)
- {
- case 1: cycles_to_output = 1; break;
- case 2: cycles_to_output = (adjusted_count(bcd, timer->value) + 1) >> 1; break;
- case 3: cycles_to_output = adjusted_count(bcd, timer->value) >> 1; break;
- }
- }
- }
- break;
-
-
- case 4:
- case 5:
- /* Mode 4: (Software Trigger Strobe)
- Mode 5: (Hardware Trigger Strobe)
-
- --------------+ +--------------------
- | |
- +-+
- <- n+1 ->
- ^ <1>
- +- counter load (mode 4) or trigger (mode 5)
-
- phase|output|length |value|next|comment
- -----+------+--------+-----+----+----------------------------------
- 0|high |infinity|0..1 |0 |waiting for count/counting down
- 1|high |1 | |2 |internal delay when counter loaded
- 2|high |n |n..1 |3 |counting down
- 3|low |1 |0 |0 |strobe
-
- Mode 4 only: counter rewrite loads new counter
- Mode 5 only: count not reloaded immediately.
- Mode control write doesn't stop count but sets output high
-
- Mode 4 only: Gate level sensitive only. Low disables counting, high enables it.
- Mode 5 only: Gate rising-edge sensitive only. Rising edge initiates counting */
-
- if (timer->gate == 0 && mode == 4)
- {
- cycles_to_output = CYCLES_NEVER;
- }
- else
- {
- if (elapsed_cycles >= 0 && timer->phase == 1)
- {
- if (elapsed_cycles > 0)
- {
- --elapsed_cycles;
- timer->phase = 2;
- }
- load_counter_value(timer);
- }
-
- if (timer->value == 0 && timer->phase == 2)
- adjusted_value = 0;
- else
- adjusted_value = adjusted_count(bcd, timer->value);
-
- if (timer->phase == 2 && elapsed_cycles >= adjusted_value)
- {
- /* Counter has hit zero, set output to low */
- elapsed_cycles -= adjusted_value;
- timer->phase = 3;
- timer->value = 0;
- set_output(timer, 0);
- }
-
- if (elapsed_cycles > 0 && timer->phase == 3)
- {
- --elapsed_cycles;
- timer->phase = 0;
- decrease_counter_value(timer, 1);
- set_output(timer, 1);
- }
-
- decrease_counter_value(timer, elapsed_cycles);
-
- switch (timer->phase)
- {
- case 1: cycles_to_output = 1; break;
- case 2: cycles_to_output = adjusted_count(bcd, timer->value); break;
- case 3: cycles_to_output = 1; break;
- }
- }
- break;
- }
-
- if (cycles_to_output == CYCLES_NEVER || timer->clockin == 0)
- {
- timer->updatetimer->adjust(attotime::never, timer->index);
- }
- else
- {
- attotime next_fire_time = timer->last_updated + cycles_to_output * attotime::from_hz(timer->clockin);
-
- timer->updatetimer->adjust(next_fire_time - machine().time(), timer->index);
- }
-
- LOG2(("pit8253: simulate2(): simulating %d cycles for %d in mode %d, bcd = %d, phase = %d, gate = %d, output %d, value = 0x%04x, cycles_to_output = %04x\n",
- (int)elapsed_cycles, timer->index, mode, bcd, timer->phase, timer->gate, timer->output, timer->value, cycles_to_output));
-}
-
-
-/* This emulates timer "timer" for "elapsed_cycles" cycles, broken down into
- sections punctuated by callbacks. */
-void pit8253_device::simulate(pit8253_timer *timer, INT64 elapsed_cycles)
-{
- if (elapsed_cycles > 0)
- simulate2(timer, elapsed_cycles);
- else if (timer->clockin)
- timer->updatetimer->adjust(attotime::from_hz(timer->clockin), timer->index);
-}
-
-
-/* This brings timer "timer" up to date */
-void pit8253_device::update(pit8253_timer *timer)
-{
- /* With the 82C54's maximum clockin of 10MHz, 64 bits is nearly 60,000
- years of time. Should be enough for now. */
- attotime now = machine().time();
- attotime elapsed_time = now - timer->last_updated;
- INT64 elapsed_cycles = elapsed_time.as_double() * timer->clockin;
-
- LOG1(("pit8253: update(): timer %d, %" I64FMT "d elapsed_cycles\n", timer->index, elapsed_cycles));
-
- if (timer->clockin)
- timer->last_updated += elapsed_cycles * attotime::from_hz(timer->clockin);
- else
- timer->last_updated = now;
-
- simulate(timer, elapsed_cycles);
-}
-
-
-/* We recycle bit 0 of timer->value to hold the phase in mode 3 when count is
- odd. Since read commands in mode 3 always return even numbers, we need to
- mask this bit off. */
-UINT16 pit8253_device::masked_value(pit8253_timer *timer)
-{
- LOG2(("pit8253: masked_value\n"));
- if (CTRL_MODE(timer->control) == 3)
- return timer->value & 0xfffe;
- return timer->value;
-}
-
-/* Reads only affect the following bits of the counter state:
- latched_status
- latched_count
- rmsb
- so they don't affect any timer operations except other reads. */
-READ8_MEMBER( pit8253_device::read )
-{
- pit8253_timer *timer = get_timer(offset);
- UINT8 data;
- UINT16 value;
-
- LOG2(("pit8253_r(): offset %d\n", offset));
-
- if (timer == NULL)
- {
- /* Reading mode control register is illegal according to docs */
- /* Experimentally determined: reading it returns 0 */
- data = 0;
- }
- else
- {
- update(timer);
-
- if (timer->latched_status)
- {
- /* Read status register (8254 only) */
- data = timer->status;
- timer->latched_status = 0;
- }
- else
- {
- if (timer->latched_count != 0)
- {
- /* Read back latched count */
- data = (timer->latch >> (timer->rmsb ? 8 : 0)) & 0xff;
- timer->rmsb = 1 - timer->rmsb;
- --timer->latched_count;
- }
- else
- {
- value = masked_value(timer);
-
- /* Read back current count */
- switch (CTRL_ACCESS(timer->control))
- {
- case 0:
- default:
- /* This should never happen */
- data = 0; /* Appease compiler */
- break;
-
- case 1:
- /* read counter bits 0-7 only */
- data = (value >> 0) & 0xff;
- break;
-
- case 2:
- /* read counter bits 8-15 only */
- data = (value >> 8) & 0xff;
- break;
-
- case 3:
- /* read bits 0-7 first, then 8-15 */
- data = (value >> (timer->rmsb ? 8 : 0)) & 0xff;
- timer->rmsb = 1 - timer->rmsb;
- break;
- }
- }
- }
- }
-
- LOG2(("pit8253: read(): offset=%d data=0x%02x\n", offset, data));
- return data;
-}
-
-
-/* Loads a new value from the bus to the count register (CR) */
-void pit8253_device::load_count(pit8253_timer *timer, UINT16 newcount)
-{
- int mode = CTRL_MODE(timer->control);
- LOG1(("pit8253: load_count(): %04x\n", newcount));
-
- if (newcount == 1)
- {
- /* Count of 1 is illegal in modes 2 and 3. What happens here was
- determined experimentally. */
- if (mode == 2)
- newcount = 2;
- if (mode == 3)
- newcount = 0;
- }
-
- timer->count = newcount;
-
- if (mode == 2 || mode == 3)
- {
- if (timer->phase == 0)
- timer->phase = 1;
- }
- else
- {
- if (mode == 0 || mode == 4)
- timer->phase = 1;
- }
-}
-
-
-void pit8253_device::readback(pit8253_timer *timer, int command)
-{
- UINT16 value;
- update(timer);
-
- if ((command & 1) == 0)
- {
- /* readback status command */
- if (!timer->latched_status)
- {
- timer->status = (timer->control & 0x3f) | ((timer->output != 0) ? 0x80 : 0) | (timer->null_count ? 0x40 : 0);
- timer->latched_status = 1;
- }
- }
-
- /* Experimentally determined: the read latch command seems to have no
- effect if we're halfway through a 16-bit read */
- if ((command & 2) == 0 && !timer->rmsb)
- {
- /* readback count command */
- if (timer->latched_count == 0)
- {
- value = masked_value(timer);
- switch (CTRL_ACCESS(timer->control))
- {
- case 0:
- /* This should never happen */
- break;
-
- case 1:
- /* latch bits 0-7 only */
- timer->latch = ((value << 8) & 0xff00) | (value & 0xff);
- timer->latched_count = 1;
- break;
-
- case 2:
- /* read bits 8-15 only */
- timer->latch = (value & 0xff00) | ((value >> 8) & 0xff);
- timer->latched_count = 1;
- break;
-
- case 3:
- /* latch all 16 bits */
- timer->latch = value;
- timer->latched_count = 2;
- break;
- }
- }
- }
-}
-
-
-void pit8253_device::readback_command(UINT8 data)
-{
- /* Readback command. Illegal on 8253 */
- /* Todo: find out what (if anything) the 8253 hardware actually does here. */
-}
-
-void pit8254_device::readback_command(UINT8 data)
-{
- LOG1(("pit8253: write(): readback %02x\n", data & 0x3f));
-
- /* Bit 0 of data must be 0. Todo: find out what the hardware does if it isn't. */
- int read_command = (data >> 4) & 3;
- if ((data & 2) != 0)
- readback(get_timer(0), read_command);
- if ((data & 4) != 0)
- readback(get_timer(1), read_command);
- if ((data & 8) != 0)
- readback(get_timer(2), read_command);
-}
-
-void pit8253_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- update(get_timer(id));
-}
-
-WRITE8_MEMBER( pit8253_device::write )
-{
- pit8253_timer *timer = get_timer(offset);
-
- LOG2(("pit8253: write(): offset=%d data=0x%02x\n", offset, data));
-
- if (timer == NULL)
- {
- /* Write to mode control register */
- timer = get_timer((data >> 6) & 3);
- if (timer == NULL)
- {
- readback_command(data);
- return;
- }
-
- update(timer);
-
- if (CTRL_ACCESS(data) == 0)
- {
- LOG1(("pit8253: write(): timer=%d readback\n", (data >> 6) & 3));
-
- /* Latch current timer value */
- /* Experimentally verified: this command does not affect the mode control register */
- readback(timer, 1);
- }
- else
- {
- LOG1(("pit8253: write(): timer=%d bytes=%d mode=%d bcd=%d\n", (data >> 6) & 3, (data >> 4) & 3, (data >> 1) & 7, data & 1));
-
- timer->control = (data & 0x3f);
- timer->null_count = 1;
- timer->wmsb = timer->rmsb = 0;
- /* Phase 0 is always the phase after a mode control write */
- timer->phase = 0;
- set_output(timer, CTRL_MODE(timer->control) ? 1 : 0);
- }
- }
- else
- {
- int middle_of_a_cycle = 0;
-
- update(timer);
-
- if (machine().time() > timer->last_updated && timer->clockin != 0)
- middle_of_a_cycle = 1;
-
- switch (CTRL_ACCESS(timer->control))
- {
- case 0:
- /* This should never happen */
- break;
-
- case 1:
- /* read/write counter bits 0-7 only */
-
- /* check if we should compensate for not being on a cycle boundary */
- if (middle_of_a_cycle)
- timer->last_updated += attotime::from_hz(timer->clockin);
-
- load_count(timer, data);
- simulate2(timer, 0);
-
- if (CTRL_MODE(timer->control) == 0)
- {
- set_output(timer, 0);
- }
- break;
-
- case 2:
- /* read/write counter bits 8-15 only */
-
- /* check if we should compensate for not being on a cycle boundary */
- if (middle_of_a_cycle)
- timer->last_updated += attotime::from_hz(timer->clockin);
-
- load_count(timer, data << 8);
- simulate2(timer, 0);
- break;
-
- case 3:
- /* read/write bits 0-7 first, then 8-15 */
- if (timer->wmsb)
- {
- /* check if we should compensate for not being on a cycle boundary */
- if (middle_of_a_cycle)
- timer->last_updated += attotime::from_hz(timer->clockin);
-
- load_count(timer, timer->lowcount | (data << 8));
- simulate2(timer, 0);
- }
- else
- {
- timer->lowcount = data;
- if (CTRL_MODE(timer->control) == 0)
- {
- /* The Intel docs say that writing the MSB in mode 0, phase
- 2 won't stop the count, but this was experimentally
- determined to be false. */
- timer->phase = 0;
- set_output(timer, 0);
- }
- }
- timer->wmsb = 1 - timer->wmsb;
- break;
- }
- }
-}
-
-void pit8253_device::gate_w(int gate, int state)
-{
- pit8253_timer *timer = get_timer(gate);
-
- if (timer == NULL)
- return;
-
- LOG2(("pit8253 : gate_w(): gate=%d state=%d\n", gate, state));
-
- if (state != timer->gate)
- {
- int mode = CTRL_MODE(timer->control);
-
- update(timer);
- timer->gate = state;
- if (state != 0 && ( mode == 1 || mode == 2 || mode == 5 ))
- {
- timer->phase = 1;
- }
- update(timer);
- }
-}
-
-WRITE_LINE_MEMBER( pit8253_device::write_gate0 )
-{
- gate_w(0, state);
-}
-
-WRITE_LINE_MEMBER( pit8253_device::write_gate1 )
-{
- gate_w(1, state);
-}
-
-WRITE_LINE_MEMBER( pit8253_device::write_gate2 )
-{
- gate_w(2, state);
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-void pit8253_device::set_clockin(int timerno, double new_clockin)
-{
- pit8253_timer *timer = get_timer(timerno);
- assert(timer != NULL);
-
- LOG2(("pit8253_set_clockin(): PIT timer=%d, clockin = %f\n", timerno, new_clockin));
-
- update(timer);
- timer->clockin = new_clockin;
- update(timer);
-}
-
-
-void pit8253_device::set_clock_signal(int timerno, int state)
-{
- pit8253_timer *timer = get_timer(timerno);
- assert(timer != NULL);
-
- LOG2(("pit8253_set_clock_signal(): PIT timer=%d, state = %d\n", timerno, state));
-
- /* Trigger on low to high transition */
- if (!timer->clock && state)
- {
- /* Advance a cycle */
- simulate2(timer, 1);
- }
- timer->clock = state;
-}
-
-WRITE_LINE_MEMBER( pit8253_device::write_clk0 )
-{
- set_clock_signal(0, state);
-}
-
-WRITE_LINE_MEMBER( pit8253_device::write_clk1 )
-{
- set_clock_signal(1, state);
-}
-
-WRITE_LINE_MEMBER( pit8253_device::write_clk2 )
-{
- set_clock_signal(2, state);
-}
-
-#if (defined(__MINGW32__) && (__GNUC__ >= 5))
-#pragma GCC diagnostic pop
-#endif
diff --git a/src/emu/machine/pit8253.h b/src/emu/machine/pit8253.h
deleted file mode 100644
index 67e3f86b23b..00000000000
--- a/src/emu/machine/pit8253.h
+++ /dev/null
@@ -1,172 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol, Nathan Woods
-/***************************************************************************
-
- Intel 8253/8254
- Programmable Interval Timer
-
- As uPD71054C (8MHz), uPD71054C-10 (10MHz) - it is a clone of Intel 82C54
- also available in 28-pin QFP and 44-pin PLCC (many pins NC)
-
- _____ _____
- D7 1 |* \_/ | 24 VCC
- D6 2 | | 23 _WR
- D5 3 | | 22 _RD
- D4 4 | | 21 _CS
- D3 5 | | 20 A1
- D2 6 | 8253 | 19 A0
- D1 7 | 8254 | 18 CLK2
- D0 8 | | 17 OUT2
- CLK0 9 | | 16 GATE2
- OUT0 10 | | 15 CLK1
- GATE0 11 | | 14 GATE1
- GND 12 |_____________| 13 OUT1
-
-
-***************************************************************************/
-
-#ifndef __PIT8253_H__
-#define __PIT8253_H__
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_PIT8253_CLK0(_clk) \
- pit8253_device::set_clk0(*device, _clk);
-
-#define MCFG_PIT8253_CLK1(_clk) \
- pit8253_device::set_clk1(*device, _clk);
-
-#define MCFG_PIT8253_CLK2(_clk) \
- pit8253_device::set_clk2(*device, _clk);
-
-#define MCFG_PIT8253_OUT0_HANDLER(_devcb) \
- devcb = &pit8253_device::set_out0_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_PIT8253_OUT1_HANDLER(_devcb) \
- devcb = &pit8253_device::set_out1_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_PIT8253_OUT2_HANDLER(_devcb) \
- devcb = &pit8253_device::set_out2_handler(*device, DEVCB_##_devcb);
-
-
-class pit8253_device : public device_t
-{
-public:
- pit8253_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- pit8253_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
- ~pit8253_device() {}
-
- // static configuration helpers
- static void set_clk0(device_t &device, double clk0) { downcast<pit8253_device &>(device).m_clk0 = clk0; }
- static void set_clk1(device_t &device, double clk1) { downcast<pit8253_device &>(device).m_clk1 = clk1; }
- static void set_clk2(device_t &device, double clk2) { downcast<pit8253_device &>(device).m_clk2 = clk2; }
- template<class _Object> static devcb_base &set_out0_handler(device_t &device, _Object object) { return downcast<pit8253_device &>(device).m_out0_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_out1_handler(device_t &device, _Object object) { return downcast<pit8253_device &>(device).m_out1_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_out2_handler(device_t &device, _Object object) { return downcast<pit8253_device &>(device).m_out2_handler.set_callback(object); }
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- WRITE_LINE_MEMBER(write_gate0);
- WRITE_LINE_MEMBER(write_gate1);
- WRITE_LINE_MEMBER(write_gate2);
-
- /* In the 8253/8254 the CLKx input lines can be attached to a regular clock
- signal. Another option is to use the output from one timer as the input
- clock to another timer.
-
- The functions below should supply both functionalities. If the signal is
- a regular clock signal, use the pit8253_set_clockin function. If the
- CLKx input signal is the output of the different source, set the new_clockin
- to 0 with pit8253_set_clockin and call pit8253_clkX_w to change
- the state of the input CLKx signal.
- */
- WRITE_LINE_MEMBER(write_clk0);
- WRITE_LINE_MEMBER(write_clk1);
- WRITE_LINE_MEMBER(write_clk2);
-
- void set_clockin(int timer, double new_clockin);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // internal state
- struct pit8253_timer
- {
- int index; /* index number of the timer */
- double clockin; /* input clock frequency in Hz */
- int clock; /* clock signal when clockin is 0 */
-
- attotime last_updated; /* time when last updated */
-
- emu_timer *updatetimer; /* MAME timer to process updates */
-
- UINT16 value; /* current counter value ("CE" in Intel docs) */
- UINT16 latch; /* latched counter value ("OL" in Intel docs) */
- UINT16 count; /* new counter value ("CR" in Intel docs) */
- UINT8 control; /* 6-bit control byte */
- UINT8 status; /* status byte - 8254 only */
- UINT8 lowcount; /* LSB of new counter value for 16-bit writes */
- int rmsb; /* 1 = Next read is MSB of 16-bit value */
- int wmsb; /* 1 = Next write is MSB of 16-bit value */
- int output; /* 0 = low, 1 = high */
-
- int gate; /* gate input (0 = low, 1 = high) */
- int latched_count; /* number of bytes of count latched */
- int latched_status; /* 1 = status latched (8254 only) */
- int null_count; /* 1 = mode control or count written, 0 = count loaded */
- int phase; /* see phase definition tables in simulate2(), below */
- };
-
- void readback(pit8253_timer *timer, int command);
- virtual void readback_command(UINT8 data);
- pit8253_timer *get_timer(int which);
-
-private:
- double m_clk0;
- double m_clk1;
- double m_clk2;
- devcb_write_line m_out0_handler;
- devcb_write_line m_out1_handler;
- devcb_write_line m_out2_handler;
-
- enum
- {
- PIT8253_MAX_TIMER = 3
- };
-
- pit8253_timer m_timers[PIT8253_MAX_TIMER];
-
- inline UINT32 adjusted_count(int bcd, UINT16 val);
- void decrease_counter_value(pit8253_timer *timer, INT64 cycles);
- void load_counter_value(pit8253_timer *timer);
- void set_output(pit8253_timer *timer, int output);
- void simulate2(pit8253_timer *timer, INT64 elapsed_cycles);
- void simulate(pit8253_timer *timer, INT64 elapsed_cycles);
- void update(pit8253_timer *timer);
- UINT16 masked_value(pit8253_timer *timer);
- void load_count(pit8253_timer *timer, UINT16 newcount);
- void gate_w(int gate, int state);
- void set_clock_signal(int timerno, int state);
-};
-
-extern const device_type PIT8253;
-
-
-class pit8254_device : public pit8253_device
-{
-public:
- pit8254_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual void readback_command(UINT8 data);
-};
-
-extern const device_type PIT8254;
-
-#endif /* __PIT8253_H__ */
diff --git a/src/emu/machine/pla.c b/src/emu/machine/pla.c
deleted file mode 100644
index e8ca43d448f..00000000000
--- a/src/emu/machine/pla.c
+++ /dev/null
@@ -1,181 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder, hap
-/**********************************************************************
-
- PLA (Programmable Logic Array) emulation
-
-**********************************************************************/
-
-#include "pla.h"
-#include "jedparse.h"
-#include "plaparse.h"
-
-
-const device_type PLA = &device_creator<pla_device>;
-
-//-------------------------------------------------
-// pla_device - constructor
-//-------------------------------------------------
-
-pla_device::pla_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, PLA, "PLA", tag, owner, clock, "pla", __FILE__),
- m_format(PLA_FMT_JEDBIN),
- m_inputs(0),
- m_outputs(0),
- m_terms(0),
- m_input_mask(0),
- m_xor(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void pla_device::device_start()
-{
- assert(region() != NULL);
- assert(m_terms < MAX_TERMS);
- assert(m_inputs < 32 && m_outputs <= 32);
-
- if (m_input_mask == 0)
- m_input_mask = ((UINT64)1 << m_inputs) - 1;
- m_input_mask = ((UINT64)m_input_mask << 32) | m_input_mask;
-
- // parse fusemap
- parse_fusemap();
-
- // initialize cache
- m_cache2_ptr = 0;
- for (int i = 0; i < CACHE2_SIZE; i++)
- m_cache2[i] = 0x80000000;
-
- m_cache_size = 0;
- int csize = 1 << ((m_inputs > MAX_CACHE_BITS) ? MAX_CACHE_BITS : m_inputs);
- m_cache.resize(csize);
- for (int i = 0; i < csize; i++)
- m_cache[i] = read(i);
-
- m_cache_size = csize;
-}
-
-
-//-------------------------------------------------
-// parse_fusemap -
-//-------------------------------------------------
-
-void pla_device::parse_fusemap()
-{
- jed_data jed;
- int result = JEDERR_NONE;
-
- // read pla file
- switch (m_format)
- {
- case PLA_FMT_JEDBIN:
- result = jedbin_parse(region()->base(), region()->bytes(), &jed);
- break;
-
- case PLA_FMT_BERKELEY:
- result = pla_parse(region()->base(), region()->bytes(), &jed);
- break;
- }
-
- if (result != JEDERR_NONE)
- {
- for (int p = 0; p < m_terms; p++)
- {
- m_term[p].and_mask = 0;
- m_term[p].or_mask = 0;
- }
-
- logerror("%s PLA parse error %d!\n", tag(), result);
- return;
- }
-
- // parse it
- UINT32 fusenum = 0;
-
- for (int p = 0; p < m_terms; p++)
- {
- term *term = &m_term[p];
-
- // AND mask
- term->and_mask = 0;
-
- for (int i = 0; i < m_inputs; i++)
- {
- // complement
- term->and_mask |= (UINT64)jed_get_fuse(&jed, fusenum++) << (i + 32);
-
- // true
- term->and_mask |= (UINT64)jed_get_fuse(&jed, fusenum++) << i;
- }
-
- // OR mask
- term->or_mask = 0;
-
- for (int f = 0; f < m_outputs; f++)
- {
- term->or_mask |= !jed_get_fuse(&jed, fusenum++) << f;
- }
-
- term->or_mask <<= 32;
- }
-
- // XOR mask
- m_xor = 0;
-
- for (int f = 0; f < m_outputs; f++)
- {
- m_xor |= jed_get_fuse(&jed, fusenum++) << f;
- }
-
- m_xor <<= 32;
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-UINT32 pla_device::read(UINT32 input)
-{
- // try the cache first
- if (input < m_cache_size)
- return m_cache[input];
-
- for (int i = 0; i < CACHE2_SIZE; ++i)
- {
- UINT64 cache2_entry = m_cache2[i];
-
- if ((UINT32)cache2_entry == input)
- {
- // cache2 hit
- return cache2_entry >> 32;
- }
- }
-
- // cache miss, process terms
- UINT64 inputs = ((~(UINT64)input << 32) | input) & m_input_mask;
- UINT64 s = 0;
-
- for (int i = 0; i < m_terms; ++i)
- {
- term* term = &m_term[i];
-
- if ((term->and_mask | inputs) == m_input_mask)
- {
- s |= term->or_mask;
- }
- }
-
- s ^= m_xor;
-
- // store output in cache2
- m_cache2[m_cache2_ptr] = s | input;
- ++m_cache2_ptr &= (CACHE2_SIZE - 1);
-
- return s >> 32;
-}
diff --git a/src/emu/machine/pla.h b/src/emu/machine/pla.h
deleted file mode 100644
index 10dbc850370..00000000000
--- a/src/emu/machine/pla.h
+++ /dev/null
@@ -1,137 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder, hap
-/**********************************************************************
-
- PLA (Programmable Logic Array) emulation
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __PLA__
-#define __PLA__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define MAX_TERMS 512
-#define MAX_CACHE_BITS 20
-#define CACHE2_SIZE 8
-
-enum
-{
- PLA_FMT_JEDBIN = 0,
- PLA_FMT_BERKELEY
-};
-
-
-
-///*************************************************************************
-// INTERFACE CONFIGURATION MACROS
-///*************************************************************************
-
-#define MCFG_PLA_ADD(_tag, _inputs, _outputs, _terms) \
- MCFG_DEVICE_ADD(_tag, PLA, 0) \
- pla_device::set_num_inputs(*device, _inputs); \
- pla_device::set_num_outputs(*device, _outputs); \
- pla_device::set_num_terms(*device, _terms);
-
-#define MCFG_PLA_INPUTMASK(_mask) \
- pla_device::set_inputmask(*device, _mask);
-
-#define MCFG_PLA_FILEFORMAT(_format) \
- pla_device::set_format(*device, _format);
-
-
-// macros for known (and used) devices
-
-// 82S100, 82S101, PLS100, PLS101
-// 16x48x8 PLA, 28-pin:
-/* _____ _____
- FE 1 |* \_/ | 28 Vcc
- I7 2 | | 27 I8
- I6 3 | | 26 I9
- I5 4 | | 25 I10
- I4 5 | | 24 I11
- I3 6 | 82S100 | 23 I12
- I2 7 | 82S101 | 22 I13
- I1 8 | PLS100 | 21 I14
- I0 9 | PLS101 | 20 I15
- F7 10 | | 19 _CE
- F6 11 | | 18 F0
- F5 12 | | 17 F1
- F4 13 | | 16 F2
- GND 14 |_____________| 15 F3
-*/
-#define MCFG_PLS100_ADD(_tag) \
- MCFG_PLA_ADD(_tag, 16, 8, 48)
-
-// MOS 8721 PLA
-// TODO: actual number of terms is unknown
-#define MCFG_MOS8721_ADD(_tag) \
- MCFG_PLA_ADD(_tag, 27, 18, 379)
-
-
-
-///*************************************************************************
-// TYPE DEFINITIONS
-///*************************************************************************
-
-// ======================> pla_device
-
-class pla_device : public device_t
-{
-public:
- // construction/destruction
- pla_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- static void set_num_inputs(device_t &device, UINT32 i) { downcast<pla_device &>(device).m_inputs = i; }
- static void set_num_outputs(device_t &device, UINT32 o) { downcast<pla_device &>(device).m_outputs = o; }
- static void set_num_terms(device_t &device, UINT32 t) { downcast<pla_device &>(device).m_terms = t; }
- static void set_inputmask(device_t &device, UINT32 mask) { downcast<pla_device &>(device).m_input_mask = mask; } // UINT32!
- static void set_format(device_t &device, int format) { downcast<pla_device &>(device).m_format = format; }
-
- UINT32 inputs() { return m_inputs; }
- UINT32 outputs() { return m_outputs; }
-
- UINT32 read(UINT32 input);
-
-protected:
- // device-level overrides
- virtual void device_start();
-
-private:
- void parse_fusemap();
-
- int m_format;
-
- UINT32 m_inputs;
- UINT32 m_outputs;
- UINT32 m_terms;
- UINT64 m_input_mask;
- UINT64 m_xor;
-
- int m_cache_size;
- std::vector<UINT32> m_cache;
- UINT64 m_cache2[CACHE2_SIZE];
- UINT8 m_cache2_ptr;
-
- struct term
- {
- UINT64 and_mask;
- UINT64 or_mask;
- } m_term[MAX_TERMS];
-};
-
-
-// device type definition
-extern const device_type PLA;
-
-
-#endif
diff --git a/src/emu/machine/r10696.c b/src/emu/machine/r10696.c
deleted file mode 100644
index ab20caed731..00000000000
--- a/src/emu/machine/r10696.c
+++ /dev/null
@@ -1,185 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Juergen Buchmueller
-/**********************************************************************
-
- Rockwell 10696 General Purpose Input/Output (I/O)
-
- REGISTER DESCRIPTION
-
- HEX Address Select Names
- -------------------------------------------------------
- A x x x x 1 0 1 0 Read Group A
- 9 x x x x 1 0 0 1 Read Group B
- 3 x x x x 0 0 1 1 Read Group C
- 0 x x x x 0 0 0 0 Read Groups A | B | C
- 1 x x x x 0 0 0 1 Read Groups B | C
- 2 x x x x 0 0 1 0 Read Groups A | C
- 8 x x x x 1 0 0 0 Read Groups A | B
-
- E x x x x 1 1 1 0 Set Group A
- D x x x x 1 1 0 1 Set Group B
- 7 x x x x 0 1 1 1 Set Group C
- 4 x x x x 0 1 0 0 Set Groups A, B and C
- 5 x x x x 0 1 0 1 Set Groups B and C
- 6 x x x x 0 1 1 0 Set Groups A and C
- C x x x x 1 1 0 0 Set Groups A and B
-
- Notes:
- Any of the I/O chips may be used to read or set any group
- (A, B, C) or combination of groups.
-**********************************************************************/
-
-#include "emu.h"
-#include "machine/r10696.h"
-
-#define VERBOSE 1
-#if VERBOSE
-#define LOG(x) logerror x
-#else
-#define LOG(x)
-#endif
-
-/*************************************
- *
- * Device interface
- *
- *************************************/
-
-const device_type R10696 = &device_creator<r10696_device>;
-
-r10696_device::r10696_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, R10696, "Rockwell 10696", tag, owner, clock, "r10696", __FILE__),
- m_io_a(0), m_io_b(0), m_io_c(0),
- m_iord(*this), m_iowr(*this)
-{
-}
-
-/**
- * @brief r10696_device::device_start device-specific startup
- */
-void r10696_device::device_start()
-{
- m_iord.resolve();
- m_iowr.resolve();
-
- save_item(NAME(m_io_a));
- save_item(NAME(m_io_b));
- save_item(NAME(m_io_c));
-}
-
-/**
- * @brief r10696_device::device_reset device-specific reset
- */
-void r10696_device::device_reset()
-{
- m_io_a = 0;
- m_io_b = 0;
- m_io_c = 0;
-}
-
-/*************************************
- *
- * Command access handlers
- *
- *************************************/
-
-WRITE8_MEMBER( r10696_device::io_w )
-{
- assert(offset < 16);
- const UINT8 io_a = m_io_a;
- const UINT8 io_b = m_io_b;
- const UINT8 io_c = m_io_c;
- switch (offset)
- {
- case 0x0A: // Read Group A
- case 0x09: // Read Group B
- case 0x03: // Read Group C
- case 0x00: // Read Groups A | B | C
- case 0x01: // Read Groups B | C
- case 0x02: // Read Groups A | C
- case 0x08: // Read Groups A | B
- break;
-
- case 0x0E: // Set Group A
- m_io_a = data & 0x0f;
- break;
- case 0x0D: // Set Group B
- m_io_b = data & 0x0f;
- break;
- case 0x07: // Set Group C
- m_io_c = data & 0x0f;
- break;
- case 0x04: // Set Groups A, B and C
- m_io_a = m_io_b = m_io_c = data & 0x0f;
- break;
- case 0x05: // Set Groups B and C
- m_io_b = m_io_c = data & 0x0f;
- break;
- case 0x06: // Set Groups A and C
- m_io_a = m_io_c = data & 0x0f;
- break;
- case 0x0C: // Set Groups A and B
- m_io_a = m_io_b = data & 0x0f;
- break;
- }
- if (io_a != m_io_a)
- m_iowr(0, m_io_a, 0x0f);
- if (io_b != m_io_b)
- m_iowr(1, m_io_b, 0x0f);
- if (io_c != m_io_c)
- m_iowr(2, m_io_c, 0x0f);
-}
-
-
-READ8_MEMBER( r10696_device::io_r )
-{
- assert(offset < 16);
- UINT8 io_a, io_b, io_c;
- UINT8 data = 0xf;
- switch (offset)
- {
- case 0x0A: // Read Group A
- io_a = m_iord(0);
- data = io_a & 0x0f;
- break;
- case 0x09: // Read Group B
- io_b = m_iord(1);
- data = io_b & 0x0f;
- break;
- case 0x03: // Read Group C
- io_c = m_iord(2);
- data = io_c & 0x0f;
- break;
- case 0x00: // Read Groups A | B | C
- io_a = m_iord(0);
- io_b = m_iord(1);
- io_c = m_iord(2);
- data = (io_a | io_b | io_a) & 0x0f;
- break;
- case 0x01: // Read Groups B | C
- io_b = m_iord(1);
- io_c = m_iord(2);
- data = (io_b | io_c) & 0x0f;
- break;
- case 0x02: // Read Groups A | C
- io_a = m_iord(0);
- io_c = m_iord(2);
- data = (io_a | io_c) & 0x0f;
- break;
- case 0x08: // Read Groups A | B
- io_a = m_iord(0);
- io_b = m_iord(1);
- data = (io_a | io_b) & 0x0f;
- break;
-
- case 0x0E: // Set Group A
- case 0x0D: // Set Group B
- case 0x07: // Set Group C
- case 0x04: // Set Groups A, B and C
- case 0x05: // Set Groups B and C
- case 0x06: // Set Groups A and C
- case 0x0C: // Set Groups A and B
- break;
- }
- return data;
-}
diff --git a/src/emu/machine/r10696.h b/src/emu/machine/r10696.h
deleted file mode 100644
index ca3b87c935e..00000000000
--- a/src/emu/machine/r10696.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Juergen Buchmueller
-/**********************************************************************
-
- Rockwell 10696 General Purpose Input/Output (I/O)
-
- Juergen Buchmueller <pullmoll@t-online.de>
-
- The device decodes reads/write to a 16 byte I/O range defined
- by four wired inputs SC1, SC2, SC3 and SC4.
- It provides 12 inputs and 12 outputs in groups of three
- time 4 bits each.
-
-**********************************************************************/
-
-#ifndef __R10696_H__
-#define __R10696_H__
-
-#include "device.h"
-
-/*************************************
- *
- * Device configuration macros
- *
- *************************************/
-
-/* Set the read and write group (4-bit; nibble) delegates */
-#define MCFG_R10696_IO(_devcb_rd,_devcb_wr) \
- r10696_device::set_iord(*device, DEVCB_##_devcb_rd); \
- r10696_device::set_iowr(*device, DEVCB_##_devcb_wr);
-
-class r10696_device : public device_t
-{
-public:
- r10696_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~r10696_device() {}
-
- DECLARE_READ8_MEMBER ( io_r );
- DECLARE_WRITE8_MEMBER( io_w );
-
- template<class _Object> static devcb_base &set_iord(device_t &device, _Object object) { return downcast<r10696_device &>(device).m_iord.set_callback(object); }
- template<class _Object> static devcb_base &set_iowr(device_t &device, _Object object) { return downcast<r10696_device &>(device).m_iowr.set_callback(object); }
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- UINT8 m_io_a; //!< input/output flip-flops group A
- UINT8 m_io_b; //!< input/output flip-flops group B
- UINT8 m_io_c; //!< input/output flip-flops group C
- devcb_read8 m_iord; //!< input line (read, offset = group, data = 4 bits)
- devcb_write8 m_iowr; //!< output line (write, offset = group, data = 4 bits)
-};
-
-extern const device_type R10696;
-
-#endif /* __R10696_H__ */
diff --git a/src/emu/machine/r10788.c b/src/emu/machine/r10788.c
deleted file mode 100644
index f6e9d65ecbf..00000000000
--- a/src/emu/machine/r10788.c
+++ /dev/null
@@ -1,226 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Juergen Buchmueller
-/**********************************************************************
-
- Rockwell 10788 General Purpose Keyboard and Display circuit
-
- REGISTER DESCRIPTION
-
-
- [ Opcodes IOL, I2 ]
- NAME W/IO CS I/O CMD I/O Names
- --------------------------------------------------------------
- KTR 1 1 x x x 1 1 0 0 Transfer Keyboard Return
- KTS 1 1 x x x 1 0 1 0 Transfer Keyboard Strobe
- KLA 1 1 x x x 1 1 1 0 Load Display Register A
- KLB 1 1 x x x 1 1 0 1 Load Display Register A
- KDN 1 1 x x x 0 0 1 1 Turn On Display
- KAF 1 1 x x x 1 0 1 1 Turn Off A
- KBF 1 1 x x x 0 1 1 1 Turn Off B
- KER 1 1 x x x 0 1 1 0 Reset Keyboard Error
-
- Notes:
- 1.) W/IO is generated by the first word of the PPS IOL instruction.
- 2.) Polarities of I/O7, I/O6 and I/O5 must be the same as the
- polarities of the chip select straps SC7, SC6 and SC5.
- 3.) KLA resets DA1-DA4 and DB1 and DB2 to VSS level. KLB resets
- DB3 and DB4 to VSS level.
- 4.) KAF and KBF is used to blank the display without changing the
- contents of display data registers.
- 5.) KAF resets output lines DA1, DA2, DA3, DA4, DB1 and DB2 to
- VSS level. KBF resets output lines DB3 and DB4 to VSS level.
- 6.) KAF stops the circulation of the display register A, and KBF
- stops the circulation of the display register B.
- 7.) KER takes a maximum of 10-bit times to complete (= 80 clocks)
- Therefore, there must be at least 10 bit times between KER
- and the next KTS instruction.
-**********************************************************************/
-
-#include "emu.h"
-#include "machine/r10788.h"
-
-#define VERBOSE 0
-#if VERBOSE
-#define LOG(x) logerror x
-#else
-#define LOG(x)
-#endif
-
-/*************************************
- *
- * Device interface
- *
- *************************************/
-
-const device_type R10788 = &device_creator<r10788_device>;
-
-r10788_device::r10788_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, R10788, "Rockwell 10788", tag, owner, clock, "r10788", __FILE__),
- m_ktr(0), m_kts(0), m_kla(0), m_klb(0), m_mask_a(15), m_mask_b(15), m_ker(0),
- m_io_counter(0), m_scan_counter(0),
- m_display(*this)
-{
-}
-
-/**
- * @brief r10788_device::device_start device-specific startup
- */
-void r10788_device::device_start()
-{
- m_display.resolve();
-
- save_item(NAME(m_reg));
- save_item(NAME(m_ktr));
- save_item(NAME(m_kts));
- save_item(NAME(m_kla));
- save_item(NAME(m_klb));
- save_item(NAME(m_mask_a));
- save_item(NAME(m_mask_b));
- save_item(NAME(m_ker));
- save_item(NAME(m_io_counter));
- save_item(NAME(m_scan_counter));
-
- m_timer = timer_alloc(TIMER_DISPLAY);
- // recurring timer every 36 cycles
- m_timer->adjust(clocks_to_attotime(36), 0, clocks_to_attotime(36));
-}
-
-/**
- * @brief r10788_device::device_reset device-specific reset
- */
-void r10788_device::device_reset()
-{
- memset(m_reg, 0x00, sizeof(m_reg));
- m_ktr = 0;
- m_kts = 0;
- m_kla = 0;
- m_klb = 0;
- m_mask_a = 15;
- m_mask_b = 15;
- m_ker = 0;
- m_scan_counter = 0;
-}
-
-
-/**
- * @brief r10788_device::device_timer timer event callback
- * @param timer emu_timer which fired
- * @param id timer identifier
- * @param param parameter
- * @param ptr pointer parameter
- */
-void r10788_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- UINT8 data;
- switch (id)
- {
- case TIMER_DISPLAY:
- data = (m_reg[0][m_scan_counter] & m_mask_a) +
- 16 * (m_reg[1][m_scan_counter] & m_mask_b);
- LOG(("%s: scan counter:%2d data:%02x\n", __FUNCTION__, m_scan_counter, data));
- m_display(m_scan_counter, data, 0xff);
- break;
- default:
- LOG(("%s: invalid timer id:%d\n", __FUNCTION__, id));
- }
- m_scan_counter = (m_scan_counter + 1) % 16;
-}
-
-/*************************************
- *
- * Constants
- *
- *************************************/
-
-/*************************************
- *
- * Command access handlers
- *
- *************************************/
-
-WRITE8_MEMBER( r10788_device::io_w )
-{
- assert(offset < 16);
- switch (offset)
- {
- case KTR: // Transfer Keyboard Return
- LOG(("%s: KTR data:%02x\n", __FUNCTION__, data));
- m_ktr = data;
- break;
- case KTS: // Transfer Keyboard Strobe
- LOG(("%s: KTS data:%02x\n", __FUNCTION__, data));
- m_kts = data;
- break;
- case KLA: // Load Display Register A
- LOG(("%s: KLA [%2d] data:%02x\n", __FUNCTION__, m_io_counter, data));
- m_kla = data;
- m_reg[0][m_io_counter] = m_kla;
- break;
- case KLB: // Load Display Register B
- LOG(("%s: KLB [%2d] data:%02x\n", __FUNCTION__, m_io_counter, data));
- m_klb = data;
- m_reg[1][m_io_counter] = m_kla;
- break;
- case KDN: // Turn On Display
- LOG(("%s: KDN data:%02x\n", __FUNCTION__, data));
- m_mask_a = 15;
- m_mask_b = 15;
- break;
- case KAF: // Turn Off A
- LOG(("%s: KAF data:%02x\n", __FUNCTION__, data));
- m_mask_a = 0;
- m_mask_b &= ~3;
- break;
- case KBF: // Turn Off B
- LOG(("%s: KBF data:%02x\n", __FUNCTION__, data));
- m_mask_b &= ~12;
- break;
- case KER: // Reset Keyboard Error
- LOG(("%s: KER data:%02x\n", __FUNCTION__, data));
- m_ker = 10;
- break;
- }
-}
-
-
-READ8_MEMBER( r10788_device::io_r )
-{
- assert(offset < 16);
- UINT8 data = 0xf;
- switch (offset)
- {
- case KTR: // Transfer Keyboard Return
- data = m_ktr;
- LOG(("%s: KTR data:%02x\n", __FUNCTION__, data));
- break;
- case KTS: // Transfer Keyboard Strobe
- data = m_kts;
- LOG(("%s: KTS data:%02x\n", __FUNCTION__, data));
- break;
- case KLA: // Load Display Register A
- m_kla = m_reg[0][m_io_counter];
- data = m_kla;
- LOG(("%s: KLA [%2d] data:%02x\n", __FUNCTION__, m_io_counter, data));
- break;
- case KLB: // Load Display Register B
- m_klb = m_reg[1][m_io_counter];
- data = m_klb;
- LOG(("%s: KLB [%2d] data:%02x\n", __FUNCTION__, m_io_counter, data));
- // FIXME: does it automagically increment at KLB write?
- m_io_counter = (m_io_counter + 1) % 16;
- break;
- case KDN: // Turn On Display
- LOG(("%s: KDN data:%02x\n", __FUNCTION__, data));
- break;
- case KAF: // Turn Off A
- LOG(("%s: KAF data:%02x\n", __FUNCTION__, data));
- break;
- case KBF: // Turn Off B
- LOG(("%s: KBF data:%02x\n", __FUNCTION__, data));
- break;
- case KER: // Reset Keyboard Error
- LOG(("%s: KER data:%02x\n", __FUNCTION__, data));
- break;
- }
- return data;
-}
diff --git a/src/emu/machine/r10788.h b/src/emu/machine/r10788.h
deleted file mode 100644
index af58aca65c7..00000000000
--- a/src/emu/machine/r10788.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Juergen Buchmueller
-/**********************************************************************
-
- Rockwell 10788 General Purpose Keyboard and Display circuit
-
- Juergen Buchmueller <pullmoll@t-online.de>
-
- The device decodes reads/write to a 16 byte I/O range defined
- by three wired inputs SC5, SC6 and SC7. The range is one of
- 80-8f, 90-9f, ..., f0-ff depending on the wiring.
-
-**********************************************************************/
-
-#ifndef __R10788_H__
-#define __R10788_H__
-
-#include "device.h"
-
-/*************************************
- *
- * Device configuration macros
- *
- *************************************/
-
-/* Set the writer used to update a display digit */
-#define MCFG_R10788_UPDATE(_devcb) \
- r10788_device::set_update(*device, DEVCB_##_devcb);
-
-class r10788_device : public device_t
-{
-public:
- r10788_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~r10788_device() {}
-
- enum {
- KTR = 0xc, //!< Transfer Keyboard Return
- KTS = 0xa, //!< Transfer Keyboard Strobe
- KLA = 0xe, //!< Load Display Register A
- KLB = 0xd, //!< Load Display Register B
- KDN = 0x3, //!< Turn On Display
- KAF = 0xb, //!< Turn Off A
- KBF = 0x7, //!< Turn Off B
- KER = 0x6 //!< Reset Keyboard Error
- };
-
- DECLARE_READ8_MEMBER ( io_r );
- DECLARE_WRITE8_MEMBER( io_w );
-
- template<class _Object> static devcb_base &set_update(device_t &device, _Object object) { return downcast<r10788_device &>(device).m_display.set_callback(object); }
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- static const device_timer_id TIMER_DISPLAY = 0;
-
- UINT8 m_reg[2][16]; //!< display registers
- UINT8 m_ktr; //!< transfer keyboard return value
- UINT8 m_kts; //!< transfer keyboard strobe value
- UINT8 m_kla; //!< display register A value
- UINT8 m_klb; //!< display register B value
- UINT8 m_mask_a; //!< display enable bits for A
- UINT8 m_mask_b; //!< display enable bits for B
- UINT8 m_ker; //!< keyboard error value
- int m_io_counter; //!< current I/O register index
- int m_scan_counter; //!< current display scan
- devcb_write8 m_display; //!< display updater
- emu_timer* m_timer; //!< timer running at clock / 18 / 36
-};
-
-extern const device_type R10788;
-
-#endif /* __R10788_H__ */
diff --git a/src/emu/machine/ra17xx.c b/src/emu/machine/ra17xx.c
deleted file mode 100644
index c1252181c7d..00000000000
--- a/src/emu/machine/ra17xx.c
+++ /dev/null
@@ -1,131 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Juergen Buchmueller
-/**********************************************************************
-
- Rockwell A17XX ROM, RAM and I/O chip
-
- A ROM of 2048 x 8 bits is addressed whenever the RRSEL line
- (ROM/RAM select) is 0. A RAM of 128 x 4 bit is addressed when
- RRSEL is 1. The 16 I/O ports are addressed when the WI/O line
- is 1, i.e. whenever the CPU executes an IOL instruction.
- There are two basic I/O instructions:
- SES = Select Enable Status and SOS = Select Output Status
- The lower 4 bits of the I/O address select one of 16 I/O lines.
-
- There are at most two A17XX per system, one for the lower
- ROM and RAM portion and one for the higher.
-
- I/O section instructions
-
- Menmonic I/O bus Accu Description
- ------------------------------------------------------------------
- SES 0 S S 0 X X X 0 1 X X X Enable all outputs
- Acuu:3 <- I/O(BL)
- ------------------------------------------------------------------
- SES 0 S S 0 X X X 0 0 X X X Disable all outputs
- Acuu:3 <- I/O(BL)
- ------------------------------------------------------------------
- SOS 0 S S 0 X X X 1 1 X X X I/O(BL) <- 1
- Acuu:3 <- I/O(BL)
- ------------------------------------------------------------------
- SOS 0 S S 0 X X X 1 0 X X X I/O(BL) <- 0
- Acuu:3 <- I/O(BL)
-
- This device emulation takes care of the I/O commands, not the
- ROM and RAM, because these are emulated using the generic MAME
- memory system.
-**********************************************************************/
-
-#include "emu.h"
-#include "machine/ra17xx.h"
-
-#define VERBOSE 1
-#if VERBOSE
-#define LOG(x) logerror x
-#else
-#define LOG(x)
-#endif
-
-/*************************************
- *
- * Device interface
- *
- *************************************/
-
-const device_type RA17XX = &device_creator<ra17xx_device>;
-
-ra17xx_device::ra17xx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, RA17XX, "Rockwell A17XX", tag, owner, clock, "ra17xx", __FILE__),
- m_enable(false),
- m_iord(*this),
- m_iowr(*this)
-{
-}
-
-/**
- * @brief ra17xx_device::device_start device-specific startup
- */
-void ra17xx_device::device_start()
-{
- m_iord.resolve();
- m_iowr.resolve();
-
- save_item(NAME(m_line));
-}
-
-/**
- * @brief ra17xx_device::device_reset device-specific reset
- */
-void ra17xx_device::device_reset()
-{
- memset(m_line, 0, sizeof(m_line));
-}
-
-
-/*************************************
- *
- * Constants
- *
- *************************************/
-
-/*************************************
- *
- * Command access handlers
- *
- *************************************/
-
-WRITE8_MEMBER( ra17xx_device::io_w )
-{
- assert(offset < 16);
- m_bl = (data >> 4) & 15; // BL on the data bus most significant bits
- if (offset & 1) {
- // SOS command
- if (data & (1 << 3)) {
- m_line[m_bl] = 1; // enable output
-// if (m_enable)
- m_iowr(m_bl, 1, 1);
- } else {
- m_line[m_bl] = 0; // disable output
-// if (m_enable)
- m_iowr(m_bl, 0, 1);
- }
- } else {
- // SES command
- if (data & (1 << 3)) {
- // enable all outputs
- m_enable = true;
- for (int i = 0; i < 16; i++)
- m_iowr(i, m_line[i], 1);
- } else {
- // disable all outputs
- m_enable = false;
- }
- }
-}
-
-
-READ8_MEMBER( ra17xx_device::io_r )
-{
- assert(offset < 16);
- return (m_iord(m_bl) & 1) ? 0x0f : 0x07;
-}
diff --git a/src/emu/machine/ra17xx.h b/src/emu/machine/ra17xx.h
deleted file mode 100644
index 3ca8877d7de..00000000000
--- a/src/emu/machine/ra17xx.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Juergen Buchmueller
-/**********************************************************************
-
- Rockwell RA17xx (e.g. A1752, A1753) ROM, RAM and I/O chip
-
- Juergen Buchmueller <pullmoll@t-online.de>
-
- The device integrates a 2048 x 8 ROM, a 128 x 4 RAM and
- and 16 I/O ports at one of the port ranges 00 ... 0f,
- 20 ... 2f, 40 ... 4f or 60 ... 6f.
-
-**********************************************************************/
-
-#ifndef __RA17XX_H__
-#define __RA17XX_H__
-
-#include "device.h"
-
-/*************************************
- *
- * Device configuration macros
- *
- *************************************/
-
-/* Set the read line handler */
-#define MCFG_RA17XX_READ(_devcb) \
- ra17xx_device::set_iord(*device, DEVCB_##_devcb);
-/* Set the write line handler */
-#define MCFG_RA17XX_WRITE(_devcb) \
- ra17xx_device::set_iowr(*device, DEVCB_##_devcb);
-class ra17xx_device : public device_t
-{
-public:
- ra17xx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~ra17xx_device() {}
-
- DECLARE_READ8_MEMBER ( io_r );
- DECLARE_WRITE8_MEMBER( io_w );
-
- template<class _Object> static devcb_base &set_iord(device_t &device, _Object object) { return downcast<ra17xx_device &>(device).m_iord.set_callback(object); }
- template<class _Object> static devcb_base &set_iowr(device_t &device, _Object object) { return downcast<ra17xx_device &>(device).m_iowr.set_callback(object); }
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- UINT8 m_line[16]; //!< input/output flip-flops for 16 I/O lines
- UINT8 m_bl; //!< value of BL during the most recent output
- bool m_enable; //!< true if outputs are enabled
- devcb_read8 m_iord; //!< input line (read, offset = line, data = 0/1)
- devcb_write8 m_iowr; //!< output line (write, offset = line, data = 0/1)
-};
-
-extern const device_type RA17XX;
-
-#endif /* __RA17XX_H__ */
diff --git a/src/emu/machine/ram.c b/src/emu/machine/ram.c
deleted file mode 100644
index 3a92aa48c1b..00000000000
--- a/src/emu/machine/ram.c
+++ /dev/null
@@ -1,222 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/*************************************************************************
-
- RAM device
-
- Provides a configurable amount of RAM to drivers
-
-**************************************************************************/
-
-#include <stdio.h>
-#include <ctype.h>
-
-#include "emu.h"
-#include "emuopts.h"
-#include "ram.h"
-
-
-/*****************************************************************************
- LIVE DEVICE
-*****************************************************************************/
-
-// device type definition
-const device_type RAM = &device_creator<ram_device>;
-
-
-
-//-------------------------------------------------
-// ram_device - constructor
-//-------------------------------------------------
-
-ram_device::ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, RAM, "RAM", tag, owner, clock, "ram", __FILE__)
-{
- m_size = 0;
- m_default_size = NULL;
- m_extra_options = NULL;
- m_default_value = 0xCD;
-}
-
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void ram_device::device_start()
-{
- /* the device named 'ram' can get ram options from command line */
- m_size = 0;
- if (strcmp(tag(), ":" RAM_TAG) == 0)
- {
- const char *ramsize_string = machine().options().ram_size();
- if ((ramsize_string != NULL) && (ramsize_string[0] != '\0'))
- m_size = parse_string(ramsize_string);
- }
-
- /* if we didn't get a size yet, use the default */
- if (m_size == 0)
- m_size = default_size();
-
- /* allocate space for the ram */
- m_pointer.resize(m_size);
- memset(&m_pointer[0], m_default_value, m_size);
-
- /* register for state saving */
- save_item(NAME(m_size));
- save_item(NAME(m_pointer));
-}
-
-
-//-------------------------------------------------
-// device_validity_check - device-specific validity
-// checks
-//-------------------------------------------------
-
-void ram_device::device_validity_check(validity_checker &valid) const
-{
- const char *ramsize_string = NULL;
- int is_valid = FALSE;
- UINT32 specified_ram = 0;
- const char *gamename_option = NULL;
-
- /* verify default ram value */
- if (default_size() == 0)
- osd_printf_error("Invalid default RAM option: %s\n", m_default_size);
-
- /* command line options are only parsed for the device named RAM_TAG */
- if (tag() != NULL && strcmp(tag(), ":" RAM_TAG) == 0)
- {
- /* verify command line ram option */
- ramsize_string = mconfig().options().ram_size();
- gamename_option = mconfig().options().system_name();
-
- if ((ramsize_string != NULL) && (ramsize_string[0] != '\0'))
- {
- specified_ram = parse_string(ramsize_string);
-
- if (specified_ram == 0)
- osd_printf_error("Cannot recognize the RAM option %s\n", ramsize_string);
-
- if (gamename_option != NULL && *gamename_option != 0 && strcmp(gamename_option, mconfig().gamedrv().name) == 0)
- {
- /* compare command line option to default value */
- if (default_size() == specified_ram)
- is_valid = TRUE;
-
- /* verify extra ram options */
- if (m_extra_options != NULL)
- {
- int j;
- int size = strlen(m_extra_options);
- char * const s = core_strdup(m_extra_options);
- char * const e = s + size;
- char *p = s;
- for (j=0;j<size;j++) {
- if (p[j]==',') p[j]=0;
- }
-
- /* try to parse each option */
- while(p <= e)
- {
- UINT32 option_ram_size = parse_string(p);
-
- if (option_ram_size == 0)
- osd_printf_error("Invalid RAM option: %s\n", p);
-
- if (option_ram_size == specified_ram)
- is_valid = TRUE;
-
- p += strlen(p);
- if (p == e)
- break;
- p += 1;
- }
-
- osd_free(s);
- }
-
- } else {
- /* if not for this driver then return ok */
- is_valid = TRUE;
- }
- }
- else
- {
- /* not specifying the ramsize on the command line is valid as well */
- is_valid = TRUE;
- }
- }
- else
- is_valid = TRUE;
-
- if (!is_valid)
- {
- std::string output;
- strcatprintf(output, "Cannot recognize the RAM option %s", ramsize_string);
- strcatprintf(output, " (valid options are %s", m_default_size);
-
- if (m_extra_options != NULL)
- strcatprintf(output, ",%s).\n", m_extra_options);
- else
- strcatprintf(output, ").\n");
-
- osd_printf_error("%s", output.c_str());
-
- osd_printf_warning("Setting value to default %s\n",m_default_size);
- std::string error;
- mconfig().options().set_value(OPTION_RAMSIZE, m_default_size, OPTION_PRIORITY_CMDLINE, error);
- assert(error.empty());
- }
-}
-
-
-
-//-------------------------------------------------
-// parse_string - convert a ram string to an
-// integer value
-//-------------------------------------------------
-
-UINT32 ram_device::parse_string(const char *s)
-{
- UINT32 ram;
- char suffix = '\0';
-
- s += sscanf(s, "%u%c", &ram, &suffix);
-
- switch(tolower(suffix))
- {
- case 'k':
- /* kilobytes */
- ram *= 1024;
- break;
-
- case 'm':
- /* megabytes */
- ram *= 1024*1024;
- break;
-
- case '\0':
- /* no suffix */
- break;
-
- default:
- /* parse failure */
- ram = 0;
- break;
- }
-
- return ram;
-}
-
-
-
-//-------------------------------------------------
-// default_size
-//-------------------------------------------------
-
-UINT32 ram_device::default_size(void) const
-{
- return parse_string(m_default_size);
-}
diff --git a/src/emu/machine/ram.h b/src/emu/machine/ram.h
deleted file mode 100644
index c17832dff16..00000000000
--- a/src/emu/machine/ram.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
-/*************************************************************************
-
- RAM device
-
- Provides a configurable amount of RAM to drivers
-
-**************************************************************************/
-
-#ifndef __RAM_H__
-#define __RAM_H__
-
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-#define RAM_TAG "ram"
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_RAM_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, RAM, 0)
-
-#define MCFG_RAM_REMOVE(_tag) \
- MCFG_DEVICE_REMOVE(_tag)
-
-#define MCFG_RAM_MODIFY(_tag) \
- MCFG_DEVICE_MODIFY(_tag) \
- ram_device::static_set_extra_options(*device, NULL);
-
-#define MCFG_RAM_DEFAULT_SIZE(_default_size) \
- ram_device::static_set_default_size(*device, _default_size);
-
-#define MCFG_RAM_EXTRA_OPTIONS(_extra_options) \
- ram_device::static_set_extra_options(*device, _extra_options);
-
-#define MCFG_RAM_DEFAULT_VALUE(_default_value) \
- ram_device::static_set_default_value(*device, _default_value);
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-class ram_device : public device_t
-{
-public:
- // construction/destruction
- ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // accessors
- UINT32 size(void) const { return m_size; }
- UINT32 mask(void) const { return m_size - 1; }
- UINT8 *pointer(void) { return &m_pointer[0]; }
- static UINT32 parse_string(const char *s);
- UINT32 default_size(void) const;
- const char *extra_options(void) const { return m_extra_options; }
-
- // read/write
- UINT8 read(offs_t offset) { return m_pointer[offset % m_size]; }
- void write(offs_t offset, UINT8 data) { m_pointer[offset % m_size] = data; }
-
- // inline configuration helpers
- static void static_set_default_size(device_t &device, const char *default_size) { downcast<ram_device &>(device).m_default_size = default_size; }
- static void static_set_extra_options(device_t &device, const char *extra_options) { downcast<ram_device &>(device).m_extra_options = extra_options; }
- static void static_set_default_value(device_t &device, UINT8 default_value) { downcast<ram_device &>(device).m_default_value = default_value; }
-
-protected:
- virtual void device_start(void);
- virtual void device_validity_check(validity_checker &valid) const;
-
-private:
- // device state
- UINT32 m_size;
- dynamic_buffer m_pointer;
-
- // device config
- const char *m_default_size;
- const char *m_extra_options;
- UINT8 m_default_value;
-};
-
-
-// device type definition
-extern const device_type RAM;
-
-// device iterator
-typedef device_type_iterator<&device_creator<ram_device>, ram_device> ram_device_iterator;
-
-#endif /* __RAM_H__ */
diff --git a/src/emu/machine/rescap.h b/src/emu/machine/rescap.h
deleted file mode 100644
index 23e4b9f4329..00000000000
--- a/src/emu/machine/rescap.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-#ifndef RC_MACROS_H
-#define RC_MACROS_H
-
-/* Little helpers for magnitude conversions */
-#define RES_R(res) ((double)(res))
-#define RES_K(res) ((double)(res) * 1e3)
-#define RES_M(res) ((double)(res) * 1e6)
-#define RES_INF (-1)
-#define CAP_U(cap) ((double)(cap) * 1e-6)
-#define CAP_N(cap) ((double)(cap) * 1e-9)
-#define CAP_P(cap) ((double)(cap) * 1e-12)
-#define IND_U(ind) ((double)(ind) * 1e-6)
-#define IND_N(ind) ((double)(ind) * 1e-9)
-#define IND_P(ind) ((double)(ind) * 1e-12)
-
-/* vin --/\r1/\-- out --/\r2/\-- gnd */
-#define RES_VOLTAGE_DIVIDER(r1, r2) ((double)(r2) / ((double)(r1) + (double)(r2)))
-
-#define RES_2_PARALLEL(r1, r2) (((r1) * (r2)) / ((r1) + (r2)))
-#define RES_3_PARALLEL(r1, r2, r3) (1.0 / (1.0 / (r1) + 1.0 / (r2) + 1.0 / (r3)))
-#define RES_4_PARALLEL(r1, r2, r3, r4) (1.0 / (1.0 / (r1) + 1.0 / (r2) + 1.0 / (r3) + 1.0 / (r4)))
-#define RES_5_PARALLEL(r1, r2, r3, r4, r5) (1.0 / (1.0 / (r1) + 1.0 / (r2) + 1.0 / (r3) + 1.0 / (r4) + 1.0 / (r5)))
-#define RES_6_PARALLEL(r1, r2, r3, r4, r5, r6) (1.0 / (1.0 / (r1) + 1.0 / (r2) + 1.0 / (r3) + 1.0 / (r4) + 1.0 / (r5) + 1.0 / (r6)))
-
-#define RES_2_SERIAL(r1,r2) ((r1)+(r2))
-
-#endif
diff --git a/src/emu/machine/rf5c296.c b/src/emu/machine/rf5c296.c
deleted file mode 100644
index 72fea9ede66..00000000000
--- a/src/emu/machine/rf5c296.c
+++ /dev/null
@@ -1,113 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "rf5c296.h"
-
-// rf5c296 is very inaccurate at that point, it hardcodes the gnet config
-
-const device_type RF5C296 = &device_creator<rf5c296_device>;
-
-rf5c296_device::rf5c296_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, PCCARD_SLOT, "PCCARD SLOT", tag, owner, clock, "pccard", __FILE__)
-{
-}
-
-void rf5c296_device::device_start()
-{
- m_pccard = machine().device<pccard_slot_device>(m_pccard_name);
-}
-
-void rf5c296_device::reg_w(ATTR_UNUSED UINT8 reg, UINT8 data)
-{
- // fprintf(stderr, "rf5c296_reg_w %02x, %02x (%s)\n", reg, data, machine().describe_context());
- switch (reg)
- {
- // Interrupt and General Control Register
- case 0x03:
- // Check for card reset
- if (!(data & 0x40))
- {
- m_pccard->reset();
- }
- break;
-
- default:
- break;
- }
-}
-
-UINT8 rf5c296_device::reg_r(ATTR_UNUSED UINT8 reg)
-{
- // fprintf(stderr, "rf5c296_reg_r %02x (%s)\n", reg, machine().describe_context());
- return 0x00;
-}
-
-WRITE16_MEMBER(rf5c296_device::io_w)
-{
- /// TODO: find out if this should be done here.
- offset *= 2;
- if (mem_mask == 0xff00)
- {
- mem_mask >>= 8;
- data >>= 8;
- offset++;
- }
-
- switch(offset)
- {
- case 0x3e0:
- m_rf5c296_reg = data;
- break;
-
- case 0x3e1:
- reg_w(m_rf5c296_reg, data);
- break;
-
- default:
- m_pccard->write_memory(space, offset, data, mem_mask);
- break;
- }
-}
-
-READ16_MEMBER(rf5c296_device::io_r)
-{
- /// TODO: find out if this should be done here.
- offset *= 2;
- int shift = 0;
- if (mem_mask == 0xff00)
- {
- shift = 8;
- mem_mask >>= 8;
- offset++;
- }
-
- UINT16 data;
-
- switch( offset )
- {
- case 0x3e0:
- data = m_rf5c296_reg;
- break;
-
- case 0x3e1:
- data = reg_r(m_rf5c296_reg);
- break;
-
- default:
- data = m_pccard->read_memory(space, offset, mem_mask);
- break;
- }
-
- return data << shift;
-}
-
-// Hardcoded to reach the pcmcia CIS
-
-READ16_MEMBER(rf5c296_device::mem_r)
-{
- return m_pccard->read_reg(space, offset, mem_mask);
-}
-
-WRITE16_MEMBER(rf5c296_device::mem_w)
-{
- m_pccard->write_reg(space, offset, data, mem_mask);
-}
diff --git a/src/emu/machine/rf5c296.h b/src/emu/machine/rf5c296.h
deleted file mode 100644
index 61556b677b7..00000000000
--- a/src/emu/machine/rf5c296.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#pragma once
-
-#ifndef __RF5C296_H__
-#define __RF5C296_H__
-
-#include "pccard.h"
-
-#define MCFG_RF5C296_SLOT(name) \
- rf5c296_device::set_pccard_name(*device, name);
-
-class rf5c296_device : public device_t
-{
-public:
- rf5c296_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- static void set_pccard_name(device_t &device, const char *name) { downcast<rf5c296_device &>(device).m_pccard_name = name; }
-
- DECLARE_WRITE16_MEMBER(io_w);
- DECLARE_READ16_MEMBER(io_r);
- DECLARE_READ16_MEMBER(mem_r);
- DECLARE_WRITE16_MEMBER(mem_w);
-
-protected:
- // device-level overrides
- virtual void device_start();
-
-private:
- private:
- void reg_w(ATTR_UNUSED UINT8 reg, UINT8 data);
- UINT8 reg_r(ATTR_UNUSED UINT8 reg);
-
- unsigned char m_rf5c296_reg;
- pccard_slot_device *m_pccard;
- const char *m_pccard_name;
-};
-
-extern const device_type RF5C296;
-
-#endif
diff --git a/src/emu/machine/roc10937.c b/src/emu/machine/roc10937.c
deleted file mode 100644
index fbfda7ce0e8..00000000000
--- a/src/emu/machine/roc10937.c
+++ /dev/null
@@ -1,388 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:James Wallace
-/**********************************************************************
-
- Rockwell 10937/10957 interface and emulation by J.Wallace
- OKI MSC1937 is a clone of this chip
-
-**********************************************************************/
-
-#include "emu.h"
-#include "roc10937.h"
-
-/*
- Rockwell 10937 16 segment charset lookup table
- 0 1
- ---- ----
- |\ | /|
- 7 | \F |8 /9| 2
- | \ | / |
- -E-- --A-
- | / | \ |
- 6 | /D |C \B| 3
- |/ | \|
- ---- ---- .11
- 5 4 ,10
-
-In 14 segment mode, 0 represents the whole top line,
-and 5 the bottom line, allowing both modes to share
-a charset.
-
-Note that, although we call this a '16 segment' display,
-we actually have 18 segments, including the semicolon portions.
-16-bit tables are used to hold the main characters, the rest are OR'd in
-*/
-
-static const UINT16 roc10937charset[]=
-{ // FEDC BA98 7654 3210
- 0x507F, // 0101 0000 0111 1111 @.
- 0x44CF, // 0100 0100 1100 1111 A.
- 0x153F, // 0001 0101 0011 1111 B.
- 0x00F3, // 0000 0000 1111 0011 C.
- 0x113F, // 0001 0001 0011 1111 D.
- 0x40F3, // 0100 0000 1111 0011 E.
- 0x40C3, // 0100 0000 1100 0011 F.
- 0x04FB, // 0000 0100 1111 1011 G.
- 0x44CC, // 0100 0100 1100 1100 H.
- 0x1133, // 0001 0001 0011 0011 I.
- 0x007C, // 0000 0000 0111 1100 J.
- 0x4AC0, // 0100 1010 1100 0000 K.
- 0x00F0, // 0000 0000 1111 0000 L.
- 0x82CC, // 1000 0010 1100 1100 M.
- 0x88CC, // 1000 1000 1100 1100 N.
- 0x00FF, // 0000 0000 1111 1111 O.
- 0x44C7, // 0100 0100 1100 0111 P.
- 0x08FF, // 0000 1000 1111 1111 Q.
- 0x4CC7, // 0100 1100 1100 0111 R.
- 0x44BB, // 0100 0100 1011 1011 S.
- 0x1103, // 0001 0001 0000 0011 T.
- 0x00FC, // 0000 0000 1111 1100 U.
- 0x22C0, // 0010 0010 1100 0000 V.
- 0x28CC, // 0010 1000 1100 1100 W.
- 0xAA00, // 1010 1010 0000 0000 X.
- 0x9200, // 1001 0010 0000 0000 Y.
- 0x2233, // 0010 0010 0011 0011 Z.
- 0x00E1, // 0000 0000 1110 0001 [.
- 0x8800, // 1000 1000 0000 0000 \.
- 0x001E, // 0000 0000 0001 1110 ].
- 0x2800, // 0010 1000 0000 0000 ^.
- 0x0030, // 0000 0000 0011 0000 _.
- 0x0000, // 0000 0000 0000 0000 dummy.
- 0x8121, // 1000 0001 0010 0001 !.
- 0x0180, // 0000 0001 1000 0000 ".
- 0x553C, // 0101 0101 0011 1100 #.
- 0x55BB, // 0101 0101 1011 1011 $.
- 0x7799, // 0111 0111 1001 1001 %.
- 0xC979, // 1100 1001 0111 1001 &.
- 0x0200, // 0000 0010 0000 0000 '.
- 0x0A00, // 0000 1010 0000 0000 (.
- 0xA050, // 1010 0000 0000 0000 ).
- 0xFF00, // 1111 1111 0000 0000 *.
- 0x5500, // 0101 0101 0000 0000 +.
- 0x0000, // 0000 0000 0000 0000 ;. (Set separately)
- 0x4400, // 0100 0100 0000 0000 --.
- 0x0000, // 0000 0000 0000 0000 . .(Set separately)
- 0x2200, // 0010 0010 0000 0000 /.
- 0x22FF, // 0010 0010 1111 1111 0.
- 0x1100, // 0001 0001 0000 0000 1.
- 0x4477, // 0100 0100 0111 0111 2.
- 0x443F, // 0100 0100 0011 1111 3.
- 0x448C, // 0100 0100 1000 1100 4.
- 0x44BB, // 0100 0100 1011 1011 5.
- 0x44FB, // 0100 0100 1111 1011 6.
- 0x000F, // 0000 0000 0000 1111 7.
- 0x44FF, // 0100 0100 1111 1111 8.
- 0x44BF, // 0100 0100 1011 1111 9.
- 0x0021, // 0000 0000 0010 0001 -
- // -.
- 0x2001, // 0010 0000 0000 0001 -
- // /.
- 0x2230, // 0010 0010 0011 0000 <.
- 0x4430, // 0100 0100 0011 0000 =.
- 0x8830, // 1000 1000 0011 0000 >.
- 0x1407, // 0001 0100 0000 0111 ?.
-};
-
-
-///////////////////////////////////////////////////////////////////////////
-static const int roc10937poslut[]=
-{
- 1,//0
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10,
- 11,
- 12,
- 13,
- 14,
- 15,
- 0//15
-};
-
-const device_type ROC10937 = &device_creator<roc10937_t>;
-
-rocvfd_t::rocvfd_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- device_t(mconfig, type, name, tag, owner, clock, shortname, source)
-{
- m_port_val=0;
-}
-
-
-void rocvfd_t::static_set_value(device_t &device, int val)
-{
- rocvfd_t &roc = downcast<rocvfd_t &>(device);
- roc.m_port_val = val;
-}
-
-void rocvfd_t::device_start()
-{
- save_item(NAME(m_port_val));
- save_item(NAME(m_cursor_pos));
- save_item(NAME(m_window_size));
- save_item(NAME(m_shift_count));
- save_item(NAME(m_shift_data));
- save_item(NAME(m_pcursor_pos));
- save_item(NAME(m_chars));
- save_item(NAME(m_outputs));
- save_item(NAME(m_brightness));
- save_item(NAME(m_count));
- save_item(NAME(m_sclk));
- save_item(NAME(m_data));
- save_item(NAME(m_duty));
- save_item(NAME(m_disp));
-
-
- device_reset();
-}
-
-void rocvfd_t::device_reset()
-{
- m_cursor_pos = 0;
- m_window_size = 16;
- m_shift_count = 0;
- m_shift_data = 0;
- m_pcursor_pos = 0;
- m_brightness =31;
- m_count=0;
- m_duty=31;
- m_disp = 0;
- m_sclk = 0;
- m_data = 0;
-
- memset(m_chars, 0, sizeof(m_chars));
- memset(m_outputs, 0, sizeof(m_outputs));
-}
-
-///////////////////////////////////////////////////////////////////////////
-UINT32 rocvfd_t::set_display(UINT32 segin)
-{
- return BITSWAP32(segin, 31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,11,9,15,13,12,8,10,14,7,6,5,4,3,2,1,0);
-
-}
-
-///////////////////////////////////////////////////////////////////////////
-void rocvfd_t::device_post_load()
-{
- update_display();
-}
-
-void rocvfd_t::update_display()
-{
- for (int i =0; i<16; i++)
- {
- m_outputs[i] = set_display(m_chars[i]);
- output_set_indexed_value("vfd", (m_port_val*16) + i, m_outputs[i]);
- }
-}
-
-WRITE_LINE_MEMBER( rocvfd_t::sclk )
-{
- shift_clock(state);
-}
-
-WRITE_LINE_MEMBER( rocvfd_t::data )
-{
- m_data = state;
-}
-
-WRITE_LINE_MEMBER( rocvfd_t::por )
-{
- //If line goes low, reset mode is engaged, until such a time as it goes high again.
- if (!state)
- {
- reset();
- }
-}
-
-
-void rocvfd_t::shift_clock(int state)
-{
- if (m_sclk != state)
- {
- //Clock data on FALLING edge
- if (!m_sclk)
- {
- m_shift_data <<= 1;
-
- if ( m_data ) m_shift_data |= 1;
-
- if ( ++m_shift_count >= 8 )
- {
- write_char(m_shift_data);
- m_shift_count = 0;
- m_shift_data = 0;
- }
- update_display();
-
- }
- }
- m_sclk = state;
-}
-
-///////////////////////////////////////////////////////////////////////////
-roc10937_t::roc10937_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : rocvfd_t(mconfig, ROC10937, "Rockwell 10937 VFD controller and compatible", tag, owner, clock, "roc10937", __FILE__)
-{
- m_port_val=0;
-}
-
-const device_type MSC1937 = &device_creator<msc1937_t>;
-
-msc1937_t::msc1937_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : rocvfd_t(mconfig, MSC1937, "OKI MSC1937 VFD controller", tag, owner, clock, "msc1937", __FILE__)
-{
- m_port_val=0;
-}
-
-void rocvfd_t::write_char(int data)
-{
- if ( data & 0x80 )
- { // Control data received
- if ( (data & 0xF0) == 0xA0 ) // 1010 xxxx
- { // 1 010 xxxx Buffer Pointer control
- m_cursor_pos = roc10937poslut[data & 0x0F];
- }
- else if ( (data & 0xF0) == 0xC0 ) // 1100 xxxx
- { // 1100 xxxx Set number of digits
- data &= 0x0F;
-
- if ( data == 0 ) m_window_size = 16;
- else m_window_size = data;
- }
- else if ( (data & 0xE0) == 0xE0 ) // 111x xxxx
- { // 111x xxxx Set duty cycle ( brightness )
- m_brightness = (data & 0x1F);
- }
- else if ( (data & 0xE0) == 0x80 ) // 100x ---
- { // 100x xxxx Test mode
- m_duty =4;
- }
- }
- else
- { // Display data
-// data &= 0x3F;
-
- switch ( data )
- {
- case 0x2C: // ;
- m_chars[m_pcursor_pos] |= (1<<16);//.
- m_chars[m_pcursor_pos] |= (1<<17);//,
- break;
- case 0x2E: //
- m_chars[m_pcursor_pos] |= (1<<16);//.
- break;
- default :
- m_pcursor_pos = m_cursor_pos;
- m_chars[m_cursor_pos] = roc10937charset[data & 0x3F];
-
- m_cursor_pos++;
- if ( m_cursor_pos > (m_window_size -1) )
- {
- m_cursor_pos = 0;
- }
- break;
- }
- }
-}
-
-const device_type ROC10957 = &device_creator<roc10957_t>;
-
-roc10957_t::roc10957_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : rocvfd_t(mconfig, ROC10957, "Rockwell 10957 VFD controller and compatible", tag, owner, clock, "roc10957", __FILE__)
-{
- m_port_val=0;
-}
-
-void roc10957_t::write_char(int data)
-{
- if ( data & 0x80 )
- { // Control data received
- if ( (data & 0xF0) == 0xA0 ) // 1010 xxxx
- { // 1 010 xxxx Buffer Pointer control
- m_cursor_pos = roc10937poslut[data & 0x0F];
- }
- else if ( (data & 0xF0) == 0xC0 ) // 1100 xxxx
- { // 1100 xxxx Set number of digits
- data &= 0x0F;
-
- if ( data == 0 ) m_window_size = 16;
- else m_window_size = data;
- }
- else if ( (data & 0xE0) == 0xE0 ) // 111x xxxx
- { // 111x xxxx Set duty cycle ( brightness )
- m_brightness = (data & 0x1F);
- }
- else if ( (data & 0xE0) == 0x80 ) // 100x ---
- { // 100x xxxx Test mode
- popmessage("TEST MODE ENABLED!");
- m_duty = 4;
- }
- }
- else
- { // Display data
- data &= 0x3F;
-
- switch ( data )
- {
- case 0x2C: // ;
- m_chars[m_pcursor_pos] |= (1<<16);//.
- m_chars[m_pcursor_pos] |= (1<<17);//,
- break;
- case 0x2E: //
- m_chars[m_pcursor_pos] |= (1<<16);//.
- break;
- case 0x6C: // ;
- m_chars[m_pcursor_pos] |= (1<<16);//.
- break;
- case 0x6E: //
- {
- m_chars[m_pcursor_pos] = 0;
- }
- break;
- default :
- m_pcursor_pos = m_cursor_pos;
- m_chars[m_cursor_pos] = roc10937charset[data & 0x3F];
-
- m_cursor_pos++;
- if ( m_cursor_pos > (m_window_size -1) )
- {
- m_cursor_pos = 0;
- }
- break;
- }
- }
-}
-
-const device_type S16LF01 = &device_creator<s16lf01_t>;
-
-s16lf01_t::s16lf01_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : rocvfd_t(mconfig, S16LF01, "Samsung 16LF01 Series VFD controller and compatible", tag, owner, clock, "s16lf01", __FILE__)
-{
- m_port_val=0;
-}
diff --git a/src/emu/machine/roc10937.h b/src/emu/machine/roc10937.h
deleted file mode 100644
index 9aee3bf6997..00000000000
--- a/src/emu/machine/roc10937.h
+++ /dev/null
@@ -1,128 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:James Wallace
-/**********************************************************************
-
- Rockwell 10937/10957 interface and simlar chips
- Emulation by J.Wallace
- OKI MSC1937 is a clone of this chip, with many others.
-
-**********************************************************************/
-#pragma once
-
-#ifndef ROC10937_H
-#define ROC10937_H
-
-#define MCFG_ROC10937_ADD(_tag,_val) \
- MCFG_DEVICE_ADD(_tag, ROC10937,60)\
- MCFG_ROC10937_PORT(_val)
-
-#define MCFG_ROC10937_PORT(_val) \
- roc10937_t::static_set_value(*device, _val);
-#define MCFG_ROC10937_REMOVE(_tag) \
- MCFG_DEVICE_REMOVE(_tag)
-
-#define MCFG_ROC10957_ADD(_tag,_val) \
- MCFG_DEVICE_ADD(_tag, ROC10957,60)\
- MCFG_ROC10957_PORT(_val)
-
-#define MCFG_ROC10957_PORT(_val) \
- roc10957_t::static_set_value(*device, _val);
-#define MCFG_ROC10957_REMOVE(_tag) \
- MCFG_DEVICE_REMOVE(_tag)
-
-#define MCFG_MSC1937_ADD(_tag,_val) \
- MCFG_DEVICE_ADD(_tag, ROC10937,60)\
- MCFG_MSC1937_PORT(_val)
-
-#define MCFG_MSC1937_PORT(_val) \
- MCFG_ROC10937_PORT(_val)
-
-#define MCFG_MSC1937_REMOVE(_tag) \
- MCFG_DEVICE_REMOVE(_tag)
-
-#define MCFG_S16LF01_ADD(_tag,_val) \
- MCFG_DEVICE_ADD(_tag, S16LF01,60)\
- MCFG_S16LF01_PORT(_val)
-
-#define MCFG_S16LF01_PORT(_val) \
- MCFG_ROC10937_PORT(_val)
-
-class rocvfd_t : public device_t {
-public:
- rocvfd_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- // inline configuration helpers
- static void static_set_value(device_t &device, int val);
- virtual void update_display();
- UINT8 m_port_val;
- void blank(int data);
- void shift_clock(int data);
- void write_char(int data);
- void setdata(int segdata, int data);
- UINT32 set_display(UINT32 segin);
- DECLARE_WRITE_LINE_MEMBER( sclk );
- DECLARE_WRITE_LINE_MEMBER( data );
- DECLARE_WRITE_LINE_MEMBER( por );
-
-
-protected:
- int m_cursor_pos;
- int m_window_size; // window size
- int m_shift_count;
- int m_shift_data;
- int m_pcursor_pos;
- int m_brightness;
- int m_count;
- int m_data;
- int m_duty;
- int m_disp;
- int m_sclk;
- UINT8 m_cursor;
- UINT32 m_chars[16];
- UINT32 m_outputs[16];
-
- virtual void device_start();
- virtual void device_reset();
- virtual void device_post_load();
-};
-
-
-class roc10937_t : public rocvfd_t {
-public:
- roc10937_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
-
-};
-
-class msc1937_t : public rocvfd_t {
-public:
- msc1937_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
-
-};
-
-class roc10957_t : public rocvfd_t {
-public:
- roc10957_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- void write_char(int data);
-
-protected:
-
-};
-
-class s16lf01_t : public rocvfd_t {
-public:
- s16lf01_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-protected:
-
-};
-
-extern const device_type ROC10937;
-extern const device_type MSC1937;
-extern const device_type ROC10957;
-extern const device_type S16LF01;
-
-#endif
diff --git a/src/emu/machine/rp5c01.c b/src/emu/machine/rp5c01.c
deleted file mode 100644
index 5ac56b4b415..00000000000
--- a/src/emu/machine/rp5c01.c
+++ /dev/null
@@ -1,428 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Ricoh RP5C01(A) Real Time Clock With Internal RAM emulation
-
-*********************************************************************/
-
-/*
-
- TODO:
-
- - 12 hour clock
- - test register
- - timer reset
-
-*/
-
-#include "rp5c01.h"
-
-
-// device type definition
-const device_type RP5C01 = &device_creator<rp5c01_device>;
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-#define RAM_SIZE 13
-
-
-// registers
-enum
-{
- REGISTER_1_SECOND = 0,
- REGISTER_10_SECOND,
- REGISTER_1_MINUTE,
- REGISTER_10_MINUTE,
- REGISTER_1_HOUR,
- REGISTER_10_HOUR,
- REGISTER_DAY_OF_THE_WEEK,
- REGISTER_1_DAY,
- REGISTER_10_DAY,
- REGISTER_1_MONTH,
- REGISTER_10_MONTH, REGISTER_12_24_SELECT = REGISTER_10_MONTH,
- REGISTER_1_YEAR, REGISTER_LEAP_YEAR = REGISTER_1_YEAR,
- REGISTER_10_YEAR,
- REGISTER_MODE,
- REGISTER_TEST,
- REGISTER_RESET
-};
-
-
-// register write mask
-static const int register_write_mask[2][16] =
-{
- { 0xf, 0x7, 0xf, 0x7, 0xf, 0x3, 0x7, 0xf, 0x3, 0xf, 0x1, 0xf, 0xf, 0xf, 0xf, 0xf },
- { 0x0, 0x0, 0xf, 0x7, 0xf, 0x3, 0x7, 0xf, 0x3, 0x0, 0x1, 0x3, 0x0, 0xf, 0xf, 0xf }
-};
-
-
-// modes
-enum
-{
- MODE00 = 0,
- MODE01,
- BLOCK10,
- BLOCK11
-};
-
-
-// mode register
-#define MODE_MASK 0x03
-#define MODE_ALARM_EN 0x04
-#define MODE_TIMER_EN 0x08
-
-
-// test register
-#define TEST_0 0x01
-#define TEST_1 0x02
-#define TEST_2 0x04
-#define TEST_3 0x08
-
-
-// reset register
-#define RESET_ALARM 0x01
-#define RESET_TIMER 0x02
-#define RESET_16_HZ 0x04
-#define RESET_1_HZ 0x08
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// set_alarm_line -
-//-------------------------------------------------
-
-inline void rp5c01_device::set_alarm_line()
-{
- int alarm = ((m_mode & MODE_ALARM_EN) ? m_alarm_on : 1) &
- ((m_reset & RESET_16_HZ) ? 1 : m_16hz) &
- ((m_reset & RESET_1_HZ) ? 1 : m_1hz);
-
- if (m_alarm != alarm)
- {
- if (LOG) logerror("RP5C01 '%s' Alarm %u\n", tag(), alarm);
-
- m_out_alarm_cb(alarm);
- m_alarm = alarm;
- }
-}
-
-
-//-------------------------------------------------
-// read_counter -
-//-------------------------------------------------
-
-inline int rp5c01_device::read_counter(int counter)
-{
- return (m_reg[MODE00][counter + 1] * 10) + m_reg[MODE00][counter];
-}
-
-
-//-------------------------------------------------
-// write_counter -
-//-------------------------------------------------
-
-inline void rp5c01_device::write_counter(int counter, int value)
-{
- m_reg[MODE00][counter] = value % 10;
- m_reg[MODE00][counter + 1] = value / 10;
-}
-
-
-//-------------------------------------------------
-// check_alarm -
-//-------------------------------------------------
-
-inline void rp5c01_device::check_alarm()
-{
- bool all_match = true;
- bool all_zeroes = true;
-
- for (int i = REGISTER_1_MINUTE; i < REGISTER_1_MONTH; i++)
- {
- if (m_reg[MODE01][i] != 0) all_zeroes = false;
- if (m_reg[MODE01][i] != m_reg[MODE00][i]) all_match = false;
- }
-
- m_alarm_on = (all_match || (!m_alarm_on && all_zeroes)) ? 0 : 1;
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// rp5c01_device - constructor
-//-------------------------------------------------
-
-rp5c01_device::rp5c01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, RP5C01, "RP5C01", tag, owner, clock, "rp5c01", __FILE__),
- device_rtc_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this),
- m_out_alarm_cb(*this),
- m_battery_backed(true),
- m_mode(0),
- m_reset(0),
- m_alarm(1),
- m_alarm_on(1),
- m_1hz(1),
- m_16hz(1)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void rp5c01_device::device_start()
-{
- // resolve callbacks
- m_out_alarm_cb.resolve_safe();
-
- // allocate timers
- if (clock() > 0)
- {
- m_clock_timer = timer_alloc(TIMER_CLOCK);
- m_clock_timer->adjust(attotime::from_hz(clock() / 16384), 0, attotime::from_hz(clock() / 16384));
-
- m_16hz_timer = timer_alloc(TIMER_16HZ);
- m_16hz_timer->adjust(attotime::from_hz(clock() / 1024), 0, attotime::from_hz(clock() / 1024));
- }
-
- // state saving
- save_item(NAME(m_reg[MODE00]));
- save_item(NAME(m_reg[MODE01]));
- save_item(NAME(m_mode));
- save_item(NAME(m_reset));
- save_item(NAME(m_alarm));
- save_item(NAME(m_alarm_on));
- save_item(NAME(m_1hz));
- save_item(NAME(m_16hz));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void rp5c01_device::device_reset()
-{
- memset(m_reg, 0, sizeof(m_reg));
- memset(m_ram, 0, sizeof(m_ram));
-
- // 24 hour mode
- m_reg[MODE01][REGISTER_12_24_SELECT] = 1;
-
- if (m_battery_backed && clock() > 0)
- set_current_time(machine());
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void rp5c01_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_CLOCK:
- if (m_1hz && (m_mode & MODE_TIMER_EN))
- {
- advance_seconds();
- }
-
- m_1hz = !m_1hz;
- set_alarm_line();
- break;
-
- case TIMER_16HZ:
- m_16hz = !m_16hz;
- set_alarm_line();
- break;
- }
-}
-
-
-//-------------------------------------------------
-// rtc_clock_updated -
-//-------------------------------------------------
-
-void rp5c01_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
- m_reg[MODE01][REGISTER_LEAP_YEAR] = year % 4;
- write_counter(REGISTER_1_YEAR, year);
- write_counter(REGISTER_1_MONTH, month);
- write_counter(REGISTER_1_DAY, day);
- m_reg[MODE00][REGISTER_DAY_OF_THE_WEEK] = day_of_week;
- write_counter(REGISTER_1_HOUR, hour);
- write_counter(REGISTER_1_MINUTE, minute);
- write_counter(REGISTER_1_SECOND, second);
-
- check_alarm();
- set_alarm_line();
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void rp5c01_device::nvram_default()
-{
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void rp5c01_device::nvram_read(emu_file &file)
-{
- if (m_battery_backed)
- file.read(m_ram, RAM_SIZE);
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void rp5c01_device::nvram_write(emu_file &file)
-{
- if (m_battery_backed)
- file.write(m_ram, RAM_SIZE);
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( rp5c01_device::read )
-{
- UINT8 data = 0;
- offset &= 0x0f;
-
- switch (offset)
- {
- case REGISTER_MODE:
- data = m_mode;
- break;
-
- case REGISTER_TEST:
- case REGISTER_RESET:
- // write only
- break;
-
- default:
- switch (m_mode & MODE_MASK)
- {
- case MODE00:
- case MODE01:
- data = m_reg[m_mode & MODE_MASK][offset];
- break;
-
- case BLOCK10:
- data = m_ram[offset];
- break;
-
- case BLOCK11:
- data = m_ram[offset] >> 4;
- break;
- }
- break;
- }
-
- if (LOG) logerror("RP5C01 '%s' Register %u Read %02x\n", tag(), offset, data);
-
- return data & 0x0f;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( rp5c01_device::write )
-{
- data &= 0x0f;
- offset &= 0x0f;
-
- switch (offset)
- {
- case REGISTER_MODE:
- m_mode = data;
-
- if (LOG)
- {
- logerror("RP5C01 '%s' Mode %u\n", tag(), data & MODE_MASK);
- logerror("RP5C01 '%s' Timer %s\n", tag(), (data & MODE_TIMER_EN) ? "enabled" : "disabled");
- logerror("RP5C01 '%s' Alarm %s\n", tag(), (data & MODE_ALARM_EN) ? "enabled" : "disabled");
- }
- break;
-
- case REGISTER_TEST:
- if (LOG) logerror("RP5C01 '%s' Test %u not supported!\n", tag(), data);
- break;
-
- case REGISTER_RESET:
- m_reset = data;
-
- if (data & RESET_ALARM)
- {
- // reset alarm registers
- for (int i = REGISTER_1_MINUTE; i < REGISTER_1_MONTH; i++)
- {
- m_reg[MODE01][i] = 0;
- }
- }
-
- if (LOG)
- {
- if (data & RESET_ALARM) logerror("RP5C01 '%s' Alarm Reset\n", tag());
- if (data & RESET_TIMER) logerror("RP5C01 '%s' Timer Reset not supported!\n", tag());
- logerror("RP5C01 '%s' 16Hz Signal %s\n", tag(), (data & RESET_16_HZ) ? "disabled" : "enabled");
- logerror("RP5C01 '%s' 1Hz Signal %s\n", tag(), (data & RESET_1_HZ) ? "disabled" : "enabled");
- }
- break;
-
- default:
- switch (m_mode & MODE_MASK)
- {
- case MODE00:
- case MODE01:
- m_reg[m_mode & MODE_MASK][offset] = data & register_write_mask[m_mode & MODE_MASK][offset];
-
- set_time(false, read_counter(REGISTER_1_YEAR), read_counter(REGISTER_1_MONTH), read_counter(REGISTER_1_DAY), m_reg[MODE00][REGISTER_DAY_OF_THE_WEEK],
- read_counter(REGISTER_1_HOUR), read_counter(REGISTER_1_MINUTE), read_counter(REGISTER_1_SECOND));
- break;
-
- case BLOCK10:
- m_ram[offset] = (m_ram[offset] & 0xf0) | data;
- break;
-
- case BLOCK11:
- m_ram[offset] = (data << 4) | (m_ram[offset] & 0x0f);
- break;
- }
-
- if (LOG) logerror("RP5C01 '%s' Register %u Write %02x\n", tag(), offset, data);
- break;
- }
-}
diff --git a/src/emu/machine/rp5c01.h b/src/emu/machine/rp5c01.h
deleted file mode 100644
index e0283816067..00000000000
--- a/src/emu/machine/rp5c01.h
+++ /dev/null
@@ -1,112 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Ricoh RP5C01(A) Real Time Clock With Internal RAM emulation
-
-**********************************************************************
- _____ _____
- _CS 1 |* \_/ | 18 Vcc
- CS 2 | | 17 OSCOUT
- ADJ 3 | | 16 OSCIN
- A0 4 | RP5C01 | 15 _ALARM
- A1 5 | RP5C01A | 14 D3
- A2 6 | RF5C01A | 13 D2
- A3 7 | TC8521 | 12 D1
- _RD 8 | | 11 D0
- GND 9 |_____________| 10 _WR
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __RP5C01__
-#define __RP5C01__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_RP5C01_OUT_ALARM_CB(_devcb) \
- devcb = &rp5c01_device::set_out_alarm_callback(*device, DEVCB_##_devcb);
-
-// include this macro if the chip is not battery backed
-#define MCFG_RP5C01_REMOVE_BATTERY() \
- rp5c01_device::remove_battery(*device);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> rp5c01_device
-
-class rp5c01_device : public device_t,
- public device_rtc_interface,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- rp5c01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_alarm_callback(device_t &device, _Object object) { return downcast<rp5c01_device &>(device).m_out_alarm_cb.set_callback(object); }
- static void remove_battery(device_t &device) { downcast<rp5c01_device &>(device).m_battery_backed = false; }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_READ_LINE_MEMBER( alarm_r ) { return m_alarm; }
- DECLARE_WRITE_LINE_MEMBER( adj_w ) { if (state) adjust_seconds(); }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_rtc_interface overrides
- virtual bool rtc_feature_leap_year() { return true; }
- virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
-private:
- inline void set_alarm_line();
- inline int read_counter(int counter);
- inline void write_counter(int counter, int value);
- inline void check_alarm();
-
- static const device_timer_id TIMER_CLOCK = 0;
- static const device_timer_id TIMER_16HZ = 1;
-
- devcb_write_line m_out_alarm_cb;
- bool m_battery_backed;
-
- UINT8 m_reg[2][13]; // clock registers
- UINT8 m_ram[13]; // RAM
-
- UINT8 m_mode; // mode register
- UINT8 m_reset; // reset register
- int m_alarm; // alarm output
- int m_alarm_on; // alarm condition
- int m_1hz; // 1 Hz condition
- int m_16hz; // 16 Hz condition
-
- // timers
- emu_timer *m_clock_timer;
- emu_timer *m_16hz_timer;
-};
-
-
-// device type definition
-extern const device_type RP5C01;
-
-
-
-#endif
diff --git a/src/emu/machine/rp5c15.c b/src/emu/machine/rp5c15.c
deleted file mode 100644
index 7967366c349..00000000000
--- a/src/emu/machine/rp5c15.c
+++ /dev/null
@@ -1,447 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Ricoh RP5C15 Real Time Clock emulation
-
-*********************************************************************/
-
-/*
-
- TODO:
-
- - 12 hour clock
- - test register
- - timer reset
-
-*/
-
-#include "rp5c15.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-// registers
-enum
-{
- REGISTER_1_SECOND = 0, REGISTER_CLOCK_OUTPUT = REGISTER_1_SECOND,
- REGISTER_10_SECOND, REGISTER_ADJUST = REGISTER_10_SECOND,
- REGISTER_1_MINUTE,
- REGISTER_10_MINUTE,
- REGISTER_1_HOUR,
- REGISTER_10_HOUR,
- REGISTER_DAY_OF_THE_WEEK,
- REGISTER_1_DAY,
- REGISTER_10_DAY,
- REGISTER_1_MONTH,
- REGISTER_10_MONTH, REGISTER_12_24_SELECT = REGISTER_10_MONTH,
- REGISTER_1_YEAR, REGISTER_LEAP_YEAR = REGISTER_1_YEAR,
- REGISTER_10_YEAR,
- REGISTER_MODE,
- REGISTER_TEST,
- REGISTER_RESET
-};
-
-
-// clock output select
-enum
-{
- CLKOUT_Z = 0,
- CLKOUT_16384_HZ,
- CLKOUT_1024_HZ,
- CLKOUT_128_HZ,
- CLKOUT_16_HZ,
- CLKOUT_1_HZ,
- CLKOUT_1_DIV_60_HZ,
- CLKOUT_L
-};
-
-
-// register write mask
-static const int register_write_mask[2][16] =
-{
- { 0xf, 0x7, 0xf, 0x7, 0xf, 0x3, 0x7, 0xf, 0x3, 0xf, 0x1, 0xf, 0xf, 0xf, 0xf, 0xf },
- { 0x3, 0x1, 0xf, 0x7, 0xf, 0x3, 0x7, 0xf, 0x3, 0x0, 0x1, 0x3, 0x0, 0xf, 0xf, 0xf }
-};
-
-
-// modes
-enum
-{
- MODE00 = 0,
- MODE01
-};
-
-
-// mode register
-#define MODE_MASK 0x01
-#define MODE_ALARM_EN 0x04
-#define MODE_TIMER_EN 0x08
-
-
-// test register
-#define TEST_0 0x01
-#define TEST_1 0x02
-#define TEST_2 0x04
-#define TEST_3 0x08
-
-
-// reset register
-#define RESET_ALARM 0x01
-#define RESET_TIMER 0x02
-#define RESET_16_HZ 0x04
-#define RESET_1_HZ 0x08
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// devices
-const device_type RP5C15 = &device_creator<rp5c15_device>;
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// set_alarm_line -
-//-------------------------------------------------
-
-inline void rp5c15_device::set_alarm_line()
-{
- int alarm = ((m_mode & MODE_ALARM_EN) ? m_alarm_on : 1) &
- ((m_reset & RESET_16_HZ) ? 1 : m_16hz) &
- ((m_reset & RESET_1_HZ) ? 1 : m_1hz);
-
- if (m_alarm != alarm)
- {
- if (LOG) logerror("RP5C15 '%s' Alarm %u\n", tag(), alarm);
-
- m_out_alarm_cb(alarm);
- m_alarm = alarm;
- }
-}
-
-
-//-------------------------------------------------
-// read_counter -
-//-------------------------------------------------
-
-inline int rp5c15_device::read_counter(int counter)
-{
- return (m_reg[MODE00][counter + 1] * 10) + m_reg[MODE00][counter];
-}
-
-
-//-------------------------------------------------
-// write_counter -
-//-------------------------------------------------
-
-inline void rp5c15_device::write_counter(int counter, int value)
-{
- m_reg[MODE00][counter] = value % 10;
- m_reg[MODE00][counter + 1] = value / 10;
-}
-
-
-//-------------------------------------------------
-// check_alarm -
-//-------------------------------------------------
-
-inline void rp5c15_device::check_alarm()
-{
- bool all_match = true;
- bool all_zeroes = true;
-
- for (int i = REGISTER_1_MINUTE; i < REGISTER_1_MONTH; i++)
- {
- if (m_reg[MODE01][i] != 0) all_zeroes = false;
- if (m_reg[MODE01][i] != m_reg[MODE00][i]) all_match = false;
- }
-
- m_alarm_on = (all_match || (!m_alarm_on && all_zeroes)) ? 0 : 1;
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// rp5c15_device - constructor
-//-------------------------------------------------
-
-rp5c15_device::rp5c15_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, RP5C15, "RP5C15", tag, owner, clock, "rp5c15", __FILE__),
- device_rtc_interface(mconfig, *this),
- m_out_alarm_cb(*this),
- m_out_clkout_cb(*this),
- m_alarm(1),
- m_alarm_on(1),
- m_1hz(1),
- m_16hz(1),
- m_clkout(1)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void rp5c15_device::device_start()
-{
- // resolve callbacks
- m_out_alarm_cb.resolve_safe();
- m_out_clkout_cb.resolve_safe();
-
- // allocate timers
- m_clock_timer = timer_alloc(TIMER_CLOCK);
- m_clock_timer->adjust(attotime::from_hz(clock() / 16384), 0, attotime::from_hz(clock() / 16384));
-
- m_16hz_timer = timer_alloc(TIMER_16HZ);
- m_16hz_timer->adjust(attotime::from_hz(clock() / 1024), 0, attotime::from_hz(clock() / 1024));
-
- m_clkout_timer = timer_alloc(TIMER_CLKOUT);
-
- memset(m_reg, 0, sizeof(m_reg));
- memset(m_ram, 0, sizeof(m_ram));
- m_mode = 0;
- m_reset = 0;
- m_alarm = 0;
- m_alarm_on = 0;
- m_1hz = 0;
- m_16hz = 0;
- m_clkout = 0;
-
- // state saving
- save_item(NAME(m_reg[MODE00]));
- save_item(NAME(m_reg[MODE01]));
- save_item(NAME(m_mode));
- save_item(NAME(m_reset));
- save_item(NAME(m_alarm));
- save_item(NAME(m_alarm_on));
- save_item(NAME(m_1hz));
- save_item(NAME(m_16hz));
- save_item(NAME(m_clkout));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void rp5c15_device::device_reset()
-{
- set_current_time(machine());
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void rp5c15_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_CLOCK:
- if (m_1hz && (m_mode & MODE_TIMER_EN))
- {
- advance_seconds();
- }
-
- m_1hz = !m_1hz;
- set_alarm_line();
- break;
-
- case TIMER_16HZ:
- m_16hz = !m_16hz;
- set_alarm_line();
- break;
-
- case TIMER_CLKOUT:
- m_clkout = !m_clkout;
- m_out_clkout_cb(m_clkout);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// rtc_clock_updated -
-//-------------------------------------------------
-
-void rp5c15_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
- m_reg[MODE01][REGISTER_LEAP_YEAR] = year % 4;
- write_counter(REGISTER_1_YEAR, year);
- write_counter(REGISTER_1_MONTH, month);
- write_counter(REGISTER_1_DAY, day);
- m_reg[MODE00][REGISTER_DAY_OF_THE_WEEK] = day_of_week;
- write_counter(REGISTER_1_HOUR, hour);
- write_counter(REGISTER_1_MINUTE, minute);
- write_counter(REGISTER_1_SECOND, second);
-
- check_alarm();
- set_alarm_line();
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( rp5c15_device::read )
-{
- UINT8 data = 0;
- offset &= 0x0f;
-
- switch (offset)
- {
- case REGISTER_MODE:
- data = m_mode;
- break;
-
- case REGISTER_TEST:
- case REGISTER_RESET:
- // write only
- break;
-
- default:
- data = m_reg[m_mode & MODE_MASK][offset];
- break;
- }
-
- if (LOG) logerror("RP5C15 '%s' Register %u Read %02x\n", tag(), offset, data);
-
- return data & 0x0f;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( rp5c15_device::write )
-{
- data &= 0x0f;
- offset &= 0x0f;
-
- switch (offset)
- {
- case REGISTER_MODE:
- m_mode = data;
-
- if (LOG)
- {
- logerror("RP5C15 '%s' Mode %u\n", tag(), data & MODE_MASK);
- logerror("RP5C15 '%s' Timer %s\n", tag(), (data & MODE_TIMER_EN) ? "enabled" : "disabled");
- logerror("RP5C15 '%s' Alarm %s\n", tag(), (data & MODE_ALARM_EN) ? "enabled" : "disabled");
- }
- break;
-
- case REGISTER_TEST:
- if (LOG) logerror("RP5C15 '%s' Test %u not supported!\n", tag(), data);
- break;
-
- case REGISTER_RESET:
- m_reset = data;
-
- if (data & RESET_ALARM)
- {
- // reset alarm registers
- for (int i = REGISTER_1_MINUTE; i < REGISTER_1_MONTH; i++)
- {
- m_reg[MODE01][i] = 0;
- }
- }
-
- if (LOG)
- {
- if (data & RESET_ALARM) logerror("RP5C15 '%s' Alarm Reset\n", tag());
- if (data & RESET_TIMER) logerror("RP5C15 '%s' Timer Reset not supported!\n", tag());
- logerror("RP5C15 '%s' 16Hz Signal %s\n", tag(), (data & RESET_16_HZ) ? "disabled" : "enabled");
- logerror("RP5C15 '%s' 1Hz Signal %s\n", tag(), (data & RESET_1_HZ) ? "disabled" : "enabled");
- }
- break;
-
- default:
- switch (m_mode & MODE_MASK)
- {
- case MODE00:
- m_reg[MODE00][offset] = data & register_write_mask[MODE00][offset];
-
- set_time(false, read_counter(REGISTER_1_YEAR), read_counter(REGISTER_1_MONTH), read_counter(REGISTER_1_DAY), m_reg[MODE00][REGISTER_DAY_OF_THE_WEEK],
- read_counter(REGISTER_1_HOUR), read_counter(REGISTER_1_MINUTE), read_counter(REGISTER_1_SECOND));
- break;
-
- case MODE01:
- switch (offset)
- {
- case REGISTER_CLOCK_OUTPUT:
- switch (data & 0x07)
- {
- case CLKOUT_16384_HZ:
- m_clkout_timer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock()));
- break;
-
- case CLKOUT_1024_HZ:
- m_clkout_timer->adjust(attotime::from_hz(clock() / 16), 0, attotime::from_hz(clock() / 16));
- break;
-
- case CLKOUT_128_HZ:
- m_clkout_timer->adjust(attotime::from_hz(clock() / 128), 0, attotime::from_hz(clock() / 128));
- break;
-
- case CLKOUT_16_HZ:
- m_clkout_timer->adjust(attotime::from_hz(clock() / 1024), 0, attotime::from_hz(clock() / 1024));
- break;
-
- case CLKOUT_1_HZ:
- m_clkout_timer->adjust(attotime::from_hz(clock() / 16384), 0, attotime::from_hz(clock() / 16384));
- break;
-
- case CLKOUT_1_DIV_60_HZ:
- // TODO
- break;
-
- case CLKOUT_L:
- case CLKOUT_Z:
- m_clkout = 1;
- m_clkout_timer->adjust(attotime::zero, 0);
- break;
- }
-
- m_reg[MODE01][offset] = data & register_write_mask[MODE01][offset];
- break;
-
- case REGISTER_ADJUST:
- if (data & 0x01)
- {
- adjust_seconds();
- }
- m_reg[MODE01][offset] = data & register_write_mask[MODE01][offset];
- break;
-
- default:
- m_reg[MODE01][offset] = data & register_write_mask[MODE01][offset];
- break;
- }
- break;
- }
-
- if (LOG) logerror("RP5C15 '%s' Register %u Write %02x\n", tag(), offset, data);
- break;
- }
-}
diff --git a/src/emu/machine/rp5c15.h b/src/emu/machine/rp5c15.h
deleted file mode 100644
index 2f97d49d99f..00000000000
--- a/src/emu/machine/rp5c15.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Ricoh RP5C15 Real Time Clock emulation
-
-**********************************************************************
- _____ _____
- _CS 1 |* \_/ | 18 Vcc
- CS 2 | | 17 OSCOUT
- CLKOUT 3 | | 16 OSCIN
- A0 4 | RP5C15 | 15 _ALARM
- A1 5 | RF5C15 | 14 D3
- A2 6 | RJ5C15 | 13 D2
- A3 7 | | 12 D1
- _RD 8 | | 11 D0
- GND 9 |_____________| 10 _WR
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __RP5C15__
-#define __RP5C15__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_RP5C15_OUT_ALARM_CB(_devcb) \
- devcb = &rp5c15_device::set_out_alarm_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_RP5C15_OUT_CLKOUT_CB(_devcb) \
- devcb = &rp5c15_device::set_out_clkout_callback(*device, DEVCB_##_devcb);
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> rp5c15_device
-
-class rp5c15_device : public device_t,
- public device_rtc_interface
-{
-public:
- // construction/destruction
- rp5c15_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_alarm_callback(device_t &device, _Object object) { return downcast<rp5c15_device &>(device).m_out_alarm_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_clkout_callback(device_t &device, _Object object) { return downcast<rp5c15_device &>(device).m_out_clkout_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_WRITE_LINE_MEMBER( adj_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_rtc_interface overrides
- virtual bool rtc_feature_leap_year() { return true; }
- virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
-
-private:
- inline void set_alarm_line();
- inline int read_counter(int counter);
- inline void write_counter(int counter, int value);
- inline void check_alarm();
-
- static const device_timer_id TIMER_CLOCK = 0;
- static const device_timer_id TIMER_16HZ = 1;
- static const device_timer_id TIMER_CLKOUT = 2;
-
- devcb_write_line m_out_alarm_cb;
- devcb_write_line m_out_clkout_cb;
-
- UINT8 m_reg[2][13]; // clock registers
- UINT8 m_ram[13]; // RAM
-
- UINT8 m_mode; // mode register
- UINT8 m_reset; // reset register
- int m_alarm; // alarm output
- int m_alarm_on; // alarm condition
- int m_1hz; // 1 Hz condition
- int m_16hz; // 16 Hz condition
- int m_clkout; // clock output
-
- // timers
- emu_timer *m_clock_timer;
- emu_timer *m_16hz_timer;
- emu_timer *m_clkout_timer;
-};
-
-
-// device type definition
-extern const device_type RP5C15;
-
-
-
-#endif
diff --git a/src/emu/machine/rp5h01.c b/src/emu/machine/rp5h01.c
deleted file mode 100644
index 53691cf160f..00000000000
--- a/src/emu/machine/rp5h01.c
+++ /dev/null
@@ -1,201 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Nicola Salmoria
-/***************************************************************************
-
- RP5H01 - Ricoh 64x1bit(+8bit) PROM with 6/7-bit counter
-
- In reality, PROM data is 72bits (64 + 8bit 'dummy'). In 7-bit counter mode,
- from 64 to 127 (%1000000 to %1111111), the dummy bits are read repeatedly,
- with a mask of %1010111. For example if the 8 dummy bits are $7c,
- bits 64 to 127 are read as $7c $7c $00 $00 $7c $7c $00 $00.
- To simplify this, our emulation expects 'overdumps', 128bits total.
-
- TODO:
- - not sure if the polarity of our PROM dumps (playch10) is correct,
- same goes for the bit order (note: does not require new dumps)
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/rp5h01.h"
-
-// this is the contents of an unprogrammed PROM
-static const UINT8 initial_data[0x10] =
-{
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00
-};
-
-//-------------------------------------------------
-// rp5h01_device - constructor
-//-------------------------------------------------
-
-const device_type RP5H01 = &device_creator<rp5h01_device>;
-
-rp5h01_device::rp5h01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, RP5H01, "RP5H01 6/7-bit Counter", tag, owner, clock, "rp5h01", __FILE__)
-{
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void rp5h01_device::device_config_complete()
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void rp5h01_device::device_start()
-{
- m_data = region()->base();
- if (m_data == NULL)
- m_data = initial_data;
- else
- assert(region()->bytes() == 0x10);
-
- /* register for state saving */
- save_item(NAME(m_counter));
- save_item(NAME(m_counter_mode));
- save_item(NAME(m_enabled));
- save_item(NAME(m_old_reset));
- save_item(NAME(m_old_clock));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void rp5h01_device::device_reset()
-{
- m_counter = 0;
- m_counter_mode = COUNTER_MODE_6_BITS;
- m_enabled = 0;
- m_old_reset = 0;
- m_old_clock = 0;
-}
-
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-/*-------------------------------------------------
- enable_w
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( rp5h01_device::enable_w )
-{
- /* process the /CE signal and enable/disable the IC */
- m_enabled = state ? 0 : 1;
-}
-
-/*-------------------------------------------------
- reset_w
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( rp5h01_device::reset_w )
-{
- /* if it's not enabled, ignore */
- if (!m_enabled)
- return;
-
- /* now look for a 0->1 transition */
- if (!m_old_reset && state)
- {
- /* reset the counter */
- m_counter = 0;
- }
-
- /* update the pin */
- m_old_reset = state;
-}
-
-/*-------------------------------------------------
- cs_w
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( rp5h01_device::cs_w )
-{
- /* if it's not enabled, ignore */
- if (!m_enabled)
- return;
-
- if (state)
- {
- /* reset the counter */
- m_counter = 0;
- }
-}
-
-/*-------------------------------------------------
- clock_w
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( rp5h01_device::clock_w )
-{
- /* if it's not enabled, ignore */
- if (!m_enabled)
- return;
-
- /* now look for a 1->0 transition */
- if (m_old_clock && !state)
- {
- /* increment the counter, and mask it with the mode */
- m_counter++;
- }
-
- /* update the pin */
- m_old_clock = state;
-}
-
-/*-------------------------------------------------
- test_w
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( rp5h01_device::test_w )
-{
- /* if it's not enabled, ignore */
- if (!m_enabled)
- return;
-
- /* process the test signal and change the counter mode */
- m_counter_mode = (state) ? COUNTER_MODE_7_BITS : COUNTER_MODE_6_BITS;
-}
-
-/*-------------------------------------------------
- counter_r
--------------------------------------------------*/
-
-READ_LINE_MEMBER( rp5h01_device::counter_r )
-{
- /* if it's not enabled, ignore */
- if (!m_enabled)
- return 1; /* high impedance */
-
- /* return A5 */
- return (m_counter >> 5) & 1;
-}
-
-/*-------------------------------------------------
- data_r
--------------------------------------------------*/
-
-READ_LINE_MEMBER( rp5h01_device::data_r )
-{
- /* if it's not enabled, ignore */
- if (!m_enabled)
- return 1; /* high impedance */
-
- /* get the byte offset and bit offset */
- int byte = (m_counter & m_counter_mode) >> 3;
- int bit = 7 - (m_counter & 7);
-
- /* return the data */
- return (m_data[byte] >> bit) & 1;
-}
diff --git a/src/emu/machine/rp5h01.h b/src/emu/machine/rp5h01.h
deleted file mode 100644
index 016f05884ae..00000000000
--- a/src/emu/machine/rp5h01.h
+++ /dev/null
@@ -1,77 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Nicola Salmoria
-/***************************************************************************
-
- RP5H01 - Ricoh 64x1bit(+8bit) PROM with 6/7-bit counter
-
-****************************************************************************
- ___________
- DATA 1 |* | 8 COUNTER OUT
- | |
- _CE/Vpp 2 | RP5H01 | 7 RESET
- | RF5H01 |
- Vcc 3 | | 6 DATA CLOCK
- | |
- GND 4 |___________| 5 TEST
-
-***************************************************************************/
-
-#ifndef __RP5H01_H__
-#define __RP5H01_H__
-
-
-/***************************************************************************
- PARAMETERS
-***************************************************************************/
-
-/* these also work as the address masks */
-enum {
- COUNTER_MODE_6_BITS = 0x3f,
- COUNTER_MODE_7_BITS = 0x7f
-};
-
-/***************************************************************************
- MACROS / CONSTANTS
-***************************************************************************/
-
-class rp5h01_device : public device_t
-{
-public:
- rp5h01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_WRITE_LINE_MEMBER( enable_w ); /* /CE */
- DECLARE_WRITE_LINE_MEMBER( reset_w ); /* RESET */
- DECLARE_WRITE_LINE_MEMBER( cs_w ); /* CS */
- DECLARE_WRITE_LINE_MEMBER( clock_w ); /* DATA CLOCK (active low) */
- DECLARE_WRITE_LINE_MEMBER( test_w ); /* TEST */
- DECLARE_READ_LINE_MEMBER( counter_r ); /* COUNTER OUT */
- DECLARE_READ_LINE_MEMBER( data_r ); /* DATA */
-
-protected:
- // device-level overrides
- virtual void device_config_complete();
- virtual void device_start();
- virtual void device_reset();
-private:
- // internal state
- int m_counter;
- int m_counter_mode; /* test pin */
- int m_enabled; /* chip enable */
- int m_old_reset; /* reset pin state (level-triggered) */
- int m_old_clock; /* clock pin state (level-triggered) */
- const UINT8 *m_data;
-};
-
-extern const device_type RP5H01;
-
-
-#define MCFG_RP5H01_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, RP5H01, 0)
-
-/*
- * Device uses memory region
- * with the same tag as the one
- * assigned to device.
- */
-
-#endif /* __RP5H01_H__ */
diff --git a/src/emu/machine/rtc4543.c b/src/emu/machine/rtc4543.c
deleted file mode 100644
index ccbf32b5faa..00000000000
--- a/src/emu/machine/rtc4543.c
+++ /dev/null
@@ -1,206 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/**********************************************************************
-
- rtc4543.c - Epson R4543 real-time clock chip emulation
- by R. Belmont
-
- TODO: writing (not done by System 12 or 23 so no test case)
-
-**********************************************************************/
-
-#include "rtc4543.h"
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define VERBOSE 0
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type RTC4543 = &device_creator<rtc4543_device>;
-
-
-//-------------------------------------------------
-// rtc4543_device - constructor
-//-------------------------------------------------
-
-rtc4543_device::rtc4543_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, RTC4543, "R4543 RTC", tag, owner, clock, "rtc4543", __FILE__),
- device_rtc_interface(mconfig, *this),
- data_cb(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void rtc4543_device::device_start()
-{
- data_cb.resolve_safe();
-
- // allocate timers
- m_clock_timer = timer_alloc();
- m_clock_timer->adjust(attotime::from_hz(clock() / 32768), 0, attotime::from_hz(clock() / 32768));
-
- // state saving
- save_item(NAME(m_ce));
- save_item(NAME(m_clk));
- save_item(NAME(m_wr));
- save_item(NAME(m_data));
- save_item(NAME(m_shiftreg));
- save_item(NAME(m_regs));
- save_item(NAME(m_curreg));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void rtc4543_device::device_reset()
-{
- set_current_time(machine());
-
- m_ce = 0;
- m_wr = 0;
- m_clk = 0;
- m_data = 0;
- m_shiftreg = 0;
- m_curreg = 0;
- m_curbit = 0;
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void rtc4543_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- advance_seconds();
-}
-
-
-INLINE UINT8 make_bcd(UINT8 data)
-{
- return ((data / 10) << 4) | (data % 10);
-}
-
-//-------------------------------------------------
-// rtc_clock_updated -
-//-------------------------------------------------
-
-void rtc4543_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
- static const int weekday[7] = { 7, 1, 2, 3, 4, 5, 6 };
-
- m_regs[0] = make_bcd(second); // seconds (BCD, 0-59) in bits 0-6, bit 7 = battery low
- m_regs[1] = make_bcd(minute); // minutes (BCD, 0-59)
- m_regs[2] = make_bcd(hour); // hour (BCD, 0-23)
- m_regs[3] = make_bcd(weekday[day_of_week - 1]); // low nibble = day of the week
- m_regs[3] |= (make_bcd(day) & 0x0f) << 4; // high nibble = low digit of day
- m_regs[4] = (make_bcd(day) >> 4); // low nibble = high digit of day
- m_regs[4] |= (make_bcd(month & 0x0f) << 4); // high nibble = low digit of month
- m_regs[5] = make_bcd(month & 0x0f) >> 4; // low nibble = high digit of month
- m_regs[5] |= (make_bcd(year % 10) << 4); // high nibble = low digit of year
- m_regs[6] = make_bcd(year % 100) >> 4; // low nibble = tens digit of year (BCD, 0-9)
-}
-
-//-------------------------------------------------
-// ce_w - chip enable write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( rtc4543_device::ce_w )
-{
- if (VERBOSE) printf("RTC4543 '%s' CE: %u\n", tag(), state);
-
- if (!state && m_ce) // complete transfer
- {
- }
- else if (state && !m_ce) // start new data transfer
- {
- m_curreg = 0;
- m_curbit = 0; // force immediate reload of output data
- }
-
- m_ce = state;
-}
-
-//-------------------------------------------------
-// wr_w - data direction line write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( rtc4543_device::wr_w )
-{
- if (VERBOSE) logerror("RTC4543 '%s' WR: %u\n", tag(), state);
-
- m_wr = state;
-}
-
-//-------------------------------------------------
-// clk_w - serial clock write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( rtc4543_device::clk_w )
-{
- if (VERBOSE) logerror("RTC4543 '%s' CLK: %u\n", tag(), state);
-
- if (!m_ce) return;
-
- // rising edge - read data becomes valid here
- if (!m_clk && state)
- {
- if (!m_wr)
- {
- // reload data?
- if ((m_curbit & 7) == 0)
- {
- m_shiftreg = m_regs[m_curreg++];
-
- if (VERBOSE)
- logerror("RTC4543 '%s' sending byte: %02x\n", tag(), m_shiftreg);
- }
-
- // shift data bit
- // note: output data does not change when clk at final bit
- if (m_curbit != 55)
- {
- m_data = m_shiftreg & 1;
- m_curbit++;
- m_shiftreg >>= 1;
- data_cb(m_data);
- }
- }
- }
-
- m_clk = state;
-}
-
-
-//-------------------------------------------------
-// data_w - I/O write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( rtc4543_device::data_w )
-{
- if (VERBOSE) logerror("RTC4543 '%s' I/O: %u\n", tag(), state);
-
- m_data = state & 1;
-}
-
-
-//-------------------------------------------------
-// data_r - I/O read
-//-------------------------------------------------
-
-READ_LINE_MEMBER( rtc4543_device::data_r )
-{
- return m_data;
-}
diff --git a/src/emu/machine/rtc4543.h b/src/emu/machine/rtc4543.h
deleted file mode 100644
index c1eafb47efb..00000000000
--- a/src/emu/machine/rtc4543.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/**********************************************************************
-
- rtc4543.h - Epson R4543 real-time clock emulation
- by R. Belmont
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __RTC4543_H__
-#define __RTC4543_H__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_RTC4543_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, RTC4543, _clock)
-
-#define MCFG_RTC4543_DATA_CALLBACK(_devcb) \
- devcb = &rtc4543_device::set_data_cb(*device, DEVCB_##_devcb);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> rtc4543_device
-
-class rtc4543_device : public device_t,
- public device_rtc_interface
-{
-public:
- // construction/destruction
- rtc4543_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_WRITE_LINE_MEMBER( ce_w );
- DECLARE_WRITE_LINE_MEMBER( wr_w );
- DECLARE_WRITE_LINE_MEMBER( clk_w );
- DECLARE_READ_LINE_MEMBER( data_r );
- DECLARE_WRITE_LINE_MEMBER( data_w );
-
- template<class _Object> static devcb_base &set_data_cb(device_t &device, _Object object) { return downcast<rtc4543_device &>(device).data_cb.set_callback(object); }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_rtc_interface overrides
- virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
- virtual bool rtc_feature_leap_year() { return true; }
-
-private:
- devcb_write_line data_cb;
-
- int m_ce;
- int m_clk;
- int m_wr;
- int m_data;
- int m_shiftreg;
- int m_regs[7];
- int m_curreg;
- int m_curbit;
-
- // timers
- emu_timer *m_clock_timer;
-};
-
-
-// device type definition
-extern const device_type RTC4543;
-
-#endif
diff --git a/src/emu/machine/rtc65271.c b/src/emu/machine/rtc65271.c
deleted file mode 100644
index 074b8d87f48..00000000000
--- a/src/emu/machine/rtc65271.c
+++ /dev/null
@@ -1,697 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Raphael Nabet, R. Belmont
-/*
- rtc65271 emulation
-
- This chip is an RTC for computer built by Epson and Spezial-Electronic (I
- think SE is the second source here).
-
- Reference:
- * Realtime Clock Module RTC-65271 Application Manual
- <http://www.bgmicro.com/pdf/rtc65271.pdf>
-
- Todo:
- * Support square wave pin output?
- * Support DSE mode?
-
- Raphael Nabet, 2003-2004
- R. Belmont, 2012
-*/
-
-#include "emu.h"
-#include "rtc65271.h"
-
-/* Delay between the beginning (UIP asserted) and the end (UIP cleared and
-update interrupt asserted) of the update cycle */
-#define UPDATE_CYCLE_TIME attotime::from_usec(1984)
-/* Delay between the assertion of UIP and the effective start of the update
-cycle */
-/*#define UPDATE_CYCLE_DELAY attotime::from_usec(244)*/
-
-enum
-{
- reg_second = 0,
- reg_alarm_second,
- reg_minute,
- reg_alarm_minute,
- reg_hour,
- reg_alarm_hour,
- reg_weekday,
- reg_monthday,
- reg_month,
- reg_year,
- reg_A,
- reg_B,
- reg_C,
- reg_D
-};
-
-enum
-{
- reg_A_UIP = 0x80,
- reg_A_DV = 0x70,
- reg_A_RS = 0x0F,
-
- reg_B_SET = 0x80,
- reg_B_PIE = 0x40,
- reg_B_AIE = 0x20,
- reg_B_UIE = 0x10,
- reg_B_SQW = 0x08,
- reg_B_DM = 0x04,
- reg_B_24h = 0x02,
- reg_B_DSE = 0x01,
-
- reg_C_IRQF = 0x80,
- reg_C_PF = 0x40,
- reg_C_AF = 0x20,
- reg_C_UF = 0x10,
-
- reg_D_VRT = 0x80
-};
-
-static const int SQW_freq_table[16] =
-{
- 0,
- 256,
- 128,
- 8192,
- 4096,
- 2048,
- 1024,
- 512,
- 256,
- 128,
- 64,
- 32,
- 16,
- 8,
- 4,
- 2,
-};
-
-
-/*
- BCD utilities
-*/
-
-/*
- Increment a binary-encoded UINT8
-*/
-static UINT8 increment_binary(UINT8 data)
-{
- return data+1;
-}
-
-
-/*
- Increment a BCD-encoded UINT8
-*/
-static UINT8 increment_BCD(UINT8 data)
-{
- if ((data & 0x0f) < 0x09)
- {
- if ((data & 0xf0) < 0xa0)
- data++;
- else
- data = data + 0x01 - 0xa0;
- }
- else
- {
- if ((data & 0xf0) < 0xa0)
- data = data - 0x09 + 0x10;
- else
- data = data - 0x09 - 0x90;
- }
- return data;
-}
-
-
-/*
- Convert a binary-encoded UINT8 to BCD
-*/
-static UINT8 binary_to_BCD(UINT8 data)
-{
- data %= 100;
-
- return ((data / 10) << 4) | (data %10);
-}
-
-
-/*
- Convert a BCD-encoded UINT8 to binary
-*/
-static UINT8 BCD_to_binary(UINT8 data)
-{
- if ((data & 0x0f) >= 0x0a)
- data = data - 0x0a + 0x10;
- if ((data & 0xf0) >= 0xa0)
- data = data - 0xa0;
-
- return (data & 0x0f) + (((data & 0xf0) >> 4) * 10);
-}
-
-
-/*
- Public functions
-*/
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void rtc65271_device::nvram_default()
-{
- memset(m_regs,0, sizeof(m_regs));
- memset(m_xram,0, sizeof(m_xram));
-
- m_regs[reg_B] |= reg_B_DM; // Firebeat assumes the chip factory defaults to non-BCD mode (or maybe Konami programs it that way?)
-}
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void rtc65271_device::nvram_read(emu_file &file)
-{
- UINT8 buf;
-
- /* version flag */
- if (file.read(&buf, 1) != 1)
- return;
- if (buf != 0)
- return;
-
- /* control registers */
- if (file.read(&buf, 1) != 1)
- return;
- m_regs[reg_A] = buf & (reg_A_DV /*| reg_A_RS*/);
- if (file.read(&buf, 1) != 1)
- return;
- m_regs[reg_B] = buf & (reg_B_SET | reg_B_DM | reg_B_24h | reg_B_DSE);
-
- /* alarm registers */
- if (file.read(&m_regs[reg_alarm_second], 1) != 1)
- return;
- if (file.read(&m_regs[reg_alarm_minute], 1) != 1)
- return;
- if (file.read(&m_regs[reg_alarm_hour], 1) != 1)
- return;
-
- /* user RAM */
- if (file.read(m_regs+14, 50) != 50)
- return;
-
- /* extended RAM */
- if (file.read(m_xram, 4096) != 4096)
- return;
-
- m_regs[reg_D] |= reg_D_VRT; /* the data was backed up successfully */
- /*m_dirty = FALSE;*/
-
- {
- system_time systime;
-
- /* get the current date/time from the core */
- machine().current_datetime(systime);
-
- /* set clock registers */
- m_regs[reg_second] = systime.local_time.second;
- m_regs[reg_minute] = systime.local_time.minute;
- if (m_regs[reg_B] & reg_B_24h)
- /* 24-hour mode */
- m_regs[reg_hour] = systime.local_time.hour;
- else
- { /* 12-hour mode */
- if (systime.local_time.hour >= 12)
- {
- m_regs[reg_hour] = 0x80;
- systime.local_time.hour -= 12;
- }
- else
- {
- m_regs[reg_hour] = 0;
- }
-
- // Firebeat indicates non-BCD 12-hour mode has 0-based hour, so 12 AM is 0x00 and 12 PM is 0x80
- m_regs[reg_hour] |= systime.local_time.hour; // ? systime.local_time.hour : 12;
- }
- m_regs[reg_weekday] = systime.local_time.weekday + 1;
- m_regs[reg_monthday] = systime.local_time.mday;
- m_regs[reg_month] = systime.local_time.month + 1;
- m_regs[reg_year] = systime.local_time.year % 100;
- if (! (m_regs[reg_B] & reg_B_DM))
- { /* BCD mode */
- m_regs[reg_second] = binary_to_BCD(m_regs[reg_second]);
- m_regs[reg_minute] = binary_to_BCD(m_regs[reg_minute]);
- m_regs[reg_hour] = (m_regs[reg_hour] & 0x80) | binary_to_BCD(m_regs[reg_hour] & 0x7f);
- /*m_regs[reg_weekday] = binary_to_BCD(m_regs[reg_weekday]);*/
- m_regs[reg_monthday] = binary_to_BCD(m_regs[reg_monthday]);
- m_regs[reg_month] = binary_to_BCD(m_regs[reg_month]);
- m_regs[reg_year] = binary_to_BCD(m_regs[reg_year]);
- }
- }
-}
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void rtc65271_device::nvram_write(emu_file &file)
-{
- UINT8 buf;
-
-
- /* version flag */
- buf = 0;
- if (file.write(& buf, 1) != 1)
- return;
-
- /* control registers */
- buf = m_regs[reg_A] & (reg_A_DV | reg_A_RS);
- if (file.write(&buf, 1) != 1)
- return;
- buf = m_regs[reg_B] & (reg_B_SET | reg_B_DM | reg_B_24h | reg_B_DSE);
- if (file.write(&buf, 1) != 1)
- return;
-
- /* alarm registers */
- if (file.write(&m_regs[reg_alarm_second], 1) != 1)
- return;
- if (file.write(&m_regs[reg_alarm_minute], 1) != 1)
- return;
- if (file.write(&m_regs[reg_alarm_hour], 1) != 1)
- return;
-
- /* user RAM */
- if (file.write(m_regs+14, 50) != 50)
- return;
-
- /* extended RAM */
- if (file.write(m_xram, 4096) != 4096)
- return;
-}
-
-/*
- Read a byte from clock
-
- xramsel: select RTC register if 0, XRAM if 1
- offset: address (A0-A5 pins)
-*/
-UINT8 rtc65271_device::read(int xramsel, offs_t offset)
-{
- int reply;
-
- if (xramsel)
- {
- if (offset & 0x20)
- /* XRAM page register */
- reply = m_cur_xram_page;
- else
- /* XRAM data */
- reply = m_xram[(offset & 0x1f) + 0x0020*m_cur_xram_page];
- }
- else
- {
- if (offset & 0x01)
- /* data register */
- switch (m_cur_reg)
- {
- case reg_A:
- reply = m_regs[m_cur_reg] & ~reg_A_DV;
- reply |= 0x20; // indicate normal RTC operation
- break;
-
- case reg_C:
- reply = m_regs[m_cur_reg];
- m_regs[m_cur_reg] = 0;
- field_interrupts();
- break;
- case reg_D:
- reply = m_regs[m_cur_reg];
- m_regs[m_cur_reg] = /*0*/reg_D_VRT; /* set VRT flag so that the computer does not complain that the battery is low */
- break;
-
- default:
- reply = m_regs[m_cur_reg];
- break;
- }
- else
- /* indirect address register */
- reply = m_cur_reg;
- }
-
- return reply;
-}
-
-READ8_MEMBER( rtc65271_device::rtc_r )
-{
- return read(0, offset );
-}
-
-READ8_MEMBER( rtc65271_device::xram_r )
-{
- return read(1, offset );
-}
-
-/*
- Write a byte to clock
-
- xramsel: select RTC register if 0, XRAM if 1
- offset: address (A0-A5 pins)
-*/
-void rtc65271_device::write(int xramsel, offs_t offset, UINT8 data)
-{
- if (xramsel)
- {
- if (offset & 0x20)
- /* XRAM page register */
- m_cur_xram_page = data & 0x7f;
- else
- /* XRAM data */
- m_xram[(offset & 0x1f) + 0x0020*m_cur_xram_page] = data;
- }
- else
- {
- if (offset & 0x01)
- /* data register */
- switch (m_cur_reg)
- {
- case reg_second:
- /* the data sheet says bit 7 is read-only. (I have no idea of
- the reason why it is.) */
- m_regs[reg_second] = data & 0x7f;
- break;
-
- case reg_A:
- if ((data & reg_A_RS) != (m_regs[m_cur_reg] & reg_A_RS))
- {
- if (data & reg_A_RS)
- {
- attotime period = attotime::from_hz(SQW_freq_table[data & reg_A_RS]);
- attotime half_period = period / 2;
- attotime elapsed = m_update_timer->elapsed();
-
- if (half_period > elapsed)
- m_SQW_timer->adjust(half_period - elapsed);
- else
- m_SQW_timer->adjust(half_period);
- }
- else
- {
- m_SQW_internal_state = 0; /* right??? */
-
- /* Stop the divider used for SQW and periodic interrupts. */
- m_SQW_timer->adjust(attotime::never);
- }
- }
- /* The UIP bit is read-only */
- m_regs[reg_A] = (data & ~reg_A_UIP) | (m_regs[reg_A] & reg_A_UIP);
- break;
-
- case reg_B:
- m_regs[m_cur_reg] = data;
- if (data & reg_B_SET)
- {
- /* if we are in SET mode, clear update cycle */
- m_regs[reg_A] &= ~reg_A_UIP;
- m_regs[reg_B] &= ~reg_B_UIE; /* the data sheet tells this, but I wonder how much sense it makes */
- field_interrupts();
- }
- break;
-
- case reg_C:
- case reg_D:
- break;
-
- default:
- m_regs[m_cur_reg] = data;
- break;
- }
- else
- /* indirect address register */
- m_cur_reg = data & 0x3f;
- }
-}
-
-WRITE8_MEMBER( rtc65271_device::rtc_w )
-{
- write(0, offset, data );
-}
-
-WRITE8_MEMBER( rtc65271_device::xram_w )
-{
- write(1, offset, data );
-}
-
-void rtc65271_device::field_interrupts()
-{
- if (m_regs[reg_C] & m_regs[reg_B] & (reg_C_PF | reg_C_AF | reg_C_UF))
- {
- m_regs[reg_C] |= reg_C_IRQF;
- if (!m_interrupt_cb.isnull())
- m_interrupt_cb(1);
- }
- else
- {
- m_regs[reg_C] &= ~reg_C_IRQF;
- if (!m_interrupt_cb.isnull())
- m_interrupt_cb(0);
- }
-}
-
-
-/*
- Timer handlers
-*/
-TIMER_CALLBACK( rtc65271_device::rtc_SQW_callback )
-{
- rtc65271_device *rtc = reinterpret_cast<rtc65271_device *>(ptr);
- rtc->rtc_SQW_cb();
-}
-
-TIMER_CALLBACK( rtc65271_device::rtc_begin_update_callback )
-{
- rtc65271_device *rtc = reinterpret_cast<rtc65271_device *>(ptr);
- rtc->rtc_begin_update_cb();
-}
-
-TIMER_CALLBACK( rtc65271_device::rtc_end_update_callback )
-{
- rtc65271_device *rtc = reinterpret_cast<rtc65271_device *>(ptr);
- rtc->rtc_end_update_cb();
-}
-/*
- Update SQW output state each half-period and assert periodic interrupt each
- period.
-*/
-void rtc65271_device::rtc_SQW_cb()
-{
- attotime half_period;
-
- m_SQW_internal_state = ! m_SQW_internal_state;
- if (! m_SQW_internal_state)
- {
- /* high-to-low??? transition -> interrupt (or should it be low-to-high?) */
- m_regs[reg_C] |= reg_C_PF;
- field_interrupts();
- }
-
- half_period = attotime::from_hz(SQW_freq_table[m_regs[reg_A] & reg_A_RS]) / 2;
- m_SQW_timer->adjust(half_period);
-}
-
-/*
- Begin update cycle (called every second)
-*/
-void rtc65271_device::rtc_begin_update_cb()
-{
- if (((m_regs[reg_A] & reg_A_DV) == 0x20) && ! (m_regs[reg_B] & reg_B_SET))
- {
- m_regs[reg_A] |= reg_A_UIP;
-
- /* schedule end of update cycle */
- machine().scheduler().timer_set(UPDATE_CYCLE_TIME, FUNC(rtc_end_update_callback), 0, (void *)this);
- }
-}
-
-/*
- End update cycle (called UPDATE_CYCLE_TIME = 1948us after start of update
- cycle)
-*/
-void rtc65271_device::rtc_end_update_cb()
-{
- static const int days_in_month_table[12] =
- {
- 31,28,31, 30,31,30,
- 31,31,30, 31,30,31
- };
- UINT8 (*increment)(UINT8 data);
- int c59, c23, c12, c11, c29;
-
- if (! (m_regs[reg_A] & reg_A_UIP))
- /* abort if update cycle has been canceled */
- return;
-
- if (m_regs[reg_B] & reg_B_DM)
- {
- /* binary mode */
- increment = increment_binary;
- c59 = 59;
- c23 = 23;
- c12 = 12;
- c11 = 11;
- c29 = 29;
- }
- else
- {
- /* BCD mode */
- increment = increment_BCD;
- c59 = 0x59;
- c23 = 0x23;
- c12 = 0x12;
- c11 = 0x11;
- c29 = 0x29;
- }
-
- /* increment second */
- if (m_regs[reg_second] < c59)
- m_regs[reg_second] = (*increment)(m_regs[reg_second]);
- else
- {
- m_regs[reg_second] = 0;
-
- /* increment minute */
- if (m_regs[reg_minute] < c59)
- m_regs[reg_minute] = (*increment)(m_regs[reg_minute]);
- else
- {
- m_regs[reg_minute] = 0;
-
- /* increment hour */
- if (m_regs[reg_B] & reg_B_24h)
- {
- /* 24 hour mode */
- if (m_regs[reg_hour] < c23)
- m_regs[reg_hour] = (*increment)(m_regs[reg_hour]);
- else
- m_regs[reg_hour] = 0;
- }
- else
- {
- /* 12 hour mode */
- if (m_regs[reg_hour] < c12)
- {
- if ((m_regs[reg_hour] & 0x7f) == c11)
- m_regs[reg_hour] ^= 0x80;
- m_regs[reg_hour] = ((*increment)(m_regs[reg_hour] & 0x7f) & 0x7f)
- | (m_regs[reg_hour] & 0x80);
- }
- else
- m_regs[reg_hour] = 1 | (m_regs[reg_hour] & 0x80);
- }
-
- /* increment day if needed */
- if (m_regs[reg_hour] == ((m_regs[reg_B] & reg_B_24h) ? 0 : c12))
- {
- /* increment day */
- int days_in_month;
-
- if (m_regs[reg_weekday] < 7)
- m_regs[reg_weekday]++;
- else
- m_regs[reg_weekday] = 1;
-
- if ((m_regs[reg_month] != 2) || (m_regs[reg_year] & 0x03))
- {
- if (m_regs[reg_B] & reg_B_DM)
- {
- /* binary mode */
- days_in_month = days_in_month_table[m_regs[reg_month] - 1];
- }
- else
- {
- /* BCD mode */
- days_in_month = binary_to_BCD(days_in_month_table[BCD_to_binary(m_regs[reg_month]) - 1]);
- }
- }
- else
- days_in_month = c29;
-
- if (m_regs[reg_monthday] < days_in_month)
- m_regs[reg_monthday] = (*increment)(m_regs[reg_monthday]);
- else
- {
- /* increment month */
- m_regs[reg_monthday] = 1;
-
- if (m_regs[reg_month] < c12)
- m_regs[reg_month] = (*increment)(m_regs[reg_month]);
- else
- {
- /* increment year */
- m_regs[reg_month] = 1;
-
- if (m_regs[reg_B] & reg_B_DM)
- {
- /* binary mode */
- if (m_regs[reg_year] < 99)
- m_regs[reg_year]++;
- else
- m_regs[reg_year] = 0;
- }
- else
- {
- /* BCD mode */
- m_regs[reg_year] = increment_BCD(m_regs[reg_year]);
- }
- }
- }
- }
- }
- }
-
- m_regs[reg_A] &= ~reg_A_UIP;
- m_regs[reg_C] |= reg_C_UF;
-
- /* test for alarm (values in range 0xc0-0xff mean "don't care") */
- if ((((m_regs[reg_alarm_second] & 0xc0) == 0xc0) || (m_regs[reg_alarm_second] == m_regs[reg_second]))
- && (((m_regs[reg_alarm_minute] & 0xc0) == 0xc0) || (m_regs[reg_alarm_minute] == m_regs[reg_minute]))
- && (((m_regs[reg_alarm_hour] & 0xc0) == 0xc0) || (m_regs[reg_alarm_hour] == m_regs[reg_hour])))
- m_regs[reg_C] |= reg_C_AF;
-
- field_interrupts();
-}
-
-// device type definition
-const device_type RTC65271 = &device_creator<rtc65271_device>;
-
-//-------------------------------------------------
-// rtc65271_device - constructor
-//-------------------------------------------------
-
-rtc65271_device::rtc65271_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, RTC65271, "RTC-65271", tag, owner, clock, "rtc65271", __FILE__),
- device_nvram_interface(mconfig, *this),
- m_interrupt_cb(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-void rtc65271_device::device_start()
-{
- m_update_timer = machine().scheduler().timer_alloc(FUNC(rtc_begin_update_callback), (void *)this);
- m_update_timer->adjust(attotime::from_seconds(1), 0, attotime::from_seconds(1));
- m_SQW_timer = machine().scheduler().timer_alloc(FUNC(rtc_SQW_callback), (void *)this);
- m_interrupt_cb.resolve();
-
- save_item(NAME(m_regs));
- save_item(NAME(m_cur_reg));
- save_item(NAME(m_xram));
- save_item(NAME(m_cur_xram_page));
- save_item(NAME(m_SQW_internal_state));
-}
diff --git a/src/emu/machine/rtc65271.h b/src/emu/machine/rtc65271.h
deleted file mode 100644
index b81e92755d5..00000000000
--- a/src/emu/machine/rtc65271.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Raphael Nabet, R. Belmont
-/*
- rtc65271.h: include file for rtc65271.c
-*/
-
-#ifndef __RTC65271_H__
-#define __RTC65271_H__
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_RTC65271_INTERRUPT_CB(_devcb) \
- devcb = &rtc65271_device::set_interrupt_callback(*device, DEVCB_##_devcb);
-
-
-// ======================> rtc65271_device
-
-class rtc65271_device : public device_t,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- rtc65271_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-protected:
- // device-level overrides
- virtual void device_start();
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-public:
-
- template<class _Object> static devcb_base &set_interrupt_callback(device_t &device, _Object object) { return downcast<rtc65271_device &>(device).m_interrupt_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( rtc_r );
- DECLARE_READ8_MEMBER( xram_r );
- DECLARE_WRITE8_MEMBER( rtc_w );
- DECLARE_WRITE8_MEMBER( xram_w );
-private:
- UINT8 read(int xramsel, offs_t offset);
- void write(int xramsel, offs_t offset, UINT8 data);
- void field_interrupts();
-
- static TIMER_CALLBACK( rtc_SQW_callback );
- static TIMER_CALLBACK( rtc_begin_update_callback );
- static TIMER_CALLBACK( rtc_end_update_callback );
-
- void rtc_SQW_cb();
- void rtc_begin_update_cb();
- void rtc_end_update_cb();
- /* 64 8-bit registers (10 clock registers, 4 control/status registers, and
- 50 bytes of user RAM) */
- UINT8 m_regs[64];
- UINT8 m_cur_reg;
-
- /* extended RAM: 4kbytes of battery-backed RAM (in pages of 32 bytes) */
- UINT8 m_xram[4096];
- UINT8 m_cur_xram_page;
-
- /* update timer: called every second */
- emu_timer *m_update_timer;
-
- /* SQW timer: called every periodic clock half-period */
- emu_timer *m_SQW_timer;
- UINT8 m_SQW_internal_state;
-
- /* callback called when interrupt pin state changes (may be NULL) */
- devcb_write_line m_interrupt_cb;
-};
-
-// device type definition
-extern const device_type RTC65271;
-
-#endif
diff --git a/src/emu/machine/rtc9701.c b/src/emu/machine/rtc9701.c
deleted file mode 100644
index afa46572ef4..00000000000
--- a/src/emu/machine/rtc9701.c
+++ /dev/null
@@ -1,469 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Angelo Salese, David Haywood
-/***************************************************************************
-
- rtc9701.c
-
- Epson RTC-9701-JE
-
- Serial Real Time Clock + EEPROM
-
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/rtc9701.h"
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type rtc9701 = &device_creator<rtc9701_device>;
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// rtc9701_device - constructor
-//-------------------------------------------------
-
-rtc9701_device::rtc9701_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, rtc9701, "RTC-9701", tag, owner, clock, "rtc9701", __FILE__),
- device_nvram_interface(mconfig, *this),
- m_latch(0),
- m_reset_line(CLEAR_LINE),
- m_clock_line(CLEAR_LINE)
-{
-}
-
-void rtc9701_device::timer_callback()
-{
- static const UINT8 dpm[12] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 };
- int dpm_count;
-
- m_rtc.sec++;
-
- if((m_rtc.sec & 0x0f) >= 0x0a) { m_rtc.sec+=0x10; m_rtc.sec&=0xf0; }
- if((m_rtc.sec & 0xf0) >= 0x60) { m_rtc.min++; m_rtc.sec = 0; }
- if((m_rtc.min & 0x0f) >= 0x0a) { m_rtc.min+=0x10; m_rtc.min&=0xf0; }
- if((m_rtc.min & 0xf0) >= 0x60) { m_rtc.hour++; m_rtc.min = 0; }
- if((m_rtc.hour & 0x0f) >= 0x0a) { m_rtc.hour+=0x10; m_rtc.hour&=0xf0; }
- if((m_rtc.hour & 0xff) >= 0x24) { m_rtc.day++; m_rtc.wday<<=1; m_rtc.hour = 0; }
- if(m_rtc.wday & 0x80) { m_rtc.wday = 1; }
- if((m_rtc.day & 0x0f) >= 0x0a) { m_rtc.day+=0x10; m_rtc.day&=0xf0; }
-
- /* TODO: crude leap year support */
- dpm_count = (m_rtc.month & 0xf) + (((m_rtc.month & 0x10) >> 4)*10)-1;
-
- if(((m_rtc.year % 4) == 0) && m_rtc.month == 2)
- {
- if((m_rtc.day & 0xff) >= dpm[dpm_count]+1+1)
- { m_rtc.month++; m_rtc.day = 0x01; }
- }
- else if((m_rtc.day & 0xff) >= dpm[dpm_count]+1){ m_rtc.month++; m_rtc.day = 0x01; }
- if((m_rtc.month & 0x0f) >= 0x0a) { m_rtc.month = 0x10; }
- if(m_rtc.month >= 0x13) { m_rtc.year++; m_rtc.month = 1; }
- if((m_rtc.year & 0x0f) >= 0x0a) { m_rtc.year+=0x10; m_rtc.year&=0xf0; }
- if((m_rtc.year & 0xf0) >= 0xa0) { m_rtc.year = 0; } //2000-2099 possible timeframe
-}
-
-TIMER_CALLBACK( rtc9701_device::rtc_inc_callback )
-{
- reinterpret_cast<rtc9701_device *>(ptr)->timer_callback();
-}
-
-//-------------------------------------------------
-// device_validity_check - perform validity checks
-// on this device
-//-------------------------------------------------
-
-void rtc9701_device::device_validity_check(validity_checker &valid) const
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void rtc9701_device::device_start()
-{
- /* let's call the timer callback every second */
- machine().scheduler().timer_pulse(attotime::from_hz(clock() / XTAL_32_768kHz), FUNC(rtc_inc_callback), 0, (void *)this);
-
- system_time systime;
- machine().base_datetime(systime);
-
- m_rtc.day = ((systime.local_time.mday / 10)<<4) | ((systime.local_time.mday % 10) & 0xf);
- m_rtc.month = (((systime.local_time.month+1) / 10) << 4) | (((systime.local_time.month+1) % 10) & 0xf);
- m_rtc.wday = 1 << systime.local_time.weekday;
- m_rtc.year = (((systime.local_time.year % 100)/10)<<4) | ((systime.local_time.year % 10) & 0xf);
- m_rtc.hour = ((systime.local_time.hour / 10)<<4) | ((systime.local_time.hour % 10) & 0xf);
- m_rtc.min = ((systime.local_time.minute / 10)<<4) | ((systime.local_time.minute % 10) & 0xf);
- m_rtc.sec = ((systime.local_time.second / 10)<<4) | ((systime.local_time.second % 10) & 0xf);
-
- rtc_state = RTC9701_CMD_WAIT;
- cmd_stream_pos = 0;
- current_cmd = 0;
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void rtc9701_device::device_reset()
-{
-}
-
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void rtc9701_device::nvram_default()
-{
- for (offs_t offs = 0; offs < 0x100; offs++)
- rtc9701_data[offs] = 0xffff;
-}
-
-
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void rtc9701_device::nvram_read(emu_file &file)
-{
- file.read(rtc9701_data, 0x200);
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void rtc9701_device::nvram_write(emu_file &file)
-{
- file.write(rtc9701_data, 0x200);
-}
-
-//-------------------------------------------------
-// rtc_read - used to route RTC reading registers
-//-------------------------------------------------
-
-inline UINT8 rtc9701_device::rtc_read(UINT8 offset)
-{
- UINT8 res;
-
- res = 0;
-
- switch(offset)
- {
- case 0: res = m_rtc.sec; break;
- case 1: res = m_rtc.min; break;
- case 2: res = m_rtc.hour; break;
- case 3: res = m_rtc.wday; break; /* untested */
- case 4: res = m_rtc.day; break;
- case 5: res = m_rtc.month; break;
- case 6: res = m_rtc.year & 0xff; break;
- case 7: res = 0x20; break;
- }
-
- return res;
-}
-
-inline void rtc9701_device::rtc_write(UINT8 offset,UINT8 data)
-{
- switch(offset)
- {
- case 0: m_rtc.sec = data; break;
- case 1: m_rtc.min = data; break;
- case 2: m_rtc.hour = data; break;
- case 3: m_rtc.wday = data; break; /* untested */
- case 4: m_rtc.day = data; break;
- case 5: m_rtc.month = data; break;
- case 6: m_rtc.year = data; break;
- case 7: break; // NOP
- }
-}
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-WRITE_LINE_MEMBER( rtc9701_device::write_bit )
-{
- m_latch = state;
-}
-
-
-READ_LINE_MEMBER( rtc9701_device::read_bit )
-{
- if (rtc_state == RTC9701_RTC_READ)
- {
- //printf("RTC data bits left c9701_data_pos %02x\n", rtc9701_data_pos);
- return ((rtc9701_current_data) >> (rtc9701_data_pos-1))&1;
-
- }
- else if (rtc_state == RTC9701_EEPROM_READ)
- {
- //printf("EEPROM data bits left c9701_data_pos %02x\n", rtc9701_data_pos);
- return ((rtc9701_current_data) >> (rtc9701_data_pos-1))&1;
-
- }
- else
- {
- //printf("read something else (status?) %02x\n", rtc9701_data_pos);
- }
-
-
-
- return 0;
-}
-
-
-WRITE_LINE_MEMBER( rtc9701_device::set_cs_line )
-{
- //logerror("set reset line %d\n",state);
- m_reset_line = state;
-
- if (m_reset_line != CLEAR_LINE)
- {
- rtc_state = RTC9701_CMD_WAIT;
- cmd_stream_pos = 0;
- current_cmd = 0;
- rtc9701_address_pos = 0;
- rtc9701_current_address = 0;
- rtc9701_current_data = 0;
- rtc9701_data_pos = 0;
-
- }
-}
-
-
-
-WRITE_LINE_MEMBER( rtc9701_device::set_clock_line )
-{
- //logerror("set clock line %d\n",state);
-
- if (m_reset_line == CLEAR_LINE)
- {
- if (state==1)
- {
- //logerror("write latched bit %d\n",m_latch);
-
- switch (rtc_state)
- {
- case RTC9701_CMD_WAIT:
-
- //logerror("xx\n");
- current_cmd = (current_cmd << 1) | (m_latch&1);
- cmd_stream_pos++;
-
- if (cmd_stream_pos==4)
- {
- cmd_stream_pos = 0;
- //logerror("Comamnd is %02x\n", current_cmd);
-
- if (current_cmd==0x00) /* 0000 */
- {
- //logerror("WRITE RTC MODE\n");
- rtc_state = RTC9701_RTC_WRITE;
- cmd_stream_pos = 0;
- rtc9701_address_pos = 0;
- rtc9701_current_address = 0;
- rtc9701_data_pos = 0;
- rtc9701_current_data = 0;
- }
- else if (current_cmd==0x02) /* 0010 */
- {
- //logerror("WRITE EEPROM MODE\n");
- rtc_state = RTC9701_EEPROM_WRITE;
- cmd_stream_pos = 0;
- rtc9701_address_pos = 0;
- rtc9701_current_address = 0;
- rtc9701_data_pos = 0;
- rtc9701_current_data = 0;
-
- }
- else if (current_cmd==0x06) /* 0110 */
- {
- //logerror("WRITE ENABLE\n");
- rtc_state = RTC9701_AFTER_WRITE_ENABLE;
- cmd_stream_pos = 0;
- }
- else if (current_cmd==0x08) /* 1000 */
- {
- //logerror("READ RTC MODE\n");
- rtc_state = RTC9701_RTC_READ;
- cmd_stream_pos = 0;
- rtc9701_address_pos = 0;
- rtc9701_current_address = 0;
- rtc9701_data_pos = 0;
- rtc9701_current_data = 0;
- }
- else if (current_cmd==0x0a) /* 1010 */
- {
- //logerror("READ EEPROM MODE\n");
- rtc_state = RTC9701_EEPROM_READ;
- cmd_stream_pos = 0;
- rtc9701_address_pos = 0;
- rtc9701_current_address = 0;
- rtc9701_data_pos = 0;
- rtc9701_current_data = 0;
-
-
- }
- else
- {
- //logerror("RTC9701 UNKNOWN MODE\n");
- }
-
- current_cmd = 0;
- }
- break;
-
- case RTC9701_AFTER_WRITE_ENABLE:
- cmd_stream_pos++;
- if (cmd_stream_pos==12)
- {
- cmd_stream_pos = 0;
- //logerror("Written 12 bits, going back to WAIT mode\n");
- rtc_state = RTC9701_CMD_WAIT;
- }
- break;
-
- case RTC9701_RTC_WRITE:
- cmd_stream_pos++;
- if (cmd_stream_pos<=4)
- {
- rtc9701_address_pos++;
- rtc9701_current_address = (rtc9701_current_address << 1) | (m_latch&1);
- if (cmd_stream_pos==4)
- {
- //printf("Set RTC Write Address To %04x\n", rtc9701_current_address );
- }
- }
-
- if (cmd_stream_pos>4)
- {
- rtc9701_data_pos++;
- rtc9701_current_data = (rtc9701_current_data << 1) | (m_latch&1);;
- }
-
- if (cmd_stream_pos==12)
- {
- cmd_stream_pos = 0;
- rtc_write(rtc9701_current_address,rtc9701_current_data);
- //logerror("Written 12 bits, going back to WAIT mode\n");
- rtc_state = RTC9701_CMD_WAIT;
- }
- break;
-
-
-
- case RTC9701_EEPROM_READ:
- cmd_stream_pos++;
- if (cmd_stream_pos<=12)
- {
- rtc9701_address_pos++;
- rtc9701_current_address = (rtc9701_current_address << 1) | (m_latch&1);
- if (cmd_stream_pos==12)
- {
- //printf("Set EEPROM Read Address To %04x - ", (rtc9701_current_address>>1)&0xff );
- rtc9701_current_data = rtc9701_data[(rtc9701_current_address>>1)&0xff];
- //printf("Setting data latch for reading to %04x\n", rtc9701_current_data);
- rtc9701_data_pos = 16;
- }
- }
-
- if (cmd_stream_pos>12)
- {
- rtc9701_data_pos--;
-
- }
-
- if (cmd_stream_pos==28)
- {
- cmd_stream_pos = 0;
- // //logerror("accesed 28 bits, going back to WAIT mode\n");
- // rtc_state = RTC9701_CMD_WAIT;
- }
- break;
-
-
-
- case RTC9701_EEPROM_WRITE:
- cmd_stream_pos++;
-
- if (cmd_stream_pos<=12)
- {
- rtc9701_address_pos++;
- rtc9701_current_address = (rtc9701_current_address << 1) | (m_latch&1);
- if (cmd_stream_pos==12)
- {
- //printf("Set EEPROM Write Address To %04x\n", rtc9701_current_address );
- }
- }
-
- if (cmd_stream_pos>12)
- {
- rtc9701_data_pos++;
- rtc9701_current_data = (rtc9701_current_data << 1) | (m_latch&1);;
- }
-
- if (cmd_stream_pos==28)
- {
- cmd_stream_pos = 0;
- //printf("written 28 bits - writing data %04x to %04x and going back to WAIT mode\n", rtc9701_current_data, (rtc9701_current_address>>1)&0xff);
- rtc9701_data[(rtc9701_current_address>>1)&0xff] = rtc9701_current_data;
- rtc_state = RTC9701_CMD_WAIT;
- }
- break;
-
- case RTC9701_RTC_READ:
- cmd_stream_pos++;
- if (cmd_stream_pos<=4)
- {
- rtc9701_address_pos++;
- rtc9701_current_address = (rtc9701_current_address << 1) | (m_latch&1);
- if (cmd_stream_pos==4)
- {
- //printf("Set RTC Read Address To %04x\n", rtc9701_current_address );
- rtc9701_current_data = rtc_read(rtc9701_current_address);
- //printf("Setting data latch for reading to %04x\n", rtc9701_current_data);
- rtc9701_data_pos = 8;
- }
- }
-
- if (cmd_stream_pos>4)
- {
- rtc9701_data_pos--;
- }
-
- if (cmd_stream_pos==12)
- {
- cmd_stream_pos = 0;
- // //logerror("accessed 12 bits, going back to WAIT mode\n");
- // rtc_state = RTC9701_CMD_WAIT;
- }
- break;
-
-
- default:
- break;
-
- }
- }
- }
-}
diff --git a/src/emu/machine/rtc9701.h b/src/emu/machine/rtc9701.h
deleted file mode 100644
index eaad28ad0b5..00000000000
--- a/src/emu/machine/rtc9701.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Angelo Salese, David Haywood
-/***************************************************************************
-
- rtc9701.h
-
- Serial rtc9701s.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __rtc9701DEV_H__
-#define __rtc9701DEV_H__
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_RTC9701_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, rtc9701, XTAL_32_768kHz)
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-enum rtc9701_state_t
-{
- RTC9701_CMD_WAIT = 0,
- RTC9701_RTC_READ,
- RTC9701_RTC_WRITE,
- RTC9701_EEPROM_READ,
- RTC9701_EEPROM_WRITE,
- RTC9701_AFTER_WRITE_ENABLE
-
-};
-
-struct rtc_regs_t
-{
- UINT8 sec, min, hour, day, wday, month, year;
-};
-
-
-// ======================> rtc9701_device
-
-class rtc9701_device : public device_t,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- rtc9701_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-
- // I/O operations
- DECLARE_WRITE_LINE_MEMBER( write_bit );
- DECLARE_READ_LINE_MEMBER( read_bit );
- DECLARE_WRITE_LINE_MEMBER( set_cs_line );
- DECLARE_WRITE_LINE_MEMBER( set_clock_line );
- void timer_callback();
-
-protected:
- // device-level overrides
- virtual void device_validity_check(validity_checker &valid) const;
- virtual void device_start();
- virtual void device_reset();
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
- inline UINT8 rtc_read(UINT8 offset);
- inline void rtc_write(UINT8 offset,UINT8 data);
-
- static TIMER_CALLBACK( rtc_inc_callback );
-
- int m_latch;
- int m_reset_line;
- int m_clock_line;
-
-
- rtc9701_state_t rtc_state;
- int cmd_stream_pos;
- int current_cmd;
-
- int rtc9701_address_pos;
- int rtc9701_current_address;
-
- UINT16 rtc9701_current_data;
- int rtc9701_data_pos;
-
- UINT16 rtc9701_data[0x100];
-
- rtc_regs_t m_rtc;
-};
-
-
-// device type definition
-extern const device_type rtc9701;
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-
-
-#endif
diff --git a/src/emu/machine/s2636.c b/src/emu/machine/s2636.c
deleted file mode 100644
index c3cf7bb8178..00000000000
--- a/src/emu/machine/s2636.c
+++ /dev/null
@@ -1,367 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Mariusz Wojcieszek, Peter Trauner
-/**********************************************************************
-
- Signetics 2636 video chip
-
- PVI REGISTER DESCRIPTION
- ------------------------
-
- | bit |R/W| description
- byte | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |
- | | |
- FC0 | size 4| size 3| size 2| size 1| W | size of the 4 objects(=sprites)
- | | |
- FC1 | |C1 |C2 |C3 |C1 |C2 |C3 | W | colors of the 4 objects
- | | color 1 | color 2 | |
- FC2 | |C1 |C2 |C3 |C1 |C2 |C3 | W |
- | | color 3 | color 4 | |
- | | |
- FC3 | |sh |pos| W | 1=shape 0=position
- | | | display format and position
- FC4 | (free) | |
- FC5 | (free) | |
- | | |
- FC6 | |C1 |C2 |C3 |BG |scrn colr | W | background lock and color
- | |backg colr |enb|C1 |C2 |C3 | | 3="enable"
- | | |
- FC7 | sound | W | squarewave output
- | | |
- FC8 | N1 | N2 | W | range of the 4 display digits
- FC9 | N3 | N4 | W |
- | | |
- |obj/backgrnd |complete object| R |
- FCA | 1 | 2 | 3 | 4 | 1 | 2 | 3 | 4 | |
- | | |
- FCB | |VR-| object collisions | R | Composition of object and back-
- | |LE |1/2|1/3|1/3|1/4|2/4|3/4| | ground,collision detection and
- | | | object display as a state display
- | | | for the status register.Set VRLE.
- | | | wait for VRST.Read out or transmit
- | | | [copy?] all bits until reset by
- | | | VRST.
- | | |
- FCC | PORT1 | R | PORT1 and PORT2 for the range of
- FCD | PORT2 | | the A/D conversion.Cleared by VRST
- FCE | (free) | |
- FCF | (free) | |
-
-
- Size control by byte FC0
-
- bit matrix
- |0|0| 8x10
- |0|1| 16x20
- |1|0| 32x40
- |1|1| 64x80
-
- CE1 and not-CE2 are outputs from the PVI.$E80..$EFF also controls the
- analog multiplexer.
-
-
- SPRITES
- -------
-
- each object field: (=sprite data structure)
-
- 0 \ 10 bytes of bitmap (Each object is 8 pixels wide.)
- 9 /
- A HC horizontal object coordinate
- B HCB horizontal duplicate coordinate
- C VC vertical object coordinate
- D VCB vertical duplicate coordinate
-
-*************************************************************/
-
-#include "emu.h"
-#include "machine/s2636.h"
-
-
-/*************************************
- *
- * Device interface
- *
- *************************************/
-
-const device_type S2636 = &device_creator<s2636_device>;
-
-s2636_device::s2636_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, S2636, "Signetics 2636", tag, owner, clock, "s2636", __FILE__),
- device_video_interface(mconfig, *this),
- device_sound_interface(mconfig, *this),
- m_channel(NULL),
- m_size(0),
- m_pos(0),
- m_level(0),
- m_work_ram_size(0),
- m_y_offset(0),
- m_x_offset(0)
-{
- for (int i = 0; i < 1; i++)
- m_reg[i] = 0;
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void s2636_device::device_start()
-{
- int width = m_screen->width();
- int height = m_screen->height();
-
- m_work_ram.resize(m_work_ram_size);
- memset(&m_work_ram[0], 0, m_work_ram_size);
- m_bitmap.resize(width, height);
- m_collision_bitmap.resize(width, height);
-
- save_item(NAME(m_work_ram));
- save_item(NAME(m_bitmap));
- save_item(NAME(m_collision_bitmap));
-
- m_channel = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate());
- save_item(NAME(m_size));
- save_item(NAME(m_pos));
- save_item(NAME(m_level));
- save_item(NAME(m_reg));
-}
-
-/*************************************
- *
- * Constants
- *
- *************************************/
-
-#define SPRITE_WIDTH (8)
-#define SPRITE_HEIGHT (10)
-
-static const int sprite_offsets[4] = { 0x00, 0x10, 0x20, 0x40 };
-
-
-/*************************************
- *
- * Draw a sprite
- *
- *************************************/
-
-static void draw_sprite( UINT8 *gfx, int color, int y, int x, int expand, int or_mode, bitmap_ind16 &bitmap, const rectangle &cliprect )
-{
- /* for each row */
- for (int sy = 0; sy < SPRITE_HEIGHT; sy++)
- {
- /* for each pixel on the row */
- for (int sx = 0; sx < SPRITE_WIDTH; sx++)
- {
- /* each pixel can be expanded */
- for (int ey = 0; ey <= expand; ey++)
- {
- for (int ex = 0; ex <= expand; ex++)
- {
- /* compute effective destination pixel */
- int ty = y + sy * (expand + 1) + ey;
- int tx = x + sx * (expand + 1) + ex;
-
- /* get out if outside the drawing region */
- if (!cliprect.contains(tx, ty))
- continue;
-
- /* get out if current image bit is transparent */
- if (((gfx[sy] << sx) & 0x80) == 0x00)
- continue;
-
- if (or_mode)
- bitmap.pix16(ty, tx) = 0x08 | bitmap.pix16(ty, tx) | color;
- else
- bitmap.pix16(ty, tx) = 0x08 | color;
- }
- }
- }
- }
-}
-
-
-/*************************************
- *
- * Collision detection
- *
- *************************************/
-
-int s2636_device::check_collision( int spriteno1, int spriteno2, const rectangle &cliprect )
-{
- int checksum = 0;
-
- UINT8* attr1 = &m_work_ram[sprite_offsets[spriteno1]];
- UINT8* attr2 = &m_work_ram[sprite_offsets[spriteno2]];
-
- /* TODO: does not check shadow sprites yet */
-
- m_collision_bitmap.fill(0, cliprect);
-
- if ((attr1[0x0a] != 0xff) && (attr2[0x0a] != 0xff))
- {
- int x, y;
-
- int x1 = attr1[0x0a] + m_x_offset;
- int y1 = attr1[0x0c] + m_y_offset;
- int x2 = attr2[0x0a] + m_x_offset;
- int y2 = attr2[0x0c] + m_y_offset;
-
- int expand1 = (m_work_ram[0xc0] >> (spriteno1 << 1)) & 0x03;
- int expand2 = (m_work_ram[0xc0] >> (spriteno2 << 1)) & 0x03;
-
- /* draw first sprite */
- draw_sprite(attr1, 1, y1, x1, expand1, FALSE, m_collision_bitmap, cliprect);
-
- /* get fingerprint */
- for (x = x1; x < x1 + SPRITE_WIDTH; x++)
- for (y = y1; y < y1 + SPRITE_HEIGHT; y++)
- {
- if (!cliprect.contains(x, y))
- continue;
-
- checksum = checksum + m_collision_bitmap.pix16(y, x);
- }
-
- /* black out second sprite */
- draw_sprite(attr2, 0, y2, x2, expand2, FALSE, m_collision_bitmap, cliprect);
-
- /* remove fingerprint */
- for (x = x1; x < x1 + SPRITE_WIDTH; x++)
- for (y = y1; y < y1 + SPRITE_HEIGHT; y++)
- {
- if (!cliprect.contains(x, y))
- continue;
-
- checksum = checksum - m_collision_bitmap.pix16(y, x);
- }
- }
-
- return (checksum != 0);
-}
-
-
-
-/*************************************
- *
- * Main drawing
- *
- *************************************/
-
-bitmap_ind16 &s2636_device::update( const rectangle &cliprect )
-{
- UINT8 collision = 0;
- int spriteno;
-
- m_bitmap.fill(0, cliprect);
-
- for (spriteno = 0; spriteno < 4; spriteno++)
- {
- int color, expand, x, y;
- UINT8* attr = &m_work_ram[sprite_offsets[spriteno]];
-
- /* get out if sprite is turned off */
- if (attr[0x0a] == 0xff)
- continue;
-
- x = attr[0x0a] + m_x_offset;
- y = attr[0x0c] + m_y_offset;
-
- color = (m_work_ram[0xc1 + (spriteno >> 1)] >> ((spriteno & 1) ? 0 : 3)) & 0x07;
- expand = (m_work_ram[0xc0] >> (spriteno << 1)) & 0x03;
-
- draw_sprite(attr, color, y, x, expand, TRUE, m_bitmap, cliprect);
-
- /* bail if no shadow sprites */
- if ((attr[0x0b] == 0xff) || (attr[0x0d] == 0xfe))
- continue;
-
- x = attr[0x0b] + m_x_offset;
-
- while (y < 0xff)
- {
- y = y + SPRITE_HEIGHT + attr[0x0d];
-
- draw_sprite(attr, color, y, x, expand, TRUE, m_bitmap, cliprect);
- }
- }
-
- /* collision detection */
- if (check_collision(0, 1, cliprect)) collision |= 0x20;
- if (check_collision(0, 2, cliprect)) collision |= 0x10;
- if (check_collision(0, 3, cliprect)) collision |= 0x08;
- if (check_collision(1, 2, cliprect)) collision |= 0x04;
- if (check_collision(1, 3, cliprect)) collision |= 0x02;
- if (check_collision(2, 3, cliprect)) collision |= 0x01;
-
- m_work_ram[0xcb] = collision;
-
- return m_bitmap;
-}
-
-
-/*************************************
- *
- * Work RAM access handlers
- *
- *************************************/
-
-WRITE8_MEMBER( s2636_device::work_ram_w )
-{
- assert(offset < m_work_ram_size);
-
- if ( offset == 0xc7 )
- {
- soundport_w(0, data);
- }
-
- m_work_ram[offset] = data;
-}
-
-
-READ8_MEMBER( s2636_device::work_ram_r )
-{
- assert(offset < m_work_ram_size);
-
- return m_work_ram[offset];
-}
-
-/* Sound */
-
-void s2636_device::soundport_w (int offset, int data)
-{
- m_channel->update();
- m_reg[offset] = data;
- switch (offset)
- {
- case 0:
- m_pos = 0;
- m_level = TRUE;
- // frequency 7874/(data+1)
- m_size = machine().sample_rate() * (data + 1) /7874;
- break;
- }
-}
-
-
-//-------------------------------------------------
-// sound_stream_update - handle a stream update
-//-------------------------------------------------
-
-void s2636_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
-{
- int i;
- stream_sample_t *buffer = outputs[0];
-
- for (i = 0; i < samples; i++, buffer++)
- {
- *buffer = 0;
- if (m_reg[0] && m_pos <= m_size / 2)
- {
- *buffer = 0x7fff;
- }
- if (m_pos <= m_size)
- m_pos++;
- if (m_pos > m_size)
- m_pos = 0;
- }
-}
diff --git a/src/emu/machine/s2636.h b/src/emu/machine/s2636.h
deleted file mode 100644
index 082eeabab9f..00000000000
--- a/src/emu/machine/s2636.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Mariusz Wojcieszek, Peter Trauner
-/**********************************************************************
-
- Signetics 2636 video chip
-
-**********************************************************************/
-
-#ifndef __S2636_H__
-#define __S2636_H__
-
-
-#define S2636_IS_PIXEL_DRAWN(p) (((p) & 0x08) ? TRUE : FALSE)
-#define S2636_PIXEL_COLOR(p) ((p) & 0x07)
-
-/*************************************
- *
- * Device configuration macros
- *
- *************************************/
-
-class s2636_device : public device_t,
- public device_video_interface,
- public device_sound_interface
-{
-public:
- s2636_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~s2636_device() {}
-
- static void set_workram_size(device_t &device, int size) { downcast<s2636_device &>(device).m_work_ram_size = size; }
- static void set_offsets(device_t &device, int y_offset, int x_offset)
- {
- s2636_device &dev = downcast<s2636_device &>(device);
- dev.m_x_offset = x_offset;
- dev.m_y_offset = y_offset;
- }
-
- // returns a BITMAP_FORMAT_IND16 bitmap the size of the screen
- // D0-D2 of each pixel is the pixel color
- // D3 indicates whether the S2636 drew this pixel - 0 = not drawn, 1 = drawn
- bitmap_ind16 &update(const rectangle &cliprect);
-
- DECLARE_WRITE8_MEMBER( work_ram_w );
- DECLARE_READ8_MEMBER( work_ram_r );
-
- void soundport_w(int mode, int data);
-
-protected:
- // device-level overrides
- virtual void device_start();
-
- // sound stream update overrides
- virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
-
-private:
- // internal state
- dynamic_buffer m_work_ram;
- bitmap_ind16 m_bitmap;
- bitmap_ind16 m_collision_bitmap;
-
- sound_stream *m_channel;
- UINT8 m_reg[1];
- int m_size;
- int m_pos;
- unsigned m_level;
-
- int m_work_ram_size;
- int m_y_offset;
- int m_x_offset;
-
- int check_collision( int spriteno1, int spriteno2, const rectangle &cliprect );
-};
-
-extern const device_type S2636;
-
-
-#define MCFG_S2636_OFFSETS(_yoffs, _xoffs) \
- s2636_device::set_offsets(*device, _yoffs, _xoffs);
-
-#define MCFG_S2636_WORKRAM_SIZE(_size) \
- s2636_device::set_workram_size(*device, _size);
-
-
-#endif /* __S2636_H__ */
diff --git a/src/emu/machine/s3520cf.c b/src/emu/machine/s3520cf.c
deleted file mode 100644
index 3a183982298..00000000000
--- a/src/emu/machine/s3520cf.c
+++ /dev/null
@@ -1,265 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Angelo Salese
-/***************************************************************************
-
-Seiko/Epson S-3520CF
-
-preliminary device by Angelo Salese
-
-TODO:
-- kludge on address?
-- SRAM hook-ups;
-- SRAM load/save;
-- system bits;
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/s3520cf.h"
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type S3520CF = &device_creator<s3520cf_device>;
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// s3520cf_device - constructor
-//-------------------------------------------------
-
-s3520cf_device::s3520cf_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, S3520CF, "S-3520CF RTC", tag, owner, clock, "s3520cf", __FILE__)
-{
-}
-
-void s3520cf_device::timer_callback()
-{
- static const UINT8 dpm[12] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 };
- int dpm_count;
-
- m_rtc.sec++;
-
- if((m_rtc.sec & 0x0f) >= 0x0a) { m_rtc.sec+=0x10; m_rtc.sec&=0xf0; }
- if((m_rtc.sec & 0xf0) >= 0x60) { m_rtc.min++; m_rtc.sec = 0; }
- if((m_rtc.min & 0x0f) >= 0x0a) { m_rtc.min+=0x10; m_rtc.min&=0xf0; }
- if((m_rtc.min & 0xf0) >= 0x60) { m_rtc.hour++; m_rtc.min = 0; }
- if((m_rtc.hour & 0x0f) >= 0x0a) { m_rtc.hour+=0x10; m_rtc.hour&=0xf0; }
- if((m_rtc.hour & 0xff) >= 0x24) { m_rtc.day++; m_rtc.wday++; m_rtc.hour = 0; }
- if(m_rtc.wday >= 7) { m_rtc.wday = 0; }
- if((m_rtc.day & 0x0f) >= 0x0a) { m_rtc.day+=0x10; m_rtc.day&=0xf0; }
-
- /* TODO: crude leap year support */
- dpm_count = (m_rtc.month & 0xf) + (((m_rtc.month & 0x10) >> 4)*10)-1;
-
- if(((m_rtc.year % 4) == 0) && m_rtc.month == 2)
- {
- if((m_rtc.day & 0xff) >= dpm[dpm_count]+1+1)
- { m_rtc.month++; m_rtc.day = 0x01; }
- }
- else if((m_rtc.day & 0xff) >= dpm[dpm_count]+1){ m_rtc.month++; m_rtc.day = 0x01; }
- if((m_rtc.month & 0x0f) >= 0x0a) { m_rtc.month = 0x10; }
- if(m_rtc.month >= 0x13) { m_rtc.year++; m_rtc.month = 1; }
- if((m_rtc.year & 0x0f) >= 0x0a) { m_rtc.year+=0x10; m_rtc.year&=0xf0; }
- if((m_rtc.year & 0xf0) >= 0xa0) { m_rtc.year = 0; } //1901-2000 possible timeframe
-}
-
-TIMER_CALLBACK( s3520cf_device::rtc_inc_callback )
-{
- reinterpret_cast<s3520cf_device *>(ptr)->timer_callback();
-}
-
-//-------------------------------------------------
-// device_validity_check - perform validity checks
-// on this device
-//-------------------------------------------------
-
-void s3520cf_device::device_validity_check(validity_checker &valid) const
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void s3520cf_device::device_start()
-{
- /* let's call the timer callback every second for now */
- machine().scheduler().timer_pulse(attotime::from_hz(clock() / XTAL_32_768kHz), FUNC(rtc_inc_callback), 0, (void *)this);
-
- system_time systime;
- machine().base_datetime(systime);
-
- m_rtc.day = ((systime.local_time.mday / 10)<<4) | ((systime.local_time.mday % 10) & 0xf);
- m_rtc.month = (((systime.local_time.month+1) / 10) << 4) | (((systime.local_time.month+1) % 10) & 0xf);
- m_rtc.wday = systime.local_time.weekday;
- m_rtc.year = (((systime.local_time.year % 100)/10)<<4) | ((systime.local_time.year % 10) & 0xf);
- m_rtc.hour = ((systime.local_time.hour / 10)<<4) | ((systime.local_time.hour % 10) & 0xf);
- m_rtc.min = ((systime.local_time.minute / 10)<<4) | ((systime.local_time.minute % 10) & 0xf);
- m_rtc.sec = ((systime.local_time.second / 10)<<4) | ((systime.local_time.second % 10) & 0xf);
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void s3520cf_device::device_reset()
-{
- m_mode = 0;
-}
-
-//-------------------------------------------------
-// rtc_read - used to route RTC reading registers
-//-------------------------------------------------
-
-inline UINT8 s3520cf_device::rtc_read(UINT8 offset)
-{
- UINT8 res;
-
- res = 0;
-
- if(m_mode != 0)
- {
- if(offset == 0xf)
- res = (m_sysr << 3) | m_mode;
- else
- {
- res = 0;
- printf("Warning: S-3520CF RTC reads SRAM %02x %02x\n",offset,m_mode);
- }
- }
- else
- {
- switch(offset)
- {
- case 0x0: res = m_rtc.sec & 0xf; break;
- case 0x1: res = m_rtc.sec >> 4; break;
- case 0x2: res = m_rtc.min & 0xf; break;
- case 0x3: res = m_rtc.min >> 4; break;
- case 0x4: res = m_rtc.hour & 0xf; break;
- case 0x5: res = m_rtc.hour >> 4; break;
- case 0x6: res = m_rtc.wday & 0xf; break;
- case 0x7: res = m_rtc.day & 0xf; break;
- case 0x8: res = m_rtc.day >> 4; break;
- case 0x9: res = m_rtc.month & 0xf; break;
- case 0xa: res = m_rtc.month >> 4; break;
- case 0xb: res = m_rtc.year & 0xf; break;
- case 0xc: res = m_rtc.year >> 4; break;
- }
- }
-
- return res;
-}
-
-inline void s3520cf_device::rtc_write(UINT8 offset,UINT8 data)
-{
- if(offset == 0xf)
- {
- m_mode = data & 3;
- m_sysr = (data & 8) >> 3;
- printf("%02x\n",data);
- }
- else
- {
- if(m_mode != 0)
- printf("Warning: S-3520CF RTC writes SRAM %02x %d\n",offset,m_mode);
- }
-}
-
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-READ_LINE_MEMBER( s3520cf_device::read_bit )
-{
- return m_read_latch;
-}
-
-WRITE_LINE_MEMBER( s3520cf_device::set_dir_line )
-{
- //printf("%d DIR LINE\n",state);
-
- m_dir = state;
-}
-
-WRITE_LINE_MEMBER( s3520cf_device::set_cs_line )
-{
- m_reset_line = state;
-
- //printf("%d CS LINE\n",state);
-
- if(m_reset_line != CLEAR_LINE)
- {
- //printf("Reset asserted\n");
- m_current_cmd = 0;
- m_cmd_stream_pos = 0;
- m_rtc_state = RTC_SET_ADDRESS;
- //m_latch = 0;
- }
-}
-
-WRITE_LINE_MEMBER( s3520cf_device::write_bit )
-{
- m_latch = state;
-// printf("%d LATCH LINE\n",state);
-}
-
-WRITE_LINE_MEMBER( s3520cf_device::set_clock_line )
-{
- if(state == 1 && m_reset_line == CLEAR_LINE)
- {
- //printf("%d %d\n",m_latch, m_dir);
-
- switch(m_rtc_state)
- {
- case RTC_SET_ADDRESS:
- m_current_cmd = (m_current_cmd >> 1) | ((m_latch<<3)&8);
- m_cmd_stream_pos++;
-
- if(m_cmd_stream_pos == 4)
- {
- m_rtc_addr = (m_current_cmd) & 0xf;
- m_rtc_state = RTC_SET_DATA;
- m_cmd_stream_pos = 0;
- m_current_cmd = 0;
- }
- break;
- case RTC_SET_DATA:
- if(m_dir == 1) // READ
- {
- //if(m_cmd_stream_pos == 0)
- {
- //printf("%02x %d\n",m_rtc_addr,m_cmd_stream_pos);
- }
- m_read_latch = (rtc_read((m_rtc_addr+1) & 0xf) >> (m_cmd_stream_pos)) & 1; /* TODO: +1??? */
- }
-
- m_current_cmd = (m_current_cmd >> 1) | ((m_latch<<3)&8);
- m_cmd_stream_pos++;
- if(m_cmd_stream_pos == 4)
- {
- if(m_dir == 0) // WRITE
- {
- //printf("%02x %02x\n",m_rtc_addr,m_current_cmd);
- rtc_write((m_rtc_addr - 1) & 0xf,m_current_cmd); /* TODO: -1??? */
- }
-
- m_rtc_addr = m_current_cmd;
- m_rtc_state = RTC_SET_ADDRESS;
- m_cmd_stream_pos = 0;
- m_current_cmd = 0;
- }
- break;
- }
- }
-}
diff --git a/src/emu/machine/s3520cf.h b/src/emu/machine/s3520cf.h
deleted file mode 100644
index af7ba33a835..00000000000
--- a/src/emu/machine/s3520cf.h
+++ /dev/null
@@ -1,91 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Angelo Salese
-/***************************************************************************
-
-Seiko/Epson S-3520CF
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __S3520CFDEV_H__
-#define __S3520CFDEV_H__
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_S3520CF_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, S3520CF, XTAL_32_768kHz)
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-enum s3520cf_state_t
-{
- RTC_SET_ADDRESS = 0,
- RTC_SET_DATA
-};
-
-struct rtc_regs_t
-{
- UINT8 sec, min, hour, day, wday, month, year;
-};
-
-
-// ======================> s3520cf_device
-
-class s3520cf_device : public device_t
-{
-public:
- // construction/destruction
- s3520cf_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // I/O operations
- DECLARE_READ_LINE_MEMBER( read_bit );
- DECLARE_WRITE_LINE_MEMBER( set_dir_line );
- DECLARE_WRITE_LINE_MEMBER( set_cs_line );
- DECLARE_WRITE_LINE_MEMBER( set_clock_line );
- DECLARE_WRITE_LINE_MEMBER( write_bit );
- void timer_callback();
-
-protected:
- // device-level overrides
- virtual void device_validity_check(validity_checker &valid) const;
- virtual void device_start();
- virtual void device_reset();
- inline UINT8 rtc_read(UINT8 offset);
- inline void rtc_write(UINT8 offset,UINT8 data);
-
- static TIMER_CALLBACK( rtc_inc_callback );
-
- int m_dir;
- int m_latch;
- int m_reset_line;
- int m_read_latch;
- UINT8 m_current_cmd;
- UINT8 m_cmd_stream_pos;
- UINT8 m_rtc_addr;
- UINT8 m_mode, m_sysr;
-
- s3520cf_state_t m_rtc_state;
- rtc_regs_t m_rtc;
-
-};
-
-
-// device type definition
-extern const device_type S3520CF;
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-
-
-#endif
diff --git a/src/emu/machine/s3c2400.c b/src/emu/machine/s3c2400.c
deleted file mode 100644
index d47e81b08ce..00000000000
--- a/src/emu/machine/s3c2400.c
+++ /dev/null
@@ -1,140 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Schuerewegen
-/*******************************************************************************
-
- Samsung S3C2400
-
- (c) 2010 Tim Schuerewegen
-
-*******************************************************************************/
-
-#include "emu.h"
-#include "cpu/arm7/arm7.h"
-#include "cpu/arm7/arm7core.h"
-#include "machine/s3c2400.h"
-#include "sound/dac.h"
-
-#define VERBOSE_LEVEL ( 0 )
-
-INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ...)
-{
- if (VERBOSE_LEVEL >= n_level)
- {
- va_list v;
- char buf[32768];
- va_start( v, s_fmt);
- vsprintf( buf, s_fmt, v);
- va_end( v);
- logerror( "%s: %s", machine.describe_context( ), buf);
- }
-}
-
-#define DEVICE_S3C2400
-#define S3C24_CLASS_NAME s3c2400_device
-#include "machine/s3c24xx.inc"
-#undef DEVICE_S3C2400
-
-UINT32 s3c2400_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
-{
- return s3c24xx_video_update(screen, bitmap, cliprect);
-}
-
-const device_type S3C2400 = &device_creator<s3c2400_device>;
-
-s3c2400_device::s3c2400_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, S3C2400, "Samsung S3C2400", tag, owner, clock, "s3c2400", __FILE__),
- m_palette(*this),
- m_cpu(*this, ":maincpu"),
- m_pin_r_cb(*this),
- m_pin_w_cb(*this),
- m_port_r_cb(*this),
- m_port_w_cb(*this),
- m_scl_w_cb(*this),
- m_sda_r_cb(*this),
- m_sda_w_cb(*this),
- m_data_r_cb(*this),
- m_data_w_cb(*this),
- m_flags(0)
-{
- memset(&m_memcon, 0, sizeof(m_memcon));
- memset(&m_usbhost, 0, sizeof(m_usbhost));
- memset(&m_irq, 0, sizeof(m_irq));
- memset(m_dma, 0, sizeof(m_dma));
- memset(&m_clkpow, 0, sizeof(m_clkpow));
- memset(&m_lcd, 0, sizeof(m_lcd));
- memset(&m_lcdpal, 0, sizeof(m_lcdpal));
- memset(m_uart, 0, sizeof(m_uart));
- memset(&m_pwm, 0, sizeof(m_pwm));
- memset(&m_usbdev, 0, sizeof(m_usbdev));
- memset(&m_wdt, 0, sizeof(m_wdt));
- memset(&m_iic, 0, sizeof(m_iic));
- memset(&m_iis, 0, sizeof(m_iis));
- memset(&m_gpio, 0, sizeof(m_gpio));
- memset(&m_rtc, 0, sizeof(m_rtc));
- memset(&m_adc, 0, sizeof(m_adc));
- memset(m_spi, 0, sizeof(m_spi));
- memset(&m_mmc, 0, sizeof(m_mmc));
-}
-
-s3c2400_device::~s3c2400_device()
-{
-}
-
-//-------------------------------------------------
-// static_set_palette_tag: Set the tag of the
-// palette device
-//-------------------------------------------------
-
-void s3c2400_device::static_set_palette_tag(device_t &device, const char *tag)
-{
- downcast<s3c2400_device &>(device).m_palette.set_tag(tag);
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void s3c2400_device::device_start()
-{
- s3c24xx_device_start();
-
- address_space &space = m_cpu->memory().space( AS_PROGRAM);
- space.install_readwrite_handler(0x14000000, 0x1400003b, read32_delegate(FUNC(s3c2400_device::s3c24xx_memcon_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_memcon_w), this));
- space.install_readwrite_handler(0x14200000, 0x1420005b, read32_delegate(FUNC(s3c2400_device::s3c24xx_usb_host_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_usb_host_w), this));
- space.install_readwrite_handler(0x14400000, 0x14400017, read32_delegate(FUNC(s3c2400_device::s3c24xx_irq_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_irq_w), this));
- space.install_readwrite_handler(0x14600000, 0x1460001b, read32_delegate(FUNC(s3c2400_device::s3c24xx_dma_0_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_dma_0_w), this));
- space.install_readwrite_handler(0x14600020, 0x1460003b, read32_delegate(FUNC(s3c2400_device::s3c24xx_dma_1_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_dma_1_w), this));
- space.install_readwrite_handler(0x14600040, 0x1460005b, read32_delegate(FUNC(s3c2400_device::s3c24xx_dma_2_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_dma_2_w), this));
- space.install_readwrite_handler(0x14600060, 0x1460007b, read32_delegate(FUNC(s3c2400_device::s3c24xx_dma_3_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_dma_3_w), this));
- space.install_readwrite_handler(0x14800000, 0x14800017, read32_delegate(FUNC(s3c2400_device::s3c24xx_clkpow_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_clkpow_w), this));
- space.install_readwrite_handler(0x14a00000, 0x14a003ff, read32_delegate(FUNC(s3c2400_device::s3c24xx_lcd_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_lcd_w), this));
- space.install_readwrite_handler(0x14a00400, 0x14a007ff, read32_delegate(FUNC(s3c2400_device::s3c24xx_lcd_palette_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_lcd_palette_w), this));
- space.install_readwrite_handler(0x15000000, 0x1500002b, read32_delegate(FUNC(s3c2400_device::s3c24xx_uart_0_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_uart_0_w), this));
- space.install_readwrite_handler(0x15004000, 0x1500402b, read32_delegate(FUNC(s3c2400_device::s3c24xx_uart_1_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_uart_1_w), this));
- space.install_readwrite_handler(0x15100000, 0x15100043, read32_delegate(FUNC(s3c2400_device::s3c24xx_pwm_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_pwm_w), this));
- space.install_readwrite_handler(0x15200140, 0x152001fb, read32_delegate(FUNC(s3c2400_device::s3c24xx_usb_device_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_usb_device_w), this));
- space.install_readwrite_handler(0x15300000, 0x1530000b, read32_delegate(FUNC(s3c2400_device::s3c24xx_wdt_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_wdt_w), this));
- space.install_readwrite_handler(0x15400000, 0x1540000f, read32_delegate(FUNC(s3c2400_device::s3c24xx_iic_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_iic_w), this));
- space.install_readwrite_handler(0x15508000, 0x15508013, read32_delegate(FUNC(s3c2400_device::s3c24xx_iis_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_iis_w), this));
- space.install_readwrite_handler(0x15600000, 0x1560005b, read32_delegate(FUNC(s3c2400_device::s3c24xx_gpio_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_gpio_w), this));
- space.install_readwrite_handler(0x15700040, 0x1570008b, read32_delegate(FUNC(s3c2400_device::s3c24xx_rtc_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_rtc_w), this));
- space.install_readwrite_handler(0x15800000, 0x15800007, read32_delegate(FUNC(s3c2400_device::s3c24xx_adc_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_adc_w), this));
- space.install_readwrite_handler(0x15900000, 0x15900017, read32_delegate(FUNC(s3c2400_device::s3c24xx_spi_0_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_spi_0_w), this));
- space.install_readwrite_handler(0x15a00000, 0x15a0003f, read32_delegate(FUNC(s3c2400_device::s3c24xx_mmc_r), this), write32_delegate(FUNC(s3c2400_device::s3c24xx_mmc_w), this));
-
- s3c24xx_video_start();
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void s3c2400_device::device_reset()
-{
- s3c24xx_device_reset();
-}
-
-void s3c2400_device::s3c2400_uart_fifo_w(int uart, UINT8 data)
-{
- s3c24xx_uart_fifo_w(uart, data);
-}
diff --git a/src/emu/machine/s3c2400.h b/src/emu/machine/s3c2400.h
deleted file mode 100644
index f274e5ad36d..00000000000
--- a/src/emu/machine/s3c2400.h
+++ /dev/null
@@ -1,894 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Schuerewegen
-/*******************************************************************************
-
- Samsung S3C2400
-
-*******************************************************************************/
-
-#ifndef __S3C2400_H__
-#define __S3C2400_H__
-
-
-/*******************************************************************************
- MACROS / CONSTANTS
-*******************************************************************************/
-
-#define S3C2400_TAG "s3c2400"
-
-#define MCFG_S3C2400_PALETTE(_palette_tag) \
- s3c2400_device::static_set_palette_tag(*device, "^" _palette_tag);
-
-#define MCFG_S3C2400_CORE_PIN_R_CB(_devcb) \
- devcb = &s3c2400_device::set_core_pin_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2400_CORE_PIN_W_CB(_devcb) \
- devcb = &s3c2400_device::set_core_pin_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2400_GPIO_PORT_R_CB(_devcb) \
- devcb = &s3c2400_device::set_gpio_port_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2400_GPIO_PORT_W_CB(_devcb) \
- devcb = &s3c2400_device::set_gpio_port_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2400_I2C_SCL_W_CB(_devcb) \
- devcb = &s3c2400_device::set_i2c_scl_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2400_I2C_SDA_R_CB(_devcb) \
- devcb = &s3c2400_device::set_i2c_sda_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2400_I2C_SDA_W_CB(_devcb) \
- devcb = &s3c2400_device::set_i2c_sda_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2400_ADC_DATA_R_CB(_devcb) \
- devcb = &s3c2400_device::set_adc_data_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2400_I2S_DATA_W_CB(_devcb) \
- devcb = &s3c2400_device::set_i2s_data_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2400_LCD_FLAGS(_flags) \
- s3c2400_device::set_lcd_flags(*device, _flags);
-
-enum
-{
- S3C2400_GPIO_PORT_A = 0,
- S3C2400_GPIO_PORT_B,
- S3C2400_GPIO_PORT_C,
- S3C2400_GPIO_PORT_D,
- S3C2400_GPIO_PORT_E,
- S3C2400_GPIO_PORT_F,
- S3C2400_GPIO_PORT_G
-};
-
-
-/*******************************************************************************
- MACROS & CONSTANTS
-*******************************************************************************/
-
-/* Interface */
-
-#define S3C24XX_INTERFACE_LCD_REVERSE 1
-
-/* Memory Controller */
-
-#define S3C24XX_BASE_MEMCON 0x14000000
-
-/* USB Host Controller */
-
-#define S3C24XX_BASE_USBHOST 0x14200000
-
-/* Interrupt Controller */
-
-#define S3C24XX_BASE_INT 0x14400000
-
-#define S3C24XX_SRCPND (0x00 / 4) // Interrupt Request Status
-#define S3C24XX_INTMOD (0x04 / 4) // Interrupt Mode Control
-#define S3C24XX_INTMSK (0x08 / 4) // Interrupt Mask Control
-#define S3C24XX_PRIORITY (0x0C / 4) // IRQ Priority Control
-#define S3C24XX_INTPND (0x10 / 4) // Interrupt Request Status
-#define S3C24XX_INTOFFSET (0x14 / 4) // Interrupt Request Source Offset
-
-/* DMA */
-
-#define S3C24XX_BASE_DMA_0 0x14600000
-#define S3C24XX_BASE_DMA_1 0x14600020
-#define S3C24XX_BASE_DMA_2 0x14600040
-#define S3C24XX_BASE_DMA_3 0x14600060
-
-#define S3C24XX_DISRC (0x00 / 4) // DMA Initial Source
-#define S3C24XX_DIDST (0x04 / 4) // DMA Initial Destination
-#define S3C24XX_DCON (0x08 / 4) // DMA Control
-#define S3C24XX_DSTAT (0x0C / 4) // DMA Count
-#define S3C24XX_DCSRC (0x10 / 4) // DMA Current Source Address
-#define S3C24XX_DCDST (0x14 / 4) // DMA Current Destination Address
-#define S3C24XX_DMASKTRIG (0x18 / 4) // DMA Mask Trigger
-
-/* Clock & Power Management */
-
-#define S3C24XX_BASE_CLKPOW 0x14800000
-
-#define S3C24XX_LOCKTIME (0x00 / 4) // PLL Lock Time Counter
-#define S3C24XX_MPLLCON (0x04 / 4) // MPLL Control
-#define S3C24XX_UPLLCON (0x08 / 4) // UPLL Control
-#define S3C24XX_CLKCON (0x0C / 4) // Clock Generator Control
-#define S3C24XX_CLKSLOW (0x10 / 4) // Slow Clock Control
-#define S3C24XX_CLKDIVN (0x14 / 4) // Clock Divider Control
-
-/* LCD Controller */
-
-#define S3C24XX_BASE_LCD 0x14a00000
-#define S3C24XX_BASE_LCDPAL 0x14a00400
-
-#define S3C24XX_LCDCON1 (0x00 / 4) // LCD Control 1
-#define S3C24XX_LCDCON2 (0x04 / 4) // LCD Control 2
-#define S3C24XX_LCDCON3 (0x08 / 4) // LCD Control 3
-#define S3C24XX_LCDCON4 (0x0C / 4) // LCD Control 4
-#define S3C24XX_LCDCON5 (0x10 / 4) // LCD Control 5
-#define S3C24XX_LCDSADDR1 (0x14 / 4) // STN/TFT: Frame Buffer Start Address 1
-#define S3C24XX_LCDSADDR2 (0x18 / 4) // STN/TFT: Frame Buffer Start Address 2
-#define S3C24XX_LCDSADDR3 (0x1C / 4) // STN/TFT: Virtual Screen Address Set
-#define S3C24XX_REDLUT (0x20 / 4) // STN: Red Lookup Table
-#define S3C24XX_GREENLUT (0x24 / 4) // STN: Green Lookup Table
-#define S3C24XX_BLUELUT (0x28 / 4) // STN: Blue Lookup Table
-#define S3C24XX_DITHMODE (0x4C / 4) // STN: Dithering Mode
-#define S3C24XX_TPAL (0x50 / 4) // TFT: Temporary Palette
-
-/* UART */
-
-#define S3C24XX_BASE_UART_0 0x15000000
-#define S3C24XX_BASE_UART_1 0x15004000
-
-#define S3C24XX_ULCON (0x00 / 4) // UART Line Control
-#define S3C24XX_UCON (0x04 / 4) // UART Control
-#define S3C24XX_UFCON (0x08 / 4) // UART FIFO Control
-#define S3C24XX_UMCON (0x0C / 4) // UART Modem Control
-#define S3C24XX_UTRSTAT (0x10 / 4) // UART Tx/Rx Status
-#define S3C24XX_UERSTAT (0x14 / 4) // UART Rx Error Status
-#define S3C24XX_UFSTAT (0x18 / 4) // UART FIFO Status
-#define S3C24XX_UMSTAT (0x1C / 4) // UART Modem Status
-#define S3C24XX_UTXH (0x20 / 4) // UART Transmission Hold
-#define S3C24XX_URXH (0x24 / 4) // UART Receive Buffer
-#define S3C24XX_UBRDIV (0x28 / 4) // UART Baud Rate Divisor
-
-/* PWM Timer */
-
-#define S3C24XX_BASE_PWM 0x15100000
-
-#define S3C24XX_TCFG0 (0x00 / 4) // Timer Configuration
-#define S3C24XX_TCFG1 (0x04 / 4) // Timer Configuration
-#define S3C24XX_TCON (0x08 / 4) // Timer Control
-#define S3C24XX_TCNTB0 (0x0C / 4) // Timer Count Buffer 0
-#define S3C24XX_TCMPB0 (0x10 / 4) // Timer Compare Buffer 0
-#define S3C24XX_TCNTO0 (0x14 / 4) // Timer Count Observation 0
-#define S3C24XX_TCNTB1 (0x18 / 4) // Timer Count Buffer 1
-#define S3C24XX_TCMPB1 (0x1C / 4) // Timer Compare Buffer 1
-#define S3C24XX_TCNTO1 (0x20 / 4) // Timer Count Observation 1
-#define S3C24XX_TCNTB2 (0x24 / 4) // Timer Count Buffer 2
-#define S3C24XX_TCMPB2 (0x28 / 4) // Timer Compare Buffer 2
-#define S3C24XX_TCNTO2 (0x2C / 4) // Timer Count Observation 2
-#define S3C24XX_TCNTB3 (0x30 / 4) // Timer Count Buffer 3
-#define S3C24XX_TCMPB3 (0x34 / 4) // Timer Compare Buffer 3
-#define S3C24XX_TCNTO3 (0x38 / 4) // Timer Count Observation 3
-#define S3C24XX_TCNTB4 (0x3C / 4) // Timer Count Buffer 4
-#define S3C24XX_TCNTO4 (0x40 / 4) // Timer Count Observation 4
-
-/* USB Device */
-
-#define S3C24XX_BASE_USBDEV 0x15200140
-
-/* Watchdog Timer */
-
-#define S3C24XX_BASE_WDT 0x15300000
-
-#define S3C24XX_WTCON (0x00 / 4) // Watchdog Timer Mode
-#define S3C24XX_WTDAT (0x04 / 4) // Watchdog Timer Data
-#define S3C24XX_WTCNT (0x08 / 4) // Watchdog Timer Count
-
-/* IIC */
-
-#define S3C24XX_BASE_IIC 0x15400000
-
-#define S3C24XX_IICCON (0x00 / 4) // IIC Control
-#define S3C24XX_IICSTAT (0x04 / 4) // IIC Status
-#define S3C24XX_IICADD (0x08 / 4) // IIC Address
-#define S3C24XX_IICDS (0x0C / 4) // IIC Data Shift
-
-/* IIS */
-
-#define S3C24XX_BASE_IIS 0x15508000
-
-#define S3C24XX_IISCON (0x00 / 4) // IIS Control
-#define S3C24XX_IISMOD (0x04 / 4) // IIS Mode
-#define S3C24XX_IISPSR (0x08 / 4) // IIS Prescaler
-#define S3C24XX_IISFCON (0x0C / 4) // IIS FIFO Control
-#define S3C24XX_IISFIFO (0x10 / 4) // IIS FIFO Entry
-
-/* I/O Port */
-
-#define S3C24XX_BASE_GPIO 0x15600000
-
-#define S3C24XX_GPACON (0x00 / 4) // Port A Control
-#define S3C24XX_GPADAT (0x04 / 4) // Port A Data
-#define S3C24XX_GPBCON (0x08 / 4) // Port B Control
-#define S3C24XX_GPBDAT (0x0C / 4) // Port B Data
-#define S3C24XX_GPBUP (0x10 / 4) // Pull-up Control B
-#define S3C24XX_GPCCON (0x14 / 4) // Port C Control
-#define S3C24XX_GPCDAT (0x18 / 4) // Port C Data
-#define S3C24XX_GPCUP (0x1C / 4) // Pull-up Control C
-#define S3C24XX_GPDCON (0x20 / 4) // Port D Control
-#define S3C24XX_GPDDAT (0x24 / 4) // Port D Data
-#define S3C24XX_GPDUP (0x28 / 4) // Pull-up Control D
-#define S3C24XX_GPECON (0x2C / 4) // Port E Control
-#define S3C24XX_GPEDAT (0x30 / 4) // Port E Data
-#define S3C24XX_GPEUP (0x34 / 4) // Pull-up Control E
-#define S3C24XX_GPFCON (0x38 / 4) // Port F Control
-#define S3C24XX_GPFDAT (0x3C / 4) // Port F Data
-#define S3C24XX_GPFUP (0x40 / 4) // Pull-up Control F
-#define S3C24XX_GPGCON (0x44 / 4) // Port G Control
-#define S3C24XX_GPGDAT (0x48 / 4) // Port G Data
-#define S3C24XX_GPGUP (0x4C / 4) // Pull-up Control G
-#define S3C24XX_OPENCR (0x50 / 4) // Open Drain Enable
-#define S3C24XX_MISCCR (0x54 / 4) // Miscellaneous Control
-#define S3C24XX_EXTINT (0x58 / 4) // External Interrupt Control
-
-#define S3C24XX_GPADAT_MASK 0x0003FFFF
-#define S3C24XX_GPBDAT_MASK 0x0000FFFF
-#define S3C24XX_GPCDAT_MASK 0x0000FFFF
-#define S3C24XX_GPDDAT_MASK 0x000007FF
-#define S3C24XX_GPEDAT_MASK 0x00000FFF
-#define S3C24XX_GPFDAT_MASK 0x0000007F
-#define S3C24XX_GPGDAT_MASK 0x000003FF
-
-/* RTC */
-
-#define S3C24XX_BASE_RTC 0x15700040
-
-#define S3C24XX_RTCCON (0x00 / 4) // RTC Control
-#define S3C24XX_TICNT (0x04 / 4) // Tick Time count
-#define S3C24XX_RTCALM (0x10 / 4) // RTC Alarm Control
-#define S3C24XX_ALMSEC (0x14 / 4) // Alarm Second
-#define S3C24XX_ALMMIN (0x18 / 4) // Alarm Minute
-#define S3C24XX_ALMHOUR (0x1C / 4) // Alarm Hour
-#define S3C24XX_ALMDAY (0x20 / 4) // Alarm Day
-#define S3C24XX_ALMMON (0x24 / 4) // Alarm Month
-#define S3C24XX_ALMYEAR (0x28 / 4) // Alarm Year
-#define S3C24XX_RTCRST (0x2C / 4) // RTC Round Reset
-#define S3C24XX_BCDSEC (0x30 / 4) // BCD Second
-#define S3C24XX_BCDMIN (0x34 / 4) // BCD Minute
-#define S3C24XX_BCDHOUR (0x38 / 4) // BCD Hour
-#define S3C24XX_BCDDAY (0x3C / 4) // BCD Day
-#define S3C24XX_BCDDOW (0x40 / 4) // BCD Day of Week
-#define S3C24XX_BCDMON (0x44 / 4) // BCD Month
-#define S3C24XX_BCDYEAR (0x48 / 4) // BCD Year
-
-/* A/D Converter */
-
-#define S3C24XX_BASE_ADC 0x15800000
-
-#define S3C24XX_ADCCON (0x00 / 4) // ADC Control
-#define S3C24XX_ADCDAT (0x04 / 4) // ADC Data
-
-/* SPI */
-
-#define S3C24XX_BASE_SPI_0 0x15900000
-
-#define S3C24XX_SPCON (0x00 / 4) // SPI Control
-#define S3C24XX_SPSTA (0x04 / 4) // SPI Status
-#define S3C24XX_SPPIN (0x08 / 4) // SPI Pin Control
-#define S3C24XX_SPPRE (0x0C / 4) // SPI Baud Rate Prescaler
-#define S3C24XX_SPTDAT (0x10 / 4) // SPI Tx Data
-#define S3C24XX_SPRDAT (0x14 / 4) // SPI Rx Data
-
-/* MMC Interface */
-
-#define S3C24XX_BASE_MMC 0x15a00000
-
-/* ... */
-
-#define S3C24XX_INT_ADC 31
-#define S3C24XX_INT_RTC 30
-#define S3C24XX_INT_UTXD1 29
-#define S3C24XX_INT_UTXD0 28
-#define S3C24XX_INT_IIC 27
-#define S3C24XX_INT_USBH 26
-#define S3C24XX_INT_USBD 25
-#define S3C24XX_INT_URXD1 24
-#define S3C24XX_INT_URXD0 23
-#define S3C24XX_INT_SPI 22
-#define S3C24XX_INT_MMC 21
-#define S3C24XX_INT_DMA3 20
-#define S3C24XX_INT_DMA2 19
-#define S3C24XX_INT_DMA1 18
-#define S3C24XX_INT_DMA0 17
-#define S3C24XX_INT_RESERVED 16
-#define S3C24XX_INT_UERR 15
-#define S3C24XX_INT_TIMER4 14
-#define S3C24XX_INT_TIMER3 13
-#define S3C24XX_INT_TIMER2 12
-#define S3C24XX_INT_TIMER1 11
-#define S3C24XX_INT_TIMER0 10
-#define S3C24XX_INT_WDT 9
-#define S3C24XX_INT_TICK 8
-#define S3C24XX_INT_EINT7 7
-#define S3C24XX_INT_EINT6 6
-#define S3C24XX_INT_EINT5 5
-#define S3C24XX_INT_EINT4 4
-#define S3C24XX_INT_EINT3 3
-#define S3C24XX_INT_EINT2 2
-#define S3C24XX_INT_EINT1 1
-#define S3C24XX_INT_EINT0 0
-
-#define S3C24XX_BPPMODE_STN_01 0x00
-#define S3C24XX_BPPMODE_STN_02 0x01
-#define S3C24XX_BPPMODE_STN_04 0x02
-#define S3C24XX_BPPMODE_STN_08 0x03
-#define S3C24XX_BPPMODE_STN_12_P 0x04
-#define S3C24XX_BPPMODE_STN_12_U 0x05
-#define S3C24XX_BPPMODE_STN_16 0x06
-#define S3C24XX_BPPMODE_TFT_01 0x08
-#define S3C24XX_BPPMODE_TFT_02 0x09
-#define S3C24XX_BPPMODE_TFT_04 0x0A
-#define S3C24XX_BPPMODE_TFT_08 0x0B
-#define S3C24XX_BPPMODE_TFT_16 0x0C
-#define S3C24XX_BPPMODE_TFT_24 0x0D
-
-#define S3C24XX_PNRMODE_STN_04_DS 0
-#define S3C24XX_PNRMODE_STN_04_SS 1
-#define S3C24XX_PNRMODE_STN_08_SS 2
-#define S3C24XX_PNRMODE_TFT 3
-
-#define S3C24XX_GPIO_PORT_A S3C2400_GPIO_PORT_A
-#define S3C24XX_GPIO_PORT_B S3C2400_GPIO_PORT_B
-#define S3C24XX_GPIO_PORT_C S3C2400_GPIO_PORT_C
-#define S3C24XX_GPIO_PORT_D S3C2400_GPIO_PORT_D
-#define S3C24XX_GPIO_PORT_E S3C2400_GPIO_PORT_E
-#define S3C24XX_GPIO_PORT_F S3C2400_GPIO_PORT_F
-#define S3C24XX_GPIO_PORT_G S3C2400_GPIO_PORT_G
-
-#define S3C24XX_UART_COUNT 2
-#define S3C24XX_DMA_COUNT 4
-#define S3C24XX_SPI_COUNT 1
-
-class s3c2400_device : public device_t
-{
-public:
- s3c2400_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~s3c2400_device();
-
- // static configuration
- static void static_set_palette_tag(device_t &device, const char *tag);
- template<class _Object> static devcb_base &set_core_pin_r_callback(device_t &device, _Object object) { return downcast<s3c2400_device &>(device).m_pin_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_core_pin_w_callback(device_t &device, _Object object) { return downcast<s3c2400_device &>(device).m_pin_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_gpio_port_r_callback(device_t &device, _Object object) { return downcast<s3c2400_device &>(device).m_port_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_gpio_port_w_callback(device_t &device, _Object object) { return downcast<s3c2400_device &>(device).m_port_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2c_scl_w_callback(device_t &device, _Object object) { return downcast<s3c2400_device &>(device).m_scl_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2c_sda_r_callback(device_t &device, _Object object) { return downcast<s3c2400_device &>(device).m_sda_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2c_sda_w_callback(device_t &device, _Object object) { return downcast<s3c2400_device &>(device).m_sda_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_adc_data_r_callback(device_t &device, _Object object) { return downcast<s3c2400_device &>(device).m_data_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2s_data_w_callback(device_t &device, _Object object) { return downcast<s3c2400_device &>(device).m_data_w_cb.set_callback(object); }
- static void set_lcd_flags(device_t &device, int flags) { downcast<s3c2400_device &>(device).m_flags = flags; }
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-private:
- // internal state
- required_device<palette_device> m_palette;
-public:
- UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
-
- void s3c24xx_reset();
- inline int iface_core_pin_r(int pin);
- void s3c24xx_lcd_reset();
- rgb_t s3c24xx_get_color_tft_16(UINT16 data);
- rgb_t s3c24xx_get_color_stn_12(UINT16 data);
- rgb_t s3c24xx_get_color_stn_08( UINT8 data);
- rgb_t s3c24xx_get_color_stn_01(UINT8 data);
- rgb_t s3c24xx_get_color_stn_02(UINT8 data);
- rgb_t s3c24xx_get_color_stn_04(UINT8 data);
- rgb_t s3c24xx_get_color_tpal();
- void s3c24xx_lcd_dma_reload();
- void s3c24xx_lcd_dma_init();
- UINT32 s3c24xx_lcd_dma_read();
- UINT32 s3c24xx_lcd_dma_read_bits(int count);
- void s3c24xx_lcd_render_tpal();
- void s3c24xx_lcd_render_stn_01();
- void s3c24xx_lcd_render_stn_02();
- void s3c24xx_lcd_render_stn_04();
- void s3c24xx_lcd_render_stn_08();
- void s3c24xx_lcd_render_stn_12_p();
- void s3c24xx_lcd_render_stn_12_u(); // not tested
- void s3c24xx_lcd_render_tft_01();
- void s3c24xx_lcd_render_tft_02();
- void s3c24xx_lcd_render_tft_04();
- void s3c24xx_lcd_render_tft_08();
- void s3c24xx_lcd_render_tft_16();
- TIMER_CALLBACK_MEMBER( s3c24xx_lcd_timer_exp );
- void s3c24xx_video_start();
- void bitmap_blend( bitmap_rgb32 &bitmap_dst, bitmap_rgb32 &bitmap_src_1, bitmap_rgb32 &bitmap_src_2);
- UINT32 s3c24xx_video_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
- READ32_MEMBER( s3c24xx_lcd_r );
- int s3c24xx_lcd_configure_tft();
- int s3c24xx_lcd_configure_stn();
- int s3c24xx_lcd_configure();
- void s3c24xx_lcd_start();
- void s3c24xx_lcd_stop();
- void s3c24xx_lcd_recalc();
- WRITE32_MEMBER( s3c24xx_lcd_w );
- READ32_MEMBER( s3c24xx_lcd_palette_r );
- WRITE32_MEMBER( s3c24xx_lcd_palette_w );
- void s3c24xx_clkpow_reset();
- UINT32 s3c24xx_get_fclk();
- UINT32 s3c24xx_get_hclk();
- UINT32 s3c24xx_get_pclk();
- READ32_MEMBER( s3c24xx_clkpow_r );
- WRITE32_MEMBER( s3c24xx_clkpow_w );
- void s3c24xx_irq_reset();
- void s3c24xx_check_pending_irq();
- void s3c24xx_request_irq(UINT32 int_type);
- READ32_MEMBER( s3c24xx_irq_r );
- WRITE32_MEMBER( s3c24xx_irq_w );
- void s3c24xx_pwm_reset();
- UINT16 s3c24xx_pwm_calc_observation(int ch);
- READ32_MEMBER( s3c24xx_pwm_r );
- void s3c24xx_pwm_start(int timer);
- void s3c24xx_pwm_stop(int timer);
- void s3c24xx_pwm_recalc(int timer);
- WRITE32_MEMBER( s3c24xx_pwm_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_pwm_timer_exp );
- void s3c24xx_dma_reset();
- void s3c24xx_dma_reload(int ch);
- void s3c24xx_dma_trigger(int ch);
- void s3c24xx_dma_request_iis();
- void s3c24xx_dma_request_pwm();
- void s3c24xx_dma_start(int ch);
- void s3c24xx_dma_stop(int ch);
- void s3c24xx_dma_recalc(int ch);
- UINT32 s3c24xx_dma_r(UINT32 ch, UINT32 offset);
- void s3c24xx_dma_w(UINT32 ch, UINT32 offset, UINT32 data, UINT32 mem_mask);
- READ32_MEMBER( s3c24xx_dma_0_r );
- READ32_MEMBER( s3c24xx_dma_1_r );
- READ32_MEMBER( s3c24xx_dma_2_r );
- READ32_MEMBER( s3c24xx_dma_3_r );
- WRITE32_MEMBER( s3c24xx_dma_0_w );
- WRITE32_MEMBER( s3c24xx_dma_1_w );
- WRITE32_MEMBER( s3c24xx_dma_2_w );
- WRITE32_MEMBER( s3c24xx_dma_3_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_dma_timer_exp );
- void s3c24xx_gpio_reset();
- inline UINT32 iface_gpio_port_r(int port, UINT32 mask);
- inline void iface_gpio_port_w(int port, UINT32 mask, UINT32 data);
- UINT16 s3c24xx_gpio_get_mask( UINT32 con, int val);
- READ32_MEMBER( s3c24xx_gpio_r );
- WRITE32_MEMBER( s3c24xx_gpio_w );
- void s3c24xx_memcon_reset();
- READ32_MEMBER( s3c24xx_memcon_r );
- WRITE32_MEMBER( s3c24xx_memcon_w );
- void s3c24xx_usb_host_reset();
- READ32_MEMBER( s3c24xx_usb_host_r );
- WRITE32_MEMBER( s3c24xx_usb_host_w );
- void s3c24xx_uart_reset();
- UINT32 s3c24xx_uart_r(UINT32 ch, UINT32 offset);
- void s3c24xx_uart_w(UINT32 ch, UINT32 offset, UINT32 data, UINT32 mem_mask);
- READ32_MEMBER( s3c24xx_uart_0_r );
- READ32_MEMBER( s3c24xx_uart_1_r );
- WRITE32_MEMBER( s3c24xx_uart_0_w );
- WRITE32_MEMBER( s3c24xx_uart_1_w );
- void s3c24xx_uart_fifo_w(int uart, UINT8 data);
- void s3c24xx_usb_device_reset();
- READ32_MEMBER( s3c24xx_usb_device_r );
- WRITE32_MEMBER( s3c24xx_usb_device_w );
- void s3c24xx_wdt_reset();
- UINT16 s3c24xx_wdt_calc_current_count();
- READ32_MEMBER( s3c24xx_wdt_r );
- void s3c24xx_wdt_start();
- void s3c24xx_wdt_stop();
- void s3c24xx_wdt_recalc();
- WRITE32_MEMBER( s3c24xx_wdt_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_wdt_timer_exp );
- void s3c24xx_iic_reset();
- inline void iface_i2c_scl_w( int state);
- inline void iface_i2c_sda_w(int state);
- inline int iface_i2c_sda_r();
- void i2c_send_start();
- void i2c_send_stop();
- UINT8 i2c_receive_byte(int ack);
- int i2c_send_byte(UINT8 data);
- void iic_start();
- void iic_stop();
- void iic_resume();
- READ32_MEMBER( s3c24xx_iic_r );
- WRITE32_MEMBER( s3c24xx_iic_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_iic_timer_exp );
- void s3c24xx_iis_reset();
- inline void iface_i2s_data_w(int ch, UINT16 data);
- void s3c24xx_iis_start();
- void s3c24xx_iis_stop();
- void s3c24xx_iis_recalc();
- READ32_MEMBER( s3c24xx_iis_r );
- WRITE32_MEMBER( s3c24xx_iis_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_iis_timer_exp );
- void s3c24xx_rtc_reset();
- READ32_MEMBER( s3c24xx_rtc_r );
- void s3c24xx_rtc_recalc();
- WRITE32_MEMBER( s3c24xx_rtc_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_rtc_timer_tick_count_exp );
- void s3c24xx_rtc_update();
- void s3c24xx_rtc_check_alarm();
- TIMER_CALLBACK_MEMBER( s3c24xx_rtc_timer_update_exp );
- void s3c24xx_adc_reset();
- UINT32 iface_adc_data_r(int ch);
- READ32_MEMBER( s3c24xx_adc_r );
- void s3c24xx_adc_start();
- WRITE32_MEMBER( s3c24xx_adc_w );
- void s3c24xx_spi_reset();
- UINT32 s3c24xx_spi_r(UINT32 ch, UINT32 offset);
- void s3c24xx_spi_w(UINT32 ch, UINT32 offset, UINT32 data, UINT32 mem_mask);
- READ32_MEMBER( s3c24xx_spi_0_r );
- WRITE32_MEMBER( s3c24xx_spi_0_w );
- void s3c24xx_mmc_reset();
- READ32_MEMBER( s3c24xx_mmc_r );
- WRITE32_MEMBER( s3c24xx_mmc_w );
- void s3c24xx_device_reset();
- void s3c24xx_device_start();
-
-
- void s3c2400_uart_fifo_w(int uart, UINT8 data);
-
- /*******************************************************************************
- TYPE DEFINITIONS
- *******************************************************************************/
-
- struct s3c24xx_memcon_regs_t
- {
- UINT32 data[0x34/4];
- };
-
- struct s3c24xx_usbhost_regs_t
- {
- UINT32 data[0x5C/4];
- };
-
- struct s3c24xx_irq_regs_t
- {
- UINT32 srcpnd;
- UINT32 intmod;
- UINT32 intmsk;
- UINT32 priority;
- UINT32 intpnd;
- UINT32 intoffset;
- };
-
- struct s3c24xx_dma_regs_t
- {
- UINT32 disrc;
- UINT32 didst;
- UINT32 dcon;
- UINT32 dstat;
- UINT32 dcsrc;
- UINT32 dcdst;
- UINT32 dmasktrig;
- };
-
- struct s3c24xx_clkpow_regs_t
- {
- UINT32 locktime;
- UINT32 mpllcon;
- UINT32 upllcon;
- UINT32 clkcon;
- UINT32 clkslow;
- UINT32 clkdivn;
- };
-
- struct s3c24xx_lcd_regs_t
- {
- UINT32 lcdcon1;
- UINT32 lcdcon2;
- UINT32 lcdcon3;
- UINT32 lcdcon4;
- UINT32 lcdcon5;
- UINT32 lcdsaddr1;
- UINT32 lcdsaddr2;
- UINT32 lcdsaddr3;
- UINT32 redlut;
- UINT32 greenlut;
- UINT32 bluelut;
- UINT32 reserved[8];
- UINT32 dithmode;
- UINT32 tpal;
- };
-
- struct s3c24xx_lcdpal_regs_t
- {
- UINT32 data[0x400/4];
- };
-
- struct s3c24xx_uart_regs_t
- {
- UINT32 ulcon;
- UINT32 ucon;
- UINT32 ufcon;
- UINT32 umcon;
- UINT32 utrstat;
- UINT32 uerstat;
- UINT32 ufstat;
- UINT32 umstat;
- UINT32 utxh;
- UINT32 urxh;
- UINT32 ubrdiv;
- };
-
- struct s3c24xx_pwm_regs_t
- {
- UINT32 tcfg0;
- UINT32 tcfg1;
- UINT32 tcon;
- UINT32 tcntb0;
- UINT32 tcmpb0;
- UINT32 tcnto0;
- UINT32 tcntb1;
- UINT32 tcmpb1;
- UINT32 tcnto1;
- UINT32 tcntb2;
- UINT32 tcmpb2;
- UINT32 tcnto2;
- UINT32 tcntb3;
- UINT32 tcmpb3;
- UINT32 tcnto3;
- UINT32 tcntb4;
- UINT32 tcnto4;
- };
-
- struct s3c24xx_usbdev_regs_t
- {
- UINT32 data[0xBC/4];
- };
-
- struct s3c24xx_wdt_regs_t
- {
- UINT32 wtcon;
- UINT32 wtdat;
- UINT32 wtcnt;
- };
-
- struct s3c24xx_iic_regs_t
- {
- UINT32 iiccon;
- UINT32 iicstat;
- UINT32 iicadd;
- UINT32 iicds;
- };
-
- struct s3c24xx_iis_regs_t
- {
- UINT32 iiscon;
- UINT32 iismod;
- UINT32 iispsr;
- UINT32 iisfcon;
- UINT32 iisfifo;
- };
-
- struct s3c24xx_gpio_regs_t
- {
- UINT32 gpacon;
- UINT32 gpadat;
- UINT32 gpbcon;
- UINT32 gpbdat;
- UINT32 gpbup;
- UINT32 gpccon;
- UINT32 gpcdat;
- UINT32 gpcup;
- UINT32 gpdcon;
- UINT32 gpddat;
- UINT32 gpdup;
- UINT32 gpecon;
- UINT32 gpedat;
- UINT32 gpeup;
- UINT32 gpfcon;
- UINT32 gpfdat;
- UINT32 gpfup;
- UINT32 gpgcon;
- UINT32 gpgdat;
- UINT32 gpgup;
- UINT32 opencr;
- UINT32 misccr;
- UINT32 extint;
- };
-
- struct s3c24xx_rtc_regs_t
- {
- UINT32 rtccon;
- UINT32 ticnt;
- UINT32 reserved[2];
- UINT32 rtcalm;
- UINT32 almsec;
- UINT32 almmin;
- UINT32 almhour;
- UINT32 almday;
- UINT32 almmon;
- UINT32 almyear;
- UINT32 rtcrst;
- UINT32 bcdsec;
- UINT32 bcdmin;
- UINT32 bcdhour;
- UINT32 bcdday;
- UINT32 bcddow;
- UINT32 bcdmon;
- UINT32 bcdyear;
- };
-
- struct s3c24xx_adc_regs_t
- {
- UINT32 adccon;
- UINT32 adcdat;
- };
-
- struct s3c24xx_spi_regs_t
- {
- UINT32 spcon;
- UINT32 spsta;
- UINT32 sppin;
- UINT32 sppre;
- UINT32 sptdat;
- UINT32 sprdat;
- };
-
- struct s3c24xx_mmc_regs_t
- {
- UINT32 data[0x40/4];
- };
-
- struct s3c24xx_memcon_t
- {
- s3c24xx_memcon_regs_t regs;
- };
-
- struct s3c24xx_usbhost_t
- {
- s3c24xx_usbhost_regs_t regs;
- };
-
- struct s3c24xx_irq_t
- {
- s3c24xx_irq_regs_t regs;
- int line_irq, line_fiq;
- };
-
- struct s3c24xx_dma_t
- {
- s3c24xx_dma_regs_t regs;
- emu_timer *timer;
- };
-
- struct s3c24xx_clkpow_t
- {
- s3c24xx_clkpow_regs_t regs;
- };
-
- struct s3c24xx_lcd_t
- {
- s3c24xx_lcd_regs_t regs;
- emu_timer *timer;
- bitmap_rgb32 *bitmap[2];
- UINT32 vramaddr_cur;
- UINT32 vramaddr_max;
- UINT32 offsize;
- UINT32 pagewidth_cur;
- UINT32 pagewidth_max;
- UINT32 bppmode;
- UINT32 bswp, hwswp;
- int vpos, hpos;
- double framerate;
- UINT32 tpal;
- UINT32 hpos_min, hpos_max, vpos_min, vpos_max;
- UINT32 dma_data, dma_bits;
- };
-
- struct s3c24xx_lcdpal_t
- {
- s3c24xx_lcdpal_regs_t regs;
- };
-
- struct s3c24xx_uart_t
- {
- s3c24xx_uart_regs_t regs;
- };
-
- struct s3c24xx_pwm_t
- {
- s3c24xx_pwm_regs_t regs;
- emu_timer *timer[5];
- UINT32 cnt[5];
- UINT32 cmp[5];
- UINT32 freq[5];
- };
-
- struct s3c24xx_usbdev_t
- {
- s3c24xx_usbdev_regs_t regs;
- };
-
- struct s3c24xx_wdt_t
- {
- s3c24xx_wdt_regs_t regs;
- emu_timer *timer;
- };
-
- struct s3c24xx_iic_t
- {
- s3c24xx_iic_regs_t regs;
- emu_timer *timer;
- int count;
- };
-
- struct s3c24xx_iis_t
- {
- s3c24xx_iis_regs_t regs;
- emu_timer *timer;
- UINT16 fifo[16/2];
- int fifo_index;
- };
-
- struct s3c24xx_gpio_t
- {
- s3c24xx_gpio_regs_t regs;
- };
-
- struct s3c24xx_rtc_t
- {
- s3c24xx_rtc_regs_t regs;
- emu_timer *timer_tick_count;
- emu_timer *timer_update;
- };
-
- struct s3c24xx_adc_t
- {
- s3c24xx_adc_regs_t regs;
- };
-
- struct s3c24xx_spi_t
- {
- s3c24xx_spi_regs_t regs;
- };
-
- struct s3c24xx_mmc_t
- {
- s3c24xx_mmc_regs_t regs;
- };
-
-
- s3c24xx_memcon_t m_memcon;
- s3c24xx_usbhost_t m_usbhost;
- s3c24xx_irq_t m_irq;
- s3c24xx_dma_t m_dma[S3C24XX_DMA_COUNT];
- s3c24xx_clkpow_t m_clkpow;
- s3c24xx_lcd_t m_lcd;
- s3c24xx_lcdpal_t m_lcdpal;
- s3c24xx_uart_t m_uart[S3C24XX_UART_COUNT];
- s3c24xx_pwm_t m_pwm;
- s3c24xx_usbdev_t m_usbdev;
- s3c24xx_wdt_t m_wdt;
- s3c24xx_iic_t m_iic;
- s3c24xx_iis_t m_iis;
- s3c24xx_gpio_t m_gpio;
- s3c24xx_rtc_t m_rtc;
- s3c24xx_adc_t m_adc;
- s3c24xx_spi_t m_spi[S3C24XX_SPI_COUNT];
- s3c24xx_mmc_t m_mmc;
- required_device<device_t> m_cpu;
- devcb_read32 m_pin_r_cb;
- devcb_write32 m_pin_w_cb;
- devcb_read32 m_port_r_cb;
- devcb_write32 m_port_w_cb;
- devcb_write_line m_scl_w_cb;
- devcb_read_line m_sda_r_cb;
- devcb_write_line m_sda_w_cb;
- devcb_read32 m_data_r_cb;
- devcb_write16 m_data_w_cb;
- int m_flags;
-};
-
-extern const device_type S3C2400;
-
-
-#endif
diff --git a/src/emu/machine/s3c2410.c b/src/emu/machine/s3c2410.c
deleted file mode 100644
index ac5bec78180..00000000000
--- a/src/emu/machine/s3c2410.c
+++ /dev/null
@@ -1,170 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Schuerewegen
-/*******************************************************************************
-
- Samsung S3C2410
-
- (c) 2010 Tim Schuerewegen
-
-*******************************************************************************/
-
-#include "emu.h"
-#include "cpu/arm7/arm7.h"
-#include "cpu/arm7/arm7core.h"
-#include "machine/s3c2410.h"
-#include "sound/dac.h"
-
-#define VERBOSE_LEVEL ( 0 )
-
-INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ...)
-{
- if (VERBOSE_LEVEL >= n_level)
- {
- va_list v;
- char buf[32768];
- va_start( v, s_fmt);
- vsprintf( buf, s_fmt, v);
- va_end( v);
- logerror( "%s: %s", machine.describe_context( ), buf);
- }
-}
-
-#define DEVICE_S3C2410
-#define S3C24_CLASS_NAME s3c2410_device
-#include "machine/s3c24xx.inc"
-#undef DEVICE_S3C2410
-
-UINT32 s3c2410_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
-{
- return s3c24xx_video_update(screen, bitmap, cliprect);
-}
-
-const device_type S3C2410 = &device_creator<s3c2410_device>;
-
-s3c2410_device::s3c2410_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, S3C2410, "S3C2410 MCU", tag, owner, clock, "s3c2410", __FILE__),
- m_palette(*this),
- m_cpu(*this, ":maincpu"),
- m_pin_r_cb(*this),
- m_pin_w_cb(*this),
- m_port_r_cb(*this),
- m_port_w_cb(*this),
- m_scl_w_cb(*this),
- m_sda_r_cb(*this),
- m_sda_w_cb(*this),
- m_data_r_cb(*this),
- m_data_w_cb(*this),
- m_command_w_cb(*this),
- m_address_w_cb(*this),
- m_nand_data_r_cb(*this),
- m_nand_data_w_cb(*this),
- m_flags(0)
-{
- memset(m_steppingstone, 0, sizeof(m_steppingstone));
- memset(&m_memcon, 0, sizeof(m_memcon));
- memset(&m_usbhost, 0, sizeof(m_usbhost));
- memset(&m_irq, 0, sizeof(m_irq));
- memset(m_dma, 0, sizeof(m_dma));
- memset(&m_clkpow, 0, sizeof(m_clkpow));
- memset(&m_lcd, 0, sizeof(m_lcd));
- memset(&m_lcdpal, 0, sizeof(m_lcdpal));
- memset(&m_nand, 0, sizeof(m_nand));
- memset(m_uart, 0, sizeof(m_uart));
- memset(&m_pwm, 0, sizeof(m_pwm));
- memset(&m_usbdev, 0, sizeof(m_usbdev));
- memset(&m_wdt, 0, sizeof(m_wdt));
- memset(&m_iic, 0, sizeof(m_iic));
- memset(&m_iis, 0, sizeof(m_iis));
- memset(&m_gpio, 0, sizeof(m_gpio));
- memset(&m_rtc, 0, sizeof(m_rtc));
- memset(&m_adc, 0, sizeof(m_adc));
- memset(m_spi, 0, sizeof(m_spi));
- memset(&m_sdi, 0, sizeof(m_sdi));
-}
-
-s3c2410_device::~s3c2410_device()
-{
-}
-
-//-------------------------------------------------
-// static_set_palette_tag: Set the tag of the
-// palette device
-//-------------------------------------------------
-
-void s3c2410_device::static_set_palette_tag(device_t &device, const char *tag)
-{
- downcast<s3c2410_device &>(device).m_palette.set_tag(tag);
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void s3c2410_device::device_start()
-{
- s3c24xx_device_start();
-
- address_space &space = m_cpu->memory().space( AS_PROGRAM);
- space.install_readwrite_handler( 0x48000000, 0x4800003b, read32_delegate(FUNC(s3c2410_device::s3c24xx_memcon_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_memcon_w), this));
- space.install_readwrite_handler( 0x49000000, 0x4900005b, read32_delegate(FUNC(s3c2410_device::s3c24xx_usb_host_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_usb_host_w), this));
- space.install_readwrite_handler( 0x4a000000, 0x4a00001f, read32_delegate(FUNC(s3c2410_device::s3c24xx_irq_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_irq_w), this));
- space.install_readwrite_handler( 0x4b000000, 0x4b000023, read32_delegate(FUNC(s3c2410_device::s3c24xx_dma_0_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_dma_0_w), this));
- space.install_readwrite_handler( 0x4b000040, 0x4b000063, read32_delegate(FUNC(s3c2410_device::s3c24xx_dma_1_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_dma_1_w), this));
- space.install_readwrite_handler( 0x4b000080, 0x4b0000a3, read32_delegate(FUNC(s3c2410_device::s3c24xx_dma_2_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_dma_2_w), this));
- space.install_readwrite_handler( 0x4b0000c0, 0x4b0000e3, read32_delegate(FUNC(s3c2410_device::s3c24xx_dma_3_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_dma_3_w), this));
- space.install_readwrite_handler( 0x4c000000, 0x4c000017, read32_delegate(FUNC(s3c2410_device::s3c24xx_clkpow_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_clkpow_w), this));
- space.install_readwrite_handler( 0x4d000000, 0x4d000063, read32_delegate(FUNC(s3c2410_device::s3c24xx_lcd_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_lcd_w), this));
- space.install_readwrite_handler( 0x4d000400, 0x4d0007ff, read32_delegate(FUNC(s3c2410_device::s3c24xx_lcd_palette_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_lcd_palette_w), this));
- space.install_readwrite_handler( 0x4e000000, 0x4e000017, read32_delegate(FUNC(s3c2410_device::s3c24xx_nand_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_nand_w), this));
- space.install_readwrite_handler( 0x50000000, 0x5000002b, read32_delegate(FUNC(s3c2410_device::s3c24xx_uart_0_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_uart_0_w), this));
- space.install_readwrite_handler( 0x50004000, 0x5000402b, read32_delegate(FUNC(s3c2410_device::s3c24xx_uart_1_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_uart_1_w), this));
- space.install_readwrite_handler( 0x50008000, 0x5000802b, read32_delegate(FUNC(s3c2410_device::s3c24xx_uart_2_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_uart_2_w), this));
- space.install_readwrite_handler( 0x51000000, 0x51000043, read32_delegate(FUNC(s3c2410_device::s3c24xx_pwm_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_pwm_w), this));
- space.install_readwrite_handler( 0x52000140, 0x5200026f, read32_delegate(FUNC(s3c2410_device::s3c24xx_usb_device_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_usb_device_w), this));
- space.install_readwrite_handler( 0x53000000, 0x5300000b, read32_delegate(FUNC(s3c2410_device::s3c24xx_wdt_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_wdt_w), this));
- space.install_readwrite_handler( 0x54000000, 0x5400000f, read32_delegate(FUNC(s3c2410_device::s3c24xx_iic_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_iic_w), this));
- space.install_readwrite_handler( 0x55000000, 0x55000013, read32_delegate(FUNC(s3c2410_device::s3c24xx_iis_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_iis_w), this));
- space.install_readwrite_handler( 0x56000000, 0x560000bf, read32_delegate(FUNC(s3c2410_device::s3c24xx_gpio_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_gpio_w), this));
- space.install_readwrite_handler( 0x57000040, 0x5700008b, read32_delegate(FUNC(s3c2410_device::s3c24xx_rtc_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_rtc_w), this));
- space.install_readwrite_handler( 0x58000000, 0x58000013, read32_delegate(FUNC(s3c2410_device::s3c24xx_adc_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_adc_w), this));
- space.install_readwrite_handler( 0x59000000, 0x59000017, read32_delegate(FUNC(s3c2410_device::s3c24xx_spi_0_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_spi_0_w), this));
- space.install_readwrite_handler( 0x59000020, 0x59000037, read32_delegate(FUNC(s3c2410_device::s3c24xx_spi_1_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_spi_1_w), this));
- space.install_readwrite_handler( 0x5a000000, 0x5a000043, read32_delegate(FUNC(s3c2410_device::s3c24xx_sdi_r), this), write32_delegate(FUNC(s3c2410_device::s3c24xx_sdi_w), this));
-
- s3c24xx_video_start();
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void s3c2410_device::device_reset()
-{
- s3c24xx_device_reset();
-}
-
-void s3c2410_device::s3c2410_uart_fifo_w( int uart, UINT8 data)
-{
- s3c24xx_uart_fifo_w( uart, data);
-}
-
-void s3c2410_device::s3c2410_touch_screen( int state)
-{
- s3c24xx_touch_screen(state);
-}
-
-WRITE_LINE_MEMBER( s3c2410_device::frnb_w )
-{
- s3c24xx_pin_frnb_w(state);
-}
-
-void s3c2410_device::s3c2410_nand_calculate_mecc( UINT8 *data, UINT32 size, UINT8 *mecc)
-{
- mecc[0] = mecc[1] = mecc[2] = mecc[3] = 0xFF;
- for (int i = 0; i < size; i++) nand_update_mecc( mecc, i, data[i]);
-}
-
-void s3c2410_device::s3c2410_request_eint(UINT32 number)
-{
- s3c24xx_request_eint(number);
-}
diff --git a/src/emu/machine/s3c2410.h b/src/emu/machine/s3c2410.h
deleted file mode 100644
index 6ad02c90d1e..00000000000
--- a/src/emu/machine/s3c2410.h
+++ /dev/null
@@ -1,1073 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Schuerewegen
-/*******************************************************************************
-
- Samsung S3C2410
-
-*******************************************************************************/
-
-#ifndef __S3C2410_H__
-#define __S3C2410_H__
-
-
-/*******************************************************************************
- MACROS / CONSTANTS
-*******************************************************************************/
-
-#define S3C2410_TAG "s3c2410"
-
-#define MCFG_S3C2410_PALETTE(_palette_tag) \
- s3c2410_device::static_set_palette_tag(*device, "^" _palette_tag);
-
-#define MCFG_S3C2410_CORE_PIN_R_CB(_devcb) \
- devcb = &s3c2410_device::set_core_pin_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_CORE_PIN_W_CB(_devcb) \
- devcb = &s3c2410_device::set_core_pin_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_GPIO_PORT_R_CB(_devcb) \
- devcb = &s3c2410_device::set_gpio_port_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_GPIO_PORT_W_CB(_devcb) \
- devcb = &s3c2410_device::set_gpio_port_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_I2C_SCL_W_CB(_devcb) \
- devcb = &s3c2410_device::set_i2c_scl_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_I2C_SDA_R_CB(_devcb) \
- devcb = &s3c2410_device::set_i2c_sda_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_I2C_SDA_W_CB(_devcb) \
- devcb = &s3c2410_device::set_i2c_sda_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_ADC_DATA_R_CB(_devcb) \
- devcb = &s3c2410_device::set_adc_data_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_I2S_DATA_W_CB(_devcb) \
- devcb = &s3c2410_device::set_i2s_data_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_NAND_COMMAND_W_CB(_devcb) \
- devcb = &s3c2410_device::set_nand_command_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_NAND_ADDRESS_W_CB(_devcb) \
- devcb = &s3c2410_device::set_nand_address_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_NAND_DATA_R_CB(_devcb) \
- devcb = &s3c2410_device::set_nand_data_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_NAND_DATA_W_CB(_devcb) \
- devcb = &s3c2410_device::set_nand_data_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2410_LCD_FLAGS(_flags) \
- s3c2410_device::set_lcd_flags(*device, _flags);
-
-enum
-{
- S3C2410_GPIO_PORT_A = 0,
- S3C2410_GPIO_PORT_B,
- S3C2410_GPIO_PORT_C,
- S3C2410_GPIO_PORT_D,
- S3C2410_GPIO_PORT_E,
- S3C2410_GPIO_PORT_F,
- S3C2410_GPIO_PORT_G,
- S3C2410_GPIO_PORT_H
-};
-
-enum
-{
- S3C2410_CORE_PIN_NCON = 0,
- S3C2410_CORE_PIN_OM0,
- S3C2410_CORE_PIN_OM1
-};
-
-
-/*******************************************************************************
- MACROS & CONSTANTS
-*******************************************************************************/
-
-/* Interface */
-
-#define S3C24XX_INTERFACE_LCD_REVERSE 1
-
-/* Memory Controller */
-
-#define S3C24XX_BASE_MEMCON 0x48000000
-
-/* USB Host Controller */
-
-#define S3C24XX_BASE_USBHOST 0x49000000
-
-/* Interrupt Controller */
-
-#define S3C24XX_BASE_INT 0x4A000000
-
-#define S3C24XX_SRCPND (0x00 / 4) // Interrupt Request Status
-#define S3C24XX_INTMOD (0x04 / 4) // Interrupt Mode Control
-#define S3C24XX_INTMSK (0x08 / 4) // Interrupt Mask Control
-#define S3C24XX_PRIORITY (0x0C / 4) // IRQ Priority Control
-#define S3C24XX_INTPND (0x10 / 4) // Interrupt Request Status
-#define S3C24XX_INTOFFSET (0x14 / 4) // Interrupt Request Source Offset
-#define S3C24XX_SUBSRCPND (0x18 / 4) // Sub Source Pending
-#define S3C24XX_INTSUBMSK (0x1C / 4) // Interrupt Sub Mask
-
-/* DMA */
-
-#define S3C24XX_BASE_DMA_0 0x4B000000
-#define S3C24XX_BASE_DMA_1 0x4B000040
-#define S3C24XX_BASE_DMA_2 0x4B000080
-#define S3C24XX_BASE_DMA_3 0x4B0000C0
-
-#define S3C24XX_DISRC (0x00 / 4) // DMA Initial Source
-#define S3C24XX_DISRCC (0x04 / 4) // DMA Initial Source Control
-#define S3C24XX_DIDST (0x08 / 4) // DMA Initial Destination
-#define S3C24XX_DIDSTC (0x0C / 4) // DMA Initial Destination Control
-#define S3C24XX_DCON (0x10 / 4) // DMA Control
-#define S3C24XX_DSTAT (0x14 / 4) // DMA Count
-#define S3C24XX_DCSRC (0x18 / 4) // DMA Current Source
-#define S3C24XX_DCDST (0x1C / 4) // DMA Current Destination
-#define S3C24XX_DMASKTRIG (0x20 / 4) // DMA Mask Trigger
-
-/* Clock & Power Management */
-
-#define S3C24XX_BASE_CLKPOW 0x4C000000
-
-#define S3C24XX_LOCKTIME (0x00 / 4) // PLL Lock Time Counter
-#define S3C24XX_MPLLCON (0x04 / 4) // MPLL Control
-#define S3C24XX_UPLLCON (0x08 / 4) // UPLL Control
-#define S3C24XX_CLKCON (0x0C / 4) // Clock Generator Control
-#define S3C24XX_CLKSLOW (0x10 / 4) // Slow Clock Control
-#define S3C24XX_CLKDIVN (0x14 / 4) // Clock Divider Control
-
-/* LCD Controller */
-
-#define S3C24XX_BASE_LCD 0x4D000000
-#define S3C24XX_BASE_LCDPAL 0x4D000400
-
-#define S3C24XX_LCDCON1 (0x00 / 4) // LCD Control 1
-#define S3C24XX_LCDCON2 (0x04 / 4) // LCD Control 2
-#define S3C24XX_LCDCON3 (0x08 / 4) // LCD Control 3
-#define S3C24XX_LCDCON4 (0x0C / 4) // LCD Control 4
-#define S3C24XX_LCDCON5 (0x10 / 4) // LCD Control 5
-#define S3C24XX_LCDSADDR1 (0x14 / 4) // STN/TFT: Frame Buffer Start Address 1
-#define S3C24XX_LCDSADDR2 (0x18 / 4) // STN/TFT: Frame Buffer Start Address 2
-#define S3C24XX_LCDSADDR3 (0x1C / 4) // STN/TFT: Virtual Screen Address Set
-#define S3C24XX_REDLUT (0x20 / 4) // STN: Red Lookup Table
-#define S3C24XX_GREENLUT (0x24 / 4) // STN: Green Lookup Table
-#define S3C24XX_BLUELUT (0x28 / 4) // STN: Blue Lookup Table
-#define S3C24XX_DITHMODE (0x4C / 4) // STN: Dithering Mode
-#define S3C24XX_TPAL (0x50 / 4) // TFT: Temporary Palette
-#define S3C24XX_LCDINTPND (0x54 / 4) // LCD Interrupt Pending
-#define S3C24XX_LCDSRCPND (0x58 / 4) // LCD Interrupt Source
-#define S3C24XX_LCDINTMSK (0x5C / 4) // LCD Interrupt Mask
-#define S3C24XX_LPCSEL (0x60 / 4) // LPC3600 Control
-
-/* NAND Flash */
-
-#define S3C24XX_BASE_NAND 0x4E000000
-
-#define S3C24XX_NFCONF (0x00 / 4) // NAND Flash Configuration
-#define S3C24XX_NFCMD (0x04 / 4) // NAND Flash Command
-#define S3C24XX_NFADDR (0x08 / 4) // NAND Flash Address
-#define S3C24XX_NFDATA (0x0C / 4) // NAND Flash Data
-#define S3C24XX_NFSTAT (0x10 / 4) // NAND Flash Operation Status
-#define S3C24XX_NFECC (0x14 / 4) // NAND Flash ECC
-
-/* UART */
-
-#define S3C24XX_BASE_UART_0 0x50000000
-#define S3C24XX_BASE_UART_1 0x50004000
-#define S3C24XX_BASE_UART_2 0x50008000
-
-#define S3C24XX_ULCON (0x00 / 4) // UART Line Control
-#define S3C24XX_UCON (0x04 / 4) // UART Control
-#define S3C24XX_UFCON (0x08 / 4) // UART FIFO Control
-#define S3C24XX_UMCON (0x0C / 4) // UART Modem Control
-#define S3C24XX_UTRSTAT (0x10 / 4) // UART Tx/Rx Status
-#define S3C24XX_UERSTAT (0x14 / 4) // UART Rx Error Status
-#define S3C24XX_UFSTAT (0x18 / 4) // UART FIFO Status
-#define S3C24XX_UMSTAT (0x1C / 4) // UART Modem Status
-#define S3C24XX_UTXH (0x20 / 4) // UART Transmission Hold
-#define S3C24XX_URXH (0x24 / 4) // UART Receive Buffer
-#define S3C24XX_UBRDIV (0x28 / 4) // UART Baud Rate Divisor
-
-/* PWM Timer */
-
-#define S3C24XX_BASE_PWM 0x51000000
-
-#define S3C24XX_TCFG0 (0x00 / 4) // Timer Configuration
-#define S3C24XX_TCFG1 (0x04 / 4) // Timer Configuration
-#define S3C24XX_TCON (0x08 / 4) // Timer Control
-#define S3C24XX_TCNTB0 (0x0C / 4) // Timer Count Buffer 0
-#define S3C24XX_TCMPB0 (0x10 / 4) // Timer Compare Buffer 0
-#define S3C24XX_TCNTO0 (0x14 / 4) // Timer Count Observation 0
-#define S3C24XX_TCNTB1 (0x18 / 4) // Timer Count Buffer 1
-#define S3C24XX_TCMPB1 (0x1C / 4) // Timer Compare Buffer 1
-#define S3C24XX_TCNTO1 (0x20 / 4) // Timer Count Observation 1
-#define S3C24XX_TCNTB2 (0x24 / 4) // Timer Count Buffer 2
-#define S3C24XX_TCMPB2 (0x28 / 4) // Timer Compare Buffer 2
-#define S3C24XX_TCNTO2 (0x2C / 4) // Timer Count Observation 2
-#define S3C24XX_TCNTB3 (0x30 / 4) // Timer Count Buffer 3
-#define S3C24XX_TCMPB3 (0x34 / 4) // Timer Compare Buffer 3
-#define S3C24XX_TCNTO3 (0x38 / 4) // Timer Count Observation 3
-#define S3C24XX_TCNTB4 (0x3C / 4) // Timer Count Buffer 4
-#define S3C24XX_TCNTO4 (0x40 / 4) // Timer Count Observation 4
-
-/* USB Device */
-
-#define S3C24XX_BASE_USBDEV 0x52000140
-
-/* Watchdog Timer */
-
-#define S3C24XX_BASE_WDT 0x53000000
-
-#define S3C24XX_WTCON (0x00 / 4) // Watchdog Timer Mode
-#define S3C24XX_WTDAT (0x04 / 4) // Watchdog Timer Data
-#define S3C24XX_WTCNT (0x08 / 4) // Watchdog Timer Count
-
-/* IIC */
-
-#define S3C24XX_BASE_IIC 0x54000000
-
-#define S3C24XX_IICCON (0x00 / 4) // IIC Control
-#define S3C24XX_IICSTAT (0x04 / 4) // IIC Status
-#define S3C24XX_IICADD (0x08 / 4) // IIC Address
-#define S3C24XX_IICDS (0x0C / 4) // IIC Data Shift
-
-/* IIS */
-
-#define S3C24XX_BASE_IIS 0x55000000
-
-#define S3C24XX_IISCON (0x00 / 4) // IIS Control
-#define S3C24XX_IISMOD (0x04 / 4) // IIS Mode
-#define S3C24XX_IISPSR (0x08 / 4) // IIS Prescaler
-#define S3C24XX_IISFCON (0x0C / 4) // IIS FIFO Control
-#define S3C24XX_IISFIFO (0x10 / 4) // IIS FIFO Entry
-
-/* I/O Port */
-
-#define S3C24XX_BASE_GPIO 0x56000000
-
-#define S3C24XX_GPACON (0x00 / 4) // Port A Control
-#define S3C24XX_GPADAT (0x04 / 4) // Port A Data
-#define S3C24XX_GPBCON (0x10 / 4) // Port B Control
-#define S3C24XX_GPBDAT (0x14 / 4) // Port B Data
-#define S3C24XX_GPBUP (0x18 / 4) // Pull-up Control B
-#define S3C24XX_GPCCON (0x20 / 4) // Port C Control
-#define S3C24XX_GPCDAT (0x24 / 4) // Port C Data
-#define S3C24XX_GPCUP (0x28 / 4) // Pull-up Control C
-#define S3C24XX_GPDCON (0x30 / 4) // Port D Control
-#define S3C24XX_GPDDAT (0x34 / 4) // Port D Data
-#define S3C24XX_GPDUP (0x38 / 4) // Pull-up Control D
-#define S3C24XX_GPECON (0x40 / 4) // Port E Control
-#define S3C24XX_GPEDAT (0x44 / 4) // Port E Data
-#define S3C24XX_GPEUP (0x48 / 4) // Pull-up Control E
-#define S3C24XX_GPFCON (0x50 / 4) // Port F Control
-#define S3C24XX_GPFDAT (0x54 / 4) // Port F Data
-#define S3C24XX_GPFUP (0x58 / 4) // Pull-up Control F
-#define S3C24XX_GPGCON (0x60 / 4) // Port G Control
-#define S3C24XX_GPGDAT (0x64 / 4) // Port G Data
-#define S3C24XX_GPGUP (0x68 / 4) // Pull-up Control G
-#define S3C24XX_GPHCON (0x70 / 4) // Port H Control
-#define S3C24XX_GPHDAT (0x74 / 4) // Port H Data
-#define S3C24XX_GPHUP (0x78 / 4) // Pull-up Control H
-#define S3C24XX_MISCCR (0x80 / 4) // Miscellaneous Control
-#define S3C24XX_DCLKCON (0x84 / 4) // DCLK0/1 Control
-#define S3C24XX_EXTINT0 (0x88 / 4) // External Interrupt Control Register 0
-#define S3C24XX_EXTINT1 (0x8C / 4) // External Interrupt Control Register 1
-#define S3C24XX_EXTINT2 (0x90 / 4) // External Interrupt Control Register 2
-#define S3C24XX_EINTFLT0 (0x94 / 4) // Reserved
-#define S3C24XX_EINTFLT1 (0x98 / 4) // Reserved
-#define S3C24XX_EINTFLT2 (0x9C / 4) // External Interrupt Filter Control Register 2
-#define S3C24XX_EINTFLT3 (0xA0 / 4) // External Interrupt Filter Control Register 3
-#define S3C24XX_EINTMASK (0xA4 / 4) // External Interrupt Mask
-#define S3C24XX_EINTPEND (0xA8 / 4) // External Interrupt Pending
-#define S3C24XX_GSTATUS0 (0xAC / 4) // External Pin Status
-#define S3C24XX_GSTATUS1 (0xB0 / 4) // Chip ID
-#define S3C24XX_GSTATUS2 (0xB4 / 4) // Reset Status
-#define S3C24XX_GSTATUS3 (0xB8 / 4) // Inform Register
-#define S3C24XX_GSTATUS4 (0xBC / 4) // Inform Register
-
-#define S3C24XX_GPADAT_MASK 0x007FFFFF
-#define S3C24XX_GPBDAT_MASK 0x000007FF
-#define S3C24XX_GPCDAT_MASK 0x0000FFFF
-#define S3C24XX_GPDDAT_MASK 0x0000FFFF
-#define S3C24XX_GPEDAT_MASK 0x0000FFFF
-#define S3C24XX_GPFDAT_MASK 0x000000FF
-#define S3C24XX_GPGDAT_MASK 0x0000FFFF
-#define S3C24XX_GPHDAT_MASK 0x000007FF
-
-/* RTC */
-
-#define S3C24XX_BASE_RTC 0x57000040
-
-#define S3C24XX_RTCCON (0x00 / 4) // RTC Control
-#define S3C24XX_TICNT (0x04 / 4) // Tick Time count
-#define S3C24XX_RTCALM (0x10 / 4) // RTC Alarm Control
-#define S3C24XX_ALMSEC (0x14 / 4) // Alarm Second
-#define S3C24XX_ALMMIN (0x18 / 4) // Alarm Minute
-#define S3C24XX_ALMHOUR (0x1C / 4) // Alarm Hour
-#define S3C24XX_ALMDAY (0x20 / 4) // Alarm Day
-#define S3C24XX_ALMMON (0x24 / 4) // Alarm Month
-#define S3C24XX_ALMYEAR (0x28 / 4) // Alarm Year
-#define S3C24XX_RTCRST (0x2C / 4) // RTC Round Reset
-#define S3C24XX_BCDSEC (0x30 / 4) // BCD Second
-#define S3C24XX_BCDMIN (0x34 / 4) // BCD Minute
-#define S3C24XX_BCDHOUR (0x38 / 4) // BCD Hour
-#define S3C24XX_BCDDAY (0x3C / 4) // BCD Day
-#define S3C24XX_BCDDOW (0x40 / 4) // BCD Day of Week
-#define S3C24XX_BCDMON (0x44 / 4) // BCD Month
-#define S3C24XX_BCDYEAR (0x48 / 4) // BCD Year
-
-/* A/D Converter */
-
-#define S3C24XX_BASE_ADC 0x58000000
-
-#define S3C24XX_ADCCON (0x00 / 4) // ADC Control
-#define S3C24XX_ADCTSC (0x04 / 4) // ADC Touch Screen Control
-#define S3C24XX_ADCDLY (0x08 / 4) // ADC Start or Interval Delay
-#define S3C24XX_ADCDAT0 (0x0C / 4) // ADC Conversion Data
-#define S3C24XX_ADCDAT1 (0x10 / 4) // ADC Conversion Data
-
-/* SPI */
-
-#define S3C24XX_BASE_SPI_0 0x59000000
-#define S3C24XX_BASE_SPI_1 0x59000020
-
-#define S3C24XX_SPCON (0x00 / 4) // SPI Control
-#define S3C24XX_SPSTA (0x04 / 4) // SPI Status
-#define S3C24XX_SPPIN (0x08 / 4) // SPI Pin Control
-#define S3C24XX_SPPRE (0x0C / 4) // SPI Baud Rate Prescaler
-#define S3C24XX_SPTDAT (0x10 / 4) // SPI Tx Data
-#define S3C24XX_SPRDAT (0x14 / 4) // SPI Rx Data
-
-/* SD Interface */
-
-#define S3C24XX_BASE_SDI 0x5A000000
-
-/* ... */
-
-#define S3C24XX_INT_ADC 31
-#define S3C24XX_INT_RTC 30
-#define S3C24XX_INT_SPI1 29
-#define S3C24XX_INT_UART0 28
-#define S3C24XX_INT_IIC 27
-#define S3C24XX_INT_USBH 26
-#define S3C24XX_INT_USBD 25
-#define S3C24XX_INT_24 24
-#define S3C24XX_INT_UART1 23
-#define S3C24XX_INT_SPI0 22
-#define S3C24XX_INT_SDI 21
-#define S3C24XX_INT_DMA3 20
-#define S3C24XX_INT_DMA2 19
-#define S3C24XX_INT_DMA1 18
-#define S3C24XX_INT_DMA0 17
-#define S3C24XX_INT_LCD 16
-#define S3C24XX_INT_UART2 15
-#define S3C24XX_INT_TIMER4 14
-#define S3C24XX_INT_TIMER3 13
-#define S3C24XX_INT_TIMER2 12
-#define S3C24XX_INT_TIMER1 11
-#define S3C24XX_INT_TIMER0 10
-#define S3C24XX_INT_WDT 9
-#define S3C24XX_INT_TICK 8
-#define S3C24XX_INT_BATT_FLT 7
-#define S3C24XX_INT_6 6
-#define S3C24XX_INT_EINT8_23 5
-#define S3C24XX_INT_EINT4_7 4
-#define S3C24XX_INT_EINT3 3
-#define S3C24XX_INT_EINT2 2
-#define S3C24XX_INT_EINT1 1
-#define S3C24XX_INT_EINT0 0
-
-#define S3C24XX_SUBINT_ADC 10
-#define S3C24XX_SUBINT_TC 9
-#define S3C24XX_SUBINT_ERR2 8
-#define S3C24XX_SUBINT_TXD2 7
-#define S3C24XX_SUBINT_RXD2 6
-#define S3C24XX_SUBINT_ERR1 5
-#define S3C24XX_SUBINT_TXD1 4
-#define S3C24XX_SUBINT_RXD1 3
-#define S3C24XX_SUBINT_ERR0 2
-#define S3C24XX_SUBINT_TXD0 1
-#define S3C24XX_SUBINT_RXD0 0
-
-static const UINT32 MAP_SUBINT_TO_INT[11] =
-{
- S3C24XX_INT_UART0, S3C24XX_INT_UART0, S3C24XX_INT_UART0,
- S3C24XX_INT_UART1, S3C24XX_INT_UART1, S3C24XX_INT_UART1,
- S3C24XX_INT_UART2, S3C24XX_INT_UART2, S3C24XX_INT_UART2,
- S3C24XX_INT_ADC, S3C24XX_INT_ADC
-};
-
-#define S3C24XX_BPPMODE_STN_01 0x00
-#define S3C24XX_BPPMODE_STN_02 0x01
-#define S3C24XX_BPPMODE_STN_04 0x02
-#define S3C24XX_BPPMODE_STN_08 0x03
-#define S3C24XX_BPPMODE_STN_12_P 0x04
-#define S3C24XX_BPPMODE_STN_12_U 0x05
-#define S3C24XX_BPPMODE_STN_16 0x06
-#define S3C24XX_BPPMODE_TFT_01 0x08
-#define S3C24XX_BPPMODE_TFT_02 0x09
-#define S3C24XX_BPPMODE_TFT_04 0x0A
-#define S3C24XX_BPPMODE_TFT_08 0x0B
-#define S3C24XX_BPPMODE_TFT_16 0x0C
-#define S3C24XX_BPPMODE_TFT_24 0x0D
-
-#define S3C24XX_PNRMODE_STN_04_DS 0
-#define S3C24XX_PNRMODE_STN_04_SS 1
-#define S3C24XX_PNRMODE_STN_08_SS 2
-#define S3C24XX_PNRMODE_TFT 3
-
-#define S3C24XX_GPIO_PORT_A S3C2410_GPIO_PORT_A
-#define S3C24XX_GPIO_PORT_B S3C2410_GPIO_PORT_B
-#define S3C24XX_GPIO_PORT_C S3C2410_GPIO_PORT_C
-#define S3C24XX_GPIO_PORT_D S3C2410_GPIO_PORT_D
-#define S3C24XX_GPIO_PORT_E S3C2410_GPIO_PORT_E
-#define S3C24XX_GPIO_PORT_F S3C2410_GPIO_PORT_F
-#define S3C24XX_GPIO_PORT_G S3C2410_GPIO_PORT_G
-#define S3C24XX_GPIO_PORT_H S3C2410_GPIO_PORT_H
-
-#define S3C24XX_CORE_PIN_NCON S3C2410_CORE_PIN_NCON
-#define S3C24XX_CORE_PIN_OM0 S3C2410_CORE_PIN_OM0
-#define S3C24XX_CORE_PIN_OM1 S3C2410_CORE_PIN_OM1
-
-#define S3C24XX_UART_COUNT 3
-#define S3C24XX_DMA_COUNT 4
-#define S3C24XX_SPI_COUNT 2
-
-class s3c2410_device : public device_t
-{
-public:
- s3c2410_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~s3c2410_device();
-
- // static configuration
- static void static_set_palette_tag(device_t &device, const char *tag);
- template<class _Object> static devcb_base &set_core_pin_r_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_pin_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_core_pin_w_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_pin_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_gpio_port_r_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_port_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_gpio_port_w_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_port_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2c_scl_w_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_scl_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2c_sda_r_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_sda_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2c_sda_w_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_sda_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_adc_data_r_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_data_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2s_data_w_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_data_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_nand_command_w_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_command_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_nand_address_w_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_address_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_nand_data_r_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_nand_data_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_nand_data_w_callback(device_t &device, _Object object) { return downcast<s3c2410_device &>(device).m_nand_data_w_cb.set_callback(object); }
- static void set_lcd_flags(device_t &device, int flags) { downcast<s3c2410_device &>(device).m_flags = flags; }
-
- DECLARE_WRITE_LINE_MEMBER( frnb_w );
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-private:
- // internal state
- required_device<palette_device> m_palette;
-public:
- UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
-
- void s3c24xx_reset();
- inline int iface_core_pin_r(int pin);
- void s3c24xx_lcd_reset();
- rgb_t s3c24xx_get_color_tft_16(UINT16 data);
- rgb_t s3c24xx_get_color_tft_24(UINT32 data);
- rgb_t s3c24xx_get_color_stn_12(UINT16 data);
- rgb_t s3c24xx_get_color_stn_08( UINT8 data);
- rgb_t s3c24xx_get_color_stn_01(UINT8 data);
- rgb_t s3c24xx_get_color_stn_02(UINT8 data);
- rgb_t s3c24xx_get_color_stn_04(UINT8 data);
- rgb_t s3c24xx_get_color_tpal();
- void s3c24xx_lcd_dma_reload();
- void s3c24xx_lcd_dma_init();
- UINT32 s3c24xx_lcd_dma_read();
- UINT32 s3c24xx_lcd_dma_read_bits(int count);
- void s3c24xx_lcd_render_tpal();
- void s3c24xx_lcd_render_stn_01();
- void s3c24xx_lcd_render_stn_02();
- void s3c24xx_lcd_render_stn_04();
- void s3c24xx_lcd_render_stn_08();
- void s3c24xx_lcd_render_stn_12_p();
- void s3c24xx_lcd_render_stn_12_u(); // not tested
- void s3c24xx_lcd_render_tft_01();
- void s3c24xx_lcd_render_tft_02();
- void s3c24xx_lcd_render_tft_04();
- void s3c24xx_lcd_render_tft_08();
- void s3c24xx_lcd_render_tft_16();
- TIMER_CALLBACK_MEMBER( s3c24xx_lcd_timer_exp );
- void s3c24xx_video_start();
- void bitmap_blend( bitmap_rgb32 &bitmap_dst, bitmap_rgb32 &bitmap_src_1, bitmap_rgb32 &bitmap_src_2);
- UINT32 s3c24xx_video_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
- READ32_MEMBER( s3c24xx_lcd_r );
- int s3c24xx_lcd_configure_tft();
- int s3c24xx_lcd_configure_stn();
- int s3c24xx_lcd_configure();
- void s3c24xx_lcd_start();
- void s3c24xx_lcd_stop();
- void s3c24xx_lcd_recalc();
- WRITE32_MEMBER( s3c24xx_lcd_w );
- READ32_MEMBER( s3c24xx_lcd_palette_r );
- WRITE32_MEMBER( s3c24xx_lcd_palette_w );
- void s3c24xx_clkpow_reset();
- UINT32 s3c24xx_get_fclk();
- UINT32 s3c24xx_get_hclk();
- UINT32 s3c24xx_get_pclk();
- READ32_MEMBER( s3c24xx_clkpow_r );
- WRITE32_MEMBER( s3c24xx_clkpow_w );
- void s3c24xx_irq_reset();
- void s3c24xx_check_pending_irq();
- void s3c24xx_request_irq(UINT32 int_type);
- void s3c24xx_check_pending_subirq();
- void s3c24xx_request_subirq( UINT32 int_type);
- void s3c24xx_check_pending_eint();
- void s3c24xx_request_eint(UINT32 number);
- READ32_MEMBER( s3c24xx_irq_r );
- WRITE32_MEMBER( s3c24xx_irq_w );
- void s3c24xx_pwm_reset();
- UINT16 s3c24xx_pwm_calc_observation(int ch);
- READ32_MEMBER( s3c24xx_pwm_r );
- void s3c24xx_pwm_start(int timer);
- void s3c24xx_pwm_stop(int timer);
- void s3c24xx_pwm_recalc(int timer);
- WRITE32_MEMBER( s3c24xx_pwm_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_pwm_timer_exp );
- void s3c24xx_dma_reset();
- void s3c24xx_dma_reload(int ch);
- void s3c24xx_dma_trigger(int ch);
- void s3c24xx_dma_request_iis();
- void s3c24xx_dma_request_pwm();
- void s3c24xx_dma_start(int ch);
- void s3c24xx_dma_stop(int ch);
- void s3c24xx_dma_recalc(int ch);
- UINT32 s3c24xx_dma_r(UINT32 ch, UINT32 offset);
- void s3c24xx_dma_w(UINT32 ch, UINT32 offset, UINT32 data, UINT32 mem_mask);
- READ32_MEMBER( s3c24xx_dma_0_r );
- READ32_MEMBER( s3c24xx_dma_1_r );
- READ32_MEMBER( s3c24xx_dma_2_r );
- READ32_MEMBER( s3c24xx_dma_3_r );
- WRITE32_MEMBER( s3c24xx_dma_0_w );
- WRITE32_MEMBER( s3c24xx_dma_1_w );
- WRITE32_MEMBER( s3c24xx_dma_2_w );
- WRITE32_MEMBER( s3c24xx_dma_3_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_dma_timer_exp );
- void s3c24xx_gpio_reset();
- inline UINT32 iface_gpio_port_r(int port, UINT32 mask);
- inline void iface_gpio_port_w(int port, UINT32 mask, UINT32 data);
- UINT16 s3c24xx_gpio_get_mask( UINT32 con, int val);
- READ32_MEMBER( s3c24xx_gpio_r );
- WRITE32_MEMBER( s3c24xx_gpio_w );
- void s3c24xx_memcon_reset();
- READ32_MEMBER( s3c24xx_memcon_r );
- WRITE32_MEMBER( s3c24xx_memcon_w );
- void s3c24xx_usb_host_reset();
- READ32_MEMBER( s3c24xx_usb_host_r );
- WRITE32_MEMBER( s3c24xx_usb_host_w );
- void s3c24xx_uart_reset();
- UINT32 s3c24xx_uart_r(UINT32 ch, UINT32 offset);
- void s3c24xx_uart_w(UINT32 ch, UINT32 offset, UINT32 data, UINT32 mem_mask);
- READ32_MEMBER( s3c24xx_uart_0_r );
- READ32_MEMBER( s3c24xx_uart_1_r );
- READ32_MEMBER( s3c24xx_uart_2_r );
- WRITE32_MEMBER( s3c24xx_uart_0_w );
- WRITE32_MEMBER( s3c24xx_uart_1_w );
- WRITE32_MEMBER( s3c24xx_uart_2_w );
- void s3c24xx_uart_fifo_w(int uart, UINT8 data);
- void s3c24xx_usb_device_reset();
- READ32_MEMBER( s3c24xx_usb_device_r );
- WRITE32_MEMBER( s3c24xx_usb_device_w );
- void s3c24xx_wdt_reset();
- UINT16 s3c24xx_wdt_calc_current_count();
- READ32_MEMBER( s3c24xx_wdt_r );
- void s3c24xx_wdt_start();
- void s3c24xx_wdt_stop();
- void s3c24xx_wdt_recalc();
- WRITE32_MEMBER( s3c24xx_wdt_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_wdt_timer_exp );
- void s3c24xx_iic_reset();
- inline void iface_i2c_scl_w( int state);
- inline void iface_i2c_sda_w(int state);
- inline int iface_i2c_sda_r();
- void i2c_send_start();
- void i2c_send_stop();
- UINT8 i2c_receive_byte(int ack);
- int i2c_send_byte(UINT8 data);
- void iic_start();
- void iic_stop();
- void iic_resume();
- READ32_MEMBER( s3c24xx_iic_r );
- WRITE32_MEMBER( s3c24xx_iic_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_iic_timer_exp );
- void s3c24xx_iis_reset();
- inline void iface_i2s_data_w(int ch, UINT16 data);
- void s3c24xx_iis_start();
- void s3c24xx_iis_stop();
- void s3c24xx_iis_recalc();
- READ32_MEMBER( s3c24xx_iis_r );
- WRITE32_MEMBER( s3c24xx_iis_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_iis_timer_exp );
- void s3c24xx_rtc_reset();
- READ32_MEMBER( s3c24xx_rtc_r );
- void s3c24xx_rtc_recalc();
- WRITE32_MEMBER( s3c24xx_rtc_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_rtc_timer_tick_count_exp );
- void s3c24xx_rtc_update();
- void s3c24xx_rtc_check_alarm();
- TIMER_CALLBACK_MEMBER( s3c24xx_rtc_timer_update_exp );
- void s3c24xx_adc_reset();
- UINT32 iface_adc_data_r(int ch);
- READ32_MEMBER( s3c24xx_adc_r );
- void s3c24xx_adc_start();
- WRITE32_MEMBER( s3c24xx_adc_w );
- void s3c24xx_touch_screen(int state);
- void s3c24xx_spi_reset();
- UINT32 s3c24xx_spi_r(UINT32 ch, UINT32 offset);
- void s3c24xx_spi_w(UINT32 ch, UINT32 offset, UINT32 data, UINT32 mem_mask);
- READ32_MEMBER( s3c24xx_spi_0_r );
- READ32_MEMBER( s3c24xx_spi_1_r );
- WRITE32_MEMBER( s3c24xx_spi_0_w );
- WRITE32_MEMBER( s3c24xx_spi_1_w );
- void s3c24xx_sdi_reset();
- READ32_MEMBER( s3c24xx_sdi_r );
- WRITE32_MEMBER( s3c24xx_sdi_w );
- void s3c24xx_nand_reset();
- inline void iface_nand_command_w(UINT8 data);
- inline void iface_nand_address_w(UINT8 data);
- inline UINT8 iface_nand_data_r();
- inline void iface_nand_data_w(UINT8 data);
- void nand_update_mecc( UINT8 *ecc, int pos, UINT8 data);
- void s3c24xx_nand_update_ecc(UINT8 data);
- void s3c24xx_nand_command_w(UINT8 data);
- void s3c24xx_nand_address_w(UINT8 data);
- UINT8 s3c24xx_nand_data_r();
- void s3c24xx_nand_data_w(UINT8 data);
- READ32_MEMBER( s3c24xx_nand_r );
- void s3c24xx_nand_init_ecc();
- WRITE32_MEMBER( s3c24xx_nand_w );
- ATTR_UNUSED WRITE_LINE_MEMBER( s3c24xx_pin_frnb_w );
- void s3c24xx_nand_auto_boot();
- void s3c24xx_device_reset();
- void s3c24xx_device_start();
-
- void s3c2410_uart_fifo_w( int uart, UINT8 data);
- void s3c2410_touch_screen( int state);
- void s3c2410_request_eint( UINT32 number);
- void s3c2410_nand_calculate_mecc( UINT8 *data, UINT32 size, UINT8 *mecc);
-
- /*******************************************************************************
- TYPE DEFINITIONS
- *******************************************************************************/
-
- struct s3c24xx_memcon_regs_t
- {
- UINT32 data[0x34/4];
- };
-
- struct s3c24xx_usbhost_regs_t
- {
- UINT32 data[0x5C/4];
- };
-
- struct s3c24xx_irq_regs_t
- {
- UINT32 srcpnd;
- UINT32 intmod;
- UINT32 intmsk;
- UINT32 priority;
- UINT32 intpnd;
- UINT32 intoffset;
- UINT32 subsrcpnd;
- UINT32 intsubmsk;
- };
-
- struct s3c24xx_dma_regs_t
- {
- UINT32 disrc;
- UINT32 disrcc;
- UINT32 didst;
- UINT32 didstc;
- UINT32 dcon;
- UINT32 dstat;
- UINT32 dcsrc;
- UINT32 dcdst;
- UINT32 dmasktrig;
- };
-
- struct s3c24xx_clkpow_regs_t
- {
- UINT32 locktime;
- UINT32 mpllcon;
- UINT32 upllcon;
- UINT32 clkcon;
- UINT32 clkslow;
- UINT32 clkdivn;
- };
-
- struct s3c24xx_lcd_regs_t
- {
- UINT32 lcdcon1;
- UINT32 lcdcon2;
- UINT32 lcdcon3;
- UINT32 lcdcon4;
- UINT32 lcdcon5;
- UINT32 lcdsaddr1;
- UINT32 lcdsaddr2;
- UINT32 lcdsaddr3;
- UINT32 redlut;
- UINT32 greenlut;
- UINT32 bluelut;
- UINT32 reserved[8];
- UINT32 dithmode;
- UINT32 tpal;
- UINT32 lcdintpnd;
- UINT32 lcdsrcpnd;
- UINT32 lcdintmsk;
- UINT32 lpcsel;
- };
-
- struct s3c24xx_lcdpal_regs_t
- {
- UINT32 data[0x400/4];
- };
-
- struct s3c24xx_nand_regs_t
- {
- UINT32 nfconf;
- UINT32 nfcmd;
- UINT32 nfaddr;
- UINT32 nfdata;
- UINT32 nfstat;
- UINT32 nfecc;
- };
-
- struct s3c24xx_uart_regs_t
- {
- UINT32 ulcon;
- UINT32 ucon;
- UINT32 ufcon;
- UINT32 umcon;
- UINT32 utrstat;
- UINT32 uerstat;
- UINT32 ufstat;
- UINT32 umstat;
- UINT32 utxh;
- UINT32 urxh;
- UINT32 ubrdiv;
- };
-
- struct s3c24xx_pwm_regs_t
- {
- UINT32 tcfg0;
- UINT32 tcfg1;
- UINT32 tcon;
- UINT32 tcntb0;
- UINT32 tcmpb0;
- UINT32 tcnto0;
- UINT32 tcntb1;
- UINT32 tcmpb1;
- UINT32 tcnto1;
- UINT32 tcntb2;
- UINT32 tcmpb2;
- UINT32 tcnto2;
- UINT32 tcntb3;
- UINT32 tcmpb3;
- UINT32 tcnto3;
- UINT32 tcntb4;
- UINT32 tcnto4;
- };
-
- struct s3c24xx_usbdev_regs_t
- {
- UINT32 data[0x130/4];
- };
-
- struct s3c24xx_wdt_regs_t
- {
- UINT32 wtcon;
- UINT32 wtdat;
- UINT32 wtcnt;
- };
-
- struct s3c24xx_iic_regs_t
- {
- UINT32 iiccon;
- UINT32 iicstat;
- UINT32 iicadd;
- UINT32 iicds;
- };
-
- struct s3c24xx_iis_regs_t
- {
- UINT32 iiscon;
- UINT32 iismod;
- UINT32 iispsr;
- UINT32 iisfcon;
- UINT32 iisfifo;
- };
-
- struct s3c24xx_gpio_regs_t
- {
- UINT32 gpacon;
- UINT32 gpadat;
- UINT32 pad_08;
- UINT32 pad_0c;
- UINT32 gpbcon;
- UINT32 gpbdat;
- UINT32 gpbup;
- UINT32 pad_1c;
- UINT32 gpccon;
- UINT32 gpcdat;
- UINT32 gpcup;
- UINT32 pad_2c;
- UINT32 gpdcon;
- UINT32 gpddat;
- UINT32 gpdup;
- UINT32 pad_3c;
- UINT32 gpecon;
- UINT32 gpedat;
- UINT32 gpeup;
- UINT32 pad_4c;
- UINT32 gpfcon;
- UINT32 gpfdat;
- UINT32 gpfup;
- UINT32 pad_5c;
- UINT32 gpgcon;
- UINT32 gpgdat;
- UINT32 gpgup;
- UINT32 pad_6c;
- UINT32 gphcon;
- UINT32 gphdat;
- UINT32 gphup;
- UINT32 pad_7c;
- UINT32 misccr;
- UINT32 dclkcon;
- UINT32 extint0;
- UINT32 extint1;
- UINT32 extint2;
- UINT32 eintflt0;
- UINT32 eintflt1;
- UINT32 eintflt2;
- UINT32 eintflt3;
- UINT32 eintmask;
- UINT32 eintpend;
- UINT32 gstatus0;
- UINT32 gstatus1;
- UINT32 gstatus2;
- UINT32 gstatus3;
- UINT32 gstatus4;
- };
-
- struct s3c24xx_rtc_regs_t
- {
- UINT32 rtccon;
- UINT32 ticnt;
- UINT32 reserved[2];
- UINT32 rtcalm;
- UINT32 almsec;
- UINT32 almmin;
- UINT32 almhour;
- UINT32 almday;
- UINT32 almmon;
- UINT32 almyear;
- UINT32 rtcrst;
- UINT32 bcdsec;
- UINT32 bcdmin;
- UINT32 bcdhour;
- UINT32 bcdday;
- UINT32 bcddow;
- UINT32 bcdmon;
- UINT32 bcdyear;
- };
-
- struct s3c24xx_adc_regs_t
- {
- UINT32 adccon;
- UINT32 adctsc;
- UINT32 adcdly;
- UINT32 adcdat0;
- UINT32 adcdat1;
- };
-
- struct s3c24xx_spi_regs_t
- {
- UINT32 spcon;
- UINT32 spsta;
- UINT32 sppin;
- UINT32 sppre;
- UINT32 sptdat;
- UINT32 sprdat;
- };
-
- struct s3c24xx_sdi_regs_t
- {
- UINT32 data[0x44/4];
- };
-
- struct s3c24xx_memcon_t
- {
- s3c24xx_memcon_regs_t regs;
- };
-
- struct s3c24xx_usbhost_t
- {
- s3c24xx_usbhost_regs_t regs;
- };
-
- struct s3c24xx_irq_t
- {
- s3c24xx_irq_regs_t regs;
- int line_irq, line_fiq;
- };
-
- struct s3c24xx_dma_t
- {
- s3c24xx_dma_regs_t regs;
- emu_timer *timer;
- };
-
- struct s3c24xx_clkpow_t
- {
- s3c24xx_clkpow_regs_t regs;
- };
-
- struct s3c24xx_lcd_t
- {
- s3c24xx_lcd_regs_t regs;
- emu_timer *timer;
- bitmap_rgb32 *bitmap[2];
- UINT32 vramaddr_cur;
- UINT32 vramaddr_max;
- UINT32 offsize;
- UINT32 pagewidth_cur;
- UINT32 pagewidth_max;
- UINT32 bppmode;
- UINT32 bswp, hwswp;
- int vpos, hpos;
- double framerate;
- UINT32 tpal;
- UINT32 hpos_min, hpos_max, vpos_min, vpos_max;
- UINT32 dma_data, dma_bits;
- };
-
- struct s3c24xx_lcdpal_t
- {
- s3c24xx_lcdpal_regs_t regs;
- };
-
- struct s3c24xx_nand_t
- {
- s3c24xx_nand_regs_t regs;
- UINT8 mecc[3];
- int ecc_pos, data_count;
- };
-
- struct s3c24xx_uart_t
- {
- s3c24xx_uart_regs_t regs;
- };
-
- struct s3c24xx_pwm_t
- {
- s3c24xx_pwm_regs_t regs;
- emu_timer *timer[5];
- UINT32 cnt[5];
- UINT32 cmp[5];
- UINT32 freq[5];
- };
-
- struct s3c24xx_usbdev_t
- {
- s3c24xx_usbdev_regs_t regs;
- };
-
- struct s3c24xx_wdt_t
- {
- s3c24xx_wdt_regs_t regs;
- emu_timer *timer;
- UINT32 freq, cnt;
- };
-
- struct s3c24xx_iic_t
- {
- s3c24xx_iic_regs_t regs;
- emu_timer *timer;
- int count;
- };
-
- struct s3c24xx_iis_t
- {
- s3c24xx_iis_regs_t regs;
- emu_timer *timer;
- UINT16 fifo[16/2];
- int fifo_index;
- };
-
- struct s3c24xx_gpio_t
- {
- s3c24xx_gpio_regs_t regs;
- };
-
- struct s3c24xx_rtc_t
- {
- s3c24xx_rtc_regs_t regs;
- emu_timer *timer_tick_count;
- emu_timer *timer_update;
- };
-
- struct s3c24xx_adc_t
- {
- s3c24xx_adc_regs_t regs;
- };
-
- struct s3c24xx_spi_t
- {
- s3c24xx_spi_regs_t regs;
- };
-
- struct s3c24xx_sdi_t
- {
- s3c24xx_sdi_regs_t regs;
- };
-
- UINT8 m_steppingstone[4*1024];
- s3c24xx_memcon_t m_memcon;
- s3c24xx_usbhost_t m_usbhost;
- s3c24xx_irq_t m_irq;
- s3c24xx_dma_t m_dma[S3C24XX_DMA_COUNT];
- s3c24xx_clkpow_t m_clkpow;
- s3c24xx_lcd_t m_lcd;
- s3c24xx_lcdpal_t m_lcdpal;
- s3c24xx_nand_t m_nand;
- s3c24xx_uart_t m_uart[S3C24XX_UART_COUNT];
- s3c24xx_pwm_t m_pwm;
- s3c24xx_usbdev_t m_usbdev;
- s3c24xx_wdt_t m_wdt;
- s3c24xx_iic_t m_iic;
- s3c24xx_iis_t m_iis;
- s3c24xx_gpio_t m_gpio;
- s3c24xx_rtc_t m_rtc;
- s3c24xx_adc_t m_adc;
- s3c24xx_spi_t m_spi[S3C24XX_SPI_COUNT];
- s3c24xx_sdi_t m_sdi;
- required_device<device_t> m_cpu;
- devcb_read32 m_pin_r_cb;
- devcb_write32 m_pin_w_cb;
- devcb_read32 m_port_r_cb;
- devcb_write32 m_port_w_cb;
- devcb_write_line m_scl_w_cb;
- devcb_read_line m_sda_r_cb;
- devcb_write_line m_sda_w_cb;
- devcb_read32 m_data_r_cb;
- devcb_write16 m_data_w_cb;
- devcb_write8 m_command_w_cb;
- devcb_write8 m_address_w_cb;
- devcb_read8 m_nand_data_r_cb;
- devcb_write8 m_nand_data_w_cb;
- int m_flags;
-};
-
-extern const device_type S3C2410;
-
-
-#endif
diff --git a/src/emu/machine/s3c2440.c b/src/emu/machine/s3c2440.c
deleted file mode 100644
index eaa0301d157..00000000000
--- a/src/emu/machine/s3c2440.c
+++ /dev/null
@@ -1,175 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Schuerewegen
-/*******************************************************************************
-
- Samsung S3C2440
-
- (c) 2010 Tim Schuerewegen
-
-*******************************************************************************/
-
-#include "emu.h"
-#include "cpu/arm7/arm7.h"
-#include "cpu/arm7/arm7core.h"
-#include "machine/s3c2440.h"
-#include "sound/dac.h"
-
-#define VERBOSE_LEVEL ( 0 )
-
-INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ...)
-{
- if (VERBOSE_LEVEL >= n_level)
- {
- va_list v;
- char buf[32768];
- va_start( v, s_fmt);
- vsprintf( buf, s_fmt, v);
- va_end( v);
- logerror( "%s: %s", machine.describe_context( ), buf);
- }
-}
-
-#define DEVICE_S3C2440
-#define S3C24_CLASS_NAME s3c2440_device
-#include "machine/s3c24xx.inc"
-#undef DEVICE_S3C2440
-
-UINT32 s3c2440_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
-{
- return s3c24xx_video_update( screen, bitmap, cliprect);
-}
-
-const device_type S3C2440 = &device_creator<s3c2440_device>;
-
-s3c2440_device::s3c2440_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, S3C2440, "Samsung S3C2440", tag, owner, clock, "s3c2440", __FILE__),
- m_palette(*this),
- m_cpu(*this, ":maincpu"),
- m_pin_r_cb(*this),
- m_pin_w_cb(*this),
- m_port_r_cb(*this),
- m_port_w_cb(*this),
- m_scl_w_cb(*this),
- m_sda_r_cb(*this),
- m_sda_w_cb(*this),
- m_data_r_cb(*this),
- m_data_w_cb(*this),
- m_command_w_cb(*this),
- m_address_w_cb(*this),
- m_nand_data_r_cb(*this),
- m_nand_data_w_cb(*this),
- m_flags(0)
-{
- memset(m_steppingstone, 0, sizeof(m_steppingstone));
- memset(&m_memcon, 0, sizeof(m_memcon));
- memset(&m_usbhost, 0, sizeof(m_usbhost));
- memset(&m_irq, 0, sizeof(m_irq));
- memset(m_dma, 0, sizeof(m_dma));
- memset(&m_clkpow, 0, sizeof(m_clkpow));
- memset(&m_lcd, 0, sizeof(m_lcd));
- memset(&m_lcdpal, 0, sizeof(m_lcdpal));
- memset(&m_nand, 0, sizeof(m_nand));
- memset(&m_cam, 0, sizeof(m_cam));
- memset(m_uart, 0, sizeof(m_uart));
- memset(&m_pwm, 0, sizeof(m_pwm));
- memset(&m_usbdev, 0, sizeof(m_usbdev));
- memset(&m_wdt, 0, sizeof(m_wdt));
- memset(&m_iic, 0, sizeof(m_iic));
- memset(&m_iis, 0, sizeof(m_iis));
- memset(&m_gpio, 0, sizeof(m_gpio));
- memset(&m_rtc, 0, sizeof(m_rtc));
- memset(&m_adc, 0, sizeof(m_adc));
- memset(m_spi, 0, sizeof(m_spi));
- memset(&m_sdi, 0, sizeof(m_sdi));
- memset(&m_ac97, 0, sizeof(m_ac97));
-}
-
-s3c2440_device::~s3c2440_device()
-{
-}
-
-//-------------------------------------------------
-// static_set_palette_tag: Set the tag of the
-// palette device
-//-------------------------------------------------
-
-void s3c2440_device::static_set_palette_tag(device_t &device, const char *tag)
-{
- downcast<s3c2440_device &>(device).m_palette.set_tag(tag);
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void s3c2440_device::device_start()
-{
- address_space &space = m_cpu->memory().space( AS_PROGRAM);
- space.install_readwrite_handler(0x48000000, 0x4800003b, read32_delegate(FUNC(s3c2440_device::s3c24xx_memcon_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_memcon_w), this));
- space.install_readwrite_handler(0x49000000, 0x4900005b, read32_delegate(FUNC(s3c2440_device::s3c24xx_usb_host_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_usb_host_w), this));
- space.install_readwrite_handler(0x4a000000, 0x4a00001f, read32_delegate(FUNC(s3c2440_device::s3c24xx_irq_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_irq_w), this));
- space.install_readwrite_handler(0x4b000000, 0x4b000023, read32_delegate(FUNC(s3c2440_device::s3c24xx_dma_0_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_dma_0_w), this));
- space.install_readwrite_handler(0x4b000040, 0x4b000063, read32_delegate(FUNC(s3c2440_device::s3c24xx_dma_1_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_dma_1_w), this));
- space.install_readwrite_handler(0x4b000080, 0x4b0000a3, read32_delegate(FUNC(s3c2440_device::s3c24xx_dma_2_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_dma_2_w), this));
- space.install_readwrite_handler(0x4b0000c0, 0x4b0000e3, read32_delegate(FUNC(s3c2440_device::s3c24xx_dma_3_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_dma_3_w), this));
- space.install_readwrite_handler(0x4c000000, 0x4c00001b, read32_delegate(FUNC(s3c2440_device::s3c24xx_clkpow_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_clkpow_w), this));
- space.install_readwrite_handler(0x4d000000, 0x4d000063, read32_delegate(FUNC(s3c2440_device::s3c24xx_lcd_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_lcd_w), this));
- space.install_readwrite_handler(0x4d000400, 0x4d0007ff, read32_delegate(FUNC(s3c2440_device::s3c24xx_lcd_palette_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_lcd_palette_w), this));
- space.install_readwrite_handler(0x4e000000, 0x4e00003f, read32_delegate(FUNC(s3c2440_device::s3c24xx_nand_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_nand_w), this));
- space.install_readwrite_handler(0x4f000000, 0x4f0000a3, read32_delegate(FUNC(s3c2440_device::s3c24xx_cam_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_cam_w), this));
- space.install_readwrite_handler(0x50000000, 0x5000002b, read32_delegate(FUNC(s3c2440_device::s3c24xx_uart_0_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_uart_0_w), this));
- space.install_readwrite_handler(0x50004000, 0x5000402b, read32_delegate(FUNC(s3c2440_device::s3c24xx_uart_1_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_uart_1_w), this));
- space.install_readwrite_handler(0x50008000, 0x5000802b, read32_delegate(FUNC(s3c2440_device::s3c24xx_uart_2_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_uart_2_w), this));
- space.install_readwrite_handler(0x51000000, 0x51000043, read32_delegate(FUNC(s3c2440_device::s3c24xx_pwm_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_pwm_w), this));
- space.install_readwrite_handler(0x52000140, 0x5200026f, read32_delegate(FUNC(s3c2440_device::s3c24xx_usb_device_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_usb_device_w), this));
- space.install_readwrite_handler(0x53000000, 0x5300000b, read32_delegate(FUNC(s3c2440_device::s3c24xx_wdt_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_wdt_w), this));
- space.install_readwrite_handler(0x54000000, 0x54000013, read32_delegate(FUNC(s3c2440_device::s3c24xx_iic_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_iic_w), this));
- space.install_readwrite_handler(0x55000000, 0x55000013, read32_delegate(FUNC(s3c2440_device::s3c24xx_iis_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_iis_w), this));
- space.install_readwrite_handler(0x56000000, 0x560000df, read32_delegate(FUNC(s3c2440_device::s3c24xx_gpio_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_gpio_w), this));
- space.install_readwrite_handler(0x57000040, 0x5700008b, read32_delegate(FUNC(s3c2440_device::s3c24xx_rtc_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_rtc_w), this));
- space.install_readwrite_handler(0x58000000, 0x58000017, read32_delegate(FUNC(s3c2440_device::s3c24xx_adc_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_adc_w), this));
- space.install_readwrite_handler(0x59000000, 0x59000017, read32_delegate(FUNC(s3c2440_device::s3c24xx_spi_0_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_spi_0_w), this));
- space.install_readwrite_handler(0x59000020, 0x59000037, read32_delegate(FUNC(s3c2440_device::s3c24xx_spi_1_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_spi_1_w), this));
- space.install_readwrite_handler(0x5a000000, 0x5a000043, read32_delegate(FUNC(s3c2440_device::s3c24xx_sdi_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_sdi_w), this));
- space.install_readwrite_handler(0x5b000000, 0x5b00001f, read32_delegate(FUNC(s3c2440_device::s3c24xx_ac97_r), this), write32_delegate(FUNC(s3c2440_device::s3c24xx_ac97_w), this));
-
- s3c24xx_device_start();
-
- s3c24xx_video_start();
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void s3c2440_device::device_reset()
-{
- s3c24xx_device_reset();
-}
-
-
-void s3c2440_device::s3c2440_uart_fifo_w(int uart, UINT8 data)
-{
- s3c24xx_uart_fifo_w( uart, data);
-}
-
-void s3c2440_device::s3c2440_touch_screen(int state)
-{
- s3c24xx_touch_screen( state);
-}
-
-void s3c2440_device::s3c2440_request_irq(UINT32 int_type)
-{
- s3c24xx_request_irq( int_type);
-}
-
-void s3c2440_device::s3c2440_request_eint(UINT32 number)
-{
- s3c24xx_request_eint( number);
-}
-
-WRITE_LINE_MEMBER( s3c2440_device::frnb_w )
-{
- s3c24xx_pin_frnb_w(state);
-}
diff --git a/src/emu/machine/s3c2440.h b/src/emu/machine/s3c2440.h
deleted file mode 100644
index b76148eca09..00000000000
--- a/src/emu/machine/s3c2440.h
+++ /dev/null
@@ -1,1157 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Schuerewegen
-/*******************************************************************************
-
- Samsung S3C2440
-
-*******************************************************************************/
-
-#ifndef __S3C2440_H__
-#define __S3C2440_H__
-
-/*******************************************************************************
- MACROS / CONSTANTS
-*******************************************************************************/
-
-#define S3C2440_TAG "s3c2440"
-
-#define MCFG_S3C2440_PALETTE(_palette_tag) \
- s3c2440_device::static_set_palette_tag(*device, "^" _palette_tag);
-
-#define MCFG_S3C2440_CORE_PIN_R_CB(_devcb) \
- devcb = &s3c2440_device::set_core_pin_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_CORE_PIN_W_CB(_devcb) \
- devcb = &s3c2440_device::set_core_pin_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_GPIO_PORT_R_CB(_devcb) \
- devcb = &s3c2440_device::set_gpio_port_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_GPIO_PORT_W_CB(_devcb) \
- devcb = &s3c2440_device::set_gpio_port_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_I2C_SCL_W_CB(_devcb) \
- devcb = &s3c2440_device::set_i2c_scl_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_I2C_SDA_R_CB(_devcb) \
- devcb = &s3c2440_device::set_i2c_sda_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_I2C_SDA_W_CB(_devcb) \
- devcb = &s3c2440_device::set_i2c_sda_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_ADC_DATA_R_CB(_devcb) \
- devcb = &s3c2440_device::set_adc_data_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_I2S_DATA_W_CB(_devcb) \
- devcb = &s3c2440_device::set_i2s_data_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_NAND_COMMAND_W_CB(_devcb) \
- devcb = &s3c2440_device::set_nand_command_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_NAND_ADDRESS_W_CB(_devcb) \
- devcb = &s3c2440_device::set_nand_address_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_NAND_DATA_R_CB(_devcb) \
- devcb = &s3c2440_device::set_nand_data_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_NAND_DATA_W_CB(_devcb) \
- devcb = &s3c2440_device::set_nand_data_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C2440_LCD_FLAGS(_flags) \
- s3c2440_device::set_lcd_flags(*device, _flags);
-
-enum
-{
- S3C2440_GPIO_PORT_A = 0,
- S3C2440_GPIO_PORT_B,
- S3C2440_GPIO_PORT_C,
- S3C2440_GPIO_PORT_D,
- S3C2440_GPIO_PORT_E,
- S3C2440_GPIO_PORT_F,
- S3C2440_GPIO_PORT_G,
- S3C2440_GPIO_PORT_H,
- S3C2440_GPIO_PORT_J
-};
-
-enum
-{
- S3C2440_CORE_PIN_NCON = 0,
- S3C2440_CORE_PIN_OM0,
- S3C2440_CORE_PIN_OM1
-};
-
-/*******************************************************************************
- MACROS & CONSTANTS
-*******************************************************************************/
-
-/* Interface */
-
-#define S3C24XX_INTERFACE_LCD_REVERSE 1
-
-/* Memory Controller */
-
-#define S3C24XX_BASE_MEMCON 0x48000000
-
-/* USB Host Controller */
-
-#define S3C24XX_BASE_USBHOST 0x49000000
-
-/* Interrupt Controller */
-
-#define S3C24XX_BASE_INT 0x4A000000
-
-#define S3C24XX_SRCPND (0x00 / 4) // Interrupt Request Status
-#define S3C24XX_INTMOD (0x04 / 4) // Interrupt Mode Control
-#define S3C24XX_INTMSK (0x08 / 4) // Interrupt Mask Control
-#define S3C24XX_PRIORITY (0x0C / 4) // IRQ Priority Control
-#define S3C24XX_INTPND (0x10 / 4) // Interrupt Request Status
-#define S3C24XX_INTOFFSET (0x14 / 4) // Interrupt Request Source Offset
-#define S3C24XX_SUBSRCPND (0x18 / 4) // Sub Source Pending
-#define S3C24XX_INTSUBMSK (0x1C / 4) // Interrupt Sub Mask
-
-/* DMA */
-
-#define S3C24XX_BASE_DMA_0 0x4B000000
-#define S3C24XX_BASE_DMA_1 0x4B000040
-#define S3C24XX_BASE_DMA_2 0x4B000080
-#define S3C24XX_BASE_DMA_3 0x4B0000C0
-
-#define S3C24XX_DISRC (0x00 / 4) // DMA Initial Source
-#define S3C24XX_DISRCC (0x04 / 4) // DMA Initial Source Control
-#define S3C24XX_DIDST (0x08 / 4) // DMA Initial Destination
-#define S3C24XX_DIDSTC (0x0C / 4) // DMA Initial Destination Control
-#define S3C24XX_DCON (0x10 / 4) // DMA Control
-#define S3C24XX_DSTAT (0x14 / 4) // DMA Count
-#define S3C24XX_DCSRC (0x18 / 4) // DMA Current Source
-#define S3C24XX_DCDST (0x1C / 4) // DMA Current Destination
-#define S3C24XX_DMASKTRIG (0x20 / 4) // DMA Mask Trigger
-
-/* Clock & Power Management */
-
-#define S3C24XX_BASE_CLKPOW 0x4C000000
-
-#define S3C24XX_LOCKTIME (0x00 / 4) // PLL Lock Time Counter
-#define S3C24XX_MPLLCON (0x04 / 4) // MPLL Control
-#define S3C24XX_UPLLCON (0x08 / 4) // UPLL Control
-#define S3C24XX_CLKCON (0x0C / 4) // Clock Generator Control
-#define S3C24XX_CLKSLOW (0x10 / 4) // Slow Clock Control
-#define S3C24XX_CLKDIVN (0x14 / 4) // Clock Divider Control
-#define S3C24XX_CAMDIVN (0x18 / 4) // Camera Clock Divider Control
-
-/* LCD Controller */
-
-#define S3C24XX_BASE_LCD 0x4D000000
-#define S3C24XX_BASE_LCDPAL 0x4D000400
-
-#define S3C24XX_LCDCON1 (0x00 / 4) // LCD Control 1
-#define S3C24XX_LCDCON2 (0x04 / 4) // LCD Control 2
-#define S3C24XX_LCDCON3 (0x08 / 4) // LCD Control 3
-#define S3C24XX_LCDCON4 (0x0C / 4) // LCD Control 4
-#define S3C24XX_LCDCON5 (0x10 / 4) // LCD Control 5
-#define S3C24XX_LCDSADDR1 (0x14 / 4) // STN/TFT: Frame Buffer Start Address 1
-#define S3C24XX_LCDSADDR2 (0x18 / 4) // STN/TFT: Frame Buffer Start Address 2
-#define S3C24XX_LCDSADDR3 (0x1C / 4) // STN/TFT: Virtual Screen Address Set
-#define S3C24XX_REDLUT (0x20 / 4) // STN: Red Lookup Table
-#define S3C24XX_GREENLUT (0x24 / 4) // STN: Green Lookup Table
-#define S3C24XX_BLUELUT (0x28 / 4) // STN: Blue Lookup Table
-#define S3C24XX_DITHMODE (0x4C / 4) // STN: Dithering Mode
-#define S3C24XX_TPAL (0x50 / 4) // TFT: Temporary Palette
-#define S3C24XX_LCDINTPND (0x54 / 4) // LCD Interrupt Pending
-#define S3C24XX_LCDSRCPND (0x58 / 4) // LCD Interrupt Source
-#define S3C24XX_LCDINTMSK (0x5C / 4) // LCD Interrupt Mask
-#define S3C24XX_TCONSEL (0x60 / 4) // TCON (LPC3600/LCC3600) Control
-
-/* NAND Flash */
-
-#define S3C24XX_BASE_NAND 0x4E000000
-
-#define S3C24XX_NFCONF (0x00 / 4) // NAND Flash Configuration
-#define S3C24XX_NFCONT (0x04 / 4) // NAND Flash Control
-#define S3C24XX_NFCMD (0x08 / 4) // NAND Flash Command
-#define S3C24XX_NFADDR (0x0C / 4) // NAND Flash Address
-#define S3C24XX_NFDATA (0x10 / 4) // NAND Flash Data
-#define S3C24XX_NFMECCD0 (0x14 / 4) // NAND Flash Main Area ECC0/1
-#define S3C24XX_NFMECCD1 (0x18 / 4) // NAND Flash Main Area ECC2/3
-#define S3C24XX_NFSECCD (0x1C / 4) // NAND Flash Spare Area Ecc
-#define S3C24XX_NFSTAT (0x20 / 4) // NAND Flash Operation Status
-#define S3C24XX_NFESTAT0 (0x24 / 4) // NAND Flash ECC Status For I/O[7:0]
-#define S3C24XX_NFESTAT1 (0x28 / 4) // NAND Flash ECC Status For I/O[15:8]
-#define S3C24XX_NFMECC0 (0x2C / 4) // NAND Flash Main Area ECC0 Status
-#define S3C24XX_NFMECC1 (0x30 / 4) // NAND Flash Main Area ECC1 Status
-#define S3C24XX_NFSECC (0x34 / 4) // NAND Flash Spare Area ECC Status
-#define S3C24XX_NFSBLK (0x38 / 4) // NAND Flash Start Block Address
-#define S3C24XX_NFEBLK (0x3C / 4) // NAND Flash End Block Address
-
-/* Camera Interface */
-
-#define S3C24XX_BASE_CAM 0x4F000000
-
-/* UART */
-
-#define S3C24XX_BASE_UART_0 0x50000000
-#define S3C24XX_BASE_UART_1 0x50004000
-#define S3C24XX_BASE_UART_2 0x50008000
-
-#define S3C24XX_ULCON (0x00 / 4) // UART Line Control
-#define S3C24XX_UCON (0x04 / 4) // UART Control
-#define S3C24XX_UFCON (0x08 / 4) // UART FIFO Control
-#define S3C24XX_UMCON (0x0C / 4) // UART Modem Control
-#define S3C24XX_UTRSTAT (0x10 / 4) // UART Tx/Rx Status
-#define S3C24XX_UERSTAT (0x14 / 4) // UART Rx Error Status
-#define S3C24XX_UFSTAT (0x18 / 4) // UART FIFO Status
-#define S3C24XX_UMSTAT (0x1C / 4) // UART Modem Status
-#define S3C24XX_UTXH (0x20 / 4) // UART Transmission Hold
-#define S3C24XX_URXH (0x24 / 4) // UART Receive Buffer
-#define S3C24XX_UBRDIV (0x28 / 4) // UART Baud Rate Divisor
-
-/* PWM Timer */
-
-#define S3C24XX_BASE_PWM 0x51000000
-
-#define S3C24XX_TCFG0 (0x00 / 4) // Timer Configuration
-#define S3C24XX_TCFG1 (0x04 / 4) // Timer Configuration
-#define S3C24XX_TCON (0x08 / 4) // Timer Control
-#define S3C24XX_TCNTB0 (0x0C / 4) // Timer Count Buffer 0
-#define S3C24XX_TCMPB0 (0x10 / 4) // Timer Compare Buffer 0
-#define S3C24XX_TCNTO0 (0x14 / 4) // Timer Count Observation 0
-#define S3C24XX_TCNTB1 (0x18 / 4) // Timer Count Buffer 1
-#define S3C24XX_TCMPB1 (0x1C / 4) // Timer Compare Buffer 1
-#define S3C24XX_TCNTO1 (0x20 / 4) // Timer Count Observation 1
-#define S3C24XX_TCNTB2 (0x24 / 4) // Timer Count Buffer 2
-#define S3C24XX_TCMPB2 (0x28 / 4) // Timer Compare Buffer 2
-#define S3C24XX_TCNTO2 (0x2C / 4) // Timer Count Observation 2
-#define S3C24XX_TCNTB3 (0x30 / 4) // Timer Count Buffer 3
-#define S3C24XX_TCMPB3 (0x34 / 4) // Timer Compare Buffer 3
-#define S3C24XX_TCNTO3 (0x38 / 4) // Timer Count Observation 3
-#define S3C24XX_TCNTB4 (0x3C / 4) // Timer Count Buffer 4
-#define S3C24XX_TCNTO4 (0x40 / 4) // Timer Count Observation 4
-
-/* USB Device */
-
-#define S3C24XX_BASE_USBDEV 0x52000140
-
-/* Watchdog Timer */
-
-#define S3C24XX_BASE_WDT 0x53000000
-
-#define S3C24XX_WTCON (0x00 / 4) // Watchdog Timer Mode
-#define S3C24XX_WTDAT (0x04 / 4) // Watchdog Timer Data
-#define S3C24XX_WTCNT (0x08 / 4) // Watchdog Timer Count
-
-/* IIC */
-
-#define S3C24XX_BASE_IIC 0x54000000
-
-#define S3C24XX_IICCON (0x00 / 4) // IIC Control
-#define S3C24XX_IICSTAT (0x04 / 4) // IIC Status
-#define S3C24XX_IICADD (0x08 / 4) // IIC Address
-#define S3C24XX_IICDS (0x0C / 4) // IIC Data Shift
-#define S3C24XX_IICLC (0x10 / 4) // IIC Multi-Master Line Control
-
-/* IIS */
-
-#define S3C24XX_BASE_IIS 0x55000000
-
-#define S3C24XX_IISCON (0x00 / 4) // IIS Control
-#define S3C24XX_IISMOD (0x04 / 4) // IIS Mode
-#define S3C24XX_IISPSR (0x08 / 4) // IIS Prescaler
-#define S3C24XX_IISFCON (0x0C / 4) // IIS FIFO Control
-#define S3C24XX_IISFIFO (0x10 / 4) // IIS FIFO Entry
-
-/* I/O Port */
-
-#define S3C24XX_BASE_GPIO 0x56000000
-
-#define S3C24XX_GPACON (0x00 / 4) // Port A Control
-#define S3C24XX_GPADAT (0x04 / 4) // Port A Data
-#define S3C24XX_GPBCON (0x10 / 4) // Port B Control
-#define S3C24XX_GPBDAT (0x14 / 4) // Port B Data
-#define S3C24XX_GPBUP (0x18 / 4) // Pull-up Control B
-#define S3C24XX_GPCCON (0x20 / 4) // Port C Control
-#define S3C24XX_GPCDAT (0x24 / 4) // Port C Data
-#define S3C24XX_GPCUP (0x28 / 4) // Pull-up Control C
-#define S3C24XX_GPDCON (0x30 / 4) // Port D Control
-#define S3C24XX_GPDDAT (0x34 / 4) // Port D Data
-#define S3C24XX_GPDUP (0x38 / 4) // Pull-up Control D
-#define S3C24XX_GPECON (0x40 / 4) // Port E Control
-#define S3C24XX_GPEDAT (0x44 / 4) // Port E Data
-#define S3C24XX_GPEUP (0x48 / 4) // Pull-up Control E
-#define S3C24XX_GPFCON (0x50 / 4) // Port F Control
-#define S3C24XX_GPFDAT (0x54 / 4) // Port F Data
-#define S3C24XX_GPFUP (0x58 / 4) // Pull-up Control F
-#define S3C24XX_GPGCON (0x60 / 4) // Port G Control
-#define S3C24XX_GPGDAT (0x64 / 4) // Port G Data
-#define S3C24XX_GPGUP (0x68 / 4) // Pull-up Control G
-#define S3C24XX_GPHCON (0x70 / 4) // Port H Control
-#define S3C24XX_GPHDAT (0x74 / 4) // Port H Data
-#define S3C24XX_GPHUP (0x78 / 4) // Pull-up Control H
-#define S3C24XX_MISCCR (0x80 / 4) // Miscellaneous Control
-#define S3C24XX_DCLKCON (0x84 / 4) // DCLK0/1 Control
-#define S3C24XX_EXTINT0 (0x88 / 4) // External Interrupt Control Register 0
-#define S3C24XX_EXTINT1 (0x8C / 4) // External Interrupt Control Register 1
-#define S3C24XX_EXTINT2 (0x90 / 4) // External Interrupt Control Register 2
-#define S3C24XX_EINTFLT0 (0x94 / 4) // Reserved
-#define S3C24XX_EINTFLT1 (0x98 / 4) // Reserved
-#define S3C24XX_EINTFLT2 (0x9C / 4) // External Interrupt Filter Control Register 2
-#define S3C24XX_EINTFLT3 (0xA0 / 4) // External Interrupt Filter Control Register 3
-#define S3C24XX_EINTMASK (0xA4 / 4) // External Interrupt Mask
-#define S3C24XX_EINTPEND (0xA8 / 4) // External Interrupt Pending
-#define S3C24XX_GSTATUS0 (0xAC / 4) // External Pin Status
-#define S3C24XX_GSTATUS1 (0xB0 / 4) // Chip ID
-#define S3C24XX_GSTATUS2 (0xB4 / 4) // Reset Status
-#define S3C24XX_GSTATUS3 (0xB8 / 4) // Inform Register
-#define S3C24XX_GSTATUS4 (0xBC / 4) // Inform Register
-#define S3C24XX_MSLCON (0xCC / 4) // Memory Sleep Control Register
-#define S3C24XX_GPJCON (0xD0 / 4) // Port J Control
-#define S3C24XX_GPJDAT (0xD4 / 4) // Port J Data
-#define S3C24XX_GPJUP (0xD8 / 4) // Pull-up Control J
-
-#define S3C24XX_GPADAT_MASK 0x01FFFFFF
-#define S3C24XX_GPBDAT_MASK 0x000007FF
-#define S3C24XX_GPCDAT_MASK 0x0000FFFF
-#define S3C24XX_GPDDAT_MASK 0x0000FFFF
-#define S3C24XX_GPEDAT_MASK 0x0000FFFF
-#define S3C24XX_GPFDAT_MASK 0x000000FF
-#define S3C24XX_GPGDAT_MASK 0x0000FFFF
-#define S3C24XX_GPHDAT_MASK 0x000007FF
-#define S3C24XX_GPJDAT_MASK 0x0000FFFF
-
-/* RTC */
-
-#define S3C24XX_BASE_RTC 0x57000040
-
-#define S3C24XX_RTCCON (0x00 / 4) // RTC Control
-#define S3C24XX_TICNT (0x04 / 4) // Tick Time count
-#define S3C24XX_RTCALM (0x10 / 4) // RTC Alarm Control
-#define S3C24XX_ALMSEC (0x14 / 4) // Alarm Second
-#define S3C24XX_ALMMIN (0x18 / 4) // Alarm Minute
-#define S3C24XX_ALMHOUR (0x1C / 4) // Alarm Hour
-#define S3C24XX_ALMDAY (0x20 / 4) // Alarm Day
-#define S3C24XX_ALMMON (0x24 / 4) // Alarm Month
-#define S3C24XX_ALMYEAR (0x28 / 4) // Alarm Year
-#define S3C24XX_BCDSEC (0x30 / 4) // BCD Second
-#define S3C24XX_BCDMIN (0x34 / 4) // BCD Minute
-#define S3C24XX_BCDHOUR (0x38 / 4) // BCD Hour
-#define S3C24XX_BCDDAY (0x3C / 4) // BCD Day
-#define S3C24XX_BCDDOW (0x40 / 4) // BCD Day of Week
-#define S3C24XX_BCDMON (0x44 / 4) // BCD Month
-#define S3C24XX_BCDYEAR (0x48 / 4) // BCD Year
-
-/* A/D Converter */
-
-#define S3C24XX_BASE_ADC 0x58000000
-
-#define S3C24XX_ADCCON (0x00 / 4) // ADC Control
-#define S3C24XX_ADCTSC (0x04 / 4) // ADC Touch Screen Control
-#define S3C24XX_ADCDLY (0x08 / 4) // ADC Start or Interval Delay
-#define S3C24XX_ADCDAT0 (0x0C / 4) // ADC Conversion Data
-#define S3C24XX_ADCDAT1 (0x10 / 4) // ADC Conversion Data
-#define S3C24XX_ADCUPDN (0x14 / 4) // Stylus up or down interrupt status
-
-/* SPI */
-
-#define S3C24XX_BASE_SPI_0 0x59000000
-#define S3C24XX_BASE_SPI_1 0x59000020
-
-#define S3C24XX_SPCON (0x00 / 4) // SPI Control
-#define S3C24XX_SPSTA (0x04 / 4) // SPI Status
-#define S3C24XX_SPPIN (0x08 / 4) // SPI Pin Control
-#define S3C24XX_SPPRE (0x0C / 4) // SPI Baud Rate Prescaler
-#define S3C24XX_SPTDAT (0x10 / 4) // SPI Tx Data
-#define S3C24XX_SPRDAT (0x14 / 4) // SPI Rx Data
-
-/* SD Interface */
-
-#define S3C24XX_BASE_SDI 0x5A000000
-
-/* AC97 Interface */
-
-#define S3C24XX_BASE_AC97 0x5B000000
-
-/* ... */
-
-#define S3C24XX_INT_ADC 31
-#define S3C24XX_INT_RTC 30
-#define S3C24XX_INT_SPI1 29
-#define S3C24XX_INT_UART0 28
-#define S3C24XX_INT_IIC 27
-#define S3C24XX_INT_USBH 26
-#define S3C24XX_INT_USBD 25
-#define S3C24XX_INT_NFCON 24
-#define S3C24XX_INT_UART1 23
-#define S3C24XX_INT_SPI0 22
-#define S3C24XX_INT_SDI 21
-#define S3C24XX_INT_DMA3 20
-#define S3C24XX_INT_DMA2 19
-#define S3C24XX_INT_DMA1 18
-#define S3C24XX_INT_DMA0 17
-#define S3C24XX_INT_LCD 16
-#define S3C24XX_INT_UART2 15
-#define S3C24XX_INT_TIMER4 14
-#define S3C24XX_INT_TIMER3 13
-#define S3C24XX_INT_TIMER2 12
-#define S3C24XX_INT_TIMER1 11
-#define S3C24XX_INT_TIMER0 10
-#define S3C24XX_INT_WDT_AC97 9
-#define S3C24XX_INT_TICK 8
-#define S3C24XX_INT_BATT_FLT 7
-#define S3C24XX_INT_CAM 6
-#define S3C24XX_INT_EINT8_23 5
-#define S3C24XX_INT_EINT4_7 4
-#define S3C24XX_INT_EINT3 3
-#define S3C24XX_INT_EINT2 2
-#define S3C24XX_INT_EINT1 1
-#define S3C24XX_INT_EINT0 0
-
-#define S3C24XX_SUBINT_AC97 14
-#define S3C24XX_SUBINT_WDT 13
-#define S3C24XX_SUBINT_CAM_P 12
-#define S3C24XX_SUBINT_CAM_C 11
-#define S3C24XX_SUBINT_ADC 10
-#define S3C24XX_SUBINT_TC 9
-#define S3C24XX_SUBINT_ERR2 8
-#define S3C24XX_SUBINT_TXD2 7
-#define S3C24XX_SUBINT_RXD2 6
-#define S3C24XX_SUBINT_ERR1 5
-#define S3C24XX_SUBINT_TXD1 4
-#define S3C24XX_SUBINT_RXD1 3
-#define S3C24XX_SUBINT_ERR0 2
-#define S3C24XX_SUBINT_TXD0 1
-#define S3C24XX_SUBINT_RXD0 0
-
-static const UINT32 MAP_SUBINT_TO_INT[15] =
-{
- S3C24XX_INT_UART0, S3C24XX_INT_UART0, S3C24XX_INT_UART0,
- S3C24XX_INT_UART1, S3C24XX_INT_UART1, S3C24XX_INT_UART1,
- S3C24XX_INT_UART2, S3C24XX_INT_UART2, S3C24XX_INT_UART2,
- S3C24XX_INT_ADC, S3C24XX_INT_ADC,
- S3C24XX_INT_CAM, S3C24XX_INT_CAM,
- S3C24XX_INT_WDT_AC97, S3C24XX_INT_WDT_AC97
-};
-
-#define S3C24XX_BPPMODE_STN_01 0x00
-#define S3C24XX_BPPMODE_STN_02 0x01
-#define S3C24XX_BPPMODE_STN_04 0x02
-#define S3C24XX_BPPMODE_STN_08 0x03
-#define S3C24XX_BPPMODE_STN_12_P 0x04
-#define S3C24XX_BPPMODE_STN_12_U 0x05
-#define S3C24XX_BPPMODE_STN_16 0x06
-#define S3C24XX_BPPMODE_TFT_01 0x08
-#define S3C24XX_BPPMODE_TFT_02 0x09
-#define S3C24XX_BPPMODE_TFT_04 0x0A
-#define S3C24XX_BPPMODE_TFT_08 0x0B
-#define S3C24XX_BPPMODE_TFT_16 0x0C
-#define S3C24XX_BPPMODE_TFT_24 0x0D
-
-#define S3C24XX_PNRMODE_STN_04_DS 0
-#define S3C24XX_PNRMODE_STN_04_SS 1
-#define S3C24XX_PNRMODE_STN_08_SS 2
-#define S3C24XX_PNRMODE_TFT 3
-
-#define S3C24XX_GPIO_PORT_A S3C2440_GPIO_PORT_A
-#define S3C24XX_GPIO_PORT_B S3C2440_GPIO_PORT_B
-#define S3C24XX_GPIO_PORT_C S3C2440_GPIO_PORT_C
-#define S3C24XX_GPIO_PORT_D S3C2440_GPIO_PORT_D
-#define S3C24XX_GPIO_PORT_E S3C2440_GPIO_PORT_E
-#define S3C24XX_GPIO_PORT_F S3C2440_GPIO_PORT_F
-#define S3C24XX_GPIO_PORT_G S3C2440_GPIO_PORT_G
-#define S3C24XX_GPIO_PORT_H S3C2440_GPIO_PORT_H
-#define S3C24XX_GPIO_PORT_J S3C2440_GPIO_PORT_J
-
-#define S3C24XX_CORE_PIN_NCON S3C2440_CORE_PIN_NCON
-#define S3C24XX_CORE_PIN_OM0 S3C2440_CORE_PIN_OM0
-#define S3C24XX_CORE_PIN_OM1 S3C2440_CORE_PIN_OM1
-
-#define S3C24XX_UART_COUNT 3
-#define S3C24XX_DMA_COUNT 4
-#define S3C24XX_SPI_COUNT 2
-
-class s3c2440_device : public device_t
-{
-public:
- s3c2440_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~s3c2440_device();
-
- // static configuration
- static void static_set_palette_tag(device_t &device, const char *tag);
- template<class _Object> static devcb_base &set_core_pin_r_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_pin_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_core_pin_w_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_pin_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_gpio_port_r_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_port_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_gpio_port_w_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_port_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2c_scl_w_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_scl_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2c_sda_r_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_sda_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2c_sda_w_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_sda_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_adc_data_r_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_data_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2s_data_w_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_data_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_nand_command_w_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_command_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_nand_address_w_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_address_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_nand_data_r_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_nand_data_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_nand_data_w_callback(device_t &device, _Object object) { return downcast<s3c2440_device &>(device).m_nand_data_w_cb.set_callback(object); }
- static void set_lcd_flags(device_t &device, int flags) { downcast<s3c2440_device &>(device).m_flags = flags; }
-
- DECLARE_WRITE_LINE_MEMBER( frnb_w );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-private:
- // internal state
- required_device<palette_device> m_palette;
-public:
- UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
-
- void s3c24xx_reset();
- inline int iface_core_pin_r(int pin);
- void s3c24xx_lcd_reset();
- rgb_t s3c24xx_get_color_tft_16(UINT16 data);
- rgb_t s3c24xx_get_color_tft_24(UINT32 data);
- rgb_t s3c24xx_get_color_stn_12(UINT16 data);
- rgb_t s3c24xx_get_color_stn_08( UINT8 data);
- rgb_t s3c24xx_get_color_stn_01(UINT8 data);
- rgb_t s3c24xx_get_color_stn_02(UINT8 data);
- rgb_t s3c24xx_get_color_stn_04(UINT8 data);
- rgb_t s3c24xx_get_color_tpal();
- void s3c24xx_lcd_dma_reload();
- void s3c24xx_lcd_dma_init();
- UINT32 s3c24xx_lcd_dma_read();
- UINT32 s3c24xx_lcd_dma_read_bits(int count);
- void s3c24xx_lcd_render_tpal();
- void s3c24xx_lcd_render_stn_01();
- void s3c24xx_lcd_render_stn_02();
- void s3c24xx_lcd_render_stn_04();
- void s3c24xx_lcd_render_stn_08();
- void s3c24xx_lcd_render_stn_12_p();
- void s3c24xx_lcd_render_stn_12_u(); // not tested
- void s3c24xx_lcd_render_tft_01();
- void s3c24xx_lcd_render_tft_02();
- void s3c24xx_lcd_render_tft_04();
- void s3c24xx_lcd_render_tft_08();
- void s3c24xx_lcd_render_tft_16();
- TIMER_CALLBACK_MEMBER( s3c24xx_lcd_timer_exp );
- void s3c24xx_video_start();
- void bitmap_blend( bitmap_rgb32 &bitmap_dst, bitmap_rgb32 &bitmap_src_1, bitmap_rgb32 &bitmap_src_2);
- UINT32 s3c24xx_video_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
- READ32_MEMBER( s3c24xx_lcd_r );
- int s3c24xx_lcd_configure_tft();
- int s3c24xx_lcd_configure_stn();
- int s3c24xx_lcd_configure();
- void s3c24xx_lcd_start();
- void s3c24xx_lcd_stop();
- void s3c24xx_lcd_recalc();
- WRITE32_MEMBER( s3c24xx_lcd_w );
- READ32_MEMBER( s3c24xx_lcd_palette_r );
- WRITE32_MEMBER( s3c24xx_lcd_palette_w );
- void s3c24xx_clkpow_reset();
- UINT32 s3c24xx_get_fclk();
- UINT32 s3c24xx_get_hclk();
- UINT32 s3c24xx_get_pclk();
- READ32_MEMBER( s3c24xx_clkpow_r );
- WRITE32_MEMBER( s3c24xx_clkpow_w );
- void s3c24xx_irq_reset();
- void s3c24xx_check_pending_irq();
- void s3c24xx_request_irq(UINT32 int_type);
- void s3c24xx_check_pending_subirq();
- void s3c24xx_request_subirq( UINT32 int_type);
- void s3c24xx_check_pending_eint();
- void s3c24xx_request_eint(UINT32 number);
- READ32_MEMBER( s3c24xx_irq_r );
- WRITE32_MEMBER( s3c24xx_irq_w );
- void s3c24xx_pwm_reset();
- UINT16 s3c24xx_pwm_calc_observation(int ch);
- READ32_MEMBER( s3c24xx_pwm_r );
- void s3c24xx_pwm_start(int timer);
- void s3c24xx_pwm_stop(int timer);
- void s3c24xx_pwm_recalc(int timer);
- WRITE32_MEMBER( s3c24xx_pwm_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_pwm_timer_exp );
- void s3c24xx_dma_reset();
- void s3c24xx_dma_reload(int ch);
- void s3c24xx_dma_trigger(int ch);
- void s3c24xx_dma_request_iis();
- void s3c24xx_dma_request_pwm();
- void s3c24xx_dma_start(int ch);
- void s3c24xx_dma_stop(int ch);
- void s3c24xx_dma_recalc(int ch);
- UINT32 s3c24xx_dma_r(UINT32 ch, UINT32 offset);
- void s3c24xx_dma_w(UINT32 ch, UINT32 offset, UINT32 data, UINT32 mem_mask);
- READ32_MEMBER( s3c24xx_dma_0_r );
- READ32_MEMBER( s3c24xx_dma_1_r );
- READ32_MEMBER( s3c24xx_dma_2_r );
- READ32_MEMBER( s3c24xx_dma_3_r );
- WRITE32_MEMBER( s3c24xx_dma_0_w );
- WRITE32_MEMBER( s3c24xx_dma_1_w );
- WRITE32_MEMBER( s3c24xx_dma_2_w );
- WRITE32_MEMBER( s3c24xx_dma_3_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_dma_timer_exp );
- void s3c24xx_gpio_reset();
- inline UINT32 iface_gpio_port_r(int port, UINT32 mask);
- inline void iface_gpio_port_w(int port, UINT32 mask, UINT32 data);
- UINT16 s3c24xx_gpio_get_mask( UINT32 con, int val);
- READ32_MEMBER( s3c24xx_gpio_r );
- WRITE32_MEMBER( s3c24xx_gpio_w );
- void s3c24xx_memcon_reset();
- READ32_MEMBER( s3c24xx_memcon_r );
- WRITE32_MEMBER( s3c24xx_memcon_w );
- void s3c24xx_usb_host_reset();
- READ32_MEMBER( s3c24xx_usb_host_r );
- WRITE32_MEMBER( s3c24xx_usb_host_w );
- void s3c24xx_uart_reset();
- UINT32 s3c24xx_uart_r(UINT32 ch, UINT32 offset);
- void s3c24xx_uart_w(UINT32 ch, UINT32 offset, UINT32 data, UINT32 mem_mask);
- READ32_MEMBER( s3c24xx_uart_0_r );
- READ32_MEMBER( s3c24xx_uart_1_r );
- READ32_MEMBER( s3c24xx_uart_2_r );
- WRITE32_MEMBER( s3c24xx_uart_0_w );
- WRITE32_MEMBER( s3c24xx_uart_1_w );
- WRITE32_MEMBER( s3c24xx_uart_2_w );
- void s3c24xx_uart_fifo_w(int uart, UINT8 data);
- void s3c24xx_usb_device_reset();
- READ32_MEMBER( s3c24xx_usb_device_r );
- WRITE32_MEMBER( s3c24xx_usb_device_w );
- void s3c24xx_wdt_reset();
- UINT16 s3c24xx_wdt_calc_current_count();
- READ32_MEMBER( s3c24xx_wdt_r );
- void s3c24xx_wdt_start();
- void s3c24xx_wdt_stop();
- void s3c24xx_wdt_recalc();
- WRITE32_MEMBER( s3c24xx_wdt_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_wdt_timer_exp );
- void s3c24xx_iic_reset();
- inline void iface_i2c_scl_w( int state);
- inline void iface_i2c_sda_w(int state);
- inline int iface_i2c_sda_r();
- void i2c_send_start();
- void i2c_send_stop();
- UINT8 i2c_receive_byte(int ack);
- int i2c_send_byte(UINT8 data);
- void iic_start();
- void iic_stop();
- void iic_resume();
- READ32_MEMBER( s3c24xx_iic_r );
- WRITE32_MEMBER( s3c24xx_iic_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_iic_timer_exp );
- void s3c24xx_iis_reset();
- inline void iface_i2s_data_w(int ch, UINT16 data);
- void s3c24xx_iis_start();
- void s3c24xx_iis_stop();
- void s3c24xx_iis_recalc();
- READ32_MEMBER( s3c24xx_iis_r );
- WRITE32_MEMBER( s3c24xx_iis_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_iis_timer_exp );
- void s3c24xx_rtc_reset();
- READ32_MEMBER( s3c24xx_rtc_r );
- void s3c24xx_rtc_recalc();
- WRITE32_MEMBER( s3c24xx_rtc_w );
- TIMER_CALLBACK_MEMBER( s3c24xx_rtc_timer_tick_count_exp );
- void s3c24xx_rtc_update();
- void s3c24xx_rtc_check_alarm();
- TIMER_CALLBACK_MEMBER( s3c24xx_rtc_timer_update_exp );
- void s3c24xx_adc_reset();
- UINT32 iface_adc_data_r(int ch);
- READ32_MEMBER( s3c24xx_adc_r );
- void s3c24xx_adc_start();
- WRITE32_MEMBER( s3c24xx_adc_w );
- void s3c24xx_touch_screen(int state);
- void s3c24xx_spi_reset();
- UINT32 s3c24xx_spi_r(UINT32 ch, UINT32 offset);
- void s3c24xx_spi_w(UINT32 ch, UINT32 offset, UINT32 data, UINT32 mem_mask);
- READ32_MEMBER( s3c24xx_spi_0_r );
- READ32_MEMBER( s3c24xx_spi_1_r );
- WRITE32_MEMBER( s3c24xx_spi_0_w );
- WRITE32_MEMBER( s3c24xx_spi_1_w );
- void s3c24xx_sdi_reset();
- READ32_MEMBER( s3c24xx_sdi_r );
- WRITE32_MEMBER( s3c24xx_sdi_w );
- void s3c24xx_nand_reset();
- inline void iface_nand_command_w(UINT8 data);
- inline void iface_nand_address_w(UINT8 data);
- inline UINT8 iface_nand_data_r();
- inline void iface_nand_data_w(UINT8 data);
- void nand_update_mecc( UINT8 *ecc, int pos, UINT8 data);
- void nand_update_secc( UINT8 *ecc, int pos, UINT8 data);
- void s3c24xx_nand_update_ecc(UINT8 data);
- void s3c24xx_nand_command_w(UINT8 data);
- void s3c24xx_nand_address_w(UINT8 data);
- UINT8 s3c24xx_nand_data_r();
- void s3c24xx_nand_data_w(UINT8 data);
- READ32_MEMBER( s3c24xx_nand_r );
- void s3c24xx_nand_init_ecc();
- WRITE32_MEMBER( s3c24xx_nand_w );
- ATTR_UNUSED WRITE_LINE_MEMBER( s3c24xx_pin_frnb_w );
- void s3c24xx_cam_reset();
- READ32_MEMBER( s3c24xx_cam_r );
- WRITE32_MEMBER( s3c24xx_cam_w );
- void s3c24xx_ac97_reset();
- READ32_MEMBER( s3c24xx_ac97_r );
- WRITE32_MEMBER( s3c24xx_ac97_w );
- void s3c24xx_nand_auto_boot();
- void s3c24xx_device_reset();
- void s3c24xx_device_start();
-
-
- void s3c2440_uart_fifo_w( int uart, UINT8 data);
- void s3c2440_touch_screen( int state);
- void s3c2440_request_irq( UINT32 int_type);
- void s3c2440_request_eint( UINT32 number);
-
-
- /*******************************************************************************
- TYPE DEFINITIONS
- *******************************************************************************/
-
- struct s3c24xx_memcon_regs_t
- {
- UINT32 data[0x34/4];
- };
-
- struct s3c24xx_usbhost_regs_t
- {
- UINT32 data[0x5C/4];
- };
-
- struct s3c24xx_irq_regs_t
- {
- UINT32 srcpnd;
- UINT32 intmod;
- UINT32 intmsk;
- UINT32 priority;
- UINT32 intpnd;
- UINT32 intoffset;
- UINT32 subsrcpnd;
- UINT32 intsubmsk;
- };
-
- struct s3c24xx_dma_regs_t
- {
- UINT32 disrc;
- UINT32 disrcc;
- UINT32 didst;
- UINT32 didstc;
- UINT32 dcon;
- UINT32 dstat;
- UINT32 dcsrc;
- UINT32 dcdst;
- UINT32 dmasktrig;
- };
-
- struct s3c24xx_clkpow_regs_t
- {
- UINT32 locktime;
- UINT32 mpllcon;
- UINT32 upllcon;
- UINT32 clkcon;
- UINT32 clkslow;
- UINT32 clkdivn;
- UINT32 camdivn;
- };
-
- struct s3c24xx_lcd_regs_t
- {
- UINT32 lcdcon1;
- UINT32 lcdcon2;
- UINT32 lcdcon3;
- UINT32 lcdcon4;
- UINT32 lcdcon5;
- UINT32 lcdsaddr1;
- UINT32 lcdsaddr2;
- UINT32 lcdsaddr3;
- UINT32 redlut;
- UINT32 greenlut;
- UINT32 bluelut;
- UINT32 reserved[8];
- UINT32 dithmode;
- UINT32 tpal;
- UINT32 lcdintpnd;
- UINT32 lcdsrcpnd;
- UINT32 lcdintmsk;
- UINT32 tconsel;
- };
-
- struct s3c24xx_lcdpal_regs_t
- {
- UINT32 data[0x400/4];
- };
-
- struct s3c24xx_nand_regs_t
- {
- UINT32 nfconf;
- UINT32 nfcont;
- UINT32 nfcmd;
- UINT32 nfaddr;
- UINT32 nfdata;
- UINT32 nfmeccd0;
- UINT32 nfmeccd1;
- UINT32 nfseccd;
- UINT32 nfstat;
- UINT32 nfestat0;
- UINT32 nfestat1;
- UINT32 nfmecc0;
- UINT32 nfmecc1;
- UINT32 nfsecc;
- UINT32 nfsblk;
- UINT32 nfeblk;
- };
-
- struct s3c24xx_cam_regs_t
- {
- UINT32 data[0xA4/4];
- };
-
- struct s3c24xx_uart_regs_t
- {
- UINT32 ulcon;
- UINT32 ucon;
- UINT32 ufcon;
- UINT32 umcon;
- UINT32 utrstat;
- UINT32 uerstat;
- UINT32 ufstat;
- UINT32 umstat;
- UINT32 utxh;
- UINT32 urxh;
- UINT32 ubrdiv;
- };
-
- struct s3c24xx_pwm_regs_t
- {
- UINT32 tcfg0;
- UINT32 tcfg1;
- UINT32 tcon;
- UINT32 tcntb0;
- UINT32 tcmpb0;
- UINT32 tcnto0;
- UINT32 tcntb1;
- UINT32 tcmpb1;
- UINT32 tcnto1;
- UINT32 tcntb2;
- UINT32 tcmpb2;
- UINT32 tcnto2;
- UINT32 tcntb3;
- UINT32 tcmpb3;
- UINT32 tcnto3;
- UINT32 tcntb4;
- UINT32 tcnto4;
- };
-
- struct s3c24xx_usbdev_regs_t
- {
- UINT32 data[0x130/4];
- };
-
- struct s3c24xx_wdt_regs_t
- {
- UINT32 wtcon;
- UINT32 wtdat;
- UINT32 wtcnt;
- };
-
- struct s3c24xx_iic_regs_t
- {
- UINT32 iiccon;
- UINT32 iicstat;
- UINT32 iicadd;
- UINT32 iicds;
- UINT32 iiclc;
- };
-
- struct s3c24xx_iis_regs_t
- {
- UINT32 iiscon;
- UINT32 iismod;
- UINT32 iispsr;
- UINT32 iisfcon;
- UINT32 iisfifo;
- };
-
- struct s3c24xx_gpio_regs_t
- {
- UINT32 gpacon;
- UINT32 gpadat;
- UINT32 pad_08;
- UINT32 pad_0c;
- UINT32 gpbcon;
- UINT32 gpbdat;
- UINT32 gpbup;
- UINT32 pad_1c;
- UINT32 gpccon;
- UINT32 gpcdat;
- UINT32 gpcup;
- UINT32 pad_2c;
- UINT32 gpdcon;
- UINT32 gpddat;
- UINT32 gpdup;
- UINT32 pad_3c;
- UINT32 gpecon;
- UINT32 gpedat;
- UINT32 gpeup;
- UINT32 pad_4c;
- UINT32 gpfcon;
- UINT32 gpfdat;
- UINT32 gpfup;
- UINT32 pad_5c;
- UINT32 gpgcon;
- UINT32 gpgdat;
- UINT32 gpgup;
- UINT32 pad_6c;
- UINT32 gphcon;
- UINT32 gphdat;
- UINT32 gphup;
- UINT32 pad_7c;
- UINT32 misccr;
- UINT32 dclkcon;
- UINT32 extint0;
- UINT32 extint1;
- UINT32 extint2;
- UINT32 eintflt0;
- UINT32 eintflt1;
- UINT32 eintflt2;
- UINT32 eintflt3;
- UINT32 eintmask;
- UINT32 eintpend;
- UINT32 gstatus0;
- UINT32 gstatus1;
- UINT32 gstatus2;
- UINT32 gstatus3;
- UINT32 gstatus4;
- UINT32 pad_c0;
- UINT32 pad_c4;
- UINT32 pad_c8;
- UINT32 mslcon;
- UINT32 gpjcon;
- UINT32 gpjdat;
- UINT32 gpjup;
- };
-
- struct s3c24xx_rtc_regs_t
- {
- UINT32 rtccon;
- UINT32 ticnt;
- UINT32 reserved[2];
- UINT32 rtcalm;
- UINT32 almsec;
- UINT32 almmin;
- UINT32 almhour;
- UINT32 almday;
- UINT32 almmon;
- UINT32 almyear;
- UINT32 rtcrst;
- UINT32 bcdsec;
- UINT32 bcdmin;
- UINT32 bcdhour;
- UINT32 bcdday;
- UINT32 bcddow;
- UINT32 bcdmon;
- UINT32 bcdyear;
- };
-
- struct s3c24xx_adc_regs_t
- {
- UINT32 adccon;
- UINT32 adctsc;
- UINT32 adcdly;
- UINT32 adcdat0;
- UINT32 adcdat1;
- UINT32 adcupdn;
- };
-
- struct s3c24xx_spi_regs_t
- {
- UINT32 spcon;
- UINT32 spsta;
- UINT32 sppin;
- UINT32 sppre;
- UINT32 sptdat;
- UINT32 sprdat;
- };
-
- struct s3c24xx_sdi_regs_t
- {
- UINT32 data[0x44/4];
- };
-
- struct s3c24xx_ac97_regs_t
- {
- UINT32 data[0x20/4];
- };
-
- struct s3c24xx_memcon_t
- {
- s3c24xx_memcon_regs_t regs;
- };
-
- struct s3c24xx_usbhost_t
- {
- s3c24xx_usbhost_regs_t regs;
- };
-
- struct s3c24xx_irq_t
- {
- s3c24xx_irq_regs_t regs;
- int line_irq, line_fiq;
- };
-
- struct s3c24xx_dma_t
- {
- s3c24xx_dma_regs_t regs;
- emu_timer *timer;
- };
-
- struct s3c24xx_clkpow_t
- {
- s3c24xx_clkpow_regs_t regs;
- };
-
- struct s3c24xx_lcd_t
- {
- s3c24xx_lcd_regs_t regs;
- emu_timer *timer;
- bitmap_rgb32 *bitmap[2];
- UINT32 vramaddr_cur;
- UINT32 vramaddr_max;
- UINT32 offsize;
- UINT32 pagewidth_cur;
- UINT32 pagewidth_max;
- UINT32 bppmode;
- UINT32 bswp, hwswp;
- int vpos, hpos;
- double framerate;
- UINT32 tpal;
- UINT32 hpos_min, hpos_max, vpos_min, vpos_max;
- UINT32 dma_data, dma_bits;
- };
-
- struct s3c24xx_lcdpal_t
- {
- s3c24xx_lcdpal_regs_t regs;
- };
-
- struct s3c24xx_nand_t
- {
- s3c24xx_nand_regs_t regs;
- UINT8 mecc[4];
- UINT8 secc[2];
- int ecc_pos, data_count;
- };
-
- struct s3c24xx_cam_t
- {
- s3c24xx_cam_regs_t regs;
- };
-
- struct s3c24xx_uart_t
- {
- s3c24xx_uart_regs_t regs;
- };
-
- struct s3c24xx_pwm_t
- {
- s3c24xx_pwm_regs_t regs;
- emu_timer *timer[5];
- UINT32 cnt[5];
- UINT32 cmp[5];
- UINT32 freq[5];
- };
-
- struct s3c24xx_usbdev_t
- {
- s3c24xx_usbdev_regs_t regs;
- };
-
- struct s3c24xx_wdt_t
- {
- s3c24xx_wdt_regs_t regs;
- emu_timer *timer;
- };
-
- struct s3c24xx_iic_t
- {
- s3c24xx_iic_regs_t regs;
- emu_timer *timer;
- int count;
- };
-
- struct s3c24xx_iis_t
- {
- s3c24xx_iis_regs_t regs;
- emu_timer *timer;
- UINT16 fifo[16/2];
- int fifo_index;
- };
-
- struct s3c24xx_gpio_t
- {
- s3c24xx_gpio_regs_t regs;
- };
-
- struct s3c24xx_rtc_t
- {
- s3c24xx_rtc_regs_t regs;
- emu_timer *timer_tick_count;
- emu_timer *timer_update;
- };
-
- struct s3c24xx_adc_t
- {
- s3c24xx_adc_regs_t regs;
- };
-
- struct s3c24xx_spi_t
- {
- s3c24xx_spi_regs_t regs;
- };
-
- struct s3c24xx_sdi_t
- {
- s3c24xx_sdi_regs_t regs;
- };
-
- struct s3c24xx_ac97_t
- {
- s3c24xx_ac97_regs_t regs;
- };
-
-
- UINT8 m_steppingstone[4*1024];
- s3c24xx_memcon_t m_memcon;
- s3c24xx_usbhost_t m_usbhost;
- s3c24xx_irq_t m_irq;
- s3c24xx_dma_t m_dma[S3C24XX_DMA_COUNT];
- s3c24xx_clkpow_t m_clkpow;
- s3c24xx_lcd_t m_lcd;
- s3c24xx_lcdpal_t m_lcdpal;
- s3c24xx_nand_t m_nand;
- s3c24xx_cam_t m_cam;
- s3c24xx_uart_t m_uart[S3C24XX_UART_COUNT];
- s3c24xx_pwm_t m_pwm;
- s3c24xx_usbdev_t m_usbdev;
- s3c24xx_wdt_t m_wdt;
- s3c24xx_iic_t m_iic;
- s3c24xx_iis_t m_iis;
- s3c24xx_gpio_t m_gpio;
- s3c24xx_rtc_t m_rtc;
- s3c24xx_adc_t m_adc;
- s3c24xx_spi_t m_spi[S3C24XX_SPI_COUNT];
- s3c24xx_sdi_t m_sdi;
- s3c24xx_ac97_t m_ac97;
- required_device<device_t> m_cpu;
- devcb_read32 m_pin_r_cb;
- devcb_write32 m_pin_w_cb;
- devcb_read32 m_port_r_cb;
- devcb_write32 m_port_w_cb;
- devcb_write_line m_scl_w_cb;
- devcb_read_line m_sda_r_cb;
- devcb_write_line m_sda_w_cb;
- devcb_read32 m_data_r_cb;
- devcb_write16 m_data_w_cb;
- devcb_write8 m_command_w_cb;
- devcb_write8 m_address_w_cb;
- devcb_read8 m_nand_data_r_cb;
- devcb_write8 m_nand_data_w_cb;
- int m_flags;
-};
-
-extern const device_type S3C2440;
-
-
-#endif
diff --git a/src/emu/machine/s3c24xx.inc b/src/emu/machine/s3c24xx.inc
deleted file mode 100644
index d90f105b7bb..00000000000
--- a/src/emu/machine/s3c24xx.inc
+++ /dev/null
@@ -1,3519 +0,0 @@
-/*******************************************************************************
-
- Samsung S3C2400 / S3C2410 / S3C2440
-
-*******************************************************************************/
-
-#include "emu.h"
-#include "cpu/arm7/arm7.h"
-#include "cpu/arm7/arm7core.h"
-#include "coreutil.h"
-
-/*******************************************************************************
- MACROS & CONSTANTS
-*******************************************************************************/
-
-//#define UART_PRINTF
-
-#define CLOCK_MULTIPLIER 1
-
-#define BIT(x,n) (((x)>>(n))&1)
-#define BITS(x,m,n) (((x)>>(n))&(((UINT32)1<<((m)-(n)+1))-1))
-#define CLR_BITS(x,m,n) ((x) & ~((((UINT32)1 << ((m) - (n) + 1)) - 1) << n))
-
-#if defined(DEVICE_S3C2400)
-
-#define S3C24XX_TPAL_GET_TPALEN(x) BIT(x,16)
-#define S3C24XX_TPAL_GET_TPALVAL(x) BITS(x,15,0)
-
-#else
-
-#define S3C24XX_TPAL_GET_TPALEN(x) BIT(x,24)
-#define S3C24XX_TPAL_GET_TPALVAL(x) BITS(x,23,0)
-
-#endif
-
-#define S3C24XX_DCON_GET_TC(x) BITS(x,19,0)
-#define S3C24XX_DCON_GET_DSZ(x) BITS(x,21,20)
-#define S3C24XX_DCON_GET_RELOAD(x) BIT(x,22)
-#define S3C24XX_DCON_GET_SWHWSEL(x) BIT(x,23)
-
-#define S3C24XX_DSTAT_GET_CURR_TC(x) BITS(x,19,0)
-#define S3C24XX_DSTAT_SET_CURR_TC(x,m) (CLR_BITS(x,19,0) | m)
-
-#define S3C24XX_DMASKTRIG_GET_ON_OFF(x) BIT(x,1)
-
-#if defined(DEVICE_S3C2400)
-
-#define S3C24XX_DCON_GET_HWSRCSEL(x) BITS(x,25,24)
-#define S3C24XX_DCON_GET_SERVMODE(x) BIT(x,26)
-#define S3C24XX_DCON_GET_TSZ(x) BIT(x,27)
-#define S3C24XX_DCON_GET_INT(x) BIT(x,28)
-
-#define S3C24XX_DISRC_GET_SADDR(x) BITS(x,28,0)
-
-#define S3C24XX_DIDST_GET_DADDR(x) BITS(x,28,0)
-
-#define S3C24XX_DCSRC_GET_CURR_SRC(x) BITS(x,28,0)
-#define S3C24XX_DCSRC_SET_CURR_SRC(x,m) (CLR_BITS(x,28,0) | m)
-
-#define S3C24XX_DCDST_GET_CURR_DST(x) BITS(x,28,0)
-#define S3C24XX_DCDST_SET_CURR_DST(x,m) (CLR_BITS(x,28,0) | m)
-
-#else
-
-#define S3C24XX_DCON_GET_HWSRCSEL(x) BITS(x,26,24)
-#define S3C24XX_DCON_GET_SERVMODE(x) BIT(x,27)
-#define S3C24XX_DCON_GET_TSZ(x) BIT(x,28)
-#define S3C24XX_DCON_GET_INT(x) BIT(x,29)
-
-#define S3C24XX_DISRC_GET_SADDR(x) BITS(x,30,0)
-
-#define S3C24XX_DIDST_GET_DADDR(x) BITS(x,30,0)
-
-#define S3C24XX_DCSRC_GET_CURR_SRC(x) BITS(x,30,0)
-#define S3C24XX_DCSRC_SET_CURR_SRC(x,m) (CLR_BITS(x,30,0) | m)
-
-#define S3C24XX_DCDST_GET_CURR_DST(x) BITS(x,30,0)
-#define S3C24XX_DCDST_SET_CURR_DST(x,m) (CLR_BITS(x,30,0) | m)
-
-#endif
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-/* ... */
-
-void S3C24_CLASS_NAME::s3c24xx_reset()
-{
- verboselog( machine(), 1, "reset\n");
- m_cpu->reset();
- this->reset();
-}
-
-int S3C24_CLASS_NAME::iface_core_pin_r(int pin)
-{
- if (!m_pin_r_cb.isnull())
- {
- return (m_pin_r_cb)(pin);
- }
- else
- {
- return 0;
- }
-}
-
-/* LCD Controller */
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_reset()
-{
- s3c24xx_lcd_t *lcd = &m_lcd;
- memset( &lcd->regs, 0, sizeof( lcd->regs));
- #if defined(DEVICE_S3C2410)
- lcd->regs.lcdintmsk = 3;
- lcd->regs.lpcsel = 4;
- #elif defined(DEVICE_S3C2440)
- lcd->regs.lcdintmsk = 3;
- lcd->regs.tconsel = 0x0F84;
- #endif
- lcd->vramaddr_cur = lcd->vramaddr_max = 0;
- lcd->offsize = 0;
- lcd->pagewidth_cur = lcd->pagewidth_max = 0;
- lcd->bppmode = 0;
- lcd->bswp = lcd->hwswp = 0;
- lcd->vpos = lcd->hpos = 0;
- lcd->framerate = 0;
- lcd->tpal = 0;
- lcd->hpos_min = lcd->hpos_max = lcd->vpos_min = lcd->vpos_max = 0;
- lcd->dma_data = lcd->dma_bits = 0;
- lcd->timer->adjust( attotime::never);
-}
-
-rgb_t S3C24_CLASS_NAME::s3c24xx_get_color_tft_16(UINT16 data)
-{
- if ((m_lcd.regs.lcdcon5 & (1 << 11)) == 0)
- {
- UINT8 r, g, b, i;
- r = (BITS( data, 15, 11) << 3);
- g = (BITS( data, 10, 6) << 3);
- b = (BITS( data, 5, 1) << 3);
- i = BIT( data, 1) << 2;
- return rgb_t( r | i, g | i, b | i);
- }
- else
- {
- UINT8 r, g, b;
- r = BITS( data, 15, 11) << 3;
- g = BITS( data, 10, 5) << 2;
- b = BITS( data, 4, 0) << 3;
- return rgb_t( r, g, b);
- }
-}
-
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
-
-rgb_t S3C24_CLASS_NAME::s3c24xx_get_color_tft_24(UINT32 data)
-{
- UINT8 r, g, b;
- r = BITS( data, 23, 16);
- g = BITS( data, 15, 8);
- b = BITS( data, 7, 0);
- return rgb_t( r, g, b);
-}
-
-#endif
-
-rgb_t S3C24_CLASS_NAME::s3c24xx_get_color_stn_12(UINT16 data)
-{
- UINT8 r, g, b;
- r = BITS( data, 11, 8) << 4;
- g = BITS( data, 7, 4) << 4;
- b = BITS( data, 3, 0) << 4;
- return rgb_t( r, g, b);
-}
-
-rgb_t S3C24_CLASS_NAME::s3c24xx_get_color_stn_08( UINT8 data)
-{
- UINT8 r, g, b;
- r = ((m_lcd.regs.redlut >> (BITS( data, 7, 5) << 2)) & 0xF) << 4;
- g = ((m_lcd.regs.greenlut >> (BITS( data, 4, 2) << 2)) & 0xF) << 4;
- b = ((m_lcd.regs.bluelut >> (BITS( data, 1, 0) << 2)) & 0xF) << 4;
- return rgb_t( r, g, b);
-}
-
-rgb_t S3C24_CLASS_NAME::s3c24xx_get_color_stn_01(UINT8 data)
-{
- if ((data & 1) == 0)
- {
- return rgb_t::black;
- }
- else
- {
- return rgb_t::white;
- }
-}
-
-rgb_t S3C24_CLASS_NAME::s3c24xx_get_color_stn_02(UINT8 data)
-{
- UINT8 r, g, b;
- r = g = b = ((m_lcd.regs.bluelut >> (BITS( data, 1, 0) << 2)) & 0xF) << 4;
- return rgb_t( r, g, b);
-}
-
-rgb_t S3C24_CLASS_NAME::s3c24xx_get_color_stn_04(UINT8 data)
-{
- UINT8 r, g, b;
- r = g = b = BITS( data, 3, 0) << 4;
- return rgb_t( r, g, b);
-}
-
-rgb_t S3C24_CLASS_NAME::s3c24xx_get_color_tpal()
-{
-#if defined(DEVICE_S3C2400)
- return s3c24xx_get_color_tft_16(S3C24XX_TPAL_GET_TPALVAL( m_lcd.tpal));
-#else
- return s3c24xx_get_color_tft_24(S3C24XX_TPAL_GET_TPALVAL( m_lcd.tpal));
-#endif
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_dma_reload()
-{
- m_lcd.vramaddr_cur = m_lcd.regs.lcdsaddr1 << 1;
- m_lcd.vramaddr_max = ((m_lcd.regs.lcdsaddr1 & 0xFFE00000) | m_lcd.regs.lcdsaddr2) << 1;
- m_lcd.offsize = BITS( m_lcd.regs.lcdsaddr3, 21, 11);
- m_lcd.pagewidth_cur = 0;
- m_lcd.pagewidth_max = BITS( m_lcd.regs.lcdsaddr3, 10, 0);
- if (m_lcd.pagewidth_max == 0)
- {
- if (m_lcd.bppmode == S3C24XX_BPPMODE_STN_12_P)
- {
- m_lcd.pagewidth_max = (m_lcd.hpos_max - m_lcd.hpos_min + 1) / 16 * 12;
- }
- }
- verboselog( machine(), 3, "LCD - vramaddr %08X %08X offsize %08X pagewidth %08X\n", m_lcd.vramaddr_cur, m_lcd.vramaddr_max, m_lcd.offsize, m_lcd.pagewidth_max);
- m_lcd.dma_data = 0;
- m_lcd.dma_bits = 0;
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_dma_init()
-{
- m_lcd.bppmode = BITS( m_lcd.regs.lcdcon1, 4, 1);
- s3c24xx_lcd_dma_reload();
- m_lcd.bswp = BIT( m_lcd.regs.lcdcon5, 1);
- m_lcd.hwswp = BIT( m_lcd.regs.lcdcon5, 0);
- m_lcd.tpal = m_lcd.regs.tpal;
- verboselog( machine(), 3, "LCD - bppmode %d hwswp %d bswp %d\n", m_lcd.bppmode, m_lcd.hwswp, m_lcd.bswp);
- m_lcd.dma_data = 0;
- m_lcd.dma_bits = 0;
-}
-
-#if 0
-UINT32 S3C24_CLASS_NAME::s3c24xx_lcd_dma_read()
-{
- address_space& space = m_cpu->memory().space( AS_PROGRAM);
- UINT8 *vram, data[4];
- vram = (UINT8 *)space.get_read_ptr( m_lcd.vramaddr_cur);
- for (int i = 0; i < 2; i++)
- {
- data[i*2+0] = *vram++;
- data[i*2+1] = *vram++;
- m_lcd.vramaddr_cur += 2;
- m_lcd.pagewidth_cur++;
- if (m_lcd.pagewidth_cur >= m_lcd.pagewidth_max)
- {
- m_lcd.vramaddr_cur += m_lcd.offsize << 1;
- m_lcd.pagewidth_cur = 0;
- vram = (UINT8 *)space.get_read_ptr( m_lcd.vramaddr_cur);
- }
- }
- if (m_lcd.hwswp == 0)
- {
- if (m_lcd.bswp == 0)
- {
- return (data[3] << 24) | (data[2] << 16) | (data[1] << 8) | (data[0] << 0);
- }
- else
- {
- return (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | (data[3] << 0);
- }
- }
- else
- {
- if (m_lcd.bswp == 0)
- {
- return (data[1] << 24) | (data[0] << 16) | (data[3] << 8) | (data[2] << 0);
- }
- else
- {
- return (data[2] << 24) | (data[3] << 16) | (data[0] << 8) | (data[1] << 0);
- }
- }
-}
-#endif
-
-UINT32 S3C24_CLASS_NAME::s3c24xx_lcd_dma_read()
-{
- address_space& space = m_cpu->memory().space( AS_PROGRAM);
- UINT8 *vram, data[4];
- vram = (UINT8 *)space.get_read_ptr( m_lcd.vramaddr_cur);
- for (int i = 0; i < 2; i++)
- {
- if (m_lcd.hwswp == 0)
- {
- if (m_lcd.bswp == 0)
- {
- if ((m_lcd.vramaddr_cur & 2) == 0)
- {
- data[i*2+0] = *(vram + 3);
- data[i*2+1] = *(vram + 2);
- }
- else
- {
- data[i*2+0] = *(vram - 1);
- data[i*2+1] = *(vram - 2);
- }
- }
- else
- {
- data[i*2+0] = *(vram + 0);
- data[i*2+1] = *(vram + 1);
- }
- }
- else
- {
- if (m_lcd.bswp == 0)
- {
- data[i*2+0] = *(vram + 1);
- data[i*2+1] = *(vram + 0);
- }
- else
- {
- if ((m_lcd.vramaddr_cur & 2) == 0)
- {
- data[i*2+0] = *(vram + 2);
- data[i*2+1] = *(vram + 3);
- }
- else
- {
- data[i*2+0] = *(vram - 2);
- data[i*2+1] = *(vram - 1);
- }
- }
- }
- m_lcd.vramaddr_cur += 2;
- m_lcd.pagewidth_cur++;
- if (m_lcd.pagewidth_cur >= m_lcd.pagewidth_max)
- {
- m_lcd.vramaddr_cur += m_lcd.offsize << 1;
- m_lcd.pagewidth_cur = 0;
- vram = (UINT8 *)space.get_read_ptr( m_lcd.vramaddr_cur);
- }
- else
- {
- vram += 2;
- }
- }
- if (m_flags & S3C24XX_INTERFACE_LCD_REVERSE)
- {
- return (data[3] << 24) | (data[2] << 16) | (data[1] << 8) | (data[0] << 0);
- }
- else
- {
- return (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | (data[3] << 0);
- }
-}
-
-UINT32 S3C24_CLASS_NAME::s3c24xx_lcd_dma_read_bits(int count)
-{
- UINT32 data;
- if (count <= m_lcd.dma_bits)
- {
- m_lcd.dma_bits -= count;
- data = BITS( m_lcd.dma_data, 31, 32 - count);
- m_lcd.dma_data = m_lcd.dma_data << count;
- }
- else
- {
- if (m_lcd.dma_bits == 0)
- {
- if (count == 32)
- {
- data = s3c24xx_lcd_dma_read();
- }
- else
- {
- UINT32 temp = s3c24xx_lcd_dma_read();
- data = BITS( temp, 31, 32 - count);
- m_lcd.dma_data = temp << count;
- m_lcd.dma_bits = 32 - count;
- }
- }
- else
- {
- UINT32 temp = s3c24xx_lcd_dma_read();
- data = (m_lcd.dma_data >> (32 - count)) | BITS( temp, 31, 32 - (count - m_lcd.dma_bits));
- m_lcd.dma_data = temp << (count - m_lcd.dma_bits);
- m_lcd.dma_bits = 32 - (count - m_lcd.dma_bits);
- }
- }
- return data;
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_render_tpal()
-{
- bitmap_rgb32 &bitmap = *m_lcd.bitmap[0];
- UINT32 color = s3c24xx_get_color_tpal();
- for (int y = m_lcd.vpos_min; y <= m_lcd.vpos_max; y++)
- {
- UINT32 *scanline = &bitmap.pix32(y, m_lcd.hpos_min);
- for (int x = m_lcd.hpos_min; x <= m_lcd.hpos_max; x++)
- {
- *scanline++ = color;
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_render_stn_01()
-{
- bitmap_rgb32 &bitmap = *m_lcd.bitmap[0];
- UINT32 *scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- for (int i = 0; i < 4; i++)
- {
- UINT32 data = s3c24xx_lcd_dma_read();
- for (int j = 0; j < 32; j++)
- {
- if (m_flags & S3C24XX_INTERFACE_LCD_REVERSE)
- {
- *scanline++ = s3c24xx_get_color_stn_01( data & 0x01);
- data = data >> 1;
- }
- else
- {
- *scanline++ = s3c24xx_get_color_stn_01((data >> 31) & 0x01);
- data = data << 1;
- }
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max << 4))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max) m_lcd.vpos = m_lcd.vpos_min;
- m_lcd.hpos = m_lcd.hpos_min;
- scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- }
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_render_stn_02()
-{
- bitmap_rgb32 &bitmap = *m_lcd.bitmap[0];
- UINT32 *scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- for (int i = 0; i < 4; i++)
- {
- UINT32 data = s3c24xx_lcd_dma_read();
- for (int j = 0; j < 16; j++)
- {
- *scanline++ = s3c24xx_get_color_stn_02((data >> 30) & 0x03);
- data = data << 2;
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max << 3))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max) m_lcd.vpos = m_lcd.vpos_min;
- m_lcd.hpos = m_lcd.hpos_min;
- scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- }
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_render_stn_04()
-{
- bitmap_rgb32 &bitmap = *m_lcd.bitmap[0];
- UINT32 *scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- for (int i = 0; i < 4; i++)
- {
- UINT32 data = s3c24xx_lcd_dma_read();
- for (int j = 0; j < 8; j++)
- {
- *scanline++ = s3c24xx_get_color_stn_04((data >> 28) & 0x0F);
- data = data << 4;
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max << 2))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max) m_lcd.vpos = m_lcd.vpos_min;
- m_lcd.hpos = m_lcd.hpos_min;
- scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- }
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_render_stn_08()
-{
- bitmap_rgb32 &bitmap = *m_lcd.bitmap[0];
- UINT32 *scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- for (int i = 0; i < 4; i++)
- {
- UINT32 data = s3c24xx_lcd_dma_read();
- for (int j = 0; j < 4; j++)
- {
- *scanline++ = s3c24xx_get_color_stn_08((data >> 24) & 0xFF);
- data = data << 8;
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max << 1))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max) m_lcd.vpos = m_lcd.vpos_min;
- m_lcd.hpos = m_lcd.hpos_min;
- scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- }
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_render_stn_12_p()
-{
- bitmap_rgb32 &bitmap = *m_lcd.bitmap[0];
- UINT32 *scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- for (int i = 0; i < 16; i++)
- {
- *scanline++ = s3c24xx_get_color_stn_12(s3c24xx_lcd_dma_read_bits(12));
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max * 16 / 12))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max) m_lcd.vpos = m_lcd.vpos_min;
- m_lcd.hpos = m_lcd.hpos_min;
- scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_render_stn_12_u() // not tested
-{
- bitmap_rgb32 &bitmap = *m_lcd.bitmap[0];
- UINT32 *scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- for (int i = 0; i < 4; i++)
- {
- UINT32 data = s3c24xx_lcd_dma_read();
- for (int j = 0; j < 2; j++)
- {
- *scanline++ = s3c24xx_get_color_stn_12((data >> 16) & 0x0FFF);
- data = data << 16;
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max << 0))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max) m_lcd.vpos = m_lcd.vpos_min;
- m_lcd.hpos = m_lcd.hpos_min;
- scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- }
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_render_tft_01()
-{
- bitmap_rgb32 &bitmap = *m_lcd.bitmap[0];
- UINT32 *scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- for (int i = 0; i < 4; i++)
- {
- UINT32 data = s3c24xx_lcd_dma_read();
- for (int j = 0; j < 32; j++)
- {
- *scanline++ = m_palette->pen_color((data >> 31) & 0x01);
- data = data << 1;
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max << 4))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max) m_lcd.vpos = m_lcd.vpos_min;
- m_lcd.hpos = m_lcd.hpos_min;
- scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- }
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_render_tft_02()
-{
- bitmap_rgb32 &bitmap = *m_lcd.bitmap[0];
- UINT32 *scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- for (int i = 0; i < 4; i++)
- {
- UINT32 data = s3c24xx_lcd_dma_read();
- for (int j = 0; j < 16; j++)
- {
- *scanline++ = m_palette->pen_color((data >> 30) & 0x03);
- data = data << 2;
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max << 3))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max) m_lcd.vpos = m_lcd.vpos_min;
- m_lcd.hpos = m_lcd.hpos_min;
- scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- }
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_render_tft_04()
-{
- bitmap_rgb32 &bitmap = *m_lcd.bitmap[0];
- UINT32 *scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- for (int i = 0; i < 4; i++)
- {
- UINT32 data = s3c24xx_lcd_dma_read();
- for (int j = 0; j < 8; j++)
- {
- *scanline++ = m_palette->pen_color((data >> 28) & 0x0F);
- data = data << 4;
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max << 2))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max) m_lcd.vpos = m_lcd.vpos_min;
- m_lcd.hpos = m_lcd.hpos_min;
- scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- }
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_render_tft_08()
-{
- bitmap_rgb32 &bitmap = *m_lcd.bitmap[0];
- UINT32 *scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- for (int i = 0; i < 4; i++)
- {
- UINT32 data = s3c24xx_lcd_dma_read();
- for (int j = 0; j < 4; j++)
- {
- *scanline++ = m_palette->pen_color((data >> 24) & 0xFF);
- data = data << 8;
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max << 1))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max) m_lcd.vpos = m_lcd.vpos_min;
- m_lcd.hpos = m_lcd.hpos_min;
- scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- }
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_render_tft_16()
-{
- bitmap_rgb32 &bitmap = *m_lcd.bitmap[0];
- UINT32 *scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- for (int i = 0; i < 4; i++)
- {
- UINT32 data = s3c24xx_lcd_dma_read();
- for (int j = 0; j < 2; j++)
- {
- *scanline++ = s3c24xx_get_color_tft_16((data >> 16) & 0xFFFF);
- data = data << 16;
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max << 0))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max) m_lcd.vpos = m_lcd.vpos_min;
- m_lcd.hpos = m_lcd.hpos_min;
- scanline = &bitmap.pix32(m_lcd.vpos, m_lcd.hpos);
- }
- }
- }
-}
-
-TIMER_CALLBACK_MEMBER( S3C24_CLASS_NAME::s3c24xx_lcd_timer_exp )
-{
- screen_device *screen = machine().first_screen();
- UINT32 tpalen;
- verboselog( machine(), 2, "LCD timer callback\n");
- m_lcd.vpos = screen->vpos();
- m_lcd.hpos = screen->hpos();
- verboselog( machine(), 3, "LCD - vpos %d hpos %d\n", m_lcd.vpos, m_lcd.hpos);
- tpalen = S3C24XX_TPAL_GET_TPALEN( m_lcd.tpal);
- if (tpalen == 0)
- {
- if (m_lcd.vramaddr_cur >= m_lcd.vramaddr_max)
- {
- s3c24xx_lcd_dma_reload();
- }
- verboselog( machine(), 3, "LCD - vramaddr %08X\n", m_lcd.vramaddr_cur);
- while (m_lcd.vramaddr_cur < m_lcd.vramaddr_max)
- {
- switch (m_lcd.bppmode)
- {
- case S3C24XX_BPPMODE_STN_01 : s3c24xx_lcd_render_stn_01(); break;
- case S3C24XX_BPPMODE_STN_02 : s3c24xx_lcd_render_stn_02(); break;
- case S3C24XX_BPPMODE_STN_04 : s3c24xx_lcd_render_stn_04(); break;
- case S3C24XX_BPPMODE_STN_08 : s3c24xx_lcd_render_stn_08(); break;
- case S3C24XX_BPPMODE_STN_12_P : s3c24xx_lcd_render_stn_12_p(); break;
- case S3C24XX_BPPMODE_STN_12_U : s3c24xx_lcd_render_stn_12_u(); break;
- case S3C24XX_BPPMODE_TFT_01 : s3c24xx_lcd_render_tft_01(); break;
- case S3C24XX_BPPMODE_TFT_02 : s3c24xx_lcd_render_tft_02(); break;
- case S3C24XX_BPPMODE_TFT_04 : s3c24xx_lcd_render_tft_04(); break;
- case S3C24XX_BPPMODE_TFT_08 : s3c24xx_lcd_render_tft_08(); break;
- case S3C24XX_BPPMODE_TFT_16 : s3c24xx_lcd_render_tft_16(); break;
- default : verboselog( machine(), 0, "s3c24xx_lcd_timer_exp: bppmode %d not supported\n", m_lcd.bppmode); break;
- }
- if ((m_lcd.vpos == m_lcd.vpos_min) && (m_lcd.hpos == m_lcd.hpos_min)) break;
- }
- }
- else
- {
- s3c24xx_lcd_render_tpal();
- }
- m_lcd.timer->adjust( screen->time_until_pos( m_lcd.vpos, m_lcd.hpos));
-}
-
-void S3C24_CLASS_NAME::s3c24xx_video_start()
-{
- screen_device *screen = machine().first_screen();
- m_lcd.bitmap[0] = auto_bitmap_rgb32_alloc(machine(), screen->width(), screen->height());
- m_lcd.bitmap[1] = auto_bitmap_rgb32_alloc(machine(), screen->width(), screen->height());
-}
-
-void S3C24_CLASS_NAME::bitmap_blend( bitmap_rgb32 &bitmap_dst, bitmap_rgb32 &bitmap_src_1, bitmap_rgb32 &bitmap_src_2)
-{
- for (int y = 0; y < bitmap_dst.height(); y++)
- {
- UINT32 *line0 = &bitmap_src_1.pix32(y);
- UINT32 *line1 = &bitmap_src_2.pix32(y);
- UINT32 *line2 = &bitmap_dst.pix32(y);
- for (int x = 0; x < bitmap_dst.width(); x++)
- {
- UINT32 color0 = line0[x];
- UINT32 color1 = line1[x];
- UINT16 r0 = (color0 >> 16) & 0x000000ff;
- UINT16 g0 = (color0 >> 8) & 0x000000ff;
- UINT16 b0 = (color0 >> 0) & 0x000000ff;
- UINT16 r1 = (color1 >> 16) & 0x000000ff;
- UINT16 g1 = (color1 >> 8) & 0x000000ff;
- UINT16 b1 = (color1 >> 0) & 0x000000ff;
- UINT8 r = (UINT8)((r0 + r1) >> 1);
- UINT8 g = (UINT8)((g0 + g1) >> 1);
- UINT8 b = (UINT8)((b0 + b1) >> 1);
- line2[x] = (r << 16) | (g << 8) | b;
- }
- }
-}
-
-UINT32 S3C24_CLASS_NAME::s3c24xx_video_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
-{
- if (m_lcd.regs.lcdcon1 & (1 << 0))
- {
- if (m_lcd.framerate >= 1195)
- {
- bitmap_blend( bitmap, *m_lcd.bitmap[0], *m_lcd.bitmap[1]);
- copybitmap( *m_lcd.bitmap[1], *m_lcd.bitmap[0], 0, 0, 0, 0, cliprect);
- }
- else
- {
- copybitmap( bitmap, *m_lcd.bitmap[0], 0, 0, 0, 0, cliprect);
- }
- s3c24xx_lcd_dma_init();
- }
- return 0;
-}
-
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_lcd_r )
-{
- UINT32 data = ((UINT32*)&m_lcd.regs)[offset];
- switch (offset)
- {
- case S3C24XX_LCDCON1 :
- {
- // make sure line counter is going
- UINT32 vpos = machine().first_screen()->vpos();
- if (vpos < m_lcd.vpos_min) vpos = m_lcd.vpos_min;
- if (vpos > m_lcd.vpos_max) vpos = m_lcd.vpos_max;
- data = (data & ~0xFFFC0000) | ((m_lcd.vpos_max - vpos) << 18);
- }
- break;
- case S3C24XX_LCDCON5 :
- {
- UINT32 vpos = machine().first_screen()->vpos();
- data = data & ~0x00018000;
- if (vpos < m_lcd.vpos_min) data = data | 0x00000000;
- if (vpos > m_lcd.vpos_max) data = data | 0x00018000;
- // todo: 00 = VSYNC, 01 = BACK Porch, 10 = ACTIVE, 11 = FRONT Porch
- }
- break;
- }
- verboselog( machine(), 9, "(LCD) %08X -> %08X\n", S3C24XX_BASE_LCD + (offset << 2), data);
- return data;
-}
-
-int S3C24_CLASS_NAME::s3c24xx_lcd_configure_tft()
-{
- screen_device *screen = machine().first_screen();
- UINT32 vspw, vbpd, lineval, vfpd, hspw, hbpd, hfpd, hozval, clkval, hclk;
- double framerate, vclk;
- UINT32 width, height;
- rectangle visarea;
- verboselog( machine(), 5, "s3c24xx_lcd_configure_tft\n");
- vspw = BITS( m_lcd.regs.lcdcon2, 5, 0);
- vbpd = BITS( m_lcd.regs.lcdcon2, 31, 24);
- lineval = BITS( m_lcd.regs.lcdcon2, 23, 14);
- vfpd = BITS( m_lcd.regs.lcdcon2, 13, 6);
- hspw = BITS( m_lcd.regs.lcdcon4, 7, 0);
- hbpd = BITS( m_lcd.regs.lcdcon3, 25, 19);
- hfpd = BITS( m_lcd.regs.lcdcon3, 7, 0);
- hozval = BITS( m_lcd.regs.lcdcon3, 18, 8);
- clkval = BITS( m_lcd.regs.lcdcon1, 17, 8);
- hclk = s3c24xx_get_hclk();
- verboselog( machine(), 3, "LCD - vspw %d vbpd %d lineval %d vfpd %d hspw %d hbpd %d hfpd %d hozval %d clkval %d hclk %d\n", vspw, vbpd, lineval, vfpd, hspw, hbpd, hfpd, hozval, clkval, hclk);
- vclk = (double)(hclk / ((clkval + 1) * 2));
- verboselog( machine(), 3, "LCD - vclk %f\n", vclk);
- framerate = vclk / (((vspw + 1) + (vbpd + 1) + (lineval + 1) + (vfpd + 1)) * ((hspw + 1) + (hbpd + 1) + (hozval + 1) + (hfpd + 1)));
- verboselog( machine(), 3, "LCD - framerate %f\n", framerate);
- m_lcd.framerate = framerate;
- width = (hspw + 1) + (hbpd + 1) + (hozval + 1) + (hfpd + 1);
- height = (vspw + 1) + (vbpd + 1) + (lineval + 1) + (vfpd + 1);
- visarea.min_x = (hspw + 1) + (hbpd + 1);
- visarea.min_y = (vspw + 1) + (vbpd + 1);
- visarea.max_x = visarea.min_x + (hozval + 1) - 1;
- visarea.max_y = visarea.min_y + (lineval + 1) - 1;
- verboselog( machine(), 3, "LCD - visarea min_x %d min_y %d max_x %d max_y %d\n", visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y);
- verboselog( machine(), 3, "video_screen_configure %d %d %f\n", width, height, m_lcd.framerate);
- m_lcd.hpos_min = (hspw + 1) + (hbpd + 1);
- m_lcd.hpos_max = m_lcd.hpos_min + (hozval + 1) - 1;
- m_lcd.vpos_min = (vspw + 1) + (vbpd + 1);
- m_lcd.vpos_max = m_lcd.vpos_min + (lineval + 1) - 1;
- screen->configure( width, height, visarea, HZ_TO_ATTOSECONDS( m_lcd.framerate));
- return TRUE;
-}
-
-int S3C24_CLASS_NAME::s3c24xx_lcd_configure_stn()
-{
- screen_device *screen = machine().first_screen();
- UINT32 pnrmode, bppmode, clkval, lineval, wdly, hozval, lineblank, wlh, hclk;
- double vclk, framerate;
- UINT32 width, height;
- rectangle visarea;
- verboselog( machine(), 5, "s3c24xx_lcd_configure_stn\n");
- pnrmode = BITS( m_lcd.regs.lcdcon1, 6, 5);
- bppmode = BITS( m_lcd.regs.lcdcon1, 4, 1);
- clkval = BITS( m_lcd.regs.lcdcon1, 17, 8);
- lineval = BITS( m_lcd.regs.lcdcon2, 23, 14);
- wdly = BITS( m_lcd.regs.lcdcon3, 20, 19);
- hozval = BITS( m_lcd.regs.lcdcon3, 18, 8);
- lineblank = BITS( m_lcd.regs.lcdcon3, 7, 0);
- wlh = BITS( m_lcd.regs.lcdcon4, 1, 0);
- hclk = s3c24xx_get_hclk();
- verboselog( machine(), 3, "LCD - pnrmode %d bppmode %d clkval %d lineval %d wdly %d hozval %d lineblank %d wlh %d hclk %d\n", pnrmode, bppmode, clkval, lineval, wdly, hozval, lineblank, wlh, hclk);
- if (clkval == 0)
- {
- return FALSE;
- }
- vclk = (double)(hclk / ((clkval + 0) * 2));
- verboselog( machine(), 3, "LCD - vclk %f\n", vclk);
- framerate = 1 / (((1 / vclk) * (hozval + 1) + (1 / hclk) * ((1 << (4 + wlh)) + (1 << (4 + wdly)) + (lineblank * 8))) * (lineval + 1));
- verboselog( machine(), 3, "LCD - framerate %f\n", framerate);
- switch (pnrmode)
- {
- case S3C24XX_PNRMODE_STN_04_SS : width = ((hozval + 1) * 4); break;
- case S3C24XX_PNRMODE_STN_04_DS : width = ((hozval + 1) * 4); break;
- case S3C24XX_PNRMODE_STN_08_SS : width = ((hozval + 1) * 8 / 3); break;
- default : width = 0; break;
- }
- height = lineval + 1;
- m_lcd.framerate = framerate;
- visarea.set(0, width - 1, 0, height - 1);
- verboselog( machine(), 3, "LCD - visarea min_x %d min_y %d max_x %d max_y %d\n", visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y);
- verboselog( machine(), 3, "video_screen_configure %d %d %f\n", width, height, m_lcd.framerate);
- m_lcd.hpos_min = 0;
- m_lcd.hpos_max = width - 1;
- m_lcd.vpos_min = 0;
- m_lcd.vpos_max = height - 1;
- screen->configure( width, height, visarea, HZ_TO_ATTOSECONDS( m_lcd.framerate));
- return TRUE;
-}
-
-int S3C24_CLASS_NAME::s3c24xx_lcd_configure()
-{
- UINT32 bppmode;
- verboselog( machine(), 5, "s3c24xx_lcd_configure\n");
- bppmode = BITS( m_lcd.regs.lcdcon1, 4, 1);
- if ((bppmode & (1 << 3)) == 0)
- {
- return s3c24xx_lcd_configure_stn();
- }
- else
- {
- return s3c24xx_lcd_configure_tft();
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_start()
-{
- screen_device *screen = machine().first_screen();
- verboselog( machine(), 1, "LCD start\n");
- if (s3c24xx_lcd_configure())
- {
- s3c24xx_lcd_dma_init();
- m_lcd.timer->adjust( screen->time_until_pos( m_lcd.vpos_min, m_lcd.hpos_min));
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_stop()
-{
- verboselog( machine(), 1, "LCD stop\n");
- m_lcd.timer->adjust( attotime::never);
-}
-
-void S3C24_CLASS_NAME::s3c24xx_lcd_recalc()
-{
- if (m_lcd.regs.lcdcon1 & (1 << 0))
- {
- s3c24xx_lcd_start();
- }
- else
- {
- s3c24xx_lcd_stop();
- }
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_lcd_w )
-{
- UINT32 old_value = ((UINT32*)&m_lcd.regs)[offset];
- verboselog( machine(), 9, "(LCD) %08X <- %08X\n", S3C24XX_BASE_LCD + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_lcd.regs)[offset]);
- switch (offset)
- {
- case S3C24XX_LCDCON1 :
- {
- if ((old_value & (1 << 0)) != (data & (1 << 0)))
- {
- s3c24xx_lcd_recalc();
- }
- }
- break;
- }
-}
-
-/* LCD Palette */
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_lcd_palette_r )
-{
- UINT32 data = m_lcdpal.regs.data[offset];
- verboselog( machine(), 9, "(LCD) %08X -> %08X\n", S3C24XX_BASE_LCDPAL + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_lcd_palette_w )
-{
- verboselog( machine(), 9, "(LCD) %08X <- %08X\n", S3C24XX_BASE_LCDPAL + (offset << 2), data);
- COMBINE_DATA(&m_lcdpal.regs.data[offset]);
- if (mem_mask != 0xffffffff)
- {
- verboselog( machine(), 0, "s3c24xx_lcd_palette_w: unknown mask %08x\n", mem_mask);
- }
- m_palette->set_pen_color( offset, s3c24xx_get_color_tft_16(data & 0xFFFF));
-}
-
-/* Clock & Power Management */
-
-void S3C24_CLASS_NAME::s3c24xx_clkpow_reset()
-{
- s3c24xx_clkpow_t *clkpow = &m_clkpow;
- memset( &clkpow->regs, 0, sizeof( clkpow->regs));
- #if defined(DEVICE_S3C2400)
- clkpow->regs.locktime = 0x00FFFFFF;
- clkpow->regs.mpllcon = 0x0005C080;
- clkpow->regs.upllcon = 0x00028080;
- clkpow->regs.clkcon = 0x0000FFF8;
- #elif defined(DEVICE_S3C2410)
- clkpow->regs.locktime = 0x00FFFFFF;
- clkpow->regs.mpllcon = 0x0005C080;
- clkpow->regs.upllcon = 0x00028080;
- clkpow->regs.clkcon = 0x0007FFF0;
- #elif defined(DEVICE_S3C2440)
- clkpow->regs.locktime = 0xFFFFFFFF;
- clkpow->regs.mpllcon = 0x00096030;
- clkpow->regs.upllcon = 0x0004D030;
- clkpow->regs.clkcon = 0x00FFFFF0;
- #endif
- clkpow->regs.clkslow = 4;
-}
-
-UINT32 S3C24_CLASS_NAME::s3c24xx_get_fclk()
-{
- UINT32 mpllcon, clkslow, mdiv, pdiv, sdiv, fclk;
- double temp1, temp2;
- mpllcon = m_clkpow.regs.mpllcon;
- mdiv = BITS( mpllcon, 19, 12);
- pdiv = BITS( mpllcon, 9, 4);
- sdiv = BITS( mpllcon, 1, 0);
-#if defined(DEVICE_S3C2400) || defined(DEVICE_S3C2410)
- temp1 = 1 * (mdiv + 8) * (double)clock();
-#else
- temp1 = 2 * (mdiv + 8) * (double)clock();
-#endif
- temp2 = (double)((pdiv + 2) * (1 << sdiv));
- fclk = (UINT32)(temp1 / temp2);
- clkslow = m_clkpow.regs.clkslow;
- if (BIT( clkslow, 4) == 1)
- {
- UINT32 slow_val = BITS( clkslow, 2, 0);
- if (slow_val > 0)
- {
- fclk = fclk / (2 * slow_val);
- }
- }
- return fclk;
-}
-
-UINT32 S3C24_CLASS_NAME::s3c24xx_get_hclk()
-{
-#if defined(DEVICE_S3C2400) || defined(DEVICE_S3C2410)
- return s3c24xx_get_fclk() / (BIT( m_clkpow.regs.clkdivn, 1) + 1);
-#else
- switch (BITS( m_clkpow.regs.clkdivn, 2, 1))
- {
- case 0 : return s3c24xx_get_fclk() / 1;
- case 1 : return s3c24xx_get_fclk() / 2;
- case 2 : return s3c24xx_get_fclk() / (4 * (BIT( m_clkpow.regs.camdivn, 9) + 1));
- case 3 : return s3c24xx_get_fclk() / (3 * (BIT( m_clkpow.regs.camdivn, 8) + 1));
- }
- return 0;
-#endif
-}
-
-UINT32 S3C24_CLASS_NAME::s3c24xx_get_pclk()
-{
- return s3c24xx_get_hclk() / (1 << BIT( m_clkpow.regs.clkdivn, 0));
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_clkpow_r )
-{
- UINT32 data = ((UINT32*)&m_clkpow.regs)[offset];
- verboselog(machine(), 9, "(CLKPOW) %08X -> %08X\n", S3C24XX_BASE_CLKPOW + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_clkpow_w )
-{
- verboselog( machine(), 9, "(CLKPOW) %08X <- %08X\n", S3C24XX_BASE_CLKPOW + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_clkpow.regs)[offset]);
- switch (offset)
- {
- case S3C24XX_MPLLCON :
- {
- verboselog( machine(), 5, "CLKPOW - fclk %d hclk %d pclk %d\n", s3c24xx_get_fclk(), s3c24xx_get_hclk(), s3c24xx_get_pclk());
- m_cpu->set_unscaled_clock(s3c24xx_get_fclk() * CLOCK_MULTIPLIER);
- }
- break;
- case S3C24XX_CLKSLOW :
- {
- verboselog( machine(), 5, "CLKPOW - fclk %d hclk %d pclk %d\n", s3c24xx_get_fclk(), s3c24xx_get_hclk(), s3c24xx_get_pclk());
- m_cpu->set_unscaled_clock(s3c24xx_get_fclk() * CLOCK_MULTIPLIER);
- }
- break;
- }
-}
-
-/* Interrupt Controller */
-
-void S3C24_CLASS_NAME::s3c24xx_irq_reset()
-{
- s3c24xx_irq_t *irq = &m_irq;
- memset( &irq->regs, 0, sizeof( irq->regs));
- irq->line_irq = irq->line_fiq = CLEAR_LINE;
- irq->regs.intmsk = 0xFFFFFFFF;
- irq->regs.priority = 0x7F;
- #if defined(DEVICE_S3C2410)
- irq->regs.intsubmsk = 0x07FF;
- #elif defined(DEVICE_S3C2440)
- irq->regs.intsubmsk = 0xFFFF;
- #endif
-}
-
-void S3C24_CLASS_NAME::s3c24xx_check_pending_irq()
-{
- UINT32 temp;
- // normal irq
-
- if ((m_irq.regs.intpnd == 0) && (m_irq.regs.intoffset == 0)) // without this "touryuu" crashes
- {
- temp = (m_irq.regs.srcpnd & ~m_irq.regs.intmsk) & ~m_irq.regs.intmod;
- if (temp != 0)
- {
- UINT32 int_type = 0;
- verboselog( machine(), 5, "srcpnd %08X intmsk %08X intmod %08X\n", m_irq.regs.srcpnd, m_irq.regs.intmsk, m_irq.regs.intmod);
- while ((temp & 1) == 0)
- {
- int_type++;
- temp = temp >> 1;
- }
- verboselog( machine(), 5, "intpnd set bit %d\n", int_type);
- m_irq.regs.intpnd |= (1 << int_type);
- m_irq.regs.intoffset = int_type;
- if (m_irq.line_irq != ASSERT_LINE)
- {
- verboselog( machine(), 5, "ARM7_IRQ_LINE -> ASSERT_LINE\n");
- m_cpu->execute().set_input_line(ARM7_IRQ_LINE, ASSERT_LINE);
- m_irq.line_irq = ASSERT_LINE;
- }
- }
- else
- {
- if (m_irq.line_irq != CLEAR_LINE)
- {
- verboselog( machine(), 5, "srcpnd %08X intmsk %08X intmod %08X\n", m_irq.regs.srcpnd, m_irq.regs.intmsk, m_irq.regs.intmod);
- verboselog( machine(), 5, "ARM7_IRQ_LINE -> CLEAR_LINE\n");
- m_cpu->execute().set_input_line(ARM7_IRQ_LINE, CLEAR_LINE);
- m_irq.line_irq = CLEAR_LINE;
- }
- }
- }
-
- // fast irq
- temp = (m_irq.regs.srcpnd & ~m_irq.regs.intmsk) & m_irq.regs.intmod;
- if (temp != 0)
- {
- UINT32 int_type = 0;
- while ((temp & 1) == 0)
- {
- int_type++;
- temp = temp >> 1;
- }
- if (m_irq.line_fiq != ASSERT_LINE)
- {
- verboselog( machine(), 5, "ARM7_FIRQ_LINE -> ASSERT_LINE\n");
- m_cpu->execute().set_input_line(ARM7_FIRQ_LINE, ASSERT_LINE);
- m_irq.line_fiq = ASSERT_LINE;
- }
- }
- else
- {
- if (m_irq.line_fiq != CLEAR_LINE)
- {
- verboselog( machine(), 5, "ARM7_FIRQ_LINE -> CLEAR_LINE\n");
- m_cpu->execute().set_input_line(ARM7_FIRQ_LINE, CLEAR_LINE);
- m_irq.line_fiq = CLEAR_LINE;
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_request_irq(UINT32 int_type)
-{
- verboselog( machine(), 5, "request irq %d\n", int_type);
- m_irq.regs.srcpnd |= (1 << int_type);
- s3c24xx_check_pending_irq();
-}
-
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
-
-void S3C24_CLASS_NAME::s3c24xx_check_pending_subirq()
-{
- UINT32 temp = m_irq.regs.subsrcpnd & ~m_irq.regs.intsubmsk;
- if (temp != 0)
- {
- UINT32 int_type = 0;
- while ((temp & 1) == 0)
- {
- int_type++;
- temp = temp >> 1;
- }
- s3c24xx_request_irq( MAP_SUBINT_TO_INT[int_type]);
- }
-}
-
-ATTR_UNUSED void S3C24_CLASS_NAME::s3c24xx_request_subirq( UINT32 int_type)
-{
- verboselog( machine(), 5, "request subirq %d\n", int_type);
- m_irq.regs.subsrcpnd |= (1 << int_type);
- s3c24xx_check_pending_subirq();
-}
-
-void S3C24_CLASS_NAME::s3c24xx_check_pending_eint()
-{
- UINT32 temp = m_gpio.regs.eintpend & ~m_gpio.regs.eintmask;
- if (temp != 0)
- {
- UINT32 int_type = 0;
- while ((temp & 1) == 0)
- {
- int_type++;
- temp = temp >> 1;
- }
- if (int_type < 8)
- {
- s3c24xx_request_irq(S3C24XX_INT_EINT4_7);
- }
- else
- {
- s3c24xx_request_irq(S3C24XX_INT_EINT8_23);
- }
- }
-}
-
-ATTR_UNUSED void S3C24_CLASS_NAME::s3c24xx_request_eint(UINT32 number)
-{
- verboselog( machine(), 5, "request external interrupt %d\n", number);
- if (number < 4)
- {
- s3c24xx_request_irq( S3C24XX_INT_EINT0 + number);
- }
- else
- {
- m_gpio.regs.eintpend |= (1 << number);
- s3c24xx_check_pending_eint();
- }
-}
-
-#endif
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_irq_r )
-{
- UINT32 data = ((UINT32*)&m_irq.regs)[offset];
- verboselog( machine(), 9, "(IRQ) %08X -> %08X\n", S3C24XX_BASE_INT + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_irq_w )
-{
- UINT32 old_value = ((UINT32*)&m_irq.regs)[offset];
- verboselog( machine(), 9, "(IRQ) %08X <- %08X\n", S3C24XX_BASE_INT + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_irq.regs)[offset]);
- switch (offset)
- {
- case S3C24XX_SRCPND :
- {
- m_irq.regs.srcpnd = (old_value & ~data); // clear only the bit positions of SRCPND corresponding to those set to one in the data
- m_irq.regs.intoffset = 0; // "This bit can be cleared automatically by clearing SRCPND and INTPND."
- s3c24xx_check_pending_irq();
- }
- break;
- case S3C24XX_INTMSK :
- {
- s3c24xx_check_pending_irq();
- }
- break;
- case S3C24XX_INTPND :
- {
- m_irq.regs.intpnd = (old_value & ~data); // clear only the bit positions of INTPND corresponding to those set to one in the data
- m_irq.regs.intoffset = 0; // "This bit can be cleared automatically by clearing SRCPND and INTPND."
- s3c24xx_check_pending_irq();
- }
- break;
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- case S3C24XX_SUBSRCPND :
- {
- m_irq.regs.subsrcpnd = (old_value & ~data); // clear only the bit positions of SRCPND corresponding to those set to one in the data
- s3c24xx_check_pending_subirq();
- }
- break;
- case S3C24XX_INTSUBMSK :
- {
- s3c24xx_check_pending_subirq();
- }
- break;
-#endif
- }
-}
-
-/* PWM Timer */
-
-void S3C24_CLASS_NAME::s3c24xx_pwm_reset()
-{
- s3c24xx_pwm_t *pwm = &m_pwm;
- memset( &pwm->regs, 0, sizeof( pwm->regs));
- for (int i = 0; i < 5; i++)
- {
- pwm->timer[i]->adjust( attotime::never);
- }
-}
-
-UINT16 S3C24_CLASS_NAME::s3c24xx_pwm_calc_observation(int ch)
-{
- double timeleft, x1, x2;
- UINT32 cnto;
- timeleft = m_pwm.timer[ch]->remaining( ).as_double();
-// printf( "timeleft %f freq %d cntb %d cmpb %d\n", timeleft, m_pwm.freq[ch], m_pwm.cnt[ch], m_pwm.cmp[ch]);
- x1 = 1 / ((double)m_pwm.freq[ch] / (m_pwm.cnt[ch]- m_pwm.cmp[ch] + 1));
- x2 = x1 / timeleft;
-// printf( "x1 %f\n", x1);
- cnto = m_pwm.cmp[ch] + ((m_pwm.cnt[ch]- m_pwm.cmp[ch]) / x2);
-// printf( "cnto %d\n", cnto);
- return cnto;
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_pwm_r )
-{
- UINT32 data = ((UINT32*)&m_pwm.regs)[offset];
- switch (offset)
- {
- case S3C24XX_TCNTO0 :
- {
- data = (data & ~0x0000FFFF) | s3c24xx_pwm_calc_observation( 0);
- }
- break;
- case S3C24XX_TCNTO1 :
- {
- data = (data & ~0x0000FFFF) | s3c24xx_pwm_calc_observation( 1);
- }
- break;
- case S3C24XX_TCNTO2 :
- {
- data = (data & ~0x0000FFFF) | s3c24xx_pwm_calc_observation( 2);
- }
- break;
- case S3C24XX_TCNTO3 :
- {
- data = (data & ~0x0000FFFF) | s3c24xx_pwm_calc_observation( 3);
- }
- break;
- case S3C24XX_TCNTO4 :
- {
- data = (data & ~0x0000FFFF) | s3c24xx_pwm_calc_observation( 4);
- }
- break;
- }
- verboselog( machine(), 9, "(PWM) %08X -> %08X\n", S3C24XX_BASE_PWM + (offset << 2), data);
- return data;
-}
-
-void S3C24_CLASS_NAME::s3c24xx_pwm_start(int timer)
-{
- const int mux_table[] = { 2, 4, 8, 16};
- const int prescaler_shift[] = { 0, 0, 8, 8, 8};
- const int mux_shift[] = { 0, 4, 8, 12, 16};
- UINT32 pclk, prescaler, mux, cnt, cmp, auto_reload;
- double freq, hz;
- verboselog( machine(), 1, "PWM %d start\n", timer);
- pclk = s3c24xx_get_pclk();
- prescaler = (m_pwm.regs.tcfg0 >> prescaler_shift[timer]) & 0xFF;
- mux = (m_pwm.regs.tcfg1 >> mux_shift[timer]) & 0x0F;
- if (mux < 4)
- {
- freq = (double)pclk / (prescaler + 1) / mux_table[mux];
- }
- else
- {
- // todo
- freq = (double)pclk / (prescaler + 1) / 1;
- }
- switch (timer)
- {
- case 0 :
- {
- cnt = BITS( m_pwm.regs.tcntb0, 15, 0);
- cmp = BITS( m_pwm.regs.tcmpb0, 15, 0);
- auto_reload = BIT( m_pwm.regs.tcon, 3);
- }
- break;
- case 1 :
- {
- cnt = BITS( m_pwm.regs.tcntb1, 15, 0);
- cmp = BITS( m_pwm.regs.tcmpb1, 15, 0);
- auto_reload = BIT( m_pwm.regs.tcon, 11);
- }
- break;
- case 2 :
- {
- cnt = BITS( m_pwm.regs.tcntb2, 15, 0);
- cmp = BITS( m_pwm.regs.tcmpb2, 15, 0);
- auto_reload = BIT( m_pwm.regs.tcon, 15);
- }
- break;
- case 3 :
- {
- cnt = BITS( m_pwm.regs.tcntb3, 15, 0);
- cmp = BITS( m_pwm.regs.tcmpb3, 15, 0);
- auto_reload = BIT( m_pwm.regs.tcon, 19);
- }
- break;
- case 4 :
- {
- cnt = BITS( m_pwm.regs.tcntb4, 15, 0);
- cmp = 0;
- auto_reload = BIT( m_pwm.regs.tcon, 22);
- }
- break;
- default :
- {
- cnt = cmp = auto_reload = 0;
- }
- break;
- }
-// hz = freq / (cnt - cmp + 1);
- if (cnt < 2)
- {
- hz = freq;
- }
- else
- {
- hz = freq / cnt;
- }
- verboselog( machine(), 5, "PWM %d - pclk=%d prescaler=%d div=%d freq=%f cnt=%d cmp=%d auto_reload=%d hz=%f\n", timer, pclk, prescaler, mux_table[mux], freq, cnt, cmp, auto_reload, hz);
- m_pwm.cnt[timer] = cnt;
- m_pwm.cmp[timer] = cmp;
- m_pwm.freq[timer] = freq;
- if (auto_reload)
- {
- m_pwm.timer[timer]->adjust( attotime::from_hz( hz), timer, attotime::from_hz( hz));
- }
- else
- {
- m_pwm.timer[timer]->adjust( attotime::from_hz( hz), timer);
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_pwm_stop(int timer)
-{
- verboselog( machine(), 1, "PWM %d stop\n", timer);
- m_pwm.timer[timer]->adjust( attotime::never);
-}
-
-void S3C24_CLASS_NAME::s3c24xx_pwm_recalc(int timer)
-{
- const int tcon_shift[] = { 0, 8, 12, 16, 20};
- if (m_pwm.regs.tcon & (1 << tcon_shift[timer]))
- {
- s3c24xx_pwm_start(timer);
- }
- else
- {
- s3c24xx_pwm_stop(timer);
- }
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_pwm_w )
-{
- UINT32 old_value = ((UINT32*)&m_pwm.regs)[offset];
- verboselog( machine(), 9, "(PWM) %08X <- %08X\n", S3C24XX_BASE_PWM + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_pwm.regs)[offset]);
- switch (offset)
- {
- case S3C24XX_TCON :
- {
- if ((data & (1 << 0)) != (old_value & (1 << 0)))
- {
- s3c24xx_pwm_recalc( 0);
- }
- if ((data & (1 << 8)) != (old_value & (1 << 8)))
- {
- s3c24xx_pwm_recalc( 1);
- }
- if ((data & (1 << 12)) != (old_value & (1 << 12)))
- {
- s3c24xx_pwm_recalc(2);
- }
- if ((data & (1 << 16)) != (old_value & (1 << 16)))
- {
- s3c24xx_pwm_recalc(3);
- }
- if ((data & (1 << 20)) != (old_value & (1 << 20)))
- {
- s3c24xx_pwm_recalc(4);
- }
- }
- break;
- }
-}
-
-TIMER_CALLBACK_MEMBER( S3C24_CLASS_NAME::s3c24xx_pwm_timer_exp )
-{
- int ch = param;
- const int ch_int[] = { S3C24XX_INT_TIMER0, S3C24XX_INT_TIMER1, S3C24XX_INT_TIMER2, S3C24XX_INT_TIMER3, S3C24XX_INT_TIMER4 };
- verboselog( machine(), 2, "PWM %d timer callback\n", ch);
- if (BITS( m_pwm.regs.tcfg1, 23, 20) == (ch + 1))
- {
- s3c24xx_dma_request_pwm();
- }
- else
- {
- s3c24xx_request_irq(ch_int[ch]);
- }
-}
-
-/* DMA */
-
-void S3C24_CLASS_NAME::s3c24xx_dma_reset()
-{
- for (int i = 0; i < S3C24XX_DMA_COUNT; i++)
- {
- s3c24xx_dma_t *dma = &m_dma[i];
- memset( &dma->regs, 0, sizeof( dma->regs));
- dma->timer->adjust( attotime::never);
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_dma_reload(int ch)
-{
- s3c24xx_dma_regs_t *regs = &m_dma[ch].regs;
- regs->dstat = S3C24XX_DSTAT_SET_CURR_TC( regs->dstat, S3C24XX_DCON_GET_TC( regs->dcon));
- regs->dcsrc = S3C24XX_DCSRC_SET_CURR_SRC( regs->dcsrc, S3C24XX_DISRC_GET_SADDR( regs->disrc));
- regs->dcdst = S3C24XX_DCDST_SET_CURR_DST( regs->dcdst, S3C24XX_DIDST_GET_DADDR( regs->didst));
-}
-
-void S3C24_CLASS_NAME::s3c24xx_dma_trigger(int ch)
-{
- s3c24xx_dma_regs_t *regs = &m_dma[ch].regs;
- UINT32 curr_tc, curr_src, curr_dst;
- address_space &space = m_cpu->memory().space( AS_PROGRAM);
- int dsz, inc_src, inc_dst, servmode, tsz;
- const UINT32 ch_int[] = { S3C24XX_INT_DMA0, S3C24XX_INT_DMA1, S3C24XX_INT_DMA2, S3C24XX_INT_DMA3};
- verboselog( machine(), 5, "DMA %d trigger\n", ch);
- curr_tc = S3C24XX_DSTAT_GET_CURR_TC( regs->dstat);
- dsz = S3C24XX_DCON_GET_DSZ( regs->dcon);
- curr_src = S3C24XX_DCSRC_GET_CURR_SRC( regs->dcsrc);
- curr_dst = S3C24XX_DCDST_GET_CURR_DST( regs->dcdst);
- servmode = S3C24XX_DCON_GET_SERVMODE( regs->dcon);
- tsz = S3C24XX_DCON_GET_TSZ( regs->dcon);
-#if defined(DEVICE_S3C2400)
- inc_src = BIT( regs->disrc, 29);
- inc_dst = BIT( regs->didst, 29);
-#else
- inc_src = BIT( regs->disrcc, 0);
- inc_dst = BIT( regs->didstc, 0);
-#endif
- verboselog( machine(), 5, "DMA %d - curr_src %08X curr_dst %08X curr_tc %d dsz %d\n", ch, curr_src, curr_dst, curr_tc, dsz);
- while (curr_tc > 0)
- {
- curr_tc--;
- for (int i = 0; i < 1 << (tsz << 1); i++)
- {
- switch (dsz)
- {
- case 0 : space.write_byte( curr_dst, space.read_byte( curr_src)); break;
- case 1 : space.write_word( curr_dst, space.read_word( curr_src)); break;
- case 2 : space.write_dword( curr_dst, space.read_dword( curr_src)); break;
- }
- if (inc_src == 0) curr_src += (1 << dsz);
- if (inc_dst == 0) curr_dst += (1 << dsz);
- }
- if (servmode == 0) break;
- }
- regs->dcsrc = S3C24XX_DCSRC_SET_CURR_SRC( regs->dcsrc, curr_src);
- regs->dcdst = S3C24XX_DCDST_SET_CURR_DST( regs->dcdst, curr_dst);
- regs->dstat = S3C24XX_DSTAT_SET_CURR_TC( regs->dstat, curr_tc);
- if (curr_tc == 0)
- {
- if (S3C24XX_DCON_GET_RELOAD( regs->dcon) == 0)
- {
- s3c24xx_dma_reload(ch);
- }
- else
- {
- regs->dmasktrig &= ~(1 << 1); // clear on/off
- }
- if (S3C24XX_DCON_GET_INT( regs->dcon) != 0)
- {
- s3c24xx_request_irq(ch_int[ch]);
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_dma_request_iis()
-{
- s3c24xx_dma_regs_t *regs = &m_dma[2].regs;
- verboselog( machine(), 5, "s3c24xx_dma_request_iis\n");
- if ((S3C24XX_DMASKTRIG_GET_ON_OFF( regs->dmasktrig) != 0) && (S3C24XX_DCON_GET_SWHWSEL( regs->dcon) != 0) && (S3C24XX_DCON_GET_HWSRCSEL( regs->dcon) == 0))
- {
- s3c24xx_dma_trigger(2);
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_dma_request_pwm()
-{
- verboselog( machine(), 5, "s3c24xx_dma_request_pwm\n");
- for (int i = 0; i < 4; i++)
- {
- if (i != 1)
- {
- s3c24xx_dma_regs_t *regs = &m_dma[i].regs;
- if ((S3C24XX_DMASKTRIG_GET_ON_OFF( regs->dmasktrig) != 0) && (S3C24XX_DCON_GET_SWHWSEL( regs->dcon) != 0) && (S3C24XX_DCON_GET_HWSRCSEL( regs->dcon) == 3))
- {
- s3c24xx_dma_trigger(i);
- }
- }
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_dma_start(int ch)
-{
- UINT32 addr_src, addr_dst, tc;
- s3c24xx_dma_regs_t *regs = &m_dma[ch].regs;
- UINT32 dsz, tsz, reload;
- int inc_src, inc_dst, _int, servmode, swhwsel, hwsrcsel;
- verboselog( machine(), 1, "DMA %d start\n", ch);
- addr_src = S3C24XX_DISRC_GET_SADDR( regs->disrc);
- addr_dst = S3C24XX_DIDST_GET_DADDR( regs->didst);
- tc = S3C24XX_DCON_GET_TC( regs->dcon);
- _int = S3C24XX_DCON_GET_INT( regs->dcon);
- servmode = S3C24XX_DCON_GET_SERVMODE( regs->dcon);
- hwsrcsel = S3C24XX_DCON_GET_HWSRCSEL( regs->dcon);
- swhwsel = S3C24XX_DCON_GET_SWHWSEL( regs->dcon);
- reload = S3C24XX_DCON_GET_RELOAD( regs->dcon);
- dsz = S3C24XX_DCON_GET_DSZ( regs->dcon);
- tsz = S3C24XX_DCON_GET_TSZ( regs->dcon);
-#if defined(DEVICE_S3C2400)
- inc_src = BIT( regs->disrc, 29);
- inc_dst = BIT( regs->didst, 29);
-#else
- inc_src = BIT( regs->disrcc, 0);
- inc_dst = BIT( regs->didstc, 0);
-#endif
- verboselog( machine(), 5, "DMA %d - addr_src %08X inc_src %d addr_dst %08X inc_dst %d int %d tsz %d servmode %d hwsrcsel %d swhwsel %d reload %d dsz %d tc %d\n", ch, addr_src, inc_src, addr_dst, inc_dst, _int, tsz, servmode, hwsrcsel, swhwsel, reload, dsz, tc);
- verboselog( machine(), 5, "DMA %d - copy %08X bytes from %08X (%s) to %08X (%s)\n", ch, (tc << dsz) << (tsz << 1), addr_src, inc_src ? "fix" : "inc", addr_dst, inc_dst ? "fix" : "inc");
- s3c24xx_dma_reload(ch);
- if (swhwsel == 0)
- {
- s3c24xx_dma_trigger(ch);
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_dma_stop(int ch)
-{
- verboselog( machine(), 1, "DMA %d stop\n", ch);
-}
-
-void S3C24_CLASS_NAME::s3c24xx_dma_recalc(int ch)
-{
- if ((m_dma[ch].regs.dmasktrig & (1 << 1)) != 0)
- {
- s3c24xx_dma_start(ch);
- }
- else
- {
- s3c24xx_dma_stop(ch);
- }
-}
-
-UINT32 S3C24_CLASS_NAME::s3c24xx_dma_r(UINT32 ch, UINT32 offset)
-{
- return ((UINT32*)&m_dma[ch].regs)[offset];
-}
-
-void S3C24_CLASS_NAME::s3c24xx_dma_w(UINT32 ch, UINT32 offset, UINT32 data, UINT32 mem_mask)
-{
- UINT32 old_value = ((UINT32*)&m_dma[ch].regs)[offset];
- COMBINE_DATA(&((UINT32*)&m_dma[ch].regs)[offset]);
- switch (offset)
- {
- case S3C24XX_DCON :
- {
- #if 0 // is this code necessary ???
- if ((data & (1 << 22)) != 0) // reload
- {
- s3c24xx_dma_regs_t *regs = &m_dma[ch].regs;
- regs->dmasktrig &= ~(1 << 1); // clear on/off
- }
- #endif
- }
- break;
- case S3C24XX_DMASKTRIG :
- {
- if ((old_value & (1 << 1)) != (data & (1 << 1)))
- {
- s3c24xx_dma_recalc(ch);
- }
- }
- break;
- }
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_dma_0_r )
-{
- UINT32 data = s3c24xx_dma_r( 0, offset);
- verboselog( machine(), 9, "(DMA 0) %08X -> %08X\n", S3C24XX_BASE_DMA_0 + (offset << 2), data);
- return data;
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_dma_1_r )
-{
- UINT32 data = s3c24xx_dma_r( 1, offset);
- verboselog( machine(), 9, "(DMA 1) %08X -> %08X\n", S3C24XX_BASE_DMA_1 + (offset << 2), data);
- return data;
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_dma_2_r )
-{
- UINT32 data = s3c24xx_dma_r( 2, offset);
- verboselog( machine(), 9, "(DMA 2) %08X -> %08X\n", S3C24XX_BASE_DMA_2 + (offset << 2), data);
- return data;
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_dma_3_r )
-{
- UINT32 data = s3c24xx_dma_r( 3, offset);
- verboselog( machine(), 9, "(DMA 3) %08X -> %08X\n", S3C24XX_BASE_DMA_3 + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_dma_0_w )
-{
- verboselog( machine(), 9, "(DMA 0) %08X <- %08X\n", S3C24XX_BASE_DMA_0 + (offset << 2), data);
- s3c24xx_dma_w( 0, offset, data, mem_mask);
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_dma_1_w )
-{
- verboselog( machine(), 9, "(DMA 1) %08X <- %08X\n", S3C24XX_BASE_DMA_1 + (offset << 2), data);
- s3c24xx_dma_w( 1, offset, data, mem_mask);
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_dma_2_w )
-{
- verboselog( machine(), 9, "(DMA 2) %08X <- %08X\n", S3C24XX_BASE_DMA_2 + (offset << 2), data);
- s3c24xx_dma_w( 2, offset, data, mem_mask);
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_dma_3_w )
-{
- verboselog( machine(), 9, "(DMA 3) %08X <- %08X\n", S3C24XX_BASE_DMA_3 + (offset << 2), data);
- s3c24xx_dma_w( 3, offset, data, mem_mask);
-}
-
-TIMER_CALLBACK_MEMBER( S3C24_CLASS_NAME::s3c24xx_dma_timer_exp )
-{
- int ch = param;
- verboselog( machine(), 2, "DMA %d timer callback\n", ch);
-}
-
-/* I/O Port */
-
-void S3C24_CLASS_NAME::s3c24xx_gpio_reset()
-{
- s3c24xx_gpio_t *gpio = &m_gpio;
- memset( &gpio->regs, 0, sizeof( gpio->regs));
- #if defined(DEVICE_S3C2400)
- gpio->regs.gpacon = 0x0003FFFF;
- gpio->regs.gpbcon = 0xAAAAAAAA;
- gpio->regs.gpdup = 0x0620;
- gpio->regs.gpeup = 0x0003;
- #elif defined(DEVICE_S3C2410)
- gpio->regs.gpacon = 0x007FFFFF;
- gpio->regs.gpgup = 0xF800;
- gpio->regs.misccr = 0x00010330;
- gpio->regs.eintmask = 0x00FFFFF0;
- gpio->regs.gstatus1 = 0x32410002;
- #elif defined(DEVICE_S3C2440)
- gpio->regs.gpacon = 0x00FFFFFF;
- gpio->regs.gpgup = 0xFC00;
- gpio->regs.misccr = 0x00010020;
- gpio->regs.eintmask = 0x000FFFFF;
- gpio->regs.gstatus1 = 0x32440001;
- #endif
- gpio->regs.gpdup = 0xF000;
- #if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- gpio->regs.gstatus2 = 1 << 0; // Boot is caused by power on reset
- #endif
-}
-
-UINT32 S3C24_CLASS_NAME::iface_gpio_port_r(int port, UINT32 mask)
-{
- if (!m_port_r_cb.isnull())
- {
- // TO CHECK : masking is not done in any of handlers
- // devcb do it automatically so guess is masks are not proper right now
- // without masking works fine
- return (m_port_r_cb)( port ); //, mask);
- }
- else
- {
- return 0;
- }
-}
-
-void S3C24_CLASS_NAME::iface_gpio_port_w(int port, UINT32 mask, UINT32 data)
-{
- if (!m_port_w_cb.isnull())
- {
- (m_port_w_cb)( port, data, mask );
- }
-}
-
-UINT16 S3C24_CLASS_NAME::s3c24xx_gpio_get_mask( UINT32 con, int val)
-{
- UINT16 mask = 0;
- for (int i = 0; i < 16; i++)
- {
- if (((con >> (i << 1)) & 3) == val)
- {
- mask = mask | (1 << i);
- }
- }
- return mask;
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_gpio_r )
-{
- s3c24xx_gpio_t *gpio = &m_gpio;
- UINT32 data = ((UINT32*)&m_gpio.regs)[offset];
- switch (offset)
- {
- case S3C24XX_GPADAT :
- {
- data = iface_gpio_port_r( S3C24XX_GPIO_PORT_A, 0) & S3C24XX_GPADAT_MASK;
- }
- break;
- case S3C24XX_GPBDAT :
- {
- data = iface_gpio_port_r( S3C24XX_GPIO_PORT_B, s3c24xx_gpio_get_mask( gpio->regs.gpbcon, 0) & S3C24XX_GPBDAT_MASK) & S3C24XX_GPBDAT_MASK;
- }
- break;
- case S3C24XX_GPCDAT :
- {
- data = iface_gpio_port_r( S3C24XX_GPIO_PORT_C, s3c24xx_gpio_get_mask( gpio->regs.gpccon, 0) & S3C24XX_GPCDAT_MASK) & S3C24XX_GPCDAT_MASK;
- }
- break;
- case S3C24XX_GPDDAT :
- {
- data = iface_gpio_port_r( S3C24XX_GPIO_PORT_D, s3c24xx_gpio_get_mask( gpio->regs.gpdcon, 0) & S3C24XX_GPDDAT_MASK) & S3C24XX_GPDDAT_MASK;
- }
- break;
- case S3C24XX_GPEDAT :
- {
- data = iface_gpio_port_r( S3C24XX_GPIO_PORT_E, s3c24xx_gpio_get_mask( gpio->regs.gpecon, 0) & S3C24XX_GPEDAT_MASK) & S3C24XX_GPEDAT_MASK;
- }
- break;
- case S3C24XX_GPFDAT :
- {
- data = iface_gpio_port_r( S3C24XX_GPIO_PORT_F, s3c24xx_gpio_get_mask( gpio->regs.gpfcon, 0) & S3C24XX_GPFDAT_MASK) & S3C24XX_GPFDAT_MASK;
- }
- break;
- case S3C24XX_GPGDAT :
- {
- data = iface_gpio_port_r( S3C24XX_GPIO_PORT_G, s3c24xx_gpio_get_mask( gpio->regs.gpgcon, 0) & S3C24XX_GPGDAT_MASK) & S3C24XX_GPGDAT_MASK;
- }
- break;
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- case S3C24XX_GPHDAT :
- {
- data = iface_gpio_port_r( S3C24XX_GPIO_PORT_H, s3c24xx_gpio_get_mask( gpio->regs.gphcon, 0) & S3C24XX_GPHDAT_MASK) & S3C24XX_GPHDAT_MASK;
- }
- break;
-#endif
-#if defined(DEVICE_S3C2440)
- case S3C24XX_GPJDAT :
- {
- data = iface_gpio_port_r( S3C24XX_GPIO_PORT_J, s3c24xx_gpio_get_mask( gpio->regs.gpjcon, 0) & S3C24XX_GPJDAT_MASK) & S3C24XX_GPJDAT_MASK;
- }
- break;
-#endif
- }
- verboselog( machine(), 9, "(GPIO) %08X -> %08X\n", S3C24XX_BASE_GPIO + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_gpio_w )
-{
- s3c24xx_gpio_t *gpio = &m_gpio;
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- UINT32 old_value = ((UINT32*)&m_gpio.regs)[offset];
-#endif
- verboselog( machine(), 9, "(GPIO) %08X <- %08X\n", S3C24XX_BASE_GPIO + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_gpio.regs)[offset]);
- switch (offset)
- {
- case S3C24XX_GPADAT :
- {
- iface_gpio_port_w( S3C24XX_GPIO_PORT_A, gpio->regs.gpacon ^ 0xFFFFFFFF, data & S3C24XX_GPADAT_MASK);
- }
- break;
- case S3C24XX_GPBDAT :
- {
- iface_gpio_port_w( S3C24XX_GPIO_PORT_B, s3c24xx_gpio_get_mask( gpio->regs.gpbcon, 1) & S3C24XX_GPBDAT_MASK, data & S3C24XX_GPBDAT_MASK);
- }
- break;
- case S3C24XX_GPCDAT :
- {
- iface_gpio_port_w( S3C24XX_GPIO_PORT_C, s3c24xx_gpio_get_mask( gpio->regs.gpccon, 1) & S3C24XX_GPCDAT_MASK, data & S3C24XX_GPCDAT_MASK);
- }
- break;
- case S3C24XX_GPDDAT :
- {
- iface_gpio_port_w( S3C24XX_GPIO_PORT_D, s3c24xx_gpio_get_mask( gpio->regs.gpdcon, 1) & S3C24XX_GPDDAT_MASK, data & S3C24XX_GPDDAT_MASK);
- }
- break;
- case S3C24XX_GPEDAT :
- {
- iface_gpio_port_w( S3C24XX_GPIO_PORT_E, s3c24xx_gpio_get_mask( gpio->regs.gpecon, 1) & S3C24XX_GPEDAT_MASK, data & S3C24XX_GPEDAT_MASK);
- }
- break;
- case S3C24XX_GPFDAT :
- {
- iface_gpio_port_w( S3C24XX_GPIO_PORT_F, s3c24xx_gpio_get_mask( gpio->regs.gpfcon, 1) & S3C24XX_GPFDAT_MASK, data & S3C24XX_GPFDAT_MASK);
- }
- break;
- case S3C24XX_GPGDAT :
- {
- iface_gpio_port_w( S3C24XX_GPIO_PORT_G, s3c24xx_gpio_get_mask( gpio->regs.gpgcon, 1) & S3C24XX_GPGDAT_MASK, data & S3C24XX_GPGDAT_MASK);
- }
- break;
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- case S3C24XX_GPHDAT :
- {
- iface_gpio_port_w( S3C24XX_GPIO_PORT_H, s3c24xx_gpio_get_mask( gpio->regs.gphcon, 1) & S3C24XX_GPHDAT_MASK, data & S3C24XX_GPHDAT_MASK);
- }
- break;
- case S3C24XX_EINTPEND :
- {
- m_gpio.regs.eintpend = (old_value & ~data);
- s3c24xx_check_pending_eint();
- }
- break;
- case S3C24XX_EINTMASK :
- {
- s3c24xx_check_pending_eint();
- }
- break;
- case S3C24XX_GSTATUS2 :
- {
- m_gpio.regs.gstatus2 = (old_value & ~data) & 7; // "The setting is cleared by writing '1' to this bit"
- }
- break;
-#endif
-#if defined(DEVICE_S3C2440)
- case S3C24XX_GPJDAT :
- {
- iface_gpio_port_w( S3C24XX_GPIO_PORT_J, s3c24xx_gpio_get_mask( gpio->regs.gpjcon, 1) & S3C24XX_GPJDAT_MASK, data & S3C24XX_GPJDAT_MASK);
- }
- break;
-#endif
- }
-}
-
-/* Memory Controller */
-
-void S3C24_CLASS_NAME::s3c24xx_memcon_reset()
-{
- s3c24xx_memcon_t *memcon = &m_memcon;
- memset( &memcon->regs, 0, sizeof( memcon->regs));
- memcon->regs.data[0x04/4] = 0x00000700;
- memcon->regs.data[0x08/4] = 0x00000700;
- memcon->regs.data[0x0C/4] = 0x00000700;
- memcon->regs.data[0x10/4] = 0x00000700;
- memcon->regs.data[0x14/4] = 0x00000700;
- memcon->regs.data[0x18/4] = 0x00000700;
- memcon->regs.data[0x1C/4] = 0x00018008;
- memcon->regs.data[0x20/4] = 0x00018008;
- memcon->regs.data[0x24/4] = 0x00AC0000;
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_memcon_r )
-{
- assert(offset < ARRAY_LENGTH(m_memcon.regs.data));
- UINT32 data = m_memcon.regs.data[offset];
- verboselog( machine(), 9, "(MEMCON) %08X -> %08X\n", S3C24XX_BASE_MEMCON + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_memcon_w )
-{
- verboselog( machine(), 9, "(MEMCON) %08X <- %08X\n", S3C24XX_BASE_MEMCON + (offset << 2), data);
- COMBINE_DATA(&m_memcon.regs.data[offset]);
-}
-
-/* USB Host Controller */
-
-void S3C24_CLASS_NAME::s3c24xx_usb_host_reset()
-{
- s3c24xx_usbhost_t *usbhost = &m_usbhost;
- memset( &usbhost->regs, 0, sizeof( usbhost->regs));
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_usb_host_r )
-{
- UINT32 data = m_usbhost.regs.data[offset];
- switch (offset)
- {
- // HcCommandStatus
- case 0x08 / 4 :
- {
- data = data & ~(1 << 0); // [bit 0] HostControllerReset
- }
- break;
- // HcPeriodStart
- case 0x40 / 4:
- {
- // "After a hardware reset, this field is cleared. This is then set by"
- // "HCD during the HC initialization. The value is calculated"
- // "roughly as 10% off from HcFmInterval.. A typical value will be 3E67h."
- data = (data & ~0x00003FFF) | 0x3E67;
- }
- break;
- // HcRhDescriptorA
- case 0x48 / 4:
- {
- data = (data & ~0xFF) | 2; // number of ports
- }
- break;
- // HcRhStatus
- case 0x50 / 4:
- {
- data = data & ~(1 << 16); // "The Root Hub does not support the local power status feature; thus, this bit is always read as ?0?."
- }
- break;
- }
- verboselog( machine(), 9, "(USB H) %08X -> %08X\n", S3C24XX_BASE_USBHOST + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_usb_host_w )
-{
- verboselog( machine(), 9, "(USB H) %08X <- %08X\n", S3C24XX_BASE_USBHOST + (offset << 2), data);
- COMBINE_DATA(&m_usbhost.regs.data[offset]);
-}
-
-/* UART */
-
-void S3C24_CLASS_NAME::s3c24xx_uart_reset()
-{
- for (int i = 0; i < S3C24XX_UART_COUNT; i++)
- {
- s3c24xx_uart_t *uart = &m_uart[i];
- memset( &uart->regs, 0, sizeof( uart->regs));
- uart->regs.utrstat = 6;
- }
-}
-
-UINT32 S3C24_CLASS_NAME::s3c24xx_uart_r(UINT32 ch, UINT32 offset)
-{
- UINT32 data = ((UINT32*)&m_uart[ch].regs)[offset];
- switch (offset)
- {
- case S3C24XX_UTRSTAT :
- {
- data = (data & ~0x00000006) | 0x00000004 | 0x00000002; // [bit 2] Transmitter empty / [bit 1] Transmit buffer empty
- }
- break;
- case S3C24XX_URXH :
- {
- UINT8 rxdata = data & 0xFF;
- verboselog( machine(), 5, "UART %d read %02X (%c)\n", ch, rxdata, ((rxdata >= 32) && (rxdata < 128)) ? (char)rxdata : '?');
- m_uart[ch].regs.utrstat &= ~1; // [bit 0] Receive buffer data ready
- }
- break;
- }
- return data;
-}
-
-void S3C24_CLASS_NAME::s3c24xx_uart_w(UINT32 ch, UINT32 offset, UINT32 data, UINT32 mem_mask)
-{
- COMBINE_DATA(&((UINT32*)&m_uart[ch].regs)[offset]);
- switch (offset)
- {
- case S3C24XX_UFCON :
- {
- m_uart[ch].regs.ufcon &= ~((1 << 2) | (1 << 1)); // bits 1 and 2 are auto-cleared after resetting FIFO
- }
- break;
- case S3C24XX_UTXH :
- {
- UINT8 txdata = data & 0xFF;
- verboselog( machine(), 5, "UART %d write %02X (%c)\n", ch, txdata, ((txdata >= 32) && (txdata < 128)) ? (char)txdata : '?');
-#ifdef UART_PRINTF
- printf( "%c", ((txdata >= 32) && (txdata < 128)) ? (char)txdata : '?');
-#endif
- }
- break;
- }
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_uart_0_r )
-{
- UINT32 data = s3c24xx_uart_r( 0, offset);
-// verboselog( machine(), 9, "(UART 0) %08X -> %08X\n", S3C24XX_BASE_UART_0 + (offset << 2), data);
- return data;
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_uart_1_r )
-{
- UINT32 data = s3c24xx_uart_r( 1, offset);
-// verboselog( machine(), 9, "(UART 1) %08X -> %08X\n", S3C24XX_BASE_UART_1 + (offset << 2), data);
- return data;
-}
-
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_uart_2_r )
-{
- UINT32 data = s3c24xx_uart_r( 2, offset);
-// verboselog( machine(), 9, "(UART 2) %08X -> %08X\n", S3C24XX_BASE_UART_2 + (offset << 2), data);
- return data;
-}
-
-#endif
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_uart_0_w )
-{
-// verboselog( machine(), 9, "(UART 0) %08X <- %08X\n", S3C24XX_BASE_UART_0 + (offset << 2), data);
- s3c24xx_uart_w( 0, offset, data, mem_mask);
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_uart_1_w )
-{
-// verboselog( machine(), 9, "(UART 1) %08X <- %08X\n", S3C24XX_BASE_UART_1 + (offset << 2), data);
- s3c24xx_uart_w( 1, offset, data, mem_mask);
-}
-
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_uart_2_w )
-{
-// verboselog( machine(), 9, "(UART 2) %08X <- %08X\n", S3C24XX_BASE_UART_2 + (offset << 2), data);
- s3c24xx_uart_w( 2, offset, data, mem_mask);
-}
-
-#endif
-
-void S3C24_CLASS_NAME::s3c24xx_uart_fifo_w(int uart, UINT8 data)
-{
-// printf( "s3c24xx_uart_fifo_w (%c)\n", data);
- m_uart[uart].regs.urxh = data;
- m_uart[uart].regs.utrstat |= 1; // [bit 0] Receive buffer data ready
-}
-
-/* USB Device */
-
-void S3C24_CLASS_NAME::s3c24xx_usb_device_reset()
-{
- s3c24xx_usbdev_t *usbdev = &m_usbdev;
- memset( &usbdev->regs, 0, sizeof( usbdev->regs));
- #if defined(DEVICE_S3C2400)
- usbdev->regs.data[0x0C/4] = 0x033F;
- usbdev->regs.data[0x14/4] = 0x000A;
- usbdev->regs.data[0x24/4] = 0x0001;
- usbdev->regs.data[0x44/4] = 0x0001;
- usbdev->regs.data[0x54/4] = 0x0001;
- usbdev->regs.data[0x64/4] = 0x0001;
- usbdev->regs.data[0x74/4] = 0x0001;
- usbdev->regs.data[0xB8/4] = 0x00FF;
- #elif defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- usbdev->regs.data[0x1C/4] = 0xFF;
- usbdev->regs.data[0x2C/4] = 0x04;
- usbdev->regs.data[0x40/4] = 0x01;
- usbdev->regs.data[0x48/4] = 0x20;
- #endif
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_usb_device_r )
-{
- UINT32 data = m_usbdev.regs.data[offset];
- verboselog( machine(), 9, "(USB D) %08X -> %08X\n", S3C24XX_BASE_USBDEV + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_usb_device_w )
-{
- verboselog( machine(), 9, "(USB D) %08X <- %08X\n", S3C24XX_BASE_USBDEV + (offset << 2), data);
- COMBINE_DATA(&m_usbdev.regs.data[offset]);
-}
-
-/* Watchdog Timer */
-
-void S3C24_CLASS_NAME::s3c24xx_wdt_reset()
-{
- s3c24xx_wdt_t *wdt = &m_wdt;
- memset( &wdt->regs, 0, sizeof( wdt->regs));
- wdt->regs.wtcon = 0x8021;
- wdt->regs.wtdat = 0x8000;
- wdt->regs.wtcnt = 0x8000;
- wdt->timer->adjust( attotime::never);
-}
-
-#if defined(DEVICE_S3C2410)
-
-UINT16 S3C24_CLASS_NAME::s3c24xx_wdt_calc_current_count()
-{
- double timeleft, x1, x2;
- UINT32 cnt;
- timeleft = m_wdt.timer->remaining( ).as_double();
-// printf( "timeleft %f freq %d cnt %d\n", timeleft, m_wdt.freq, m_wdt.cnt);
- x1 = 1 / ((double)m_wdt.freq / m_wdt.cnt);
- x2 = x1 / timeleft;
-// printf( "x1 %f\n", x1);
- cnt = m_wdt.cnt / x2;
-// printf( "cnt %d\n", cnt);
- return cnt;
-}
-
-#else
-
-UINT16 S3C24_CLASS_NAME::s3c24xx_wdt_calc_current_count()
-{
- return 0;
-}
-
-#endif
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_wdt_r )
-{
- UINT32 data = ((UINT32*)&m_wdt.regs)[offset];
- switch (offset)
- {
- case S3C24XX_WTCNT :
- {
- // is wdt active?
- if ((m_wdt.regs.wtcon & (1 << 5)) != 0)
- {
- data = s3c24xx_wdt_calc_current_count();
- }
- }
- break;
- }
- verboselog( machine(), 9, "(WDT) %08X -> %08X\n", S3C24XX_BASE_WDT + (offset << 2), data);
- return data;
-}
-
-void S3C24_CLASS_NAME::s3c24xx_wdt_start()
-{
- UINT32 pclk, prescaler, clock;
- double freq, hz;
- verboselog( machine(), 1, "WDT start\n");
- pclk = s3c24xx_get_pclk();
- prescaler = BITS( m_wdt.regs.wtcon, 15, 8);
- clock = 16 << BITS( m_wdt.regs.wtcon, 4, 3);
- freq = (double)pclk / (prescaler + 1) / clock;
- hz = freq / m_wdt.regs.wtcnt;
- verboselog( machine(), 5, "WDT pclk %d prescaler %d clock %d freq %f hz %f\n", pclk, prescaler, clock, freq, hz);
- m_wdt.timer->adjust( attotime::from_hz( hz), 0, attotime::from_hz( hz));
-#if defined(DEVICE_S3C2410)
- m_wdt.freq = freq;
- m_wdt.cnt = m_wdt.regs.wtcnt;
-#endif
-}
-
-void S3C24_CLASS_NAME::s3c24xx_wdt_stop()
-{
- verboselog( machine(), 1, "WDT stop\n");
- m_wdt.regs.wtcnt = s3c24xx_wdt_calc_current_count();
- m_wdt.timer->adjust( attotime::never);
-}
-
-void S3C24_CLASS_NAME::s3c24xx_wdt_recalc()
-{
- if ((m_wdt.regs.wtcon & (1 << 5)) != 0)
- {
- s3c24xx_wdt_start();
- }
- else
- {
- s3c24xx_wdt_stop();
- }
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_wdt_w )
-{
- UINT32 old_value = ((UINT32*)&m_wdt.regs)[offset];
- verboselog( machine(), 9, "(WDT) %08X <- %08X\n", S3C24XX_BASE_WDT + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_wdt.regs)[offset]);
- switch (offset)
- {
- case S3C24XX_WTCON :
- {
- if ((data & (1 << 5)) != (old_value & (1 << 5)))
- {
- s3c24xx_wdt_recalc();
- }
- }
- break;
- }
-}
-
-TIMER_CALLBACK_MEMBER( S3C24_CLASS_NAME::s3c24xx_wdt_timer_exp )
-{
- verboselog( machine(), 2, "WDT timer callback\n");
- if ((m_wdt.regs.wtcon & (1 << 2)) != 0)
- {
-#if defined(DEVICE_S3C2400) || defined(DEVICE_S3C2410)
- s3c24xx_request_irq( S3C24XX_INT_WDT);
-#else
- s3c24xx_request_subirq( S3C24XX_SUBINT_WDT);
-#endif
- }
- if ((m_wdt.regs.wtcon & (1 << 0)) != 0)
- {
- s3c24xx_reset();
- #if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- m_gpio.regs.gstatus2 = 1 << 2; // Watchdog reset
- #endif
- }
-}
-
-/* IIC */
-
-void S3C24_CLASS_NAME::s3c24xx_iic_reset()
-{
- s3c24xx_iic_t *iic = &m_iic;
- memset( &iic->regs, 0, sizeof( iic->regs));
- iic->count = 0;
- iic->timer->adjust( attotime::never);
-}
-
-void S3C24_CLASS_NAME::iface_i2c_scl_w( int state)
-{
- if (!m_scl_w_cb.isnull())
- {
- (m_scl_w_cb)( state);
- }
-}
-
-void S3C24_CLASS_NAME::iface_i2c_sda_w(int state)
-{
- if (!m_sda_w_cb.isnull())
- {
- (m_sda_w_cb)(state);
- }
-}
-
-int S3C24_CLASS_NAME::iface_i2c_sda_r()
-{
- if (!m_sda_r_cb.isnull())
- {
- return (m_sda_r_cb)();
- }
- else
- {
- return 0;
- }
-}
-
-void S3C24_CLASS_NAME::i2c_send_start()
-{
- verboselog( machine(), 5, "i2c_send_start\n");
- iface_i2c_sda_w( 1);
- iface_i2c_scl_w( 1);
- iface_i2c_sda_w( 0);
- iface_i2c_scl_w( 0);
-}
-
-void S3C24_CLASS_NAME::i2c_send_stop()
-{
- verboselog( machine(), 5, "i2c_send_stop\n");
- iface_i2c_sda_w( 0);
- iface_i2c_scl_w( 1);
- iface_i2c_sda_w( 1);
- iface_i2c_scl_w( 0);
-}
-
-UINT8 S3C24_CLASS_NAME::i2c_receive_byte(int ack)
-{
- UINT8 data = 0;
- verboselog( machine(), 5, "i2c_receive_byte ...\n");
- iface_i2c_sda_w( 1);
- for (int i = 0; i < 8; i++)
- {
- iface_i2c_scl_w( 1);
- data = (data << 1) + (iface_i2c_sda_r() ? 1 : 0);
- iface_i2c_scl_w( 0);
- }
- verboselog( machine(), 5, "recv data %02X\n", data);
- verboselog( machine(), 5, "send ack %d\n", ack);
- iface_i2c_sda_w( ack ? 0 : 1);
- iface_i2c_scl_w( 1);
- iface_i2c_scl_w( 0);
- return data;
-}
-
-int S3C24_CLASS_NAME::i2c_send_byte(UINT8 data)
-{
- int ack;
- verboselog( machine(), 5, "i2c_send_byte ...\n");
- verboselog( machine(), 5, "send data %02X\n", data);
- for (int i = 0; i < 8; i++)
- {
- iface_i2c_sda_w( (data & 0x80) ? 1 : 0);
- data = data << 1;
- iface_i2c_scl_w( 1);
- iface_i2c_scl_w( 0);
- }
- iface_i2c_sda_w( 1); // ack bit
- iface_i2c_scl_w( 1);
- ack = iface_i2c_sda_r();
- verboselog( machine(), 5, "recv ack %d\n", ack);
- iface_i2c_scl_w( 0);
- return ack;
-}
-
-void S3C24_CLASS_NAME::iic_start()
-{
- int mode_selection;
- verboselog( machine(), 1, "IIC start\n");
- i2c_send_start();
- mode_selection = BITS( m_iic.regs.iicstat, 7, 6);
- switch (mode_selection)
- {
- case 2 : i2c_send_byte( m_iic.regs.iicds | 0x01); break;
- case 3 : i2c_send_byte( m_iic.regs.iicds & 0xFE); break;
- }
- m_iic.timer->adjust( attotime::from_usec( 1));
-}
-
-void S3C24_CLASS_NAME::iic_stop()
-{
- verboselog( machine(), 1, "IIC stop\n");
- i2c_send_stop();
- m_iic.timer->adjust( attotime::never);
-}
-
-void S3C24_CLASS_NAME::iic_resume()
-{
- int mode_selection;
- verboselog(machine(), 1, "IIC resume\n");
- mode_selection = BITS( m_iic.regs.iicstat, 7, 6);
- switch (mode_selection)
- {
- case 2 : m_iic.regs.iicds = i2c_receive_byte( BIT( m_iic.regs.iiccon, 7)); break;
- case 3 : i2c_send_byte( m_iic.regs.iicds & 0xFF); break;
- }
- m_iic.timer->adjust( attotime::from_usec( 1));
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_iic_r )
-{
- UINT32 data = ((UINT32*)&m_iic.regs)[offset];
- switch (offset)
- {
- case S3C24XX_IICSTAT :
- {
- data = data & ~0x0000000F;
- }
- break;
- }
- verboselog( machine(), 9, "(IIC) %08X -> %08X\n", S3C24XX_BASE_IIC + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_iic_w )
-{
- UINT32 old_value = ((UINT32*)&m_iic.regs)[offset];
- verboselog( machine(), 9, "(IIC) %08X <- %08X\n", S3C24XX_BASE_IIC + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_iic.regs)[offset]);
- switch (offset)
- {
- case S3C24XX_IICCON :
- {
- int interrupt_pending_flag;
-#if 0
- const int div_table[] = { 16, 512};
- int enable_interrupt, transmit_clock_value, tx_clock_source_selection
- double clock;
- transmit_clock_value = (data >> 0) & 0xF;
- tx_clock_source_selection = (data >> 6) & 1;
- enable_interrupt = (data >> 5) & 1;
- clock = (double)s3c24xx_get_pclk() / div_table[tx_clock_source_selection] / (transmit_clock_value + 1);
-#endif
- interrupt_pending_flag = BIT( old_value, 4);
- if (interrupt_pending_flag != 0)
- {
- interrupt_pending_flag = BIT( data, 4);
- if (interrupt_pending_flag == 0)
- {
- int start_stop_condition;
- start_stop_condition = BIT( m_iic.regs.iicstat, 5);
- if (start_stop_condition != 0)
- {
- if (m_iic.count == 0)
- {
- iic_start();
-
- }
- else
- {
- iic_resume();
- }
- }
- else
- {
- iic_stop();
- }
- }
- }
- }
- break;
- case S3C24XX_IICSTAT :
- {
- int interrupt_pending_flag;
- m_iic.count = 0;
- interrupt_pending_flag = BIT( m_iic.regs.iiccon, 4);
- if (interrupt_pending_flag == 0)
- {
- int start_stop_condition;
- start_stop_condition = BIT( data, 5);
- if (start_stop_condition != 0)
- {
- if (m_iic.count == 0)
- {
- iic_start();
-
- }
- else
- {
- iic_resume();
- }
- }
- else
- {
- iic_stop();
- }
- }
- }
- break;
- }
-}
-
-TIMER_CALLBACK_MEMBER( S3C24_CLASS_NAME::s3c24xx_iic_timer_exp )
-{
- int enable_interrupt;
- verboselog( machine(), 2, "IIC timer callback\n");
- m_iic.count++;
- enable_interrupt = BIT( m_iic.regs.iiccon, 5);
- if (enable_interrupt)
- {
- m_iic.regs.iiccon |= (1 << 4); // [bit 4] interrupt is pending
- s3c24xx_request_irq(S3C24XX_INT_IIC);
- }
-}
-
-/* IIS */
-
-void S3C24_CLASS_NAME::s3c24xx_iis_reset()
-{
- s3c24xx_iis_t *iis = &m_iis;
- memset( &iis->regs, 0, sizeof( iis->regs));
- iis->fifo_index = 0;
- iis->regs.iiscon = 0x0100;
- iis->timer->adjust( attotime::never);
-}
-
-void S3C24_CLASS_NAME::iface_i2s_data_w(int ch, UINT16 data)
-{
- if (!m_data_w_cb.isnull())
- {
- (m_data_w_cb)( ch, data, 0);
- }
-}
-
-void S3C24_CLASS_NAME::s3c24xx_iis_start()
-{
- const UINT32 codeclk_table[] = { 256, 384};
- double freq;
- int pclk, prescaler_enable, prescaler_control_a, prescaler_control_b, codeclk;
- verboselog( machine(), 1, "IIS start\n");
- prescaler_enable = BIT( m_iis.regs.iiscon, 1);
- prescaler_control_a = BITS( m_iis.regs.iispsr, 9, 5);
- prescaler_control_b = BITS( m_iis.regs.iispsr, 4, 0);
- codeclk = BIT( m_iis.regs.iismod, 2);
- pclk = s3c24xx_get_pclk();
- freq = ((double)pclk / (prescaler_control_a + 1) / codeclk_table[codeclk]) * 2; // why do I have to multiply by two?
- verboselog( machine(), 5, "IIS - pclk %d psc_enable %d psc_a %d psc_b %d codeclk %d freq %f\n", pclk, prescaler_enable, prescaler_control_a, prescaler_control_b, codeclk_table[codeclk], freq);
- m_iis.timer->adjust( attotime::from_hz( freq), 0, attotime::from_hz( freq));
-}
-
-void S3C24_CLASS_NAME::s3c24xx_iis_stop()
-{
- verboselog( machine(), 1, "IIS stop\n");
- m_iis.timer->adjust( attotime::never);
-}
-
-void S3C24_CLASS_NAME::s3c24xx_iis_recalc()
-{
- if ((m_iis.regs.iiscon & (1 << 0)) != 0)
- {
- s3c24xx_iis_start();
- }
- else
- {
- s3c24xx_iis_stop();
- }
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_iis_r )
-{
- UINT32 data = ((UINT32*)&m_iis.regs)[offset];
-#if 0
- switch (offset)
- {
- case S3C24XX_IISCON :
- {
- data = data & ~1; // hack for mp3 player
- }
- break;
- }
-#endif
- verboselog( machine(), 9, "(IIS) %08X -> %08X\n", S3C24XX_BASE_IIS + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_iis_w )
-{
- UINT32 old_value = ((UINT32*)&m_iis.regs)[offset];
- verboselog( machine(), 9, "(IIS) %08X <- %08X\n", S3C24XX_BASE_IIS + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_iis.regs)[offset]);
- switch (offset)
- {
- case S3C24XX_IISCON :
- {
- if ((old_value & (1 << 0)) != (data & (1 << 0)))
- {
- s3c24xx_iis_recalc();
- }
- }
- break;
- case S3C24XX_IISFIFO :
- {
- if (ACCESSING_BITS_16_31)
- {
- m_iis.fifo[m_iis.fifo_index++] = BITS( data, 31, 16);
- }
- if (ACCESSING_BITS_0_15)
- {
- m_iis.fifo[m_iis.fifo_index++] = BITS( data, 15, 0);
- }
- if (m_iis.fifo_index == 2)
- {
- m_iis.fifo_index = 0;
- iface_i2s_data_w( 0, m_iis.fifo[0]);
- iface_i2s_data_w( 1, m_iis.fifo[1]);
- }
- }
- break;
- }
-}
-
-TIMER_CALLBACK_MEMBER( S3C24_CLASS_NAME::s3c24xx_iis_timer_exp )
-{
- verboselog( machine(), 2, "IIS timer callback\n");
- s3c24xx_dma_request_iis();
-}
-
-/* RTC */
-
-void S3C24_CLASS_NAME::s3c24xx_rtc_reset()
-{
- s3c24xx_rtc_t *rtc = &m_rtc;
- memset( &rtc->regs, 0, sizeof( rtc->regs));
- rtc->regs.almday = 1;
- rtc->regs.almmon = 1;
- rtc->timer_update->adjust( attotime::never);
- rtc->timer_update->adjust( attotime::from_msec( 1000), 0, attotime::from_msec( 1000));
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_rtc_r )
-{
- UINT32 data = ((UINT32*)&m_rtc.regs)[offset];
- verboselog( machine(), 9, "(RTC) %08X -> %08X\n", S3C24XX_BASE_RTC + (offset << 2), data);
- return data;
-}
-
-void S3C24_CLASS_NAME::s3c24xx_rtc_recalc()
-{
- if (m_rtc.regs.ticnt & (1 << 7))
- {
- UINT32 ttc;
- double freq;
- ttc = BITS( m_rtc.regs.ticnt, 6, 0);
- freq = 128 / (ttc + 1);
-// printf( "ttc %d freq %f\n", ttc, freq);
- m_rtc.timer_tick_count->adjust( attotime::from_hz( freq), 0, attotime::from_hz( freq));
- }
- else
- {
- m_rtc.timer_tick_count->adjust( attotime::never);
- }
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_rtc_w )
-{
- verboselog( machine(), 9, "(RTC) %08X <- %08X\n", S3C24XX_BASE_RTC + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_rtc.regs)[offset]);
- switch (offset)
- {
- case S3C24XX_TICNT :
- {
- s3c24xx_rtc_recalc();
- }
- break;
- }
-}
-
-TIMER_CALLBACK_MEMBER( S3C24_CLASS_NAME::s3c24xx_rtc_timer_tick_count_exp )
-{
- verboselog( machine(), 2, "RTC timer callback (tick count)\n");
- s3c24xx_request_irq( S3C24XX_INT_TICK);
-}
-
-void S3C24_CLASS_NAME::s3c24xx_rtc_update()
-{
- UINT32 bcdday_max;
- // increase second
- m_rtc.regs.bcdsec = bcd_adjust( m_rtc.regs.bcdsec + 1);
- if (m_rtc.regs.bcdsec >= 0x60)
- {
- m_rtc.regs.bcdsec = 0;
- // increase minute
- m_rtc.regs.bcdmin = bcd_adjust( m_rtc.regs.bcdmin + 1);
- if (m_rtc.regs.bcdmin >= 0x60)
- {
- m_rtc.regs.bcdmin = 0;
- // increase hour
- m_rtc.regs.bcdhour = bcd_adjust( m_rtc.regs.bcdhour + 1);
- if (m_rtc.regs.bcdhour >= 0x24)
- {
- m_rtc.regs.bcdhour = 0;
- // increase day-of-week
- m_rtc.regs.bcddow = (m_rtc.regs.bcddow % 7) + 1;
- // increase day
- m_rtc.regs.bcdday = bcd_adjust( m_rtc.regs.bcdday + 1);
- bcdday_max = dec_2_bcd( gregorian_days_in_month( bcd_2_dec( m_rtc.regs.bcdmon), bcd_2_dec( m_rtc.regs.bcdyear) + 2000));
- if (m_rtc.regs.bcdday > bcdday_max)
- {
- m_rtc.regs.bcdday = 1;
- // increase month
- m_rtc.regs.bcdmon = bcd_adjust( m_rtc.regs.bcdmon + 1);
- if (m_rtc.regs.bcdmon >= 0x12)
- {
- m_rtc.regs.bcdmon = 1;
- // increase year
- m_rtc.regs.bcdyear = bcd_adjust( m_rtc.regs.bcdyear + 1);
- if (m_rtc.regs.bcdyear >= 0x100)
- {
- m_rtc.regs.bcdyear = 0;
- }
- }
- }
- }
- }
- }
- verboselog( machine(), 5, "RTC - %04d/%02d/%02d %02d:%02d:%02d\n", bcd_2_dec( m_rtc.regs.bcdyear) + 2000, bcd_2_dec( m_rtc.regs.bcdmon), bcd_2_dec( m_rtc.regs.bcdday), bcd_2_dec( m_rtc.regs.bcdhour), bcd_2_dec( m_rtc.regs.bcdmin), bcd_2_dec( m_rtc.regs.bcdsec));
-}
-
-void S3C24_CLASS_NAME::s3c24xx_rtc_check_alarm()
-{
- if (m_rtc.regs.rtcalm & 0x40)
- {
- int isalarm = 1;
- isalarm = isalarm && (((m_rtc.regs.rtcalm & 0x20) == 0) || (m_rtc.regs.almyear == m_rtc.regs.bcdyear));
- isalarm = isalarm && (((m_rtc.regs.rtcalm & 0x10) == 0) || (m_rtc.regs.almmon == m_rtc.regs.bcdmon));
- isalarm = isalarm && (((m_rtc.regs.rtcalm & 0x08) == 0) || (m_rtc.regs.almday == m_rtc.regs.bcdday));
- isalarm = isalarm && (((m_rtc.regs.rtcalm & 0x04) == 0) || (m_rtc.regs.almhour == m_rtc.regs.bcdhour));
- isalarm = isalarm && (((m_rtc.regs.rtcalm & 0x02) == 0) || (m_rtc.regs.almmin == m_rtc.regs.bcdmin));
- isalarm = isalarm && (((m_rtc.regs.rtcalm & 0x01) == 0) || (m_rtc.regs.almsec == m_rtc.regs.bcdsec));
- if (isalarm != 0)
- {
- s3c24xx_request_irq(S3C24XX_INT_RTC);
- }
- }
-}
-
-TIMER_CALLBACK_MEMBER( S3C24_CLASS_NAME::s3c24xx_rtc_timer_update_exp )
-{
- verboselog( machine(), 2, "RTC timer callback (update)\n");
- s3c24xx_rtc_update();
- s3c24xx_rtc_check_alarm();
-}
-
-/* A/D Converter */
-
-void S3C24_CLASS_NAME::s3c24xx_adc_reset()
-{
- s3c24xx_adc_t *adc = &m_adc;
- memset( &adc->regs, 0, sizeof( adc->regs));
- adc->regs.adccon = 0x3FC4;
- #if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- adc->regs.adctsc = 0x58;
- adc->regs.adcdly = 0xFF;
- #endif
-}
-
-UINT32 S3C24_CLASS_NAME::iface_adc_data_r(int ch)
-{
- if (!m_data_r_cb.isnull())
- {
- int offs = ch;
- #if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- if (BIT( m_adc.regs.adctsc, 2) != 0)
- {
- offs += 2;
- }
- #endif
- return (m_data_r_cb)(offs, 0);
- }
- else
- {
- return 0;
- }
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_adc_r )
-{
- UINT32 data = ((UINT32*)&m_adc.regs)[offset];
- switch (offset)
- {
-#if defined(DEVICE_S3C2400)
- case S3C24XX_ADCDAT :
- {
- data = (data & ~0x3FF) | (iface_adc_data_r( 0) & 0x3FF);
- }
- break;
-#else
- case S3C24XX_ADCDAT0 :
- {
- data = (data & ~0x3FF) | (iface_adc_data_r( 0) & 0x3FF);
- }
- break;
- case S3C24XX_ADCDAT1 :
- {
- data = (data & ~0x3FF) | (iface_adc_data_r( 1) & 0x3FF);
- }
- break;
-#endif
- }
- verboselog( machine(), 9, "(ADC) %08X -> %08X\n", S3C24XX_BASE_ADC + (offset << 2), data);
- return data;
-}
-
-void S3C24_CLASS_NAME::s3c24xx_adc_start()
-{
- verboselog( machine(), 1, "ADC start\n");
- m_adc.regs.adccon &= ~(1 << 0); // A/D conversion is completed
- m_adc.regs.adccon |= (1 << 15); // End of A/D conversion
- #if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- s3c24xx_request_subirq( S3C24XX_SUBINT_ADC);
- #endif
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_adc_w )
-{
- UINT32 old_value = ((UINT32*)&m_adc.regs)[offset];
- verboselog( machine(), 9, "(ADC) %08X <- %08X\n", S3C24XX_BASE_ADC + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_adc.regs)[offset]);
- switch (offset)
- {
- case S3C24XX_ADCCON :
- {
- if (((old_value & (1 << 0)) == 0) && ((data & (1 << 0)) != 0))
- {
- s3c24xx_adc_start();
- }
- }
- break;
- }
-}
-
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
-
-void S3C24_CLASS_NAME::s3c24xx_touch_screen(int state)
-{
- m_adc.regs.adcdat0 = ((state ? 0 : 1) << 15);
- m_adc.regs.adcdat1 = ((state ? 0 : 1) << 15);
- s3c24xx_request_subirq( S3C24XX_SUBINT_TC);
-}
-
-#endif
-
-/* SPI */
-
-void S3C24_CLASS_NAME::s3c24xx_spi_reset()
-{
- for (int i = 0; i < S3C24XX_SPI_COUNT; i++)
- {
- s3c24xx_spi_t *spi = &m_spi[i];
- memset( &spi->regs, 0, sizeof( spi->regs));
- spi->regs.spsta = 1;
- #if defined(DEVICE_S3C2400) || defined(DEVICE_S3C2410)
- spi->regs.sppin = 2;
- #endif
- }
-}
-
-UINT32 S3C24_CLASS_NAME::s3c24xx_spi_r(UINT32 ch, UINT32 offset)
-{
- UINT32 data = ((UINT32*)&m_spi[ch].regs)[offset];
- switch (offset)
- {
- case S3C24XX_SPSTA :
- {
- data = data | (1 << 0); // [bit 0] Transfer Ready Flag
- }
- break;
- }
- return data;
-}
-
-void S3C24_CLASS_NAME::s3c24xx_spi_w(UINT32 ch, UINT32 offset, UINT32 data, UINT32 mem_mask)
-{
- COMBINE_DATA(&((UINT32*)&m_spi[ch].regs)[offset]);
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_spi_0_r )
-{
- UINT32 data = s3c24xx_spi_r( 0, offset);
- verboselog( machine(), 9, "(SPI 0) %08X -> %08X\n", S3C24XX_BASE_SPI_0 + (offset << 2), data);
- return data;
-}
-
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_spi_1_r )
-{
- UINT32 data = s3c24xx_spi_r( 1, offset);
- verboselog( machine(), 9, "(SPI 1) %08X -> %08X\n", S3C24XX_BASE_SPI_1 + (offset << 2), data);
- return data;
-}
-
-#endif
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_spi_0_w )
-{
- verboselog( machine(), 9, "(SPI 0) %08X <- %08X\n", S3C24XX_BASE_SPI_0 + (offset << 2), data);
- s3c24xx_spi_w( 0, offset, data, mem_mask);
-}
-
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_spi_1_w )
-{
- verboselog( machine(), 9, "(SPI 1) %08X <- %08X\n", S3C24XX_BASE_SPI_1 + (offset << 2), data);
- s3c24xx_spi_w( 1, offset, data, mem_mask);
-}
-
-#endif
-
-/* MMC Interface */
-
-#if defined(DEVICE_S3C2400)
-
-void S3C24_CLASS_NAME::s3c24xx_mmc_reset()
-{
- s3c24xx_mmc_t *mmc = &m_mmc;
- memset( &mmc->regs, 0, sizeof( mmc->regs));
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_mmc_r )
-{
- UINT32 data = m_mmc.regs.data[offset];
- verboselog( machine(), 9, "(MMC) %08X -> %08X\n", S3C24XX_BASE_MMC + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_mmc_w )
-{
- verboselog( machine(), 9, "(MMC) %08X <- %08X\n", S3C24XX_BASE_MMC + (offset << 2), data);
- COMBINE_DATA(&m_mmc.regs.data[offset]);
-}
-
-#endif
-
-/* SD Interface */
-
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
-
-void S3C24_CLASS_NAME::s3c24xx_sdi_reset()
-{
- s3c24xx_sdi_t *sdi = &m_sdi;
- memset( &sdi->regs, 0, sizeof( sdi->regs));
- #if defined(DEVICE_S3C2410)
- sdi->regs.data[0x24/4] = 0x2000;
- #elif defined(DEVICE_S3C2440)
- sdi->regs.data[0x04/4] = 1;
- sdi->regs.data[0x24/4] = 0x10000;
- #endif
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_sdi_r )
-{
- UINT32 data = m_sdi.regs.data[offset];
- verboselog( machine(), 9, "(SDI) %08X -> %08X\n", S3C24XX_BASE_SDI + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_sdi_w )
-{
- verboselog( machine(), 9, "(SDI) %08X <- %08X\n", S3C24XX_BASE_SDI + (offset << 2), data);
- COMBINE_DATA(&m_sdi.regs.data[offset]);
-}
-
-#endif
-
-/* NAND Flash */
-
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
-
-void S3C24_CLASS_NAME::s3c24xx_nand_reset()
-{
- s3c24xx_nand_t *nand = &m_nand;
- memset( &nand->regs, 0, sizeof( nand->regs));
- #if defined(DEVICE_S3C2440)
- nand->regs.nfconf = 0x1000;
- nand->regs.nfcont = 0x0384;
- #endif
-}
-
-void S3C24_CLASS_NAME::iface_nand_command_w(UINT8 data)
-{
- if (!m_command_w_cb.isnull())
- {
- (m_command_w_cb)( 0, data, 0xff);
- }
-}
-
-void S3C24_CLASS_NAME::iface_nand_address_w(UINT8 data)
-{
- if (!m_address_w_cb.isnull())
- {
- (m_address_w_cb)( 0, data, 0xff);
- }
-}
-
-UINT8 S3C24_CLASS_NAME::iface_nand_data_r()
-{
- if (!m_nand_data_r_cb.isnull())
- {
- return (m_nand_data_r_cb)( 0, 0xff);
- }
- else
- {
- return 0;
- }
-}
-
-void S3C24_CLASS_NAME::iface_nand_data_w(UINT8 data)
-{
- if (!m_nand_data_w_cb.isnull())
- {
- (m_nand_data_w_cb)(0, data, 0xff);
- }
-}
-
-void S3C24_CLASS_NAME::nand_update_mecc( UINT8 *ecc, int pos, UINT8 data)
-{
- int bit[8];
- UINT8 temp;
- bit[0] = (data >> 0) & 1;
- bit[1] = (data >> 1) & 1;
- bit[2] = (data >> 2) & 1;
- bit[3] = (data >> 3) & 1;
- bit[4] = (data >> 4) & 1;
- bit[5] = (data >> 5) & 1;
- bit[6] = (data >> 6) & 1;
- bit[7] = (data >> 7) & 1;
- // column parity
- ecc[2] ^= ((bit[6] ^ bit[4] ^ bit[2] ^ bit[0]) << 2);
- ecc[2] ^= ((bit[7] ^ bit[5] ^ bit[3] ^ bit[1]) << 3);
- ecc[2] ^= ((bit[5] ^ bit[4] ^ bit[1] ^ bit[0]) << 4);
- ecc[2] ^= ((bit[7] ^ bit[6] ^ bit[3] ^ bit[2]) << 5);
- ecc[2] ^= ((bit[3] ^ bit[2] ^ bit[1] ^ bit[0]) << 6);
- ecc[2] ^= ((bit[7] ^ bit[6] ^ bit[5] ^ bit[4]) << 7);
- // line parity
- temp = bit[7] ^ bit[6] ^ bit[5] ^ bit[4] ^ bit[3] ^ bit[2] ^ bit[1] ^ bit[0];
- if (pos & 0x001) ecc[0] ^= (temp << 1); else ecc[0] ^= (temp << 0);
- if (pos & 0x002) ecc[0] ^= (temp << 3); else ecc[0] ^= (temp << 2);
- if (pos & 0x004) ecc[0] ^= (temp << 5); else ecc[0] ^= (temp << 4);
- if (pos & 0x008) ecc[0] ^= (temp << 7); else ecc[0] ^= (temp << 6);
- if (pos & 0x010) ecc[1] ^= (temp << 1); else ecc[1] ^= (temp << 0);
- if (pos & 0x020) ecc[1] ^= (temp << 3); else ecc[1] ^= (temp << 2);
- if (pos & 0x040) ecc[1] ^= (temp << 5); else ecc[1] ^= (temp << 4);
- if (pos & 0x080) ecc[1] ^= (temp << 7); else ecc[1] ^= (temp << 6);
- if (pos & 0x100) ecc[2] ^= (temp << 1); else ecc[2] ^= (temp << 0);
- if (pos & 0x200) ecc[3] ^= (temp << 5); else ecc[3] ^= (temp << 4);
- if (pos & 0x400) ecc[3] ^= (temp << 7); else ecc[3] ^= (temp << 6);
-}
-
-#if defined(DEVICE_S3C2440)
-
-void S3C24_CLASS_NAME::nand_update_secc( UINT8 *ecc, int pos, UINT8 data)
-{
- int bit[8];
- UINT8 temp;
- bit[0] = (data >> 0) & 1;
- bit[1] = (data >> 1) & 1;
- bit[2] = (data >> 2) & 1;
- bit[3] = (data >> 3) & 1;
- bit[4] = (data >> 4) & 1;
- bit[5] = (data >> 5) & 1;
- bit[6] = (data >> 6) & 1;
- bit[7] = (data >> 7) & 1;
- // column parity
- ecc[1] ^= ((bit[6] ^ bit[4] ^ bit[2] ^ bit[0]) << 6);
- ecc[1] ^= ((bit[7] ^ bit[5] ^ bit[3] ^ bit[1]) << 7);
- ecc[0] ^= ((bit[5] ^ bit[4] ^ bit[1] ^ bit[0]) << 0);
- ecc[0] ^= ((bit[7] ^ bit[6] ^ bit[3] ^ bit[2]) << 1);
- ecc[0] ^= ((bit[3] ^ bit[2] ^ bit[1] ^ bit[0]) << 2);
- ecc[0] ^= ((bit[7] ^ bit[6] ^ bit[5] ^ bit[4]) << 3);
- // line parity
- temp = bit[7] ^ bit[6] ^ bit[5] ^ bit[4] ^ bit[3] ^ bit[2] ^ bit[1] ^ bit[0];
- if (pos & 0x001) ecc[0] ^= (temp << 5); else ecc[0] ^= (temp << 4);
- if (pos & 0x002) ecc[0] ^= (temp << 7); else ecc[0] ^= (temp << 6);
- if (pos & 0x004) ecc[1] ^= (temp << 3); else ecc[1] ^= (temp << 2);
- if (pos & 0x008) ecc[1] ^= (temp << 5); else ecc[1] ^= (temp << 4);
-}
-
-#endif
-
-void S3C24_CLASS_NAME::s3c24xx_nand_update_ecc(UINT8 data)
-{
- s3c24xx_nand_t *nand = &m_nand;
- UINT8 temp[4];
-#if defined(DEVICE_S3C2410)
- temp[0] = nand->mecc[0];
- temp[1] = nand->mecc[1];
- temp[2] = nand->mecc[2];
- nand_update_mecc( nand->mecc, nand->ecc_pos++, data);
- verboselog( machine(), 5, "NAND - MECC %03X - %02X %02X %02X -> %02X %02X %02X\n", nand->ecc_pos - 1, temp[0], temp[1], temp[2], nand->mecc[0], nand->mecc[1], nand->mecc[2]);
- if (nand->ecc_pos == 512) nand->ecc_pos = 0;
-#else
- if ((nand->regs.nfcont & (1 << 5)) == 0)
- {
- temp[0] = nand->mecc[0];
- temp[1] = nand->mecc[1];
- temp[2] = nand->mecc[2];
- temp[3] = nand->mecc[3];
- nand_update_mecc( nand->mecc, nand->ecc_pos++, data);
- verboselog( machine(), 5, "NAND - MECC %03X - %02X %02X %02X %02X -> %02X %02X %02X %02X\n", nand->ecc_pos - 1, temp[0], temp[1], temp[2], temp[3], nand->mecc[0], nand->mecc[1], nand->mecc[2], nand->mecc[3]);
- if (nand->ecc_pos == 2048) nand->ecc_pos = 0;
- }
- if ((nand->regs.nfcont & (1 << 6)) == 0)
- {
- temp[0] = nand->secc[0];
- temp[1] = nand->secc[1];
- nand_update_secc( nand->secc, nand->ecc_pos++, data);
- verboselog( machine(), 5, "NAND - SECC %02X - %02X %02X -> %02X %02X\n", nand->ecc_pos - 1, temp[0], temp[1], nand->secc[0], nand->secc[1]);
- if (nand->ecc_pos == 16) nand->ecc_pos = 0;
- }
-#endif
-}
-
-void S3C24_CLASS_NAME::s3c24xx_nand_command_w(UINT8 data)
-{
- verboselog( machine(), 5, "NAND write command %02X\n", data);
- m_nand.data_count = 0;
- iface_nand_command_w( data);
-}
-
-void S3C24_CLASS_NAME::s3c24xx_nand_address_w(UINT8 data)
-{
- verboselog( machine(), 5, "NAND write address %02X\n", data);
- m_nand.data_count = 0;
- iface_nand_address_w( data);
-}
-
-UINT8 S3C24_CLASS_NAME::s3c24xx_nand_data_r()
-{
- UINT8 data = iface_nand_data_r();
- verboselog( machine(), 5, "NAND read data %02X [%04X]\n", data, m_nand.data_count++);
- s3c24xx_nand_update_ecc( data);
- return data;
-}
-
-void S3C24_CLASS_NAME::s3c24xx_nand_data_w(UINT8 data)
-{
- verboselog( machine(), 5, "NAND write data %02X [%04X]\n", data, m_nand.data_count++);
- iface_nand_data_w( data);
- s3c24xx_nand_update_ecc( data);
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_nand_r )
-{
- UINT32 data = ((UINT32*)&m_nand.regs)[offset];
- switch (offset)
- {
- case S3C24XX_NFDATA :
- {
- data = 0;
- #if defined(DEVICE_S3C2410)
- data = data | s3c24xx_nand_data_r();
- #elif defined(DEVICE_S3C2440)
- if ((mem_mask & 0x000000FF) != 0) data = data | (s3c24xx_nand_data_r() << 0);
- if ((mem_mask & 0x0000FF00) != 0) data = data | (s3c24xx_nand_data_r() << 8);
- if ((mem_mask & 0x00FF0000) != 0) data = data | (s3c24xx_nand_data_r() << 16);
- if ((mem_mask & 0xFF000000) != 0) data = data | (s3c24xx_nand_data_r() << 24);
- #endif
- }
- break;
-#if defined(DEVICE_S3C2410)
- case S3C24XX_NFECC :
- {
- data = ((m_nand.mecc[2] << 16) | (m_nand.mecc[1] << 8) | (m_nand.mecc[0] << 0));
- }
- break;
-#endif
-#if defined(DEVICE_S3C2440)
- case S3C24XX_NFMECC0 :
- {
- data = (m_nand.mecc[3] << 24) | (m_nand.mecc[2] << 16) | (m_nand.mecc[1] << 8) | (m_nand.mecc[0] << 0);
- }
- break;
- case S3C24XX_NFSECC :
- {
- data = (m_nand.secc[1] << 8) | (m_nand.secc[0] << 0);
- }
- break;
- case S3C24XX_NFESTAT0 :
- {
- data &= ~0x000000F; // no main/spare ECC errors
- }
- break;
- case S3C24XX_NFESTAT1 :
- {
- data &= ~0x000000F; // no main/spare ECC errors
- }
- break;
-#endif
- }
- verboselog( machine(), 9, "(NAND) %08X -> %08X (%08X)\n", S3C24XX_BASE_NAND + (offset << 2), data, mem_mask);
- return data;
-}
-
-void S3C24_CLASS_NAME::s3c24xx_nand_init_ecc()
-{
- verboselog( machine(), 5, "NAND - init ecc\n");
- m_nand.mecc[0] = 0xFF;
- m_nand.mecc[1] = 0xFF;
- m_nand.mecc[2] = 0xFF;
- #if defined(DEVICE_S3C2440)
- m_nand.mecc[3] = 0xFF;
- m_nand.secc[0] = 0;
- m_nand.secc[1] = 0;
- #endif
- m_nand.ecc_pos = 0;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_nand_w )
-{
- UINT32 old_value = ((UINT32*)&m_nand.regs)[offset];
- verboselog( machine(), 9, "(NAND) %08X <- %08X (%08X)\n", S3C24XX_BASE_NAND + (offset << 2), data, mem_mask);
- COMBINE_DATA(&((UINT32*)&m_nand.regs)[offset]);
- switch (offset)
- {
-#if defined(DEVICE_S3C2410)
- case S3C24XX_NFCONF :
- {
- if ((data & (1 << 12)) != 0)
- {
- s3c24xx_nand_init_ecc();
- }
- }
- break;
-#endif
-#if defined(DEVICE_S3C2440)
- case S3C24XX_NFCONT :
- {
- if ((data & (1 << 4)) != 0)
- {
- s3c24xx_nand_init_ecc();
- }
- }
- break;
-#endif
- case S3C24XX_NFSTAT :
- {
- m_nand.regs.nfstat = (m_nand.regs.nfstat & ~0x03) | (old_value & 0x03); // read-only
-#if defined(DEVICE_S3C2440)
- if ((data & (1 << 2)) != 0)
- {
- m_nand.regs.nfstat &= ~(1 << 2); // "RnB_TransDetect, to clear this value write 1"
- }
-#endif
- }
- break;
- case S3C24XX_NFCMD :
- {
- s3c24xx_nand_command_w(data);
- }
- break;
- case S3C24XX_NFADDR :
- {
- s3c24xx_nand_address_w(data);
- }
- break;
- case S3C24XX_NFDATA :
- {
- #if defined(DEVICE_S3C2410)
- s3c24xx_nand_data_w(data & 0xFF);
- #elif defined(DEVICE_S3C2440)
- if ((mem_mask & 0x000000FF) != 0) s3c24xx_nand_data_w((data >> 0) & 0xFF);
- if ((mem_mask & 0x0000FF00) != 0) s3c24xx_nand_data_w((data >> 8) & 0xFF);
- if ((mem_mask & 0x00FF0000) != 0) s3c24xx_nand_data_w((data >> 16) & 0xFF);
- if ((mem_mask & 0xFF000000) != 0) s3c24xx_nand_data_w((data >> 24) & 0xFF);
- #endif
- }
- break;
- }
-}
-
-ATTR_UNUSED WRITE_LINE_MEMBER( S3C24_CLASS_NAME::s3c24xx_pin_frnb_w )
-{
- verboselog( machine(), 9, "s3c24xx_pin_frnb_w (%d)\n", state);
-#if defined(DEVICE_S3C2440)
- if ((BIT( m_nand.regs.nfstat, 0) == 0) && (state != 0))
- {
- m_nand.regs.nfstat |= (1 << 2);
- if (BIT( m_nand.regs.nfcont, 9) != 0)
- {
- s3c24xx_request_irq( S3C24XX_INT_NFCON);
- }
- }
-#endif
- if (state == 0)
- {
- m_nand.regs.nfstat &= ~(1 << 0);
- }
- else
- {
- m_nand.regs.nfstat |= (1 << 0);
- }
-}
-
-#endif
-
-/* Camera Interface */
-
-#if defined(DEVICE_S3C2440)
-
-void S3C24_CLASS_NAME::s3c24xx_cam_reset()
-{
- s3c24xx_cam_t *cam = &m_cam;
- memset( &cam->regs, 0, sizeof( cam->regs));
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_cam_r )
-{
- UINT32 data = m_cam.regs.data[offset];
- verboselog( machine(), 9, "(CAM) %08X -> %08X\n", S3C24XX_BASE_CAM + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_cam_w )
-{
- verboselog( machine(), 9, "(CAM) %08X <- %08X\n", S3C24XX_BASE_CAM + (offset << 2), data);
- COMBINE_DATA(&m_cam.regs.data[offset]);
-}
-
-#endif
-
-/* AC97 Interface */
-
-#if defined(DEVICE_S3C2440)
-
-void S3C24_CLASS_NAME::s3c24xx_ac97_reset()
-{
- s3c24xx_ac97_t *ac97 = &m_ac97;
- memset( &ac97->regs, 0, sizeof( ac97->regs));
-}
-
-READ32_MEMBER( S3C24_CLASS_NAME::s3c24xx_ac97_r )
-{
- UINT32 data = m_ac97.regs.data[offset];
- verboselog( machine(), 9, "(AC97) %08X -> %08X\n", S3C24XX_BASE_AC97 + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_ac97_w )
-{
- verboselog( machine(), 9, "(AC97) %08X <- %08X\n", S3C24XX_BASE_AC97 + (offset << 2), data);
- COMBINE_DATA(&m_ac97.regs.data[offset]);
-}
-
-#endif
-
-// ...
-
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
-
-void S3C24_CLASS_NAME::s3c24xx_nand_auto_boot()
-{
- int om0 = iface_core_pin_r( S3C24XX_CORE_PIN_OM0);
- int om1 = iface_core_pin_r( S3C24XX_CORE_PIN_OM1);
- if ((om0 == 0) && (om1 == 0))
- {
- int ncon = iface_core_pin_r( S3C24XX_CORE_PIN_NCON);
- UINT8 *ptr = m_steppingstone;
- int page_size, address_cycle;
- #if defined(DEVICE_S3C2410)
- page_size = 512;
- if (ncon == 0)
- {
- address_cycle = 3; // byte-page-page
- }
- else
- {
- address_cycle = 4; // byte-page-page-page
- }
- #elif defined(DEVICE_S3C2440)
- UINT32 port_g = iface_gpio_port_r( S3C24XX_GPIO_PORT_G, 0);
- if (ncon == 0)
- {
- if (BIT( port_g, 13) == 0)
- {
- page_size = 256;
- address_cycle = 3; // byte-page-page
- }
- else
- {
- page_size = 512;
- address_cycle = 4; // byte-page-page-page
- }
- }
- else
- {
- if (BIT( port_g, 13) == 0)
- {
- page_size = 1024;
- address_cycle = 4; // byte-byte-page-page or byte-page-page-page ??? assume latter
- }
- else
- {
- page_size = 2048;
- address_cycle = 5; // byte-byte-page-page-page
- }
- }
- #endif
- iface_nand_command_w( 0xFF);
- for (int page = 0; page < (4 * 1024) / page_size; page++)
- {
- iface_nand_command_w( 0x00);
- iface_nand_address_w( 0x00);
- if (address_cycle > 4)
- {
- iface_nand_address_w( 0x00);
- }
- iface_nand_address_w( (page >> 0) & 0xFF);
- iface_nand_address_w( (page >> 8) & 0xFF);
- if (address_cycle > 3)
- {
- iface_nand_address_w( (page >> 16) & 0xFF);
- }
- for (int i = 0; i < page_size; i++)
- {
- *ptr++ = iface_nand_data_r();
- }
- }
- iface_nand_command_w( 0xFF);
- }
-}
-
-#endif
-
-void S3C24_CLASS_NAME::s3c24xx_device_reset()
-{
- verboselog( machine(), 1, "s3c24xx device reset\n");
- s3c24xx_uart_reset( );
- s3c24xx_pwm_reset();
- s3c24xx_dma_reset();
- s3c24xx_iic_reset();
- s3c24xx_iis_reset();
- s3c24xx_lcd_reset();
- s3c24xx_rtc_reset();
- s3c24xx_wdt_reset();
- s3c24xx_irq_reset();
- s3c24xx_gpio_reset();
- s3c24xx_memcon_reset();
- s3c24xx_clkpow_reset();
- s3c24xx_usb_host_reset();
- s3c24xx_usb_device_reset();
- s3c24xx_adc_reset();
- s3c24xx_spi_reset();
- #if defined(DEVICE_S3C2400)
- s3c24xx_mmc_reset();
- #endif
- #if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- s3c24xx_sdi_reset();
- s3c24xx_nand_reset();
- #endif
- #if defined(DEVICE_S3C2440)
- s3c24xx_cam_reset();
- s3c24xx_ac97_reset();
- #endif
- #if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- s3c24xx_nand_auto_boot();
- #endif
-}
-
-void S3C24_CLASS_NAME::s3c24xx_device_start()
-{
- verboselog( machine(), 1, "s3c24xx device start\n");
- m_pin_r_cb.resolve();
- m_pin_w_cb.resolve_safe();
- m_port_r_cb.resolve();
- m_port_w_cb.resolve();
- m_scl_w_cb.resolve();
- m_sda_r_cb.resolve();
- m_sda_w_cb.resolve();
- m_data_r_cb.resolve();
- m_data_w_cb.resolve();
- #if !defined(DEVICE_S3C2400)
- m_command_w_cb.resolve();
- m_address_w_cb.resolve();
- m_nand_data_r_cb.resolve();
- m_nand_data_w_cb.resolve();
- #endif
- for (int i = 0; i < 5; i++)
- {
- m_pwm.timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_pwm_timer_exp), this));
- }
- for (int i = 0; i < S3C24XX_DMA_COUNT; i++)
- {
- m_dma[i].timer = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_dma_timer_exp), this));
- }
- m_iic.timer = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_iic_timer_exp), this));
- m_iis.timer = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_iis_timer_exp), this));
- m_lcd.timer = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_lcd_timer_exp), this));
- m_rtc.timer_tick_count = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_rtc_timer_tick_count_exp), this));
- m_rtc.timer_update = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_rtc_timer_update_exp), this));
- m_wdt.timer = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_wdt_timer_exp), this));
- #if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- int om0 = iface_core_pin_r( S3C24XX_CORE_PIN_OM0);
- int om1 = iface_core_pin_r( S3C24XX_CORE_PIN_OM1);
- if ((om0 == 0) && (om1 == 0))
- {
- address_space &space = m_cpu->memory().space( AS_PROGRAM);
- space.install_ram( 0x00000000, 0x00000fff, m_steppingstone);
- space.install_ram( 0x40000000, 0x40000fff, m_steppingstone);
- }
- #endif
-}
diff --git a/src/emu/machine/s3c44b0.c b/src/emu/machine/s3c44b0.c
deleted file mode 100644
index fb9d3f15036..00000000000
--- a/src/emu/machine/s3c44b0.c
+++ /dev/null
@@ -1,2055 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Schuerewegen
-/*******************************************************************************
-
- Samsung S3C44B0
-
- (c) 2011 Tim Schuerewegen
-
-*******************************************************************************/
-
-#include "emu.h"
-#include "cpu/arm7/arm7.h"
-#include "cpu/arm7/arm7core.h"
-#include "machine/s3c44b0.h"
-#include "sound/dac.h"
-#include "coreutil.h"
-
-#define VERBOSE_LEVEL ( 0 )
-
-INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ...)
-{
- if (VERBOSE_LEVEL >= n_level)
- {
- va_list v;
- char buf[32768];
- va_start(v, s_fmt);
- vsprintf(buf, s_fmt, v);
- va_end(v);
- logerror("%s: %s", machine.describe_context(), buf);
- }
-}
-
-const device_type S3C44B0 = &device_creator<s3c44b0_device>;
-
-s3c44b0_device::s3c44b0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, S3C44B0, "Samsung S3C44B0", tag, owner, clock, "s3c44b0", __FILE__),
- m_port_r_cb(*this),
- m_port_w_cb(*this),
- m_scl_w_cb(*this),
- m_sda_r_cb(*this),
- m_sda_w_cb(*this),
- m_data_r_cb(*this),
- m_data_w_cb(*this)
-{
- memset(&m_irq, 0, sizeof(s3c44b0_irq_t));
- memset(m_zdma, 0, sizeof(s3c44b0_dma_t)*2);
- memset(m_bdma, 0, sizeof(s3c44b0_dma_t)*2);
- memset(&m_clkpow, 0, sizeof(s3c44b0_clkpow_t));
- memset(&m_lcd, 0, sizeof(s3c44b0_lcd_t));
- memset(m_uart, 0, sizeof(s3c44b0_uart_t)*2);
- memset(&m_sio, 0, sizeof(s3c44b0_sio_t));
- memset(&m_pwm, 0, sizeof(s3c44b0_pwm_t));
- memset(&m_wdt, 0, sizeof(s3c44b0_wdt_t));
- memset(&m_iic, 0, sizeof(s3c44b0_iic_t));
- memset(&m_iis, 0, sizeof(s3c44b0_iis_t));
- memset(&m_gpio, 0, sizeof(s3c44b0_gpio_t));
- memset(&m_adc, 0, sizeof(s3c44b0_adc_t));
- memset(&m_cpuwrap, 0, sizeof(s3c44b0_cpuwrap_t));
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void s3c44b0_device::device_start()
-{
- m_cpu = machine().device<cpu_device>("maincpu");
-
- m_port_r_cb.resolve();
- m_port_w_cb.resolve();
- m_scl_w_cb.resolve();
- m_sda_r_cb.resolve();
- m_sda_w_cb.resolve();
- m_data_r_cb.resolve_safe(0);
- m_data_w_cb.resolve();
-
-
- for (int i = 0; i < 6; i++) m_pwm.timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::pwm_timer_exp),this));
- for (int i = 0; i < 2; i++) m_uart[i].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::uart_timer_exp),this));
- for (int i = 0; i < 2; i++) m_zdma[i].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::zdma_timer_exp),this));
- for (int i = 0; i < 2; i++) m_bdma[i].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::bdma_timer_exp),this));
-
- m_lcd.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::lcd_timer_exp),this));
- m_wdt.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::wdt_timer_exp),this));
- m_sio.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::sio_timer_exp),this));
- m_adc.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::adc_timer_exp),this));
- m_iic.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::iic_timer_exp),this));
- m_iis.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::iis_timer_exp),this));
-
- video_start();
-
- save_item(NAME(m_irq.regs.intcon));
- save_item(NAME(m_irq.regs.intpnd));
- save_item(NAME(m_irq.regs.intmod));
- save_item(NAME(m_irq.regs.intmsk));
- save_item(NAME(m_irq.regs.i_pslv));
- save_item(NAME(m_irq.regs.i_pmst));
- save_item(NAME(m_irq.regs.i_cslv));
- save_item(NAME(m_irq.regs.i_cmst));
- save_item(NAME(m_irq.regs.i_ispr));
- save_item(NAME(m_irq.regs.i_ispc));
- save_item(NAME(m_irq.regs.reserved));
- save_item(NAME(m_irq.regs.f_ispr));
- save_item(NAME(m_irq.regs.f_ispc));
- save_item(NAME(m_irq.line_irq));
- save_item(NAME(m_irq.line_fiq));
-
- save_item(NAME(m_clkpow.regs.pllcon));
- save_item(NAME(m_clkpow.regs.clkcon));
- save_item(NAME(m_clkpow.regs.clkslow));
- save_item(NAME(m_clkpow.regs.locktime));
-
- // FIXME: how to save m_lcd.bitmap which gets allocated/freed during emulation?
- save_item(NAME(m_lcd.regs.lcdcon1));
- save_item(NAME(m_lcd.regs.lcdcon2));
- save_item(NAME(m_lcd.regs.lcdsaddr1));
- save_item(NAME(m_lcd.regs.lcdsaddr2));
- save_item(NAME(m_lcd.regs.lcdsaddr3));
- save_item(NAME(m_lcd.regs.redlut));
- save_item(NAME(m_lcd.regs.greenlut));
- save_item(NAME(m_lcd.regs.bluelut));
- save_item(NAME(m_lcd.regs.reserved));
- save_item(NAME(m_lcd.regs.lcdcon3));
- save_item(NAME(m_lcd.regs.dithmode));
- save_item(NAME(m_lcd.vramaddr_cur));
- save_item(NAME(m_lcd.vramaddr_max));
- save_item(NAME(m_lcd.offsize));
- save_item(NAME(m_lcd.pagewidth_cur));
- save_item(NAME(m_lcd.pagewidth_max));
- save_item(NAME(m_lcd.modesel));
- save_item(NAME(m_lcd.bswp));
- save_item(NAME(m_lcd.vpos));
- save_item(NAME(m_lcd.hpos));
- save_item(NAME(m_lcd.framerate));
- save_item(NAME(m_lcd.hpos_min));
- save_item(NAME(m_lcd.hpos_max));
- save_item(NAME(m_lcd.hpos_end));
- save_item(NAME(m_lcd.vpos_min));
- save_item(NAME(m_lcd.vpos_max));
- save_item(NAME(m_lcd.vpos_end));
- save_item(NAME(m_lcd.frame_time));
-
- machine().save().register_postload(save_prepost_delegate(FUNC(s3c44b0_device::s3c44b0_postload), this));
-
- for (int i = 0; i < 2; i++)
- {
- save_item(NAME(m_zdma[i].regs.dcon), i);
- save_item(NAME(m_zdma[i].regs.disrc), i);
- save_item(NAME(m_zdma[i].regs.didst), i);
- save_item(NAME(m_zdma[i].regs.dicnt), i);
- save_item(NAME(m_zdma[i].regs.dcsrc), i);
- save_item(NAME(m_zdma[i].regs.dcdst), i);
- save_item(NAME(m_zdma[i].regs.dccnt), i);
-
- save_item(NAME(m_bdma[i].regs.dcon), i);
- save_item(NAME(m_bdma[i].regs.disrc), i);
- save_item(NAME(m_bdma[i].regs.didst), i);
- save_item(NAME(m_bdma[i].regs.dicnt), i);
- save_item(NAME(m_bdma[i].regs.dcsrc), i);
- save_item(NAME(m_bdma[i].regs.dcdst), i);
- save_item(NAME(m_bdma[i].regs.dccnt), i);
-
- save_item(NAME(m_uart[i].regs.ulcon), i);
- save_item(NAME(m_uart[i].regs.ucon), i);
- save_item(NAME(m_uart[i].regs.ufcon), i);
- save_item(NAME(m_uart[i].regs.umcon), i);
- save_item(NAME(m_uart[i].regs.utrstat), i);
- save_item(NAME(m_uart[i].regs.uerstat), i);
- save_item(NAME(m_uart[i].regs.ufstat), i);
- save_item(NAME(m_uart[i].regs.umstat), i);
- save_item(NAME(m_uart[i].regs.utxh), i);
- save_item(NAME(m_uart[i].regs.urxh), i);
- save_item(NAME(m_uart[i].regs.ubrdiv), i);
- }
-
- save_item(NAME(m_sio.regs.siocon));
- save_item(NAME(m_sio.regs.siodat));
- save_item(NAME(m_sio.regs.sbrdr));
- save_item(NAME(m_sio.regs.itvcnt));
- save_item(NAME(m_sio.regs.dcntz));
-
- save_item(NAME(m_pwm.regs.tcfg0));
- save_item(NAME(m_pwm.regs.tcfg1));
- save_item(NAME(m_pwm.regs.tcon));
- save_item(NAME(m_pwm.regs.tcntb0));
- save_item(NAME(m_pwm.regs.tcmpb0));
- save_item(NAME(m_pwm.regs.tcnto0));
- save_item(NAME(m_pwm.regs.tcntb1));
- save_item(NAME(m_pwm.regs.tcmpb1));
- save_item(NAME(m_pwm.regs.tcnto1));
- save_item(NAME(m_pwm.regs.tcntb2));
- save_item(NAME(m_pwm.regs.tcmpb2));
- save_item(NAME(m_pwm.regs.tcnto2));
- save_item(NAME(m_pwm.regs.tcntb3));
- save_item(NAME(m_pwm.regs.tcmpb3));
- save_item(NAME(m_pwm.regs.tcnto3));
- save_item(NAME(m_pwm.regs.tcntb4));
- save_item(NAME(m_pwm.regs.tcmpb4));
- save_item(NAME(m_pwm.regs.tcnto4));
- save_item(NAME(m_pwm.regs.tcntb5));
- save_item(NAME(m_pwm.regs.tcnto5));
- save_item(NAME(m_pwm.cnt));
- save_item(NAME(m_pwm.cmp));
- save_item(NAME(m_pwm.freq));
-
- save_item(NAME(m_wdt.regs.wtcon));
- save_item(NAME(m_wdt.regs.wtdat));
- save_item(NAME(m_wdt.regs.wtcnt));
-
- save_item(NAME(m_iic.regs.iiccon));
- save_item(NAME(m_iic.regs.iicstat));
- save_item(NAME(m_iic.regs.iicadd));
- save_item(NAME(m_iic.regs.iicds));
- save_item(NAME(m_iic.count));
-
- save_item(NAME(m_iis.regs.iiscon));
- save_item(NAME(m_iis.regs.iismod));
- save_item(NAME(m_iis.regs.iispsr));
- save_item(NAME(m_iis.regs.iisfcon));
- save_item(NAME(m_iis.regs.iisfifo));
- save_item(NAME(m_iis.fifo));
- save_item(NAME(m_iis.fifo_index));
-
- save_item(NAME(m_gpio.regs.gpacon));
- save_item(NAME(m_gpio.regs.gpadat));
- save_item(NAME(m_gpio.regs.gpbcon));
- save_item(NAME(m_gpio.regs.gpbdat));
- save_item(NAME(m_gpio.regs.gpccon));
- save_item(NAME(m_gpio.regs.gpcdat));
- save_item(NAME(m_gpio.regs.gpcup));
- save_item(NAME(m_gpio.regs.gpdcon));
- save_item(NAME(m_gpio.regs.gpddat));
- save_item(NAME(m_gpio.regs.gpdup));
- save_item(NAME(m_gpio.regs.gpecon));
- save_item(NAME(m_gpio.regs.gpedat));
- save_item(NAME(m_gpio.regs.gpeup));
- save_item(NAME(m_gpio.regs.gpfcon));
- save_item(NAME(m_gpio.regs.gpfdat));
- save_item(NAME(m_gpio.regs.gpfup));
- save_item(NAME(m_gpio.regs.gpgcon));
- save_item(NAME(m_gpio.regs.gpgdat));
- save_item(NAME(m_gpio.regs.gpgup));
- save_item(NAME(m_gpio.regs.spucr));
- save_item(NAME(m_gpio.regs.extint));
- save_item(NAME(m_gpio.regs.extintpnd));
-
- save_item(NAME(m_adc.regs.adccon));
- save_item(NAME(m_adc.regs.adcpsr));
- save_item(NAME(m_adc.regs.adcdat));
-
- save_item(NAME(m_cpuwrap.regs.syscfg));
- save_item(NAME(m_cpuwrap.regs.ncachbe0));
- save_item(NAME(m_cpuwrap.regs.ncachbe1));
-}
-
-
-void s3c44b0_device::s3c44b0_postload()
-{
- m_lcd.frame_period = HZ_TO_ATTOSECONDS(m_lcd.framerate);
- m_lcd.scantime = m_lcd.frame_period / m_lcd.vpos_end;
- m_lcd.pixeltime = m_lcd.frame_period / (m_lcd.vpos_end * m_lcd.hpos_end);
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void s3c44b0_device::device_reset()
-{
- m_iis.fifo_index = 0;
- // m_iic.data_index = 0;
-#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
- m_gpio.regs.gstatus2 = 0x00000001; // Boot is caused by power on reset
-#endif
- m_irq.line_irq = m_irq.line_fiq = CLEAR_LINE;
-}
-
-
-/*******************************************************************************
- MACROS & CONSTANTS
-*******************************************************************************/
-
-#define UART_PRINTF
-
-#define CLOCK_MULTIPLIER 1
-
-#define BIT(x,n) (((x)>>(n))&1)
-#define BITS(x,m,n) (((x)>>(n))&(((UINT32)1<<((m)-(n)+1))-1))
-#define CLR_BITS(x,m,n) ((x) & ~((((UINT32)1 << ((m) - (n) + 1)) - 1) << n))
-
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-/* LCD Controller */
-
-rgb_t s3c44b0_device::lcd_get_color_stn_04(UINT8 data)
-{
- UINT8 r, g, b;
- r = g = b = BITS(data, 3, 0) << 4;
- return rgb_t(r, g, b);
-}
-
-UINT8 s3c44b0_device::lcd_get_color_stn_08_r(UINT8 data)
-{
- return ((m_lcd.regs.redlut >> (BITS(data, 7, 5) << 2)) & 0xf) << 4;
-}
-
-UINT8 s3c44b0_device::lcd_get_color_stn_08_g(UINT8 data)
-{
- return ((m_lcd.regs.greenlut >> (BITS(data, 4, 2) << 2)) & 0xf) << 4;
-}
-
-UINT8 s3c44b0_device::lcd_get_color_stn_08_b(UINT8 data)
-{
- return ((m_lcd.regs.bluelut >> (BITS(data, 1, 0) << 2)) & 0xf) << 4;
-}
-
-void s3c44b0_device::lcd_dma_reload()
-{
- int lcdbank, lcdbaseu, lcdbasel;
- lcdbank = BITS(m_lcd.regs.lcdsaddr1, 26, 21);
- lcdbaseu = BITS(m_lcd.regs.lcdsaddr1, 20, 0);
- lcdbasel = BITS(m_lcd.regs.lcdsaddr2, 20, 0);
-
- m_lcd.vramaddr_cur = (lcdbank << 22) | (lcdbaseu << 1);
- m_lcd.vramaddr_max = (lcdbank << 22) | (lcdbasel << 1);
- if (lcdbasel == 0) m_lcd.vramaddr_max += 1 << 22;
- m_lcd.offsize = BITS(m_lcd.regs.lcdsaddr3, 19, 9);
- m_lcd.pagewidth_cur = 0;
- m_lcd.pagewidth_max = BITS(m_lcd.regs.lcdsaddr3, 8, 0);
- m_lcd.bswp = BIT(m_lcd.regs.lcdsaddr2, 29); // note: juicebox changes bswp when video playback starts
-// verboselog(machine(), 3, "LCD - vramaddr %08X %08X offsize %08X pagewidth %08X\n", m_lcd.vramaddr_cur, m_lcd.vramaddr_max, m_lcd.offsize, m_lcd.pagewidth_max);
-}
-
-void s3c44b0_device::lcd_dma_init()
-{
- m_lcd.modesel = BITS(m_lcd.regs.lcdsaddr1, 28, 27);
-// verboselog(machine(), 3, "LCD - modesel %d bswp %d\n", m_lcd.modesel, m_lcd.bswp);
- lcd_dma_reload();
-}
-
-void s3c44b0_device::lcd_dma_read(int count, UINT8 *data)
-{
- address_space &space = m_cpu->space(AS_PROGRAM);
- UINT8 *vram = (UINT8 *)space.get_read_ptr(m_lcd.vramaddr_cur);
- for (int i = 0; i < count / 2; i++)
- {
- if (m_lcd.bswp == 0)
- {
- if ((m_lcd.vramaddr_cur & 2) == 0)
- {
- data[0] = *(vram + 3);
- data[1] = *(vram + 2);
- }
- else
- {
- data[0] = *(vram - 1);
- data[1] = *(vram - 2);
- }
- }
- else
- {
- data[0] = *(vram + 0);
- data[1] = *(vram + 1);
- }
- m_lcd.vramaddr_cur += 2;
- m_lcd.pagewidth_cur++;
- if (m_lcd.pagewidth_cur >= m_lcd.pagewidth_max)
- {
- m_lcd.vramaddr_cur += m_lcd.offsize << 1;
- if (m_lcd.vramaddr_cur >= m_lcd.vramaddr_max)
- {
- lcd_dma_reload();
- }
- m_lcd.pagewidth_cur = 0;
- vram = (UINT8 *)space.get_read_ptr(m_lcd.vramaddr_cur);
- }
- else
- {
- vram += 2;
- }
- data += 2;
- }
-}
-
-void s3c44b0_device::lcd_render_stn_04()
-{
- UINT8 *bitmap = m_lcd.bitmap + ((m_lcd.vpos - m_lcd.vpos_min) * (m_lcd.hpos_max - m_lcd.hpos_min + 1)) + (m_lcd.hpos - m_lcd.hpos_min);
- UINT8 data[16];
- lcd_dma_read(16, data);
- for (int i = 0; i < 16; i++)
- {
- for (int j = 0; j < 2; j++)
- {
- *bitmap++ = lcd_get_color_stn_04((data[i] >> 4) & 0x0F);
- data[i] = data[i] << 4;
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max << 2))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max)
- {
- m_lcd.vpos = m_lcd.vpos_min;
- bitmap = m_lcd.bitmap;
- }
- m_lcd.hpos = m_lcd.hpos_min;
- }
- }
- }
-}
-
-void s3c44b0_device::lcd_render_stn_08()
-{
- UINT8 *bitmap = m_lcd.bitmap + ((m_lcd.vpos - m_lcd.vpos_min) * (m_lcd.hpos_max - m_lcd.hpos_min + 1)) + (m_lcd.hpos - m_lcd.hpos_min);
- UINT8 data[16];
- lcd_dma_read(16, data);
- for (int i = 0; i < 16; i++)
- {
- UINT8 xxx[3];
- xxx[0] = lcd_get_color_stn_08_r(data[i]);
- xxx[1] = lcd_get_color_stn_08_g(data[i]);
- xxx[2] = lcd_get_color_stn_08_b(data[i]);
- for (int j = 0; j < 3; j++)
- {
- *bitmap++ = xxx[j];
- m_lcd.hpos++;
- if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max * 6))
- {
- m_lcd.vpos++;
- if (m_lcd.vpos > m_lcd.vpos_max)
- {
- m_lcd.vpos = m_lcd.vpos_min;
- bitmap = m_lcd.bitmap;
- }
- m_lcd.hpos = m_lcd.hpos_min;
- }
- }
- }
-}
-
-attotime s3c44b0_device::time_until_pos(int vpos, int hpos)
-{
- attoseconds_t time1, time2;
- attotime retval;
- verboselog(machine(), 3, "s3c44b0_time_until_pos - vpos %d hpos %d\n", vpos, hpos);
- time1 = (attoseconds_t)vpos * m_lcd.scantime + (attoseconds_t)hpos * m_lcd.pixeltime;
- time2 = (machine().time() - m_lcd.frame_time).as_attoseconds();
- verboselog(machine(), 3, "machine %f frametime %f time1 %f time2 %f\n", machine().time().as_double(), m_lcd.frame_time.as_double(), attotime(0, time1).as_double(), attotime(0, time2).as_double());
- while (time1 <= time2) time1 += m_lcd.frame_period;
- retval = attotime( 0, time1 - time2);
- verboselog(machine(), 3, "result %f\n", retval.as_double());
- return retval;
-}
-
-int s3c44b0_device::lcd_get_vpos()
-{
- attoseconds_t delta;
- int vpos;
- delta = (machine().time() - m_lcd.frame_time).as_attoseconds();
- delta = delta + (m_lcd.pixeltime / 2);
- vpos = delta / m_lcd.scantime;
- return (m_lcd.vpos_min + vpos) % m_lcd.vpos_end;
-}
-
-int s3c44b0_device::lcd_get_hpos()
-{
- attoseconds_t delta;
- int vpos;
- delta = (machine().time() - m_lcd.frame_time).as_attoseconds();
- delta = delta + (m_lcd.pixeltime / 2);
- vpos = delta / m_lcd.scantime;
- delta = delta - (vpos * m_lcd.scantime);
- return delta / m_lcd.pixeltime;
-}
-
-TIMER_CALLBACK_MEMBER( s3c44b0_device::lcd_timer_exp )
-{
- int vpos = m_lcd.vpos;
- verboselog(machine(), 2, "LCD timer callback (%f)\n", machine().time().as_double());
- verboselog(machine(), 3, "LCD - (1) vramaddr %08X vpos %d hpos %d\n", m_lcd.vramaddr_cur, m_lcd.vpos, m_lcd.hpos);
- switch (m_lcd.modesel)
- {
- case S3C44B0_MODESEL_04 : lcd_render_stn_04(); break;
- case S3C44B0_MODESEL_08 : lcd_render_stn_08(); break;
- default : verboselog(machine(), 0, "s3c44b0_lcd_timer_exp: modesel %d not supported\n", m_lcd.modesel); break;
- }
- verboselog(machine(), 3, "LCD - (2) vramaddr %08X vpos %d hpos %d\n", m_lcd.vramaddr_cur, m_lcd.vpos, m_lcd.hpos);
- if (m_lcd.vpos < vpos)
- {
-// verboselog(machine(), 3, "LCD - (1) frame_time %f\n", attotime_to_double(m_lcd.frame_time));
- m_lcd.frame_time = machine().time() + time_until_pos(m_lcd.vpos_min, m_lcd.hpos_min);
-// verboselog(machine(), 3, "LCD - (2) frame_time %f\n", attotime_to_double(m_lcd.frame_time));
- }
- m_lcd.timer->adjust(time_until_pos(m_lcd.vpos, m_lcd.hpos), 0);
-}
-
-void s3c44b0_device::video_start()
-{
- // do nothing
-}
-
-UINT32 s3c44b0_device::video_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
-{
- if (m_lcd.regs.lcdcon1 & (1 << 0))
- {
- if (m_lcd.bitmap)
- {
- for (int y = 0; y < screen.height(); y++)
- {
- UINT32 *scanline = &bitmap.pix32(y);
- UINT8 *vram = m_lcd.bitmap + y * (m_lcd.hpos_max - m_lcd.hpos_min + 1);
- for (int x = 0; x < screen.width(); x++)
- {
- *scanline++ = rgb_t(vram[0], vram[1], vram[2]);
- vram += 3;
- }
- }
- }
- }
- else
- {
- for (int y = 0; y < screen.height(); y++)
- {
- UINT32 *scanline = &bitmap.pix32(y);
- memset(scanline, 0, screen.width() * 4);
- }
- }
- return 0;
-}
-
-READ32_MEMBER( s3c44b0_device::lcd_r )
-{
- UINT32 data = ((UINT32*)&m_lcd.regs)[offset];
- switch (offset)
- {
- case S3C44B0_LCDCON1 :
- {
- int vpos = 0;
- // make sure line counter is going
- if (m_lcd.regs.lcdcon1 & (1 << 0))
- {
- vpos = lcd_get_vpos();
- int hpos = lcd_get_hpos();
- if (hpos < m_lcd.hpos_min) vpos = vpos - 1;
- if ((vpos < m_lcd.vpos_min) || (vpos > m_lcd.vpos_max)) vpos = m_lcd.vpos_max;
- vpos = m_lcd.vpos_max - vpos;
- }
- data = (data & ~0xFFC00000) | (vpos << 22);
- }
- break;
- }
-// verboselog(machine(), 9, "(LCD) %08X -> %08X\n", S3C44B0_BASE_LCD + (offset << 2), data);
- return data;
-}
-
-void s3c44b0_device::lcd_configure()
-{
- screen_device *screen = machine().first_screen();
- int dismode, clkval, lineval, wdly, hozval, lineblank, wlh, mclk;
- double vclk, framerate;
- int width, height;
- verboselog(machine(), 5, "s3c44b0_lcd_configure\n");
- dismode = BITS(m_lcd.regs.lcdcon1, 6, 5);
- clkval = BITS(m_lcd.regs.lcdcon1, 21, 12);
- lineval = BITS(m_lcd.regs.lcdcon2, 9, 0);
- wdly = BITS(m_lcd.regs.lcdcon1, 9, 8);
- hozval = BITS(m_lcd.regs.lcdcon2, 20, 10);
- lineblank = BITS(m_lcd.regs.lcdcon2, 31, 21);
- wlh = BITS(m_lcd.regs.lcdcon1, 11, 10);
- mclk = get_mclk();
- verboselog(machine(), 3, "LCD - dismode %d clkval %d lineval %d wdly %d hozval %d lineblank %d wlh %d mclk %d\n", dismode, clkval, lineval, wdly, hozval, lineblank, wlh, mclk);
- vclk = (double)(mclk / (clkval * 2));
- verboselog(machine(), 3, "LCD - vclk %f\n", vclk);
- framerate = 1 / (((1 / vclk) * (hozval + 1) + (1 / mclk) * (wlh + wdly + lineblank)) * (lineval + 1));
- framerate = framerate / 3; // ???
- verboselog(machine(), 3, "LCD - framerate %f\n", framerate);
- switch (dismode)
- {
- case S3C44B0_PNRMODE_STN_04_SS : width = ((hozval + 1) * 4); break;
- case S3C44B0_PNRMODE_STN_04_DS : width = ((hozval + 1) * 4); break;
- case S3C44B0_PNRMODE_STN_08_SS : width = ((hozval + 1) * 8); break;
- default : fatalerror("invalid display mode (%d)\n", dismode);
- }
- height = lineval + 1;
- m_lcd.framerate = framerate;
- verboselog(machine(), 3, "video_screen_configure %d %d %f\n", width, height, m_lcd.framerate);
- screen->configure(screen->width(), screen->height(), screen->visible_area(), HZ_TO_ATTOSECONDS(m_lcd.framerate));
- m_lcd.hpos_min = 25;
- m_lcd.hpos_max = 25 + width - 1;
- m_lcd.hpos_end = 25 + width - 1 + 25;
- m_lcd.vpos_min = 25;
- m_lcd.vpos_max = 25 + height - 1;
- m_lcd.vpos_end = 25 + height - 1 + 25;
- verboselog(machine(), 3, "LCD - min_x %d min_y %d max_x %d max_y %d\n", m_lcd.hpos_min, m_lcd.vpos_min, m_lcd.hpos_max, m_lcd.vpos_max);
- if (m_lcd.bitmap)
- {
- auto_free(machine(), m_lcd.bitmap);
- }
- m_lcd.bitmap = auto_alloc_array(machine(), UINT8, (m_lcd.hpos_max - m_lcd.hpos_min + 1) * (m_lcd.vpos_max - m_lcd.vpos_min + 1) * 3);
- m_lcd.frame_period = HZ_TO_ATTOSECONDS(m_lcd.framerate);
- m_lcd.scantime = m_lcd.frame_period / m_lcd.vpos_end;
- m_lcd.pixeltime = m_lcd.frame_period / (m_lcd.vpos_end * m_lcd.hpos_end);
-// printf("frame_period %f\n", attotime( 0, m_lcd.frame_period).as_double());
-// printf("scantime %f\n", attotime( 0, m_lcd.scantime).as_double());
-// printf("pixeltime %f\n", attotime( 0, m_lcd.pixeltime).as_double());
-}
-
-
-void s3c44b0_device::lcd_start()
-{
- screen_device *screen = machine().first_screen();
- verboselog(machine(), 1, "LCD start\n");
- lcd_configure();
- lcd_dma_init();
- m_lcd.vpos = m_lcd.vpos_min;
- m_lcd.hpos = m_lcd.hpos_min;
- m_lcd.frame_time = screen->time_until_pos( 0, 0);
- m_lcd.timer->adjust(m_lcd.frame_time, 0);
- m_lcd.frame_time = machine().time() + m_lcd.frame_time;
-}
-
-void s3c44b0_device::lcd_stop()
-{
- verboselog(machine(), 1, "LCD stop\n");
- m_lcd.timer->adjust(attotime::never, 0);
-}
-
-void s3c44b0_device::lcd_recalc()
-{
- if (m_lcd.regs.lcdcon1 & (1 << 0))
- lcd_start();
- else
- lcd_stop();
-}
-
-WRITE32_MEMBER( s3c44b0_device::lcd_w )
-{
- UINT32 old_value = ((UINT32*)&m_lcd.regs)[offset];
-// verboselog(machine(), 9, "(LCD) %08X <- %08X\n", S3C44B0_BASE_LCD + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_lcd.regs)[offset]);
- switch (offset)
- {
- case S3C44B0_LCDCON1 :
- {
- if ((old_value & (1 << 0)) != (data & (1 << 0)))
- {
- lcd_recalc();
- }
- }
- break;
- }
-}
-
-
-/* Clock & Power Management */
-
-UINT32 s3c44b0_device::get_mclk()
-{
- UINT32 data, mdiv, pdiv, sdiv;
- data = m_clkpow.regs.pllcon;
- mdiv = BITS(data, 19, 12);
- pdiv = BITS(data, 9, 4);
- sdiv = BITS(data, 1, 0);
- return (UINT32)((double)((mdiv + 8) * clock()) / (double)((pdiv + 2) * (1 << sdiv)));
-}
-
-READ32_MEMBER( s3c44b0_device::clkpow_r )
-{
- UINT32 data = ((UINT32*)&m_clkpow.regs)[offset];
- verboselog(machine(), 9, "(CLKPOW) %08X -> %08X\n", S3C44B0_BASE_CLKPOW + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( s3c44b0_device::clkpow_w )
-{
- verboselog(machine(), 9, "(CLKPOW) %08X <- %08X\n", S3C44B0_BASE_CLKPOW + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_clkpow.regs)[offset]);
- switch (offset)
- {
- case S3C44B0_PLLCON :
- {
- verboselog(machine(), 5, "CLKPOW - mclk %d\n", get_mclk());
- m_cpu->set_unscaled_clock(get_mclk() * CLOCK_MULTIPLIER);
- }
- break;
- case S3C44B0_CLKCON :
- {
- if (data & (1 << 2))
- {
- m_cpu->spin_until_interrupt();
- }
- }
- break;
- }
-}
-
-/* Interrupt Controller */
-
-void s3c44b0_device::check_pending_irq()
-{
- // normal irq
- UINT32 temp = (m_irq.regs.intpnd & ~m_irq.regs.intmsk) & ~m_irq.regs.intmod;
-
- if (temp != 0)
- {
- UINT32 int_type = 0;
- while ((temp & 1) == 0)
- {
- int_type++;
- temp = temp >> 1;
- }
- m_irq.regs.i_ispr |= (1 << int_type);
- if (m_irq.line_irq != ASSERT_LINE)
- {
- m_cpu->set_input_line(ARM7_IRQ_LINE, ASSERT_LINE);
- m_irq.line_irq = ASSERT_LINE;
- }
- }
- else
- {
- if (m_irq.line_irq != CLEAR_LINE)
- {
- m_cpu->set_input_line(ARM7_IRQ_LINE, CLEAR_LINE);
- m_irq.line_irq = CLEAR_LINE;
- }
- }
- // fast irq
- temp = (m_irq.regs.intpnd & ~m_irq.regs.intmsk) & m_irq.regs.intmod;
- if (temp != 0)
- {
- UINT32 int_type = 0;
- while ((temp & 1) == 0)
- {
- int_type++;
- temp = temp >> 1;
- }
- if (m_irq.line_fiq != ASSERT_LINE)
- {
- m_cpu->set_input_line(ARM7_FIRQ_LINE, ASSERT_LINE);
- m_irq.line_fiq = ASSERT_LINE;
- }
- }
- else
- {
- if (m_irq.line_fiq != CLEAR_LINE)
- {
- m_cpu->set_input_line(ARM7_FIRQ_LINE, CLEAR_LINE);
- m_irq.line_fiq = CLEAR_LINE;
- }
- }
-}
-
-void s3c44b0_device::request_irq(UINT32 int_type)
-{
- verboselog(machine(), 5, "request irq %d\n", int_type);
- m_irq.regs.intpnd |= (1 << int_type);
- check_pending_irq();
-}
-
-void s3c44b0_device::check_pending_eint()
-{
- UINT32 temp = m_gpio.regs.extintpnd;
- if (temp != 0)
- {
- UINT32 int_type = 0;
- while ((temp & 1) == 0)
- {
- int_type++;
- temp = temp >> 1;
- }
- request_irq(S3C44B0_INT_EINT4_7);
- }
-}
-
-void s3c44b0_device::request_eint(UINT32 number)
-{
- verboselog(machine(), 5, "request external interrupt %d\n", number);
- if (number < 4)
- {
- request_irq(S3C44B0_INT_EINT0 + number);
- }
- else
- {
- m_gpio.regs.extintpnd |= (1 << (number - 4));
- check_pending_eint();
- }
-}
-
-READ32_MEMBER( s3c44b0_device::irq_r )
-{
- UINT32 data = ((UINT32*)&m_irq.regs)[offset];
- verboselog(machine(), 9, "(IRQ) %08X -> %08X\n", S3C44B0_BASE_INT + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( s3c44b0_device::irq_w )
-{
- verboselog(machine(), 9, "(IRQ) %08X <- %08X\n", S3C44B0_BASE_INT + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_irq.regs)[offset]);
- switch (offset)
- {
- case S3C44B0_INTMSK :
- {
- check_pending_irq();
- }
- break;
- case S3C44B0_I_ISPC :
- {
- m_irq.regs.intpnd = (m_irq.regs.intpnd & ~data); // The bit of INTPND bit is cleared to zero by writing '1' on I_ISPC/F_ISPC
- m_irq.regs.i_ispr = (m_irq.regs.i_ispr & ~data); // The pending bit in I_ISPR register should be cleared by writing I_ISPC register.
- check_pending_irq();
- }
- break;
- case S3C44B0_F_ISPC :
- {
- m_irq.regs.intpnd = (m_irq.regs.intpnd & ~data); // The bit of INTPND bit is cleared to zero by writing '1' on I_ISPC/F_ISPC
- check_pending_irq();
- }
- break;
- }
-}
-
-/* PWM Timer */
-
-UINT16 s3c44b0_device::pwm_calc_observation(int ch)
-{
- double timeleft, x1, x2;
- UINT32 cnto;
- timeleft = (m_pwm.timer[ch]->remaining()).as_double();
-// printf( "timeleft %f freq %d cntb %d cmpb %d\n", timeleft, m_pwm.freq[ch], m_pwm.cnt[ch], m_pwm.cmp[ch]);
- x1 = 1 / ((double)m_pwm.freq[ch] / (m_pwm.cnt[ch]- m_pwm.cmp[ch] + 1));
- x2 = x1 / timeleft;
-// printf( "x1 %f\n", x1);
- cnto = m_pwm.cmp[ch] + ((m_pwm.cnt[ch]- m_pwm.cmp[ch]) / x2);
-// printf( "cnto %d\n", cnto);
- return cnto;
-}
-
-READ32_MEMBER( s3c44b0_device::pwm_r )
-{
- UINT32 data = ((UINT32*)&m_pwm.regs)[offset];
- switch (offset)
- {
- case S3C44B0_TCNTO0 :
- {
- data = (data & ~0x0000FFFF) | pwm_calc_observation(0);
- }
- break;
- case S3C44B0_TCNTO1 :
- {
- data = (data & ~0x0000FFFF) | pwm_calc_observation(1);
- }
- break;
- case S3C44B0_TCNTO2 :
- {
- data = (data & ~0x0000FFFF) | pwm_calc_observation(2);
- }
- break;
- case S3C44B0_TCNTO3 :
- {
- data = (data & ~0x0000FFFF) | pwm_calc_observation(3);
- }
- break;
- case S3C44B0_TCNTO4 :
- {
- data = (data & ~0x0000FFFF) | pwm_calc_observation(4);
- }
- break;
- case S3C44B0_TCNTO5 :
- {
- data = (data & ~0x0000FFFF) | pwm_calc_observation(5);
- }
- break;
- }
- verboselog(machine(), 9, "(PWM) %08X -> %08X\n", S3C44B0_BASE_PWM + (offset << 2), data);
- return data;
-}
-
-void s3c44b0_device::pwm_start(int timer)
-{
- const int mux_table[] = { 2, 4, 8, 16};
- const int prescaler_shift[] = { 0, 0, 8, 8, 16, 16};
- const int mux_shift[] = { 0, 4, 8, 12, 16, 20};
- UINT32 mclk, prescaler, mux, cnt, cmp, auto_reload;
- double freq, hz;
- verboselog(machine(), 1, "PWM %d start\n", timer);
- mclk = get_mclk();
- prescaler = (m_pwm.regs.tcfg0 >> prescaler_shift[timer]) & 0xFF;
- mux = (m_pwm.regs.tcfg1 >> mux_shift[timer]) & 0x0F;
- if (mux < 4)
- {
- freq = (double)mclk / (prescaler + 1) / mux_table[mux];
- }
- else
- {
- // todo
- freq = (double)mclk / (prescaler + 1) / 1;
- }
- switch (timer)
- {
- case 0 :
- {
- cnt = BITS(m_pwm.regs.tcntb0, 15, 0);
- cmp = BITS(m_pwm.regs.tcmpb0, 15, 0);
- auto_reload = BIT(m_pwm.regs.tcon, 3);
- }
- break;
- case 1 :
- {
- cnt = BITS(m_pwm.regs.tcntb1, 15, 0);
- cmp = BITS(m_pwm.regs.tcmpb1, 15, 0);
- auto_reload = BIT(m_pwm.regs.tcon, 11);
- }
- break;
- case 2 :
- {
- cnt = BITS(m_pwm.regs.tcntb2, 15, 0);
- cmp = BITS(m_pwm.regs.tcmpb2, 15, 0);
- auto_reload = BIT(m_pwm.regs.tcon, 15);
- }
- break;
- case 3 :
- {
- cnt = BITS(m_pwm.regs.tcntb3, 15, 0);
- cmp = BITS(m_pwm.regs.tcmpb3, 15, 0);
- auto_reload = BIT(m_pwm.regs.tcon, 19);
- }
- break;
- case 4 :
- {
- cnt = BITS(m_pwm.regs.tcntb4, 15, 0);
- cmp = BITS(m_pwm.regs.tcmpb4, 15, 0);
- auto_reload = BIT(m_pwm.regs.tcon, 23);
- }
- break;
- case 5 :
- {
- cnt = BITS(m_pwm.regs.tcntb5, 15, 0);
- cmp = 0;
- auto_reload = BIT(m_pwm.regs.tcon, 26);
- }
- break;
- default :
- {
- cnt = cmp = auto_reload = 0;
- }
- break;
- }
-// hz = freq / (cnt - cmp + 1);
- if (cnt < 2)
- {
- hz = freq;
- }
- else
- {
- hz = freq / cnt;
- }
- verboselog(machine(), 5, "PWM %d - mclk=%d prescaler=%d div=%d freq=%f cnt=%d cmp=%d auto_reload=%d hz=%f\n", timer, mclk, prescaler, mux_table[mux], freq, cnt, cmp, auto_reload, hz);
- m_pwm.cnt[timer] = cnt;
- m_pwm.cmp[timer] = cmp;
- m_pwm.freq[timer] = freq;
- if (cnt == 0)
- {
- m_pwm.timer[timer]->adjust(attotime::never, 0);
- }
- else
- {
- if (auto_reload)
- {
- m_pwm.timer[timer]->adjust(attotime::from_hz(hz), timer, attotime::from_hz(hz));
- }
- else
- {
- m_pwm.timer[timer]->adjust(attotime::from_hz(hz), timer);
- }
- }
-}
-
-void s3c44b0_device::pwm_stop(int timer)
-{
- verboselog(machine(), 1, "PWM %d stop\n", timer);
- m_pwm.timer[timer]->adjust(attotime::never, 0);
-}
-
-void s3c44b0_device::pwm_recalc(int timer)
-{
- const int tcon_shift[] = { 0, 8, 12, 16, 20, 24};
- if (m_pwm.regs.tcon & (1 << tcon_shift[timer]))
- pwm_start(timer);
- else
- pwm_stop(timer);
-}
-
-WRITE32_MEMBER( s3c44b0_device::pwm_w )
-{
- UINT32 old_value = ((UINT32*)&m_pwm.regs)[offset];
- verboselog(machine(), 9, "(PWM) %08X <- %08X\n", S3C44B0_BASE_PWM + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_pwm.regs)[offset]);
- switch (offset)
- {
- case S3C44B0_TCON :
- {
- if ((data & (1 << 0)) != (old_value & (1 << 0)))
- {
- pwm_recalc(0);
- }
- if ((data & (1 << 8)) != (old_value & (1 << 8)))
- {
- pwm_recalc(1);
- }
- if ((data & (1 << 12)) != (old_value & (1 << 12)))
- {
- pwm_recalc(2);
- }
- if ((data & (1 << 16)) != (old_value & (1 << 16)))
- {
- pwm_recalc(3);
- }
- if ((data & (1 << 20)) != (old_value & (1 << 20)))
- {
- pwm_recalc(4);
- }
- if ((data & (1 << 24)) != (old_value & (1 << 24)))
- {
- pwm_recalc(5);
- }
- }
- break;
- }
-}
-
-TIMER_CALLBACK_MEMBER( s3c44b0_device::pwm_timer_exp )
-{
- int ch = param;
- const int ch_int[] = { S3C44B0_INT_TIMER0, S3C44B0_INT_TIMER1, S3C44B0_INT_TIMER2, S3C44B0_INT_TIMER3, S3C44B0_INT_TIMER4, S3C44B0_INT_TIMER5 };
- verboselog(machine(), 2, "PWM %d timer callback\n", ch);
- if (BITS(m_pwm.regs.tcfg1, 27, 24) == (ch + 1))
- {
- fatalerror("s3c44b0_dma_request_pwm( device)\n");
- }
- else
- {
- request_irq(ch_int[ch]);
- }
-}
-
-/* IIC */
-
-inline void s3c44b0_device::iface_i2c_scl_w(int state)
-{
- if (!m_scl_w_cb.isnull())
- (m_scl_w_cb)( state);
-}
-
-inline void s3c44b0_device::iface_i2c_sda_w(int state)
-{
- if (!m_sda_w_cb.isnull())
- (m_sda_w_cb)( state);
-}
-
-inline int s3c44b0_device::iface_i2c_sda_r()
-{
- if (!m_sda_r_cb.isnull())
- return (m_sda_r_cb)();
- else
- return 0;
-}
-
-void s3c44b0_device::i2c_send_start()
-{
- verboselog(machine(), 5, "i2c_send_start\n");
- iface_i2c_sda_w(1);
- iface_i2c_scl_w(1);
- iface_i2c_sda_w(0);
- iface_i2c_scl_w(0);
-}
-
-void s3c44b0_device::i2c_send_stop()
-{
- verboselog(machine(), 5, "i2c_send_stop\n");
- iface_i2c_sda_w(0);
- iface_i2c_scl_w(1);
- iface_i2c_sda_w(1);
- iface_i2c_scl_w(0);
-}
-
-UINT8 s3c44b0_device::i2c_receive_byte(int ack)
-{
- UINT8 data = 0;
- verboselog(machine(), 5, "i2c_receive_byte ...\n");
- iface_i2c_sda_w(1);
- for (int i = 0; i < 8; i++)
- {
- iface_i2c_scl_w(1);
- data = (data << 1) + (iface_i2c_sda_r() ? 1 : 0);
- iface_i2c_scl_w(0);
- }
- verboselog(machine(), 5, "recv data %02X\n", data);
- verboselog(machine(), 5, "send ack %d\n", ack);
- iface_i2c_sda_w(ack ? 0 : 1);
- iface_i2c_scl_w(1);
- iface_i2c_scl_w(0);
- return data;
-}
-
-int s3c44b0_device::i2c_send_byte(UINT8 data)
-{
- int ack;
- verboselog(machine(), 5, "i2c_send_byte ...\n");
- verboselog(machine(), 5, "send data %02X\n", data);
- for (int i = 0; i < 8; i++)
- {
- iface_i2c_sda_w((data & 0x80) ? 1 : 0);
- data = data << 1;
- iface_i2c_scl_w(1);
- iface_i2c_scl_w(0);
- }
- iface_i2c_sda_w(1); // ack bit
- iface_i2c_scl_w(1);
- ack = iface_i2c_sda_r();
- verboselog(machine(), 5, "recv ack %d\n", ack);
- iface_i2c_scl_w(0);
- return ack;
-}
-
-void s3c44b0_device::iic_start()
-{
- int mode_selection;
- verboselog(machine(), 1, "IIC start\n");
- i2c_send_start();
- mode_selection = BITS(m_iic.regs.iicstat, 7, 6);
- switch (mode_selection)
- {
- case 2 : i2c_send_byte(m_iic.regs.iicds | 0x01); break;
- case 3 : i2c_send_byte(m_iic.regs.iicds & 0xFE); break;
- }
- m_iic.timer->adjust(attotime::from_usec( 1), 0);
-}
-
-void s3c44b0_device::iic_stop()
-{
- verboselog(machine(), 1, "IIC stop\n");
- i2c_send_stop();
- m_iic.timer->adjust(attotime::never, 0);
-}
-
-void s3c44b0_device::iic_resume()
-{
- int mode_selection;
- verboselog(machine(), 1, "IIC resume\n");
- mode_selection = BITS(m_iic.regs.iicstat, 7, 6);
- switch (mode_selection)
- {
- case 2 : m_iic.regs.iicds = i2c_receive_byte(BIT(m_iic.regs.iiccon, 7)); break;
- case 3 : i2c_send_byte(m_iic.regs.iicds & 0xFF); break;
- }
- m_iic.timer->adjust(attotime::from_usec( 1), 0);
-}
-
-READ32_MEMBER( s3c44b0_device::iic_r )
-{
- UINT32 data = ((UINT32*)&m_iic.regs)[offset];
- switch (offset)
- {
- case S3C44B0_IICSTAT :
- {
- data = data & ~0x0000000F;
- }
- break;
- }
- verboselog(machine(), 9, "(IIC) %08X -> %08X\n", S3C44B0_BASE_IIC + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( s3c44b0_device::iic_w )
-{
- UINT32 old_value = ((UINT32*)&m_iic.regs)[offset];
- verboselog(machine(), 9, "(IIC) %08X <- %08X\n", S3C44B0_BASE_IIC + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_iic.regs)[offset]);
- switch (offset)
- {
- case S3C44B0_IICCON :
- {
- int interrupt_pending_flag;
-#if 0
- const int div_table[] = { 16, 512};
- int enable_interrupt, transmit_clock_value, tx_clock_source_selection
- double clock;
- transmit_clock_value = (data >> 0) & 0xF;
- tx_clock_source_selection = (data >> 6) & 1;
- enable_interrupt = (data >> 5) & 1;
- clock = (double)get_pclk() / div_table[tx_clock_source_selection] / (transmit_clock_value + 1);
-#endif
- interrupt_pending_flag = BIT(old_value, 4);
- if (interrupt_pending_flag != 0)
- {
- interrupt_pending_flag = BIT(data, 4);
- if (interrupt_pending_flag == 0)
- {
- int start_stop_condition;
- start_stop_condition = BIT(m_iic.regs.iicstat, 5);
- if (start_stop_condition != 0)
- {
- if (m_iic.count == 0)
- {
- iic_start();
-
- }
- else
- {
- iic_resume();
- }
- }
- else
- {
- iic_stop();
- }
- }
- }
- }
- break;
- case S3C44B0_IICSTAT :
- {
- int interrupt_pending_flag;
- m_iic.count = 0;
- interrupt_pending_flag = BIT(m_iic.regs.iiccon, 4);
- if (interrupt_pending_flag == 0)
- {
- int start_stop_condition;
- start_stop_condition = BIT(data, 5);
- if (start_stop_condition != 0)
- {
- if (m_iic.count == 0)
- {
- iic_start();
-
- }
- else
- {
- iic_resume();
- }
- }
- else
- {
- iic_stop();
- }
- }
- }
- break;
- }
-}
-
-TIMER_CALLBACK_MEMBER( s3c44b0_device::iic_timer_exp )
-{
- int enable_interrupt;
- verboselog(machine(), 2, "IIC timer callback\n");
- m_iic.count++;
- enable_interrupt = BIT(m_iic.regs.iiccon, 5);
-
- m_iic.regs.iicds = 0xFF; // TEST
-
- if (enable_interrupt)
- {
- m_iic.regs.iiccon |= (1 << 4); // [bit 4] interrupt is pending
- request_irq(S3C44B0_INT_IIC);
- }
-}
-
-/* I/O Port */
-
-inline UINT32 s3c44b0_device::iface_gpio_port_r(int port)
-{
- if (!m_port_r_cb.isnull())
- return (m_port_r_cb)(port);
- else
- return 0;
-}
-
-inline void s3c44b0_device::iface_gpio_port_w(int port, UINT32 data)
-{
- if (!m_port_w_cb.isnull())
- (m_port_w_cb)(port, data, 0xffff);
-}
-
-READ32_MEMBER( s3c44b0_device::gpio_r )
-{
- UINT32 data = ((UINT32*)&m_gpio.regs)[offset];
- switch (offset)
- {
- case S3C44B0_GPADAT :
- {
- data = iface_gpio_port_r(S3C44B0_GPIO_PORT_A) & S3C44B0_GPADAT_MASK;
- }
- break;
- case S3C44B0_GPBDAT :
- {
- data = iface_gpio_port_r(S3C44B0_GPIO_PORT_B) & S3C44B0_GPBDAT_MASK;
- }
- break;
- case S3C44B0_GPCDAT :
- {
- data = iface_gpio_port_r(S3C44B0_GPIO_PORT_C) & S3C44B0_GPCDAT_MASK;
- }
- break;
- case S3C44B0_GPDDAT :
- {
- data = iface_gpio_port_r(S3C44B0_GPIO_PORT_D) & S3C44B0_GPDDAT_MASK;
- }
- break;
- case S3C44B0_GPEDAT :
- {
- data = iface_gpio_port_r(S3C44B0_GPIO_PORT_E) & S3C44B0_GPEDAT_MASK;
- }
- break;
- case S3C44B0_GPFDAT :
- {
- data = iface_gpio_port_r(S3C44B0_GPIO_PORT_F) & S3C44B0_GPFDAT_MASK;
- }
- break;
- case S3C44B0_GPGDAT :
- {
- data = iface_gpio_port_r(S3C44B0_GPIO_PORT_G) & S3C44B0_GPGDAT_MASK;
- }
- break;
- }
- verboselog(machine(), 9, "(GPIO) %08X -> %08X\n", S3C44B0_BASE_GPIO + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( s3c44b0_device::gpio_w )
-{
- UINT32 old_value = ((UINT32*)&m_gpio.regs)[offset];
- verboselog(machine(), 9, "(GPIO) %08X <- %08X\n", S3C44B0_BASE_GPIO + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_gpio.regs)[offset]);
- switch (offset)
- {
- case S3C44B0_GPADAT :
- {
- iface_gpio_port_w(S3C44B0_GPIO_PORT_A, data & S3C44B0_GPADAT_MASK);
- }
- break;
- case S3C44B0_GPBDAT :
- {
- iface_gpio_port_w(S3C44B0_GPIO_PORT_B, data & S3C44B0_GPBDAT_MASK);
- }
- break;
- case S3C44B0_GPCDAT :
- {
- iface_gpio_port_w(S3C44B0_GPIO_PORT_C, data & S3C44B0_GPCDAT_MASK);
- }
- break;
- case S3C44B0_GPDDAT :
- {
- iface_gpio_port_w(S3C44B0_GPIO_PORT_D, data & S3C44B0_GPDDAT_MASK);
- }
- break;
- case S3C44B0_GPEDAT :
- {
- iface_gpio_port_w(S3C44B0_GPIO_PORT_E, data & S3C44B0_GPEDAT_MASK);
- }
- break;
- case S3C44B0_GPFDAT :
- {
- iface_gpio_port_w(S3C44B0_GPIO_PORT_F, data & S3C44B0_GPFDAT_MASK);
- }
- break;
- case S3C44B0_GPGDAT :
- {
- iface_gpio_port_w(S3C44B0_GPIO_PORT_G, data & S3C44B0_GPGDAT_MASK);
- }
- break;
- case S3C44B0_EXTINTPND :
- {
- m_gpio.regs.extintpnd = (old_value & ~data);
- check_pending_eint();
- }
- break;
- }
-}
-
-/* UART */
-
-UINT32 s3c44b0_device::uart_r(int ch, UINT32 offset)
-{
- UINT32 data = ((UINT32*)&m_uart[ch].regs)[offset];
- switch (offset)
- {
- case S3C44B0_UTRSTAT :
- {
- data = (data & ~0x00000006) | 0x00000004 | 0x00000002; // [bit 2] Transmitter empty / [bit 1] Transmit buffer empty
- }
- break;
- case S3C44B0_URXH :
- {
- UINT8 rxdata = data & 0xFF;
- verboselog(machine(), 5, "UART %d read %02X (%c)\n", ch, rxdata, ((rxdata >= 32) && (rxdata < 128)) ? (char)rxdata : '?');
- m_uart[ch].regs.utrstat &= ~1; // [bit 0] Receive buffer data ready
- }
- break;
- }
- return data;
-}
-
-void s3c44b0_device::uart_w(int ch, UINT32 offset, UINT32 data, UINT32 mem_mask)
-{
- COMBINE_DATA(&((UINT32*)&m_uart[ch].regs)[offset]);
- switch (offset)
- {
- case S3C44B0_UTXH :
- {
- UINT8 txdata = data & 0xFF;
- verboselog(machine(), 5, "UART %d write %02X (%c)\n", ch, txdata, ((txdata >= 32) && (txdata < 128)) ? (char)txdata : '?');
-#ifdef UART_PRINTF
- printf( "%c", ((txdata >= 32) && (txdata < 128)) ? (char)txdata : '?');
-#endif
- }
- break;
- case S3C44B0_UBRDIV :
- {
- UINT32 mclk, hz;
- mclk = get_mclk();
- hz = (mclk / (m_uart->regs.ubrdiv + 1)) / 16;
- verboselog(machine(), 5, "UART %d - mclk %08X hz %08X\n", ch, mclk, hz);
- m_uart->timer->adjust(attotime::from_hz(hz), ch, attotime::from_hz(hz));
- }
- break;
- }
-}
-
-READ32_MEMBER( s3c44b0_device::uart_0_r )
-{
- UINT32 data = uart_r(0, offset);
-// verboselog(machine(), 9, "(UART 0) %08X -> %08X\n", S3C44B0_BASE_UART_0 + (offset << 2), data);
- return data;
-}
-
-READ32_MEMBER( s3c44b0_device::uart_1_r )
-{
- UINT32 data = uart_r(1, offset);
-// verboselog(machine(), 9, "(UART 1) %08X -> %08X\n", S3C44B0_BASE_UART_1 + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( s3c44b0_device::uart_0_w )
-{
- verboselog(machine(), 9, "(UART 0) %08X <- %08X (%08X)\n", S3C44B0_BASE_UART_0 + (offset << 2), data, mem_mask);
- uart_w(0, offset, data, mem_mask);
-}
-
-WRITE32_MEMBER( s3c44b0_device::uart_1_w )
-{
- verboselog(machine(), 9, "(UART 1) %08X <- %08X (%08X)\n", S3C44B0_BASE_UART_1 + (offset << 2), data, mem_mask);
- uart_w(1, offset, data, mem_mask);
-}
-
-void s3c44b0_device::uart_fifo_w(int uart, UINT8 data)
-{
-// printf("s3c44b0_uart_fifo_w (%c)\n", data);
- m_uart[uart].regs.urxh = data;
- m_uart[uart].regs.utrstat |= 1; // [bit 0] Receive buffer data ready
-}
-
-TIMER_CALLBACK_MEMBER( s3c44b0_device::uart_timer_exp )
-{
- int ch = param;
- verboselog(machine(), 2, "UART %d timer callback\n", ch);
- if ((m_uart->regs.ucon & (1 << 9)) != 0)
- {
- const int ch_int[] = { S3C44B0_INT_UTXD0, S3C44B0_INT_UTXD1 };
- request_irq(ch_int[ch]);
- }
-}
-
-/* Watchdog Timer */
-
-UINT16 s3c44b0_device::wdt_calc_current_count()
-{
- return 0;
-}
-
-READ32_MEMBER( s3c44b0_device::wdt_r )
-{
- UINT32 data = ((UINT32*)&m_wdt.regs)[offset];
- switch (offset)
- {
- case S3C44B0_WTCNT :
- {
- // is wdt active?
- if ((m_wdt.regs.wtcon & (1 << 5)) != 0)
- {
- data = wdt_calc_current_count();
- }
- }
- break;
- }
- verboselog(machine(), 9, "(WDT) %08X -> %08X\n", S3C44B0_BASE_WDT + (offset << 2), data);
- return data;
-}
-
-void s3c44b0_device::wdt_start()
-{
- UINT32 mclk, prescaler, clock;
- double freq, hz;
- verboselog(machine(), 1, "WDT start\n");
- mclk = get_mclk();
- prescaler = BITS(m_wdt.regs.wtcon, 15, 8);
- clock = 16 << BITS(m_wdt.regs.wtcon, 4, 3);
- freq = (double)mclk / (prescaler + 1) / clock;
- hz = freq / m_wdt.regs.wtcnt;
- verboselog(machine(), 5, "WDT mclk %d prescaler %d clock %d freq %f hz %f\n", mclk, prescaler, clock, freq, hz);
- m_wdt.timer->adjust(attotime::from_hz(hz), 0, attotime::from_hz(hz));
-}
-
-void s3c44b0_device::wdt_stop()
-{
- verboselog(machine(), 1, "WDT stop\n");
- m_wdt.regs.wtcnt = wdt_calc_current_count();
- m_wdt.timer->adjust(attotime::never, 0);
-}
-
-void s3c44b0_device::wdt_recalc()
-{
- if ((m_wdt.regs.wtcon & (1 << 5)) != 0)
- wdt_start();
- else
- wdt_stop();
-}
-
-WRITE32_MEMBER( s3c44b0_device::wdt_w )
-{
- UINT32 old_value = ((UINT32*)&m_wdt.regs)[offset];
- verboselog(machine(), 9, "(WDT) %08X <- %08X\n", S3C44B0_BASE_WDT + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_wdt.regs)[offset]);
- switch (offset)
- {
- case S3C44B0_WTCON :
- {
- if ((data & (1 << 5)) != (old_value & (1 << 5)))
- {
- wdt_recalc();
- }
- }
- break;
- }
-}
-
-TIMER_CALLBACK_MEMBER( s3c44b0_device::wdt_timer_exp )
-{
- verboselog(machine(), 2, "WDT timer callback\n");
- if ((m_wdt.regs.wtcon & (1 << 2)) != 0)
- {
- request_irq(S3C44B0_INT_WDT);
- }
- if ((m_wdt.regs.wtcon & (1 << 0)) != 0)
- {
- //s3c44b0_reset();
- fatalerror("s3c44b0_reset\n");
- }
-}
-
-/* CPU Wrapper */
-
-READ32_MEMBER( s3c44b0_device::cpuwrap_r )
-{
- UINT32 data = ((UINT32*)&m_cpuwrap.regs)[offset];
- verboselog(machine(), 9, "(CPUWRAP) %08X -> %08X\n", S3C44B0_BASE_CPU_WRAPPER + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( s3c44b0_device::cpuwrap_w )
-{
- verboselog(machine(), 9, "(CPUWRAP) %08X <- %08X\n", S3C44B0_BASE_CPU_WRAPPER + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_cpuwrap.regs)[offset]);
-}
-
-/* A/D Converter */
-
-READ32_MEMBER( s3c44b0_device::adc_r )
-{
- UINT32 data = ((UINT32*)&m_adc.regs)[offset];
- verboselog(machine(), 9, "(ADC) %08X -> %08X\n", S3C44B0_BASE_ADC + (offset << 2), data);
- return data;
-}
-
-void s3c44b0_device::adc_start()
-{
- UINT32 mclk, prescaler;
- double freq, hz;
- verboselog(machine(), 1, "ADC start\n");
- mclk = get_mclk();
- prescaler = BITS(m_adc.regs.adcpsr, 7, 0);
- freq = (double)mclk / (2 * (prescaler + 1)) / 16;
- hz = freq / 1; //m_wdt.regs.wtcnt;
- verboselog(machine(), 5, "ADC mclk %d prescaler %d freq %f hz %f\n", mclk, prescaler, freq, hz);
- m_adc.timer->adjust(attotime::from_hz(hz), 0);
-}
-
-void s3c44b0_device::adc_stop()
-{
- verboselog(machine(), 1, "ADC stop\n");
- m_adc.timer->adjust(attotime::never, 0);
-}
-
-void s3c44b0_device::adc_recalc()
-{
- if ((m_adc.regs.adccon & (1 << 0)) != 0)
- adc_start();
- else
- adc_stop();
-}
-
-WRITE32_MEMBER( s3c44b0_device::adc_w )
-{
- UINT32 old_value = ((UINT32*)&m_wdt.regs)[offset];
- verboselog(machine(), 9, "(ADC) %08X <- %08X\n", S3C44B0_BASE_ADC + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_adc.regs)[offset]);
- switch (offset)
- {
- case S3C44B0_ADCCON :
- {
- if ((data & (1 << 0)) != (old_value & (1 << 0)))
- {
- adc_recalc();
- }
- m_adc.regs.adccon &= ~(1 << 0); // "this bit is cleared after the start-up"
- }
- break;
- }
-}
-
-TIMER_CALLBACK_MEMBER( s3c44b0_device::adc_timer_exp )
-{
- verboselog(machine(), 2, "ADC timer callback\n");
- m_adc.regs.adccon |= (1 << 6);
- request_irq(S3C44B0_INT_ADC);
-}
-
-/* SIO */
-
-READ32_MEMBER( s3c44b0_device::sio_r )
-{
- UINT32 data = ((UINT32*)&m_sio.regs)[offset];
- verboselog(machine(), 9, "(SIO) %08X -> %08X\n", S3C44B0_BASE_SIO + (offset << 2), data);
- return data;
-}
-
-void s3c44b0_device::sio_start()
-{
- UINT32 mclk, prescaler;
- double freq, hz;
- verboselog(machine(), 1, "SIO start\n");
- mclk = get_mclk();
- prescaler = BITS(m_sio.regs.sbrdr, 11, 0);
- freq = (double)mclk / 2 / (prescaler + 1);
- hz = freq / 1; //m_wdt.regs.wtcnt;
- verboselog(machine(), 5, "SIO mclk %d prescaler %d freq %f hz %f\n", mclk, prescaler, freq, hz);
- m_sio.timer->adjust(attotime::from_hz(hz), 0);
-// printf("SIO transmit %02X (%c)\n", m_sio.regs.siodat, ((m_sio.regs.siodat >= 32) && (m_sio.regs.siodat < 128)) ? (char)m_sio.regs.siodat : '?');
-}
-
-void s3c44b0_device::sio_stop()
-{
- verboselog(machine(), 1, "SIO stop\n");
-// m_wdt.regs.wtcnt = s3c44b0_wdt_calc_current_count( device);
- m_sio.timer->adjust(attotime::never, 0);
-}
-
-void s3c44b0_device::sio_recalc()
-{
- if ((m_sio.regs.siocon & (1 << 3)) != 0)
- sio_start();
- else
- sio_stop();
-}
-
-WRITE32_MEMBER( s3c44b0_device::sio_w )
-{
- UINT32 old_value = ((UINT32*)&m_sio.regs)[offset];
- verboselog(machine(), 9, "(SIO) %08X <- %08X\n", S3C44B0_BASE_SIO + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_sio.regs)[offset]);
- switch (offset)
- {
- case S3C44B0_SIOCON :
- {
- if ((old_value & (1 << 3)) != (data & (1 << 3)))
- {
- sio_recalc();
- }
- m_sio.regs.siocon &= ~(1 << 3); // "This bit is cleared just after writing this bit as 1."
- }
- break;
- }
-}
-
-TIMER_CALLBACK_MEMBER( s3c44b0_device::sio_timer_exp )
-{
- verboselog(machine(), 2, "SIO timer callback\n");
-
- m_sio.regs.siodat = 0x00; // TEST
-
- if ((m_sio.regs.siocon & (1 << 0)) != 0)
- {
- request_irq(S3C44B0_INT_SIO);
- }
-}
-
-/* IIS */
-
-inline void s3c44b0_device::iface_i2s_data_w(address_space &space, int ch, UINT16 data)
-{
- if (!m_data_w_cb.isnull())
- (m_data_w_cb)(ch, data, 0);
-}
-
-void s3c44b0_device::iis_start()
-{
- UINT32 mclk;
- int prescaler;
- double freq, hz;
- const int div[] = { 2, 4, 6, 8, 10, 12, 14, 16, 1, 0, 3, 0, 5, 0, 7, 0 };
- verboselog(machine(), 1, "IIS start\n");
- mclk = get_mclk();
- prescaler = BITS(m_iis.regs.iispsr, 3, 0);
- freq = (double)mclk / div[prescaler];
- hz = freq / 256 * 2;
- verboselog(machine(), 5, "IIS mclk %d prescaler %d freq %f hz %f\n", mclk, prescaler, freq, hz);
- m_iis.timer->adjust(attotime::from_hz(hz), 0, attotime::from_hz(hz));
-}
-
-void s3c44b0_device::iis_stop()
-{
- verboselog(machine(), 1, "IIS stop\n");
- m_iis.timer->adjust(attotime::never, 0);
-}
-
-READ32_MEMBER( s3c44b0_device::iis_r )
-{
- UINT32 data = ((UINT32*)&m_iis.regs)[offset];
- verboselog(machine(), 9, "(IIS) %08X -> %08X\n", S3C44B0_BASE_IIS + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( s3c44b0_device::iis_w )
-{
- UINT32 old_value = ((UINT32*)&m_iis.regs)[offset];
- verboselog(machine(), 9, "(IIS) %08X <- %08X\n", S3C44B0_BASE_IIS + (offset << 2), data);
- COMBINE_DATA(&((UINT32*)&m_iis.regs)[offset]);
- switch (offset)
- {
- case S3C44B0_IISCON :
- {
- if ((old_value & (1 << 0)) != (data & (1 << 0)))
- {
- if ((data & (1 << 0)) != 0)
- {
- iis_start();
- }
- else
- {
- iis_stop();
- }
- }
- }
- break;
- case S3C44B0_IISFIFO :
- {
- if (ACCESSING_BITS_16_31)
- {
- m_iis.fifo[m_iis.fifo_index++] = BITS(data, 31, 16);
- }
- if (ACCESSING_BITS_0_15)
- {
- m_iis.fifo[m_iis.fifo_index++] = BITS(data, 15, 0);
- }
- if (m_iis.fifo_index == 2)
- {
- m_iis.fifo_index = 0;
- iface_i2s_data_w(space, 0, m_iis.fifo[0]);
- iface_i2s_data_w(space, 1, m_iis.fifo[1]);
- }
- }
- break;
- }
-}
-
-TIMER_CALLBACK_MEMBER( s3c44b0_device::iis_timer_exp )
-{
- verboselog(machine(), 2, "IIS timer callback\n");
- if ((m_iis.regs.iiscon & (1 << 5)) != 0)
- {
- bdma_request_iis();
- }
-}
-
-/* ZDMA */
-
-void s3c44b0_device::zdma_trigger(int ch)
-{
- address_space &space = m_cpu->space(AS_PROGRAM);
- UINT32 saddr, daddr;
- int dal, dst, opt, das, cnt;
- verboselog(machine(), 5, "s3c44b0_zdma_trigger %d\n", ch);
- dst = BITS(m_zdma->regs.dcsrc, 31, 30);
- dal = BITS(m_zdma->regs.dcsrc, 29, 28);
- saddr = BITS(m_zdma->regs.dcsrc, 27, 0);
- verboselog(machine(), 5, "dst %d dal %d saddr %08X\n", dst, dal, saddr);
- opt = BITS(m_zdma->regs.dcdst, 31, 30);
- das = BITS(m_zdma->regs.dcdst, 29, 28);
- daddr = BITS(m_zdma->regs.dcdst, 27, 0);
- verboselog(machine(), 5, "opt %d das %d daddr %08X\n", opt, das, daddr);
- cnt = BITS(m_zdma->regs.dccnt, 19, 0);
- verboselog(machine(), 5, "icnt %08X\n", cnt);
- while (cnt > 0)
- {
- verboselog(machine(), 9, "[%08X] -> [%08X]\n", saddr, daddr);
- switch (dst)
- {
- case 0 : space.write_byte(daddr, space.read_byte(saddr)); break;
- case 1 : space.write_word(daddr, space.read_word(saddr)); break;
- case 2 : space.write_dword(daddr, space.read_dword(saddr)); break;
- }
- switch (dal)
- {
- case 1 : saddr += (1 << dst); break;
- case 2 : saddr -= (1 << dst); break;
- }
- switch (das)
- {
- case 1 : daddr += (1 << dst); break;
- case 2 : daddr -= (1 << dst); break;
- }
- cnt -= (1 << dst);
- }
- m_zdma->regs.dcsrc = CLR_BITS(m_zdma->regs.dcsrc, 27, 0) | saddr;
- m_zdma->regs.dcdst = CLR_BITS(m_zdma->regs.dcdst, 27, 0) | daddr;
- m_zdma->regs.dccnt = CLR_BITS(m_zdma->regs.dcdst, 19, 0) | cnt;
- if (cnt == 0)
- {
- if ((m_zdma->regs.dccnt & (1 << 23)) != 0)
- {
- const int ch_int[] = { S3C44B0_INT_ZDMA0, S3C44B0_INT_ZDMA1 };
- request_irq(ch_int[ch]);
- }
- }
-}
-
-void s3c44b0_device::zdma_start(int ch)
-{
- verboselog(machine(), 5, "ZDMA %d start\n", ch);
- m_zdma->regs.dcsrc = m_zdma->regs.disrc;
- m_zdma->regs.dcdst = m_zdma->regs.didst;
- m_zdma->regs.dccnt = m_zdma->regs.dicnt;
- zdma_trigger(ch);
-}
-
-UINT32 s3c44b0_device::zdma_r(int ch, UINT32 offset)
-{
- UINT32 data = ((UINT32*)&m_zdma[ch].regs)[offset];
- return data;
-}
-
-void s3c44b0_device::zdma_w(int ch, UINT32 offset, UINT32 data, UINT32 mem_mask)
-{
- UINT32 old_value = ((UINT32*)&m_zdma[ch].regs)[offset];
- COMBINE_DATA(&((UINT32*)&m_zdma[ch].regs)[offset]);
- switch (offset)
- {
- case S3C44B0_DCON :
- {
- if ((old_value & 3) != (data & 3))
- {
- switch (data & 3)
- {
- case 1 : zdma_start(ch); break;
- }
- }
- m_zdma[ch].regs.dcon &= ~3; // "After writing 01,10,11, CMD bit is cleared automatically"
- }
- break;
- }
-}
-
-READ32_MEMBER( s3c44b0_device::zdma_0_r )
-{
- UINT32 data = zdma_r(0, offset);
- verboselog(machine(), 9, "(ZDMA 0) %08X -> %08X\n", S3C44B0_BASE_ZDMA_0 + (offset << 2), data);
- return data;
-}
-
-READ32_MEMBER( s3c44b0_device::zdma_1_r )
-{
- UINT32 data = zdma_r(1, offset);
- verboselog(machine(), 9, "(ZDMA 1) %08X -> %08X\n", S3C44B0_BASE_ZDMA_1 + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( s3c44b0_device::zdma_0_w )
-{
- verboselog(machine(), 9, "(ZDMA 0) %08X <- %08X (%08X)\n", S3C44B0_BASE_ZDMA_0 + (offset << 2), data, mem_mask);
- zdma_w(0, offset, data, mem_mask);
-}
-
-WRITE32_MEMBER( s3c44b0_device::zdma_1_w )
-{
- verboselog(machine(), 9, "(ZDMA 1) %08X <- %08X (%08X)\n", S3C44B0_BASE_ZDMA_1 + (offset << 2), data, mem_mask);
- zdma_w(1, offset, data, mem_mask);
-}
-
-TIMER_CALLBACK_MEMBER( s3c44b0_device::zdma_timer_exp )
-{
- int ch = param;
- verboselog(machine(), 2, "ZDMA %d timer callback\n", ch);
-}
-
-/* BDMA */
-
-void s3c44b0_device::bdma_trigger(int ch)
-{
- address_space &space = m_cpu->space(AS_PROGRAM);
- UINT32 saddr, daddr;
- int dal, dst, tdm, das, cnt;
- verboselog(machine(), 5, "s3c44b0_bdma_trigger %d\n", ch);
- dst = BITS(m_bdma->regs.dcsrc, 31, 30);
- dal = BITS(m_bdma->regs.dcsrc, 29, 28);
- saddr = BITS(m_bdma->regs.dcsrc, 27, 0);
- verboselog(machine(), 5, "dst %d dal %d saddr %08X\n", dst, dal, saddr);
- tdm = BITS(m_bdma->regs.dcdst, 31, 30);
- das = BITS(m_bdma->regs.dcdst, 29, 28);
- daddr = BITS(m_bdma->regs.dcdst, 27, 0);
- verboselog(machine(), 5, "tdm %d das %d daddr %08X\n", tdm, das, daddr);
- cnt = BITS(m_bdma->regs.dccnt, 19, 0);
- verboselog(machine(), 5, "icnt %08X\n", cnt);
- verboselog(machine(), 9, "[%08X] -> [%08X]\n", saddr, daddr);
- switch (dst)
- {
- case 0 : space.write_byte(daddr, space.read_byte(saddr)); break;
- case 1 : space.write_word(daddr, space.read_word(saddr)); break;
- case 2 : space.write_dword(daddr, space.read_dword(saddr)); break;
- }
- switch (dal)
- {
- case 1 : saddr += (1 << dst); break;
- case 2 : saddr -= (1 << dst); break;
- }
- switch (das)
- {
- case 1 : daddr += (1 << dst); break;
- case 2 : daddr -= (1 << dst); break;
- }
- cnt -= (1 << dst);
- m_bdma->regs.dcsrc = CLR_BITS(m_bdma->regs.dcsrc, 27, 0) | saddr;
- m_bdma->regs.dcdst = CLR_BITS(m_bdma->regs.dcdst, 27, 0) | daddr;
- m_bdma->regs.dccnt = CLR_BITS(m_bdma->regs.dcdst, 19, 0) | cnt;
- if (cnt == 0)
- {
- if ((m_bdma->regs.dccnt & (1 << 23)) != 0)
- {
- const int ch_int[] = { S3C44B0_INT_BDMA0, S3C44B0_INT_BDMA1 };
- request_irq(ch_int[ch]);
- }
- }
-}
-
-void s3c44b0_device::bdma_request_iis()
-{
- verboselog(machine(), 5, "s3c44b0_bdma_request_iis\n");
- bdma_trigger(0);
-}
-
-UINT32 s3c44b0_device::bdma_r(int ch, UINT32 offset)
-{
- UINT32 data = ((UINT32*)&m_bdma[ch].regs)[offset];
- return data;
-}
-
-void s3c44b0_device::bdma_start(int ch)
-{
- verboselog(machine(), 5, "BDMA %d start\n", ch);
- int qsc = BITS(m_bdma->regs.dicnt, 31, 30);
- if ((ch == 0) && (qsc == 1))
- {
- // IIS
- }
- else
- {
- printf( "s3c44b0_bdma_start - todo\n");
- }
- m_bdma->regs.dcsrc = m_bdma->regs.disrc;
- m_bdma->regs.dcdst = m_bdma->regs.didst;
- m_bdma->regs.dccnt = m_bdma->regs.dicnt;
-}
-
-void s3c44b0_device::bdma_stop(int ch)
-{
- verboselog(machine(), 5, "BDMA %d stop\n", ch);
- m_bdma[ch].timer->adjust(attotime::never, ch);
-}
-
-void s3c44b0_device::bdma_w(int ch, UINT32 offset, UINT32 data, UINT32 mem_mask)
-{
- UINT32 old_value = ((UINT32*)&m_bdma[ch].regs)[offset];
- COMBINE_DATA(&((UINT32*)&m_bdma[ch].regs)[offset]);
- switch (offset)
- {
- case S3C44B0_DICNT :
- {
- if ((old_value & (1 << 20)) != (data & (1 << 20)))
- {
- if ((data & (1 << 20)) != 0)
- {
- bdma_start(ch);
- }
- else
- {
- bdma_stop(ch);
- }
- }
- }
- break;
- }
-}
-
-READ32_MEMBER( s3c44b0_device::bdma_0_r )
-{
- UINT32 data = bdma_r(0, offset);
- verboselog(machine(), 9, "(BDMA 0) %08X -> %08X\n", S3C44B0_BASE_BDMA_0 + (offset << 2), data);
- return data;
-}
-
-READ32_MEMBER( s3c44b0_device::bdma_1_r )
-{
- UINT32 data = bdma_r(1, offset);
- verboselog(machine(), 9, "(BDMA 1) %08X -> %08X\n", S3C44B0_BASE_BDMA_1 + (offset << 2), data);
- return data;
-}
-
-WRITE32_MEMBER( s3c44b0_device::bdma_0_w )
-{
- verboselog(machine(), 9, "(BDMA 0) %08X <- %08X (%08X)\n", S3C44B0_BASE_BDMA_0 + (offset << 2), data, mem_mask);
- bdma_w(0, offset, data, mem_mask);
-}
-
-WRITE32_MEMBER( s3c44b0_device::bdma_1_w )
-{
- verboselog(machine(), 9, "(BDMA 1) %08X <- %08X (%08X)\n", S3C44B0_BASE_BDMA_1 + (offset << 2), data, mem_mask);
- bdma_w(1, offset, data, mem_mask);
-}
-
-TIMER_CALLBACK_MEMBER( s3c44b0_device::bdma_timer_exp )
-{
- int ch = param;
- verboselog(machine(), 2, "BDMA %d timer callback\n", ch);
-}
diff --git a/src/emu/machine/s3c44b0.h b/src/emu/machine/s3c44b0.h
deleted file mode 100644
index 462bda280d2..00000000000
--- a/src/emu/machine/s3c44b0.h
+++ /dev/null
@@ -1,814 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Tim Schuerewegen
-/*******************************************************************************
-
- Samsung S3C44B0
-
- (c) 2011 Tim Schuerewegen
-
-*******************************************************************************/
-
-#ifndef __S3C44B0_H__
-#define __S3C44B0_H__
-
-
-/*******************************************************************************
- MACROS & CONSTANTS
-*******************************************************************************/
-
-/* Memory Controller */
-
-#define S3C44B0_BASE_MEMCON 0x01C80000
-
-/* Interrupt Controller */
-
-#define S3C44B0_BASE_INT 0x01E00000
-
-#define S3C44B0_INTCON (0x00 / 4) // Interrupt Control
-#define S3C44B0_INTPND (0x04 / 4) // Interrupt Request Status
-#define S3C44B0_INTMOD (0x08 / 4) // Interrupt Mode Control
-#define S3C44B0_INTMSK (0x0C / 4) // Interrupt Mask Control
-#define S3C44B0_I_PSLV (0x10 / 4)
-#define S3C44B0_I_PMST (0x14 / 4)
-#define S3C44B0_I_CSLV (0x18 / 4)
-#define S3C44B0_I_CMST (0x1C / 4)
-#define S3C44B0_I_ISPR (0x20 / 4)
-#define S3C44B0_I_ISPC (0x24 / 4)
-#define S3C44B0_F_ISPR (0x38 / 4)
-#define S3C44B0_F_ISPC (0x3C / 4)
-
-/* ZDMA & BDMA */
-
-#define S3C44B0_BASE_ZDMA_0 0x01E80000
-#define S3C44B0_BASE_ZDMA_1 0x01E80020
-#define S3C44B0_BASE_BDMA_0 0x01F80000
-#define S3C44B0_BASE_BDMA_1 0x01F80020
-
-#define S3C44B0_DCON (0x00 / 4) // DMA Control
-#define S3C44B0_DISRC (0x04 / 4) // DMA Initial Source
-#define S3C44B0_DIDST (0x08 / 4) // DMA Initial Destination
-#define S3C44B0_DICNT (0x0C / 4) // DMA Initial Transfer Count
-#define S3C44B0_DCSRC (0x10 / 4) // DMA Current Source Address
-#define S3C44B0_DCDST (0x14 / 4) // DMA Current Destination Address
-#define S3C44B0_DCCNT (0x18 / 4) // DMA Current Transfer Count
-
-/* Clock & Power Management */
-
-#define S3C44B0_BASE_CLKPOW 0x01D80000
-
-#define S3C44B0_PLLCON (0x00 / 4) // PLL Control
-#define S3C44B0_CLKCON (0x04 / 4) // Clock Generator Control
-#define S3C44B0_CLKSLOW (0x08 / 4) // Slow Clock Control
-#define S3C44B0_LOCKTIME (0x0C / 4) // PLL lock time Counter
-
-/* LCD Controller */
-
-#define S3C44B0_BASE_LCD 0x01F00000
-
-#define S3C44B0_LCDCON1 (0x00 / 4) // LCD Control 1
-#define S3C44B0_LCDCON2 (0x04 / 4) // LCD Control 2
-#define S3C44B0_LCDSADDR1 (0x08 / 4) // Frame Buffer Start Address 1
-#define S3C44B0_LCDSADDR2 (0x0C / 4) // Frame Buffer Start Address 2
-#define S3C44B0_LCDSADDR3 (0x10 / 4) // Virtual Screen Address Set
-#define S3C44B0_REDLUT (0x14 / 4) // STN: Red Lookup Table
-#define S3C44B0_GREENLUT (0x18 / 4) // STN: Green Lookup Table
-#define S3C44B0_BLUELUT (0x1C / 4) // STN: Blue Lookup Table
-#define S3C44B0_LCDCON3 (0x40 / 4) // LCD Control 3
-#define S3C44B0_DITHMODE (0x44 / 4) // STN: Dithering Mode
-
-/* UART */
-
-#define S3C44B0_BASE_UART_0 0x01D00000
-#define S3C44B0_BASE_UART_1 0x01D04000
-
-#define S3C44B0_ULCON (0x00 / 4) // UART Line Control
-#define S3C44B0_UCON (0x04 / 4) // UART Control
-#define S3C44B0_UFCON (0x08 / 4) // UART FIFO Control
-#define S3C44B0_UMCON (0x0C / 4) // UART Modem Control
-#define S3C44B0_UTRSTAT (0x10 / 4) // UART Tx/Rx Status
-#define S3C44B0_UERSTAT (0x14 / 4) // UART Rx Error Status
-#define S3C44B0_UFSTAT (0x18 / 4) // UART FIFO Status
-#define S3C44B0_UMSTAT (0x1C / 4) // UART Modem Status
-#define S3C44B0_UTXH (0x20 / 4) // UART Transmission Hold
-#define S3C44B0_URXH (0x24 / 4) // UART Receive Buffer
-#define S3C44B0_UBRDIV (0x28 / 4) // UART Baud Rate Divisor
-
-/* SIO */
-
-#define S3C44B0_BASE_SIO 0x01D14000
-
-#define S3C44B0_SIOCON (0x00 / 4) // SIO Control
-#define S3C44B0_SIODAT (0x04 / 4) // SIO Data
-#define S3C44B0_SBRDR (0x08 / 4) // SIO Baud Rate Prescaler
-#define S3C44B0_ITVCNT (0x0C / 4) // SIO Interval Counter
-#define S3C44B0_DCNTZ (0x10 / 4) // SIO DMA Count Zero
-
-/* PWM Timer */
-
-#define S3C44B0_BASE_PWM 0x01D50000
-
-#define S3C44B0_TCFG0 (0x00 / 4) // Timer Configuration
-#define S3C44B0_TCFG1 (0x04 / 4) // Timer Configuration
-#define S3C44B0_TCON (0x08 / 4) // Timer Control
-#define S3C44B0_TCNTB0 (0x0C / 4) // Timer Count Buffer 0
-#define S3C44B0_TCMPB0 (0x10 / 4) // Timer Compare Buffer 0
-#define S3C44B0_TCNTO0 (0x14 / 4) // Timer Count Observation 0
-#define S3C44B0_TCNTB1 (0x18 / 4) // Timer Count Buffer 1
-#define S3C44B0_TCMPB1 (0x1C / 4) // Timer Compare Buffer 1
-#define S3C44B0_TCNTO1 (0x20 / 4) // Timer Count Observation 1
-#define S3C44B0_TCNTB2 (0x24 / 4) // Timer Count Buffer 2
-#define S3C44B0_TCMPB2 (0x28 / 4) // Timer Compare Buffer 2
-#define S3C44B0_TCNTO2 (0x2C / 4) // Timer Count Observation 2
-#define S3C44B0_TCNTB3 (0x30 / 4) // Timer Count Buffer 3
-#define S3C44B0_TCMPB3 (0x34 / 4) // Timer Compare Buffer 3
-#define S3C44B0_TCNTO3 (0x38 / 4) // Timer Count Observation 3
-#define S3C44B0_TCNTB4 (0x3C / 4) // Timer Count Buffer 4
-#define S3C44B0_TCMPB4 (0x40 / 4) // Timer Compare Buffer 4
-#define S3C44B0_TCNTO4 (0x44 / 4) // Timer Count Observation 4
-#define S3C44B0_TCNTB5 (0x48 / 4) // Timer Count Buffer 5
-#define S3C44B0_TCNTO5 (0x4C / 4) // Timer Count Observation 5
-
-/* USB Device */
-
-#define S3C44B0_BASE_USBDEV 0x15200140
-
-/* Watchdog Timer */
-
-#define S3C44B0_BASE_WDT 0x01D30000
-
-#define S3C44B0_WTCON (0x00 / 4) // Watchdog Timer Mode
-#define S3C44B0_WTDAT (0x04 / 4) // Watchdog Timer Data
-#define S3C44B0_WTCNT (0x08 / 4) // Watchdog Timer Count
-
-/* IIC */
-
-#define S3C44B0_BASE_IIC 0x01D60000
-
-#define S3C44B0_IICCON (0x00 / 4) // IIC Control
-#define S3C44B0_IICSTAT (0x04 / 4) // IIC Status
-#define S3C44B0_IICADD (0x08 / 4) // IIC Address
-#define S3C44B0_IICDS (0x0C / 4) // IIC Data Shift
-
-/* IIS */
-
-#define S3C44B0_BASE_IIS 0x01D18000
-
-#define S3C44B0_IISCON (0x00 / 4) // IIS Control
-#define S3C44B0_IISMOD (0x04 / 4) // IIS Mode
-#define S3C44B0_IISPSR (0x08 / 4) // IIS Prescaler
-#define S3C44B0_IISFCON (0x0C / 4) // IIS FIFO Control
-#define S3C44B0_IISFIFO (0x10 / 4) // IIS FIFO Entry
-
-/* I/O Port */
-
-#define S3C44B0_BASE_GPIO 0x01D20000
-
-#define S3C44B0_GPACON (0x00 / 4) // Port A Control
-#define S3C44B0_GPADAT (0x04 / 4) // Port A Data
-#define S3C44B0_GPBCON (0x08 / 4) // Port B Control
-#define S3C44B0_GPBDAT (0x0C / 4) // Port B Data
-#define S3C44B0_GPCCON (0x10 / 4) // Port C Control
-#define S3C44B0_GPCDAT (0x14 / 4) // Port C Data
-#define S3C44B0_GPCUP (0x18 / 4) // Pull-up Control C
-#define S3C44B0_GPDCON (0x1C / 4) // Port D Control
-#define S3C44B0_GPDDAT (0x20 / 4) // Port D Data
-#define S3C44B0_GPDUP (0x24 / 4) // Pull-up Control D
-#define S3C44B0_GPECON (0x28 / 4) // Port E Control
-#define S3C44B0_GPEDAT (0x2C / 4) // Port E Data
-#define S3C44B0_GPEUP (0x30 / 4) // Pull-up Control E
-#define S3C44B0_GPFCON (0x34 / 4) // Port F Control
-#define S3C44B0_GPFDAT (0x38 / 4) // Port F Data
-#define S3C44B0_GPFUP (0x3C / 4) // Pull-up Control F
-#define S3C44B0_GPGCON (0x40 / 4) // Port G Control
-#define S3C44B0_GPGDAT (0x44 / 4) // Port G Data
-#define S3C44B0_GPGUP (0x48 / 4) // Pull-up Control G
-#define S3C44B0_SPUCR (0x4C / 4) // Special Pull-up
-#define S3C44B0_EXTINT (0x50 / 4) // External Interrupt Control
-#define S3C44B0_EXTINTPND (0x54 / 4) // External Interrupt Pending
-
-#define S3C44B0_GPADAT_MASK 0x000003FF
-#define S3C44B0_GPBDAT_MASK 0x000007FF
-#define S3C44B0_GPCDAT_MASK 0x0000FFFF
-#define S3C44B0_GPDDAT_MASK 0x000000FF
-#define S3C44B0_GPEDAT_MASK 0x000001FF
-#define S3C44B0_GPFDAT_MASK 0x000001FF
-#define S3C44B0_GPGDAT_MASK 0x000000FF
-
-/* RTC */
-
-#define S3C44B0_BASE_RTC 0x01D70040
-
-#define S3C44B0_RTCCON (0x00 / 4) // RTC Control
-#define S3C44B0_RTCALM (0x10 / 4) // RTC Alarm Control
-#define S3C44B0_ALMSEC (0x14 / 4) // Alarm Second
-#define S3C44B0_ALMMIN (0x18 / 4) // Alarm Minute
-#define S3C44B0_ALMHOUR (0x1C / 4) // Alarm Hour
-#define S3C44B0_ALMDAY (0x20 / 4) // Alarm Day
-#define S3C44B0_ALMMON (0x24 / 4) // Alarm Month
-#define S3C44B0_ALMYEAR (0x28 / 4) // Alarm Year
-#define S3C44B0_RTCRST (0x2C / 4) // RTC Round Reset
-#define S3C44B0_BCDSEC (0x30 / 4) // BCD Second
-#define S3C44B0_BCDMIN (0x34 / 4) // BCD Minute
-#define S3C44B0_BCDHOUR (0x38 / 4) // BCD Hour
-#define S3C44B0_BCDDAY (0x3C / 4) // BCD Day
-#define S3C44B0_BCDDOW (0x40 / 4) // BCD Day of Week
-#define S3C44B0_BCDMON (0x44 / 4) // BCD Month
-#define S3C44B0_BCDYEAR (0x48 / 4) // BCD Year
-#define S3C44B0_TICNT (0x4C / 4) // Tick Time count
-
-/* A/D Converter */
-
-#define S3C44B0_BASE_ADC 0x01D40000
-
-#define S3C44B0_ADCCON (0x00 / 4) // ADC Control
-#define S3C44B0_ADCPSR (0x04 / 4) // ADC Prescaler
-#define S3C44B0_ADCDAT (0x08 / 4) // ADC Data
-
-/* CPU Wrapper */
-
-#define S3C44B0_BASE_CPU_WRAPPER 0x01C00000
-
-#define S3C44B0_SYSCFG (0x00 / 4) // System Configuration
-#define S3C44B0_NCACHBE0 (0x04 / 4) // Non Cacheable Area 0
-#define S3C44B0_NCACHBE1 (0x08 / 4) // Non Cacheable Area 1
-
-/* ... */
-
-#define S3C44B0_INT_ADC 0
-#define S3C44B0_INT_RTC 1
-#define S3C44B0_INT_UTXD1 2
-#define S3C44B0_INT_UTXD0 3
-#define S3C44B0_INT_SIO 4
-#define S3C44B0_INT_IIC 5
-#define S3C44B0_INT_URXD1 6
-#define S3C44B0_INT_URXD0 7
-#define S3C44B0_INT_TIMER5 8
-#define S3C44B0_INT_TIMER4 9
-#define S3C44B0_INT_TIMER3 10
-#define S3C44B0_INT_TIMER2 11
-#define S3C44B0_INT_TIMER1 12
-#define S3C44B0_INT_TIMER0 13
-#define S3C44B0_INT_UERR 14
-#define S3C44B0_INT_WDT 15
-#define S3C44B0_INT_BDMA1 16
-#define S3C44B0_INT_BDMA0 17
-#define S3C44B0_INT_ZDMA1 18
-#define S3C44B0_INT_ZDMA0 19
-#define S3C44B0_INT_TICK 20
-#define S3C44B0_INT_EINT4_7 21
-#define S3C44B0_INT_EINT3 22
-#define S3C44B0_INT_EINT2 23
-#define S3C44B0_INT_EINT1 24
-#define S3C44B0_INT_EINT0 25
-
-#define S3C44B0_MODESEL_01 0
-#define S3C44B0_MODESEL_02 1
-#define S3C44B0_MODESEL_04 2
-#define S3C44B0_MODESEL_08 3
-
-#define S3C44B0_PNRMODE_STN_04_DS 0
-#define S3C44B0_PNRMODE_STN_04_SS 1
-#define S3C44B0_PNRMODE_STN_08_SS 2
-
-#define S3C44B0_GPIO_PORT_A S3C44B0_GPIO_PORT_A
-#define S3C44B0_GPIO_PORT_B S3C44B0_GPIO_PORT_B
-#define S3C44B0_GPIO_PORT_C S3C44B0_GPIO_PORT_C
-#define S3C44B0_GPIO_PORT_D S3C44B0_GPIO_PORT_D
-#define S3C44B0_GPIO_PORT_E S3C44B0_GPIO_PORT_E
-#define S3C44B0_GPIO_PORT_F S3C44B0_GPIO_PORT_F
-#define S3C44B0_GPIO_PORT_G S3C44B0_GPIO_PORT_G
-
-
-/*******************************************************************************
- MACROS / CONSTANTS
- *******************************************************************************/
-
-
-struct s3c44b0_memcon_regs_t
-{
- UINT32 data[0x34/4];
-};
-
-struct s3c44b0_irq_regs_t
-{
- UINT32 intcon;
- UINT32 intpnd;
- UINT32 intmod;
- UINT32 intmsk;
- UINT32 i_pslv;
- UINT32 i_pmst;
- UINT32 i_cslv;
- UINT32 i_cmst;
- UINT32 i_ispr;
- UINT32 i_ispc;
- UINT32 reserved[4];
- UINT32 f_ispr;
- UINT32 f_ispc;
-};
-
-struct s3c44b0_dma_regs_t
-{
- UINT32 dcon;
- UINT32 disrc;
- UINT32 didst;
- UINT32 dicnt;
- UINT32 dcsrc;
- UINT32 dcdst;
- UINT32 dccnt;
-};
-
-struct s3c44b0_clkpow_regs_t
-{
- UINT32 pllcon;
- UINT32 clkcon;
- UINT32 clkslow;
- UINT32 locktime;
-};
-
-struct s3c44b0_lcd_regs_t
-{
- UINT32 lcdcon1;
- UINT32 lcdcon2;
- UINT32 lcdsaddr1;
- UINT32 lcdsaddr2;
- UINT32 lcdsaddr3;
- UINT32 redlut;
- UINT32 greenlut;
- UINT32 bluelut;
- UINT32 reserved[8];
- UINT32 lcdcon3;
- UINT32 dithmode;
-};
-
-struct s3c44b0_uart_regs_t
-{
- UINT32 ulcon;
- UINT32 ucon;
- UINT32 ufcon;
- UINT32 umcon;
- UINT32 utrstat;
- UINT32 uerstat;
- UINT32 ufstat;
- UINT32 umstat;
- UINT32 utxh;
- UINT32 urxh;
- UINT32 ubrdiv;
-};
-
-struct s3c44b0_sio_regs_t
-{
- UINT32 siocon;
- UINT32 siodat;
- UINT32 sbrdr;
- UINT32 itvcnt;
- UINT32 dcntz;
-};
-
-struct s3c44b0_pwm_regs_t
-{
- UINT32 tcfg0;
- UINT32 tcfg1;
- UINT32 tcon;
- UINT32 tcntb0;
- UINT32 tcmpb0;
- UINT32 tcnto0;
- UINT32 tcntb1;
- UINT32 tcmpb1;
- UINT32 tcnto1;
- UINT32 tcntb2;
- UINT32 tcmpb2;
- UINT32 tcnto2;
- UINT32 tcntb3;
- UINT32 tcmpb3;
- UINT32 tcnto3;
- UINT32 tcntb4;
- UINT32 tcmpb4;
- UINT32 tcnto4;
- UINT32 tcntb5;
- UINT32 tcnto5;
-};
-
-struct s3c44b0_wdt_regs_t
-{
- UINT32 wtcon;
- UINT32 wtdat;
- UINT32 wtcnt;
-};
-
-struct s3c44b0_iic_regs_t
-{
- UINT32 iiccon;
- UINT32 iicstat;
- UINT32 iicadd;
- UINT32 iicds;
-};
-
-struct s3c44b0_iis_regs_t
-{
- UINT32 iiscon;
- UINT32 iismod;
- UINT32 iispsr;
- UINT32 iisfcon;
- UINT32 iisfifo;
-};
-
-struct s3c44b0_gpio_regs_t
-{
- UINT32 gpacon;
- UINT32 gpadat;
- UINT32 gpbcon;
- UINT32 gpbdat;
- UINT32 gpccon;
- UINT32 gpcdat;
- UINT32 gpcup;
- UINT32 gpdcon;
- UINT32 gpddat;
- UINT32 gpdup;
- UINT32 gpecon;
- UINT32 gpedat;
- UINT32 gpeup;
- UINT32 gpfcon;
- UINT32 gpfdat;
- UINT32 gpfup;
- UINT32 gpgcon;
- UINT32 gpgdat;
- UINT32 gpgup;
- UINT32 spucr;
- UINT32 extint;
- UINT32 extintpnd;
-};
-
-struct s3c44b0_rtc_regs_t
-{
- UINT32 rtccon;
- UINT32 reserved[3];
- UINT32 rtcalm;
- UINT32 almsec;
- UINT32 almmin;
- UINT32 almhour;
- UINT32 almday;
- UINT32 almmon;
- UINT32 almyear;
- UINT32 rtcrst;
- UINT32 bcdsec;
- UINT32 bcdmin;
- UINT32 bcdhour;
- UINT32 bcdday;
- UINT32 bcddow;
- UINT32 bcdmon;
- UINT32 bcdyear;
- UINT32 ticnt;
-};
-
-struct s3c44b0_adc_regs_t
-{
- UINT32 adccon;
- UINT32 adcpsr;
- UINT32 adcdat;
-};
-
-struct s3c44b0_cpuwrap_regs_t
-{
- UINT32 syscfg;
- UINT32 ncachbe0;
- UINT32 ncachbe1;
-};
-
-struct s3c44b0_memcon_t
-{
- s3c44b0_memcon_regs_t regs;
-};
-
-struct s3c44b0_irq_t
-{
- s3c44b0_irq_regs_t regs;
- int line_irq, line_fiq;
-};
-
-struct s3c44b0_dma_t
-{
- s3c44b0_dma_regs_t regs;
- emu_timer *timer;
-};
-
-struct s3c44b0_clkpow_t
-{
- s3c44b0_clkpow_regs_t regs;
-};
-
-struct rectangle_t
-{
- int x1, y1, x2, y2;
-};
-
-struct s3c44b0_lcd_t
-{
- s3c44b0_lcd_regs_t regs;
- emu_timer *timer;
- UINT8 *bitmap;
- UINT32 vramaddr_cur;
- UINT32 vramaddr_max;
- UINT32 offsize;
- UINT32 pagewidth_cur;
- UINT32 pagewidth_max;
- UINT32 modesel;
- UINT32 bswp;
- int vpos, hpos;
- double framerate;
- UINT32 hpos_min, hpos_max, hpos_end, vpos_min, vpos_max, vpos_end;
- attotime frame_time;
- attoseconds_t frame_period, pixeltime, scantime;
-};
-
-struct s3c44b0_uart_t
-{
- s3c44b0_uart_regs_t regs;
- emu_timer *timer;
-};
-
-struct s3c44b0_sio_t
-{
- s3c44b0_sio_regs_t regs;
- emu_timer *timer;
-};
-
-struct s3c44b0_pwm_t
-{
- s3c44b0_pwm_regs_t regs;
- emu_timer *timer[6];
- UINT32 cnt[6];
- UINT32 cmp[6];
- UINT32 freq[6];
-};
-
-struct s3c44b0_wdt_t
-{
- s3c44b0_wdt_regs_t regs;
- emu_timer *timer;
-};
-
-struct s3c44b0_iic_t
-{
- s3c44b0_iic_regs_t regs;
- emu_timer *timer;
- int count;
-};
-
-struct s3c44b0_iis_t
-{
- s3c44b0_iis_regs_t regs;
- emu_timer *timer;
- UINT16 fifo[16/2];
- int fifo_index;
-};
-
-struct s3c44b0_gpio_t
-{
- s3c44b0_gpio_regs_t regs;
-};
-
-struct s3c44b0_rtc_t
-{
- s3c44b0_rtc_regs_t regs;
- emu_timer *timer_tick_count;
- emu_timer *timer_update;
-};
-
-struct s3c44b0_adc_t
-{
- s3c44b0_adc_regs_t regs;
- emu_timer *timer;
-};
-
-struct s3c44b0_cpuwrap_t
-{
- s3c44b0_cpuwrap_regs_t regs;
-};
-
-
-enum
-{
- S3C44B0_GPIO_PORT_A = 0,
- S3C44B0_GPIO_PORT_B,
- S3C44B0_GPIO_PORT_C,
- S3C44B0_GPIO_PORT_D,
- S3C44B0_GPIO_PORT_E,
- S3C44B0_GPIO_PORT_F,
- S3C44B0_GPIO_PORT_G
-};
-
-class s3c44b0_device : public device_t
-{
-public:
- s3c44b0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~s3c44b0_device() {}
-
- template<class _Object> static devcb_base &set_gpio_port_r_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_port_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_gpio_port_w_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_port_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2c_scl_w_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_scl_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2c_sda_r_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_sda_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2c_sda_w_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_sda_w_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_adc_data_r_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_data_r_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_i2s_data_w_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_data_w_cb.set_callback(object); }
-
- DECLARE_READ32_MEMBER(lcd_r);
- DECLARE_READ32_MEMBER(clkpow_r);
- DECLARE_READ32_MEMBER(irq_r);
- DECLARE_READ32_MEMBER(pwm_r);
- DECLARE_READ32_MEMBER(iic_r);
- DECLARE_READ32_MEMBER(gpio_r);
- DECLARE_READ32_MEMBER(uart_0_r);
- DECLARE_READ32_MEMBER(uart_1_r);
- DECLARE_READ32_MEMBER(wdt_r);
- DECLARE_READ32_MEMBER(cpuwrap_r);
- DECLARE_READ32_MEMBER(adc_r);
- DECLARE_READ32_MEMBER(sio_r);
- DECLARE_READ32_MEMBER(iis_r);
- DECLARE_READ32_MEMBER(zdma_0_r);
- DECLARE_READ32_MEMBER(zdma_1_r);
- DECLARE_READ32_MEMBER(bdma_0_r);
- DECLARE_READ32_MEMBER(bdma_1_r);
-
- DECLARE_WRITE32_MEMBER(lcd_w);
- DECLARE_WRITE32_MEMBER(clkpow_w);
- DECLARE_WRITE32_MEMBER(irq_w);
- DECLARE_WRITE32_MEMBER(pwm_w);
- DECLARE_WRITE32_MEMBER(iic_w);
- DECLARE_WRITE32_MEMBER(gpio_w);
- DECLARE_WRITE32_MEMBER(uart_0_w);
- DECLARE_WRITE32_MEMBER(uart_1_w);
- DECLARE_WRITE32_MEMBER(wdt_w);
- DECLARE_WRITE32_MEMBER(cpuwrap_w);
- DECLARE_WRITE32_MEMBER(adc_w);
- DECLARE_WRITE32_MEMBER(sio_w);
- DECLARE_WRITE32_MEMBER(iis_w);
- DECLARE_WRITE32_MEMBER(zdma_0_w);
- DECLARE_WRITE32_MEMBER(zdma_1_w);
- DECLARE_WRITE32_MEMBER(bdma_0_w);
- DECLARE_WRITE32_MEMBER(bdma_1_w);
-
- void request_eint(UINT32 number);
- UINT32 video_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
- // LCD Controller
- rgb_t lcd_get_color_stn_04(UINT8 data);
- UINT8 lcd_get_color_stn_08_r(UINT8 data);
- UINT8 lcd_get_color_stn_08_g(UINT8 data);
- UINT8 lcd_get_color_stn_08_b(UINT8 data);
- void lcd_dma_reload();
- void lcd_dma_init();
- void lcd_dma_read(int count, UINT8 *data);
- void lcd_render_stn_04();
- void lcd_render_stn_08();
- attotime time_until_pos(int vpos, int hpos);
- int lcd_get_vpos();
- int lcd_get_hpos();
- void video_start();
- void lcd_configure();
- void lcd_start();
- void lcd_stop();
- void lcd_recalc();
- TIMER_CALLBACK_MEMBER(lcd_timer_exp);
-
- // Clock & Power Management
- UINT32 get_mclk();
-
- // Interrupt Controller
- void check_pending_irq();
- void request_irq(UINT32 int_type);
- void check_pending_eint();
-
- // PWM Timer
- UINT16 pwm_calc_observation(int ch);
- void pwm_start(int timer);
- void pwm_stop(int timer);
- void pwm_recalc(int timer);
- TIMER_CALLBACK_MEMBER(pwm_timer_exp);
- //void dma_request_pwm();
-
- // IIC
- inline void iface_i2c_scl_w(int state);
- inline void iface_i2c_sda_w(int state);
- inline int iface_i2c_sda_r();
- void i2c_send_start();
- void i2c_send_stop();
- UINT8 i2c_receive_byte(int ack);
- int i2c_send_byte(UINT8 data);
- void iic_start();
- void iic_stop();
- void iic_resume();
- TIMER_CALLBACK_MEMBER(iic_timer_exp);
-
- // I/O Port
- inline UINT32 iface_gpio_port_r(int port);
- inline void iface_gpio_port_w(int port, UINT32 data);
-
- // UART
- UINT32 uart_r(int ch, UINT32 offset);
- void uart_w(int ch, UINT32 offset, UINT32 data, UINT32 mem_mask);
- void uart_fifo_w(int uart, UINT8 data);
- TIMER_CALLBACK_MEMBER(uart_timer_exp);
-
- // Watchdog Timer
- UINT16 wdt_calc_current_count();
- void wdt_start();
- void wdt_stop();
- void wdt_recalc();
- TIMER_CALLBACK_MEMBER(wdt_timer_exp);
-
- // A/D Converter
- void adc_start();
- void adc_stop();
- void adc_recalc();
- TIMER_CALLBACK_MEMBER(adc_timer_exp);
-
- // SIO
- void sio_start();
- void sio_stop();
- void sio_recalc();
- TIMER_CALLBACK_MEMBER(sio_timer_exp);
-
- // IIS
- inline void iface_i2s_data_w(address_space &space, int ch, UINT16 data);
- void iis_start();
- void iis_stop();
- TIMER_CALLBACK_MEMBER(iis_timer_exp);
-
- // ZDMA
- void zdma_trigger(int ch);
- void zdma_start(int ch);
- UINT32 zdma_r(int ch, UINT32 offset);
- void zdma_w(int ch, UINT32 offset, UINT32 data, UINT32 mem_mask);
- TIMER_CALLBACK_MEMBER(zdma_timer_exp);
-
- // BDMA
- void bdma_trigger(int ch);
- void bdma_request_iis();
- UINT32 bdma_r(int ch, UINT32 offset);
- void bdma_start(int ch);
- void bdma_stop(int ch);
- void bdma_w(int ch, UINT32 offset, UINT32 data, UINT32 mem_mask);
- TIMER_CALLBACK_MEMBER(bdma_timer_exp);
-
- cpu_device *m_cpu;
- //s3c44b0_memcon_t m_memcon;
- s3c44b0_irq_t m_irq;
- s3c44b0_dma_t m_zdma[2];
- s3c44b0_dma_t m_bdma[2];
- s3c44b0_clkpow_t m_clkpow;
- s3c44b0_lcd_t m_lcd;
- s3c44b0_uart_t m_uart[2];
- s3c44b0_sio_t m_sio;
- s3c44b0_pwm_t m_pwm;
- s3c44b0_wdt_t m_wdt;
- s3c44b0_iic_t m_iic;
- s3c44b0_iis_t m_iis;
- s3c44b0_gpio_t m_gpio;
- //s3c44b0_rtc_t m_rtc;
- s3c44b0_adc_t m_adc;
- s3c44b0_cpuwrap_t m_cpuwrap;
-
- devcb_read32 m_port_r_cb;
- devcb_write32 m_port_w_cb;
- devcb_write_line m_scl_w_cb;
- devcb_read_line m_sda_r_cb;
- devcb_write_line m_sda_w_cb;
- devcb_read32 m_data_r_cb;
- devcb_write16 m_data_w_cb;
-
- void s3c44b0_postload();
-};
-
-extern const device_type S3C44B0;
-
-
-#define MCFG_S3C44B0_GPIO_PORT_R_CB(_devcb) \
- devcb = &s3c44b0_device::set_gpio_port_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C44B0_GPIO_PORT_W_CB(_devcb) \
- devcb = &s3c44b0_device::set_gpio_port_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C44B0_I2C_SCL_W_CB(_devcb) \
- devcb = &s3c44b0_device::set_i2c_scl_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C44B0_I2C_SDA_R_CB(_devcb) \
- devcb = &s3c44b0_device::set_i2c_sda_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C44B0_I2C_SDA_W_CB(_devcb) \
- devcb = &s3c44b0_device::set_i2c_sda_w_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C44B0_ADC_DATA_R_CB(_devcb) \
- devcb = &s3c44b0_device::set_adc_data_r_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_S3C44B0_I2S_DATA_W_CB(_devcb) \
- devcb = &s3c44b0_device::set_i2s_data_w_callback(*device, DEVCB_##_devcb);
-
-
-#endif
diff --git a/src/emu/machine/saturn.c b/src/emu/machine/saturn.c
deleted file mode 100644
index cf79fdc26a2..00000000000
--- a/src/emu/machine/saturn.c
+++ /dev/null
@@ -1,1003 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:David Haywood, Angelo Salese, Olivier Galibert, Mariusz Wojcieszek, R. Belmont
-/**************************************************************************************
-
- Sega Saturn (c) 1994 Sega
-
- @todo List of things that needs to be implemented:
- - There's definitely an ack mechanism in SCU irqs. This is almost surely done via
- the ISM register (i.e. going 0->1 to the given bit acks it).
- - There might be a delay to exactly when SCU irqs happens. This is due to the basic
- fact that SCU runs at 14-ish MHz, so it needs some time before actually firing the
- irq.
- - Vblank-Out actually happens at the last screen line, not at 0.
- - VDP2 V counter has a similar roll-back as MD correspondent register:
- vpos line 0 == 0x1ff (Vblank-Out happens here)
- vpos line 1 == 0
- ...
- vpos line 241 == 0xf0 (Vblank-In happens here)
- vpos line 246 == 0xf5
- vpos line 247 == 0x1ef (rolls back here)
- vpos line 263 == 0x1ff again
- - HBlank bit seems to follow a normal logic instead.
- - Timer 0 doesn't work if the TENB bit isn't enabled (documentation is a bit fussy
- over this).
- - Timer 0 fires at the HBlank-In signal, not before.
- - VDP2 H Counter actually counts x2 in non Hi-Res mode.
- - Timer 1 is definitely annoying. Starts from H-Blank signal and starts counting from
- that position.
- H counter value 0x282 (642) -> timer 1 fires at setting 1
- H counter value 0x284 (644) -> 2
- H counter value 0x2a0 (672) -> 0x10
- H counter value 0x2c0 (704) -> 0x20
- H counter value 0x300 (768) -> 0x40
- H counter value 0x340 (832) -> 0x60
- H counter value 0x352 (850) -> 0x69
- H counter value 0x000 (0) -> 0x6a, V counter goes +1 here (max range?)
- H counter value 0x02c (44) -> 0x80
- H counter value 0x0ec (236) -> 0xe0
- H counter value 0x12c (300) -> 0x100
- - Timer 1 seems to count backwards compared to Timer 0 from setting 0x6b onward.
- - Yabause claims that if VDP2 DISP bit isn't enabled then vblank irqs (hblank too?)
- doesn't happen.
-
-**************************************************************************************/
-
-#include "emu.h"
-#include "includes/stv.h"
-#include "cpu/sh2/sh2.h"
-#include "cpu/scudsp/scudsp.h"
-
-/* TODO: do this in a verboselog style */
-#define LOG_CDB 0
-#define LOG_SCU 1
-#define LOG_IRQ 0
-#define LOG_IOGA 0
-
-int saturn_state::DectoBCD(int num)
-{
- int i, cnt = 0, tmp, res = 0;
-
- while (num > 0) {
- tmp = num;
- while (tmp >= 10) tmp %= 10;
- for (i=0; i<cnt; i++)
- tmp *= 16;
- res += tmp;
- cnt++;
- num /= 10;
- }
-
- return res;
-}
-
-/**************************************************************************************/
-
-/*
-
-SCU Handling
-
-*/
-
-/**********************************************************************************
-SCU Register Table
-offset,relative address
-Registers are in long words.
-===================================================================================
-0 0000 Level 0 DMA Set Register
-1 0004
-2 0008
-3 000c
-4 0010
-5 0014
-6 0018
-7 001c
-8 0020 Level 1 DMA Set Register
-9 0024
-10 0028
-11 002c
-12 0030
-13 0034
-14 0038
-15 003c
-16 0040 Level 2 DMA Set Register
-17 0044
-18 0048
-19 004c
-20 0050
-21 0054
-22 0058
-23 005c
-24 0060 DMA Forced Stop
-25 0064
-26 0068
-27 006c
-28 0070 <Free>
-29 0074
-30 0078
-31 007c DMA Status Register
-32 0080 DSP Program Control Port
-33 0084 DSP Program RAM Data Port
-34 0088 DSP Data RAM Address Port
-35 008c DSP Data RAM Data Port
-36 0090 Timer 0 Compare Register
-37 0094 Timer 1 Set Data Register
-38 0098 Timer 1 Mode Register
-39 009c <Free>
-40 00a0 Interrupt Mask Register
-41 00a4 Interrupt Status Register
-42 00a8 A-Bus Interrupt Acknowledge
-43 00ac <Free>
-44 00b0 A-Bus Set Register
-45 00b4
-46 00b8 A-Bus Refresh Register
-47 00bc <Free>
-48 00c0
-49 00c4 SCU SDRAM Select Register
-50 00c8 SCU Version Register
-51 00cc <Free>
-52 00cf
-===================================================================================
-DMA Status Register(32-bit):
-xxxx xxxx x--- xx-- xx-- xx-- xx-- xx-- UNUSED
----- ---- -x-- ---- ---- ---- ---- ---- DMA DSP-Bus access
----- ---- --x- ---- ---- ---- ---- ---- DMA B-Bus access
----- ---- ---x ---- ---- ---- ---- ---- DMA A-Bus access
----- ---- ---- --x- ---- ---- ---- ---- DMA lv 1 interrupt
----- ---- ---- ---x ---- ---- ---- ---- DMA lv 0 interrupt
----- ---- ---- ---- --x- ---- ---- ---- DMA lv 2 in stand-by
----- ---- ---- ---- ---x ---- ---- ---- DMA lv 2 in operation
----- ---- ---- ---- ---- --x- ---- ---- DMA lv 1 in stand-by
----- ---- ---- ---- ---- ---x ---- ---- DMA lv 1 in operation
----- ---- ---- ---- ---- ---- --x- ---- DMA lv 0 in stand-by
----- ---- ---- ---- ---- ---- ---x ---- DMA lv 0 in operation
----- ---- ---- ---- ---- ---- ---- --x- DSP side DMA in stand-by
----- ---- ---- ---- ---- ---- ---- ---x DSP side DMA in operation
-
-**********************************************************************************/
-/*
-DMA TODO:
--Remove CD transfer DMA hack (tied with CD block bug(s)?)
--Add timings(but how fast are each DMA?).
--Add level priority & DMA status register.
-*/
-
-#define DIRECT_MODE(_lv_) (!(m_scu_regs[5+(_lv_*8)] & 0x01000000))
-#define INDIRECT_MODE(_lv_) (m_scu_regs[5+(_lv_*8)] & 0x01000000)
-#define DRUP(_lv_) (m_scu_regs[5+(_lv_*8)] & 0x00010000)
-#define DWUP(_lv_) (m_scu_regs[5+(_lv_*8)] & 0x00000100)
-
-/*These macros sets the various DMA status flags.*/
-#define DnMV_1(_ch_) m_scu.status|=(0x10 << 4 * _ch_)
-#define DnMV_0(_ch_) m_scu.status&=~(0x10 << 4 * _ch_)
-
-/*For area checking*/
-#define BIOS_BUS(var) (var & 0x07f00000) == 0
-#define ABUS(_lv_) ((m_scu.src[_lv_] & 0x07000000) >= 0x02000000) && ((m_scu.src[_lv_] & 0x07000000) <= 0x04000000)
-#define BBUS(_lv_) ((scu_##_lv_ & 0x07ffffff) >= 0x05a00000) && ((scu_##_lv_ & 0x07ffffff) <= 0x05ffffff)
-#define VDP1_REGS(_lv_) ((scu_##_lv_ & 0x07ffffff) >= 0x05d00000) && ((scu_##_lv_ & 0x07ffffff) <= 0x05dfffff)
-#define VDP2(_lv_) ((scu_##_lv_ & 0x07ffffff) >= 0x05e00000) && ((scu_##_lv_ & 0x07ffffff) <= 0x05fdffff)
-#define WORK_RAM_L(_lv_) ((scu_##_lv_ & 0x07ffffff) >= 0x00200000) && ((scu_##_lv_ & 0x07ffffff) <= 0x002fffff)
-#define WORK_RAM_H(var) (var & 0x07000000) == 0x06000000
-#define SOUND_RAM(_lv_) ((scu_##_lv_ & 0x07ffffff) >= 0x05a00000) && ((scu_##_lv_ & 0x07ffffff) <= 0x05afffff)
-
-void saturn_state::scu_do_transfer(UINT8 event)
-{
- address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
- int i;
-
- for(i=0;i<3;i++)
- {
- if(m_scu.enable_mask[i] && m_scu.start_factor[i] == event)
- {
- if(DIRECT_MODE(i)) { scu_dma_direct(space,i); }
- else { scu_dma_indirect(space,i); }
- }
- }
-}
-
-/* test pending irqs */
-void saturn_state::scu_test_pending_irq()
-{
- int i;
- const int irq_level[32] = { 0xf, 0xe, 0xd, 0xc,
- 0xb, 0xa, 0x9, 0x8,
- 0x8, 0x6, 0x6, 0x5,
- 0x3, 0x2, -1, -1,
- 0x7, 0x7, 0x7, 0x7,
- 0x4, 0x4, 0x4, 0x4,
- 0x1, 0x1, 0x1, 0x1,
- 0x1, 0x1, 0x1, 0x1 };
-
- for(i=0;i<32;i++)
- {
- if((!(m_scu.ism & 1 << i)) && (m_scu.ist & 1 << i))
- {
- if(irq_level[i] != -1) /* TODO: cheap check for undefined irqs */
- {
- m_maincpu->set_input_line_and_vector(irq_level[i], HOLD_LINE, 0x40 + i);
- m_scu.ist &= ~(1 << i);
- return; /* avoid spurious irqs, correct? */
- }
- }
- }
-}
-
-READ32_MEMBER(saturn_state::saturn_scu_r)
-{
- UINT32 res;
-
- /*TODO: write only registers must return 0 or open bus */
- switch(offset)
- {
- case 0x5c/4:
- // Super Major League and Shin Megami Tensei - Akuma Zensho reads from there (undocumented), DMA status mirror?
- if(LOG_SCU && !space.debugger_access()) logerror("(PC=%08x) DMA status reg read\n",space.device().safe_pc());
- res = m_scu.status;
- break;
- case 0x7c/4:
- if(LOG_SCU && !space.debugger_access()) logerror("(PC=%08x) DMA status reg read\n",space.device().safe_pc());
- res = m_scu.status;
- break;
- case 0x80/4:
- res = m_scudsp->program_control_r(space, 0, mem_mask);
- break;
- case 0x8c/4:
- if(LOG_SCU && !space.debugger_access()) logerror( "DSP mem read at %08X\n", m_scu_regs[34]);
- res = m_scudsp->ram_address_r(space, 0, mem_mask);
- break;
- case 0xa0/4:
- if(LOG_SCU && !space.debugger_access()) logerror("(PC=%08x) IRQ mask reg read %08x MASK=%08x\n",space.device().safe_pc(),mem_mask,m_scu_regs[0xa0/4]);
- res = m_scu.ism;
- break;
- case 0xa4/4:
- if(LOG_SCU && !space.debugger_access()) logerror("(PC=%08x) IRQ status reg read MASK=%08x IST=%08x | ISM=%08x\n",space.device().safe_pc(),mem_mask,m_scu.ist,m_scu.ism);
- /* TODO: Bug! trips an HW fault. Basically, it tries to read the IST bit 1 with that irq enabled.
- Densetsu no Ogre Battle doesn't like this, so it needs investigation ...
- */
-// res = m_scu.ist | ~m_scu.ism;
- res = m_scu.ist;
- break;
- case 0xc8/4:
- if(LOG_SCU && !space.debugger_access()) logerror("(PC=%08x) SCU version reg read\n",space.device().safe_pc());
- res = 0x00000004;/*SCU Version 4, OK? */
- break;
- default:
- if(LOG_SCU && !space.debugger_access()) logerror("(PC=%08x) SCU reg read at %d = %08x\n",space.device().safe_pc(),offset,m_scu_regs[offset]);
- res = m_scu_regs[offset];
- break;
- }
-
- return res;
-}
-
-#define DMA_CH ((offset & 0x18) / 8)
-
-WRITE32_MEMBER(saturn_state::saturn_scu_w)
-{
- COMBINE_DATA(&m_scu_regs[offset]);
-
- switch(offset)
- {
- /*LV 0 DMA*/
- case 0x00/4: case 0x20/4: case 0x40/4: m_scu.src[DMA_CH] = ((m_scu_regs[offset] & 0x07ffffff) >> 0); break;
- case 0x04/4: case 0x24/4: case 0x44/4: m_scu.dst[DMA_CH] = ((m_scu_regs[offset] & 0x07ffffff) >> 0); break;
- case 0x08/4: case 0x28/4: case 0x48/4: m_scu.size[DMA_CH] = ((m_scu_regs[offset] & ((offset == 2) ? 0x000fffff : 0xfff)) >> 0); break;
- case 0x0c/4: case 0x2c/4: case 0x4c/4:
- m_scu.src_add[DMA_CH] = (m_scu_regs[offset] & 0x100) ? 4 : 0;
- m_scu.dst_add[DMA_CH] = 1 << (m_scu_regs[offset] & 7);
- if(m_scu.dst_add[DMA_CH] == 1) { m_scu.dst_add[DMA_CH] = 0; }
- break;
- case 0x10/4: case 0x30/4: case 0x50/4:
- m_scu.enable_mask[DMA_CH] = (data & 0x100) >> 8;
- if(m_scu.enable_mask[DMA_CH] && m_scu.start_factor[DMA_CH] == 7 && m_scu_regs[offset] & 1)
- {
- if(DIRECT_MODE(DMA_CH)) { scu_dma_direct(space,DMA_CH); }
- else { scu_dma_indirect(space,DMA_CH); }
- m_scu_regs[offset]&=~1;//disable starting bit.
- }
- break;
- case 0x14/4: case 0x34/4: case 0x54/4:
- if(INDIRECT_MODE(DMA_CH))
- {
- //if(LOG_SCU) logerror("Indirect Mode DMA lv %d set\n",DMA_CH);
- if(!DWUP(DMA_CH)) m_scu.index[DMA_CH] = m_scu.dst[DMA_CH];
- }
-
- m_scu.start_factor[DMA_CH] = m_scu_regs[offset] & 7;
- break;
-
- case 0x60/4:
- if(LOG_SCU) logerror("DMA Forced Stop Register set = %02x\n",m_scu_regs[24]);
- break;
- case 0x7c/4: if(LOG_SCU) logerror("Warning: DMA status WRITE! Offset %02x(%d)\n",offset*4,offset); break;
- /*DSP section*/
- case 0x80/4:
- m_scudsp->program_control_w(space, 0, m_scu_regs[offset], mem_mask);
- if(LOG_SCU) logerror("SCU DSP: Program Control Port Access %08x\n",data);
- break;
- case 0x84/4:
- m_scudsp->program_w(space, 0, m_scu_regs[offset], mem_mask);
- if(LOG_SCU) logerror("SCU DSP: Program RAM Data Port Access %08x\n",data);
- break;
- case 0x88/4:
- m_scudsp->ram_address_control_w(space, 0,m_scu_regs[offset], mem_mask);
- if(LOG_SCU) logerror("SCU DSP: Data RAM Address Port Access %08x\n",data);
- break;
- case 0x8c/4:
- m_scudsp->ram_address_w(space, 0, m_scu_regs[offset], mem_mask);
- if(LOG_SCU) logerror("SCU DSP: Data RAM Data Port Access %08x\n",data);
- break;
- case 0x90/4: /*if(LOG_SCU) logerror("timer 0 compare data = %03x\n",m_scu_regs[36]);*/ break;
- case 0x94/4: /*if(LOG_SCU) logerror("timer 1 set data = %08x\n",m_scu_regs[37]);*/ break;
- case 0x98/4: /*if(LOG_SCU) logerror("timer 1 mode data = %08x\n",m_scu_regs[38]);*/ break;
- case 0xa0/4: /* IRQ mask */
- m_scu.ism = m_scu_regs[0xa0/4];
- scu_test_pending_irq();
- break;
- case 0xa4/4: /* IRQ control */
- if(LOG_SCU) logerror("PC=%08x IRQ status reg set:%08x %08x\n",space.device().safe_pc(),m_scu_regs[41],mem_mask);
- m_scu.ist &= m_scu_regs[offset];
- scu_test_pending_irq();
- break;
- case 0xa8/4:
- /* This sends an irq signal to the extra devices connected to the A-Bus, not really needed for now. */
- //if(LOG_SCU) logerror("A-Bus IRQ ACK %08x\n",m_scu_regs[42]);
- break;
- case 0xc4/4: if(LOG_SCU) logerror("SCU SDRAM set: %02x\n",m_scu_regs[49]); break;
- default: if(LOG_SCU) logerror("Warning: unused SCU reg set %d = %08x\n",offset,data);
- }
-}
-
-/*Lv 0 DMA end irq*/
-TIMER_CALLBACK_MEMBER(saturn_state::dma_lv0_ended )
-{
- if(!(m_scu.ism & IRQ_DMALV0))
- m_maincpu->set_input_line_and_vector(5, HOLD_LINE, 0x4b);
- else
- m_scu.ist |= (IRQ_DMALV0);
-
- DnMV_0(0);
-}
-
-/*Lv 1 DMA end irq*/
-TIMER_CALLBACK_MEMBER(saturn_state::dma_lv1_ended)
-{
- if(!(m_scu.ism & IRQ_DMALV1))
- m_maincpu->set_input_line_and_vector(6, HOLD_LINE, 0x4a);
- else
- m_scu.ist |= (IRQ_DMALV1);
-
- DnMV_0(1);
-}
-
-/*Lv 2 DMA end irq*/
-TIMER_CALLBACK_MEMBER(saturn_state::dma_lv2_ended)
-{
- if(!(m_scu.ism & IRQ_DMALV2))
- m_maincpu->set_input_line_and_vector(6, HOLD_LINE, 0x49);
- else
- m_scu.ist |= (IRQ_DMALV2);
-
- DnMV_0(2);
-}
-
-void saturn_state::scu_single_transfer(address_space &space, UINT32 src, UINT32 dst,UINT8 *src_shift)
-{
- UINT32 src_data;
-
- if(src & 1)
- {
- /* Road Blaster does a work ram h to color ram with offsetted source address, do some data rotation */
- src_data = ((space.read_dword(src & 0x07fffffc) & 0x00ffffff)<<8);
- src_data |= ((space.read_dword((src & 0x07fffffc)+4) & 0xff000000) >> 24);
- src_data >>= (*src_shift)*16;
- }
- else
- src_data = space.read_dword(src & 0x07fffffc) >> (*src_shift)*16;
-
- space.write_word(dst,src_data);
-
- *src_shift ^= 1;
-}
-
-void saturn_state::scu_dma_direct(address_space &space, UINT8 dma_ch)
-{
- UINT32 tmp_src,tmp_dst,total_size;
- UINT8 cd_transfer_flag;
-
- if(m_scu.src_add[dma_ch] == 0 || (m_scu.dst_add[dma_ch] != 2 && m_scu.dst_add[dma_ch] != 4))
- {
- if(LOG_SCU) printf("DMA lv %d transfer START\n"
- "Start %08x End %08x Size %04x\n",dma_ch,m_scu.src[dma_ch],m_scu.dst[dma_ch],m_scu.size[dma_ch]);
- if(LOG_SCU) printf("Start Add %04x Destination Add %04x\n",m_scu.src_add[dma_ch],m_scu.dst_add[dma_ch]);
- }
-
- /* Game Basic and World Cup 98 trips this, according to the docs the SCU can't transfer from BIOS area (can't communicate from/to that bus) */
- if(BIOS_BUS(m_scu.src[dma_ch]))
- {
- popmessage("Warning: SCU transfer from BIOS area, contact MAMEdev");
- if(!(m_scu.ism & IRQ_DMAILL))
- m_maincpu->set_input_line_and_vector(3, HOLD_LINE, 0x4c);
- else
- m_scu.ist |= (IRQ_DMAILL);
- return;
- }
-
- DnMV_1(dma_ch);
-
- /* max size */
- if(m_scu.size[dma_ch] == 0) { m_scu.size[dma_ch] = (dma_ch == 0) ? 0x00100000 : 0x1000; }
-
- tmp_src = tmp_dst = 0;
-
- total_size = m_scu.size[dma_ch];
- if(!(DRUP(dma_ch))) tmp_src = m_scu.src[dma_ch];
- if(!(DWUP(dma_ch))) tmp_dst = m_scu.dst[dma_ch];
-
- cd_transfer_flag = m_scu.src_add[dma_ch] == 0 && m_scu.src[dma_ch] == 0x05818000;
-
- /* TODO: Many games directly accesses CD-ROM register 0x05818000, it must be a dword access with current implementation otherwise it won't work */
- if(cd_transfer_flag)
- {
- int i;
- if(WORK_RAM_H(m_scu.dst[dma_ch]))
- m_scu.dst_add[dma_ch] = 4;
- else
- m_scu.dst_add[dma_ch] <<= 1;
-
- for (i = 0; i < m_scu.size[dma_ch];i+=m_scu.dst_add[dma_ch])
- {
- space.write_dword(m_scu.dst[dma_ch],space.read_dword(m_scu.src[dma_ch]));
- if(m_scu.dst_add[dma_ch] == 8)
- space.write_dword(m_scu.dst[dma_ch]+4,space.read_dword(m_scu.src[dma_ch]));
-
- m_scu.src[dma_ch]+=m_scu.src_add[dma_ch];
- m_scu.dst[dma_ch]+=m_scu.dst_add[dma_ch];
- }
- }
- else
- {
- int i;
- UINT8 src_shift;
-
- src_shift = ((m_scu.src[dma_ch] & 2) >> 1) ^ 1;
-
- for (i = 0; i < m_scu.size[dma_ch];i+=2)
- {
- scu_single_transfer(space,m_scu.src[dma_ch],m_scu.dst[dma_ch],&src_shift);
-
- if(src_shift)
- m_scu.src[dma_ch]+=m_scu.src_add[dma_ch];
-
- /* if target is Work RAM H, the add value is fixed, behaviour confirmed by Final Romance 2, Virtual Mahjong and Burning Rangers */
- m_scu.dst[dma_ch]+=(WORK_RAM_H(m_scu.dst[dma_ch])) ? 2 : m_scu.dst_add[dma_ch];
- }
- }
-
- /* Burning Rangers doesn't agree with this. */
-// m_scu.size[dma_ch] = 0;
- if(!(DRUP(dma_ch))) m_scu.src[dma_ch] = tmp_src;
- if(!(DWUP(dma_ch))) m_scu.dst[dma_ch] = tmp_dst;
-
- {
- /*TODO: Timing is a guess. */
- switch(dma_ch)
- {
- case 0: machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(total_size/4), timer_expired_delegate(FUNC(saturn_state::dma_lv0_ended),this)); break;
- case 1: machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(total_size/4), timer_expired_delegate(FUNC(saturn_state::dma_lv1_ended),this)); break;
- case 2: machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(total_size/4), timer_expired_delegate(FUNC(saturn_state::dma_lv2_ended),this)); break;
- }
- }
-}
-
-void saturn_state::scu_dma_indirect(address_space &space,UINT8 dma_ch)
-{
- /*Helper to get out of the cycle*/
- UINT8 job_done = 0;
- /*temporary storage for the transfer data*/
- UINT32 tmp_src;
- UINT32 indirect_src,indirect_dst;
- INT32 indirect_size;
- UINT32 total_size = 0;
-
- DnMV_1(dma_ch);
-
- m_scu.index[dma_ch] = m_scu.dst[dma_ch];
-
- do{
- tmp_src = m_scu.index[dma_ch];
-
- indirect_size = space.read_dword(m_scu.index[dma_ch]);
- indirect_src = space.read_dword(m_scu.index[dma_ch]+8);
- indirect_dst = space.read_dword(m_scu.index[dma_ch]+4);
-
- /*Indirect Mode end factor*/
- if(indirect_src & 0x80000000)
- job_done = 1;
-
- if(m_scu.src_add[dma_ch] == 0 || (m_scu.dst_add[dma_ch] != 2))
- {
- if(LOG_SCU) printf("DMA lv %d indirect mode transfer START\n"
- "Index %08x Start %08x End %08x Size %04x\n",dma_ch,tmp_src,indirect_src,indirect_dst,indirect_size);
- if(LOG_SCU) printf("Start Add %04x Destination Add %04x\n",m_scu.src_add[dma_ch],m_scu.dst_add[dma_ch]);
- }
-
- indirect_src &=0x07ffffff;
- indirect_dst &=0x07ffffff;
- indirect_size &= ((dma_ch == 0) ? 0xfffff : 0x3ffff); //TODO: Guardian Heroes sets up a 0x23000 transfer for the FMV?
-
- if(indirect_size == 0) { indirect_size = (dma_ch == 0) ? 0x00100000 : 0x2000; }
-
- {
- int i;
- UINT8 src_shift;
-
- src_shift = ((indirect_src & 2) >> 1) ^ 1;
-
- for (i = 0; i < indirect_size;i+=2)
- {
- scu_single_transfer(space,indirect_src,indirect_dst,&src_shift);
-
- if(src_shift)
- indirect_src+=m_scu.src_add[dma_ch];
-
- indirect_dst+= (WORK_RAM_H(indirect_dst)) ? 2 : m_scu.dst_add[dma_ch];
- }
- }
-
- /* Guess: Size + data acquire (1 cycle for src/dst/size) */
- total_size += indirect_size + 3*4;
-
- //if(DRUP(0)) space.write_dword(tmp_src+8,m_scu.src[0]|job_done ? 0x80000000 : 0);
- //if(DWUP(0)) space.write_dword(tmp_src+4,m_scu.dst[0]);
-
- m_scu.index[dma_ch] = tmp_src+0xc;
-
- }while(job_done == 0);
-
- {
- /*TODO: change DMA into DRQ model. Timing is a guess. */
- switch(dma_ch)
- {
- case 0: machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(total_size/4), timer_expired_delegate(FUNC(saturn_state::dma_lv0_ended),this)); break;
- case 1: machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(total_size/4), timer_expired_delegate(FUNC(saturn_state::dma_lv1_ended),this)); break;
- case 2: machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(total_size/4), timer_expired_delegate(FUNC(saturn_state::dma_lv2_ended),this)); break;
- }
- }
-}
-
-
-/**************************************************************************************/
-
-WRITE16_MEMBER(saturn_state::saturn_soundram_w)
-{
- //machine().scheduler().synchronize(); // force resync
-
- COMBINE_DATA(&m_sound_ram[offset]);
-}
-
-READ16_MEMBER(saturn_state::saturn_soundram_r)
-{
- //machine().scheduler().synchronize(); // force resync
-
- return m_sound_ram[offset];
-}
-
-/* communication,SLAVE CPU acquires data from the MASTER CPU and triggers an irq. */
-WRITE32_MEMBER(saturn_state::minit_w)
-{
- //logerror("cpu %s (PC=%08X) MINIT write = %08x\n", space.device().tag(), space.device().safe_pc(),data);
- machine().scheduler().boost_interleave(m_minit_boost_timeslice, attotime::from_usec(m_minit_boost));
- machine().scheduler().trigger(1000);
- machine().scheduler().synchronize(); // force resync
- m_slave->sh2_set_frt_input(PULSE_LINE);
-}
-
-WRITE32_MEMBER(saturn_state::sinit_w)
-{
- //logerror("cpu %s (PC=%08X) SINIT write = %08x\n", space.device().tag(), space.device().safe_pc(),data);
- machine().scheduler().boost_interleave(m_sinit_boost_timeslice, attotime::from_usec(m_sinit_boost));
- machine().scheduler().synchronize(); // force resync
- m_maincpu->sh2_set_frt_input(PULSE_LINE);
-}
-
-/*
-TODO:
-Some games seems to not like either MAME's interleave system and/or SH-2 DRC, causing an hard crash.
-Reported games are:
-Blast Wind (before FMV)
-Choro Q Park (car selection)
-060311E4: MOV.L R14,@-SP ;R14 = 0x60ffba0 / R15 = 0x60ffba0
-060311E6: MOV SP,R14 ;R14 = 0x60ffba0 / R15 = 0x60ffb9c / [0x60ffb9c] <- 0x60ffba0
-060311E8: MOV.L @SP+,R14 ;R14 = 0x60ffb9c / R15 = 0x60ffb9c / [0x60ffb9c] -> R14
-060311EA: RTS ;R14 = 0x60ffba0 / R15 = 0x60ffba0
-060311EC: NOP
-06031734: MULS.W R9, R8 ;R14 = 0x60ffba0 / R15 = 0x60ffba0 / EA = 0x60311E4
-on DRC this becomes:
-R14 0x6031b78 (cause of the crash later on), R15 = 0x60ffba4 and EA = 0
-
-Shinrei Jusatsushi Taromaru (options menu)
-
-*/
-
-WRITE32_MEMBER(saturn_state::saturn_minit_w)
-{
- //logerror("cpu %s (PC=%08X) MINIT write = %08x\n", space.device().tag(), space.device().safe_pc(),data);
- if(m_fake_comms->read() & 1)
- machine().scheduler().synchronize(); // force resync
- else
- {
- machine().scheduler().boost_interleave(m_minit_boost_timeslice, attotime::from_usec(m_minit_boost));
- machine().scheduler().trigger(1000);
- }
-
- m_slave->sh2_set_frt_input(PULSE_LINE);
-}
-
-WRITE32_MEMBER(saturn_state::saturn_sinit_w)
-{
- //logerror("cpu %s (PC=%08X) SINIT write = %08x\n", space.device().tag(), space.device().safe_pc(),data);
- if(m_fake_comms->read() & 1)
- machine().scheduler().synchronize(); // force resync
- else
- machine().scheduler().boost_interleave(m_sinit_boost_timeslice, attotime::from_usec(m_sinit_boost));
-
- m_maincpu->sh2_set_frt_input(PULSE_LINE);
-}
-
-
-READ8_MEMBER(saturn_state::saturn_backupram_r)
-{
- if(!(offset & 1))
- return 0; // yes, it makes sure the "holes" are there.
-
- return m_backupram[offset >> 1] & 0xff;
-}
-
-WRITE8_MEMBER(saturn_state::saturn_backupram_w)
-{
- if(!(offset & 1))
- return;
-
- m_backupram[offset >> 1] = data;
-}
-
-void saturn_state::scu_reset(void)
-{
- m_scu.ism = 0xbfff;
- m_scu.ist = 0;
- m_scu.start_factor[0] = 7;
- m_scu.start_factor[1] = 7;
- m_scu.start_factor[2] = 7;
- m_scu.status = 0;
-}
-
-TIMER_CALLBACK_MEMBER(saturn_state::stv_rtc_increment)
-{
- static const UINT8 dpm[12] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 };
- static int year_num, year_count;
-
- /*
- m_smpc.rtc_data[0] = DectoBCD(systime.local_time.year /100);
- m_smpc.rtc_data[1] = DectoBCD(systime.local_time.year %100);
- m_smpc.rtc_data[2] = (systime.local_time.weekday << 4) | (systime.local_time.month+1);
- m_smpc.rtc_data[3] = DectoBCD(systime.local_time.mday);
- m_smpc.rtc_data[4] = DectoBCD(systime.local_time.hour);
- m_smpc.rtc_data[5] = DectoBCD(systime.local_time.minute);
- m_smpc.rtc_data[6] = DectoBCD(systime.local_time.second);
- */
-
- m_smpc.rtc_data[6]++;
-
- /* seconds from 9 -> 10*/
- if((m_smpc.rtc_data[6] & 0x0f) >= 0x0a) { m_smpc.rtc_data[6]+=0x10; m_smpc.rtc_data[6]&=0xf0; }
- /* seconds from 59 -> 0 */
- if((m_smpc.rtc_data[6] & 0xf0) >= 0x60) { m_smpc.rtc_data[5]++; m_smpc.rtc_data[6] = 0; }
- /* minutes from 9 -> 10 */
- if((m_smpc.rtc_data[5] & 0x0f) >= 0x0a) { m_smpc.rtc_data[5]+=0x10; m_smpc.rtc_data[5]&=0xf0; }
- /* minutes from 59 -> 0 */
- if((m_smpc.rtc_data[5] & 0xf0) >= 0x60) { m_smpc.rtc_data[4]++; m_smpc.rtc_data[5] = 0; }
- /* hours from 9 -> 10 */
- if((m_smpc.rtc_data[4] & 0x0f) >= 0x0a) { m_smpc.rtc_data[4]+=0x10; m_smpc.rtc_data[4]&=0xf0; }
- /* hours from 23 -> 0 */
- if((m_smpc.rtc_data[4] & 0xff) >= 0x24) { m_smpc.rtc_data[3]++; m_smpc.rtc_data[2]+=0x10; m_smpc.rtc_data[4] = 0; }
- /* week day name sunday -> monday */
- if((m_smpc.rtc_data[2] & 0xf0) >= 0x70) { m_smpc.rtc_data[2]&=0x0f; }
- /* day number 9 -> 10 */
- if((m_smpc.rtc_data[3] & 0x0f) >= 0x0a) { m_smpc.rtc_data[3]+=0x10; m_smpc.rtc_data[3]&=0xf0; }
-
- // year BCD to dec conversion (for the leap year stuff)
- {
- year_num = (m_smpc.rtc_data[1] & 0xf);
-
- for(year_count = 0; year_count < (m_smpc.rtc_data[1] & 0xf0); year_count += 0x10)
- year_num += 0xa;
-
- year_num += (m_smpc.rtc_data[0] & 0xf)*0x64;
-
- for(year_count = 0; year_count < (m_smpc.rtc_data[0] & 0xf0); year_count += 0x10)
- year_num += 0x3e8;
- }
-
- /* month +1 check */
- /* the RTC have a range of 1980 - 2100, so we don't actually need to support the leap year special conditions */
- if(((year_num % 4) == 0) && (m_smpc.rtc_data[2] & 0xf) == 2)
- {
- if((m_smpc.rtc_data[3] & 0xff) >= dpm[(m_smpc.rtc_data[2] & 0xf)-1]+1+1)
- { m_smpc.rtc_data[2]++; m_smpc.rtc_data[3] = 0x01; }
- }
- else if((m_smpc.rtc_data[3] & 0xff) >= dpm[(m_smpc.rtc_data[2] & 0xf)-1]+1){ m_smpc.rtc_data[2]++; m_smpc.rtc_data[3] = 0x01; }
- /* year +1 check */
- if((m_smpc.rtc_data[2] & 0x0f) > 12) { m_smpc.rtc_data[1]++; m_smpc.rtc_data[2] = (m_smpc.rtc_data[2] & 0xf0) | 0x01; }
- /* year from 9 -> 10 */
- if((m_smpc.rtc_data[1] & 0x0f) >= 0x0a) { m_smpc.rtc_data[1]+=0x10; m_smpc.rtc_data[1]&=0xf0; }
- /* year from 99 -> 100 */
- if((m_smpc.rtc_data[1] & 0xf0) >= 0xa0) { m_smpc.rtc_data[0]++; m_smpc.rtc_data[1] = 0; }
-
- // probably not SO precise, here just for reference ...
- /* year from 999 -> 1000 */
- //if((m_smpc.rtc_data[0] & 0x0f) >= 0x0a) { m_smpc.rtc_data[0]+=0x10; m_smpc.rtc_data[0]&=0xf0; }
- /* year from 9999 -> 0 */
- //if((m_smpc.rtc_data[0] & 0xf0) >= 0xa0) { m_smpc.rtc_data[0] = 0; } //roll over
-}
-
-/* Official documentation says that the "RESET/TAS opcodes aren't supported", but Out Run definitely contradicts with it.
- Since that m68k can't reset itself via the RESET opcode I suppose that the SMPC actually do it by reading an i/o
- connected to this opcode. */
-WRITE_LINE_MEMBER(saturn_state::m68k_reset_callback)
-{
- machine().scheduler().timer_set(attotime::from_usec(100), timer_expired_delegate(FUNC(saturn_state::smpc_audio_reset_line_pulse), this));
-
- printf("m68k RESET opcode triggered\n");
-}
-
-WRITE8_MEMBER(saturn_state::scsp_irq)
-{
- // don't bother the 68k if it's off
- if (!m_en_68k)
- {
- return;
- }
-
- if (offset != 0)
- {
- if (data == ASSERT_LINE) m_scsp_last_line = offset;
- m_audiocpu->set_input_line(offset, data);
- }
- else
- {
- m_audiocpu->set_input_line(m_scsp_last_line, data);
- }
-}
-
-WRITE_LINE_MEMBER(saturn_state::scsp_to_main_irq)
-{
- if(state)
- {
- if(!(m_scu.ism & IRQ_SOUND_REQ))
- {
- m_maincpu->set_input_line_and_vector(9, HOLD_LINE, 0x46);
- scu_do_transfer(5);
- }
- else
- m_scu.ist |= (IRQ_SOUND_REQ);
- }
-}
-
-
-
-/*
-(Preliminary) explanation about this:
-VBLANK-OUT is used at the start of the vblank period.It also sets the timer zero
-variable to 0.
-If the Timer Compare register is zero too,the Timer 0 irq is triggered.
-
-HBLANK-IN is used at the end of each scanline except when in VBLANK-IN/OUT periods.
-
-The timer 0 is also incremented by one at each HBLANK and checked with the value
-of the Timer Compare register;if equal,the timer 0 irq is triggered here too.
-Notice that the timer 0 compare register can be more than the VBLANK maximum range,in
-this case the timer 0 irq is simply never triggered.This is a known Sega Saturn/ST-V "bug".
-
-VBLANK-IN is used at the end of the vblank period.
-
-SCU register[36] is the timer zero compare register.
-SCU register[40] is for IRQ masking.
-
-TODO:
-- VDP1 timing and CEF emulation isn't accurate at all.
-*/
-
-
-TIMER_DEVICE_CALLBACK_MEMBER(saturn_state::saturn_scanline)
-{
- int scanline = param;
- int y_step,vblank_line;
-
- vblank_line = get_vblank_start_position();
- y_step = get_ystep_count();
-
- //popmessage("%08x %d T0 %d T1 %d %08x",m_scu.ism ^ 0xffffffff,max_y,m_scu_regs[36],m_scu_regs[37],m_scu_regs[38]);
-
- if(scanline == 0*y_step)
- {
- if(!(m_scu.ism & IRQ_VBLANK_OUT))
- {
- m_maincpu->set_input_line_and_vector(0xe, HOLD_LINE, 0x41);
- scu_do_transfer(1);
- }
- else
- m_scu.ist |= (IRQ_VBLANK_OUT);
-
- }
- else if(scanline == vblank_line*y_step)
- {
- if(!(m_scu.ism & IRQ_VBLANK_IN))
- {
- m_maincpu->set_input_line_and_vector(0xf, HOLD_LINE ,0x40);
- scu_do_transfer(0);
- }
- else
- m_scu.ist |= (IRQ_VBLANK_IN);
-
- /* TODO: when Automatic Draw actually happens? Night Striker S is very fussy on this, and it looks like that VDP1 starts at more or less vblank-in time ... */
- video_update_vdp1();
- }
- else if((scanline % y_step) == 0 && scanline < vblank_line*y_step)
- {
- if(!(m_scu.ism & IRQ_HBLANK_IN))
- {
- m_maincpu->set_input_line_and_vector(0xd, HOLD_LINE, 0x42);
- scu_do_transfer(2);
- }
- else
- m_scu.ist |= (IRQ_HBLANK_IN);
- }
-
- if(scanline == (vblank_line+1)*y_step)
- {
- /* docs mentions that VBE happens one line after vblank-in. */
- if(STV_VDP1_VBE)
- m_vdp1.framebuffer_clear_on_next_frame = 1;
- }
-
-
- if(scanline == (m_scu_regs[36] & 0x3ff)*y_step)
- {
- if(!(m_scu.ism & IRQ_TIMER_0))
- {
- m_maincpu->set_input_line_and_vector(0xc, HOLD_LINE, 0x43 );
- scu_do_transfer(3);
- }
- else
- m_scu.ist |= (IRQ_TIMER_0);
- }
-
- /* TODO: this isn't completely correct */
- if(m_scu_regs[38] & 0x1)
- {
- if((!(m_scu_regs[38] & 0x100) && (scanline % y_step) == 0) ||
- ((m_scu_regs[38] & 0x100) && (scanline == (m_scu_regs[36] & 0x3ff)*y_step)))
- {
- if(!(m_scu.ism & IRQ_TIMER_1))
- {
- m_maincpu->set_input_line_and_vector(0xb, HOLD_LINE, 0x44 );
- scu_do_transfer(4);
- }
- else
- m_scu.ist |= (IRQ_TIMER_1);
- }
- }
-}
-
-TIMER_DEVICE_CALLBACK_MEMBER(saturn_state::saturn_slave_scanline )
-{
- int scanline = param;
- int y_step,vblank_line;
-
- vblank_line = get_vblank_start_position();
- y_step = get_ystep_count();
-
- if(scanline == vblank_line*y_step)
- m_slave->set_input_line_and_vector(0x6, HOLD_LINE, 0x43);
- else if((scanline % y_step) == 0 && scanline < vblank_line*y_step)
- m_slave->set_input_line_and_vector(0x2, HOLD_LINE, 0x41);
-}
-
-static const gfx_layout tiles8x8x4_layout =
-{
- 8,8,
- 0x100000/(32*8/8),
- 4,
- { 0, 1, 2, 3 },
- { 0, 4, 8, 12, 16, 20, 24, 28 },
- { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
- 32*8
-};
-
-static const gfx_layout tiles16x16x4_layout =
-{
- 16,16,
- 0x100000/(32*32/8),
- 4,
- { 0, 1, 2, 3 },
- { 0, 4, 8, 12, 16, 20, 24, 28,
- 32*8+0, 32*8+4, 32*8+8, 32*8+12, 32*8+16, 32*8+20, 32*8+24, 32*8+28,
-
- },
- { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
- 32*16, 32*17,32*18, 32*19,32*20,32*21,32*22,32*23
-
- },
- 32*32
-};
-
-static const gfx_layout tiles8x8x8_layout =
-{
- 8,8,
- 0x100000/(32*8/8),
- 8,
- { 0, 1, 2, 3, 4, 5, 6, 7 },
- { 0, 8, 16, 24, 32, 40, 48, 56 },
- { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64 },
- 32*8 /* really 64*8, but granularity is 32 bytes */
-};
-
-static const gfx_layout tiles16x16x8_layout =
-{
- 16,16,
- 0x100000/(64*16/8),
- 8,
- { 0, 1, 2, 3, 4, 5, 6, 7 },
- { 0, 8, 16, 24, 32, 40, 48, 56,
- 64*8+0, 65*8, 66*8, 67*8, 68*8, 69*8, 70*8, 71*8
-
- },
- { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64,
- 64*16, 64*17, 64*18, 64*19, 64*20, 64*21, 64*22, 64*23
- },
- 64*16 /* really 128*16, but granularity is 32 bytes */
-};
-
-
-
-
-GFXDECODE_START( stv )
- GFXDECODE_ENTRY( NULL, 0, tiles8x8x4_layout, 0x00, (0x80*(2+1)) )
- GFXDECODE_ENTRY( NULL, 0, tiles16x16x4_layout, 0x00, (0x80*(2+1)) )
- GFXDECODE_ENTRY( NULL, 0, tiles8x8x8_layout, 0x00, (0x08*(2+1)) )
- GFXDECODE_ENTRY( NULL, 0, tiles16x16x8_layout, 0x00, (0x08*(2+1)) )
-GFXDECODE_END
-
-WRITE_LINE_MEMBER(saturn_state::scudsp_end_w)
-{
- if(state)
- {
- if(!(m_scu.ism & IRQ_DSP_END))
- m_maincpu->set_input_line_and_vector(0xa, HOLD_LINE, 0x45);
- else
- m_scu.ist |= (IRQ_DSP_END);
- }
-}
-
-READ16_MEMBER(saturn_state::scudsp_dma_r)
-{
- address_space &program = m_maincpu->space(AS_PROGRAM);
- offs_t addr = offset;
-
-// printf("%08x\n",addr);
-
- return program.read_word(addr,mem_mask);
-}
-
-
-WRITE16_MEMBER(saturn_state::scudsp_dma_w)
-{
- address_space &program = m_maincpu->space(AS_PROGRAM);
- offs_t addr = offset;
-
-// printf("%08x %02x\n",addr,data);
-
- program.write_word(addr, data,mem_mask);
-}
diff --git a/src/emu/machine/serflash.c b/src/emu/machine/serflash.c
deleted file mode 100644
index 60ff6712a2b..00000000000
--- a/src/emu/machine/serflash.c
+++ /dev/null
@@ -1,411 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood, Luca Elia
-/* Serial Flash Device */
-
-/* todo: cleanup, refactor etc. */
-/* ghosteo.c is similar? */
-
-#include "emu.h"
-#include "machine/serflash.h"
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type SERFLASH = &device_creator<serflash_device>;
-
-//-------------------------------------------------
-// serflash_device - constructor
-//-------------------------------------------------
-
-serflash_device::serflash_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, SERFLASH, "Serial Flash", tag, owner, clock, "serflash", __FILE__),
- device_nvram_interface(mconfig, *this),
- m_length(0)
-{
-}
-
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void serflash_device::device_start()
-{
- m_length = machine().root_device().memregion( tag() )->bytes();
- m_region = machine().root_device().memregion( tag() )->base();
-
- m_flashwritemap.resize(m_length / FLASH_PAGE_SIZE);
- memset(&m_flashwritemap[0], 0, m_length / FLASH_PAGE_SIZE);
-}
-
-void serflash_device::device_reset()
-{
- m_flash_enab = 0;
- flash_hard_reset(machine());
-
- m_last_flash_cmd = 0x00;
- m_flash_addr_seq = 0;
- m_flash_addr = 0;
-
- m_flash_page_addr = 0;
-}
-
-//-------------------------------------------------
-// serflash_default - called to initialize SERFLASH to
-// its default state
-//-------------------------------------------------
-
-void serflash_device::nvram_default()
-{
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read SERFLASH from the
-// .nv file
-//-------------------------------------------------
-
-void serflash_device::nvram_read(emu_file &file)
-{
- if (m_length % FLASH_PAGE_SIZE) return; // region size must be multiple of flash page size
- int size = m_length / FLASH_PAGE_SIZE;
-
-
- if (file)
- {
- UINT32 page;
- file.read(&page, 4);
- while (page < size)
- {
- m_flashwritemap[page] = 1;
- file.read(m_region + page * FLASH_PAGE_SIZE, FLASH_PAGE_SIZE);
- file.read(&page, 4);
- }
- }
-
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write SERFLASH to the
-// .nv file
-//-------------------------------------------------
-
-void serflash_device::nvram_write(emu_file &file)
-{
- if (m_length % FLASH_PAGE_SIZE) return; // region size must be multiple of flash page size
- int size = m_length / FLASH_PAGE_SIZE;
-
- UINT32 page = 0;
- while (page < size)
- {
- if (m_flashwritemap[page])
- {
- file.write(&page, 4);
- file.write(m_region + page * FLASH_PAGE_SIZE, FLASH_PAGE_SIZE);
- }
- page++;
- }
- file.write(&page, 4);
-}
-
-void serflash_device::flash_hard_reset(running_machine &machine)
-{
-// logerror("%08x FLASH: RESET\n", cpuexec_describe_context(machine));
-
- m_flash_state = STATE_READ;
-
- m_flash_cmd_prev = -1;
- m_flash_cmd_seq = 0;
-
- m_flash_addr_seq = 0;
- m_flash_read_seq = 0;
-
- m_flash_row = 0;
- m_flash_col = 0;
-
- memset(m_flash_page_data, 0, FLASH_PAGE_SIZE);
- m_flash_page_addr = 0;
- m_flash_page_index = 0;
-}
-
-WRITE8_MEMBER( serflash_device::flash_enab_w )
-{
- //logerror("%08x FLASH: enab = %02X\n", m_maincpu->pc(), data);
- m_flash_enab = data;
-}
-
-void serflash_device::flash_change_state(running_machine &machine, flash_state_t state)
-{
- m_flash_state = state;
-
- m_flash_cmd_prev = -1;
- m_flash_cmd_seq = 0;
-
- m_flash_read_seq = 0;
- m_flash_addr_seq = 0;
-
- //logerror("flash_change_state - FLASH: state = %s\n", m_flash_state_name[state]);
-}
-
-WRITE8_MEMBER( serflash_device::flash_cmd_w )
-{
- if (!m_flash_enab)
- return;
-
- //logerror("%08x FLASH: cmd = %02X (prev = %02X)\n", m_maincpu->pc(), data, m_flash_cmd_prev);
-
- if (m_flash_cmd_prev == -1)
- {
- m_flash_cmd_prev = data;
-
- switch (data)
- {
- case 0x00: // READ
- m_flash_addr_seq = 0;
- break;
-
- case 0x60: // BLOCK ERASE
- m_flash_addr_seq = 0;
- break;
-
- case 0x70: // READ STATUS
- flash_change_state( space.machine(), STATE_READ_STATUS );
- break;
-
- case 0x80: // PAGE / CACHE PROGRAM
- m_flash_addr_seq = 0;
- // this actually seems to be set with the next 2 writes?
- m_flash_page_addr = 0;
- break;
-
- case 0x90: // READ ID
- flash_change_state( space.machine(), STATE_READ_ID );
- break;
-
- case 0xff: // RESET
- flash_change_state( space.machine(), STATE_IDLE );
- break;
-
- default:
- {
- //logerror("%08x FLASH: unknown cmd1 = %02X\n", cpu_get_pc(space.device()), data);
- }
- }
- }
- else
- {
- switch (m_flash_cmd_prev)
- {
- case 0x00: // READ
- if (data == 0x30)
- {
- memcpy(m_flash_page_data, m_region + m_flash_row * FLASH_PAGE_SIZE, FLASH_PAGE_SIZE);
- m_flash_page_addr = m_flash_col;
- m_flash_page_index = m_flash_row;
-
- flash_change_state( space.machine(), STATE_READ );
-
- //logerror("%08x FLASH: caching page = %04X\n", m_maincpu->pc(), m_flash_row);
- }
- break;
-
- case 0x60: // BLOCK ERASE
- if (data==0xd0)
- {
- flash_change_state( space.machine(), STATE_BLOCK_ERASE );
- m_flashwritemap[m_flash_col] |= 1;
- memset(m_region + m_flash_col * FLASH_PAGE_SIZE, 0xff, FLASH_PAGE_SIZE);
- //logerror("erased block %04x (%08x - %08x)\n", m_flash_col, m_flash_col * FLASH_PAGE_SIZE, ((m_flash_col+1) * FLASH_PAGE_SIZE)-1);
- }
- else
- {
- //logerror("unexpected 2nd command after BLOCK ERASE\n");
- }
- break;
- case 0x80:
- if (data==0x10)
- {
- flash_change_state( space.machine(), STATE_PAGE_PROGRAM );
- m_flashwritemap[m_flash_row] |= (memcmp(m_region + m_flash_row * FLASH_PAGE_SIZE, m_flash_page_data, FLASH_PAGE_SIZE) != 0);
- memcpy(m_region + m_flash_row * FLASH_PAGE_SIZE, m_flash_page_data, FLASH_PAGE_SIZE);
- //logerror("re-written block %04x (%08x - %08x)\n", m_flash_row, m_flash_row * FLASH_PAGE_SIZE, ((m_flash_row+1) * FLASH_PAGE_SIZE)-1);
-
- }
- else
- {
- //logerror("unexpected 2nd command after SPAGE PROGRAM\n");
- }
- break;
-
-
- default:
- {
- //logerror("%08x FLASH: unknown cmd2 = %02X (cmd1 = %02X)\n", m_maincpu->pc(), data, m_flash_cmd_prev);
- }
- }
- }
-}
-
-WRITE8_MEMBER( serflash_device::flash_data_w )
-{
- if (!m_flash_enab)
- return;
-
- //logerror("flash data write %04x\n", m_flash_page_addr);
- m_flash_page_data[m_flash_page_addr] = data;
- m_flash_page_addr++;
-}
-
-WRITE8_MEMBER( serflash_device::flash_addr_w )
-{
- if (!m_flash_enab)
- return;
-
- //logerror("%08x FLASH: addr = %02X (seq = %02X)\n", m_maincpu->pc(), data, m_flash_addr_seq);
-
- switch( m_flash_addr_seq++ )
- {
- case 0:
- m_flash_col = (m_flash_col & 0xff00) | data;
- break;
- case 1:
- m_flash_col = (m_flash_col & 0x00ff) | (data << 8);
- break;
- case 2:
- m_flash_row = (m_flash_row & 0xff00) | data;
- break;
- case 3:
- m_flash_row = (m_flash_row & 0x00ff) | (data << 8);
- m_flash_addr_seq = 0;
- break;
- }
-}
-
-READ8_MEMBER( serflash_device::flash_io_r )
-{
- UINT8 data = 0x00;
-// UINT32 old;
-
- if (!m_flash_enab)
- return 0xff;
-
- switch (m_flash_state)
- {
- case STATE_READ_ID:
- //old = m_flash_read_seq;
-
- switch( m_flash_read_seq++ )
- {
- case 0:
- data = 0xEC; // Manufacturer
- break;
- case 1:
- data = 0xF1; // Device
- break;
- case 2:
- data = 0x00; // XX
- break;
- case 3:
- data = 0x15; // Flags
- m_flash_read_seq = 0;
- break;
- }
-
- //logerror("%08x FLASH: read %02X from id(%02X)\n", m_maincpu->pc(), data, old);
- break;
-
- case STATE_READ:
- if (m_flash_page_addr > FLASH_PAGE_SIZE-1)
- m_flash_page_addr = FLASH_PAGE_SIZE-1;
-
- //old = m_flash_page_addr;
-
- data = m_flash_page_data[m_flash_page_addr++];
-
- //logerror("%08x FLASH: read data %02X from addr %03X (page %04X)\n", m_maincpu->pc(), data, old, m_flash_page_index);
- break;
-
- case STATE_READ_STATUS:
- // bit 7 = writeable, bit 6 = ready, bit 5 = ready/true ready, bit 1 = fail(N-1), bit 0 = fail
- data = 0xe0;
- //logerror("%08x FLASH: read status %02X\n", m_maincpu->pc(), data);
- break;
-
- default:
- {
- // logerror("%08x FLASH: unknown read in state %s\n",0x00/*m_maincpu->pc()*/, m_flash_state_name[m_flash_state]);
- }
- }
-
- return data;
-}
-
-READ8_MEMBER( serflash_device::flash_ready_r )
-{
- return 1;
-}
-
-
-
-READ8_MEMBER(serflash_device::n3d_flash_r)
-{
- if (m_last_flash_cmd==0x70) return 0xe0;
-
- if (m_last_flash_cmd==0x00)
- {
- UINT8 retdat = m_flash_page_data[m_flash_page_addr];
-
- //logerror("n3d_flash_r %02x %04x\n", offset, m_flash_page_addr);
-
- m_flash_page_addr++;
- return retdat;
- }
-
-
- logerror("n3d_flash_r %02x\n", offset);
- return 0x00;
-
-}
-
-
-WRITE8_MEMBER(serflash_device::n3d_flash_cmd_w)
-{
- logerror("n3d_flash_cmd_w %02x %02x\n", offset, data);
- m_last_flash_cmd = data;
-
- if (data==0x00)
- {
- memcpy(m_flash_page_data, m_region + m_flash_addr * FLASH_PAGE_SIZE, FLASH_PAGE_SIZE);
-
- }
-
-}
-
-WRITE8_MEMBER(serflash_device::n3d_flash_addr_w)
-{
-// logerror("n3d_flash_addr_w %02x %02x\n", offset, data);
-
- m_flash_addr_seq++;
-
- if (m_flash_addr_seq==3)
- m_flash_addr = (m_flash_addr & 0xffff00) | data;
-
- if (m_flash_addr_seq==4)
- m_flash_addr = (m_flash_addr & 0xff00ff) | data << 8;
-
- if (m_flash_addr_seq==5)
- m_flash_addr = (m_flash_addr & 0x00ffff) | data << 16;
-
- if (m_flash_addr_seq==5)
- {
- m_flash_addr_seq = 0;
- m_flash_page_addr = 0;
- logerror("set flash block to %08x\n", m_flash_addr);
- }
-}
diff --git a/src/emu/machine/serflash.h b/src/emu/machine/serflash.h
deleted file mode 100644
index fdda31e3912..00000000000
--- a/src/emu/machine/serflash.h
+++ /dev/null
@@ -1,108 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:David Haywood, Luca Elia
-/* Serial Flash */
-
-#pragma once
-
-#ifndef __SERFLASH_H__
-#define __SERFLASH_H__
-
-
-#define FLASH_PAGE_SIZE (2048+64)
-
-
-
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_SERFLASH_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SERFLASH, 0)
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-class serflash_device;
-
-typedef enum { STATE_IDLE = 0, STATE_READ, STATE_READ_ID, STATE_READ_STATUS, STATE_BLOCK_ERASE, STATE_PAGE_PROGRAM } flash_state_t;
-//const char *m_flash_state_name[] = { "IDLE", "READ", "READ_ID", "READ_STATUS", "BLOCK ERASE", "PAGE PROGRAM" };
-
-// custom initialization for default state
-typedef device_delegate<void (serflash_device &, void *, size_t)> serflash_init_delegate;
-
-
-// ======================> serflash_device
-
-class serflash_device : public device_t,
- public device_nvram_interface
-{
-public:
-
- // construction/destruction
- serflash_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER( flash_ready_r );
- DECLARE_READ8_MEMBER( flash_io_r );
- DECLARE_WRITE8_MEMBER( flash_addr_w );
- DECLARE_WRITE8_MEMBER( flash_data_w );
- DECLARE_WRITE8_MEMBER( flash_cmd_w );
- DECLARE_WRITE8_MEMBER( flash_enab_w );
- void flash_hard_reset(running_machine &machine);
-
- DECLARE_READ8_MEMBER(n3d_flash_r);
- DECLARE_WRITE8_MEMBER(n3d_flash_cmd_w);
- DECLARE_WRITE8_MEMBER(n3d_flash_addr_w);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
- void flash_change_state(running_machine &machine, flash_state_t state);
-
- // runtime state
- size_t m_length;
- UINT8* m_region;
-
-
- flash_state_t m_flash_state;
-
- UINT8 m_flash_enab;
-
- UINT8 m_flash_cmd_seq;
- UINT32 m_flash_cmd_prev;
-
- UINT8 m_flash_addr_seq;
- UINT8 m_flash_read_seq;
-
- UINT16 m_flash_row, m_flash_col;
- int m_flash_page_addr;
- UINT16 m_flash_page_index;
-
-
- dynamic_buffer m_flashwritemap;
-
- UINT8 m_last_flash_cmd;
-
- UINT32 m_flash_addr;
-
- UINT8 m_flash_page_data[FLASH_PAGE_SIZE];
-
-
-
-};
-
-
-// device type definition
-extern const device_type SERFLASH;
-
-
-#endif
diff --git a/src/emu/machine/smc91c9x.c b/src/emu/machine/smc91c9x.c
deleted file mode 100644
index c075f03fb76..00000000000
--- a/src/emu/machine/smc91c9x.c
+++ /dev/null
@@ -1,531 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- SMC91C9X ethernet controller implementation
-
- by Aaron Giles
-
-***************************************************************************
-
- Notes:
- * only loopback mode really works
-
-**************************************************************************/
-
-#include "emu.h"
-#include "smc91c9x.h"
-
-
-
-/***************************************************************************
- DEBUGGING
-***************************************************************************/
-
-#define LOG_ETHERNET (0)
-#define DISPLAY_STATS (0)
-
-
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-/* Ethernet registers - bank 0 */
-#define EREG_TCR (0*8 + 0)
-#define EREG_EPH_STATUS (0*8 + 1)
-#define EREG_RCR (0*8 + 2)
-#define EREG_COUNTER (0*8 + 3)
-#define EREG_MIR (0*8 + 4)
-#define EREG_MCR (0*8 + 5)
-#define EREG_BANK (0*8 + 7)
-
-/* Ethernet registers - bank 1 */
-#define EREG_CONFIG (1*8 + 0)
-#define EREG_BASE (1*8 + 1)
-#define EREG_IA0_1 (1*8 + 2)
-#define EREG_IA2_3 (1*8 + 3)
-#define EREG_IA4_5 (1*8 + 4)
-#define EREG_GENERAL_PURP (1*8 + 5)
-#define EREG_CONTROL (1*8 + 6)
-
-/* Ethernet registers - bank 2 */
-#define EREG_MMU_COMMAND (2*8 + 0)
-#define EREG_PNR_ARR (2*8 + 1)
-#define EREG_FIFO_PORTS (2*8 + 2)
-#define EREG_POINTER (2*8 + 3)
-#define EREG_DATA_0 (2*8 + 4)
-#define EREG_DATA_1 (2*8 + 5)
-#define EREG_INTERRUPT (2*8 + 6)
-
-/* Ethernet registers - bank 3 */
-#define EREG_MT0_1 (3*8 + 0)
-#define EREG_MT2_3 (3*8 + 1)
-#define EREG_MT4_5 (3*8 + 2)
-#define EREG_MT6_7 (3*8 + 3)
-#define EREG_MGMT (3*8 + 4)
-#define EREG_REVISION (3*8 + 5)
-#define EREG_ERCV (3*8 + 6)
-
-/* Ethernet MMU commands */
-#define ECMD_NOP 0
-#define ECMD_ALLOCATE 1
-#define ECMD_RESET_MMU 2
-#define ECMD_REMOVE 3
-#define ECMD_REMOVE_RELEASE 4
-#define ECMD_RELEASE_PACKET 5
-#define ECMD_ENQUEUE_PACKET 6
-#define ECMD_RESET_FIFOS 7
-
-/* Ethernet interrupt bits */
-#define EINT_RCV 0x01
-#define EINT_TX 0x02
-#define EINT_TX_EMPTY 0x04
-#define EINT_ALLOC 0x08
-#define EINT_RX_OVRN 0x10
-#define EINT_EPH 0x20
-#define EINT_ERCV 0x40
-
-/* Ethernet register names */
-static const char *const ethernet_regname[64] =
-{
- "TCR", "EPH STATUS", "RCR", "COUNTER", "MIR", "MCR", "(0.6)", "BANK",
- "CONFIG", "BASE", "IA0-1", "IA2-3", "IA4-5", "GENERAL PURPOSE", "CONTROL", "BANK",
- "MMU COMMAND", "PNR ARR", "FIFO PORTS", "POINTER", "DATA", "DATA", "INTERRUPT", "BANK",
- "MT0-1", "MT2-3", "MT4-5", "MT6-7", "MGMT", "REVISION", "ERCV", "BANK",
- "(4.0)", "(4.1)", "(4.2)", "(4.3)", "(4.4)", "(4.5)", "(4.6)", "BANK",
- "(5.0)", "(5.1)", "(5.2)", "(5.3)", "(5.4)", "(5.5)", "(5.6)", "BANK",
- "(6.0)", "(6.1)", "(6.2)", "(6.3)", "(6.4)", "(6.5)", "(6.6)", "BANK",
- "(7.0)", "(7.1)", "(7.2)", "(7.3)", "(7.4)", "(7.5)", "(7.6)", "BANK"
-};
-
-
-
-/***************************************************************************
- DEVICE INTERFACE
-***************************************************************************/
-
-smc91c9x_device::smc91c9x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_irq_handler(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void smc91c9x_device::device_start()
-{
- m_irq_handler.resolve_safe();
-
- /* register ide states */
- save_item(NAME(m_reg));
- save_item(NAME(m_regmask));
- save_item(NAME(m_irq_state));
- save_item(NAME(m_alloc_count));
- save_item(NAME(m_fifo_count));
- save_item(NAME(m_rx));
- save_item(NAME(m_tx));
- save_item(NAME(m_sent));
- save_item(NAME(m_recd));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void smc91c9x_device::device_reset()
-{
- memset(m_reg, 0, sizeof(m_reg));
- memset(m_regmask, 0, sizeof(m_regmask));
- m_irq_state = 0;
- m_alloc_count = 0;
- m_fifo_count = 0;
- m_sent = 0;
- m_recd = 0;
-
- m_reg[EREG_TCR] = 0x0000; m_regmask[EREG_TCR] = 0x3d87;
- m_reg[EREG_EPH_STATUS] = 0x0000; m_regmask[EREG_EPH_STATUS] = 0x0000;
- m_reg[EREG_RCR] = 0x0000; m_regmask[EREG_RCR] = 0xc307;
- m_reg[EREG_COUNTER] = 0x0000; m_regmask[EREG_COUNTER] = 0x0000;
- m_reg[EREG_MIR] = 0x1212; m_regmask[EREG_MIR] = 0x0000;
- m_reg[EREG_MCR] = 0x3300; m_regmask[EREG_MCR] = 0x00ff;
- m_reg[EREG_BANK] = 0x3300; m_regmask[EREG_BANK] = 0x0007;
-
- m_reg[EREG_CONFIG] = 0x0030; m_regmask[EREG_CONFIG] = 0x17c6;
- m_reg[EREG_BASE] = 0x1866; m_regmask[EREG_BASE] = 0xfffe;
- m_reg[EREG_IA0_1] = 0x0000; m_regmask[EREG_IA0_1] = 0xffff;
- m_reg[EREG_IA2_3] = 0x0000; m_regmask[EREG_IA2_3] = 0xffff;
- m_reg[EREG_IA4_5] = 0x0000; m_regmask[EREG_IA4_5] = 0xffff;
- m_reg[EREG_GENERAL_PURP] = 0x0000; m_regmask[EREG_GENERAL_PURP] = 0xffff;
- m_reg[EREG_CONTROL] = 0x0100; m_regmask[EREG_CONTROL] = 0x68e7;
-
- m_reg[EREG_MMU_COMMAND] = 0x0000; m_regmask[EREG_MMU_COMMAND] = 0x00e7;
- m_reg[EREG_PNR_ARR] = 0x8000; m_regmask[EREG_PNR_ARR] = 0x00ff;
- m_reg[EREG_FIFO_PORTS] = 0x8080; m_regmask[EREG_FIFO_PORTS] = 0x0000;
- m_reg[EREG_POINTER] = 0x0000; m_regmask[EREG_POINTER] = 0xf7ff;
- m_reg[EREG_DATA_0] = 0x0000; m_regmask[EREG_DATA_0] = 0xffff;
- m_reg[EREG_DATA_1] = 0x0000; m_regmask[EREG_DATA_1] = 0xffff;
- m_reg[EREG_INTERRUPT] = 0x0004; m_regmask[EREG_INTERRUPT] = 0x7f00;
-
- m_reg[EREG_MT0_1] = 0x0000; m_regmask[EREG_MT0_1] = 0xffff;
- m_reg[EREG_MT2_3] = 0x0000; m_regmask[EREG_MT2_3] = 0xffff;
- m_reg[EREG_MT4_5] = 0x0000; m_regmask[EREG_MT4_5] = 0xffff;
- m_reg[EREG_MT6_7] = 0x0000; m_regmask[EREG_MT6_7] = 0xffff;
- m_reg[EREG_MGMT] = 0x3030; m_regmask[EREG_MGMT] = 0x0f0f;
- m_reg[EREG_REVISION] = 0x3340; m_regmask[EREG_REVISION] = 0x0000;
- m_reg[EREG_ERCV] = 0x331f; m_regmask[EREG_ERCV] = 0x009f;
-
- update_ethernet_irq();
-}
-
-
-const device_type SMC91C94 = &device_creator<smc91c94_device>;
-
-smc91c94_device::smc91c94_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : smc91c9x_device(mconfig, SMC91C94, "SMC91C94 Ethernet Controller", tag, owner, clock, "smc91c94", __FILE__)
-{
-}
-
-
-const device_type SMC91C96 = &device_creator<smc91c96_device>;
-
-smc91c96_device::smc91c96_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : smc91c9x_device(mconfig, SMC91C96, "SMC91C96", tag, owner, clock, "smc91c96", __FILE__)
-{
-}
-
-/***************************************************************************
- INTERNAL HELPERS
-***************************************************************************/
-
-/*-------------------------------------------------
- update_ethernet_irq - update the IRQ state
--------------------------------------------------*/
-
-void smc91c9x_device::update_ethernet_irq()
-{
- UINT8 mask = m_reg[EREG_INTERRUPT] >> 8;
- UINT8 state = m_reg[EREG_INTERRUPT] & 0xff;
-
- /* update the IRQ state */
- m_irq_state = ((mask & state) != 0);
- if (!m_irq_handler.isnull())
- m_irq_handler(m_irq_state ? ASSERT_LINE : CLEAR_LINE);
-}
-
-
-/*-------------------------------------------------
- update_stats - draw statistics
--------------------------------------------------*/
-
-void smc91c9x_device::update_stats()
-{
- if (DISPLAY_STATS)
- popmessage("Sent:%d Rec'd:%d", m_sent, m_recd);
-}
-
-
-/*-------------------------------------------------
- finish_enqueue - complete an enqueued packet
--------------------------------------------------*/
-
-void smc91c9x_device::finish_enqueue(int param)
-{
- int is_broadcast = (m_tx[4] == 0xff && m_tx[5] == 0xff && m_tx[6] == 0xff &&
- m_tx[7] == 0xff && m_tx[8] == 0xff && m_tx[9] == 0xff);
-
- /* update the EPH register and stuff it in the first transmit word */
- m_reg[EREG_EPH_STATUS] = 0x0001;
- if (is_broadcast)
- m_reg[EREG_EPH_STATUS] |= 0x0040;
- m_tx[0] = m_reg[EREG_EPH_STATUS];
- m_tx[1] = m_reg[EREG_EPH_STATUS] >> 8;
-
- /* signal a transmit interrupt and mark the transmit buffer empty */
- m_reg[EREG_INTERRUPT] |= EINT_TX;
- m_reg[EREG_INTERRUPT] |= EINT_TX_EMPTY;
- m_reg[EREG_FIFO_PORTS] |= 0x0080;
- m_sent++;
- update_stats();
-
- /* loopback? */
- if (m_reg[EREG_TCR] & 0x2002)
- if (m_fifo_count < ETHER_RX_BUFFERS)
- {
- int buffer_len = ((m_tx[3] << 8) | m_tx[2]) & 0x7ff;
- UINT8 *packet = &m_rx[m_fifo_count++ * ETHER_BUFFER_SIZE];
- int packet_len;
-
- /* compute the packet length */
- packet_len = buffer_len - 6;
- if (packet[buffer_len - 1] & 0x20)
- packet_len++;
-
- /* build up the packet */
- packet[0] = 0x0000;
- packet[1] = 0x0000;
- packet[2] = buffer_len;
- packet[3] = buffer_len >> 8;
- memcpy(&packet[4], &m_tx[4], 6);
- memcpy(&packet[10], &m_tx[10], 6);
- memcpy(&packet[16], &m_tx[16], buffer_len - 16);
-
- /* set the broadcast flag */
- if (is_broadcast)
- packet[1] |= 0x40;
-
- /* pad? */
- if (m_reg[EREG_TCR & 0x0080])
- if (packet_len < 64)
- {
- memset(&packet[buffer_len], 0, 64+6 - buffer_len);
- packet[buffer_len - 1] = 0;
- buffer_len = 64+6;
- packet[2] = buffer_len;
- packet[3] = buffer_len >> 8;
- }
-
- /* signal a receive */
- m_reg[EREG_INTERRUPT] |= EINT_RCV;
- m_reg[EREG_FIFO_PORTS] &= ~0x8000;
- }
- update_ethernet_irq();
-}
-
-
-/*-------------------------------------------------
- process_command - handle MMU commands
--------------------------------------------------*/
-
-void smc91c9x_device::process_command(UINT16 data)
-{
- switch ((data >> 5) & 7)
- {
- case ECMD_NOP:
- if (LOG_ETHERNET)
- logerror(" NOP\n");
- break;
-
- case ECMD_ALLOCATE:
- if (LOG_ETHERNET)
- logerror(" ALLOCATE MEMORY FOR TX (%d)\n", (data & 7));
- m_reg[EREG_PNR_ARR] &= ~0xff00;
- m_reg[EREG_PNR_ARR] |= m_alloc_count++ << 8;
- m_reg[EREG_INTERRUPT] |= 0x0008;
- update_ethernet_irq();
- break;
-
- case ECMD_RESET_MMU:
- if (LOG_ETHERNET)
- logerror(" RESET MMU\n");
- break;
-
- case ECMD_REMOVE:
- if (LOG_ETHERNET)
- logerror(" REMOVE FRAME FROM RX FIFO\n");
- break;
-
- case ECMD_REMOVE_RELEASE:
- if (LOG_ETHERNET)
- logerror(" REMOVE AND RELEASE FRAME FROM RX FIFO\n");
- m_reg[EREG_INTERRUPT] &= ~EINT_RCV;
- if (m_fifo_count > 0)
- m_fifo_count--;
- if (m_fifo_count > 0)
- {
- memmove(&m_rx[0], &m_rx[ETHER_BUFFER_SIZE], m_fifo_count * ETHER_BUFFER_SIZE);
- m_reg[EREG_INTERRUPT] |= EINT_RCV;
- m_reg[EREG_FIFO_PORTS] &= ~0x8000;
- }
- else
- m_reg[EREG_FIFO_PORTS] |= 0x8000;
- update_ethernet_irq();
- m_recd++;
- update_stats();
- break;
-
- case ECMD_RELEASE_PACKET:
- if (LOG_ETHERNET)
- logerror(" RELEASE SPECIFIC PACKET\n");
- break;
-
- case ECMD_ENQUEUE_PACKET:
- if (LOG_ETHERNET)
- logerror(" ENQUEUE TX PACKET\n");
- finish_enqueue(0);
- break;
-
- case ECMD_RESET_FIFOS:
- if (LOG_ETHERNET)
- logerror(" RESET TX FIFOS\n");
- break;
- }
- m_reg[EREG_MMU_COMMAND] &= ~0x0001;
-}
-
-
-
-/***************************************************************************
- CORE READ/WRITE HANDLERS
-***************************************************************************/
-
-/*-------------------------------------------------
- smc91c9x_r - handle a read from the device
--------------------------------------------------*/
-
-READ16_MEMBER( smc91c9x_device::read )
-{
- UINT32 result = ~0;
-
- /* determine the effective register */
- offset %= 8;
- if (offset != EREG_BANK)
- offset += 8 * (m_reg[EREG_BANK] & 7);
- result = m_reg[offset];
-
- switch (offset)
- {
- case EREG_PNR_ARR:
- if (ACCESSING_BITS_8_15)
- {
- m_reg[EREG_INTERRUPT] &= ~0x0008;
- update_ethernet_irq();
- }
- break;
-
- case EREG_DATA_0: /* data register */
- case EREG_DATA_1: /* data register */
- {
- UINT8 *buffer = (m_reg[EREG_POINTER] & 0x8000) ? m_rx : m_tx;
- int addr = m_reg[EREG_POINTER] & 0x7ff;
- result = buffer[addr++];
- if (ACCESSING_BITS_8_15)
- result |= buffer[addr++] << 8;
- if (m_reg[EREG_POINTER] & 0x4000)
- m_reg[EREG_POINTER] = (m_reg[EREG_POINTER] & ~0x7ff) | (addr & 0x7ff);
- break;
- }
- }
-
- if (LOG_ETHERNET && offset != EREG_BANK)
- logerror("%s:smc91c9x_r(%s) = %04X & %04X\n", machine().describe_context(), ethernet_regname[offset], result, mem_mask);
- return result;
-}
-
-
-/*-------------------------------------------------
- smc91c9x_w - handle a write to the device
--------------------------------------------------*/
-
-WRITE16_MEMBER( smc91c9x_device::write )
-{
- // UINT16 olddata;
-
- /* determine the effective register */
- offset %= 8;
- if (offset != EREG_BANK)
- offset += 8 * (m_reg[EREG_BANK] & 7);
-
- /* update the data generically */
- // olddata = m_reg[offset];
- mem_mask &= m_regmask[offset];
- COMBINE_DATA(&m_reg[offset]);
-
- if (LOG_ETHERNET && offset != 7)
- logerror("%s:smc91c9x_w(%s) = %04X & %04X\n", machine().describe_context(), ethernet_regname[offset], data, mem_mask);
-
- /* handle it */
- switch (offset)
- {
- case EREG_TCR: /* transmit control register */
- if (LOG_ETHERNET)
- {
- if (data & 0x2000) logerror(" EPH LOOP\n");
- if (data & 0x1000) logerror(" STP SQET\n");
- if (data & 0x0800) logerror(" FDUPLX\n");
- if (data & 0x0400) logerror(" MON_CSN\n");
- if (data & 0x0100) logerror(" NOCRC\n");
- if (data & 0x0080) logerror(" PAD_EN\n");
- if (data & 0x0004) logerror(" FORCOL\n");
- if (data & 0x0002) logerror(" LOOP\n");
- if (data & 0x0001) logerror(" TXENA\n");
- }
- break;
-
- case EREG_RCR: /* receive control register */
- if (LOG_ETHERNET)
- {
- if (data & 0x8000) reset();
- if (data & 0x8000) logerror(" SOFT RST\n");
- if (data & 0x4000) logerror(" FILT_CAR\n");
- if (data & 0x0200) logerror(" STRIP CRC\n");
- if (data & 0x0100) logerror(" RXEN\n");
- if (data & 0x0004) logerror(" ALMUL\n");
- if (data & 0x0002) logerror(" PRMS\n");
- if (data & 0x0001) logerror(" RX_ABORT\n");
- }
- break;
-
- case EREG_CONFIG: /* configuration register */
- if (LOG_ETHERNET)
- {
- if (data & 0x1000) logerror(" NO WAIT\n");
- if (data & 0x0400) logerror(" FULL STEP\n");
- if (data & 0x0200) logerror(" SET SQLCH\n");
- if (data & 0x0100) logerror(" AUI SELECT\n");
- if (data & 0x0080) logerror(" 16 BIT\n");
- if (data & 0x0040) logerror(" DIS LINK\n");
- if (data & 0x0004) logerror(" INT SEL1\n");
- if (data & 0x0002) logerror(" INT SEL0\n");
- }
- break;
-
- case EREG_BASE: /* base address register */
- if (LOG_ETHERNET)
- {
- logerror(" base = $%04X\n", (data & 0xe000) | ((data & 0x1f00) >> 3));
- logerror(" romsize = %d\n", ((data & 0xc0) >> 6));
- logerror(" romaddr = $%05X\n", ((data & 0x3e) << 13));
- }
- break;
-
- case EREG_CONTROL: /* control register */
- if (LOG_ETHERNET)
- {
- if (data & 0x4000) logerror(" RCV_BAD\n");
- if (data & 0x2000) logerror(" PWRDN\n");
- if (data & 0x0800) logerror(" AUTO RELEASE\n");
- if (data & 0x0080) logerror(" LE ENABLE\n");
- if (data & 0x0040) logerror(" CR ENABLE\n");
- if (data & 0x0020) logerror(" TE ENABLE\n");
- if (data & 0x0004) logerror(" EEPROM SELECT\n");
- if (data & 0x0002) logerror(" RELOAD\n");
- if (data & 0x0001) logerror(" STORE\n");
- }
- break;
-
- case EREG_MMU_COMMAND: /* command register */
- process_command(data);
- break;
-
- case EREG_DATA_0: /* data register */
- case EREG_DATA_1: /* data register */
- {
- UINT8 *buffer = (m_reg[EREG_POINTER] & 0x8000) ? m_rx : m_tx;
- int addr = m_reg[EREG_POINTER] & 0x7ff;
- buffer[addr++] = data;
- if (ACCESSING_BITS_8_15)
- buffer[addr++] = data >> 8;
- if (m_reg[EREG_POINTER] & 0x4000)
- m_reg[EREG_POINTER] = (m_reg[EREG_POINTER] & ~0x7ff) | (addr & 0x7ff);
- break;
- }
-
- case EREG_INTERRUPT:
- m_reg[EREG_INTERRUPT] &= ~(data & 0x56);
- update_ethernet_irq();
- break;
- }
-}
diff --git a/src/emu/machine/smc91c9x.h b/src/emu/machine/smc91c9x.h
deleted file mode 100644
index 799af951928..00000000000
--- a/src/emu/machine/smc91c9x.h
+++ /dev/null
@@ -1,100 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- SMC91C9X ethernet controller implementation
-
- by Aaron Giles
-
-**************************************************************************/
-
-#ifndef __SMC91C9X__
-#define __SMC91C9X__
-
-#define ETHER_BUFFER_SIZE (2048)
-#define ETHER_RX_BUFFERS (4)
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-class smc91c9x_device : public device_t
-{
-public:
- smc91c9x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
- ~smc91c9x_device() {}
-
- template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<smc91c9x_device &>(device).m_irq_handler.set_callback(object); }
-
- DECLARE_READ16_MEMBER( read );
- DECLARE_WRITE16_MEMBER( write );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- // internal state
- devcb_write_line m_irq_handler;
-
- /* raw register data and masks */
- UINT16 m_reg[64];
- UINT16 m_regmask[64];
-
- /* IRQ information */
- UINT8 m_irq_state;
-
- /* allocate information */
- UINT8 m_alloc_count;
-
- /* transmit/receive FIFOs */
- UINT8 m_fifo_count;
- UINT8 m_rx[ETHER_BUFFER_SIZE * ETHER_RX_BUFFERS];
- UINT8 m_tx[ETHER_BUFFER_SIZE];
-
- /* counters */
- UINT32 m_sent;
- UINT32 m_recd;
-
- void update_ethernet_irq();
- void update_stats();
- void finish_enqueue(int param);
- void process_command(UINT16 data);
-};
-
-
-class smc91c94_device : public smc91c9x_device
-{
-public:
- smc91c94_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-extern const device_type SMC91C94;
-
-class smc91c96_device : public smc91c9x_device
-{
-public:
- smc91c96_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-extern const device_type SMC91C96;
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_SMC91C94_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SMC91C94, 0)
-
-#define MCFG_SMC91C94_IRQ_CALLBACK(_write) \
- devcb = &smc91c94_device::set_irq_callback(*device, DEVCB_##_write);
-
-#define MCFG_SMC91C96_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SMC91C96, 0)
-
-#define MCFG_SMC91C96_IRQ_CALLBACK(_write) \
- devcb = &smc91c96_device::set_irq_callback(*device, DEVCB_##_write);
-
-
-#endif
diff --git a/src/emu/machine/smpc.c b/src/emu/machine/smpc.c
deleted file mode 100644
index caf0834da5a..00000000000
--- a/src/emu/machine/smpc.c
+++ /dev/null
@@ -1,1084 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:Angelo Salese, R. Belmont
-/************************************************************************************
-
-Sega Saturn SMPC - System Manager and Peripheral Control MCU simulation
-
-The SMPC is actually a 4-bit Hitachi HD404920FS MCU, labeled with a Sega custom
-315-5744 (that needs decapping)
-
-MCU simulation by Angelo Salese & R. Belmont
-
-TODO:
-- timings;
-- fix intback issue with inputs (according to the docs, it should fall in between
- VBLANK-IN and OUT, for obvious reasons);
-- clean-ups;
-
-*************************************************************************************/
-/* SMPC Addresses
-
-00
-01 -w Input Register 0 (IREG)
-02
-03 -w Input Register 1
-04
-05 -w Input Register 2
-06
-07 -w Input Register 3
-08
-09 -w Input Register 4
-0a
-0b -w Input Register 5
-0c
-0d -w Input Register 6
-0e
-0f
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-1a
-1b
-1c
-1d
-1e
-1f -w Command Register (COMREG)
-20
-21 r- Output Register 0 (OREG)
-22
-23 r- Output Register 1
-24
-25 r- Output Register 2
-26
-27 r- Output Register 3
-28
-29 r- Output Register 4
-2a
-2b r- Output Register 5
-2c
-2d r- Output Register 6
-2e
-2f r- Output Register 7
-30
-31 r- Output Register 8
-32
-33 r- Output Register 9
-34
-35 r- Output Register 10
-36
-37 r- Output Register 11
-38
-39 r- Output Register 12
-3a
-3b r- Output Register 13
-3c
-3d r- Output Register 14
-3e
-3f r- Output Register 15
-40
-41 r- Output Register 16
-42
-43 r- Output Register 17
-44
-45 r- Output Register 18
-46
-47 r- Output Register 19
-48
-49 r- Output Register 20
-4a
-4b r- Output Register 21
-4c
-4d r- Output Register 22
-4e
-4f r- Output Register 23
-50
-51 r- Output Register 24
-52
-53 r- Output Register 25
-54
-55 r- Output Register 26
-56
-57 r- Output Register 27
-58
-59 r- Output Register 28
-5a
-5b r- Output Register 29
-5c
-5d r- Output Register 30
-5e
-5f r- Output Register 31
-60
-61 r- SR
-62
-63 rw SF
-64
-65
-66
-67
-68
-69
-6a
-6b
-6c
-6d
-6e
-6f
-70
-71
-72
-73
-74
-75 rw PDR1
-76
-77 rw PDR2
-78
-79 -w DDR1
-7a
-7b -w DDR2
-7c
-7d -w IOSEL2/1
-7e
-7f -w EXLE2/1
-*/
-
-#include "emu.h"
-#include "coreutil.h"
-#include "includes/stv.h"
-#include "machine/smpc.h"
-#include "machine/eepromser.h"
-
-#define LOG_SMPC 0
-#define LOG_PAD_CMD 0
-
-
-/********************************************
- *
- * Bankswitch code for ST-V Multi Cart mode
- *
- *******************************************/
-
-void saturn_state::stv_select_game(int gameno)
-{
- if (m_prev_bankswitch != gameno)
- {
- if (m_cart_reg[gameno] && m_cart_reg[gameno]->base())
- memcpy(memregion("abus")->base(), m_cart_reg[gameno]->base(), 0x3000000);
- else
- memset(memregion("abus")->base(), 0x00, 0x3000000); // TODO: 1-filled?
-
- m_prev_bankswitch = gameno;
- }
-}
-
-/********************************************
- *
- * Command functions
- *
- *******************************************/
-
-void saturn_state::smpc_master_on()
-{
- m_maincpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
-}
-
-TIMER_CALLBACK_MEMBER( saturn_state::smpc_slave_enable )
-{
- m_slave->set_input_line(INPUT_LINE_RESET, param ? ASSERT_LINE : CLEAR_LINE);
- m_smpc.OREG[31] = param + 0x02; //read-back for last command issued
- m_smpc.SF = 0x00; //clear hand-shake flag
- m_smpc.slave_on = param;
-// printf("%d %d\n",machine().first_screen()->hpos(),machine().first_screen()->vpos());
-}
-
-TIMER_CALLBACK_MEMBER( saturn_state::smpc_sound_enable )
-{
- m_audiocpu->set_input_line(INPUT_LINE_RESET, param ? ASSERT_LINE : CLEAR_LINE);
- m_en_68k = param ^ 1;
- m_smpc.OREG[31] = param + 0x06; //read-back for last command issued
- m_smpc.SF = 0x00; //clear hand-shake flag
-}
-
-TIMER_CALLBACK_MEMBER( saturn_state::smpc_cd_enable )
-{
- m_smpc.OREG[31] = param + 0x08; //read-back for last command issued
- m_smpc.SF = 0x08; //clear hand-shake flag (TODO: diagnostic wants this to have bit 3 high)
-}
-
-void saturn_state::smpc_system_reset()
-{
- /*Only backup ram and SMPC ram are retained after that this command is issued.*/
- memset(m_scu_regs ,0x00,0x000100);
- memset(m_scsp_regs,0x00,0x001000);
- memset(m_sound_ram,0x00,0x080000);
- memset(m_workram_h,0x00,0x100000);
- memset(m_workram_l,0x00,0x100000);
- memset(m_vdp2_regs,0x00,0x040000);
- memset(m_vdp2_vram,0x00,0x100000);
- memset(m_vdp2_cram,0x00,0x080000);
- memset(m_vdp1_vram,0x00,0x100000);
- //A-Bus
-
- m_maincpu->set_input_line(INPUT_LINE_RESET, PULSE_LINE);
-}
-
-TIMER_CALLBACK_MEMBER( saturn_state::smpc_change_clock )
-{
- UINT32 xtal;
-
- if(LOG_SMPC) printf ("Clock change execute at (%d %d)\n",machine().first_screen()->hpos(),machine().first_screen()->vpos());
-
- xtal = param ? MASTER_CLOCK_320 : MASTER_CLOCK_352;
-
- machine().device("maincpu")->set_unscaled_clock(xtal/2);
- machine().device("slave")->set_unscaled_clock(xtal/2);
-
- m_vdp2.dotsel = param ^ 1;
- stv_vdp2_dynamic_res_change();
-
- m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
- if(!m_NMI_reset)
- m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
- m_slave->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
- m_slave->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
- m_audiocpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
-
- /* put issued command in OREG31 */
- m_smpc.OREG[31] = 0x0e + param;
- /* clear hand-shake flag */
- m_smpc.SF = 0x00;
-
- /* TODO: VDP1 / VDP2 / SCU / SCSP default power ON values? */
-}
-
-TIMER_CALLBACK_MEMBER( saturn_state::stv_intback_peripheral )
-{
- if (m_smpc.intback_stage == 2)
- {
- m_smpc.SR = (0x80 | m_smpc.pmode); // pad 2, no more data, echo back pad mode set by intback
- m_smpc.intback_stage = 0;
- }
- else
- {
- m_smpc.SR = (0xc0 | m_smpc.pmode); // pad 1, more data, echo back pad mode set by intback
- m_smpc.intback_stage ++;
- }
-
- if(!(m_scu.ism & IRQ_SMPC))
- m_maincpu->set_input_line_and_vector(8, HOLD_LINE, 0x47);
- else
- m_scu.ist |= (IRQ_SMPC);
-
- m_smpc.OREG[31] = 0x10; /* callback for last command issued */
- m_smpc.SF = 0x00; /* clear hand-shake flag */
-}
-
-
-TIMER_CALLBACK_MEMBER( saturn_state::stv_smpc_intback )
-{
- int i;
-
-// printf("%02x %02x %02x\n",m_smpc.intback_buf[0],m_smpc.intback_buf[1],m_smpc.intback_buf[2]);
-
- if(m_smpc.intback_buf[0] != 0)
- {
- m_smpc.OREG[0] = (0x80) | ((m_NMI_reset & 1) << 6);
-
- for(i=0;i<7;i++)
- m_smpc.OREG[1+i] = m_smpc.rtc_data[i];
-
- m_smpc.OREG[8]=0x00; // CTG0 / CTG1?
-
- m_smpc.OREG[9]=0x00; // TODO: system region on Saturn
-
- m_smpc.OREG[10]= 0 << 7 |
- m_vdp2.dotsel << 6 |
- 1 << 5 |
- 1 << 4 |
- 0 << 3 | //MSHNMI
- 1 << 2 |
- 0 << 1 | //SYSRES
- 0 << 0; //SOUNDRES
- m_smpc.OREG[11]= 0 << 6; //CDRES
-
- for(i=0;i<4;i++)
- m_smpc.OREG[12+i]=m_smpc.SMEM[i];
-
- for(i=0;i<15;i++)
- m_smpc.OREG[16+i]=0xff; // undefined
-
- m_smpc.intback_stage = (m_smpc.intback_buf[1] & 8) >> 3; // first peripheral
- m_smpc.SR = 0x40 | m_smpc.intback_stage << 5;
- m_smpc.pmode = m_smpc.intback_buf[0]>>4;
-
- // /*This is for RTC,cartridge code and similar stuff...*/
- //if(LOG_SMPC) printf ("Interrupt: System Manager (SMPC) at scanline %04x, Vector 0x47 Level 0x08\n",scanline);
- if(!(m_scu.ism & IRQ_SMPC))
- m_maincpu->set_input_line_and_vector(8, HOLD_LINE, 0x47);
- else
- m_scu.ist |= (IRQ_SMPC);
-
- /* put issued command in OREG31 */
- m_smpc.OREG[31] = 0x10; // TODO: doc says 0?
- /* clear hand-shake flag */
- m_smpc.SF = 0x00;
- }
- else if(m_smpc.intback_buf[1] & 8)
- {
- m_smpc.intback_stage = (m_smpc.intback_buf[1] & 8) >> 3; // first peripheral
- m_smpc.SR = 0x40;
- m_smpc.OREG[31] = 0x10;
- machine().scheduler().timer_set(attotime::from_usec(0), timer_expired_delegate(FUNC(saturn_state::stv_intback_peripheral),this),0);
- }
- else
- {
- /* Shienryu calls this, it would be plainly illegal on Saturn, I'll just return the command and clear the hs flag for now. */
- m_smpc.OREG[31] = 0x10;
- m_smpc.SF = 0x00;
- }
-}
-
-
-/*
- [0] port status:
- 0x04 Sega-tap
- 0x16 Multi-tap
- 0x2x clock serial peripheral
- 0xf0 peripheral isn't connected
- 0xf1 peripheral is connected
- [1] Peripheral ID (note: lowest four bits determines the size of the input packet)
- 0x02 digital pad
- 0x25 (tested by Game Basic?)
- 0x34 keyboard
-*/
-
-void saturn_state::smpc_digital_pad(UINT8 pad_num, UINT8 offset)
-{
- static const char *const padnames[] = { "JOY1", "JOY2" };
- UINT16 pad_data;
-
- pad_data = ioport(padnames[pad_num])->read();
- m_smpc.OREG[0+pad_num*offset] = 0xf1;
- m_smpc.OREG[1+pad_num*offset] = 0x02;
- m_smpc.OREG[2+pad_num*offset] = pad_data>>8;
- m_smpc.OREG[3+pad_num*offset] = pad_data & 0xff;
-}
-
-void saturn_state::smpc_analog_pad( UINT8 pad_num, UINT8 offset, UINT8 id)
-{
- static const char *const padnames[] = { "AN_JOY1", "AN_JOY2" };
- static const char *const annames[2][3] = { { "AN_X1", "AN_Y1", "AN_Z1" },
- { "AN_X2", "AN_Y2", "AN_Z2" }};
- UINT16 pad_data;
-
- pad_data = ioport(padnames[pad_num])->read();
- m_smpc.OREG[0+pad_num*offset] = 0xf1;
- m_smpc.OREG[1+pad_num*offset] = id;
- m_smpc.OREG[2+pad_num*offset] = pad_data>>8;
- m_smpc.OREG[3+pad_num*offset] = pad_data & 0xff;
- m_smpc.OREG[4+pad_num*offset] = ioport(annames[pad_num][0])->read();
- if(id == 0x15)
- {
- m_smpc.OREG[5+pad_num*offset] = ioport(annames[pad_num][1])->read();
- m_smpc.OREG[6+pad_num*offset] = ioport(annames[pad_num][2])->read();
- }
-}
-
-void saturn_state::smpc_keyboard(UINT8 pad_num, UINT8 offset)
-{
- UINT16 game_key;
-
- game_key = 0xffff;
-
- game_key ^= ((ioport("KEYS_1")->read() & 0x80) << 8); // right
- game_key ^= ((ioport("KEYS_1")->read() & 0x40) << 8); // left
- game_key ^= ((ioport("KEYS_1")->read() & 0x20) << 8); // down
- game_key ^= ((ioport("KEYS_1")->read() & 0x10) << 8); // up
- game_key ^= ((ioport("KEYF")->read() & 0x80) << 4); // ESC -> START
- game_key ^= ((ioport("KEY3")->read() & 0x04) << 8); // Z / A trigger
- game_key ^= ((ioport("KEY4")->read() & 0x02) << 8); // C / C trigger
- game_key ^= ((ioport("KEY6")->read() & 0x04) << 6); // X / B trigger
- game_key ^= ((ioport("KEY2")->read() & 0x20) << 2); // Q / R trigger
- game_key ^= ((ioport("KEY3")->read() & 0x10) << 2); // A / X trigger
- game_key ^= ((ioport("KEY3")->read() & 0x08) << 2); // S / Y trigger
- game_key ^= ((ioport("KEY4")->read() & 0x08) << 1); // D / Z trigger
- game_key ^= ((ioport("KEY4")->read() & 0x10) >> 1); // E / L trigger
-
- m_smpc.OREG[0+pad_num*offset] = 0xf1;
- m_smpc.OREG[1+pad_num*offset] = 0x34;
- m_smpc.OREG[2+pad_num*offset] = game_key>>8; // game buttons, TODO
- m_smpc.OREG[3+pad_num*offset] = game_key & 0xff;
- /*
- Keyboard Status hook-up
- TODO: how shift key actually works? EGWord uses it in order to switch between hiragana and katakana modes.
- x--- ---- 0
- -x-- ---- caps lock
- --x- ---- num lock
- ---x ---- scroll lock
- ---- x--- data ok
- ---- -x-- 1
- ---- --x- 1
- ---- ---x Break key
- */
- m_smpc.OREG[4+pad_num*offset] = m_keyb.status | 6;
- if(m_keyb.prev_data != m_keyb.data)
- {
- m_smpc.OREG[5+pad_num*offset] = m_keyb.data;
- m_keyb.repeat_count = 0;
- m_keyb.prev_data = m_keyb.data;
- }
- else
- {
- /* Very crude repeat support */
- m_keyb.repeat_count ++;
- m_keyb.repeat_count = m_keyb.repeat_count > 32 ? 32 : m_keyb.repeat_count;
- m_smpc.OREG[5+pad_num*offset] = (m_keyb.repeat_count == 32) ? m_keyb.data : 0;
- }
-}
-
-void saturn_state::smpc_mouse(UINT8 pad_num, UINT8 offset, UINT8 id)
-{
- static const char *const mousenames[2][3] = { { "MOUSEB1", "MOUSEX1", "MOUSEY1" },
- { "MOUSEB2", "MOUSEX2", "MOUSEY2" }};
- UINT8 mouse_ctrl;
- INT16 mouse_x, mouse_y;
-
- mouse_ctrl = ioport(mousenames[pad_num][0])->read();
- mouse_x = ioport(mousenames[pad_num][1])->read();
- mouse_y = ioport(mousenames[pad_num][2])->read();
-
- if(mouse_x < 0)
- mouse_ctrl |= 0x10;
-
- if(mouse_y < 0)
- mouse_ctrl |= 0x20;
-
- if((mouse_x & 0xff00) != 0xff00 && (mouse_x & 0xff00) != 0x0000)
- mouse_ctrl |= 0x40;
-
- if((mouse_y & 0xff00) != 0xff00 && (mouse_y & 0xff00) != 0x0000)
- mouse_ctrl |= 0x80;
-
- m_smpc.OREG[0+pad_num*offset] = 0xf1;
- m_smpc.OREG[1+pad_num*offset] = id; // 0x23 / 0xe3
- m_smpc.OREG[2+pad_num*offset] = mouse_ctrl;
- m_smpc.OREG[3+pad_num*offset] = mouse_x & 0xff;
- m_smpc.OREG[4+pad_num*offset] = mouse_y & 0xff;
-}
-
-/* TODO: is there ANY game on which the MD pad works? */
-void saturn_state::smpc_md_pad(UINT8 pad_num, UINT8 offset, UINT8 id)
-{
- static const char *const padnames[] = { "MD_JOY1", "MD_JOY2" };
- UINT16 pad_data;
-
- pad_data = ioport(padnames[pad_num])->read();
- m_smpc.OREG[0+pad_num*offset] = 0xf1;
- m_smpc.OREG[1+pad_num*offset] = id;
- m_smpc.OREG[2+pad_num*offset] = pad_data>>8;
- if(id == 0xe2) // MD 6 Button PAD
- m_smpc.OREG[3+pad_num*offset] = pad_data & 0xff;
-}
-
-void saturn_state::smpc_unconnected(UINT8 pad_num, UINT8 offset)
-{
- m_smpc.OREG[0+pad_num*offset] = 0xf0;
-}
-
-TIMER_CALLBACK_MEMBER( saturn_state::intback_peripheral )
-{
- int pad_num;
- static const UINT8 peri_id[10] = { 0x02, 0x13, 0x15, 0x23, 0x23, 0x34, 0xe1, 0xe2, 0xe3, 0xff };
- UINT8 read_id[2];
- UINT8 offset;
-
-// if (LOG_SMPC) logerror("SMPC: providing PAD data for intback, pad %d\n", intback_stage-2);
-
- read_id[0] = (ioport("INPUT_TYPE")->read()) & 0x0f;
- read_id[1] = (ioport("INPUT_TYPE")->read()) >> 4;
-
- /* doesn't work? */
- //pad_num = m_smpc.intback_stage - 1;
-
- if(LOG_PAD_CMD) printf("%d %d %d\n",m_smpc.intback_stage - 1,machine().first_screen()->vpos(),(int)machine().first_screen()->frame_number());
-
- offset = 0;
-
- for(pad_num=0;pad_num<2;pad_num++)
- {
- switch(read_id[pad_num])
- {
- case 0: smpc_digital_pad(pad_num,offset); break;
- case 1: smpc_analog_pad(pad_num,offset,peri_id[read_id[pad_num]]); break; /* Steering Wheel */
- case 2: smpc_analog_pad(pad_num,offset,peri_id[read_id[pad_num]]); break; /* Analog Pad */
- case 4: smpc_mouse(pad_num,offset,peri_id[read_id[pad_num]]); break; /* Pointing Device */
- case 5: smpc_keyboard(pad_num,offset); break;
- case 6: smpc_md_pad(pad_num,offset,peri_id[read_id[pad_num]]); break; /* MD 3B PAD */
- case 7: smpc_md_pad(pad_num,offset,peri_id[read_id[pad_num]]); break; /* MD 6B PAD */
- case 8: smpc_mouse(pad_num,offset,peri_id[read_id[pad_num]]); break; /* Saturn Mouse */
- case 9: smpc_unconnected(pad_num,offset); break;
- }
-
- offset += (peri_id[read_id[pad_num]] & 0xf) + 2; /* offset for port 2 */
- }
-
- if (m_smpc.intback_stage == 2)
- {
- m_smpc.SR = (0x80 | m_smpc.pmode); // pad 2, no more data, echo back pad mode set by intback
- m_smpc.intback_stage = 0;
- }
- else
- {
- m_smpc.SR = (0xc0 | m_smpc.pmode); // pad 1, more data, echo back pad mode set by intback
- m_smpc.intback_stage ++;
- }
-
- if(!(m_scu.ism & IRQ_SMPC))
- m_maincpu->set_input_line_and_vector(8, HOLD_LINE, 0x47);
- else
- m_scu.ist |= (IRQ_SMPC);
-
- m_smpc.OREG[31] = 0x10; /* callback for last command issued */
- m_smpc.SF = 0x00; /* clear hand-shake flag */
-}
-
-TIMER_CALLBACK_MEMBER( saturn_state::saturn_smpc_intback )
-{
- if(m_smpc.intback_buf[0] != 0)
- {
- {
- int i;
-
- m_smpc.OREG[0] = (0x80) | ((m_NMI_reset & 1) << 6); // bit 7: SETTIME (RTC isn't setted up properly)
-
- for(i=0;i<7;i++)
- m_smpc.OREG[1+i] = m_smpc.rtc_data[i];
-
- m_smpc.OREG[8]=0x00; //Cartridge code?
-
- m_smpc.OREG[9] = m_saturn_region;
-
- m_smpc.OREG[10]= 0 << 7 |
- m_vdp2.dotsel << 6 |
- 1 << 5 |
- 1 << 4 |
- 0 << 3 | //MSHNMI
- 1 << 2 |
- 0 << 1 | //SYSRES
- 0 << 0; //SOUNDRES
- m_smpc.OREG[11]= 0 << 6; //CDRES
-
- for(i=0;i<4;i++)
- m_smpc.OREG[12+i]=m_smpc.SMEM[i];
-
- for(i=0;i<15;i++)
- m_smpc.OREG[16+i]=0xff; // undefined
- }
-
- m_smpc.intback_stage = (m_smpc.intback_buf[1] & 8) >> 3; // first peripheral
- m_smpc.SR = 0x40 | m_smpc.intback_stage << 5;
- m_smpc.pmode = m_smpc.intback_buf[0]>>4;
-
- if(!(m_scu.ism & IRQ_SMPC))
- m_maincpu->set_input_line_and_vector(8, HOLD_LINE, 0x47);
- else
- m_scu.ist |= (IRQ_SMPC);
-
- /* put issued command in OREG31 */
- m_smpc.OREG[31] = 0x10;
- /* clear hand-shake flag */
- m_smpc.SF = 0x00;
- }
- else if(m_smpc.intback_buf[1] & 8)
- {
- m_smpc.intback_stage = (m_smpc.intback_buf[1] & 8) >> 3; // first peripheral
- m_smpc.SR = 0x40;
- m_smpc.OREG[31] = 0x10;
- machine().scheduler().timer_set(attotime::from_usec(0), timer_expired_delegate(FUNC(saturn_state::intback_peripheral),this),0);
- }
- else
- {
- printf("SMPC intback bogus behaviour called %02x %02x\n",m_smpc.IREG[0],m_smpc.IREG[1]);
- }
-
-}
-
-void saturn_state::smpc_rtc_write()
-{
- int i;
-
- for(i=0;i<7;i++)
- m_smpc.rtc_data[i] = m_smpc.IREG[i];
-}
-
-void saturn_state::smpc_memory_setting()
-{
- int i;
-
- for(i=0;i<4;i++)
- m_smpc.SMEM[i] = m_smpc.IREG[i];
-}
-
-void saturn_state::smpc_nmi_req()
-{
- /*NMI is unconditionally requested */
- m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
-}
-
-TIMER_CALLBACK_MEMBER( saturn_state::smpc_nmi_set )
-{
-// printf("%d %d\n",machine().first_screen()->hpos(),machine().first_screen()->vpos());
-
- m_NMI_reset = param;
- /* put issued command in OREG31 */
- m_smpc.OREG[31] = 0x19 + param;
- /* clear hand-shake flag */
- m_smpc.SF = 0x00;
-
- //m_smpc.OREG[0] = (0x80) | ((m_NMI_reset & 1) << 6);
-}
-
-
-TIMER_CALLBACK_MEMBER( saturn_state::smpc_audio_reset_line_pulse )
-{
- m_audiocpu->set_input_line(INPUT_LINE_RESET, PULSE_LINE);
-}
-
-/********************************************
- *
- * COMREG sub-routine
- *
- *******************************************/
-
-void saturn_state::smpc_comreg_exec(address_space &space, UINT8 data, UINT8 is_stv)
-{
- switch (data)
- {
- case 0x00:
- if(LOG_SMPC) printf ("SMPC: Master ON\n");
- smpc_master_on();
- break;
- //case 0x01: Master OFF?
- case 0x02:
- case 0x03:
- if(LOG_SMPC) printf ("SMPC: Slave %s %d %d\n",(data & 1) ? "off" : "on",machine().first_screen()->hpos(),machine().first_screen()->vpos());
- machine().scheduler().timer_set(attotime::from_usec(15), timer_expired_delegate(FUNC(saturn_state::smpc_slave_enable),this),data & 1);
- break;
- case 0x06:
- case 0x07:
- if(LOG_SMPC) printf ("SMPC: Sound %s\n",(data & 1) ? "off" : "on");
-
- if(!is_stv)
- machine().scheduler().timer_set(attotime::from_usec(15), timer_expired_delegate(FUNC(saturn_state::smpc_sound_enable),this),data & 1);
- break;
- /*CD (SH-1) ON/OFF */
- case 0x08:
- case 0x09:
- printf ("SMPC: CD %s\n",(data & 1) ? "off" : "on");
- machine().scheduler().timer_set(attotime::from_usec(20), timer_expired_delegate(FUNC(saturn_state::smpc_cd_enable),this),data & 1);
- break;
- case 0x0a:
- case 0x0b:
- popmessage ("SMPC: NETLINK %s, contact MAMEdev",(data & 1) ? "off" : "on");
- break; case 0x0d:
- if(LOG_SMPC) printf ("SMPC: System Reset\n");
- smpc_system_reset();
- break;
- case 0x0e:
- case 0x0f:
- if(LOG_SMPC) printf ("SMPC: Change Clock to %s (%d %d)\n",data & 1 ? "320" : "352",machine().first_screen()->hpos(),machine().first_screen()->vpos());
-
- /* on ST-V timing of this is pretty fussy, you get 2 credits at start-up otherwise
- My current theory is that SMPC first stops all CPUs until it executes the whole snippet for this,
- and restarts them when the screen is again ready for use. I really don't think that the system
- can do an usable mid-frame clock switching anyway.
- */
-
- m_maincpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
- m_slave->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
- m_audiocpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
-
- machine().scheduler().timer_set(machine().first_screen()->time_until_pos(get_vblank_start_position()*get_ystep_count(), 0), timer_expired_delegate(FUNC(saturn_state::smpc_change_clock),this),data & 1);
- break;
- /*"Interrupt Back"*/
- case 0x10:
- if(0)
- {
- printf ("SMPC: Status Acquire %02x %02x %02x %d\n",m_smpc.IREG[0],m_smpc.IREG[1],m_smpc.IREG[2],machine().first_screen()->vpos());
- }
-
- int timing;
-
- timing = 8;
-
- if(m_smpc.IREG[0] != 0) // non-peripheral data
- timing += 8;
-
- /* TODO: At vblank-out actually ... */
- if(m_smpc.IREG[1] & 8) // peripheral data
- timing += 700;
-
- /* TODO: check if IREG[2] is setted to 0xf0 */
- {
- int i;
-
- for(i=0;i<3;i++)
- m_smpc.intback_buf[i] = m_smpc.IREG[i];
- }
-
- if(is_stv)
- {
- machine().scheduler().timer_set(attotime::from_usec(timing), timer_expired_delegate(FUNC(saturn_state::stv_smpc_intback),this),0); //TODO: variable time
- }
- else
- {
- if(LOG_PAD_CMD) printf("INTBACK %02x %02x %d %d\n",m_smpc.IREG[0],m_smpc.IREG[1],machine().first_screen()->vpos(),(int)machine().first_screen()->frame_number());
- machine().scheduler().timer_set(attotime::from_usec(timing), timer_expired_delegate(FUNC(saturn_state::saturn_smpc_intback),this),0); //TODO: is variable time correct?
- }
- break;
- /* RTC write*/
- case 0x16:
- if(LOG_SMPC) printf("SMPC: RTC write\n");
- smpc_rtc_write();
- break;
- /* SMPC memory setting*/
- case 0x17:
- if(LOG_SMPC) printf ("SMPC: memory setting\n");
- smpc_memory_setting();
- break;
- case 0x18:
- if(LOG_SMPC) printf ("SMPC: NMI request\n");
- smpc_nmi_req();
- break;
- case 0x19:
- case 0x1a:
- /* TODO: timing */
- if(LOG_SMPC) printf ("SMPC: NMI %sable %d %d\n",data & 1 ? "Dis" : "En",machine().first_screen()->hpos(),machine().first_screen()->vpos());
- machine().scheduler().timer_set(attotime::from_usec(100), timer_expired_delegate(FUNC(saturn_state::smpc_nmi_set),this),data & 1);
- break;
- default:
- printf ("cpu '%s' (PC=%08X) SMPC: undocumented Command %02x\n", space.device().tag(), space.device().safe_pc(), data);
- }
-}
-
-/********************************************
- *
- * ST-V handlers
- *
- *******************************************/
-
-READ8_MEMBER( saturn_state::stv_SMPC_r )
-{
- int return_data = 0;
-
- if(!(offset & 1))
- return 0;
-
- if(offset >= 0x21 && offset <= 0x5f)
- return_data = m_smpc.OREG[(offset-0x21) >> 1];
-
- if (offset == 0x61) // TODO: SR
- return_data = m_smpc.SR;
-
- if (offset == 0x63)
- return_data = m_smpc.SF;
-
- if (offset == 0x75)//PDR1 read
- return_data = ioport("DSW1")->read();
-
- if (offset == 0x77)//PDR2 read
- return_data = (0xfe | m_eeprom->do_read());
-
- return return_data;
-}
-
-WRITE8_MEMBER( saturn_state::stv_SMPC_w )
-{
- if (!(offset & 1)) // avoid writing to even bytes
- return;
-
-// if(LOG_SMPC) printf ("8-bit SMPC Write to Offset %02x with Data %02x\n", offset, data);
-
- if(offset >= 1 && offset <= 0xd)
- m_smpc.IREG[offset >> 1] = data;
-
- if(offset == 1) //IREG0, check if a BREAK / CONTINUE request for INTBACK command
- {
- if(m_smpc.intback_stage)
- {
- if(data & 0x40)
- {
- if(LOG_PAD_CMD) printf("SMPC: BREAK request\n");
- m_smpc.SR &= 0x0f;
- m_smpc.intback_stage = 0;
- }
- else if(data & 0x80)
- {
- if(LOG_PAD_CMD) printf("SMPC: CONTINUE request\n");
- machine().scheduler().timer_set(attotime::from_usec(700), timer_expired_delegate(FUNC(saturn_state::stv_intback_peripheral),this),0); /* TODO: is timing correct? */
- m_smpc.OREG[31] = 0x10;
- m_smpc.SF = 0x01; //TODO: set hand-shake flag?
- }
- }
- }
-
- if (offset == 0x1f) // COMREG
- {
- smpc_comreg_exec(space,data,1);
-
- // we've processed the command, clear status flag
- if(data != 0x10 && data != 0x02 && data != 0x03 && data != 0x08 && data != 0x09 && data != 0xe && data != 0xf && data != 0x19 && data != 0x1a)
- {
- m_smpc.OREG[31] = data; //read-back command
- m_smpc.SF = 0x00;
- }
- /*TODO:emulate the timing of each command...*/
- }
-
- if(offset == 0x63)
- m_smpc.SF = data & 1;
-
- if(offset == 0x75)
- {
- /*
- -xx- ---- PDR1
- ---x ---- EEPROM write bit
- ---- x--- EEPROM CLOCK line
- ---- -x-- EEPROM CS line
- ---- --xx A-Bus bank bits
- */
- m_eeprom->clk_write((data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
- m_eeprom->di_write((data >> 4) & 1);
- m_eeprom->cs_write((data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
- m_stv_multi_bank = data & 3;
-
- stv_select_game(m_stv_multi_bank);
-
- m_smpc.PDR1 = (data & 0x60);
- }
-
- if(offset == 0x77)
- {
- /*
- -xx- ---- PDR2
- ---x ---- Enable Sound System (ACTIVE LOW)
- */
- //popmessage("PDR2 = %02x",m_smpc_ram[0x77]);
-
- if(LOG_SMPC) printf("SMPC: M68k %s\n",(data & 0x10) ? "off" : "on");
- //machine().scheduler().timer_set(attotime::from_usec(100), timer_expired_delegate(FUNC(saturn_state::smpc_sound_enable),this),(m_smpc_ram[0x77] & 0x10) >> 4);
- m_audiocpu->set_input_line(INPUT_LINE_RESET, (data & 0x10) ? ASSERT_LINE : CLEAR_LINE);
- m_en_68k = ((data & 0x10) >> 4) ^ 1;
-
- //if(LOG_SMPC) printf("SMPC: ram [0x77] = %02x\n",data);
- m_smpc.PDR2 = (data & 0x60);
- }
-
- if(offset == 0x7d)
- {
- /*
- ---- --x- IOSEL2 direct (1) / control mode (0) port select
- ---- ---x IOSEL1 direct (1) / control mode (0) port select
- */
- m_smpc.IOSEL1 = (data & 1) >> 0;
- m_smpc.IOSEL2 = (data & 2) >> 1;
- }
-
- if(offset == 0x7f)
- {
- //enable PAD irq & VDP2 external latch for port 1/2
- m_smpc.EXLE1 = (data & 1) >> 0;
- m_smpc.EXLE2 = (data & 2) >> 1;
- }
-}
-
-/********************************************
- *
- * Saturn handlers
- *
- *******************************************/
-
-UINT8 saturn_state::smpc_th_control_mode(UINT8 pad_n)
-{
- int th;
- const char *const padnames[] = { "JOY1", "JOY2" };
- UINT8 res = 0;
-
- th = (pad_n == 0) ? ((m_smpc.PDR1>>5) & 3) : ((m_smpc.PDR2>>5) & 3);
-
- if (LOG_SMPC) printf("SMPC: SH-2 TH control mode, returning pad data %d for phase %d\n",pad_n+1, th);
-
- switch(th)
- {
- /* TODO: 3D Lemmings bogusly enables TH Control mode, wants this to return the ID, needs HW tests. */
- case 3:
- res = th<<6;
- res |= 0x14;
- res |= machine().root_device().ioport(padnames[pad_n])->read() & 8; // L
- break;
- case 2:
- res = th<<6;
- // 1 C B Right Left Down Up
- // WHP actually has a very specific code at 0x6015f30, doesn't like bits 0-1 active here ...
- res|= (((machine().root_device().ioport(padnames[pad_n])->read()>>4)) & 0x30); // C & B
- res|= (((machine().root_device().ioport(padnames[pad_n])->read()>>12)) & 0xc);
- break;
- case 1:
- res = th<<6;
- res |= 0x10;
- res |= (machine().root_device().ioport(padnames[pad_n])->read()>>4) & 0xf; // R, X, Y, Z
- break;
- case 0:
- res = th<<6;
- // 0 Start A 0 0 Down Up
- res|= (((machine().root_device().ioport(padnames[pad_n])->read()>>6)) & 0x30); // Start & A
- res|= (((machine().root_device().ioport(padnames[pad_n])->read()>>12)) & 0x3);
- // ... and actually wants bits 2 - 3 active here.
- res|= 0xc;
- break;
- }
-
- return res;
-}
-
-UINT8 saturn_state::smpc_direct_mode(UINT8 pad_n)
-{
- int hshake;
- const int shift_bit[4] = { 4, 12, 8, 0 };
- const char *const padnames[] = { "JOY1", "JOY2" };
-
- hshake = (pad_n == 0) ? ((m_smpc.PDR1>>5) & 3) : ((m_smpc.PDR2>>5) & 3);
-
- if (LOG_SMPC) logerror("SMPC: SH-2 direct mode, returning data for phase %d\n", hshake);
-
- return 0x80 | 0x10 | ((machine().root_device().ioport(padnames[pad_n])->read()>>shift_bit[hshake]) & 0xf);
-}
-
-READ8_MEMBER( saturn_state::saturn_SMPC_r )
-{
- UINT8 return_data = 0;
-
- if (!(offset & 1)) // avoid reading to even bytes (TODO: is it 0s or 1s?)
- return 0x00;
-
- if(offset >= 0x21 && offset <= 0x5f)
- return_data = m_smpc.OREG[(offset-0x21) >> 1];
-
- if (offset == 0x61)
- return_data = m_smpc.SR;
-
- if (offset == 0x63)
- {
- //printf("SF %d %d\n",machine().first_screen()->hpos(),machine().first_screen()->vpos());
- return_data = m_smpc.SF;
- }
-
- if (offset == 0x75 || offset == 0x77)//PDR1/2 read
- {
- if ((m_smpc.IOSEL1 && offset == 0x75) || (m_smpc.IOSEL2 && offset == 0x77))
- {
- UINT8 cur_ddr;
-
- if(machine().root_device().ioport("INPUT_TYPE")->read() && !(space.debugger_access()))
- {
- popmessage("Warning: read with SH-2 direct mode with a non-pad device");
- return 0;
- }
-
- cur_ddr = (offset == 0x75) ? m_smpc.DDR1 : m_smpc.DDR2;
-
- switch(cur_ddr & 0x60)
- {
- case 0x00: break; // in diag test
- case 0x40: return_data = smpc_th_control_mode(offset == 0x77); break;
- case 0x60: return_data = smpc_direct_mode(offset == 0x77); break;
- default:
- popmessage("SMPC: unemulated control method %02x, contact MAMEdev",cur_ddr & 0x60);
- return_data = 0;
- break;
- }
- }
- }
-
- if (LOG_SMPC) logerror ("cpu %s (PC=%08X) SMPC: Read from Byte Offset %02x (%d) Returns %02x\n", space.device().tag(), space.device().safe_pc(), offset, offset>>1, return_data);
-
- return return_data;
-}
-
-WRITE8_MEMBER( saturn_state::saturn_SMPC_w )
-{
- if (LOG_SMPC) logerror ("8-bit SMPC Write to Offset %02x (reg %d) with Data %02x\n", offset, offset>>1, data);
-
- if (!(offset & 1)) // avoid writing to even bytes
- return;
-
- if(offset >= 1 && offset <= 0xd)
- m_smpc.IREG[offset >> 1] = data;
-
- if(offset == 1) //IREG0, check if a BREAK / CONTINUE request for INTBACK command
- {
- if(m_smpc.intback_stage)
- {
- if(data & 0x40)
- {
- if(LOG_PAD_CMD) printf("SMPC: BREAK request %02x\n",data);
- m_smpc.SR &= 0x0f;
- m_smpc.intback_stage = 0;
- }
- else if(data & 0x80)
- {
- if(LOG_PAD_CMD) printf("SMPC: CONTINUE request %02x\n",data);
- machine().scheduler().timer_set(attotime::from_usec(700), timer_expired_delegate(FUNC(saturn_state::intback_peripheral),this),0); /* TODO: is timing correct? */
- m_smpc.OREG[31] = 0x10;
- m_smpc.SF = 0x01; //TODO: set hand-shake flag?
- }
- }
- }
-
- if (offset == 0x1f)
- {
- smpc_comreg_exec(space,data,0);
-
- // we've processed the command, clear status flag
- if(data != 0x10 && data != 2 && data != 3 && data != 6 && data != 7 && data != 0x08 && data != 0x09 && data != 0x0e && data != 0x0f && data != 0x19 && data != 0x1a)
- {
- m_smpc.OREG[31] = data; //read-back for last command issued
- m_smpc.SF = 0x00; //clear hand-shake flag
- }
- /*TODO:emulate the timing of each command...*/
- }
-
- if (offset == 0x63)
- m_smpc.SF = data & 1; // hand-shake flag
-
- if(offset == 0x75) // PDR1
- m_smpc.PDR1 = data & 0x7f;
-
- if(offset == 0x77) // PDR2
- m_smpc.PDR2 = data & 0x7f;
-
- if(offset == 0x79)
- m_smpc.DDR1 = data & 0x7f;
-
- if(offset == 0x7b)
- m_smpc.DDR2 = data & 0x7f;
-
- if(offset == 0x7d)
- {
- m_smpc.IOSEL1 = data & 1;
- m_smpc.IOSEL2 = (data & 2) >> 1;
- }
-
- if(offset == 0x7f)
- {
- //enable PAD irq & VDP2 external latch for port 1/2
- m_smpc.EXLE1 = (data & 1) >> 0;
- m_smpc.EXLE2 = (data & 2) >> 1;
- }
-}
diff --git a/src/emu/machine/smpc.h b/src/emu/machine/smpc.h
deleted file mode 100644
index 7bb17fe337d..00000000000
--- a/src/emu/machine/smpc.h
+++ /dev/null
@@ -1,7 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:Angelo Salese, R. Belmont
-// TODO: make separate device when code is decoupled better
-//DECLARE_WRITE8_MEMBER( stv_SMPC_w );
-//DECLARE_READ8_MEMBER( stv_SMPC_r );
-//DECLARE_WRITE8_MEMBER( saturn_SMPC_w );
-//DECLARE_READ8_MEMBER( saturn_SMPC_r );
diff --git a/src/emu/machine/spchrom.c b/src/emu/machine/spchrom.c
deleted file mode 100644
index a49590e9e00..00000000000
--- a/src/emu/machine/spchrom.c
+++ /dev/null
@@ -1,139 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Frank Palazzolo, Aaron Giles, Jonathan Gevaryahu, Raphael Nabet, Couriersud, Michael Zapf
-/*
- spchroms.c - This is an emulator for "typical" speech ROMs from TI, as used by TI99/4(a).
-
- In order to support its speech processor, TI designed some ROMs with a 1-bit data bus
- and 4-bit address bus (multiplexed 5 times to provide a 18-bit address).
- A fairly complete description of such a ROM (tms6100) is found in the tms5220 datasheet.
-
- One notable thing is that the address is a byte address (*NOT* a bit address).
-
- This file is designed to be interfaced with the tms5220 core.
- Interfacing it with the tms5110 would make sense, too.
-
- TODO:
- Create separate devices for TMS6100 & TMS6125
- Implement the serial protocol
-*/
-
-#include "emu.h"
-#include "spchrom.h"
-
-#define TMS5220_ADDRESS_MASK 0x3FFFFUL /* 18-bit mask for tms5220 address */
-
-// device type definition
-const device_type SPEECHROM = &device_creator<speechrom_device>;
-
-speechrom_device::speechrom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, SPEECHROM, "SPEECHROM", tag, owner, clock, "speechrom", __FILE__),
- m_speechROMaddr(0),
- m_load_pointer(0),
- m_ROM_bits_count(0),
- m_reverse(false)
-{
-}
-
-/*
- Read 'count' bits serially from speech ROM
-
- Actually, the ROM is expected to have reversed bit order, but there are
- many dumps with normal bit order.
-
- compatibility mode: 01234567 01234567 01234567 ...
- correct mode: 76543210 76543210 76543210 ...
-*/
-int speechrom_device::read(int count)
-{
- int val;
- int spchbyte;
- int pos;
-
- if (m_load_pointer)
- { /* first read after load address is ignored */
- m_load_pointer = 0;
- count--;
- }
-
- if (m_speechROMaddr < m_speechROMlen)
- {
- val = 0;
- pos = 8 - m_ROM_bits_count;
-
- spchbyte = (m_reverse? (m_speechrom_data[m_speechROMaddr] >> pos) : (m_speechrom_data[m_speechROMaddr] << pos)) & 0xff;
-
- while (count > 0)
- {
- val = val << 1;
- if ((spchbyte & (m_reverse? 0x01:0x80))!=0) val |= 1;
- spchbyte = m_reverse? (spchbyte >> 1) : (spchbyte << 1);
- count--;
- if (pos == 7)
- {
- pos = 0;
- m_speechROMaddr = (m_speechROMaddr + 1) & TMS5220_ADDRESS_MASK;
- if (m_speechROMaddr >= m_speechROMlen)
- count = 0;
- else
- spchbyte = m_speechrom_data[m_speechROMaddr];
- }
- else pos++;
- }
- m_ROM_bits_count = 8 - pos;
- }
- else
- {
- val = 0;
- }
-
- return val;
-}
-
-/*
- Write an address nibble to speech ROM
-*/
-void speechrom_device::load_address(int data)
-{
- /* tms5220 data sheet says that if we load only one 4-bit nibble, it won't work.
- This code does not care about this. */
- m_speechROMaddr = ( (m_speechROMaddr & ~(0xf << m_load_pointer))
- | (((unsigned long) (data & 0xf)) << m_load_pointer) ) & TMS5220_ADDRESS_MASK;
- m_load_pointer += 4;
- m_ROM_bits_count = 8;
-}
-
-/*
- Perform a read and branch command
-*/
-void speechrom_device::read_and_branch()
-{
- /* tms5220 data sheet says that if more than one speech ROM (tms6100) is present,
- there is a bus contention. This code does not care about this. */
- if (m_speechROMaddr < m_speechROMlen-1)
- m_speechROMaddr = (m_speechROMaddr & 0x3c000UL)
- | (((((unsigned long) m_speechrom_data[m_speechROMaddr]) << 8)
- | m_speechrom_data[m_speechROMaddr+1]) & 0x3fffUL);
- else if (m_speechROMaddr == m_speechROMlen-1)
- m_speechROMaddr = (m_speechROMaddr & 0x3c000UL)
- | ((((unsigned long) m_speechrom_data[m_speechROMaddr]) << 8) & 0x3fffUL);
- else
- m_speechROMaddr = (m_speechROMaddr & 0x3c000UL);
-
- m_ROM_bits_count = 8;
-}
-
-void speechrom_device::device_start()
-{
- memory_region *region = memregion(tag());
- if (region == NULL)
- {
- throw emu_fatalerror("No region for device '%s'\n", tag());
- }
-
- m_speechrom_data = region->base();
- m_speechROMlen = region->bytes();
-
- save_item(NAME(m_speechROMaddr));
- save_item(NAME(m_load_pointer));
- save_item(NAME(m_ROM_bits_count));
-}
diff --git a/src/emu/machine/spchrom.h b/src/emu/machine/spchrom.h
deleted file mode 100644
index 520c7fc967b..00000000000
--- a/src/emu/machine/spchrom.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Frank Palazzolo, Aaron Giles, Jonathan Gevaryahu, Raphael Nabet, Couriersud, Michael Zapf
-/*
- * Voice Synthesis Memory
- *
- */
-
-#ifndef __SPCHROMS_H
-#define __SPCHROMS_H
-
-#include "emu.h"
-
-class speechrom_device : public device_t
-{
-public:
- // construction/destruction
- speechrom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- /// TODO: implement bus behaviour
- int read(int count);
- void load_address(int data);
- void read_and_branch();
- void set_reverse_bit_order(bool reverse) { m_reverse = reverse; }
-
- // device-level overrides
- virtual void device_start();
-
-private:
- UINT8 *m_speechrom_data; /* pointer to speech ROM data */
- unsigned int m_speechROMlen; /* length of data pointed by speechrom_data, from 0 to 2^18 */
- unsigned int m_speechROMaddr; /* 18 bit pointer in ROM */
- int m_load_pointer; /* which 4-bit nibble will be affected by load address */
- int m_ROM_bits_count; /* current bit position in ROM */
- bool m_reverse;
-};
-
-
-// device type definition
-extern const device_type SPEECHROM;
-
-#endif
diff --git a/src/emu/machine/steppers.c b/src/emu/machine/steppers.c
deleted file mode 100644
index e1eea4d648e..00000000000
--- a/src/emu/machine/steppers.c
+++ /dev/null
@@ -1,450 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:James Wallace
-///////////////////////////////////////////////////////////////////////////
-// //
-// steppers.c steppermotor emulation //
-// //
-// Emulates : Stepper motors driven with full step or half step //
-// also emulates the index optic //
-// //
-// 26-05-2012: J. Wallace - Implemented proper phase alignment, we no //
-// longer need reverse interfaces here, the //
-// layout will suffice. Added belt reel handler.//
-// 09-04-2012: J. Wallace - Studied some old reel motors and added a //
-// number of new stepper types. I am yet to //
-// add them to drivers, but barring some init //
-// stuff, they should work. //
-// 15-01-2012: J. Wallace - Total internal rewrite to remove the table //
-// hoodoo that stops anyone but me actually //
-// updating this. In theory, we should be able //
-// to adapt the phase code to any reel type by //
-// studying a game's startup //
-// Documentation is much better now. //
-// 04-04-2011: J. Wallace - Added reverse spin (this is necessary for //
-// accuracy), and improved wraparound logic //
-// 03-2011: New 2D array to remove reel bounce and //
-// make more realistic //
-// 26-01-2007: J. Wallace - Rewritten to make it more flexible //
-// and to allow indices to be set in drivers //
-// 29-12-2006: J. Wallace - Added state save support //
-// 05-03-2004: Re-Animator //
-// //
-// TODO: add further types of stepper motors if needed (Konami/IGT?) //
-// 200 Step reels can alter their relative opto tab position, //
-// may be worth adding the phase setting to the interface //
-// There are reports that some games use a pulse that is too short//
-// to give a 'judder' effect for holds, etc. We'll need to time //
-// the pulses to keep tack of this without going out of sync. //
-// Check 20RM and Starpoint 200 step //
-///////////////////////////////////////////////////////////////////////////
-
-#include "emu.h"
-#include "steppers.h"
-
-const device_type STEPPER = &device_creator<stepper_device>;
-
-stepper_device::stepper_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, STEPPER, "Stepper Motor", tag, owner, clock, "stepper", __FILE__),
- m_optic_cb(*this)
- {
- m_max_steps=(48*2);
- }
-///////////////////////////////////////////////////////////////////////////
-
-void stepper_device::update_optic()
-{
- int pos = m_step_pos,
- start = m_index_start,
- end = m_index_end;
-
- if (start > end) // cope with index patterns that wrap around
- {
- if ( (( pos > start ) || ( pos < end )) &&
- ( ( m_pattern == m_index_patt || m_index_patt==0) ||
- ( m_pattern == 0 &&
- (m_old_pattern == m_index_patt || m_index_patt==0)
- ) ) )
- {
- m_optic = 1;
- }
- else m_optic = 0;
- }
- else
- {
- if ( (( pos > start ) && ( pos < end )) &&
- ( ( m_pattern == m_index_patt || m_index_patt==0) ||
- ( m_pattern == 0 &&
- (m_old_pattern == m_index_patt || m_index_patt==0)
- ) ) )
- {
- m_optic = 1;
- }
- else m_optic = 0;
- }
-
- m_optic_cb(m_optic);
-}
-///////////////////////////////////////////////////////////////////////////
-
-void stepper_device::device_start()
-{
- /* resolve callbacks */
- m_optic_cb.resolve_safe();
-
- /* register for state saving */
- save_item(NAME(m_index_start));
- save_item(NAME(m_index_end));
- save_item(NAME(m_index_patt));
- save_item(NAME(m_initphase));
- save_item(NAME(m_phase));
- save_item(NAME(m_old_phase));
- save_item(NAME(m_pattern));
- save_item(NAME(m_old_pattern));
- save_item(NAME(m_step_pos));
- save_item(NAME(m_abs_step_pos));
- save_item(NAME(m_max_steps));
- save_item(NAME(m_type));
-}
-
-///////////////////////////////////////////////////////////////////////////
-
-void stepper_device::device_reset()
-{
- m_step_pos = 0x00;
- m_abs_step_pos = 0x00;
- m_pattern = 0x00;
- m_old_pattern = 0x00;
- m_phase = m_initphase;
- m_old_phase = m_initphase;
- update_optic();
-}
-
-///////////////////////////////////////////////////////////////////////////
-
-int stepper_device::update(UINT8 pattern)
-{
- int changed = 0;
-
- /* This code probably makes more sense if you visualise what is being emulated, namely
- a spinning drum with two electromagnets inside. Essentially, the CPU
- activates a pair of windings on these magnets leads as necessary to attract and repel the drum to pull it round and
- display as appropriate. To attempt to visualise the rotation effect, take a look at the compass rose below, representing a side on view of the reel,
- the numbers indicate the phase information as used
-
- 7
- N
- 1 W E 5
- S
- 3
-
- For sake of accuracy, we're representing all possible phases of the motor, effectively moving the motor one half step at a time, so a 48 step motor becomes
- 96 half steps. This is necessary because of some programs running the wiring in series with a distinct delay between the pair being completed. This causes
- a small movement that may trigger the optic tab.
- */
-
- int pos,steps=0;
- m_pattern = pattern;
- switch ( m_type )
- {
- default:
- logerror("No reel type specified!\n");
- break;
- case NOT_A_REEL :
- case STARPOINT_48STEP_REEL : /* STARPOINT RMxxx */
- case GAMESMAN_200STEP_REEL : /* Gamesman GMxxxx */
- case STARPOINT_144STEP_DICE :/* STARPOINT 1DCU DICE mechanism */
- case STARPOINT_200STEP_REEL :/* STARPOINT 1DCU DICE mechanism */
- //Standard drive table is 2,6,4,5,1,9,8,a
- //NOTE: This runs through the stator patterns in such a way as to drive the reel forward (downwards from the player's view, clockwise on our rose)
- //The Heber 'Pluto' controller runs this in reverse
- switch (pattern)
- { //Black Blue Red Yellow
- case 0x02:// 0 0 1 0
- m_phase = 7;
- break;
- case 0x06:// 0 1 1 0
- m_phase = 6;
- break;
- case 0x04:// 0 1 0 0
- m_phase = 5;
- break;
- case 0x05:// 0 1 0 1
- m_phase = 4;
- break;
- case 0x01:// 0 0 0 1
- m_phase = 3;
- break;
- case 0x09:// 1 0 0 1
- m_phase = 2;
- break;
- case 0x08:// 1 0 0 0
- m_phase = 1;
- break;
- case 0x0A:// 1 0 1 0
- m_phase = 0;
- break;
- // Black Blue Red Yellow
- case 0x03:// 0 0 1 1
- {
- if ((m_old_phase ==6)||(m_old_phase == 0)) // if the previous pattern had the drum in the northern quadrant, it will point north now
- {
- m_phase = 7;
- }
- else //otherwise it will line up due south
- {
- m_phase = 3;
- }
- }
- break;
- case 0x0C:// 1 1 0 0
- {
- if ((m_old_phase ==6)||(m_old_phase == 4)) // if the previous pattern had the drum in the eastern quadrant, it will point east now
- {
- m_phase = 5;
- }
- else //otherwise it will line up due west
- {
- m_phase = 1;
- }
- }
- break;
- }
- break;
-
- case BARCREST_48STEP_REEL :
- case GAMESMAN_48STEP_REEL :
- case GAMESMAN_100STEP_REEL :
- //Standard drive table is 1,3,2,6,4,C,8,9
- //Gamesman 48 step uses this pattern shifted one place forward, though this shouldn't matter
- switch (pattern)
- {
- // Yellow Brown Orange Black
- case 0x01:// 0 0 0 1
- m_phase = 7;
- break;
- case 0x03:// 0 0 1 1
- m_phase = 6;
- break;
- case 0x02:// 0 0 1 0
- m_phase = 5;
- break;
- case 0x06:// 0 1 1 0
- m_phase = 4;
- break;
- case 0x04:// 0 1 0 0
- m_phase = 3;
- break;
- case 0x0C:// 1 1 0 0
- m_phase = 2;
- break;
- case 0x08:// 1 0 0 0
- m_phase = 1;
- break;//YOLB
- case 0x09:// 1 0 0 1
- m_phase = 0;
- break;
-
- // The below values should not be used by anything sane, as they effectively ignore one stator side entirely
- // Yellow Brown Orange Black
- case 0x05:// 0 1 0 1
- {
- if ((m_old_phase ==6)||(m_old_phase == 0)) // if the previous pattern had the drum in the northern quadrant, it will point north now
- {
- m_phase = 7;
- }
- else //otherwise it will line up due south
- {
- m_phase = 3;
- }
- }
- break;
-
- case 0x0A:// 1 0 1 0
- {
- if ((m_old_phase ==6)||(m_old_phase == 4)) // if the previous pattern had the drum in the eastern quadrant, it will point east now
- {
- m_phase = 5;
- }
- else //otherwise it will line up due west
- {
- m_phase = 1;
- }
- }
- break;
- }
- break;
-
- case MPU3_48STEP_REEL :
- /* The MPU3 interface is actually the same as the MPU4 setup, but with two active lines instead of four
- Inverters are used so if a pin is low, the higher bit of the pair is activated, and if high the lower bit is activated.
- TODO:Check this, 2 and 1 could be switched over.
- */
- switch (pattern)
- {
- // Yellow(2) Brown(1) Orange(!2) Black(!1)
- case 0x00 :// 0 0 1 1
- m_phase = 6;
- break;
- case 0x01 :// 0 1 1 0
- m_phase = 4;
- break;
- case 0x03 :// 1 1 0 0
- m_phase = 2;
- break;
- case 0x02 :// 1 0 0 1
- m_phase = 0;
- break;
- }
- break;
-
- case ECOIN_200STEP_REEL :
- //While the 48 and 100 step models appear to be reverse driven Starpoint reels, the 200 step model seems bespoke, certainly in terms of wiring.
- //On a Proconn machine this same pattern is seen but running in reverse
- //Standard drive table is 8,c,4,6,2,3,1,9
- switch (pattern)
- {
- case 0x08:// 0 0 1 0
- m_phase = 7;
- break;
- case 0x0c:// 0 1 1 0
- m_phase = 6;
- break;
- case 0x04:// 0 1 0 0
- m_phase = 5;
- break;
- case 0x06:// 0 1 0 1
- m_phase = 4;
- break;
- case 0x02:// 0 0 0 1
- m_phase = 3;
- break;
- case 0x03:// 1 0 0 1
- m_phase = 2;
- break;
- case 0x01:// 1 0 0 0
- m_phase = 1;
- break;
- case 0x09:// 1 0 1 0
- m_phase = 0;
- break;
- case 0x0a:// 0 0 1 1
- {
- if ((m_old_phase ==6)||(m_old_phase == 0)) // if the previous pattern had the drum in the northern quadrant, it will point north now
- {
- m_phase = 7;
- }
- else //otherwise it will line up due south
- {
- m_phase = 3;
- }
- }
- break;
- case 0x07:// 1 1 0 0
- {
- if ((m_old_phase ==6)||(m_old_phase == 4)) // if the previous pattern had the drum in the eastern quadrant, it will point east now
- {
- m_phase = 5;
- }
- else //otherwise it will line up due west
- {
- m_phase = 1;
- }
- }
- break;
- }
- break;
-
- case PROJECT_48STEP_REEL :
- //Standard drive table is 8,c,4,5,1,3,2,a
- //This appears to be basically a rewired Gamesman (the reel PCB looks like it does some shuffling)
- //TODO: Not sure if this should be represented as a type here, or by defining it as a Gamesman in the driver and bitswapping.
- switch (pattern)
- {
- case 0x08:// 0 0 1 0
- m_phase = 7;
- break;
- case 0x0c:// 0 1 1 0
- m_phase = 6;
- break;
- case 0x04:// 0 1 0 0
- m_phase = 5;
- break;
- case 0x05:// 0 1 0 1
- m_phase = 4;
- break;
- case 0x01:// 0 0 0 1
- m_phase = 3;
- break;
- case 0x03:// 1 0 0 1
- m_phase = 2;
- break;
- case 0x02:// 1 0 0 0
- m_phase = 1;
- break;
- case 0x0a:// 1 0 1 0
- m_phase = 0;
- break;
- case 0x09:// 0 0 1 1
- {
- if ((m_old_phase ==6)||(m_old_phase == 0)) // if the previous pattern had the drum in the northern quadrant, it will point north now
- {
- m_phase = 7;
- }
- else //otherwise it will line up due south
- {
- m_phase = 3;
- }
- }
- break;
- case 0x06:// 1 1 0 0
- {
- if ((m_old_phase ==6)||(m_old_phase == 4)) // if the previous pattern had the drum in the eastern quadrant, it will point east now
- {
- m_phase = 5;
- }
- else //otherwise it will line up due west
- {
- m_phase = 1;
- }
- }
- break;
- }
- break;
-
-
-
- }
-
- steps = m_old_phase - m_phase;
-
- if (steps < -4)
- {
- steps = steps +8;
- }
- if (steps > 4)
- {
- steps = steps -8;
- }
-
- m_old_phase = m_phase;
- m_old_pattern = m_pattern;
-
- int max = m_max_steps;
- pos = 0;
-
- if (max!=0)
- {
- m_abs_step_pos += steps;
- pos = (m_step_pos + steps + max) % max;
- }
-
- if (pos != m_step_pos)
- {
- changed++;
- }
-
- m_step_pos = pos;
- update_optic();
-
- return changed;
-}
diff --git a/src/emu/machine/steppers.h b/src/emu/machine/steppers.h
deleted file mode 100644
index 1ed62da6885..00000000000
--- a/src/emu/machine/steppers.h
+++ /dev/null
@@ -1,179 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:James Wallace
-///////////////////////////////////////////////////////////////////////////
-// //
-// steppers.c steppermotor emulation //
-// //
-// Emulates : stepper motors driven with full step or half step //
-// also emulates the index optic //
-// //
-// //
-// TODO: add further types of stepper motors if needed (Konami/IGT?) //
-///////////////////////////////////////////////////////////////////////////
-
-
-#ifndef INC_STEPPERS
-#define INC_STEPPERS
-
-#define NOT_A_REEL 0
-#define STARPOINT_48STEP_REEL 1 /* STARPOINT RMXXX reel unit */
-#define STARPOINT_144STEP_DICE 2 /* STARPOINT 1DCU DICE mechanism */
-#define STARPOINT_200STEP_REEL 3
-
-#define BARCREST_48STEP_REEL 4 /* Barcrest bespoke reel unit */
-#define MPU3_48STEP_REEL 5
-
-#define ECOIN_200STEP_REEL 6 /* Probably not bespoke, but can't find a part number */
-
-#define GAMESMAN_48STEP_REEL 7
-#define GAMESMAN_100STEP_REEL 8
-#define GAMESMAN_200STEP_REEL 9
-
-#define PROJECT_48STEP_REEL 10
-
-#define MCFG_STEPPER_ADD(_tag)\
- MCFG_DEVICE_ADD(_tag, STEPPER, 0)
-
-#define MCFG_STEPPER_REEL_TYPE(_data) \
- stepper_device::set_reel_type(*device, _data);
-
-/* total size of reel (in half steps) */
-#define MCFG_STEPPER_MAX_STEPS(_write) \
- stepper_device::set_max_steps(*device, _write);
-
-/* start position of index (in half steps) */
-#define MCFG_STEPPER_START_INDEX(_write) \
- stepper_device::set_start_index(*device, _write);
-
-/* end position of index (in half steps) */
-#define MCFG_STEPPER_END_INDEX(_write) \
- stepper_device::set_end_index(*device, _write);
-
-/* end position of index (in half steps) */
-#define MCFG_STEPPER_INDEX_PATTERN(_write) \
- stepper_device::set_index_pattern(*device, _write);
-
-/* Phase at 0, for opto linkage */
-#define MCFG_STEPPER_INIT_PHASE(_write) \
- stepper_device::set_init_phase(*device, _write);
-
-#define MCFG_STARPOINT_48STEP_ADD(_tag)\
- MCFG_STEPPER_ADD(_tag)\
- MCFG_STEPPER_REEL_TYPE(STARPOINT_48STEP_REEL)\
- MCFG_STEPPER_START_INDEX(1)\
- MCFG_STEPPER_END_INDEX(3)\
- MCFG_STEPPER_INDEX_PATTERN(0x09)\
- MCFG_STEPPER_INIT_PHASE(4)
-
-#define MCFG_STARPOINT_RM20_48STEP_ADD(_tag)\
- MCFG_DEVICE_ADD(_tag, STEPPER, 0)\
- MCFG_STEPPER_REEL_TYPE(STARPOINT_48STEP_REEL)\
- MCFG_STEPPER_START_INDEX(16)\
- MCFG_STEPPER_END_INDEX(24)\
- MCFG_STEPPER_INDEX_PATTERN(0x09)\
- MCFG_STEPPER_INIT_PHASE(7)
-
-#define MCFG_STARPOINT_200STEP_ADD(_tag)\
- MCFG_DEVICE_ADD(_tag, STEPPER, 0)\
- MCFG_STEPPER_REEL_TYPE(STARPOINT_200STEP_REEL)\
- MCFG_STEPPER_MAX_STEPS(200*2)\
- MCFG_STEPPER_START_INDEX(12)\
- MCFG_STEPPER_END_INDEX(24)\
- MCFG_STEPPER_INDEX_PATTERN(0x09)\
- MCFG_STEPPER_INIT_PHASE(7)
-
-//guess
-#define MCFG_ECOIN_200STEP_ADD(_tag)\
- MCFG_DEVICE_ADD(_tag, STEPPER, 0)\
- MCFG_STEPPER_REEL_TYPE(ECOIN_200STEP_REEL)\
- MCFG_STEPPER_MAX_STEPS(200*2)\
- MCFG_STEPPER_START_INDEX(12)\
- MCFG_STEPPER_END_INDEX(24)\
- MCFG_STEPPER_INDEX_PATTERN(0x09)\
- MCFG_STEPPER_INIT_PHASE(7)
-
-#define MCFG_STEPPER_OPTIC_CALLBACK(_write) \
- devcb = &stepper_device::set_optic_handler(*device, DEVCB_##_write);
-
-class stepper_device;
-extern const device_type STEPPER;
-
-class stepper_device : public device_t
-{
-public:
- stepper_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_optic_handler(device_t &device, _Object object) { return downcast<stepper_device &>(device).m_optic_cb.set_callback(object); }
-
- static void set_reel_type(device_t &device, UINT8 type)
- {
- downcast<stepper_device &>(device).m_type = type;
- switch ( type )
- { default:
- case STARPOINT_48STEP_REEL: /* STARPOINT RMxxx */
- case BARCREST_48STEP_REEL : /* Barcrest Reel unit */
- case MPU3_48STEP_REEL :
- case GAMESMAN_48STEP_REEL : /* Gamesman GMxxxx */
- case PROJECT_48STEP_REEL :
- downcast<stepper_device &>(device).m_max_steps = (48*2);
- break;
- case GAMESMAN_100STEP_REEL :
- downcast<stepper_device &>(device).m_max_steps = (100*2);
- break;
- case STARPOINT_144STEP_DICE :/* STARPOINT 1DCU DICE mechanism */
- //Dice reels are 48 step motors, but complete three full cycles between opto updates
- downcast<stepper_device &>(device).m_max_steps = ((48*3)*2);
- break;
- case STARPOINT_200STEP_REEL :
- case GAMESMAN_200STEP_REEL :
- case ECOIN_200STEP_REEL :
- downcast<stepper_device &>(device).m_max_steps = (200*2);
- break;
- }
- }
- static void set_max_steps(device_t &device, INT16 steps) { downcast<stepper_device &>(device).m_max_steps = steps; }
- static void set_start_index(device_t &device, INT16 index) { downcast<stepper_device &>(device).m_index_start = index; }
- static void set_end_index(device_t &device, INT16 index) { downcast<stepper_device &>(device).m_index_end = index; }
- static void set_index_pattern(device_t &device, INT16 index) { downcast<stepper_device &>(device).m_index_patt = index; }
- static void set_init_phase(device_t &device, UINT8 phase)
- {
- downcast<stepper_device &>(device).m_initphase = phase;
- downcast<stepper_device &>(device).m_phase = phase;
- downcast<stepper_device &>(device).m_old_phase = phase;
- }
-
- /* update a motor */
- int update(UINT8 pattern);
-
- /* get current position in half steps */
- int get_position() { return m_step_pos; }
- /* get current absolute position in half steps */
- int get_absolute_position() { return m_abs_step_pos; }
- /* get maximum position in half steps */
- int get_max() { return m_max_steps; }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- UINT8 m_pattern; /* coil pattern */
- UINT8 m_old_pattern; /* old coil pattern */
- UINT8 m_initphase;
- UINT8 m_phase; /* motor phase */
- UINT8 m_old_phase; /* old phase */
- UINT8 m_type; /* reel type */
- INT16 m_step_pos; /* step position 0 - max_steps */
- INT16 m_max_steps; /* maximum step position */
- INT32 m_abs_step_pos; /* absolute step position */
- INT16 m_index_start; /* start position of index (in half steps) */
- INT16 m_index_end; /* end position of index (in half steps) */
- INT16 m_index_patt; /* pattern needed on coils (0=don't care) */
- UINT8 m_optic;
-
- void update_optic();
- devcb_write_line m_optic_cb;
-};
-
-#endif
diff --git a/src/emu/machine/strata.c b/src/emu/machine/strata.c
deleted file mode 100644
index 01651eb90bd..00000000000
--- a/src/emu/machine/strata.c
+++ /dev/null
@@ -1,675 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Raphael Nabet, Michael Zapf
-/*
- Intel 28F640J5 Flash ROM emulation (could also handle 28F320J5 with minor
- changes, and possibly 28F256J3, 28F128J3, 28F640J3 and 28F320J3)
-
- The 28F640J5 is a 64Mbit FEEPROM that can be accessed either on an 8-bit or
- a 16-bit bus.
-
- References:
- Datasheets were found on Intel's site (www.intel.com)
-
- Raphael Nabet 2004, based on MAME's intelfsh.c core
-
- Device is currently only used in ti99/tn_usbsm
-
- Rewritten as class
- Michael Zapf, 2014
-
- TODO: Make it work
-*/
-
-#include "emu.h"
-#include "strata.h"
-
-#define MAX_STRATA 1
-
-#define FEEPROM_SIZE 0x800000 // 64Mbit
-#define BLOCK_SIZE 0x020000
-
-#define BLOCKLOCK_SIZE ((FEEPROM_SIZE/BLOCK_SIZE+7)/8)
-#define WRBUF_SIZE 32
-#define PROT_REGS_SIZE 18
-
-#define COMPLETE_SIZE FEEPROM_SIZE + WRBUF_SIZE + PROT_REGS_SIZE + BLOCKLOCK_SIZE
-
-#define ADDRESS_MASK 0x7fffff
-#define BLOCK_ADDRESS_MASK 0x7e0000
-#define BLOCK_ADDRESS_SHIFT 17
-#define BYTE_ADDRESS_MASK 0x01ffff
-
-/* accessors for individual block lock flags */
-#define READ_BLOCKLOCK(block) ((m_blocklock[(block) >> 3] >> ((block) & 7)) & 1)
-#define SET_BLOCKLOCK(block) (m_blocklock[(block) >> 3] |= 1 << ((block) & 7))
-#define CLEAR_BLOCKLOCK(block) (m_blocklock[(block) >> 3] &= ~(1 << ((block) & 7)))
-
-const device_type STRATAFLASH = &device_creator<strataflash_device>;
-
-strataflash_device::strataflash_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, STRATAFLASH, "Intel 28F640J5", tag, owner, clock, "strataflash", __FILE__),
- device_nvram_interface(mconfig, *this)
-{
-}
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void strataflash_device::nvram_default()
-{
- memset(m_flashmemory, 0, COMPLETE_SIZE);
-}
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void strataflash_device::nvram_read(emu_file &file)
-{
- file.read(m_flashmemory, COMPLETE_SIZE);
-
- // TODO
-
- /*
- UINT8 buf;
- int i;
-
- // version flag
- if (file->read(& buf, 1) != 1)
- return 1;
- if (buf != 0)
- return 1;
-
- // chip state: master lock
- if (file->read(& buf, 1) != 1)
- return 1;
- m_master_lock = buf & 1;
-
- // main FEEPROM area
- if (file->read(m_flashmemory, FEEPROM_SIZE) != FEEPROM_SIZE)
- return 1;
- for (i = 0; i < FEEPROM_SIZE; i += 2)
- {
- UINT16 *ptr = (UINT16 *) (&m_flashmemory[i]);
- *ptr = LITTLE_ENDIANIZE_INT16(*ptr);
- }
-
- // protection registers
- if (file->read(m_prot_regs, PROT_REGS_SIZE) != PROT_REGS_SIZE)
- return 1;
- for (i = 0; i < PROT_REGS_SIZE; i += 2)
- {
- UINT16 *ptr = (UINT16 *) (&m_prot_regs[i]);
- *ptr = LITTLE_ENDIANIZE_INT16(*ptr);
- }
-
- // block lock flags
- if (file->read(m_blocklock, BLOCKLOCK_SIZE) != BLOCKLOCK_SIZE)
- return 1;
-
- return 0;
- */
-}
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void strataflash_device::nvram_write(emu_file &file)
-{
- // TODO
-
- /*
- UINT8 buf;
- int i;
-
- // version flag
- buf = 0;
- if (file->write(& buf, 1) != 1)
- return 1;
-
- // chip state: lower boot block lockout, higher boot block lockout,
- software data protect
- buf = m_master_lock;
- if (file->write(& buf, 1) != 1)
- return 1;
-
- // main FEEPROM area
- for (i = 0; i < FEEPROM_SIZE; i += 2)
- {
- UINT16 *ptr = (UINT16 *) (&m_flashmemory[i]);
- *ptr = LITTLE_ENDIANIZE_INT16(*ptr);
- }
- if (file->write(m_flashmemory, FEEPROM_SIZE) != FEEPROM_SIZE)
- return 1;
- for (i = 0; i < FEEPROM_SIZE; i += 2)
- {
- UINT16 *ptr = (UINT16 *) (&m_flashmemory[i]);
- *ptr = LITTLE_ENDIANIZE_INT16(*ptr);
- }
-
- // protection registers
- for (i = 0; i < PROT_REGS_SIZE; i += 2)
- {
- UINT16 *ptr = (UINT16 *) (&m_prot_regs[i]);
- *ptr = LITTLE_ENDIANIZE_INT16(*ptr);
- }
- if (file->write(m_prot_regs, PROT_REGS_SIZE) != PROT_REGS_SIZE)
- return 1;
- for (i = 0; i < PROT_REGS_SIZE; i += 2)
- {
- UINT16 *ptr = (UINT16 *) (&m_prot_regs[i]);
- *ptr = LITTLE_ENDIANIZE_INT16(*ptr);
- }
-
- // block lock flags
- if (file->write(m_blocklock, BLOCKLOCK_SIZE) != BLOCKLOCK_SIZE)
- return 1;
-
- return 0;
- */
-
- file.write(m_flashmemory, COMPLETE_SIZE);
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-void strataflash_device::device_start(void)
-{
- m_mode = FM_NORMAL;
- m_status = 0x80;
- m_master_lock = 0;
- m_flashmemory = auto_alloc_array(machine(), UINT8, COMPLETE_SIZE);
-
- m_wrbuf = m_flashmemory + FEEPROM_SIZE;
- m_prot_regs = m_wrbuf + WRBUF_SIZE;
- m_blocklock = m_prot_regs + PROT_REGS_SIZE;
-
- // clear various FEEPROM areas
- memset(m_prot_regs, 0xff, 18);
- memset(m_flashmemory, 0xff, FEEPROM_SIZE);
- memset(m_blocklock, 0x00, BLOCKLOCK_SIZE);
-
- // set-up factory-programmed protection register segment
- m_prot_regs[BYTE_XOR_LE(0)] &= 0xfe;
- for (int i=2; i<10; i++)
- m_prot_regs[i] = machine().rand();
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void strataflash_device::device_config_complete()
-{
-}
-
-/*
- read a 8/16-bit word from FEEPROM
-*/
-UINT16 strataflash_device::read8_16(address_space& space, offs_t offset, bus_width_t bus_width)
-{
- switch (bus_width)
- {
- case bw_8:
- offset &= ADDRESS_MASK;
- break;
- case bw_16:
- offset &= ADDRESS_MASK & ~1;
- }
-
- switch (m_mode)
- {
- default:
- case FM_NORMAL:
- switch (bus_width)
- {
- case bw_8:
- return m_flashmemory[BYTE_XOR_LE(offset)];
- case bw_16:
- return *(UINT16*)(m_flashmemory+offset);
- }
- break;
- case FM_READSTATUS:
- return m_status;
- case FM_WRBUFPART1:
- return 0x80;
- case FM_READID:
- if ((offset >= 0x100) && (offset < 0x112))
- { /* protection registers */
- switch (bus_width)
- {
- case bw_8:
- return m_prot_regs[BYTE_XOR_LE(offset)];
- case bw_16:
- return *(UINT16*)(m_prot_regs+offset);
- }
- }
- else
- switch (offset >> 1)
- {
- case 0: // maker ID
- return 0x89; // Intel
- case 1: // chip ID
- return 0x15; // 64 Mbit
- default:
- if (((offset & BYTE_ADDRESS_MASK) >> 1) == 2)
- { // block lock config
- return READ_BLOCKLOCK(offset >> BLOCK_ADDRESS_SHIFT);
- }
- return 0; // default case
- case 3: // master lock config
- if (m_master_lock)
- return 1;
- else
- return 0;
- }
- break;
- case FM_READQUERY:
- switch (offset >> 1)
- {
- case 0x00: // maker ID
- return 0x89; // Intel
- case 0x01: // chip ID
- return 0x15; // 64 Mbit
- default:
- if (((offset & BYTE_ADDRESS_MASK) >> 1) == 2)
- { // block lock config
- return READ_BLOCKLOCK(offset >> BLOCK_ADDRESS_SHIFT);
- }
- return 0; // default case
-#if 0
- case 0x03: // master lock config
- if (m_flash_master_lock)
- return 1;
- else
- return 0;
-#endif
-
- /* CFI query identification string */
- case 0x10:
- return 'Q';
- case 0x11:
- return 'R';
- case 0x12:
- return 'Y';
- case 0x13:
- return 0x01;
- case 0x14:
- return 0x00;
- case 0x15:
- return 0x31;
- case 0x16:
- return 0x00;
- case 0x17:
- case 0x18:
- case 0x19:
- case 0x1a:
- return 0x00;
-
- /* system interface information: voltage */
- case 0x1b:
- return 0x45;
- case 0x1c:
- return 0x55;
- case 0x1d:
- return 0x00;
- case 0x1e:
- return 0x00;
-
- /* system interface information: timings */
- case 0x1f:
- return /*0x07*/0x00;
- case 0x20:
- return /*0x07*/0x00;
- case 0x21:
- return /*0x0a*/0x00;
- case 0x22:
- return 0x00;
- case 0x23:
- return /*0x04*/0x00;
- case 0x24:
- return /*0x04*/0x00;
- case 0x25:
- return /*0x04*/0x00;
- case 0x26:
- return 0x00;
-
- /* device geometry definition */
- case 0x27:
- return 0x17;
- case 0x28:
- return 0x02;
- case 0x29:
- return 0x00;
- case 0x2a:
- return 0x05;
- case 0x2b:
- return 0x00;
- case 0x2c:
- return 0x01;
- case 0x2d:
- return 0x3f;
- case 0x2e:
- return 0x00;
- case 0x2f:
- return 0x00;
- case 0x30:
- return 0x02;
-
- /* primary vendor-specific extended query */
- case 0x31:
- return 'P';
- case 0x32:
- return 'R';
- case 0x33:
- return 'I';
- case 0x34:
- return '1';
- case 0x35:
- return '1';
- case 0x36:
- return 0x0a;
- case 0x37:
- return 0x00;
- case 0x38:
- return 0x00;
- case 0x39:
- return 0x00;
- case 0x3a:
- return 0x01;
- case 0x3b:
- return 0x01;
- case 0x3c:
- return 0x00;
- case 0x3d:
- return 0x50;
- case 0x3e:
- return 0x00;
- case 0x3f:
- return 0x00;
- }
- }
-
- return 0;
-}
-
-/*
- write a 8/16-bit word to FEEPROM
-*/
-void strataflash_device::write8_16(address_space& space, offs_t offset, UINT16 data, bus_width_t bus_width)
-{
- switch (bus_width)
- {
- case bw_8:
- offset &= ADDRESS_MASK;
- break;
- case bw_16:
- offset &= ADDRESS_MASK & ~1;
- break;
- }
-
- switch (m_mode)
- {
- case FM_NORMAL:
- case FM_READID:
- case FM_READQUERY:
- case FM_READSTATUS:
- switch (data)
- {
- case 0xff: // read array
- m_mode = FM_NORMAL;
- break;
- case 0x90: // read identifier codes
- m_mode = FM_READID;
- break;
- case 0x98: // read query
- m_mode = FM_READQUERY;
- break;
- case 0x70: // read status register
- m_mode = FM_READSTATUS;
- break;
- case 0x50: // clear status register
- m_mode = FM_READSTATUS;
- m_status &= 0xC5;
- break;
- case 0xe8: // write to buffer
- m_mode = FM_WRBUFPART1;
- m_wrbuf_base = offset & BLOCK_ADDRESS_MASK;
- /*m_status &= 0xC5;*/
- break;
- case 0x40:
- case 0x10: // program
- m_mode = FM_WRITEPART1;
- m_status &= 0xC5;
- break;
- case 0x20: // block erase
- m_mode = FM_CLEARPART1;
- m_status &= 0xC5;
- break;
- case 0xb0: // block erase, program suspend
- /* not emulated (erase is instantaneous) */
- break;
- case 0xd0: // block erase, program resume
- /* not emulated (erase is instantaneous) */
- break;
- case 0xb8: // configuration
- m_mode = FM_CONFPART1;
- m_status &= 0xC5;
- break;
- case 0x60: // set master lock
- m_mode = FM_SETLOCK;
- m_status &= 0xC5;
- break;
- case 0xc0: // protection program
- m_mode = FM_WRPROTPART1;
- m_status &= 0xC5;
- break;
- default:
- logerror("Unknown flash mode byte %x\n", data);
- break;
- }
- break;
- case FM_WRBUFPART1:
- m_mode = FM_WRBUFPART2;
- if (((offset & BLOCK_ADDRESS_MASK) != m_wrbuf_base) || (data >= 0x20))
- {
- m_status |= 0x30;
- m_wrbuf_len = 0;
- m_wrbuf_count = data;
- }
- else
- {
- switch (bus_width)
- {
- case bw_8:
- m_wrbuf_len = data+1;
- break;
- case bw_16:
- m_wrbuf_len = (data+1) << 1;
- break;
- }
- m_wrbuf_count = data;
- }
- break;
- case FM_WRBUFPART2:
- m_mode = FM_WRBUFPART3;
- if (((offset & BLOCK_ADDRESS_MASK) != m_wrbuf_base)
- || (((offset & BYTE_ADDRESS_MASK) + m_wrbuf_len) > BLOCK_SIZE))
- {
- m_status |= 0x30;
- m_wrbuf_len = 0;
- m_wrbuf_base = 0;
- }
- else
- m_wrbuf_base = offset;
- memset(m_wrbuf, 0xff, m_wrbuf_len); /* right??? */
- case FM_WRBUFPART3:
- if ((offset < m_wrbuf_base) || (offset >= (m_wrbuf_base + m_wrbuf_len)))
- m_status |= 0x30;
- else
- {
- switch (bus_width)
- {
- case bw_8:
- m_wrbuf[offset-m_wrbuf_base] = data;
- break;
- case bw_16:
- m_wrbuf[offset-m_wrbuf_base] = data & 0xff;
- m_wrbuf[offset-m_wrbuf_base+1] = data >> 8;
- break;
- }
- }
- if (m_wrbuf_count == 0)
- m_mode = FM_WRBUFPART4;
- else
- m_wrbuf_count--;
- break;
- case FM_WRBUFPART4:
- if (((offset & BLOCK_ADDRESS_MASK) != (m_wrbuf_base & BLOCK_ADDRESS_MASK)) || (data != 0xd0))
- {
- m_status |= 0x30;
- }
- else if (READ_BLOCKLOCK(offset >> BLOCK_ADDRESS_SHIFT) && !m_hard_unlock)
- {
- m_status |= 0x12;
- }
- else if (!(m_status & 0x30))
- {
- int i;
- for (i=0; i<m_wrbuf_len; i++)
- m_flashmemory[BYTE_XOR_LE(m_wrbuf_base+i)] &= m_wrbuf[i];
- m_mode = FM_READSTATUS;
- }
- break;
- case FM_WRITEPART1:
- if (READ_BLOCKLOCK(offset >> BLOCK_ADDRESS_SHIFT) && !m_hard_unlock)
- {
- m_status |= 0x12;
- }
- else
- {
- switch (bus_width)
- {
- case bw_8:
- m_flashmemory[BYTE_XOR_LE(offset)] &= data;
- break;
- case bw_16:
- *(UINT16*)(m_flashmemory+offset) &= data;
- break;
- }
- }
- m_mode = FM_READSTATUS;
- break;
- case FM_CLEARPART1:
- if (data == 0xd0)
- {
- // clear the 128k block containing the current address
- // to all 0xffs
- if (READ_BLOCKLOCK(offset >> BLOCK_ADDRESS_SHIFT) && !m_hard_unlock)
- {
- m_status |= 0x22;
- }
- else
- {
- offset &= BLOCK_ADDRESS_MASK;
- memset(&m_flashmemory[offset], 0xff, BLOCK_SIZE);
- }
- m_mode = FM_READSTATUS;
- }
- break;
- case FM_SETLOCK:
- switch (data)
- {
- case 0xf1:
- if (!m_hard_unlock)
- m_status |= 0x12;
- else
- m_master_lock = 1;
- break;
- case 0x01:
- if (m_master_lock && !m_hard_unlock)
- m_status |= 0x12;
- else
- SET_BLOCKLOCK(offset >> BLOCK_ADDRESS_SHIFT);
- break;
- case 0xd0:
- if (m_master_lock && !m_hard_unlock)
- m_status |= 0x22;
- else
- CLEAR_BLOCKLOCK(offset >> BLOCK_ADDRESS_SHIFT);
- break;
- case 0x03: // Set Read configuration
- /* ignore command */
- break;
- default:
- m_status |= 0x30;
- break;
- }
- m_mode = FM_READSTATUS;
- break;
- case FM_CONFPART1:
- /* configuration register is not emulated because the sts pin is not */
- //m_configuration = data;
- m_mode = FM_READSTATUS; /* right??? */
- break;
- case FM_WRPROTPART1:
- if ((offset < 0x100) || (offset >= 0x112))
- m_status |= 0x10;
- else if ((offset >= 0x102) && !((m_prot_regs[BYTE_XOR_LE(0)] >> ((offset - 0x102) >> 3)) & 1))
- m_status |= 0x12;
- else
- {
- switch (bus_width)
- {
- case bw_8:
- m_prot_regs[BYTE_XOR_LE(offset-0x100)] &= data;
- break;
- case bw_16:
- *(UINT16*)(m_prot_regs+(offset-0x100)) &= data;
- break;
- }
- }
- m_mode = FM_READSTATUS; /* right??? */
- break;
- }
-}
-
-/*
- read a byte from FEEPROM
-*/
-READ8_MEMBER( strataflash_device::read8 )
-{
- return read8_16(space, offset, bw_8);
-}
-
-/*
- Write a byte to FEEPROM
-*/
-WRITE8_MEMBER( strataflash_device::write8 )
-{
- write8_16(space, offset, data, bw_8);
-}
-
-/*
- read a 16-bit word from FEEPROM
-*/
-READ16_MEMBER( strataflash_device::read16 )
-{
- return read8_16(space, offset, bw_16);
-}
-
-/*
- Write a byte to FEEPROM
-*/
-WRITE16_MEMBER( strataflash_device::write16 )
-{
- write8_16(space, offset, data, bw_16);
-}
diff --git a/src/emu/machine/strata.h b/src/emu/machine/strata.h
deleted file mode 100644
index c037a24396b..00000000000
--- a/src/emu/machine/strata.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Raphael Nabet, Michael Zapf
-/*
- strata.h: header file for strata.c
-*/
-
-class strataflash_device : public device_t, public device_nvram_interface
-{
-public:
- strataflash_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // 8-bit access
- DECLARE_READ8_MEMBER( read8 );
- DECLARE_WRITE8_MEMBER( write8 );
-
- // 16-bit access
- DECLARE_READ16_MEMBER( read16 );
- DECLARE_WRITE16_MEMBER( write16 );
-
-protected:
- // device-level overrides
- void device_config_complete();
-
- void device_start();
-
- void nvram_default();
- void nvram_read(emu_file &file);
- void nvram_write(emu_file &file);
-
-private:
-
- // bus width for 8/16-bit handlers
- enum bus_width_t
- {
- bw_8,
- bw_16
- };
-
- UINT16 read8_16(address_space& space, offs_t offset, bus_width_t bus_width);
- void write8_16(address_space& space, offs_t offset, UINT16 data, bus_width_t bus_width);
-
- enum fm_mode_t
- {
- FM_NORMAL, // normal read/write
- FM_READID, // read ID
- FM_READQUERY, // read query
- FM_READSTATUS, // read status
- FM_WRITEPART1, // first half of programming, awaiting second
- FM_WRBUFPART1, // first part of write to buffer, awaiting second
- FM_WRBUFPART2, // second part of write to buffer, awaiting third
- FM_WRBUFPART3, // third part of write to buffer, awaiting fourth
- FM_WRBUFPART4, // fourth part of write to buffer
- FM_CLEARPART1, // first half of clear, awaiting second
- FM_SETLOCK, // first half of set master lock/set block lock
- FM_CONFPART1, // first half of configuration, awaiting second
- FM_WRPROTPART1 // first half of protection program, awaiting second
- };
-
- fm_mode_t m_mode; // current operation mode
- int m_hard_unlock; // 1 if RP* pin is at Vhh (not fully implemented)
- int m_status; // current status
- int m_master_lock; // master lock flag
- offs_t m_wrbuf_base; // start address in write buffer command
- int m_wrbuf_len; // count converted into byte length in write buffer command
- int m_wrbuf_count; // current count in write buffer command
- UINT8* m_wrbuf; // write buffer used by write buffer command
- UINT8* m_flashmemory; // main FEEPROM area
- UINT8* m_blocklock; // block lock flags
- UINT8* m_prot_regs; // protection registers
-};
-
-extern const device_type STRATAFLASH;
-
-#define MCFG_STRATAFLASH_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, STRATAFLASH, 0)
diff --git a/src/emu/machine/stvcd.c b/src/emu/machine/stvcd.c
deleted file mode 100644
index eebb8d11cb4..00000000000
--- a/src/emu/machine/stvcd.c
+++ /dev/null
@@ -1,2702 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:Angelo Salese, R. Belmont
-/***************************************************************************
-
- machine/stvcd.c - Sega Saturn and ST-V CD-ROM handling
-
- Another tilt at the windmill in 2011 by R. Belmont.
-
- Status: All known discs at least load their executable, and many load
- some data files successfully, but there are other problems.
-
- Information sources:
- - Tyranid's document
- - A commented disassembly I made of the Saturn BIOS's CD code
- - Yabuse's cs2.c
- - The ISO/IEC "Yellow Book" CD-ROM standard, 1995 version
-
- Address is mostly in terms of FAD (Frame ADdress).
- FAD is absolute number of frames from the start of the disc.
- In other words, FAD = LBA + 150; FAD is the same units as
- LBA except it counts starting at absolute zero instead of
- the first sector (00:02:00 in MSF format).
-
-***************************************************************************/
-
-#include "emu.h"
-#include "imagedev/chd_cd.h"
-#include "includes/stv.h"
-#include "cdrom.h"
-#include "sound/cdda.h"
-#include "debugger.h"
-#include "coreutil.h"
-
-// super-verbose
-#if 0
-#define CDROM_LOG(x) printf x;
-#else
-#define CDROM_LOG(x)
-#endif
-
-// HIRQ definitions
-#define CMOK 0x0001 // command dispatch possible
-#define DRDY 0x0002 // data transfer preparations complete
-#define CSCT 0x0004 // finished reading 1 sector
-#define BFUL 0x0008 // CD buffer full
-#define PEND 0x0010 // CD playback completed
-#define DCHG 0x0020 // disc change / tray open
-#define ESEL 0x0040 // selector settings processing complete
-#define EHST 0x0080 // host input/output processing complete
-#define ECPY 0x0100 // duplication/move processing complete
-#define EFLS 0x0200 // file system processing complete
-#define SCDQ 0x0400 // subcode Q update completed
-#define MPED 0x0800 // MPEG-related processing complete
-#define MPCM 0x1000 // MPEG action uncertain
-#define MPST 0x2000 // MPEG interrupt status report
-
-// CD status (hi byte of CR1) definitions:
-// (these defines are shifted up 8)
-#define CD_STAT_BUSY 0x0000 // status change in progress
-#define CD_STAT_PAUSE 0x0100 // CD block paused (temporary stop)
-#define CD_STAT_STANDBY 0x0200 // CD drive stopped
-#define CD_STAT_PLAY 0x0300 // CD play in progress
-#define CD_STAT_SEEK 0x0400 // drive seeking
-#define CD_STAT_SCAN 0x0500 // drive scanning
-#define CD_STAT_OPEN 0x0600 // tray is open
-#define CD_STAT_NODISC 0x0700 // no disc present
-#define CD_STAT_RETRY 0x0800 // read retry in progress
-#define CD_STAT_ERROR 0x0900 // read data error occurred
-#define CD_STAT_FATAL 0x0a00 // fatal error (hard reset required)
-#define CD_STAT_PERI 0x2000 // periodic response if set, else command response
-#define CD_STAT_TRANS 0x4000 // data transfer request if set
-#define CD_STAT_WAIT 0x8000 // waiting for command if set, else executed immediately
-#define CD_STAT_REJECT 0xff00 // ultra-fatal error.
-
-int saturn_state::get_timing_command(void)
-{
- /* TODO: calculate timings based off command params */
- return 16667;
-}
-
-/* FIXME: assume Saturn CD-ROMs to have a 2 secs pre-gap for now. */
-int saturn_state::get_track_index(UINT32 fad)
-{
- UINT32 rel_fad;
- UINT8 track;
-
- if(cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, fad)) != CD_TRACK_AUDIO)
- return 1;
-
- track = cdrom_get_track( cdrom, fad );
-
- rel_fad = fad - cdrom_get_track_start( cdrom, track );
-
- if(rel_fad < 150)
- return 0;
-
- return 1;
-}
-
-int saturn_state::sega_cdrom_get_adr_control(cdrom_file *file, int track)
-{
- return BITSWAP8(cdrom_get_adr_control(file, cur_track),3,2,1,0,7,6,5,4);
-}
-
-void saturn_state::cr_standard_return(UINT16 cur_status)
-{
- if ((cd_stat & 0x0f00) == CD_STAT_SEEK)
- {
- /* During seek state, values returned are from the target position */
- UINT8 seek_track = cdrom_get_track(cdrom, cd_fad_seek-150);
-
- cr1 = cur_status | (playtype << 7) | 0x00 | (cdda_repeat_count & 0xf);
- cr2 = (seek_track == 0xff) ? 0xffff : ((sega_cdrom_get_adr_control(cdrom, seek_track)<<8) | seek_track);
- cr3 = (get_track_index(cd_fad_seek)<<8) | (cd_fad_seek>>16); //index & 0xff00
- cr4 = cd_fad_seek;
- }
- else
- {
- /*
- TODO:
- - Whizz: wpset 0x608f030,4,w,wpdata==0x100&&pc!=0x6040006
- */
- cr1 = cur_status | (playtype << 7) | 0x00 | (cdda_repeat_count & 0xf); //options << 4 | repeat & 0xf
- cr2 = (cur_track == 0xff) ? 0xffff : ((sega_cdrom_get_adr_control(cdrom, cur_track)<<8) | (cdrom_get_track(cdrom, cd_curfad-150)+1));
- cr3 = (get_track_index(cd_curfad)<<8) | (cd_curfad>>16); //index & 0xff00
- cr4 = cd_curfad;
- }
-}
-
-void saturn_state::cd_exec_command( void )
-{
- UINT32 temp;
-
- if(cr1 != 0 &&
- ((cr1 & 0xff00) != 0x5100) &&
- ((cr1 & 0xff00) != 0x5200) &&
- ((cr1 & 0xff00) != 0x5300) &&
- 1)
- printf("CD: command exec %04x %04x %04x %04x %04x (stat %04x)\n", hirqreg, cr1, cr2, cr3, cr4, cd_stat);
-
- switch ((cr1 >> 8) & 0xff)
- {
- case 0x00:
- //CDROM_LOG(("%s:CD: Get Status\n", machine().describe_context()))
- hirqreg |= CMOK;
- if(status_type == 0)
- cr_standard_return(cd_stat);
- else
- {
- cr1 = (cd_stat) | (prev_cr1 & 0xff);
- cr2 = prev_cr2;
- cr3 = prev_cr3;
- cr4 = prev_cr4;
- status_type = 0; /* Road Blaster and friends needs this otherwise they won't boot. */
- }
- //CDROM_LOG((" = %04x %04x %04x %04x %04x\n", hirqreg, cr1, cr2, cr3, cr4))
- break;
-
- case 0x01:
- CDROM_LOG(("%s:CD: Get Hardware Info\n", machine().describe_context()))
- hirqreg |= CMOK;
- cr1 = cd_stat;
- cr2 = 0x0201;
- cr3 = 0x0000;
- cr4 = 0x0400;
- status_type = 0;
- break;
-
- case 0x02: // Get TOC
- CDROM_LOG(("%s:CD: Get TOC\n", machine().describe_context()))
- cd_readTOC();
- cd_stat = CD_STAT_TRANS|CD_STAT_PAUSE;
- cr1 = cd_stat;
- cr2 = 102*2; // TOC length in words (102 entries @ 2 words/4bytes each)
- cr3 = 0;
- cr4 = 0;
- xferdnum = 0;
- hirqreg |= (CMOK|DRDY);
- status_type = 0;
- break;
-
- case 0x03: // get session info (lower byte = session # to get?)
- // bios is interested in returns in cr3 and cr4
- // cr3 should be data track #
- // cr4 must be > 1 and < 100 or bios gets angry.
- CDROM_LOG(("%s:CD: Get Session Info\n", machine().describe_context()))
- cd_readTOC();
- switch (cr1 & 0xff)
- {
- case 0: // get total session info / disc end
- cd_stat = CD_STAT_PAUSE;
- cr1 = cd_stat;
- cr2 = 0;
- cr3 = 0x0100 | tocbuf[(101*4)+1];
- cr4 = tocbuf[(101*4)+2]<<8 | tocbuf[(101*4)+3];
- break;
-
- case 1: // get total session info / disc start
- cd_stat = CD_STAT_PAUSE;
- cr1 = cd_stat;
- cr2 = 0;
- cr3 = 0x0100; // sessions in high byte, session start in lower
- cr4 = 0;
- break;
-
- default:
- osd_printf_error("CD: Unknown request to Get Session Info %x\n", cr1 & 0xff);
- cr1 = cd_stat;
- cr2 = 0;
- cr3 = 0;
- cr4 = 0;
- break;
- }
-
- hirqreg |= (CMOK);
- status_type = 0;
- break;
-
- /* TODO: double check this */
- case 0x04: // initialize CD system
- // CR1 & 1 = reset software
- // CR1 & 2 = decode RW subcode
- // CR1 & 4 = don't confirm mode 2 subheader
- // CR1 & 8 = retry reading mode 2 sectors
- // CR1 & 10 = force single-speed
- // CR1 & 80 = no change flag (done by Assault Suit Leynos 2)
- CDROM_LOG(("%s:CD: Initialize CD system\n", machine().describe_context()))
- //if((cr1 & 0x81) == 0x00) //guess TODO: nope, Choice Cuts doesn't like it, it crashes if you try to skip the FMV otherwise.
- {
- if(((cd_stat & 0x0f00) != CD_STAT_NODISC) && ((cd_stat & 0x0f00) != CD_STAT_OPEN))
- {
- cd_stat = CD_STAT_PAUSE;
- cd_curfad = 150;
- //cur_track = 1;
- fadstoplay = 0;
- }
- in_buffer = 0;
- buffull = 0;
- hirqreg &= 0xffe5;
- cd_speed = (cr1 & 0x10) ? 1 : 2;
-
- /* reset filter connections */
- /* Guess: X-Men COTA sequence is 0x48->0x48->0x04(01)->0x04(00)->0x30 then 0x10, without this game throws a FAD reject error */
- /* X-Men vs. SF is even fussier, sequence is 0x04 (1) 0x04 (0) 0x03 (0) 0x03 (1) 0x30 */
- #if 0
- for(int i=0;i<MAX_FILTERS;i++)
- {
- filters[i].fad = 0;
- filters[i].range = 0xffffffff;
- filters[i].mode = 0;
- filters[i].chan = 0;
- filters[i].smmask = 0;
- filters[i].cimask = 0;
- filters[i].fid = 0;
- filters[i].smval = 0;
- filters[i].cival = 0;
- }
- #endif
-
- /* reset CD device connection */
- //cddevice = (filterT *)NULL;
- }
-
- hirqreg |= (CMOK|ESEL);
- cr_standard_return(cd_stat);
- status_type = 0;
- break;
-
- case 0x06: // end data transfer (TODO: needs to be worked on!)
- // returns # of bytes transfered (24 bits) in
- // low byte of cr1 (MSB) and cr2 (middle byte, LSB)
- CDROM_LOG(("%s:CD: End data transfer (%d bytes xfer'd)\n", machine().describe_context(), xferdnum))
-
- // clear the "transfer" flag
- cd_stat &= ~CD_STAT_TRANS;
-
- if (xferdnum)
- {
- cr1 = (cd_stat) | ((xferdnum>>17) & 0xff);
- cr2 = (xferdnum>>1)&0xffff;
- cr3 = 0;
- cr4 = 0;
- }
- else
- {
- printf("No xferdnum error\n");
- cr1 = (cd_stat) | (0xff); // is this right?
- cr2 = 0xffff;
- cr3 = 0;
- cr4 = 0;
- }
-
- // try to clean up any transfers still in progress
- switch (xfertype32)
- {
- case XFERTYPE32_GETSECTOR:
- case XFERTYPE32_PUTSECTOR:
- hirqreg |= EHST;
- break;
-
- case XFERTYPE32_GETDELETESECTOR:
- if (transpart->size > 0)
- {
- INT32 i;
-
- xfertype32 = XFERTYPE32_INVALID;
-
- // deallocate the blocks
- for (i = xfersectpos; i < xfersectpos+xfersectnum; i++)
- {
- cd_free_block(transpart->blocks[i]);
- transpart->blocks[i] = (blockT *)NULL;
- transpart->bnum[i] = 0xff;
- }
-
- // defrag what's left
- cd_defragblocks(transpart);
-
- // clean up our state
- transpart->size -= xferdnum;
- transpart->numblks -= xfersectnum;
-
- if (freeblocks == 200)
- {
- sectorstore = 0;
- }
-
- hirqreg |= EHST;
- }
- break;
-
- default:
- break;
- }
-
-
- xferdnum = 0;
- hirqreg |= CMOK;
-
- CDROM_LOG((" = %04x %04x %04x %04x %04x\n", hirqreg, cr1, cr2, cr3, cr4))
- status_type = 1;
- break;
-
- case 0x10: // Play Disc. FAD is in lowest 7 bits of cr1 and all of cr2.
- UINT32 start_pos,end_pos;
- UINT8 play_mode;
-
- CDROM_LOG(("%s:CD: Play Disc\n", machine().describe_context()))
- cd_stat = CD_STAT_PLAY;
-
- play_mode = (cr3 >> 8) & 0x7f;
-
- if (!(cr3 & 0x8000)) // preserve current position if bit 7 set
- {
- start_pos = ((cr1&0xff)<<16) | cr2;
- end_pos = ((cr3&0xff)<<16) | cr4;
-
- if (start_pos & 0x800000)
- {
- if (start_pos != 0xffffff)
- cd_curfad = start_pos & 0xfffff;
-
- printf("fad mode\n");
- cur_track = cdrom_get_track(cdrom, cd_curfad-150);
- }
- else
- {
- // track mode
- if(((start_pos)>>8) != 0)
- {
- cur_track = (start_pos)>>8;
- cd_fad_seek = cdrom_get_track_start(cdrom, cur_track-1);
- cd_stat = CD_STAT_SEEK;
- machine().device<cdda_device>("cdda")->pause_audio(0);
- }
- else
- {
- /* TODO: Waku Waku 7 sets up track 0, that basically doesn't make any sense. Just skip it for now. */
- popmessage("Warning: track mode == 0, contact MAMEdev");
- cr_standard_return(cd_stat);
- hirqreg |= (CMOK);
- return;
- }
-
- printf("track mode %d\n",cur_track);
- }
-
- if (end_pos & 0x800000)
- {
- if (end_pos != 0xffffff)
- fadstoplay = end_pos & 0xfffff;
- }
- else
- {
- UINT8 end_track;
-
- end_track = (end_pos)>>8;
- fadstoplay = cdrom_get_track_start(cdrom, end_track) - cd_fad_seek;
- }
- }
- else // play until the end of the disc
- {
- start_pos = ((cr1&0xff)<<16) | cr2;
- end_pos = ((cr3&0xff)<<16) | cr4;
-
- if(start_pos != 0xffffff)
- {
- /* Madou Monogatari sets 0xff80xxxx as end position, needs investigation ... */
- if(end_pos & 0x800000)
- fadstoplay = end_pos & 0xfffff;
- else
- {
- if(end_pos == 0)
- fadstoplay = (cdrom_get_track_start(cdrom, 0xaa)) - cd_curfad;
- else
- fadstoplay = (cdrom_get_track_start(cdrom, (end_pos & 0xff00) >> 8)) - cd_curfad;
- }
- printf("track mode %08x %08x\n",cd_curfad,fadstoplay);
- }
- else
- {
- /* resume from a pause state */
- /* TODO: Galaxy Fight calls 10ff ffff ffff ffff, but then it calls 0x04->0x02->0x06->0x11->0x04->0x02->0x06 command sequence
- (and current implementation nukes start/end FAD addresses at 0x04). I'm sure that this doesn't work like this, but there could
- be countless possible combinations ... */
- if(fadstoplay == 0)
- {
- cd_curfad = cdrom_get_track_start(cdrom, cur_track-1);
- fadstoplay = cdrom_get_track_start(cdrom, cur_track) - cd_curfad;
- }
- printf("track resume %08x %08x\n",cd_curfad,fadstoplay);
- }
- }
-
- CDROM_LOG(("CD: Play Disc: start %x length %x\n", cd_curfad, fadstoplay))
-
- cr_standard_return(cd_stat);
- hirqreg |= (CMOK);
- oddframe = 0;
- in_buffer = 0;
-
- playtype = 0;
-
- // cdda
- if(cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, cd_curfad)) == CD_TRACK_AUDIO)
- {
- machine().device<cdda_device>("cdda")->pause_audio(0);
- //machine().device<cdda_device>("cdda")->start_audio(cd_curfad, fadstoplay);
- //cdda_repeat_count = 0;
- }
-
- if(play_mode != 0x7f)
- cdda_maxrepeat = play_mode & 0xf;
- else
- cdda_maxrepeat = 0;
-
- cdda_repeat_count = 0;
- status_type = 0;
- break;
-
- case 0x11: // disc seek
- CDROM_LOG(("%s:CD: Disc seek\n", machine().describe_context()))
- //printf("%08x %08x %08x %08x\n",cr1,cr2,cr3,cr4);
- if (cr1 & 0x80)
- {
- temp = (cr1&0xff)<<16; // get FAD to seek to
- temp |= cr2;
-
- //cd_curfad = temp;
-
- if (temp == 0xffffff)
- {
- cd_stat = CD_STAT_PAUSE;
- machine().device<cdda_device>("cdda")->pause_audio(1);
- }
- else
- {
- cd_curfad = ((cr1&0x7f)<<16) | cr2;
- printf("disc seek with params %04x %04x\n",cr1,cr2); //Area 51 sets this up
- }
- }
- else
- {
- // is it a valid track?
- if (cr2 >> 8)
- {
- cd_stat = CD_STAT_PAUSE;
- cur_track = cr2>>8;;
- cd_curfad = cdrom_get_track_start(cdrom, cur_track-1);
- machine().device<cdda_device>("cdda")->pause_audio(1);
- // (index is cr2 low byte)
- }
- else // error!
- {
- cd_stat = CD_STAT_STANDBY;
- cd_curfad = 0xffffffff;
- cur_track = 0xff;
- machine().device<cdda_device>("cdda")->stop_audio(); //stop any pending CD-DA
- }
- }
-
-
- hirqreg |= CMOK;
- cr_standard_return(cd_stat);
- status_type = 0;
- break;
-
- case 0x12: // FFWD / REW
- //cr1 bit 0 determines if this is a Fast Forward (0) or a Rewind (1) command
- // ...
- break;
-
- case 0x20: // Get SubCode Q / RW Channel
- switch(cr1 & 0xff)
- {
- case 0: // Get Q
- {
- UINT32 msf_abs,msf_rel;
- UINT8 track;
- cr1 = cd_stat | 0;
- cr2 = 10/2;
- cr3 = 0;
- cr4 = 0;
-
- /*
- Subcode Q info should be:
- ---- --x- S0
- ---- ---x S1
- xxxx ---- [0] Control (bit 7 Pre-emphasis, bit 6: copy permitted, bit 5 undefined, bit 4 number of channels)
- ---- xxxx [0] address (0x0001 Mode 1)
- xxxx xxxx [1] track number (1-99, AA lead-out), BCD format
- xxxx xxxx [2] index (01 lead-out), BCD format
- xxxx xxxx [3] Time within' track M
- xxxx xxxx [4] Time within' track S
- xxxx xxxx [5] Time within' track F
- xxxx xxxx [6] Zero
- xxxx xxxx [7] Absolute M
- xxxx xxxx [8] Absolute S
- xxxx xxxx [9] Absolute F
- xxxx xxxx [10] CRCC
- xxxx xxxx [11] CRCC
- */
-
- msf_abs = lba_to_msf_alt( cd_curfad - 150 );
- track = cdrom_get_track( cdrom, cd_curfad );
- msf_rel = lba_to_msf_alt( cd_curfad - 150 - cdrom_get_track_start( cdrom, track ) );
-
- xfertype = XFERTYPE_SUBQ;
- xfercount = 0;
- subqbuf[0] = 0x01 | ((cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, track+1)) == CD_TRACK_AUDIO) ? 0x00 : 0x40);
- subqbuf[1] = dec_2_bcd(track+1);
- subqbuf[2] = dec_2_bcd(get_track_index(cd_curfad));
- subqbuf[3] = dec_2_bcd((msf_rel >> 16) & 0xff);
- subqbuf[4] = dec_2_bcd((msf_rel >> 8) & 0xff);
- subqbuf[5] = dec_2_bcd((msf_rel >> 0) & 0xff);
- subqbuf[6] = 0;
- subqbuf[7] = dec_2_bcd((msf_abs >> 16) & 0xff);
- subqbuf[8] = dec_2_bcd((msf_abs >> 8) & 0xff);
- subqbuf[9] = dec_2_bcd((msf_abs >> 0) & 0xff);
- }
- break;
-
- case 1: // Get RW
- cr1 = cd_stat | 0;
- cr2 = 12;
- cr3 = 0;
- cr4 = 0;
-
- xfertype = XFERTYPE_SUBRW;
- xfercount = 0;
-
- /* return null data for now */
- {
- int i;
-
- for(i=0;i<12*2;i++)
- subrwbuf[i] = 0;
- }
- break;
- }
- hirqreg |= CMOK|DRDY;
- status_type = 0;
- break;
-
- case 0x30: // Set CD Device connection
- {
- UINT8 parm;
-
- // get operation
- parm = cr3>>8;
-
- CDROM_LOG(("%s:CD: Set CD Device Connection filter # %x\n", machine().describe_context(), parm))
-
- cddevicenum = parm;
-
- if (parm == 0xff)
- {
- cddevice = (filterT *)NULL;
- }
- else
- {
- if (parm < 0x24)
- {
- cddevice = &filters[(cr3>>8)];
- }
- }
-
-
- hirqreg |= (CMOK|ESEL);
- cr_standard_return(cd_stat);
- status_type = 0;
- }
- break;
-
- case 0x31:
- popmessage("Get CD Device Connection, contact MAMEdev");
- hirqreg |= CMOK;
- break;
-
- case 0x32: // Last Buffer Destination
- cr1 = cd_stat | 0;
- cr2 = 0;
- cr3 = lastbuf << 8;
- cr4 = 0;
- hirqreg |= (CMOK);
- status_type = 0;
- break;
-
- case 0x40: // Set Filter Range
- // cr1 low + cr2 = FAD0, cr3 low + cr4 = FAD1
- // cr3 hi = filter num.
- {
- UINT8 fnum = (cr3>>8)&0xff;
-
- CDROM_LOG(("%s:CD: Set Filter Range\n", machine().describe_context()))
-
- filters[fnum].fad = ((cr1 & 0xff)<<16) | cr2;
- filters[fnum].range = ((cr3 & 0xff)<<16) | cr4;
-
- printf("%08x %08x %d\n",filters[fnum].fad,filters[fnum].range,fnum);
-
- hirqreg |= (CMOK|ESEL);
- cr_standard_return(cd_stat);
- status_type = 0;
- }
- break;
-
- case 0x41:
- popmessage("Get Filter Range, contact MAMEdev");
- hirqreg |= CMOK;
- break;
-
- case 0x42: // Set Filter Subheader conditions
- {
- UINT8 fnum = (cr3>>8)&0xff;
-
- CDROM_LOG(("%s:CD: Set Filter Subheader conditions %x => chan %x masks %x fid %x vals %x\n", machine().describe_context(), fnum, cr1&0xff, cr2, cr3&0xff, cr4))
-
- filters[fnum].chan = cr1 & 0xff;
- filters[fnum].smmask = (cr2>>8)&0xff;
- filters[fnum].cimask = cr2&0xff;
- filters[fnum].fid = cr3&0xff;
- filters[fnum].smval = (cr4>>8)&0xff;
- filters[fnum].cival = cr4&0xff;
-
- hirqreg |= (CMOK|ESEL);
- cr_standard_return(cd_stat);
- status_type = 0;
- }
- break;
-
- case 0x43: // Get Filter Subheader conditions
- {
- UINT8 fnum = (cr3>>8)&0xff;
-
- CDROM_LOG(("%s:CD: Set Filter Subheader conditions %x => chan %x masks %x fid %x vals %x\n", machine().describe_context(), fnum, cr1&0xff, cr2, cr3&0xff, cr4))
-
- cr1 = cd_stat | (filters[fnum].chan & 0xff);
- cr2 = (filters[fnum].smmask << 8) | (filters[fnum].cimask & 0xff);
- cr3 = filters[fnum].fid;
- cr4 = (filters[fnum].smval << 8) | (filters[fnum].cival & 0xff);
-
- hirqreg |= (CMOK|ESEL);
- status_type = 0;
- }
- break;
-
- case 0x44: // Set Filter Mode
- {
- UINT8 fnum = (cr3>>8)&0xff;
- UINT8 mode = (cr1 & 0xff);
-
- // initialize filter?
- if (mode & 0x80)
- {
- memset(&filters[fnum], 0, sizeof(filterT));
- }
- else
- {
- filters[fnum].mode = mode;
- }
-
- CDROM_LOG(("%s:CD: Set Filter Mode filt %x mode %x\n", machine().describe_context(), fnum, mode))
- hirqreg |= (CMOK|ESEL);
- cr_standard_return(cd_stat);
- status_type = 0;
- }
- break;
-
- case 0x45: // Get Filter Mode
- {
- UINT8 fnum = (cr3>>8)&0xff;
-
- cr1 = cd_stat | (filters[fnum].mode & 0xff);
- cr2 = 0;
- cr3 = 0;
- cr4 = 0;
-
- hirqreg |= (CMOK|ESEL);
- status_type = 0;
- }
- break;
-
- case 0x46: // Set Filter Connection
- {
- /* TODO: maybe condition false is cr3 low? */
- UINT8 fnum = (cr3>>8)&0xff;
-
- CDROM_LOG(("%s:CD: Set Filter Connection %x => mode %x parm %04x\n", machine().describe_context(), fnum, cr1 & 0xf, cr2))
-
- if (cr1 & 1) // set true condition
- filters[fnum].condtrue = (cr2>>8)&0xff;
-
- if (cr1 & 2) // set false condition
- filters[fnum].condfalse = cr2&0xff;
-
- hirqreg |= (CMOK|ESEL);
- cr_standard_return(cd_stat);
- status_type = 0;
- }
- break;
-
- case 0x48: // Reset Selector
- {
- int i,j;
-
- CDROM_LOG(("%s:CD: Reset Selector\n", machine().describe_context()))
-
- if((cr1 & 0xff) == 0x00)
- {
- UINT8 bufnum = cr3>>8;
-
- if(bufnum < MAX_FILTERS)
- {
- for (i = 0; i < MAX_BLOCKS; i++)
- {
- cd_free_block(partitions[bufnum].blocks[i]);
- partitions[bufnum].blocks[i] = (blockT *)NULL;
- partitions[bufnum].bnum[i] = 0xff;
- }
-
- partitions[bufnum].size = -1;
- partitions[bufnum].numblks = 0;
- }
-
- // TODO: buffer full flag
-
- if (freeblocks == 200) { sectorstore = 0; }
-
- hirqreg |= (CMOK|ESEL);
- cr_standard_return(cd_stat);
- status_type = 0;
- return;
- }
-
- /* reset false filter output conditions */
- /* TODO: check these two. */
- if(cr1 & 0x80)
- {
- for(i=0;i<MAX_FILTERS;i++)
- filters[i].condfalse = 0;
- }
-
- /* reset true filter output conditions */
- if(cr1 & 0x40)
- {
- for(i=0;i<MAX_FILTERS;i++)
- filters[i].condtrue = 0;
- }
-
- /* reset filter conditions*/
- if(cr1 & 0x10)
- {
- for(i=0;i<MAX_FILTERS;i++)
- {
- filters[i].fad = 0;
- filters[i].range = 0xffffffff;
- filters[i].mode = 0;
- filters[i].chan = 0;
- filters[i].smmask = 0;
- filters[i].cimask = 0;
- filters[i].fid = 0;
- filters[i].smval = 0;
- filters[i].cival = 0;
- }
- }
-
- /* reset partition buffer data */
- if(cr1 & 0x4)
- {
- for(i=0;i<MAX_FILTERS;i++)
- {
- for (j = 0; j < MAX_BLOCKS; j++)
- {
- cd_free_block(partitions[i].blocks[j]);
- partitions[i].blocks[j] = (blockT *)NULL;
- partitions[i].bnum[j] = 0xff;
- }
-
- partitions[i].size = -1;
- partitions[i].numblks = 0;
- }
-
- buffull = sectorstore = 0;
- }
-
- hirqreg |= (CMOK|ESEL);
- cr_standard_return(cd_stat);
- status_type = 0;
- }
- break;
-
- case 0x50: // get Buffer Size
- cr1 = cd_stat;
- cr2 = (freeblocks > 200) ? 200 : freeblocks;
- cr3 = 0x1800;
- cr4 = 200;
- CDROM_LOG(("CD: Get Buffer Size = %d\n", cr2))
- hirqreg |= (CMOK);
- status_type = 0;
- break;
-
- case 0x51: // get # sectors used in a buffer
- {
- UINT32 bufnum = cr3>>8;
-
- CDROM_LOG(("%s:CD: Get Sector Number (bufno %d) = %d blocks\n", machine().describe_context(), bufnum, cr4))
- cr1 = cd_stat;
- cr2 = 0;
- cr3 = 0;
- if(cr1 & 0xff || cr2 || cr3 & 0xff || cr4)
- printf("Get # sectors used with params %04x %04x %04x %04x\n",cr1,cr2,cr3,cr4);
-
- // is the partition empty?
- if (partitions[bufnum].size == -1)
- {
- cr4 = 0;
- }
- else
- {
- cr4 = partitions[bufnum].numblks;
- //printf("Partition %08x %04x\n",bufnum,cr4);
- }
-
- //printf("%04x\n",cr4);
- if(cr4 == 0)
- hirqreg |= (CMOK);
- else
- hirqreg |= (CMOK|DRDY);
- status_type = 1;
- }
- break;
-
- case 0x52: // calculate actual size
- {
- UINT32 bufnum = cr3>>8;
- UINT32 sectoffs = cr2;
- UINT32 numsect = cr4;
-
- CDROM_LOG(("%s:CD: Calculate actual size: buf %x offs %x numsect %x\n", machine().describe_context(), bufnum, sectoffs, numsect))
-
- calcsize = 0;
- if (partitions[bufnum].size != -1)
- {
- INT32 i;
-
- for (i = 0; i < numsect; i++)
- {
- if (partitions[bufnum].blocks[sectoffs+i])
- {
- calcsize += (partitions[bufnum].blocks[sectoffs+i]->size / 2);
- }
- }
- }
-
- hirqreg |= (CMOK|ESEL);
- cr_standard_return(cd_stat);
- status_type = 0;
- }
- break;
-
- case 0x53: // get actual block size
- CDROM_LOG(("%s:CD: Get actual block size\n", machine().describe_context()))
- cr1 = cd_stat | ((calcsize>>16)&0xff);
- cr2 = (calcsize & 0xffff);
- cr3 = 0;
- cr4 = 0;
- hirqreg |= (CMOK|ESEL);
- status_type = 1;
- break;
-
- case 0x54: // get sector info
- {
- UINT32 sectoffs = cr2 & 0xff;
- UINT32 bufnum = cr3>>8;
-
- if (bufnum >= MAX_FILTERS || !partitions[bufnum].blocks[sectoffs])
- {
- cr1 |= CD_STAT_REJECT & 0xff00;
- hirqreg |= (CMOK|ESEL);
- printf("Get sector info reject\n");
- }
- else
- {
- cr1 = cd_stat | ((partitions[bufnum].blocks[sectoffs]->FAD >> 16) & 0xff);
- cr2 = partitions[bufnum].blocks[sectoffs]->FAD & 0xffff;
- cr3 = ((partitions[bufnum].blocks[sectoffs]->fnum & 0xff) << 8) | (partitions[bufnum].blocks[sectoffs]->chan & 0xff);
- cr4 = ((partitions[bufnum].blocks[sectoffs]->subm & 0xff) << 8) | (partitions[bufnum].blocks[sectoffs]->cinf & 0xff);
- hirqreg |= (CMOK|ESEL);
- }
-
- status_type = 0;
- }
- break;
-
- case 0x60: // set sector length
- CDROM_LOG(("%s:CD: Set sector length\n", machine().describe_context()))
-
- switch (cr1 & 0xff)
- {
- case 0:
- sectlenin = 2048;
- break;
- case 1:
- sectlenin = 2336;
- break;
- case 2:
- sectlenin = 2340;
- break;
- case 3:
- sectlenin = 2352;
- break;
- }
-
- switch ((cr2>>8) & 0xff)
- {
- case 0:
- sectlenout = 2048;
- break;
- case 1:
- sectlenout = 2336;
- break;
- case 2:
- sectlenout = 2340;
- break;
- case 3:
- sectlenout = 2352;
- break;
- }
- hirqreg |= (CMOK|ESEL);
- cr_standard_return(cd_stat);
- status_type = 0;
- break;
-
- case 0x61: // get sector data
- {
- UINT32 sectnum = cr4;
- UINT32 sectofs = cr2;
- UINT32 bufnum = cr3>>8;
-
- CDROM_LOG(("%s:CD: Get sector data (SN %d SO %d BN %d)\n", machine().describe_context(), sectnum, sectofs, bufnum))
-
- if (bufnum >= MAX_FILTERS)
- {
- printf("CD: invalid buffer number\n");
- /* TODO: why this is happening? */
- cr_standard_return(CD_STAT_REJECT);
- hirqreg |= (CMOK|EHST);
- return;
- }
-
- if (partitions[bufnum].numblks < sectnum)
- {
- printf("CD: buffer is not full %08x %08x\n",partitions[bufnum].numblks,sectnum);
- cr_standard_return(CD_STAT_REJECT);
- hirqreg |= (CMOK|EHST);
- return;
- }
-
- cd_getsectoroffsetnum(bufnum, &sectofs, &sectnum);
-
- xfertype32 = XFERTYPE32_GETSECTOR;
- xferoffs = 0;
- xfersect = 0;
- xferdnum = 0;
- xfersectpos = sectofs;
- xfersectnum = sectnum;
- transpart = &partitions[bufnum];
-
- cd_stat |= CD_STAT_TRANS;
- cr_standard_return(cd_stat);
- hirqreg |= (CMOK|EHST|DRDY);
- status_type = 0;
- }
- break;
-
- case 0x62: // delete sector data
- {
- UINT32 sectnum = cr4;
- UINT32 sectofs = cr2;
- UINT32 bufnum = cr3>>8;
- INT32 i;
-
- CDROM_LOG(("%s:CD: Delete sector data (SN %d SO %d BN %d)\n", machine().describe_context(), sectnum, sectofs, bufnum))
-
- if (bufnum >= MAX_FILTERS)
- {
- printf("CD: invalid buffer number\n");
- /* TODO: why this is happening? */
- cr_standard_return(CD_STAT_REJECT);
- hirqreg |= (CMOK|EHST);
- return;
- }
-
- /* TODO: Phantasy Star 2 throws this one. */
- if (partitions[bufnum].numblks == 0)
- {
- printf("CD: buffer is already empty\n");
- cr_standard_return(CD_STAT_REJECT);
- hirqreg |= (CMOK|EHST);
- return;
- }
-
- cd_getsectoroffsetnum(bufnum, &sectofs, &sectnum);
-
- for (i = sectofs; i < (sectofs + sectnum); i++)
- {
- partitions[bufnum].size -= partitions[bufnum].blocks[i]->size;
- cd_free_block(partitions[bufnum].blocks[i]);
- partitions[bufnum].blocks[i] = (blockT *)NULL;
- partitions[bufnum].bnum[i] = 0xff;
- }
-
- cd_defragblocks(&partitions[bufnum]);
-
- partitions[bufnum].numblks -= sectnum;
-
- if (freeblocks == 200)
- {
- sectorstore = 0;
- }
-
- cd_stat &= ~CD_STAT_TRANS;
- cr_standard_return(cd_stat);
- hirqreg |= (CMOK|EHST);
- status_type = 0;
- }
- break;
-
- case 0x63: // get then delete sector data
- {
- UINT32 sectnum = cr4;
- UINT32 sectofs = cr2;
- UINT32 bufnum = cr3>>8;
-
- CDROM_LOG(("%s:CD: Get and delete sector data (SN %d SO %d BN %d)\n", machine().describe_context(), sectnum, sectofs, bufnum))
-
- if (bufnum >= MAX_FILTERS)
- {
- printf("CD: invalid buffer number\n");
- /* TODO: why this is happening? */
- cr_standard_return(CD_STAT_REJECT);
- hirqreg |= (CMOK|EHST);
- return;
- }
-
- /* Yoshimoto Mahjong uses the REJECT status to verify when the data is ready. */
- if (partitions[bufnum].numblks < sectnum)
- {
- printf("CD: buffer is not full %08x %08x\n",partitions[bufnum].numblks,sectnum);
- cr_standard_return(CD_STAT_REJECT);
- hirqreg |= (CMOK|EHST);
- return;
- }
-
- cd_getsectoroffsetnum(bufnum, &sectofs, &sectnum);
-
- xfertype32 = XFERTYPE32_GETDELETESECTOR;
- xferoffs = 0;
- xfersect = 0;
- xferdnum = 0;
- xfersectpos = sectofs;
- xfersectnum = sectnum;
- transpart = &partitions[bufnum];
-
- cd_stat |= CD_STAT_TRANS;
- cr_standard_return(cd_stat);
- hirqreg |= (CMOK|EHST|DRDY);
- status_type = 0;
- }
- break;
-
- case 0x64: // put sector data
- /* After Burner 2, Out Run, Fantasy Zone and Dungeon Master Nexus trips this */
- {
- UINT32 sectnum = cr4 & 0xff;
- UINT32 sectofs = cr2;
- UINT32 bufnum = cr3>>8;
-
- xfertype32 = XFERTYPE32_PUTSECTOR;
-
- /*TODO: eventual errors? */
-
- cd_getsectoroffsetnum(bufnum, &sectofs, &sectnum);
-
- cd_stat |= CD_STAT_TRANS;
-
- xferoffs = 0;
- xfersect = 0;
- xferdnum = 0;
- xfersectpos = sectofs;
- xfersectnum = sectnum;
- transpart = &partitions[bufnum];
-
- // allocate the blocks
- for (int i = xfersectpos; i < xfersectpos+xfersectnum; i++)
- {
- transpart->blocks[i] = cd_alloc_block(&transpart->bnum[i]);
- if(transpart->size == -1)
- transpart->size = 0;
- transpart->size += transpart->blocks[i]->size;
- transpart->numblks++;
- }
- }
-
- hirqreg |= (CMOK|DRDY);
- cr_standard_return(cd_stat);
- status_type = 0;
- break;
-
- case 0x65:
- popmessage("Move Sector data, contact MAMEdev");
- hirqreg |= (CMOK);
- break;
-
- case 0x66: // copy sector data
- /* TODO: Sword & Sorcery / Riglord Saga 2 */
- {
- UINT32 src_filter = (cr3>>8)&0xff;
- UINT32 dst_filter = cr1&0xff;
- UINT32 sectnum = cr4 & 0xff;
-
- //cd_stat |= CD_STAT_TRANS;
- //transpart = &partitions[dst_filter];
-
- for (int i = 0; i < sectnum; i++)
- {
- // allocate the dst blocks
- partitions[dst_filter].blocks[i] = cd_alloc_block(&partitions[dst_filter].bnum[i]);
- if(partitions[dst_filter].size == -1)
- partitions[dst_filter].size = 0;
- partitions[dst_filter].size += partitions[dst_filter].blocks[i]->size;
- partitions[dst_filter].numblks++;
-
- //copy data
- for(int j = 0; j < sectlenin; j++)
- partitions[dst_filter].blocks[i]->data[j] = partitions[src_filter].blocks[i]->data[j];
-
- //deallocate the src blocks
- //partitions[src_filter].size -= partitions[src_filter].blocks[i]->size;
- //cd_free_block(partitions[src_filter].blocks[i]);
- //partitions[src_filter].blocks[i] = (blockT *)NULL;
- //partitions[src_filter].bnum[i] = 0xff;
- }
-
- }
-
- hirqreg |= (CMOK|ECPY);
- cr_standard_return(cd_stat);
- status_type = 0;
- break;
-
-
- case 0x67: // get copy error
- CDROM_LOG(("%s:CD: Get copy error\n", machine().describe_context()))
- printf("Get copy error\n");
- cr1 = cd_stat;
- cr2 = 0;
- cr3 = 0;
- cr4 = 0;
- hirqreg |= (CMOK);
- status_type = 0;
- break;
-
- case 0x70: // change directory
- CDROM_LOG(("%s:CD: Change Directory\n", machine().describe_context()))
- hirqreg |= (CMOK|EFLS);
-
- temp = (cr3&0xff)<<16;
- temp |= cr4;
-
- read_new_dir(temp);
- cr_standard_return(cd_stat);
- status_type = 0;
- break;
-
- case 0x71: // Read directory entry
- CDROM_LOG(("%s:CD: Read Directory Entry\n", machine().describe_context()))
-// UINT32 read_dir;
-
-// read_dir = ((cr3&0xff)<<16)|cr4;
-
- if((cr3 >> 8) < 0x24)
- cddevice = &filters[cr3 >> 8];
- else
- cddevice = (filterT *)NULL;
-
- /* TODO: */
- //read_new_dir(read_dir - 2);
-
- cr_standard_return(cd_stat);
- hirqreg |= (CMOK|EFLS);
- status_type = 0;
- break;
-
- case 0x72: // Get file system scope
- CDROM_LOG(("CD: Get file system scope\n"))
- hirqreg |= (CMOK|EFLS);
- cr1 = cd_stat;
- cr2 = numfiles; // # of files in directory
- cr3 = 0x0100; // report directory held
- cr4 = firstfile; // first file id
- printf("%04x %04x %04x %04x\n",cr1,cr2,cr3,cr4);
- status_type = 0;
- break;
-
- case 0x73: // Get File Info
- CDROM_LOG(("%s:CD: Get File Info\n", machine().describe_context()))
- cd_stat |= CD_STAT_TRANS;
- cd_stat &= 0xff00; // clear top byte of return value
- playtype = 0;
- cdda_repeat_count = 0;
- hirqreg |= (CMOK|DRDY);
-
- temp = (cr3&0xff)<<16;
- temp |= cr4;
-
- if (temp == 0xffffff) // special
- {
- xfertype = XFERTYPE_FILEINFO_254;
- xfercount = 0;
-
- cr1 = cd_stat;
- cr2 = 0x5f4;
- cr3 = 0;
- cr4 = 0;
- }
- else
- {
- cr1 = cd_stat;
- cr2 = 6; // 6 words for single file
- // first 4 bytes = FAD address
- // second 4 bytes = length
- // last 4 bytes:
- // - unit size
- // - gap size
- // - file #
- // attributes flags
-
- cr3 = 0;
- cr4 = 0;
-
- printf("%08x %08x\n",curdir[temp].firstfad,curdir[temp].length);
- // first 4 bytes = FAD
- finfbuf[0] = (curdir[temp].firstfad>>24)&0xff;
- finfbuf[1] = (curdir[temp].firstfad>>16)&0xff;
- finfbuf[2] = (curdir[temp].firstfad>>8)&0xff;
- finfbuf[3] = (curdir[temp].firstfad&0xff);
- // second 4 bytes = length of file
- finfbuf[4] = (curdir[temp].length>>24)&0xff;
- finfbuf[5] = (curdir[temp].length>>16)&0xff;
- finfbuf[6] = (curdir[temp].length>>8)&0xff;
- finfbuf[7] = (curdir[temp].length&0xff);
- finfbuf[8] = curdir[temp].interleave_gap_size;
- finfbuf[9] = curdir[temp].file_unit_size;
- finfbuf[10] = temp;
- finfbuf[11] = curdir[temp].flags;
-
- xfertype = XFERTYPE_FILEINFO_1;
- xfercount = 0;
- }
- CDROM_LOG((" = %04x %04x %04x %04x %04x\n", hirqreg, cr1, cr2, cr3, cr4))
- status_type = 0;
- break;
-
- case 0x74: // Read File
- CDROM_LOG(("%s:CD: Read File\n", machine().describe_context()))
- UINT16 file_offset,file_filter,file_id,file_size;
-
- file_offset = ((cr1 & 0xff)<<8)|(cr2 & 0xff); /* correct? */
- file_filter = cr3 >> 8;
- file_id = ((cr3 & 0xff) << 16)|(cr4);
- file_size = ((curdir[file_id].length + sectlenin - 1) / sectlenin) - file_offset;
-
- cd_stat = CD_STAT_PLAY|0x80; // set "cd-rom" bit
- cd_curfad = (curdir[file_id].firstfad + file_offset);
- fadstoplay = file_size;
- if(file_filter < 0x24)
- cddevice = &filters[file_filter];
- else
- cddevice = (filterT *)NULL;
-
- printf("Read file %08x (%08x %08x) %02x %d\n",curdir[file_id].firstfad,cd_curfad,fadstoplay,file_filter,sectlenin);
-
- cr_standard_return(cd_stat);
-
- oddframe = 0;
- in_buffer = 0;
-
- playtype = 1;
-
- hirqreg |= (CMOK|EHST);
- status_type = 0;
- break;
-
- case 0x75:
- CDROM_LOG(("%s:CD: Abort File\n", machine().describe_context()))
- // bios expects "2bc" mask to work against this
- hirqreg |= (CMOK|EFLS);
- sectorstore = 0;
- xfertype32 = XFERTYPE32_INVALID;
- xferdnum = 0;
- if(((cd_stat & 0x0f00) != CD_STAT_NODISC) && ((cd_stat & 0x0f00) != CD_STAT_OPEN))
- cd_stat = CD_STAT_PAUSE; // force to pause
- cr_standard_return(cd_stat);
- status_type = 0;
- break;
-
- case 0xe0: // appears to be copy protection check. needs only to return OK.
- CDROM_LOG(("%s:CD: Verify copy protection\n", machine().describe_context()))
- if(((cd_stat & 0x0f00) != CD_STAT_NODISC) && ((cd_stat & 0x0f00) != CD_STAT_OPEN))
- cd_stat = CD_STAT_PAUSE;
-// cr1 = cd_stat; // necessary to pass
-// cr2 = 0x4;
-// hirqreg |= (CMOK|EFLS|CSCT);
- sectorstore = 1;
- hirqreg = 0xfc5;
- cr_standard_return(cd_stat);
- status_type = 0;
- break;
-
- case 0xe1: // get disc region
- CDROM_LOG(("%s:CD: Get disc region\n", machine().describe_context()))
- if(cd_stat != CD_STAT_NODISC && cd_stat != CD_STAT_OPEN)
- cd_stat = CD_STAT_PAUSE;
- cr1 = cd_stat; // necessary to pass
- cr2 = 0x4; // (must return this value to pass bios checks)
- cr3 = 0;
- cr4 = 0;
- hirqreg |= (CMOK);
-// cr_standard_return(cd_stat);
- status_type = 0;
- break;
-
- default:
- CDROM_LOG(("CD: Unknown command %04x\n", cr1>>8))
- popmessage("CD Block unknown command %02x, contact MAMEdev",cr1>>8);
- hirqreg |= (CMOK);
- break;
- }
-
- if(status_type == 1)
- {
- prev_cr1 = cr1;
- prev_cr2 = cr2;
- prev_cr3 = cr3;
- prev_cr4 = cr4;
- }
-}
-
-TIMER_DEVICE_CALLBACK_MEMBER( saturn_state::stv_sh1_sim )
-{
- if((cmd_pending == 0xf) && (!(hirqreg & CMOK)))
- cd_exec_command();
-}
-
-TIMER_DEVICE_CALLBACK_MEMBER( saturn_state::stv_sector_cb )
-{
- //sector_timer->reset();
-
- //popmessage("%08x %08x %d %d",cd_curfad,fadstoplay,cmd_pending,cd_speed);
-
- cd_playdata();
-
- if(cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, cd_curfad)) == CD_TRACK_AUDIO)
- sector_timer->adjust(attotime::from_hz(75)); // 75 sectors / second = 150kBytes/second (cdda track ignores cd_speed setting)
- else
- sector_timer->adjust(attotime::from_hz(75*cd_speed)); // 75 / 150 sectors / second = 150 / 300kBytes/second
-
- /* TODO: doesn't boot if a disk isn't in? */
- /* TODO: Check out when this really happens. (Daytona USA original version definitely wants it to be on).*/
- //if(((cd_stat & 0x0f00) != CD_STAT_NODISC) && ((cd_stat & 0x0f00) != CD_STAT_OPEN))
- hirqreg |= SCDQ;
-
- if(cd_stat & CD_STAT_PERI)
- {
- cr_standard_return(cd_stat);
- }
-}
-
-// global functions
-void saturn_state::stvcd_reset( void )
-{
- INT32 i, j;
-
- hirqmask = 0xffff;
- hirqreg = 0xffff;
- cr1 = 'C';
- cr2 = ('D'<<8) | 'B';
- cr3 = ('L'<<8) | 'O';
- cr4 = ('C'<<8) | 'K';
- cd_stat = CD_STAT_PAUSE;
- cd_stat |= CD_STAT_PERI;
- cur_track = 0xff;
-
- curdir.clear();
-
- xfertype = XFERTYPE_INVALID;
- xfertype32 = XFERTYPE32_INVALID;
-
- // reset flag vars
- buffull = sectorstore = 0;
-
- freeblocks = 200;
-
- sectlenin = sectlenout = 2048;
-
- lastbuf = 0xff;
-
- // reset buffer partitions
- for (i = 0; i < MAX_FILTERS; i++)
- {
- partitions[i].size = -1;
- partitions[i].numblks = 0;
-
- for (j = 0; j < MAX_BLOCKS; j++)
- {
- partitions[i].blocks[j] = (blockT *)NULL;
- partitions[i].bnum[j] = 0xff;
- }
- }
-
- // reset blocks
- for (i = 0; i < MAX_BLOCKS; i++)
- {
- blocks[i].size = -1;
- memset(&blocks[i].data, 0, CD_MAX_SECTOR_DATA);
- }
-
- // open device
- if (cdrom)
- {
- cdrom_close(cdrom);
- cdrom = (cdrom_file *)NULL;
- }
-
- cdrom_image_device *cddevice = machine().device<cdrom_image_device>("cdrom");
- if (cddevice!=NULL)
- {
- // MESS case
- cdrom = cddevice->get_cdrom_file();
- }
- else
- {
- // MAME case
- cdrom = cdrom_open(get_disk_handle(machine(), "cdrom"));
- }
-
- machine().device<cdda_device>("cdda")->set_cdrom(cdrom);
-
- if (cdrom)
- {
- CDROM_LOG(("Opened CD-ROM successfully, reading root directory\n"))
- read_new_dir(0xffffff); // read root directory
- }
- else
- {
- cd_stat = CD_STAT_NODISC;
- }
-
- cd_speed = 2;
- cdda_repeat_count = 0;
- tray_is_closed = 1;
-
- sector_timer = machine().device<timer_device>("sector_timer");
- sector_timer->adjust(attotime::from_hz(150)); // 150 sectors / second = 300kBytes/second
- sh1_timer = machine().device<timer_device>("sh1_cmd");
-}
-
-saturn_state::blockT *saturn_state::cd_alloc_block(UINT8 *blknum)
-{
- INT32 i;
-
- // search the 200 available blocks for a free one
- for (i = 0; i < 200; i++)
- {
- if (blocks[i].size == -1)
- {
- freeblocks--;
- if (freeblocks <= 0)
- {
- buffull = 1;
- printf("buffull in cd_alloc_block\n");
- }
-
- blocks[i].size = sectlenin;
- *blknum = i;
-
- CDROM_LOG(("CD: allocating block %d, size %x\n", i, sectlenin))
-
- return &blocks[i];
- }
- }
-
- buffull = 1;
- return (blockT *)NULL;
-}
-
-void saturn_state::cd_free_block(blockT *blktofree)
-{
- INT32 i;
-
- CDROM_LOG(("cd_free_block: %x\n", (UINT32)(FPTR)blktofree))
-
- if(blktofree == NULL)
- {
- return;
- }
-
- for (i = 0; i < 200; i++)
- {
- if (&blocks[i] == blktofree)
- {
- CDROM_LOG(("CD: freeing block %d\n", i))
- }
- }
-
- blktofree->size = -1;
- freeblocks++;
- buffull = 0;
- hirqreg &= ~BFUL;
-}
-
-void saturn_state::cd_getsectoroffsetnum(UINT32 bufnum, UINT32 *sectoffs, UINT32 *sectnum)
-{
- if (*sectoffs == 0xffff)
- {
- // last sector
- printf("CD: Don't know how to handle offset ffff\n");
- }
- else if (*sectnum == 0xffff)
- {
- *sectnum = partitions[bufnum].numblks - *sectoffs;
- }
-}
-
-void saturn_state::cd_defragblocks(partitionT *part)
-{
- UINT32 i, j;
- blockT *temp;
- UINT8 temp2;
-
- for (i = 0; i < (MAX_BLOCKS-1); i++)
- {
- for (j = i+1; j < MAX_BLOCKS; j++)
- {
- if ((part->blocks[i] == (blockT *)NULL) && (part->blocks[j] != (blockT *)NULL))
- {
- temp = part->blocks[i];
- part->blocks[i] = part->blocks[j];
- part->blocks[j] = temp;
-
- temp2 = part->bnum[i];
- part->bnum[i] = part->bnum[j];
- part->bnum[j] = temp2;
- }
- }
- }
-}
-
-UINT16 saturn_state::cd_readWord(UINT32 addr)
-{
- UINT16 rv;
-
- switch (addr & 0xffff)
- {
- case 0x0008: // read HIRQ register
- case 0x000a:
- case 0x8008:
- case 0x800a:
- rv = hirqreg;
-
- rv &= ~DCHG; // always clear bit 6 (tray open)
-
- if (buffull) rv |= BFUL; else rv &= ~BFUL;
- if (sectorstore) rv |= CSCT; else rv &= ~CSCT;
-
- hirqreg = rv;
-
-// CDROM_LOG(("RW HIRQ: %04x\n", rv))
-
- return rv;
-
- case 0x000c:
- case 0x000e:
- case 0x800c:
- case 0x800e:
-// CDROM_LOG(("RW HIRM: %04x\n", hirqmask))
- printf("RW HIRM: %04x\n", hirqmask);
- return hirqmask;
-
- case 0x0018:
- case 0x001a:
- case 0x8018:
- case 0x801a:
-// CDROM_LOG(("RW CR1: %04x\n", cr1))
- return cr1;
-
- case 0x001c:
- case 0x001e:
- case 0x801c:
- case 0x801e:
-// CDROM_LOG(("RW CR2: %04x\n", cr2))
- return cr2;
-
- case 0x0020:
- case 0x0022:
- case 0x8020:
- case 0x8022:
-// CDROM_LOG(("RW CR3: %04x\n", cr3))
- return cr3;
-
- case 0x0024:
- case 0x0026:
- case 0x8024:
- case 0x8026:
-// CDROM_LOG(("RW CR4: %04x\n", cr4))
- //popmessage("%04x %04x %04x %04x",cr1,cr2,cr3,cr4);
- cmd_pending = 0;
- cd_stat |= CD_STAT_PERI;
- return cr4;
-
- case 0x8000:
- rv = 0xffff;
- switch (xfertype)
- {
- case XFERTYPE_TOC:
- rv = tocbuf[xfercount]<<8 | tocbuf[xfercount+1];
-
- xfercount += 2;
- xferdnum += 2;
-
- if (xfercount > 102*4)
- {
- xfercount = 0;
- xfertype = XFERTYPE_INVALID;
- }
- break;
-
- case XFERTYPE_FILEINFO_1:
- rv = finfbuf[xfercount]<<8 | finfbuf[xfercount+1];
- xfercount += 2;
- xferdnum += 2;
-
- if (xfercount > 6*2)
- {
- xfercount = 0;
- xfertype = XFERTYPE_INVALID;
- }
- break;
-
- case XFERTYPE_FILEINFO_254: // Lunar 2
- if((xfercount % (6 * 2)) == 0)
- {
- UINT32 temp = 2 + (xfercount / (0x6 * 2));
-
- // first 4 bytes = FAD
- finfbuf[0] = (curdir[temp].firstfad>>24)&0xff;
- finfbuf[1] = (curdir[temp].firstfad>>16)&0xff;
- finfbuf[2] = (curdir[temp].firstfad>>8)&0xff;
- finfbuf[3] = (curdir[temp].firstfad&0xff);
- // second 4 bytes = length of file
- finfbuf[4] = (curdir[temp].length>>24)&0xff;
- finfbuf[5] = (curdir[temp].length>>16)&0xff;
- finfbuf[6] = (curdir[temp].length>>8)&0xff;
- finfbuf[7] = (curdir[temp].length&0xff);
- finfbuf[8] = curdir[temp].interleave_gap_size;
- finfbuf[9] = curdir[temp].file_unit_size;
- finfbuf[10] = temp;
- finfbuf[11] = curdir[temp].flags;
- }
-
- rv = finfbuf[xfercount % (6 * 2)]<<8 | finfbuf[(xfercount % (6 * 2)) +1];
-
- xfercount += 2;
- xferdnum += 2;
-
- if (xfercount > (254 * 6 * 2))
- {
- xfercount = 0;
- xfertype = XFERTYPE_INVALID;
- }
- break;
-
- case XFERTYPE_SUBQ:
- rv = subqbuf[xfercount]<<8 | subqbuf[xfercount+1];
-
- xfercount += 2;
- xferdnum += 2;
-
- if (xfercount > 5*2)
- {
- xfercount = 0;
- xfertype = XFERTYPE_INVALID;
- }
- break;
-
-
- case XFERTYPE_SUBRW:
- rv = subrwbuf[xfercount]<<8 | subrwbuf[xfercount+1];
-
- xfercount += 2;
- xferdnum += 2;
-
- if (xfercount > 12*2)
- {
- xfercount = 0;
- xfertype = XFERTYPE_INVALID;
- }
- break;
-
- default:
- printf("STVCD: Unhandled xfer type %d\n", (int)xfertype);
- rv = 0;
- break;
- }
-
- return rv;
-
- default:
- CDROM_LOG(("CD: RW %08x\n", addr))
- return 0xffff;
- }
-
-}
-
-UINT32 saturn_state::cd_readLong(UINT32 addr)
-{
- UINT32 rv = 0;
-
- switch (addr & 0xffff)
- {
- case 0x8000:
- switch (xfertype32)
- {
- case XFERTYPE32_GETSECTOR:
- case XFERTYPE32_GETDELETESECTOR:
- // make sure we have sectors left
- if (xfersect < xfersectnum)
- {
- // get next longword
- rv = (transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 0]<<24) |
- (transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 1]<<16) |
- (transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 2]<<8) |
- (transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 3]<<0);
-
- xferdnum += 4;
- xferoffs += 4;
-
- // did we run out of sector?
- if (xferoffs >= transpart->blocks[xfersect]->size)
- {
- CDROM_LOG(("CD: finished xfer of block %d of %d\n", xfersect+1, xfersectnum))
-
- xferoffs = 0;
- xfersect++;
- }
- }
- else // sectors are done, kill 'em all if we can
- {
- if (xfertype32 == XFERTYPE32_GETDELETESECTOR)
- {
- INT32 i;
-
- CDROM_LOG(("Killing sectors in done\n"))
-
- // deallocate the blocks
- for (i = xfersectpos; i < xfersectpos+xfersectnum; i++)
- {
- cd_free_block(transpart->blocks[i]);
- transpart->blocks[i] = (blockT *)NULL;
- transpart->bnum[i] = 0xff;
- }
-
- // defrag what's left
- cd_defragblocks(transpart);
-
- // clean up our state
- transpart->size -= xferdnum;
- transpart->numblks -= xfersectnum;
-
- /* TODO: is this correct? */
- xfertype32 = XFERTYPE32_INVALID;
- }
- }
- break;
-
- default:
- printf("CD: unhandled 32-bit transfer type\n");
- break;
- }
-
- return rv;
-
- default:
- CDROM_LOG(("CD: RL %08x\n", addr))
- return 0xffff;
- }
-}
-
-void saturn_state::cd_writeLong(UINT32 addr, UINT32 data)
-{
- switch (addr & 0xffff)
- {
- case 0x8000:
- switch (xfertype32)
- {
- case XFERTYPE32_PUTSECTOR:
- // make sure we have sectors left
- if (xfersect < xfersectnum)
- {
- // get next longword
- transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 0] = (data >> 24) & 0xff;
- transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 1] = (data >> 16) & 0xff;
- transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 2] = (data >> 8) & 0xff;
- transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 3] = (data >> 0) & 0xff;
-
- xferdnum += 4;
- xferoffs += 4;
-
- // did we run out of sector?
- if (xferoffs >= transpart->blocks[xfersectpos+xfersect]->size)
- {
- CDROM_LOG(("CD: finished xfer of block %d of %d\n", xfersect+1, xfersectnum))
-
- xferoffs = 0;
- xfersect++;
- }
- }
- else // sectors are done
- {
- /* Virtual On doesnt want this to be resetted. */
- //xfertype32 = XFERTYPE32_INVALID;
- }
- break;
-
- default:
- printf("CD: unhandled 32-bit transfer type write\n");
- break;
- }
- break;
-
- default:
- break;
- }
-}
-
-void saturn_state::cd_writeWord(UINT32 addr, UINT16 data)
-{
- switch(addr & 0xffff)
- {
- case 0x0008:
- case 0x000a:
- case 0x8008:
- case 0x800a:
-// CDROM_LOG(("%s:WW HIRQ: %04x & %04x => %04x\n", machine().describe_context(), hirqreg, data, hirqreg & data))
- hirqreg &= data;
- return;
- case 0x000c:
- case 0x000e:
- case 0x800c:
- case 0x800e:
-// CDROM_LOG(("WW HIRM: %04x => %04x\n", hirqmask, data))
- printf("WW HIRM: %04x => %04x\n", hirqmask, data);
- hirqmask = data;
- return;
- case 0x0018:
- case 0x001a:
- case 0x8018:
- case 0x801a:
-// CDROM_LOG(("WW CR1: %04x\n", data))
- cr1 = data;
- cd_stat &= ~CD_STAT_PERI;
- cmd_pending |= 1;
- sh1_timer->adjust(attotime::never);
- break;
- case 0x001c:
- case 0x001e:
- case 0x801c:
- case 0x801e:
-// CDROM_LOG(("WW CR2: %04x\n", data))
- cr2 = data;
- cmd_pending |= 2;
- break;
- case 0x0020:
- case 0x0022:
- case 0x8020:
- case 0x8022:
-// CDROM_LOG(("WW CR3: %04x\n", data))
- cr3 = data;
- cmd_pending |= 4;
- break;
- case 0x0024:
- case 0x0026:
- case 0x8024:
- case 0x8026:
-// CDROM_LOG(("WW CR4: %04x\n", data))
- cr4 = data;
- cmd_pending |= 8;
- sh1_timer->adjust(attotime::from_hz(get_timing_command()));
- break;
- default:
- CDROM_LOG(("CD: WW %08x %04x\n", addr, data))
- break;
- }
-}
-
-READ32_MEMBER( saturn_state::stvcd_r )
-{
- UINT32 rv = 0;
-
- offset <<= 2;
-
- switch (offset)
- {
- case 0x88008:
- case 0x8800a:
- case 0x8800c:
- case 0x8800e:
- case 0x88018:
- case 0x8801a:
- case 0x8801c:
- case 0x8801e:
- case 0x88020:
- case 0x88022:
- case 0x88024:
- case 0x88026:
- case 0x90008:
- case 0x9000a:
- case 0x9000c:
- case 0x9000e:
- case 0x90018:
- case 0x9001a:
- case 0x9001c:
- case 0x9001e:
- case 0x90020:
- case 0x90022:
- case 0x90024:
- case 0x90026:
- rv = cd_readWord(offset);
- return rv<<16;
-
- case 0x98000:
- case 0x18000:
- if (mem_mask == 0xffffffff)
- {
- rv = cd_readLong(offset);
- }
- else if (mem_mask == 0xffff0000)
- {
- rv = cd_readWord(offset)<<16;
- }
- else if (mem_mask == 0x0000ffff)
- {
- rv = cd_readWord(offset);
- }
- else
- {
- osd_printf_error("CD: Unknown data buffer read @ mask = %08x\n", mem_mask);
- }
-
- break;
-
- default:
- printf("Unknown CD read %x\n", offset);
- break;
- }
-
- return rv;
-}
-
-WRITE32_MEMBER( saturn_state::stvcd_w )
-{
- offset <<= 2;
-
- switch (offset)
- {
- case 0x18000:
- if (mem_mask == 0xffffffff)
- cd_writeLong(offset, data);
- else
- printf("CD: Unknown data buffer write @ mask = %08x\n", mem_mask);
- break;
-
- case 0x88008:
- case 0x8800a:
- case 0x8800c:
- case 0x8800e:
- case 0x88018:
- case 0x8801a:
- case 0x8801c:
- case 0x8801e:
- case 0x88020:
- case 0x88022:
- case 0x88024:
- case 0x88026:
- case 0x90008:
- case 0x9000a:
- case 0x9000c:
- case 0x9000e:
- case 0x90018:
- case 0x9001a:
- case 0x9001c:
- case 0x9001e:
- case 0x90020:
- case 0x90022:
- case 0x90024:
- case 0x90026:
- cd_writeWord(offset, data>>16);
- break;
-
- default:
- printf("Unknown CD write %x @ %x\n", data, offset);
- //xferdnum = 0x8c00;
- break;
- }
-}
-
-// iso9660 parsing
-void saturn_state::read_new_dir(UINT32 fileno)
-{
- int foundpd, i;
- UINT32 cfad;//, dirfad;
- UINT8 sect[2048];
-
- if (fileno == 0xffffff)
- {
- cfad = 166; // first sector of directory as per iso9660 specs
-
- foundpd = 0; // search for primary vol. desc
- while ((!foundpd) && (cfad < 200))
- {
- if(sectlenin != 2048)
- popmessage("Sector Length %d, contact MAMEdev (0)",sectlenin);
-
- memset(sect, 0, 2048);
- cd_readblock(cfad++, sect);
-
- if ((sect[1] == 'C') && (sect[2] == 'D') && (sect[3] == '0') && (sect[4] == '0') && (sect[5] == '1'))
- {
- switch (sect[0])
- {
- case 0: // boot record
- break;
-
- case 1: // primary vol. desc
- foundpd = 1;
- break;
-
- case 2: // secondary vol desc
- break;
-
- case 3: // vol. section descriptor
- break;
-
- case 0xff:
- cfad = 200;
- break;
- }
- }
- }
-
- // got primary vol. desc.
- if (foundpd)
- {
- //dirfad = sect[140] | (sect[141]<<8) | (sect[142]<<16) | (sect[143]<<24);
- //dirfad += 150;
-
- // parse root entry
- curroot.firstfad = sect[158] | (sect[159]<<8) | (sect[160]<<16) | (sect[161]<<24);
- curroot.firstfad += 150;
- curroot.length = sect[166] | (sect[167]<<8) | (sect[168]<<16) | (sect[169]<<24);
- curroot.flags = sect[181];
- for (i = 0; i < sect[188]; i++)
- {
- curroot.name[i] = sect[189+i];
- }
- curroot.name[i] = '\0'; // terminate
-
- // easy to fix, but make sure we *need* to first
- if (curroot.length > MAX_DIR_SIZE)
- {
- osd_printf_error("ERROR: root directory too big (%d)\n", curroot.length);
- }
-
- // done with all that, read the root directory now
- make_dir_current(curroot.firstfad);
- }
- }
- else
- {
- if (curdir[fileno].length > MAX_DIR_SIZE)
- {
- osd_printf_error("ERROR: new directory too big (%d)!\n", curdir[fileno].length);
- }
- make_dir_current(curdir[fileno].firstfad);
- }
-}
-
-// makes the directory pointed to by FAD current
-void saturn_state::make_dir_current(UINT32 fad)
-{
- int i;
- UINT32 nextent, numentries;
- dynamic_buffer sect(MAX_DIR_SIZE);
- direntryT *curentry;
-
- memset(&sect[0], 0, MAX_DIR_SIZE);
- if(sectlenin != 2048)
- popmessage("Sector Length %d, contact MAMEdev (1)",sectlenin);
-
- for (i = 0; i < (curroot.length/2048); i++)
- {
- cd_readblock(fad+i, &sect[2048*i]);
- }
-
- nextent = 0;
- numentries = 0;
- while (nextent < MAX_DIR_SIZE)
- {
- if (sect[nextent])
- {
- nextent += sect[nextent];
- numentries++;
- }
- else
- {
- nextent = MAX_DIR_SIZE;
- }
- }
-
- curdir.resize(numentries);
- curentry = &curdir[0];
- numfiles = numentries;
-
- nextent = 0;
- while (numentries)
- {
- // [0] record size
- // [1] xa record size
- // [2-5] lba
- // [6-9] (lba?)
- // [10-13] size
- // [14-17] (size?)
- // [18] year
- // [19] month
- // [20] day
- // [21] hour
- // [22] minute
- // [23] second
- // [24] gmt offset
- // [25] flags
- // [26] file unit size
- // [27] interleave gap size
- // [28-29] volume sequencer number
- // [30-31] (volume sequencer number?)
- // [32] name character size
- // [33+ ...] file name
-
- curentry->record_size = sect[nextent+0];
- curentry->xa_record_size = sect[nextent+1];
- curentry->firstfad = sect[nextent+2] | (sect[nextent+3]<<8) | (sect[nextent+4]<<16) | (sect[nextent+5]<<24);
- curentry->firstfad += 150;
- curentry->length = sect[nextent+10] | (sect[nextent+11]<<8) | (sect[nextent+12]<<16) | (sect[nextent+13]<<24);
- curentry->year = sect[nextent+18];
- curentry->month = sect[nextent+19];
- curentry->day = sect[nextent+20];
- curentry->hour = sect[nextent+21];
- curentry->minute = sect[nextent+22];
- curentry->second = sect[nextent+23];
- curentry->gmt_offset = sect[nextent+24];
- curentry->flags = sect[nextent+25];
- curentry->file_unit_size = sect[nextent+26];
- curentry->interleave_gap_size = sect[nextent+27];
- curentry->volume_sequencer_number = sect[nextent+28] | (sect[nextent+29] << 8);
-
- for (i = 0; i < sect[nextent+32]; i++)
- {
- curentry->name[i] = sect[nextent+33+i];
- }
- curentry->name[i] = '\0'; // terminate
- //printf("%08x %08x %s %d/%d/%d\n",curentry->firstfad,curentry->length,curentry->name,curentry->year,curentry->month,curentry->day);
-
- nextent += sect[nextent];
- curentry++;
- numentries--;
- }
-
- for (i = 0; i < numfiles; i++)
- {
- if (!(curdir[i].flags & 0x02))
- {
- firstfile = i;
- i = numfiles;
- }
- }
-}
-
-void saturn_state::stvcd_exit( void )
-{
- curdir.clear();
-
- if (cdrom)
- {
- cdrom_image_device *cddevice = machine().device<cdrom_image_device>("cdrom");
- if (cddevice==NULL)
- {
- cdrom_close(cdrom);
- }
- cdrom = (cdrom_file *)NULL;
- }
-}
-
-void saturn_state::cd_readTOC(void)
-{
- int i, ntrks, tocptr, fad;
-
- xfertype = XFERTYPE_TOC;
- xfercount = 0;
-
- if (cdrom)
- {
- ntrks = cdrom_get_last_track(cdrom);
- }
- else
- {
- ntrks = 0;
- }
-
- // data format for Saturn TOC:
- // no header.
- // 4 bytes per track
- // top nibble of first byte is CTRL info
- // low nibble is ADR
- // next 3 bytes are FAD address (LBA + 150)
- // there are always 99 track entries (0-98)
- // unused tracks are ffffffff.
- // entries 99-101 are metadata
-
- tocptr = 0; // starting point of toc entries
-
- for (i = 0; i < ntrks; i++)
- {
- if (cdrom)
- {
- //tocbuf[tocptr] = sega_cdrom_get_adr_control(cdrom, i);
- //HACK: ddsom does not enter ingame with the line above!
- tocbuf[tocptr] = cdrom_get_adr_control(cdrom, i)<<4 | 0x01;
- }
- else
- {
- tocbuf[tocptr] = 0xff;
- }
-
- if (cdrom)
- {
- fad = cdrom_get_track_start(cdrom, i) + 150;
-
- tocbuf[tocptr+1] = (fad>>16)&0xff;
- tocbuf[tocptr+2] = (fad>>8)&0xff;
- tocbuf[tocptr+3] = fad&0xff;
- }
- else
- {
- tocbuf[tocptr+1] = 0xff;
- tocbuf[tocptr+2] = 0xff;
- tocbuf[tocptr+3] = 0xff;
- }
-
- tocptr += 4;
- }
-
- // fill in the rest
- for ( ; i < 99; i++)
- {
- tocbuf[tocptr] = 0xff;
- tocbuf[tocptr+1] = 0xff;
- tocbuf[tocptr+2] = 0xff;
- tocbuf[tocptr+3] = 0xff;
-
- tocptr += 4;
- }
-
- // tracks 99-101 are special metadata
- // $$$FIXME: what to do with the address info for these?
- tocptr = 99 * 4;
- tocbuf[tocptr] = tocbuf[0]; // get ctrl/adr from first track
- tocbuf[tocptr+1] = 1; // first track's track #
- tocbuf[tocptr+2] = 0;
- tocbuf[tocptr+3] = 0;
-
- tocbuf[tocptr+4] = tocbuf[(ntrks-1)*4]; // ditto for last track
- tocbuf[tocptr+5] = ntrks; // last track's track #
- tocbuf[tocptr+6] = 0;
- tocbuf[tocptr+7] = 0;
-
- // get total disc length (start of lead-out)
- fad = cdrom_get_track_start(cdrom, 0xaa) + 150;
-
- tocbuf[tocptr+8] = tocbuf[0];
- tocbuf[tocptr+9] = (fad>>16)&0xff;
- tocbuf[tocptr+10] = (fad>>8)&0xff;
- tocbuf[tocptr+11] = fad&0xff;
-}
-
-saturn_state::partitionT *saturn_state::cd_filterdata(filterT *flt, int trktype, UINT8 *p_ok)
-{
- int match, keepgoing;
- partitionT *filterprt = (partitionT *)NULL;
-
- CDROM_LOG(("cd_filterdata, trktype %d\n", trktype))
- match = 1;
- keepgoing = 2;
- lastbuf = flt->condtrue;
-
- // loop on the filters
- do
- {
- // FAD range check?
- /* according to an obscure document note, this switches the filter connector to be false if the range fails ... I think ... */
- if (flt->mode & 0x40)
- {
- if ((cd_curfad < flt->fad) || (cd_curfad > (flt->fad + flt->range)))
- {
- printf("curfad reject %08x %08x %08x %08x\n",cd_curfad,fadstoplay,flt->fad,flt->fad+flt->range);
- match = 0;
- //lastbuf = flt->condfalse;
- //flt = &filters[lastbuf];
- }
- }
-
- if ((trktype != CD_TRACK_AUDIO) && (curblock.data[15] == 2))
- {
- if (flt->mode & 1) // file number
- {
- if (curblock.fnum != flt->fid)
- {
- printf("fnum reject\n");
- match = 0;
- }
- }
-
- if (flt->mode & 2) // channel number
- {
- if (curblock.chan != flt->chan)
- {
- printf("channel number reject\n");
- match = 0;
- }
- }
-
- if (flt->mode & 4) // sub mode
- {
- if((curblock.subm & flt->smmask) != flt->smval)
- {
- printf("sub mode reject\n");
- match = 0;
- }
- }
-
- if (flt->mode & 8) // coding information
- {
- if((curblock.cinf & flt->cimask) != flt->cival)
- {
- printf("coding information reject\n");
- match = 0;
- }
- }
-
- if (flt->mode & 0x10) // reverse subheader conditions
- {
- match ^= 1;
- }
- }
-
- if (match)
- {
- //lastbuf = flt->condtrue;
- //filterprt = &partitions[lastbuf];
- // we're done
- keepgoing = 0;
- }
- else
- {
- lastbuf = flt->condfalse;
-
- // reject sector if no match on either connector
- if ((lastbuf == 0xff) || (keepgoing == 0))
- {
- *p_ok = 0;
- return (partitionT *)NULL;
- }
-
- // try again using the filter that was on the "false" connector
- flt = &filters[lastbuf];
- match = 1;
-
- // and exit if we fail
- keepgoing--;
- }
- } while (keepgoing);
-
- filterprt = &partitions[lastbuf];
-
- // try to allocate a block
- filterprt->blocks[filterprt->numblks] = cd_alloc_block(&filterprt->bnum[filterprt->numblks]);
-
- // did the allocation succeed?
- if (filterprt->blocks[filterprt->numblks] == (blockT *)NULL)
- {
- *p_ok = 0;
- return (partitionT *)NULL;
- }
-
- // copy working block to the newly allocated one
- memcpy(filterprt->blocks[filterprt->numblks], &curblock, sizeof(blockT));
-
- // and massage the data format a bit
- switch (curblock.size)
- {
- case 2048: // user data
- if (curblock.data[15] == 2)
- {
- // mode 2
- memcpy(&filterprt->blocks[filterprt->numblks]->data[0], &curblock.data[24], curblock.size);
- }
- else
- {
- // mode 1
- memcpy(&filterprt->blocks[filterprt->numblks]->data[0], &curblock.data[16], curblock.size);
- }
- break;
-
- case 2324: // Mode 2 Form 2 data
- memcpy(&filterprt->blocks[filterprt->numblks]->data[0], &curblock.data[24], curblock.size);
- break;
-
- case 2336: // Mode 2 Form 2 skip sync/header
- memcpy(&filterprt->blocks[filterprt->numblks]->data[0], &curblock.data[16], curblock.size);
- break;
-
- case 2340: // Mode 2 Form 2 skip sync only
- memcpy(&filterprt->blocks[filterprt->numblks]->data[0], &curblock.data[12], curblock.size);
- break;
-
- case 2352: // want all data, it's already done, so don't do it again :)
- break;
- }
-
- // update the status of the partition
- if (filterprt->size == -1)
- filterprt->size = 0;
-
- filterprt->size += filterprt->blocks[filterprt->numblks]->size;
- filterprt->numblks++;
-
- *p_ok = 1;
- return filterprt;
-}
-
-// read a single sector off the CD, applying the current filter(s) as necessary
-saturn_state::partitionT *saturn_state::cd_read_filtered_sector(INT32 fad, UINT8 *p_ok)
-{
- int trktype;
-
- if ((cddevice != NULL) && (!buffull))
- {
- // find out the track's type
- trktype = cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, fad-150));
-
- // now get a raw 2352 byte sector - if it's mode 1, get mode1_raw
- if ((trktype == CD_TRACK_MODE1) || (trktype == CD_TRACK_MODE1_RAW))
- {
- cdrom_read_data(cdrom, fad-150, curblock.data, CD_TRACK_MODE1_RAW);
- }
- else if (trktype != CD_TRACK_AUDIO) // if not audio it must be mode 2 so get mode2_raw
- {
- cdrom_read_data(cdrom, fad-150, curblock.data, CD_TRACK_MODE2_RAW);
- }
- else
- {
- cdrom_read_data(cdrom, fad-150, curblock.data, CD_TRACK_AUDIO);
- }
-
- curblock.size = sectlenin;
- curblock.FAD = fad;
-
- // if track is Mode 2, get the subheader values
- if ((trktype != CD_TRACK_AUDIO) && (curblock.data[15] == 2))
- {
- curblock.chan = curblock.data[17];
- curblock.fnum = curblock.data[16];
- curblock.subm = curblock.data[18];
- curblock.cinf = curblock.data[19];
-
- // if it's Form 2, the length is actually 2324 bytes
- if (curblock.subm & 0x20)
- {
- curblock.size = 2324;
- }
- }
-
- return cd_filterdata(cddevice, trktype, &*p_ok);
- }
-
- *p_ok = 0;
- return (partitionT *)NULL;
-}
-
-// loads in data set up by a CD-block PLAY command
-void saturn_state::cd_playdata( void )
-{
- if ((cd_stat & 0x0f00) == CD_STAT_SEEK)
- {
- INT32 fad_diff;
- //printf("PRE %08x %08x %08x %d\n",cd_curfad,cd_fad_seek,cd_stat,cd_fad_seek - cd_curfad);
-
- fad_diff = (cd_fad_seek - cd_curfad);
-
- /* Zero Divide wants this TODO: timings. */
- if(fad_diff > (750*cd_speed))
- {
- //printf("PRE FFWD %08x %08x %08x %d %d\n",cd_curfad,cd_fad_seek,cd_stat,cd_fad_seek - cd_curfad,750*cd_speed);
- cd_curfad += (750*cd_speed);
- //printf("POST FFWD %08x %08x %08x %d %d\n",cd_curfad,cd_fad_seek,cd_stat,cd_fad_seek - cd_curfad, 750*cd_speed);
- }
- else if(fad_diff < (-750*cd_speed))
- {
- //printf("PRE REW %08x %08x %08x %d %d\n",cd_curfad,cd_fad_seek,cd_stat,cd_fad_seek - cd_curfad, -750*cd_speed);
- cd_curfad -= (750*cd_speed);
- //printf("POST REW %08x %08x %08x %d %d\n",cd_curfad,cd_fad_seek,cd_stat,cd_fad_seek - cd_curfad, -750*cd_speed);
- }
- else
- {
- //printf("Ready\n");
- cd_curfad = cd_fad_seek;
- cd_stat = CD_STAT_PLAY;
- }
-
- return;
- }
-
- if ((cd_stat & 0x0f00) == CD_STAT_PLAY)
- {
- if (fadstoplay)
- {
- logerror("STVCD: Reading FAD %d\n", cd_curfad);
-
- if (cdrom)
- {
- UINT8 p_ok;
-
- if(cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, cd_curfad)) != CD_TRACK_AUDIO)
- {
- cd_read_filtered_sector(cd_curfad,&p_ok);
- machine().device<cdda_device>("cdda")->stop_audio(); //stop any pending CD-DA
- }
- else
- {
- p_ok = 1; // TODO
- machine().device<cdda_device>("cdda")->start_audio(cd_curfad, 1);
- }
-
- if(p_ok)
- {
- cd_curfad++;
- fadstoplay--;
- hirqreg |= CSCT;
- sectorstore = 1;
-
- if (!fadstoplay)
- {
- if(cdda_repeat_count >= cdda_maxrepeat)
- {
- CDROM_LOG(("cd_playdata: playback ended\n"))
- cd_stat = CD_STAT_PAUSE;
-
- hirqreg |= PEND;
-
- if (playtype == 1)
- {
- CDROM_LOG(("cd_playdata: setting EFLS\n"))
- hirqreg |= EFLS;
- }
- }
- else
- {
- if(cdda_repeat_count < 0xe)
- cdda_repeat_count++;
-
- cd_curfad = cdrom_get_track_start(cdrom, cur_track-1) + 150;
- fadstoplay = cdrom_get_track_start(cdrom, cur_track) - cd_curfad;
- }
- }
- }
- }
- }
- }
-}
-
-// loads a single sector off the CD, anywhere from FAD 150 on up
-void saturn_state::cd_readblock(UINT32 fad, UINT8 *dat)
-{
- if (cdrom)
- {
- cdrom_read_data(cdrom, fad-150, dat, CD_TRACK_MODE1);
- }
-}
-
-void saturn_state::stvcd_set_tray_open( void )
-{
- if(!tray_is_closed)
- return;
-
- hirqreg |= DCHG;
- cd_stat = CD_STAT_OPEN;
-
- cdrom = (cdrom_file *)NULL;
- tray_is_closed = 0;
-
- popmessage("Tray Open");
-}
-
-void saturn_state::stvcd_set_tray_close( void )
-{
- /* avoid user attempts to load a CD-ROM without opening the tray first (emulation asserts anyway with current framework) */
- if(tray_is_closed)
- return;
-
- hirqreg |= DCHG;
-
- cdrom_image_device *cddevice = machine().device<cdrom_image_device>("cdrom");
- if (cddevice!=NULL)
- {
- // MESS case
- cdrom = cddevice->get_cdrom_file();
- }
- else
- {
- // MAME case
- cdrom = cdrom_open(get_disk_handle(machine(), "cdrom"));
- }
-
- machine().device<cdda_device>("cdda")->set_cdrom(cdrom);
-
- if (cdrom)
- {
- CDROM_LOG(("Opened CD-ROM successfully, reading root directory\n"))
- //read_new_dir(0xffffff); // read root directory
- cd_stat = CD_STAT_PAUSE;
- }
- else
- {
- cd_stat = CD_STAT_NODISC;
- }
-
- cd_speed = 2;
- cdda_repeat_count = 0;
- tray_is_closed = 1;
-
- popmessage("Tray Close");
-}
diff --git a/src/emu/machine/t10mmc.c b/src/emu/machine/t10mmc.c
deleted file mode 100644
index 86e3ec696ed..00000000000
--- a/src/emu/machine/t10mmc.c
+++ /dev/null
@@ -1,765 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "t10mmc.h"
-
-static int to_msf(int frame)
-{
- int m = frame / (75 * 60);
- int s = (frame / 75) % 60;
- int f = frame % 75;
-
- return (m << 16) | (s << 8) | f;
-}
-
-void t10mmc::t10_start(device_t &device)
-{
- t10spc::t10_start(device);
-
- device.save_item(NAME(m_lba));
- device.save_item(NAME(m_blocks));
- device.save_item(NAME(m_last_lba));
- device.save_item(NAME(m_num_subblocks));
- device.save_item(NAME(m_cur_subblock));
- device.save_item(NAME(m_audio_sense));
-}
-
-void t10mmc::t10_reset()
-{
- t10spc::t10_reset();
-
- SetDevice( m_image->get_cdrom_file() );
- if( !m_cdrom )
- {
- logerror( "T10MMC %s: no CD found!\n", m_image->tag() );
- }
-
- m_lba = 0;
- m_blocks = 0;
- m_last_lba = 0;
- m_sector_bytes = 2048;
- m_num_subblocks = 1;
- m_cur_subblock = 0;
- m_audio_sense = 0;
-}
-
-// scsicd_exec_command
-
-void t10mmc::abort_audio()
-{
- if (m_cdda->audio_active())
- {
- m_cdda->stop_audio();
- m_audio_sense = SCSI_SENSE_ASC_ASCQ_AUDIO_PLAY_OPERATION_STOPPED_DUE_TO_ERROR;
- }
-}
-
-t10mmc::toc_format_t t10mmc::toc_format()
-{
- int mmc_format = command[2] & 0xf;
- if (mmc_format != 0)
- {
- return (toc_format_t) mmc_format;
- }
-
- /// SFF8020 legacy format field (see T10/1836-D Revision 2g page 643)
- return (toc_format_t) ((command[9] >> 6) & 3);
-}
-
-int t10mmc::toc_tracks()
-{
- int start_track = command[6];
- int end_track = cdrom_get_last_track(m_cdrom);
-
- if (start_track == 0)
- {
- return end_track + 1;
- }
- else if (start_track <= end_track)
- {
- return ( end_track - start_track ) + 2;
- }
- else if (start_track <= 0xaa)
- {
- return 1;
- }
-
- return 0;
-}
-
-//
-// Execute a SCSI command.
-
-void t10mmc::ExecCommand()
-{
- int trk;
-
- // keep updating the sense data while playing audio.
- if (command[0] == T10SPC_CMD_REQUEST_SENSE && m_audio_sense != SCSI_SENSE_ASC_ASCQ_NO_SENSE && m_sense_key == SCSI_SENSE_KEY_NO_SENSE && m_sense_asc == 0 && m_sense_ascq == 0)
- {
- if (m_audio_sense == SCSI_SENSE_ASC_ASCQ_AUDIO_PLAY_OPERATION_IN_PROGRESS && !m_cdda->audio_active())
- {
- m_audio_sense = SCSI_SENSE_ASC_ASCQ_AUDIO_PLAY_OPERATION_SUCCESSFULLY_COMPLETED;
- }
-
- set_sense(SCSI_SENSE_KEY_NO_SENSE, (sense_asc_ascq_t) m_audio_sense);
-
- if (m_audio_sense != SCSI_SENSE_ASC_ASCQ_AUDIO_PLAY_OPERATION_IN_PROGRESS)
- {
- m_audio_sense = SCSI_SENSE_ASC_ASCQ_NO_SENSE;
- }
- }
-
- switch ( command[0] )
- {
- case T10SPC_CMD_INQUIRY:
- logerror("T10MMC: INQUIRY\n");
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = SCSILengthFromUINT8( &command[ 4 ] );
- if (m_transfer_length > 36)
- m_transfer_length = 36;
- break;
-
- case T10SPC_CMD_MODE_SELECT_6:
- logerror("T10MMC: MODE SELECT(6) length %x control %x\n", command[4], command[5]);
- m_phase = SCSI_PHASE_DATAOUT;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = SCSILengthFromUINT8( &command[ 4 ] );
- break;
-
- case T10SPC_CMD_MODE_SENSE_6:
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = SCSILengthFromUINT8( &command[ 4 ] );
- break;
-
- case T10SPC_CMD_START_STOP_UNIT:
- abort_audio();
- m_phase = SCSI_PHASE_STATUS;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 0;
- break;
-
- case T10SPC_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
- m_phase = SCSI_PHASE_STATUS;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 0;
- break;
-
- case T10SBC_CMD_READ_CAPACITY:
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 8;
- break;
-
- case T10SBC_CMD_READ_10:
- m_lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
- m_blocks = SCSILengthFromUINT16( &command[7] );
-
- logerror("T10MMC: READ(10) at LBA %x for %d blocks (%d bytes)\n", m_lba, m_blocks, m_blocks * m_sector_bytes);
-
- if (m_num_subblocks > 1)
- {
- m_cur_subblock = m_lba % m_num_subblocks;
- m_lba /= m_num_subblocks;
- }
- else
- {
- m_cur_subblock = 0;
- }
-
- abort_audio();
-
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = m_blocks * m_sector_bytes;
- break;
-
- case T10MMC_CMD_READ_SUB_CHANNEL:
- //logerror("T10MMC: READ SUB-CHANNEL type %d\n", command[3]);
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = SCSILengthFromUINT16( &command[ 7 ] );
- break;
-
- case T10MMC_CMD_READ_TOC_PMA_ATIP:
- {
- int length;
-
- switch (toc_format())
- {
- case TOC_FORMAT_TRACKS:
- length = 4 + (8 * toc_tracks());
- break;
-
- case TOC_FORMAT_SESSIONS:
- length = 4 + (8 * 1);
- break;
-
- default:
- logerror("T10MMC: Unhandled READ TOC format %d\n", toc_format());
- length = 0;
- break;
- }
-
- int allocation_length = SCSILengthFromUINT16( &command[ 7 ] );
-
- if( length > allocation_length )
- {
- length = allocation_length;
- }
-
- abort_audio();
-
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = length;
- break;
- }
- case T10MMC_CMD_PLAY_AUDIO_10:
- m_lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
- m_blocks = SCSILengthFromUINT16( &command[7] );
-
- // special cases: lba of 0 means MSF of 00:02:00
- if (m_lba == 0)
- {
- m_lba = 150;
- }
- else if (m_lba == 0xffffffff)
- {
- logerror("T10MMC: play audio from current not implemented!\n");
- }
-
- logerror("T10MMC: PLAY AUDIO(10) at LBA %x for %x blocks\n", m_lba, m_blocks);
-
- trk = cdrom_get_track(m_cdrom, m_lba);
-
- if (cdrom_get_track_type(m_cdrom, trk) == CD_TRACK_AUDIO)
- {
- m_cdda->start_audio(m_lba, m_blocks);
- m_audio_sense = SCSI_SENSE_ASC_ASCQ_AUDIO_PLAY_OPERATION_IN_PROGRESS;
- }
- else
- {
- logerror("T10MMC: track is NOT audio!\n");
- set_sense(SCSI_SENSE_KEY_ILLEGAL_REQUEST, SCSI_SENSE_ASC_ASCQ_ILLEGAL_MODE_FOR_THIS_TRACK);
- }
-
- m_phase = SCSI_PHASE_STATUS;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 0;
- break;
-
- case T10MMC_CMD_PLAY_AUDIO_TRACK_INDEX:
- // be careful: tracks here are zero-based, but the SCSI command
- // uses the real CD track number which is 1-based!
- logerror("T10MMC: PLAY AUDIO T/I: strk %d idx %d etrk %d idx %d frames %d\n", command[4], command[5], command[7], command[8], m_blocks);
- m_lba = cdrom_get_track_start(m_cdrom, command[4]-1);
- m_blocks = cdrom_get_track_start(m_cdrom, command[7]-1) - m_lba;
- if (command[4] > command[7])
- {
- m_blocks = 0;
- }
-
- if (command[4] == command[7])
- {
- m_blocks = cdrom_get_track_start(m_cdrom, command[4]) - m_lba;
- }
-
- trk = cdrom_get_track(m_cdrom, m_lba);
-
- if (cdrom_get_track_type(m_cdrom, trk) == CD_TRACK_AUDIO)
- {
- m_cdda->start_audio(m_lba, m_blocks);
- m_audio_sense = SCSI_SENSE_ASC_ASCQ_AUDIO_PLAY_OPERATION_IN_PROGRESS;
- }
- else
- {
- logerror("T10MMC: track is NOT audio!\n");
- set_sense(SCSI_SENSE_KEY_ILLEGAL_REQUEST, SCSI_SENSE_ASC_ASCQ_ILLEGAL_MODE_FOR_THIS_TRACK);
- }
-
- m_phase = SCSI_PHASE_STATUS;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 0;
- break;
-
- case T10MMC_CMD_PAUSE_RESUME:
- if (m_cdrom)
- {
- m_cdda->pause_audio((command[8] & 0x01) ^ 0x01);
- }
-
- logerror("T10MMC: PAUSE/RESUME: %s\n", command[8]&1 ? "RESUME" : "PAUSE");
- m_phase = SCSI_PHASE_STATUS;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 0;
- break;
-
- case T10MMC_CMD_STOP_PLAY_SCAN:
- abort_audio();
-
- logerror("T10MMC: STOP_PLAY_SCAN\n");
- m_phase = SCSI_PHASE_STATUS;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 0;
- break;
-
- case T10SPC_CMD_MODE_SELECT_10:
- logerror("T10MMC: MODE SELECT length %x control %x\n", command[7]<<8 | command[8], command[1]);
- m_phase = SCSI_PHASE_DATAOUT;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = SCSILengthFromUINT16( &command[ 7 ] );
- break;
-
- case T10SPC_CMD_MODE_SENSE_10:
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = SCSILengthFromUINT16( &command[ 7 ] );
- break;
-
- case T10MMC_CMD_PLAY_AUDIO_12:
- m_lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
- m_blocks = command[6]<<24 | command[7]<<16 | command[8]<<8 | command[9];
-
- // special cases: lba of 0 means MSF of 00:02:00
- if (m_lba == 0)
- {
- m_lba = 150;
- }
- else if (m_lba == 0xffffffff)
- {
- logerror("T10MMC: play audio from current not implemented!\n");
- }
-
- logerror("T10MMC: PLAY AUDIO(12) at LBA %x for %x blocks\n", m_lba, m_blocks);
-
- trk = cdrom_get_track(m_cdrom, m_lba);
-
- if (cdrom_get_track_type(m_cdrom, trk) == CD_TRACK_AUDIO)
- {
- m_cdda->start_audio(m_lba, m_blocks);
- m_audio_sense = SCSI_SENSE_ASC_ASCQ_AUDIO_PLAY_OPERATION_IN_PROGRESS;
- }
- else
- {
- logerror("T10MMC: track is NOT audio!\n");
- set_sense(SCSI_SENSE_KEY_ILLEGAL_REQUEST, SCSI_SENSE_ASC_ASCQ_ILLEGAL_MODE_FOR_THIS_TRACK);
- }
-
- m_phase = SCSI_PHASE_STATUS;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 0;
- break;
-
- case T10SBC_CMD_READ_12:
- m_lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
- m_blocks = command[7]<<16 | command[8]<<8 | command[9];
-
- logerror("T10MMC: READ(12) at LBA %x for %x blocks (%x bytes)\n", m_lba, m_blocks, m_blocks * m_sector_bytes);
-
- if (m_num_subblocks > 1)
- {
- m_cur_subblock = m_lba % m_num_subblocks;
- m_lba /= m_num_subblocks;
- }
- else
- {
- m_cur_subblock = 0;
- }
-
- abort_audio();
-
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = m_blocks * m_sector_bytes;
- break;
-
- case T10MMC_CMD_SET_CD_SPEED:
- logerror("T10MMC: SET CD SPEED to %d kbytes/sec.\n", command[2]<<8 | command[3]);
- m_phase = SCSI_PHASE_STATUS;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 0;
- break;
-
- default:
- t10spc::ExecCommand();
- }
-}
-
-// scsicd_read_data
-//
-// Read data from the device resulting from the execution of a command
-
-void t10mmc::ReadData( UINT8 *data, int dataLength )
-{
- UINT32 temp;
- UINT8 tmp_buffer[2048];
-
- switch ( command[0] )
- {
- case T10SPC_CMD_INQUIRY:
- data[0] = 0x05; // device is present, device is CD/DVD (MMC-3)
- data[1] = 0x80; // media is removable
- data[2] = 0x05; // device complies with SPC-3 standard
- data[3] = 0x02; // response data format = SPC-3 standard
- data[4] = 0x1f;
- data[5] = 0;
- data[6] = 0;
- data[7] = 0;
- memset(&data[8], ' ', 28);
- memcpy(&data[8], "MAME", 4);
- memcpy(&data[16], "Virtual CDROM", 13);
- memcpy(&data[32], "1.0", 3);
- break;
-
- case T10SBC_CMD_READ_CAPACITY:
- logerror("T10MMC: READ CAPACITY\n");
-
- temp = cdrom_get_track_start(m_cdrom, 0xaa);
- temp--; // return the last used block on the disc
-
- data[0] = (temp>>24) & 0xff;
- data[1] = (temp>>16) & 0xff;
- data[2] = (temp>>8) & 0xff;
- data[3] = (temp & 0xff);
- data[4] = 0;
- data[5] = 0;
- data[6] = (m_sector_bytes>>8)&0xff;
- data[7] = (m_sector_bytes & 0xff);
- break;
-
- case T10SBC_CMD_READ_10:
- case T10SBC_CMD_READ_12:
- logerror("T10MMC: read %x dataLength, \n", dataLength);
- if ((m_cdrom) && (m_blocks))
- {
- while (dataLength > 0)
- {
- if (!cdrom_read_data(m_cdrom, m_lba, tmp_buffer, CD_TRACK_MODE1))
- {
- logerror("T10MMC: CD read error!\n");
- }
-
- logerror("True LBA: %d, buffer half: %d\n", m_lba, m_cur_subblock * m_sector_bytes);
-
- memcpy(data, &tmp_buffer[m_cur_subblock * m_sector_bytes], m_sector_bytes);
-
- m_cur_subblock++;
- if (m_cur_subblock >= m_num_subblocks)
- {
- m_cur_subblock = 0;
-
- m_lba++;
- m_blocks--;
- }
-
- m_last_lba = m_lba;
- dataLength -= m_sector_bytes;
- data += m_sector_bytes;
- }
- }
- break;
-
- case T10MMC_CMD_READ_SUB_CHANNEL:
- switch (command[3])
- {
- case 1: // return current position
- {
- if (!m_cdrom)
- {
- return;
- }
-
- logerror("T10MMC: READ SUB-CHANNEL Time = %x, SUBQ = %x\n", command[1], command[2]);
-
- bool msf = (command[1] & 0x2) != 0;
-
- data[0]= 0x00;
-
- int audio_active = m_cdda->audio_active();
- if (audio_active)
- {
- // if audio is playing, get the latest LBA from the CDROM layer
- m_last_lba = m_cdda->get_audio_lba();
- if (m_cdda->audio_paused())
- {
- data[1] = 0x12; // audio is paused
- }
- else
- {
- data[1] = 0x11; // audio in progress
- }
- }
- else
- {
- m_last_lba = 0;
- if (m_cdda->audio_ended())
- {
- data[1] = 0x13; // ended successfully
- }
- else
- {
-// data[1] = 0x14; // stopped due to error
- data[1] = 0x15; // No current audio status to return
- }
- }
-
- if (command[2] & 0x40)
- {
- data[2] = 0;
- data[3] = 12; // data length
- data[4] = 0x01; // sub-channel format code
- data[5] = 0x10 | (audio_active ? 0 : 4);
- data[6] = cdrom_get_track(m_cdrom, m_last_lba) + 1; // track
- data[7] = 0; // index
-
- UINT32 frame = m_last_lba;
-
- if (msf)
- {
- frame = to_msf(frame);
- }
-
- data[8] = (frame>>24)&0xff;
- data[9] = (frame>>16)&0xff;
- data[10] = (frame>>8)&0xff;
- data[11] = frame&0xff;
-
- frame -= cdrom_get_track_start(m_cdrom, data[6] - 1);
-
- if (msf)
- {
- frame = to_msf(frame);
- }
-
- data[12] = (frame>>24)&0xff;
- data[13] = (frame>>16)&0xff;
- data[14] = (frame>>8)&0xff;
- data[15] = frame&0xff;
- }
- else
- {
- data[2] = 0;
- data[3] = 0;
- }
- break;
- }
- default:
- logerror("T10MMC: Unknown subchannel type %d requested\n", command[3]);
- }
- break;
-
- case T10MMC_CMD_READ_TOC_PMA_ATIP:
- /*
- Track numbers are problematic here: 0 = lead-in, 0xaa = lead-out.
- That makes sense in terms of how real-world CDs are referred to, but
- our internal routines for tracks use "0" as track 1. That probably
- should be fixed...
- */
- {
- bool msf = (command[1] & 0x2) != 0;
-
- logerror("T10MMC: READ TOC, format = %d time=%d\n", toc_format(),msf);
- switch (toc_format())
- {
- case TOC_FORMAT_TRACKS:
- {
- int tracks = toc_tracks();
- int len = 2 + (tracks * 8);
-
- // the returned TOC DATA LENGTH must be the full amount,
- // regardless of how much we're able to pass back due to in_len
- int dptr = 0;
- data[dptr++] = (len>>8) & 0xff;
- data[dptr++] = (len & 0xff);
- data[dptr++] = 1;
- data[dptr++] = cdrom_get_last_track(m_cdrom);
-
- int first_track = command[6];
- if (first_track == 0)
- {
- first_track = 1;
- }
-
- for (int i = 0; i < tracks; i++)
- {
- int track = first_track + i;
- int cdrom_track = track - 1;
- if( i == tracks - 1 )
- {
- track = 0xaa;
- cdrom_track = 0xaa;
- }
-
- if( dptr >= dataLength )
- {
- break;
- }
-
- data[dptr++] = 0;
- data[dptr++] = cdrom_get_adr_control(m_cdrom, cdrom_track);
- data[dptr++] = track;
- data[dptr++] = 0;
-
- UINT32 tstart = cdrom_get_track_start(m_cdrom, cdrom_track);
-
- if (msf)
- {
- tstart = to_msf(tstart+150);
- }
-
- data[dptr++] = (tstart>>24) & 0xff;
- data[dptr++] = (tstart>>16) & 0xff;
- data[dptr++] = (tstart>>8) & 0xff;
- data[dptr++] = (tstart & 0xff);
- }
- }
- break;
-
- case TOC_FORMAT_SESSIONS:
- {
- int len = 2 + (8 * 1);
-
- int dptr = 0;
- data[dptr++] = (len>>8) & 0xff;
- data[dptr++] = (len & 0xff);
- data[dptr++] = 1;
- data[dptr++] = 1;
-
- data[dptr++] = 0;
- data[dptr++] = cdrom_get_adr_control(m_cdrom, 0);
- data[dptr++] = 1;
- data[dptr++] = 0;
-
- UINT32 tstart = cdrom_get_track_start(m_cdrom, 0);
-
- if (msf)
- {
- tstart = to_msf(tstart+150);
- }
-
- data[dptr++] = (tstart>>24) & 0xff;
- data[dptr++] = (tstart>>16) & 0xff;
- data[dptr++] = (tstart>>8) & 0xff;
- data[dptr++] = (tstart & 0xff);
- }
- break;
-
- default:
- logerror("T10MMC: Unhandled READ TOC format %d\n", toc_format());
- break;
- }
- }
- break;
-
- case T10SPC_CMD_MODE_SENSE_6:
- case T10SPC_CMD_MODE_SENSE_10:
- logerror("T10MMC: MODE SENSE page code = %x, PC = %x\n", command[2] & 0x3f, (command[2]&0xc0)>>6);
-
- memset(data, 0, SCSILengthFromUINT16( &command[ 7 ] ));
-
- switch (command[2] & 0x3f)
- {
- case 0xe: // CD Audio control page
- data[0] = 0x8e; // page E, parameter is savable
- data[1] = 0x0e; // page length
- data[2] = 0x04; // IMMED = 1, SOTC = 0
- data[3] = data[4] = data[5] = data[6] = data[7] = 0; // reserved
-
- // connect each audio channel to 1 output port
- data[8] = 1;
- data[10] = 2;
- data[12] = 4;
- data[14] = 8;
-
- // indicate max volume
- data[9] = data[11] = data[13] = data[15] = 0xff;
- break;
- case 0x2a: // Page capabilities
- data[0] = 0x2a;
- data[1] = 0x14; // page length
- data[2] = 0x00; data[3] = 0x00; // CD-R only
- data[4] = 0x01; // can play audio
- data[5] = 0;
- data[6] = 0;
- data[7] = 0;
- data[8] = 0x02; data[9] = 0xc0; // 4x speed
- data[10] = 0;
- data[11] = 2; // two volumen levels
- data[12] = 0x00; data[13] = 0x00; // buffer
- data[14] = 0x02; data[15] = 0xc0; // 4x read speed
- data[16] = 0;
- data[17] = 0;
- data[18] = 0;
- data[19] = 0;
- data[20] = 0;
- data[21] = 0;
- break;
-
- default:
- logerror("T10MMC: MODE SENSE unknown page %x\n", command[2] & 0x3f);
- break;
- }
- break;
-
- default:
- t10spc::ReadData( data, dataLength );
- break;
- }
-}
-
-// scsicd_write_data
-//
-// Write data to the CD-ROM device as part of the execution of a command
-
-void t10mmc::WriteData( UINT8 *data, int dataLength )
-{
- switch (command[ 0 ])
- {
- case T10SPC_CMD_MODE_SELECT_6:
- case T10SPC_CMD_MODE_SELECT_10:
- logerror("T10MMC: MODE SELECT page %x\n", data[0] & 0x3f);
-
- switch (data[0] & 0x3f)
- {
- case 0x0: // vendor-specific
- // check for SGI extension to force 512-byte blocks
- if ((data[3] == 8) && (data[10] == 2))
- {
- logerror("T10MMC: Experimental SGI 512-byte block extension enabled\n");
-
- m_sector_bytes = 512;
- m_num_subblocks = 4;
- }
- else
- {
- logerror("T10MMC: Unknown vendor-specific page!\n");
- }
- break;
-
- case 0xe: // audio page
- logerror("Ch 0 route: %x vol: %x\n", data[8], data[9]);
- logerror("Ch 1 route: %x vol: %x\n", data[10], data[11]);
- logerror("Ch 2 route: %x vol: %x\n", data[12], data[13]);
- logerror("Ch 3 route: %x vol: %x\n", data[14], data[15]);
- break;
- }
- break;
-
- default:
- t10spc::WriteData( data, dataLength );
- break;
-}
-}
-
-void t10mmc::GetDevice( void **_cdrom )
-{
- *(cdrom_file **)_cdrom = m_cdrom;
-}
-
-void t10mmc::SetDevice( void *_cdrom )
-{
- m_cdrom = (cdrom_file *)_cdrom;
- m_cdda->set_cdrom(m_cdrom);
-}
diff --git a/src/emu/machine/t10mmc.h b/src/emu/machine/t10mmc.h
deleted file mode 100644
index cfebfc1694c..00000000000
--- a/src/emu/machine/t10mmc.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
-t10mmc.h
-
-***************************************************************************/
-
-#ifndef _T10MMC_H_
-#define _T10MMC_H_
-
-#include "t10spc.h"
-#include "imagedev/chd_cd.h"
-#include "sound/cdda.h"
-
-class t10mmc : public virtual t10spc
-{
-public:
- virtual void SetDevice( void *device );
- virtual void GetDevice( void **device );
- virtual void ExecCommand();
- virtual void WriteData( UINT8 *data, int dataLength );
- virtual void ReadData( UINT8 *data, int dataLength );
-
-protected:
- virtual void t10_start(device_t &device);
- virtual void t10_reset();
-
- enum
- {
- T10MMC_CMD_READ_SUB_CHANNEL = 0x42,
- T10MMC_CMD_READ_TOC_PMA_ATIP = 0x43,
- T10MMC_CMD_PLAY_AUDIO_10 = 0x45,
- T10MMC_CMD_PLAY_AUDIO_TRACK_INDEX = 0x48,
- T10MMC_CMD_PAUSE_RESUME = 0x4b,
- T10MMC_CMD_STOP_PLAY_SCAN = 0x4e,
- T10MMC_CMD_PLAY_AUDIO_12 = 0xa5,
- T10MMC_CMD_SET_CD_SPEED = 0xbb
- };
-
- enum toc_format_t
- {
- TOC_FORMAT_TRACKS = 0,
- TOC_FORMAT_SESSIONS = 1
- };
-
- void abort_audio();
- toc_format_t toc_format();
- int toc_tracks();
-
- cdrom_image_device *m_image;
- cdda_device *m_cdda;
- cdrom_file *m_cdrom;
-
- UINT32 m_lba;
- UINT32 m_blocks;
- UINT32 m_last_lba;
- UINT32 m_num_subblocks;
- UINT32 m_cur_subblock;
- int m_audio_sense;
-};
-
-#endif
diff --git a/src/emu/machine/t10sbc.c b/src/emu/machine/t10sbc.c
deleted file mode 100644
index c5d68be8162..00000000000
--- a/src/emu/machine/t10sbc.c
+++ /dev/null
@@ -1,268 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "t10sbc.h"
-
-void t10sbc::t10_start(device_t &device)
-{
- t10spc::t10_start(device);
-
- device.save_item( NAME( m_lba ) );
- device.save_item( NAME( m_blocks ) );
-}
-
-void t10sbc::t10_reset()
-{
- t10spc::t10_reset();
-
- m_lba = 0;
- m_blocks = 0;
- m_sector_bytes = 512;
-
- m_disk = m_image->get_hard_disk_file();
- if (!m_disk)
- {
- logerror("T10SBC %s: no HD found!\n", m_image->owner()->tag());
- }
- else
- {
- // get hard disk sector size from CHD metadata
- const hard_disk_info *hdinfo = hard_disk_get_info(m_disk);
- m_sector_bytes = hdinfo->sectorbytes;
- }
-}
-
-// scsihd_exec_command
-void t10sbc::ExecCommand()
-{
- switch ( command[0] )
- {
- case T10SBC_CMD_FORMAT_UNIT:
- m_phase = SCSI_PHASE_STATUS;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 0;
- break;
-
- case T10SBC_CMD_SEEK_6:
- m_lba = (command[1]&0x1f)<<16 | command[2]<<8 | command[3];
-
- logerror("S1410: SEEK to LBA %x\n", m_lba);
-
- m_phase = SCSI_PHASE_STATUS;
- m_transfer_length = 0;
- break;
-
- case T10SBC_CMD_READ_6:
- m_lba = (command[1]&0x1f)<<16 | command[2]<<8 | command[3];
- m_blocks = SCSILengthFromUINT8( &command[4] );
-
- logerror("T10SBC: READ at LBA %x for %x blocks\n", m_lba, m_blocks);
-
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = m_blocks * m_sector_bytes;
- break;
-
- case T10SBC_CMD_WRITE_6:
- m_lba = (command[1]&0x1f)<<16 | command[2]<<8 | command[3];
- m_blocks = SCSILengthFromUINT8( &command[4] );
-
- logerror("T10SBC: WRITE to LBA %x for %x blocks\n", m_lba, m_blocks);
-
- m_phase = SCSI_PHASE_DATAOUT;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = m_blocks * m_sector_bytes;
- break;
-
- case T10SPC_CMD_INQUIRY:
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = SCSILengthFromUINT8( &command[ 4 ] );
- break;
-
- case T10SPC_CMD_MODE_SELECT_6:
- logerror("T10SBC: MODE SELECT length %x control %x\n", command[4], command[5]);
- m_phase = SCSI_PHASE_DATAOUT;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = SCSILengthFromUINT8( &command[ 4 ] );
- break;
-
- case T10SPC_CMD_MODE_SENSE_6:
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = SCSILengthFromUINT8( &command[ 4 ] );
- break;
-
- case T10SBC_CMD_READ_CAPACITY:
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 8;
- break;
-
- case T10SBC_CMD_READ_10:
- m_lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
- m_blocks = SCSILengthFromUINT16( &command[7] );
-
- logerror("T10SBC: READ at LBA %x for %x blocks\n", m_lba, m_blocks);
-
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = m_blocks * m_sector_bytes;
- break;
-
- case T10SBC_CMD_WRITE_10:
- m_lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
- m_blocks = SCSILengthFromUINT16( &command[7] );
-
- logerror("T10SBC: WRITE to LBA %x for %x blocks\n", m_lba, m_blocks);
-
- m_phase = SCSI_PHASE_DATAOUT;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = m_blocks * m_sector_bytes;
- break;
-
- case T10SBC_CMD_READ_12:
- m_lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
- m_blocks = command[6]<<24 | command[7]<<16 | command[8]<<8 | command[9];
-
- logerror("T10SBC: READ at LBA %x for %x blocks\n", m_lba, m_blocks);
-
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = m_blocks * m_sector_bytes;
- break;
-
- default:
- t10spc::ExecCommand();
- break;
- }
-}
-
-void t10sbc::ReadData( UINT8 *data, int dataLength )
-{
- // if we're a drive without a disk, return all zeroes
- if (!m_disk)
- {
- memset(data, 0, dataLength);
- return;
- }
-
- switch ( command[0] )
- {
- case T10SPC_CMD_INQUIRY:
- memset( data, 0, dataLength );
- data[0] = 0x00; // device is direct-access (e.g. hard disk)
- data[1] = 0x00; // media is not removable
- data[2] = 0x05; // device complies with SPC-3 standard
- data[3] = 0x02; // response data format = SPC-3 standard
- // Apple HD SC setup utility needs to see this
- strcpy((char *)&data[8], " SEAGATE");
- strcpy((char *)&data[16], " ST225N");
- strcpy((char *)&data[32], "1.0");
- break;
-
- case T10SPC_CMD_MODE_SENSE_6:
- // special Apple ID page. this is a vendor-specific page,
- // so unless collisions occur there should be no need
- // to change it.
- if ((command[2] & 0x3f) == 0x30)
- {
- memset(data, 0, 40);
- data[0] = 0x14;
- strcpy((char *)&data[14], "APPLE COMPUTER, INC.");
- }
- break;
-
- case T10SBC_CMD_READ_6:
- case T10SBC_CMD_READ_10:
- case T10SBC_CMD_READ_12:
- if ((m_disk) && (m_blocks))
- {
- while (dataLength > 0)
- {
- if (!hard_disk_read(m_disk, m_lba, data))
- {
- logerror("T10SBC: HD read error!\n");
- }
- m_lba++;
- m_blocks--;
- dataLength -= m_sector_bytes;
- data += m_sector_bytes;
- }
- }
- break;
-
- case T10SBC_CMD_READ_CAPACITY: // READ CAPACITY
- {
- hard_disk_info *info;
- UINT32 temp;
-
- info = hard_disk_get_info(m_disk);
-
- logerror("T10SBC: READ CAPACITY\n");
-
- // get # of sectors
- temp = info->cylinders * info->heads * info->sectors;
- temp--;
-
- data[0] = (temp>>24) & 0xff;
- data[1] = (temp>>16) & 0xff;
- data[2] = (temp>>8) & 0xff;
- data[3] = (temp & 0xff);
- data[4] = (info->sectorbytes>>24)&0xff;
- data[5] = (info->sectorbytes>>16)&0xff;
- data[6] = (info->sectorbytes>>8)&0xff;
- data[7] = (info->sectorbytes & 0xff);
- }
- break;
-
- default:
- t10spc::ReadData( data, dataLength );
- break;
- }
-}
-
-void t10sbc::WriteData( UINT8 *data, int dataLength )
-{
- if (!m_disk)
- {
- return;
- }
-
- switch ( command[0] )
- {
- case T10SPC_CMD_MODE_SELECT_6:
- break;
-
- case T10SBC_CMD_WRITE_6:
- case T10SBC_CMD_WRITE_10:
- if ((m_disk) && (m_blocks))
- {
- while (dataLength > 0)
- {
- if (!hard_disk_write(m_disk, m_lba, data))
- {
- logerror("T10SBC: HD write error!\n");
- }
- m_lba++;
- m_blocks--;
- dataLength -= m_sector_bytes;
- data += m_sector_bytes;
- }
- }
- break;
-
- default:
- t10spc::WriteData( data, dataLength );
- break;
- }
-}
-
-void t10sbc::GetDevice( void **_disk )
-{
- *(hard_disk_file **)_disk = m_disk;
-}
-
-void t10sbc::SetDevice( void *_disk )
-{
- m_disk = (hard_disk_file *)_disk;
-}
diff --git a/src/emu/machine/t10sbc.h b/src/emu/machine/t10sbc.h
deleted file mode 100644
index d32c0beee57..00000000000
--- a/src/emu/machine/t10sbc.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
-t10sbc.h
-
-***************************************************************************/
-
-#ifndef _T10SBC_H_
-#define _T10SBC_H_
-
-#include "t10spc.h"
-#include "imagedev/harddriv.h"
-
-class t10sbc : public virtual t10spc
-{
-public:
- virtual void SetDevice( void *device );
- virtual void GetDevice( void **device );
- virtual void ExecCommand();
- virtual void WriteData( UINT8 *data, int dataLength );
- virtual void ReadData( UINT8 *data, int dataLength );
-
-protected:
- virtual void t10_start(device_t &device);
- virtual void t10_reset();
-
- harddisk_image_device *m_image;
-
- UINT32 m_lba;
- UINT32 m_blocks;
-
- hard_disk_file *m_disk;
-};
-
-#endif
diff --git a/src/emu/machine/t10spc.c b/src/emu/machine/t10spc.c
deleted file mode 100644
index 80b279efb44..00000000000
--- a/src/emu/machine/t10spc.c
+++ /dev/null
@@ -1,150 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "t10spc.h"
-
-void t10spc::t10_start(device_t &device)
-{
- device.save_item(NAME(command));
- device.save_item(NAME(commandLength));
- device.save_item(NAME(m_transfer_length));
- device.save_item(NAME(m_phase));
- device.save_item(NAME(m_sense_key));
- device.save_item(NAME(m_sense_asc));
- device.save_item(NAME(m_sense_ascq));
- device.save_item(NAME(m_sense_information));
-}
-
-void t10spc::t10_reset()
-{
- m_phase = SCSI_PHASE_BUS_FREE;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_sense_key = 0;
- m_sense_asc = 0;
- m_sense_ascq = 0;
- m_sense_information = 0;
-}
-
-void t10spc::set_sense(sense_key_t key, sense_asc_ascq_t asc_ascq)
-{
- m_sense_key = key;
- m_sense_asc = (asc_ascq >> 8) & 0xff;
- m_sense_ascq = asc_ascq & 0xff;
- m_sense_information = 0;
-}
-
-void t10spc::ExecCommand()
-{
- switch( command[ 0 ] )
- {
- case T10SPC_CMD_TEST_UNIT_READY:
- m_phase = SCSI_PHASE_STATUS;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 0;
- break;
-
- case T10SPC_CMD_RECALIBRATE:
- m_phase = SCSI_PHASE_STATUS;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 0;
- break;
-
- case T10SPC_CMD_REQUEST_SENSE:
- m_phase = SCSI_PHASE_DATAIN;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- if (command[4] == 0)
- {
- m_transfer_length = 4;
- }
- else if (command[4] > 18)
- {
- m_transfer_length = 18;
- }
- else
- {
- m_transfer_length = command[ 4 ];
- }
- break;
-
- case T10SPC_CMD_SEND_DIAGNOSTIC:
- m_phase = SCSI_PHASE_DATAOUT;
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = SCSILengthFromUINT16(&command[3]);
- break;
-
- default:
- logerror( "SCSIDEV unknown command %02x\n", command[ 0 ] );
- m_status_code = SCSI_STATUS_CODE_GOOD;
- m_transfer_length = 0;
- break;
- }
-}
-
-void t10spc::ReadData( UINT8 *data, int dataLength )
-{
- switch( command[ 0 ] )
- {
- case T10SPC_CMD_REQUEST_SENSE:
- if (command[4] == 0)
- {
- data[0] = m_sense_asc & 0x7f;
- data[1] = (m_sense_information >> 16) & 0x1f;
- data[2] = (m_sense_information >> 8) & 0xff;
- data[3] = (m_sense_information >> 0) & 0xff;
- }
- else
- {
- data[0] = 0x70;
- data[1] = 0;
- data[2] = m_sense_key & 0xf;
- data[3] = (m_sense_information >> 24) & 0xff;
- data[4] = (m_sense_information >> 16) & 0xff;
- data[5] = (m_sense_information >> 8) & 0xff;
- data[6] = (m_sense_information >> 0) & 0xff;
- data[7] = 10;
- data[8] = 0;
- data[9] = 0;
- data[10] = 0;
- data[11] = 0;
- data[12] = m_sense_asc;
- data[13] = m_sense_ascq;
- data[14] = 0;
- data[15] = 0;
- data[16] = 0;
- data[17] = 0;
- }
-
- set_sense(SCSI_SENSE_KEY_NO_SENSE, SCSI_SENSE_ASC_ASCQ_NO_SENSE);
- break;
-
- default:
- logerror( "SCSIDEV unknown read %02x\n", command[ 0 ] );
- break;
- }
-}
-
-void t10spc::WriteData( UINT8 *data, int dataLength )
-{
- switch( command[ 0 ] )
- {
- case T10SPC_CMD_SEND_DIAGNOSTIC:
- break;
-
- default:
- logerror( "SCSIDEV unknown write %02x\n", command[ 0 ] );
- break;
- }
-}
-
-void t10spc::SetCommand( UINT8 *_command, int _commandLength )
-{
- if( _commandLength > sizeof( command ) )
- {
- /// TODO: output an error.
- return;
- }
-
- memcpy( command, _command, _commandLength );
- commandLength = _commandLength;
-
- m_phase = SCSI_PHASE_COMMAND;
-}
diff --git a/src/emu/machine/t10spc.h b/src/emu/machine/t10spc.h
deleted file mode 100644
index 778fd40bce1..00000000000
--- a/src/emu/machine/t10spc.h
+++ /dev/null
@@ -1,136 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
-t10spc.h
-
-***************************************************************************/
-
-#ifndef _T10SPC_H_
-#define _T10SPC_H_
-
-#include "emu.h"
-
-class t10spc
-{
-public:
- virtual ~t10spc() {};
- virtual void SetDevice( void *device ) = 0;
- virtual void GetDevice( void **device ) = 0;
-
- virtual void SetCommand( UINT8 *command, int commandLength );
- virtual void ExecCommand();
- virtual void WriteData( UINT8 *data, int dataLength );
- virtual void ReadData( UINT8 *data, int dataLength );
- void GetLength( int *transferLength ) { *transferLength = m_transfer_length; }
- virtual void GetPhase( int *phase ) { *phase = m_phase; }
-
-protected:
- virtual void t10_start(device_t &device);
- virtual void t10_reset();
-
- int SCSILengthFromUINT8( UINT8 *length ) { if( *length == 0 ) { return 256; } return *length; }
- int SCSILengthFromUINT16( UINT8 *length ) { return ( *(length) << 8 ) | *(length + 1 ); }
-
- enum sense_key_t
- {
- SCSI_SENSE_KEY_NO_SENSE = 0,
- SCSI_SENSE_KEY_ILLEGAL_REQUEST = 5
- };
-
- enum sense_asc_ascq_t
- {
- SCSI_SENSE_ASC_ASCQ_NO_SENSE = 0x0,
- SCSI_SENSE_ASC_ASCQ_AUDIO_PLAY_OPERATION_IN_PROGRESS = 0x0011,
- SCSI_SENSE_ASC_ASCQ_AUDIO_PLAY_OPERATION_PAUSED = 0x0012,
- SCSI_SENSE_ASC_ASCQ_AUDIO_PLAY_OPERATION_SUCCESSFULLY_COMPLETED = 0x0013,
- SCSI_SENSE_ASC_ASCQ_AUDIO_PLAY_OPERATION_STOPPED_DUE_TO_ERROR = 0x0014,
- SCSI_SENSE_ASC_ASCQ_ILLEGAL_MODE_FOR_THIS_TRACK = 0x6400
- };
-
- enum status_code_t
- {
- SCSI_STATUS_CODE_GOOD = 0x00,
- SCSI_STATUS_CODE_CHECK_CONDITION = 0x02,
- SCSI_STATUS_CODE_CONDITION_MET = 0x04,
- SCSI_STATUS_CODE_BUSY = 0x08,
- SCSI_STATUS_CODE_INTERMEDIATE = 0x14,
- SCSI_STATUS_CODE_RESERVATION_CONFLICT = 0x18,
- SCSI_STATUS_CODE_COMMAND_TERMINATED = 0x22,
- SCSI_STATUS_CODE_TASK_SET_FULL = 0x28,
- SCSI_STATUS_CODE_ACA_ACTIVE = 0x30,
- SCSI_STATUS_CODE_TASK_ABORTED = 0x40
- };
-
- // these are defined here because t10mmc also needs them.
- enum
- {
- T10SBC_CMD_FORMAT_UNIT = 0x04,
- T10SBC_CMD_READ_6 = 0x08,
- T10SBC_CMD_WRITE_6 = 0x0a,
- T10SBC_CMD_SEEK_6 = 0x0b,
- T10SBC_CMD_READ_10 = 0x28,
- T10SBC_CMD_READ_CAPACITY = 0x25,
- T10SBC_CMD_WRITE_10 = 0x2a,
- T10SBC_CMD_SEEK_10 = 0x2b,
- T10SBC_CMD_READ_12 = 0xa8
- };
-
- enum
- {
- T10SPC_CMD_TEST_UNIT_READY = 0x00,
- T10SPC_CMD_RECALIBRATE = 0x01,
- T10SPC_CMD_REQUEST_SENSE = 0x03,
- T10SPC_CMD_INQUIRY = 0x12,
- T10SPC_CMD_MODE_SELECT_6 = 0x15,
- T10SPC_CMD_RESERVE_6 = 0x16,
- T10SPC_CMD_RELEASE_6 = 0x17,
- T10SPC_CMD_MODE_SENSE_6 = 0x1a,
- T10SPC_CMD_START_STOP_UNIT = 0x1b,
- T10SPC_CMD_RECEIVE_DIAGNOSTIC_RESULTS = 0x1c,
- T10SPC_CMD_SEND_DIAGNOSTIC = 0x1d,
- T10SPC_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1e,
- T10SPC_CMD_WRITE_BUFFER = 0x3b,
- T10SPC_CMD_READ_BUFFER = 0x3c,
- T10SPC_CMD_LOG_SELECT = 0x4c,
- T10SPC_CMD_LOG_SENSE = 0x4d,
- T10SPC_CMD_MODE_SELECT_10 = 0x55,
- T10SPC_CMD_RESERVE_10 = 0x56,
- T10SPC_CMD_RELEASE_10 = 0x57,
- T10SPC_CMD_MODE_SENSE_10 = 0x5a,
- T10SPC_CMD_PERSISTENT_RESERVE_IN = 0x5e,
- T10SPC_CMD_PERSISTENT_RESERVE_OUT = 0x5f,
- T10SPC_CMD_EXTENDED_COPY = 0x83,
- T10SPC_CMD_RECEIVE_COPY_RESULTS = 0x84,
- T10SPC_CMD_REPORT_LUNS = 0xa0,
- T10SPC_CMD_REPORT_DEVICE_IDENTIFIER = 0xa3,
- T10SPC_CMD_SET_DEVICE_IDENTIFIER = 0xa4,
- T10SPC_CMD_MOVE_MEDIUM_ATTACHED = 0xa7,
- T10SPC_CMD_READ_ELEMENT_STATUS_ATTACHED = 0xb4
- };
-
- void set_sense(sense_key_t key, sense_asc_ascq_t asc_ascq);
-
- UINT8 command[ 32 ];
- int commandLength;
- int m_transfer_length;
- int m_phase;
- status_code_t m_status_code;
- UINT8 m_sense_key;
- UINT8 m_sense_asc;
- UINT8 m_sense_ascq;
- UINT32 m_sense_information;
- int m_sector_bytes;
- device_t *m_device;
-};
-
-#define SCSI_PHASE_DATAOUT ( 0 )
-#define SCSI_PHASE_DATAIN ( 1 )
-#define SCSI_PHASE_COMMAND ( 2 )
-#define SCSI_PHASE_STATUS ( 3 )
-#define SCSI_PHASE_MESSAGE_OUT ( 6 )
-#define SCSI_PHASE_MESSAGE_IN ( 7 )
-#define SCSI_PHASE_BUS_FREE ( 8 )
-#define SCSI_PHASE_SELECT ( 9 )
-
-#endif
diff --git a/src/emu/machine/tc009xlvc.c b/src/emu/machine/tc009xlvc.c
deleted file mode 100644
index 5897d555d88..00000000000
--- a/src/emu/machine/tc009xlvc.c
+++ /dev/null
@@ -1,417 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:Angelo Salese
-/***************************************************************************
-
- TC009xLVC device emulation
-
- Written by Angelo Salese, based off Taito L implementation
-
- TODO:
- - non-video stuff needs to be ported there as well
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/tc009xlvc.h"
-
-const device_type TC0091LVC = &device_creator<tc0091lvc_device>;
-
-
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_paletteram_r)
-{
- return m_palette_ram[offset & 0x1ff];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_paletteram_w)
-{
- m_palette_ram[offset & 0x1ff] = data;
-
- {
- UINT8 r,g,b,i;
- UINT16 pal;
-
- pal = (m_palette_ram[offset & ~1]<<0) | (m_palette_ram[offset | 1]<<8);
-
- i = (pal & 0x7000) >> 12;
- b = (pal & 0x0f00) >> 8;
- g = (pal & 0x00f0) >> 4;
- r = (pal & 0x000f) >> 0;
-
- r <<= 1;
- g <<= 1;
- b <<= 1;
-
- /* TODO: correct? */
- b |= ((i & 4) >> 2);
- g |= ((i & 2) >> 1);
- r |= (i & 1);
-
- m_palette->set_pen_color(offset / 2, pal5bit(r), pal5bit(g), pal5bit(b));
- }
-}
-
-READ8_MEMBER(tc0091lvc_device::vregs_r)
-{
- return m_vregs[offset];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::vregs_w)
-{
- if((offset & 0xfc) == 0)
- {
- bg0_tilemap->mark_all_dirty();
- bg1_tilemap->mark_all_dirty();
- }
-
- m_vregs[offset] = data;
-}
-
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_bitmap_r)
-{
- return m_bitmap_ram[offset];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_bitmap_w)
-{
- m_bitmap_ram[offset] = data;
-}
-
-
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_pcg1_r)
-{
- return m_pcg1_ram[offset];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_pcg1_w)
-{
- m_pcg1_ram[offset] = data;
- m_gfxdecode->gfx(m_gfx_index)->mark_dirty((offset+0x4000) / 32);
- tx_tilemap->mark_all_dirty();
-}
-
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_pcg2_r)
-{
- return m_pcg2_ram[offset];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_pcg2_w)
-{
- m_pcg2_ram[offset] = data;
- m_gfxdecode->gfx(m_gfx_index)->mark_dirty((offset+0xc000) / 32);
- tx_tilemap->mark_all_dirty();
-}
-
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_vram0_r)
-{
- return m_vram0[offset];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_vram0_w)
-{
- m_vram0[offset] = data;
- bg0_tilemap->mark_tile_dirty(offset/2);
- m_gfxdecode->gfx(m_gfx_index)->mark_dirty((offset+0x8000) / 32);
- tx_tilemap->mark_all_dirty();
-
-}
-
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_vram1_r)
-{
- return m_vram1[offset];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_vram1_w)
-{
- m_vram1[offset] = data;
- bg1_tilemap->mark_tile_dirty(offset/2);
- m_gfxdecode->gfx(m_gfx_index)->mark_dirty((offset+0x9000) / 32);
- tx_tilemap->mark_all_dirty();
-}
-
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_tvram_r)
-{
- return m_tvram[offset];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_tvram_w)
-{
- m_tvram[offset] = data;
- tx_tilemap->mark_tile_dirty(offset/2);
- m_gfxdecode->gfx(m_gfx_index)->mark_dirty((offset+0xa000) / 32);
- tx_tilemap->mark_all_dirty();
-}
-
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_spr_r)
-{
- return m_sprram[offset];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_spr_w)
-{
- m_sprram[offset] = data;
- m_gfxdecode->gfx(m_gfx_index)->mark_dirty((offset+0xb000) / 32);
- tx_tilemap->mark_all_dirty();
-}
-
-static ADDRESS_MAP_START( tc0091lvc_map8, AS_0, 8, tc0091lvc_device )
- AM_RANGE(0x014000, 0x017fff) AM_READWRITE(tc0091lvc_pcg1_r, tc0091lvc_pcg1_w)
- AM_RANGE(0x018000, 0x018fff) AM_READWRITE(tc0091lvc_vram0_r, tc0091lvc_vram0_w)
- AM_RANGE(0x019000, 0x019fff) AM_READWRITE(tc0091lvc_vram1_r, tc0091lvc_vram1_w)
- AM_RANGE(0x01a000, 0x01afff) AM_READWRITE(tc0091lvc_tvram_r, tc0091lvc_tvram_w)
- AM_RANGE(0x01b000, 0x01bfff) AM_READWRITE(tc0091lvc_spr_r, tc0091lvc_spr_w)
- AM_RANGE(0x01c000, 0x01ffff) AM_READWRITE(tc0091lvc_pcg2_r, tc0091lvc_pcg2_w)
- AM_RANGE(0x040000, 0x05ffff) AM_READWRITE(tc0091lvc_bitmap_r, tc0091lvc_bitmap_w)
- AM_RANGE(0x080000, 0x0801ff) AM_READWRITE(tc0091lvc_paletteram_r,tc0091lvc_paletteram_w)
-ADDRESS_MAP_END
-
-tc0091lvc_device::tc0091lvc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, TC0091LVC, "Taito TC0091LVC", tag, owner, clock, "tc0091lvc", __FILE__),
- device_memory_interface(mconfig, *this),
- m_space_config("tc0091lvc", ENDIANNESS_LITTLE, 8,20, 0, NULL, *ADDRESS_MAP_NAME(tc0091lvc_map8)),
- m_gfxdecode(*this),
- m_palette(*this)
-{
-}
-
-//-------------------------------------------------
-// static_set_gfxdecode_tag: Set the tag of the
-// gfx decoder
-//-------------------------------------------------
-
-void tc0091lvc_device::static_set_gfxdecode_tag(device_t &device, const char *tag)
-{
- downcast<tc0091lvc_device &>(device).m_gfxdecode.set_tag(tag);
-}
-
-
-//-------------------------------------------------
-// static_set_palette_tag: Set the tag of the
-// palette device
-//-------------------------------------------------
-
-void tc0091lvc_device::static_set_palette_tag(device_t &device, const char *tag)
-{
- downcast<tc0091lvc_device &>(device).m_palette.set_tag(tag);
-}
-
-
-void tc0091lvc_device::device_config_complete()
-{
-// int address_bits = 20;
-
-// m_space_config = address_space_config("janshi_vdp", ENDIANNESS_LITTLE, 8, address_bits, 0, *ADDRESS_MAP_NAME(tc0091lvc_map8));
-}
-
-void tc0091lvc_device::device_validity_check(validity_checker &valid) const
-{
-}
-
-TILE_GET_INFO_MEMBER(tc0091lvc_device::get_bg0_tile_info)
-{
- int attr = m_vram0[2 * tile_index + 1];
- int code = m_vram0[2 * tile_index]
- | ((attr & 0x03) << 8)
- | ((m_vregs[(attr & 0xc) >> 2]) << 10);
-// | (state->m_horshoes_gfxbank << 12);
-
- SET_TILE_INFO_MEMBER(0,
- code,
- (attr & 0xf0) >> 4,
- 0);
-}
-
-TILE_GET_INFO_MEMBER(tc0091lvc_device::get_bg1_tile_info)
-{
- int attr = m_vram1[2 * tile_index + 1];
- int code = m_vram1[2 * tile_index]
- | ((attr & 0x03) << 8)
- | ((m_vregs[(attr & 0xc) >> 2]) << 10);
-// | (state->m_horshoes_gfxbank << 12);
-
- SET_TILE_INFO_MEMBER(0,
- code,
- (attr & 0xf0) >> 4,
- 0);
-}
-
-TILE_GET_INFO_MEMBER(tc0091lvc_device::get_tx_tile_info)
-{
- int attr = m_tvram[2 * tile_index + 1];
- UINT16 code = m_tvram[2 * tile_index]
- | ((attr & 0x07) << 8);
-
- SET_TILE_INFO_MEMBER(m_gfx_index,
- code,
- (attr & 0xf0) >> 4,
- 0);
-}
-
-
-static const gfx_layout char_layout =
-{
- 8, 8,
- 0x10000 / (8 * 4), // need to specify exact number because we create dynamically
- 4,
- { 8, 12, 0, 4 },
- { 3, 2, 1, 0, 19, 18, 17, 16},
- { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
- 8*8*4
-};
-
-
-void tc0091lvc_device::device_start()
-{
- if(!m_gfxdecode->started())
- throw device_missing_dependencies();
-
- memset(m_palette_ram, 0, sizeof(m_palette_ram));
- memset(m_vregs, 0, sizeof(m_palette_ram));
- memset(m_bitmap_ram, 0, sizeof(m_palette_ram));
- memset(m_pcg_ram, 0, sizeof(m_pcg_ram));
- memset(m_sprram_buffer, 0, sizeof(m_sprram_buffer));
-
- // note, the way tiles are addressed suggests that 0x0000-0x3fff of this might be usable,
- // but we don't map it anywhere, so the first tiles are always blank at the moment.
- m_pcg1_ram = m_pcg_ram + 0x4000;
- m_pcg2_ram = m_pcg_ram + 0xc000;
- m_vram0 = m_pcg_ram + 0x8000;
- m_vram1 = m_pcg_ram + 0x9000;
- m_tvram = m_pcg_ram + 0xa000;
- m_sprram = m_pcg_ram + 0xb000;
-
- tx_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(tc0091lvc_device::get_tx_tile_info),this),TILEMAP_SCAN_ROWS,8,8,64,32);
- bg0_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(tc0091lvc_device::get_bg0_tile_info),this),TILEMAP_SCAN_ROWS,8,8,64,32);
- bg1_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(tc0091lvc_device::get_bg1_tile_info),this),TILEMAP_SCAN_ROWS,8,8,64,32);
-
- tx_tilemap->set_transparent_pen(0);
- bg0_tilemap->set_transparent_pen(0);
- bg1_tilemap->set_transparent_pen(0);
-
- tx_tilemap->set_scrolldx(-8, -8);
- bg0_tilemap->set_scrolldx(28, -11);
- bg1_tilemap->set_scrolldx(38, -21);
-
- for (m_gfx_index = 0; m_gfx_index < MAX_GFX_ELEMENTS; m_gfx_index++)
- if (m_gfxdecode->gfx(m_gfx_index) == 0)
- break;
-
- //printf("m_gfx_index %d\n", m_gfx_index);
-
- m_gfxdecode->set_gfx(m_gfx_index, global_alloc(gfx_element(m_palette, char_layout, (UINT8 *)m_pcg_ram, 0, m_palette->entries() / 16, 0)));
-}
-
-void tc0091lvc_device::device_reset()
-{
-}
-
-const address_space_config *tc0091lvc_device::memory_space_config(address_spacenum spacenum) const
-{
- return (spacenum == 0) ? &m_space_config : NULL;
-}
-
-
-void tc0091lvc_device::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 global_flip )
-{
- gfx_element *gfx = m_gfxdecode->gfx(1);
- int count;
-
- for(count=0;count<0x3e7;count+=8)
- {
- int x,y,spr_offs,col,fx,fy;
-
- spr_offs = m_sprram_buffer[count+0]|(m_sprram_buffer[count+1]<<8);
- x = m_sprram_buffer[count+4]|(m_sprram_buffer[count+5]<<8);
- if (x >= 320)
- x -= 512;
- y = m_sprram_buffer[count+6];
- col = (m_sprram_buffer[count+2])&0x0f;
- fx = m_sprram_buffer[count+3] & 0x1;
- fy = m_sprram_buffer[count+3] & 0x2;
-
- if (global_flip)
- {
- x = 304 - x;
- y = 240 - y;
- fx = !fx;
- fy = !fy;
- }
-
- gfx->prio_transpen(bitmap,cliprect,spr_offs,col,fx,fy,x,y,screen.priority(),(col & 0x08) ? 0xaa : 0x00,0);
- }
-}
-
-UINT32 tc0091lvc_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
-{
- UINT32 count;
- int x,y;
- UINT8 global_flip;
-
- bitmap.fill(m_palette->black_pen(), cliprect);
-
- if((m_vregs[4] & 0x20) == 0)
- return 0;
-
- global_flip = m_vregs[4] & 0x10;
-
- if((m_vregs[4] & 0x7) == 7) // 8bpp bitmap enabled
- {
- count = 0;
-
- for (y=0;y<256;y++)
- {
- for (x=0;x<512;x++)
- {
- int res_x, res_y;
-
- res_x = (global_flip) ? 320-x : x;
- res_y = (global_flip) ? 256-y : y;
-
- if(screen.visible_area().contains(res_x, res_y))
- bitmap.pix16(res_y, res_x) = m_palette->pen(m_bitmap_ram[count]);
-
- count++;
- }
- }
- }
- else
- {
- int dx, dy;
-
- machine().tilemap().set_flip_all(global_flip ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
-
- dx = m_bg0_scroll[0] | (m_bg0_scroll[1] << 8);
- if (global_flip) { dx = ((dx & 0xfffc) | ((dx - 3) & 0x0003)) ^ 0xf; dx += 192; }
- dy = m_bg0_scroll[2];
-
- bg0_tilemap->set_scrollx(0, -dx);
- bg0_tilemap->set_scrolly(0, -dy);
-
- dx = m_bg1_scroll[0] | (m_bg1_scroll[1] << 8);
- if (global_flip) { dx = ((dx & 0xfffc) | ((dx - 3) & 0x0003)) ^ 0xf; dx += 192; }
- dy = m_bg1_scroll[2];
-
- bg1_tilemap->set_scrollx(0, -dx);
- bg1_tilemap->set_scrolly(0, -dy);
-
- tx_tilemap->set_scrollx(0, (global_flip) ? -192 : 0);
-
- screen.priority().fill(0, cliprect);
- bg1_tilemap->draw(screen, bitmap, cliprect, 0,0);
- bg0_tilemap->draw(screen, bitmap, cliprect, 0,(m_vregs[4] & 0x8) ? 0 : 1);
- draw_sprites(screen, bitmap, cliprect, global_flip);
- tx_tilemap->draw(screen, bitmap, cliprect, 0,0);
- }
- return 0;
-}
-
-void tc0091lvc_device::screen_eof(void)
-{
- memcpy(m_sprram_buffer,m_sprram,0x400);
- m_bg0_scroll[0] = m_sprram_buffer[0x3f4];
- m_bg0_scroll[1] = m_sprram_buffer[0x3f5];
- m_bg0_scroll[2] = m_sprram_buffer[0x3f6];
-
- m_bg1_scroll[0] = m_sprram_buffer[0x3fc];
- m_bg1_scroll[1] = m_sprram_buffer[0x3fd];
- m_bg1_scroll[2] = m_sprram_buffer[0x3fe];
-}
diff --git a/src/emu/machine/tc009xlvc.h b/src/emu/machine/tc009xlvc.h
deleted file mode 100644
index de7e20a5c43..00000000000
--- a/src/emu/machine/tc009xlvc.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:Angelo Salese
-/***************************************************************************
-
- TC0091LVC device
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __ramdacDEV_H__
-#define __ramdacDEV_H__
-
-#include "emu.h"
-
-class tc0091lvc_device : public device_t,
- public device_memory_interface
-{
-public:
- tc0091lvc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration
- static void static_set_gfxdecode_tag(device_t &device, const char *tag);
- static void static_set_palette_tag(device_t &device, const char *tag);
-
- DECLARE_READ8_MEMBER( vregs_r );
- DECLARE_WRITE8_MEMBER( vregs_w );
-
- DECLARE_READ8_MEMBER( tc0091lvc_paletteram_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_paletteram_w );
- DECLARE_READ8_MEMBER( tc0091lvc_bitmap_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_bitmap_w );
- DECLARE_READ8_MEMBER( tc0091lvc_pcg1_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_pcg1_w );
- DECLARE_READ8_MEMBER( tc0091lvc_pcg2_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_pcg2_w );
- DECLARE_READ8_MEMBER( tc0091lvc_vram0_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_vram0_w );
- DECLARE_READ8_MEMBER( tc0091lvc_vram1_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_vram1_w );
- DECLARE_READ8_MEMBER( tc0091lvc_spr_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_spr_w );
- DECLARE_READ8_MEMBER( tc0091lvc_tvram_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_tvram_w );
-
- DECLARE_WRITE8_MEMBER( tc0091lvc_bg0_scroll_w );
- DECLARE_WRITE8_MEMBER( tc0091lvc_bg1_scroll_w );
-
- TILE_GET_INFO_MEMBER(get_bg0_tile_info);
- TILE_GET_INFO_MEMBER(get_bg1_tile_info);
- TILE_GET_INFO_MEMBER(get_tx_tile_info);
-
- UINT8 *m_pcg1_ram;
- UINT8 *m_pcg2_ram;
- UINT8 *m_vram0;
- UINT8 *m_vram1;
- UINT8 *m_sprram;
- UINT8 *m_tvram;
- UINT8 m_bg0_scroll[4];
- UINT8 m_bg1_scroll[4];
-
- tilemap_t *bg0_tilemap;
- tilemap_t *bg1_tilemap;
- tilemap_t *tx_tilemap;
-
- int m_gfx_index; // for RAM tiles
-
- UINT8 m_palette_ram[0x200];
- UINT8 m_vregs[0x100];
- UINT8 m_bitmap_ram[0x20000];
- UINT8 m_pcg_ram[0x10000];
- UINT8 m_sprram_buffer[0x400];
-
- UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
- void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 global_flip);
- void screen_eof(void);
-
-protected:
- virtual void device_config_complete();
- virtual void device_validity_check(validity_checker &valid) const;
- virtual void device_start();
- virtual void device_reset();
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
- address_space_config m_space_config;
- required_device<gfxdecode_device> m_gfxdecode;
- required_device<palette_device> m_palette;
-};
-
-extern const device_type TC0091LVC;
-
-#define MCFG_TC0091LVC_GFXDECODE(_gfxtag) \
- tc0091lvc_device::static_set_gfxdecode_tag(*device, "^" _gfxtag);
-
-#define MCFG_TC0091LVC_PALETTE(_palette_tag) \
- tc0091lvc_device::static_set_palette_tag(*device, "^" _palette_tag);
-
-
-#endif
diff --git a/src/emu/machine/terminal.c b/src/emu/machine/terminal.c
deleted file mode 100644
index f46bcd3156e..00000000000
--- a/src/emu/machine/terminal.c
+++ /dev/null
@@ -1,411 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Miodrag Milanovic
-#include "machine/terminal.h"
-
-#define KEYBOARD_TAG "keyboard"
-
-/***************************************************************************
- IMPLEMENTATION
-***************************************************************************/
-
-static const UINT8 terminal_font[256*16] =
-{
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x92, 0x44, 0x92, 0x44, 0x92, 0x44, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x88, 0x88, 0xf8, 0x88, 0x88, 0x3e, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xf0, 0x80, 0xe0, 0x80, 0x9e, 0x10, 0x1c, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x78, 0x80, 0x80, 0x78, 0x3c, 0x22, 0x3c, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x80, 0x80, 0xf8, 0x3e, 0x20, 0x3c, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x38, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x10, 0x10, 0xfe, 0x10, 0x10, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x88, 0xc8, 0xa8, 0x98, 0x88, 0x20, 0x20, 0x20, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x88, 0x88, 0x50, 0x20, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x10, 0x10, 0x10, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xf0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x1f, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x10, 0x10, 0x10, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x10, 0x10, 0x10, 0xff, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x10, 0x10, 0x10, 0x1f, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x10, 0x10, 0x10, 0xf0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x10, 0x10, 0x10, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xff, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x02, 0x08, 0x20, 0x80, 0x20, 0x08, 0x02, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x20, 0x08, 0x02, 0x08, 0x20, 0x80, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xfe, 0x24, 0x24, 0x24, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x02, 0x04, 0xfe, 0x10, 0xfe, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x1c, 0x22, 0x20, 0xf8, 0x20, 0x78, 0xa6, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x24, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x48, 0x48, 0xfc, 0x48, 0xfc, 0x48, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x7c, 0x90, 0x7c, 0x12, 0x7c, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xc2, 0xc4, 0x08, 0x10, 0x20, 0x46, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x70, 0x88, 0x88, 0x70, 0x8a, 0x84, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x18, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x20, 0x10, 0x08, 0x08, 0x08, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x44, 0x28, 0xfe, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x10, 0x10, 0xfe, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x38, 0x44, 0x82, 0x82, 0x82, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x30, 0x50, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x78, 0x84, 0x02, 0x1c, 0x60, 0x80, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfe, 0x04, 0x08, 0x1c, 0x02, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x08, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfe, 0x80, 0xbc, 0xc2, 0x02, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x3c, 0x42, 0x80, 0xbc, 0xc2, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfe, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x7c, 0x82, 0x82, 0x7c, 0x82, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x78, 0x84, 0x86, 0x7a, 0x02, 0x84, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x02, 0x08, 0x20, 0x80, 0x20, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x20, 0x08, 0x02, 0x08, 0x20, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x7c, 0x82, 0x0c, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x7c, 0x82, 0x8a, 0x92, 0x9c, 0x80, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x28, 0x44, 0x82, 0xfe, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfc, 0x42, 0x42, 0x7c, 0x42, 0x42, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x3c, 0x42, 0x80, 0x80, 0x80, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xf8, 0x44, 0x42, 0x42, 0x42, 0x44, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfe, 0x80, 0x80, 0xf8, 0x80, 0x80, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfe, 0x80, 0x80, 0xf8, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x3c, 0x42, 0x80, 0x80, 0x8e, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x82, 0x82, 0x82, 0xfe, 0x82, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x0e, 0x04, 0x04, 0x04, 0x04, 0x84, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x82, 0x8c, 0xb0, 0xc0, 0xb0, 0x8c, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x82, 0xc6, 0xaa, 0x92, 0x82, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x82, 0xc2, 0xa2, 0x92, 0x8a, 0x86, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfc, 0x82, 0x82, 0xfc, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x7c, 0x82, 0x82, 0x82, 0x8a, 0x84, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfc, 0x82, 0x82, 0xfc, 0x88, 0x84, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x7c, 0x82, 0x80, 0x7c, 0x02, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfe, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x82, 0x82, 0x44, 0x44, 0x28, 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x82, 0x82, 0x82, 0x92, 0x92, 0xaa, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfe, 0x04, 0x08, 0x10, 0x20, 0x40, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x3c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x28, 0x44, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x30, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x7c, 0x02, 0x7e, 0x82, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x80, 0xbc, 0xc2, 0x82, 0xc2, 0xbc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x3c, 0x42, 0x80, 0x40, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x02, 0x02, 0x7a, 0x86, 0x82, 0x86, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x7c, 0x82, 0xfe, 0x80, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x1c, 0x22, 0x20, 0xf8, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x7c, 0x84, 0x84, 0x7c, 0x04, 0x84, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//g
- 0x00, 0x80, 0x80, 0xbc, 0xc2, 0x82, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x00, 0x30, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x80, 0x88, 0x90, 0xe0, 0x88, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xc4, 0xaa, 0x92, 0x92, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xbc, 0xc2, 0x82, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x7c, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xbc, 0xc2, 0xc2, 0xbc, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x7a, 0x86, 0x86, 0x7a, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x9c, 0x62, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x7c, 0x80, 0x7c, 0x02, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x20, 0x20, 0xf8, 0x20, 0x20, 0x24, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x84, 0x84, 0x84, 0x84, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x82, 0x82, 0x44, 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x82, 0x82, 0x92, 0xaa, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x84, 0x48, 0x30, 0x48, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x84, 0x84, 0x8c, 0x74, 0x04, 0x84, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xfe, 0x04, 0x18, 0x20, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x0e, 0x10, 0x10, 0x60, 0x10, 0x10, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xe0, 0x10, 0x10, 0x0c, 0x10, 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x62, 0x92, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-generic_terminal_device::generic_terminal_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_palette(*this, "palette"),
- m_io_term_conf(*this, "TERM_CONF"),
- m_keyboard_cb(*this)
-{
-}
-
-generic_terminal_device::generic_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, GENERIC_TERMINAL, "Generic Terminal", tag, owner, clock, "generic_terminal", __FILE__),
- m_palette(*this, "palette"),
- m_io_term_conf(*this, "TERM_CONF"),
- m_keyboard_cb(*this)
-{
-}
-
-void generic_terminal_device::scroll_line()
-{
- memmove(m_buffer,m_buffer+TERMINAL_WIDTH,(TERMINAL_HEIGHT-1)*TERMINAL_WIDTH);
- memset(m_buffer + TERMINAL_WIDTH*(TERMINAL_HEIGHT-1),0x20,TERMINAL_WIDTH);
-}
-
-void generic_terminal_device::write_char(UINT8 data)
-{
- m_buffer[m_y_pos*TERMINAL_WIDTH+m_x_pos] = data;
- m_x_pos++;
- if (m_x_pos >= TERMINAL_WIDTH)
- {
- m_x_pos = 0;
- m_y_pos++;
- if (m_y_pos >= TERMINAL_HEIGHT)
- {
- scroll_line();
- m_y_pos = TERMINAL_HEIGHT-1;
- }
- }
-}
-
-void generic_terminal_device::clear()
-{
- memset(m_buffer,0x20,TERMINAL_WIDTH*TERMINAL_HEIGHT);
- m_x_pos = 0;
- m_y_pos = 0;
-}
-
-void generic_terminal_device::term_write(UINT8 data)
-{
- if (data > 0x1f)
- {
- // printable char
- if (data!=0x7f) write_char(data);
- }
- else
- {
- switch(data)
- {
- case 0x07 : // bell
- break;
-
- case 0x08: if (m_x_pos) m_x_pos--;
- break;
-
- case 0x09: m_x_pos = (m_x_pos & 0xf8) + 8;
- if (m_x_pos >= TERMINAL_WIDTH)
- m_x_pos = TERMINAL_WIDTH-1;
- break;
-
- case 0x0a: m_y_pos++;
- m_x_pos = 0;
- if (m_y_pos >= TERMINAL_HEIGHT)
- {
- scroll_line();
- m_y_pos = TERMINAL_HEIGHT-1;
- }
- break;
-
- case 0x0b: if (m_y_pos) m_y_pos--;
- break;
-
- case 0x0c: clear();
- break;
-
- case 0x0d: m_x_pos = 0;
- break;
-
- case 0x1e: m_x_pos = 0;
- m_y_pos = 0;
- break;
- }
- }
-}
-
-/***************************************************************************
- VIDEO HARDWARE
-***************************************************************************/
-UINT32 generic_terminal_device::update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect)
-{
- UINT8 options = m_io_term_conf->read();
- UINT16 cursor = m_y_pos * TERMINAL_WIDTH + m_x_pos;
- UINT8 y,ra,chr,gfx;
- UINT16 sy=0,ma=0,x;
-
- switch (options & 0x30)
- {
- case 0x10:
- m_palette->set_pen_color(1, rgb_t(0xf7, 0xaa, 0x00));
- break;
- case 0x20:
- m_palette->set_pen_color(1, rgb_t::white);
- break;
- default:
- m_palette->set_pen_color(1, rgb_t(0x00, 0xff, 0x00));
- break;
- }
- pen_t font_color = m_palette->pen(1);
-
- m_framecnt++;
-
- for (y = 0; y < TERMINAL_HEIGHT; y++)
- {
- for (ra = 0; ra < 10; ra++)
- {
- UINT32 *p = &bitmap.pix32(sy++);
-
- for (x = ma; x < ma + TERMINAL_WIDTH; x++)
- {
- chr = m_buffer[x];
- gfx = terminal_font[(chr<<4) | ra ];
-
- if ((x == cursor) && (options & 1)) // at cursor position and want a cursor
- {
- if ((options & 2) || (ra == 9)) // block, or underline & at bottom line
- {
- if ((options & 4) && (m_framecnt & 8)) // want blink & time to blink
- {
- }
- else
- {
- if (options & 8)
- gfx ^= 0xff; // invert
- else
- gfx |= 0xff; // overwrite
- }
- }
- }
-
- /* Display a scanline of a character */
- *p++ = (BIT( gfx, 7 ))?font_color:0;
- *p++ = (BIT( gfx, 6 ))?font_color:0;
- *p++ = (BIT( gfx, 5 ))?font_color:0;
- *p++ = (BIT( gfx, 4 ))?font_color:0;
- *p++ = (BIT( gfx, 3 ))?font_color:0;
- *p++ = (BIT( gfx, 2 ))?font_color:0;
- *p++ = (BIT( gfx, 1 ))?font_color:0;
- *p++ = (BIT( gfx, 0 ))?font_color:0;
- }
- }
- ma+=TERMINAL_WIDTH;
- }
- return 0;
-}
-
-WRITE8_MEMBER( generic_terminal_device::kbd_put )
-{
- if (data)
- send_key(data);
-}
-
-/***************************************************************************
- VIDEO HARDWARE
-***************************************************************************/
-
-static MACHINE_CONFIG_FRAGMENT( generic_terminal )
- MCFG_SCREEN_ADD(TERMINAL_SCREEN_TAG, RASTER)
- MCFG_SCREEN_REFRESH_RATE(50)
- MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
- MCFG_SCREEN_SIZE(TERMINAL_WIDTH*8, TERMINAL_HEIGHT*10)
- MCFG_SCREEN_VISIBLE_AREA(0, TERMINAL_WIDTH*8-1, 0, TERMINAL_HEIGHT*10-1)
- MCFG_SCREEN_UPDATE_DEVICE(DEVICE_SELF, generic_terminal_device, update)
-
- MCFG_PALETTE_ADD_MONOCHROME_GREEN("palette")
-
- MCFG_DEVICE_ADD(KEYBOARD_TAG, GENERIC_KEYBOARD, 0)
- MCFG_GENERIC_KEYBOARD_CB(WRITE8(generic_terminal_device, kbd_put))
-MACHINE_CONFIG_END
-
-machine_config_constructor generic_terminal_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME(generic_terminal);
-}
-
-void generic_terminal_device::device_start()
-{
- m_keyboard_cb.resolve_safe();
- save_item(NAME(m_buffer));
- save_item(NAME(m_x_pos));
- save_item(NAME(m_framecnt));
- save_item(NAME(m_y_pos));
-}
-
-void generic_terminal_device::device_reset()
-{
- clear();
- m_framecnt = 0;
-}
-
-/*
-Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex
--------------------------------------------------------------------------------------
-(nul) 0 0000 0x00 | (sp) 32 0040 0x20 | @ 64 0100 0x40 | ` 96 0140 0x60
-(soh) 1 0001 0x01 | ! 33 0041 0x21 | A 65 0101 0x41 | a 97 0141 0x61
-(stx) 2 0002 0x02 | " 34 0042 0x22 | B 66 0102 0x42 | b 98 0142 0x62
-(etx) 3 0003 0x03 | # 35 0043 0x23 | C 67 0103 0x43 | c 99 0143 0x63
-(eot) 4 0004 0x04 | $ 36 0044 0x24 | D 68 0104 0x44 | d 100 0144 0x64
-(enq) 5 0005 0x05 | % 37 0045 0x25 | E 69 0105 0x45 | e 101 0145 0x65
-(ack) 6 0006 0x06 | & 38 0046 0x26 | F 70 0106 0x46 | f 102 0146 0x66
-(bel) 7 0007 0x07 | ' 39 0047 0x27 | G 71 0107 0x47 | g 103 0147 0x67
-(bs) 8 0010 0x08 | ( 40 0050 0x28 | H 72 0110 0x48 | h 104 0150 0x68
-(ht) 9 0011 0x09 | ) 41 0051 0x29 | I 73 0111 0x49 | i 105 0151 0x69
-(nl) 10 0012 0x0a | * 42 0052 0x2a | J 74 0112 0x4a | j 106 0152 0x6a
-(vt) 11 0013 0x0b | + 43 0053 0x2b | K 75 0113 0x4b | k 107 0153 0x6b
-(np) 12 0014 0x0c | , 44 0054 0x2c | L 76 0114 0x4c | l 108 0154 0x6c
-(cr) 13 0015 0x0d | - 45 0055 0x2d | M 77 0115 0x4d | m 109 0155 0x6d
-(so) 14 0016 0x0e | . 46 0056 0x2e | N 78 0116 0x4e | n 110 0156 0x6e
-(si) 15 0017 0x0f | / 47 0057 0x2f | O 79 0117 0x4f | o 111 0157 0x6f
-(dle) 16 0020 0x10 | 0 48 0060 0x30 | P 80 0120 0x50 | p 112 0160 0x70
-(dc1) 17 0021 0x11 | 1 49 0061 0x31 | Q 81 0121 0x51 | q 113 0161 0x71
-(dc2) 18 0022 0x12 | 2 50 0062 0x32 | R 82 0122 0x52 | r 114 0162 0x72
-(dc3) 19 0023 0x13 | 3 51 0063 0x33 | S 83 0123 0x53 | s 115 0163 0x73
-(dc4) 20 0024 0x14 | 4 52 0064 0x34 | T 84 0124 0x54 | t 116 0164 0x74
-(nak) 21 0025 0x15 | 5 53 0065 0x35 | U 85 0125 0x55 | u 117 0165 0x75
-(syn) 22 0026 0x16 | 6 54 0066 0x36 | V 86 0126 0x56 | v 118 0166 0x76
-(etb) 23 0027 0x17 | 7 55 0067 0x37 | W 87 0127 0x57 | w 119 0167 0x77
-(can) 24 0030 0x18 | 8 56 0070 0x38 | X 88 0130 0x58 | x 120 0170 0x78
-(em) 25 0031 0x19 | 9 57 0071 0x39 | Y 89 0131 0x59 | y 121 0171 0x79
-(sub) 26 0032 0x1a | : 58 0072 0x3a | Z 90 0132 0x5a | z 122 0172 0x7a
-(esc) 27 0033 0x1b | ; 59 0073 0x3b | [ 91 0133 0x5b | { 123 0173 0x7b
-(fs) 28 0034 0x1c | < 60 0074 0x3c | \ 92 0134 0x5c | | 124 0174 0x7c
-(gs) 29 0035 0x1d | = 61 0075 0x3d | ] 93 0135 0x5d | } 125 0175 0x7d
-(rs) 30 0036 0x1e | > 62 0076 0x3e | ^ 94 0136 0x5e | ~ 126 0176 0x7e
-(us) 31 0037 0x1f | ? 63 0077 0x3f | _ 95 0137 0x5f | (del) 127 0177 0x7f
-
-*/
-INPUT_PORTS_START( generic_terminal )
- PORT_START("TERM_CONF")
- PORT_CONFNAME( 0x01, 0x01, "Cursor")
- PORT_CONFSETTING( 0x00, DEF_STR(No))
- PORT_CONFSETTING( 0x01, DEF_STR(Yes))
- PORT_CONFNAME( 0x02, 0x02, "Type")
- PORT_CONFSETTING( 0x00, "Underline")
- PORT_CONFSETTING( 0x02, "Block")
- PORT_CONFNAME( 0x04, 0x04, "Blinking")
- PORT_CONFSETTING( 0x00, DEF_STR(No))
- PORT_CONFSETTING( 0x04, DEF_STR(Yes))
- PORT_CONFNAME( 0x08, 0x08, "Invert")
- PORT_CONFSETTING( 0x00, DEF_STR(No))
- PORT_CONFSETTING( 0x08, DEF_STR(Yes))
- PORT_CONFNAME( 0x30, 0x00, "Color")
- PORT_CONFSETTING( 0x00, "Green")
- PORT_CONFSETTING( 0x10, "Amber")
- PORT_CONFSETTING( 0x20, "White")
-INPUT_PORTS_END
-
-ioport_constructor generic_terminal_device::device_input_ports() const
-{
- return INPUT_PORTS_NAME(generic_terminal);
-}
-
-const device_type GENERIC_TERMINAL = &device_creator<generic_terminal_device>;
diff --git a/src/emu/machine/terminal.h b/src/emu/machine/terminal.h
deleted file mode 100644
index 0a0e2ff9b77..00000000000
--- a/src/emu/machine/terminal.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Miodrag Milanovic
-#ifndef __TERMINAL_H__
-#define __TERMINAL_H__
-
-#include "machine/keyboard.h"
-
-#define TERMINAL_SCREEN_TAG "terminal_screen"
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_GENERIC_TERMINAL_KEYBOARD_CB(_devcb) \
- devcb = &generic_terminal_device::set_keyboard_callback(*device, DEVCB_##_devcb);
-
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-
-#define TERMINAL_WIDTH 80
-#define TERMINAL_HEIGHT 24
-
-INPUT_PORTS_EXTERN( generic_terminal );
-
-class generic_terminal_device : public device_t
-{
-public:
- generic_terminal_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
- generic_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_keyboard_callback(device_t &device, _Object object) { return downcast<generic_terminal_device &>(device).m_keyboard_cb.set_callback(object); }
-
- DECLARE_WRITE8_MEMBER(write) { term_write(data); }
- DECLARE_WRITE8_MEMBER(kbd_put);
- UINT32 update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect);
-
- virtual ioport_constructor device_input_ports() const;
- virtual machine_config_constructor device_mconfig_additions() const;
-protected:
- optional_device<palette_device> m_palette;
- required_ioport m_io_term_conf;
-
- virtual void term_write(UINT8 data);
- virtual void device_start();
- virtual void device_reset();
- virtual void send_key(UINT8 code) { m_keyboard_cb((offs_t)0, code); }
- UINT8 m_buffer[TERMINAL_WIDTH*50]; // make big enough for teleprinter
- UINT8 m_x_pos;
-private:
- void scroll_line();
- void write_char(UINT8 data);
- void clear();
-
- UINT8 m_framecnt;
- UINT8 m_y_pos;
-
- devcb_write8 m_keyboard_cb;
-};
-
-extern const device_type GENERIC_TERMINAL;
-
-#endif /* __TERMINAL_H__ */
diff --git a/src/emu/machine/timekpr.c b/src/emu/machine/timekpr.c
deleted file mode 100644
index 940fa84f259..00000000000
--- a/src/emu/machine/timekpr.c
+++ /dev/null
@@ -1,437 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles,smf
-/***************************************************************************
-
- timekpr.h
-
- Various ST Microelectronics timekeeper SRAM implementations:
- - M48T02
- - M48T35
- - M48T37
- - M48T58
- - MK48T08
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/timekpr.h"
-
-
-// device type definition
-const device_type M48T02 = &device_creator<m48t02_device>;
-const device_type M48T35 = &device_creator<m48t35_device>;
-const device_type M48T37 = &device_creator<m48t37_device>;
-const device_type M48T58 = &device_creator<m48t58_device>;
-const device_type MK48T08 = &device_creator<mk48t08_device>;
-
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-#define MASK_SECONDS ( 0x7f )
-#define MASK_MINUTES ( 0x7f )
-#define MASK_HOURS ( 0x3f )
-#define MASK_DAY ( 0x07 )
-#define MASK_DATE ( 0x3f )
-#define MASK_MONTH ( 0x1f )
-#define MASK_YEAR ( 0xff )
-#define MASK_CENTURY ( 0xff )
-
-#define CONTROL_W ( 0x80 )
-#define CONTROL_R ( 0x40 )
-#define CONTROL_S ( 0x20 ) /* not emulated */
-#define CONTROL_CALIBRATION ( 0x1f ) /* not emulated */
-
-#define SECONDS_ST ( 0x80 )
-
-#define DAY_FT ( 0x40 ) /* M48T37 - not emulated */
-#define DAY_CEB ( 0x20 ) /* M48T35/M48T58 */
-#define DAY_CB ( 0x10 ) /* M48T35/M48T58 */
-
-#define DATE_BLE ( 0x80 ) /* M48T58: not emulated */
-#define DATE_BL ( 0x40 ) /* M48T58: not emulated */
-
-#define FLAGS_BL ( 0x10 ) /* MK48T08/M48T37: not emulated */
-#define FLAGS_AF ( 0x40 ) /* M48T37: not emulated */
-#define FLAGS_WDF ( 0x80 ) /* M48T37: not emulated */
-
-
-/***************************************************************************
- INLINE FUNCTIONS
-***************************************************************************/
-
-INLINE UINT8 make_bcd(UINT8 data)
-{
- return ( ( ( data / 10 ) % 10 ) << 4 ) + ( data % 10 );
-}
-
-INLINE UINT8 from_bcd( UINT8 data )
-{
- return ( ( ( data >> 4 ) & 15 ) * 10 ) + ( data & 15 );
-}
-
-static int inc_bcd( UINT8 *data, int mask, int min, int max )
-{
- int bcd;
- int carry;
-
- bcd = ( *( data ) + 1 ) & mask;
- carry = 0;
-
- if( ( bcd & 0x0f ) > 9 )
- {
- bcd &= 0xf0;
- bcd += 0x10;
- if( bcd > max )
- {
- bcd = min;
- carry = 1;
- }
- }
-
- *( data ) = ( *( data ) & ~mask ) | ( bcd & mask );
- return carry;
-}
-
-static void counter_to_ram( UINT8 *data, int offset, int counter )
-{
- if( offset >= 0 )
- {
- data[ offset ] = counter;
- }
-}
-
-static int counter_from_ram( UINT8 *data, int offset )
-{
- if( offset >= 0 )
- {
- return data[ offset ];
- }
- return 0;
-}
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// timekeeper_device_config - constructor
-//-------------------------------------------------
-
-timekeeper_device::timekeeper_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_nvram_interface(mconfig, *this)
-{
-}
-
-m48t02_device::m48t02_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, M48T02, "M48T02 Timekeeper", tag, owner, clock, "m48t02", __FILE__)
-{
- m_offset_control = 0x7f8;
- m_offset_seconds = 0x7f9;
- m_offset_minutes = 0x7fa;
- m_offset_hours = 0x7fb;
- m_offset_day = 0x7fc;
- m_offset_date = 0x7fd;
- m_offset_month = 0x7fe;
- m_offset_year = 0x7ff;
- m_offset_century = -1;
- m_offset_flags = -1;
- m_size = 0x800;
-}
-
-m48t35_device::m48t35_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, M48T35, "M48T35 Timekeeper", tag, owner, clock, "m48t35", __FILE__)
-{
- m_offset_control = 0x7ff8;
- m_offset_seconds = 0x7ff9;
- m_offset_minutes = 0x7ffa;
- m_offset_hours = 0x7ffb;
- m_offset_day = 0x7ffc;
- m_offset_date = 0x7ffd;
- m_offset_month = 0x7ffe;
- m_offset_year = 0x7fff;
- m_offset_century = -1;
- m_offset_flags = -1;
- m_size = 0x8000;
-}
-
-m48t37_device::m48t37_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, M48T37, "M48T37 Timekeeper", tag, owner, clock, "m48t37", __FILE__)
-{
- m_offset_control = 0x7ff8;
- m_offset_seconds = 0x7ff9;
- m_offset_minutes = 0x7ffa;
- m_offset_hours = 0x7ffb;
- m_offset_day = 0x7ffc;
- m_offset_date = 0x7ffd;
- m_offset_month = 0x7ffe;
- m_offset_year = 0x7fff;
- m_offset_century = 0x7ff1;
- m_offset_flags = 0x7ff0;
- m_size = 0x8000;
-}
-
-m48t58_device::m48t58_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, M48T58, "M48T58 Timekeeper", tag, owner, clock, "m48t58", __FILE__)
-{
- m_offset_control = 0x1ff8;
- m_offset_seconds = 0x1ff9;
- m_offset_minutes = 0x1ffa;
- m_offset_hours = 0x1ffb;
- m_offset_day = 0x1ffc;
- m_offset_date = 0x1ffd;
- m_offset_month = 0x1ffe;
- m_offset_year = 0x1fff;
- m_offset_century = -1;
- m_offset_flags = -1;
- m_size = 0x2000;
-}
-
-mk48t08_device::mk48t08_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, MK48T08, "MK48T08 Timekeeper", tag, owner, clock, "m48t08", __FILE__)
-{
- m_offset_control = 0x1ff8;
- m_offset_seconds = 0x1ff9;
- m_offset_minutes = 0x1ffa;
- m_offset_hours = 0x1ffb;
- m_offset_day = 0x1ffc;
- m_offset_date = 0x1ffd;
- m_offset_month = 0x1ffe;
- m_offset_year = 0x1fff;
- m_offset_century = 0x1ff1;
- m_offset_flags = 0x1ff0;
- m_size = 0x2000;
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void timekeeper_device::device_start()
-{
- system_time systime;
-
- /* validate some basic stuff */
- assert(this != NULL);
-
- machine().base_datetime(systime);
-
- m_control = 0;
- m_seconds = make_bcd( systime.local_time.second );
- m_minutes = make_bcd( systime.local_time.minute );
- m_hours = make_bcd( systime.local_time.hour );
- m_day = make_bcd( systime.local_time.weekday + 1 );
- m_date = make_bcd( systime.local_time.mday );
- m_month = make_bcd( systime.local_time.month + 1 );
- m_year = make_bcd( systime.local_time.year % 100 );
- m_century = make_bcd( systime.local_time.year / 100 );
- m_data.resize( m_size );
-
- m_default_data = region()->base();
- if (m_default_data)
- {
- assert( region()->bytes() == m_size );
- }
-
- save_item( NAME(m_control) );
- save_item( NAME(m_seconds) );
- save_item( NAME(m_minutes) );
- save_item( NAME(m_hours) );
- save_item( NAME(m_day) );
- save_item( NAME(m_date) );
- save_item( NAME(m_month) );
- save_item( NAME(m_year) );
- save_item( NAME(m_century) );
- save_item( NAME(m_data) );
-
- emu_timer *timer = timer_alloc();
- timer->adjust(attotime::from_seconds(1), 0, attotime::from_seconds(1));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void timekeeper_device::device_reset() { }
-
-void timekeeper_device::counters_to_ram()
-{
- counter_to_ram( &m_data[0], m_offset_control, m_control );
- counter_to_ram( &m_data[0], m_offset_seconds, m_seconds );
- counter_to_ram( &m_data[0], m_offset_minutes, m_minutes );
- counter_to_ram( &m_data[0], m_offset_hours, m_hours );
- counter_to_ram( &m_data[0], m_offset_day, m_day );
- counter_to_ram( &m_data[0], m_offset_date, m_date );
- counter_to_ram( &m_data[0], m_offset_month, m_month );
- counter_to_ram( &m_data[0], m_offset_year, m_year );
- counter_to_ram( &m_data[0], m_offset_century, m_century );
-}
-
-void timekeeper_device::counters_from_ram()
-{
- m_control = counter_from_ram( &m_data[0], m_offset_control );
- m_seconds = counter_from_ram( &m_data[0], m_offset_seconds );
- m_minutes = counter_from_ram( &m_data[0], m_offset_minutes );
- m_hours = counter_from_ram( &m_data[0], m_offset_hours );
- m_day = counter_from_ram( &m_data[0], m_offset_day );
- m_date = counter_from_ram( &m_data[0], m_offset_date );
- m_month = counter_from_ram( &m_data[0], m_offset_month );
- m_year = counter_from_ram( &m_data[0], m_offset_year );
- m_century = counter_from_ram( &m_data[0], m_offset_century );
-}
-
-void timekeeper_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if( ( m_seconds & SECONDS_ST ) != 0 ||
- ( m_control & CONTROL_W ) != 0 )
- {
- return;
- }
-
- int carry = inc_bcd( &m_seconds, MASK_SECONDS, 0x00, 0x59 );
- if( carry )
- {
- carry = inc_bcd( &m_minutes, MASK_MINUTES, 0x00, 0x59 );
- }
- if( carry )
- {
- carry = inc_bcd( &m_hours, MASK_HOURS, 0x00, 0x23 );
- }
-
- if( carry )
- {
- UINT8 maxdays;
- static const UINT8 daysinmonth[] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 };
-
- inc_bcd( &m_day, MASK_DAY, 0x01, 0x07 );
-
- UINT8 month = from_bcd( m_month );
- UINT8 year = from_bcd( m_year );
-
- if( month == 2 && ( year % 4 ) == 0 )
- {
- maxdays = 0x29;
- }
- else if( month >= 1 && month <= 12 )
- {
- maxdays = daysinmonth[ month - 1 ];
- }
- else
- {
- maxdays = 0x31;
- }
-
- carry = inc_bcd( &m_date, MASK_DATE, 0x01, maxdays );
- }
- if( carry )
- {
- carry = inc_bcd( &m_month, MASK_MONTH, 0x01, 0x12 );
- }
- if( carry )
- {
- carry = inc_bcd( &m_year, MASK_YEAR, 0x00, 0x99 );
- }
- if( carry )
- {
- carry = inc_bcd( &m_century, MASK_CENTURY, 0x00, 0x99 );
-
- if( type() == M48T35 ||
- type() == M48T58 )
- {
- if( ( m_day & DAY_CEB ) != 0 )
- {
- m_day ^= DAY_CB;
- }
- }
- }
-
- if( ( m_control & CONTROL_R ) == 0 )
- {
- counters_to_ram();
- }
-}
-
-WRITE8_MEMBER( timekeeper_device::write )
-{
- if( offset == m_offset_control )
- {
- if( ( m_control & CONTROL_W ) != 0 &&
- ( data & CONTROL_W ) == 0 )
- {
- counters_from_ram();
- }
- m_control = data;
- }
- else if( offset == m_offset_day )
- {
- if( type() == M48T35 ||
- type() == M48T58 )
- {
- m_day = ( m_day & ~DAY_CEB ) | ( data & DAY_CEB );
- }
- }
-
- m_data[ offset ] = data;
-}
-
-READ8_MEMBER( timekeeper_device::read )
-{
- UINT8 result = m_data[ offset ];
- if( offset == m_offset_date && type() == M48T58 )
- {
- result &= ~DATE_BL;
- }
- else if( offset == m_offset_flags && (type() == MK48T08 || type() == M48T37) )
- {
- result = 0;
- }
- return result;
-}
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void timekeeper_device::nvram_default()
-{
- if( m_default_data != NULL )
- {
- memcpy( &m_data[0], m_default_data, m_size );
- }
- else
- {
- memset( &m_data[0], 0xff, m_data.size());
- }
-
- if ( m_offset_flags >= 0 )
- m_data[ m_offset_flags ] = 0;
- counters_to_ram();
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void timekeeper_device::nvram_read(emu_file &file)
-{
- file.read( &m_data[0], m_size );
-
- counters_to_ram();
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void timekeeper_device::nvram_write(emu_file &file)
-{
- file.write( &m_data[0], m_size );
-}
diff --git a/src/emu/machine/timekpr.h b/src/emu/machine/timekpr.h
deleted file mode 100644
index 6e72f9add62..00000000000
--- a/src/emu/machine/timekpr.h
+++ /dev/null
@@ -1,144 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles,smf
-/***************************************************************************
-
- timekpr.h
-
- Various ST Microelectronics timekeeper SRAM implementations:
- - M48T02
- - M48T35
- - M48T37
- - M48T58
- - MK48T08
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __TIMEKPR_H__
-#define __TIMEKPR_H__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_M48T02_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, M48T02, 0)
-
-#define MCFG_M48T35_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, M48T35, 0)
-
-#define MCFG_M48T37_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, M48T37, 0)
-
-#define MCFG_M48T58_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, M48T58, 0)
-
-#define MCFG_MK48T08_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, MK48T08, 0)
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-// ======================> timekeeper_device
-
-class timekeeper_device : public device_t,
- public device_nvram_interface
-{
-protected:
- // construction/destruction
- timekeeper_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
-public:
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_READ8_MEMBER( read );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
-private:
- void counters_to_ram();
- void counters_from_ram();
-
- // internal state
- UINT8 m_control;
- UINT8 m_seconds;
- UINT8 m_minutes;
- UINT8 m_hours;
- UINT8 m_day;
- UINT8 m_date;
- UINT8 m_month;
- UINT8 m_year;
- UINT8 m_century;
-
- dynamic_buffer m_data;
- UINT8 *m_default_data;
-
-protected:
- int m_size;
- int m_offset_control;
- int m_offset_seconds;
- int m_offset_minutes;
- int m_offset_hours;
- int m_offset_day;
- int m_offset_date;
- int m_offset_month;
- int m_offset_year;
- int m_offset_century;
- int m_offset_flags;
-};
-
-class m48t02_device : public timekeeper_device
-{
-public:
- m48t02_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class m48t35_device : public timekeeper_device
-{
-public:
- m48t35_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class m48t37_device : public timekeeper_device
-{
-public:
- m48t37_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class m48t58_device : public timekeeper_device
-{
-public:
- m48t58_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class mk48t08_device : public timekeeper_device
-{
-public:
- mk48t08_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-// device type definition
-extern const device_type M48T02;
-extern const device_type M48T35;
-extern const device_type M48T37;
-extern const device_type M48T58;
-extern const device_type MK48T08;
-
-#endif // __TIMEKPR_H__
diff --git a/src/emu/machine/tmp68301.c b/src/emu/machine/tmp68301.c
deleted file mode 100644
index 955a10c463b..00000000000
--- a/src/emu/machine/tmp68301.c
+++ /dev/null
@@ -1,337 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Luca Elia
-/***************************************************************************
-
- TMP68301 basic emulation + Interrupt Handling
-
- The Toshiba TMP68301 is a 68HC000 + serial I/O, parallel I/O,
- 3 timers, address decoder, wait generator, interrupt controller,
- all integrated in a single chip.
-
- TODO:
- - Interrupt generation: handle pending / in-service mechanisms
- - Parallel port: handle timing latency
- - Serial port: not done at all
- - (and many other things)
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/tmp68301.h"
-
-const device_type TMP68301 = &device_creator<tmp68301_device>;
-
-static ADDRESS_MAP_START( tmp68301_regs, AS_0, 16, tmp68301_device )
-// AM_RANGE(0x000,0x3ff) AM_RAM
- AM_RANGE(0x094,0x095) AM_READWRITE(imr_r,imr_w)
- AM_RANGE(0x098,0x099) AM_READWRITE(iisr_r,iisr_w)
-
- /* Parallel Port */
- AM_RANGE(0x100,0x101) AM_READWRITE(pdir_r,pdir_w)
- AM_RANGE(0x10a,0x10b) AM_READWRITE(pdr_r,pdr_w)
-
- /* Serial Port */
- AM_RANGE(0x18e,0x18f) AM_READWRITE(scr_r,scr_w)
-ADDRESS_MAP_END
-
-// IRQ Mask register, 0x94
-READ16_MEMBER(tmp68301_device::imr_r)
-{
- return m_imr;
-}
-
-WRITE16_MEMBER(tmp68301_device::imr_w)
-{
- COMBINE_DATA(&m_imr);
-}
-
-// IRQ In-Service Register
-READ16_MEMBER(tmp68301_device::iisr_r)
-{
- return m_iisr;
-}
-
-WRITE16_MEMBER(tmp68301_device::iisr_w)
-{
- COMBINE_DATA(&m_iisr);
-}
-
-// Serial Control Register (TODO: 8-bit wide)
-READ16_MEMBER(tmp68301_device::scr_r)
-{
- return m_scr;
-}
-
-WRITE16_MEMBER(tmp68301_device::scr_w)
-{
- /*
- *--- ---- CKSE
- --*- ---- RES
- ---- ---* INTM
- */
-
- COMBINE_DATA(&m_scr);
- m_scr &= 0xa1;
-}
-
-/* Parallel direction: 1 = output, 0 = input */
-READ16_MEMBER(tmp68301_device::pdir_r)
-{
- return m_pdir;
-}
-
-WRITE16_MEMBER(tmp68301_device::pdir_w)
-{
- COMBINE_DATA(&m_pdir);
-}
-
-READ16_MEMBER(tmp68301_device::pdr_r)
-{
- return (m_in_parallel_cb(0) & ~m_pdir) | (m_pdr & m_pdir);
-}
-
-WRITE16_MEMBER(tmp68301_device::pdr_w)
-{
- UINT16 old = m_pdr;
- COMBINE_DATA(&m_pdr);
- m_pdr = (old & ~m_pdir) | (m_pdr & m_pdir);
- m_out_parallel_cb(0, m_pdr, mem_mask);
-}
-
-
-tmp68301_device::tmp68301_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, TMP68301, "TMP68301", tag, owner, clock, "tmp68301", __FILE__),
- device_memory_interface(mconfig, *this),
- m_in_parallel_cb(*this),
- m_out_parallel_cb(*this),
- m_imr(0),
- m_iisr(0),
- m_scr(0),
- m_pdir(0),
- m_pdr(0),
- m_space_config("regs", ENDIANNESS_LITTLE, 16, 10, 0, NULL, *ADDRESS_MAP_NAME(tmp68301_regs))
-{
- memset(m_regs, 0, sizeof(m_regs));
- memset(m_IE, 0, sizeof(m_IE));
- memset(m_irq_vector, 0, sizeof(m_irq_vector));
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void tmp68301_device::device_start()
-{
- int i;
- for (i = 0; i < 3; i++)
- m_tmp68301_timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tmp68301_device::timer_callback), this));
-
- m_in_parallel_cb.resolve_safe(0);
- m_out_parallel_cb.resolve_safe();
-
- save_item(NAME(m_regs));
- save_item(NAME(m_IE));
- save_item(NAME(m_irq_vector));
- save_item(NAME(m_imr));
- save_item(NAME(m_iisr));
- save_item(NAME(m_scr));
- save_item(NAME(m_pdir));
- save_item(NAME(m_pdr));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void tmp68301_device::device_reset()
-{
- int i;
-
- for (i = 0; i < 3; i++)
- m_IE[i] = 0;
-
- m_imr = 0x7f7; // mask all irqs
-}
-
-//-------------------------------------------------
-// memory_space_config - return a description of
-// any address spaces owned by this device
-//-------------------------------------------------
-
-const address_space_config *tmp68301_device::memory_space_config(address_spacenum spacenum) const
-{
- return (spacenum == AS_0) ? &m_space_config : NULL;
-}
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// read_byte - read a byte at the given address
-//-------------------------------------------------
-
-inline UINT16 tmp68301_device::read_word(offs_t address)
-{
- return space(AS_0).read_word(address << 1);
-}
-
-//-------------------------------------------------
-// write_byte - write a byte at the given address
-//-------------------------------------------------
-
-inline void tmp68301_device::write_word(offs_t address, UINT16 data)
-{
- space(AS_0).write_word(address << 1, data);
-}
-
-IRQ_CALLBACK_MEMBER(tmp68301_device::irq_callback)
-{
- int vector = m_irq_vector[irqline];
-// logerror("%s: irq callback returns %04X for level %x\n",machine.describe_context(),vector,int_level);
- return vector;
-}
-
-TIMER_CALLBACK_MEMBER( tmp68301_device::timer_callback )
-{
- int i = param;
- UINT16 TCR = m_regs[(0x200 + i * 0x20)/2];
- UINT16 ICR = m_regs[0x8e/2+i]; // Interrupt Controller Register (ICR7..9)
- UINT16 IVNR = m_regs[0x9a/2]; // Interrupt Vector Number Register (IVNR)
-
-// logerror("s: callback timer %04X, j = %d\n",machine.describe_context(),i,tcount);
-
- if ( (TCR & 0x0004) && // INT
- !(m_imr & (0x100<<i))
- )
- {
- int level = ICR & 0x0007;
-
- // Interrupt Vector Number Register (IVNR)
- m_irq_vector[level] = IVNR & 0x00e0;
- m_irq_vector[level] += 4+i;
-
- machine().firstcpu->set_input_line(level,HOLD_LINE);
- }
-
- if (TCR & 0x0080) // N/1
- {
- // Repeat
- update_timer(i);
- }
- else
- {
- // One Shot
- }
-}
-
-void tmp68301_device::update_timer( int i )
-{
- UINT16 TCR = m_regs[(0x200 + i * 0x20)/2];
- UINT16 MAX1 = m_regs[(0x204 + i * 0x20)/2];
- UINT16 MAX2 = m_regs[(0x206 + i * 0x20)/2];
-
- int max = 0;
- attotime duration = attotime::zero;
-
- m_tmp68301_timer[i]->adjust(attotime::never,i);
-
- // timers 1&2 only
- switch( (TCR & 0x0030)>>4 ) // MR2..1
- {
- case 1:
- max = MAX1;
- break;
- case 2:
- max = MAX2;
- break;
- }
-
- switch ( (TCR & 0xc000)>>14 ) // CK2..1
- {
- case 0: // System clock (CLK)
- if (max)
- {
- int scale = (TCR & 0x3c00)>>10; // P4..1
- if (scale > 8) scale = 8;
- duration = attotime::from_hz(machine().firstcpu->unscaled_clock()) * ((1 << scale) * max);
- }
- break;
- }
-
-// logerror("%s: TMP68301 Timer %d, duration %lf, max %04X\n",machine().describe_context(),i,duration,max);
-
- if (!(TCR & 0x0002)) // CS
- {
- if (duration != attotime::zero)
- m_tmp68301_timer[i]->adjust(duration,i);
- else
- logerror("%s: TMP68301 error, timer %d duration is 0\n",machine().describe_context(),i);
- }
-}
-
-/* Update the IRQ state based on all possible causes */
-void tmp68301_device::update_irq_state()
-{
- int i;
-
- /* Take care of external interrupts */
-
- UINT16 IVNR = m_regs[0x9a/2]; // Interrupt Vector Number Register (IVNR)
-
- for (i = 0; i < 3; i++)
- {
- if ( (m_IE[i]) &&
- !(m_imr & (1<<i))
- )
- {
- UINT16 ICR = m_regs[0x80/2+i]; // Interrupt Controller Register (ICR0..2)
-
- // Interrupt Controller Register (ICR0..2)
- int level = ICR & 0x0007;
-
- // Interrupt Vector Number Register (IVNR)
- m_irq_vector[level] = IVNR & 0x00e0;
- m_irq_vector[level] += i;
-
- m_IE[i] = 0; // Interrupts are edge triggerred
-
- machine().firstcpu->set_input_line(level,HOLD_LINE);
- }
- }
-}
-
-READ16_MEMBER( tmp68301_device::regs_r )
-{
- return read_word(offset);
-}
-
-WRITE16_MEMBER( tmp68301_device::regs_w )
-{
- COMBINE_DATA(&m_regs[offset]);
-
- write_word(offset,m_regs[offset]);
-
- if (!ACCESSING_BITS_0_7) return;
-
-// logerror("CPU #0 PC %06X: TMP68301 Reg %04X<-%04X & %04X\n",space.device().safe_pc(),offset*2,data,mem_mask^0xffff);
-
- switch( offset * 2 )
- {
- // Timers
- case 0x200:
- case 0x220:
- case 0x240:
- {
- int i = ((offset*2) >> 5) & 3;
-
- update_timer( i );
- }
- break;
- }
-}
-
-void tmp68301_device::external_interrupt_0() { m_IE[0] = 1; update_irq_state(); }
-void tmp68301_device::external_interrupt_1() { m_IE[1] = 1; update_irq_state(); }
-void tmp68301_device::external_interrupt_2() { m_IE[2] = 1; update_irq_state(); }
diff --git a/src/emu/machine/tmp68301.h b/src/emu/machine/tmp68301.h
deleted file mode 100644
index b96296d31f2..00000000000
--- a/src/emu/machine/tmp68301.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Luca Elia
-#ifndef TMP68301_H
-#define TMP68301_H
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-/* TODO: serial ports, frequency & hook it up with m68k */
-#define MCFG_TMP68301_IN_PARALLEL_CB(_devcb) \
- devcb = &tmp68301_device::set_in_parallel_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TMP68301_OUT_PARALLEL_CB(_devcb) \
- devcb = &tmp68301_device::set_out_parallel_callback(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-
-class tmp68301_device : public device_t,
- public device_memory_interface
-{
-public:
- tmp68301_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~tmp68301_device() {}
-
- template<class _Object> static devcb_base &set_in_parallel_callback(device_t &device, _Object object) { return downcast<tmp68301_device &>(device).m_in_parallel_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_parallel_callback(device_t &device, _Object object) { return downcast<tmp68301_device &>(device).m_out_parallel_cb.set_callback(object); }
-
- // Hardware Registers
- DECLARE_READ16_MEMBER( regs_r );
- DECLARE_WRITE16_MEMBER( regs_w );
-
- // Interrupts
- void external_interrupt_0();
- void external_interrupt_1();
- void external_interrupt_2();
-
- DECLARE_READ16_MEMBER(imr_r);
- DECLARE_WRITE16_MEMBER(imr_w);
- DECLARE_READ16_MEMBER(iisr_r);
- DECLARE_WRITE16_MEMBER(iisr_w);
- DECLARE_READ16_MEMBER(scr_r);
- DECLARE_WRITE16_MEMBER(scr_w);
- DECLARE_READ16_MEMBER(pdr_r);
- DECLARE_WRITE16_MEMBER(pdr_w);
- DECLARE_READ16_MEMBER(pdir_r);
- DECLARE_WRITE16_MEMBER(pdir_w);
-
- IRQ_CALLBACK_MEMBER(irq_callback);
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
-
-private:
- devcb_read16 m_in_parallel_cb;
- devcb_write16 m_out_parallel_cb;
-
- // internal state
- UINT16 m_regs[0x400];
-
- UINT8 m_IE[3]; // 3 External Interrupt Lines
- emu_timer *m_tmp68301_timer[3]; // 3 Timers
-
- UINT16 m_irq_vector[8];
-
- TIMER_CALLBACK_MEMBER( timer_callback );
- void update_timer( int i );
- void update_irq_state();
-
- UINT16 m_imr;
- UINT16 m_iisr;
- UINT16 m_scr;
- UINT16 m_pdir;
- UINT16 m_pdr;
-
- inline UINT16 read_word(offs_t address);
- inline void write_word(offs_t address, UINT16 data);
- const address_space_config m_space_config;
-};
-
-extern const device_type TMP68301;
-
-#endif
diff --git a/src/emu/machine/tms1024.c b/src/emu/machine/tms1024.c
deleted file mode 100644
index f362349ef16..00000000000
--- a/src/emu/machine/tms1024.c
+++ /dev/null
@@ -1,111 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:hap
-/*
-
- Texas Instruments TMS1024/TMS1025 I/O expander
-
- No documentation was available, just a pinout.
- Other than more port pins, TMS1025 is assumed to be same as TMS1024.
-
- TODO:
- - writes to port 0
- - what's the MS pin?
- - strobe is on rising edge? or falling edge?
-
-*/
-
-#include "machine/tms1024.h"
-
-
-const device_type TMS1024 = &device_creator<tms1024_device>;
-const device_type TMS1025 = &device_creator<tms1025_device>;
-
-//-------------------------------------------------
-// constructor
-//-------------------------------------------------
-
-tms1024_device::tms1024_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, TMS1024, "TMS1024 I/O Expander", tag, owner, clock, "tms1024", __FILE__),
- m_write_port1(*this), m_write_port2(*this), m_write_port3(*this), m_write_port4(*this), m_write_port5(*this), m_write_port6(*this), m_write_port7(*this)
-{
-}
-
-tms1024_device::tms1024_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_write_port1(*this), m_write_port2(*this), m_write_port3(*this), m_write_port4(*this), m_write_port5(*this), m_write_port6(*this), m_write_port7(*this)
-{
-}
-
-tms1025_device::tms1025_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : tms1024_device(mconfig, TMS1025, "TMS1025 I/O Expander", tag, owner, clock, "tms1025", __FILE__)
-{
-}
-
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void tms1024_device::device_start()
-{
- // resolve callbacks (there is no port 0)
- m_write_port1.resolve_safe(); m_write_port[0] = &m_write_port1;
- m_write_port2.resolve_safe(); m_write_port[1] = &m_write_port2;
- m_write_port3.resolve_safe(); m_write_port[2] = &m_write_port3;
- m_write_port4.resolve_safe(); m_write_port[3] = &m_write_port4;
- m_write_port5.resolve_safe(); m_write_port[4] = &m_write_port5;
- m_write_port6.resolve_safe(); m_write_port[5] = &m_write_port6;
- m_write_port7.resolve_safe(); m_write_port[6] = &m_write_port7;
-
- // zerofill
- m_h = 0;
- m_s = 0;
- m_std = 0;
-
- // register for savestates
- save_item(NAME(m_h));
- save_item(NAME(m_s));
- save_item(NAME(m_std));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void tms1024_device::device_reset()
-{
-}
-
-
-
-//-------------------------------------------------
-// handlers
-//-------------------------------------------------
-
-WRITE8_MEMBER(tms1024_device::write_h)
-{
- // H1,2,3,4: data for outputs A,B,C,D
- m_h = data & 0xf;
-}
-
-WRITE8_MEMBER(tms1024_device::write_s)
-{
- // S0,1,2: select port
- m_s = data & 7;
-}
-
-WRITE_LINE_MEMBER(tms1024_device::write_std)
-{
- state = (state) ? 1 : 0;
-
- // output on rising edge
- if (state && !m_std)
- {
- if (m_s != 0)
- (*m_write_port[m_s-1])((offs_t)(m_s-1), m_h);
- }
-
- m_std = state;
-}
diff --git a/src/emu/machine/tms1024.h b/src/emu/machine/tms1024.h
deleted file mode 100644
index a7bdb4539bf..00000000000
--- a/src/emu/machine/tms1024.h
+++ /dev/null
@@ -1,110 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:hap
-/*
-
- Texas Instruments TMS1024/TMS1025 I/O expander
-
-*/
-
-#ifndef _TMS1024_H_
-#define _TMS1024_H_
-
-#include "emu.h"
-
-
-// ports setup
-
-// 4-bit ports (3210 = DCBA)
-// valid ports: 4-7 for TMS1024, 1-7 for TMS1025
-#define MCFG_TMS1024_WRITE_PORT_CB(X, _devcb) \
- tms1024_device::set_write_port##X##_callback(*device, DEVCB_##_devcb);
-
-enum
-{
- TMS1024_PORT1 = 0,
- TMS1024_PORT2,
- TMS1024_PORT3,
- TMS1024_PORT4,
- TMS1024_PORT5,
- TMS1024_PORT6,
- TMS1024_PORT7
-};
-
-
-// pinout reference
-
-/*
-
- ____ ____ ____ ____
- Vss 1 |* \_/ | 28 H2 Vss 1 |* \_/ | 40 H2
- H3 2 | | 27 H1 H3 2 | | 39 H1
- H4 3 | | 26 Vdd H4 3 | | 38 Vdd
- CE 4 | | 25 S2 CE 4 | | 37 S2
- MS 5 | | 24 S1 MS 5 | | 36 S1
- STD 6 | | 23 S0 STD 6 | | 35 S0
- A4 7 | TMS1024 | 22 D7 A1 7 | | 34 D3
- B4 8 | | 21 C7 B1 8 | | 33 C3
- C4 9 | | 20 B7 C1 9 | | 32 B3
- D4 10 | | 19 A7 D1 10 | TMS1025 | 31 A3
- A5 11 | | 18 D6 A4 11 | | 30 D7
- B5 12 | | 17 C6 B4 12 | | 29 C7
- C5 13 | | 16 B6 C4 13 | | 28 B7
- D5 14 |___________| 15 A6 D4 14 | | 27 A7
- A5 15 | | 26 D6
- B5 16 | | 25 C6
- CE: Chip Enable C5 17 | | 24 B6
- MS: Master S.? D5 18 | | 23 A6
- STD: STrobe Data? A2 19 | | 22 D2
- S: Select B2 20 |___________| 21 C2
- H: Hold?
-
-*/
-
-
-class tms1024_device : public device_t
-{
-public:
- tms1024_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- tms1024_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_write_port1_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port1.set_callback(object); }
- template<class _Object> static devcb_base &set_write_port2_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port2.set_callback(object); }
- template<class _Object> static devcb_base &set_write_port3_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port3.set_callback(object); }
- template<class _Object> static devcb_base &set_write_port4_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port4.set_callback(object); }
- template<class _Object> static devcb_base &set_write_port5_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port5.set_callback(object); }
- template<class _Object> static devcb_base &set_write_port6_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port6.set_callback(object); }
- template<class _Object> static devcb_base &set_write_port7_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port7.set_callback(object); }
-
- DECLARE_WRITE8_MEMBER(write_h);
- DECLARE_WRITE8_MEMBER(write_s);
- DECLARE_WRITE_LINE_MEMBER(write_std);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- UINT8 m_h; // 4-bit data latch
- UINT8 m_s; // 3-bit port select
- UINT8 m_std; // strobe pin
-
- // callbacks
- devcb_write8 m_write_port1, m_write_port2, m_write_port3, m_write_port4, m_write_port5, m_write_port6, m_write_port7;
- devcb_write8 *m_write_port[7];
-};
-
-
-class tms1025_device : public tms1024_device
-{
-public:
- tms1025_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-
-
-extern const device_type TMS1024;
-extern const device_type TMS1025;
-
-
-#endif /* _TMS1024_H_ */
diff --git a/src/emu/machine/tms5501.c b/src/emu/machine/tms5501.c
deleted file mode 100644
index 71f3f298cde..00000000000
--- a/src/emu/machine/tms5501.c
+++ /dev/null
@@ -1,529 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- TMS5501 Multifunction Input/Output Controller emulation
-
-**********************************************************************/
-
-#include "tms5501.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-const UINT8 tms5501_device::rst_vector[] = { 0xc7, 0xcf, 0xd7, 0xdf, 0xe7, 0xef, 0xf7, 0xff };
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-// device type definition
-const device_type TMS5501 = &device_creator<tms5501_device>;
-
-
-// I/O address map
-DEVICE_ADDRESS_MAP_START( io_map, 8, tms5501_device )
- AM_RANGE(0x00, 0x00) AM_READ(rb_r)
- AM_RANGE(0x01, 0x01) AM_READ(xi_r)
- AM_RANGE(0x02, 0x02) AM_READ(rst_r)
- AM_RANGE(0x03, 0x03) AM_READ(sta_r)
- AM_RANGE(0x04, 0x04) AM_WRITE(cmd_w)
- AM_RANGE(0x05, 0x05) AM_WRITE(rr_w)
- AM_RANGE(0x06, 0x06) AM_WRITE(tb_w)
- AM_RANGE(0x07, 0x07) AM_WRITE(xo_w)
- AM_RANGE(0x08, 0x08) AM_WRITE(mr_w)
- AM_RANGE(0x09, 0x0d) AM_WRITE(tmr_w)
-ADDRESS_MAP_END
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// tms5501_device - constructor
-//-------------------------------------------------
-
-tms5501_device::tms5501_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, TMS5501, "TMS5501", tag, owner, clock, "tms5501", __FILE__),
- device_serial_interface(mconfig, *this),
- m_write_irq(*this),
- m_write_xmt(*this),
- m_read_xi(*this),
- m_write_xo(*this),
- m_irq(IRQ_TB),
- m_rb(0),
- m_sta(STA_XBE | STA_SR),
- m_cmd(0),
- m_rr(0),
- m_tb(0),
- m_mr(0),
- m_sens(0),
- m_xi7(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void tms5501_device::device_start()
-{
- // resolve callbacks
- m_write_irq.resolve_safe();
- m_write_xmt.resolve_safe();
- m_read_xi.resolve_safe(0);
- m_write_xo.resolve_safe();
-
- // create timers
- m_timer[TIMER_1] = timer_alloc(TIMER_1);
- m_timer[TIMER_2] = timer_alloc(TIMER_2);
- m_timer[TIMER_3] = timer_alloc(TIMER_3);
- m_timer[TIMER_4] = timer_alloc(TIMER_4);
- m_timer[TIMER_5] = timer_alloc(TIMER_5);
-
- // state saving
- save_item(NAME(m_rb));
- save_item(NAME(m_sta));
- save_item(NAME(m_cmd));
- save_item(NAME(m_rr));
- save_item(NAME(m_tb));
- save_item(NAME(m_mr));
- save_item(NAME(m_sens));
- save_item(NAME(m_xi7));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void tms5501_device::device_reset()
-{
- receive_register_reset();
- transmit_register_reset();
-
- m_write_xmt(1);
-
- check_interrupt();
-}
-
-
-//-------------------------------------------------
-// device_timer - handle timer events
-//-------------------------------------------------
-
-void tms5501_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_1:
- set_interrupt(IRQ_TMR1);
- break;
-
- case TIMER_2:
- set_interrupt(IRQ_TMR2);
- break;
-
- case TIMER_3:
- set_interrupt(IRQ_TMR3);
- break;
-
- case TIMER_4:
- set_interrupt(IRQ_TMR4);
- break;
-
- case TIMER_5:
- if (!(m_cmd & CMD_XI7))
- {
- set_interrupt(IRQ_TMR5);
- }
- break;
-
- default:
- device_serial_interface::device_timer(timer, id, param, ptr);
- }
-}
-
-
-//-------------------------------------------------
-// tra_callback -
-//-------------------------------------------------
-
-void tms5501_device::tra_callback()
-{
- m_write_xmt(transmit_register_get_data_bit());
-}
-
-
-//-------------------------------------------------
-// tra_complete -
-//-------------------------------------------------
-
-void tms5501_device::tra_complete()
-{
- if (!(m_sta & STA_XBE))
- {
- transmit_register_setup(m_tb);
-
- m_sta |= STA_XBE;
-
- set_interrupt(IRQ_TB);
- }
-}
-
-
-//-------------------------------------------------
-// rcv_complete -
-//-------------------------------------------------
-
-void tms5501_device::rcv_complete()
-{
- receive_register_extract();
- m_rb = get_received_char();
-
- if (is_receive_framing_error())
- {
- m_sta |= STA_FE;
- }
- else
- {
- m_sta &= ~STA_FE;
- }
-
- if (m_sta & STA_RBL)
- {
- m_sta |= STA_OE;
- }
-
- m_sta |= (STA_RBL | STA_SR);
- m_sta &= ~(STA_SBD | STA_FBD);
-
- set_interrupt(IRQ_RB);
-}
-
-
-//-------------------------------------------------
-// rb_r - read receiver buffer
-//-------------------------------------------------
-
-READ8_MEMBER( tms5501_device::rb_r )
-{
- m_sta &= ~STA_RBL;
- m_irq &= ~IRQ_RB;
-
- check_interrupt();
-
- return m_rb;
-}
-
-
-//-------------------------------------------------
-// xi_r - read external inputs
-//-------------------------------------------------
-
-READ8_MEMBER( tms5501_device::xi_r )
-{
- UINT8 data = m_read_xi(0);
-
- if (m_cmd & CMD_XI7)
- {
- data = (m_xi7 << 7) | (data & 0x7f);
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// rst_r - read interrupt address
-//-------------------------------------------------
-
-READ8_MEMBER( tms5501_device::rst_r )
-{
- return get_vector();
-}
-
-
-//-------------------------------------------------
-// sta_r - read TMS5510 status
-//-------------------------------------------------
-
-READ8_MEMBER( tms5501_device::sta_r )
-{
- UINT8 data = m_sta;
-
- m_sta &= ~STA_OE;
-
- return data;
-}
-
-
-//-------------------------------------------------
-// cmd_w - issue discrete commands
-//-------------------------------------------------
-
-WRITE8_MEMBER( tms5501_device::cmd_w )
-{
- if (LOG) logerror("TMS5501 '%s' Command %02x\n", tag(), data);
-
- m_cmd = data;
-
- if (m_cmd & CMD_RST)
- {
- m_sta &= ~(STA_SBD | STA_FBD | STA_RBL | STA_OE);
- m_sta |= (STA_XBE | STA_SR);
-
- receive_register_reset();
- transmit_register_reset();
-
- m_write_xmt(1);
-
- m_irq = 0;
- set_interrupt(IRQ_TB);
-
- m_timer[TIMER_1]->enable(false);
- m_timer[TIMER_2]->enable(false);
- m_timer[TIMER_3]->enable(false);
- m_timer[TIMER_4]->enable(false);
- m_timer[TIMER_5]->enable(false);
- }
- else if (m_cmd & CMD_BRK)
- {
- receive_register_reset();
- transmit_register_reset();
-
- m_write_xmt(0);
- }
-}
-
-
-//-------------------------------------------------
-// rr_w - load rate register
-//-------------------------------------------------
-
-WRITE8_MEMBER( tms5501_device::rr_w )
-{
- if (LOG) logerror("TMS5501 '%s' Rate Register %02x\n", tag(), data);
-
- m_rr = data;
-
- stop_bits_t stop_bits = (m_rr & RR_STOP) ? STOP_BITS_1 : STOP_BITS_2;
-
- set_data_frame(1, 8, PARITY_NONE, stop_bits);
-
- int rate = 0;
-
- if (m_rr & RR_9600) rate = 9600;
- else if (m_rr & RR_4800) rate = 4800;
- else if (m_rr & RR_2400) rate = 2400;
- else if (m_rr & RR_1200) rate = 1200;
- else if (m_rr & RR_300) rate = 300;
- else if (m_rr & RR_150) rate = 150;
- else if (m_rr & RR_110) rate = 110;
-
- if (m_cmd & CMD_TST1)
- {
- rate *= 8;
- }
-
- set_rcv_rate(rate);
- set_tra_rate(rate);
-}
-
-
-//-------------------------------------------------
-// tb_w - load transmitter buffer
-//-------------------------------------------------
-
-WRITE8_MEMBER( tms5501_device::tb_w )
-{
- if (LOG) logerror("TMS5501 '%s' Transmitter Buffer %02x\n", tag(), data);
-
- m_tb = data;
-
- if (is_transmit_register_empty())
- {
- transmit_register_setup(m_tb);
-
- m_sta |= STA_XBE;
-
- set_interrupt(IRQ_TB);
- }
- else
- {
- m_sta &= ~STA_XBE;
- }
-}
-
-
-//-------------------------------------------------
-// xo_w - load output port
-//-------------------------------------------------
-
-WRITE8_MEMBER( tms5501_device::xo_w )
-{
- if (LOG) logerror("TMS5501 '%s' Output %02x\n", tag(), data);
-
- m_write_xo(data);
-}
-
-
-//-------------------------------------------------
-// mr_w - load mask register
-//-------------------------------------------------
-
-WRITE8_MEMBER( tms5501_device::mr_w )
-{
- if (LOG) logerror("TMS5501 '%s' Mask Register %02x\n", tag(), data);
-
- m_mr = data;
-
- check_interrupt();
-}
-
-
-//-------------------------------------------------
-// tmr_w - load interval timer
-//-------------------------------------------------
-
-WRITE8_MEMBER( tms5501_device::tmr_w )
-{
- if (LOG) logerror("TMS5501 '%s' Timer %u %02x\n", tag(), offset, data);
-
- m_timer[offset]->adjust(attotime::from_double((double) data / (clock() / 128.0)));
-}
-
-
-//-------------------------------------------------
-// rcv_w - receive data write
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( tms5501_device::rcv_w )
-{
- device_serial_interface::rx_w(state);
-
- if (is_receive_register_synchronized())
- {
- m_sta |= STA_SBD;
- m_sta &= ~STA_SR;
- }
-
- if (is_receive_register_shifting())
- {
- m_sta |= STA_FBD;
- }
-}
-
-
-//-------------------------------------------------
-// xi7_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( tms5501_device::xi7_w )
-{
- if (m_cmd & CMD_XI7)
- {
- if (!m_xi7 && state)
- {
- set_interrupt(IRQ_XI7);
- }
- }
-
- m_xi7 = state;
-}
-
-
-//-------------------------------------------------
-// sens_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( tms5501_device::sens_w )
-{
- if (!m_sens && state)
- {
- set_interrupt(IRQ_SENS);
- }
-
- m_sens = state;
-}
-
-
-//-------------------------------------------------
-// set_interrupt -
-//-------------------------------------------------
-
-void tms5501_device::set_interrupt(UINT8 mask)
-{
- m_irq |= mask;
-
- if (LOG) logerror("TMS5501 '%s' Interrupt %02x\n", tag(), mask);
-
- check_interrupt();
-}
-
-
-//-------------------------------------------------
-// check_interrupt -
-//-------------------------------------------------
-
-void tms5501_device::check_interrupt()
-{
- int state = (m_irq & m_mr) ? ASSERT_LINE : CLEAR_LINE;
-
- if (state == ASSERT_LINE)
- {
- if (LOG) logerror("TMS5501 '%s' Interrupt Assert\n", tag());
-
- m_sta |= STA_IP;
- }
- else
- {
- m_sta &= ~STA_IP;
- }
-
- if (m_cmd & CMD_IAE)
- {
- m_write_irq(state);
- }
- else
- {
- m_write_irq(CLEAR_LINE);
- }
-}
-
-
-//-------------------------------------------------
-// get_vector -
-//-------------------------------------------------
-
-UINT8 tms5501_device::get_vector()
-{
- UINT8 rst = 0;
-
- for (int i = 0; i < 8; i++)
- {
- if (BIT((m_irq & m_mr), i))
- {
- rst = rst_vector[i];
- m_irq &= ~(1 << i);
-
- check_interrupt();
-
- if (LOG) logerror("%s: TMS5501 '%s' Interrupt Acknowledge %02x\n", machine().describe_context(), tag(), rst);
- break;
- }
- }
-
- return rst;
-}
diff --git a/src/emu/machine/tms5501.h b/src/emu/machine/tms5501.h
deleted file mode 100644
index 0a62f751910..00000000000
--- a/src/emu/machine/tms5501.h
+++ /dev/null
@@ -1,195 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- TMS5501 Multifunction Input/Output Controller emulation
-
-**********************************************************************
- _____ _____
- Vbb 1 |* \_/ | 40 XMT
- Vcc 2 | | 39 XI0
- Vdd 3 | | 38 XI1
- VSS 4 | | 37 XI2
- RCV 5 | | 36 XI3
- D7 6 | | 35 XI4
- D6 7 | | 34 XI5
- D5 8 | | 33 XI6
- D4 9 | | 32 XI7
- D3 10 | | 31 _XO7
- D2 11 | TMS5501 | 30 _XO6
- D1 12 | | 29 _XO5
- D0 13 | | 28 _XO4
- A0 14 | | 27 _XO3
- A1 15 | | 26 _XO2
- A2 16 | | 25 _XO1
- A3 17 | | 24 _XO0
- CE 18 | | 23 INT
- SYNC 19 | | 22 SENS
- phi1 20 |_____________| 21 phi2
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __TMS5501__
-#define __TMS5501__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_TMS5501_IRQ_CALLBACK(_write) \
- devcb = &tms5501_device::set_irq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_TMS5501_XMT_CALLBACK(_write) \
- devcb = &tms5501_device::set_xmt_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_TMS5501_XI_CALLBACK(_read) \
- devcb = &tms5501_device::set_xi_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_TMS5501_XO_CALLBACK(_write) \
- devcb = &tms5501_device::set_xo_wr_callback(*device, DEVCB_##_write);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> tms5501_device
-
-class tms5501_device : public device_t,
- public device_serial_interface
-{
-public:
- // construction/destruction
- tms5501_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<tms5501_device &>(device).m_write_irq.set_callback(object); }
- template<class _Object> static devcb_base &set_xmt_wr_callback(device_t &device, _Object object) { return downcast<tms5501_device &>(device).m_write_xmt.set_callback(object); }
- template<class _Object> static devcb_base &set_xi_rd_callback(device_t &device, _Object object) { return downcast<tms5501_device &>(device).m_read_xi.set_callback(object); }
- template<class _Object> static devcb_base &set_xo_wr_callback(device_t &device, _Object object) { return downcast<tms5501_device &>(device).m_write_xo.set_callback(object); }
-
- virtual DECLARE_ADDRESS_MAP(io_map, 8);
-
- DECLARE_WRITE_LINE_MEMBER( rcv_w );
-
- DECLARE_WRITE_LINE_MEMBER( sens_w );
- DECLARE_WRITE_LINE_MEMBER( xi7_w );
-
- UINT8 get_vector();
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_serial_interface overrides
- virtual void tra_callback();
- virtual void tra_complete();
- virtual void rcv_complete();
-
- DECLARE_READ8_MEMBER( rb_r );
- DECLARE_READ8_MEMBER( xi_r );
- DECLARE_READ8_MEMBER( rst_r );
- DECLARE_READ8_MEMBER( sta_r );
- DECLARE_WRITE8_MEMBER( cmd_w );
- DECLARE_WRITE8_MEMBER( rr_w );
- DECLARE_WRITE8_MEMBER( tb_w );
- DECLARE_WRITE8_MEMBER( xo_w );
- DECLARE_WRITE8_MEMBER( mr_w );
- DECLARE_WRITE8_MEMBER( tmr_w );
-
-private:
- enum
- {
- TIMER_1 = 0,
- TIMER_2,
- TIMER_3,
- TIMER_4,
- TIMER_5
- };
-
- enum
- {
- IRQ_TMR1 = 0x01,
- IRQ_TMR2 = 0x02,
- IRQ_SENS = 0x04,
- IRQ_TMR3 = 0x08,
- IRQ_RB = 0x10,
- IRQ_TB = 0x20,
- IRQ_TMR4 = 0x40,
- IRQ_TMR5 = 0x80,
- IRQ_XI7 = 0x80
- };
-
- enum
- {
- STA_FE = 0x01,
- STA_OE = 0x02,
- STA_SR = 0x04,
- STA_RBL = 0x08,
- STA_XBE = 0x10,
- STA_IP = 0x20,
- STA_FBD = 0x40,
- STA_SBD = 0x80
- };
-
- enum
- {
- CMD_RST = 0x01,
- CMD_BRK = 0x02,
- CMD_XI7 = 0x04,
- CMD_IAE = 0x08,
- CMD_TST1 = 0x10,
- CMD_TST2 = 0x20
- };
-
- enum
- {
- RR_110 = 0x01,
- RR_150 = 0x02,
- RR_300 = 0x04,
- RR_1200 = 0x08,
- RR_2400 = 0x10,
- RR_4800 = 0x20,
- RR_9600 = 0x40,
- RR_STOP = 0x80
- };
-
- static const UINT8 rst_vector[];
-
- void set_interrupt(UINT8 mask);
- void check_interrupt();
-
- devcb_write_line m_write_irq;
- devcb_write_line m_write_xmt;
- devcb_read8 m_read_xi;
- devcb_write8 m_write_xo;
-
- UINT8 m_irq;
- UINT8 m_rb;
- UINT8 m_sta;
- UINT8 m_cmd;
- UINT8 m_rr;
- UINT8 m_tb;
- UINT8 m_mr;
-
- int m_sens;
- int m_xi7;
-
- emu_timer *m_timer[5];
-};
-
-
-// device type definition
-extern const device_type TMS5501;
-
-
-
-#endif
diff --git a/src/emu/machine/tms6100.c b/src/emu/machine/tms6100.c
deleted file mode 100644
index 7d0f3226ca5..00000000000
--- a/src/emu/machine/tms6100.c
+++ /dev/null
@@ -1,264 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Couriersud
-/**********************************************************************************************
-
- TMS6100 simulator
-
- Written for MAME by Couriersud
-
- Todo:
- - implement CS
- - implement 4 bit mode (mask programmed)
- - implement chip addressing (0-15 mask programmed)
-
- TMS6100:
-
- +-----------------+
- VDD | 1 28 | NC
- NC | 2 27 | NC
- DATA/ADD1 | 3 26 | NC
- DATA/ADD2 | 4 25 | NC
- DATA/ADD4 | 5 24 | NC
- DATA/ADD8 | 6 23 | NC
- CLK | 7 22 | NC
- NC | 8 21 | NC
- NC | 9 20 | NC
- M0 | 10 19 | NC
- M1 | 11 18 | NC
- NC | 12 17 | NC
- /CS | 13 16 | NC
- VSS | 14 15 | NC
- +-----------------+
-
- TMS6125:
-
- +---------+
- DATA/ADD1 | 1 16 | NC
- DATA/ADD2 | 2 15 | NC
- DATA/ADD4 | 3 14 | NC
- DATA/ADD8 | 4 13 | NC
- CLK | 5 12 | VDD
- NC | 6 11 | /CS
- NC | 7 10 | M1
- M0 | 8 9 | VSS
- +---------+
-
- M58819 (from radarscope schematics):
-
- +-----------------+
- AD0 | 1 40 | AD1
- GND | 2 39 | AD2
- -5V | 3 38 | AD3
- A0 | 4 37 | AD4
- NC | 5 36 | AD5
- NC | 6 35 | AD6
- A1 | 7 34 | AD7
- A2 | 8 33 | AD8
- A3 | 9 32 | AD9
- CLK | 10 31 | AD10
- NC | 11 30 | AD11
- -5V | 12 29 | AD12
- C0 | 13 28 | NC
- C1 | 14 27 | NC
- NC | 15 26 | I7
- NC | 16 25 | NC
- +5V | 17 24 | I6
- I0 | 18 23 | I5
- I1 | 19 22 | I4
- I2 | 20 21 | I3
- +-----------------+
-
- The M58819 is used as an interface to external speech eproms.
- NC pins may have a function, although they are not connected in
- radarscope.
-
-***********************************************************************************************/
-
-#include "emu.h"
-#include "tms6100.h"
-
-#define VERBOSE (0)
-
-#if VERBOSE
-#define LOG(x) logerror x
-#else
-#define LOG(x)
-#endif
-
-#define TMS6100_READ_PENDING 0x01
-#define TMS6100_NEXT_READ_IS_DUMMY 0x02
-
-/* Variants */
-
-#define TMS6110_IS_TMS6100 (1)
-#define TMS6110_IS_M58819 (2)
-
-
-const device_type TMS6100 = &device_creator<tms6100_device>;
-
-tms6100_device::tms6100_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_rom(*this, DEVICE_SELF)
-{
-}
-
-tms6100_device::tms6100_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, TMS6100, "TMS6100", tag, owner, clock, "tms6100", __FILE__),
- m_rom(*this, DEVICE_SELF)
-{
-}
-
-const device_type M58819 = &device_creator<m58819_device>;
-
-m58819_device::m58819_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : tms6100_device(mconfig, M58819, "M58819 Memory Controller", tag, owner, clock, "m58819", __FILE__)
-{
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void tms6100_device::device_config_complete()
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void tms6100_device::device_start()
-{
- // save device variables
- save_item(NAME(m_addr_bits));
- save_item(NAME(m_address));
- save_item(NAME(m_address_latch));
- save_item(NAME(m_tms_clock));
- save_item(NAME(m_data));
- save_item(NAME(m_loadptr));
- save_item(NAME(m_m0));
- save_item(NAME(m_m1));
- save_item(NAME(m_state));
- save_item(NAME(m_variant));
- set_variant(TMS6110_IS_TMS6100);
-
-}
-
-void m58819_device::device_start()
-{
- tms6100_device::device_start();
- set_variant(TMS6110_IS_M58819);
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void tms6100_device::device_reset()
-{
- /* initialize the chip */
- m_addr_bits = 0;
- m_address = 0;
- m_address_latch = 0;
- m_loadptr = 0;
- m_m0 = 0;
- m_m1 = 0;
- m_state = 0;
- m_tms_clock = 0;
- m_data = 0;
-}
-
-void tms6100_device::set_variant(int variant)
-{
- m_variant = variant;
-}
-
-WRITE_LINE_MEMBER(tms6100_device::tms6100_m0_w)
-{
- if (state != m_m0)
- m_m0 = state;
-}
-
-WRITE_LINE_MEMBER(tms6100_device::tms6100_m1_w)
-{
- if (state != m_m1)
- m_m1 = state;
-}
-
-WRITE_LINE_MEMBER(tms6100_device::tms6100_romclock_w)
-{
- /* process on falling edge */
- if (m_tms_clock && !state)
- {
- switch ((m_m1<<1) | m_m0)
- {
- case 0x00:
- /* NOP in datasheet, not really ... */
- if (m_state & TMS6100_READ_PENDING)
- {
- if (m_state & TMS6100_NEXT_READ_IS_DUMMY)
- {
- m_address = (m_address_latch << 3);
- m_address_latch = 0;
- m_loadptr = 0;
- m_state &= ~TMS6100_NEXT_READ_IS_DUMMY;
- LOG(("loaded address %08x\n", m_address));
- }
- else
- {
- /* read bit at address */
- if (m_variant == TMS6110_IS_M58819)
- {
- m_data = (m_rom[m_address >> 3] >> (7-(m_address & 0x07))) & 1;
- }
- else // m_variant == (TMS6110_IS_TMS6100 || TMS6110_IS_TMS6125)
- {
- m_data = (m_rom[m_address >> 3] >> (m_address & 0x07)) & 1;
- }
- m_address++;
- }
- m_state &= ~TMS6100_READ_PENDING;
- }
- break;
- case 0x01:
- /* READ */
- m_state |= TMS6100_READ_PENDING;
- break;
- case 0x02:
- /* LOAD ADDRESS */
- m_state |= TMS6100_NEXT_READ_IS_DUMMY;
- m_address_latch |= (m_addr_bits << m_loadptr);
- LOG(("loaded address latch %08x\n", m_address_latch));
- m_loadptr += 4;
- break;
- case 0x03:
- /* READ AND BRANCH */
- if (m_state & TMS6100_NEXT_READ_IS_DUMMY)
- {
- m_state &= ~TMS6100_NEXT_READ_IS_DUMMY; // clear - no dummy read according to datasheet
- LOG(("loaded address latch %08x\n", m_address_latch));
- m_address = m_rom[m_address_latch] | (m_rom[m_address_latch+1]<<8);
- m_address &= 0x3fff; // 14 bits
- LOG(("loaded indirect address %04x\n", m_address));
- m_address = (m_address << 3);
- m_address_latch = 0;
- m_loadptr = 0;
- }
- break;
- }
- }
- m_tms_clock = state;
-}
-
-WRITE8_MEMBER(tms6100_device::tms6100_addr_w)
-{
- if (data != m_addr_bits)
- m_addr_bits = data;
-}
-
-READ_LINE_MEMBER(tms6100_device::tms6100_data_r)
-{
- return m_data;
-}
diff --git a/src/emu/machine/tms6100.h b/src/emu/machine/tms6100.h
deleted file mode 100644
index 4aed02a846b..00000000000
--- a/src/emu/machine/tms6100.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Couriersud
-#pragma once
-
-#ifndef __TMS6100_H__
-#define __TMS6100_H__
-
-/* TMS 6100 memory controller */
-
-class tms6100_device : public device_t
-{
-public:
- tms6100_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- tms6100_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- DECLARE_WRITE_LINE_MEMBER( tms6100_m0_w );
- DECLARE_WRITE_LINE_MEMBER( tms6100_m1_w );
- DECLARE_WRITE_LINE_MEMBER( tms6100_romclock_w );
- DECLARE_WRITE8_MEMBER( tms6100_addr_w );
-
- DECLARE_READ_LINE_MEMBER( tms6100_data_r );
-
-protected:
- // device-level overrides
- virtual void device_config_complete();
- virtual void device_start();
- virtual void device_reset();
- void set_variant(int variant);
-private:
- // internal state
- required_region_ptr<UINT8> m_rom;
- UINT32 m_address;
- UINT32 m_address_latch;
- UINT8 m_loadptr;
- UINT8 m_m0;
- UINT8 m_m1;
- UINT8 m_addr_bits;
- UINT8 m_tms_clock;
- UINT8 m_data;
- UINT8 m_state;
- UINT8 m_variant;
-
-};
-
-extern const device_type TMS6100;
-
-class m58819_device : public tms6100_device
-{
-public:
- m58819_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- // device-level overrides
- virtual void device_start();
-};
-
-extern const device_type M58819;
-
-
-#endif /* __TMS6100_H__ */
diff --git a/src/emu/machine/tms9901.c b/src/emu/machine/tms9901.c
deleted file mode 100644
index 8ca2f4b2bf7..00000000000
--- a/src/emu/machine/tms9901.c
+++ /dev/null
@@ -1,630 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Michael Zapf
-/****************************************************************************
-
- TMS9901 Programmable System Interface
-
- +--------------+
- RST1*| 1 | | 40| Vcc
- CRUOUT | 2 +--+ 39| S0
- CRUCLK | 3 38| P0
- CRUIN | 4 37| P1
- CE*| 5 36| S1
- INT6*| 6 35| S2
- INT5*| 7 34| INT7* / P15
- INT4*| 8 33| INT8* / P14
- INT3*| 9 32| INT9* / P13
- Phi*|10 31| INT10* / P12
- INTREQ*|11 30| INT11* / P11
- IC3 |12 29| INT12* / P10
- IC2 |13 28| INT13* / P9
- IC1 |14 27| INT14* / P8
- IC0 |15 26| P2
- Vss |16 25| S3
- INT1*|17 24| S4
- INT2*|18 23| INT15* / P7
- P6 |19 22| P3
- P5 |20 21| P4
- +--------------+
-
-Overview:
- TMS9901 is a support chip for TMS9900. It handles interrupts, provides
- several I/O pins, and a timer (a.k.a. clock: it is merely a register which
- decrements regularly and can generate an interrupt when it reaches 0).
-
- It communicates with the TMS9900 with the CRU bus, and with the rest of the
- world with a number of parallel I/O pins.
-
- I/O and timer functions should work with any other 990/99xx/99xxx CPU.
- On the other hand, interrupt handling was primarily designed for tms9900
- and 99000 based systems: other CPUs can support interrupts, but not the 16
- distinct interrupt vectors.
-
-Pins:
- Vcc, Vss: power supply
- Phi*: system clock (connected to TMS9900 Phi3* or TMS9980 CLKOUT*)
- RST1*: reset input
- CRUIN, CRUOUT, CRUCLK, CE*, S0-S4: CRU bus (CPU interface)
- INTREQ*, IC0-IC3: interrupt bus (CPU interface)
- INT*1-INT*6: used as interrupt/input pins.
- P0-P6: used as input/output pins.
- INT*7/P15-INT*15/P7: used as either interrupt/input or input/output pins.
- Note that a pin cannot be used simultaneously as output and as interrupt.
- (This is mostly obvious, but it implies that you cannot trigger an
- interrupt by setting the output state of a pin, which is not SO obvious.)
-
-Interrupt handling:
- After each clock cycle, TMS9901 latches the state of INT1*-INT15* (except
- pins which are set as output pins). If the clock is enabled, it replaces
- INT3* with an internal timer interrupt flag. Then it inverts the value and
- performs a bit-wise AND with the interrupt mask.
-
- If there are some unmasked interrupt bits, INTREQ* is asserted and the code
- of the lowest active interrupt is placed on IC0-IC3. If these pins are
- duly connected to the tms9900 INTREQ* and IC0-IC3 pins, the result is that
- asserting an INTn* on tms9901 will cause a level-n interrupt request on the
- tms9900, provided that this interrupt pin is not masked in tms9901, and
- that no unmasked higher-priority (i.e. lower-level) interrupt pin is set.
-
- This interrupt request lasts for as long as the interrupt pin and the
- relevant bit in the interrupt mask are set (level-triggered interrupts).
- (The request may be shadowed by a higher-priority interrupt request, but
- it will resume when the higher-priority request ends.)
-
- TIMER interrupts are kind of an exception, since they are not associated
- with an external interrupt pin. I think there is an internal timer
- interrupt flag that is set when the decrementer reaches 0, and is cleared
- by a write to the 9901 int*3 enable bit ("SBO 3" in interrupt mode).
-
-TODO:
- * Emulate the RST1* input. Note that RST1* active (low) makes INTREQ*
- inactive (high) with IC0-IC3 = 0.
- * the clock read register is updated every time the timer decrements when
- the TMS9901 is not in clock mode. This probably implies that if the
- clock mode is cleared and re-asserted immediately, the tms9901 may fail
- to update the clock read register: this is not emulated.
- * The clock mode is entered when a 1 is written to the control bit. It is
- exited when a 0 is written to the control bit or the a tms9901 select bit
- greater than 15 is accessed. According to the data sheet, "when CE* is
- inactive (HIGH), the PSI is not disabled from seeing the select lines.
- As the CPU is accessing memory, A10-A14 could very easily have a value of
- 15 or greater" (this is assuming that S0-S4 are connected to A10-A14,
- which makes sense with most tms9900 family members). There is no way
- this "feature" (I would call it a hardware bug) can be emulated
- efficiently, as we would need to watch every memory access.
-
-MZ: According to the description in
- A. Osborne, G. Kane: Osborne 16-bit microprocessor handbook
- page 3-81
- the 9901 only temporarily leaves the timer mode as long as S0 is set to 1.
- In the meantime the timer function continues but cannot be queried. This
- makes it possible to continue using the chip as a timer while working with
- its I/O pins. Thus I believe the above TODO concering the exit of the timer
- mode is not applicable.
- The problem is that the original 9901 specification is not clear about this.
-
-MZ: Turned to class (January 2012)
-
-TODO: Tests on a real machine
-- Set an interrupt input (e.g. keyboard for Geneve), trigger RST2*, check whether
- interrupt mask has been reset
-- Check whether the clock_read_register is updated whenever clock mode is exited
- (in particular when S0=1, i.e. A10=1 -> addresses xxxx xxxx xx1x xxxx
- requires to write a program that fits into 32 bytes; workspace elsewhere)
-
- Raphael Nabet, 2000-2004
- Michael Zapf
-
- February 2012: Rewritten as class
-
-*****************************************************************************/
-
-#include <math.h>
-#include "emu.h"
-
-#include "tms9901.h"
-
-/*
- Debugging flags.
-*/
-#define TRACE_PINS 0
-#define TRACE_CLOCK 0
-#define TRACE_MODE 0
-
-/*
- Constructor
-*/
-tms9901_device::tms9901_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
-: device_t(mconfig, TMS9901, "TMS9901 Programmable System Interface", tag, owner, clock, "tms9901", __FILE__),
- m_read_block(*this),
- m_write_p0(*this),
- m_write_p1(*this),
- m_write_p2(*this),
- m_write_p3(*this),
- m_write_p4(*this),
- m_write_p5(*this),
- m_write_p6(*this),
- m_write_p7(*this),
- m_write_p8(*this),
- m_write_p9(*this),
- m_write_p10(*this),
- m_write_p11(*this),
- m_write_p12(*this),
- m_write_p13(*this),
- m_write_p14(*this),
- m_write_p15(*this),
- m_interrupt(*this)
-{
-}
-
-/*
- should be called after any change to int_state or enabled_ints.
-*/
-void tms9901_device::field_interrupts(void)
-{
- int current_ints;
-
- // m_int_state: inverted state of lines INT1*-INT15*. Bits are set by set_single_int only.
- current_ints = m_int_state;
- if (m_clock_register != 0)
- {
- // if timer is enabled, INT3 pin is overridden by timer
- if (m_timer_int_pending)
- {
- if (TRACE_CLOCK) logerror("%s: timer fires\n", tag());
- current_ints |= TMS9901_INT3;
- }
- else
- {
- if (TRACE_CLOCK) logerror("%s: timer clear\n", tag());
- current_ints &= ~TMS9901_INT3;
- }
- }
-
- // enabled_ints: enabled interrupts
- // Remove all settings from pins that are set as outputs (INT7*-INT15* share the same pins as P15-P7)
- current_ints &= m_enabled_ints & (~m_pio_direction_mirror);
-
- // Check whether we have a new state. For systems that use level-triggered
- // interrupts it should not do any harm if the line is re-asserted
- // but we may as well avoid this.
- if (current_ints == m_old_int_state)
- return;
-
- m_old_int_state = current_ints;
-
- if (current_ints != 0)
- {
- // find which interrupt tripped us:
- // the number of the first (i.e. least significant) non-zero bit among
- // the 16 first bits
- // we simply look for the first bit set to 1 in current_ints...
- int level = 0;
-
- while ((current_ints & 1)==0)
- {
- current_ints >>= 1; /* try next bit */
- level++;
- }
- m_int_pending = true;
- if (!m_interrupt.isnull())
- m_interrupt(level, 1, 0xff); // the offset carries the IC0-3 level
- }
- else
- {
- m_int_pending = false;
- if (!m_interrupt.isnull())
- m_interrupt(0xf, 0, 0xff); //Spec: INTREQ*=1 <=> IC0,1,2,3 = 1111
- }
-}
-
-/*
- function which should be called by the driver when the state of an INTn*
- pin changes (only required if the pin is set up as an interrupt pin)
-
- state == CLEAR_LINE: INTn* is inactive (high)
- state == ASSERT_LINE: INTn* is active (low)
-
- 0<=pin_number<=15
-*/
-void tms9901_device::set_single_int(int pin_number, int state)
-{
- /* remember new state of INTn* pin state */
- if (state==ASSERT_LINE)
- m_int_state |= 1 << pin_number;
- else
- m_int_state &= ~(1 << pin_number);
-
- field_interrupts();
-}
-
-/*
- load the content of m_clock_register into the decrementer
-*/
-void tms9901_device::timer_reload(void)
-{
- if (m_clock_register != 0)
- { /* reset clock interval */
- m_decrementer_value = m_clock_register;
- m_decrementer->enable(true);
- }
- else
- { /* clock interval == 0 -> no timer */
- m_decrementer->enable(false);
- }
-}
-
-/*----------------------------------------------------------------
- TMS9901 CRU interface.
-----------------------------------------------------------------*/
-
-/*
- Read a 8 bit chunk from tms9901.
-
- signification:
- bit 0: m_clock_mode
- if (m_clock_mode == false)
- bit 1-15: current status of the INT1*-INT15* pins
- else
- bit 1-14: current timer value
- bit 15: value of the INTREQ* (interrupt request to TMS9900) pin.
-
- bit 16-31: current status of the P0-P15 pins (quits timer mode, too...)
-*/
-READ8_MEMBER( tms9901_device::read )
-{
- int answer = 0;
-
- offset &= 0x003;
-
- switch (offset)
- {
- case 0:
- if (m_clock_mode)
- {
- // Clock mode. The LSB reflects the CB bit which is set to 1 for clock mode.
- answer = ((m_clock_read_register & 0x7F) << 1) | 0x01;
- }
- else
- {
- // Interrupt mode
- // Note that we rely on the read function to deliver the same
- // INTx levels that have been signaled via the set_single_int method.
- // This may mean that those levels must be latched by the callee.
- if (!m_read_block.isnull())
- answer |= m_read_block(TMS9901_CB_INT7);
-
- // Remove the bits that are set as outputs (can only be INT7*)
- answer &= ~m_pio_direction_mirror;
-
- // Set those bits here
- answer |= (m_pio_output_mirror & m_pio_direction_mirror) & 0xFF;
- }
- if (TRACE_PINS) logerror("%s: input on lines INT7..CB = %02x\n", tag(), answer);
- break;
- case 1:
- if (m_clock_mode)
- {
- // clock mode
- answer = (m_clock_read_register & 0x3F80) >> 7;
- if (!m_int_pending)
- answer |= 0x80;
- }
- else
- {
- // See above concerning the INT levels.
- if (!m_read_block.isnull())
- answer |= m_read_block(TMS9901_INT8_INT15);
-
- // Remove the bits that are set as outputs (can be any line)
- answer &= ~(m_pio_direction_mirror >> 8);
- answer |= (m_pio_output_mirror & m_pio_direction_mirror) >> 8;
- }
- if (TRACE_PINS) logerror("%s: input on lines INT15..INT8 = %02x\n", tag(), answer);
- break;
- case 2:
- /* exit timer mode */
- // MZ: See comments at the beginning. I'm sure that we do not quit clock mode.
- // m_clock_mode = false;
-
- if (!m_read_block.isnull())
- answer = m_read_block(TMS9901_P0_P7);
- else
- answer = 0;
-
- answer &= ~m_pio_direction;
- answer |= (m_pio_output & m_pio_direction) & 0xFF;
- if (TRACE_PINS) logerror("%s: input on lines P7..P0 = %02x\n", tag(), answer);
-
- break;
- case 3:
- // MZ: see above
- // m_clock_mode = false;
- if (!m_read_block.isnull())
- answer = m_read_block(TMS9901_P8_P15);
- else
- answer = 0;
-
- answer &= ~(m_pio_direction >> 8);
- answer |= (m_pio_output & m_pio_direction) >> 8;
- if (TRACE_PINS) logerror("%s: input on lines P15..P8 = %02x\n", tag(), answer);
-
- break;
- }
-
- return answer;
-}
-
-/*
- Write 1 bit to tms9901.
-
- signification:
- bit 0: write m_clock_mode
- if (!m_clock_mode)
- bit 1-15: write interrupt mask register
- else
- bit 1-14: write timer period
- bit 15: if written value == 0, soft reset (just resets all I/O pins as input)
-
- bit 16-31: set output state of P0-P15 (and set them as output pin) (quit timer mode, too...)
-*/
-WRITE8_MEMBER ( tms9901_device::write )
-{
- data &= 1; /* clear extra bits */
- offset &= 0x01F;
-
- if (offset >= 0x10)
- {
- int pin = offset & 0x0F;
- if (TRACE_PINS) logerror("%s: output on P%d = %d\n", tag(), pin, data);
-
- int bit = (1 << pin);
-
- // MZ: see above - I think this is wrong
- // m_clock_mode = false; // exit timer mode
-
- // Once a value is written to a pin, the pin remains in output mode
- // until the chip is reset
- m_pio_direction |= bit;
-
- // Latch the value
- if (data)
- m_pio_output |= bit;
- else
- m_pio_output &= ~bit;
-
- if (pin >= 7)
- {
- // pins P7-P15 are mirrored as INT15*-INT7*,
- // also using the same pins in the package
- int mirror_bit = (1 << (22 - pin));
-
- // See above
- m_pio_direction_mirror |= mirror_bit;
-
- if (data)
- m_pio_output_mirror |= mirror_bit;
- else
- m_pio_output_mirror &= ~mirror_bit;
- }
-
- switch (offset)
- {
- case 0x10:
- if (!m_write_p0.isnull()) m_write_p0(data); break;
- case 0x11:
- if (!m_write_p1.isnull()) m_write_p1(data); break;
- case 0x12:
- if (!m_write_p2.isnull()) m_write_p2(data); break;
- case 0x13:
- if (!m_write_p3.isnull()) m_write_p3(data); break;
- case 0x14:
- if (!m_write_p4.isnull()) m_write_p4(data); break;
- case 0x15:
- if (!m_write_p5.isnull()) m_write_p5(data); break;
- case 0x16:
- if (!m_write_p6.isnull()) m_write_p6(data); break;
- case 0x17:
- if (!m_write_p7.isnull()) m_write_p7(data); break;
- case 0x18:
- if (!m_write_p8.isnull()) m_write_p8(data); break;
- case 0x19:
- if (!m_write_p9.isnull()) m_write_p9(data); break;
- case 0x1A:
- if (!m_write_p10.isnull()) m_write_p10(data); break;
- case 0x1B:
- if (!m_write_p11.isnull()) m_write_p11(data); break;
- case 0x1C:
- if (!m_write_p12.isnull()) m_write_p12(data); break;
- case 0x1D:
- if (!m_write_p13.isnull()) m_write_p13(data); break;
- case 0x1E:
- if (!m_write_p14.isnull()) m_write_p14(data); break;
- case 0x1F:
- if (!m_write_p15.isnull()) m_write_p15(data); break;
-
- }
- return;
- }
-
- if (offset == 0)
- {
- // Write to control bit (CB)
- if (data == 0)
- {
- // Switch to interrupt mode; quit clock mode
- m_clock_mode = false;
- if (TRACE_MODE) logerror("%s: int mode\n", tag());
- }
- else
- {
- m_clock_mode = true;
- if (TRACE_MODE) logerror("%s: clock mode\n", tag());
- // we are switching to clock mode: latch the current value of
- // the decrementer register
- if (m_clock_register != 0)
- m_clock_read_register = m_decrementer_value;
- else
- m_clock_read_register = 0; /* timer inactive... */
- }
- }
- else
- {
- if (offset == 0x0f)
- {
- if (m_clock_mode)
- { /* in clock mode this is the soft reset bit */
- if (!data)
- { // TMS9901 soft reset (RST2*)
- // Spec: "Writing a 0 to bit 15 while in the clock mode executes a soft reset on the I/O pins.
- // [...] RST2* will program all ports to the input mode"
- m_pio_direction = 0;
- m_pio_direction_mirror = 0;
-
- // "RST1* (power-up reset) will reset all mask bits low."
- // Spec is not clear on whether the mask bits are also reset by RST2*
- // TODO: Check on a real machine. (I'd guess from the text they are not touched)
- m_enabled_ints = 0;
- if (TRACE_MODE) logerror("%s: Soft reset (RST2*)\n", tag());
- }
- }
- else
- { /* modify interrupt enable mask */
- if (data)
- m_enabled_ints |= 0x4000; /* set bit */
- else
- m_enabled_ints &= ~0x4000; /* unset bit */
-
- if (TRACE_PINS) logerror("%s: interrupts = %04x\n", tag(), m_enabled_ints);
- field_interrupts(); /* changed interrupt state */
- }
- }
- else
- {
- // write one bit to 9901 (bits 1-14)
- //
- // m_clock_mode==false ? Disable/Enable an interrupt
- // : Bit in clock interval
- //
- // offset is the index of the modified bit of register (-> interrupt number -1)
- if (m_clock_mode)
- { /* modify clock interval */
- int bit = 1 << ((offset & 0x0F) - 1); /* corresponding mask */
-
- if (data)
- m_clock_register |= bit; /* set bit */
- else
- m_clock_register &= ~bit; /* clear bit */
-
- /* reset clock timer (page 8) */
- if (TRACE_CLOCK) logerror("%s: clock register = %04x\n", tag(), m_clock_register);
- timer_reload();
- }
- else
- { /* modify interrupt enable mask */
- int bit = 1 << (offset & 0x0F); /* corresponding mask */
-
- if (data)
- m_enabled_ints |= bit; /* set bit */
- else
- m_enabled_ints &= ~bit; /* unset bit */
-
- if (offset == 3)
- m_timer_int_pending = false; /* SBO 3 clears pending timer interrupt (??) */
-
- if (TRACE_MODE) logerror("%s: enabled interrupts = %04x\n", tag(), m_enabled_ints);
- field_interrupts(); /* changed interrupt state */
- }
- }
- }
-}
-
-/*
- Timer callback
- Decrementer counts down the value set in clock mode; when it reaches 0,
- raises an interrupt and resets to the start value
- The decrementer works as long as the clock_register contains a non-zero value.
-*/
-void tms9901_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if (id==DECREMENTER) // we have only that one
- {
- m_decrementer_value--;
- if (TRACE_CLOCK) logerror("%s: decrementer = %d\n", tag(), m_decrementer_value);
- if (m_decrementer_value<=0)
- {
- m_timer_int_pending = true; // decrementer interrupt requested
- field_interrupts();
- m_decrementer_value = m_clock_register;
- }
- }
-}
-
-/*-------------------------------------------------
- device_stop - device-specific stop
--------------------------------------------------*/
-
-void tms9901_device::device_stop(void)
-{
-}
-
-/*-------------------------------------------------
- device_reset - device-specific reset
--------------------------------------------------*/
-
-void tms9901_device::device_reset(void)
-{
- m_timer_int_pending = false;
- m_enabled_ints = 0;
-
- m_pio_direction = 0;
- m_pio_direction_mirror = 0;
- m_pio_output = m_pio_output_mirror = 0;
-
- // This is an interrupt level latch, positive logic (bit 0 = no int)
- // The inputs are negative logic (INTx*)
- m_int_state = 0;
-
- m_old_int_state = -1;
- field_interrupts();
-
- m_clock_mode = false;
-
- m_clock_register = 0;
- timer_reload();
-}
-
-
-/*-------------------------------------------------
- device_start - device-specific startup
--------------------------------------------------*/
-
-void tms9901_device::device_start(void)
-{
- m_decrementer = timer_alloc(DECREMENTER);
- m_decrementer->adjust(attotime::from_hz(clock() / 64.), 0, attotime::from_hz(clock() / 64.));
- m_decrementer->enable(false);
-
- m_read_block.resolve();
- m_write_p0.resolve();
- m_write_p1.resolve();
- m_write_p2.resolve();
- m_write_p3.resolve();
- m_write_p4.resolve();
- m_write_p5.resolve();
- m_write_p6.resolve();
- m_write_p7.resolve();
- m_write_p8.resolve();
- m_write_p9.resolve();
- m_write_p10.resolve();
- m_write_p11.resolve();
- m_write_p12.resolve();
- m_write_p13.resolve();
- m_write_p14.resolve();
- m_write_p15.resolve();
- m_interrupt.resolve();
-
- m_clock_register = 0;
-}
-
-const device_type TMS9901 = &device_creator<tms9901_device>;
diff --git a/src/emu/machine/tms9901.h b/src/emu/machine/tms9901.h
deleted file mode 100644
index d6859bf21c5..00000000000
--- a/src/emu/machine/tms9901.h
+++ /dev/null
@@ -1,224 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Michael Zapf
-/****************************************************************************
-
- TMS9901 Programmable System Interface
- See tms9901.c for documentation
-
- Raphael Nabet
- Michael Zapf
-
- February 2012: Rewritten as class
-
-*****************************************************************************/
-
-#ifndef __TMS9901_H__
-#define __TMS9901_H__
-
-#include "emu.h"
-
-extern const device_type TMS9901;
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-// Masks for the interrupts levels available on TMS9901
-
-#define TMS9901_INT1 0x0002
-#define TMS9901_INT2 0x0004
-#define TMS9901_INT3 0x0008 // overridden by the timer interrupt
-#define TMS9901_INT4 0x0010
-#define TMS9901_INT5 0x0020
-#define TMS9901_INT6 0x0040
-#define TMS9901_INT7 0x0080
-#define TMS9901_INT8 0x0100
-#define TMS9901_INT9 0x0200
-#define TMS9901_INTA 0x0400
-#define TMS9901_INTB 0x0800
-#define TMS9901_INTC 0x1000
-#define TMS9901_INTD 0x2000
-#define TMS9901_INTE 0x4000
-#define TMS9901_INTF 0x8000
-
-enum
-{
- TMS9901_CB_INT7 = 0,
- TMS9901_INT8_INT15 = 1,
- TMS9901_P0_P7 = 2,
- TMS9901_P8_P15 = 3
-};
-
-/***************************************************************************
- CLASS DEFINITION
-***************************************************************************/
-
-class tms9901_device : public device_t
-{
-public:
- tms9901_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- void set_single_int(int pin_number, int state);
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- template<class _Object> static devcb_base &static_set_readblock_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_read_block.set_callback(object); }
-
- template<class _Object> static devcb_base &static_set_p0_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p0.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p1_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p1.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p2_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p2.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p3_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p3.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p4_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p4.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p5_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p5.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p6_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p6.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p7_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p7.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p8_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p8.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p9_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p9.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p10_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p10.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p11_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p11.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p12_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p12.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p13_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p13.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p14_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p14.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p15_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p15.set_callback(object); }
-
- template<class _Object> static devcb_base &static_set_intlevel_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_interrupt.set_callback(object); }
-
-private:
- static const device_timer_id DECREMENTER = 0;
-
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- void timer_reload(void);
- void field_interrupts(void);
-
- void device_start(void);
- void device_stop(void);
- void device_reset(void);
-
- // State of the INT1-INT15 lines (must be inverted when queried)
- // Note that the levels must also be delivered when reading the pins, which
- // may require to latch the int levels.
- int m_int_state;
- int m_old_int_state; // stores the previous value to avoid useless INT line assertions
- int m_enabled_ints; // interrupt enable mask
-
- bool m_int_pending; // status of the int* pin (connected to TMS9900)
- bool m_timer_int_pending; // timer int pending (overrides int3 pin if timer enabled)
-
- // PIO registers
- int m_pio_direction; // direction register for PIO
-
- // current PIO output (to be masked with pio_direction)
- int m_pio_output;
-
- // mirrors used for INT7*-INT15*
- int m_pio_direction_mirror;
- int m_pio_output_mirror;
-
- // =======================================================================
-
- // TMS9901 clock mode
- // false = so-called interrupt mode (read interrupt state, write interrupt enable mask)
- // true = clock mode (read/write clock interval)
- bool m_clock_mode;
-
- // MESS timer, used to emulate the decrementer register
- emu_timer *m_decrementer;
-
- // clock interval, loaded in decrementer when it reaches 0.
- // 0 means decrementer off
- int m_clock_register;
-
- // Current decrementer value
- int m_decrementer_value;
-
- // when we go into timer mode, the decrementer is copied there to allow to read it reliably
- int m_clock_read_register;
-
- // =======================================================================
-
- // Read callback.
- devcb_read8 m_read_block;
-
- // I/O lines, used for output. When used as inputs, the levels are delivered via the m_read_block
- devcb_write_line m_write_p0;
- devcb_write_line m_write_p1;
- devcb_write_line m_write_p2;
- devcb_write_line m_write_p3;
- devcb_write_line m_write_p4;
- devcb_write_line m_write_p5;
- devcb_write_line m_write_p6;
- devcb_write_line m_write_p7;
- devcb_write_line m_write_p8;
- devcb_write_line m_write_p9;
- devcb_write_line m_write_p10;
- devcb_write_line m_write_p11;
- devcb_write_line m_write_p12;
- devcb_write_line m_write_p13;
- devcb_write_line m_write_p14;
- devcb_write_line m_write_p15;
-
- // The invocation corresponds to the INTREQ signal (with the level passed as data)
- // and the address delivers the interrupt level (0-15)
- devcb_write8 m_interrupt;
-};
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_TMS9901_READBLOCK_HANDLER( _read ) \
- devcb = &tms9901_device::static_set_readblock_callback( *device, DEVCB_##_read );
-
-#define MCFG_TMS9901_P0_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p0_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P1_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p1_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P2_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p2_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P3_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p3_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P4_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p4_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P5_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p5_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P6_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p6_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P7_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p7_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P8_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p8_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P9_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p9_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P10_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p10_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P11_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p11_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P12_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p12_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P13_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p13_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P14_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p14_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_P15_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p15_callback( *device, DEVCB_##_write );
-
-#define MCFG_TMS9901_INTLEVEL_HANDLER( _intlevel ) \
- devcb = &tms9901_device::static_set_intlevel_callback( *device, DEVCB_##_intlevel );
-
-#endif /* __TMS9901_H__ */
diff --git a/src/emu/machine/tms9902.c b/src/emu/machine/tms9902.c
deleted file mode 100644
index 557da504f96..00000000000
--- a/src/emu/machine/tms9902.c
+++ /dev/null
@@ -1,847 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Michael Zapf
-/****************************************************************************
-
- TMS9902 Asynchronous Communication Controller
-
- TMS9902 is an asynchronous serial controller for use with the TI990 and
- TMS9900 family. It provides serial I/O, three extra I/O pins (namely RTS,
- DSR and CTS), and a timer. It communicates with the CPU through the CRU
- I/O bus, and one interrupt pin.
-
- +----+--+----+
- <- /INT |1 \--/ 18| VCC
- <- XOUT |2 17| /CE <-
- -> RIN |3 16| /PHI <-
- <- CRUIN |4 15| CRUCLK <-
- <- /RTS |5 14| S0 <-
- -> /CTS |6 13| S1 <-
- -> /DSR |7 12| S2 <-
- -> CRUOUT |8 11| S3 <-
- VSS |9 10| S4 <-
- +------------+
-
- The CRUIN line borrows its name from the connector of the connected CPU
- where it is an input, so CRUIN is an output of this chip. The same is true
- for CRUOUT.
-
- /PHI is a TTL clock input with 4 MHz maximum rate.
-
- IMPORTANT NOTE: The previous versions of TMS9902 attempted to write their
- output to a file. This implementation is able to communicate with an external
- UART via a socket connection and an external bridge. However, the work is
- not done yet, and until then the file writing is disabled.
-
- Raphael Nabet, 2003
- Michael Zapf, 2011
- February 2012: Rewritten as class
-
-*****************************************************************************/
-
-#include <math.h>
-#include "tms9902.h"
-
-#define VERBOSE 1
-#define LOG logerror
-
-enum
-{
- DECTIMER,
- RECVTIMER,
- SENDTIMER
-};
-
-// Polling frequency. We use a much higher value to allow for line state changes
-// happening between character transmissions (which happen in parallel in real
-// communications but which must be serialized here)
-#define POLLING_FREQ 20000
-
-
-/*
- Constructor
-*/
-tms9902_device::tms9902_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, TMS9902, "TMS9902 ACC", tag, owner, clock, "tms9902", __FILE__),
- m_int_cb(*this),
- m_rcv_cb(*this),
- m_xmit_cb(*this),
- m_ctrl_cb(*this)
-{
-}
-
-/*
- should be called after any change to int_state or enabled_ints.
-*/
-void tms9902_device::field_interrupts()
-{
- bool new_int = (m_DSCH && m_DSCENB)
- || (m_RBRL && m_RIENB)
- || (m_XBRE && m_XBIENB)
- || (m_TIMELP && m_TIMENB);
- if (VERBOSE>8) LOG("TMS9902: interrupt flags (DSCH = %02x, DSCENB = %02x), (RBRL = %02x, RIENB = %02x), (XBRE = %02x, XBIENB = %02x), (TIMELP = %02x, TIMENB = %02x)\n",
- m_DSCH, m_DSCENB, m_RBRL, m_RIENB, m_XBRE, m_XBIENB, m_TIMELP, m_TIMENB);
-
- if (new_int != m_INT)
- {
- // Only consider edges
- m_INT = new_int;
- if (VERBOSE>3) LOG("TMS9902: /INT = %s\n", (m_INT)? "asserted" : "cleared");
- m_int_cb(m_INT? ASSERT_LINE : CLEAR_LINE);
- }
-}
-
-/*
- Called whenever the incoming CTS* line changes. This should be called by
- the device that contains the UART.
-*/
-void tms9902_device::rcv_cts(line_state state)
-{
- bool previous = m_CTSin;
-
- // CTSin is an internal register of the TMS9902 with positive logic
- m_CTSin = (state==ASSERT_LINE);
-
- if (VERBOSE>3) LOG("TMS9902: CTS* = %s\n", (state==ASSERT_LINE)? "asserted" : "cleared");
-
- if (m_CTSin != previous)
- {
- m_DSCH = true;
- field_interrupts();
-
- // If CTS becomes asserted and we have been sending
- if (state==ASSERT_LINE && m_RTSout)
- {
- // and if the byte buffer is empty
- if (m_XBRE)
- {
- // and we want to have a BRK, send it
- if (m_BRKON) send_break(true);
- }
- else
- {
- // Buffer is not empty, we can send it
- // If the shift register is empty, transfer the data
- if (m_XSRE && !m_BRKout)
- {
- initiate_transmit();
- }
- }
- }
- }
- else
- {
- m_DSCH = false;
- if (VERBOSE>4) LOG("TMS9902: no change in CTS line, no interrupt.");
- }
-}
-
-void tms9902_device::set_clock(bool state)
-{
- if (state)
- m_recvtimer->adjust(attotime::from_msec(1), 0, attotime::from_hz(POLLING_FREQ));
- else
- m_recvtimer->reset();
-}
-
-/*
- Called whenever the incoming DSR* line changes. This should be called by
- the device that contains the UART.
-*/
-void tms9902_device::rcv_dsr(line_state state)
-{
- bool previous = m_DSRin;
- if (VERBOSE>3) LOG("TMS9902: DSR* = %s\n", (state==ASSERT_LINE)? "asserted" : "cleared");
- m_DSRin = (state==ASSERT_LINE);
-
- if (m_DSRin != previous)
- {
- m_DSCH = true;
- field_interrupts();
- }
- else
- {
- m_DSCH = false;
- if (VERBOSE>4) LOG("TMS9902: no change in DSR line, no interrupt.");
- }
-}
-
-/*
- Called whenever the incoming RIN line changes. This should be called by
- the device that contains the UART. Unlike the real thing, we deliver
- complete bytes in one go.
-*/
-void tms9902_device::rcv_data(UINT8 data)
-{
- // Put the received byte into the 1-byte receive buffer
- m_RBR = data;
-
- // Clear last errors
- m_RFER = false;
- m_RPER = false;
-
- if (!m_RBRL)
- {
- // Receive buffer was empty
- m_RBRL = true;
- m_ROVER = false;
- if (VERBOSE>3) LOG("TMS9902: Receive buffer loaded with byte %02x\n", data);
- field_interrupts();
- }
- else
- {
- // Receive buffer was full
- m_ROVER = true;
- if (VERBOSE>1) LOG("TMS9902: Receive buffer still loaded; overflow error\n");
- }
-}
-
-//------------------------------------------------
-
-/*
- Framing error. This can only be detected by a remotely attached real UART;
- if we get a report on a framing error we use it to announce the framing error
- as if it occurred here.
- The flag is reset by the next correctly received byte.
-*/
-void tms9902_device::rcv_framing_error()
-{
- if (VERBOSE>2) LOG("TMS9902: Detected framing error\n");
- m_RFER = true;
-}
-
-/*
- Parity error. This can only be detected by a remotely attached real UART;
- if we get a report on a parity error we use it to announce the parity error
- as if it occurred here.
- The flag is reset by the next correctly received byte.
-*/
-void tms9902_device::rcv_parity_error()
-{
- if (VERBOSE>2) LOG("TMS9902: Detected parity error\n");
- m_RPER = true;
-}
-
-/*
- Incoming BREAK condition. The TMS9902 does not show any directly visible
- reactions on a BREAK (no interrupt, no flag set). A BREAK is a time period
- of low level on the RIN pin which makes the chip re-synchronize on the
- next rising edge.
-*/
-void tms9902_device::rcv_break(bool value)
-{
- if (VERBOSE>2) LOG("TMS9902: Receive BREAK=%d (no effect)\n", value? 1:0);
-}
-
-//------------------------------------------------
-
-/*
- Timer callback
-*/
-void tms9902_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- // This call-back is called by the MESS timer system when the decrementer
- // reaches 0.
- case DECTIMER:
- m_TIMERR = m_TIMELP;
- break;
-
- // Callback for the autonomous operations of the chip. This is normally
- // controlled by an external clock of 3-4 MHz, internally divided by 3 or 4,
- // depending on CLK4M. With this timer, reception of characters becomes
- // possible.
- case RECVTIMER:
- m_rcv_cb(ASSERT_LINE);
- break;
-
- case SENDTIMER:
- // Byte has been sent
- m_XSRE = true;
-
- // In the meantime, the CPU may have pushed a new byte into the XBR
- // so we loop until all data are transferred
- if (!m_XBRE && m_CTSin)
- {
- initiate_transmit();
- }
- break;
- }
-}
-
-/*
- load the content of clockinvl into the decrementer
-*/
-void tms9902_device::reload_interval_timer()
-{
- if (m_TMR)
- { /* reset clock interval */
- m_dectimer->adjust(
- attotime::from_double((double) m_TMR / (m_clock_rate / ((m_CLK4M) ? 4. : 3.) / 64.)),
- 0,
- attotime::from_double((double) m_TMR / (m_clock_rate / ((m_CLK4M) ? 4. : 3.) / 64.)));
- }
- else
- { /* clock interval == 0 -> no timer */
- m_dectimer->enable(0);
- }
-}
-
-void tms9902_device::send_break(bool state)
-{
- if (state != m_BRKout)
- {
- m_BRKout = state;
- if (VERBOSE>2) LOG("TMS9902: Sending BREAK=%d\n", state? 1:0);
-
- // Signal BRK (on/off) to the remote site
- m_ctrl_cb((offs_t)(EXCEPT | BRK), state? 1:0);
- }
-}
-
-/*
- Baudpoll value allows the callback function to know when the next data byte shall be delivered.
-*/
-double tms9902_device::get_baudpoll()
-{
- return m_baudpoll;
-}
-
-// ==========================================================================
-
-/*
- Sets the data rate for the receiver part. If a remote UART is attached,
- propagate this setting.
- The TMS9902 calculates the baud rate from the external clock, and the result
- does not match the known baud rates precisely (e.g. for 9600 baud the
- closest value is 9615). Other UARTs may have a different way to set baud
- rates. Thus we transmit the bit pattern and leave it up to the remote UART
- to calculate its own baud rate from it. Apart from that, the callback
- function should add information about the UART.
-
- CLK4M RDV8 RDR9 RDR8 | RDR7 RDR6 RDR5 RDR4 | RDR3 RDR2 RDR1 RDR0
-*/
-void tms9902_device::set_receive_data_rate()
-{
- int value = (m_CLK4M? 0x800 : 0) | (m_RDV8? 0x400 : 0) | m_RDR;
- if (VERBOSE>3) LOG("TMS9902: receive rate = %04x\n", value);
-
- // Calculate the ratio between receive baud rate and polling frequency
- double fint = m_clock_rate / ((m_CLK4M) ? 4.0 : 3.0);
- double baud = fint / (2.0 * ((m_RDV8)? 8:1) * m_RDR);
-
- // We assume 10 bit per character (7 data usually add 1 parity; 1 start, 1 stop)
- // This value represents the ratio of data inputs of one poll.
- // Thus the callback function should add up this value on each poll
- // and deliver a data input not before it sums up to 1.
- m_baudpoll = (double)(baud / (10*POLLING_FREQ));
- if (VERBOSE>3) LOG ("TMS9902: baudpoll = %f\n", m_baudpoll);
-
- m_last_config_value = value;
- m_ctrl_cb((offs_t)CONFIG, RATERECV);
-}
-
-/*
- Sets the data rate for the sender part. If a remote UART is attached,
- propagate this setting.
-*/
-void tms9902_device::set_transmit_data_rate()
-{
- int value = (m_CLK4M? 0x800 : 0) | (m_XDV8? 0x400 : 0) | m_XDR;
- if (VERBOSE>3) LOG("TMS9902: set transmit rate = %04x\n", value);
- m_last_config_value = value;
- m_ctrl_cb((offs_t)CONFIG, RATEXMIT);
-}
-
-void tms9902_device::set_stop_bits()
-{
- int value = m_STOPB;
- if (VERBOSE>3) LOG("TMS9902: set stop bits = %02x\n", value);
- m_last_config_value = value;
- m_ctrl_cb((offs_t)CONFIG, STOPBITS);
-}
-
-void tms9902_device::set_data_bits()
-{
- int value = m_RCL;
- if (VERBOSE>3) LOG("TMS9902: set data bits = %02x\n", value);
- m_last_config_value = value;
- m_ctrl_cb((offs_t)CONFIG, DATABITS);
-}
-
-void tms9902_device::set_parity()
-{
- int value = (m_PENB? 2:0) | (m_ODDP? 1:0);
- if (VERBOSE>3) LOG("TMS9902: set parity = %02x\n", value);
- m_last_config_value = value;
- m_ctrl_cb((offs_t)CONFIG, PARITY);
-}
-
-void tms9902_device::transmit_line_state()
-{
- // 00ab cdef = setting line RTS=a, CTS=b, DSR=c, DCD=d, DTR=e, RI=f
- // The 9902 only outputs RTS and BRK
- if (VERBOSE>3) LOG("TMS9902: transmitting line state (only RTS) = %02x\n", (m_RTSout)? 1:0);
- m_last_config_value = (m_RTSout)? RTS : 0;
- m_ctrl_cb((offs_t)LINES, RTS);
-}
-
-void tms9902_device::set_rts(line_state state)
-{
- bool lstate = (state==ASSERT_LINE);
-
- if (lstate != m_RTSout)
- {
- // Signal RTS to the modem
- if (VERBOSE>3) LOG("TMS9902: Set RTS=%d\n", lstate? 1:0);
- m_RTSout = lstate;
- transmit_line_state();
- }
-}
-
-int tms9902_device::get_config_value()
-{
- return m_last_config_value;
-}
-
-// ==========================================================================
-
-void tms9902_device::initiate_transmit()
-{
- if (m_BRKON && m_CTSin)
- /* enter break mode */
- send_break(true);
- else
- {
- if (!m_RTSON && (!m_CTSin || (m_XBRE && !m_BRKout)))
- /* clear RTS output */
- set_rts(CLEAR_LINE);
- else
- {
- if (VERBOSE>5) LOG("TMS9902: transferring XBR to XSR; XSRE=false, XBRE=true\n");
- m_XSR = m_XBR;
- m_XSRE = false;
- m_XBRE = true;
-
- field_interrupts();
-
- if (VERBOSE>4) LOG("TMS9902: transmit XSR=%02x, RCL=%02x\n", m_XSR, m_RCL);
-
- m_xmit_cb((offs_t)0, m_XSR & (0xff >> (3-m_RCL)));
-
- // Should store that somewhere (but the CPU is fast enough, can afford to recalc :-) )
- double fint = m_clock_rate / ((m_CLK4M) ? 4.0 : 3.0);
- double baud = fint / (2.0 * ((m_RDV8)? 8:1) * m_RDR);
-
- // Time for transmitting 10 bit (8 bit + start + stop)
- m_sendtimer->adjust(attotime::from_hz(baud/10.0));
- }
- }
-}
-
-
-
-/*----------------------------------------------------------------
- TMS9902 CRU interface.
-----------------------------------------------------------------*/
-
-/*
- Read a 8 bit chunk from tms9902.
-
- signification:
- bit 0-7: RBR0-7 Receive Buffer register
- bit 8: not used (always 0)
- bit 9: RCVERR Receive Error (RFER | ROVER | RPER)
- bit 10: RPER Receive Parity Error
- bit 11: ROVER Receive Overrun Error
- bit 12: RFER Receive Framing Error
- bit 13-15: not emulated, normally used for diagnostics
- bit 16: RBINT (RBRL&RIENB)
-*/
-READ8_MEMBER( tms9902_device::cruread )
-{
- UINT8 answer = 0;
-
- offset &= 0x0003;
-
- switch (offset)
- {
- case 3: // Bits 31-24
- if (m_INT) answer |= 0x80;
- if (m_LDCTRL || m_LDIR || m_LRDR || m_LXDR || m_BRKON) answer |= 0x40;
- if (m_DSCH) answer |= 0x20;
- if (m_CTSin) answer |= 0x10;
- if (m_DSRin) answer |= 0x08;
- if (m_RTSout) answer |= 0x04;
- if (m_TIMELP) answer |= 0x02;
- if (m_TIMERR) answer |= 0x01;
- break;
-
- case 2: // Bits 23-16
- if (m_XSRE) answer |= 0x80;
- if (m_XBRE) answer |= 0x40;
- if (m_RBRL) answer |= 0x20;
- if (m_DSCH && m_DSCENB) answer |= 0x10;
- if (m_TIMELP && m_TIMENB) answer |= 0x08;
- if (m_XBRE && m_XBIENB) answer |= 0x02;
- if (m_RBRL && m_RIENB) answer |= 0x01;
- break;
-
- case 1: // Bits 15-8
- if (m_RIN) answer |= 0x80;
- if (m_RSBD) answer |= 0x40;
- if (m_RFBD) answer |= 0x20;
- if (m_RFER) answer |= 0x10;
- if (m_ROVER) answer |= 0x08;
- if (m_RPER) answer |= 0x04;
- if (m_RPER || m_RFER || m_ROVER) answer |= 0x02;
- break;
-
- case 0: // Bits 7-0
- answer = m_RBR;
- break;
- }
- if (VERBOSE>7) LOG("TMS9902: Reading flag bits %d - %d = %02x\n", ((offset+1)*8-1), offset*8, answer);
- return answer;
-}
-
-static inline void set_bits8(UINT8 *reg, UINT8 bits, bool set)
-{
- if (set)
- *reg |= bits;
- else
- *reg &= ~bits;
-}
-
-static inline void set_bits16(UINT16 *reg, UINT16 bits, bool set)
-{
- if (set)
- *reg |= bits;
- else
- *reg &= ~bits;
-}
-
-void tms9902_device::reset_uart()
-{
- if (VERBOSE>1) LOG("TMS9902: resetting\n");
-
- /* disable all interrupts */
- m_DSCENB = false; // Data Set Change Interrupt Enable
- m_TIMENB = false; // Timer Interrupt Enable
- m_XBIENB = false; // Transmit Buffer Interrupt Enable
- m_RIENB = false; // Read Buffer Interrupt Enable
-
- /* initialize transmitter */
- m_XBRE = true; // Transmit Buffer Register Empty
- m_XSRE = true; // Transmit Shift Register Empty
-
- /* initialize receiver */
- m_RBRL = false; // Read Buffer Register Loaded
-
- /* clear RTS */
- m_RTSON = false; // Request-to-send on (flag)
- m_RTSout = true; // Note we are doing this to ensure the state is sent to the interface
- set_rts(CLEAR_LINE);
- m_RTSout = false; // what we actually want
-
- /* set all register load flags to 1 */
- m_LDCTRL = true;
- m_LDIR = true;
- m_LRDR = true;
- m_LXDR = true;
-
- /* clear break condition */
- m_BRKON = false;
- m_BRKout = false;
-
- m_DSCH = false;
- m_TIMELP = false;
- m_INT = false;
- m_CTSin = false;
-
- m_TMR = 0;
- m_STOPB = 0;
- m_RCL = 0;
- m_XDR = 0;
- m_RDR = 0;
- m_RBR = 0;
- m_XBR = 0;
- m_XSR = 0;
-
- // m_INT will be cleared in field_interrupts
- field_interrupts();
-}
-
-/*
- TMS9902 CRU write
-*/
-WRITE8_MEMBER( tms9902_device::cruwrite )
-{
- data &= 1; /* clear extra bits */
-
- offset &= 0x1F;
- if (VERBOSE>5) LOG("TMS9902: Setting bit %d = %02x\n", offset, data);
-
- if (offset <= 10)
- {
- UINT16 mask = (1 << offset);
-
- if (m_LDCTRL)
- { // Control Register mode. Values written to bits 0-7 are copied
- // into the control register.
- switch (offset)
- {
- case 0:
- set_bits8(&m_RCL, 0x01, (data!=0));
- // we assume that bits are written in increasing order
- // so we do not transmit the data bits twice
- // (will fail when bit 1 is written first)
- break;
- case 1:
- set_bits8(&m_RCL, 0x02, (data!=0));
- set_data_bits();
- break;
- case 2:
- break;
- case 3:
- m_CLK4M = (data!=0);
- break;
- case 4:
- m_ODDP = (data!=0);
- // we also assume that the parity type is set before the parity enable
- break;
- case 5:
- m_PENB = (data!=0);
- set_parity();
- break;
- case 6:
- set_bits8(&m_STOPB, 0x01, (data!=0));
- break;
- case 7:
- set_bits8(&m_STOPB, 0x02, (data!=0));
- // When bit 7 is written the control register mode is automatically terminated.
- m_LDCTRL = false;
- set_stop_bits();
- break;
- default:
- if (VERBOSE>1) LOG("tms9902: Invalid control register address %d\n", offset);
- }
- }
- else if (m_LDIR)
- { // Interval Register mode. Values written to bits 0-7 are copied
- // into the interval register.
- if (offset <= 7)
- {
- set_bits8(&m_TMR, mask, (data!=0));
-
- if (offset == 7)
- {
- reload_interval_timer();
- // When bit 7 is written the interval register mode is automatically terminated.
- m_LDIR = false;
- }
- }
- }
- else if (m_LRDR || m_LXDR)
- {
- if (m_LRDR)
- { // Receive rate register mode. Values written to bits 0-10 are copied
- // into the receive rate register.
- if (offset < 10)
- {
- set_bits16(&m_RDR, mask, (data!=0));
- }
- else
- {
- // When bit 10 is written the receive register mode is automatically terminated.
- m_RDV8 = (data!=0);
- m_LRDR = false;
- set_receive_data_rate();
- }
- }
- if (m_LXDR)
- {
- // The transmit rate register can be set together with the receive rate register.
- if (offset < 10)
- {
- set_bits16(&m_XDR, mask, (data!=0));
- }
- else
- {
- // Note that the transmit rate register is NOT terminated when
- // writing bit 10. This must be done by unsetting bit 11.
- m_XDV8 = (data!=0);
- set_transmit_data_rate();
- }
- }
- }
- else
- { // LDCTRL=LDIR=LRDR=LXRD=0: Transmit buffer register mode. Values
- // written to bits 0-7 are transferred into the transmit buffer register.
- if (offset <= 7)
- {
- set_bits8(&m_XBR, mask, (data!=0));
-
- if (offset == 7)
- { /* transmit */
- m_XBRE = false;
- // Spec: When the transmitter is active, the contents of the Transmit
- // Buffer Register are transferred to the Transmit Shift Register
- // each time the previous character has been completely transmitted
- // We need to check XSRE=true as well, as the implementation
- // makes use of a timed transmission, during which XSRE=false
- if (m_XSRE && m_RTSout && m_CTSin && !m_BRKout)
- {
- initiate_transmit();
- }
- }
- }
- }
- return;
- }
- switch (offset)
- {
- case 11:
- m_LXDR = (data!=0);
- break;
- case 12:
- m_LRDR = (data!=0);
- break;
- case 13:
- m_LDIR = (data!=0);
- // Spec: Each time LDIR is reset the contents of the Interval
- // Register are loaded into the Interval Timer, thus restarting
- // the timer.
- if (data==0)
- reload_interval_timer();
- break;
- case 14:
- m_LDCTRL = (data!=0);
- break;
- case 15:
- m_TSTMD = (data!=0); // Test mode not implemented
- break;
- case 16:
- if (data!=0)
- {
- m_RTSON = true;
- set_rts(ASSERT_LINE);
- if (m_CTSin)
- {
- if (m_XSRE && !m_XBRE && !m_BRKout)
- initiate_transmit();
- else if (m_BRKON)
- send_break(true);
- }
- }
- else
- {
- m_RTSON = false;
- if (m_XBRE && m_XSRE && !m_BRKout)
- {
- set_rts(CLEAR_LINE);
- }
- }
- return;
- case 17:
- if (VERBOSE>3) LOG("TMS9902: set BRKON=%d; BRK=%d\n", data, m_BRKout? 1:0);
- m_BRKON = (data!=0);
- if (m_BRKout && data==0)
- {
- // clear BRK
- m_BRKout = false;
- if ((!m_XBRE) && m_CTSin)
- {
- /* transmit next byte */
- initiate_transmit();
- }
- else if (!m_RTSON)
- {
- /* clear RTS */
- set_rts(CLEAR_LINE);
- }
- }
- else if (m_XBRE && m_XSRE && m_RTSout && m_CTSin)
- {
- send_break(data!=0);
- }
- return;
- case 18:
- // Receiver Interrupt Enable
- // According to spec, (re)setting this flag clears the RBRL flag
- // (the only way to clear the flag!)
- m_RIENB = (data!=0);
- m_RBRL = false;
- if (VERBOSE>4) LOG("TMS9902: set RBRL=0, set RIENB=%d\n", data);
- field_interrupts();
- return;
- case 19:
- /* Transmit Buffer Interrupt Enable */
- m_XBIENB = (data!=0);
- if (VERBOSE>4) LOG("TMS9902: set XBIENB=%d\n", data);
- field_interrupts();
- return;
- case 20:
- /* Timer Interrupt Enable */
- m_TIMENB = (data!=0);
- m_TIMELP = false;
- m_TIMERR = false;
- field_interrupts();
- return;
- case 21:
- /* Data Set Change Interrupt Enable */
- m_DSCENB = (data!=0);
- m_DSCH = false;
- if (VERBOSE>4) LOG("TMS9902: set DSCH=0, set DSCENB=%d\n", data);
- field_interrupts();
- return;
- case 31:
- /* RESET */
- reset_uart();
- return;
- default:
- if (VERBOSE>1) LOG("TMS9902: Writing to undefined flag bit position %d = %01x\n", offset, data);
- }
-}
-
-/*-------------------------------------------------
- device_stop - device-specific stop
--------------------------------------------------*/
-
-void tms9902_device::device_stop()
-{
- if (m_dectimer)
- {
- m_dectimer->reset();
- m_dectimer = NULL;
- }
-}
-
-/*-------------------------------------------------
- device_reset - device-specific reset
--------------------------------------------------*/
-
-void tms9902_device::device_reset()
-{
- reset_uart();
-}
-
-/*-------------------------------------------------
- device_start - device-specific startup
--------------------------------------------------*/
-
-void tms9902_device::device_start()
-{
- m_clock_rate = clock();
-
- m_int_cb.resolve_safe();
- m_rcv_cb.resolve_safe();
- m_xmit_cb.resolve_safe();
- m_ctrl_cb.resolve_safe();
-
- m_dectimer = timer_alloc(DECTIMER);
- m_recvtimer = timer_alloc(RECVTIMER);
- m_sendtimer = timer_alloc(SENDTIMER);
-}
-
-const device_type TMS9902 = &device_creator<tms9902_device>;
diff --git a/src/emu/machine/tms9902.h b/src/emu/machine/tms9902.h
deleted file mode 100644
index ba775d3caa1..00000000000
--- a/src/emu/machine/tms9902.h
+++ /dev/null
@@ -1,203 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Michael Zapf
-/****************************************************************************
-
- TMS9902 Asynchronous Communication Controller
- See tms9902.c for documentation
-
- Michael Zapf
-
- February 2012: Rewritten as class
-
-*****************************************************************************/
-
-#ifndef __TMS9902_H__
-#define __TMS9902_H__
-
-#include "emu.h"
-
-// Serial control protocol values
-#define TYPE_TMS9902 0x01
-
-// Configuration (output only)
-#define CONFIG 0x80
-#define RATERECV 0x70
-#define RATEXMIT 0x60
-#define DATABITS 0x50
-#define STOPBITS 0x40
-#define PARITY 0x30
-
-// Exceptional states (BRK: both directions; FRMERR/PARERR: input only)
-#define EXCEPT 0x40
-#define BRK 0x02
-#define FRMERR 0x04
-#define PARERR 0x06
-
-// Line states (RTS, DTR: output; CTS, DSR, RI, DCD: input)
-#define LINES 0x00
-#define RTS 0x20
-#define CTS 0x10
-#define DSR 0x08
-#define DCD 0x04
-#define DTR 0x02
-#define RI 0x01
-
-extern const device_type TMS9902;
-
-class tms9902_device : public device_t
-{
-public:
- tms9902_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_int_callback(device_t &device, _Object object) { return downcast<tms9902_device &>(device).m_int_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_rcv_callback(device_t &device, _Object object) { return downcast<tms9902_device &>(device).m_rcv_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_xmit_callback(device_t &device, _Object object) { return downcast<tms9902_device &>(device).m_xmit_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_ctrl_callback(device_t &device, _Object object) { return downcast<tms9902_device &>(device).m_ctrl_cb.set_callback(object); }
-
- void set_clock(bool state);
-
- void rcv_cts(line_state state);
- void rcv_dsr(line_state state);
- void rcv_data(UINT8 data);
- void rcv_break(bool value);
- void rcv_framing_error();
- void rcv_parity_error();
-
- double get_baudpoll();
-
- int get_config_value();
-
- DECLARE_READ8_MEMBER( cruread );
- DECLARE_WRITE8_MEMBER( cruwrite );
-
-protected:
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual void device_start();
- virtual void device_reset();
- virtual void device_stop();
-
-private:
- void field_interrupts();
- void reload_interval_timer();
- void send_break(bool state);
- void set_receive_data_rate();
- void set_transmit_data_rate();
- void set_stop_bits();
- void set_data_bits();
- void set_parity();
- void transmit_line_state();
- void set_rts(line_state state);
- void initiate_transmit();
- void reset_uart();
-
- devcb_write_line m_int_cb;
- devcb_write_line m_rcv_cb;
- devcb_write8 m_xmit_cb;
- devcb_write8 m_ctrl_cb; // needs to be used with get_config_value
-
- // tms9902 clock rate (PHI* pin, normally connected to TMS9900 Phi3*)
- // Official range is 2MHz-3.3MHz. Some tms9902s were sold as "MP9214", and
- // were tested for speeds up to 4MHz, provided the clk4m control bit is set.
- // (warning: 3MHz on a tms9900 is equivalent to 12MHz on a tms9995 or tms99000)
- double m_clock_rate;
-
- /* Modes */
- bool m_LDCTRL; // Load control register
- bool m_LDIR; // Load interval register
- bool m_LRDR; // Load receive data register
- bool m_LXDR; // Load transmit data register
- bool m_TSTMD; // Test mode
-
- /* output pin */
- bool m_RTSON; // RTS-on request
-
- /* transmitter registers */
- bool m_BRKON; // BRK-on request
- bool m_BRKout; // indicates the current BRK state
-
- UINT8 m_XBR; // transmit buffer register
- UINT8 m_XSR; // transmit shift register
-
- /* receiver registers */
- UINT8 m_RBR; // Receive buffer register
-
- /* Interrupt enable flags */
- bool m_DSCENB; // Data set change interrupt enable
- bool m_RIENB; // Receiver interrupt enable
- bool m_XBIENB; // Tansmit buffer interrupt enable
- bool m_TIMENB; // Timer interrupt enable
-
- /*
- Rate registers. The receive bit rate calculates as
- bitrate = clock1 / (2 * (8 ^ RDV8) * RDR)
- (similarly for transmit)
-
- where clock1 = clock_rate / (CLK4M? 4:3)
- */
- UINT16 m_RDR; // Receive data rate
- bool m_RDV8; // Receive data rate divider
- UINT16 m_XDR; // Transmit data rate
- bool m_XDV8; // Transmit data rate divider
-
- /* Status flags */
- bool m_INT; // mirrors /INT output line, inverted
- bool m_DSCH; // Data set status change
-
- bool m_CTSin; // Inverted /CTS input (i.e. CTS)
- bool m_DSRin; // Inverted /DSR input (i.e. DSR)
- bool m_RTSout; // Current inverted /RTS line state (i.e. RTS)
-
- bool m_TIMELP; // Timer elapsed
- bool m_TIMERR; // Timer error
-
- bool m_XSRE; // Transmit shift register empty
- bool m_XBRE; // Transmit buffer register empty
- bool m_RBRL; // Receive buffer register loaded
-
- bool m_RIN; // State of the RIN pin
- bool m_RSBD; // Receive start bit detect
- bool m_RFBD; // Receive full bit detect
- bool m_RFER; // Receive framing error
- bool m_ROVER; // Receiver overflow
- bool m_RPER; // Receive parity error
-
- UINT8 m_RCL; // Character length
- bool m_ODDP;
- bool m_PENB;
- UINT8 m_STOPB;
- bool m_CLK4M; // /PHI input divide select
-
- UINT8 m_TMR; /* interval timer */
-
- /* clock registers */
- emu_timer *m_dectimer; /* MESS timer, used to emulate the decrementer register */
- emu_timer *m_recvtimer;
- emu_timer *m_sendtimer;
-
- // This value is the ratio of data input versus the poll rate. The
- // data source should deliver data bytes at every 1/baudpoll call.
- // This is to ensure that data is delivered at a rate that is expected
- // from the emulated program.
- double m_baudpoll;
-
- // Caches the last configuration setting (used with the ctrl_callback)
- int m_last_config_value;
-};
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_TMS9902_INT_CB(_devcb) \
- devcb = &tms9902_device::set_int_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TMS9902_RCV_CB(_devcb) \
- devcb = &tms9902_device::set_rcv_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TMS9902_XMIT_CB(_devcb) \
- devcb = &tms9902_device::set_xmit_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_TMS9902_CTRL_CB(_devcb) \
- devcb = &tms9902_device::set_ctrl_callback(*device, DEVCB_##_devcb);
-
-#endif /* __TMS9902_H__ */
diff --git a/src/emu/machine/upd1990a.c b/src/emu/machine/upd1990a.c
deleted file mode 100644
index f40bb30af48..00000000000
--- a/src/emu/machine/upd1990a.c
+++ /dev/null
@@ -1,499 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder, hap
-/**********************************************************************
-
- NEC uPD1990AC Serial I/O Calendar & Clock emulation
-
-**********************************************************************/
-
-/*
-
- TODO:
- - test mode is mostly untested
- - how does timer-interval differ from timer-pulse?
-
-*/
-
-#include "upd1990a.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-// device type definition
-const device_type UPD1990A = &device_creator<upd1990a_device>;
-const device_type UPD4990A = &device_creator<upd4990a_device>;
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// upd1990a_device - constructor
-//-------------------------------------------------
-
-upd1990a_device::upd1990a_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_rtc_interface(mconfig, *this),
- m_write_data(*this),
- m_write_tp(*this),
- m_variant(variant)
-{
-}
-
-upd1990a_device::upd1990a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, UPD1990A, "uPD1990A", tag, owner, clock, "upd1990a", __FILE__),
- device_rtc_interface(mconfig, *this),
- m_write_data(*this),
- m_write_tp(*this),
- m_variant(TYPE_1990A)
-{
-}
-
-upd4990a_device::upd4990a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : upd1990a_device(mconfig, UPD4990A, "uPD4990A RTC", tag, owner, clock, TYPE_4990A, "upd4990a", __FILE__) { }
-
-
-bool upd1990a_device::is_serial_mode()
-{
- // uPD4990A is in serial mode if c0/1/2 = high/VDD
- return (m_variant == TYPE_4990A && m_c_unlatched == 7);
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void upd1990a_device::device_start()
-{
- (void)m_variant;
- // resolve callbacks
- m_write_data.resolve_safe();
- m_write_tp.resolve_safe();
-
- // initialize
- set_current_time(machine());
-
- for (int i = 0; i < 7; i++)
- m_shift_reg[i] = 0;
-
- m_oe = 0;
- m_cs = 0;
- m_stb = 0;
- m_data_in = 0;
- m_data_out = 0;
- m_c = 0;
- m_clk = 0;
- m_tp = 0;
- m_c_unlatched = 0;
- m_testmode = false;
-
- // allocate timers
- m_timer_clock = timer_alloc(TIMER_CLOCK);
- m_timer_clock->adjust(attotime::from_hz(clock() / 32768.0), 0, attotime::from_hz(clock() / 32768.0)); // 1 second on XTAL_32_768kHz
- m_timer_tp = timer_alloc(TIMER_TP);
- m_timer_data_out = timer_alloc(TIMER_DATA_OUT);
- m_timer_test_mode = timer_alloc(TIMER_TEST_MODE);
-
- // state saving
- save_item(NAME(m_time_counter));
- save_item(NAME(m_shift_reg));
- save_item(NAME(m_oe));
- save_item(NAME(m_cs));
- save_item(NAME(m_stb));
- save_item(NAME(m_data_in));
- save_item(NAME(m_data_out));
- save_item(NAME(m_c));
- save_item(NAME(m_clk));
- save_item(NAME(m_tp));
- save_item(NAME(m_c_unlatched));
- save_item(NAME(m_testmode));
-}
-
-
-//-------------------------------------------------
-// rtc_clock_updated -
-//-------------------------------------------------
-
-void upd1990a_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
- m_time_counter[0] = convert_to_bcd(second);
- m_time_counter[1] = convert_to_bcd(minute);
- m_time_counter[2] = convert_to_bcd(hour);
- m_time_counter[3] = convert_to_bcd(day);
- m_time_counter[4] = (month << 4) | (day_of_week - 1);
- m_time_counter[5] = convert_to_bcd(year);
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void upd1990a_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_CLOCK:
- advance_seconds();
- break;
-
- case TIMER_TP:
- m_tp = !m_tp;
- m_write_tp(m_tp);
- break;
-
- case TIMER_DATA_OUT:
- m_data_out = !m_data_out;
- m_write_data(get_data_out());
- break;
-
- case TIMER_TEST_MODE:
- if (m_oe)
- {
- /* TODO: completely untested */
- /* time counter is advanced from "Second" counter input */
- int max_shift = is_serial_mode() ? 6 : 5;
- m_data_out = (m_time_counter[max_shift - 1] == 0);
- m_write_data(get_data_out());
-
- for (int i = 0; i < max_shift; i++)
- {
- m_time_counter[i]++;
- if (m_time_counter[i] != 0)
- return;
- }
- }
- else
- {
- /* each counter is advanced in parallel, overflow carry does not affect next counter */
- m_data_out = 0;
-
- int max_shift = is_serial_mode() ? 6 : 5;
- for (int i = 0; i < max_shift; i++)
- {
- m_time_counter[i]++;
- m_data_out |= (m_time_counter[i] == 0);
- }
- m_write_data(get_data_out());
- }
-
- break;
- }
-}
-
-
-//-------------------------------------------------
-// stb_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( upd1990a_device::stb_w )
-{
- if (!m_cs)
- return;
-
- if (LOG) logerror("uPD1990A '%s' STB %u\n", tag(), state);
-
- // rising edge
- if (!m_stb && state)
- {
- // read command
- if (is_serial_mode())
- m_c = m_shift_reg[6];
- else
- {
- m_c = m_c_unlatched;
- if (m_c == 7)
- m_c = MODE_TEST;
- }
-
- if (LOG) logerror("uPD1990A '%s' Command %x\n", tag(), m_c);
-
- // common functions
- if (m_c == MODE_REGISTER_HOLD || (m_c >= MODE_TP_64HZ && m_c < MODE_TEST))
- {
- // enable time counter
- m_timer_clock->enable(1);
-
- // disable testmode
- m_testmode = false;
- m_timer_test_mode->enable(0);
- }
-
- switch (m_c)
- {
- case MODE_REGISTER_HOLD:
- // 1Hz data out pulse
- m_timer_data_out->adjust(attotime::zero, 0, attotime::from_hz((clock() / 32768.0) * 2.0));
-
- // 64Hz time pulse
- m_timer_tp->adjust(attotime::zero, 0, attotime::from_hz((clock() / 512.0) * 2.0));
- break;
-
- case MODE_SHIFT:
- // enable time counter
- if (!m_testmode)
- m_timer_clock->enable(1);
-
- // data out LSB of shift register
- m_timer_data_out->enable(0);
- m_data_out = m_shift_reg[0] & 1;
- m_write_data(get_data_out());
-
- // 32Hz time pulse in testmode
- if (m_testmode)
- m_timer_tp->adjust(attotime::zero, 0, attotime::from_hz((clock() / 1024.0) * 2.0));
-
- break;
-
- case MODE_TIME_SET:
- {
- // disable time counter
- m_timer_clock->enable(0);
-
- // data out LSB of shift register
- m_timer_data_out->enable(0);
- m_data_out = m_shift_reg[0] & 1;
- m_write_data(get_data_out());
-
- // load shift register data into time counter
- int max_shift = is_serial_mode() ? 6 : 5;
- for (int i = 0; i < max_shift; i++)
- m_time_counter[i] = m_shift_reg[i];
-
- set_time(false,
- bcd_to_integer(m_time_counter[5]),
- m_time_counter[4] >> 4,
- bcd_to_integer(m_time_counter[3]),
- (m_time_counter[4] & 0xf) + 1,
- bcd_to_integer(m_time_counter[2]),
- bcd_to_integer(m_time_counter[1]),
- bcd_to_integer(m_time_counter[0])
- );
-
- // reset stage 10-15 of clock divider
- m_timer_clock->adjust(attotime::from_ticks(m_timer_clock->remaining().as_ticks(clock()) % (clock() / 512), clock()), 0, attotime::from_hz(clock() / 32768.0));
-
- // disable(low) time pulse in testmode
- if (m_testmode)
- {
- m_timer_tp->enable(0);
- m_tp = 0;
- m_write_tp(m_tp);
- }
-
- break;
- }
-
- case MODE_TIME_READ:
- {
- // enable time counter
- if (!m_testmode)
- m_timer_clock->enable(1);
-
- // load time counter data into shift register
- int max_shift = is_serial_mode() ? 6 : 5;
- for (int i = 0; i < max_shift; i++)
- m_shift_reg[i] = m_time_counter[i];
-
- // data out pulse: uPD4990A: 1Hz, uPD1990A: 512Hz in testmode, 0.5Hz in normal mode
- double div;
- if (m_variant == TYPE_4990A)
- div = 32768.0;
- else if (m_testmode)
- div = 64.0;
- else div = 65536.0;
-
- m_timer_data_out->adjust(attotime::zero, 0, attotime::from_hz((clock() / div) * 2.0));
-
- // 32Hz time pulse in testmode
- if (m_testmode)
- m_timer_tp->adjust(attotime::zero, 0, attotime::from_hz((clock() / 1024.0) * 2.0));
-
- break;
- }
-
- case MODE_TP_64HZ:
- case MODE_TP_256HZ:
- case MODE_TP_2048HZ:
- case MODE_TP_4096HZ:
- {
- // set timer pulse
- const double div[4] = { 512.0, 128.0, 16.0, 8.0 };
- m_timer_tp->adjust(attotime::zero, 0, attotime::from_hz((clock() / div[m_c - MODE_TP_64HZ]) * 2.0));
-
- break;
- }
-
- case MODE_TP_1S_INT:
- case MODE_TP_10S_INT:
- case MODE_TP_30S_INT:
- case MODE_TP_60S_INT:
- {
- // set timer pulse
- attotime one_second = attotime::from_hz(clock() / 32768.0);
- const double mul[4] = { 1.0, 10.0, 30.0, 60.0 };
- m_timer_tp->adjust(attotime::zero, 0, one_second * mul[m_c - MODE_TP_1S_INT] / 2.0);
-
- break;
- }
-
- case MODE_INT_RESET_OUTPUT:
- case MODE_INT_RUN_CLOCK:
- case MODE_INT_STOP_CLOCK:
- // TODO
- break;
-
- case MODE_TEST:
- {
- // disable time counter
- m_timer_clock->enable(0);
-
- // disable data out pulse
- m_timer_data_out->enable(0);
-
- // enable testmode
- m_testmode = true;
- m_timer_test_mode->enable(1);
- const float div = (m_variant == TYPE_4990A) ? 4.0 : 32.0; // uPD4990A: 8192Hz, uPD1990A: 1024Hz
- m_timer_test_mode->adjust(attotime::zero, 0, attotime::from_hz(clock() / div));
- break;
- }
-
- default:
- break;
- }
- }
-
- m_stb = state;
-}
-
-
-//-------------------------------------------------
-// clk_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( upd1990a_device::clk_w )
-{
- if (!m_cs)
- return;
-
- if (LOG) logerror("uPD1990A '%s' CLK %u\n", tag(), state);
-
- // rising edge
- if (!m_clk && state)
- {
- int in = m_data_in;
-
- if (is_serial_mode())
- {
- // always clock serial command register
- in = m_shift_reg[6] & 1;
- m_shift_reg[6] >>= 1;
- m_shift_reg[6] |= (m_data_in << 3);
- }
-
- if (m_c == MODE_SHIFT)
- {
- // clock shift register
- int max_shift = is_serial_mode() ? 6 : 5;
- for (int i = 0; i < max_shift; i++)
- {
- m_shift_reg[i] >>= 1;
- if (i == (max_shift - 1))
- m_shift_reg[i] |= (in << 7); // shift in new bit
- else
- m_shift_reg[i] |= (m_shift_reg[i + 1] << 7 & 0x80);
- }
-
- // data out LSB of shift register
- m_data_out = m_shift_reg[0] & 1;
- m_write_data(get_data_out());
- }
- }
-
- m_clk = state;
-}
-
-
-//-------------------------------------------------
-// misc input pins
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( upd1990a_device::cs_w )
-{
- // chip select
- if (LOG) logerror("uPD1990A '%s' CS %u\n", tag(), state);
- m_cs = state;
-}
-
-WRITE_LINE_MEMBER( upd1990a_device::oe_w )
-{
- // output enable
- if (LOG) logerror("uPD1990A '%s' OE %u\n", tag(), state);
-
- int prev_oe = m_oe;
- m_oe = state;
-
- if (m_oe != prev_oe && m_c != MODE_TEST)
- m_write_data(get_data_out());
-}
-
-WRITE_LINE_MEMBER( upd1990a_device::c0_w )
-{
- if (LOG) logerror("uPD1990A '%s' C0 %u\n", tag(), state);
- m_c_unlatched = (m_c_unlatched & 0x06) | state;
-}
-
-WRITE_LINE_MEMBER( upd1990a_device::c1_w )
-{
- if (LOG) logerror("uPD1990A '%s' C1 %u\n", tag(), state);
- m_c_unlatched = (m_c_unlatched & 0x05) | (state << 1);
-}
-
-WRITE_LINE_MEMBER( upd1990a_device::c2_w )
-{
- if (LOG) logerror("uPD1990A '%s' C2 %u\n", tag(), state);
- m_c_unlatched = (m_c_unlatched & 0x03) | (state << 2);
-}
-
-WRITE_LINE_MEMBER( upd1990a_device::data_in_w )
-{
- // data input
- if (LOG) logerror("uPD1990A '%s' DATA IN %u\n", tag(), state);
- m_data_in = state;
-}
-
-
-//-------------------------------------------------
-// output pins
-//-------------------------------------------------
-
-int upd1990a_device::get_data_out()
-{
- // except when in testmode, data_out is high impedance when OE is low
- return (m_oe || m_testmode) ? m_data_out : 1;
-}
-
-
-READ_LINE_MEMBER( upd1990a_device::data_out_r )
-{
- return get_data_out();
-}
-
-READ_LINE_MEMBER( upd1990a_device::tp_r )
-{
- return m_tp;
-}
diff --git a/src/emu/machine/upd1990a.h b/src/emu/machine/upd1990a.h
deleted file mode 100644
index 745f6c6e648..00000000000
--- a/src/emu/machine/upd1990a.h
+++ /dev/null
@@ -1,161 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder, hap
-/**********************************************************************
-
- NEC uPD1990AC Serial I/O Calendar & Clock emulation
-
-**********************************************************************
- _____ _____
- C2 1 |* \_/ | 14 Vdd
- C1 2 | | 13 XTAL
- C0 3 | | 12 _XTAL
- STB 4 | uPD1990AC | 11 OUT ENBL
- CS 5 | | 10 TP
- DATA IN 6 | | 9 DATA OUT
- GND 7 |_____________| 8 CLK
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __UPD1990A__
-#define __UPD1990A__
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_UPD1990A_ADD(_tag, _clock, _data, _tp) \
- MCFG_DEVICE_ADD((_tag), UPD1990A, _clock) \
- downcast<upd1990a_device *>(device)->set_data_callback(DEVCB_##_data); \
- downcast<upd1990a_device *>(device)->set_tp_callback(DEVCB_##_tp);
-
-#define MCFG_UPD4990A_ADD(_tag, _clock, _data, _tp) \
- MCFG_DEVICE_ADD((_tag), UPD4990A, _clock) \
- downcast<upd1990a_device *>(device)->set_data_callback(DEVCB_##_data); \
- downcast<upd1990a_device *>(device)->set_tp_callback(DEVCB_##_tp);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> upd1990a_device
-
-class upd1990a_device : public device_t,
- public device_rtc_interface
-{
-public:
- // construction/destruction
- upd1990a_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source);
- upd1990a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _data> void set_data_callback(_data data) { m_write_data.set_callback(data); }
- template<class _tp> void set_tp_callback(_tp tp) { m_write_tp.set_callback(tp); }
-
- DECLARE_WRITE_LINE_MEMBER( oe_w );
- DECLARE_WRITE_LINE_MEMBER( cs_w );
- DECLARE_WRITE_LINE_MEMBER( stb_w );
- DECLARE_WRITE_LINE_MEMBER( clk_w );
- DECLARE_WRITE_LINE_MEMBER( c0_w );
- DECLARE_WRITE_LINE_MEMBER( c1_w );
- DECLARE_WRITE_LINE_MEMBER( c2_w );
- DECLARE_WRITE_LINE_MEMBER( data_in_w );
- DECLARE_READ_LINE_MEMBER( data_out_r );
- DECLARE_READ_LINE_MEMBER( tp_r );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_rtc_interface overrides
- virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
-
- enum
- {
- TYPE_1990A = 0,
- TYPE_4990A
- };
-
-private:
- enum
- {
- TIMER_CLOCK,
- TIMER_TP,
- TIMER_DATA_OUT,
- TIMER_TEST_MODE
- };
-
- enum
- {
- MODE_REGISTER_HOLD = 0,
- MODE_SHIFT,
- MODE_TIME_SET,
- MODE_TIME_READ,
- MODE_TP_64HZ,
- MODE_TP_256HZ,
- MODE_TP_2048HZ,
- MODE_TP_4096HZ,
- MODE_TP_1S_INT,
- MODE_TP_10S_INT,
- MODE_TP_30S_INT,
- MODE_TP_60S_INT,
- MODE_INT_RESET_OUTPUT,
- MODE_INT_RUN_CLOCK,
- MODE_INT_STOP_CLOCK,
- MODE_TEST
- };
-
- devcb_write_line m_write_data;
- devcb_write_line m_write_tp;
-
- UINT8 m_time_counter[6]; // time counter
- UINT8 m_shift_reg[7]; // shift register (40 bits, or 48 bits + serial command register)
-
- int m_oe; // output enable
- int m_cs; // chip select
- int m_stb; // strobe
- int m_data_in; // data in
- int m_data_out; // data out
- int m_c; // latched command
- int m_clk; // shift clock
- int m_tp; // time pulse
- int m_c_unlatched; // command waiting for STB
-
- bool m_testmode; // testmode active
-
- int m_variant;
-
- // timers
- emu_timer *m_timer_clock;
- emu_timer *m_timer_tp;
- emu_timer *m_timer_data_out;
- emu_timer *m_timer_test_mode;
-
- bool is_serial_mode();
- int get_data_out();
-};
-
-
-// ======================> upd4990a_device
-
-class upd4990a_device : public upd1990a_device
-{
-public:
- upd4990a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-
-// device type definitions
-extern const device_type UPD1990A;
-extern const device_type UPD4990A;
-
-
-
-#endif
diff --git a/src/emu/machine/upd4701.c b/src/emu/machine/upd4701.c
deleted file mode 100644
index 4a7adfda291..00000000000
--- a/src/emu/machine/upd4701.c
+++ /dev/null
@@ -1,259 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- NEC uPD4701
-
- Incremental Encoder Control
-
- 2009-06 Converted to be a device
-
-***************************************************************************/
-
-#include "emu.h"
-#include "upd4701.h"
-
-#define MASK_SWITCHES ( 7 )
-#define MASK_COUNTER ( 0xfff )
-
-const device_type UPD4701 = &device_creator<upd4701_device>;
-
-upd4701_device::upd4701_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, UPD4701, "uPD4701 Encoder", tag, owner, clock, "upd4701", __FILE__)
-{
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void upd4701_device::device_config_complete()
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void upd4701_device::device_start()
-{
- save_item(NAME(m_cs));
- save_item(NAME(m_xy));
- save_item(NAME(m_ul));
- save_item(NAME(m_resetx));
- save_item(NAME(m_resety));
- save_item(NAME(m_latchx));
- save_item(NAME(m_latchy));
- save_item(NAME(m_startx));
- save_item(NAME(m_starty));
- save_item(NAME(m_x));
- save_item(NAME(m_y));
- save_item(NAME(m_switches));
- save_item(NAME(m_latchswitches));
- save_item(NAME(m_cf));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void upd4701_device::device_reset()
-{
- m_cs = 1;
- m_xy = 0;
- m_ul = 0;
- m_resetx = 0;
- m_resety = 0;
- m_latchx = 0;
- m_latchy = 0;
- m_startx = 0;
- m_starty = 0;
- m_x = 0;
- m_y = 0;
- m_switches = 0;
- m_latchswitches = 0;
- m_cf = 1;
-}
-
-/* x,y increments can be 12bit (see MASK_COUNTER), hence we need a couple of
-16bit handlers in the following */
-
-/*-------------------------------------------------
- ul_w
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( upd4701_device::ul_w )
-{
- m_ul = state;
-}
-
-/*-------------------------------------------------
- xy_w
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( upd4701_device::xy_w )
-{
- m_xy = state;
-}
-
-/*-------------------------------------------------
- cs_w
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( upd4701_device::cs_w )
-{
- if (m_cs != state)
- {
- m_cs = state;
-
- if (!m_cs)
- {
- m_latchx = (m_x - m_startx) & MASK_COUNTER;
- m_latchy = (m_y - m_starty) & MASK_COUNTER;
-
- m_latchswitches = (~m_switches) & MASK_SWITCHES;
- if (m_latchswitches != 0)
- {
- m_latchswitches |= 8;
- }
-
- m_cf = 1;
- }
- }
-}
-
-/*-------------------------------------------------
- resetx_w
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( upd4701_device::resetx_w )
-{
- if (m_resetx != state)
- {
- m_resetx = state;
-
- if (m_resetx)
- {
- m_startx = m_x;
- }
- }
-}
-
-/*-------------------------------------------------
- resety_w
--------------------------------------------------*/
-
-WRITE_LINE_MEMBER( upd4701_device::resety_w )
-{
- if (m_resety != state)
- {
- m_resety = state;
-
- if (m_resety)
- {
- m_starty = m_y;
- }
- }
-}
-
-/*-------------------------------------------------
- x_add
--------------------------------------------------*/
-
-void upd4701_device::x_add( INT16 data )
-{
- if (!m_resetx && data != 0)
- {
- m_x += data;
-
- if (m_cs)
- {
- m_cf = 0;
- }
- }
-}
-
-/*-------------------------------------------------
- y_add
--------------------------------------------------*/
-
-void upd4701_device::y_add( INT16 data )
-{
- if (!m_resety && data != 0)
- {
- m_y += data;
-
- if (m_cs)
- {
- m_cf = 0;
- }
- }
-}
-
-/*-------------------------------------------------
- switches_set
--------------------------------------------------*/
-
-void upd4701_device::switches_set( UINT8 data )
-{
- m_switches = data;
-}
-
-/*-------------------------------------------------
- d_r
--------------------------------------------------*/
-
-READ16_MEMBER( upd4701_device::d_r )
-{
- int data;
-
- if (m_cs)
- {
- return 0xff;
- }
-
- if (m_xy)
- {
- data = m_latchy;
- }
- else
- {
- data = m_latchx;
- }
-
- data |= m_latchswitches << 12;
-
- if (m_ul)
- {
- return data >> 8;
- }
- else
- {
- return data & 0xff;
- }
-}
-
-/*-------------------------------------------------
- sf_r
--------------------------------------------------*/
-
-READ_LINE_MEMBER( upd4701_device::sf_r )
-{
- if ((m_switches & MASK_SWITCHES) != MASK_SWITCHES)
- {
- return 0;
- }
-
- return 1;
-}
-
-/*-------------------------------------------------
- cf_r
--------------------------------------------------*/
-
-READ_LINE_MEMBER( upd4701_device::cf_r )
-{
- return m_cf;
-}
diff --git a/src/emu/machine/upd4701.h b/src/emu/machine/upd4701.h
deleted file mode 100644
index e8cb0e0243f..00000000000
--- a/src/emu/machine/upd4701.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- NEC uPD4701
-
- Incremental Encoder Control
-
-***************************************************************************/
-
-#ifndef __UPD4701_H__
-#define __UPD4701_H__
-
-/***************************************************************************
- MACROS / CONSTANTS
-***************************************************************************/
-
-class upd4701_device : public device_t
-{
-public:
- upd4701_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- void x_add( INT16 data );
- void y_add( INT16 data );
- void switches_set( UINT8 data );
-
- DECLARE_WRITE_LINE_MEMBER( cs_w );
- DECLARE_WRITE_LINE_MEMBER( xy_w );
- DECLARE_WRITE_LINE_MEMBER( ul_w );
- DECLARE_WRITE_LINE_MEMBER( resetx_w );
- DECLARE_WRITE_LINE_MEMBER( resety_w );
-
- DECLARE_READ16_MEMBER( d_r );
- DECLARE_READ_LINE_MEMBER( cf_r );
- DECLARE_READ_LINE_MEMBER( sf_r );
-
-protected:
- // device-level overrides
- virtual void device_config_complete();
- virtual void device_start();
- virtual void device_reset();
-private:
- // internal state
- int m_cs;
- int m_xy;
- int m_ul;
- int m_resetx;
- int m_resety;
- int m_latchx;
- int m_latchy;
- int m_startx;
- int m_starty;
- int m_x;
- int m_y;
- int m_switches;
- int m_latchswitches;
- int m_cf;
-};
-
-extern const device_type UPD4701;
-
-
-#define MCFG_UPD4701_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, UPD4701, 0)
-
-#endif /* __UPD4701_H__ */
diff --git a/src/emu/machine/upd4992.c b/src/emu/machine/upd4992.c
deleted file mode 100644
index 3636a7e7d75..00000000000
--- a/src/emu/machine/upd4992.c
+++ /dev/null
@@ -1,156 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders: Angelo Salese
-/***************************************************************************
-
- uPD4992 parallel RTC
-
- TODO:
- - Add timers
- - Add leap year count
- - Add 12 hours mode
- - Add mode/control register
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/upd4992.h"
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type UPD4992 = &device_creator<upd4992_device>;
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// upd4992_device - constructor
-//-------------------------------------------------
-
-upd4992_device::upd4992_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, UPD4992, "uPD4992 RTC", tag, owner, clock, "upd4992", __FILE__),
- device_rtc_interface(mconfig, *this)
-{
-}
-
-
-//-------------------------------------------------
-// device_validity_check - perform validity checks
-// on this device
-//-------------------------------------------------
-
-void upd4992_device::device_validity_check(validity_checker &valid) const
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void upd4992_device::device_start()
-{
- m_timer_clock = timer_alloc(TIMER_CLOCK);
- m_timer_clock->adjust(attotime::from_hz(clock() / 32768), 0, attotime::from_hz(clock() / 32768));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void upd4992_device::device_reset()
-{
- set_current_time(machine());
-}
-
-
-void upd4992_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_CLOCK:
- advance_seconds();
- break;
- }
-}
-
-//-------------------------------------------------
-// rtc_clock_updated -
-//-------------------------------------------------
-
-void upd4992_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
-/*
-[2]
-x--- ---- 12/24H flag
--x-- ---- AM/PM flag
---xx ---- 10 hour digit
----- xxxx 1s hour digit
-[3]
-xx-- ---- Leap year control
---xx ---- Leap year counter
----- xxxx Day of week digit
-[4]
-xxxx ---- 10s day digit
----- xxxx 1s day digit
-[5]
-xxxx ---- 10s month digit
----- xxxx 1s month digit
-[6]
-xxxx ---- 10s year digit
----- xxxx 1s year digit
-[7]
-xxxx ---- Mode register
----- xxxx Control Register
-*/
- m_rtc_regs[0] = convert_to_bcd(second);
- m_rtc_regs[1] = convert_to_bcd(minute);
- m_rtc_regs[2] = convert_to_bcd(hour);
- m_rtc_regs[3] = day_of_week-1;
- m_rtc_regs[4] = convert_to_bcd(day);
- m_rtc_regs[5] = convert_to_bcd(month);
- m_rtc_regs[6] = convert_to_bcd(year);
-}
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-READ8_MEMBER( upd4992_device::read )
-{
- return m_rtc_regs[offset];
-}
-
-WRITE8_MEMBER( upd4992_device::write )
-{
- if(offset == 7)
- {
- if(data & 8)
- {
- if(data & 2) // reset
- {
- // ...
- }
-
- m_timer_clock->enable(data & 1);
- }
- }
- else // TODO: perhaps there's a write inhibit?
- {
- m_rtc_regs[offset] = data;
- set_time(1, bcd_to_integer(m_rtc_regs[6]),
- bcd_to_integer(m_rtc_regs[5]),
- bcd_to_integer(m_rtc_regs[4]),
- m_rtc_regs[3]+1,
- bcd_to_integer(m_rtc_regs[2]),
- bcd_to_integer(m_rtc_regs[1]),
- bcd_to_integer(m_rtc_regs[0]));
- }
-}
diff --git a/src/emu/machine/upd4992.h b/src/emu/machine/upd4992.h
deleted file mode 100644
index 90d3f303c83..00000000000
--- a/src/emu/machine/upd4992.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders: Angelo Salese
-/***************************************************************************
-
- uPD4992 RTC
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __UPD4992DEV_H__
-#define __UPD4992DEV_H__
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_UPD4992_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, UPD4992, XTAL_32_768kHz)
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> upd4992_device
-
-class upd4992_device : public device_t,
- public device_rtc_interface
-{
-public:
- // construction/destruction
- upd4992_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // I/O operations
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_READ8_MEMBER( read );
-
-protected:
- // device-level overrides
- virtual void device_validity_check(validity_checker &valid) const;
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
-
-private:
- enum
- {
- TIMER_CLOCK
- //TIMER_TP,
- //TIMER_DATA_OUT,
- //TIMER_TEST_MODE
- };
-
- emu_timer *m_timer_clock;
- UINT8 m_rtc_regs[8];
-};
-
-
-// device type definition
-extern const device_type UPD4992;
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-
-
-#endif
diff --git a/src/emu/machine/upd7002.c b/src/emu/machine/upd7002.c
deleted file mode 100644
index b74d1bbf1d0..00000000000
--- a/src/emu/machine/upd7002.c
+++ /dev/null
@@ -1,172 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Gordon Jefferyes
-/******************************************************************************
- uPD7002 Analogue to Digital Converter
-
- MESS Driver By:
-
- Gordon Jefferyes
- mess_bbc@gjeffery.dircon.co.uk
-
-******************************************************************************/
-
-#include "emu.h"
-#include "upd7002.h"
-
-
-/* Device Interface */
-
-const device_type UPD7002 = &device_creator<upd7002_device>;
-
-upd7002_device::upd7002_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, UPD7002, "uPD7002", tag, owner, clock, "upd7002", __FILE__)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void upd7002_device::device_start()
-{
- m_get_analogue_cb.bind_relative_to(*owner());
- m_eoc_cb.bind_relative_to(*owner());
-
- // register for state saving
- save_item(NAME(m_status));
- save_item(NAME(m_data1));
- save_item(NAME(m_data0));
- save_item(NAME(m_digitalvalue));
- save_item(NAME(m_conversion_counter));
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void upd7002_device::device_reset()
-{
- m_status = 0;
- m_data1 = 0;
- m_data0 = 0;
- m_digitalvalue = 0;
- m_conversion_counter = 0;
-}
-
-
-/*****************************************************************************
- Implementation
-*****************************************************************************/
-
-
-READ8_MEMBER( upd7002_device::eoc_r )
-{
- return (m_status>>7)&0x01;
-}
-
-
-void upd7002_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_CONVERSION_COMPLETE:
- {
- int counter_value = param;
- if (counter_value==m_conversion_counter)
- {
- // this really always does a 12 bit conversion
- m_data1 = m_digitalvalue>>8;
- m_data0 = m_digitalvalue&0xf0;
-
- // set the status register with top 2 MSB, not busy and conversion complete
- m_status = (m_status & 0x0f)|((m_data1 & 0xc0)>>2)|0x40;
-
- // call the EOC function with EOC from status
- // eoc_r(0) this has just been set to 0
- if (!m_eoc_cb.isnull()) m_eoc_cb(0);
- m_conversion_counter=0;
- }
- break;
- }
- default:
- assert_always(FALSE, "Unknown id in upd7002_device::device_timer");
- }
-}
-
-
-READ8_MEMBER( upd7002_device::read )
-{
- switch(offset&0x03)
- {
- case 0:
- return m_status;
-
- case 1:
- return m_data1;
-
- case 2: case 3:
- return m_data0;
- }
- return 0;
-}
-
-
-
-WRITE8_MEMBER( upd7002_device::write )
-{
- /* logerror("write to uPD7002 $%02X = $%02X\n",offset,data); */
-
- switch(offset&0x03)
- {
- case 0:
- /*
- Data Latch/AD start
- D0 and D1 together define which one of the four input channels is selected
- D2 flag input, normally set to 0????
- D3 defines whether an 8 (0) or 12 (1) bit resolution conversion should occur
- D4 to D7 not used.
-
- an 8 bit conversion typically takes 4ms
- an 12 bit conversion typically takes 10ms
-
- writing to this register will initiate a conversion.
- */
-
- /* set D6=0 busy ,D7=1 conversion not complete */
- m_status=(data & 0x0f) | 0x80;
-
- // call the EOC function with EOC from status
- // eoc_r(0) this has just been set to 1
- if (!m_eoc_cb.isnull()) m_eoc_cb(1);
-
- /* the uPD7002 works by sampling the analogue value at the start of the conversion
- so it is read hear and stored until the end of the A to D conversion */
-
- // this function should return a 16 bit value.
- m_digitalvalue = m_get_analogue_cb(m_status & 0x03);
-
- m_conversion_counter++;
-
- // call a timer to start the conversion
- if (m_status & 0x08)
- {
- // 12 bit conversion takes 10ms
- timer_set(attotime::from_msec(10), TIMER_CONVERSION_COMPLETE, m_conversion_counter);
- } else {
- // 8 bit conversion takes 4ms
- timer_set(attotime::from_msec(4), TIMER_CONVERSION_COMPLETE, m_conversion_counter);
- }
- break;
-
- case 1: case 2:
- /* Nothing */
- break;
-
- case 3:
- /* Test Mode: Used for inspecting the device, The data input-output terminals assume an input
- state and are connected to the A/D counter. Therefore, the A/D conversion data
- read out after this is meaningless.
- */
- break;
- }
-}
diff --git a/src/emu/machine/upd7002.h b/src/emu/machine/upd7002.h
deleted file mode 100644
index aba6bb8b36f..00000000000
--- a/src/emu/machine/upd7002.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Gordon Jefferyes
-/*****************************************************************************
- *
- * machine/upd7002.h
- *
- * uPD7002 Analogue to Digital Converter
- *
- * Driver by Gordon Jefferyes <mess_bbc@gjeffery.dircon.co.uk>
- *
- ****************************************************************************/
-
-#ifndef UPD7002_H_
-#define UPD7002_H_
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-typedef device_delegate<int (int channel_number)> upd7002_get_analogue_delegate;
-#define UPD7002_GET_ANALOGUE(name) int name(int channel_number)
-
-typedef device_delegate<void (int data)> upd7002_eoc_delegate;
-#define UPD7002_EOC(name) void name(int data)
-
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-class upd7002_device : public device_t
-{
-public:
- upd7002_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~upd7002_device() {}
-
- static void set_get_analogue_callback(device_t &device, upd7002_get_analogue_delegate callback) { downcast<upd7002_device &>(device).m_get_analogue_cb = callback; }
- static void set_eoc_callback(device_t &device, upd7002_eoc_delegate callback) { downcast<upd7002_device &>(device).m_eoc_cb = callback; }
-
- DECLARE_READ8_MEMBER(eoc_r);
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- // internal state
-
- /* Status Register
- D0 and D1 define the currently selected input channel
- D2 flag output
- D3 0 = 8 bit mode 1 = 12 bit mode
- D4 2nd MSB of conversion
- D5 MSB of conversion
- D6 0 = busy, 1 = not busy (~busy)
- D7 0 = conversion completed, 1 = conversion not completed (~EOC)
- */
- int m_status;
-
- /* High data byte
- This byte contains the 8 most significant bits of the analogue to digital conversion. */
- int m_data1;
-
- /* Low data byte
- In 12 bit mode: Bits 7 to 4 define the four low order bits of the conversion.
- In 8 bit mode. All bits 7 to 4 are inaccurate.
- Bits 3 to 0 are always set to low. */
- int m_data0;
-
-
- /* temporary store of the next A to D conversion */
- int m_digitalvalue;
-
- /* this counter is used to check a full end of conversion has been reached
- if the uPD7002 is half way through one conversion and a new conversion is requested
- the counter at the end of the first conversion will not match and not be processed
- only then at the end of the second conversion will the conversion complete function run */
- int m_conversion_counter;
-
- upd7002_get_analogue_delegate m_get_analogue_cb;
- upd7002_eoc_delegate m_eoc_cb;
-
- enum
- {
- TIMER_CONVERSION_COMPLETE
- };
-};
-
-extern const device_type UPD7002;
-
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_UPD7002_GET_ANALOGUE_CB(_class, _method) \
- upd7002_device::set_get_analogue_callback(*device, upd7002_get_analogue_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#define MCFG_UPD7002_EOC_CB(_class, _method) \
- upd7002_device::set_eoc_callback(*device, upd7002_eoc_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
-
-#endif /* UPD7002_H_ */
diff --git a/src/emu/machine/upd71071.c b/src/emu/machine/upd71071.c
deleted file mode 100644
index 59965256bc5..00000000000
--- a/src/emu/machine/upd71071.c
+++ /dev/null
@@ -1,517 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Barry Rodewald
-
-/*
-
- am9517a.c is a more complete implementation of this, the uPD71071 appears to be a clone of it
-
- NEC uPD71071 DMA Controller
- Used on the Fujitsu FM-Towns
-
- Register description:
-
- 0x00: Initialise (Write-only)
- - bit 0: Reset
- - bit 1: 16-bit data bus
-
- 0x01: Channel Register
- On read:
- - bits 0-3: Selected channel
- - bit 4: Only base registers may be read or written
- On write:
- - bits 0-1: Select channel for programming count, address, and mode registers
- - bit 2: Only base registers can be read or written to
-
- 0x02:
- 0x03: Count Register (16-bit)
- DMA Transfer counter
-
- 0x04:
- 0x05:
- 0x06:
- 0x07: Address Register (32-bit)
- Self-explanatory, I hope. :)
- NOTE: Datasheet clearly shows this as 24-bit, with register 7 unused.
- But the FM-Towns definitely uses reg 7 as bits 24-31.
- The documentation on the V53A manual doesn't show these bits either, maybe it's
- an external connection on the FMT? might be worth checking overflow behavior etc.
-
- 0x08:
- 0x09: Device Control register (16-bit)
- bit 0: Enable memory-to-memory (MTM) transfers
- bit 1: Enable fixed address for channel 0 only (MTM only)
- bit 2: Disable DMA operation (stops HLDRQ signal to the CPU)
- bit 3: Use compressed timing
- bit 4: Rotational Priority
- bit 5: Extended Writing
- bit 6: DMARQ active level (1=active low)
- bit 7: DMAAK active level (1=active high)
- bit 8: Bus mode (0=bus release, 1=bus hold)
- bit 9: Wait Enable during Verify
-
- 0x0a: Mode Control register
- bit 0: Transfer size (1=16-bit, 0=8-bit, 16-bit data bus size only)
- bit 2-3: Transfer direction (ignored for MTM transfers)
- 00 = Verify
- 01 = I/O to memory
- 10 = memory to I/O
- 11 = invalid
- bit 4: Enable auto-initialise
- bit 5: Address direction (0=increment, 1=decrement, affects only current Address reg)
- bit 6-7: Transfer mode (ignored for MTM transfers)
- 00 = Demand
- 01 = Single
- 10 = Block
- 11 = Cascade
-
- 0x0b: Status register
- bit 0-3: Terminal count (per channel)
- bit 4-7: DMA request present (external hardware DMA only)
-
- 0x0c:
- 0x0d: Temporary register (16-bit, read-only)
- Stores the last data transferred in an MTM transfer
-
- 0x0e: Request register
- bit 0-3: Software DMA request (1=set)
- bit 0 only in MTM transfers
-
- 0x0f: Mask register
- bit 0-3: DMARQ mask
- bits 1 and 0 only in MTM transfers
-
- Note, the uPD71071 compatible mode of the V53 CPU differs from a real uPD71071 in the following ways
-
-
-
-*/
-
-#include "emu.h"
-#include "machine/upd71071.h"
-
-
-const device_type UPD71071 = &device_creator<upd71071_device>;
-
-upd71071_device::upd71071_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, UPD71071, "NEC uPD71071", tag, owner, clock, "upd71071", __FILE__),
- m_upd_clock(0),
- m_out_hreq_cb(*this),
- m_out_eop_cb(*this),
- m_dma_read_0_cb(*this),
- m_dma_read_1_cb(*this),
- m_dma_read_2_cb(*this),
- m_dma_read_3_cb(*this),
- m_dma_write_0_cb(*this),
- m_dma_write_1_cb(*this),
- m_dma_write_2_cb(*this),
- m_dma_write_3_cb(*this),
- m_out_dack_0_cb(*this),
- m_out_dack_1_cb(*this),
- m_out_dack_2_cb(*this),
- m_out_dack_3_cb(*this),
- m_cpu(*this)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void upd71071_device::device_start()
-{
- m_out_hreq_cb.resolve_safe();
- m_out_eop_cb.resolve_safe();
- m_dma_read_0_cb.resolve_safe(0);
- m_dma_read_1_cb.resolve_safe(0);
- m_dma_read_2_cb.resolve_safe(0);
- m_dma_read_3_cb.resolve_safe(0);
- m_dma_write_0_cb.resolve_safe();
- m_dma_write_1_cb.resolve_safe();
- m_dma_write_2_cb.resolve_safe();
- m_dma_write_3_cb.resolve_safe();
- m_out_dack_0_cb.resolve_safe();
- m_out_dack_1_cb.resolve_safe();
- m_out_dack_2_cb.resolve_safe();
- m_out_dack_3_cb.resolve_safe();
- for (int x = 0; x < 4; x++)
- {
- m_timer[x] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(upd71071_device::dma_transfer_timer),this));
- }
- m_selected_channel = 0;
-
- m_reg.device_control = 0;
- m_reg.mask = 0x0f; // mask all channels
- for (int x = 0; x < 4; x++)
- m_reg.mode_control[x] = 0;
-
- save_item(NAME(m_reg.initialise));
- save_item(NAME(m_reg.channel));
- save_item(NAME(m_reg.count_current));
- save_item(NAME(m_reg.count_base));
- save_item(NAME(m_reg.address_current));
- save_item(NAME(m_reg.address_base));
- save_item(NAME(m_reg.device_control));
- save_item(NAME(m_reg.mode_control));
- save_item(NAME(m_reg.status));
- save_item(NAME(m_reg.temp_l));
- save_item(NAME(m_reg.temp_h));
- save_item(NAME(m_reg.request));
- save_item(NAME(m_reg.mask));
-
- save_item(NAME(m_selected_channel));
- save_item(NAME(m_buswidth));
- save_item(NAME(m_dmarq));
- save_item(NAME(m_base));
- save_item(NAME(m_hreq));
- save_item(NAME(m_eop));
-}
-
-
-
-TIMER_CALLBACK_MEMBER(upd71071_device::dma_transfer_timer)
-{
- // single byte or word transfer
- int channel = param;
- UINT16 data = 0; // data to transfer
-
- switch (m_reg.mode_control[channel] & 0x0c)
- {
- case 0x00: // Verify
- break;
- case 0x04: // I/O -> memory
- switch (channel)
- {
- case 0:
- if (!m_dma_read_0_cb.isnull())
- data = m_dma_read_0_cb(0);
- break;
- case 1:
- if (!m_dma_read_1_cb.isnull())
- data = m_dma_read_1_cb(0);
- break;
- case 2:
- if (!m_dma_read_2_cb.isnull())
- data = m_dma_read_2_cb(0);
- break;
- case 3:
- if (!m_dma_read_3_cb.isnull())
- data = m_dma_read_3_cb(0);
- break;
- }
-
- if (m_cpu)
- {
- address_space& space = m_cpu->space(AS_PROGRAM);
- space.write_byte(m_reg.address_current[channel], data & 0xff);
- }
- else
- {
- printf("upd71071_device: dma_transfer_timer - write to memory, no dest space %02x\n", data & 0xff);
- }
-
- if (m_reg.mode_control[channel] & 0x20) // Address direction
- m_reg.address_current[channel]--;
- else
- m_reg.address_current[channel]++;
- m_reg.count_current[channel]--;
- if(m_reg.count_current[channel] == 0xffff)
- {
- if (m_reg.mode_control[channel] & 0x10) // auto-initialise
- {
- m_reg.address_current[channel] = m_reg.address_base[channel];
- m_reg.count_current[channel] = m_reg.count_base[channel];
- }
- // TODO: send terminal count
- set_eop(ASSERT_LINE);
- }
- break;
- case 0x08: // memory -> I/O
- if (m_cpu)
- {
- address_space& space = m_cpu->space(AS_PROGRAM);
- data = space.read_byte(m_reg.address_current[channel]);
- }
- else
- {
- printf("upd71071_device: dma_transfer_timer - read from memory, no src space\n");
- data = 0x00;
- }
-
- switch (channel)
- {
- case 0:
- if (!m_dma_write_0_cb.isnull())
- m_dma_write_0_cb((offs_t)0, data);
- break;
- case 1:
- if (!m_dma_write_1_cb.isnull())
- m_dma_write_1_cb((offs_t)0, data);
- break;
- case 2:
- if (!m_dma_write_2_cb.isnull())
- m_dma_write_2_cb((offs_t)0, data);
- break;
- case 3:
- if (!m_dma_write_3_cb.isnull())
- m_dma_write_3_cb((offs_t)0, data);
- break;
- }
- if (m_reg.mode_control[channel] & 0x20) // Address direction
- m_reg.address_current[channel]--;
- else
- m_reg.address_current[channel]++;
- m_reg.count_current[channel]--;
- if(m_reg.count_current[channel] == 0xffff)
- {
- if (m_reg.mode_control[channel] & 0x10) // auto-initialise
- {
- m_reg.address_current[channel] = m_reg.address_base[channel];
- m_reg.count_current[channel] = m_reg.count_base[channel];
- }
- // TODO: send terminal count
- set_eop(ASSERT_LINE);
- }
- break;
- case 0x0c: // Invalid
- break;
- }
-}
-
-void upd71071_device::soft_reset()
-{
- // Does not change base/current address, count, or buswidth
- m_selected_channel = 0;
- m_base = 0;
- for (int x = 0; x < 4; x++)
- m_reg.mode_control[x] = 0;
- m_reg.device_control = 0;
- m_reg.temp_h = 0;
- m_reg.temp_l = 0;
- m_reg.mask = 0x0f; // mask all channels
- m_reg.status &= ~0x0f; // clears bits 0-3 only
- m_reg.request = 0;
-}
-
-int upd71071_device::dmarq(int state, int channel)
-{
- if (state != 0)
- {
- if (m_reg.device_control & 0x0004)
- return 2;
-
- if (m_reg.mask & (1 << channel)) // is channel masked?
- return 1;
-
- m_dmarq[channel] = 1; // DMARQ line is set
- m_reg.status |= (0x10 << channel);
-
- // start transfer
- switch (m_reg.mode_control[channel] & 0xc0)
- {
- case 0x00: // Demand
- // TODO
- set_eop(CLEAR_LINE);
- m_timer[channel]->adjust(attotime::from_hz(m_upd_clock), channel);
- break;
- case 0x40: // Single
- m_timer[channel]->adjust(attotime::from_hz(m_upd_clock), channel);
- break;
- case 0x80: // Block
- // TODO
- break;
- case 0xc0: // Cascade
- // TODO
- break;
-
- }
- }
- else
- {
- m_dmarq[channel] = 0; // clear DMARQ line
- m_reg.status &= ~(0x10 << channel);
- m_reg.status |= (0x01 << channel); // END or TC
- }
- return 0;
-}
-
-READ8_MEMBER(upd71071_device::read)
-{
- UINT8 ret = 0;
-
- logerror("DMA: read from register %02x\n",offset);
- switch(offset)
- {
- case 0x01: // Channel
- ret = (1 << m_selected_channel);
- if (m_base != 0)
- ret |= 0x10;
- break;
- case 0x02: // Count (low)
- if (m_base != 0)
- ret = m_reg.count_base[m_selected_channel] & 0xff;
- else
- ret = m_reg.count_current[m_selected_channel] & 0xff;
- break;
- case 0x03: // Count (high)
- if (m_base != 0)
- ret = (m_reg.count_base[m_selected_channel] >> 8) & 0xff;
- else
- ret = (m_reg.count_current[m_selected_channel] >> 8) & 0xff;
- break;
- case 0x04: // Address (low)
- if (m_base != 0)
- ret = m_reg.address_base[m_selected_channel] & 0xff;
- else
- ret = m_reg.address_current[m_selected_channel] & 0xff;
- break;
- case 0x05: // Address (mid)
- if (m_base != 0)
- ret = (m_reg.address_base[m_selected_channel] >> 8) & 0xff;
- else
- ret = (m_reg.address_current[m_selected_channel] >> 8) & 0xff;
- break;
- case 0x06: // Address (high)
- if (m_base != 0)
- ret = (m_reg.address_base[m_selected_channel] >> 16) & 0xff;
- else
- ret = (m_reg.address_current[m_selected_channel] >> 16) & 0xff;
- break;
- case 0x07: // Address (highest)
- if (m_base != 0)
- ret = (m_reg.address_base[m_selected_channel] >> 24) & 0xff;
- else
- ret = (m_reg.address_current[m_selected_channel] >> 24) & 0xff;
- break;
- case 0x08: // Device control (low)
- ret = m_reg.device_control & 0xff;
- break;
- case 0x09: // Device control (high)
- ret = (m_reg.device_control >> 8) & 0xff;
- break;
- case 0x0a: // Mode control
- ret = m_reg.mode_control[m_selected_channel];
- break;
- case 0x0b: // Status
- ret = m_reg.status;
- m_reg.status &= ~0x0f; // resets END/TC?
- break;
- case 0x0c: // Temporary (low)
- ret = m_reg.temp_h;
- break;
- case 0x0d: // Temporary (high)
- ret = m_reg.temp_l;
- break;
- case 0x0e: // Request
- ret = m_reg.request;
- break;
- case 0x0f: // Mask
- ret = m_reg.mask;
- break;
- }
- return ret;
-}
-
-WRITE8_MEMBER(upd71071_device::write)
-{
- switch (offset)
- {
- case 0x00: // Initialise
- // TODO: reset (bit 0)
- m_buswidth = data & 0x02;
- if (data & 0x01)
- soft_reset();
- logerror("DMA: Initialise [%02x]\n",data);
- break;
- case 0x01: // Channel
- m_selected_channel = data & 0x03;
- m_base = data & 0x04;
- logerror("DMA: Channel selected [%02x]\n",data);
- break;
- case 0x02: // Count (low)
- m_reg.count_base[m_selected_channel] =
- (m_reg.count_base[m_selected_channel] & 0xff00) | data;
- if (m_base == 0)
- m_reg.count_current[m_selected_channel] =
- (m_reg.count_current[m_selected_channel] & 0xff00) | data;
- logerror("DMA: Channel %i Counter set [%04x]\n",m_selected_channel,m_reg.count_base[m_selected_channel]);
- break;
- case 0x03: // Count (high)
- m_reg.count_base[m_selected_channel] =
- (m_reg.count_base[m_selected_channel] & 0x00ff) | (data << 8);
- if (m_base == 0)
- m_reg.count_current[m_selected_channel] =
- (m_reg.count_current[m_selected_channel] & 0x00ff) | (data << 8);
- logerror("DMA: Channel %i Counter set [%04x]\n",m_selected_channel,m_reg.count_base[m_selected_channel]);
- break;
- case 0x04: // Address (low)
- m_reg.address_base[m_selected_channel] =
- (m_reg.address_base[m_selected_channel] & 0xffffff00) | data;
- if (m_base == 0)
- m_reg.address_current[m_selected_channel] =
- (m_reg.address_current[m_selected_channel] & 0xffffff00) | data;
- logerror("DMA: Channel %i Address set [%08x]\n",m_selected_channel,m_reg.address_base[m_selected_channel]);
- break;
- case 0x05: // Address (mid)
- m_reg.address_base[m_selected_channel] =
- (m_reg.address_base[m_selected_channel] & 0xffff00ff) | (data << 8);
- if (m_base == 0)
- m_reg.address_current[m_selected_channel] =
- (m_reg.address_current[m_selected_channel] & 0xffff00ff) | (data << 8);
- logerror("DMA: Channel %i Address set [%08x]\n",m_selected_channel,m_reg.address_base[m_selected_channel]);
- break;
- case 0x06: // Address (high)
- m_reg.address_base[m_selected_channel] =
- (m_reg.address_base[m_selected_channel] & 0xff00ffff) | (data << 16);
- if (m_base == 0)
- m_reg.address_current[m_selected_channel] =
- (m_reg.address_current[m_selected_channel] & 0xff00ffff) | (data << 16);
- logerror("DMA: Channel %i Address set [%08x]\n",m_selected_channel,m_reg.address_base[m_selected_channel]);
- break;
- case 0x07: // Address (highest)
- m_reg.address_base[m_selected_channel] =
- (m_reg.address_base[m_selected_channel] & 0x00ffffff) | (data << 24);
- if (m_base == 0)
- m_reg.address_current[m_selected_channel] =
- (m_reg.address_current[m_selected_channel] & 0x00ffffff) | (data << 24);
- logerror("DMA: Channel %i Address set [%08x]\n",m_selected_channel,m_reg.address_base[m_selected_channel]);
- break;
- case 0x08: // Device control (low)
- m_reg.device_control = (m_reg.device_control & 0xff00) | data;
- logerror("DMA: Device control set [%04x]\n",m_reg.device_control);
- break;
- case 0x09: // Device control (high)
- m_reg.device_control = (m_reg.device_control & 0x00ff) | (data << 8);
- logerror("DMA: Device control set [%04x]\n",m_reg.device_control);
- break;
- case 0x0a: // Mode control
- m_reg.mode_control[m_selected_channel] = data;
- logerror("DMA: Channel %i Mode control set [%02x]\n",m_selected_channel,m_reg.mode_control[m_selected_channel]);
- break;
- case 0x0e: // Request
- m_reg.request = data;
- logerror("DMA: Request set [%02x]\n",data);
- break;
- case 0x0f: // Mask
- m_reg.mask = data;
- logerror("DMA: Mask set [%02x]\n",data);
- break;
- }
-}
-
-WRITE_LINE_MEMBER(upd71071_device::set_hreq)
-{
- if (m_hreq != state)
- {
- m_out_hreq_cb(state);
- m_hreq = state;
- }
-}
-
-WRITE_LINE_MEMBER(upd71071_device::set_eop)
-{
- if (m_eop != state)
- {
- m_out_eop_cb(state);
- m_eop = state;
- }
-}
diff --git a/src/emu/machine/upd71071.h b/src/emu/machine/upd71071.h
deleted file mode 100644
index 99da46f80d6..00000000000
--- a/src/emu/machine/upd71071.h
+++ /dev/null
@@ -1,146 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Barry Rodewald
-#ifndef __UPD71071_H__
-#define __UPD71071_H__
-
-#include "emu.h"
-
-
-struct upd71071_reg
-{
- UINT8 initialise;
- UINT8 channel;
- UINT16 count_current[4];
- UINT16 count_base[4];
- UINT32 address_current[4];
- UINT32 address_base[4];
- UINT16 device_control;
- UINT8 mode_control[4];
- UINT8 status;
- UINT8 temp_l;
- UINT8 temp_h;
- UINT8 request;
- UINT8 mask;
-};
-
-class upd71071_device : public device_t
-{
-public:
- upd71071_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~upd71071_device() {}
-
- static void static_set_cpu_tag(device_t &device, const char *tag) { downcast<upd71071_device &>(device).m_cpu.set_tag(tag); }
- static void set_clock(device_t &device, int clock) { downcast<upd71071_device &>(device).m_upd_clock = clock; }
- template<class _Object> static devcb_base &set_out_hreq_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_out_hreq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_eop_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_out_eop_cb.set_callback(object); }
-
- template<class _Object> static devcb_base &set_dma_read_0_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_dma_read_0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_read_1_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_dma_read_1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_read_2_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_dma_read_2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_read_3_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_dma_read_3_cb.set_callback(object); }
-
- template<class _Object> static devcb_base &set_dma_write_0_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_dma_write_0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_write_1_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_dma_write_1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_write_2_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_dma_write_2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_dma_write_3_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_dma_write_3_cb.set_callback(object); }
-
- template<class _Object> static devcb_base &set_out_dack_0_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_out_dack_0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dack_1_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_out_dack_1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dack_2_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_out_dack_2_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dack_3_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_out_dack_3_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
- DECLARE_WRITE_LINE_MEMBER(set_hreq);
- DECLARE_WRITE_LINE_MEMBER(set_eop);
-
- int dmarq(int state, int channel);
-
-protected:
- // device-level overrides
- virtual void device_start();
-
-private:
- // internal state
- void soft_reset();
- TIMER_CALLBACK_MEMBER(dma_transfer_timer);
-
- struct upd71071_reg m_reg;
- int m_selected_channel;
- int m_buswidth;
- int m_dmarq[4];
- emu_timer* m_timer[4];
- //int m_in_progress[4];
- //int m_transfer_size[4];
- int m_base;
- int m_upd_clock;
- devcb_write_line m_out_hreq_cb;
- devcb_write_line m_out_eop_cb;
- devcb_read16 m_dma_read_0_cb;
- devcb_read16 m_dma_read_1_cb;
- devcb_read16 m_dma_read_2_cb;
- devcb_read16 m_dma_read_3_cb;
- devcb_write16 m_dma_write_0_cb;
- devcb_write16 m_dma_write_1_cb;
- devcb_write16 m_dma_write_2_cb;
- devcb_write16 m_dma_write_3_cb;
- devcb_write_line m_out_dack_0_cb;
- devcb_write_line m_out_dack_1_cb;
- devcb_write_line m_out_dack_2_cb;
- devcb_write_line m_out_dack_3_cb;
- int m_hreq;
- int m_eop;
- optional_device<cpu_device> m_cpu;
-};
-
-extern const device_type UPD71071;
-
-#define MCFG_UPD71071_CPU(_tag) \
- upd71071_device::static_set_cpu_tag(*device, "^" _tag);
-
-#define MCFG_UPD71071_CLOCK(_clk) \
- upd71071_device::set_clock(*device, _clk);
-
-#define MCFG_UPD71071_OUT_HREQ_CB(_devcb) \
- devcb = &upd71071_device::set_out_hreq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_OUT_EOP_CB(_devcb) \
- devcb = &upd71071_device::set_out_eop_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_DMA_READ_0_CB(_devcb) \
- devcb = &upd71071_device::set_dma_read_0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_DMA_READ_1_CB(_devcb) \
- devcb = &upd71071_device::set_dma_read_1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_DMA_READ_2_CB(_devcb) \
- devcb = &upd71071_device::set_dma_read_2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_DMA_READ_3_CB(_devcb) \
- devcb = &upd71071_device::set_dma_read_3_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_DMA_WRITE_0_CB(_devcb) \
- devcb = &upd71071_device::set_dma_write_0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_DMA_WRITE_1_CB(_devcb) \
- devcb = &upd71071_device::set_dma_write_1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_DMA_WRITE_2_CB(_devcb) \
- devcb = &upd71071_device::set_dma_write_2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_DMA_WRITE_3_CB(_devcb) \
- devcb = &upd71071_device::set_dma_write_3_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_OUT_DACK_0_CB(_devcb) \
- devcb = &upd71071_device::set_out_dack_0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_OUT_DACK_1_CB(_devcb) \
- devcb = &upd71071_device::set_out_dack_1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_OUT_DACK_2_CB(_devcb) \
- devcb = &upd71071_device::set_out_dack_2_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD71071_OUT_DACK_3_CB(_devcb) \
- devcb = &upd71071_device::set_out_dack_3_callback(*device, DEVCB_##_devcb);
-
-#endif /*UPD71071_H_*/
diff --git a/src/emu/machine/upd765.c b/src/emu/machine/upd765.c
deleted file mode 100644
index e1ce769880e..00000000000
--- a/src/emu/machine/upd765.c
+++ /dev/null
@@ -1,2534 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "debugger.h"
-
-#include "upd765.h"
-
-const device_type UPD765A = &device_creator<upd765a_device>;
-const device_type UPD765B = &device_creator<upd765b_device>;
-const device_type I8272A = &device_creator<i8272a_device>;
-const device_type UPD72065 = &device_creator<upd72065_device>;
-const device_type SMC37C78 = &device_creator<smc37c78_device>;
-const device_type N82077AA = &device_creator<n82077aa_device>;
-const device_type PC_FDC_SUPERIO = &device_creator<pc_fdc_superio_device>;
-const device_type DP8473 = &device_creator<dp8473_device>;
-const device_type PC8477A = &device_creator<pc8477a_device>;
-const device_type WD37C65C = &device_creator<wd37c65c_device>;
-const device_type MCS3201 = &device_creator<mcs3201_device>;
-const device_type TC8566AF = &device_creator<tc8566af_device>;
-
-DEVICE_ADDRESS_MAP_START(map, 8, upd765a_device)
- AM_RANGE(0x0, 0x0) AM_READ(msr_r)
- AM_RANGE(0x1, 0x1) AM_READWRITE(fifo_r, fifo_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(map, 8, upd765b_device)
- AM_RANGE(0x0, 0x0) AM_READ(msr_r)
- AM_RANGE(0x1, 0x1) AM_READWRITE(fifo_r, fifo_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(map, 8, i8272a_device)
- AM_RANGE(0x0, 0x0) AM_READ(msr_r)
- AM_RANGE(0x1, 0x1) AM_READWRITE(fifo_r, fifo_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(map, 8, upd72065_device)
- AM_RANGE(0x0, 0x0) AM_READ(msr_r)
- AM_RANGE(0x1, 0x1) AM_READWRITE(fifo_r, fifo_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(map, 8, smc37c78_device)
- AM_RANGE(0x2, 0x2) AM_READWRITE(dor_r, dor_w)
- AM_RANGE(0x3, 0x3) AM_READWRITE(tdr_r, tdr_w)
- AM_RANGE(0x4, 0x4) AM_READWRITE(msr_r, dsr_w)
- AM_RANGE(0x5, 0x5) AM_READWRITE(fifo_r, fifo_w)
- AM_RANGE(0x7, 0x7) AM_READWRITE(dir_r, ccr_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(map, 8, n82077aa_device)
- AM_RANGE(0x0, 0x0) AM_READ(sra_r)
- AM_RANGE(0x1, 0x1) AM_READ(srb_r)
- AM_RANGE(0x2, 0x2) AM_READWRITE(dor_r, dor_w)
- AM_RANGE(0x3, 0x3) AM_READWRITE(tdr_r, tdr_w)
- AM_RANGE(0x4, 0x4) AM_READWRITE(msr_r, dsr_w)
- AM_RANGE(0x5, 0x5) AM_READWRITE(fifo_r, fifo_w)
- AM_RANGE(0x7, 0x7) AM_READWRITE(dir_r, ccr_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(map, 8, pc_fdc_superio_device)
- AM_RANGE(0x0, 0x0) AM_READ(sra_r)
- AM_RANGE(0x1, 0x1) AM_READ(srb_r)
- AM_RANGE(0x2, 0x2) AM_READWRITE(dor_r, dor_w)
- AM_RANGE(0x3, 0x3) AM_READWRITE(tdr_r, tdr_w)
- AM_RANGE(0x4, 0x4) AM_READWRITE(msr_r, dsr_w)
- AM_RANGE(0x5, 0x5) AM_READWRITE(fifo_r, fifo_w)
- AM_RANGE(0x7, 0x7) AM_READWRITE(dir_r, ccr_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(map, 8, dp8473_device)
- AM_RANGE(0x0, 0x0) AM_READ(sra_r)
- AM_RANGE(0x1, 0x1) AM_READ(srb_r)
- AM_RANGE(0x2, 0x2) AM_READWRITE(dor_r, dor_w)
- AM_RANGE(0x3, 0x3) AM_READWRITE(tdr_r, tdr_w)
- AM_RANGE(0x4, 0x4) AM_READWRITE(msr_r, dsr_w)
- AM_RANGE(0x5, 0x5) AM_READWRITE(fifo_r, fifo_w)
- AM_RANGE(0x7, 0x7) AM_READWRITE(dir_r, ccr_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(map, 8, pc8477a_device)
- AM_RANGE(0x0, 0x0) AM_READ(sra_r)
- AM_RANGE(0x1, 0x1) AM_READ(srb_r)
- AM_RANGE(0x2, 0x2) AM_READWRITE(dor_r, dor_w)
- AM_RANGE(0x3, 0x3) AM_READWRITE(tdr_r, tdr_w)
- AM_RANGE(0x4, 0x4) AM_READWRITE(msr_r, dsr_w)
- AM_RANGE(0x5, 0x5) AM_READWRITE(fifo_r, fifo_w)
- AM_RANGE(0x7, 0x7) AM_READWRITE(dir_r, ccr_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START(map, 8, wd37c65c_device)
- AM_RANGE(0x0, 0x0) AM_READ(msr_r)
- AM_RANGE(0x1, 0x1) AM_READWRITE(fifo_r, fifo_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START( map, 8, mcs3201_device )
- AM_RANGE(0x0, 0x0) AM_READ(input_r)
- AM_RANGE(0x2, 0x2) AM_WRITE(dor_w)
- AM_RANGE(0x4, 0x4) AM_READ(msr_r)
- AM_RANGE(0x5, 0x5) AM_READWRITE(fifo_r, fifo_w)
- AM_RANGE(0x7, 0x7) AM_READWRITE(dir_r, ccr_w)
-ADDRESS_MAP_END
-
-DEVICE_ADDRESS_MAP_START( map, 8, tc8566af_device )
- AM_RANGE(0x2, 0x2) AM_WRITE(dor_w)
- AM_RANGE(0x3, 0x3) AM_WRITE(cr1_w)
- AM_RANGE(0x4, 0x4) AM_READ(msr_r)
- AM_RANGE(0x5, 0x5) AM_READWRITE(fifo_r, fifo_w)
-ADDRESS_MAP_END
-
-
-int upd765_family_device::rates[4] = { 500000, 300000, 250000, 1000000 };
-
-upd765_family_device::upd765_family_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- pc_fdc_interface(mconfig, type, name, tag, owner, clock, shortname, source),
- intrq_cb(*this),
- drq_cb(*this),
- hdl_cb(*this)
-{
- ready_polled = true;
- ready_connected = true;
- select_connected = true;
- external_ready = false;
- dor_reset = 0x00;
- mode = MODE_AT;
-}
-
-void upd765_family_device::set_ready_line_connected(bool _ready)
-{
- ready_connected = _ready;
-}
-
-void upd765_family_device::set_select_lines_connected(bool _select)
-{
- select_connected = _select;
-}
-
-void upd765_family_device::set_mode(int _mode)
-{
- mode = _mode;
-}
-
-void upd765_family_device::device_start()
-{
- intrq_cb.resolve_safe();
- drq_cb.resolve_safe();
- hdl_cb.resolve_safe();
-
- for(int i=0; i != 4; i++) {
- char name[2];
- flopi[i].tm = timer_alloc(i);
- flopi[i].id = i;
- if(select_connected) {
- name[0] = '0'+i;
- name[1] = 0;
- floppy_connector *con = subdevice<floppy_connector>(name);
- if(con) {
- flopi[i].dev = con->get_device();
- if (flopi[i].dev != NULL)
- flopi[i].dev->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(upd765_family_device::index_callback), this));
- } else
- flopi[i].dev = NULL;
- } else
- flopi[i].dev = NULL;
-
- flopi[i].main_state = IDLE;
- flopi[i].sub_state = IDLE;
- flopi[i].dir = 0;
- flopi[i].counter = 0;
- flopi[i].pcn = 0;
- flopi[i].st0 = 0;
- flopi[i].st0_filled = false;
- flopi[i].live = false;
- flopi[i].index = false;
- flopi[i].ready = false;
- }
- cur_rate = 250000;
- tc = false;
-
- // reset at upper levels may cause a write to tc ending up with
- // live_sync, which will crash if the live structure isn't
- // initialized enough
-
- cur_live.tm = attotime::never;
- cur_live.state = IDLE;
- cur_live.next_state = -1;
- cur_live.fi = NULL;
-
- if(ready_polled) {
- poll_timer = timer_alloc(TIMER_DRIVE_READY_POLLING);
- poll_timer->adjust(attotime::from_usec(100), 0, attotime::from_usec(1024));
- } else
- poll_timer = NULL;
-
- cur_irq = false;
- locked = false;
-}
-
-void upd765_family_device::device_reset()
-{
- dor = dor_reset;
- locked = false;
- soft_reset();
-}
-
-void upd765_family_device::soft_reset()
-{
- main_phase = PHASE_CMD;
- for(int i=0; i<4; i++) {
- flopi[i].main_state = IDLE;
- flopi[i].sub_state = IDLE;
- flopi[i].live = false;
- flopi[i].ready = !ready_polled;
- flopi[i].st0 = i;
- flopi[i].st0_filled = false;
- }
- data_irq = false;
- other_irq = false;
- internal_drq = false;
- fifo_pos = 0;
- command_pos = 0;
- result_pos = 0;
- if(!locked)
- fifocfg = FIF_DIS;
- cur_live.fi = 0;
- drq = false;
- cur_live.tm = attotime::never;
- cur_live.state = IDLE;
- cur_live.next_state = -1;
- cur_live.fi = NULL;
- tc_done = false;
- st1 = st2 = st3 = 0x00;
-
- check_irq();
- if(ready_polled)
- poll_timer->adjust(attotime::from_usec(100), 0, attotime::from_usec(1024));
-}
-
-void upd765_family_device::tc_w(bool _tc)
-{
- logerror("%s: tc=%d\n", tag(), _tc);
- if(tc != _tc && _tc) {
- live_sync();
- tc_done = true;
- tc = _tc;
- if(cur_live.fi)
- general_continue(*cur_live.fi);
- } else
- tc = _tc;
-}
-
-void upd765_family_device::ready_w(bool _ready)
-{
- external_ready = _ready;
-}
-
-bool upd765_family_device::get_ready(int fid)
-{
- if(ready_connected)
- return flopi[fid].dev ? !flopi[fid].dev->ready_r() : false;
- return !external_ready;
-}
-
-void upd765_family_device::set_floppy(floppy_image_device *flop)
-{
- for(int fid=0; fid<4; fid++) {
- if(flopi[fid].dev)
- flopi[fid].dev->setup_index_pulse_cb(floppy_image_device::index_pulse_cb());
- flopi[fid].dev = flop;
- }
- if(flop)
- flop->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(upd765_family_device::index_callback), this));
-}
-
-READ8_MEMBER(upd765_family_device::sra_r)
-{
- UINT8 sra = 0;
- int fid = dor & 3;
- floppy_info &fi = flopi[fid];
- if(fi.dir)
- sra |= 0x01;
- if(fi.index)
- sra |= 0x04;
- if(cur_rate >= 500000)
- sra |= 0x08;
- if(fi.dev && fi.dev->trk00_r())
- sra |= 0x10;
- if(fi.main_state == SEEK_WAIT_STEP_SIGNAL_TIME)
- sra |= 0x20;
- sra |= 0x40;
- if(cur_irq)
- sra |= 0x80;
- if(mode == MODE_M30)
- sra ^= 0x1f;
- return sra;
-}
-
-READ8_MEMBER(upd765_family_device::srb_r)
-{
- return 0;
-}
-
-READ8_MEMBER(upd765_family_device::dor_r)
-{
- return dor;
-}
-
-WRITE8_MEMBER(upd765_family_device::dor_w)
-{
- logerror("%s: dor = %02x\n", tag(), data);
- UINT8 diff = dor ^ data;
- dor = data;
- if(diff & 4)
- soft_reset();
-
- for(int i=0; i<4; i++) {
- floppy_info &fi = flopi[i];
- if(fi.dev)
- fi.dev->mon_w(!(dor & (0x10 << i)));
- }
- check_irq();
-}
-
-READ8_MEMBER(upd765_family_device::tdr_r)
-{
- return 0;
-}
-
-WRITE8_MEMBER(upd765_family_device::tdr_w)
-{
-}
-
-READ8_MEMBER(upd765_family_device::msr_r)
-{
- UINT32 msr = 0;
- switch(main_phase) {
- case PHASE_CMD:
- msr |= MSR_RQM;
- if(command_pos)
- msr |= MSR_CB;
- break;
- case PHASE_EXEC:
- msr |= MSR_CB;
- if(spec & SPEC_ND)
- msr |= MSR_EXM;
- if(internal_drq) {
- msr |= MSR_RQM;
- if(!fifo_write)
- msr |= MSR_DIO;
- }
- break;
-
- case PHASE_RESULT:
- msr |= MSR_RQM|MSR_DIO|MSR_CB;
- break;
- }
- for(int i=0; i<4; i++)
- if(flopi[i].main_state == RECALIBRATE || flopi[i].main_state == SEEK) {
- msr |= 1<<i;
- //msr |= MSR_CB;
- }
-
- if(data_irq) {
- data_irq = false;
- check_irq();
- }
-
- return msr;
-}
-
-WRITE8_MEMBER(upd765_family_device::dsr_w)
-{
- logerror("%s: dsr_w %02x\n", tag(), data);
- if(data & 0x80)
- soft_reset();
- dsr = data & 0x7f;
- cur_rate = rates[dsr & 3];
-}
-
-void upd765_family_device::set_rate(int rate)
-{
- cur_rate = rate;
-}
-
-READ8_MEMBER(upd765_family_device::fifo_r)
-{
- UINT8 r = 0xff;
- switch(main_phase) {
- case PHASE_EXEC:
- if(internal_drq)
- return fifo_pop(false);
- logerror("%s: fifo_r in phase %d\n", tag(), main_phase);
- break;
-
- case PHASE_RESULT:
- r = result[0];
- result_pos--;
- memmove(result, result+1, result_pos);
- if(!result_pos)
- main_phase = PHASE_CMD;
- break;
- default:
- logerror("%s: fifo_r in phase %d\n", tag(), main_phase);
- break;
- }
-
- return r;
-}
-
-WRITE8_MEMBER(upd765_family_device::fifo_w)
-{
- switch(main_phase) {
- case PHASE_CMD: {
- command[command_pos++] = data;
- other_irq = false;
- check_irq();
- int cmd = check_command();
- if(cmd == C_INCOMPLETE)
- break;
- if(cmd == C_INVALID) {
- logerror("%s: Invalid on %02x\n", tag(), command[0]);
- main_phase = PHASE_RESULT;
- result[0] = ST0_UNK;
- result_pos = 1;
- command_pos = 0;
- return;
- }
- start_command(cmd);
- break;
- }
- case PHASE_EXEC:
- if(internal_drq) {
- fifo_push(data, false);
- return;
- }
- logerror("%s: fifo_w in phase %d\n", tag(), main_phase);
- break;
-
- default:
- logerror("%s: fifo_w in phase %d\n", tag(), main_phase);
- break;
- }
-}
-
-UINT8 upd765_family_device::do_dir_r()
-{
- floppy_info &fi = flopi[dor & 3];
- if(fi.dev)
- return fi.dev->dskchg_r() ? 0x00 : 0x80;
- return 0x00;
-}
-
-READ8_MEMBER(upd765_family_device::dir_r)
-{
- return do_dir_r();
-}
-
-WRITE8_MEMBER(upd765_family_device::ccr_w)
-{
- dsr = (dsr & 0xfc) | (data & 3);
- cur_rate = rates[data & 3];
-}
-
-void upd765_family_device::set_drq(bool state)
-{
- if(state != drq) {
- drq = state;
- drq_cb(drq);
- }
-}
-
-bool upd765_family_device::get_drq() const
-{
- return drq;
-}
-
-void upd765_family_device::enable_transfer()
-{
- if(spec & SPEC_ND) {
- // PIO
- if(!internal_drq) {
- internal_drq = true;
- check_irq();
- }
-
- } else {
- // DMA
- if(!drq)
- set_drq(true);
- }
-}
-
-void upd765_family_device::disable_transfer()
-{
- if(spec & SPEC_ND) {
- internal_drq = false;
- check_irq();
- } else
- set_drq(false);
-}
-
-void upd765_family_device::fifo_push(UINT8 data, bool internal)
-{
- if(fifo_pos == 16) {
- if(internal) {
- if(!(st1 & ST1_OR))
- logerror("%s: Fifo overrun\n", tag());
- st1 |= ST1_OR;
- }
- return;
- }
- fifo[fifo_pos++] = data;
- fifo_expected--;
-
- int thr = (fifocfg & FIF_THR)+1;
- if(!fifo_write && (!fifo_expected || fifo_pos >= thr || (fifocfg & FIF_DIS)))
- enable_transfer();
- if(fifo_write && (fifo_pos == 16 || !fifo_expected))
- disable_transfer();
-}
-
-
-UINT8 upd765_family_device::fifo_pop(bool internal)
-{
- if(!fifo_pos) {
- if(internal) {
- if(!(st1 & ST1_OR))
- logerror("%s: Fifo underrun\n", tag());
- st1 |= ST1_OR;
- }
- return 0;
- }
- UINT8 r = fifo[0];
- fifo_pos--;
- memmove(fifo, fifo+1, fifo_pos);
- if(!fifo_write && !fifo_pos)
- disable_transfer();
- int thr = fifocfg & 15;
- if(fifo_write && fifo_expected && (fifo_pos <= thr || (fifocfg & 0x20)))
- enable_transfer();
- return r;
-}
-
-void upd765_family_device::fifo_expect(int size, bool write)
-{
- fifo_expected = size;
- fifo_write = write;
- if(fifo_write)
- enable_transfer();
-}
-
-READ8_MEMBER(upd765_family_device::mdma_r)
-{
- return dma_r();
-}
-
-WRITE8_MEMBER(upd765_family_device::mdma_w)
-{
- dma_w(data);
-}
-
-UINT8 upd765_family_device::dma_r()
-{
- return fifo_pop(false);
-}
-
-void upd765_family_device::dma_w(UINT8 data)
-{
- fifo_push(data, false);
-}
-
-void upd765_family_device::live_start(floppy_info &fi, int state)
-{
- cur_live.tm = machine().time();
- cur_live.state = state;
- cur_live.next_state = -1;
- cur_live.fi = &fi;
- cur_live.shift_reg = 0;
- cur_live.crc = 0xffff;
- cur_live.bit_counter = 0;
- cur_live.data_separator_phase = false;
- cur_live.data_reg = 0;
- cur_live.previous_type = live_info::PT_NONE;
- cur_live.data_bit_context = false;
- cur_live.byte_counter = 0;
- cur_live.pll.reset(cur_live.tm);
- cur_live.pll.set_clock(attotime::from_hz(mfm ? 2*cur_rate : cur_rate));
- checkpoint_live = cur_live;
- fi.live = true;
-
- live_run();
-}
-
-void upd765_family_device::checkpoint()
-{
- if(cur_live.fi)
- cur_live.pll.commit(cur_live.fi->dev, cur_live.tm);
- checkpoint_live = cur_live;
-}
-
-void upd765_family_device::rollback()
-{
- cur_live = checkpoint_live;
-}
-
-void upd765_family_device::live_delay(int state)
-{
- cur_live.next_state = state;
- if(cur_live.tm != machine().time())
- cur_live.fi->tm->adjust(cur_live.tm - machine().time());
- else
- live_sync();
-}
-
-void upd765_family_device::live_sync()
-{
- if(!cur_live.tm.is_never()) {
- if(cur_live.tm > machine().time()) {
- rollback();
- live_run(machine().time());
- cur_live.pll.commit(cur_live.fi->dev, cur_live.tm);
- } else {
- cur_live.pll.commit(cur_live.fi->dev, cur_live.tm);
- if(cur_live.next_state != -1) {
- cur_live.state = cur_live.next_state;
- cur_live.next_state = -1;
- }
- if(cur_live.state == IDLE) {
- cur_live.pll.stop_writing(cur_live.fi->dev, cur_live.tm);
- cur_live.tm = attotime::never;
- cur_live.fi->live = false;
- cur_live.fi = 0;
- }
- }
- cur_live.next_state = -1;
- checkpoint();
- }
-}
-
-void upd765_family_device::live_abort()
-{
- if(!cur_live.tm.is_never() && cur_live.tm > machine().time()) {
- rollback();
- live_run(machine().time());
- }
-
- if(cur_live.fi) {
- cur_live.pll.stop_writing(cur_live.fi->dev, cur_live.tm);
- cur_live.fi->live = false;
- cur_live.fi = 0;
- }
-
- cur_live.tm = attotime::never;
- cur_live.state = IDLE;
- cur_live.next_state = -1;
-}
-
-void upd765_family_device::live_run(attotime limit)
-{
- if(cur_live.state == IDLE || cur_live.next_state != -1)
- return;
-
- if(limit == attotime::never) {
- if(cur_live.fi->dev)
- limit = cur_live.fi->dev->time_next_index();
- if(limit == attotime::never) {
- // Happens when there's no disk or if the fdc is not
- // connected to a drive, hence no index pulse. Force a
- // sync from time to time in that case, so that the main
- // cpu timeout isn't too painful. Avoids looping into
- // infinity looking for data too.
-
- limit = machine().time() + attotime::from_msec(1);
- cur_live.fi->tm->adjust(attotime::from_msec(1));
- }
- }
-
- for(;;) {
- switch(cur_live.state) {
- case SEARCH_ADDRESS_MARK_HEADER:
- if(read_one_bit(limit))
- return;
-#if 0
- fprintf(stderr, "%s: shift = %04x data=%02x c=%d\n", tts(cur_live.tm).c_str(), cur_live.shift_reg,
- (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) |
- (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) |
- (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) |
- (cur_live.shift_reg & 0x0100 ? 0x10 : 0x00) |
- (cur_live.shift_reg & 0x0040 ? 0x08 : 0x00) |
- (cur_live.shift_reg & 0x0010 ? 0x04 : 0x00) |
- (cur_live.shift_reg & 0x0004 ? 0x02 : 0x00) |
- (cur_live.shift_reg & 0x0001 ? 0x01 : 0x00),
- cur_live.bit_counter);
-#endif
-
- if(mfm && cur_live.shift_reg == 0x4489) {
- cur_live.crc = 0x443b;
- cur_live.data_separator_phase = false;
- cur_live.bit_counter = 0;
- cur_live.state = READ_HEADER_BLOCK_HEADER;
- }
-
- if(!mfm && cur_live.shift_reg == 0xf57e) {
- cur_live.crc = 0xef21;
- cur_live.data_separator_phase = false;
- cur_live.bit_counter = 0;
- cur_live.state = READ_ID_BLOCK;
- }
- break;
-
- case READ_HEADER_BLOCK_HEADER: {
- if(read_one_bit(limit))
- return;
-#if 0
- fprintf(stderr, "%s: shift = %04x data=%02x counter=%d\n", tts(cur_live.tm).c_str(), cur_live.shift_reg,
- (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) |
- (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) |
- (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) |
- (cur_live.shift_reg & 0x0100 ? 0x10 : 0x00) |
- (cur_live.shift_reg & 0x0040 ? 0x08 : 0x00) |
- (cur_live.shift_reg & 0x0010 ? 0x04 : 0x00) |
- (cur_live.shift_reg & 0x0004 ? 0x02 : 0x00) |
- (cur_live.shift_reg & 0x0001 ? 0x01 : 0x00),
- cur_live.bit_counter);
-#endif
- if(cur_live.bit_counter & 15)
- break;
-
- int slot = cur_live.bit_counter >> 4;
-
- if(slot < 3) {
- if(cur_live.shift_reg != 0x4489)
- cur_live.state = SEARCH_ADDRESS_MARK_HEADER;
- break;
- }
- if(cur_live.data_reg != 0xfe) {
- cur_live.state = SEARCH_ADDRESS_MARK_HEADER;
- break;
- }
-
- cur_live.bit_counter = 0;
- cur_live.state = READ_ID_BLOCK;
-
- break;
- }
-
- case READ_ID_BLOCK: {
- if(read_one_bit(limit))
- return;
- if(cur_live.bit_counter & 15)
- break;
- int slot = (cur_live.bit_counter >> 4)-1;
-
- if(0)
- fprintf(stderr, "%s: slot=%d data=%02x crc=%04x\n", tts(cur_live.tm).c_str(), slot, cur_live.data_reg, cur_live.crc);
- cur_live.idbuf[slot] = cur_live.data_reg;
- if(slot == 5) {
- live_delay(IDLE);
- return;
- }
- break;
- }
-
- case SEARCH_ADDRESS_MARK_DATA:
- if(read_one_bit(limit))
- return;
-#if 0
- fprintf(stderr, "%s: shift = %04x data=%02x c=%d.%x\n", tts(cur_live.tm).c_str(), cur_live.shift_reg,
- (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) |
- (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) |
- (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) |
- (cur_live.shift_reg & 0x0100 ? 0x10 : 0x00) |
- (cur_live.shift_reg & 0x0040 ? 0x08 : 0x00) |
- (cur_live.shift_reg & 0x0010 ? 0x04 : 0x00) |
- (cur_live.shift_reg & 0x0004 ? 0x02 : 0x00) |
- (cur_live.shift_reg & 0x0001 ? 0x01 : 0x00),
- cur_live.bit_counter >> 4, cur_live.bit_counter & 15);
-#endif
-
- if(mfm) {
- // Large tolerance due to perpendicular recording at extended density
- if(cur_live.bit_counter > 62*16) {
- live_delay(SEARCH_ADDRESS_MARK_DATA_FAILED);
- return;
- }
-
- if(cur_live.bit_counter >= 28*16 && cur_live.shift_reg == 0x4489) {
- cur_live.crc = 0x443b;
- cur_live.data_separator_phase = false;
- cur_live.bit_counter = 0;
- cur_live.state = READ_DATA_BLOCK_HEADER;
- }
-
- } else {
- if(cur_live.bit_counter > 23*16) {
- live_delay(SEARCH_ADDRESS_MARK_DATA_FAILED);
- return;
- }
-
- if(cur_live.bit_counter >= 11*16 && (cur_live.shift_reg == 0xf56a || cur_live.shift_reg == 0xf56f)) {
- cur_live.crc = cur_live.shift_reg == 0xf56a ? 0x8fe7 : 0xbf84;
- cur_live.data_separator_phase = false;
- cur_live.bit_counter = 0;
- cur_live.state = READ_SECTOR_DATA;
- }
- }
-
- break;
-
- case READ_DATA_BLOCK_HEADER: {
- if(read_one_bit(limit))
- return;
-#if 0
- fprintf(stderr, "%s: shift = %04x data=%02x counter=%d\n", tts(cur_live.tm).c_str(), cur_live.shift_reg,
- (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) |
- (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) |
- (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) |
- (cur_live.shift_reg & 0x0100 ? 0x10 : 0x00) |
- (cur_live.shift_reg & 0x0040 ? 0x08 : 0x00) |
- (cur_live.shift_reg & 0x0010 ? 0x04 : 0x00) |
- (cur_live.shift_reg & 0x0004 ? 0x02 : 0x00) |
- (cur_live.shift_reg & 0x0001 ? 0x01 : 0x00),
- cur_live.bit_counter);
-#endif
- if(cur_live.bit_counter & 15)
- break;
-
- int slot = cur_live.bit_counter >> 4;
-
- if(slot < 3) {
- if(cur_live.shift_reg != 0x4489) {
- live_delay(SEARCH_ADDRESS_MARK_DATA_FAILED);
- return;
- }
- break;
- }
- if(cur_live.data_reg != 0xfb && cur_live.data_reg != 0xf8) {
- live_delay(SEARCH_ADDRESS_MARK_DATA_FAILED);
- return;
- }
-
- cur_live.bit_counter = 0;
- cur_live.state = READ_SECTOR_DATA;
- break;
- }
-
- case SEARCH_ADDRESS_MARK_DATA_FAILED:
- st1 |= ST1_MA;
- st2 |= ST2_MD;
- cur_live.state = IDLE;
- return;
-
- case READ_SECTOR_DATA: {
- if(read_one_bit(limit))
- return;
- if(cur_live.bit_counter & 15)
- break;
- int slot = (cur_live.bit_counter >> 4)-1;
- if(slot < sector_size) {
- // Sector data
- if(cur_live.fi->main_state == SCAN_DATA)
- live_delay(SCAN_SECTOR_DATA_BYTE);
- else
- live_delay(READ_SECTOR_DATA_BYTE);
- return;
-
- } else if(slot < sector_size+2) {
- // CRC
- if(slot == sector_size+1) {
- live_delay(IDLE);
- return;
- }
- }
- break;
- }
-
- case READ_SECTOR_DATA_BYTE:
- if(!tc_done)
- fifo_push(cur_live.data_reg, true);
- cur_live.state = READ_SECTOR_DATA;
- checkpoint();
- break;
-
- case SCAN_SECTOR_DATA_BYTE:
- if(!scan_done) // TODO: handle stp, x68000 sets it to 0xff (as it would dtl)?
- {
- int slot = (cur_live.bit_counter >> 4)-1;
- UINT8 data = fifo_pop(true);
- if(!slot)
- st2 = (st2 & ~(ST2_SN)) | ST2_SH;
-
- if(data != cur_live.data_reg)
- {
- st2 = (st2 & ~(ST2_SH)) | ST2_SN;
- if((data < cur_live.data_reg) && ((command[0] & 0x1f) == 0x19)) // low
- st2 &= ~ST2_SN;
-
- if((data > cur_live.data_reg) && ((command[0] & 0x1f) == 0x1d)) // high
- st2 &= ~ST2_SN;
- }
- if((slot == sector_size) && !(st2 & ST2_SN))
- {
- scan_done = true;
- tc_done = true;
- }
- }
- else
- {
- if(fifo_pos)
- fifo_pop(true);
- }
- cur_live.state = READ_SECTOR_DATA;
- checkpoint();
- break;
-
- case WRITE_SECTOR_SKIP_GAP2:
- cur_live.bit_counter = 0;
- cur_live.byte_counter = 0;
- cur_live.state = WRITE_SECTOR_SKIP_GAP2_BYTE;
- checkpoint();
- break;
-
- case WRITE_SECTOR_SKIP_GAP2_BYTE:
- if(read_one_bit(limit))
- return;
- if(mfm && cur_live.bit_counter != 22*16)
- break;
- if(!mfm && cur_live.bit_counter != 11*16)
- break;
- cur_live.bit_counter = 0;
- cur_live.byte_counter = 0;
- live_delay(WRITE_SECTOR_DATA);
- return;
-
- case WRITE_SECTOR_DATA:
- if(mfm) {
- if(cur_live.byte_counter < 12)
- live_write_mfm(0x00);
- else if(cur_live.byte_counter < 15)
- live_write_raw(0x4489);
- else if(cur_live.byte_counter < 16) {
- cur_live.crc = 0xcdb4;
- live_write_mfm(command[0] & 0x08 ? 0xf8 : 0xfb);
- } else if(cur_live.byte_counter < 16+sector_size)
- live_write_mfm(tc_done && !fifo_pos? 0x00 : fifo_pop(true));
- else if(cur_live.byte_counter < 16+sector_size+2)
- live_write_mfm(cur_live.crc >> 8);
- else if(cur_live.byte_counter < 16+sector_size+2+command[7])
- live_write_mfm(0x4e);
- else {
- cur_live.pll.stop_writing(cur_live.fi->dev, cur_live.tm);
- cur_live.state = IDLE;
- return;
- }
-
- } else {
- if(cur_live.byte_counter < 6)
- live_write_fm(0x00);
- else if(cur_live.byte_counter < 7) {
- cur_live.crc = 0xffff;
- live_write_raw(command[0] & 0x08 ? 0xf56a : 0xf56f);
- } else if(cur_live.byte_counter < 7+sector_size)
- live_write_fm(tc_done && !fifo_pos? 0x00 : fifo_pop(true));
- else if(cur_live.byte_counter < 7+sector_size+2)
- live_write_fm(cur_live.crc >> 8);
- else if(cur_live.byte_counter < 7+sector_size+2+command[7])
- live_write_fm(0xff);
- else {
- cur_live.pll.stop_writing(cur_live.fi->dev, cur_live.tm);
- cur_live.state = IDLE;
- return;
- }
- }
- cur_live.state = WRITE_SECTOR_DATA_BYTE;
- cur_live.bit_counter = 16;
- checkpoint();
- break;
-
- case WRITE_TRACK_PRE_SECTORS:
- if(!cur_live.byte_counter && command[3])
- fifo_expect(4, true);
- if(mfm) {
- if(cur_live.byte_counter < 80)
- live_write_mfm(0x4e);
- else if(cur_live.byte_counter < 92)
- live_write_mfm(0x00);
- else if(cur_live.byte_counter < 95)
- live_write_raw(0x5224);
- else if(cur_live.byte_counter < 96)
- live_write_mfm(0xfc);
- else if(cur_live.byte_counter < 146)
- live_write_mfm(0x4e);
- else {
- cur_live.state = WRITE_TRACK_SECTOR;
- cur_live.byte_counter = 0;
- break;
- }
- } else {
- if(cur_live.byte_counter < 40)
- live_write_fm(0xff);
- else if(cur_live.byte_counter < 46)
- live_write_fm(0x00);
- else if(cur_live.byte_counter < 47)
- live_write_raw(0xf77a);
- else if(cur_live.byte_counter < 73)
- live_write_fm(0xff);
- else {
- cur_live.state = WRITE_TRACK_SECTOR;
- cur_live.byte_counter = 0;
- break;
- }
- }
- cur_live.state = WRITE_TRACK_PRE_SECTORS_BYTE;
- cur_live.bit_counter = 16;
- checkpoint();
- break;
-
- case WRITE_TRACK_SECTOR:
- if(!cur_live.byte_counter) {
- command[3]--;
- if(command[3])
- fifo_expect(4, true);
- }
- if(mfm) {
- if(cur_live.byte_counter < 12)
- live_write_mfm(0x00);
- else if(cur_live.byte_counter < 15)
- live_write_raw(0x4489);
- else if(cur_live.byte_counter < 16) {
- cur_live.crc = 0xcdb4;
- live_write_mfm(0xfe);
- } else if(cur_live.byte_counter < 20) {
- UINT8 byte = fifo_pop(true);
- command[12+cur_live.byte_counter-16] = byte;
- live_write_mfm(byte);
- if(cur_live.byte_counter == 19)
- logerror("%s: formatting sector %02x %02x %02x %02x\n",
- tag(), command[12], command[13], command[14], command[15]);
- } else if(cur_live.byte_counter < 22)
- live_write_mfm(cur_live.crc >> 8);
- else if(cur_live.byte_counter < 44)
- live_write_mfm(0x4e);
- else if(cur_live.byte_counter < 56)
- live_write_mfm(0x00);
- else if(cur_live.byte_counter < 59)
- live_write_raw(0x4489);
- else if(cur_live.byte_counter < 60) {
- cur_live.crc = 0xcdb4;
- live_write_mfm(0xfb);
- } else if(cur_live.byte_counter < 60+sector_size)
- live_write_mfm(command[5]);
- else if(cur_live.byte_counter < 62+sector_size)
- live_write_mfm(cur_live.crc >> 8);
- else if(cur_live.byte_counter < 62+sector_size+command[4])
- live_write_mfm(0x4e);
- else {
- cur_live.byte_counter = 0;
- cur_live.state = command[3] ? WRITE_TRACK_SECTOR : WRITE_TRACK_POST_SECTORS;
- break;
- }
-
- } else {
- if(cur_live.byte_counter < 6)
- live_write_fm(0x00);
- else if(cur_live.byte_counter < 7) {
- cur_live.crc = 0xffff;
- live_write_raw(0xf57e);
- } else if(cur_live.byte_counter < 11) {
- UINT8 byte = fifo_pop(true);
- command[12+cur_live.byte_counter-7] = byte;
- live_write_fm(byte);
- if(cur_live.byte_counter == 10)
- logerror("%s: formatting sector %02x %02x %02x %02x\n",
- tag(), command[12], command[13], command[14], command[15]);
- } else if(cur_live.byte_counter < 13)
- live_write_fm(cur_live.crc >> 8);
- else if(cur_live.byte_counter < 24)
- live_write_fm(0xff);
- else if(cur_live.byte_counter < 30)
- live_write_fm(0x00);
- else if(cur_live.byte_counter < 31) {
- cur_live.crc = 0xffff;
- live_write_raw(0xf56f);
- } else if(cur_live.byte_counter < 31+sector_size)
- live_write_fm(command[5]);
- else if(cur_live.byte_counter < 33+sector_size)
- live_write_fm(cur_live.crc >> 8);
- else if(cur_live.byte_counter < 33+sector_size+command[4])
- live_write_fm(0xff);
- else {
- cur_live.byte_counter = 0;
- cur_live.state = command[3] ? WRITE_TRACK_SECTOR : WRITE_TRACK_POST_SECTORS;
- break;
- }
- }
- cur_live.state = WRITE_TRACK_SECTOR_BYTE;
- cur_live.bit_counter = 16;
- checkpoint();
- break;
-
- case WRITE_TRACK_POST_SECTORS:
- if(mfm)
- live_write_mfm(0x4e);
- else
- live_write_fm(0xff);
- cur_live.state = WRITE_TRACK_POST_SECTORS_BYTE;
- cur_live.bit_counter = 16;
- checkpoint();
- break;
-
- case WRITE_TRACK_PRE_SECTORS_BYTE:
- case WRITE_TRACK_SECTOR_BYTE:
- case WRITE_TRACK_POST_SECTORS_BYTE:
- case WRITE_SECTOR_DATA_BYTE:
- if(write_one_bit(limit))
- return;
- if(cur_live.bit_counter == 0) {
- cur_live.byte_counter++;
- live_delay(cur_live.state-1);
- return;
- }
- break;
-
- default:
- logerror("%s: Unknown live state %d\n", tts(cur_live.tm).c_str(), cur_live.state);
- return;
- }
- }
-}
-
-int upd765_family_device::check_command()
-{
- // 0.000010 read track
- // 00000011 specify
- // 00000100 sense drive status
- // ..000101 write data
- // ...00110 read data
- // 00000111 recalibrate
- // 00001000 sense interrupt status
- // ..001001 write deleted data
- // 0.001010 read id
- // ...01100 read deleted data
- // 0.001101 format track
- // 00001110 dumpreg
- // 00101110 save
- // 01001110 restore
- // 10001110 drive specification command
- // 00001111 seek
- // 1.001111 relative seek
- // 00010000 version
- // ...10001 scan equal
- // 00010010 perpendicular mode
- // 00010011 configure
- // 00110011 option
- // .0010100 lock
- // ...10110 verify
- // 00010111 powerdown mode
- // 00011000 part id
- // ...11001 scan low or equal
- // ...11101 scan high or equal
-
- // MSDOS 6.22 format uses 0xcd to format a track, which makes one
- // think only the bottom 5 bits are decoded.
-
- switch(command[0] & 0x1f) {
- case 0x02:
- return command_pos == 9 ? C_READ_TRACK : C_INCOMPLETE;
-
- case 0x03:
- return command_pos == 3 ? C_SPECIFY : C_INCOMPLETE;
-
- case 0x04:
- return command_pos == 2 ? C_SENSE_DRIVE_STATUS : C_INCOMPLETE;
-
- case 0x05:
- case 0x09:
- return command_pos == 9 ? C_WRITE_DATA : C_INCOMPLETE;
-
- case 0x06:
- case 0x0c:
- return command_pos == 9 ? C_READ_DATA : C_INCOMPLETE;
-
- case 0x07:
- return command_pos == 2 ? C_RECALIBRATE : C_INCOMPLETE;
-
- case 0x08:
- return C_SENSE_INTERRUPT_STATUS;
-
- case 0x0a:
- return command_pos == 2 ? C_READ_ID : C_INCOMPLETE;
-
- case 0x0d:
- return command_pos == 6 ? C_FORMAT_TRACK : C_INCOMPLETE;
-
- case 0x0e:
- return C_DUMP_REG;
-
- case 0x0f:
- return command_pos == 3 ? C_SEEK : C_INCOMPLETE;
-
- case 0x11:
- return command_pos == 9 ? C_SCAN_EQUAL : C_INCOMPLETE;
-
- case 0x12:
- return command_pos == 2 ? C_PERPENDICULAR : C_INCOMPLETE;
-
- case 0x13:
- return command_pos == 4 ? C_CONFIGURE : C_INCOMPLETE;
-
- case 0x14:
- return C_LOCK;
-
- case 0x19:
- return command_pos == 9 ? C_SCAN_LOW : C_INCOMPLETE;
-
- case 0x1d:
- return command_pos == 9 ? C_SCAN_HIGH : C_INCOMPLETE;
-
- default:
- return C_INVALID;
- }
-}
-
-void upd765_family_device::start_command(int cmd)
-{
- command_pos = 0;
- result_pos = 0;
- main_phase = PHASE_EXEC;
- tc_done = false;
- switch(cmd) {
- case C_CONFIGURE:
- logerror("%s: command configure %02x %02x %02x\n",
- tag(),
- command[1], command[2], command[3]);
- // byte 1 is ignored, byte 3 is precompensation-related
- fifocfg = command[2];
- precomp = command[3];
- main_phase = PHASE_CMD;
- break;
-
- case C_DUMP_REG:
- logerror("%s: command dump regs\n", tag());
- main_phase = PHASE_RESULT;
- result[0] = flopi[0].pcn;
- result[1] = flopi[1].pcn;
- result[2] = flopi[2].pcn;
- result[3] = flopi[3].pcn;
- result[4] = (spec & 0xff00) >> 8;
- result[5] = (spec & 0x00ff);
- result[6] = sector_size;
- result[7] = locked ? 0x80 : 0x00;
- result[7] |= (perpmode & 0x30);
- result[8] = fifocfg;
- result[9] = precomp;
- result_pos = 10;
- break;
-
- case C_FORMAT_TRACK:
- format_track_start(flopi[command[1] & 3]);
- break;
-
- case C_LOCK:
- locked = command[0] & 0x80;
- main_phase = PHASE_RESULT;
- result[0] = locked ? 0x10 : 0x00;
- result_pos = 1;
- logerror("%s: command lock (%s)\n", tag(), locked ? "on" : "off");
- break;
-
- case C_PERPENDICULAR:
- logerror("%s: command perpendicular\n", tag());
- perpmode = command[1];
- main_phase = PHASE_CMD;
- break;
-
- case C_READ_DATA:
- read_data_start(flopi[command[1] & 3]);
- break;
-
- case C_READ_ID:
- read_id_start(flopi[command[1] & 3]);
- break;
-
- case C_READ_TRACK:
- read_track_start(flopi[command[1] & 3]);
- break;
-
- case C_SCAN_EQUAL:
- case C_SCAN_LOW:
- case C_SCAN_HIGH:
- scan_start(flopi[command[1] & 3]);
- break;
-
- case C_RECALIBRATE:
- recalibrate_start(flopi[command[1] & 3]);
- main_phase = PHASE_CMD;
- break;
-
- case C_SEEK:
- seek_start(flopi[command[1] & 3]);
- main_phase = PHASE_CMD;
- break;
-
- case C_SENSE_DRIVE_STATUS: {
- floppy_info &fi = flopi[command[1] & 3];
- main_phase = PHASE_RESULT;
- result[0] = command[1] & 7;
- if(fi.ready)
- result[0] |= ST3_RY;
- if(fi.dev)
- result[0] |=
- (fi.dev->wpt_r() ? ST3_WP : 0x00) |
- (fi.dev->trk00_r() ? 0x00 : ST3_T0) |
- (fi.dev->twosid_r() ? 0x00 : ST3_TS);
- logerror("%s: command sense drive status %d (%02x)\n", tag(), fi.id, result[0]);
- result_pos = 1;
- break;
- }
-
- case C_SENSE_INTERRUPT_STATUS: {
- // Documentation is somewhat contradictory w.r.t polling
- // and irq. PC bios, especially 5150, requires that only
- // one irq happens. That's also wait the ns82077a doc
- // says it does. OTOH, a number of docs says you need to
- // call SIS 4 times, once per drive...
- //
- // There's also the interaction with the seek irq. The
- // somewhat borderline tf20 code seems to think that
- // essentially ignoring the polling irq should work.
- //
- // And the pc98 expects to be able to accumulate irq reasons
- // for different drives and things to work.
- //
- // Current hypothesis:
- // - each drive has its own st0 and irq trigger
- // - SIS drops the irq always, but also returns the first full st0 it finds
-
- main_phase = PHASE_RESULT;
-
- int fid;
- for(fid=0; fid<4 && !flopi[fid].st0_filled; fid++);
- if(fid == 4) {
- result[0] = ST0_UNK;
- result_pos = 1;
- logerror("%s: command sense interrupt status (%02x)\n", tag(), result[0]);
- break;
- }
-
- floppy_info &fi = flopi[fid];
- fi.st0_filled = false;
-
- result[0] = fi.st0;
- result[1] = fi.pcn;
-
- logerror("%s: command sense interrupt status (fid=%d %02x %02x)\n", tag(), fid, result[0], result[1]);
- result_pos = 2;
-
- other_irq = false;
- check_irq();
- break;
- }
-
- case C_SPECIFY:
- logerror("%s: command specify %02x %02x\n",
- tag(),
- command[1], command[2]);
- spec = (command[1] << 8) | command[2];
- main_phase = PHASE_CMD;
- break;
-
- case C_WRITE_DATA:
- write_data_start(flopi[command[1] & 3]);
- break;
-
- default:
- fprintf(stderr, "start command %d\n", cmd);
- exit(1);
- }
-}
-
-void upd765_family_device::command_end(floppy_info &fi, bool data_completion)
-{
- logerror("%s: command done (%s) -", tag(), data_completion ? "data" : "seek");
- for(int i=0; i != result_pos; i++)
- logerror(" %02x", result[i]);
- logerror("\n");
- fi.main_state = fi.sub_state = IDLE;
- if(data_completion)
- data_irq = true;
- else
- {
- other_irq = true;
- fi.st0_filled = true;
- }
- check_irq();
-}
-
-void upd765_family_device::recalibrate_start(floppy_info &fi)
-{
- logerror("%s: command recalibrate\n", tag());
- fi.main_state = RECALIBRATE;
- fi.sub_state = SEEK_WAIT_STEP_TIME_DONE;
- fi.dir = 1;
- fi.counter = 77;
- seek_continue(fi);
-}
-
-void upd765_family_device::seek_start(floppy_info &fi)
-{
- logerror("%s: command %sseek %d\n", tag(), command[0] & 0x80 ? "relative " : "", command[2]);
- fi.main_state = SEEK;
- fi.sub_state = SEEK_WAIT_STEP_TIME_DONE;
- fi.dir = fi.pcn > command[2] ? 1 : 0;
- seek_continue(fi);
-}
-
-void upd765_family_device::delay_cycles(emu_timer *tm, int cycles)
-{
- tm->adjust(attotime::from_double(double(cycles)/cur_rate));
-}
-
-void upd765_family_device::seek_continue(floppy_info &fi)
-{
- for(;;) {
- switch(fi.sub_state) {
- case SEEK_MOVE:
- if(fi.dev) {
- fi.dev->dir_w(fi.dir);
- fi.dev->stp_w(0);
- }
- fi.sub_state = SEEK_WAIT_STEP_SIGNAL_TIME;
- fi.tm->adjust(attotime::from_nsec(2500));
- return;
-
- case SEEK_WAIT_STEP_SIGNAL_TIME:
- return;
-
- case SEEK_WAIT_STEP_SIGNAL_TIME_DONE:
- if(fi.dev)
- fi.dev->stp_w(1);
-
- if(fi.main_state == SEEK) {
- if(fi.pcn > command[2])
- fi.pcn--;
- else
- fi.pcn++;
- }
- fi.sub_state = SEEK_WAIT_STEP_TIME;
- delay_cycles(fi.tm, 500*(16-(spec >> 12)));
- return;
-
- case SEEK_WAIT_STEP_TIME:
- return;
-
- case SEEK_WAIT_STEP_TIME_DONE: {
- bool done = false;
- switch(fi.main_state) {
- case RECALIBRATE:
- fi.counter--;
- done = fi.dev && !fi.dev->trk00_r();
- if(done)
- fi.pcn = 0;
- else if(!fi.counter) {
- fi.st0 = ST0_FAIL|ST0_SE|ST0_EC | fi.id;
- command_end(fi, false);
- return;
- }
- break;
- case SEEK:
- done = fi.pcn == command[2];
- break;
- }
- if(done) {
- fi.st0 = ST0_SE | fi.id;
- command_end(fi, false);
- return;
- }
- fi.sub_state = SEEK_MOVE;
- break;
- }
- }
- }
-}
-
-void upd765_family_device::read_data_start(floppy_info &fi)
-{
- fi.main_state = READ_DATA;
- fi.sub_state = HEAD_LOAD_DONE;
- mfm = command[0] & 0x40;
-
- logerror("%s: command read%s data%s%s%s%s cmd=%02x sel=%x chrn=(%d, %d, %d, %d) eot=%02x gpl=%02x dtl=%02x rate=%d\n",
- tag(),
- command[0] & 0x08 ? " deleted" : "",
- command[0] & 0x80 ? " mt" : "",
- command[0] & 0x40 ? " mfm" : "",
- command[0] & 0x20 ? " sk" : "",
- fifocfg & 0x40 ? " seek" : "",
- command[0],
- command[1],
- command[2],
- command[3],
- command[4],
- 128 << (command[5] & 7),
- command[6],
- command[7],
- command[8],
- cur_rate);
-
- fi.st0 = command[1] & 7;
- st1 = ST1_MA;
- st2 = 0x00;
- hdl_cb(1);
- fi.ready = get_ready(command[1] & 3);
-
- if(!fi.ready)
- {
- fi.st0 |= ST0_NR | ST0_FAIL;
- fi.sub_state = COMMAND_DONE;
- st1 = 0;
- st2 = 0;
- read_data_continue(fi);
- return;
- }
-
- if(fi.dev)
- fi.dev->ss_w(command[1] & 4 ? 1 : 0);
- read_data_continue(fi);
-}
-
-void upd765_family_device::scan_start(floppy_info &fi)
-{
- fi.main_state = SCAN_DATA;
- fi.sub_state = HEAD_LOAD_DONE;
- mfm = command[0] & 0x40;
-
- logerror("%s: command scan%s data%s%s%s%s cmd=%02x sel=%x chrn=(%d, %d, %d, %d) eot=%02x gpl=%02x stp=%02x rate=%d\n",
- tag(),
- command[0] & 0x08 ? " deleted" : "",
- command[0] & 0x80 ? " mt" : "",
- command[0] & 0x40 ? " mfm" : "",
- command[0] & 0x20 ? " sk" : "",
- fifocfg & 0x40 ? " seek" : "",
- command[0],
- command[1],
- command[2],
- command[3],
- command[4],
- 128 << (command[5] & 7),
- command[6],
- command[7],
- command[8],
- cur_rate);
-
- fi.st0 = command[1] & 7;
- st1 = ST1_MA;
- st2 = 0x00;
- scan_done = false;
- hdl_cb(1);
- fi.ready = get_ready(command[1] & 3);
-
- if(!fi.ready)
- {
- fi.st0 |= ST0_NR | ST0_FAIL;
- fi.sub_state = COMMAND_DONE;
- st1 = 0;
- st2 = 0;
- read_data_continue(fi);
- return;
- }
-
- if(fi.dev)
- fi.dev->ss_w(command[1] & 4 ? 1 : 0);
- read_data_continue(fi);
-}
-
-void upd765_family_device::read_data_continue(floppy_info &fi)
-{
- for(;;) {
- switch(fi.sub_state) {
- case HEAD_LOAD_DONE:
- if(fi.pcn == command[2] || !(fifocfg & 0x40)) {
- fi.sub_state = SEEK_DONE;
- break;
- }
- fi.st0 |= ST0_SE;
- if(fi.dev) {
- fi.dev->dir_w(fi.pcn > command[2] ? 1 : 0);
- fi.dev->stp_w(0);
- }
- fi.sub_state = SEEK_WAIT_STEP_SIGNAL_TIME;
- fi.tm->adjust(attotime::from_nsec(2500));
- return;
-
- case SEEK_WAIT_STEP_SIGNAL_TIME:
- return;
-
- case SEEK_WAIT_STEP_SIGNAL_TIME_DONE:
- if(fi.dev)
- fi.dev->stp_w(1);
-
- fi.sub_state = SEEK_WAIT_STEP_TIME;
- delay_cycles(fi.tm, 500*(16-(spec >> 12)));
- return;
-
- case SEEK_WAIT_STEP_TIME:
- return;
-
- case SEEK_WAIT_STEP_TIME_DONE:
- if(fi.pcn > command[2])
- fi.pcn--;
- else
- fi.pcn++;
- fi.sub_state = HEAD_LOAD_DONE;
- break;
-
- case SEEK_DONE:
- fi.counter = 0;
- fi.sub_state = SCAN_ID;
- live_start(fi, SEARCH_ADDRESS_MARK_HEADER);
- return;
-
- case SCAN_ID:
- if(cur_live.crc) {
- fi.st0 |= ST0_FAIL;
- st1 |= ST1_DE|ST1_ND;
- fi.sub_state = COMMAND_DONE;
- break;
- }
- st1 &= ~ST1_MA;
- if(!sector_matches()) {
- if(cur_live.idbuf[0] != command[2]) {
- if(cur_live.idbuf[0] == 0xff)
- st2 |= ST2_WC|ST2_BC;
- else
- st2 |= ST2_WC;
- fi.st0 |= ST0_FAIL;
- fi.sub_state = COMMAND_DONE;
- break;
- }
- live_start(fi, SEARCH_ADDRESS_MARK_HEADER);
- return;
- }
- logerror("%s: reading sector %02x %02x %02x %02x\n",
- tag(),
- cur_live.idbuf[0],
- cur_live.idbuf[1],
- cur_live.idbuf[2],
- cur_live.idbuf[3]);
- sector_size = calc_sector_size(cur_live.idbuf[3]);
- if(fi.main_state == SCAN_DATA)
- fifo_expect(sector_size, true);
- else
- fifo_expect(sector_size, false);
- fi.sub_state = SECTOR_READ;
- live_start(fi, SEARCH_ADDRESS_MARK_DATA);
- return;
-
- case SCAN_ID_FAILED:
- fi.st0 |= ST0_FAIL;
- st1 |= ST1_ND;
- fi.sub_state = COMMAND_DONE;
- break;
-
- case SECTOR_READ: {
- if(st2 & ST2_MD) {
- fi.st0 |= ST0_FAIL;
- fi.sub_state = COMMAND_DONE;
- break;
- }
- if(cur_live.crc) {
- fi.st0 |= ST0_FAIL;
- st1 |= ST1_DE;
- st2 |= ST2_CM;
- fi.sub_state = COMMAND_DONE;
- break;
- }
- bool done = tc_done;
- if(command[4] == command[6]) {
- if(command[0] & 0x80) {
- command[3] = command[3] ^ 1;
- command[4] = 1;
- if(fi.dev)
- fi.dev->ss_w(command[3] & 1);
- }
- if(!(command[0] & 0x80) || !(command[3] & 1)) {
- if(!tc_done) {
- fi.st0 |= ST0_FAIL;
- st1 |= ST1_EN;
- } else {
- command[2]++;
- command[4] = 1;
- }
- done = true;
- }
- } else
- command[4]++;
- if(!done) {
- fi.sub_state = SEEK_DONE;
- break;
- }
- fi.sub_state = COMMAND_DONE;
- break;
- }
-
- case COMMAND_DONE:
- main_phase = PHASE_RESULT;
- result[0] = fi.st0;
- result[1] = st1;
- result[2] = st2;
- result[3] = command[2];
- result[4] = command[3];
- result[5] = command[4];
- result[6] = command[5];
- result_pos = 7;
- command_end(fi, true);
- return;
-
- default:
- logerror("%s: read sector unknown sub-state %d\n", ttsn().c_str(), fi.sub_state);
- return;
- }
- }
-}
-
-void upd765_family_device::write_data_start(floppy_info &fi)
-{
- fi.main_state = WRITE_DATA;
- fi.sub_state = HEAD_LOAD_DONE;
- mfm = command[0] & 0x40;
- logerror("%s: command write%s data%s%s cmd=%02x sel=%x chrn=(%d, %d, %d, %d) eot=%02x gpl=%02x dtl=%02x rate=%d\n",
- tag(),
- command[0] & 0x08 ? " deleted" : "",
- command[0] & 0x80 ? " mt" : "",
- command[0] & 0x40 ? " mfm" : "",
- command[0],
- command[1],
- command[2],
- command[3],
- command[4],
- 128 << (command[5] & 7),
- command[6],
- command[7],
- command[8],
- cur_rate);
-
- if(fi.dev)
- fi.dev->ss_w(command[1] & 4 ? 1 : 0);
-
- fi.st0 = command[1] & 7;
- st1 = ST1_MA;
- st2 = 0x00;
- hdl_cb(1);
- fi.ready = get_ready(command[1] & 3);
-
- if(!fi.ready)
- {
- fi.st0 |= ST0_NR | ST0_FAIL;
- fi.sub_state = COMMAND_DONE;
- st1 = 0;
- st2 = 0;
- write_data_continue(fi);
- return;
- }
-
- write_data_continue(fi);
-}
-
-void upd765_family_device::write_data_continue(floppy_info &fi)
-{
- for(;;) {
- switch(fi.sub_state) {
- case HEAD_LOAD_DONE:
- fi.counter = 0;
- fi.sub_state = SCAN_ID;
- live_start(fi, SEARCH_ADDRESS_MARK_HEADER);
- return;
-
- case SCAN_ID:
- if(!sector_matches()) {
- live_start(fi, SEARCH_ADDRESS_MARK_HEADER);
- return;
- }
- if(cur_live.crc) {
- fi.st0 |= ST0_FAIL;
- st1 |= ST1_DE|ST1_ND;
- fi.sub_state = COMMAND_DONE;
- break;
- }
- st1 &= ~ST1_MA;
- sector_size = calc_sector_size(cur_live.idbuf[3]);
- fifo_expect(sector_size, true);
- fi.sub_state = SECTOR_WRITTEN;
- live_start(fi, WRITE_SECTOR_SKIP_GAP2);
- return;
-
- case SCAN_ID_FAILED:
- fi.st0 |= ST0_FAIL;
- st1 |= ST1_ND;
- fi.sub_state = COMMAND_DONE;
- break;
-
- case SECTOR_WRITTEN: {
- bool done = tc_done;
- if(command[4] == command[6]) {
- if(command[0] & 0x80) {
- command[3] = command[3] ^ 1;
- command[4] = 1;
- if(fi.dev)
- fi.dev->ss_w(command[3] & 1);
- }
- if(!(command[0] & 0x80) || !(command[3] & 1)) {
- if(!tc_done) {
- fi.st0 |= ST0_FAIL;
- st1 |= ST1_EN;
- } else {
- command[2]++;
- command[4] = 1;
- }
- done = true;
- }
- } else
- command[4]++;
- if(!done) {
- fi.sub_state = HEAD_LOAD_DONE;
- break;
- }
- fi.sub_state = COMMAND_DONE;
- break;
- }
-
- case COMMAND_DONE:
- main_phase = PHASE_RESULT;
- result[0] = fi.st0;
- result[1] = st1;
- result[2] = st2;
- result[3] = command[2];
- result[4] = command[3];
- result[5] = command[4];
- result[6] = command[5];
- result_pos = 7;
- command_end(fi, true);
- return;
-
- default:
- logerror("%s: write sector unknown sub-state %d\n", ttsn().c_str(), fi.sub_state);
- return;
- }
- }
-}
-
-void upd765_family_device::read_track_start(floppy_info &fi)
-{
- fi.main_state = READ_TRACK;
- fi.sub_state = HEAD_LOAD_DONE;
- mfm = command[0] & 0x40;
- sectors_read = 0;
-
- logerror("%s: command read track%s cmd=%02x sel=%x chrn=(%d, %d, %d, %d) eot=%02x gpl=%02x dtl=%02x rate=%d\n",
- tag(),
- command[0] & 0x40 ? " mfm" : "",
- command[0],
- command[1],
- command[2],
- command[3],
- command[4],
- 128 << (command[5] & 7),
- command[6],
- command[7],
- command[8],
- cur_rate);
- fi.st0 = command[1] & 7;
- st1 = ST1_MA;
- st2 = 0x00;
- hdl_cb(1);
- fi.ready = get_ready(command[1] & 3);
-
- if(!fi.ready)
- {
- fi.st0 |= ST0_NR | ST0_FAIL;
- fi.sub_state = COMMAND_DONE;
- st1 = 0;
- st2 = 0;
- read_track_continue(fi);
- return;
- }
-
- if(fi.dev)
- fi.dev->ss_w(command[1] & 4 ? 1 : 0);
- read_track_continue(fi);
-}
-
-void upd765_family_device::read_track_continue(floppy_info &fi)
-{
- for(;;) {
- switch(fi.sub_state) {
- case HEAD_LOAD_DONE:
- if(fi.pcn == command[2] || !(fifocfg & 0x40)) {
- fi.sub_state = SEEK_DONE;
- break;
- }
- fi.st0 |= ST0_SE;
- if(fi.dev) {
- fi.dev->dir_w(fi.pcn > command[2] ? 1 : 0);
- fi.dev->stp_w(0);
- }
- fi.sub_state = SEEK_WAIT_STEP_SIGNAL_TIME;
- fi.tm->adjust(attotime::from_nsec(2500));
- return;
-
- case SEEK_WAIT_STEP_SIGNAL_TIME:
- return;
-
- case SEEK_WAIT_STEP_SIGNAL_TIME_DONE:
- if(fi.dev)
- fi.dev->stp_w(1);
-
- fi.sub_state = SEEK_WAIT_STEP_TIME;
- delay_cycles(fi.tm, 500*(16-(spec >> 12)));
- return;
-
- case SEEK_WAIT_STEP_TIME:
- return;
-
- case SEEK_WAIT_STEP_TIME_DONE:
- if(fi.pcn > command[2])
- fi.pcn--;
- else
- fi.pcn++;
- fi.sub_state = HEAD_LOAD_DONE;
- break;
-
- case SEEK_DONE:
- fi.counter = 0;
- fi.sub_state = WAIT_INDEX;
- return;
-
- case WAIT_INDEX:
- return;
-
- case WAIT_INDEX_DONE:
- logerror("%s: index found, reading track\n", tag());
- fi.sub_state = SCAN_ID;
- live_start(fi, SEARCH_ADDRESS_MARK_HEADER);
- return;
-
- case SCAN_ID:
- if(cur_live.crc) {
- st1 |= ST1_DE;
- }
- st1 &= ~ST1_MA;
- logerror("%s: reading sector %02x %02x %02x %02x\n",
- tag(),
- cur_live.idbuf[0],
- cur_live.idbuf[1],
- cur_live.idbuf[2],
- cur_live.idbuf[3]);
- if(!sector_matches())
- st1 |= ST1_ND;
- else
- st1 &= ~ST1_ND;
-
- sector_size = calc_sector_size(cur_live.idbuf[3]);
- fifo_expect(sector_size, false);
- fi.sub_state = SECTOR_READ;
- live_start(fi, SEARCH_ADDRESS_MARK_DATA);
- return;
-
- case SCAN_ID_FAILED:
- fi.st0 |= ST0_FAIL;
- st1 |= ST1_ND;
- fi.sub_state = COMMAND_DONE;
- break;
-
- case SECTOR_READ: {
- if(st2 & ST2_MD) {
- fi.st0 |= ST0_FAIL;
- fi.sub_state = COMMAND_DONE;
- break;
- }
- if(cur_live.crc) {
- st1 |= ST1_DE;
- st2 |= ST2_CM;
- }
- bool done = tc_done;
- sectors_read++;
- if(sectors_read == command[6]) {
- if(!tc_done) {
- fi.st0 |= ST0_FAIL;
- st1 |= ST1_EN;
- }
- done = true;
- }
- if(!done) {
- fi.sub_state = WAIT_INDEX_DONE;
- break;
- }
- fi.sub_state = COMMAND_DONE;
- break;
- }
-
- case COMMAND_DONE:
- main_phase = PHASE_RESULT;
- result[0] = fi.st0;
- result[1] = st1;
- result[2] = st2;
- result[3] = command[2];
- result[4] = command[3];
- result[5] = command[4];
- result[6] = command[5];
- result_pos = 7;
- command_end(fi, true);
- return;
-
- default:
- logerror("%s: read track unknown sub-state %d\n", ttsn().c_str(), fi.sub_state);
- return;
- }
- }
-}
-
-int upd765_family_device::calc_sector_size(UINT8 size)
-{
- return size > 7 ? 16384 : 128 << size;
-}
-
-void upd765_family_device::format_track_start(floppy_info &fi)
-{
- fi.main_state = FORMAT_TRACK;
- fi.sub_state = HEAD_LOAD_DONE;
- mfm = command[0] & 0x40;
-
- logerror("%s: command format track %s h=%02x n=%02x sc=%02x gpl=%02x d=%02x\n",
- tag(),
- command[0] & 0x40 ? "mfm" : "fm",
- command[1], command[2], command[3], command[4], command[5]);
-
- hdl_cb(1);
- fi.ready = get_ready(command[1] & 3);
-
- if(!fi.ready)
- {
- fi.st0 = (command[1] & 7) | ST0_NR | ST0_FAIL;
- fi.sub_state = TRACK_DONE;
- format_track_continue(fi);
- return;
- }
- fi.st0 = command[1] & 7;
-
- if(fi.dev)
- fi.dev->ss_w(command[1] & 4 ? 1 : 0);
- sector_size = calc_sector_size(command[2]);
-
- format_track_continue(fi);
-}
-
-void upd765_family_device::format_track_continue(floppy_info &fi)
-{
- for(;;) {
- switch(fi.sub_state) {
- case HEAD_LOAD_DONE:
- fi.sub_state = WAIT_INDEX;
- break;
-
- case WAIT_INDEX:
- return;
-
- case WAIT_INDEX_DONE:
- logerror("%s: index found, writing track\n", tag());
- fi.sub_state = TRACK_DONE;
- cur_live.pll.start_writing(machine().time());
- live_start(fi, WRITE_TRACK_PRE_SECTORS);
- return;
-
- case TRACK_DONE:
- main_phase = PHASE_RESULT;
- result[0] = fi.st0;
- result[1] = 0;
- result[2] = 0;
- result[3] = 0;
- result[4] = 0;
- result[5] = 0;
- result[6] = 0;
- result_pos = 7;
- command_end(fi, true);
- return;
-
- default:
- logerror("%s: format track unknown sub-state %d\n", ttsn().c_str(), fi.sub_state);
- return;
- }
- }
-}
-
-void upd765_family_device::read_id_start(floppy_info &fi)
-{
- fi.main_state = READ_ID;
- fi.sub_state = HEAD_LOAD_DONE;
- mfm = command[0] & 0x40;
-
- logerror("%s: command read id%s, rate=%d\n",
- tag(),
- command[0] & 0x40 ? " mfm" : "",
- cur_rate);
-
- if(fi.dev)
- fi.dev->ss_w(command[1] & 4 ? 1 : 0);
-
- fi.st0 = command[1] & 7;
- st1 = 0x00;
- st2 = 0x00;
-
- for(int i=0; i<4; i++)
- cur_live.idbuf[i] = 0x00;
-
- hdl_cb(1);
- fi.ready = get_ready(command[1] & 3);
-
- if(!fi.ready)
- {
- fi.st0 |= ST0_NR | ST0_FAIL;
- fi.sub_state = COMMAND_DONE;
- read_id_continue(fi);
- return;
- }
-
- read_id_continue(fi);
-}
-
-void upd765_family_device::read_id_continue(floppy_info &fi)
-{
- for(;;) {
- switch(fi.sub_state) {
- case HEAD_LOAD_DONE:
- fi.counter = 0;
- fi.sub_state = SCAN_ID;
- live_start(fi, SEARCH_ADDRESS_MARK_HEADER);
- return;
-
- case SCAN_ID:
- if(cur_live.crc) {
- fi.st0 |= ST0_FAIL;
- st1 |= ST1_MA|ST1_DE|ST1_ND;
- }
- fi.sub_state = COMMAND_DONE;
- break;
-
- case SCAN_ID_FAILED:
- fi.st0 |= ST0_FAIL;
- st1 |= ST1_ND|ST1_MA;
- fi.sub_state = COMMAND_DONE;
- break;
-
- case COMMAND_DONE:
- main_phase = PHASE_RESULT;
- result[0] = fi.st0;
- result[1] = st1;
- result[2] = st2;
- result[3] = cur_live.idbuf[0];
- result[4] = cur_live.idbuf[1];
- result[5] = cur_live.idbuf[2];
- result[6] = cur_live.idbuf[3];
- result_pos = 7;
- command_end(fi, true);
- return;
-
- default:
- logerror("%s: read id unknown sub-state %d\n", ttsn().c_str(), fi.sub_state);
- return;
- }
- }
-}
-
-void upd765_family_device::check_irq()
-{
- bool old_irq = cur_irq;
- cur_irq = data_irq || other_irq || internal_drq;
- cur_irq = cur_irq && (dor & 4) && (mode != MODE_AT || (dor & 8));
- if(cur_irq != old_irq) {
- logerror("%s: irq = %d\n", tag(), cur_irq);
- intrq_cb(cur_irq);
- }
-}
-
-bool upd765_family_device::get_irq() const
-{
- return cur_irq;
-}
-
-std::string upd765_family_device::tts(attotime t)
-{
- char buf[256];
- const char *sign = "";
- if(t.seconds() < 0) {
- t = attotime::zero-t;
- sign = "-";
- }
- int nsec = t.attoseconds() / ATTOSECONDS_PER_NANOSECOND;
- sprintf(buf, "%s%04d.%03d,%03d,%03d", sign, int(t.seconds()), nsec/1000000, (nsec/1000)%1000, nsec % 1000);
- return buf;
-}
-
-std::string upd765_family_device::ttsn()
-{
- return tts(machine().time());
-}
-
-void upd765_family_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if(id == TIMER_DRIVE_READY_POLLING) {
- run_drive_ready_polling();
- return;
- }
-
- live_sync();
-
- floppy_info &fi = flopi[id];
- switch(fi.sub_state) {
- case SEEK_WAIT_STEP_SIGNAL_TIME:
- fi.sub_state = SEEK_WAIT_STEP_SIGNAL_TIME_DONE;
- break;
- case SEEK_WAIT_STEP_TIME:
- fi.sub_state = SEEK_WAIT_STEP_TIME_DONE;
- break;
- }
-
- general_continue(fi);
-}
-
-void upd765_family_device::run_drive_ready_polling()
-{
- if(main_phase != PHASE_CMD || (fifocfg & FIF_POLL) || command_pos)
- return;
-
- for(int fid=0; fid<4; fid++) {
- bool ready = get_ready(fid);
- if(ready != flopi[fid].ready) {
- logerror("%s: polled %d : %d -> %d\n", tag(), fid, flopi[fid].ready, ready);
- flopi[fid].ready = ready;
- if(!flopi[fid].st0_filled) {
- flopi[fid].st0 = ST0_ABRT | fid;
- flopi[fid].st0_filled = true;
- other_irq = true;
- }
- }
- }
-
- check_irq();
-}
-
-void upd765_family_device::index_callback(floppy_image_device *floppy, int state)
-{
- for(int fid=0; fid<4; fid++) {
- floppy_info &fi = flopi[fid];
- if(fi.dev != floppy)
- continue;
-
- if(fi.live)
- live_sync();
- fi.index = state;
-
- if(!state) {
- general_continue(fi);
- continue;
- }
-
- switch(fi.sub_state) {
- case IDLE:
- case SEEK_MOVE:
- case SEEK_WAIT_STEP_SIGNAL_TIME:
- case SEEK_WAIT_STEP_SIGNAL_TIME_DONE:
- case SEEK_WAIT_STEP_TIME:
- case SEEK_WAIT_STEP_TIME_DONE:
- case HEAD_LOAD_DONE:
- case SCAN_ID_FAILED:
- case SECTOR_READ:
- break;
-
- case WAIT_INDEX:
- fi.sub_state = WAIT_INDEX_DONE;
- break;
-
- case SCAN_ID:
- fi.counter++;
- if(fi.counter == 2) {
- fi.sub_state = SCAN_ID_FAILED;
- live_abort();
- }
- break;
-
- case TRACK_DONE:
- live_abort();
- break;
-
- default:
- logerror("%s: Index pulse on unknown sub-state %d\n", ttsn().c_str(), fi.sub_state);
- break;
- }
-
- general_continue(fi);
- }
-}
-
-
-void upd765_family_device::general_continue(floppy_info &fi)
-{
- if(fi.live && cur_live.state != IDLE) {
- live_run();
- if(cur_live.state != IDLE)
- return;
- }
-
- switch(fi.main_state) {
- case IDLE:
- break;
-
- case RECALIBRATE:
- case SEEK:
- seek_continue(fi);
- break;
-
- case READ_DATA:
- case SCAN_DATA:
- read_data_continue(fi);
- break;
-
- case WRITE_DATA:
- write_data_continue(fi);
- break;
-
- case READ_TRACK:
- read_track_continue(fi);
- break;
-
- case FORMAT_TRACK:
- format_track_continue(fi);
- break;
-
- case READ_ID:
- read_id_continue(fi);
- break;
-
- default:
- logerror("%s: general_continue on unknown main-state %d\n", ttsn().c_str(), fi.main_state);
- break;
- }
-}
-
-bool upd765_family_device::read_one_bit(const attotime &limit)
-{
- int bit = cur_live.pll.get_next_bit(cur_live.tm, cur_live.fi->dev, limit);
- if(bit < 0)
- return true;
- cur_live.shift_reg = (cur_live.shift_reg << 1) | bit;
- cur_live.bit_counter++;
- if(cur_live.data_separator_phase) {
- cur_live.data_reg = (cur_live.data_reg << 1) | bit;
- if((cur_live.crc ^ (bit ? 0x8000 : 0x0000)) & 0x8000)
- cur_live.crc = (cur_live.crc << 1) ^ 0x1021;
- else
- cur_live.crc = cur_live.crc << 1;
- }
- cur_live.data_separator_phase = !cur_live.data_separator_phase;
- return false;
-}
-
-bool upd765_family_device::write_one_bit(const attotime &limit)
-{
- bool bit = cur_live.shift_reg & 0x8000;
- if(cur_live.pll.write_next_bit(bit, cur_live.tm, cur_live.fi->dev, limit))
- return true;
- if(cur_live.bit_counter & 1) {
- if((cur_live.crc ^ (bit ? 0x8000 : 0x0000)) & 0x8000)
- cur_live.crc = (cur_live.crc << 1) ^ 0x1021;
- else
- cur_live.crc = cur_live.crc << 1;
- }
- cur_live.shift_reg = cur_live.shift_reg << 1;
- cur_live.bit_counter--;
- return false;
-}
-
-void upd765_family_device::live_write_raw(UINT16 raw)
-{
- // logerror("write %04x %04x\n", raw, cur_live.crc);
- cur_live.shift_reg = raw;
- cur_live.data_bit_context = raw & 1;
-}
-
-void upd765_family_device::live_write_mfm(UINT8 mfm)
-{
- bool context = cur_live.data_bit_context;
- UINT16 raw = 0;
- for(int i=0; i<8; i++) {
- bool bit = mfm & (0x80 >> i);
- if(!(bit || context))
- raw |= 0x8000 >> (2*i);
- if(bit)
- raw |= 0x4000 >> (2*i);
- context = bit;
- }
- cur_live.data_reg = mfm;
- cur_live.shift_reg = raw;
- cur_live.data_bit_context = context;
- // logerror("write %02x %04x %04x\n", mfm, cur_live.crc, raw);
-}
-
-void upd765_family_device::live_write_fm(UINT8 fm)
-{
- UINT16 raw = 0xaaaa;
- for(int i=0; i<8; i++)
- if(fm & (0x80 >> i))
- raw |= 0x4000 >> (2*i);
- cur_live.data_reg = fm;
- cur_live.shift_reg = raw;
- cur_live.data_bit_context = fm & 1;
- // logerror("write %02x %04x %04x\n", fm, cur_live.crc, raw);
-}
-
-bool upd765_family_device::sector_matches() const
-{
- if(0)
- logerror("%s: matching %02x %02x %02x %02x - %02x %02x %02x %02x\n", tag(),
- cur_live.idbuf[0], cur_live.idbuf[1], cur_live.idbuf[2], cur_live.idbuf[3],
- command[2], command[3], command[4], command[5]);
- return
- cur_live.idbuf[0] == command[2] &&
- cur_live.idbuf[1] == command[3] &&
- cur_live.idbuf[2] == command[4] &&
- cur_live.idbuf[3] == command[5];
-}
-
-upd765a_device::upd765a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : upd765_family_device(mconfig, UPD765A, "UPD765A", tag, owner, clock, "upd765a", __FILE__)
-{
- dor_reset = 0x0c;
-}
-
-upd765b_device::upd765b_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : upd765_family_device(mconfig, UPD765B, "UPD765B", tag, owner, clock, "upd765b", __FILE__)
-{
- dor_reset = 0x0c;
-}
-
-i8272a_device::i8272a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : upd765_family_device(mconfig, I8272A, "I8272A", tag, owner, clock, "i8272a", __FILE__)
-{
- dor_reset = 0x0c;
-}
-
-upd72065_device::upd72065_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : upd765_family_device(mconfig, UPD72065, "UPD72065", tag, owner, clock, "upd72065", __FILE__)
-{
- dor_reset = 0x0c;
-}
-
-smc37c78_device::smc37c78_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : upd765_family_device(mconfig, SMC37C78, "SMC37C78", tag, owner, clock, "smc37c78", __FILE__)
-{
- ready_connected = false;
- select_connected = true;
-}
-
-n82077aa_device::n82077aa_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : upd765_family_device(mconfig, N82077AA, "N82077AA", tag, owner, clock, "n82077aa", __FILE__)
-{
- ready_connected = false;
- select_connected = true;
-}
-
-pc_fdc_superio_device::pc_fdc_superio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : upd765_family_device(mconfig, PC_FDC_SUPERIO, "PC FDC SUPERIO", tag, owner, clock, "pc_fdc_superio", __FILE__)
-{
- ready_polled = false;
- ready_connected = false;
- select_connected = true;
-}
-
-dp8473_device::dp8473_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : upd765_family_device(mconfig, PC_FDC_SUPERIO, "DP8473", tag, owner, clock, "dp8473", __FILE__)
-{
- ready_polled = false;
- ready_connected = false;
- select_connected = true;
-}
-
-pc8477a_device::pc8477a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : upd765_family_device(mconfig, PC_FDC_SUPERIO, "PC8477A", tag, owner, clock, "pc8477a", __FILE__)
-{
- ready_polled = true;
- ready_connected = false;
- select_connected = true;
-}
-
-wd37c65c_device::wd37c65c_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : upd765_family_device(mconfig, PC_FDC_SUPERIO, "WD37C65C", tag, owner, clock, "wd37c65c", __FILE__)
-{
- ready_polled = true;
- ready_connected = false;
- select_connected = true;
-}
-
-mcs3201_device::mcs3201_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- upd765_family_device(mconfig, MCS3201, "Motorola MCS3201", tag, owner, clock, "mcs3201", __FILE__),
- m_input_handler(*this)
-{
- dor_reset = 0x0c;
- ready_polled = false;
- ready_connected = false;
- select_connected = true;
-}
-
-void mcs3201_device::device_start()
-{
- upd765_family_device::device_start();
- m_input_handler.resolve_safe(0);
-}
-
-READ8_MEMBER( mcs3201_device::input_r )
-{
- return m_input_handler();
-}
-
-tc8566af_device::tc8566af_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : upd765_family_device(mconfig, TC8566AF, "TC8566AF", tag, owner, clock, "tc8566af", __FILE__)
- , m_cr1(0)
-{
- ready_polled = true;
- ready_connected = true;
- select_connected = true;
-}
-
-void tc8566af_device::device_start()
-{
- upd765_family_device::device_start();
- save_item(NAME(m_cr1));
-}
-
-WRITE8_MEMBER(tc8566af_device::cr1_w)
-{
- m_cr1 = data;
-
- if (m_cr1 & 0x02)
- {
- // Not sure if this inverted or not
- tc_w((m_cr1 & 0x01) ? true : false);
- }
-}
diff --git a/src/emu/machine/upd765.h b/src/emu/machine/upd765.h
deleted file mode 100644
index a3465887943..00000000000
--- a/src/emu/machine/upd765.h
+++ /dev/null
@@ -1,533 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef __UPD765_F_H__
-#define __UPD765_F_H__
-
-#include "emu.h"
-#include "imagedev/floppy.h"
-#include "fdc_pll.h"
-
-/*
- * ready = true if the ready line is physically connected to the floppy drive
- * select = true if the fdc controls the floppy drive selection
- * mode = MODE_AT, MODE_PS2 or MODE_M30 for the fdcs that have reset-time selection
- */
-
-#define MCFG_UPD765A_ADD(_tag, _ready, _select) \
- MCFG_DEVICE_ADD(_tag, UPD765A, 0) \
- downcast<upd765a_device *>(device)->set_ready_line_connected(_ready); \
- downcast<upd765a_device *>(device)->set_select_lines_connected(_select);
-
-#define MCFG_UPD765B_ADD(_tag, _ready, _select) \
- MCFG_DEVICE_ADD(_tag, UPD765B, 0) \
- downcast<upd765b_device *>(device)->set_ready_line_connected(_ready); \
- downcast<upd765b_device *>(device)->set_select_lines_connected(_select);
-
-#define MCFG_I8272A_ADD(_tag, _ready) \
- MCFG_DEVICE_ADD(_tag, I8272A, 0) \
- downcast<i8272a_device *>(device)->set_ready_line_connected(_ready);
-
-#define MCFG_UPD72065_ADD(_tag, _ready, _select) \
- MCFG_DEVICE_ADD(_tag, UPD72065, 0) \
- downcast<upd72065_device *>(device)->set_ready_line_connected(_ready); \
- downcast<upd72065_device *>(device)->set_select_lines_connected(_select);
-
-#define MCFG_SMC37C78_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, SMC37C78, 0)
-
-#define MCFG_N82077AA_ADD(_tag, _mode) \
- MCFG_DEVICE_ADD(_tag, N82077AA, 0) \
- downcast<n82077aa_device *>(device)->set_mode(_mode);
-
-#define MCFG_PC_FDC_SUPERIO_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, PC_FDC_SUPERIO, 0)
-
-#define MCFG_DP8473_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, DP8473, 0)
-
-#define MCFG_PC8477A_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, PC8477A, 0)
-
-#define MCFG_WD37C65C_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, WD37C65C, 0)
-
-#define MCFG_MCS3201_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, MCS3201, 0)
-
-#define MCFG_TC8566AF_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, TC8566AF, 0)
-
-#define MCFG_MCS3201_INPUT_HANDLER(_devcb) \
- devcb = &mcs3201_device::set_input_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_UPD765_INTRQ_CALLBACK(_write) \
- devcb = &upd765_family_device::set_intrq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_UPD765_DRQ_CALLBACK(_write) \
- devcb = &upd765_family_device::set_drq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_UPD765_HDL_CALLBACK(_write) \
- devcb = &upd765_family_device::set_hdl_wr_callback(*device, DEVCB_##_write);
-
-/* Interface required for PC ISA wrapping */
-class pc_fdc_interface : public device_t {
-public:
- typedef delegate<UINT8 ()> byte_read_cb;
- typedef delegate<void (UINT8)> byte_write_cb;
-
- pc_fdc_interface(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : device_t(mconfig, type, name, tag, owner, clock, shortname, source) {}
-
- /* Note that the address map must cover and handle the whole 0-7
- * range. The upd765, while conforming to the rest of the
- * interface, is not eligible as a result.
- */
-
- virtual DECLARE_ADDRESS_MAP(map, 8) = 0;
-
- virtual UINT8 dma_r() = 0;
- virtual void dma_w(UINT8 data) = 0;
-
- virtual void tc_w(bool val) = 0;
- virtual UINT8 do_dir_r() = 0;
-};
-
-class upd765_family_device : public pc_fdc_interface {
-public:
- enum { MODE_AT, MODE_PS2, MODE_M30 };
-
- upd765_family_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- template<class _Object> static devcb_base &set_intrq_wr_callback(device_t &device, _Object object) { return downcast<upd765_family_device &>(device).intrq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_drq_wr_callback(device_t &device, _Object object) { return downcast<upd765_family_device &>(device).drq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_hdl_wr_callback(device_t &device, _Object object) { return downcast<upd765_family_device &>(device).hdl_cb.set_callback(object); }
-
- virtual DECLARE_ADDRESS_MAP(map, 8) = 0;
-
- DECLARE_READ8_MEMBER (sra_r);
- DECLARE_READ8_MEMBER (srb_r);
- DECLARE_READ8_MEMBER (dor_r);
- DECLARE_WRITE8_MEMBER(dor_w);
- DECLARE_READ8_MEMBER (tdr_r);
- DECLARE_WRITE8_MEMBER(tdr_w);
- DECLARE_READ8_MEMBER (msr_r);
- DECLARE_WRITE8_MEMBER(dsr_w);
- DECLARE_READ8_MEMBER (fifo_r);
- DECLARE_WRITE8_MEMBER(fifo_w);
- DECLARE_READ8_MEMBER (dir_r);
- DECLARE_WRITE8_MEMBER(ccr_w);
-
- virtual UINT8 do_dir_r();
-
- UINT8 dma_r();
- void dma_w(UINT8 data);
-
- // Same as the previous ones, but as memory-mappable members
- DECLARE_READ8_MEMBER(mdma_r);
- DECLARE_WRITE8_MEMBER(mdma_w);
-
- bool get_irq() const;
- bool get_drq() const;
- void tc_w(bool val);
- void ready_w(bool val);
-
- void set_rate(int rate); // rate in bps, to be used when the fdc is externally frequency-controlled
-
- void set_mode(int mode);
- void set_ready_line_connected(bool ready);
- void set_select_lines_connected(bool select);
- void set_floppy(floppy_image_device *image);
- void soft_reset();
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- enum {
- TIMER_DRIVE_READY_POLLING = 4
- };
-
- enum {
- PHASE_CMD, PHASE_EXEC, PHASE_RESULT
- };
-
- enum {
- MSR_DB = 0x0f,
- MSR_CB = 0x10,
- MSR_EXM = 0x20,
- MSR_DIO = 0x40,
- MSR_RQM = 0x80,
-
- ST0_UNIT = 0x07,
- ST0_NR = 0x08,
- ST0_EC = 0x10,
- ST0_SE = 0x20,
- ST0_FAIL = 0x40,
- ST0_UNK = 0x80,
- ST0_ABRT = 0xc0,
-
- ST1_MA = 0x01,
- ST1_NW = 0x02,
- ST1_ND = 0x04,
- ST1_OR = 0x10,
- ST1_DE = 0x20,
- ST1_EN = 0x80,
-
- ST2_MD = 0x01,
- ST2_BC = 0x02,
- ST2_SN = 0x04,
- ST2_SH = 0x08,
- ST2_WC = 0x10,
- ST2_DD = 0x20,
- ST2_CM = 0x40,
-
- ST3_UNIT = 0x07,
- ST3_TS = 0x08,
- ST3_T0 = 0x10,
- ST3_RY = 0x20,
- ST3_WP = 0x40,
- ST3_FT = 0x80,
-
- FIF_THR = 0x0f,
- FIF_POLL = 0x10,
- FIF_DIS = 0x20,
- FIF_EIS = 0x40,
-
- SPEC_ND = 0x0001
- };
-
-
- enum {
- // General "doing nothing" state
- IDLE,
-
- // Main states
- RECALIBRATE,
- SEEK,
- READ_DATA,
- WRITE_DATA,
- READ_TRACK,
- FORMAT_TRACK,
- READ_ID,
- SCAN_DATA,
-
- // Sub-states
- COMMAND_DONE,
-
- SEEK_MOVE,
- SEEK_WAIT_STEP_SIGNAL_TIME,
- SEEK_WAIT_STEP_SIGNAL_TIME_DONE,
- SEEK_WAIT_STEP_TIME,
- SEEK_WAIT_STEP_TIME_DONE,
- SEEK_DONE,
-
- HEAD_LOAD_DONE,
-
- WAIT_INDEX,
- WAIT_INDEX_DONE,
-
- SCAN_ID,
- SCAN_ID_FAILED,
-
- SECTOR_READ,
- SECTOR_WRITTEN,
- TC_DONE,
-
- TRACK_DONE,
-
- // Live states
- SEARCH_ADDRESS_MARK_HEADER,
- READ_HEADER_BLOCK_HEADER,
- READ_DATA_BLOCK_HEADER,
- READ_ID_BLOCK,
- SEARCH_ADDRESS_MARK_DATA,
- SEARCH_ADDRESS_MARK_DATA_FAILED,
- READ_SECTOR_DATA,
- READ_SECTOR_DATA_BYTE,
- SCAN_SECTOR_DATA_BYTE,
-
- WRITE_SECTOR_SKIP_GAP2,
- WRITE_SECTOR_SKIP_GAP2_BYTE,
- WRITE_SECTOR_DATA,
- WRITE_SECTOR_DATA_BYTE,
-
- WRITE_TRACK_PRE_SECTORS,
- WRITE_TRACK_PRE_SECTORS_BYTE,
-
- WRITE_TRACK_SECTOR,
- WRITE_TRACK_SECTOR_BYTE,
-
- WRITE_TRACK_POST_SECTORS,
- WRITE_TRACK_POST_SECTORS_BYTE
- };
-
- struct pll_t {
- attotime ctime, period, min_period, max_period, period_adjust_base, phase_adjust;
-
- attotime write_start_time;
- attotime write_buffer[32];
- int write_position;
- int freq_hist;
-
- void set_clock(const attotime &period);
- void reset(const attotime &when);
- int get_next_bit(attotime &tm, floppy_image_device *floppy, const attotime &limit);
- bool write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, const attotime &limit);
- void start_writing(const attotime &tm);
- void commit(floppy_image_device *floppy, const attotime &tm);
- void stop_writing(floppy_image_device *floppy, const attotime &tm);
- };
-
- struct floppy_info {
- enum { IRQ_NONE, IRQ_POLLED, IRQ_SEEK, IRQ_DONE };
- emu_timer *tm;
- floppy_image_device *dev;
- int id;
- int main_state, sub_state;
- int dir, counter;
- UINT8 pcn, st0;
- bool st0_filled;
- bool live, index, ready;
- };
-
- struct live_info {
- enum { PT_NONE, PT_CRC_1, PT_CRC_2 };
-
- attotime tm;
- int state, next_state;
- floppy_info *fi;
- UINT16 shift_reg;
- UINT16 crc;
- int bit_counter, byte_counter, previous_type;
- bool data_separator_phase, data_bit_context;
- UINT8 data_reg;
- UINT8 idbuf[6];
- fdc_pll_t pll;
- };
-
- static int rates[4];
-
- bool ready_connected, ready_polled, select_connected;
-
- bool external_ready;
-
- int mode;
- int main_phase;
-
- live_info cur_live, checkpoint_live;
- devcb_write_line intrq_cb, drq_cb, hdl_cb;
- bool cur_irq, other_irq, data_irq, drq, internal_drq, tc, tc_done, locked, mfm, scan_done;
- floppy_info flopi[4];
-
- int fifo_pos, fifo_expected, command_pos, result_pos, sectors_read;
- bool fifo_write;
- UINT8 dor, dsr, msr, fifo[16], command[16], result[16];
- UINT8 st1, st2, st3;
- UINT8 fifocfg, dor_reset;
- UINT8 precomp, perpmode;
- UINT16 spec;
- int sector_size;
- int cur_rate;
-
- emu_timer *poll_timer;
-
- static std::string tts(attotime t);
- std::string ttsn();
-
- enum {
- C_CONFIGURE,
- C_DUMP_REG,
- C_FORMAT_TRACK,
- C_LOCK,
- C_PERPENDICULAR,
- C_READ_DATA,
- C_READ_ID,
- C_READ_TRACK,
- C_RECALIBRATE,
- C_SEEK,
- C_SENSE_DRIVE_STATUS,
- C_SENSE_INTERRUPT_STATUS,
- C_SPECIFY,
- C_WRITE_DATA,
- C_SCAN_EQUAL,
- C_SCAN_LOW,
- C_SCAN_HIGH,
-
- C_INVALID,
- C_INCOMPLETE
- };
-
- void delay_cycles(emu_timer *tm, int cycles);
- void check_irq();
- void fifo_expect(int size, bool write);
- void fifo_push(UINT8 data, bool internal);
- UINT8 fifo_pop(bool internal);
- void set_drq(bool state);
- bool get_ready(int fid);
-
- void enable_transfer();
- void disable_transfer();
- int calc_sector_size(UINT8 size);
-
- void run_drive_ready_polling();
-
- int check_command();
- void start_command(int cmd);
- void command_end(floppy_info &fi, bool data_completion);
-
- void recalibrate_start(floppy_info &fi);
- void seek_start(floppy_info &fi);
- void seek_continue(floppy_info &fi);
-
- void read_data_start(floppy_info &fi);
- void read_data_continue(floppy_info &fi);
-
- void write_data_start(floppy_info &fi);
- void write_data_continue(floppy_info &fi);
-
- void read_track_start(floppy_info &fi);
- void read_track_continue(floppy_info &fi);
-
- void format_track_start(floppy_info &fi);
- void format_track_continue(floppy_info &fi);
-
- void read_id_start(floppy_info &fi);
- void read_id_continue(floppy_info &fi);
-
- void scan_start(floppy_info &fi);
-
- void general_continue(floppy_info &fi);
- void index_callback(floppy_image_device *floppy, int state);
- bool sector_matches() const;
-
- void live_start(floppy_info &fi, int live_state);
- void live_abort();
- void checkpoint();
- void rollback();
- void live_delay(int state);
- void live_sync();
- void live_run(attotime limit = attotime::never);
- void live_write_raw(UINT16 raw);
- void live_write_fm(UINT8 fm);
- void live_write_mfm(UINT8 mfm);
-
- bool read_one_bit(const attotime &limit);
- bool write_one_bit(const attotime &limit);
-};
-
-class upd765a_device : public upd765_family_device {
-public:
- upd765a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-};
-
-class upd765b_device : public upd765_family_device {
-public:
- upd765b_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-};
-
-class i8272a_device : public upd765_family_device {
-public:
- i8272a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-};
-
-class smc37c78_device : public upd765_family_device {
-public:
- smc37c78_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-};
-
-class upd72065_device : public upd765_family_device {
-public:
- upd72065_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-};
-
-class n82077aa_device : public upd765_family_device {
-public:
- n82077aa_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-};
-
-class pc_fdc_superio_device : public upd765_family_device {
-public:
- pc_fdc_superio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-};
-
-class dp8473_device : public upd765_family_device {
-public:
- dp8473_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-};
-
-class pc8477a_device : public upd765_family_device {
-public:
- pc8477a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-};
-
-class wd37c65c_device : public upd765_family_device {
-public:
- wd37c65c_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-};
-
-class mcs3201_device : public upd765_family_device {
-public:
- mcs3201_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_input_handler(device_t &device, _Object object) { return downcast<mcs3201_device &>(device).m_input_handler.set_callback(object); }
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
- DECLARE_READ8_MEMBER( input_r );
-
-protected:
- virtual void device_start();
-
-private:
- devcb_read8 m_input_handler;
-};
-
-class tc8566af_device : public upd765_family_device {
-public:
- tc8566af_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual DECLARE_ADDRESS_MAP(map, 8);
-
- DECLARE_WRITE8_MEMBER(cr1_w);
-
-protected:
- virtual void device_start();
-
-private:
- UINT8 m_cr1;
-};
-
-extern const device_type UPD765A;
-extern const device_type UPD765B;
-extern const device_type I8272A;
-extern const device_type UPD72065;
-extern const device_type SMC37C78;
-extern const device_type N82077AA;
-extern const device_type PC_FDC_SUPERIO;
-extern const device_type DP8473;
-extern const device_type PC8477A;
-extern const device_type WD37C65C;
-extern const device_type MCS3201;
-extern const device_type TC8566AF;
-
-#endif
diff --git a/src/emu/machine/v3021.c b/src/emu/machine/v3021.c
deleted file mode 100644
index de8f8526f25..00000000000
--- a/src/emu/machine/v3021.c
+++ /dev/null
@@ -1,185 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Angelo Salese
-/***************************************************************************
-
- v3021.c
-
- EM Microelectronic-Marin SA Ultra Low Power 32kHz CMOS RTC (DIP8)
-
- Serial Real Time Clock
-
- - very preliminary, borrowed from hard-coded PGM implementation.
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/v3021.h"
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-const device_type v3021 = &device_creator<v3021_device>;
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// v3021_device - constructor
-//-------------------------------------------------
-
-v3021_device::v3021_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, v3021, "V3021 RTC", tag, owner, clock, "v3021", __FILE__)
-{
-}
-
-void v3021_device::timer_callback()
-{
- static const UINT8 dpm[12] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 };
- int dpm_count;
-
- m_rtc.sec++;
-
- if((m_rtc.sec & 0x0f) >= 0x0a) { m_rtc.sec+=0x10; m_rtc.sec&=0xf0; }
- if((m_rtc.sec & 0xf0) >= 0x60) { m_rtc.min++; m_rtc.sec = 0; }
- if((m_rtc.min & 0x0f) >= 0x0a) { m_rtc.min+=0x10; m_rtc.min&=0xf0; }
- if((m_rtc.min & 0xf0) >= 0x60) { m_rtc.hour++; m_rtc.min = 0; }
- if((m_rtc.hour & 0x0f) >= 0x0a) { m_rtc.hour+=0x10; m_rtc.hour&=0xf0; }
- if((m_rtc.hour & 0xff) >= 0x24) { m_rtc.day++; m_rtc.wday<<=1; m_rtc.hour = 0; }
- if(m_rtc.wday & 0x80) { m_rtc.wday = 1; }
- if((m_rtc.day & 0x0f) >= 0x0a) { m_rtc.day+=0x10; m_rtc.day&=0xf0; }
-
- /* TODO: crude leap year support */
- dpm_count = (m_rtc.month & 0xf) + (((m_rtc.month & 0x10) >> 4)*10)-1;
-
- if(((m_rtc.year % 4) == 0) && m_rtc.month == 2)
- {
- if((m_rtc.day & 0xff) >= dpm[dpm_count]+1+1)
- { m_rtc.month++; m_rtc.day = 0x01; }
- }
- else if((m_rtc.day & 0xff) >= dpm[dpm_count]+1){ m_rtc.month++; m_rtc.day = 0x01; }
- if((m_rtc.month & 0x0f) >= 0x0a) { m_rtc.month = 0x10; }
- if(m_rtc.month >= 0x13) { m_rtc.year++; m_rtc.month = 1; }
- if((m_rtc.year & 0x0f) >= 0x0a) { m_rtc.year+=0x10; m_rtc.year&=0xf0; }
- if((m_rtc.year & 0xf0) >= 0xa0) { m_rtc.year = 0; } //2000-2099 possible timeframe
-}
-
-TIMER_CALLBACK( v3021_device::rtc_inc_callback )
-{
- reinterpret_cast<v3021_device *>(ptr)->timer_callback();
-}
-
-//-------------------------------------------------
-// device_validity_check - perform validity checks
-// on this device
-//-------------------------------------------------
-
-void v3021_device::device_validity_check(validity_checker &valid) const
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void v3021_device::device_start()
-{
- /* let's call the timer callback every second */
- machine().scheduler().timer_pulse(attotime::from_hz(clock() / XTAL_32_768kHz), FUNC(rtc_inc_callback), 0, (void *)this);
-
- system_time systime;
- machine().base_datetime(systime);
-
- m_rtc.day = ((systime.local_time.mday / 10)<<4) | ((systime.local_time.mday % 10) & 0xf);
- m_rtc.month = (((systime.local_time.month+1) / 10) << 4) | (((systime.local_time.month+1) % 10) & 0xf);
- m_rtc.wday = 1 << systime.local_time.weekday;
- m_rtc.year = (((systime.local_time.year % 100)/10)<<4) | ((systime.local_time.year % 10) & 0xf);
- m_rtc.hour = ((systime.local_time.hour / 10)<<4) | ((systime.local_time.hour % 10) & 0xf);
- m_rtc.min = ((systime.local_time.minute / 10)<<4) | ((systime.local_time.minute % 10) & 0xf);
- m_rtc.sec = ((systime.local_time.second / 10)<<4) | ((systime.local_time.second % 10) & 0xf);
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void v3021_device::device_reset()
-{
- m_cal_cnt = 0;
-}
-
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-READ8_MEMBER( v3021_device::read )
-{
- UINT8 calr = (m_cal_val & m_cal_mask) ? 1 : 0;
-
- m_cal_mask <<= 1;
- return calr;
-}
-
-WRITE8_MEMBER( v3021_device::write )
-{
- m_cal_com <<= 1;
- m_cal_com |= data & 1;
- ++m_cal_cnt;
-
- if (m_cal_cnt == 4)
- {
- m_cal_mask = 1;
- m_cal_val = 1;
- m_cal_cnt = 0;
-
- switch (m_cal_com & 0xf)
- {
- case 1: case 3: case 5: case 7: case 9: case 0xb: case 0xd:
- m_cal_val++;
- break;
-
- case 0:
- m_cal_val = (m_rtc.wday); //??
- break;
-
- case 2: //Hours
- m_cal_val = (m_rtc.hour);
- break;
-
- case 4: //Seconds
- m_cal_val = (m_rtc.sec);
- break;
-
- case 6: //Month
- m_cal_val = (m_rtc.month); //?? not bcd in MVS
- break;
-
- case 8:
- m_cal_val = 0; //Controls blinking speed, maybe milliseconds
- break;
-
- case 0xa: //Day
- m_cal_val = (m_rtc.day);
- break;
-
- case 0xc: //Minute
- m_cal_val = (m_rtc.min);
- break;
-
- case 0xe: //Year
- m_cal_val = (m_rtc.year % 100);
- break;
-
- case 0xf: //Load Date
- //space.machine().base_datetime(m_systime);
- break;
- }
- }
-}
diff --git a/src/emu/machine/v3021.h b/src/emu/machine/v3021.h
deleted file mode 100644
index 3dd1c709d1e..00000000000
--- a/src/emu/machine/v3021.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Angelo Salese
-/***************************************************************************
-
- v3021.h
-
- EM Microelectronic-Marin SA Ultra Low Power 32kHz CMOS RTC (DIP8)
-
- Serial Real Time Clock
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __v3021DEV_H__
-#define __v3021DEV_H__
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_V3021_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, v3021, XTAL_32_768kHz)
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-struct rtc_regs_t
-{
- UINT8 sec, min, hour, day, wday, month, year;
-};
-
-
-// ======================> v3021_device
-
-class v3021_device : public device_t
-{
-public:
- // construction/destruction
- v3021_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // I/O operations
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_READ8_MEMBER( read );
- void timer_callback();
-
-protected:
- // device-level overrides
- virtual void device_validity_check(validity_checker &valid) const;
- virtual void device_start();
- virtual void device_reset();
-
- inline UINT8 rtc_read(UINT8 offset);
- inline void rtc_write(UINT8 offset,UINT8 data);
-
- static TIMER_CALLBACK( rtc_inc_callback );
-
- UINT8 m_cal_mask,m_cal_com,m_cal_cnt,m_cal_val;
-
- rtc_regs_t m_rtc;
-};
-
-
-// device type definition
-extern const device_type v3021;
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-
-
-#endif
diff --git a/src/emu/machine/vrc4373.c b/src/emu/machine/vrc4373.c
deleted file mode 100644
index 860b7ff601a..00000000000
--- a/src/emu/machine/vrc4373.c
+++ /dev/null
@@ -1,432 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Ted Green
-#include "vrc4373.h"
-
-#define LOG_NILE (0)
-#define LOG_NILE_MASTER (0)
-#define LOG_NILE_TARGET (0)
-
-const device_type VRC4373 = &device_creator<vrc4373_device>;
-
-DEVICE_ADDRESS_MAP_START(config_map, 32, vrc4373_device)
- AM_RANGE(0x40, 0x43) AM_READWRITE (pcictrl_r, pcictrl_w)
- AM_INHERIT_FROM(pci_host_device::config_map)
-ADDRESS_MAP_END
-
-// cpu i/f map
-DEVICE_ADDRESS_MAP_START(cpu_map, 32, vrc4373_device)
- AM_RANGE(0x00000000, 0x0000007b) AM_READWRITE( cpu_if_r, cpu_if_w)
-ADDRESS_MAP_END
-
-// Target Window 1 map
-DEVICE_ADDRESS_MAP_START(target1_map, 32, vrc4373_device)
- AM_RANGE(0x00000000, 0xFFFFFFFF) AM_READWRITE( target1_r, target1_w)
-ADDRESS_MAP_END
-
-// Target Window 2 map
-DEVICE_ADDRESS_MAP_START(target2_map, 32, vrc4373_device)
- AM_RANGE(0x00000000, 0xFFFFFFFF) AM_READWRITE( target2_r, target2_w)
-ADDRESS_MAP_END
-
-vrc4373_device::vrc4373_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : pci_host_device(mconfig, VRC4373, "NEC VRC4373 System Controller", tag, owner, clock, "vrc4373", __FILE__),
- m_mem_config("memory_space", ENDIANNESS_LITTLE, 32, 32),
- m_io_config("io_space", ENDIANNESS_LITTLE, 32, 32)
-
-{
-}
-
-const address_space_config *vrc4373_device::memory_space_config(address_spacenum spacenum) const
-{
- return (spacenum == AS_PROGRAM) ? pci_bridge_device::memory_space_config(spacenum) : (spacenum == AS_DATA) ? &m_mem_config : (spacenum == AS_IO) ? &m_io_config : NULL;
-}
-
-void vrc4373_device::device_start()
-{
- pci_host_device::device_start();
- m_cpu = machine().device<mips3_device>(cpu_tag);
- m_cpu_space = &m_cpu->space(AS_PROGRAM);
- memory_space = &space(AS_DATA);
- io_space = &space(AS_IO);
-
- memset(m_cpu_regs, 0, sizeof(m_cpu_regs));
-
- memory_window_start = 0;
- memory_window_end = 0xffffffff;
- memory_offset = 0;
- io_window_start = 0;
- io_window_end = 0xffffffff;
- io_offset = 0x00000000;
- status = 0x0280;
- m_ram_size = 1<<22;
- m_ram_base = 0;
- m_simm_size = 1<<21;
- m_simm_base = 0;
-
- // ROM size = 1 MB
- m_cpu_space->install_rom (0x1fc00000, 0x1fcfffff, m_region->base());
- m_cpu_space->install_device(0x0f000000, 0x0f0000ff, *static_cast<vrc4373_device *>(this), &vrc4373_device::cpu_map);
- // PCI Configuration also mapped at 0x0f000100
- m_cpu_space->install_device(0x0f000100, 0x0f0001ff, *static_cast<vrc4373_device *>(this), &vrc4373_device::config_map);
-
- // MIPS drc
- m_cpu->add_fastram(0x1fc00000, 0x1fcfffff, TRUE, m_region->base());
-}
-
-void vrc4373_device::device_reset()
-{
- pci_device::device_reset();
- memset(m_cpu_regs, 0, sizeof(m_cpu_regs));
- regenerate_config_mapping();
-}
-
-void vrc4373_device::map_cpu_space()
-{
- UINT32 winStart, winEnd, winSize;
-
- // VRC4373 is at 0x0f000000 to 0x0f0001ff
- // ROM region starts at 0x1f000000
- m_cpu_space->unmap_readwrite(0x00000000, 0x0effffff);
- m_cpu_space->unmap_readwrite(0x0f000200, 0x1effffff);
-
- // Clear fastram regions in cpu after rom
- m_cpu->clear_fastram(1);
-
- if (m_cpu_regs[NREG_BMCR]&0x8) {
- m_cpu_space->install_ram(m_ram_base, m_ram_base+m_ram_size-1, &m_ram[0]);
- m_cpu->add_fastram(m_ram_base, m_ram_size-1, FALSE, &m_ram[0]);
- if (LOG_NILE)
- logerror("%s: map_cpu_space ram_size=%08X ram_base=%08X\n", tag(),m_ram_size,m_ram_base);
- }
- if (m_cpu_regs[NREG_SIMM1]&0x8) {
- m_cpu_space->install_ram(m_simm_base, m_simm_base+m_simm_size-1, &m_simm[0]);
- //m_cpu->add_fastram(m_simm_base, m_simm_size-1, FALSE, &m_simm[0]);
- if (LOG_NILE)
- logerror("%s: map_cpu_space simm_size=%08X simm_base=%08X\n", tag(),m_simm_size,m_simm_base);
- }
-
- // PCI Master Window 1
- if (m_cpu_regs[NREG_PCIMW1]&0x1000) {
- winStart = m_cpu_regs[NREG_PCIMW1]&0xff000000;
- winEnd = winStart | (~(0x80000000 | (((m_cpu_regs[NREG_PCIMW1]>>13)&0x7f)<<24)));
- winSize = winEnd - winStart + 1;
- m_cpu_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(vrc4373_device::master1_r), this));
- m_cpu_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(vrc4373_device::master1_w), this));
- if (LOG_NILE)
- logerror("%s: map_cpu_space Master Window 1 start=%08X end=%08X size=%08X laddr=%08X\n", tag(), winStart, winEnd, winSize, m_pci1_laddr);
- }
- // PCI Master Window 2
- if (m_cpu_regs[NREG_PCIMW2]&0x1000) {
- winStart = m_cpu_regs[NREG_PCIMW2]&0xff000000;
- winEnd = winStart | (~(0x80000000 | (((m_cpu_regs[NREG_PCIMW2]>>13)&0x7f)<<24)));
- winSize = winEnd - winStart + 1;
- m_cpu_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(vrc4373_device::master2_r), this));
- m_cpu_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(vrc4373_device::master2_w), this));
- if (LOG_NILE)
- logerror("%s: map_cpu_space Master Window 2 start=%08X end=%08X size=%08X laddr=%08X\n", tag(), winStart, winEnd, winSize, m_pci2_laddr);
- }
- // PCI IO Window
- if (m_cpu_regs[NREG_PCIMIOW]&0x1000) {
- winStart = m_cpu_regs[NREG_PCIMIOW]&0xff000000;
- winEnd = winStart | (~(0x80000000 | (((m_cpu_regs[NREG_PCIMIOW]>>13)&0x7f)<<24)));
- winSize = winEnd - winStart + 1;
- m_cpu_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(vrc4373_device::master_io_r), this));
- m_cpu_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(vrc4373_device::master_io_w), this));
- if (LOG_NILE)
- logerror("%s: map_cpu_space IO Window start=%08X end=%08X size=%08X laddr=%08X\n", tag(), winStart, winEnd, winSize, m_pci_io_laddr);
- }
-}
-
-void vrc4373_device::map_extra(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space)
-{
- UINT32 winStart, winEnd, winSize;
-
- // PCI Target Window 1
- if (m_cpu_regs[NREG_PCITW1]&0x1000) {
- winStart = m_cpu_regs[NREG_PCITW1]&0xffe00000;
- winEnd = winStart | (~(0xf0000000 | (((m_cpu_regs[NREG_PCITW1]>>13)&0x7f)<<21)));
- winSize = winEnd - winStart + 1;
- memory_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(vrc4373_device::target1_r), this));
- memory_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(vrc4373_device::target1_w), this));
- if (LOG_NILE)
- logerror("%s: map_extra Target Window 1 start=%08X end=%08X size=%08X laddr=%08X\n", tag(), winStart, winEnd, winSize, m_target1_laddr);
- }
- // PCI Target Window 2
- if (m_cpu_regs[NREG_PCITW2]&0x1000) {
- winStart = m_cpu_regs[NREG_PCITW2]&0xffe00000;
- winEnd = winStart | (~(0xf0000000 | (((m_cpu_regs[NREG_PCITW2]>>13)&0x7f)<<21)));
- winSize = winEnd - winStart + 1;
- memory_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(vrc4373_device::target2_r), this));
- memory_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(vrc4373_device::target2_w), this));
- if (LOG_NILE)
- logerror("%s: map_extra Target Window 2 start=%08X end=%08X size=%08X laddr=%08X\n", tag(), winStart, winEnd, winSize, m_target2_laddr);
- }
-}
-
-void vrc4373_device::reset_all_mappings()
-{
- pci_device::reset_all_mappings();
-}
-
-void vrc4373_device::set_cpu_tag(const char *_cpu_tag)
-{
- if (LOG_NILE)
- logerror("%s: set_cpu_tag\n", tag());
- cpu_tag = _cpu_tag;
-}
-// PCI bus control
-READ32_MEMBER (vrc4373_device::pcictrl_r)
-{
- UINT32 result = 0;
- if (LOG_NILE)
- logerror("%06X:nile pcictrl_r from offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, result, mem_mask);
- return result;
-}
-WRITE32_MEMBER (vrc4373_device::pcictrl_w)
-{
- if (LOG_NILE)
- logerror("%06X:nile pcictrl_w to offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
-}
-// PCI Master Window 1
-READ32_MEMBER (vrc4373_device::master1_r)
-{
- UINT32 result = this->space(AS_DATA).read_dword(m_pci1_laddr | (offset*4), mem_mask);
- if (LOG_NILE_MASTER)
- logerror("%06X:nile master1 read from offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, result, mem_mask);
- return result;
-}
-WRITE32_MEMBER (vrc4373_device::master1_w)
-{
- this->space(AS_DATA).write_dword(m_pci1_laddr | (offset*4), data, mem_mask);
- if (LOG_NILE_MASTER)
- logerror("%06X:nile master1 write to offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
-}
-
-// PCI Master Window 2
-READ32_MEMBER (vrc4373_device::master2_r)
-{
- UINT32 result = this->space(AS_DATA).read_dword(m_pci2_laddr | (offset*4), mem_mask);
- if (LOG_NILE_MASTER)
- logerror("%06X:nile master2 read from offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, result, mem_mask);
- return result;
-}
-WRITE32_MEMBER (vrc4373_device::master2_w)
-{
- this->space(AS_DATA).write_dword(m_pci2_laddr | (offset*4), data, mem_mask);
- if (LOG_NILE_MASTER)
- logerror("%06X:nile master2 write to offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
-}
-
-// PCI Master IO Window
-READ32_MEMBER (vrc4373_device::master_io_r)
-{
- UINT32 result = this->space(AS_IO).read_dword(m_pci_io_laddr | (offset*4), mem_mask);
- if (LOG_NILE_MASTER)
- logerror("%06X:nile master io read from offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, result, mem_mask);
- return result;
-}
-WRITE32_MEMBER (vrc4373_device::master_io_w)
-{
- this->space(AS_IO).write_dword(m_pci_io_laddr | (offset*4), data, mem_mask);
- if (LOG_NILE_MASTER)
- logerror("%06X:nile master io write to offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
-}
-
-// PCI Target Window 1
-READ32_MEMBER (vrc4373_device::target1_r)
-{
- UINT32 result = m_cpu->space(AS_PROGRAM).read_dword(m_target1_laddr | (offset*4), mem_mask);
- if (LOG_NILE_TARGET)
- logerror("%08X:nile target1 read from offset %02X = %08X & %08X\n", m_cpu->device_t::safe_pc(), offset*4, result, mem_mask);
- return result;
-}
-WRITE32_MEMBER (vrc4373_device::target1_w)
-{
- m_cpu->space(AS_PROGRAM).write_dword(m_target1_laddr | (offset*4), data, mem_mask);
- if (LOG_NILE_TARGET)
- logerror("%08X:nile target1 write to offset %02X = %08X & %08X\n", m_cpu->device_t::safe_pc(), offset*4, data, mem_mask);
-}
-
-// PCI Target Window 2
-READ32_MEMBER (vrc4373_device::target2_r)
-{
- UINT32 result = m_cpu->space(AS_PROGRAM).read_dword(m_target2_laddr | (offset*4), mem_mask);
- if (LOG_NILE_TARGET)
- logerror("%08X:nile target2 read from offset %02X = %08X & %08X\n", m_cpu->device_t::safe_pc(), offset*4, result, mem_mask);
- return result;
-}
-WRITE32_MEMBER (vrc4373_device::target2_w)
-{
- m_cpu->space(AS_PROGRAM).write_dword(m_target2_laddr | (offset*4), data, mem_mask);
- if (LOG_NILE_TARGET)
- logerror("%08X:nile target2 write to offset %02X = %08X & %08X\n", m_cpu->device_t::safe_pc(), offset*4, data, mem_mask);
-}
-
-// DMA Transfer
-void vrc4373_device::dma_transfer(int which)
-{
- if (LOG_NILE)
- logerror("%08X:nile Start dma PCI: %08X MEM: %08X Words: %X\n", m_cpu->space(AS_PROGRAM).device().safe_pc(), m_cpu_regs[NREG_DMA_CPAR], m_cpu_regs[NREG_DMA_CMAR], m_cpu_regs[NREG_DMA_REM]);
- int pciSel = (m_cpu_regs[NREG_DMACR1+which*0xC] & DMA_MIO) ? AS_DATA : AS_IO;
- address_space *src, *dst;
- UINT32 srcAddr, dstAddr;
-
- if (m_cpu_regs[NREG_DMACR1+which*0xC]&DMA_RW) {
- // Read data from PCI and write to cpu
- src = &this->space(pciSel);
- dst = &m_cpu->space(AS_PROGRAM);
- srcAddr = m_cpu_regs[NREG_DMA_CPAR];
- dstAddr = m_cpu_regs[NREG_DMA_CMAR];
- } else {
- // Read data from cpu and write to PCI
- src = &m_cpu->space(AS_PROGRAM);
- dst = &this->space(pciSel);
- srcAddr = m_cpu_regs[NREG_DMA_CMAR];
- dstAddr = m_cpu_regs[NREG_DMA_CPAR];
- }
- int count = m_cpu_regs[NREG_DMA_REM];
- while (count>0) {
- dst->write_dword(dstAddr, src->read_dword(srcAddr));
- dstAddr += 0x4;
- srcAddr += 0x4;
- --count;
- }
- if (m_cpu_regs[NREG_DMACR1+which*0xC]&DMA_RW) {
- m_cpu_regs[NREG_DMA_CPAR] = srcAddr;
- m_cpu_regs[NREG_DMA_CMAR] = dstAddr;
- } else {
- m_cpu_regs[NREG_DMA_CMAR] = srcAddr;
- m_cpu_regs[NREG_DMA_CPAR] = dstAddr;
- }
- m_cpu_regs[NREG_DMA_REM] = 0;
-}
-
-// CPU I/F
-READ32_MEMBER (vrc4373_device::cpu_if_r)
-{
- UINT32 result = m_cpu_regs[offset];
- switch (offset) {
- case NREG_PCICAR:
- result = config_address_r(space, offset);
- break;
- case NREG_PCICDR:
- result = config_data_r(space, offset);
- break;
- case NREG_DMACR1:
- case NREG_DMACR2:
- // Clear busy and go on read
- if (m_cpu_regs[NREG_DMA_REM]==0) {
- int which = (offset-NREG_DMACR1)>>3;
- m_cpu_regs[NREG_DMACR1+which*0xc] &= ~DMA_BUSY;
- m_cpu_regs[NREG_DMACR1+which*0xc] &= ~DMA_GO;
- }
- break;
- default:
- break;
- }
- if (LOG_NILE)
- logerror("%06X:nile read from offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, result, mem_mask);
- return result;
-}
-
-WRITE32_MEMBER(vrc4373_device::cpu_if_w)
-{
- if (LOG_NILE)
- logerror("%06X:nile write to offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
-
- UINT32 modData, oldData;
- oldData = m_cpu_regs[offset];
- COMBINE_DATA(&m_cpu_regs[offset]);
- switch (offset) {
- case NREG_PCIMW1:
- m_pci1_laddr = (data&0xff)<<24;
- map_cpu_space();
- break;
- case NREG_PCIMW2:
- m_pci2_laddr = (data&0xff)<<24;
- map_cpu_space();
- break;
- case NREG_PCIMIOW:
- m_pci_io_laddr = (data&0xff)<<24;
- map_cpu_space();
- break;
- case NREG_PCITW1:
- m_target1_laddr = 0x00000000 | ((data&0x7FF)<<21);
- remap_cb();
- break;
- case NREG_PCITW2:
- m_target2_laddr = 0x00000000 | ((data&0x7FF)<<21);
- remap_cb();
- break;
- case NREG_PCICAR:
- // Bits in reserved area are used for device selection of type 0 config transactions
- // Assuming 23:11 get mapped into device number for configuration
- if ((data&0x3) == 0x0) {
- // Type 0 transaction
- modData = 0;
- // Select the device based on one hot bit
- for (int i=11; i<24; i++) {
- if ((data>>i)&0x1) {
- // One hot encoding, bit 11 will mean device 1
- modData = i-10;
- break;
- }
- }
- // Re-organize into Type 1 transaction for bus 0 (local bus)
- modData = (modData<<11) | (data&0x7ff) | (0x80000000);
- } else {
- // Type 1 transaction, no modification needed
- modData = data;
- }
- pci_host_device::config_address_w(space, offset, modData);
- break;
- case NREG_PCICDR:
- pci_host_device::config_data_w(space, offset, data);
- break;
- case NREG_DMACR1:
- case NREG_DMACR2:
- // Start when DMA_GO bit is set
- if (!(oldData & DMA_GO) && (data & DMA_GO)) {
- int which = (offset-NREG_DMACR1)>>3;
- // Check to see DMA is not already started
- if (!(data&DMA_BUSY)) {
- // Set counts and address
- m_cpu_regs[NREG_DMA_CPAR] = m_cpu_regs[NREG_DMAPCI1+which*0xC];
- m_cpu_regs[NREG_DMA_CMAR] = m_cpu_regs[NREG_DMAMAR1+which*0xC];
- m_cpu_regs[NREG_DMA_REM] = (data & DMA_BLK_SIZE)>>2;
- m_cpu_regs[NREG_DMACR1+which*0xc] |= DMA_BUSY;
- // Start the transfer
- dma_transfer(which);
- }
- }
- break;
- case NREG_BMCR:
- if ((data>>3)&0x1) {
- m_ram_size = 1<<22; // 4MB
- for (int i=14; i<=15; i++) {
- if (!((data>>i)&0x1)) m_ram_size<<=1;
- else break;
- }
- m_ram.resize(m_ram_size/4);
- m_ram_base = (data & 0x0fc00000);
- }
- map_cpu_space();
- break;
- case NREG_SIMM1:
- if ((data>>3)&0x1) {
- m_simm_size = 1<<21; // 2MB
- for (int i=13; i<=17; i++) {
- if (!((data>>i)&0x1)) m_simm_size<<=1;
- else break;
- }
- m_simm.resize(m_simm_size/4);
- m_simm_base = (data & 0x0fe00000);
- }
- map_cpu_space();
- break;
- default:
- break;
- }
-
-}
diff --git a/src/emu/machine/vrc4373.h b/src/emu/machine/vrc4373.h
deleted file mode 100644
index 31439b58537..00000000000
--- a/src/emu/machine/vrc4373.h
+++ /dev/null
@@ -1,132 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Ted Green
-// NEC VRC 4373 System Controller
-
-#ifndef VRC4373_H
-#define VRC4373_H
-
-#include "pci.h"
-#include "cpu/mips/mips3.h"
-
-#define MCFG_VRC4373_ADD(_tag, _cpu_tag) \
- MCFG_PCI_HOST_ADD(_tag, VRC4373, 0x005B1033, 0x00, 0x00000000) \
- downcast<vrc4373_device *>(device)->set_cpu_tag(_cpu_tag);
-
-#define VRC4373_PAGESHIFT 12
-
-/* NILE 3 registers 0x000-0x0ff */
-#define NREG_BMCR (0x000/4)
-#define NREG_SIMM1 (0x004/4)
-#define NREG_SIMM2 (0x008/4)
-#define NREG_SIMM3 (0x00C/4)
-#define NREG_SIMM4 (0x010/4)
-#define NREG_PCIMW1 (0x014/4)
-#define NREG_PCIMW2 (0x018/4)
-#define NREG_PCITW1 (0x01C/4)
-#define NREG_PCITW2 (0x020/4)
-#define NREG_PCIMIOW (0x024/4)
-#define NREG_PCICDR (0x028/4)
-#define NREG_PCICAR (0x02C/4)
-#define NREG_PCIMB1 (0x030/4)
-#define NREG_PCIMB2 (0x034/4)
-#define NREG_DMACR1 (0x038/4)
-#define NREG_DMAMAR1 (0x03C/4)
-#define NREG_DMAPCI1 (0x040/4)
-#define NREG_DMACR2 (0x044/4)
-#define NREG_DMAMAR2 (0x048/4)
-#define NREG_DMAPCI2 (0x04C/4)
-
-#define NREG_BESR (0x050/4)
-#define NREG_ICSR (0x054/4)
-#define NREG_DRAMRCR (0x058/4)
-#define NREG_BOOTWP (0x05C/4)
-#define NREG_PCIEAR (0x060/4)
-#define NREG_DMA_REM (0x064/4)
-#define NREG_DMA_CMAR (0x068/4)
-#define NREG_DMA_CPAR (0x06C/4)
-#define NREG_PCIRC (0x070/4)
-#define NREG_PCIEN (0x074/4)
-#define NREG_PMIR (0x078/4)
-
-#define DMA_BUSY 0x80000000
-#define DMA_INT_EN 0x40000000
-#define DMA_RW 0x20000000
-#define DMA_GO 0x10000000
-#define DMA_SUS 0x08000000
-#define DMA_INC 0x04000000
-#define DMA_MIO 0x02000000
-#define DMA_RST 0x01000000
-#define DMA_BLK_SIZE 0x000fffff
-
-
-class vrc4373_device : public pci_host_device {
-public:
- vrc4373_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual void reset_all_mappings();
- virtual void map_extra(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
- UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space);
-
- void set_cpu_tag(const char *tag);
-
- virtual DECLARE_ADDRESS_MAP(config_map, 32);
-
- DECLARE_READ32_MEMBER( pcictrl_r);
- DECLARE_WRITE32_MEMBER( pcictrl_w);
- //cpu bus registers
- DECLARE_READ32_MEMBER (cpu_if_r);
- DECLARE_WRITE32_MEMBER(cpu_if_w);
-
- DECLARE_READ32_MEMBER (master1_r);
- DECLARE_WRITE32_MEMBER(master1_w);
-
- DECLARE_READ32_MEMBER (master2_r);
- DECLARE_WRITE32_MEMBER(master2_w);
-
- DECLARE_READ32_MEMBER (master_io_r);
- DECLARE_WRITE32_MEMBER(master_io_w);
-
- virtual DECLARE_ADDRESS_MAP(target1_map, 32);
- DECLARE_READ32_MEMBER (target1_r);
- DECLARE_WRITE32_MEMBER(target1_w);
-
- virtual DECLARE_ADDRESS_MAP(target2_map, 32);
- DECLARE_READ32_MEMBER (target2_r);
- DECLARE_WRITE32_MEMBER(target2_w);
-
-protected:
- address_space *m_cpu_space;
- virtual const address_space_config *memory_space_config(address_spacenum spacenum) const;
- virtual void device_start();
- virtual void device_reset();
- void dma_transfer(int which);
-
-private:
- mips3_device *m_cpu;
- const char *cpu_tag;
-
- address_space_config m_mem_config, m_io_config;
-
- DECLARE_ADDRESS_MAP(cpu_map, 32);
-
- void map_cpu_space();
-
- UINT32 m_ram_size;
- UINT32 m_ram_base;
- std::vector<UINT32> m_ram;
-
- UINT32 m_simm_size;
- UINT32 m_simm_base;
- std::vector<UINT32> m_simm;
-
- UINT32 m_cpu_regs[0x7c];
-
- UINT32 m_pci1_laddr, m_pci2_laddr, m_pci_io_laddr;
- UINT32 m_target1_laddr, m_target2_laddr;
-
-};
-
-
-extern const device_type VRC4373;
-
-#endif
diff --git a/src/emu/machine/vt83c461.c b/src/emu/machine/vt83c461.c
deleted file mode 100644
index 1957b848c9b..00000000000
--- a/src/emu/machine/vt83c461.c
+++ /dev/null
@@ -1,105 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-#include "vt83c461.h"
-
-/***************************************************************************
- DEBUGGING
-***************************************************************************/
-
-#define VERBOSE 0
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-
-#define VT83C461_CONFIG_UNK 1
-#define VT83C461_CONFIG_REGISTER 2
-#define VT83C461_CONFIG_DATA 3
-
-
-const device_type VT83C461 = &device_creator<vt83c461_device>;
-
-vt83c461_device::vt83c461_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- ide_controller_32_device(mconfig, VT83C461, "VIA VT83C461", tag, owner, clock, "vt83c461", __FILE__),
- m_config_unknown(0),
- m_config_register_num(0)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void vt83c461_device::device_start()
-{
- ide_controller_32_device::device_start();
-
- /* register ide states */
- save_item(NAME(m_config_unknown));
- save_item(NAME(m_config_register));
- save_item(NAME(m_config_register_num));
-}
-
-READ32_MEMBER( vt83c461_device::read_config )
-{
- UINT32 result = 0;
-
- /* logit */
- LOG(("%s:IDE via config read at %X, mem_mask=%d\n", machine().describe_context(), offset, mem_mask));
-
- switch(offset)
- {
- /* unknown config register */
- case VT83C461_CONFIG_UNK:
- result = m_config_unknown;
- break;
-
- /* active config register */
- case VT83C461_CONFIG_REGISTER:
- result = m_config_register_num;
- break;
-
- /* data from active config register */
- case VT83C461_CONFIG_DATA:
- if (m_config_register_num < IDE_CONFIG_REGISTERS)
- result = m_config_register[m_config_register_num];
- break;
-
- default:
- logerror("%s:unknown IDE via config read at %03X, mem_mask=%d\n", machine().describe_context(), offset, mem_mask);
- break;
- }
-
-// printf( "vt83c461 read config %04x %08x %04x\n", offset, result, mem_mask );
- return result;
-}
-
-WRITE32_MEMBER( vt83c461_device::write_config )
-{
-// printf( "vt83c461 write config %04x %08x %04x\n", offset, data, mem_mask );
-
- /* logit */
- LOG(("%s:IDE via config write to %X = %08X, mem_mask=%d\n", machine().describe_context(), offset, data, mem_mask));
-
- switch (offset)
- {
- /* unknown config register */
- case VT83C461_CONFIG_UNK:
- m_config_unknown = data;
- break;
-
- /* active config register */
- case VT83C461_CONFIG_REGISTER:
- m_config_register_num = data;
- break;
-
- /* data from active config register */
- case VT83C461_CONFIG_DATA:
- if (m_config_register_num < IDE_CONFIG_REGISTERS)
- m_config_register[m_config_register_num] = data;
- break;
-
- default:
- logerror("%s:unknown IDE via config write at %03X = %08x, mem_mask=%d\n", machine().describe_context(), offset, data, mem_mask);
- break;
- }
-}
diff --git a/src/emu/machine/vt83c461.h b/src/emu/machine/vt83c461.h
deleted file mode 100644
index 18e737ed29b..00000000000
--- a/src/emu/machine/vt83c461.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/***************************************************************************
-
- vt83c461.h
-
- VIA VT83C461 (IDE Hard Drive controller).
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __VT83C461_H__
-#define __VT83C461_H__
-
-#include "idectrl.h"
-
-/***************************************************************************
- DEVICE CONFIGURATION MACROS
-***************************************************************************/
-
-#define MCFG_VT83C461_ADD(_tag, _slot_intf, _master, _slave, _fixed) \
- MCFG_DEVICE_ADD(_tag, VT83C461, 0) \
- MCFG_DEVICE_MODIFY(_tag ":0") \
- MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _master, _fixed) \
- MCFG_DEVICE_MODIFY(_tag ":1") \
- MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _slave, _fixed) \
- MCFG_DEVICE_MODIFY(_tag)
-
-#define IDE_CONFIG_REGISTERS 0x10
-
-class vt83c461_device : public ide_controller_32_device
-{
-public:
- vt83c461_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ32_MEMBER(read_config);
- DECLARE_WRITE32_MEMBER(write_config);
-
-protected:
- virtual void device_start();
-
-private:
- UINT8 m_config_unknown;
- UINT8 m_config_register[IDE_CONFIG_REGISTERS];
- UINT8 m_config_register_num;
-};
-
-extern const device_type VT83C461;
-
-#endif
diff --git a/src/emu/machine/wd11c00_17.c b/src/emu/machine/wd11c00_17.c
deleted file mode 100644
index 0f38c32c624..00000000000
--- a/src/emu/machine/wd11c00_17.c
+++ /dev/null
@@ -1,474 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Western Digital WD11C00-17 PC/XT Host Interface Logic Device
-
-**********************************************************************/
-
-#include "machine/wd11c00_17.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 1
-
-
-// status register
-#define STATUS_IRQ 0x20
-#define STATUS_DRQ 0x10
-#define STATUS_BUSY 0x08
-#define STATUS_C_D 0x04
-#define STATUS_I_O 0x02
-#define STATUS_REQ 0x01
-
-
-// mask register
-#define MASK_IRQ 0x02
-#define MASK_DMA 0x01
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type WD11C00_17 = &device_creator<wd11c00_17_device>;
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// check_interrupt -
-//-------------------------------------------------
-
-inline void wd11c00_17_device::check_interrupt()
-{
- if (BIT(m_ra, 10))
- {
- m_status &= ~STATUS_DRQ;
- }
-
- int ra3 = BIT(m_ra, 3);
-
- if (m_ra3 != ra3)
- {
- m_out_ra3_cb(ra3 ? ASSERT_LINE : CLEAR_LINE);
- m_ra3 = ra3;
- }
-
- int irq5 = ((m_status & STATUS_IRQ) && (m_mask & MASK_IRQ)) ? ASSERT_LINE : CLEAR_LINE;
-
- if (m_irq5 != irq5)
- {
- m_out_irq5_cb(irq5);
- m_irq5 = irq5;
- }
-
- int drq3 = ((m_status & STATUS_DRQ) && (m_mask & MASK_DMA)) ? ASSERT_LINE : CLEAR_LINE;
-
- if (m_drq3 != drq3)
- {
- m_out_drq3_cb(drq3);
- m_drq3 = drq3;
- }
-
- int busy = (m_status & STATUS_BUSY) ? 0 : 1;
-
- if (m_busy != busy)
- {
- m_out_busy_cb(busy);
- m_busy = busy;
- }
-
- int req = (m_status & STATUS_REQ) ? 1 : 0;
-
- if (m_req != req)
- {
- m_out_req_cb(req);
- m_req = req;
- }
-}
-
-
-//-------------------------------------------------
-// increment_address -
-//-------------------------------------------------
-
-inline void wd11c00_17_device::increment_address()
-{
- m_ra++;
- check_interrupt();
-}
-
-
-//-------------------------------------------------
-// read_data -
-//-------------------------------------------------
-
-inline UINT8 wd11c00_17_device::read_data()
-{
- UINT8 data = 0;
-
- if (m_status & STATUS_BUSY)
- {
- data = m_in_ramcs_cb(m_ra & 0x7ff);
-
- increment_address();
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write_data -
-//-------------------------------------------------
-
-inline void wd11c00_17_device::write_data(UINT8 data)
-{
- if (m_status & STATUS_BUSY)
- {
- m_out_ramwr_cb(m_ra & 0x7ff, data);
-
- increment_address();
- }
-}
-
-
-//-------------------------------------------------
-// software_reset -
-//-------------------------------------------------
-
-inline void wd11c00_17_device::software_reset()
-{
- m_out_mr_cb(ASSERT_LINE);
- m_out_mr_cb(CLEAR_LINE);
-
- device_reset();
-}
-
-
-//-------------------------------------------------
-// select -
-//-------------------------------------------------
-
-inline void wd11c00_17_device::select()
-{
- m_status = STATUS_BUSY | STATUS_C_D | STATUS_REQ;
-
- check_interrupt();
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// wd11c00_17_device - constructor
-//-------------------------------------------------
-
-wd11c00_17_device::wd11c00_17_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, WD11C00_17, "Western Digital WD11C00-17", tag, owner, clock, "wd11c00_17", __FILE__),
- m_out_irq5_cb(*this),
- m_out_drq3_cb(*this),
- m_out_mr_cb(*this),
- m_out_busy_cb(*this),
- m_out_req_cb(*this),
- m_out_ra3_cb(*this),
- m_in_rd322_cb(*this),
- m_in_ramcs_cb(*this),
- m_out_ramwr_cb(*this),
- m_in_cs1010_cb(*this),
- m_out_cs1010_cb(*this),
- m_status(0),
- m_ra(0),
- m_irq5(CLEAR_LINE),
- m_drq3(CLEAR_LINE),
- m_busy(1),
- m_req(0),
- m_ra3(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void wd11c00_17_device::device_start()
-{
- // resolve callbacks
- m_out_irq5_cb.resolve_safe();
- m_out_drq3_cb.resolve_safe();
- m_out_mr_cb.resolve_safe();
- m_out_busy_cb.resolve_safe();
- m_out_req_cb.resolve_safe();
- m_out_ra3_cb.resolve_safe();
- m_in_rd322_cb.resolve_safe(0);
- m_in_ramcs_cb.resolve_safe(0);
- m_out_ramwr_cb.resolve_safe();
- m_in_cs1010_cb.resolve_safe(0);
- m_out_cs1010_cb.resolve_safe();
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void wd11c00_17_device::device_reset()
-{
- m_status &= ~(STATUS_IRQ | STATUS_DRQ | STATUS_BUSY);
- m_mask = 0;
- m_ra = 0;
-
- check_interrupt();
-}
-
-
-//-------------------------------------------------
-// io_r -
-//-------------------------------------------------
-
-READ8_MEMBER( wd11c00_17_device::io_r )
-{
- UINT8 data = 0xff;
-
- switch (offset)
- {
- case 0: // Read Data, Board to Host
- if (LOG) logerror("%s WD11C00-17 '%s' Read Data %03x:", machine().describe_context(), tag(), m_ra);
- data = read_data();
- if (LOG) logerror("%02x\n", data);
- break;
-
- case 1: // Read Board Hardware Status
- data = m_status;
- check_interrupt();
- break;
-
- case 2: // Read Drive Configuration Information
- data = m_in_rd322_cb(0);
- break;
-
- case 3: // Not Used
- break;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// io_w -
-//-------------------------------------------------
-
-WRITE8_MEMBER( wd11c00_17_device::io_w )
-{
- switch (offset)
- {
- case 0: // Write Data, Host to Board
- if (LOG) logerror("%s WD11C00-17 '%s' Write Data %03x:%02x\n", machine().describe_context(), tag(), m_ra, data);
- write_data(data);
- break;
-
- case 1: // Board Software Reset
- if (LOG) logerror("%s WD11C00-17 '%s' Software Reset\n", machine().describe_context(), tag());
- software_reset();
- break;
-
- case 2: // Board Select
- if (LOG) logerror("%s WD11C00-17 '%s' Select\n", machine().describe_context(), tag());
- increment_address(); // HACK
- select();
- break;
-
- case 3: // Set/Reset DMA, IRQ Masks
- if (LOG) logerror("%s WD11C00-17 '%s' Mask IRQ %u DMA %u\n", machine().describe_context(), tag(), BIT(data, 1), BIT(data, 0));
- m_mask = data;
- check_interrupt();
- break;
- }
-}
-
-
-//-------------------------------------------------
-// dack_r -
-//-------------------------------------------------
-
-UINT8 wd11c00_17_device::dack_r()
-{
- return read_data();
-}
-
-
-//-------------------------------------------------
-// dack_w -
-//-------------------------------------------------
-
-void wd11c00_17_device::dack_w(UINT8 data)
-{
- write_data(data);
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER( wd11c00_17_device::read )
-{
- UINT8 data = 0;
-
- switch (offset)
- {
- case 0x00:
- if (LOG) logerror("%s WD11C00-17 '%s' Read RAM %03x:", machine().describe_context(), tag(), m_ra);
- data = read_data();
- if (LOG) logerror("%02x\n", data);
- break;
-
- case 0x20:
- data = m_in_cs1010_cb(m_ra >> 8);
- break;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER( wd11c00_17_device::write )
-{
- switch (offset)
- {
- case 0x00:
- if (LOG) logerror("%s WD11C00-17 '%s' Write RAM %03x:%02x\n", machine().describe_context(), tag(), m_ra, data);
- write_data(data);
- if (m_ra > 0x400) m_ecc_not_0 = 0; // HACK
- break;
-
- case 0x20:
- m_out_cs1010_cb(m_ra >> 8, data);
- break;
-
- case 0x60:
- m_ra = (data & 0x07) << 8;
- if (LOG) logerror("%s WD11C00-17 '%s' RA %03x\n", machine().describe_context(), tag(), m_ra);
- check_interrupt();
- break;
- }
-}
-
-
-//-------------------------------------------------
-// ireq_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( wd11c00_17_device::ireq_w )
-{
- if (LOG) logerror("%s WD11C00-17 '%s' IREQ %u\n", machine().describe_context(), tag(), state);
-
- if (state) m_status |= STATUS_REQ; else m_status &= ~STATUS_REQ;
-
- if (m_status & STATUS_BUSY)
- {
- if (state)
- {
- m_status |= STATUS_IRQ | STATUS_I_O;
- }
- else
- {
- if (m_status & STATUS_I_O)
- {
- m_status &= ~(STATUS_BUSY | STATUS_I_O);
- }
- }
- }
-
- check_interrupt();
-}
-
-
-//-------------------------------------------------
-// io_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( wd11c00_17_device::io_w )
-{
- if (LOG) logerror("%s WD11C00-17 '%s' I/O %u\n", machine().describe_context(), tag(), state);
-
- if (state) m_status |= STATUS_I_O; else m_status &= ~STATUS_I_O;
-}
-
-
-//-------------------------------------------------
-// cd_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( wd11c00_17_device::cd_w )
-{
- if (LOG) logerror("%s WD11C00-17 '%s' C/D %u\n", machine().describe_context(), tag(), state);
-
- if (state) m_status |= STATUS_C_D; else m_status &= ~STATUS_C_D;
-}
-
-
-//-------------------------------------------------
-// clct_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( wd11c00_17_device::clct_w )
-{
- if (LOG) logerror("%s WD11C00-17 '%s' CLCT %u\n", machine().describe_context(), tag(), state);
-
- if (state)
- {
- m_ra &= 0xff00;
- check_interrupt();
- }
-}
-
-
-//-------------------------------------------------
-// mode_w -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( wd11c00_17_device::mode_w )
-{
- if (LOG) logerror("%s WD11C00-17 '%s' MODE %u\n", machine().describe_context(), tag(), state);
-
- m_mode = state;
- m_ecc_not_0 = state; // HACK
-}
-
-
-//-------------------------------------------------
-// busy_r -
-//-------------------------------------------------
-
-READ_LINE_MEMBER( wd11c00_17_device::busy_r )
-{
- return (m_status & STATUS_BUSY) ? 0 : 1;
-}
-
-
-//-------------------------------------------------
-// ecc_not_0_r -
-//-------------------------------------------------
-
-READ_LINE_MEMBER( wd11c00_17_device::ecc_not_0_r )
-{
- return m_ecc_not_0;
-}
diff --git a/src/emu/machine/wd11c00_17.h b/src/emu/machine/wd11c00_17.h
deleted file mode 100644
index adc8a9f2c64..00000000000
--- a/src/emu/machine/wd11c00_17.h
+++ /dev/null
@@ -1,142 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Western Digital WD11C00-17 PC/XT Host Interface Logic Device
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __WD11C00_17__
-#define __WD11C00_17__
-
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_WD11C00_17_OUT_IRQ5_CB(_devcb) \
- devcb = &wd11c00_17_device::set_out_irq5_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD11C00_17_OUT_DRQ3_CB(_devcb) \
- devcb = &wd11c00_17_device::set_out_drq3_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD11C00_17_OUT_MR_CB(_devcb) \
- devcb = &wd11c00_17_device::set_out_mr_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD11C00_17_OUT_BUSY_CB(_devcb) \
- devcb = &wd11c00_17_device::set_out_busy_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD11C00_17_OUT_REQ_CB(_devcb) \
- devcb = &wd11c00_17_device::set_out_req_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD11C00_17_OUT_RA3_CB(_devcb) \
- devcb = &wd11c00_17_device::set_out_ra3_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD11C00_17_IN_RD322_CB(_devcb) \
- devcb = &wd11c00_17_device::set_in_rd322_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD11C00_17_IN_RAMCS_CB(_devcb) \
- devcb = &wd11c00_17_device::set_in_ramcs_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD11C00_17_OUT_RAMWR_CB(_devcb) \
- devcb = &wd11c00_17_device::set_out_ramwr_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD11C00_17_IN_CS1010_CB(_devcb) \
- devcb = &wd11c00_17_device::set_in_cs1010_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD11C00_17_OUT_CS1010_CB(_devcb) \
- devcb = &wd11c00_17_device::set_out_cs1010_callback(*device, DEVCB_##_devcb);
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> wd11c00_17_device
-
-class wd11c00_17_device : public device_t
-{
-public:
- // construction/destruction
- wd11c00_17_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_irq5_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_out_irq5_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_drq3_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_out_drq3_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_mr_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_out_mr_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_busy_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_out_busy_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_req_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_out_req_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_ra3_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_out_ra3_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_rd322_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_in_rd322_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_ramcs_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_in_ramcs_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_ramwr_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_out_ramwr_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_cs1010_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_in_cs1010_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_cs1010_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_out_cs1010_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( io_r );
- DECLARE_WRITE8_MEMBER( io_w );
-
- UINT8 dack_r();
- void dack_w(UINT8 data);
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( ireq_w );
- DECLARE_WRITE_LINE_MEMBER( io_w );
- DECLARE_WRITE_LINE_MEMBER( cd_w );
- DECLARE_WRITE_LINE_MEMBER( clct_w );
- DECLARE_WRITE_LINE_MEMBER( mode_w );
-
- DECLARE_READ_LINE_MEMBER( busy_r );
- DECLARE_READ_LINE_MEMBER( ecc_not_0_r );
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- inline void check_interrupt();
- inline void increment_address();
- inline UINT8 read_data();
- inline void write_data(UINT8 data);
- inline void software_reset();
- inline void select();
-
- devcb_write_line m_out_irq5_cb;
- devcb_write_line m_out_drq3_cb;
- devcb_write_line m_out_mr_cb;
- devcb_write_line m_out_busy_cb;
- devcb_write_line m_out_req_cb;
- devcb_write_line m_out_ra3_cb;
- devcb_read8 m_in_rd322_cb;
- devcb_read8 m_in_ramcs_cb;
- devcb_write8 m_out_ramwr_cb;
- devcb_read8 m_in_cs1010_cb;
- devcb_write8 m_out_cs1010_cb;
-
- UINT8 m_status;
- UINT8 m_mask;
-
- offs_t m_ra;
-
- int m_mode;
- int m_ecc_not_0;
-
- int m_irq5;
- int m_drq3;
- int m_busy;
- int m_req;
- int m_ra3;
-};
-
-
-// device type definition
-extern const device_type WD11C00_17;
-
-#endif
diff --git a/src/emu/machine/wd2010.c b/src/emu/machine/wd2010.c
deleted file mode 100644
index 6f50622ec79..00000000000
--- a/src/emu/machine/wd2010.c
+++ /dev/null
@@ -1,989 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
-Western Digital WD2010 Winchester Disk Controller
-
-Portions (2015) : Karl-Ludwig Deisenhofer
-**********************************************************************
-
-Implements WD2010 / WD1010 controller basics.
-
- Provides IRQ / (B)DRQ signals needed for early MFM cards.
- Honors DRIVE_READY and WRITE FAULT (DRDY / WF).
-
- Single sector read / write (format) confirmed to work with
- Rainbow-100 controller (WD1010, largely compatible to WD2010, see **)
-
- LIST OF UNIMPLEMENTED FEATURES :
- - MULTI SECTOR TRANSFERS (M = 1); MULTIPLE DRIVES
- - AUTO_SCAN_ID / SEEK + INDEX TIMERS / ID NOT FOUND
- - IMPLIED SEEKS / IMPLIED WRITES / RETRIES
- - EDGE or LEVEL TRIGGERED SEEK_COMPLETE (SC)
- - SET_PARAMETER / COMPUTE_CORRECTION (DWC flag!)
-
- Pseudo code (from datasheet) left in to illustrate
- the intended instruction flow. Some loops were omitted!
-
- USAGE: tie WF (write fault) to ground if not needed:
- MCFG_WD2010_IN_WF_CB(GND)
-
- Other signals should be set to VCC if not serviced:
- MCFG_WD2010_IN_DRDY_CB(VCC) // DRIVE READY = VCC
- MCFG_WD2010_IN_SC_CB(VCC) // SEEK COMPLETE = VCC
- **********************************************************************/
-
-// WD 2010 CONFIGURATION (2048 cylinder limit)
-#define STEP_LIMIT 2048
-#define CYLINDER_HIGH_MASK 0x07
-
-// DEC RD51 chip; different STEP / CYLINDER LIMIT (**):
-
-// WD 1010 CONFIGURATION (1024 cylinder limit)
-// #define STEP_LIMIT 1024
-// #define CYLINDER_HIGH_MASK 0x03
-
-// --------------------------------------------------------
-#define MAX_MFM_SECTORS 17 // STANDARD MFM SECTORS/TRACK
-// --------------------------------------------------------
-
-
-#include "machine/wd2010.h"
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 1
-
-// task file
-enum
-{
- TASK_FILE_ERROR = 1,
- TASK_FILE_WRITE_PRECOMP_CYLINDER = TASK_FILE_ERROR,
- TASK_FILE_SECTOR_COUNT,
- TASK_FILE_SECTOR_NUMBER,
- TASK_FILE_CYLINDER_LOW,
- TASK_FILE_CYLINDER_HIGH,
- TASK_FILE_SDH_REGISTER,
- TASK_FILE_STATUS,
- TASK_FILE_COMMAND = TASK_FILE_STATUS
-};
-
-#define WRITE_PRECOMP_CYLINDER \
- (m_task_file[TASK_FILE_WRITE_PRECOMP_CYLINDER] * 4)
-
-#define SECTOR_COUNT \
- ((m_task_file[TASK_FILE_SECTOR_COUNT] + 1) * 256)
-
-#define SECTOR_NUMBER \
- (m_task_file[TASK_FILE_SECTOR_NUMBER])
-
-#define CYLINDER \
- (((m_task_file[TASK_FILE_CYLINDER_HIGH] & CYLINDER_HIGH_MASK) << 8) | m_task_file[TASK_FILE_CYLINDER_LOW])
-
-#define HEAD \
- (m_task_file[TASK_FILE_SDH_REGISTER] & 0x07)
-
-#define DRIVE \
- ((m_task_file[TASK_FILE_SDH_REGISTER] >> 3) & 0x03)
-
-static const int SECTOR_SIZES[4] = { 256, 512, 1024, 128 };
-
-#define SECTOR_SIZE \
- SECTOR_SIZES[(m_task_file[TASK_FILE_SDH_REGISTER] >> 5) & 0x03]
-
-// status register
-#define STATUS_BSY 0x80
-#define STATUS_RDY 0x40
-#define STATUS_WF 0x20
-#define STATUS_SC 0x10
-#define STATUS_DRQ 0x08
-#define STATUS_DWC 0x04
-#define STATUS_CIP 0x02
-#define STATUS_ERR 0x01
-
-
-// error register
-#define ERROR_BB 0x80
-#define ERROR_CRC_ECC 0x40
-#define ERROR_ID 0x10
-#define ERROR_AC 0x04
-#define ERROR_TK 0x02
-#define ERROR_DM 0x01
-
-
-// command register
-#define COMMAND_MASK 0xf0
-#define COMMAND_RESTORE 0x10
-#define COMMAND_SEEK 0x70
-#define COMMAND_READ_SECTOR 0x20
-#define COMMAND_WRITE_SECTOR 0x30
-#define COMMAND_SCAN_ID 0x40
-#define COMMAND_WRITE_FORMAT 0x50
-#define COMMAND_COMPUTE_CORRECTION 0x08
-#define COMMAND_SET_PARAMETER_MASK 0xfe
-#define COMMAND_SET_PARAMETER 0x00
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-const device_type WD2010 = &device_creator<wd2010_device>;
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// wd2010_device - constructor
-//-------------------------------------------------
-
-wd2010_device::wd2010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
-: device_t(mconfig, WD2010, "Western Digital WD2010", tag, owner, clock, "wd2010", __FILE__),
-m_out_intrq_cb(*this),
-m_out_bdrq_cb(*this),
-m_out_bcr_cb(*this),
-m_in_bcs_cb(*this),
-m_in_brdy_cb(*this),
-m_out_bcs_cb(*this),
-m_out_dirin_cb(*this),
-m_out_step_cb(*this),
-m_out_rwc_cb(*this),
-m_out_wg_cb(*this),
-m_in_drdy_cb(*this),
-m_in_index_cb(*this),
-m_in_wf_cb(*this),
-m_in_tk000_cb(*this),
-m_in_sc_cb(*this),
-m_status(0),
-m_error(0)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void wd2010_device::device_start()
-{
- // resolve callbacks
- m_out_intrq_cb.resolve_safe();
- m_out_bdrq_cb.resolve_safe();
- m_out_bcr_cb.resolve_safe();
- m_in_bcs_cb.resolve_safe(0);
-
- m_in_brdy_cb.resolve_safe(0);
-
- m_out_bcs_cb.resolve_safe();
- m_out_dirin_cb.resolve_safe();
- m_out_step_cb.resolve_safe();
- m_out_rwc_cb.resolve_safe();
- m_out_wg_cb.resolve_safe();
- m_in_drdy_cb.resolve_safe(0);
- m_in_index_cb.resolve_safe(0);
- m_in_wf_cb.resolve_safe(0);
- m_in_tk000_cb.resolve_safe(0);
- m_in_sc_cb.resolve_safe(0);
-
- /* allocate a timer for commands */
- cmd_timer = timer_alloc(0);
- complete_write_when_buffer_ready_high = timer_alloc(1);
- deassert_write_when_buffer_ready_low = timer_alloc(2);
- deassert_read_when_buffer_ready_high = timer_alloc(3);
-}
-
-// timers
-#define COMMAND_TIMER 0
-#define COMPLETE_WRITE_SECTOR 1
-#define DE_ASSERT_WRITE 2
-#define DE_ASSERT_READ 3
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void wd2010_device::device_reset()
-{
- m_out_intrq_cb(CLEAR_LINE);
-
- buffer_ready(false);
-
- m_present_cylinder = 0; // start somewhere
-}
-
-
-//-------------------------------------------------
-// read -
-//-------------------------------------------------
-
-READ8_MEMBER(wd2010_device::read)
-{
- UINT8 data = 0;
-
- switch (offset)
- {
- case TASK_FILE_ERROR:
- if (m_status & STATUS_CIP) // "if other registers are read while CIP, the status register contents are returned."
- data = (m_in_drdy_cb() ? 0x40 : 0) | (m_in_wf_cb() ? 0x20 : 0) | (m_in_sc_cb() ? 0x10 : 0) | m_status;// see STATUS register
- else
- data = m_error;
- break;
-
- case TASK_FILE_STATUS:
- m_out_intrq_cb(CLEAR_LINE); // "reading the status register clears INTRQ" (-> datasheet)
- data = (m_in_drdy_cb() ? 0x40 : 0) | (m_in_wf_cb() ? 0x20 : 0) | (m_in_sc_cb() ? 0x10 : 0) | m_status;// see ERROR register
- break;
-
- default:
- data = m_task_file[offset];
-
- if (offset == TASK_FILE_SDH_REGISTER)
- {
- logerror("(READ) %s WD2010 '%s' SDH: %u\n", machine().describe_context(), tag(), data);
- logerror("(READ) %s WD2010 '%s' Head: %u\n", machine().describe_context(), tag(), HEAD);
- logerror("(READ) %s WD2010 '%s' Drive: %u\n", machine().describe_context(), tag(), DRIVE);
- logerror("(READ) %s WD2010 '%s' Sector Size: %u\n", machine().describe_context(), tag(), SECTOR_SIZE);
- }
-
- break;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write -
-//-------------------------------------------------
-
-WRITE8_MEMBER(wd2010_device::write)
-{
- m_task_file[offset] = data;
-
- switch (offset)
- {
- case TASK_FILE_WRITE_PRECOMP_CYLINDER:
- if (LOG) logerror("%s WD2010 '%s' Write Precomp Cylinder: %u\n", machine().describe_context(), tag(), WRITE_PRECOMP_CYLINDER);
- break;
-
- case TASK_FILE_SECTOR_COUNT:
- if (LOG) logerror("%s WD2010 '%s' Sector Count: %u\n", machine().describe_context(), tag(), SECTOR_COUNT);
- break;
-
- case TASK_FILE_SECTOR_NUMBER:
- if (LOG) logerror("%s WD2010 '%s' Sector Number: %u\n", machine().describe_context(), tag(), SECTOR_NUMBER);
- break;
-
- case TASK_FILE_CYLINDER_LOW:
- if (LOG) logerror("%s WD2010 '%s' Cylinder (lower bits set): %u\n", machine().describe_context(), tag(), CYLINDER);
- break;
-
- case TASK_FILE_CYLINDER_HIGH:
- if (LOG) logerror("%s WD2010 '%s' Cylinder (MSB bits set): %u\n", machine().describe_context(), tag(), CYLINDER);
- break;
-
- case TASK_FILE_SDH_REGISTER:
- if (LOG)
- {
- logerror("(WRITE) %s WD2010 '%s' SDH: %u\n", machine().describe_context(), tag(), data);
- logerror("(WRITE) %s WD2010 '%s' Head: %u\n", machine().describe_context(), tag(), HEAD);
- logerror("(WRITE) %s WD2010 '%s' Drive: %u\n", machine().describe_context(), tag(), DRIVE);
- logerror("(WRITE) %s WD2010 '%s' Sector Size: %u\n", machine().describe_context(), tag(), SECTOR_SIZE);
- }
- break;
-
- case TASK_FILE_COMMAND:
- m_out_intrq_cb(CLEAR_LINE); // "either reading the status register or writing a new command clears INTRQ"
- m_status &= ~(STATUS_ERR | STATUS_BSY | STATUS_CIP); // "Reset ERR bit in STATUS upon new cmd" (see datasheet)
- m_error = 0;
-
- if (data == COMMAND_COMPUTE_CORRECTION)
- {
- if (LOG) logerror("%s WD2010 '%s' COMPUTE CORRECTION\n", machine().describe_context(), tag());
- compute_correction(data);
- }
- else if ((data & COMMAND_SET_PARAMETER_MASK) == COMMAND_SET_PARAMETER)
- {
- if (LOG) logerror("%s WD2010 '%s' SET PARAMETER\n", machine().describe_context(), tag());
- set_parameter(data);
- }
- else
- {
- switch (data & COMMAND_MASK)
- {
- case COMMAND_RESTORE:
- if (LOG) logerror("%s WD2010 '%s' RESTORE\n", machine().describe_context(), tag());
- restore(data);
- break;
-
- case COMMAND_SEEK:
- if (LOG) logerror("%s WD2010 '%s' SEEK\n", machine().describe_context(), tag());
- seek(data);
- break;
-
- case COMMAND_READ_SECTOR:
- if (LOG) logerror("%s WD2010 '%s' READ SECTOR (I = %u) (M = %u)\n", machine().describe_context(), tag(), ((data & 8)>0), ((data & 4)>0));
- read_sector(data);
- break;
-
- case COMMAND_WRITE_SECTOR:
- if (LOG) logerror("%s WD2010 '%s' WRITE SECTOR (M = %u)\n", machine().describe_context(), tag(), ((data & 4) > 0));
- write_sector(data);
- break;
-
- case COMMAND_SCAN_ID:
- if (LOG) logerror("%s WD2010 '%s' SCAN ID\n", machine().describe_context(), tag());
- scan_id(data);
- break;
-
- case COMMAND_WRITE_FORMAT:
- if (LOG) logerror("%s WD2010 '%s' WRITE FORMAT\n", machine().describe_context(), tag());
- format(data);
- break;
- }
-
- }
-
- break;
- } // switch
-}
-
-
-//-------------------------------------------------
-// compute_correction -
-//-------------------------------------------------
-void wd2010_device::compute_correction(UINT8 data)
-{
- UINT8 newstatus = STATUS_RDY | STATUS_SC;
- complete_cmd(newstatus);
-}
-
-
-//-------------------------------------------------
-// set_parameter -
-//-------------------------------------------------
-void wd2010_device::set_parameter(UINT8 data)
-{
- UINT8 newstatus = STATUS_RDY | STATUS_SC;
- complete_cmd(newstatus);
-}
-
-
-//-------------------------------------------------
-// restore -
-//-------------------------------------------------
-void wd2010_device::restore(UINT8 data)
-{
- UINT8 newstatus = STATUS_RDY | STATUS_SC;
-
- m_out_intrq_cb(CLEAR_LINE); // reset INTRQ, errors, set BUSY, CIP
- m_error = 0;
- m_status = STATUS_BSY | STATUS_CIP;
-
- m_out_rwc_cb(0); // reset RWC, set direction = OUT
-
- // datasheet: DIRIN HIGH = in ; LOW = out
- m_out_dirin_cb(0); // 0 = heads move away from the spindle, towards track O.
-
- // TODO: store step rate
-
- m_present_cylinder = 0; // (sse WD2010-05 datasheet)
- m_task_file[TASK_FILE_CYLINDER_HIGH] = 0;
- m_task_file[TASK_FILE_CYLINDER_LOW] = 0;
-
- int step_pulses = 0;
- while (step_pulses < STEP_LIMIT)
- {
- while (!m_in_sc_cb())
- {
- if (!m_in_drdy_cb() || m_in_wf_cb()) // drive not ready or write fault?
- {
- m_out_bcr_cb(0); // pulse BCR
- m_out_bcr_cb(1);
-
- m_error = ERROR_AC; // ERROR : ABORTED COMMAND
- complete_cmd(newstatus | STATUS_ERR);
- return;
- }
- }
-
- //if (m_in_tk000_cb())
- if (step_pulses == STEP_LIMIT - 2) // Simulate TRACK 00 signal (normally from DRIVE)
- {
- m_out_bcr_cb(0); // pulse BCR
- m_out_bcr_cb(1);
- newstatus &= ~(STATUS_BSY | STATUS_CIP); // prepare new status; (INTRQ later) reset BSY, CIP
- complete_cmd(newstatus);
- return;
- }
-
- if (step_pulses == STEP_LIMIT - 1) // NOTE: STEP_LIMIT - differs - between WD2010 and WD1010
- {
- m_error = ERROR_TK; // ERROR: track 0 not reached within limit
- newstatus = newstatus | STATUS_ERR;
-
- m_out_bcr_cb(0); // pulse BCR
- m_out_bcr_cb(1);
- newstatus &= ~(STATUS_BSY | STATUS_CIP); // prepare new status; (INTRQ later) reset BSY, CIP
- complete_cmd(newstatus);
- return;
- }
-
- m_out_step_cb(1); // issue a step pulse
- m_out_step_cb(0);
- step_pulses++;
- }
-
- assert(1);
-}
-
-//-------------------------------------------------
-// seek -
-//-------------------------------------------------
-
-// FIXME : step rate, drive change (!)
-
-// NOT IMPLEMENTED: IMPLIED SEEK ("wait until rising edge of SC signal")
-void wd2010_device::seek(UINT8 data)
-{
- UINT8 newstatus = STATUS_RDY | STATUS_SC;
-
- m_out_intrq_cb(CLEAR_LINE); // reset INTRQ, errors, set BUSY, CIP
- m_error = 0;
- m_status = STATUS_BSY | STATUS_CIP;
-
- // TODO : store STEP RATE.
-
- auto_scan_id(data); // has drive number changed?
-
- int direction = 0; // 0 = towards 0
- int step_pulses = 0;
-
- // Calculate number of steps by comparing the cylinder registers
- // HI/LO with the internally stored position.
- UINT32 cylinder_registers = CYLINDER;
- if (m_present_cylinder > cylinder_registers)
- {
- step_pulses = m_present_cylinder - cylinder_registers;
- direction = 0;
- }
- else
- {
- step_pulses = cylinder_registers - m_present_cylinder;
- direction = 1;
- }
- logerror("SEEK - direction = %u, step_pulses = %u\n", direction, step_pulses);
- m_out_dirin_cb(direction);
-
- if (!m_in_drdy_cb() || m_in_wf_cb()) // DRDY de-asserted or WF asserted?
- {
- m_error = ERROR_AC;
- complete_cmd(newstatus | STATUS_ERR);
- return;
- }
- else
- {
- while (step_pulses > 0) // issue STEP PULSES
- {
- if (direction == 0)
- {
- m_out_step_cb(1); // issue a step pulse
- m_out_step_cb(0);
-
- if (m_present_cylinder > 0)
- m_present_cylinder--;
- }
- else
- {
- m_out_step_cb(0);
- m_out_step_cb(1);
-
- m_present_cylinder++;
- }
- step_pulses--;
-
- // TODO: delay according to rate field
- }
-
- // ALL STEPS ISSUED NOW
-
- if (!m_in_drdy_cb()) // DRDY not asserted = > ABORTED COMMAND
- {
- m_error = ERROR_AC;
- complete_cmd(newstatus | STATUS_ERR);
- return;
- }
- }
-
- // AFTER ALL STEPS ARE ISSUED ...
- // UPDATE INTERNAL CYLINDER POSITION REGISTER (from WD1010 spec -> "SEEK COMMAND")
- m_present_cylinder = cylinder_registers;
-
- logerror("SEEK (END) - m_present_cylinder = %u\n", m_present_cylinder);
-
- cmd_timer->adjust(attotime::from_msec(35), newstatus); // 35 msecs makes "SEEK_TIMING" test happy.
-}
-
-//-------------------------------------------------
-// read_sector -
-//-------------------------------------------------
-// FIXME: multiple sector transfers, ID / CYL / HEAD / SIZE match
-// + ERROR HANDLING (...)
-void wd2010_device::read_sector(UINT8 data)
-{
- UINT8 newstatus = STATUS_RDY | STATUS_SC;
- int intrq_at_end = 0; // (default) : (I = 1 INTRQ occurs when the command
-
- m_out_intrq_cb(CLEAR_LINE); // reset INTRQ, errors, set BUSY, CIP
- m_error = 0;
- m_status = STATUS_BSY | STATUS_CIP;
-
- // Assume: drive NO # has not changed... (else: SCAN_ID; GET CYL#)
- auto_scan_id(data); // has drive number changed?
-
- // CYL REGISTERS and INTERNAL CYL. SAME ?
- // TODO: < NOT SAME? THEN _SEEK_ >
-
- // DRIVE NOT READY? OR WF?
- if ( (!m_in_drdy_cb()) || m_in_wf_cb() )
- {
- m_error = ERROR_AC; // ABORTED_COMMAND
- complete_cmd(newstatus | STATUS_ERR);
- return;
- }
- else
- {
- m_out_bcs_cb(1); // activate BCS (!)
-
- m_out_bcr_cb(0); // strobe BCR
- m_out_bcr_cb(1);
-
- if (!m_in_drdy_cb()) // DRIVE NOT READY?
- {
- m_error = ERROR_AC; // ABORTED_COMMAND
- complete_cmd(newstatus | STATUS_ERR);
- return;
- }
- else
- {
- // < SEARCH FOR ID FIELD >
- // < CYL / HEAD / SEC.SIZE MATCH ? >
-
- // < ID NOT FOUND >
- if (SECTOR_NUMBER > MAX_MFM_SECTORS)
- {
- // prepare new status; (later IRQ +) reset BSY, CIP
- m_error = ERROR_ID;
- complete_cmd(newstatus | STATUS_ERR);
- return;
- }
-
- // LOOP OVER 10 INDEXES : SCAN_ID / GET CYL.# (not implemented: ID NOT FOUND)
-
- // CYL / HEAD / SEC.SIZE MATCH ? => (ID FOUND)
- //
- // NO "BAD BLOCK DETECT" (** NOT IMPLEMENTED **)
- // NO "CRC ERROR" (** NOT IMPLEMENTED **)
- // AND "DAM FOUND" (** NOT IMPLEMENTED **)
-
- // ====> THEN "TRANSFER SECTOR TO BUFFER" <====
-
- m_out_bcr_cb(0); // strobe BCR
- m_out_bcr_cb(1);
-
- // NO "CRC ERROR"
-
- // FLAG "M" SET? (MULTIPLE SECTOR TRANSFERS)
- if (data & 4)
- logerror("WD2010 (READ): MULTIPLE SECTOR READ (M = 1).\n");
-
- // Assume: NO "M" (MULTIPLE SECTOR TRANSFERS)
-
- m_out_bcs_cb(0); // deactivate BCS (!)
-
- m_out_bcr_cb(0); // strobe BCR
- m_out_bcr_cb(1);
-
- // set BDRQ (NOTE: DRQ status bit 3 reflects state of BDRQ)
- m_status |= STATUS_DRQ;
- m_out_bdrq_cb(1);
-
- // reset BUSY (* after * TRANSFER OF SECTOR in READ)
- m_status &= ~(STATUS_BSY);
-
- // FLAG "I" SET?
- if (!(data & 8)) // (I = 0 INTRQ occurs with BDRQ/DRQ indicating the Sector Buffer is full...)
- {
- m_out_intrq_cb(ASSERT_LINE);
- if (!(data & 4)) // (...valid only when M = 0)
- intrq_at_end = STATUS_DWC; // 'reuse' unused DWC bit!
- }
- else
- {
- intrq_at_end = 0; // (default): (I = 1 INTRQ occurs when the command is completed and the Host has read the Sector Buffer)
- }
-
- // (WAIT FOR): BRDY LOW TO HIGH? (see -> TIMER)
-
- } // DRIVE_READY ? (inner)
-
- } // DRIVE_READY ? (outer)
-
- // NOTE : (intrq_at_end = 0) - INTRQ occurs when the command is completed
- newstatus |= (m_status & ~(STATUS_CIP | STATUS_DRQ)) | intrq_at_end; // de-assert CIP + DRQ (BSY already reset)
-
- deassert_read_when_buffer_ready_high->adjust(attotime::from_usec(1), newstatus); // complete command ON *RISING EDGE * OF BUFFER_READY
-}
-
-
-//-------------------------------------------------
-// write_sector (stage I)
-//-------------------------------------------------
-// FIXME: SEEK, SEEK_COMPLETE, Drive # change (!)
-// as well as CYL.register + internal CYL.register comparisons
-void wd2010_device::write_sector(UINT8 data)
-{
- m_error = 0; // De-assert ERROR + DRQ
- m_status &= ~(STATUS_DRQ);
-
- m_status = STATUS_BSY | STATUS_CIP; // Assert BUSY + CIP
-
- m_status |= STATUS_DRQ; // Assert BDRQ + DRQ (= status bit 3)
- m_out_bdrq_cb(1);
-
- // WAIT UNTIL BRDY ASSERTED (-> timer):
- complete_write_when_buffer_ready_high->adjust(attotime::from_usec(1), data); // 1 usec
-}
-
-
-//-------------------------------------------------
-// write_sector (stage II)
-//-------------------------------------------------
-void wd2010_device::complete_write_sector(UINT8 data)
-{
- UINT8 newstatus = STATUS_RDY | STATUS_SC;
-
- m_out_bdrq_cb(0); // DE-Assert BDRQ (...and DRQ !)
- m_status &= ~(STATUS_DRQ);
-
- // (When drive changed) : SCAN_ID / GET CYL#
- auto_scan_id(data); // has drive number changed? (*** UNIMPLEMENTED ***)
-
- // Assume YES : CYL.register + internal CYL.register SAME? (if NO => SEEK!)
- // Assume : SEEK_COMPLETE = YES
-
- if (!m_in_drdy_cb() || m_in_wf_cb()) // DRIVE IS READY / NO WF?
- {
- m_error = ERROR_AC; // ABORTED_COMMAND
- complete_cmd(newstatus | STATUS_ERR);
- return;
- }
- else
- { // --------------------------------------------------------
- // (*** UNIMPLEMENTED ***) Search for ID field...
-
- // < Correct ID found >
-
- // (*** UNIMPLEMENTED ***) : 'ID NOT FOUND' - set bit 4 error register
- // ........................: => SCAN_ID => RE-SEEK (2-10 INDEX PULSES) / Set ERR bit 0 status register ..
-
- m_status &= ~(STATUS_SC); // "WRITE_GATE valid when SEEK_COMPLETE = 0" (see Rainbow 100 Addendum!)
-
- m_out_bcs_cb(1);
- m_out_wg_cb(1); // (!)
-
- m_out_bcr_cb(0); // strobe BCR
- m_out_bcr_cb(1);
-
- // Assume: DRIVE IS READY / NO WF
-
- if (!m_in_drdy_cb() || m_in_wf_cb()) // DRDY de-asserted or WF asserted?
- {
- m_error = ERROR_AC; // ABORTED_COMMAND
- complete_cmd(newstatus | STATUS_ERR);
- return;
- }
- else
- {
- // ====> WRITE DATA TO SECTOR <====
-
- m_out_wg_cb(0); // (!)
-
- // Assume: (single sector transfer; M = 0)
-
- } // (INNER IF): No WF and DRIVE IS READY.
- } // --------------------------------------------------------
-
- // 'complete_cmd' ON THE FALLING EDGE OF _BUFFER_READY_ ( set by WRITE_SECTOR ) !
- deassert_write_when_buffer_ready_low->adjust(attotime::from_usec(1), newstatus);
-}
-
-// ******************************************************
-// AUTO SCAN-ID (whenever DRIVE # changes):
-
- // * does nothing right now *
-// ******************************************************
-void wd2010_device::auto_scan_id(UINT8 data)
-{
- static int last_drive;
-
- if (DRIVE != last_drive)
- {
- printf("\n(WD2010) : UNSUPPORTED DRIVE CHANGE !\n");
- logerror("\n(WD2010) : UNSUPPORTED DRIVE CHANGE !\n");
-
- //update_sdh(new_sector_size, new_head, new_cylinder, new_sectornr);
- }
- last_drive = DRIVE;
-
- return; // AUTO-SCAN CURRENTLY DISABLED (see NOTES)
-}
-// ******************************************************
-
-// What to do here (just update present_cylinder with CYLINDER)...?
-void wd2010_device::update_sdh(UINT8 new_sector_size, UINT8 new_head, UINT16 new_cylinder, UINT8 new_sectornr)
-{
- // "Update SDH"
- /*
- // Update SECTOR_SIZE, HEAD in SDH with the ID found -
- m_task_file[TASK_FILE_SDH_REGISTER] = ???
-
- // ...update CYLINDER registers with cylinder found -
- m_task_file[TASK_FILE_CYLINDER_LOW] = (new_cylinder >> 4) & 0x0f;
- m_task_file[TASK_FILE_CYLINDER_HIGH] = (new_cylinder - ((new_cylinder >> 4) << 4)) & 0x0f;
-
- // ...update SECTOR_NUMBER with sector nr. found -
- m_task_file[TASK_FILE_SECTOR_NUMBER] = new_sectornr;
- */
-
- m_present_cylinder = CYLINDER;
- logerror("UPDATE_SDH - m_present_cylinder = %u\n", m_present_cylinder);
-}
-
-//-------------------------------------------------
-// scan_id -
-//-------------------------------------------------
-
-// Reads the cylinder number from the track on which the heads are PRESENTLY located,
-// and writes this into the Present Cylinder Position Register.
-
-// FIXME: NO ID HANDLING (ID FOUND / NOT FOUND), NO BAD BLOCK; NO CRC
-void wd2010_device::scan_id(UINT8 data)
-{
- UINT8 newstatus = STATUS_RDY;
-
- m_out_intrq_cb(CLEAR_LINE);
- m_error = 0;
- m_status = STATUS_BSY | STATUS_CIP;
-
- // Assume DRIVE READY.
- // < TODO: Search for ANY ID FIELD. >
-
- // Assume ID FOUND :
- update_sdh( 32, 0, 0, 1 ); // (NEW:) SECTOR_SIZE, HEAD, CYLINDER, SECTOR_NR
-
- // NO BAD BLOCK.
- // NO CRC ERROR.
-
- complete_cmd(newstatus);
-}
-
-//--------------------------------------------------------
-// FORMAT ENTIRE TRACK using the task file + sector buffer
-
-// On real hardware, data fields are filled with FF.
-// Sector buffer is used for track layout (see datasheet).
-
-// Routine simulates one single write on each track
-// - just enough to keep formatter programs happy -
-
-// < UNIMPLEMENTED: (IMPLIED) SEEKs, INDEX, CRC and GAPs >
-//--------------------------------------------------------
-// SECTOR_COUNT REG.= 'total # of sectors to be formatted'
-// (raw number; no multiplication) = 16 decimal on RD51
-
-// SECTOR NUMBER REG.= number of bytes - 3 (for GAP 1 + 3)
-// = 40 decimal on DEC RD51 with WUTIL 3.2
-//--------------------------------------------------------
-void wd2010_device::format(UINT8 data)
-{
- UINT8 newstatus = STATUS_RDY;
-
- m_out_intrq_cb(CLEAR_LINE);
- m_error = 0;
- m_status = STATUS_BSY | STATUS_CIP;
-
- m_status |= STATUS_DRQ;
- m_out_bdrq_cb(1);
-
- // < WAIT UNTIL BRDY ASSERTED >
-
- // Datasheet says [DRQ] must go LOW...
- // ...delayed here _until BRDY goes high_ (=> TIMER EVENT <=):
-
- // m_out_bdrq_cb(0);
- // m_status &= ~(STATUS_DRQ);
-
- auto_scan_id(data); // has drive number changed?
-
- // TODO: Seek to desired cylinder
- // Assume : SEEK COMPLETE.
-
- m_out_bcr_cb(0); // strobe BCR
- m_out_bcr_cb(1);
-
- m_out_bcs_cb(1); // activate BCS (!)
-
- if (!m_in_drdy_cb() || m_in_wf_cb())
- {
- m_error = ERROR_AC; // ABORTED_COMMAND
- complete_cmd(newstatus | STATUS_ERR);
- return;
- }
-
- // WAIT FOR INDEX
-
- m_out_wg_cb(1); // Have Index, activate WRITE GATE
-
- // Check for WRITE FAULT (WF)
- if (m_in_wf_cb())
- {
- m_error = ERROR_AC; // ABORTED_COMMAND
- complete_cmd(newstatus | STATUS_ERR);
- return;
- }
-
- // UINT8 format_sector_count = m_task_file[TASK_FILE_SECTOR_COUNT];
- // do
- // {
- // < WRITE GAP 1 or GAP 3 >
-
- // < Wait for SEEK_COMPLETE=1 (extend GAP if SEEK_COMPLETE = 0) >
- // < Assume SEEK COMPLETE >
-
- // format_sector_count--;
- // if (format_sector_count != 0)
- {
- // The Rainbow 100 driver does ignore multiple sector
- // transfers so WRITE FORMAT does not actually write -
-
- m_out_wg_cb(0); // (transition from WG 1 -> 0)
-
- // NOTE: decrementing TASK_FILE_SECTOR_COUNT does * NOT WORK *
- }
- // else
- // { // < Write 4Es until INDEX (*** UNIMPLEMENTED ****) >
- // }
- // } while (format_sector_count > 0);
-
- // ** DELAY INTRQ UNTIL WRITE IS COMPLETE :
- complete_write_when_buffer_ready_high->adjust(attotime::from_usec(1), newstatus | STATUS_DRQ); // 1 USECs
-}
-
-
-// *************************************
-// INTERNAL
-// *************************************
-void wd2010_device::buffer_ready(bool state)
-{
- is_buffer_ready = state;
-}
-
-
-void wd2010_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
-{
- switch (tid)
- {
- case COMMAND_TIMER:
- cmd_timer->adjust(attotime::never);
- complete_immediate(param);
- break;
-
- case COMPLETE_WRITE_SECTOR: // when BUFFER_READY -> HIGH
- if (is_buffer_ready)
- {
- complete_write_when_buffer_ready_high->adjust(attotime::never);
- complete_write_sector(param);
- }
- else
- {
- complete_write_when_buffer_ready_high->reset();
- complete_write_when_buffer_ready_high->adjust(attotime::from_usec(1), param); // DELAY ANOTHER 1 USEC (!)
- }
- break;
-
- case DE_ASSERT_WRITE: // waiting for BUFFER_READY -> LOW
- if (!(is_buffer_ready))
- {
- deassert_write_when_buffer_ready_low->adjust(attotime::never);
- complete_immediate(param);
- }
- else
- {
- deassert_write_when_buffer_ready_low->reset();
- deassert_write_when_buffer_ready_low->adjust(attotime::from_usec(1), param); // DELAY ANOTHER 1 USEC (!)
- }
- break;
-
- case DE_ASSERT_READ: // when BUFFER_READY -> HIGH
- if (is_buffer_ready)
- {
- deassert_read_when_buffer_ready_high->adjust(attotime::never);
-
- m_error &= ~ERROR_ID;
- param &= ~STATUS_ERR;
-
- m_out_bdrq_cb(0);
- complete_immediate(param);
- }
- else
- {
- deassert_read_when_buffer_ready_high->reset();
- deassert_read_when_buffer_ready_high->adjust(attotime::from_usec(1), param); // DELAY ANOTHER 1 USEC (!)
- }
- break;
-
- default:
- break;
- }
-}
-
-// Called by 'device_timer' -
-void wd2010_device::complete_immediate(UINT8 status)
-{
- // re-evaluate external signals at end of command
- status &= ~(STATUS_RDY | STATUS_WF | STATUS_SC); // RDY 0x40 / WF 0x20 / SC 0x10
- status |= (m_in_drdy_cb() ? 0x40 : 0) | (m_in_wf_cb() ? 0x20 : 0) | (m_in_sc_cb() ? 0x10 : 0);
-
- if (status & STATUS_DRQ) // if DRQ was set, reset
- {
- status &= ~(STATUS_DRQ);
- m_out_bdrq_cb(0);
- }
-
- // Set current status (M_STATUS)
- m_status = status & (255 - STATUS_DWC); // minus "unused" bit 2 (DWC)
-
- m_status &= ~(STATUS_BSY | STATUS_CIP); // de-assert BUSY + CIP
-
- // "IRQ AT END OF COMMAND" when BIT 2 set (DWC 'data was corrected' - unused in this context!)
- if (!(status & STATUS_DWC)) // interrupt at END OF COMMAND ?
- m_out_intrq_cb(ASSERT_LINE); // Assert INTRQ (callback).
-
- m_out_bcs_cb(0); // de-assert BCS (needed)
- m_out_wg_cb(0); // deactivate WG (required by write / format)
-
- m_out_bcr_cb(0); // strobe BCR
- m_out_bcr_cb(1);
-}
-
-void wd2010_device::complete_cmd(UINT8 status)
-{
- cmd_timer->adjust(attotime::from_msec(1), status);
-}
diff --git a/src/emu/machine/wd2010.h b/src/emu/machine/wd2010.h
deleted file mode 100644
index 678844f28d6..00000000000
--- a/src/emu/machine/wd2010.h
+++ /dev/null
@@ -1,157 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Western Digital WD2010 Winchester Disk Controller
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __WD2010__
-#define __WD2010__
-
-
-#include "emu.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_WD2010_OUT_INTRQ_CB(_devcb) \
- devcb = &wd2010_device::set_out_intrq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_OUT_BDRQ_CB(_devcb) \
- devcb = &wd2010_device::set_out_bdrq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_OUT_BCR_CB(_devcb) \
- devcb = &wd2010_device::set_out_bcr_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_IN_BRDY_CB(_devcb) \
- devcb = &wd2010_device::set_in_brdy_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_IN_BCS_CB(_devcb) \
- devcb = &wd2010_device::set_in_bcs_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_OUT_BCS_CB(_devcb) \
- devcb = &wd2010_device::set_out_bcs_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_OUT_DIRIN_CB(_devcb) \
- devcb = &wd2010_device::set_out_dirin_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_OUT_STEP_CB(_devcb) \
- devcb = &wd2010_device::set_out_step_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_OUT_RWC_CB(_devcb) \
- devcb = &wd2010_device::set_out_rwc_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_OUT_WG_CB(_devcb) \
- devcb = &wd2010_device::set_out_wg_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_IN_DRDY_CB(_devcb) \
- devcb = &wd2010_device::set_in_drdy_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_IN_INDEX_CB(_devcb) \
- devcb = &wd2010_device::set_in_index_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_IN_WF_CB(_devcb) \
- devcb = &wd2010_device::set_in_wf_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_IN_TK000_CB(_devcb) \
- devcb = &wd2010_device::set_in_tk000_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_WD2010_IN_SC_CB(_devcb) \
- devcb = &wd2010_device::set_in_sc_callback(*device, DEVCB_##_devcb);
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> wd2010_device
-
-class wd2010_device : public device_t
-{
-public:
- // construction/destruction
- wd2010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_intrq_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_out_intrq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_bdrq_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_out_bdrq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_bcr_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_out_bcr_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_brdy_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_in_brdy_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_bcs_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_in_bcs_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_bcs_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_out_bcs_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dirin_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_out_dirin_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_step_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_out_step_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_rwc_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_out_rwc_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_wg_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_out_wg_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_drdy_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_in_drdy_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_index_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_in_index_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_wf_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_in_wf_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_tk000_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_in_tk000_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_sc_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_in_sc_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- void buffer_ready(bool state);
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- void compute_correction(UINT8 data);
- void set_parameter(UINT8 data);
- void restore(UINT8 data);
- void seek(UINT8 data);
- void read_sector(UINT8 data);
- void write_sector(UINT8 data);
- void scan_id(UINT8 data);
- void update_sdh(UINT8 new_sector_size, UINT8 new_head, UINT16 new_cylinder, UINT8 new_sectornr);
- void auto_scan_id(UINT8 data);
- void format(UINT8 data);
-
- devcb_write_line m_out_intrq_cb;
- devcb_write_line m_out_bdrq_cb;
- devcb_write_line m_out_bcr_cb;
- devcb_read8 m_in_bcs_cb;
- devcb_read_line m_in_brdy_cb;
- devcb_write8 m_out_bcs_cb;
- devcb_write_line m_out_dirin_cb;
- devcb_write_line m_out_step_cb;
- devcb_write_line m_out_rwc_cb;
- devcb_write_line m_out_wg_cb;
- devcb_read_line m_in_drdy_cb;
- devcb_read_line m_in_index_cb;
- devcb_read_line m_in_wf_cb;
- devcb_read_line m_in_tk000_cb;
- devcb_read_line m_in_sc_cb;
-
- UINT8 m_status;
- UINT8 m_error;
- UINT8 m_task_file[8];
-
- emu_timer *cmd_timer;
- emu_timer *complete_write_when_buffer_ready_high;
- emu_timer *deassert_write_when_buffer_ready_low;
- emu_timer *deassert_read_when_buffer_ready_high;
-
- void complete_write_sector(UINT8 status);
- void complete_cmd(UINT8 status);
- void complete_immediate(UINT8 status);
-
- bool is_buffer_ready;
-
- UINT32 m_present_cylinder; // Present Cylinder Position Register
-};
-
-// device type definition
-extern const device_type WD2010;
-
-#endif
diff --git a/src/emu/machine/wd33c93.c b/src/emu/machine/wd33c93.c
deleted file mode 100644
index 2ae5f9d370a..00000000000
--- a/src/emu/machine/wd33c93.c
+++ /dev/null
@@ -1,807 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:ElSemi, R. Belmont, Ryan Holtz
-/*
- * wd33c93.c
- *
- * WD/AMD 33c93 SCSI controller, as seen in
- * early PCs, some MSX add-ons, NEC PC-88, and SGI
- * Indigo, Indigo2, and Indy systems.
- *
- * References:
- * WD 33c93 manual
- * NetBSD 33c93 driver
- *
- */
-
-#include "emu.h"
-#include "wd33c93.h"
-
-#define VERBOSE 0
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-/* WD commands */
-#define WD_CMD_RESET 0x00
-#define WD_CMD_ABORT 0x01
-#define WD_CMD_ASSERT_ATN 0x02
-#define WD_CMD_NEGATE_ACK 0x03
-#define WD_CMD_DISCONNECT 0x04
-#define WD_CMD_RESELECT 0x05
-#define WD_CMD_SEL_ATN 0x06
-#define WD_CMD_SEL 0x07
-#define WD_CMD_SEL_ATN_XFER 0x08
-#define WD_CMD_SEL_XFER 0x09
-#define WD_CMD_RESEL_RECEIVE 0x0a
-#define WD_CMD_RESEL_SEND 0x0b
-#define WD_CMD_WAIT_SEL_RECEIVE 0x0c
-#define WD_CMD_SSCC 0x0d
-#define WD_CMD_SND_DISC 0x0e
-#define WD_CMD_SET_IDI 0x0f
-#define WD_CMD_RCV_CMD 0x10
-#define WD_CMD_RCV_DATA 0x11
-#define WD_CMD_RCV_MSG_OUT 0x12
-#define WD_CMD_RCV 0x13
-#define WD_CMD_SND_STATUS 0x14
-#define WD_CMD_SND_DATA 0x15
-#define WD_CMD_SND_MSG_IN 0x16
-#define WD_CMD_SND 0x17
-#define WD_CMD_TRANS_ADDR 0x18
-#define WD_CMD_XFER_PAD 0x19
-#define WD_CMD_TRANS_INFO 0x20
-#define WD_CMD_TRANSFER_PAD 0x21
-#define WD_CMD_SBT_MODE 0x80
-
-/* ASR register */
-#define ASR_INT 0x80
-#define ASR_LCI 0x40
-#define ASR_BSY 0x20
-#define ASR_CIP 0x10
-#define ASR_PE 0x02
-#define ASR_DBR 0x01
-
-/* SCSI Bus Phases */
-#define PHS_DATA_OUT 0x00
-#define PHS_DATA_IN 0x01
-#define PHS_COMMAND 0x02
-#define PHS_STATUS 0x03
-#define PHS_MESS_OUT 0x06
-#define PHS_MESS_IN 0x07
-
-/* Command Status Register definitions */
-
- /* reset state interrupts */
-#define CSR_RESET 0x00
-#define CSR_RESET_AF 0x01
-
- /* successful completion interrupts */
-#define CSR_RESELECT 0x10
-#define CSR_SELECT 0x11
-#define CSR_SEL_XFER_DONE 0x16
-#define CSR_XFER_DONE 0x18
-
- /* paused or aborted interrupts */
-#define CSR_MSGIN 0x20
-#define CSR_SDP 0x21
-#define CSR_SEL_ABORT 0x22
-#define CSR_RESEL_ABORT 0x25
-#define CSR_RESEL_ABORT_AM 0x27
-#define CSR_ABORT 0x28
-
- /* terminated interrupts */
-#define CSR_INVALID 0x40
-#define CSR_UNEXP_DISC 0x41
-#define CSR_TIMEOUT 0x42
-#define CSR_PARITY 0x43
-#define CSR_PARITY_ATN 0x44
-#define CSR_BAD_STATUS 0x45
-#define CSR_UNEXP 0x48
-
- /* service required interrupts */
-#define CSR_RESEL 0x80
-#define CSR_RESEL_AM 0x81
-#define CSR_DISC 0x85
-#define CSR_SRV_REQ 0x88
-
- /* Own ID/CDB Size register */
-#define OWNID_EAF 0x08
-#define OWNID_EHP 0x10
-#define OWNID_RAF 0x20
-#define OWNID_FS_8 0x00
-#define OWNID_FS_12 0x40
-#define OWNID_FS_16 0x80
-
- /* Control register */
-#define CTRL_HSP 0x01
-#define CTRL_HA 0x02
-#define CTRL_IDI 0x04
-#define CTRL_EDI 0x08
-#define CTRL_HHP 0x10
-#define CTRL_POLLED 0x00
-#define CTRL_BURST 0x20
-#define CTRL_BUS 0x40
-#define CTRL_DMA 0x80
-
- /* Synchronous Transfer Register */
-#define STR_FSS 0x80
-
- /* Destination ID register */
-#define DSTID_DPD 0x40
-#define DATA_OUT_DIR 0
-#define DATA_IN_DIR 1
-#define DSTID_SCC 0x80
-
- /* Source ID register */
-#define SRCID_MASK 0x07
-#define SRCID_SIV 0x08
-#define SRCID_DSP 0x20
-#define SRCID_ES 0x40
-#define SRCID_ER 0x80
-
-/* convernience functions */
-UINT8 wd33c93_device::getunit( void )
-{
- /* return the destination unit id */
- return regs[WD_DESTINATION_ID] & SRCID_MASK;
-}
-
-void wd33c93_device::set_xfer_count( int count )
-{
- /* set the count */
- regs[ WD_TRANSFER_COUNT_LSB ] = count & 0xff;
- regs[ WD_TRANSFER_COUNT ] = ( count >> 8 ) & 0xff;
- regs[ WD_TRANSFER_COUNT_MSB ] = ( count >> 16 ) & 0xff;
-}
-
-int wd33c93_device::get_xfer_count( void )
-{
- /* get the count */
- int count = regs[ WD_TRANSFER_COUNT_MSB ];
-
- count <<= 8;
- count |= regs[ WD_TRANSFER_COUNT ];
- count <<= 8;
- count |= regs[ WD_TRANSFER_COUNT_LSB ];
-
- return count;
-}
-
-void wd33c93_device::complete_immediate( int status )
-{
- /* reset our timer */
- cmd_timer->reset();
-
- /* set the new status */
- regs[WD_SCSI_STATUS] = status & 0xff;
-
- /* set interrupt pending */
- regs[WD_AUXILIARY_STATUS] |= ASR_INT;
-
- /* check for error conditions */
- if ( get_xfer_count() > 0 )
- {
- /* set data buffer ready */
- regs[WD_AUXILIARY_STATUS] |= ASR_DBR;
- }
- else
- {
- /* clear data buffer ready */
- regs[WD_AUXILIARY_STATUS] &= ~ASR_DBR;
- }
-
- /* clear command in progress and bus busy */
- regs[WD_AUXILIARY_STATUS] &= ~(ASR_CIP | ASR_BSY);
-
- /* if we have a callback, call it */
- if (!m_irq_cb.isnull())
- {
- m_irq_cb(1);
- }
-}
-
-void wd33c93_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
-{
- switch( tid )
- {
- case 0:
- complete_immediate( param );
- break;
-
- case 1:
- complete_immediate(CSR_SRV_REQ | busphase);
- break;
-
- case 2:
- regs[WD_AUXILIARY_STATUS] &= ~ASR_CIP;
- break;
- }
-}
-
-void wd33c93_device::complete_cmd( UINT8 status )
-{
- /* fire off a timer to complete the command */
- cmd_timer->adjust( attotime::from_usec(1), status );
-}
-
-/* command handlers */
-void wd33c93_device::unimplemented_cmd()
-{
- logerror( "%s:Unimplemented SCSI controller command: %02x\n", machine().describe_context(), regs[WD_COMMAND] );
-
- /* complete the command */
- complete_cmd( CSR_INVALID );
-}
-
-void wd33c93_device::invalid_cmd()
-{
- logerror( "%s:Invalid SCSI controller command: %02x\n", machine().describe_context(), regs[WD_COMMAND] );
-
- /* complete the command */
- complete_cmd( CSR_INVALID );
-}
-
-void wd33c93_device::reset_cmd()
-{
- int advanced = 0;
-
- /* see if it wants us to reset with advanced features */
- if ( regs[WD_OWN_ID] & OWNID_EAF )
- {
- advanced = 1;
- }
-
- /* clear out all registers */
- memset( regs, 0, sizeof( regs ) );
-
- /* complete the command */
- complete_cmd(advanced ? CSR_RESET_AF : CSR_RESET);
-}
-
-void wd33c93_device::abort_cmd()
-{
- /* complete the command */
- complete_cmd(CSR_ABORT);
-}
-
-void wd33c93_device::disconnect_cmd()
-{
- /* complete the command */
- regs[WD_AUXILIARY_STATUS] &= ~(ASR_CIP | ASR_BSY);
-}
-
-void wd33c93_device::select_cmd()
-{
- UINT8 unit = getunit();
- UINT8 newstatus;
-
- /* see if we can select that device */
- if (select(unit))
- {
- /* device is available - signal selection done */
- newstatus = CSR_SELECT;
-
- /* determine the next bus phase depending on the command */
- if ( (regs[WD_COMMAND] & 0x7f) == WD_CMD_SEL_ATN )
- {
- /* /ATN asserted during select: Move to Message Out Phase to read identify */
- busphase = PHS_MESS_OUT;
- }
- else
- {
- /* No /ATN asserted: Move to Command Phase */
- busphase = PHS_COMMAND;
- }
-
- /* queue up a service request out in the future */
- service_req_timer->adjust( attotime::from_usec(50) );
- }
- else
- {
- /* device is not available */
- newstatus = CSR_TIMEOUT;
- }
-
- /* complete the command */
- complete_cmd(newstatus);
-}
-
-void wd33c93_device::selectxfer_cmd()
-{
- UINT8 unit = getunit();
- UINT8 newstatus;
-
- /* see if we can select that device */
- if (select(unit))
- {
- if ( regs[WD_COMMAND_PHASE] < 0x45 )
- {
- /* device is available */
- int phase;
-
- /* do the request */
- send_command(&regs[WD_CDB_1], 12);
- phase = get_phase();
-
- /* set transfer count */
- if ( get_xfer_count() > TEMP_INPUT_LEN )
- {
- logerror( "WD33C93: Transfer count too big. Please increase TEMP_INPUT_LEN (size=%d)\n", get_xfer_count() );
- set_xfer_count( TEMP_INPUT_LEN );
- }
-
- switch( phase )
- {
- case SCSI_PHASE_DATAIN:
- read_pending = 1;
- break;
- }
- }
-
- if ( read_pending )
- {
- int len = TEMP_INPUT_LEN;
-
- if ( get_xfer_count() < len ) len = get_xfer_count();
-
- memset( &temp_input[0], 0, TEMP_INPUT_LEN );
- read_data(&temp_input[0], len);
- temp_input_pos = 0;
- read_pending = 0;
- }
-
- regs[WD_TARGET_LUN] = 0;
- regs[WD_CONTROL] |= CTRL_EDI;
- regs[WD_COMMAND_PHASE] = 0x60;
-
- /* signal transfer ready */
- newstatus = CSR_SEL_XFER_DONE;
-
- /* if allowed disconnect, queue a service request */
- if ( identify & 0x40 )
- {
- /* queue disconnect message in */
- busphase = PHS_MESS_IN;
-
- /* queue up a service request out in the future */
- service_req_timer->adjust( attotime::from_usec(50) );
- }
- }
- else
- {
- /* device is not available */
- newstatus = CSR_TIMEOUT;
-
- set_xfer_count( 0 );
- }
-
- /* complete the command */
- complete_cmd(newstatus);
-}
-
-void wd33c93_device::negate_ack()
-{
- logerror( "WD33C93: ACK Negated\n" );
-
- /* complete the command */
- regs[WD_AUXILIARY_STATUS] &= ~(ASR_CIP | ASR_BSY);
-}
-
-void wd33c93_device::xferinfo_cmd()
-{
- /* make the buffer available right away */
- regs[WD_AUXILIARY_STATUS] |= ASR_DBR;
- regs[WD_AUXILIARY_STATUS] |= ASR_CIP;
-
- /* the command will be completed once the data is transferred */
- deassert_cip_timer->adjust( attotime::from_msec(1) );
-}
-
-/* Handle pending commands */
-void wd33c93_device::dispatch_command()
-{
- /* get the command */
- UINT8 cmd = regs[WD_COMMAND] & 0x7f;
-
- switch(cmd)
- {
- case WD_CMD_RESET:
- reset_cmd();
- break;
-
- case WD_CMD_ABORT:
- abort_cmd();
- break;
-
- case WD_CMD_NEGATE_ACK:
- negate_ack();
- break;
-
- case WD_CMD_DISCONNECT:
- disconnect_cmd();
- break;
-
- case WD_CMD_SEL_ATN:
- case WD_CMD_SEL:
- select_cmd();
- break;
-
- case WD_CMD_SEL_ATN_XFER:
- case WD_CMD_SEL_XFER:
- selectxfer_cmd();
- break;
-
- case WD_CMD_TRANS_INFO:
- xferinfo_cmd();
- break;
-
- case WD_CMD_ASSERT_ATN:
- case WD_CMD_RESELECT:
- case WD_CMD_RESEL_RECEIVE:
- case WD_CMD_RESEL_SEND:
- case WD_CMD_WAIT_SEL_RECEIVE:
- case WD_CMD_SSCC:
- case WD_CMD_SND_DISC:
- case WD_CMD_SET_IDI:
- case WD_CMD_RCV_CMD:
- case WD_CMD_RCV_DATA:
- case WD_CMD_RCV_MSG_OUT:
- case WD_CMD_RCV:
- case WD_CMD_SND_STATUS:
- case WD_CMD_SND_DATA:
- case WD_CMD_SND_MSG_IN:
- case WD_CMD_SND:
- case WD_CMD_TRANS_ADDR:
- case WD_CMD_XFER_PAD:
- case WD_CMD_TRANSFER_PAD:
- unimplemented_cmd();
- break;
-
- default:
- invalid_cmd();
- break;
- }
-}
-
-WRITE8_MEMBER(wd33c93_device::write)
-{
- switch( offset )
- {
- case 0:
- {
- /* update register select */
- sasr = data & 0x1f;
- }
- break;
-
- case 1:
- {
- LOG(( "WD33C93: PC=%08x - Write REG=%02x, data = %02x\n", space.device().safe_pc(), sasr, data ));
-
- /* update the register */
- regs[sasr] = data;
-
- /* if we receive a command, schedule to process it */
- if ( sasr == WD_COMMAND )
- {
- LOG(( "WDC33C93: PC=%08x - Executing command %08x - unit %d\n", space.device().safe_pc(), data, getunit() ));
-
- /* signal we're processing it */
- regs[WD_AUXILIARY_STATUS] |= ASR_CIP;
-
- /* process the command */
- dispatch_command();
- }
- else if ( sasr == WD_CDB_1 )
- {
- regs[WD_COMMAND_PHASE] = 0;
- }
- else if ( sasr == WD_DATA )
- {
- /* if data was written, and we have a count, send to device */
- int count = get_xfer_count();
-
- if ( regs[WD_COMMAND] & 0x80 )
- count = 1;
-
- if ( count-- > 0 )
- {
- /* write to FIFO */
- if ( fifo_pos < FIFO_SIZE )
- {
- fifo[fifo_pos++] = data;
- }
-
- /* update count */
- set_xfer_count( count );
-
- /* if we're done with the write, see where we're at */
- if ( count == 0 )
- {
- regs[WD_AUXILIARY_STATUS] |= ASR_INT;
- regs[WD_AUXILIARY_STATUS] &= ~ASR_DBR;
-
- switch( busphase )
- {
- case PHS_MESS_OUT:
- {
- /* reset fifo */
- fifo_pos = 0;
-
- /* Message out phase. Data is probably SCSI Identify. Move to command phase. */
- busphase = PHS_COMMAND;
-
- identify = fifo[0];
- }
- break;
-
- case PHS_COMMAND:
- {
- int xfercount;
- int phase;
-
- /* Execute the command. Depending on the command, we'll move to data in or out */
- send_command(&fifo[0], 12);
- xfercount = get_length();
- phase = get_phase();
-
- /* reset fifo */
- fifo_pos = 0;
-
- /* set the new count */
- set_xfer_count( xfercount );
-
- switch( phase )
- {
- case SCSI_PHASE_STATUS:
- busphase = PHS_STATUS;
- break;
-
- case SCSI_PHASE_DATAIN:
- busphase = PHS_DATA_IN;
- read_pending = 1;
- break;
-
- case SCSI_PHASE_DATAOUT:
- busphase = PHS_DATA_OUT;
- break;
- }
- }
- break;
-
- case PHS_DATA_OUT:
- {
- /* write data out to device */
- write_data(fifo, fifo_pos);
-
- /* reset fifo */
- fifo_pos = 0;
-
- /* move to status phase */
- busphase = PHS_STATUS;
- }
- break;
- }
-
- /* complete the command */
- complete_immediate(CSR_XFER_DONE | busphase);
- }
- }
- else
- {
- logerror( "WD33C93: Sending data to device with transfer count = 0!. Ignoring...\n" );
- }
- }
-
- /* auto-increment register select if not on special registers */
- if ( sasr != WD_COMMAND && sasr != WD_DATA && sasr != WD_AUXILIARY_STATUS )
- {
- sasr = ( sasr + 1 ) & 0x1f;
- }
- }
- break;
-
- default:
- {
- logerror( "WD33C93: Write to invalid offset %d (data=%02x)\n", offset, data );
- }
- break;
- }
-}
-
-READ8_MEMBER(wd33c93_device::read)
-{
- switch( offset )
- {
- case 0:
- {
- /* read aux status */
- return regs[WD_AUXILIARY_STATUS];
- }
-
- case 1:
- {
- UINT8 ret;
-
- /* if reading status, clear irq flag */
- if ( sasr == WD_SCSI_STATUS )
- {
- regs[WD_AUXILIARY_STATUS] &= ~ASR_INT;
-
- if (!m_irq_cb.isnull())
- {
- m_irq_cb(0);
- }
-
- LOG(( "WD33C93: PC=%08x - Status read (%02x)\n", space.device().safe_pc(), regs[WD_SCSI_STATUS] ));
- }
- else if ( sasr == WD_DATA )
- {
- /* we're going to be doing synchronous reads */
-
- /* get the transfer count */
- int count = get_xfer_count();
-
- /* initialize the return value */
- regs[WD_DATA] = 0;
-
- if ( count <= 0 && busphase == PHS_MESS_IN )
- {
- /* move to disconnect */
- complete_cmd(CSR_DISC);
- }
- else if ( count == 1 && busphase == PHS_STATUS )
- {
- /* update the count */
- set_xfer_count( 0 );
-
- /* move to message in phase */
- busphase = PHS_MESS_IN;
-
- /* complete the command */
- complete_cmd(CSR_XFER_DONE | busphase);
- }
- else if ( count-- > 0 ) /* make sure we still have data to send */
- {
- if ( read_pending )
- {
- int len = TEMP_INPUT_LEN;
-
- if ( (count+1) < len ) len = count+1;
- read_data(&temp_input[0], len);
- temp_input_pos = 0;
- read_pending = 0;
- }
-
- regs[WD_AUXILIARY_STATUS] &= ~ASR_INT;
-
- /* read in one byte */
- if ( temp_input_pos < TEMP_INPUT_LEN )
- regs[WD_DATA] = temp_input[temp_input_pos++];
-
- /* update the count */
- set_xfer_count( count );
-
- /* transfer finished, see where we're at */
- if ( count == 0 )
- {
- if ( regs[WD_COMMAND_PHASE] != 0x60 )
- {
- /* move to status phase */
- busphase = PHS_STATUS;
-
- /* complete the command */
- complete_cmd(CSR_XFER_DONE | busphase);
- }
- else
- {
- regs[WD_AUXILIARY_STATUS] |= ASR_INT;
- regs[WD_AUXILIARY_STATUS] &= ~ASR_DBR;
- }
- }
- }
- }
-
- LOG(( "WD33C93: PC=%08x - Data read (%02x)\n", space.device().safe_pc(), regs[WD_DATA] ));
-
- /* get the register value */
- ret = regs[sasr];
-
- /* auto-increment register select if not on special registers */
- if ( sasr != WD_COMMAND && sasr != WD_DATA && sasr != WD_AUXILIARY_STATUS )
- {
- sasr = ( sasr + 1 ) & 0x1f;
- }
-
- return ret;
- }
-
- default:
- {
- logerror( "WD33C93: Read from invalid offset %d\n", offset );
- }
- break;
- }
-
- return 0;
-}
-
-wd33c93_device::wd33c93_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- legacy_scsi_host_adapter(mconfig, WD33C93, "33C93 SCSI", tag, owner, clock, "wd33c93", __FILE__),
- m_irq_cb(*this)
-{
-}
-
-void wd33c93_device::device_start()
-{
- legacy_scsi_host_adapter::device_start();
-
- memset(regs, 0, sizeof(regs));
- memset(fifo, 0, sizeof(fifo));
- memset(temp_input, 0, sizeof(temp_input));
-
- sasr = 0;
- fifo_pos = 0;
- temp_input_pos = 0;
- busphase = 0;
- identify = 0;
- read_pending = 0;
-
- m_irq_cb.resolve();
-
- /* allocate a timer for commands */
- cmd_timer = timer_alloc(0);
- service_req_timer = timer_alloc(1);
- deassert_cip_timer = timer_alloc(2);
-
- save_item( NAME( sasr ) );
- save_item( NAME( regs ) );
- save_item( NAME( fifo ) );
- save_item( NAME( fifo_pos ) );
- save_item( NAME( temp_input ) );
- save_item( NAME( temp_input_pos ) );
- save_item( NAME( busphase ) );
- save_item( NAME( identify ) );
- save_item( NAME( read_pending ) );
-}
-
-void wd33c93_device::dma_read_data( int bytes, UINT8 *pData )
-{
- int len = bytes;
-
- if ( len >= get_xfer_count() )
- len = get_xfer_count();
-
- if ( len == 0 )
- return;
-
- if ( (temp_input_pos+len) >= TEMP_INPUT_LEN )
- {
- logerror( "Reading past end of buffer, increase TEMP_INPUT_LEN size\n" );
- len = TEMP_INPUT_LEN - len;
- }
-
- assert(len);
-
- memcpy( pData, &temp_input[temp_input_pos], len );
-
- temp_input_pos += len;
- len = get_xfer_count() - len;
- set_xfer_count(len);
-}
-
-void wd33c93_device::dma_write_data(int bytes, UINT8 *pData)
-{
- write_data(pData, bytes);
-}
-
-void wd33c93_device::clear_dma()
-{
- /* indicate DMA completed by clearing the transfer count */
- set_xfer_count(0);
- regs[WD_AUXILIARY_STATUS] &= ~ASR_DBR;
-}
-
-int wd33c93_device::get_dma_count()
-{
- return get_xfer_count();
-}
-
-const device_type WD33C93 = &device_creator<wd33c93_device>;
diff --git a/src/emu/machine/wd33c93.h b/src/emu/machine/wd33c93.h
deleted file mode 100644
index 68ca8acfc58..00000000000
--- a/src/emu/machine/wd33c93.h
+++ /dev/null
@@ -1,109 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:ElSemi, R. Belmont, Ryan Holtz
-/*
- * wd33c93.h
- *
- */
-
-#ifndef _WD33C93_H_
-#define _WD33C93_H_
-
-#include "legscsi.h"
-
-/* wd register names */
-
-enum
-{
- WD_OWN_ID = 0x00,
- WD_CONTROL = 0x01,
- WD_TIMEOUT_PERIOD = 0x02,
- WD_CDB_1 = 0x03,
- WD_CDB_2 = 0x04,
- WD_CDB_3 = 0x05,
- WD_CDB_4 = 0x06,
- WD_CDB_5 = 0x07,
- WD_CDB_6 = 0x08,
- WD_CDB_7 = 0x09,
- WD_CDB_8 = 0x0a,
- WD_CDB_9 = 0x0b,
- WD_CDB_10 = 0x0c,
- WD_CDB_11 = 0x0d,
- WD_CDB_12 = 0x0e,
- WD_TARGET_LUN = 0x0f,
- WD_COMMAND_PHASE = 0x10,
- WD_SYNCHRONOUS_TRANSFER = 0x11,
- WD_TRANSFER_COUNT_MSB = 0x12,
- WD_TRANSFER_COUNT = 0x13,
- WD_TRANSFER_COUNT_LSB = 0x14,
- WD_DESTINATION_ID = 0x15,
- WD_SOURCE_ID = 0x16,
- WD_SCSI_STATUS = 0x17,
- WD_COMMAND = 0x18,
- WD_DATA = 0x19,
- WD_QUEUE_TAG = 0x1a,
- WD_AUXILIARY_STATUS = 0x1f
-};
-
-#define TEMP_INPUT_LEN 262144
-#define FIFO_SIZE 12
-
-#define MCFG_WD33C93_IRQ_CB(_devcb) \
- devcb = &wd33c93_device::set_irq_callback(*device, DEVCB_##_devcb);
-
-class wd33c93_device : public legacy_scsi_host_adapter
-{
-public:
- // construction/destruction
- wd33c93_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<wd33c93_device &>(device).m_irq_cb.set_callback(object); }
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- void dma_read_data( int bytes, UINT8 *pData );
- void dma_write_data(int bytes, UINT8 *pData);
- void clear_dma();
- int get_dma_count();
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- UINT8 getunit( void );
- void set_xfer_count( int count );
- int get_xfer_count( void );
- void complete_immediate( int status );
- void complete_cmd( UINT8 status );
- void unimplemented_cmd();
- void invalid_cmd();
- void reset_cmd();
- void abort_cmd();
- void disconnect_cmd();
- void select_cmd();
- void selectxfer_cmd();
- void negate_ack();
- void xferinfo_cmd();
- void dispatch_command();
-
- UINT8 sasr;
- UINT8 regs[WD_AUXILIARY_STATUS+1];
- UINT8 fifo[FIFO_SIZE];
- int fifo_pos;
- UINT8 temp_input[TEMP_INPUT_LEN];
- int temp_input_pos;
- UINT8 busphase;
- UINT8 identify;
- int read_pending;
- emu_timer *cmd_timer;
- emu_timer *service_req_timer;
- emu_timer *deassert_cip_timer;
- devcb_write_line m_irq_cb; /* irq callback */
-};
-
-// device type definition
-extern const device_type WD33C93;
-
-#endif
diff --git a/src/emu/machine/wd7600.c b/src/emu/machine/wd7600.c
deleted file mode 100644
index 26873553e14..00000000000
--- a/src/emu/machine/wd7600.c
+++ /dev/null
@@ -1,557 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Barry Rodewald
-/*
- * Western Digital WD7600 PC system chipset
- *
- * WD76C10 - system control
- * WD76C20 - FDC, RTC, Bus interface
- * WD76C30 - 1 parallel and 2 serial ports
- *
- * Created on: 5/05/2014
- *
- * TODO: pretty much everything
- */
-
-#include "machine/wd7600.h"
-
-const device_type WD7600 = &device_creator<wd7600_device>;
-
-#define LOG (1)
-
-static MACHINE_CONFIG_FRAGMENT( wd7600 )
- MCFG_DEVICE_ADD("dma1", AM9517A, 0)
- MCFG_I8237_OUT_HREQ_CB(DEVWRITELINE("dma2", am9517a_device, dreq0_w))
- MCFG_I8237_OUT_EOP_CB(WRITELINE(wd7600_device, dma1_eop_w))
- MCFG_I8237_IN_MEMR_CB(READ8(wd7600_device, dma_read_byte))
- MCFG_I8237_OUT_MEMW_CB(WRITE8(wd7600_device, dma_write_byte))
- MCFG_I8237_IN_IOR_0_CB(READ8(wd7600_device, dma1_ior0_r))
- MCFG_I8237_IN_IOR_1_CB(READ8(wd7600_device, dma1_ior1_r))
- MCFG_I8237_IN_IOR_2_CB(READ8(wd7600_device, dma1_ior2_r))
- MCFG_I8237_IN_IOR_3_CB(READ8(wd7600_device, dma1_ior3_r))
- MCFG_I8237_OUT_IOW_0_CB(WRITE8(wd7600_device, dma1_iow0_w))
- MCFG_I8237_OUT_IOW_1_CB(WRITE8(wd7600_device, dma1_iow1_w))
- MCFG_I8237_OUT_IOW_2_CB(WRITE8(wd7600_device, dma1_iow2_w))
- MCFG_I8237_OUT_IOW_3_CB(WRITE8(wd7600_device, dma1_iow3_w))
- MCFG_I8237_OUT_DACK_0_CB(WRITELINE(wd7600_device, dma1_dack0_w))
- MCFG_I8237_OUT_DACK_1_CB(WRITELINE(wd7600_device, dma1_dack1_w))
- MCFG_I8237_OUT_DACK_2_CB(WRITELINE(wd7600_device, dma1_dack2_w))
- MCFG_I8237_OUT_DACK_3_CB(WRITELINE(wd7600_device, dma1_dack3_w))
- MCFG_DEVICE_ADD("dma2", AM9517A, 0)
- MCFG_I8237_OUT_HREQ_CB(WRITELINE(wd7600_device, dma2_hreq_w))
- MCFG_I8237_IN_MEMR_CB(READ8(wd7600_device, dma_read_word))
- MCFG_I8237_OUT_MEMW_CB(WRITE8(wd7600_device, dma_write_word))
- MCFG_I8237_IN_IOR_1_CB(READ8(wd7600_device, dma2_ior1_r))
- MCFG_I8237_IN_IOR_2_CB(READ8(wd7600_device, dma2_ior2_r))
- MCFG_I8237_IN_IOR_3_CB(READ8(wd7600_device, dma2_ior3_r))
- MCFG_I8237_OUT_IOW_1_CB(WRITE8(wd7600_device, dma2_iow1_w))
- MCFG_I8237_OUT_IOW_2_CB(WRITE8(wd7600_device, dma2_iow2_w))
- MCFG_I8237_OUT_IOW_3_CB(WRITE8(wd7600_device, dma2_iow3_w))
- MCFG_I8237_OUT_DACK_0_CB(WRITELINE(wd7600_device, dma2_dack0_w))
- MCFG_I8237_OUT_DACK_1_CB(WRITELINE(wd7600_device, dma2_dack1_w))
- MCFG_I8237_OUT_DACK_2_CB(WRITELINE(wd7600_device, dma2_dack2_w))
- MCFG_I8237_OUT_DACK_3_CB(WRITELINE(wd7600_device, dma2_dack3_w))
- MCFG_PIC8259_ADD("intc1", WRITELINE(wd7600_device, pic1_int_w), VCC, READ8(wd7600_device, pic1_slave_ack_r))
- MCFG_PIC8259_ADD("intc2", DEVWRITELINE("intc1", pic8259_device, ir2_w), GND, NULL)
-
- MCFG_DEVICE_ADD("ctc", PIT8254, 0)
- MCFG_PIT8253_CLK0(XTAL_14_31818MHz / 12)
- MCFG_PIT8253_OUT0_HANDLER(DEVWRITELINE("intc1", pic8259_device, ir0_w))
- MCFG_PIT8253_CLK1(XTAL_14_31818MHz / 12)
- MCFG_PIT8253_OUT1_HANDLER(WRITELINE(wd7600_device, ctc_out1_w))
- MCFG_PIT8253_CLK2(XTAL_14_31818MHz / 12)
- MCFG_PIT8253_OUT2_HANDLER(WRITELINE(wd7600_device, ctc_out2_w))
-
- MCFG_DS12885_ADD("rtc")
- MCFG_MC146818_IRQ_HANDLER(WRITELINE(wd7600_device, rtc_irq_w))
- MCFG_MC146818_CENTURY_INDEX(0x32)
-MACHINE_CONFIG_END
-
-machine_config_constructor wd7600_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( wd7600 );
-}
-
-void wd7600_device::static_set_cputag(device_t &device, const char *tag)
-{
- wd7600_device &chip = downcast<wd7600_device &>(device);
- chip.m_cputag = tag;
-}
-
-void wd7600_device::static_set_isatag(device_t &device, const char *tag)
-{
- wd7600_device &chip = downcast<wd7600_device &>(device);
- chip.m_isatag = tag;
-}
-
-void wd7600_device::static_set_biostag(device_t &device, const char *tag)
-{
- wd7600_device &chip = downcast<wd7600_device &>(device);
- chip.m_biostag = tag;
-}
-
-void wd7600_device::static_set_keybctag(device_t &device, const char *tag)
-{
- wd7600_device &chip = downcast<wd7600_device &>(device);
- chip.m_keybctag = tag;
-}
-
-wd7600_device::wd7600_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, WD7600, "WD 7600 chipset", tag, owner, clock, "wd7600", __FILE__),
- m_read_ior(*this),
- m_write_iow(*this),
- m_write_tc(*this),
- m_write_hold(*this),
- m_write_nmi(*this),
- m_write_intr(*this),
- m_write_cpureset(*this),
- m_write_a20m(*this),
- m_write_spkr(*this),
- m_dma1(*this, "dma1"),
- m_dma2(*this, "dma2"),
- m_pic1(*this, "intc1"),
- m_pic2(*this, "intc2"),
- m_ctc(*this, "ctc"),
- m_rtc(*this, "rtc"),
- m_portb(0x0f),
- m_iochck(1),
- m_nmi_mask(1),
- m_alt_a20(0),
- m_ext_gatea20(0),
- m_kbrst(1),
- m_refresh_toggle(0),
- m_dma_eop(0),
- m_dma_high_byte(0xff),
- m_dma_channel(-1)
- {}
-
-
-void wd7600_device::device_start()
-{
- ram_device *ram_dev = machine().device<ram_device>(RAM_TAG);
-
- // make sure the ram device is already running
- if (!ram_dev->started())
- throw device_missing_dependencies();
-
- // resolve callbacks
- m_read_ior.resolve_safe(0);
- m_write_iow.resolve_safe();
- m_write_tc.resolve_safe();
- m_write_hold.resolve_safe();
- m_write_nmi.resolve_safe();
- m_write_intr.resolve_safe();
- m_write_cpureset.resolve_safe();
- m_write_a20m.resolve_safe();
- m_write_spkr.resolve_safe();
-
- device_t *cpu = machine().device(m_cputag);
- m_space = &cpu->memory().space(AS_PROGRAM);
- m_space_io = &cpu->memory().space(AS_IO);
-
- m_isa = machine().root_device().memregion(m_isatag)->base();
- m_bios = machine().root_device().memregion(m_biostag)->base();
- m_keybc = downcast<at_keyboard_controller_device *>(machine().device(m_keybctag));
-
- m_ram = ram_dev->pointer();
- UINT32 ram_size = ram_dev->size();
-
- // install base memory
- m_space->install_ram(0x000000, 0x09ffff, m_ram);
- m_space->install_ram(0x0d0000, 0x0effff, m_ram + 0xd0000);
-
- // install extended memory
- if (ram_size > 0x100000)
- m_space->install_ram(0x100000, ram_size - 1, m_ram + 0x100000);
-
- // install video BIOS (we should use the VGA BIOS at the beginning of the system BIOS ROM, but that gives a
- // blank display (but still runs))
- //m_space->install_rom(0x000c0000, 0x000cffff, m_bios + 0xe0000);
- m_space->install_rom(0x000c0000, 0x000cffff, m_isa);
-
- // install BIOS ROM at cpu inital pc
- m_space->install_rom(0x000f0000, 0x000fffff, m_bios + 0xf0000);
- m_space->install_rom(0xffff0000, 0xffffffff, m_bios + 0xf0000);
-
- // install i/o accesses
- m_space_io->install_readwrite_handler(0x0000, 0x000f, read8_delegate(FUNC(am9517a_device::read), &(*m_dma1)), write8_delegate(FUNC(am9517a_device::write), &(*m_dma1)), 0xffffffff);
- m_space_io->install_readwrite_handler(0x0020, 0x003f, read8_delegate(FUNC(pic8259_device::read), &(*m_pic1)), write8_delegate(FUNC(pic8259_device::write), &(*m_pic1)), 0x0000ffff);
- m_space_io->install_readwrite_handler(0x0040, 0x0043, read8_delegate(FUNC(pit8254_device::read), &(*m_ctc)), write8_delegate(FUNC(pit8254_device::write), &(*m_ctc)), 0xffffffff);
- m_space_io->install_readwrite_handler(0x0060, 0x0063, read8_delegate(FUNC(wd7600_device::keyb_data_r), this), write8_delegate(FUNC(wd7600_device::keyb_data_w), this), 0x000000ff);
- m_space_io->install_readwrite_handler(0x0060, 0x0063, read8_delegate(FUNC(wd7600_device::portb_r), this), write8_delegate(FUNC(wd7600_device::portb_w), this), 0x0000ff00);
- m_space_io->install_readwrite_handler(0x0064, 0x0067, read8_delegate(FUNC(wd7600_device::keyb_status_r), this), write8_delegate(FUNC(wd7600_device::keyb_cmd_w), this), 0x000000ff);
- m_space_io->install_readwrite_handler(0x0070, 0x007f, read8_delegate(FUNC(mc146818_device::read), &(*m_rtc)), write8_delegate(FUNC(wd7600_device::rtc_w), this), 0x0000ffff);
- m_space_io->install_readwrite_handler(0x0080, 0x009f, read8_delegate(FUNC(wd7600_device::dma_page_r), this), write8_delegate(FUNC(wd7600_device::dma_page_w), this), 0xffffffff);
- m_space_io->install_readwrite_handler(0x0090, 0x0093, read8_delegate(FUNC(wd7600_device::a20_reset_r), this), write8_delegate(FUNC(wd7600_device::a20_reset_w), this), 0x00ff0000);
- m_space_io->install_readwrite_handler(0x00a0, 0x00a3, read8_delegate(FUNC(pic8259_device::read), &(*m_pic2)), write8_delegate(FUNC(pic8259_device::write), &(*m_pic2)), 0x0000ffff);
- m_space_io->install_readwrite_handler(0x00c0, 0x00df, read8_delegate(FUNC(am9517a_device::read), &(*m_dma2)), write8_delegate(FUNC(am9517a_device::write), &(*m_dma2)), 0x00ff00ff);
- m_space_io->install_readwrite_handler(0x2070, 0x2073, read16_delegate(FUNC(wd7600_device::refresh_r), this), write16_delegate(FUNC(wd7600_device::refresh_w), this), 0xffff0000);
- m_space_io->install_readwrite_handler(0x2870, 0x2873, read16_delegate(FUNC(wd7600_device::chipsel_r), this), write16_delegate(FUNC(wd7600_device::chipsel_w), this), 0xffff0000);
- m_space_io->install_readwrite_handler(0x3870, 0x3873, read16_delegate(FUNC(wd7600_device::mem_ctrl_r), this), write16_delegate(FUNC(wd7600_device::mem_ctrl_w), this), 0xffff0000);
- m_space_io->install_readwrite_handler(0x4870, 0x4873, read16_delegate(FUNC(wd7600_device::bank_01_start_r), this), write16_delegate(FUNC(wd7600_device::bank_01_start_w), this), 0xffff0000);
- m_space_io->install_readwrite_handler(0x5070, 0x5073, read16_delegate(FUNC(wd7600_device::bank_23_start_r), this), write16_delegate(FUNC(wd7600_device::bank_23_start_w), this), 0xffff0000);
- m_space_io->install_readwrite_handler(0x5870, 0x5873, read16_delegate(FUNC(wd7600_device::split_addr_r), this), write16_delegate(FUNC(wd7600_device::split_addr_w), this), 0xffff0000);
- m_space_io->install_readwrite_handler(0x9870, 0x9873, read16_delegate(FUNC(wd7600_device::diag_r), this), write16_delegate(FUNC(wd7600_device::diag_w), this), 0xffff0000);
-}
-
-void wd7600_device::device_reset()
-{
- m_split_start = 0;
- m_chip_sel = 0;
- m_refresh_ctrl = 0;
- m_memory_ctrl = 0;
- m_diagnostic = 0xe080;
-
- for(int x=0;x<4;x++)
- m_bank_start[x] = 0;
-
- // initialize dma controller clocks
- m_dma1->set_unscaled_clock(clock());
- m_dma2->set_unscaled_clock(clock());
-}
-
-
-WRITE_LINE_MEMBER( wd7600_device::iochck_w )
-{
- if (BIT(m_portb, 3) == 0)
- {
- if (m_iochck && state == 0)
- {
- // set channel check latch
- m_portb |= 1 << 6;
- nmi();
- }
-
- m_iochck = state;
- }
-}
-
-void wd7600_device::nmi()
-{
- if (m_nmi_mask & BIT(m_portb, 6))
- {
- m_write_nmi(1);
- m_write_nmi(0);
- }
-}
-
-void wd7600_device::a20m()
-{
- // TODO: ignore keyboard A20 signal if set in Diagnostic register (0x9872)
- m_write_a20m(m_alt_a20 | m_ext_gatea20);
-}
-
-void wd7600_device::keyboard_gatea20(int state)
-{
- m_ext_gatea20 = state;
- a20m();
-}
-
-WRITE8_MEMBER( wd7600_device::rtc_w )
-{
- if (offset == 0)
- {
- m_nmi_mask = !BIT(data, 7);
- data &= 0x7f;
- }
-
- m_rtc->write(space, offset, data);
-}
-
-WRITE_LINE_MEMBER( wd7600_device::rtc_irq_w )
-{
- m_pic2->ir0_w(state ? 0 : 1); // inverted?
-}
-
-READ8_MEMBER( wd7600_device::pic1_slave_ack_r )
-{
- if (offset == 2) // IRQ 2
- return m_pic2->acknowledge();
-
- return 0x00;
-}
-
-// Timer outputs
-WRITE_LINE_MEMBER( wd7600_device::ctc_out1_w )
-{
- m_refresh_toggle ^= state;
- m_portb = (m_portb & 0xef) | (m_refresh_toggle << 4);
-}
-
-WRITE_LINE_MEMBER( wd7600_device::ctc_out2_w )
-{
- m_write_spkr(!(state));
- m_portb = (m_portb & 0xdf) | (state << 5);
-}
-
-// Keyboard
-WRITE8_MEMBER( wd7600_device::keyb_data_w )
-{
-// if(LOG) logerror("WD7600 '%s': keyboard data write %02x\n", tag(), data);
- m_keybc->data_w(space,0,data);
-}
-
-READ8_MEMBER( wd7600_device::keyb_data_r )
-{
- UINT8 ret = m_keybc->data_r(space,0);
-// if(LOG) logerror("WD7600 '%s': keyboard data read %02x\n", tag(), ret);
- return ret;
-}
-
-WRITE8_MEMBER( wd7600_device::keyb_cmd_w )
-{
-// if(LOG) logerror("WD7600 '%s': keyboard command %02x\n", tag(), data);
- m_keybc->command_w(space,0,data);
-}
-
-READ8_MEMBER( wd7600_device::keyb_status_r )
-{
- return m_keybc->status_r(space,0);
-}
-
-READ8_MEMBER( wd7600_device::portb_r )
-{
- return m_portb;
-}
-
-WRITE8_MEMBER( wd7600_device::portb_w )
-{
- m_portb = (m_portb & 0xf0) | (data & 0x0f);
-
- // bit 5 forced to 1 if timer disabled
- if (!BIT(m_portb, 0))
- m_portb |= 1 << 5;
-
- m_ctc->write_gate2(BIT(m_portb, 0));
-
- m_write_spkr(!BIT(m_portb, 1));
-
- // clear channel check latch?
- if (BIT(m_portb, 3))
- m_portb &= 0xbf;
-}
-
-// DMA controllers
-offs_t wd7600_device::page_offset()
-{
- switch (m_dma_channel)
- {
- case 0: return (offs_t) m_dma_page[0x07] << 16;
- case 1: return (offs_t) m_dma_page[0x03] << 16;
- case 2: return (offs_t) m_dma_page[0x01] << 16;
- case 3: return (offs_t) m_dma_page[0x02] << 16;
- case 5: return (offs_t) m_dma_page[0x0b] << 16;
- case 6: return (offs_t) m_dma_page[0x09] << 16;
- case 7: return (offs_t) m_dma_page[0x0a] << 16;
- }
-
- // should never get here
- return 0xff0000;
-}
-
-READ8_MEMBER( wd7600_device::dma_read_byte )
-{
- if (m_dma_channel == -1)
- return 0xff;
-
- return m_space->read_byte(page_offset() + offset);
-}
-
-WRITE8_MEMBER( wd7600_device::dma_write_byte )
-{
- if (m_dma_channel == -1)
- return;
-
- m_space->write_byte(page_offset() + offset, data);
-}
-
-READ8_MEMBER( wd7600_device::dma_read_word )
-{
- if (m_dma_channel == -1)
- return 0xff;
-
- UINT16 result = m_space->read_word(page_offset() + (offset << 1));
- m_dma_high_byte = result >> 8;
-
- return result;
-}
-
-WRITE8_MEMBER( wd7600_device::dma_write_word )
-{
- if (m_dma_channel == -1)
- return;
-
- m_space->write_word(page_offset() + (offset << 1), (m_dma_high_byte << 8) | data);
-}
-
-WRITE_LINE_MEMBER( wd7600_device::dma2_dack0_w )
-{
- m_dma1->hack_w(state ? 0 : 1); // inverted?
-}
-
-WRITE_LINE_MEMBER( wd7600_device::dma1_eop_w )
-{
- m_dma_eop = state;
- if (m_dma_channel != -1)
- m_write_tc(m_dma_channel, state, 0xff);
-}
-
-void wd7600_device::set_dma_channel(int channel, bool state)
-{
- if (!state)
- {
- m_dma_channel = channel;
- if (m_dma_eop)
- m_write_tc(channel, 1, 0xff);
- }
- else
- {
- if (m_dma_channel == channel)
- {
- m_dma_channel = -1;
- if (m_dma_eop)
- m_write_tc(channel, 0, 0xff);
- }
- }
-}
-
-WRITE_LINE_MEMBER( wd7600_device::gatea20_w )
-{
- keyboard_gatea20(state);
-}
-
-WRITE_LINE_MEMBER( wd7600_device::kbrst_w )
-{
- // convert to active low signal (gets inverted in at_keybc.c)
- state = (state == ASSERT_LINE ? 0 : 1);
-
- // detect transition
- if (m_kbrst == 1 && state == 0)
- {
- m_write_cpureset(1);
- m_write_cpureset(0);
- }
-
- m_kbrst = state;
-}
-
-WRITE8_MEMBER( wd7600_device::a20_reset_w )
-{
- m_alt_a20 = BIT(data,1);
- a20m();
- // TODO: proper timing. Reset occurs 128 cycles after changing to a 1, and lasts for 16 cycles
- if(BIT(data,0))
- {
- m_write_cpureset(1);
- m_write_cpureset(0);
- if(LOG) logerror("WD7600 '%s': System reset\n",tag());
- }
-}
-
-READ8_MEMBER( wd7600_device::a20_reset_r )
-{
- UINT8 ret = 0;
- if(m_alt_a20)
- ret |= 0x02;
- return ret;
-}
-
-// port 0x2072 - Refresh Control, and serial/parallel port address select
-READ16_MEMBER(wd7600_device::refresh_r)
-{
- return m_refresh_ctrl;
-}
-
-WRITE16_MEMBER(wd7600_device::refresh_w)
-{
- // TODO: select serial/parallel I/O port location
- m_refresh_ctrl = data;
- if(LOG) logerror("WD7600 '%s': Refresh Control write %04x\n",tag(),data);
-}
-
-// port 0x2872 - chip select
-READ16_MEMBER(wd7600_device::chipsel_r)
-{
- return m_chip_sel;
-}
-
-WRITE16_MEMBER(wd7600_device::chipsel_w)
-{
- m_chip_sel = data;
- if(LOG) logerror("WD7600 '%s': Chip Select write %04x\n",tag(),data);
-}
-
-// port 0x3872 - Memory Control
-READ16_MEMBER(wd7600_device::mem_ctrl_r)
-{
- return m_memory_ctrl;
-}
-
-WRITE16_MEMBER(wd7600_device::mem_ctrl_w)
-{
- m_memory_ctrl = data;
- if(LOG) logerror("WD7600 '%s': Memory Control write %04x\n",tag(),data);
-}
-
-// port 0x4872 - Bank 0 and 1 start address
-READ16_MEMBER(wd7600_device::bank_01_start_r)
-{
- return (m_bank_start[1] << 8) | m_bank_start[0];
-}
-
-WRITE16_MEMBER(wd7600_device::bank_01_start_w)
-{
- if(ACCESSING_BITS_0_7)
- {
- m_bank_start[0] = data & 0xff;
- if(LOG) logerror("WD7600 '%s': Bank 0 start address %08x\n",tag(),m_bank_start[0] << 16);
- }
- if(ACCESSING_BITS_8_15)
- {
- m_bank_start[1] = (data & 0xff00) >> 8;
- if(LOG) logerror("WD7600 '%s': Bank 1 start address %08x\n",tag(),m_bank_start[1] << 16);
- }
-}
-
-// port 0x5072 - Bank 2 and 3 start address
-READ16_MEMBER(wd7600_device::bank_23_start_r)
-{
- return (m_bank_start[3] << 8) | m_bank_start[2];
-}
-
-WRITE16_MEMBER(wd7600_device::bank_23_start_w)
-{
- if(ACCESSING_BITS_0_7)
- {
- m_bank_start[2] = data & 0xff;
- if(LOG) logerror("WD7600 '%s': Bank 2 start address %08x\n",tag(),m_bank_start[2] << 16);
- }
- if(ACCESSING_BITS_8_15)
- {
- m_bank_start[3] = (data & 0xff00) >> 8;
- if(LOG) logerror("WD7600 '%s': Bank 3 start address %08x\n",tag(),m_bank_start[3] << 16);
- }
-}
-
-// port 0x5872 - split starting address (used for BIOS shadowing)
-READ16_MEMBER(wd7600_device::split_addr_r)
-{
- return m_split_start;
-}
-
-WRITE16_MEMBER(wd7600_device::split_addr_w)
-{
- m_split_start = data;
- if(LOG) logerror("WD7600 '%s': Split start address write %04x\n",tag(),data);
-}
-
-// port 0x9872 - Diagnostic
-READ16_MEMBER(wd7600_device::diag_r)
-{
- return m_diagnostic | 0xe080;
-}
-
-WRITE16_MEMBER(wd7600_device::diag_w)
-{
- m_diagnostic = data;
- if(LOG) logerror("WD7600 '%s': Diagnostic write %04x\n",tag(),data);
-}
diff --git a/src/emu/machine/wd7600.h b/src/emu/machine/wd7600.h
deleted file mode 100644
index 7cfada03261..00000000000
--- a/src/emu/machine/wd7600.h
+++ /dev/null
@@ -1,240 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Barry Rodewald
-/*
- * wd7600.h
- *
- * Created on: 5/05/2014
- */
-
-#ifndef WD7600_H_
-#define WD7600_H_
-
-#include "emu.h"
-#include "machine/am9517a.h"
-#include "machine/pic8259.h"
-#include "machine/pit8253.h"
-#include "machine/ds128x.h"
-#include "machine/at_keybc.h"
-#include "machine/ram.h"
-
-
-#define MCFG_WD7600_ADD(_tag, _clock, _cputag, _isatag, _biostag, _keybctag) \
- MCFG_DEVICE_ADD(_tag, WD7600, _clock) \
- wd7600_device::static_set_cputag(*device, _cputag); \
- wd7600_device::static_set_isatag(*device, _isatag); \
- wd7600_device::static_set_biostag(*device, _biostag); \
- wd7600_device::static_set_keybctag(*device, _keybctag);
-
-#define MCFG_WD7600_IOR(_ior) \
- downcast<wd7600_device *>(device)->set_ior_callback(DEVCB_##_ior);
-
-#define MCFG_WD7600_IOW(_iow) \
- downcast<wd7600_device *>(device)->set_iow_callback(DEVCB_##_iow);
-
-#define MCFG_WD7600_TC(_tc) \
- downcast<wd7600_device *>(device)->set_tc_callback(DEVCB_##_tc);
-
-#define MCFG_WD7600_HOLD(_hold) \
- downcast<wd7600_device *>(device)->set_hold_callback(DEVCB_##_hold);
-
-#define MCFG_WD7600_NMI(_nmi) \
- downcast<wd7600_device *>(device)->set_nmi_callback(DEVCB_##_nmi);
-
-#define MCFG_WD7600_INTR(_intr) \
- downcast<wd7600_device *>(device)->set_intr_callback(DEVCB_##_intr);
-
-#define MCFG_WD7600_CPURESET(_cpureset) \
- downcast<wd7600_device *>(device)->set_cpureset_callback(DEVCB_##_cpureset);
-
-#define MCFG_WD7600_A20M(_a20m) \
- downcast<wd7600_device *>(device)->set_a20m_callback(DEVCB_##_a20m);
-
-#define MCFG_WD7600_SPKR(_spkr) \
- downcast<wd7600_device *>(device)->set_spkr_callback(DEVCB_##_spkr);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> wd7600_device
-
-class wd7600_device : public device_t
-{
-public:
- // construction/destruction
- wd7600_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // optional information overrides
- virtual machine_config_constructor device_mconfig_additions() const;
-
- // callbacks
- template<class _ior> void set_ior_callback(_ior ior) { m_read_ior.set_callback(ior); }
- template<class _iow> void set_iow_callback(_iow iow) { m_write_iow.set_callback(iow); }
- template<class _tc> void set_tc_callback(_tc tc) { m_write_tc.set_callback(tc); }
- template<class _hold> void set_hold_callback(_hold hold) { m_write_hold.set_callback(hold); }
- template<class _cpureset> void set_cpureset_callback(_cpureset cpureset) { m_write_cpureset.set_callback(cpureset); }
- template<class _nmi> void set_nmi_callback(_nmi nmi) { m_write_nmi.set_callback(nmi); }
- template<class _intr> void set_intr_callback(_intr intr) { m_write_intr.set_callback(intr); }
- template<class _a20m> void set_a20m_callback(_a20m a20m) { m_write_a20m.set_callback(a20m); }
- template<class _spkr> void set_spkr_callback(_spkr spkr) { m_write_spkr.set_callback(spkr); }
-
- // inline configuration
- static void static_set_cputag(device_t &device, const char *tag);
- static void static_set_isatag(device_t &device, const char *tag);
- static void static_set_biostag(device_t &device, const char *tag);
- static void static_set_keybctag(device_t &device, const char *tag);
-
- DECLARE_WRITE_LINE_MEMBER(rtc_irq_w);
- DECLARE_WRITE_LINE_MEMBER( pic1_int_w ) { m_write_intr(state); }
- DECLARE_READ8_MEMBER( pic1_slave_ack_r );
- DECLARE_WRITE_LINE_MEMBER( ctc_out1_w );
- DECLARE_WRITE_LINE_MEMBER( ctc_out2_w );
- DECLARE_WRITE8_MEMBER( rtc_w );
- DECLARE_WRITE8_MEMBER( keyb_cmd_w );
- DECLARE_WRITE8_MEMBER( keyb_data_w );
- DECLARE_READ8_MEMBER( keyb_data_r );
- DECLARE_READ8_MEMBER( keyb_status_r );
- DECLARE_WRITE8_MEMBER( a20_reset_w );
- DECLARE_READ8_MEMBER( a20_reset_r );
- DECLARE_READ8_MEMBER( portb_r );
- DECLARE_WRITE8_MEMBER( portb_w );
- DECLARE_WRITE8_MEMBER( dma_page_w ) { m_dma_page[offset & 0x0f] = data; }
- DECLARE_READ8_MEMBER( dma_page_r ) { return m_dma_page[offset & 0x0f]; }
- DECLARE_READ8_MEMBER( dma_read_byte );
- DECLARE_WRITE8_MEMBER( dma_write_byte );
- DECLARE_READ8_MEMBER( dma_read_word );
- DECLARE_WRITE8_MEMBER( dma_write_word );
- DECLARE_WRITE_LINE_MEMBER( dma1_eop_w );
- DECLARE_READ8_MEMBER( dma1_ior0_r ) { return m_read_ior(0); }
- DECLARE_READ8_MEMBER( dma1_ior1_r ) { return m_read_ior(1); }
- DECLARE_READ8_MEMBER( dma1_ior2_r ) { return m_read_ior(2); }
- DECLARE_READ8_MEMBER( dma1_ior3_r ) { return m_read_ior(3); }
- DECLARE_READ8_MEMBER( dma2_ior1_r ) { UINT16 result = m_read_ior(5); m_dma_high_byte = result >> 8; return result; }
- DECLARE_READ8_MEMBER( dma2_ior2_r ) { UINT16 result = m_read_ior(6); m_dma_high_byte = result >> 8; return result; }
- DECLARE_READ8_MEMBER( dma2_ior3_r ) { UINT16 result = m_read_ior(7); m_dma_high_byte = result >> 8; return result; }
- DECLARE_WRITE8_MEMBER( dma1_iow0_w ) { m_write_iow(0, data, 0xffff); }
- DECLARE_WRITE8_MEMBER( dma1_iow1_w ) { m_write_iow(1, data, 0xffff); }
- DECLARE_WRITE8_MEMBER( dma1_iow2_w ) { m_write_iow(2, data, 0xffff); }
- DECLARE_WRITE8_MEMBER( dma1_iow3_w ) { m_write_iow(3, data, 0xffff); }
- DECLARE_WRITE8_MEMBER( dma2_iow1_w ) { m_write_iow(5, (m_dma_high_byte << 8) | data, 0xffff); }
- DECLARE_WRITE8_MEMBER( dma2_iow2_w ) { m_write_iow(6, (m_dma_high_byte << 8) | data, 0xffff); }
- DECLARE_WRITE8_MEMBER( dma2_iow3_w ) { m_write_iow(7, (m_dma_high_byte << 8) | data, 0xffff); }
- DECLARE_WRITE_LINE_MEMBER( dma1_dack0_w ) { set_dma_channel(0, state); }
- DECLARE_WRITE_LINE_MEMBER( dma1_dack1_w ) { set_dma_channel(1, state); }
- DECLARE_WRITE_LINE_MEMBER( dma1_dack2_w ) { set_dma_channel(2, state); }
- DECLARE_WRITE_LINE_MEMBER( dma1_dack3_w ) { set_dma_channel(3, state); }
- DECLARE_WRITE_LINE_MEMBER( dma2_dack0_w );
- DECLARE_WRITE_LINE_MEMBER( dma2_dack1_w ) { set_dma_channel(5, state); }
- DECLARE_WRITE_LINE_MEMBER( dma2_dack2_w ) { set_dma_channel(6, state); }
- DECLARE_WRITE_LINE_MEMBER( dma2_dack3_w ) { set_dma_channel(7, state); }
- DECLARE_WRITE_LINE_MEMBER( dma2_hreq_w ) { m_write_hold(state); }
-
- // input lines
- DECLARE_WRITE_LINE_MEMBER( irq01_w ) { m_pic1->ir1_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq03_w ) { m_pic1->ir3_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq04_w ) { m_pic1->ir4_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq05_w ) { m_pic1->ir5_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq06_w ) { m_pic1->ir6_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq07_w ) { m_pic1->ir7_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq09_w ) { m_pic2->ir1_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq10_w ) { m_pic2->ir2_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq11_w ) { m_pic2->ir3_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq12_w ) { m_pic2->ir4_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq13_w ) { m_pic2->ir5_w(state); } // also FERR#
- DECLARE_WRITE_LINE_MEMBER( irq14_w ) { m_pic2->ir6_w(state); }
- DECLARE_WRITE_LINE_MEMBER( irq15_w ) { m_pic2->ir7_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq0_w ) { m_dma1->dreq0_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq1_w ) { m_dma1->dreq1_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq2_w ) { m_dma1->dreq2_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq3_w ) { m_dma1->dreq3_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq5_w ) { m_dma2->dreq1_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq6_w ) { m_dma2->dreq2_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dreq7_w ) { m_dma2->dreq3_w(state); }
- DECLARE_WRITE_LINE_MEMBER( hlda_w ) { m_dma2->hack_w(state); }
- DECLARE_WRITE_LINE_MEMBER( iochck_w );
- DECLARE_WRITE_LINE_MEMBER( gatea20_w );
- DECLARE_WRITE_LINE_MEMBER( kbrst_w );
-
- DECLARE_READ16_MEMBER(refresh_r);
- DECLARE_WRITE16_MEMBER(refresh_w);
- DECLARE_READ16_MEMBER(chipsel_r);
- DECLARE_WRITE16_MEMBER(chipsel_w);
- DECLARE_READ16_MEMBER(mem_ctrl_r);
- DECLARE_WRITE16_MEMBER(mem_ctrl_w);
- DECLARE_READ16_MEMBER(bank_01_start_r);
- DECLARE_WRITE16_MEMBER(bank_01_start_w);
- DECLARE_READ16_MEMBER(bank_23_start_r);
- DECLARE_WRITE16_MEMBER(bank_23_start_w);
- DECLARE_READ16_MEMBER(split_addr_r);
- DECLARE_WRITE16_MEMBER(split_addr_w);
- DECLARE_READ16_MEMBER(diag_r);
- DECLARE_WRITE16_MEMBER(diag_w);
-
- IRQ_CALLBACK_MEMBER(intack_cb) { return m_pic1->acknowledge(); }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
-private:
- devcb_read16 m_read_ior;
- devcb_write16 m_write_iow;
- devcb_write8 m_write_tc;
- devcb_write_line m_write_hold;
- devcb_write_line m_write_nmi;
- devcb_write_line m_write_intr;
- devcb_write_line m_write_cpureset;
- devcb_write_line m_write_a20m;
- devcb_write_line m_write_spkr;
-
- required_device<am9517a_device> m_dma1;
- required_device<am9517a_device> m_dma2;
- required_device<pic8259_device> m_pic1;
- required_device<pic8259_device> m_pic2;
- required_device<pit8254_device> m_ctc;
- required_device<ds12885_device> m_rtc;
-
- offs_t page_offset();
- void set_dma_channel(int channel, bool state);
- void keyboard_gatea20(int state);
- void nmi();
- void a20m();
-
- // internal state
- const char *m_cputag;
- const char *m_isatag;
- const char *m_biostag;
- const char *m_keybctag;
- UINT8 m_portb;
- int m_iochck;
- int m_nmi_mask;
- int m_alt_a20;
- int m_ext_gatea20;
- int m_kbrst;
- int m_refresh_toggle;
- UINT16 m_refresh_ctrl;
- UINT16 m_memory_ctrl;
- UINT16 m_chip_sel;
- UINT16 m_split_start;
- UINT8 m_bank_start[4];
- UINT16 m_diagnostic;
-
- int m_dma_eop;
- UINT8 m_dma_page[0x10];
- UINT8 m_dma_high_byte;
- int m_dma_channel;
-
- address_space *m_space;
- address_space *m_space_io;
- UINT8 *m_isa;
- UINT8 *m_bios;
- UINT8 *m_ram;
- at_keyboard_controller_device *m_keybc;
-};
-
-// device type definition
-extern const device_type WD7600;
-
-#endif /* WD7600_H_ */
diff --git a/src/emu/machine/wd_fdc.c b/src/emu/machine/wd_fdc.c
deleted file mode 100644
index 8b27486c79a..00000000000
--- a/src/emu/machine/wd_fdc.c
+++ /dev/null
@@ -1,2831 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#include "wd_fdc.h"
-
-#include "debugger.h"
-
-const device_type FD1771 = &device_creator<fd1771_t>;
-const device_type FD1781 = &device_creator<fd1781_t>;
-const device_type FD1791 = &device_creator<fd1791_t>;
-const device_type FD1792 = &device_creator<fd1792_t>;
-const device_type FD1793 = &device_creator<fd1793_t>;
-const device_type KR1818VG93 = &device_creator<kr1818vg93_t>;
-const device_type FD1794 = &device_creator<fd1794_t>;
-const device_type FD1795 = &device_creator<fd1795_t>;
-const device_type FD1797 = &device_creator<fd1797_t>;
-const device_type MB8866 = &device_creator<mb8866_t>;
-const device_type MB8876 = &device_creator<mb8876_t>;
-const device_type MB8877 = &device_creator<mb8877_t>;
-const device_type FD1761 = &device_creator<fd1761_t>;
-const device_type FD1763 = &device_creator<fd1763_t>;
-const device_type FD1765 = &device_creator<fd1765_t>;
-const device_type FD1767 = &device_creator<fd1767_t>;
-const device_type WD2791 = &device_creator<wd2791_t>;
-const device_type WD2793 = &device_creator<wd2793_t>;
-const device_type WD2795 = &device_creator<wd2795_t>;
-const device_type WD2797 = &device_creator<wd2797_t>;
-const device_type WD1770 = &device_creator<wd1770_t>;
-const device_type WD1772 = &device_creator<wd1772_t>;
-const device_type WD1773 = &device_creator<wd1773_t>;
-
-/*
- Debugging flags. Set to 0 or 1.
-*/
-
-// Shows shift register contents
-#define TRACE_SHIFT 0
-
-// Shows operations on the CPU side
-#define TRACE_COMP 0
-
-// Shows command invocation
-#define TRACE_COMMAND 0
-
-// Shows sync actions
-#define TRACE_SYNC 0
-
-// Show control lines
-#define TRACE_LINES 0
-
-// Show events
-#define TRACE_EVENT 0
-
-// Show sector match operation
-#define TRACE_MATCH 0
-
-// Show track description
-#define TRACE_DESC 0
-
-// Show write operation on image
-#define TRACE_WRITE 0
-
-// Show transitions
-#define TRACE_TRANSITION 0
-
-// Show state machine
-#define TRACE_STATE 0
-
-wd_fdc_t::wd_fdc_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- intrq_cb(*this),
- drq_cb(*this),
- hld_cb(*this),
- enp_cb(*this),
- enmf_cb(*this)
-{
- force_ready = false;
-}
-
-void wd_fdc_t::set_force_ready(bool _force_ready)
-{
- force_ready = _force_ready;
-}
-
-void wd_fdc_t::device_start()
-{
- intrq_cb.resolve();
- drq_cb.resolve();
- hld_cb.resolve();
- enp_cb.resolve();
- enmf_cb.resolve();
-
- if (!has_enmf && !enmf_cb.isnull())
- logerror("%s: Warning, this chip doesn't have an ENMF line.\n", tag());
-
- t_gen = timer_alloc(TM_GEN);
- t_cmd = timer_alloc(TM_CMD);
- t_track = timer_alloc(TM_TRACK);
- t_sector = timer_alloc(TM_SECTOR);
- dden = disable_mfm;
- enmf = false;
- floppy = 0;
- status = 0x00;
-
- save_item(NAME(status));
- save_item(NAME(command));
- save_item(NAME(main_state));
- save_item(NAME(sub_state));
- save_item(NAME(track));
- save_item(NAME(sector));
- save_item(NAME(intrq_cond));
- save_item(NAME(cmd_buffer));
- save_item(NAME(track_buffer));
- save_item(NAME(sector_buffer));
- save_item(NAME(counter));
- save_item(NAME(status_type_1));
- save_item(NAME(last_dir));
-}
-
-void wd_fdc_t::device_reset()
-{
- soft_reset();
-}
-
-void wd_fdc_t::soft_reset()
-{
- command = 0x00;
- main_state = IDLE;
- sub_state = IDLE;
- cur_live.state = IDLE;
- track = 0x00;
- sector = 0x01;
- status = 0x00;
- data = 0x00;
- cmd_buffer = track_buffer = sector_buffer = -1;
- counter = 0;
- status_type_1 = true;
- last_dir = 1;
-
- // gnd == enmf enabled, otherwise disabled (default)
- if (!enmf_cb.isnull() && has_enmf)
- enmf = enmf_cb() ? false : true;
-
- intrq = false;
- if (!intrq_cb.isnull())
- {
- intrq_cb(intrq);
- }
- drq = false;
- if (!drq_cb.isnull())
- {
- drq_cb(drq);
- }
- hld = false;
- intrq_cond = 0;
- live_abort();
-
- // restore
- last_dir = 1;
- seek_start(RESTORE);
-}
-
-void wd_fdc_t::set_floppy(floppy_image_device *_floppy)
-{
- if(floppy == _floppy)
- return;
-
- int prev_ready = floppy ? floppy->ready_r() : 1;
-
- if(floppy) {
- // Warning: deselecting a drive does *not* stop its motor if it was running
- floppy->setup_index_pulse_cb(floppy_image_device::index_pulse_cb());
- floppy->setup_ready_cb(floppy_image_device::ready_cb());
- }
-
- floppy = _floppy;
-
- int next_ready = floppy ? floppy->ready_r() : 1;
-
- if(floppy) {
- if(motor_control)
- floppy->mon_w(status & S_MON ? 0 : 1);
- floppy->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(wd_fdc_t::index_callback), this));
- floppy->setup_ready_cb(floppy_image_device::ready_cb(FUNC(wd_fdc_t::ready_callback), this));
- }
-
- if(prev_ready != next_ready)
- ready_callback(floppy, next_ready);
-}
-
-void wd_fdc_t::dden_w(bool _dden)
-{
- if(disable_mfm) {
- logerror("%s: Error, this chip does not have a dden line\n", tag());
- return;
- }
-
- if(dden != _dden) {
- dden = _dden;
- if (TRACE_LINES) logerror("%s: select %s\n", tag(), dden ? "fm" : "mfm");
- }
-}
-
-std::string wd_fdc_t::tts(const attotime &t)
-{
- char buf[256];
- int nsec = t.attoseconds() / ATTOSECONDS_PER_NANOSECOND;
- sprintf(buf, "%4d.%03d,%03d,%03d", int(t.seconds()), nsec/1000000, (nsec/1000)%1000, nsec % 1000);
- return buf;
-}
-
-std::string wd_fdc_t::ttsn()
-{
- return tts(machine().time());
-}
-
-void wd_fdc_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if (TRACE_EVENT) logerror("%s: Event fired for timer %s\n", tag(), (id==TM_GEN)? "TM_GEN" : (id==TM_CMD)? "TM_CMD" : (id==TM_TRACK)? "TM_TRACK" : "TM_SECTOR");
- live_sync();
-
- switch(id) {
- case TM_GEN: do_generic(); break;
- case TM_CMD: do_cmd_w(); break;
- case TM_TRACK: do_track_w(); break;
- case TM_SECTOR: do_sector_w(); break;
- }
-
- general_continue();
-}
-
-void wd_fdc_t::command_end()
-{
- main_state = sub_state = IDLE;
- motor_timeout = 0;
-
- if (!drq) {
- status &= ~S_BUSY;
- intrq = true;
- if(!intrq_cb.isnull())
- intrq_cb(intrq);
- }
-}
-
-void wd_fdc_t::seek_start(int state)
-{
- if (TRACE_COMMAND) logerror("%s: seek %d (track=%d)\n", tag(), data, track);
- main_state = state;
- status &= ~(S_CRC|S_RNF|S_SPIN);
- if(head_control) {
- // TODO get value from HLT callback
- if(command & 8)
- status |= S_HLD;
- else
- status &= ~S_HLD;
- }
- sub_state = motor_control ? SPINUP : SPINUP_DONE;
- status_type_1 = true;
- seek_continue();
-}
-
-void wd_fdc_t::seek_continue()
-{
- for(;;) {
- switch(sub_state) {
- case SPINUP:
- if (TRACE_STATE) logerror("%s: SPINUP\n", tag());
- if(!(status & S_MON)) {
- spinup();
- return;
- }
- if(!(command & 0x08))
- status |= S_SPIN;
- sub_state = SPINUP_DONE;
- break;
-
- case SPINUP_WAIT:
- if (TRACE_STATE) logerror("%s: SPINUP_WAIT\n", tag());
- return;
-
- case SPINUP_DONE:
- if (TRACE_STATE) logerror("%s: SPINUP_DONE\n", tag());
- if(main_state == RESTORE && floppy && !floppy->trk00_r()) {
- sub_state = SEEK_WAIT_STEP_TIME;
- delay_cycles(t_gen, step_times[command & 3]);
- }
-
- if(main_state == SEEK && track == data) {
- sub_state = SEEK_WAIT_STABILIZATION_TIME;
- delay_cycles(t_gen, 30000);
- }
-
- if(sub_state == SPINUP_DONE) {
- counter = 0;
- sub_state = SEEK_MOVE;
- }
- break;
-
- case SEEK_MOVE:
- if (TRACE_STATE) logerror("%s: SEEK_MOVE\n", tag());
- if(floppy) {
- floppy->dir_w(last_dir);
- floppy->stp_w(0);
- floppy->stp_w(1);
- }
- // When stepping with update, the track register is updated before seeking.
- // Important for the sam coupe format code.
- if(main_state == STEP && (command & 0x10))
- track += last_dir ? -1 : 1;
- counter++;
- sub_state = SEEK_WAIT_STEP_TIME;
- delay_cycles(t_gen, step_times[command & 3]);
- return;
-
- case SEEK_WAIT_STEP_TIME:
- if (TRACE_STATE) logerror("%s: SEEK_WAIT_STEP_TIME\n", tag());
- return;
-
- case SEEK_WAIT_STEP_TIME_DONE: {
- if (TRACE_STATE) logerror("%s: SEEK_WAIT_STEP_TIME_DONE\n", tag());
- bool done = false;
- switch(main_state) {
- case RESTORE:
- done = floppy && !floppy->trk00_r();
- break;
- case SEEK:
- track += last_dir ? -1 : 1;
- done = track == data;
- break;
- case STEP:
- done = true;
- break;
- }
-
- if(done || counter == 255) {
- if(main_state == RESTORE)
- track = 0;
-
- if(command & 0x04) {
- sub_state = SEEK_WAIT_STABILIZATION_TIME;
- delay_cycles(t_gen, 30000);
- return;
- } else
- sub_state = SEEK_DONE;
-
- } else
- sub_state = SEEK_MOVE;
-
- break;
- }
-
- case SEEK_WAIT_STABILIZATION_TIME:
- if (TRACE_STATE) logerror("%s: SEEK_WAIT_STABILIZATION_TIME\n", tag());
- return;
-
- case SEEK_WAIT_STABILIZATION_TIME_DONE:
- if (TRACE_STATE) logerror("%s: SEEK_WAIT_STABILIZATION_TIME_DONE\n", tag());
- sub_state = SEEK_DONE;
- break;
-
- case SEEK_DONE:
- if (TRACE_STATE) logerror("%s: SEEK_DONE\n", tag());
- status |= S_HLD;
- if(command & 0x04) {
- if(!is_ready()) {
- status |= S_RNF;
- command_end();
- return;
- }
- sub_state = SCAN_ID;
- counter = 0;
- live_start(SEARCH_ADDRESS_MARK_HEADER);
- return;
- }
- command_end();
- return;
-
- case SCAN_ID:
- if (TRACE_STATE) logerror("%s: SCAN_ID\n", tag());
- if(cur_live.idbuf[0] != track) {
- live_start(SEARCH_ADDRESS_MARK_HEADER);
- return;
- }
- if(cur_live.crc) {
- status |= S_CRC;
- live_start(SEARCH_ADDRESS_MARK_HEADER);
- return;
- }
- command_end();
- return;
-
- case SCAN_ID_FAILED:
- if (TRACE_STATE) logerror("%s: SCAN_ID_FAILED\n", tag());
- status |= S_RNF;
- command_end();
- return;
-
- default:
- logerror("%s: seek unknown sub-state %d\n", ttsn().c_str(), sub_state);
- return;
- }
- }
-}
-
-bool wd_fdc_t::sector_matches() const
-{
- if(TRACE_MATCH)
- logerror("%s: matching read T=%02x H=%02x S=%02x L=%02x - searched T=%02x S=%02x\n", tag(),
- cur_live.idbuf[0], cur_live.idbuf[1], cur_live.idbuf[2], cur_live.idbuf[3],
- track, sector);
-
- if(cur_live.idbuf[0] != track || cur_live.idbuf[2] != sector)
- return false;
- if(!side_compare || ((command & 2)==0))
- return true;
- if(command & 8)
- return cur_live.idbuf[1] & 1;
- else
- return !(cur_live.idbuf[1] & 1);
-}
-
-bool wd_fdc_t::is_ready()
-{
- return !ready_hooked || force_ready || (floppy && !floppy->ready_r());
-}
-
-void wd_fdc_t::read_sector_start()
-{
- if (TRACE_COMMAND) logerror("%s: read sector%s (c=%02x) t=%d, s=%d\n", tag(), command & 0x10 ? " multiple" : "", command, track, sector);
- if(!is_ready()) {
- command_end();
- return;
- }
-
- main_state = READ_SECTOR;
- status &= ~(S_CRC|S_LOST|S_RNF|S_WP|S_DDM);
- drop_drq();
- if(side_control && floppy)
- floppy->ss_w((command & 0x02) ? 1 : 0);
- sub_state = motor_control ? SPINUP : SPINUP_DONE;
- status_type_1 = false;
- read_sector_continue();
-}
-
-void wd_fdc_t::read_sector_continue()
-{
- for(;;) {
- switch(sub_state) {
- case SPINUP:
- if (TRACE_STATE) logerror("%s: SPINUP\n", tag());
- if(!(status & S_MON)) {
- spinup();
- return;
- }
- sub_state = SPINUP_DONE;
- break;
-
- case SPINUP_WAIT:
- if (TRACE_STATE) logerror("%s: SPINUP_WAIT\n", tag());
- return;
-
- case SPINUP_DONE:
- if (TRACE_STATE) logerror("%s: SPINUP_DONE\n", tag());
- if(command & 4) {
- sub_state = SETTLE_WAIT;
- delay_cycles(t_gen, settle_time());
- return;
- } else {
- sub_state = SETTLE_DONE;
- break;
- }
-
- case SETTLE_WAIT:
- if (TRACE_STATE) logerror("%s: SETTLE_WAIT\n", tag());
- return;
-
- case SETTLE_DONE:
- if (TRACE_STATE) logerror("%s: SETTLE_DONE\n", tag());
- sub_state = SCAN_ID;
- counter = 0;
- live_start(SEARCH_ADDRESS_MARK_HEADER);
- return;
-
- case SCAN_ID:
- if (TRACE_STATE) logerror("%s: SCAN_ID\n", tag());
- if(!sector_matches()) {
- live_start(SEARCH_ADDRESS_MARK_HEADER);
- return;
- }
- if(cur_live.crc) {
- status |= S_CRC;
- live_start(SEARCH_ADDRESS_MARK_HEADER);
- return;
- }
- sector_size = calc_sector_size(cur_live.idbuf[3], command);
- sub_state = SECTOR_READ;
- live_start(SEARCH_ADDRESS_MARK_DATA);
- return;
-
- case SCAN_ID_FAILED:
- if (TRACE_STATE) logerror("%s: SCAN_ID_FAILED\n", tag());
- status |= S_RNF;
- command_end();
- return;
-
- case SECTOR_READ:
- if (TRACE_STATE) logerror("%s: SECTOR_READ\n", tag());
- if(cur_live.crc)
- status |= S_CRC;
-
- if(command & 0x10 && !(status & S_RNF)) {
- sector++;
- sub_state = SETTLE_DONE;
- } else {
- command_end();
- return;
- }
- break;
-
- default:
- logerror("%s: read sector unknown sub-state %d\n", ttsn().c_str(), sub_state);
- return;
- }
- }
-}
-
-void wd_fdc_t::read_track_start()
-{
- if (TRACE_COMMAND) logerror("%s: read track (c=%02x) t=%d\n", tag(), command, track);
-
- if(!is_ready()) {
- command_end();
- return;
- }
-
- main_state = READ_TRACK;
- status &= ~(S_LOST|S_RNF);
- drop_drq();
- if(side_control && floppy)
- floppy->ss_w((command & 0x02) ? 1 : 0);
- sub_state = motor_control ? SPINUP : SPINUP_DONE;
- status_type_1 = false;
- read_track_continue();
-}
-
-void wd_fdc_t::read_track_continue()
-{
- for(;;) {
- switch(sub_state) {
- case SPINUP:
- if (TRACE_STATE) logerror("%s: SPINUP\n", tag());
- if(!(status & S_MON)) {
- spinup();
- return;
- }
- sub_state = SPINUP_DONE;
- break;
-
- case SPINUP_WAIT:
- if (TRACE_STATE) logerror("%s: SPINUP_WAIT\n", tag());
- return;
-
- case SPINUP_DONE:
- if (TRACE_STATE) logerror("%s: SPINUP_DONE\n", tag());
- if(command & 4) {
- sub_state = SETTLE_WAIT;
- delay_cycles(t_gen, settle_time());
- return;
-
- } else {
- sub_state = SETTLE_DONE;
- break;
- }
-
- case SETTLE_WAIT:
- if (TRACE_STATE) logerror("%s: SETTLE_WAIT\n", tag());
- return;
-
- case SETTLE_DONE:
- if (TRACE_STATE) logerror("%s: SETTLE_DONE\n", tag());
- sub_state = WAIT_INDEX;
- return;
-
- case WAIT_INDEX:
- if (TRACE_STATE) logerror("%s: WAIT_INDEX\n", tag());
- return;
-
- case WAIT_INDEX_DONE:
- if (TRACE_STATE) logerror("%s: WAIT_INDEX_DONE\n", tag());
- sub_state = TRACK_DONE;
- live_start(READ_TRACK_DATA);
- return;
-
- case TRACK_DONE:
- if (TRACE_STATE) logerror("%s: TRACK_DONE\n", tag());
- command_end();
- return;
-
- default:
- logerror("%s: read track unknown sub-state %d\n", ttsn().c_str(), sub_state);
- return;
- }
- }
-}
-
-void wd_fdc_t::read_id_start()
-{
- if (TRACE_COMMAND) logerror("%s: read id (c=%02x)\n", tag(), command);
- if(!is_ready()) {
- command_end();
- return;
- }
-
- main_state = READ_ID;
- status &= ~(S_WP|S_DDM|S_LOST|S_RNF);
- drop_drq();
- if(side_control && floppy)
- floppy->ss_w((command & 0x02) ? 1 : 0);
- sub_state = motor_control ? SPINUP : SPINUP_DONE;
- status_type_1 = false;
- read_id_continue();
-}
-
-void wd_fdc_t::read_id_continue()
-{
- for(;;) {
- switch(sub_state) {
- case SPINUP:
- if (TRACE_STATE) logerror("%s: SPINUP\n", tag());
- if(!(status & S_MON)) {
- spinup();
- return;
- }
- sub_state = SPINUP_DONE;
- break;
-
- case SPINUP_WAIT:
- if (TRACE_STATE) logerror("%s: SPINUP_WAIT\n", tag());
- return;
-
- case SPINUP_DONE:
- if (TRACE_STATE) logerror("%s: SPINUP_DONE\n", tag());
- if(command & 4) {
- sub_state = SETTLE_WAIT;
- delay_cycles(t_gen, settle_time());
- return;
- } else {
- sub_state = SETTLE_DONE;
- break;
- }
-
- case SETTLE_WAIT:
- if (TRACE_STATE) logerror("%s: SETTLE_WAIT\n", tag());
- return;
-
- case SETTLE_DONE:
- if (TRACE_STATE) logerror("%s: SETTLE_DONE\n", tag());
- sub_state = SCAN_ID;
- counter = 0;
- live_start(SEARCH_ADDRESS_MARK_HEADER);
- return;
-
- case SCAN_ID:
- if (TRACE_STATE) logerror("%s: SCAN_ID\n", tag());
- command_end();
- return;
-
- case SCAN_ID_FAILED:
- if (TRACE_STATE) logerror("%s: SCAN_ID_FAILED\n", tag());
- status |= S_RNF;
- command_end();
- return;
-
- default:
- logerror("%s: read id unknown sub-state %d\n", ttsn().c_str(), sub_state);
- return;
- }
- }
-}
-
-void wd_fdc_t::write_track_start()
-{
- if (TRACE_COMMAND) logerror("%s: write track (c=%02x) t=%d\n", tag(), command, track);
-
- if(!is_ready()) {
- command_end();
- return;
- }
-
- main_state = WRITE_TRACK;
- status &= ~(S_WP|S_DDM|S_LOST|S_RNF);
- drop_drq();
- if(side_control && floppy)
- floppy->ss_w((command & 0x02) ? 1 : 0);
- sub_state = motor_control ? SPINUP : SPINUP_DONE;
- status_type_1 = false;
-
- format_last_byte = 0;
- format_last_byte_count = 0;
- format_description_string = "";
-
- write_track_continue();
-}
-
-void wd_fdc_t::write_track_continue()
-{
- for(;;) {
- switch(sub_state) {
- case SPINUP:
- if (TRACE_STATE) logerror("%s: SPINUP\n", tag());
- if(!(status & S_MON)) {
- spinup();
- return;
- }
- sub_state = SPINUP_DONE;
- break;
-
- case SPINUP_WAIT:
- if (TRACE_STATE) logerror("%s: SPINUP_WAIT\n", tag());
- return;
-
- case SPINUP_DONE:
- if (TRACE_STATE) logerror("%s: SPINUP_DONE\n", tag());
- if(command & 4) {
- sub_state = SETTLE_WAIT;
- delay_cycles(t_gen, settle_time());
- return;
- } else {
- sub_state = SETTLE_DONE;
- break;
- }
-
- case SETTLE_WAIT:
- if (TRACE_STATE) logerror("%s: SETTLE_WAIT\n", tag());
- return;
-
- case SETTLE_DONE:
- if (TRACE_STATE) logerror("%s: SETTLE_DONE\n", tag());
- set_drq();
- sub_state = DATA_LOAD_WAIT;
- delay_cycles(t_gen, 192);
- return;
-
- case DATA_LOAD_WAIT:
- if (TRACE_STATE) logerror("%s: DATA_LOAD_WAIT\n", tag());
- return;
-
- case DATA_LOAD_WAIT_DONE:
- if (TRACE_STATE) logerror("%s: DATA_LOAD_WAIT_DONE\n", tag());
- if(drq) {
- status |= S_LOST;
- drop_drq();
- command_end();
- return;
- }
- sub_state = WAIT_INDEX;
- break;
-
- case WAIT_INDEX:
- if (TRACE_STATE) logerror("%s: WAIT_INDEX\n", tag());
- return;
-
- case WAIT_INDEX_DONE:
- if (TRACE_STATE) logerror("%s: WAIT_INDEX_DONE\n", tag());
- sub_state = TRACK_DONE;
- live_start(WRITE_TRACK_DATA);
- pll_start_writing(machine().time());
- return;
-
- case TRACK_DONE:
- if (TRACE_STATE) logerror("%s: TRACK_DONE\n", tag());
- if(format_last_byte_count) {
- char buf[32];
- if(format_last_byte_count > 1)
- sprintf(buf, "%dx%02x", format_last_byte_count, format_last_byte);
- else
- sprintf(buf, "%02x", format_last_byte);
- format_description_string += buf;
- }
- if (TRACE_DESC) logerror("%s: track description %s\n", tag(), format_description_string.c_str());
- command_end();
- return;
-
- default:
- logerror("%s: write track unknown sub-state %d\n", ttsn().c_str(), sub_state);
- return;
- }
- }
-}
-
-
-void wd_fdc_t::write_sector_start()
-{
- if (TRACE_COMMAND) logerror("%s: write sector%s (c=%02x) t=%d, s=%d\n", tag(), command & 0x10 ? " multiple" : "", command, track, sector);
-
- if(!is_ready()) {
- command_end();
- return;
- }
-
- main_state = WRITE_SECTOR;
- status &= ~(S_CRC|S_LOST|S_RNF|S_WP|S_DDM);
- drop_drq();
- if(side_control && floppy)
- floppy->ss_w((command & 0x02) ? 1 : 0);
- sub_state = motor_control ? SPINUP : SPINUP_DONE;
- status_type_1 = false;
- write_sector_continue();
-}
-
-void wd_fdc_t::write_sector_continue()
-{
- for(;;) {
- switch(sub_state) {
- case SPINUP:
- if (TRACE_STATE) logerror("%s: SPINUP\n", tag());
- if(!(status & S_MON)) {
- spinup();
- return;
- }
- sub_state = SPINUP_DONE;
- break;
-
- case SPINUP_WAIT:
- if (TRACE_STATE) logerror("%s: SPINUP_WAIT\n", tag());
- return;
-
- case SPINUP_DONE:
- if (TRACE_STATE) logerror("%s: SPINUP_DONE\n", tag());
- if(command & 4) {
- sub_state = SETTLE_WAIT;
- delay_cycles(t_gen, settle_time());
- return;
- } else {
- sub_state = SETTLE_DONE;
- break;
- }
-
- case SETTLE_WAIT:
- if (TRACE_STATE) logerror("%s: SETTLE_WAIT\n", tag());
- return;
-
- case SETTLE_DONE:
- if (TRACE_STATE) logerror("%s: SETTLE_DONE\n", tag());
- sub_state = SCAN_ID;
- counter = 0;
- live_start(SEARCH_ADDRESS_MARK_HEADER);
- return;
-
- case SCAN_ID:
- if (TRACE_STATE) logerror("%s: SCAN_ID\n", tag());
- if(!sector_matches()) {
- live_start(SEARCH_ADDRESS_MARK_HEADER);
- return;
- }
- if(cur_live.crc) {
- status |= S_CRC;
- live_start(SEARCH_ADDRESS_MARK_HEADER);
- return;
- }
- sector_size = calc_sector_size(cur_live.idbuf[3], command);
- sub_state = SECTOR_WRITE;
- live_start(WRITE_SECTOR_PRE);
- return;
-
- case SCAN_ID_FAILED:
- if (TRACE_STATE) logerror("%s: SCAN_ID_FAILED\n", tag());
- status |= S_RNF;
- command_end();
- return;
-
- case SECTOR_WRITE:
- if (TRACE_STATE) logerror("%s: SECTOR_WRITE\n", tag());
- if(command & 0x10) {
- sector++;
- sub_state = SPINUP_DONE;
- } else {
- command_end();
- return;
- }
- break;
-
- default:
- logerror("%s: write sector unknown sub-state %d\n", ttsn().c_str(), sub_state);
- return;
- }
- }
-}
-
-void wd_fdc_t::interrupt_start()
-{
- if (TRACE_COMMAND) logerror("%s: Forced interrupt (c=%02x)\n", tag(), command);
-
- if(status & S_BUSY) {
- main_state = sub_state = cur_live.state = IDLE;
- cur_live.tm = attotime::never;
- status &= ~S_BUSY;
- drop_drq();
- motor_timeout = 0;
- }
- else
- {
- // when a force interrupt command is issued and there is no
- // currently running command, return the status type 1 bits
- status_type_1 = true;
- }
-
- int intcond = command & 0x0f;
- if (!nonsticky_immint) {
- if(intcond == 0)
- intrq_cond = 0;
- else
- intrq_cond = (intrq_cond & I_IMM) | intcond;
- } else {
- if (intcond < 8)
- intrq_cond = intcond;
- else
- intrq_cond = 0;
- }
-
- if(command & I_IMM) {
- intrq = true;
- if(!intrq_cb.isnull())
- intrq_cb(intrq);
- }
-
- if(command & 0x03) {
- logerror("%s: unhandled interrupt generation (%02x)\n", ttsn().c_str(), command);
- }
-}
-
-void wd_fdc_t::general_continue()
-{
- if(cur_live.state != IDLE) {
- live_run();
- if(cur_live.state != IDLE)
- return;
- }
-
- switch(main_state) {
- case IDLE:
- break;
- case RESTORE: case SEEK: case STEP:
- seek_continue();
- break;
- case READ_SECTOR:
- read_sector_continue();
- break;
- case READ_TRACK:
- read_track_continue();
- break;
- case READ_ID:
- read_id_continue();
- break;
- case WRITE_TRACK:
- write_track_continue();
- break;
- case WRITE_SECTOR:
- write_sector_continue();
- break;
- default:
- logerror("%s: general_continue on unknown main-state %d\n", ttsn().c_str(), main_state);
- break;
- }
-}
-
-void wd_fdc_t::do_generic()
-{
- switch(sub_state) {
- case IDLE:
- case SCAN_ID:
- case SECTOR_READ:
- break;
-
- case SETTLE_WAIT:
- sub_state = SETTLE_DONE;
- break;
-
- case SEEK_WAIT_STEP_TIME:
- sub_state = SEEK_WAIT_STEP_TIME_DONE;
- break;
-
- case SEEK_WAIT_STABILIZATION_TIME:
- sub_state = SEEK_WAIT_STABILIZATION_TIME_DONE;
- break;
-
- case DATA_LOAD_WAIT:
- sub_state = DATA_LOAD_WAIT_DONE;
- break;
-
- default:
- if(cur_live.tm.is_never())
- logerror("%s: do_generic on unknown sub-state %d\n", ttsn().c_str(), sub_state);
- break;
- }
-}
-
-void wd_fdc_t::do_cmd_w()
-{
- // Only available command when busy is interrupt
- if(main_state != IDLE && (cmd_buffer & 0xf0) != 0xd0) {
- cmd_buffer = -1;
- return;
- }
- command = cmd_buffer;
- cmd_buffer = -1;
-
- switch(command & 0xf0) {
- case 0x00:
- last_dir = 1;
- seek_start(RESTORE);
- break;
- case 0x10:
- last_dir = data > track ? 0 : 1;
- seek_start(SEEK);
- break;
- case 0x20:
- case 0x30:
- seek_start(STEP);
- break;
- case 0x40:
- case 0x50:
- last_dir = 0;
- seek_start(STEP);
- break;
- case 0x60:
- case 0x70:
- last_dir = 1;
- seek_start(STEP);
- break;
- case 0x80:
- case 0x90:
- read_sector_start();
- break;
- case 0xa0:
- case 0xb0:
- write_sector_start();
- break;
- case 0xc0:
- read_id_start();
- break;
- case 0xd0:
- interrupt_start();
- break;
- case 0xe0:
- read_track_start();
- break;
- case 0xf0:
- write_track_start();
- break;
- }
-}
-
-void wd_fdc_t::cmd_w(UINT8 val)
-{
- if (TRACE_COMP) logerror("%s: Initiating command %02x\n", tag(), val);
- if (inverted_bus) val ^= 0xff;
-
- if(intrq && !(intrq_cond & I_IMM)) {
- intrq = false;
- if(!intrq_cb.isnull())
- intrq_cb(intrq);
- }
-
- // No more than one write in flight, but interrupts take priority
- if(cmd_buffer != -1 && ((val & 0xf0) != 0xd0))
- return;
-
- cmd_buffer = val;
-
- if ((val & 0xf0) == 0xd0)
- {
- // force interrupt is executed instantly (?)
- delay_cycles(t_cmd, 0);
- }
- else
- {
- // set busy, then set a timer to process the command
- status |= S_BUSY;
- delay_cycles(t_cmd, dden ? delay_command_commit*2 : delay_command_commit);
- }
-}
-
-UINT8 wd_fdc_t::status_r()
-{
- if(intrq && !(intrq_cond & I_IMM)) {
- intrq = false;
- if(!intrq_cb.isnull())
- intrq_cb(intrq);
- }
-
- if(status_type_1) {
- if(floppy && floppy->idx_r())
- status |= S_IP;
- else
- status &= ~S_IP;
- } else {
- if(drq)
- status |= S_DRQ;
- else
- status &= ~S_DRQ;
- }
-
- if(status_type_1) {
- status &= ~(S_TR00|S_WP);
- if(floppy) {
- if(floppy->wpt_r())
- status |= S_WP;
- if(!floppy->trk00_r())
- status |= S_TR00;
- }
- }
-
- if(ready_hooked) {
- if(!is_ready())
- status |= S_NRDY;
- else
- status &= ~S_NRDY;
- }
-
- UINT8 val = status;
- if (inverted_bus) val ^= 0xff;
-
- return val;
-}
-
-void wd_fdc_t::do_track_w()
-{
- track = track_buffer;
- track_buffer = -1;
-}
-
-void wd_fdc_t::track_w(UINT8 val)
-{
- if (inverted_bus) val ^= 0xff;
-
- // No more than one write in flight
- if(track_buffer != -1)
- return;
-
- track_buffer = val;
- delay_cycles(t_track, dden ? delay_register_commit*2 : delay_register_commit);
-}
-
-UINT8 wd_fdc_t::track_r()
-{
- UINT8 val = track;
- if (inverted_bus) val ^= 0xff;
-
- return val;
-}
-
-void wd_fdc_t::do_sector_w()
-{
- sector = sector_buffer;
- sector_buffer = -1;
-}
-
-void wd_fdc_t::sector_w(UINT8 val)
-{
- if (inverted_bus) val ^= 0xff;
-
- // No more than one write in flight
- // C1581 accesses this register with an INC opcode,
- // i.e. write old value, write new value, and the new value gets ignored by this
- //if(sector_buffer != -1)
- // return;
-
- sector_buffer = val;
-
- // set a timer to write the new value to the register, but only if we aren't in
- // the middle of an already occurring update
- if (!t_sector->enabled())
- delay_cycles(t_sector, dden ? delay_register_commit*2 : delay_register_commit);
-}
-
-UINT8 wd_fdc_t::sector_r()
-{
- UINT8 val = sector;
- if (inverted_bus) val ^= 0xff;
-
- return val;
-}
-
-void wd_fdc_t::data_w(UINT8 val)
-{
- if (inverted_bus) val ^= 0xff;
-
- data = val;
- drop_drq();
-}
-
-UINT8 wd_fdc_t::data_r()
-{
- drop_drq();
-
- UINT8 val = data;
- if (inverted_bus) val ^= 0xff;
-
- return val;
-}
-
-void wd_fdc_t::gen_w(int reg, UINT8 val)
-{
- switch(reg) {
- case 0: cmd_w(val); break;
- case 1: track_w(val); break;
- case 2: sector_w(val); break;
- case 3: data_w(val); break;
- }
-}
-
-UINT8 wd_fdc_t::gen_r(int reg)
-{
- switch(reg) {
- case 0: return status_r();
- case 1: return track_r();
- case 2: return sector_r();
- case 3: return data_r();
- }
- return 0xff;
-}
-
-void wd_fdc_t::delay_cycles(emu_timer *tm, int cycles)
-{
- tm->adjust(clocks_to_attotime(cycles*clock_ratio));
-}
-
-void wd_fdc_t::spinup()
-{
- if(command & 0x08)
- sub_state = SPINUP_DONE;
- else {
- sub_state = SPINUP_WAIT;
- counter = 0;
- }
-
- status |= S_MON|S_SPIN;
- if(floppy)
- floppy->mon_w(0);
-}
-
-void wd_fdc_t::ready_callback(floppy_image_device *floppy, int state)
-{
- // why is this even possible?
- if (!floppy)
- return;
-
- live_sync();
- if(!ready_hooked)
- return;
-
- if(!intrq && (((intrq_cond & I_RDY) && !state) || ((intrq_cond & I_NRDY) && state))) {
- intrq = true;
- if(!intrq_cb.isnull())
- intrq_cb(intrq);
- }
-}
-
-void wd_fdc_t::index_callback(floppy_image_device *floppy, int state)
-{
- live_sync();
-
- if(!state) {
- general_continue();
- return;
- }
-
- if(!intrq && (intrq_cond & I_IDX)) {
- intrq = true;
- if(!intrq_cb.isnull())
- intrq_cb(intrq);
- }
-
- switch(sub_state) {
- case IDLE:
- if(motor_control || head_control) {
- motor_timeout ++;
- if(motor_control && motor_timeout >= 5) {
- status &= ~S_MON;
- if(floppy)
- floppy->mon_w(1);
- }
-
- if (head_control && motor_timeout >= 3)
- {
- hld = false;
-
- // signal drive to unload head
- if (!hld_cb.isnull())
- hld_cb(hld);
-
- status &= ~S_HLD; // todo: should get this value from the drive
- }
- }
- break;
-
- case SPINUP:
- break;
-
- case SPINUP_WAIT:
- counter++;
- if(counter == 6) {
- sub_state = SPINUP_DONE;
- if(status_type_1)
- status |= S_SPIN;
- }
- break;
-
- case SPINUP_DONE:
- case SETTLE_WAIT:
- case SETTLE_DONE:
- case DATA_LOAD_WAIT:
- case DATA_LOAD_WAIT_DONE:
- case SEEK_MOVE:
- case SEEK_WAIT_STEP_TIME:
- case SEEK_WAIT_STEP_TIME_DONE:
- case SEEK_WAIT_STABILIZATION_TIME:
- case SEEK_WAIT_STABILIZATION_TIME_DONE:
- case SEEK_DONE:
- case WAIT_INDEX_DONE:
- case SCAN_ID_FAILED:
- case SECTOR_READ:
- case SECTOR_WRITE:
- break;
-
- case SCAN_ID:
- counter++;
- if(counter == 5) {
- sub_state = SCAN_ID_FAILED;
- live_abort();
- }
- break;
-
- case WAIT_INDEX:
- sub_state = WAIT_INDEX_DONE;
- break;
-
- case TRACK_DONE:
- live_abort();
- break;
-
- default:
- logerror("%s: Index pulse on unknown sub-state %d\n", ttsn().c_str(), sub_state);
- break;
- }
-
- general_continue();
-}
-
-bool wd_fdc_t::intrq_r()
-{
- return intrq;
-}
-
-bool wd_fdc_t::drq_r()
-{
- return drq;
-}
-
-bool wd_fdc_t::hld_r()
-{
- return hld;
-}
-
-void wd_fdc_t::hlt_w(bool state)
-{
- hlt = state;
-}
-
-bool wd_fdc_t::enp_r()
-{
- return enp;
-}
-
-void wd_fdc_t::live_start(int state)
-{
- cur_live.tm = machine().time();
- cur_live.state = state;
- cur_live.next_state = -1;
- cur_live.shift_reg = 0;
- cur_live.crc = 0xffff;
- cur_live.bit_counter = 0;
- cur_live.data_separator_phase = false;
- cur_live.data_reg = 0;
- cur_live.previous_type = live_info::PT_NONE;
- cur_live.data_bit_context = false;
- cur_live.byte_counter = 0;
-
- if (!enmf_cb.isnull() && has_enmf)
- enmf = enmf_cb() ? false : true;
-
- pll_reset(dden, enmf, cur_live.tm);
- checkpoint_live = cur_live;
- pll_save_checkpoint();
-
- live_run();
-}
-
-void wd_fdc_t::checkpoint()
-{
- pll_commit(floppy, cur_live.tm);
- checkpoint_live = cur_live;
- pll_save_checkpoint();
-}
-
-void wd_fdc_t::rollback()
-{
- cur_live = checkpoint_live;
- pll_retrieve_checkpoint();
-}
-
-void wd_fdc_t::live_delay(int state)
-{
- cur_live.next_state = state;
- t_gen->adjust(cur_live.tm - machine().time());
-}
-
-void wd_fdc_t::live_sync()
-{
- if(!cur_live.tm.is_never()) {
- if(cur_live.tm > machine().time()) {
- if (TRACE_SYNC) logerror("%s: Rolling back and replaying (%s)\n", ttsn().c_str(), tts(cur_live.tm).c_str());
- rollback();
- live_run(machine().time());
- pll_commit(floppy, cur_live.tm);
- } else {
- if (TRACE_SYNC) logerror("%s: Committing (%s)\n", ttsn().c_str(), tts(cur_live.tm).c_str());
- pll_commit(floppy, cur_live.tm);
- if(cur_live.next_state != -1) {
- cur_live.state = cur_live.next_state;
- cur_live.next_state = -1;
- }
- if(cur_live.state == IDLE) {
- pll_stop_writing(floppy, cur_live.tm);
- cur_live.tm = attotime::never;
- }
- }
- cur_live.next_state = -1;
- checkpoint();
- }
-}
-
-void wd_fdc_t::live_abort()
-{
- if(!cur_live.tm.is_never() && cur_live.tm > machine().time()) {
- rollback();
- live_run(machine().time());
- }
-
- pll_stop_writing(floppy, cur_live.tm);
- cur_live.tm = attotime::never;
- cur_live.state = IDLE;
- cur_live.next_state = -1;
-}
-
-bool wd_fdc_t::read_one_bit(const attotime &limit)
-{
- int bit = pll_get_next_bit(cur_live.tm, floppy, limit);
- if(bit < 0)
- return true;
- cur_live.shift_reg = (cur_live.shift_reg << 1) | bit;
- cur_live.bit_counter++;
- if(cur_live.data_separator_phase) {
- cur_live.data_reg = (cur_live.data_reg << 1) | bit;
- if((cur_live.crc ^ (bit ? 0x8000 : 0x0000)) & 0x8000)
- cur_live.crc = (cur_live.crc << 1) ^ 0x1021;
- else
- cur_live.crc = cur_live.crc << 1;
- }
- cur_live.data_separator_phase = !cur_live.data_separator_phase;
- return false;
-}
-
-bool wd_fdc_t::write_one_bit(const attotime &limit)
-{
- bool bit = cur_live.shift_reg & 0x8000;
- if(pll_write_next_bit(bit, cur_live.tm, floppy, limit))
- return true;
- if(cur_live.bit_counter & 1) {
- if((cur_live.crc ^ (bit ? 0x8000 : 0x0000)) & 0x8000)
- cur_live.crc = (cur_live.crc << 1) ^ 0x1021;
- else
- cur_live.crc = cur_live.crc << 1;
- }
- cur_live.shift_reg = cur_live.shift_reg << 1;
- cur_live.bit_counter--;
- return false;
-}
-
-void wd_fdc_t::live_write_raw(UINT16 raw)
-{
- if (TRACE_WRITE) logerror("%s: write raw %04x, CRC=%04x\n", tag(), raw, cur_live.crc);
- cur_live.shift_reg = raw;
- cur_live.data_bit_context = raw & 1;
-}
-
-void wd_fdc_t::live_write_mfm(UINT8 mfm)
-{
- bool context = cur_live.data_bit_context;
- UINT16 raw = 0;
- for(int i=0; i<8; i++) {
- bool bit = mfm & (0x80 >> i);
- if(!(bit || context))
- raw |= 0x8000 >> (2*i);
- if(bit)
- raw |= 0x4000 >> (2*i);
- context = bit;
- }
- cur_live.shift_reg = raw;
- cur_live.data_bit_context = context;
- if (TRACE_WRITE) logerror("%s: live_write_mfm byte=%02x, raw=%04x, CRC=%04x\n", tag(), mfm, raw, cur_live.crc);
-}
-
-
-void wd_fdc_t::live_write_fm(UINT8 fm)
-{
- UINT16 raw = 0xaaaa;
- for(int i=0; i<8; i++)
- if(fm & (0x80 >> i))
- raw |= 0x4000 >> (2*i);
- cur_live.data_reg = fm;
- cur_live.shift_reg = raw;
- cur_live.data_bit_context = fm & 1;
- if (TRACE_WRITE) logerror("%s: live_write_fm byte=%02x, raw=%04x, CRC=%04x\n", tag(), fm, raw, cur_live.crc);
-}
-
-void wd_fdc_t::live_run(attotime limit)
-{
- if(cur_live.state == IDLE || cur_live.next_state != -1)
- return;
-
- if(limit == attotime::never) {
- if(floppy)
- limit = floppy->time_next_index();
- if(limit == attotime::never) {
- // Happens when there's no disk or if the wd is not
- // connected to a drive, hence no index pulse. Force a
- // sync from time to time in that case, so that the main
- // cpu timeout isn't too painful. Avoids looping into
- // infinity looking for data too.
-
- limit = machine().time() + attotime::from_msec(1);
- t_gen->adjust(attotime::from_msec(1));
- }
- }
-
- // fprintf(stderr, "%s: live_run(%s)\n", ttsn().c_str(), tts(limit).c_str());
-
- for(;;) {
- switch(cur_live.state) {
- case SEARCH_ADDRESS_MARK_HEADER:
- if(read_one_bit(limit))
- return;
-
- if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d\n", tts(cur_live.tm).c_str(), cur_live.shift_reg,
- (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) |
- (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) |
- (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) |
- (cur_live.shift_reg & 0x0100 ? 0x10 : 0x00) |
- (cur_live.shift_reg & 0x0040 ? 0x08 : 0x00) |
- (cur_live.shift_reg & 0x0010 ? 0x04 : 0x00) |
- (cur_live.shift_reg & 0x0004 ? 0x02 : 0x00) |
- (cur_live.shift_reg & 0x0001 ? 0x01 : 0x00),
- cur_live.bit_counter);
-
- if(!dden && cur_live.shift_reg == 0x4489) {
- cur_live.crc = 0x443b;
- cur_live.data_separator_phase = false;
- cur_live.bit_counter = 0;
- cur_live.state = READ_HEADER_BLOCK_HEADER;
- }
-
- if(dden && cur_live.shift_reg == 0xf57e) {
- cur_live.crc = 0xef21;
- cur_live.data_separator_phase = false;
- cur_live.bit_counter = 0;
- if(main_state == READ_ID)
- cur_live.state = READ_ID_BLOCK_TO_DMA;
- else
- cur_live.state = READ_ID_BLOCK_TO_LOCAL;
- }
- break;
-
- case READ_HEADER_BLOCK_HEADER: {
- if(read_one_bit(limit))
- return;
-
- if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x counter=%d\n", tts(cur_live.tm).c_str(), cur_live.shift_reg,
- (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) |
- (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) |
- (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) |
- (cur_live.shift_reg & 0x0100 ? 0x10 : 0x00) |
- (cur_live.shift_reg & 0x0040 ? 0x08 : 0x00) |
- (cur_live.shift_reg & 0x0010 ? 0x04 : 0x00) |
- (cur_live.shift_reg & 0x0004 ? 0x02 : 0x00) |
- (cur_live.shift_reg & 0x0001 ? 0x01 : 0x00),
- cur_live.bit_counter);
-
- if(cur_live.bit_counter & 15)
- break;
-
- int slot = cur_live.bit_counter >> 4;
-
- if(slot < 3) {
- if(cur_live.shift_reg != 0x4489)
- cur_live.state = SEARCH_ADDRESS_MARK_HEADER;
- break;
- }
- if(cur_live.data_reg != 0xfe && cur_live.data_reg != 0xff) {
- cur_live.state = SEARCH_ADDRESS_MARK_HEADER;
- break;
- }
-
- cur_live.bit_counter = 0;
-
- if(main_state == READ_ID)
- cur_live.state = READ_ID_BLOCK_TO_DMA;
- else
- cur_live.state = READ_ID_BLOCK_TO_LOCAL;
-
- break;
- }
-
- case READ_ID_BLOCK_TO_LOCAL: {
- if(read_one_bit(limit))
- return;
- if(cur_live.bit_counter & 15)
- break;
- int slot = (cur_live.bit_counter >> 4)-1;
- // fprintf(stderr, "%s: slot[%d] = %02x crc = %04x\n", tts(cur_live.tm).c_str(), slot, cur_live.data_reg, cur_live.crc);
- cur_live.idbuf[slot] = cur_live.data_reg;
- if(slot == 5) {
- live_delay(IDLE);
- return;
- }
- break;
- }
-
- case READ_ID_BLOCK_TO_DMA:
- if(read_one_bit(limit))
- return;
- if(cur_live.bit_counter & 15)
- break;
- live_delay(READ_ID_BLOCK_TO_DMA_BYTE);
- return;
-
- case READ_ID_BLOCK_TO_DMA_BYTE:
- data = cur_live.data_reg;
- if(cur_live.bit_counter == 16)
- sector = data;
- set_drq();
-
- if(cur_live.bit_counter == 16*6) {
- if(cur_live.crc) {
- status |= S_CRC;
- }
-
- // Already synchronous
- cur_live.state = IDLE;
- return;
- }
-
- cur_live.state = READ_ID_BLOCK_TO_DMA;
- checkpoint();
- break;
-
- case SEARCH_ADDRESS_MARK_DATA:
- if(read_one_bit(limit))
- return;
-
- if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d.%x\n", tts(cur_live.tm).c_str(), cur_live.shift_reg,
- (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) |
- (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) |
- (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) |
- (cur_live.shift_reg & 0x0100 ? 0x10 : 0x00) |
- (cur_live.shift_reg & 0x0040 ? 0x08 : 0x00) |
- (cur_live.shift_reg & 0x0010 ? 0x04 : 0x00) |
- (cur_live.shift_reg & 0x0004 ? 0x02 : 0x00) |
- (cur_live.shift_reg & 0x0001 ? 0x01 : 0x00),
- cur_live.bit_counter >> 4, cur_live.bit_counter & 15);
-
- if(!dden) {
- if(cur_live.bit_counter > 43*16) {
- live_delay(SEARCH_ADDRESS_MARK_DATA_FAILED);
- return;
- }
-
- if(cur_live.bit_counter >= 28*16 && cur_live.shift_reg == 0x4489) {
- cur_live.crc = 0x443b;
- cur_live.data_separator_phase = false;
- cur_live.bit_counter = 0;
- cur_live.state = READ_DATA_BLOCK_HEADER;
- }
- } else {
- if(cur_live.bit_counter > 23*16) {
- live_delay(SEARCH_ADDRESS_MARK_DATA_FAILED);
- return;
- }
-
- if(cur_live.bit_counter >= 11*16 && (cur_live.shift_reg == 0xf56a || cur_live.shift_reg == 0xf56b ||
- cur_live.shift_reg == 0xf56e || cur_live.shift_reg == 0xf56f)) {
- cur_live.crc =
- cur_live.shift_reg == 0xf56a ? 0x8fe7 :
- cur_live.shift_reg == 0xf56b ? 0x9fc6 :
- cur_live.shift_reg == 0xf56e ? 0xafa5 :
- 0xbf84;
-
- if((cur_live.data_reg & 0xfe) == 0xf8)
- status |= S_DDM;
-
- cur_live.data_separator_phase = false;
- cur_live.bit_counter = 0;
- cur_live.state = READ_SECTOR_DATA;
- }
- }
- break;
-
- case READ_DATA_BLOCK_HEADER: {
- if(read_one_bit(limit))
- return;
-
- if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x counter=%d\n", tts(cur_live.tm).c_str(), cur_live.shift_reg,
- (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) |
- (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) |
- (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) |
- (cur_live.shift_reg & 0x0100 ? 0x10 : 0x00) |
- (cur_live.shift_reg & 0x0040 ? 0x08 : 0x00) |
- (cur_live.shift_reg & 0x0010 ? 0x04 : 0x00) |
- (cur_live.shift_reg & 0x0004 ? 0x02 : 0x00) |
- (cur_live.shift_reg & 0x0001 ? 0x01 : 0x00),
- cur_live.bit_counter);
-
- if(cur_live.bit_counter & 15)
- break;
-
- int slot = cur_live.bit_counter >> 4;
-
- if(slot < 3) {
- if(cur_live.shift_reg != 0x4489) {
- live_delay(SEARCH_ADDRESS_MARK_DATA_FAILED);
- return;
- }
- break;
- }
- if((cur_live.data_reg & 0xfe) != 0xfa && (cur_live.data_reg & 0xfe) != 0xf8) {
- live_delay(SEARCH_ADDRESS_MARK_DATA_FAILED);
- return;
- }
-
- cur_live.bit_counter = 0;
- if((cur_live.data_reg & 0xfe) == 0xf8)
- status |= S_DDM;
- live_delay(READ_SECTOR_DATA);
- return;
- }
-
- case SEARCH_ADDRESS_MARK_DATA_FAILED:
- status |= S_RNF;
- cur_live.state = IDLE;
- return;
-
- case READ_SECTOR_DATA: {
- if(read_one_bit(limit))
- return;
- if(cur_live.bit_counter & 15)
- break;
- int slot = (cur_live.bit_counter >> 4)-1;
- if(slot < sector_size) {
- // Sector data
- live_delay(READ_SECTOR_DATA_BYTE);
- return;
-
- } else if(slot < sector_size+2) {
- // CRC
- if(slot == sector_size+1) {
- live_delay(IDLE);
- return;
- }
- }
- break;
- }
-
- case READ_SECTOR_DATA_BYTE:
- data = cur_live.data_reg;
- set_drq();
- cur_live.state = READ_SECTOR_DATA;
- checkpoint();
- break;
-
- case READ_TRACK_DATA: {
- if(read_one_bit(limit))
- return;
- if(cur_live.bit_counter != 16
- && cur_live.shift_reg != 0x4489
- && cur_live.shift_reg != 0x5224)
- break;
-
- // Incorrect, hmmm
- // Probably >2 + not just after a sync if <16
-
- // Transitions 00..00 -> 4489.4489.4489 at varied syncs:
- // 0: 00.00.14.a1 1: ff.fe.c2.a1 2: 00.01.14.a1 3: ff.fc.c2.a1
- // 4: 00.02.14.a1 5: ff.f8.c2.a1 6: 00.05.14.a1 7: ff.f0.c2.a1
- // 8: 00.00.0a.a1 9: ff.ff.e1.a1 10: 00.00.14.a1 11: ff.ff.ce.a1
- // 12: 00.00.14.a1 13: ff.ff.c2.a1 14: 00.00.14.a1 15: ff.ff.c2.a1
-
- bool output_byte = cur_live.bit_counter > 5;
-
- cur_live.data_separator_phase = false;
- cur_live.bit_counter = 0;
-
- if(output_byte) {
- live_delay(READ_TRACK_DATA_BYTE);
- return;
- }
- break;
- }
-
- case READ_TRACK_DATA_BYTE:
- data = cur_live.data_reg;
- set_drq();
- cur_live.state = READ_TRACK_DATA;
- checkpoint();
- break;
-
- case WRITE_TRACK_DATA:
- if(drq) {
- status |= S_LOST;
- data = 0;
- }
- if(data != format_last_byte) {
- if(format_last_byte_count) {
- char buf[32];
- if(format_last_byte_count > 1)
- sprintf(buf, "%dx%02x ", format_last_byte_count, format_last_byte);
- else
- sprintf(buf, "%02x ", format_last_byte);
- format_description_string += buf;
- }
- format_last_byte = data;
- format_last_byte_count = 1;
- } else
- format_last_byte_count++;
-
- if(dden) {
- switch(data) {
- case 0xf7:
- if(cur_live.previous_type == live_info::PT_CRC_2) {
- cur_live.previous_type = live_info::PT_NONE;
- live_write_fm(0xf7);
- } else {
- cur_live.previous_type = live_info::PT_CRC_1;
- live_write_fm(cur_live.crc >> 8);
- }
- break;
- case 0xf8:
- live_write_raw(0xf56a);
- cur_live.crc = 0xffff;
- cur_live.previous_type = live_info::PT_NONE;
- break;
- case 0xf9:
- live_write_raw(0xf56b);
- cur_live.crc = 0xffff;
- cur_live.previous_type = live_info::PT_NONE;
- break;
- case 0xfa:
- live_write_raw(0xf56e);
- cur_live.crc = 0xffff;
- cur_live.previous_type = live_info::PT_NONE;
- break;
- case 0xfb:
- live_write_raw(0xf56f);
- cur_live.crc = 0xffff;
- cur_live.previous_type = live_info::PT_NONE;
- break;
- case 0xfc:
- live_write_raw(0xf77a);
- cur_live.previous_type = live_info::PT_NONE;
- break;
- case 0xfe:
- live_write_raw(0xf57e);
- cur_live.crc = 0xffff;
- cur_live.previous_type = live_info::PT_NONE;
- break;
- default:
- cur_live.previous_type = live_info::PT_NONE;
- live_write_fm(data);
- break;
- }
-
- } else {
- switch(data) {
- case 0xf5:
- live_write_raw(0x4489);
- cur_live.crc = 0x968b; // Ensures that the crc is cdb4 after writing the byte
- cur_live.previous_type = live_info::PT_NONE;
- break;
- case 0xf6:
- cur_live.previous_type = live_info::PT_NONE;
- live_write_raw(0x5224);
- break;
- case 0xf7:
- if(cur_live.previous_type == live_info::PT_CRC_2) {
- cur_live.previous_type = live_info::PT_NONE;
- live_write_mfm(0xf7);
- } else {
- cur_live.previous_type = live_info::PT_CRC_1;
- live_write_mfm(cur_live.crc >> 8);
- }
- break;
- default:
- cur_live.previous_type = live_info::PT_NONE;
- live_write_mfm(data);
- break;
- }
- }
- set_drq();
- cur_live.state = WRITE_BYTE;
- cur_live.bit_counter = 16;
- checkpoint();
- break;
-
- case WRITE_BYTE:
- if(write_one_bit(limit))
- return;
- if(cur_live.bit_counter == 0) {
- live_delay(WRITE_BYTE_DONE);
- return;
- }
- break;
-
- case WRITE_BYTE_DONE:
- switch(sub_state) {
- case TRACK_DONE:
- if(cur_live.previous_type == live_info::PT_CRC_1) {
- cur_live.previous_type = live_info::PT_CRC_2;
- if(dden)
- live_write_fm(cur_live.crc >> 8);
- else
- live_write_mfm(cur_live.crc >> 8);
- cur_live.state = WRITE_BYTE;
- cur_live.bit_counter = 16;
- checkpoint();
- } else
- cur_live.state = WRITE_TRACK_DATA;
- break;
-
- case SECTOR_WRITE:
- cur_live.state = WRITE_BYTE;
- cur_live.bit_counter = 16;
- cur_live.byte_counter++;
-
- if(dden) {
- if(cur_live.byte_counter < 6)
- live_write_fm(0x00);
- else if(cur_live.byte_counter < 7) {
- cur_live.crc = 0xffff;
- live_write_raw(command & 1 ? 0xf56a : 0xf56f);
- } else if(cur_live.byte_counter < sector_size + 7-1) {
- if(drq) {
- status |= S_LOST;
- data = 0;
- }
- live_write_fm(data);
- set_drq();
- } else if(cur_live.byte_counter < sector_size + 7) {
- if(drq) {
- status |= S_LOST;
- data = 0;
- }
- live_write_fm(data);
- } else if(cur_live.byte_counter < sector_size + 7+2)
- live_write_fm(cur_live.crc >> 8);
- else if(cur_live.byte_counter < sector_size + 7+3)
- live_write_fm(0xff);
- else {
- pll_stop_writing(floppy, cur_live.tm);
- cur_live.state = IDLE;
- return;
- }
-
- } else {
- if(cur_live.byte_counter < 12)
- live_write_mfm(0x00);
- else if(cur_live.byte_counter < 15)
- live_write_raw(0x4489);
- else if(cur_live.byte_counter < 16) {
- cur_live.crc = 0xcdb4;
- live_write_mfm(command & 1 ? 0xf8 : 0xfb);
-
- } else if(cur_live.byte_counter < sector_size + 16-1) {
- if(drq) {
- status |= S_LOST;
- data = 0;
- }
- live_write_mfm(data);
- set_drq();
- } else if(cur_live.byte_counter < sector_size + 16) {
- if(drq) {
- status |= S_LOST;
- data = 0;
- }
- live_write_mfm(data);
- } else if(cur_live.byte_counter < sector_size + 16+2)
- live_write_mfm(cur_live.crc >> 8);
- else if(cur_live.byte_counter < sector_size + 16+3)
- live_write_mfm(0xff);
- else {
- pll_stop_writing(floppy, cur_live.tm);
- cur_live.state = IDLE;
- return;
- }
- }
-
-
- checkpoint();
- break;
-
- default:
- logerror("%s: Unknown sub state %d in WRITE_BYTE_DONE\n", tts(cur_live.tm).c_str(), sub_state);
- live_abort();
- return;
- }
- break;
-
- case WRITE_SECTOR_PRE:
- if(read_one_bit(limit))
- return;
- if(cur_live.bit_counter != 16)
- break;
- live_delay(WRITE_SECTOR_PRE_BYTE);
- return;
-
- case WRITE_SECTOR_PRE_BYTE:
- cur_live.state = WRITE_SECTOR_PRE;
- cur_live.byte_counter++;
- cur_live.bit_counter = 0;
- switch(cur_live.byte_counter) {
- case 2:
- set_drq();
- checkpoint();
- break;
-
- // MZ: There is an inconsistency in the wd177x specs; compare
- // the flow chart and the text of the section "Write sector" (1-9) and
- // pages 1-17 and 1-18.
- //
- // I suppose the sum of the delays in the flow chart should be
- // 11 and 22, so we shorten the 9-byte delay to 8 bytes.
-
- // case 11:
- case 10:
- if(drq) {
- status |= S_LOST;
- cur_live.state = IDLE;
- return;
- }
- break;
- // case 12:
- case 11:
- if(dden) {
- cur_live.state = WRITE_BYTE;
- cur_live.bit_counter = 16;
- cur_live.byte_counter = 0;
- cur_live.data_bit_context = cur_live.data_reg & 1;
- pll_start_writing(cur_live.tm);
- live_write_fm(0x00);
- }
- break;
-
- case 22:
- cur_live.state = WRITE_BYTE;
- cur_live.bit_counter = 16;
- cur_live.byte_counter = 0;
- cur_live.data_bit_context = cur_live.data_reg & 1;
- pll_start_writing(cur_live.tm);
- live_write_mfm(0x00);
- break;
- }
- break;
-
- default:
- logerror("%s: Unknown live state %d\n", tts(cur_live.tm).c_str(), cur_live.state);
- return;
- }
- }
-}
-
-void wd_fdc_t::set_drq()
-{
- if(drq) {
- status |= S_LOST;
- drq = false;
- if(!drq_cb.isnull())
- drq_cb(false);
- } else if(!(status & S_LOST)) {
- drq = true;
- if(!drq_cb.isnull())
- drq_cb(true);
- }
-}
-
-void wd_fdc_t::drop_drq()
-{
- if(drq) {
- drq = false;
- if(!drq_cb.isnull())
- drq_cb(false);
- if (main_state == IDLE) {
- status &= ~S_BUSY;
- intrq = true;
- if(!intrq_cb.isnull())
- intrq_cb(intrq);
- }
- }
-}
-
-int wd_fdc_t::calc_sector_size(UINT8 size, UINT8 command) const
-{
- return 128 << (size & 3);
-}
-
-int wd_fdc_t::settle_time() const
-{
- return 60000;
-}
-
-wd_fdc_analog_t::wd_fdc_analog_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- wd_fdc_t(mconfig, type, name, tag, owner, clock, shortname, source)
-{
- clock_ratio = 1;
-}
-
-void wd_fdc_analog_t::pll_reset(bool fm, bool enmf, const attotime &when)
-{
- int clocks = 2;
-
- if (fm) clocks *= 2;
- if (enmf) clocks *= 2;
-
- cur_pll.reset(when);
- cur_pll.set_clock(clocks_to_attotime(clocks));
-}
-
-void wd_fdc_analog_t::pll_start_writing(const attotime &tm)
-{
- cur_pll.start_writing(tm);
-}
-
-void wd_fdc_analog_t::pll_commit(floppy_image_device *floppy, const attotime &tm)
-{
- cur_pll.commit(floppy, tm);
-}
-
-void wd_fdc_analog_t::pll_stop_writing(floppy_image_device *floppy, const attotime &tm)
-{
- cur_pll.stop_writing(floppy, tm);
-}
-
-void wd_fdc_analog_t::pll_save_checkpoint()
-{
- checkpoint_pll = cur_pll;
-}
-
-void wd_fdc_analog_t::pll_retrieve_checkpoint()
-{
- cur_pll = checkpoint_pll;
-}
-
-int wd_fdc_analog_t::pll_get_next_bit(attotime &tm, floppy_image_device *floppy, const attotime &limit)
-{
- return cur_pll.get_next_bit(tm, floppy, limit);
-}
-
-bool wd_fdc_analog_t::pll_write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, const attotime &limit)
-{
- return cur_pll.write_next_bit(bit, tm, floppy, limit);
-}
-
-wd_fdc_digital_t::wd_fdc_digital_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- wd_fdc_t(mconfig, type, name, tag, owner, clock, shortname, source)
-{
- clock_ratio = 4;
-}
-
-const int wd_fdc_digital_t::wd_digital_step_times[4] = { 12000, 24000, 40000, 60000 };
-
-void wd_fdc_digital_t::pll_reset(bool fm, bool enmf, const attotime &when)
-{
- int clocks = 1;
-
- if (fm) clocks *= 2;
- if (enmf) clocks *= 2;
-
- cur_pll.reset(when);
- cur_pll.set_clock(clocks_to_attotime(clocks));
-}
-
-void wd_fdc_digital_t::pll_start_writing(const attotime &tm)
-{
- cur_pll.start_writing(tm);
-}
-
-void wd_fdc_digital_t::pll_commit(floppy_image_device *floppy, const attotime &tm)
-{
- cur_pll.commit(floppy, tm);
-}
-
-void wd_fdc_digital_t::pll_stop_writing(floppy_image_device *floppy, const attotime &tm)
-{
- cur_pll.stop_writing(floppy, tm);
-}
-
-int wd_fdc_digital_t::pll_get_next_bit(attotime &tm, floppy_image_device *floppy, const attotime &limit)
-{
- return cur_pll.get_next_bit(tm, floppy, limit);
-}
-
-bool wd_fdc_digital_t::pll_write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, const attotime &limit)
-{
- return cur_pll.write_next_bit(bit, tm, floppy, limit);
-}
-
-void wd_fdc_digital_t::pll_save_checkpoint()
-{
- checkpoint_pll = cur_pll;
-}
-
-void wd_fdc_digital_t::pll_retrieve_checkpoint()
-{
- cur_pll = checkpoint_pll;
-}
-
-void wd_fdc_digital_t::digital_pll_t::set_clock(const attotime &period)
-{
- for(int i=0; i<42; i++)
- delays[i] = period*(i+1);
-}
-
-void wd_fdc_digital_t::digital_pll_t::reset(const attotime &when)
-{
- counter = 0;
- increment = 128;
- transition_time = 0xffff;
- history = 0x80;
- slot = 0;
- ctime = when;
- phase_add = 0x00;
- phase_sub = 0x00;
- freq_add = 0x00;
- freq_sub = 0x00;
- write_position = 0;
- write_start_time = attotime::never;
-}
-
-int wd_fdc_digital_t::digital_pll_t::get_next_bit(attotime &tm, floppy_image_device *floppy, const attotime &limit)
-{
- attotime when = floppy ? floppy->get_next_transition(ctime) : attotime::never;
-
- /* if (TRACE_TRANSITION)
- if(!when.is_never())
- logerror("transition_time=%s\n", tts(when).c_str());
- */
- for(;;) {
- // if (TRACE_TRANSITION) logerror("slot=%2d, counter=%03x\n", slot, counter);
- attotime etime = ctime+delays[slot];
- // if (TRACE_TRANSITION) logerror("etime=%s\n", tts(etime).c_str());
- if(etime > limit)
- return -1;
- if(transition_time == 0xffff && !when.is_never() && etime >= when)
- transition_time = counter;
- if(slot < 8) {
- UINT8 mask = 1 << slot;
- if(phase_add & mask)
- counter += 226;
- else if(phase_sub & mask)
- counter += 30;
- else
- counter += increment;
-
- if((freq_add & mask) && increment < 140)
- increment++;
- else if((freq_sub & mask) && increment > 117)
- increment--;
- } else
- counter += increment;
-
- slot++;
- tm = etime;
- if(counter & 0x800)
- break;
- }
- if (TRACE_TRANSITION) logerror("first transition, time=%03x, inc=%3d\n", transition_time, increment);
- int bit = transition_time != 0xffff;
-
- if(transition_time != 0xffff) {
- static const UINT8 pha[8] = { 0xf, 0x7, 0x3, 0x1, 0, 0, 0, 0 };
- static const UINT8 phs[8] = { 0, 0, 0, 0, 0x1, 0x3, 0x7, 0xf };
- static const UINT8 freqa[4][8] = {
- { 0xf, 0x7, 0x3, 0x1, 0, 0, 0, 0 },
- { 0x7, 0x3, 0x1, 0, 0, 0, 0, 0 },
- { 0x7, 0x3, 0x1, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0 }
- };
- static const UINT8 freqs[4][8] = {
- { 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0x1, 0x3, 0x7 },
- { 0, 0, 0, 0, 0, 0x1, 0x3, 0x7 },
- { 0, 0, 0, 0, 0x1, 0x3, 0x7, 0xf },
- };
-
- int cslot = transition_time >> 8;
- phase_add = pha[cslot];
- phase_sub = phs[cslot];
- int way = transition_time & 0x400 ? 1 : 0;
- if(history & 0x80)
- history = way ? 0x80 : 0x83;
- else if(history & 0x40)
- history = way ? history & 2 : (history & 2) | 1;
- freq_add = freqa[history & 3][cslot];
- freq_sub = freqs[history & 3][cslot];
- history = way ? (history >> 1) | 2 : history >> 1;
-
- } else
- phase_add = phase_sub = freq_add = freq_sub = 0;
-
- counter &= 0x7ff;
-
- ctime = tm;
- transition_time = 0xffff;
- slot = 0;
-
- return bit;
-}
-
-void wd_fdc_digital_t::digital_pll_t::start_writing(const attotime &tm)
-{
- write_start_time = tm;
- write_position = 0;
-}
-
-void wd_fdc_digital_t::digital_pll_t::stop_writing(floppy_image_device *floppy, const attotime &tm)
-{
- commit(floppy, tm);
- write_start_time = attotime::never;
-}
-
-bool wd_fdc_digital_t::digital_pll_t::write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, const attotime &limit)
-{
- if(write_start_time.is_never()) {
- write_start_time = ctime;
- write_position = 0;
- }
-
- for(;;) {
- attotime etime = ctime+delays[slot];
- if(etime > limit)
- return true;
- UINT16 pre_counter = counter;
- counter += increment;
- if(bit && !(pre_counter & 0x400) && (counter & 0x400))
- if(write_position < ARRAY_LENGTH(write_buffer))
- write_buffer[write_position++] = etime;
- slot++;
- tm = etime;
- if(counter & 0x800)
- break;
- }
-
- counter &= 0x7ff;
-
- ctime = tm;
- slot = 0;
-
- return false;
-}
-
-void wd_fdc_digital_t::digital_pll_t::commit(floppy_image_device *floppy, const attotime &tm)
-{
- if(write_start_time.is_never() || tm == write_start_time)
- return;
-
- if(floppy)
- floppy->write_flux(write_start_time, tm, write_position, write_buffer);
- write_start_time = tm;
- write_position = 0;
-}
-
-fd1771_t::fd1771_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1771, "FD1771", tag, owner, clock, "fd1771", __FILE__)
-{
- const static int fd1771_step_times[4] = { 12000, 12000, 20000, 40000 };
-
- step_times = fd1771_step_times;
- delay_register_commit = 16;
- delay_command_commit = 20; // x2 due to fm
- disable_mfm = true;
- inverted_bus = true;
- side_control = false;
- side_compare = false;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-int fd1771_t::calc_sector_size(UINT8 size, UINT8 command) const
-{
- if(command & 0x08)
- return 128 << (size & 3);
- else
- return size ? size << 4 : 4096;
-}
-
-fd1781_t::fd1781_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1781, "FD1781", tag, owner, clock, "fd1781", __FILE__)
-{
- const static int fd1781_step_times[4] = { 6000, 12000, 20000, 40000 };
-
- step_times = fd1781_step_times;
- delay_register_commit = 16;
- delay_command_commit = 12;
- disable_mfm = false;
- inverted_bus = true;
- side_control = false;
- side_compare = false;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-int fd1781_t::calc_sector_size(UINT8 size, UINT8 command) const
-{
- if(command & 0x08)
- return 128 << (size & 3);
- else
- return size ? size << 4 : 4096;
-}
-
-const int wd_fdc_t::fd179x_step_times[4] = { 6000, 12000, 20000, 30000 };
-const int wd_fdc_t::fd176x_step_times[4] = { 12000, 24000, 40000, 60000 };
-
-fd1791_t::fd1791_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1791, "FD1791", tag, owner, clock, "fd1791", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 4;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = true;
- side_control = false;
- side_compare = true;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-fd1792_t::fd1792_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1792, "FD1792", tag, owner, clock, "fd1792", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 4;
- delay_command_commit = 12;
- disable_mfm = true;
- has_enmf = false;
- inverted_bus = true;
- side_control = false;
- side_compare = true;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-fd1793_t::fd1793_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1793, "FD1793", tag, owner, clock, "fd1793", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 4;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = false;
- side_control = false;
- side_compare = true;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-kr1818vg93_t::kr1818vg93_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, KR1818VG93, "KR1818VG93", tag, owner, clock, "kr1818vg93", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 4;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = false;
- side_control = false;
- side_compare = true;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = true;
-}
-
-fd1794_t::fd1794_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1794, "FD1794", tag, owner, clock, "fd1794", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 4;
- delay_command_commit = 12;
- disable_mfm = true;
- has_enmf = false;
- inverted_bus = false;
- side_control = false;
- side_compare = true;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-fd1795_t::fd1795_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1795, "FD1795", tag, owner, clock, "fd1795", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 4;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = true;
- side_control = true;
- side_compare = false;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-int fd1795_t::calc_sector_size(UINT8 size, UINT8 command) const
-{
- if(command & 0x08)
- return 128 << (size & 3);
- else
- return 128 << ((size + 1) & 3);
-}
-
-fd1797_t::fd1797_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1797, "FD1797", tag, owner, clock, "fd1797", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 4;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = false;
- side_control = true;
- side_compare = false;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-int fd1797_t::calc_sector_size(UINT8 size, UINT8 command) const
-{
- if(command & 0x08)
- return 128 << (size & 3);
- else
- return 128 << ((size + 1) & 3);
-}
-
-mb8866_t::mb8866_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, MB8866, "MB8866", tag, owner, clock, "mb8866", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 4;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = true;
- side_control = false;
- side_compare = true;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-mb8876_t::mb8876_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, MB8876, "MB8876", tag, owner, clock, "mb8876", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 4;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = true;
- side_control = false;
- side_compare = true;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-mb8877_t::mb8877_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, MB8877, "MB8877", tag, owner, clock, "mb8877", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 4;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = false;
- side_control = false;
- side_compare = true;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-fd1761_t::fd1761_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1761, "FD1761", tag, owner, clock, "fd1761", __FILE__)
-{
- step_times = fd176x_step_times;
- delay_register_commit = 16;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = true;
- side_control = false;
- side_compare = true;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-fd1763_t::fd1763_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1763, "FD1763", tag, owner, clock, "fd1763", __FILE__)
-{
- step_times = fd176x_step_times;
- delay_register_commit = 16;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = false;
- side_control = false;
- side_compare = true;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-fd1765_t::fd1765_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1765, "FD1765", tag, owner, clock, "fd1765", __FILE__)
-{
- step_times = fd176x_step_times;
- delay_register_commit = 16;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = true;
- side_control = true;
- side_compare = false;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-int fd1765_t::calc_sector_size(UINT8 size, UINT8 command) const
-{
- if(command & 0x08)
- return 128 << (size & 3);
- else
- return 128 << ((size + 1) & 3);
-}
-
-fd1767_t::fd1767_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1767, "FD1767", tag, owner, clock, "fd1767", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 16;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = false;
- side_control = true;
- side_compare = false;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-int fd1767_t::calc_sector_size(UINT8 size, UINT8 command) const
-{
- if(command & 0x08)
- return 128 << (size & 3);
- else
- return 128 << ((size + 1) & 3);
-}
-
-wd2791_t::wd2791_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, WD2791, "WD2791", tag, owner, clock, "wd2791", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 16;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = true;
- inverted_bus = true;
- side_control = false;
- side_compare = true;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-wd2793_t::wd2793_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, WD2793, "WD2793", tag, owner, clock, "wd2793", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 16;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = true;
- inverted_bus = false;
- side_control = false;
- side_compare = true;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-wd2795_t::wd2795_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, WD2795, "WD2795", tag, owner, clock, "wd2795", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 16;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = true;
- side_control = true;
- side_compare = false;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-int wd2795_t::calc_sector_size(UINT8 size, UINT8 command) const
-{
- if(command & 0x08)
- return 128 << (size & 3);
- else
- return 128 << ((size + 1) & 3);
-}
-
-wd2797_t::wd2797_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, WD2797, "WD2797", tag, owner, clock, "wd2797", __FILE__)
-{
- step_times = fd179x_step_times;
- delay_register_commit = 16;
- delay_command_commit = 12;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = false;
- side_control = true;
- side_compare = false;
- head_control = true;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
-
-int wd2797_t::calc_sector_size(UINT8 size, UINT8 command) const
-{
- if(command & 0x08)
- return 128 << (size & 3);
- else
- return 128 << ((size + 1) & 3);
-}
-
-wd1770_t::wd1770_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_digital_t(mconfig, WD1770, "WD1770", tag, owner, clock, "wd1770", __FILE__)
-{
- step_times = wd_digital_step_times;
- delay_register_commit = 32;
- delay_command_commit = 36; // official 48 is too high for oric jasmin boot
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = false;
- side_control = false;
- side_compare = false;
- head_control = false;
- motor_control = true;
- ready_hooked = false;
- nonsticky_immint = false;
-}
-
-wd1772_t::wd1772_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_digital_t(mconfig, WD1772, "WD1772", tag, owner, clock, "wd1772", __FILE__)
-{
- const static int wd1772_step_times[4] = { 12000, 24000, 4000, 6000 };
-
- step_times = wd1772_step_times;
- delay_register_commit = 32;
- delay_command_commit = 48;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = false;
- side_control = false;
- side_compare = false;
- head_control = false;
- motor_control = true;
- ready_hooked = false;
- nonsticky_immint = false;
-}
-
-int wd1772_t::settle_time() const
-{
- return 30000;
-}
-
-wd1773_t::wd1773_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_digital_t(mconfig, WD1773, "WD1773", tag, owner, clock, "wd1773", __FILE__)
-{
- step_times = wd_digital_step_times;
- delay_register_commit = 32;
- delay_command_commit = 48;
- disable_mfm = false;
- has_enmf = false;
- inverted_bus = false;
- side_control = false;
- side_compare = true;
- head_control = false;
- motor_control = false;
- ready_hooked = true;
- nonsticky_immint = false;
-}
diff --git a/src/emu/machine/wd_fdc.h b/src/emu/machine/wd_fdc.h
deleted file mode 100644
index 7af735a7bef..00000000000
--- a/src/emu/machine/wd_fdc.h
+++ /dev/null
@@ -1,683 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-#ifndef WD_FDC_H
-#define WD_FDC_H
-
-#include "emu.h"
-#include "imagedev/floppy.h"
-#include "fdc_pll.h"
-
-/*
- * The Western Digital floppy controller family
- *
-
- * Chip Bus SCtrl SCmp Len HLO Motor Rdy MFM clock ENMF 58 pll
-
- * fd1771 inverted n n y y n y n 2MHz n n analog
-
- * fd1781 inverted n n y y n y y 1/2MHz n n analog
-
- * fd1791 inverted n y n y n y y 1/2MHz n n analog
- * fd1792 inverted n y n y n y n 1/2MHz n n analog
- * fd1793 normal n y n y n y y 1/2MHz n n analog
- * fd1794 normal n y n y n y n 1/2MHz n n analog
- * fd1795 inverted y n y y n y y 1/2MHz n n analog
- * fd1797 normal y n y y n y y 1/2MHz n n analog
-
- * mb8866 inverted n n n y n y y 1/2MHz n n analog (fd1791 compatible)
- * mb8876 inverted n y n y n y y 1/2MHz n n analog (fd1791-01/02 compatible)
- * mb8877 normal n y n y n y y 1/2MHz n n analog (fd1793 compatible)
-
- * fd1761 inverted n y n y n y y 1MHz n n analog
- * fd1763 normal n y n y n y y 1MHz n n analog
- * fd1765 inverted y n y y n y y 1MHz n n analog
- * fd1767 normal y n y y n y y 1MHz n n analog
-
- * wd2791 inverted n y n y n y y 1/2MHz y y analog
- * wd2793 normal n y n y n y y 1/2MHz y y analog
- * wd2795 inverted y n y y n y y 1/2MHz n y analog
- * wd2797 normal y n y y n y y 1/2MHz n y analog
-
- * wd1770 normal n n n n y n y 8Mhz n n digital
- * wd1772 normal n n n n y n y 8MHz n n digital
- * wd1773 normal n y n n n y y 8MHz n n digital
-
- */
-
-#define MCFG_FD1771_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, FD1771, _clock)
-
-#define MCFG_FD1781_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, FD1781, _clock)
-
-#define MCFG_FD1791_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, FD1791, _clock)
-
-#define MCFG_FD1792_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, FD1792, _clock)
-
-#define MCFG_FD1793_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, FD1793, _clock)
-
-#define MCFG_KR1818VG93_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, KR1818VG93, _clock)
-
-#define MCFG_FD1794_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, FD1794, _clock)
-
-#define MCFG_FD1795_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, FD1795, _clock)
-
-#define MCFG_FD1797_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, FD1797, _clock)
-
-#define MCFG_MB8866_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, MB8866, _clock)
-
-#define MCFG_MB8876_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, MB8876, _clock)
-
-#define MCFG_MB8877_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, MB8877, _clock)
-
-#define MCFG_FD1761_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, FD1761, _clock)
-
-#define MCFG_FD1763_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, FD1763, _clock)
-
-#define MCFG_FD1765_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, FD1765, _clock)
-
-#define MCFG_FD1767_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, FD1767, _clock)
-
-#define MCFG_WD2791_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, WD2791, _clock)
-
-#define MCFG_WD2793_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, WD2793, _clock)
-
-#define MCFG_WD2795_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, WD2795, _clock)
-
-#define MCFG_WD2797_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, WD2797, _clock)
-
-#define MCFG_WD1770_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, WD1770, _clock)
-
-#define MCFG_WD1772_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, WD1772, _clock)
-
-#define MCFG_WD1773_ADD(_tag, _clock) \
- MCFG_DEVICE_ADD(_tag, WD1773, _clock)
-
-#define MCFG_WD_FDC_FORCE_READY \
- downcast<wd_fdc_t *>(device)->set_force_ready(true);
-
-#define MCFG_WD_FDC_INTRQ_CALLBACK(_write) \
- devcb = &wd_fdc_t::set_intrq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_WD_FDC_DRQ_CALLBACK(_write) \
- devcb = &wd_fdc_t::set_drq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_WD_FDC_HLD_CALLBACK(_write) \
- devcb = &wd_fdc_t::set_hld_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_WD_FDC_ENP_CALLBACK(_write) \
- devcb = &wd_fdc_t::set_enp_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_WD_FDC_ENMF_CALLBACK(_read) \
- devcb = &wd_fdc_t::set_enmf_rd_callback(*device, DEVCB_##_read);
-
-class wd_fdc_t : public device_t {
-public:
- wd_fdc_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- template<class _Object> static devcb_base &set_intrq_wr_callback(device_t &device, _Object object) { return downcast<wd_fdc_t &>(device).intrq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_drq_wr_callback(device_t &device, _Object object) { return downcast<wd_fdc_t &>(device).drq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_hld_wr_callback(device_t &device, _Object object) { return downcast<wd_fdc_t &>(device).hld_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_enp_wr_callback(device_t &device, _Object object) { return downcast<wd_fdc_t &>(device).enp_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_enmf_rd_callback(device_t &device, _Object object) { return downcast<wd_fdc_t &>(device).enmf_cb.set_callback(object); }
-
- void soft_reset();
-
- void dden_w(bool dden);
- void set_floppy(floppy_image_device *floppy);
- void set_force_ready(bool force_ready);
-
- void cmd_w(UINT8 val);
- UINT8 status_r();
- DECLARE_READ8_MEMBER( status_r ) { return status_r(); }
- DECLARE_WRITE8_MEMBER( cmd_w ) { cmd_w(data); }
-
- void track_w(UINT8 val);
- UINT8 track_r();
- DECLARE_READ8_MEMBER( track_r ) { return track_r(); }
- DECLARE_WRITE8_MEMBER( track_w ) { track_w(data); }
-
- void sector_w(UINT8 val);
- UINT8 sector_r();
- DECLARE_READ8_MEMBER( sector_r ) { return sector_r(); }
- DECLARE_WRITE8_MEMBER( sector_w ) { sector_w(data); }
-
- void data_w(UINT8 val);
- UINT8 data_r();
- DECLARE_READ8_MEMBER( data_r ) { return data_r(); }
- DECLARE_WRITE8_MEMBER( data_w ) { data_w(data); }
-
- void gen_w(int reg, UINT8 val);
- UINT8 gen_r(int reg);
- DECLARE_READ8_MEMBER( read ) { return gen_r(offset);}
- DECLARE_WRITE8_MEMBER( write ) { gen_w(offset,data); }
-
- bool intrq_r();
- bool drq_r();
-
- bool hld_r();
- void hlt_w(bool state);
-
- bool enp_r();
-
- void index_callback(floppy_image_device *floppy, int state);
-
-protected:
- // Chip-specific configuration flags
- bool disable_mfm;
- bool enmf;
- bool has_enmf;
- bool inverted_bus;
- bool side_control;
- bool side_compare;
- bool head_control;
- bool motor_control;
- bool ready_hooked;
- bool nonsticky_immint;
- int clock_ratio;
- const int *step_times;
- int delay_register_commit;
- int delay_command_commit;
-
- static const int fd179x_step_times[4];
- static const int fd176x_step_times[4];
-
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- virtual int calc_sector_size(UINT8 size, UINT8 command) const;
- virtual int settle_time() const;
-
- virtual void pll_reset(bool fm, bool enmf, const attotime &when) = 0;
- virtual void pll_start_writing(const attotime &tm) = 0;
- virtual void pll_commit(floppy_image_device *floppy, const attotime &tm) = 0;
- virtual void pll_stop_writing(floppy_image_device *floppy, const attotime &tm) = 0;
- virtual int pll_get_next_bit(attotime &tm, floppy_image_device *floppy, const attotime &limit) = 0;
- virtual bool pll_write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, const attotime &limit) = 0;
- virtual void pll_save_checkpoint() = 0;
- virtual void pll_retrieve_checkpoint() = 0;
-
-private:
- enum { TM_GEN, TM_CMD, TM_TRACK, TM_SECTOR };
-
- // State machine general behaviour:
- //
- // There are three levels of state.
- //
- // Main state is associated to (groups of) commands. They're set
- // by a *_start() function below, and the associated _continue()
- // function can then be called at pretty much any time.
- //
- // Sub state is the state of execution within a command. The
- // principle is that the *_start() function selects the initial
- // substate, then the *_continue() function decides what to do,
- // possibly changing state. Eventually it can:
- // - decide to wait for an event (timer, index)
- // - end the command with command_end()
- // - start a live state (see below)
- //
- // In the first case, it must first switch to a waiting
- // sub-state, then return. The waiting sub-state must just
- // return immediatly when *_continue is called. Eventually the
- // event handler function will advance the state machine to
- // another sub-state, and things will continue synchronously.
- //
- // On command end it's also supposed to return immediatly.
- //
- // The last option is to switch to the next sub-state, start a
- // live state with live_start() then return. The next sub-state
- // will only be called once the live state is finished.
- //
- // Live states change continually depending on the disk contents
- // until the next externally discernable event is found. They
- // are checkpointing, run until an event is found, then they wait
- // for it. When an event eventually happens, the changes are
- // either committed or replayed until the sync event time.
- //
- // The transition to IDLE is only done on a synced event. Some
- // other transitions, such as activating drq, are also done after
- // syncing without exiting live mode. Syncing in live mode is
- // done by calling live_delay() with the state to change to after
- // syncing.
-
- enum {
- // General "doing nothing" state
- IDLE,
-
- // Main states - the commands
- RESTORE,
- SEEK,
- STEP,
- READ_SECTOR,
- READ_TRACK,
- READ_ID,
- WRITE_TRACK,
- WRITE_SECTOR,
-
- // Sub states
-
- SPINUP,
- SPINUP_WAIT,
- SPINUP_DONE,
-
- SETTLE_WAIT,
- SETTLE_DONE,
-
- DATA_LOAD_WAIT,
- DATA_LOAD_WAIT_DONE,
-
- SEEK_MOVE,
- SEEK_WAIT_STEP_TIME,
- SEEK_WAIT_STEP_TIME_DONE,
- SEEK_WAIT_STABILIZATION_TIME,
- SEEK_WAIT_STABILIZATION_TIME_DONE,
- SEEK_DONE,
-
- WAIT_INDEX,
- WAIT_INDEX_DONE,
-
- SCAN_ID,
- SCAN_ID_FAILED,
-
- SECTOR_READ,
- SECTOR_WRITE,
- TRACK_DONE,
-
- // Live states
-
- SEARCH_ADDRESS_MARK_HEADER,
- READ_HEADER_BLOCK_HEADER,
- READ_DATA_BLOCK_HEADER,
- READ_ID_BLOCK_TO_LOCAL,
- READ_ID_BLOCK_TO_DMA,
- READ_ID_BLOCK_TO_DMA_BYTE,
- SEARCH_ADDRESS_MARK_DATA,
- SEARCH_ADDRESS_MARK_DATA_FAILED,
- READ_SECTOR_DATA,
- READ_SECTOR_DATA_BYTE,
- READ_TRACK_DATA,
- READ_TRACK_DATA_BYTE,
- WRITE_TRACK_DATA,
- WRITE_BYTE,
- WRITE_BYTE_DONE,
- WRITE_SECTOR_PRE,
- WRITE_SECTOR_PRE_BYTE
- };
-
- struct live_info {
- enum { PT_NONE, PT_CRC_1, PT_CRC_2 };
-
- attotime tm;
- int state, next_state;
- UINT16 shift_reg;
- UINT16 crc;
- int bit_counter, byte_counter, previous_type;
- bool data_separator_phase, data_bit_context;
- UINT8 data_reg;
- UINT8 idbuf[6];
- };
-
- enum {
- S_BUSY = 0x01,
- S_DRQ = 0x02,
- S_IP = 0x02,
- S_TR00 = 0x04,
- S_LOST = 0x04,
- S_CRC = 0x08,
- S_RNF = 0x10,
- S_HLD = 0x20,
- S_SPIN = 0x20, // WD1770, WD1772
- S_DDM = 0x20,
- S_WF = 0x20, // WD1773
- S_WP = 0x40,
- S_NRDY = 0x80,
- S_MON = 0x80 // WD1770, WD1772
- };
-
- enum {
- I_RDY = 0x01,
- I_NRDY = 0x02,
- I_IDX = 0x04,
- I_IMM = 0x08
- };
-
-
- floppy_image_device *floppy;
-
- emu_timer *t_gen, *t_cmd, *t_track, *t_sector;
-
- bool dden, status_type_1, intrq, drq, hld, hlt, enp, force_ready;
- int main_state, sub_state;
- UINT8 command, track, sector, data, status, intrq_cond;
- int last_dir;
-
- int counter, motor_timeout, sector_size;
-
- int cmd_buffer, track_buffer, sector_buffer;
-
- live_info cur_live, checkpoint_live;
-
- devcb_write_line intrq_cb, drq_cb, hld_cb, enp_cb;
- devcb_read_line enmf_cb;
-
- UINT8 format_last_byte;
- int format_last_byte_count;
- std::string format_description_string;
-
- static std::string tts(const attotime &t);
- std::string ttsn();
-
- void delay_cycles(emu_timer *tm, int cycles);
-
- // Device timer subfunctions
- void do_cmd_w();
- void do_track_w();
- void do_sector_w();
- void do_generic();
-
-
- // Main-state handling functions
- void seek_start(int state);
- void seek_continue();
-
- void read_sector_start();
- void read_sector_continue();
-
- void read_track_start();
- void read_track_continue();
-
- void read_id_start();
- void read_id_continue();
-
- void write_track_start();
- void write_track_continue();
-
- void write_sector_start();
- void write_sector_continue();
-
- void interrupt_start();
-
- void general_continue();
- void command_end();
-
- void spinup();
- void ready_callback(floppy_image_device *floppy, int state);
- bool sector_matches() const;
- bool is_ready();
-
- void live_start(int live_state);
- void live_abort();
- void checkpoint();
- void rollback();
- void live_delay(int state);
- void live_sync();
- void live_run(attotime limit = attotime::never);
- bool read_one_bit(const attotime &limit);
- bool write_one_bit(const attotime &limit);
-
- void live_write_raw(UINT16 raw);
- void live_write_mfm(UINT8 mfm);
- void live_write_fm(UINT8 fm);
-
- void drop_drq();
- void set_drq();
-};
-
-class wd_fdc_analog_t : public wd_fdc_t {
-public:
- wd_fdc_analog_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
-protected:
- virtual void pll_reset(bool fm, bool enmf, const attotime &when);
- virtual void pll_start_writing(const attotime &tm);
- virtual void pll_commit(floppy_image_device *floppy, const attotime &tm);
- virtual void pll_stop_writing(floppy_image_device *floppy, const attotime &tm);
- virtual int pll_get_next_bit(attotime &tm, floppy_image_device *floppy, const attotime &limit);
- virtual bool pll_write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, const attotime &limit);
- virtual void pll_save_checkpoint();
- virtual void pll_retrieve_checkpoint();
-
-private:
- fdc_pll_t cur_pll, checkpoint_pll;
-};
-
-class wd_fdc_digital_t : public wd_fdc_t {
-public:
- wd_fdc_digital_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
-protected:
- static const int wd_digital_step_times[4];
-
- virtual void pll_reset(bool fm, bool enmf, const attotime &when);
- virtual void pll_start_writing(const attotime &tm);
- virtual void pll_commit(floppy_image_device *floppy, const attotime &tm);
- virtual void pll_stop_writing(floppy_image_device *floppy, const attotime &tm);
- virtual int pll_get_next_bit(attotime &tm, floppy_image_device *floppy, const attotime &limit);
- virtual bool pll_write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, const attotime &limit);
- virtual void pll_save_checkpoint();
- virtual void pll_retrieve_checkpoint();
-
-private:
- struct digital_pll_t {
- UINT16 counter;
- UINT16 increment;
- UINT16 transition_time;
- UINT8 history;
- UINT8 slot;
- UINT8 phase_add, phase_sub, freq_add, freq_sub;
- attotime ctime;
-
- attotime delays[42];
-
- attotime write_start_time;
- attotime write_buffer[32];
- int write_position;
-
- void set_clock(const attotime &period);
- void reset(const attotime &when);
- int get_next_bit(attotime &tm, floppy_image_device *floppy, const attotime &limit);
- bool write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, const attotime &limit);
- void start_writing(const attotime &tm);
- void commit(floppy_image_device *floppy, const attotime &tm);
- void stop_writing(floppy_image_device *floppy, const attotime &tm);
- };
-
- digital_pll_t cur_pll, checkpoint_pll;
-};
-
-class fd1771_t : public wd_fdc_analog_t {
-public:
- fd1771_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual int calc_sector_size(UINT8 size, UINT8 command) const;
-};
-
-class fd1781_t : public wd_fdc_analog_t {
-public:
- fd1781_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual int calc_sector_size(UINT8 size, UINT8 command) const;
-};
-
-class fd1791_t : public wd_fdc_analog_t {
-public:
- fd1791_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class fd1792_t : public wd_fdc_analog_t {
-public:
- fd1792_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class fd1793_t : public wd_fdc_analog_t {
-public:
- fd1793_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class kr1818vg93_t : public wd_fdc_analog_t {
-public:
- kr1818vg93_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class fd1794_t : public wd_fdc_analog_t {
-public:
- fd1794_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class fd1795_t : public wd_fdc_analog_t {
-public:
- fd1795_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual int calc_sector_size(UINT8 size, UINT8 command) const;
-};
-
-class fd1797_t : public wd_fdc_analog_t {
-public:
- fd1797_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual int calc_sector_size(UINT8 size, UINT8 command) const;
-};
-
-class mb8866_t : public wd_fdc_analog_t {
-public:
- mb8866_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class mb8876_t : public wd_fdc_analog_t {
-public:
- mb8876_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class mb8877_t : public wd_fdc_analog_t {
-public:
- mb8877_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class fd1761_t : public wd_fdc_analog_t {
-public:
- fd1761_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class fd1763_t : public wd_fdc_analog_t {
-public:
- fd1763_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class fd1765_t : public wd_fdc_analog_t {
-public:
- fd1765_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual int calc_sector_size(UINT8 size, UINT8 command) const;
-};
-
-class fd1767_t : public wd_fdc_analog_t {
-public:
- fd1767_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual int calc_sector_size(UINT8 size, UINT8 command) const;
-};
-
-class wd2791_t : public wd_fdc_analog_t {
-public:
- wd2791_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- DECLARE_WRITE_LINE_MEMBER(enmf_w) { enmf = state ? false : true; }
-};
-
-class wd2793_t : public wd_fdc_analog_t {
-public:
- wd2793_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- DECLARE_WRITE_LINE_MEMBER(enmf_w) { enmf = state ? false : true; }
-};
-
-class wd2795_t : public wd_fdc_analog_t {
-public:
- wd2795_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual int calc_sector_size(UINT8 size, UINT8 command) const;
-};
-
-class wd2797_t : public wd_fdc_analog_t {
-public:
- wd2797_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual int calc_sector_size(UINT8 size, UINT8 command) const;
-};
-
-class wd1770_t : public wd_fdc_digital_t {
-public:
- wd1770_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-class wd1772_t : public wd_fdc_digital_t {
-public:
- wd1772_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- virtual int settle_time() const;
-};
-
-class wd1773_t : public wd_fdc_digital_t {
-public:
- wd1773_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-extern const device_type FD1771;
-
-extern const device_type FD1781;
-
-extern const device_type FD1791;
-extern const device_type FD1792;
-extern const device_type FD1793;
-extern const device_type FD1794;
-extern const device_type KR1818VG93;
-extern const device_type FD1795;
-extern const device_type FD1797;
-
-extern const device_type MB8866;
-extern const device_type MB8876;
-extern const device_type MB8877;
-
-extern const device_type FD1761;
-extern const device_type FD1763;
-extern const device_type FD1765;
-extern const device_type FD1767;
-
-extern const device_type WD2791;
-extern const device_type WD2793;
-extern const device_type WD2795;
-extern const device_type WD2797;
-
-extern const device_type WD1770;
-extern const device_type WD1772;
-extern const device_type WD1773;
-
-#endif
diff --git a/src/emu/machine/wozfdc.c b/src/emu/machine/wozfdc.c
deleted file mode 100644
index dd3f2483c77..00000000000
--- a/src/emu/machine/wozfdc.c
+++ /dev/null
@@ -1,587 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-/*********************************************************************
-
- wozfdc.c
-
- Implementation of the Apple Disk II floppy disk controller
-
-*********************************************************************/
-
-#include "emu.h"
-#include "imagedev/floppy.h"
-#include "formats/ap2_dsk.h"
-#include "wozfdc.h"
-
-/***************************************************************************
- PARAMETERS
-***************************************************************************/
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-const device_type DISKII_FDC = &device_creator<diskii_fdc>;
-const device_type APPLEIII_FDC = &device_creator<appleiii_fdc>;
-
-#define DISKII_P6_REGION "diskii_rom_p6"
-
-ROM_START( diskiing )
- ROM_REGION(0x100, DISKII_P6_REGION, 0)
- ROM_LOAD( "341-0028-a.rom", 0x0000, 0x0100, CRC(b72a2c70) SHA1(bc39fbd5b9a8d2287ac5d0a42e639fc4d3c2f9d4)) /* 341-0028: 16-sector disk drive (older version), PROM P6 */
-ROM_END
-
-//-------------------------------------------------
-// rom_region - device-specific ROM region
-//-------------------------------------------------
-
-const rom_entry *wozfdc_device::device_rom_region() const
-{
- return ROM_NAME( diskiing );
-}
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-wozfdc_device::wozfdc_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- device_t(mconfig, type, name, tag, owner, clock, shortname, source)
-{
-}
-
-diskii_fdc::diskii_fdc(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- wozfdc_device(mconfig, DISKII_FDC, "Apple Disk II floppy controller", tag, owner, clock, "d2fdc", __FILE__)
-{
-}
-
-appleiii_fdc::appleiii_fdc(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- wozfdc_device(mconfig, DISKII_FDC, "Apple III floppy controller", tag, owner, clock, "a3fdc", __FILE__)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void wozfdc_device::device_start()
-{
- m_rom_p6 = machine().root_device().memregion(this->subtag(DISKII_P6_REGION).c_str())->base();
-
- timer = timer_alloc(0);
- delay_timer = timer_alloc(1);
-
- save_item(NAME(last_6502_write));
- save_item(NAME(mode_write));
- save_item(NAME(mode_load));
- save_item(NAME(active));
- save_item(NAME(phases));
- save_item(NAME(external_io_select));
- save_item(NAME(cur_lss.tm));
- save_item(NAME(cur_lss.cycles));
- save_item(NAME(cur_lss.data_reg));
- save_item(NAME(cur_lss.address));
- save_item(NAME(cur_lss.write_start_time));
-// save_item(NAME(cur_lss.write_buffer));
- save_item(NAME(cur_lss.write_position));
- save_item(NAME(cur_lss.write_line_active));
- save_item(NAME(predicted_lss.tm));
- save_item(NAME(predicted_lss.cycles));
- save_item(NAME(predicted_lss.data_reg));
- save_item(NAME(predicted_lss.address));
- save_item(NAME(predicted_lss.write_start_time));
-// save_item(NAME(predicted_lss.write_buffer));
- save_item(NAME(predicted_lss.write_position));
- save_item(NAME(predicted_lss.write_line_active));
- save_item(NAME(drvsel));
- save_item(NAME(enable1));
-}
-
-void wozfdc_device::device_reset()
-{
- floppy = NULL;
- active = MODE_IDLE;
- phases = 0x00;
- mode_write = false;
- mode_load = false;
- last_6502_write = 0x00;
- cur_lss.tm = machine().time();
- cur_lss.cycles = time_to_cycles(cur_lss.tm);
- cur_lss.data_reg = 0x00;
- cur_lss.address = 0x00;
- cur_lss.write_start_time = attotime::never;
- cur_lss.write_position = 0;
- cur_lss.write_line_active = false;
- predicted_lss.tm = attotime::never;
- external_io_select = false;
-}
-
-void wozfdc_device::a3_update_drive_sel()
-{
- floppy_image_device *newflop = NULL;
-
- if (!external_io_select)
- {
- newflop = floppy0->get_device();
- }
- else
- {
- switch (drvsel & 3)
- {
- case 0:
- newflop = floppy0->get_device();
- break;
-
- case 1:
- newflop = floppy1->get_device();
- break;
-
- case 2:
- newflop = floppy2->get_device();
- break;
-
- case 3:
- newflop = floppy3->get_device();
- break;
- }
- }
-
- if (floppy != newflop)
- {
- if(active) {
- lss_sync();
- floppy->mon_w(true);
- }
- floppy = newflop;
- if(active) {
- floppy->mon_w(false);
- lss_predict();
- }
- }
-}
-
-void diskii_fdc::device_reset()
-{
- wozfdc_device::device_reset();
- external_drive_select = false;
-
- if (floppy0 != NULL)
- {
- floppy = floppy0->get_device();
- }
-}
-
-void appleiii_fdc::device_reset()
-{
- wozfdc_device::device_reset();
- external_drive_select = true;
- drvsel = 0;
- enable1 = 1;
-}
-
-void wozfdc_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if(active)
- lss_sync();
-
- if(id == 1 && active == MODE_DELAY) {
- if(floppy)
- floppy->mon_w(true);
- active = MODE_IDLE;
- }
-
- if(active)
- lss_predict();
-}
-
-/*-------------------------------------------------
- read - called to read the FDC's registers
--------------------------------------------------*/
-
-READ8_MEMBER(wozfdc_device::read)
-{
- control(offset);
-
- if(!(offset & 1))
- return cur_lss.data_reg;
- return 0xff;
-}
-
-
-/*-------------------------------------------------
- write - called to write the FDC's registers
--------------------------------------------------*/
-
-WRITE8_MEMBER(wozfdc_device::write)
-{
- control(offset);
- last_6502_write = data;
- lss_predict();
-}
-
-void wozfdc_device::phase(int ph, bool on)
-{
- if(on)
- phases |= 1 << ph;
- else
- phases &= ~(1 << ph);
-
- if(floppy && active)
- floppy->seek_phase_w(phases);
-}
-
-void wozfdc_device::control(int offset)
-{
- if(offset < 8) {
- if(active)
- lss_sync();
- phase(offset >> 1, offset & 1);
- if(active)
- lss_predict();
-
- } else
- switch(offset) {
- case 0x8:
- if(active == MODE_ACTIVE) {
- lss_sync();
- delay_timer->adjust(attotime::from_seconds(1));
- active = MODE_DELAY;
- }
- break;
- case 0x9:
- switch(active) {
- case MODE_IDLE:
- if(floppy)
- floppy->mon_w(false);
- active = MODE_ACTIVE;
- if(floppy)
- lss_start();
- break;
- case MODE_DELAY:
- active = MODE_ACTIVE;
- delay_timer->adjust(attotime::never);
- break;
- }
- break;
- case 0xa:
- external_io_select = false;
- if(floppy != floppy0->get_device()) {
- if(active) {
- lss_sync();
- floppy->mon_w(true);
- }
- floppy = floppy0->get_device();
- if(active) {
- floppy->mon_w(false);
- lss_predict();
- }
- }
- break;
- case 0xb:
- external_io_select = true;
- if (!external_drive_select)
- {
- if (floppy != floppy1->get_device())
- {
- if(active) {
- lss_sync();
- floppy->mon_w(true);
- }
- floppy = floppy1->get_device();
- if(active) {
- floppy->mon_w(false);
- lss_predict();
- }
- }
- }
- else
- {
- a3_update_drive_sel();
- }
- break;
- case 0xc:
- if(mode_load) {
- if(active) {
- lss_sync();
- cur_lss.address &= ~0x04;
- }
- mode_load = false;
- if(active)
- lss_predict();
- }
- break;
- case 0xd:
- if(!mode_load) {
- if(active) {
- lss_sync();
- cur_lss.address |= 0x04;
- }
- mode_load = true;
- if(active)
- lss_predict();
- }
- break;
- case 0xe:
- if(mode_write) {
- if(active) {
- lss_sync();
- cur_lss.address &= ~0x08;
- }
- mode_write = false;
- if(active)
- lss_predict();
- }
- break;
- case 0xf:
- if(!mode_write) {
- if(active) {
- lss_sync();
- cur_lss.address |= 0x08;
- cur_lss.write_start_time = machine().time();
- if(floppy)
- floppy->set_write_splice(cur_lss.write_start_time);
- }
- mode_write = true;
- if(active)
- lss_predict();
- }
- break;
- }
-}
-
-UINT64 wozfdc_device::time_to_cycles(const attotime &tm)
-{
- // Clock is falling edges of the ~2Mhz clock
- // The 1021800 must be the controlling 6502's speed
-
- UINT64 cycles = tm.as_ticks(clock()*2);
- cycles = (cycles+1) >> 1;
- return cycles;
-}
-
-attotime wozfdc_device::cycles_to_time(UINT64 cycles)
-{
- return attotime::from_ticks(cycles*2+1, clock()*2);
-}
-
-void wozfdc_device::lss_start()
-{
- cur_lss.tm = machine().time();
- cur_lss.cycles = time_to_cycles(cur_lss.tm);
- cur_lss.data_reg = 0x00;
- cur_lss.address &= ~0x0e;
- cur_lss.write_position = 0;
- cur_lss.write_start_time = mode_write ? machine().time() : attotime::never;
- cur_lss.write_line_active = false;
- if(mode_write && floppy)
- floppy->set_write_splice(cur_lss.write_start_time);
- lss_predict();
-}
-
-void wozfdc_device::lss_delay(UINT64 cycles, const attotime &tm, UINT8 data_reg, UINT8 address, bool write_line_active)
-{
- if(data_reg & 0x80)
- address |= 0x02;
- else
- address &= ~0x02;
- predicted_lss.cycles = cycles;
- predicted_lss.tm = tm;
- predicted_lss.data_reg = data_reg;
- predicted_lss.address = address;
- predicted_lss.write_line_active = write_line_active;
- attotime mtm = machine().time();
- if(predicted_lss.tm > mtm)
- timer->adjust(predicted_lss.tm - mtm);
-}
-
-void wozfdc_device::lss_delay(UINT64 cycles, UINT8 data_reg, UINT8 address, bool write_line_active)
-{
- lss_delay(cycles, cycles_to_time(cycles), data_reg, address, write_line_active);
-}
-
-void wozfdc_device::commit_predicted()
-{
- cur_lss = predicted_lss;
- assert(!mode_write || (cur_lss.write_line_active && (cur_lss.address & 0x80)) || ((!cur_lss.write_line_active) && !(cur_lss.address & 0x80)));
- if(mode_write) {
- if(floppy)
- floppy->write_flux(cur_lss.write_start_time, cur_lss.tm, cur_lss.write_position, cur_lss.write_buffer);
- cur_lss.write_start_time = cur_lss.tm;
- cur_lss.write_position = 0;
- }
-
- predicted_lss.tm = attotime::never;
-}
-
-void wozfdc_device::lss_sync()
-{
- attotime tm = machine().time();
- if(!predicted_lss.tm.is_never() && predicted_lss.tm <= tm)
- commit_predicted();
-
- while(cur_lss.tm < tm) {
- lss_predict(tm);
- commit_predicted();
- }
-}
-
-void wozfdc_device::lss_predict(attotime limit)
-{
- predicted_lss.write_start_time = cur_lss.write_start_time;
- predicted_lss.write_position = cur_lss.write_position;
- memcpy(predicted_lss.write_buffer, cur_lss.write_buffer, cur_lss.write_position * sizeof(attotime));
- bool write_line_active = cur_lss.write_line_active;
-
- attotime next_flux = floppy ? floppy->get_next_transition(cur_lss.tm - attotime::from_usec(1)) : attotime::never;
-
- if(limit == attotime::never)
- limit = machine().time() + attotime::from_usec(50);
-
- UINT64 cycles = cur_lss.cycles;
- UINT64 cycles_limit = time_to_cycles(limit);
- UINT64 cycles_next_flux = next_flux != attotime::never ? time_to_cycles(next_flux) : UINT64(-1);
- UINT64 cycles_next_flux_down = cycles_next_flux != UINT64(-1) ? cycles_next_flux+1 : UINT64(-1);
-
- UINT8 address = cur_lss.address;
- UINT8 data_reg = cur_lss.data_reg;
-
- if(cycles >= cycles_next_flux && cycles < cycles_next_flux_down)
- address &= ~0x10;
- else
- address |= 0x10;
-
- while(cycles < cycles_limit) {
- UINT64 cycles_next_trans = cycles_limit;
- if(cycles_next_trans > cycles_next_flux && cycles < cycles_next_flux)
- cycles_next_trans = cycles_next_flux;
- if(cycles_next_trans > cycles_next_flux_down && cycles < cycles_next_flux_down)
- cycles_next_trans = cycles_next_flux_down;
-
- while(cycles < cycles_next_trans) {
- UINT8 opcode = m_rom_p6[address];
-
- if(mode_write) {
- if((write_line_active && !(address & 0x80)) ||
- (!write_line_active && (address & 0x80))) {
- write_line_active = !write_line_active;
- assert(predicted_lss.write_position != 32);
- predicted_lss.write_buffer[predicted_lss.write_position++] = cycles_to_time(cycles);
- }
- }
-
- address = (address & 0x1e) | (opcode & 0xc0) | ((opcode & 0x20) >> 5) | ((opcode & 0x10) << 1);
- switch(opcode & 0x0f) {
- case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
- if(data_reg) {
- lss_delay(cycles+1, 0x00, address, write_line_active);
- return;
- }
- break;
- case 0x8: case 0xc:
- break;
- case 0x9:
- lss_delay(cycles+1, data_reg << 1, address, write_line_active);
- return;
- case 0xa: case 0xe:
- lss_delay(cycles+1, (data_reg >> 1) | (floppy && floppy->wpt_r() ? 0x80 : 0x00), address, write_line_active);
- return;
- case 0xb: case 0xf:
- lss_delay(cycles+1, last_6502_write, address, write_line_active);
- return;
- case 0xd:
- lss_delay(cycles+1, (data_reg << 1) | 0x01, address, write_line_active);
- return;
- }
- cycles++;
- }
-
- if(cycles == cycles_next_flux)
- address &= ~0x10;
- else if(cycles == cycles_next_flux_down) {
- address |= 0x10;
- next_flux = floppy ? floppy->get_next_transition(cycles_to_time(cycles)) : attotime::never;
- cycles_next_flux = next_flux != attotime::never ? time_to_cycles(next_flux) : UINT64(-1);
- cycles_next_flux_down = cycles_next_flux != UINT64(-1) ? cycles_next_flux+1 : UINT64(-1);
- }
- }
-
- lss_delay(cycles, limit, data_reg, address, write_line_active);
-}
-
-// set the two images for the Disk II
-void diskii_fdc::set_floppies(floppy_connector *f0, floppy_connector *f1)
-{
- floppy0 = f0;
- floppy1 = f1;
-
- if (floppy0)
- {
- floppy = floppy0->get_device();
- }
-}
-
-void appleiii_fdc::set_floppies_4(floppy_connector *f0, floppy_connector *f1, floppy_connector *f2, floppy_connector *f3)
-{
- floppy0 = f0;
- floppy1 = f1;
- floppy2 = f2;
- floppy3 = f3;
-
- if (floppy0)
- {
- floppy = floppy0->get_device();
- }
-}
-
-READ8_MEMBER(appleiii_fdc::read_c0dx)
-{
- control_dx(offset);
-
- return 0xff;
-}
-
-WRITE8_MEMBER(appleiii_fdc::write_c0dx)
-{
- control_dx(offset);
-}
-
-void appleiii_fdc::control_dx(int offset)
-{
- switch (offset)
- {
- case 0: // clear drive select bit 0
- drvsel &= ~1;
- break;
-
- case 1: // set drive select bit 0
- drvsel |= 1;
- break;
-
- case 2: // clear drive select bit 1
- drvsel &= ~2;
- break;
-
- case 3: // set drive select bit 1
- drvsel |= 2;
- break;
-
- case 4: // clear enable 1
- enable1 = 0;
- break;
-
- case 5: // set enable 1
- enable1 = 1;
- break;
-
- case 6: // clear side 2
- case 7: // set side 2
- break;
-
- default: // cod8-c0df are not FDC related
- break;
- }
-
- if (offset < 8)
- {
- a3_update_drive_sel();
- }
-}
diff --git a/src/emu/machine/wozfdc.h b/src/emu/machine/wozfdc.h
deleted file mode 100644
index 384f057919d..00000000000
--- a/src/emu/machine/wozfdc.h
+++ /dev/null
@@ -1,122 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-/*********************************************************************
-
- wozfdc.h
-
- Apple Disk II floppy disk controller
-
-*********************************************************************/
-
-#pragma once
-
-#ifndef __WOZFDC_H__
-#define __WOZFDC_H__
-
-#include "emu.h"
-#include "imagedev/floppy.h"
-#include "formats/flopimg.h"
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-class wozfdc_device:
- public device_t
-{
- friend class diskii_fdc;
- friend class appleiii_fdc;
-
-public:
- // construction/destruction
- wozfdc_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- // optional information overrides
- virtual const rom_entry *device_rom_region() const;
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- floppy_connector *floppy0, *floppy1, *floppy2, *floppy3;
- floppy_image_device *floppy;
-
-private:
- enum {
- MODE_IDLE, MODE_ACTIVE, MODE_DELAY
- };
-
- struct lss {
- attotime tm;
- UINT64 cycles;
- UINT8 data_reg, address;
- attotime write_start_time;
- attotime write_buffer[32];
- int write_position;
- bool write_line_active;
- };
-
- const UINT8 *m_rom_p6;
- UINT8 last_6502_write;
- bool mode_write, mode_load;
- int active;
- UINT8 phases;
- emu_timer *timer, *delay_timer;
- bool external_drive_select;
- bool external_io_select;
-
- lss cur_lss, predicted_lss;
-
- int drvsel;
- int enable1;
-
- void control(int offset);
- void phase(int ph, bool on);
- UINT64 time_to_cycles(const attotime &tm);
- attotime cycles_to_time(UINT64 cycles);
- void a3_update_drive_sel();
-
- void lss_start();
- void lss_delay(UINT64 cycles, const attotime &tm, UINT8 data_reg, UINT8 address, bool write_line_active);
- void lss_delay(UINT64 cycles, UINT8 data_reg, UINT8 address, bool write_line_active);
- void lss_sync();
- void lss_predict(attotime limit = attotime::never);
- void commit_predicted();
-};
-
-class diskii_fdc : public wozfdc_device
-{
-public:
- diskii_fdc(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual void device_reset();
-
- void set_floppies(floppy_connector *f0, floppy_connector *f1);
-};
-
-class appleiii_fdc : public wozfdc_device
-{
-public:
- appleiii_fdc(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- virtual void device_reset();
-
- void set_floppies_4(floppy_connector *f0, floppy_connector *f1, floppy_connector *f2, floppy_connector *f3);
-
- DECLARE_READ8_MEMBER(read_c0dx);
- DECLARE_WRITE8_MEMBER(write_c0dx);
-
-private:
- void control_dx(int offset);
-};
-
-// device type definition
-extern const device_type DISKII_FDC;
-extern const device_type APPLEIII_FDC;
-
-#endif /* __WOZFDC_H__ */
diff --git a/src/emu/machine/x2212.c b/src/emu/machine/x2212.c
deleted file mode 100644
index 01db1709c74..00000000000
--- a/src/emu/machine/x2212.c
+++ /dev/null
@@ -1,261 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf,Barry Rodewald
-/***************************************************************************
-
- x2212.c
-
- Xicor X2212 256 x 4 bit Nonvolatile Static RAM.
-
-***************************************************************************/
-
-#include "emu.h"
-#include "machine/x2212.h"
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-static ADDRESS_MAP_START( x2212_sram_map, AS_0, 8, x2212_device )
- AM_RANGE(0x0000, 0x00ff) AM_RAM
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( x2212_e2prom_map, AS_1, 8, x2212_device )
- AM_RANGE(0x0000, 0x00ff) AM_RAM
-ADDRESS_MAP_END
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type X2212 = &device_creator<x2212_device>;
-const device_type X2210 = &device_creator<x2210_device>;
-
-//-------------------------------------------------
-// x2212_device - constructor
-//-------------------------------------------------
-
-x2212_device::x2212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, X2212, "X2212 NVRAM", tag, owner, clock, "x2212", __FILE__),
- device_memory_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this),
- m_auto_save(false),
- m_sram_space_config("SRAM", ENDIANNESS_BIG, 8, 8, 0, *ADDRESS_MAP_NAME(x2212_sram_map)),
- m_e2prom_space_config("E2PROM", ENDIANNESS_BIG, 8, 8, 0, *ADDRESS_MAP_NAME(x2212_e2prom_map)),
- m_store(false),
- m_array_recall(false)
-{
-}
-
-x2212_device::x2212_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_memory_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this),
- m_auto_save(false),
- m_sram_space_config("SRAM", ENDIANNESS_BIG, 8, 8, 0, *ADDRESS_MAP_NAME(x2212_sram_map)),
- m_e2prom_space_config("E2PROM", ENDIANNESS_BIG, 8, 8, 0, *ADDRESS_MAP_NAME(x2212_e2prom_map)),
- m_store(false),
- m_array_recall(false)
-{
-}
-
-//-------------------------------------------------
-// static_set_auto_save - configuration helper
-// to set the auto-save flag
-//-------------------------------------------------
-
-void x2212_device::static_set_auto_save(device_t &device)
-{
- downcast<x2212_device &>(device).m_auto_save = true;
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void x2212_device::device_start()
-{
- save_item(NAME(m_store));
- save_item(NAME(m_array_recall));
-
- m_sram = m_addrspace[0];
- m_e2prom = m_addrspace[1];
-
- SIZE_DATA = 0x100;
-}
-
-void x2210_device::device_start()
-{
- save_item(NAME(m_store));
- save_item(NAME(m_array_recall));
-
- m_sram = m_addrspace[0];
- m_e2prom = m_addrspace[1];
-
- SIZE_DATA = 0x40;
-}
-
-
-//-------------------------------------------------
-// memory_space_config - return a description of
-// any address spaces owned by this device
-//-------------------------------------------------
-
-const address_space_config *x2212_device::memory_space_config(address_spacenum spacenum) const
-{
- return (spacenum == 0) ? &m_sram_space_config : (spacenum == 1) ? &m_e2prom_space_config : NULL;
-}
-
-
-//-------------------------------------------------
-// nvram_default - called to initialize NVRAM to
-// its default state
-//-------------------------------------------------
-
-void x2212_device::nvram_default()
-{
- // default to all-0xff
- for (int byte = 0; byte < SIZE_DATA; byte++)
- {
- m_sram->write_byte(byte, 0xff);
- m_e2prom->write_byte(byte, 0xff);
- }
-
- // populate from a memory region if present
- if (m_region != NULL)
- {
- if (m_region->bytes() != SIZE_DATA)
- fatalerror("x2212 region '%s' wrong size (expected size = 0x100)\n", tag());
- if (m_region->bytewidth() != 1)
- fatalerror("x2212 region '%s' needs to be an 8-bit region\n", tag());
-
- UINT8 *default_data = m_region->base();
- for (int byte = 0; byte < SIZE_DATA; byte++)
- m_e2prom->write_byte(byte, default_data[byte]);
- }
-}
-
-
-//-------------------------------------------------
-// nvram_read - called to read NVRAM from the
-// .nv file
-//-------------------------------------------------
-
-void x2212_device::nvram_read(emu_file &file)
-{
- UINT8 *buffer = (UINT8 *) alloca(SIZE_DATA);
- file.read(buffer, SIZE_DATA);
- for (int byte = 0; byte < SIZE_DATA; byte++)
- {
- m_sram->write_byte(byte, 0xff);
- m_e2prom->write_byte(byte, buffer[byte]);
- }
-}
-
-
-//-------------------------------------------------
-// nvram_write - called to write NVRAM to the
-// .nv file
-//-------------------------------------------------
-
-void x2212_device::nvram_write(emu_file &file)
-{
- // auto-save causes an implicit store prior to exiting (writing)
- if (m_auto_save)
- store();
-
- UINT8 *buffer = (UINT8 *) alloca(SIZE_DATA);
- for (int byte = 0; byte < SIZE_DATA; byte++)
- buffer[byte] = m_e2prom->read_byte(byte);
- file.write(buffer, SIZE_DATA);
-}
-
-
-
-//**************************************************************************
-// INTERNAL HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// store - store data from live RAM into the
-// EEPROM
-//-------------------------------------------------
-
-void x2212_device::store()
-{
- for (int byte = 0; byte < SIZE_DATA; byte++)
- m_e2prom->write_byte(byte, m_sram->read_byte(byte));
-}
-
-
-//-------------------------------------------------
-// recall - fetch data from the EEPROM into live
-// RAM
-//-------------------------------------------------
-
-void x2212_device::recall()
-{
- for (int byte = 0; byte < SIZE_DATA; byte++)
- m_sram->write_byte(byte, m_e2prom->read_byte(byte));
-}
-
-
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-//-------------------------------------------------
-// write - store to the live RAM
-//-------------------------------------------------
-
-WRITE8_MEMBER( x2212_device::write )
-{
- m_sram->write_byte(offset, data & 0x0f);
-}
-
-
-//-------------------------------------------------
-// read - read from the live RAM
-//-------------------------------------------------
-
-READ8_MEMBER( x2212_device::read )
-{
- return (m_sram->read_byte(offset) & 0x0f) | (space.unmap() & 0xf0);
-}
-
-
-//-------------------------------------------------
-// store - set the state of the store line
-// (active high)
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( x2212_device::store )
-{
- if (state != 0 && !m_store)
- store();
- m_store = (state != 0);
-}
-
-
-//-------------------------------------------------
-// recall - set the state of the recall line
-// (active high)
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( x2212_device::recall )
-{
- if (state != 0 && !m_array_recall)
- recall();
- m_array_recall = (state != 0);
-}
-
-
-x2210_device::x2210_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : x2212_device(mconfig, X2210, "X2210", tag, owner, clock, "x2210", __FILE__)
-{
-}
diff --git a/src/emu/machine/x2212.h b/src/emu/machine/x2212.h
deleted file mode 100644
index 4345c8f9a64..00000000000
--- a/src/emu/machine/x2212.h
+++ /dev/null
@@ -1,113 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf,Barry Rodewald
-/***************************************************************************
-
- x2212.h
-
- Xicor X2212 256 x 4 bit Nonvolatile Static RAM.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __X2212_H__
-#define __X2212_H__
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_X2212_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, X2212, 0)
-// some systems (like many early Atari games) wire up the /STORE signal
-// to fire on power-down, effectively creating an "auto-save" functionality
-#define MCFG_X2212_ADD_AUTOSAVE(_tag) \
- MCFG_DEVICE_ADD(_tag, X2212, 0) \
- x2212_device::static_set_auto_save(*device);
-
-#define MCFG_X2210_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, X2210, 0)
-
-#define MCFG_X2210_ADD_AUTOSAVE(_tag) \
- MCFG_DEVICE_ADD(_tag, X2210, 0) \
- x2212_device::static_set_auto_save(*device);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-// ======================> x2212_device
-
-class x2212_device : public device_t,
- public device_memory_interface,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- x2212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- x2212_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
-
- // inline configuration helpers
- static void static_set_auto_save(device_t &device);
-
- // I/O operations
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( store );
- DECLARE_WRITE_LINE_MEMBER( recall );
-
-protected:
- // internal helpers
- void store();
- void recall();
-
- // device-level overrides
- virtual void device_start();
-
- // device_memory_interface overrides
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read(emu_file &file);
- virtual void nvram_write(emu_file &file);
-
- int SIZE_DATA;
-
- // configuration state
- bool m_auto_save;
-
- // device-specific configuration
- address_space_config m_sram_space_config;
- address_space_config m_e2prom_space_config;
-
- // internal state
- address_space * m_sram;
- address_space * m_e2prom;
-
- bool m_store;
- bool m_array_recall;
-};
-
-class x2210_device : public x2212_device
-{
-public:
- x2210_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- // device-level overrides
- virtual void device_start();
-};
-
-
-// device type definition
-extern const device_type X2212;
-extern const device_type X2210;
-
-
-#endif
diff --git a/src/emu/machine/x76f041.c b/src/emu/machine/x76f041.c
deleted file mode 100644
index 21dea0ae141..00000000000
--- a/src/emu/machine/x76f041.c
+++ /dev/null
@@ -1,540 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
- * x76f041.c
- *
- * Secure SerialFlash
- *
- * The X76F041 is a Password Access Security Supervisor, containing four 128 x 8 bit SecureFlash arrays.
- * Access can be controlled by three 64-bit programmable passwords, one for read operations, one for write
- * operations and one for device configuration.
- *
- * The data sheet has an incorrect diagrams for sequential read with password, there shouldn't be an extra address after the 0xc0 command.
- *
- */
-
-#include "emu.h"
-#include "machine/x76f041.h"
-
-#define VERBOSE_LEVEL ( 0 )
-
-inline void ATTR_PRINTF( 3, 4 ) x76f041_device::verboselog( int n_level, const char *s_fmt, ... )
-{
- if( VERBOSE_LEVEL >= n_level )
- {
- va_list v;
- char buf[ 32768 ];
- va_start( v, s_fmt );
- vsprintf( buf, s_fmt, v );
- va_end( v );
- logerror( "%s: x76f041(%s) %s", machine().describe_context(), tag(), buf );
- }
-}
-
-// device type definition
-const device_type X76F041 = &device_creator<x76f041_device>;
-
-x76f041_device::x76f041_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
- : device_t( mconfig, X76F041, "X76F041 Flash", tag, owner, clock, "x76f041", __FILE__ ),
- device_nvram_interface(mconfig, *this),
- m_cs( 0 ),
- m_rst( 0 ),
- m_scl( 0 ),
- m_sdaw( 0 ),
- m_sdar( 0 ),
- m_state( STATE_STOP ),
- m_shift( 0 ),
- m_bit( 0 ),
- m_byte( 0 ),
- m_command( 0 ),
- m_address( 0 )
-{
-}
-
-void x76f041_device::device_start()
-{
- memset( m_write_buffer, 0, sizeof( m_write_buffer ) );
-
- save_item( NAME( m_cs ) );
- save_item( NAME( m_rst ) );
- save_item( NAME( m_scl ) );
- save_item( NAME( m_sdaw ) );
- save_item( NAME( m_sdar ) );
- save_item( NAME( m_state ) );
- save_item( NAME( m_shift ) );
- save_item( NAME( m_bit ) );
- save_item( NAME( m_byte ) );
- save_item( NAME( m_command ) );
- save_item( NAME( m_address ) );
- save_item( NAME( m_write_buffer ) );
- save_item( NAME( m_response_to_reset ) );
- save_item( NAME( m_write_password ) );
- save_item( NAME( m_read_password ) );
- save_item( NAME( m_configuration_password ) );
- save_item( NAME( m_configuration_registers ) );
- save_item( NAME( m_data ) );
-}
-
-WRITE_LINE_MEMBER( x76f041_device::write_cs )
-{
- if( m_cs != state )
- {
- verboselog( 2, "cs=%d\n", state );
- }
-
- if( m_cs != 0 && state == 0 )
- {
- /* enable chip */
- m_state = STATE_STOP;
- }
-
- if( m_cs == 0 && state != 0 )
- {
- /* disable chip */
- m_state = STATE_STOP;
- /* high impendence? */
- m_sdar = 0;
- }
-
- m_cs = state;
-}
-
-WRITE_LINE_MEMBER( x76f041_device::write_rst )
-{
- if( m_rst != state )
- {
- verboselog( 2, "rst=%d\n", state );
- }
-
- if( m_rst == 0 && state != 0 && m_cs == 0 )
- {
- verboselog( 1, "goto response to reset\n" );
- m_state = STATE_RESPONSE_TO_RESET;
- m_bit = 0;
- m_byte = 0;
- }
-
- m_rst = state;
-}
-
-UINT8 *x76f041_device::password()
-{
- switch( m_command & 0xe0 )
- {
- case COMMAND_WRITE:
- return m_write_password;
-
- case COMMAND_READ:
- return m_read_password;
-
- default:
- return m_configuration_password;
- }
-}
-
-void x76f041_device::password_ok()
-{
- switch( m_command & 0xe0 )
- {
- case COMMAND_WRITE:
- m_state = STATE_WRITE_DATA;
- break;
- case COMMAND_READ:
- m_state = STATE_READ_DATA;
- break;
- case COMMAND_WRITE_USE_CONFIGURATION_PASSWORD:
- m_state = STATE_WRITE_DATA;
- break;
- case COMMAND_READ_USE_CONFIGURATION_PASSWORD:
- m_state = STATE_READ_DATA;
- break;
- case COMMAND_CONFIGURATION:
- switch( m_address )
- {
- case CONFIGURATION_PROGRAM_WRITE_PASSWORD:
- break;
- case CONFIGURATION_PROGRAM_READ_PASSWORD:
- break;
- case CONFIGURATION_PROGRAM_CONFIGURATION_PASSWORD:
- break;
- case CONFIGURATION_RESET_WRITE_PASSWORD:
- break;
- case CONFIGURATION_RESET_READ_PASSWORD:
- break;
- case CONFIGURATION_PROGRAM_CONFIGURATION_REGISTERS:
- m_state = STATE_WRITE_CONFIGURATION_REGISTERS;
- m_byte = 0;
- break;
- case CONFIGURATION_READ_CONFIGURATION_REGISTERS:
- m_state = STATE_READ_CONFIGURATION_REGISTERS;
- m_byte = 0;
- break;
- case CONFIGURATION_MASS_PROGRAM:
- break;
- case CONFIGURATION_MASS_ERASE:
- break;
- default:
- break;
- }
- }
-}
-
-void x76f041_device::load_address()
-{
- /* todo: handle other bcr bits */
- int bcr;
-
- m_address = m_shift;
-
- verboselog( 1, "-> address: %02x\n", m_address );
-
- if( ( m_command & 1 ) == 0 )
- {
- bcr = m_configuration_registers[ CONFIG_BCR1 ];
- }
- else
- {
- bcr = m_configuration_registers[ CONFIG_BCR2 ];
- }
- if( ( m_address & 0x80 ) != 0 )
- {
- bcr >>= 4;
- }
-
- if( ( ( m_command & 0xe0 ) == COMMAND_READ && ( bcr & BCR_Z ) != 0 && ( bcr & BCR_T ) != 0 ) ||
- ( ( m_command & 0xe0 ) == COMMAND_WRITE && ( bcr & BCR_Z ) != 0 ) )
- {
- /* todo: find out when this is really checked. */
- verboselog( 1, "command not allowed\n" );
- m_state = STATE_STOP;
- m_sdar = 0;
- }
- else if( ( ( m_command & 0xe0 ) == COMMAND_WRITE && ( bcr & BCR_X ) == 0 ) ||
- ( ( m_command & 0xe0 ) == COMMAND_READ && ( bcr & BCR_Y ) == 0 ) )
- {
- verboselog( 1, "password not required\n" );
- password_ok();
- }
- else
- {
- verboselog( 1, "send password\n" );
- m_state = STATE_LOAD_PASSWORD;
- m_byte = 0;
- }
-}
-
-int x76f041_device::data_offset()
-{
- int block_offset = ( ( m_command & 1 ) << 8 ) + m_address;
-
- // TODO: confirm block_start doesn't wrap.
-
- return ( block_offset & 0x180 ) | ( ( block_offset + m_byte ) & 0x7f );
-}
-
-WRITE_LINE_MEMBER( x76f041_device::write_scl )
-{
- if( m_scl != state )
- {
- verboselog( 2, "scl=%d\n", state );
- }
-
- if( m_cs == 0 )
- {
- switch( m_state )
- {
- case STATE_STOP:
- break;
-
- case STATE_RESPONSE_TO_RESET:
- if( m_scl != 0 && state == 0 )
- {
- m_sdar = ( m_response_to_reset[ m_byte ] >> m_bit ) & 1;
- verboselog( 2, "in response to reset %d (%d/%d)\n", m_sdar, m_byte, m_bit );
- m_bit++;
-
- if( m_bit == 8 )
- {
- m_bit = 0;
- m_byte++;
-
- if( m_byte == sizeof( m_response_to_reset ) )
- {
- m_byte = 0;
- }
- }
- }
- break;
-
- case STATE_LOAD_COMMAND:
- case STATE_LOAD_ADDRESS:
- case STATE_LOAD_PASSWORD:
- case STATE_VERIFY_PASSWORD:
- case STATE_WRITE_DATA:
- case STATE_WRITE_CONFIGURATION_REGISTERS:
- if( m_scl == 0 && state != 0 )
- {
- if( m_bit < 8 )
- {
- verboselog( 2, "clock\n" );
- m_shift <<= 1;
-
- if( m_sdaw != 0 )
- {
- m_shift |= 1;
- }
-
- m_bit++;
- }
- else
- {
- m_sdar = 0;
-
- switch( m_state )
- {
- case STATE_LOAD_COMMAND:
- m_command = m_shift;
- verboselog( 1, "-> command: %02x\n", m_command );
- /* todo: verify command is valid? */
- m_state = STATE_LOAD_ADDRESS;
- break;
-
- case STATE_LOAD_ADDRESS:
- load_address();
- break;
-
- case STATE_LOAD_PASSWORD:
- verboselog( 1, "-> password: %02x\n", m_shift );
- m_write_buffer[ m_byte++ ] = m_shift;
-
- if( m_byte == sizeof( m_write_buffer ) )
- {
- m_state = STATE_VERIFY_PASSWORD;
- }
- break;
-
- case STATE_VERIFY_PASSWORD:
- verboselog( 1, "-> verify password: %02x\n", m_shift );
-
- /* todo: this should probably be handled as a command */
- if( m_shift == 0xc0 )
- {
- /* todo: this should take 10ms before it returns ok. */
- if( memcmp( password(), m_write_buffer, sizeof( m_write_buffer ) ) == 0 )
- {
- password_ok();
- }
- else
- {
- m_sdar = 1;
- }
- }
- break;
-
- case STATE_WRITE_DATA:
- verboselog( 2, "-> data: %02x\n", m_shift );
- m_write_buffer[ m_byte++ ] = m_shift;
-
- if( m_byte == sizeof( m_write_buffer ) )
- {
- for( m_byte = 0; m_byte < sizeof( m_write_buffer ); m_byte++ )
- {
- int offset = data_offset();
- verboselog( 1, "-> data[ %03x ]: %02x\n", offset, m_write_buffer[ m_byte ] );
- m_data[ offset ] = m_write_buffer[ m_byte ];
- }
- m_byte = 0;
-
- verboselog( 1, "data flushed\n" );
- }
- break;
-
- case STATE_WRITE_CONFIGURATION_REGISTERS:
- verboselog( 1, "-> configuration register[ %d ]: %02x\n", m_byte, m_shift );
- /* todo: write after all bytes received? */
- m_configuration_registers[ m_byte++ ] = m_shift;
-
- if( m_byte == sizeof( m_configuration_registers ) )
- {
- m_byte = 0;
- }
- break;
- }
-
- m_bit = 0;
- m_shift = 0;
- }
- }
- break;
-
- case STATE_READ_DATA:
- case STATE_READ_CONFIGURATION_REGISTERS:
- if( m_scl == 0 && state != 0 )
- {
- if( m_bit < 8 )
- {
- if( m_bit == 0 )
- {
- int offset;
-
- switch( m_state )
- {
- case STATE_READ_DATA:
- offset = data_offset();
- m_shift = m_data[ offset ];
- verboselog( 1, "<- data[ %03x ]: %02x\n", offset, m_shift );
- break;
-
- case STATE_READ_CONFIGURATION_REGISTERS:
- offset = m_byte & 7;
- m_shift = m_configuration_registers[ offset ];
- verboselog( 1, "<- configuration register[ %d ]: %02x\n", offset, m_shift );
- break;
- }
- }
-
- m_sdar = ( m_shift >> 7 ) & 1;
- m_shift <<= 1;
- m_bit++;
- }
- else
- {
- m_bit = 0;
- m_sdar = 0;
-
- if( m_sdaw == 0 )
- {
- verboselog( 2, "ack <-\n" );
- m_byte++;
- }
- else
- {
- verboselog( 2, "nak <-\n" );
- }
- }
- }
- break;
- }
- }
-
- m_scl = state;
-}
-
-WRITE_LINE_MEMBER( x76f041_device::write_sda )
-{
- if( m_sdaw != state )
- {
- verboselog( 2, "sdaw=%d\n", state );
- }
-
- if( m_cs == 0 && m_scl != 0 )
- {
- if( m_sdaw == 0 && state != 0 )
- {
- verboselog( 1, "goto stop\n" );
- m_state = STATE_STOP;
- m_sdar = 0;
- }
-
- if( m_sdaw != 0 && state == 0 )
- {
- switch( m_state )
- {
- case STATE_STOP:
- verboselog( 1, "goto start\n" );
- m_state = STATE_LOAD_COMMAND;
- break;
-
- case STATE_LOAD_PASSWORD:
- /* todo: this will be the 0xc0 command, but it's not handled as a command yet. */
- verboselog( 1, "goto start\n" );
- break;
-
- case STATE_READ_DATA:
- verboselog( 1, "goto load address\n" );
- m_state = STATE_LOAD_ADDRESS;
- break;
-
- default:
- verboselog( 1, "skipped start (default)\n" );
- break;
- }
-
- m_bit = 0;
- m_byte = 0;
- m_shift = 0;
- m_sdar = 0;
- }
- }
-
- m_sdaw = state;
-}
-
-READ_LINE_MEMBER( x76f041_device::read_sda )
-{
- if( m_cs != 0 )
- {
- verboselog( 2, "not selected\n" );
- return 1;
- }
-
- verboselog( 2, "sdar=%d\n", m_sdar );
- return m_sdar;
-}
-
-void x76f041_device::nvram_default()
-{
- m_response_to_reset[0] = 0x19;
- m_response_to_reset[1] = 0x55;
- m_response_to_reset[2] = 0xaa;
- m_response_to_reset[3] = 0x55,
-
- memset( m_write_password, 0, sizeof( m_write_password ) );
- memset( m_read_password, 0, sizeof( m_read_password ) );
- memset( m_configuration_password, 0, sizeof( m_configuration_password ) );
- memset( m_configuration_registers, 0, sizeof( m_configuration_registers ) );
- memset( m_data, 0, sizeof( m_data ) );
-
- int expected_bytes = sizeof( m_response_to_reset ) + sizeof( m_write_password ) + sizeof( m_read_password ) +
- sizeof( m_configuration_password ) + sizeof( m_configuration_registers ) + sizeof( m_data );
-
- if( !m_region )
- {
- logerror( "x76f041(%s) region not found\n", tag() );
- }
- else if( m_region->bytes() != expected_bytes )
- {
- logerror( "x76f041(%s) region length 0x%x expected 0x%x\n", tag(), m_region->bytes(), expected_bytes );
- }
- else
- {
- UINT8 *region = m_region->base();
-
- memcpy( m_response_to_reset, region, sizeof( m_response_to_reset ) ); region += sizeof( m_response_to_reset );
- memcpy( m_write_password, region, sizeof( m_write_password ) ); region += sizeof( m_write_password );
- memcpy( m_read_password, region, sizeof( m_read_password ) ); region += sizeof( m_read_password );
- memcpy( m_configuration_password, region, sizeof( m_configuration_password ) ); region += sizeof( m_configuration_password );
- memcpy( m_configuration_registers, region, sizeof( m_configuration_registers ) ); region += sizeof( m_configuration_registers );
- memcpy( m_data, region, sizeof( m_data ) ); region += sizeof( m_data );
- }
-}
-
-void x76f041_device::nvram_read( emu_file &file )
-{
- file.read( m_response_to_reset, sizeof( m_response_to_reset ) );
- file.read( m_write_password, sizeof( m_write_password ) );
- file.read( m_read_password, sizeof( m_read_password ) );
- file.read( m_configuration_password, sizeof( m_configuration_password ) );
- file.read( m_configuration_registers, sizeof( m_configuration_registers ) );
- file.read( m_data, sizeof( m_data ) );
-}
-
-void x76f041_device::nvram_write( emu_file &file )
-{
- file.write( m_response_to_reset, sizeof( m_response_to_reset ) );
- file.write( m_write_password, sizeof( m_write_password ) );
- file.write( m_read_password, sizeof( m_read_password ) );
- file.write( m_configuration_password, sizeof( m_configuration_password ) );
- file.write( m_configuration_registers, sizeof( m_configuration_registers ) );
- file.write( m_data, sizeof( m_data ) );
-}
diff --git a/src/emu/machine/x76f041.h b/src/emu/machine/x76f041.h
deleted file mode 100644
index d1f8a8e9e46..00000000000
--- a/src/emu/machine/x76f041.h
+++ /dev/null
@@ -1,127 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
- * x76f041.h
- *
- * Secure SerialFlash
- *
- */
-
-#pragma once
-
-#ifndef __X76F041_H__
-#define __X76F041_H__
-
-#include "emu.h"
-
-#define MCFG_X76F041_ADD( _tag ) \
- MCFG_DEVICE_ADD( _tag, X76F041, 0 )
-
-class x76f041_device : public device_t,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- x76f041_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock );
-
- DECLARE_WRITE_LINE_MEMBER( write_cs );
- DECLARE_WRITE_LINE_MEMBER( write_rst );
- DECLARE_WRITE_LINE_MEMBER( write_scl );
- DECLARE_WRITE_LINE_MEMBER( write_sda );
- DECLARE_READ_LINE_MEMBER( read_sda );
-
-protected:
- // device-level overrides
- virtual void device_start();
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read( emu_file &file );
- virtual void nvram_write( emu_file &file );
-
-private:
- inline void ATTR_PRINTF( 3, 4 ) verboselog( int n_level, const char *s_fmt, ... );
- UINT8 *password();
- void password_ok();
- void load_address();
- int data_offset();
-
- enum configuration_register_t
- {
- CONFIG_BCR1 = 0,
- CONFIG_BCR2 = 1,
- CONFIG_CR = 2,
- CONFIG_RR = 3,
- CONFIG_RC = 4
- };
-
- enum bcr_t
- {
- BCR_X = 8,
- BCR_Y = 4,
- BCR_Z = 2,
- BCR_T = 1
- };
-
- enum command_t
- {
- COMMAND_WRITE = 0x00,
- COMMAND_READ = 0x20,
- COMMAND_WRITE_USE_CONFIGURATION_PASSWORD = 0x40,
- COMMAND_READ_USE_CONFIGURATION_PASSWORD = 0x60,
- COMMAND_CONFIGURATION = 0x80
- };
-
- enum configuration_t
- {
- CONFIGURATION_PROGRAM_WRITE_PASSWORD = 0x00,
- CONFIGURATION_PROGRAM_READ_PASSWORD = 0x10,
- CONFIGURATION_PROGRAM_CONFIGURATION_PASSWORD = 0x20,
- CONFIGURATION_RESET_WRITE_PASSWORD = 0x30,
- CONFIGURATION_RESET_READ_PASSWORD = 0x40,
- CONFIGURATION_PROGRAM_CONFIGURATION_REGISTERS = 0x50,
- CONFIGURATION_READ_CONFIGURATION_REGISTERS = 0x60,
- CONFIGURATION_MASS_PROGRAM = 0x70,
- CONFIGURATION_MASS_ERASE = 0x80
- };
-
- enum state_t
- {
- STATE_STOP,
- STATE_RESPONSE_TO_RESET,
- STATE_LOAD_COMMAND,
- STATE_LOAD_ADDRESS,
- STATE_LOAD_PASSWORD,
- STATE_VERIFY_PASSWORD,
- STATE_READ_DATA,
- STATE_WRITE_DATA,
- STATE_READ_CONFIGURATION_REGISTERS,
- STATE_WRITE_CONFIGURATION_REGISTERS
- };
-
- // internal state
- int m_cs;
- int m_rst;
- int m_scl;
- int m_sdaw;
- int m_sdar;
- int m_state;
- int m_shift;
- int m_bit;
- int m_byte;
- int m_command;
- int m_address;
- UINT8 m_write_buffer[ 8 ];
- UINT8 m_response_to_reset[ 4 ];
- UINT8 m_write_password[ 8 ];
- UINT8 m_read_password[ 8 ];
- UINT8 m_configuration_password[ 8 ];
- UINT8 m_configuration_registers[ 8 ];
- UINT8 m_data[ 512 ];
-};
-
-
-// device type definition
-extern const device_type X76F041;
-
-#endif
diff --git a/src/emu/machine/x76f100.c b/src/emu/machine/x76f100.c
deleted file mode 100644
index 830a0e51448..00000000000
--- a/src/emu/machine/x76f100.c
+++ /dev/null
@@ -1,427 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
- * x76f100.c
- *
- * Secure SerialFlash
- *
- * The X76F100 is a Password Access Security Supervisor, containing one 896-bit Secure SerialFlash array.
- * Access to the memory array can be controlled by two 64-bit passwords. These passwords protect read and
- * write operations of the memory array.
- *
- */
-
-#include "emu.h"
-#include "machine/x76f100.h"
-
-#define VERBOSE_LEVEL ( 0 )
-
-inline void ATTR_PRINTF( 3, 4 ) x76f100_device::verboselog( int n_level, const char *s_fmt, ... )
-{
- if( VERBOSE_LEVEL >= n_level )
- {
- va_list v;
- char buf[ 32768 ];
- va_start( v, s_fmt );
- vsprintf( buf, s_fmt, v );
- va_end( v );
- logerror( "%s: x76f100(%s) %s", machine().describe_context(), tag(), buf );
- }
-}
-
-// device type definition
-const device_type X76F100 = &device_creator<x76f100_device>;
-
-x76f100_device::x76f100_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
- : device_t( mconfig, X76F100, "X76F100 Flash", tag, owner, clock, "x76f100", __FILE__ ),
- device_nvram_interface(mconfig, *this),
- m_cs( 0 ),
- m_rst( 0 ),
- m_scl( 0 ),
- m_sdaw( 0 ),
- m_sdar( 0 ),
- m_state( STATE_STOP ),
- m_shift( 0 ),
- m_bit( 0 ),
- m_byte( 0 ),
- m_command( 0 )
-{
-}
-
-void x76f100_device::device_start()
-{
- memset( m_write_buffer, 0, sizeof( m_write_buffer ) );
-
- save_item( NAME( m_cs ) );
- save_item( NAME( m_rst ) );
- save_item( NAME( m_scl ) );
- save_item( NAME( m_sdaw ) );
- save_item( NAME( m_sdar ) );
- save_item( NAME( m_state ) );
- save_item( NAME( m_shift ) );
- save_item( NAME( m_bit ) );
- save_item( NAME( m_byte ) );
- save_item( NAME( m_command ) );
- save_item( NAME( m_write_buffer ) );
- save_item( NAME( m_response_to_reset ) );
- save_item( NAME( m_write_password ) );
- save_item( NAME( m_read_password ) );
- save_item( NAME( m_data ) );
-}
-
-WRITE_LINE_MEMBER( x76f100_device::write_cs )
-{
- if( m_cs != state )
- {
- verboselog( 2, "cs=%d\n", state );
- }
-
- if( m_cs != 0 && state == 0 )
- {
- /* enable chip */
- m_state = STATE_STOP;
- }
-
- if( m_cs == 0 && state != 0 )
- {
- /* disable chip */
- m_state = STATE_STOP;
- /* high impendence? */
- m_sdar = 0;
- }
-
- m_cs = state;
-}
-
-WRITE_LINE_MEMBER( x76f100_device::write_rst )
-{
- if( m_rst != state )
- {
- verboselog( 2, "rst=%d\n", state );
- }
-
- if( m_rst == 0 && state != 0 && m_cs == 0 )
- {
- verboselog( 1, "goto response to reset\n" );
- m_state = STATE_RESPONSE_TO_RESET;
- m_bit = 0;
- m_byte = 0;
- }
-
- m_rst = state;
-}
-
-UINT8 *x76f100_device::password()
-{
- if( ( m_command & 0xe1 ) == COMMAND_READ )
- {
- return m_read_password;
- }
-
- return m_write_password;
-}
-
-void x76f100_device::password_ok()
-{
- if( ( m_command & 0xe1 ) == COMMAND_READ )
- {
- m_state = STATE_READ_DATA;
- }
- else if( ( m_command & 0xe1 ) == COMMAND_WRITE )
- {
- m_state = STATE_WRITE_DATA;
- }
- else
- {
- /* TODO: */
- }
-}
-
-int x76f100_device::data_offset()
-{
- int block_offset = ( m_command >> 1 ) & 0x0f;
-
- return ( block_offset * sizeof( m_write_buffer ) ) + m_byte;
-}
-
-WRITE_LINE_MEMBER( x76f100_device::write_scl )
-{
- if( m_scl != state )
- {
- verboselog( 2, "scl=%d\n", state );
- }
-
- if( m_cs == 0 )
- {
- switch( m_state )
- {
- case STATE_STOP:
- break;
-
- case STATE_RESPONSE_TO_RESET:
- if( m_scl != 0 && state == 0 )
- {
- if( m_bit == 0 )
- {
- m_shift = m_response_to_reset[ m_byte ];
- verboselog( 1, "<- response_to_reset[%d]: %02x\n", m_byte, m_shift );
- }
-
- m_sdar = m_shift & 1;
- m_shift >>= 1;
- m_bit++;
-
- if( m_bit == 8 )
- {
- m_bit = 0;
- m_byte++;
-
- if( m_byte == sizeof( m_response_to_reset ) )
- {
- m_byte = 0;
- }
- }
- }
- break;
-
- case STATE_LOAD_COMMAND:
- case STATE_LOAD_PASSWORD:
- case STATE_VERIFY_PASSWORD:
- case STATE_WRITE_DATA:
- if( m_scl == 0 && state != 0 )
- {
- if( m_bit < 8 )
- {
- verboselog( 2, "clock\n" );
- m_shift <<= 1;
-
- if( m_sdaw != 0 )
- {
- m_shift |= 1;
- }
-
- m_bit++;
- }
- else
- {
- m_sdar = 0;
-
- switch( m_state )
- {
- case STATE_LOAD_COMMAND:
- m_command = m_shift;
- verboselog( 1, "-> command: %02x\n", m_command );
- /* todo: verify command is valid? */
- m_state = STATE_LOAD_PASSWORD;
- break;
-
- case STATE_LOAD_PASSWORD:
- verboselog( 1, "-> password: %02x\n", m_shift );
- m_write_buffer[ m_byte++ ] = m_shift;
-
- if( m_byte == sizeof( m_write_buffer ) )
- {
- m_state = STATE_VERIFY_PASSWORD;
- }
- break;
-
- case STATE_VERIFY_PASSWORD:
- verboselog( 1, "-> verify password: %02x\n", m_shift );
-
- /* todo: this should probably be handled as a command */
- if( m_shift == COMMAND_ACK_PASSWORD )
- {
- /* todo: this should take 10ms before it returns ok. */
- if( memcmp( password(), m_write_buffer, sizeof( m_write_buffer ) ) == 0 )
- {
- password_ok();
- }
- else
- {
- m_sdar = 1;
- }
- }
- break;
-
- case STATE_WRITE_DATA:
- verboselog( 2, "-> data: %02x\n", m_shift );
- m_write_buffer[ m_byte++ ] = m_shift;
-
- if( m_byte == sizeof( m_write_buffer ) )
- {
- for( m_byte = 0; m_byte < sizeof( m_write_buffer ); m_byte++ )
- {
- int offset = data_offset();
- verboselog( 1, "-> data[ %03x ]: %02x\n", offset, m_write_buffer[ m_byte ] );
- m_data[ offset ] = m_write_buffer[ m_byte ];
- }
-
- m_byte = 0;
-
- verboselog( 1, "data flushed\n" );
- }
- break;
- }
-
- m_bit = 0;
- m_shift = 0;
- }
- }
- break;
-
- case STATE_READ_DATA:
- if( m_scl == 0 && state != 0 )
- {
- if( m_bit < 8 )
- {
- if( m_bit == 0 )
- {
- int offset;
-
- switch( m_state )
- {
- case STATE_READ_DATA:
- offset = data_offset();
- m_shift = m_data[ offset ];
- verboselog( 1, "<- data[ %02x ]: %02x\n", offset, m_shift );
- break;
- }
- }
-
- m_sdar = ( m_shift >> 7 ) & 1;
- m_shift <<= 1;
- m_bit++;
- }
- else
- {
- m_bit = 0;
- m_sdar = 0;
-
- if( m_sdaw == 0 )
- {
- verboselog( 2, "ack <-\n" );
- m_byte++;
- }
- else
- {
- verboselog( 2, "nak <-\n" );
- }
- }
- }
- break;
- }
- }
-
- m_scl = state;
-}
-
-WRITE_LINE_MEMBER( x76f100_device::write_sda )
-{
- if( m_sdaw != state )
- {
- verboselog( 2, "sdaw=%d\n", state );
- }
-
- if( m_cs == 0 && m_scl != 0 )
- {
- if( m_sdaw == 0 && state != 0 )
- {
- verboselog( 1, "goto stop\n" );
- m_state = STATE_STOP;
- m_sdar = 0;
- }
-
- if( m_sdaw != 0 && state == 0 )
- {
- switch( m_state )
- {
- case STATE_STOP:
- verboselog( 1, "goto start\n" );
- m_state = STATE_LOAD_COMMAND;
- break;
-
- case STATE_LOAD_PASSWORD:
- /* todo: this will be the 0xc0 command, but it's not handled as a command yet. */
- verboselog( 1, "goto start\n" );
- break;
-
- case STATE_READ_DATA:
- verboselog( 1, "continue reading??\n" );
-// verboselog( 1, "goto load address\n" );
-// m_state = STATE_LOAD_ADDRESS;
- break;
-
- default:
- verboselog( 1, "skipped start (default)\n" );
- break;
- }
-
- m_bit = 0;
- m_byte = 0;
- m_shift = 0;
- m_sdar = 0;
- }
- }
-
- m_sdaw = state;
-}
-
-READ_LINE_MEMBER( x76f100_device::read_sda )
-{
- if( m_cs != 0 )
- {
- verboselog( 2, "not selected\n" );
- return 1;
- }
-
- verboselog( 2, "sdar=%d\n", m_sdar );
- return m_sdar;
-}
-
-void x76f100_device::nvram_default()
-{
- m_response_to_reset[ 0 ] = 0x19;
- m_response_to_reset[ 1 ] = 0x00;
- m_response_to_reset[ 2 ] = 0xaa;
- m_response_to_reset[ 3 ] = 0x55,
-
- memset( m_write_password, 0, sizeof( m_write_password ) );
- memset( m_read_password, 0, sizeof( m_read_password ) );
- memset( m_data, 0, sizeof( m_data ) );
-
- int expected_size = sizeof( m_response_to_reset ) + sizeof( m_write_password ) + sizeof( m_read_password ) + sizeof( m_data );
-
- if( !m_region )
- {
- logerror( "x76f100(%s) region not found\n", tag() );
- }
- else if( m_region->bytes() != expected_size )
- {
- logerror("x76f100(%s) region length 0x%x expected 0x%x\n", tag(), m_region->bytes(), expected_size );
- }
- else
- {
- UINT8 *region = m_region->base();
-
- memcpy( m_response_to_reset, region, sizeof( m_response_to_reset )); region += sizeof( m_response_to_reset );
- memcpy( m_write_password, region, sizeof( m_write_password )); region += sizeof( m_write_password );
- memcpy( m_read_password, region, sizeof( m_read_password )); region += sizeof( m_read_password );
- memcpy( m_data, region, sizeof( m_data )); region += sizeof( m_data );
- }
-}
-
-void x76f100_device::nvram_read( emu_file &file )
-{
- file.read( m_response_to_reset, sizeof( m_response_to_reset ) );
- file.read( m_write_password, sizeof( m_write_password ) );
- file.read( m_read_password, sizeof( m_read_password ) );
- file.read( m_data, sizeof( m_data ) );
-}
-
-void x76f100_device::nvram_write( emu_file &file )
-{
- file.write( m_response_to_reset, sizeof( m_response_to_reset ) );
- file.write( m_write_password, sizeof( m_write_password ) );
- file.write( m_read_password, sizeof( m_read_password ) );
- file.write( m_data, sizeof( m_data ) );
-}
diff --git a/src/emu/machine/x76f100.h b/src/emu/machine/x76f100.h
deleted file mode 100644
index dea839c4c5e..00000000000
--- a/src/emu/machine/x76f100.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:smf
-/*
- * x76f100.h
- *
- * Secure SerialFlash
- *
- */
-
-#pragma once
-
-#ifndef __X76F100_H__
-#define __X76F100_H__
-
-#include "emu.h"
-
-#define MCFG_X76F100_ADD( _tag ) \
- MCFG_DEVICE_ADD( _tag, X76F100, 0 )
-
-class x76f100_device : public device_t,
- public device_nvram_interface
-{
-public:
- // construction/destruction
- x76f100_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock );
-
- DECLARE_WRITE_LINE_MEMBER( write_cs );
- DECLARE_WRITE_LINE_MEMBER( write_rst );
- DECLARE_WRITE_LINE_MEMBER( write_scl );
- DECLARE_WRITE_LINE_MEMBER( write_sda );
- DECLARE_READ_LINE_MEMBER( read_sda );
-
-protected:
- // device-level overrides
- virtual void device_start();
-
- // device_nvram_interface overrides
- virtual void nvram_default();
- virtual void nvram_read( emu_file &file );
- virtual void nvram_write( emu_file &file );
-
-private:
- inline void verboselog(int n_level, const char *s_fmt, ...) ATTR_PRINTF(3,4);
-
- UINT8 *password();
- void password_ok();
- int data_offset();
-
- enum command_t
- {
- COMMAND_WRITE = 0x80,
- COMMAND_READ = 0x81,
- COMMAND_CHANGE_WRITE_PASSWORD = 0xfc,
- COMMAND_CHANGE_READ_PASSWORD = 0xfe,
- COMMAND_ACK_PASSWORD = 0x55
- };
-
- enum state_t
- {
- STATE_STOP,
- STATE_RESPONSE_TO_RESET,
- STATE_LOAD_COMMAND,
- STATE_LOAD_PASSWORD,
- STATE_VERIFY_PASSWORD,
- STATE_READ_DATA,
- STATE_WRITE_DATA
- };
-
- // internal state
- int m_cs;
- int m_rst;
- int m_scl;
- int m_sdaw;
- int m_sdar;
- int m_state;
- int m_shift;
- int m_bit;
- int m_byte;
- int m_command;
- UINT8 m_write_buffer[ 8 ];
- UINT8 m_response_to_reset[ 4 ];
- UINT8 m_write_password[ 8 ];
- UINT8 m_read_password[ 8 ];
- UINT8 m_data[ 112 ];
-};
-
-// device type definition
-extern const device_type X76F100;
-
-#endif
diff --git a/src/emu/machine/ym2148.c b/src/emu/machine/ym2148.c
deleted file mode 100644
index d0f45fc8844..00000000000
--- a/src/emu/machine/ym2148.c
+++ /dev/null
@@ -1,209 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol
-/**************************************************************************
-
- Yamaha YM-2148 emulation
-
-TODO:
-- Finish implemention of midi out
-
-**************************************************************************/
-
-#include "emu.h"
-#include "ym2148.h"
-
-
-const device_type YM2148 = &device_creator<ym2148_device>;
-
-
-ym2148_device::ym2148_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, YM2148, "YM2148", tag, owner, clock, "ym2148", __FILE__)
- , device_serial_interface(mconfig, *this)
- , m_txd_handler(*this)
- , m_irq_handler(*this)
- , m_port_write_handler(*this)
- , m_port_read_handler(*this)
- , m_irq_state(CLEAR_LINE)
- , m_irq_vector(0xff) // guess
- , m_external_irq_vector(0xff) // guess
- , m_data_out(0)
- , m_data_in(0)
- , m_control(0)
- , m_status(0)
- , m_rxd(1)
- , m_tx_busy(false)
-{
-}
-
-
-void ym2148_device::device_start()
-{
- m_txd_handler.resolve_safe();
- m_irq_handler.resolve_safe();
- m_port_write_handler.resolve_safe();
- m_port_read_handler.resolve_safe(0xff);
-
- // Start a timer to trigger at clock / 8 / 16
- m_timer = timer_alloc(0);
- m_timer->adjust(attotime::from_hz(m_clock / 8 / 16), 0, attotime::from_hz(m_clock / 8 / 16));
-}
-
-
-void ym2148_device::device_reset()
-{
- set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1);
- transmit_register_reset();
- receive_register_reset();
- m_status |= STATUS_TRANSMIT_READY;
-}
-
-
-void ym2148_device::receive_clock()
-{
- if (m_control & CONTROL_RECEIVE_ENABLE)
- {
- /* get bit received from other side and update receive register */
- receive_register_update_bit(m_rxd);
-
- if (is_receive_register_full())
- {
- receive_register_extract();
-
- m_data_in = get_received_char();
-
- if (m_status & STATUS_RECEIVE_BUFFER_FULL)
- {
- // Overrun error
- m_status |= STATUS_OVERRUN_ERROR;
- }
- m_status |= STATUS_RECEIVE_BUFFER_FULL;
- update_irq();
- }
- }
-}
-
-
-void ym2148_device::transmit_clock()
-{
- if (m_control & CONTROL_TRANSMIT_ENABLE)
- {
- if (!(m_status & STATUS_TRANSMIT_READY))
- {
- /* is diserial ready for it? */
- if (is_transmit_register_empty())
- {
- /* set it up */
- transmit_register_setup(m_data_out);
- /* ready for next transmit */
- m_status |= STATUS_TRANSMIT_READY;
- }
- }
-
- /* if diserial has bits to send, make them so */
- if (!is_transmit_register_empty())
- {
- UINT8 data = transmit_register_get_data_bit();
- m_tx_busy = true;
- m_txd_handler(data);
- }
-
- // is transmitter totally done?
- if ((m_status & STATUS_TRANSMIT_READY) && is_transmit_register_empty())
- {
- m_tx_busy = false;
- }
- }
-}
-
-
-void ym2148_device::update_irq()
-{
- m_irq_state = CLEAR_LINE;
-
- if ((m_status & STATUS_RECEIVE_BUFFER_FULL) && (m_control & CONTROL_RECEIVE_IRQ_ENABLE))
- {
- m_irq_state = ASSERT_LINE;
- }
- if ((m_status & STATUS_TRANSMIT_READY) && (m_control & CONTROL_TRANSMIT_IRQ_ENABLE))
- {
-// m_irq_state = ASSERT_LINE;
- }
-
- m_irq_handler(m_irq_state);
-}
-
-
-void ym2148_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- receive_clock();
- transmit_clock();
-}
-
-
-READ8_MEMBER(ym2148_device::read)
-{
- switch (offset & 7)
- {
- case 2: // External port read
- return m_port_read_handler();
-
- case 5: // Midi data read register
- m_status &= ~STATUS_RECEIVE_BUFFER_FULL;
- update_irq();
- return m_data_in;
-
- case 6: // Midi status register
- return m_status;
- }
- return 0xff;
-}
-
-
-WRITE8_MEMBER(ym2148_device::write)
-{
- switch (offset & 7)
- {
- case 2: // External port write
- m_port_write_handler(data);
- break;
-
- case 3: // IRQ vector
- m_irq_vector = data;
- break;
-
- case 4: // External IRQ vector
- m_external_irq_vector = data;
- break;
-
- case 5: // Midi data write register
- m_data_out = data;
- m_status &= ~STATUS_TRANSMIT_READY;
- break;
-
- case 6: // Midi control register
- m_control = data;
-
- if (m_control & 0x80)
- {
- // Reset
- receive_clock();
- transmit_clock();
- m_irq_state = CLEAR_LINE;
- m_irq_handler(m_irq_state);
- }
- update_irq();
- break;
- }
-}
-
-
-UINT8 ym2148_device::get_irq_vector()
-{
- return (m_irq_state == ASSERT_LINE) ? m_irq_vector : m_external_irq_vector;
-}
-
-
-WRITE_LINE_MEMBER(ym2148_device::write_rxd)
-{
- m_rxd = state;
-}
diff --git a/src/emu/machine/ym2148.h b/src/emu/machine/ym2148.h
deleted file mode 100644
index 58d2d5cb360..00000000000
--- a/src/emu/machine/ym2148.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol
-/*********************************************************************
-
- ym2148.h
-
- Yamaha YM2148 Midi and keyboard interface
-
-*********************************************************************/
-
-#ifndef __YM2148_H__
-#define __YM2148_H__
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_YM2148_TXD_HANDLER(_devcb) \
- devcb = &ym2148_device::set_txd_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_YM2148_PORT_WRITE_HANDLER(_devcb) \
- devcb = &ym2148_device::set_port_write_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_YM2148_PORT_READ_HANDLER(_devcb) \
- devcb = &ym2148_device::set_port_read_handler(*device, DEVCB_##_devcb);
-
-#define MCFG_YM2148_IRQ_HANDLER(_devcb) \
- devcb = &ym2148_device::set_irq_handler(*device, DEVCB_##_devcb);
-
-
-class ym2148_device : public device_t,
- public device_serial_interface
-{
-public:
- // construction/destruction
- ym2148_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_txd_handler(device_t &device, _Object object) { return downcast<ym2148_device &>(device).m_txd_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_port_write_handler(device_t &device, _Object object) { return downcast<ym2148_device &>(device).m_port_write_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_port_read_handler(device_t &device, _Object object) { return downcast<ym2148_device &>(device).m_port_read_handler.set_callback(object); }
- template<class _Object> static devcb_base &set_irq_handler(device_t &device, _Object object) { return downcast<ym2148_device &>(device).m_irq_handler.set_callback(object); }
-
- DECLARE_READ8_MEMBER(read);
- DECLARE_WRITE8_MEMBER(write);
-
- DECLARE_WRITE_LINE_MEMBER(write_rxd);
- UINT8 get_irq_vector();
-
-protected:
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
-private:
- devcb_write_line m_txd_handler;
- devcb_write_line m_irq_handler;
- devcb_write8 m_port_write_handler; // write ST0-ST7
- devcb_read8 m_port_read_handler; // read SD0-SD7
- int m_irq_state;
- UINT8 m_irq_vector;
- UINT8 m_external_irq_vector;
- // Does this chip have 1 or 2 data registers?
- UINT8 m_data_out;
- UINT8 m_data_in;
- UINT8 m_control;
- UINT8 m_status;
- emu_timer *m_timer;
- int m_rxd;
- bool m_tx_busy;
-
- void receive_clock();
- void transmit_clock();
- void update_irq();
-
- enum
- {
- STATUS_TRANSMIT_READY = 0x01,
- STATUS_RECEIVE_BUFFER_FULL = 0x2,
- STATUS_OVERRUN_ERROR = 0x20,
- CONTROL_TRANSMIT_ENABLE = 0x01,
- CONTROL_TRANSMIT_IRQ_ENABLE = 0x02,
- CONTROL_RECEIVE_ENABLE = 0x04,
- CONTROL_RECEIVE_IRQ_ENABLE = 0x08
- };
-};
-
-
-extern const device_type YM2148;
-
-
-#endif
diff --git a/src/emu/machine/z80ctc.c b/src/emu/machine/z80ctc.c
deleted file mode 100644
index 8ab638a5e8d..00000000000
--- a/src/emu/machine/z80ctc.c
+++ /dev/null
@@ -1,525 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol
-/***************************************************************************
-
- Z80 CTC (Z8430) implementation
-
- based on original version (c) 1997, Tatsuyuki Satoh
-
-***************************************************************************/
-
-#include "emu.h"
-#include "z80ctc.h"
-#include "cpu/z80/z80.h"
-#include "cpu/z80/z80daisy.h"
-
-
-
-//**************************************************************************
-// DEBUGGING
-//**************************************************************************
-
-#define VERBOSE 0
-
-#define VPRINTF(x) do { if (VERBOSE) logerror x; } while (0)
-
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-// these are the bits of the incoming commands to the CTC
-const int INTERRUPT = 0x80;
-const int INTERRUPT_ON = 0x80;
-//const int INTERRUPT_OFF = 0x00;
-
-const int MODE = 0x40;
-const int MODE_TIMER = 0x00;
-const int MODE_COUNTER = 0x40;
-
-const int PRESCALER = 0x20;
-//const int PRESCALER_256 = 0x20;
-const int PRESCALER_16 = 0x00;
-
-const int EDGE = 0x10;
-const int EDGE_FALLING = 0x00;
-const int EDGE_RISING = 0x10;
-
-const int TRIGGER = 0x08;
-const int TRIGGER_AUTO = 0x00;
-//const int TRIGGER_CLOCK = 0x08;
-
-const int CONSTANT = 0x04;
-const int CONSTANT_LOAD = 0x04;
-//const int CONSTANT_NONE = 0x00;
-
-const int RESET = 0x02;
-//const int RESET_CONTINUE = 0x00;
-const int RESET_ACTIVE = 0x02;
-
-const int CONTROL = 0x01;
-const int CONTROL_VECTOR = 0x00;
-const int CONTROL_WORD = 0x01;
-
-// these extra bits help us keep things accurate
-const int WAITING_FOR_TRIG = 0x100;
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type Z80CTC = &device_creator<z80ctc_device>;
-
-//-------------------------------------------------
-// z80ctc_device - constructor
-//-------------------------------------------------
-
-z80ctc_device::z80ctc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, Z80CTC, "Z80 CTC", tag, owner, clock, "z80ctc", __FILE__),
- device_z80daisy_interface(mconfig, *this),
- m_intr_cb(*this),
- m_zc0_cb(*this),
- m_zc1_cb(*this),
- m_zc2_cb(*this),
- m_zc3_cb(*this)
-{
-}
-
-
-//-------------------------------------------------
-// read - standard handler for reading
-//-------------------------------------------------
-
-READ8_MEMBER( z80ctc_device::read )
-{
- return m_channel[offset & 3].read();
-}
-
-
-//-------------------------------------------------
-// write - standard handler for writing
-//-------------------------------------------------
-
-WRITE8_MEMBER( z80ctc_device::write )
-{
- m_channel[offset & 3].write(data);
-}
-
-
-//-------------------------------------------------
-// trg0-3 - standard write line handlers for each
-// trigger
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( z80ctc_device::trg0 ) { m_channel[0].trigger(state); }
-WRITE_LINE_MEMBER( z80ctc_device::trg1 ) { m_channel[1].trigger(state); }
-WRITE_LINE_MEMBER( z80ctc_device::trg2 ) { m_channel[2].trigger(state); }
-WRITE_LINE_MEMBER( z80ctc_device::trg3 ) { m_channel[3].trigger(state); }
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void z80ctc_device::device_start()
-{
- m_period16 = attotime::from_hz(m_clock) * 16;
- m_period256 = attotime::from_hz(m_clock) * 256;
-
- // resolve callbacks
- m_intr_cb.resolve_safe();
- m_zc0_cb.resolve_safe();
- m_zc1_cb.resolve_safe();
- m_zc2_cb.resolve_safe();
- m_zc3_cb.resolve_safe();
-
- // start each channel
- m_channel[0].start(this, 0);
- m_channel[1].start(this, 1);
- m_channel[2].start(this, 2);
- m_channel[3].start(this, 3);
-
- // register for save states
- save_item(NAME(m_vector));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void z80ctc_device::device_reset()
-{
- // reset each channel
- m_channel[0].reset();
- m_channel[1].reset();
- m_channel[2].reset();
- m_channel[3].reset();
-
- // check for interrupts
- interrupt_check();
- VPRINTF(("CTC Reset\n"));
-}
-
-
-
-//**************************************************************************
-// DAISY CHAIN INTERFACE
-//**************************************************************************
-
-//-------------------------------------------------
-// z80daisy_irq_state - return the overall IRQ
-// state for this device
-//-------------------------------------------------
-
-int z80ctc_device::z80daisy_irq_state()
-{
- VPRINTF(("CTC IRQ state = %d%d%d%d\n", m_channel[0].m_int_state, m_channel[1].m_int_state, m_channel[2].m_int_state, m_channel[3].m_int_state));
-
- // loop over all channels
- int state = 0;
- for (int ch = 0; ch < 4; ch++)
- {
- ctc_channel &channel = m_channel[ch];
-
- // if we're servicing a request, don't indicate more interrupts
- if (channel.m_int_state & Z80_DAISY_IEO)
- {
- state |= Z80_DAISY_IEO;
- break;
- }
- state |= channel.m_int_state;
- }
-
- return state;
-}
-
-
-//-------------------------------------------------
-// z80daisy_irq_ack - acknowledge an IRQ and
-// return the appropriate vector
-//-------------------------------------------------
-
-int z80ctc_device::z80daisy_irq_ack()
-{
- // loop over all channels
- for (int ch = 0; ch < 4; ch++)
- {
- ctc_channel &channel = m_channel[ch];
-
- // find the first channel with an interrupt requested
- if (channel.m_int_state & Z80_DAISY_INT)
- {
- VPRINTF(("CTC IRQAck ch%d\n", ch));
-
- // clear interrupt, switch to the IEO state, and update the IRQs
- channel.m_int_state = Z80_DAISY_IEO;
- interrupt_check();
- return m_vector + ch * 2;
- }
- }
-
- //logerror("z80ctc_irq_ack: failed to find an interrupt to ack!\n");
- return m_vector;
-}
-
-
-//-------------------------------------------------
-// z80daisy_irq_reti - clear the interrupt
-// pending state to allow other interrupts through
-//-------------------------------------------------
-
-void z80ctc_device::z80daisy_irq_reti()
-{
- // loop over all channels
- for (int ch = 0; ch < 4; ch++)
- {
- ctc_channel &channel = m_channel[ch];
-
- // find the first channel with an IEO pending
- if (channel.m_int_state & Z80_DAISY_IEO)
- {
- VPRINTF(("CTC IRQReti ch%d\n", ch));
-
- // clear the IEO state and update the IRQs
- channel.m_int_state &= ~Z80_DAISY_IEO;
- interrupt_check();
- return;
- }
- }
-
- //logerror("z80ctc_irq_reti: failed to find an interrupt to clear IEO on!\n");
-}
-
-
-
-//**************************************************************************
-// INTERNAL STATE MANAGEMENT
-//**************************************************************************
-
-//-------------------------------------------------
-// interrupt_check - look for pending interrupts
-// and update the line
-//-------------------------------------------------
-
-void z80ctc_device::interrupt_check()
-{
- int state = (z80daisy_irq_state() & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE;
- m_intr_cb(state);
-}
-
-
-
-//*************************************************************************
-// CTC CHANNELS
-//**************************************************************************
-
-//-------------------------------------------------
-// ctc_channel - constructor
-//-------------------------------------------------
-
-z80ctc_device::ctc_channel::ctc_channel()
- : m_mode(0),
- m_tconst(0),
- m_down(0),
- m_extclk(0),
- m_timer(NULL),
- m_int_state(0)
-{
-}
-
-
-//-------------------------------------------------
-// start - set up at device start time
-//-------------------------------------------------
-
-void z80ctc_device::ctc_channel::start(z80ctc_device *device, int index)
-{
- // initialize state
- m_device = device;
- m_index = index;
- m_timer = m_device->machine().scheduler().timer_alloc(FUNC(static_timer_callback), this);
-
- // register for save states
- m_device->save_item(NAME(m_mode), m_index);
- m_device->save_item(NAME(m_tconst), m_index);
- m_device->save_item(NAME(m_down), m_index);
- m_device->save_item(NAME(m_extclk), m_index);
- m_device->save_item(NAME(m_int_state), m_index);
-}
-
-
-//-------------------------------------------------
-// reset - reset the channel
-//-------------------------------------------------
-
-void z80ctc_device::ctc_channel::reset()
-{
- m_mode = RESET_ACTIVE;
- m_tconst = 0x100;
- m_timer->adjust(attotime::never);
- m_int_state = 0;
-}
-
-
-//-------------------------------------------------
-// period - return the current channel's period
-//-------------------------------------------------
-
-attotime z80ctc_device::ctc_channel::period() const
-{
- // if reset active, no period
- if ((m_mode & RESET) == RESET_ACTIVE)
- return attotime::zero;
-
- // if counter mode, no real period
- if ((m_mode & MODE) == MODE_COUNTER)
- {
- logerror("CTC %d is CounterMode : Can't calculate period\n", m_index);
- return attotime::zero;
- }
-
- // compute the period
- attotime period = ((m_mode & PRESCALER) == PRESCALER_16) ? m_device->m_period16 : m_device->m_period256;
- return period * m_tconst;
-}
-
-
-//-------------------------------------------------
-// read - read the channel's state
-//-------------------------------------------------
-
-UINT8 z80ctc_device::ctc_channel::read()
-{
- // if we're in counter mode, just return the count
- if ((m_mode & MODE) == MODE_COUNTER || (m_mode & WAITING_FOR_TRIG))
- return m_down;
-
- // else compute the down counter value
- else
- {
- attotime period = ((m_mode & PRESCALER) == PRESCALER_16) ? m_device->m_period16 : m_device->m_period256;
-
- VPRINTF(("CTC clock %f\n",ATTOSECONDS_TO_HZ(period.attoseconds())));
-
- if (m_timer != NULL)
- return ((int)(m_timer->remaining().as_double() / period.as_double()) + 1) & 0xff;
- else
- return 0;
- }
-}
-
-
-//-------------------------------------------------
-// write - handle writes to a channel
-//-------------------------------------------------
-
-void z80ctc_device::ctc_channel::write(UINT8 data)
-{
- // if we're waiting for a time constant, this is it
- if ((m_mode & CONSTANT) == CONSTANT_LOAD)
- {
- VPRINTF(("CTC ch.%d constant = %02x\n", m_index, data));
-
- // set the time constant (0 -> 0x100)
- m_tconst = data ? data : 0x100;
-
- // clear the internal mode -- we're no longer waiting
- m_mode &= ~CONSTANT;
-
- // also clear the reset, since the constant gets it going again
- m_mode &= ~RESET;
-
- // if we're in timer mode....
- if ((m_mode & MODE) == MODE_TIMER)
- {
- // if we're triggering on the time constant, reset the down counter now
- if ((m_mode & TRIGGER) == TRIGGER_AUTO)
- {
- attotime curperiod = period();
- m_timer->adjust(curperiod, m_index, curperiod);
- }
-
- // else set the bit indicating that we're waiting for the appropriate trigger
- else
- m_mode |= WAITING_FOR_TRIG;
- }
-
- // also set the down counter in case we're clocking externally
- m_down = m_tconst;
- }
-
- // if we're writing the interrupt vector, handle it specially
-#if 0 /* Tatsuyuki Satoh changes */
- // The 'Z80family handbook' wrote,
- // interrupt vector is able to set for even channel (0 or 2)
- else if ((data & CONTROL) == CONTROL_VECTOR && (m_index & 1) == 0)
-#else
- else if ((data & CONTROL) == CONTROL_VECTOR && m_index == 0)
-#endif
- {
- m_device->m_vector = data & 0xf8;
- logerror("CTC Vector = %02x\n", m_device->m_vector);
- }
-
- // this must be a control word
- else if ((data & CONTROL) == CONTROL_WORD)
- {
- // set the new mode
- m_mode = data;
- VPRINTF(("CTC ch.%d mode = %02x\n", m_index, data));
-
- // if we're being reset, clear out any pending timers for this channel
- if ((data & RESET) == RESET_ACTIVE)
- {
- m_timer->adjust(attotime::never);
- // note that we don't clear the interrupt state here!
- }
- }
-}
-
-
-//-------------------------------------------------
-// trigger - clock this channel and handle any
-// side-effects
-//-------------------------------------------------
-
-void z80ctc_device::ctc_channel::trigger(UINT8 data)
-{
- // normalize data
- data = data ? 1 : 0;
-
- // see if the trigger value has changed
- if (data != m_extclk)
- {
- m_extclk = data;
-
- // see if this is the active edge of the trigger
- if (((m_mode & EDGE) == EDGE_RISING && data) || ((m_mode & EDGE) == EDGE_FALLING && !data))
- {
- // if we're waiting for a trigger, start the timer
- if ((m_mode & WAITING_FOR_TRIG) && (m_mode & MODE) == MODE_TIMER)
- {
- attotime curperiod = period();
- VPRINTF(("CTC period %s\n", curperiod.as_string()));
- m_timer->adjust(curperiod, m_index, curperiod);
- }
-
- // we're no longer waiting
- m_mode &= ~WAITING_FOR_TRIG;
-
- // if we're clocking externally, decrement the count
- if ((m_mode & MODE) == MODE_COUNTER)
- {
- // if we hit zero, do the same thing as for a timer interrupt
- if (--m_down == 0)
- timer_callback();
- }
- }
- }
-}
-
-
-//-------------------------------------------------
-// trigger - clock this channel and handle any
-// side-effects
-//-------------------------------------------------
-
-void z80ctc_device::ctc_channel::timer_callback()
-{
- // down counter has reached zero - see if we should interrupt
- if ((m_mode & INTERRUPT) == INTERRUPT_ON)
- {
- m_int_state |= Z80_DAISY_INT;
- VPRINTF(("CTC timer ch%d\n", m_index));
- m_device->interrupt_check();
- }
-
- // generate the clock pulse
- switch (m_index)
- {
- case 0:
- m_device->m_zc0_cb(1);
- m_device->m_zc0_cb(0);
- break;
- case 1:
- m_device->m_zc1_cb(1);
- m_device->m_zc1_cb(0);
- break;
- case 2:
- m_device->m_zc2_cb(1);
- m_device->m_zc2_cb(0);
- break;
- case 3:
- m_device->m_zc3_cb(1);
- m_device->m_zc3_cb(0);
- break;
- }
-
- // reset the down counter
- m_down = m_tconst;
-}
diff --git a/src/emu/machine/z80ctc.h b/src/emu/machine/z80ctc.h
deleted file mode 100644
index b5191d21104..00000000000
--- a/src/emu/machine/z80ctc.h
+++ /dev/null
@@ -1,140 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol
-/***************************************************************************
-
- Z80 CTC (Z8430) implementation
-
-****************************************************************************
- _____ _____
- D4 1 |* \_/ | 28 D3
- D5 2 | | 27 D2
- D6 3 | | 26 D1
- D7 4 | | 25 D0
- GND 5 | | 24 +5V
- _RD 6 | | 23 CLK/TRG0
- ZC/TOO 7 | Z80-CTC | 22 CLK/TRG1
- ZC/TO1 8 | | 21 CLK/TRG2
- ZC/TO2 9 | | 20 CLK/TRG3
- _IORQ 10 | | 19 CS1
- IEO 11 | | 18 CS0
- _INT 12 | | 17 _RESET
- IEI 13 | | 16 _CE
- _M1 14 |_____________| 15 CLK
-
-***************************************************************************/
-
-#ifndef __Z80CTC_H__
-#define __Z80CTC_H__
-
-#include "cpu/z80/z80daisy.h"
-
-
-//**************************************************************************
-// DEVICE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_Z80CTC_INTR_CB(_devcb) \
- devcb = &z80ctc_device::set_intr_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80CTC_ZC0_CB(_devcb) \
- devcb = &z80ctc_device::set_zc0_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80CTC_ZC1_CB(_devcb) \
- devcb = &z80ctc_device::set_zc1_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80CTC_ZC2_CB(_devcb) \
- devcb = &z80ctc_device::set_zc2_callback(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-// ======================> z80ctc_device
-
-class z80ctc_device : public device_t,
- public device_z80daisy_interface
-{
-public:
- // construction/destruction
- z80ctc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_intr_callback(device_t &device, _Object object) { return downcast<z80ctc_device &>(device).m_intr_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_zc0_callback(device_t &device, _Object object) { return downcast<z80ctc_device &>(device).m_zc0_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_zc1_callback(device_t &device, _Object object) { return downcast<z80ctc_device &>(device).m_zc1_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_zc2_callback(device_t &device, _Object object) { return downcast<z80ctc_device &>(device).m_zc2_cb.set_callback(object); }
-
- // read/write handlers
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
- DECLARE_WRITE_LINE_MEMBER( trg0 );
- DECLARE_WRITE_LINE_MEMBER( trg1 );
- DECLARE_WRITE_LINE_MEMBER( trg2 );
- DECLARE_WRITE_LINE_MEMBER( trg3 );
-
- UINT16 get_channel_constant(UINT8 channel) { return m_channel[channel].m_tconst; }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- // z80daisy_interface overrides
- virtual int z80daisy_irq_state();
- virtual int z80daisy_irq_ack();
- virtual void z80daisy_irq_reti();
-
-private:
- // internal helpers
- void interrupt_check();
- void timercallback(int chanindex);
-
- // a single channel within the CTC
- class ctc_channel
- {
- public:
- ctc_channel();
-
- void start(z80ctc_device *device, int index);
- void reset();
-
- UINT8 read();
- void write(UINT8 data);
-
- attotime period() const;
- void trigger(UINT8 data);
- void timer_callback();
-
- z80ctc_device * m_device; // pointer back to our device
- int m_index; // our channel index
- UINT16 m_mode; // current mode
- UINT16 m_tconst; // time constant
- UINT16 m_down; // down counter (clock mode only)
- UINT8 m_extclk; // current signal from the external clock
- emu_timer * m_timer; // array of active timers
- UINT8 m_int_state; // interrupt status (for daisy chain)
-
- private:
- static TIMER_CALLBACK( static_timer_callback ) { reinterpret_cast<z80ctc_device::ctc_channel *>(ptr)->timer_callback(); }
- };
-
- // internal state
- devcb_write_line m_intr_cb; // interrupt callback
- devcb_write_line m_zc0_cb; // channel 0 zero crossing callbacks
- devcb_write_line m_zc1_cb; // channel 1 zero crossing callbacks
- devcb_write_line m_zc2_cb; // channel 2 zero crossing callbacks
- devcb_write_line m_zc3_cb; // channel 3 zero crossing callbacks = NULL ?
-
- UINT8 m_vector; // interrupt vector
- attotime m_period16; // 16/system clock
- attotime m_period256; // 256/system clock
- ctc_channel m_channel[4]; // data for each channel
-};
-
-
-// device type definition
-extern const device_type Z80CTC;
-
-
-#endif
diff --git a/src/emu/machine/z80dart.c b/src/emu/machine/z80dart.c
deleted file mode 100644
index 6254d1d81f1..00000000000
--- a/src/emu/machine/z80dart.c
+++ /dev/null
@@ -1,1357 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- Intel 8274 Multi-Protocol Serial Controller emulation
- NEC uPD7201 Multiprotocol Serial Communications Controller emulation
- Z80-DART Dual Asynchronous Receiver/Transmitter emulation
- Z80-SIO/0/1/2/3/4 Serial Input/Output Controller emulation
-
- The z80dart/z80sio itself is based on an older intel serial chip, the i8274 MPSC
- (see http://doc.chipfind.ru/pdf/intel/8274.pdf), which also has almost identical
- behavior, except lacks the interrupt daisy chaining and has its own interrupt/dma
- scheme which uses write register 2 on channel A, that register which is unused on
- the z80dart and z80sio.
-
-***************************************************************************/
-
-/*
-
- TODO:
-
- - i8274 DMA scheme
- - break detection
- - wr0 reset tx interrupt pending
- - wait/ready
- - 1.5 stop bits
- - synchronous mode (Z80-SIO/1,2)
- - SDLC mode (Z80-SIO/1,2)
-
-*/
-
-#include "z80dart.h"
-
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define VERBOSE 0
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-#define CHANA_TAG "cha"
-#define CHANB_TAG "chb"
-
-
-
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
-// device type definition
-const device_type Z80DART = &device_creator<z80dart_device>;
-const device_type Z80DART_CHANNEL = &device_creator<z80dart_channel>;
-const device_type Z80SIO0 = &device_creator<z80sio0_device>;
-const device_type Z80SIO1 = &device_creator<z80sio1_device>;
-const device_type Z80SIO2 = &device_creator<z80sio2_device>;
-const device_type Z80SIO3 = &device_creator<z80sio3_device>;
-const device_type Z80SIO4 = &device_creator<z80sio4_device>;
-const device_type I8274 = &device_creator<i8274_device>;
-const device_type UPD7201 = &device_creator<upd7201_device>;
-
-
-//-------------------------------------------------
-// device_mconfig_additions -
-//-------------------------------------------------
-
-MACHINE_CONFIG_FRAGMENT( z80dart )
- MCFG_DEVICE_ADD(CHANA_TAG, Z80DART_CHANNEL, 0)
- MCFG_DEVICE_ADD(CHANB_TAG, Z80DART_CHANNEL, 0)
-MACHINE_CONFIG_END
-
-machine_config_constructor z80dart_device::device_mconfig_additions() const
-{
- return MACHINE_CONFIG_NAME( z80dart );
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// z80dart_device - constructor
-//-------------------------------------------------
-
-z80dart_device::z80dart_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_z80daisy_interface(mconfig, *this),
- m_chanA(*this, CHANA_TAG),
- m_chanB(*this, CHANB_TAG),
- m_rxca(0),
- m_txca(0),
- m_rxcb(0),
- m_txcb(0),
- m_out_txda_cb(*this),
- m_out_dtra_cb(*this),
- m_out_rtsa_cb(*this),
- m_out_wrdya_cb(*this),
- m_out_synca_cb(*this),
- m_out_txdb_cb(*this),
- m_out_dtrb_cb(*this),
- m_out_rtsb_cb(*this),
- m_out_wrdyb_cb(*this),
- m_out_syncb_cb(*this),
- m_out_int_cb(*this),
- m_out_rxdrqa_cb(*this),
- m_out_txdrqa_cb(*this),
- m_out_rxdrqb_cb(*this),
- m_out_txdrqb_cb(*this),
- m_variant(variant)
-{
- for (int i = 0; i < 8; i++)
- m_int_state[i] = 0;
-}
-
-z80dart_device::z80dart_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, Z80DART, "Z80 DART", tag, owner, clock, "z80dart", __FILE__),
- device_z80daisy_interface(mconfig, *this),
- m_chanA(*this, CHANA_TAG),
- m_chanB(*this, CHANB_TAG),
- m_rxca(0),
- m_txca(0),
- m_rxcb(0),
- m_txcb(0),
- m_out_txda_cb(*this),
- m_out_dtra_cb(*this),
- m_out_rtsa_cb(*this),
- m_out_wrdya_cb(*this),
- m_out_synca_cb(*this),
- m_out_txdb_cb(*this),
- m_out_dtrb_cb(*this),
- m_out_rtsb_cb(*this),
- m_out_wrdyb_cb(*this),
- m_out_syncb_cb(*this),
- m_out_int_cb(*this),
- m_out_rxdrqa_cb(*this),
- m_out_txdrqa_cb(*this),
- m_out_rxdrqb_cb(*this),
- m_out_txdrqb_cb(*this),
- m_variant(TYPE_DART)
-{
- for (int i = 0; i < 8; i++)
- m_int_state[i] = 0;
-}
-
-z80sio0_device::z80sio0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : z80dart_device(mconfig, Z80SIO0, "Z80 SIO/0", tag, owner, clock, TYPE_SIO0, "z80sio0", __FILE__)
-{
-}
-
-z80sio1_device::z80sio1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : z80dart_device(mconfig, Z80SIO1, "Z80 SIO/1", tag, owner, clock, TYPE_SIO1, "z80sio1", __FILE__)
-{
-}
-
-z80sio2_device::z80sio2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : z80dart_device(mconfig, Z80SIO2, "Z80 SIO/2", tag, owner, clock, TYPE_SIO2, "z80sio2", __FILE__)
-{
-}
-
-z80sio3_device::z80sio3_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : z80dart_device(mconfig, Z80SIO3, "Z80 SIO/3", tag, owner, clock, TYPE_SIO3, "z80sio3", __FILE__)
-{
-}
-
-z80sio4_device::z80sio4_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : z80dart_device(mconfig, Z80SIO4, "Z80 SIO/4", tag, owner, clock, TYPE_SIO4, "z80sio4", __FILE__)
-{
-}
-
-i8274_device::i8274_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : z80dart_device(mconfig, I8274, "I8274", tag, owner, clock, TYPE_I8274, "i8274", __FILE__)
-{
-}
-
-upd7201_device::upd7201_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : z80dart_device(mconfig, UPD7201, "uPD7201", tag, owner, clock, TYPE_UPD7201, "upd7201", __FILE__)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void z80dart_device::device_start()
-{
- // resolve callbacks
- m_out_txda_cb.resolve_safe();
- m_out_dtra_cb.resolve_safe();
- m_out_rtsa_cb.resolve_safe();
- m_out_wrdya_cb.resolve_safe();
- m_out_synca_cb.resolve_safe();
- m_out_txdb_cb.resolve_safe();
- m_out_dtrb_cb.resolve_safe();
- m_out_rtsb_cb.resolve_safe();
- m_out_wrdyb_cb.resolve_safe();
- m_out_syncb_cb.resolve_safe();
- m_out_int_cb.resolve_safe();
- m_out_rxdrqa_cb.resolve_safe();
- m_out_txdrqa_cb.resolve_safe();
- m_out_rxdrqb_cb.resolve_safe();
- m_out_txdrqb_cb.resolve_safe();
-
- // configure channel A
- m_chanA->m_rxc = m_rxca;
- m_chanA->m_txc = m_txca;
-
- // configure channel B
- m_chanB->m_rxc = m_rxcb;
- m_chanB->m_txc = m_txcb;
-
- // state saving
- save_item(NAME(m_int_state));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void z80dart_device::device_reset()
-{
- LOG(("Z80DART \"%s\" Reset\n", tag()));
-
- m_chanA->reset();
- m_chanB->reset();
-}
-
-//-------------------------------------------------
-// z80daisy_irq_state - get interrupt status
-//-------------------------------------------------
-
-int z80dart_device::z80daisy_irq_state()
-{
- int state = 0;
- int i;
-
- LOG(("Z80DART \"%s\" : Interrupt State A:%d%d%d%d B:%d%d%d%d\n", tag(),
- m_int_state[0], m_int_state[1], m_int_state[2], m_int_state[3],
- m_int_state[4], m_int_state[5], m_int_state[6], m_int_state[7]));
-
- // loop over all interrupt sources
- for (i = 0; i < 8; i++)
- {
- // if we're servicing a request, don't indicate more interrupts
- if (m_int_state[i] & Z80_DAISY_IEO)
- {
- state |= Z80_DAISY_IEO;
- break;
- }
- state |= m_int_state[i];
- }
-
- LOG(("Z80DART \"%s\" : Interrupt State %u\n", tag(), state));
-
- return state;
-}
-
-
-//-------------------------------------------------
-// z80daisy_irq_ack - interrupt acknowledge
-//-------------------------------------------------
-
-int z80dart_device::z80daisy_irq_ack()
-{
- int i;
-
- LOG(("Z80DART \"%s\" Interrupt Acknowledge\n", tag()));
-
- // loop over all interrupt sources
- for (i = 0; i < 8; i++)
- {
- // find the first channel with an interrupt requested
- if (m_int_state[i] & Z80_DAISY_INT)
- {
- // clear interrupt, switch to the IEO state, and update the IRQs
- m_int_state[i] = Z80_DAISY_IEO;
- m_chanA->m_rr[0] &= ~z80dart_channel::RR0_INTERRUPT_PENDING;
- check_interrupts();
-
- LOG(("Z80DART \"%s\" : Interrupt Acknowledge Vector %02x\n", tag(), m_chanB->m_rr[2]));
-
- return m_chanB->m_rr[2];
- }
- }
-
- //logerror("z80dart_irq_ack: failed to find an interrupt to ack!\n");
-
- return m_chanB->m_rr[2];
-}
-
-
-//-------------------------------------------------
-// z80daisy_irq_reti - return from interrupt
-//-------------------------------------------------
-
-void z80dart_device::z80daisy_irq_reti()
-{
- int i;
-
- LOG(("Z80DART \"%s\" Return from Interrupt\n", tag()));
-
- // loop over all interrupt sources
- for (i = 0; i < 8; i++)
- {
- // find the first channel with an IEO pending
- if (m_int_state[i] & Z80_DAISY_IEO)
- {
- // clear the IEO state and update the IRQs
- m_int_state[i] &= ~Z80_DAISY_IEO;
- check_interrupts();
- return;
- }
- }
-
- //logerror("z80dart_irq_reti: failed to find an interrupt to clear IEO on!\n");
-}
-
-
-//-------------------------------------------------
-// check_interrupts -
-//-------------------------------------------------
-
-void z80dart_device::check_interrupts()
-{
- int state = (z80daisy_irq_state() & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE;
- m_out_int_cb(state);
-}
-
-
-//-------------------------------------------------
-// reset_interrupts -
-//-------------------------------------------------
-
-void z80dart_device::reset_interrupts()
-{
- for (int i = 0; i < 8; i++)
- {
- m_int_state[i] = 0;
- }
-
- check_interrupts();
-}
-
-
-//-------------------------------------------------
-// trigger_interrupt -
-//-------------------------------------------------
-
-void z80dart_device::trigger_interrupt(int index, int state)
-{
- UINT8 vector = m_chanB->m_wr[2];
- int priority;
-
- if((m_variant == TYPE_I8274) || (m_variant == TYPE_UPD7201))
- {
- int prio_level = 0;
- switch(state)
- {
- case z80dart_channel::INT_TRANSMIT:
- prio_level = 1;
- break;
- case z80dart_channel::INT_RECEIVE:
- case z80dart_channel::INT_SPECIAL:
- prio_level = 0;
- break;
- case z80dart_channel::INT_EXTERNAL:
- prio_level = 2;
- break;
- }
-
- if(m_chanA->m_wr[2] & z80dart_channel::WR2_PRIORITY)
- {
- priority = (prio_level * 2) + index;
- }
- else
- {
- priority = (prio_level == 2) ? index + 4 : ((index * 2) + prio_level);
- }
- if (m_chanB->m_wr[1] & z80dart_channel::WR1_STATUS_VECTOR)
- {
- vector = (!index << 2) | state;
- if((m_chanA->m_wr[1] & 0x18) == z80dart_channel::WR2_MODE_8086_8088)
- {
- vector = (m_chanB->m_wr[2] & 0xf8) | vector;
- }
- else
- {
- vector = (m_chanB->m_wr[2] & 0xe3) | (vector << 2);
- }
- }
- }
- else
- {
- priority = (index << 2) | state;
- if (m_chanB->m_wr[1] & z80dart_channel::WR1_STATUS_VECTOR)
- {
- // status affects vector
- vector = (m_chanB->m_wr[2] & 0xf1) | (!index << 3) | (state << 1);
- }
- }
-
- LOG(("Z80DART \"%s\" Channel %c : Interrupt Request %u\n", tag(), 'A' + index, state));
-
- // update vector register
- m_chanB->m_rr[2] = vector;
-
- // trigger interrupt
- m_int_state[priority] |= Z80_DAISY_INT;
- m_chanA->m_rr[0] |= z80dart_channel::RR0_INTERRUPT_PENDING;
-
- // check for interrupt
- check_interrupts();
-}
-
-
-//-------------------------------------------------
-// m1_r - interrupt acknowledge
-//-------------------------------------------------
-
-int z80dart_device::m1_r()
-{
- return z80daisy_irq_ack();
-}
-
-
-//-------------------------------------------------
-// cd_ba_r -
-//-------------------------------------------------
-
-READ8_MEMBER( z80dart_device::cd_ba_r )
-{
- int ba = BIT(offset, 0);
- int cd = BIT(offset, 1);
- z80dart_channel *channel = ba ? m_chanB : m_chanA;
-
- return cd ? channel->control_read() : channel->data_read();
-}
-
-
-//-------------------------------------------------
-// cd_ba_w -
-//-------------------------------------------------
-
-WRITE8_MEMBER( z80dart_device::cd_ba_w )
-{
- int ba = BIT(offset, 0);
- int cd = BIT(offset, 1);
- z80dart_channel *channel = ba ? m_chanB : m_chanA;
-
- if (cd)
- channel->control_write(data);
- else
- channel->data_write(data);
-}
-
-
-//-------------------------------------------------
-// ba_cd_r -
-//-------------------------------------------------
-
-READ8_MEMBER( z80dart_device::ba_cd_r )
-{
- int ba = BIT(offset, 1);
- int cd = BIT(offset, 0);
- z80dart_channel *channel = ba ? m_chanB : m_chanA;
-
- return cd ? channel->control_read() : channel->data_read();
-}
-
-
-//-------------------------------------------------
-// ba_cd_w -
-//-------------------------------------------------
-
-WRITE8_MEMBER( z80dart_device::ba_cd_w )
-{
- int ba = BIT(offset, 1);
- int cd = BIT(offset, 0);
- z80dart_channel *channel = ba ? m_chanB : m_chanA;
-
- if (cd)
- channel->control_write(data);
- else
- channel->data_write(data);
-}
-
-
-
-//**************************************************************************
-// DART CHANNEL
-//**************************************************************************
-
-//-------------------------------------------------
-// dart_channel - constructor
-//-------------------------------------------------
-
-z80dart_channel::z80dart_channel(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, Z80DART_CHANNEL, "Z80 DART channel", tag, owner, clock, "z80dart_channel", __FILE__),
- device_serial_interface(mconfig, *this),
- m_rx_error(0),
- m_rx_fifo(-1),
- m_rx_clock(0),
- m_rx_first(0),
- m_rx_break(0),
- m_rx_rr0_latch(0),
- m_rxd(0),
- m_ri(0),
- m_cts(0),
- m_dcd(0),
- m_tx_data(0),
- m_tx_clock(0),
- m_dtr(0),
- m_rts(0),
- m_sync(0)
-{
- for (int i = 0; i < 3; i++)
- m_rr[i] = 0;
-
- for (int i = 0; i < 6; i++)
- m_wr[i] = 0;
-
- for (int i = 0; i < 3; i++)
- {
- m_rx_data_fifo[i] = 0;
- m_rx_error_fifo[i] = 0;
- }
-}
-
-
-//-------------------------------------------------
-// start - channel startup
-//-------------------------------------------------
-
-void z80dart_channel::device_start()
-{
- m_uart = downcast<z80dart_device *>(owner());
- m_index = m_uart->get_channel_index(this);
-
- // state saving
- save_item(NAME(m_rr));
- save_item(NAME(m_wr));
- save_item(NAME(m_rx_data_fifo));
- save_item(NAME(m_rx_error_fifo));
- save_item(NAME(m_rx_error));
- save_item(NAME(m_rx_fifo));
- save_item(NAME(m_rx_clock));
- save_item(NAME(m_rx_first));
- save_item(NAME(m_rx_break));
- save_item(NAME(m_rx_rr0_latch));
- save_item(NAME(m_ri));
- save_item(NAME(m_cts));
- save_item(NAME(m_dcd));
- save_item(NAME(m_tx_data));
- save_item(NAME(m_tx_clock));
- save_item(NAME(m_dtr));
- save_item(NAME(m_rts));
- save_item(NAME(m_sync));
- device_serial_interface::register_save_state(machine().save(), this);
-}
-
-
-//-------------------------------------------------
-// reset - reset channel status
-//-------------------------------------------------
-
-void z80dart_channel::device_reset()
-{
- receive_register_reset();
- transmit_register_reset();
-
- // disable receiver
- m_wr[3] &= ~WR3_RX_ENABLE;
-
- // disable transmitter
- m_wr[5] &= ~WR5_TX_ENABLE;
- m_rr[0] |= RR0_TX_BUFFER_EMPTY;
- m_rr[1] |= RR1_ALL_SENT;
-
- // reset external lines
- set_rts(1);
- set_dtr(1);
-
- // reset interrupts
- if (m_index == z80dart_device::CHANNEL_A)
- {
- m_uart->reset_interrupts();
- }
-}
-
-void z80dart_channel::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- device_serial_interface::device_timer(timer, id, param, ptr);
-}
-
-
-//-------------------------------------------------
-// tra_callback -
-//-------------------------------------------------
-
-void z80dart_channel::tra_callback()
-{
- if (!(m_wr[5] & WR5_TX_ENABLE))
- {
- // transmit mark
- if (m_index == z80dart_device::CHANNEL_A)
- m_uart->m_out_txda_cb(1);
- else
- m_uart->m_out_txdb_cb(1);
- }
- else if (m_wr[5] & WR5_SEND_BREAK)
- {
- // transmit break
- if (m_index == z80dart_device::CHANNEL_A)
- m_uart->m_out_txda_cb(0);
- else
- m_uart->m_out_txdb_cb(0);
- }
- else if (!is_transmit_register_empty())
- {
- // transmit data
- if (m_index == z80dart_device::CHANNEL_A)
- m_uart->m_out_txda_cb(transmit_register_get_data_bit());
- else
- m_uart->m_out_txdb_cb(transmit_register_get_data_bit());
- }
-}
-
-
-//-------------------------------------------------
-// tra_complete -
-//-------------------------------------------------
-
-void z80dart_channel::tra_complete()
-{
- if ((m_wr[5] & WR5_TX_ENABLE) && !(m_wr[5] & WR5_SEND_BREAK) && !(m_rr[0] & RR0_TX_BUFFER_EMPTY))
- {
- LOG(("Z80DART \"%s\" Channel %c : Transmit Data Byte '%02x'\n", m_owner->tag(), 'A' + m_index, m_tx_data));
-
- transmit_register_setup(m_tx_data);
-
- // empty transmit buffer
- m_rr[0] |= RR0_TX_BUFFER_EMPTY;
-
- if (m_wr[1] & WR1_TX_INT_ENABLE)
- m_uart->trigger_interrupt(m_index, INT_TRANSMIT);
- }
- else if (m_wr[5] & WR5_SEND_BREAK)
- {
- // transmit break
- if (m_index == z80dart_device::CHANNEL_A)
- m_uart->m_out_txda_cb(0);
- else
- m_uart->m_out_txdb_cb(0);
- }
- else
- {
- // transmit mark
- if (m_index == z80dart_device::CHANNEL_A)
- m_uart->m_out_txda_cb(1);
- else
- m_uart->m_out_txdb_cb(1);
- }
-
- // if transmit buffer is empty
- if (m_rr[0] & RR0_TX_BUFFER_EMPTY)
- {
- // then all characters have been sent
- m_rr[1] |= RR1_ALL_SENT;
-
- // when the RTS bit is reset, the _RTS output goes high after the transmitter empties
- if (!m_rts)
- set_rts(1);
- }
-}
-
-
-//-------------------------------------------------
-// rcv_callback -
-//-------------------------------------------------
-
-void z80dart_channel::rcv_callback()
-{
- if (m_wr[3] & WR3_RX_ENABLE)
- {
- receive_register_update_bit(m_rxd);
- }
-}
-
-
-//-------------------------------------------------
-// rcv_complete -
-//-------------------------------------------------
-
-void z80dart_channel::rcv_complete()
-{
- receive_register_extract();
- receive_data(get_received_char());
-}
-
-
-//-------------------------------------------------
-// get_clock_mode - get clock divisor
-//-------------------------------------------------
-
-int z80dart_channel::get_clock_mode()
-{
- int clocks = 1;
-
- switch (m_wr[4] & WR4_CLOCK_RATE_MASK)
- {
- case WR4_CLOCK_RATE_X1: clocks = 1; break;
- case WR4_CLOCK_RATE_X16: clocks = 16; break;
- case WR4_CLOCK_RATE_X32: clocks = 32; break;
- case WR4_CLOCK_RATE_X64: clocks = 64; break;
- }
-
- return clocks;
-}
-
-
-//-------------------------------------------------
-// get_stop_bits - get number of stop bits
-//-------------------------------------------------
-
-device_serial_interface::stop_bits_t z80dart_channel::get_stop_bits()
-{
- switch (m_wr[4] & WR4_STOP_BITS_MASK)
- {
- case WR4_STOP_BITS_1: return STOP_BITS_1;
- case WR4_STOP_BITS_1_5: return STOP_BITS_1_5;
- case WR4_STOP_BITS_2: return STOP_BITS_2;
- }
-
- return STOP_BITS_0;
-}
-
-
-//-------------------------------------------------
-// get_rx_word_length - get receive word length
-//-------------------------------------------------
-
-int z80dart_channel::get_rx_word_length()
-{
- int bits = 5;
-
- switch (m_wr[3] & WR3_RX_WORD_LENGTH_MASK)
- {
- case WR3_RX_WORD_LENGTH_5: bits = 5; break;
- case WR3_RX_WORD_LENGTH_6: bits = 6; break;
- case WR3_RX_WORD_LENGTH_7: bits = 7; break;
- case WR3_RX_WORD_LENGTH_8: bits = 8; break;
- }
-
- return bits;
-}
-
-
-//-------------------------------------------------
-// get_tx_word_length - get transmit word length
-//-------------------------------------------------
-
-int z80dart_channel::get_tx_word_length()
-{
- int bits = 5;
-
- switch (m_wr[5] & WR5_TX_WORD_LENGTH_MASK)
- {
- case WR5_TX_WORD_LENGTH_5: bits = 5; break;
- case WR5_TX_WORD_LENGTH_6: bits = 6; break;
- case WR5_TX_WORD_LENGTH_7: bits = 7; break;
- case WR5_TX_WORD_LENGTH_8: bits = 8; break;
- }
-
- return bits;
-}
-
-
-//-------------------------------------------------
-// control_read - read control register
-//-------------------------------------------------
-
-UINT8 z80dart_channel::control_read()
-{
- UINT8 data = 0;
-
- int reg = m_wr[0] & WR0_REGISTER_MASK;
-
- if (reg != 0)
- {
- // mask out register index
- m_wr[0] &= ~WR0_REGISTER_MASK;
- }
-
- switch (reg)
- {
- case 0:
- case 1:
- data = m_rr[reg];
- break;
-
- case 2:
- // channel B only
- if (m_index == z80dart_device::CHANNEL_B)
- data = m_rr[reg];
- break;
- }
-
- //LOG(("Z80DART \"%s\" Channel %c : Control Register Read '%02x'\n", m_owner->tag(), 'A' + m_index, data));
-
- return data;
-}
-
-
-//-------------------------------------------------
-// control_write - write control register
-//-------------------------------------------------
-
-void z80dart_channel::control_write(UINT8 data)
-{
- int reg = m_wr[0] & WR0_REGISTER_MASK;
-
- LOG(("Z80DART \"%s\" Channel %c : Control Register Write '%02x'\n", m_owner->tag(), 'A' + m_index, data));
-
- // write data to selected register
- if (reg < 6)
- m_wr[reg] = data;
-
- if (reg != 0)
- {
- // mask out register index
- m_wr[0] &= ~WR0_REGISTER_MASK;
- }
-
- switch (reg)
- {
- case 0:
- switch (data & WR0_COMMAND_MASK)
- {
- case WR0_NULL:
- LOG(("Z80DART \"%s\" Channel %c : Null\n", m_owner->tag(), 'A' + m_index));
- break;
-
- case WR0_SEND_ABORT:
- LOG(("Z80DART \"%s\" Channel %c : Send Abort\n", m_owner->tag(), 'A' + m_index));
- logerror("Z80DART \"%s\" Channel %c : unsupported command: Send Abort\n", m_owner->tag(), 'A' + m_index);
- break;
-
- case WR0_RESET_EXT_STATUS:
- // reset external/status interrupt
- m_rr[0] &= ~(RR0_DCD | RR0_RI | RR0_CTS | RR0_BREAK_ABORT);
-
- if (!m_dcd) m_rr[0] |= RR0_DCD;
- if (m_ri) m_rr[0] |= RR0_RI;
- if (m_cts) m_rr[0] |= RR0_CTS;
-
- m_rx_rr0_latch = 0;
-
- LOG(("Z80DART \"%s\" Channel %c : Reset External/Status Interrupt\n", m_owner->tag(), 'A' + m_index));
- break;
-
- case WR0_CHANNEL_RESET:
- // channel reset
- LOG(("Z80DART \"%s\" Channel %c : Channel Reset\n", m_owner->tag(), 'A' + m_index));
- device_reset();
- break;
-
- case WR0_ENABLE_INT_NEXT_RX:
- // enable interrupt on next receive character
- LOG(("Z80DART \"%s\" Channel %c : Enable Interrupt on Next Received Character\n", m_owner->tag(), 'A' + m_index));
- m_rx_first = 1;
- break;
-
- case WR0_RESET_TX_INT:
- // reset transmitter interrupt pending
- LOG(("Z80DART \"%s\" Channel %c : Reset Transmitter Interrupt Pending\n", m_owner->tag(), 'A' + m_index));
- logerror("Z80DART \"%s\" Channel %c : unsupported command: Reset Transmitter Interrupt Pending\n", m_owner->tag(), 'A' + m_index);
- break;
-
- case WR0_ERROR_RESET:
- // error reset
- LOG(("Z80DART \"%s\" Channel %c : Error Reset\n", m_owner->tag(), 'A' + m_index));
- m_rr[1] &= ~(RR1_CRC_FRAMING_ERROR | RR1_RX_OVERRUN_ERROR | RR1_PARITY_ERROR);
- break;
-
- case WR0_RETURN_FROM_INT:
- // return from interrupt
- LOG(("Z80DART \"%s\" Channel %c : Return from Interrupt\n", m_owner->tag(), 'A' + m_index));
- m_uart->z80daisy_irq_reti();
- break;
- }
- break;
-
- case 1:
- LOG(("Z80DART \"%s\" Channel %c : External Interrupt Enable %u\n", m_owner->tag(), 'A' + m_index, (data & WR1_EXT_INT_ENABLE) ? 1 : 0));
- LOG(("Z80DART \"%s\" Channel %c : Transmit Interrupt Enable %u\n", m_owner->tag(), 'A' + m_index, (data & WR1_TX_INT_ENABLE) ? 1 : 0));
- LOG(("Z80DART \"%s\" Channel %c : Status Affects Vector %u\n", m_owner->tag(), 'A' + m_index, (data & WR1_STATUS_VECTOR) ? 1 : 0));
- LOG(("Z80DART \"%s\" Channel %c : Wait/Ready Enable %u\n", m_owner->tag(), 'A' + m_index, (data & WR1_WRDY_ENABLE) ? 1 : 0));
- LOG(("Z80DART \"%s\" Channel %c : Wait/Ready Function %s\n", m_owner->tag(), 'A' + m_index, (data & WR1_WRDY_FUNCTION) ? "Ready" : "Wait"));
- LOG(("Z80DART \"%s\" Channel %c : Wait/Ready on %s\n", m_owner->tag(), 'A' + m_index, (data & WR1_WRDY_ON_RX_TX) ? "Receive" : "Transmit"));
-
- switch (data & WR1_RX_INT_MODE_MASK)
- {
- case WR1_RX_INT_DISABLE:
- LOG(("Z80DART \"%s\" Channel %c : Receiver Interrupt Disabled\n", m_owner->tag(), 'A' + m_index));
- break;
-
- case WR1_RX_INT_FIRST:
- LOG(("Z80DART \"%s\" Channel %c : Receiver Interrupt on First Character\n", m_owner->tag(), 'A' + m_index));
- break;
-
- case WR1_RX_INT_ALL_PARITY:
- LOG(("Z80DART \"%s\" Channel %c : Receiver Interrupt on All Characters, Parity Affects Vector\n", m_owner->tag(), 'A' + m_index));
- break;
-
- case WR1_RX_INT_ALL:
- LOG(("Z80DART \"%s\" Channel %c : Receiver Interrupt on All Characters\n", m_owner->tag(), 'A' + m_index));
- break;
- }
-
- m_uart->check_interrupts();
- break;
-
- case 2:
- // interrupt vector
- if (m_index == z80dart_device::CHANNEL_B)
- {
- if(m_wr[1] & z80dart_channel::WR1_STATUS_VECTOR)
- m_rr[2] = ( m_rr[2] & 0x0e ) | ( m_wr[2] & 0xF1);
- else
- m_rr[2] = m_wr[2];
- }
- m_uart->check_interrupts();
- LOG(("Z80DART \"%s\" Channel %c : Interrupt Vector %02x\n", m_owner->tag(), 'A' + m_index, data));
- break;
-
- case 3:
- LOG(("Z80DART \"%s\" Channel %c : Receiver Enable %u\n", m_owner->tag(), 'A' + m_index, (data & WR3_RX_ENABLE) ? 1 : 0));
- LOG(("Z80DART \"%s\" Channel %c : Auto Enables %u\n", m_owner->tag(), 'A' + m_index, (data & WR3_AUTO_ENABLES) ? 1 : 0));
- LOG(("Z80DART \"%s\" Channel %c : Receiver Bits/Character %u\n", m_owner->tag(), 'A' + m_index, get_rx_word_length()));
-
- update_serial();
- break;
-
- case 4:
- LOG(("Z80DART \"%s\" Channel %c : Parity Enable %u\n", m_owner->tag(), 'A' + m_index, (data & WR4_PARITY_ENABLE) ? 1 : 0));
- LOG(("Z80DART \"%s\" Channel %c : Parity %s\n", m_owner->tag(), 'A' + m_index, (data & WR4_PARITY_EVEN) ? "Even" : "Odd"));
- LOG(("Z80DART \"%s\" Channel %c : Stop Bits %s\n", m_owner->tag(), 'A' + m_index, stop_bits_tostring(get_stop_bits())));
- LOG(("Z80DART \"%s\" Channel %c : Clock Mode %uX\n", m_owner->tag(), 'A' + m_index, get_clock_mode()));
-
- update_serial();
- break;
-
- case 5:
- LOG(("Z80DART \"%s\" Channel %c : Transmitter Enable %u\n", m_owner->tag(), 'A' + m_index, (data & WR5_TX_ENABLE) ? 1 : 0));
- LOG(("Z80DART \"%s\" Channel %c : Transmitter Bits/Character %u\n", m_owner->tag(), 'A' + m_index, get_tx_word_length()));
- LOG(("Z80DART \"%s\" Channel %c : Send Break %u\n", m_owner->tag(), 'A' + m_index, (data & WR5_SEND_BREAK) ? 1 : 0));
- LOG(("Z80DART \"%s\" Channel %c : Request to Send %u\n", m_owner->tag(), 'A' + m_index, (data & WR5_RTS) ? 1 : 0));
- LOG(("Z80DART \"%s\" Channel %c : Data Terminal Ready %u\n", m_owner->tag(), 'A' + m_index, (data & WR5_DTR) ? 1 : 0));
-
- update_serial();
-
- if (data & WR5_RTS)
- {
- // when the RTS bit is set, the _RTS output goes low
- set_rts(0);
- m_rts = 1;
- }
- else
- {
- // when the RTS bit is reset, the _RTS output goes high after the transmitter empties
- m_rts = 0;
- }
-
- // data terminal ready output follows the state programmed into the DTR bit*/
- set_dtr((data & WR5_DTR) ? 0 : 1);
- break;
-
- case 6:
- LOG(("Z80DART \"%s\" Channel %c : Transmit Sync %02x\n", m_owner->tag(), 'A' + m_index, data));
- m_sync = (m_sync & 0xff00) | data;
- break;
-
- case 7:
- LOG(("Z80DART \"%s\" Channel %c : Receive Sync %02x\n", m_owner->tag(), 'A' + m_index, data));
- m_sync = (data << 8) | (m_sync & 0xff);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// data_read - read data register
-//-------------------------------------------------
-
-UINT8 z80dart_channel::data_read()
-{
- UINT8 data = 0;
-
- if (m_rx_fifo >= 0)
- {
- // load data from the FIFO
- data = m_rx_data_fifo[m_rx_fifo];
-
- // load error status from the FIFO
- m_rr[1] = (m_rr[1] & ~(RR1_CRC_FRAMING_ERROR | RR1_RX_OVERRUN_ERROR | RR1_PARITY_ERROR)) | m_rx_error_fifo[m_rx_fifo];
-
- // decrease FIFO pointer
- m_rx_fifo--;
-
- if (m_rx_fifo < 0)
- {
- // no more characters available in the FIFO
- m_rr[0] &= ~ RR0_RX_CHAR_AVAILABLE;
- }
- }
-
- LOG(("Z80DART \"%s\" Channel %c : Data Register Read '%02x'\n", m_owner->tag(), 'A' + m_index, data));
-
- return data;
-}
-
-
-//-------------------------------------------------
-// data_write - write data register
-//-------------------------------------------------
-
-void z80dart_channel::data_write(UINT8 data)
-{
- m_tx_data = data;
-
- if ((m_wr[5] & WR5_TX_ENABLE) && is_transmit_register_empty())
- {
- LOG(("Z80DART \"%s\" Channel %c : Transmit Data Byte '%02x'\n", m_owner->tag(), 'A' + m_index, m_tx_data));
-
- transmit_register_setup(m_tx_data);
-
- // empty transmit buffer
- m_rr[0] |= RR0_TX_BUFFER_EMPTY;
-
- if (m_wr[1] & WR1_TX_INT_ENABLE)
- m_uart->trigger_interrupt(m_index, INT_TRANSMIT);
- }
- else
- {
- m_rr[0] &= ~RR0_TX_BUFFER_EMPTY;
- }
-
- m_rr[1] &= ~RR1_ALL_SENT;
-
- LOG(("Z80DART \"%s\" Channel %c : Data Register Write '%02x'\n", m_owner->tag(), 'A' + m_index, data));
-}
-
-
-//-------------------------------------------------
-// receive_data - receive data word
-//-------------------------------------------------
-
-void z80dart_channel::receive_data(UINT8 data)
-{
- LOG(("Z80DART \"%s\" Channel %c : Receive Data Byte '%02x'\n", m_owner->tag(), 'A' + m_index, data));
-
- if (m_rx_fifo == 2)
- {
- // receive overrun error detected
- m_rx_error |= RR1_RX_OVERRUN_ERROR;
-
- switch (m_wr[1] & WR1_RX_INT_MODE_MASK)
- {
- case WR1_RX_INT_FIRST:
- if (!m_rx_first)
- {
- m_uart->trigger_interrupt(m_index, INT_SPECIAL);
- }
- break;
-
- case WR1_RX_INT_ALL_PARITY:
- case WR1_RX_INT_ALL:
- m_uart->trigger_interrupt(m_index, INT_SPECIAL);
- break;
- }
- }
- else
- {
- m_rx_fifo++;
- }
-
- // store received character and error status into FIFO
- m_rx_data_fifo[m_rx_fifo] = data;
- m_rx_error_fifo[m_rx_fifo] = m_rx_error;
-
- m_rr[0] |= RR0_RX_CHAR_AVAILABLE;
-
- // receive interrupt
- switch (m_wr[1] & WR1_RX_INT_MODE_MASK)
- {
- case WR1_RX_INT_FIRST:
- if (m_rx_first)
- {
- m_uart->trigger_interrupt(m_index, INT_RECEIVE);
-
- m_rx_first = 0;
- }
- break;
-
- case WR1_RX_INT_ALL_PARITY:
- case WR1_RX_INT_ALL:
- m_uart->trigger_interrupt(m_index, INT_RECEIVE);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// cts_w - clear to send handler
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( z80dart_channel::cts_w )
-{
- LOG(("Z80DART \"%s\" Channel %c : CTS %u\n", m_owner->tag(), 'A' + m_index, state));
-
- if (m_cts != state)
- {
- // enable transmitter if in auto enables mode
- if (!state)
- if (m_wr[3] & WR3_AUTO_ENABLES)
- m_wr[5] |= WR5_TX_ENABLE;
-
- // set clear to send
- m_cts = state;
-
- if (!m_rx_rr0_latch)
- {
- if (!m_cts)
- m_rr[0] |= RR0_CTS;
- else
- m_rr[0] &= ~RR0_CTS;
-
- // trigger interrupt
- if (m_wr[1] & WR1_EXT_INT_ENABLE)
- {
- // trigger interrupt
- m_uart->trigger_interrupt(m_index, INT_EXTERNAL);
-
- // latch read register 0
- m_rx_rr0_latch = 1;
- }
- }
- }
-}
-
-
-//-------------------------------------------------
-// dcd_w - data carrier detected handler
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( z80dart_channel::dcd_w )
-{
- LOG(("Z80DART \"%s\" Channel %c : DCD %u\n", m_owner->tag(), 'A' + m_index, state));
-
- if (m_dcd != state)
- {
- // enable receiver if in auto enables mode
- if (!state)
- if (m_wr[3] & WR3_AUTO_ENABLES)
- m_wr[3] |= WR3_RX_ENABLE;
-
- // set data carrier detect
- m_dcd = state;
-
- if (!m_rx_rr0_latch)
- {
- if (m_dcd)
- m_rr[0] |= RR0_DCD;
- else
- m_rr[0] &= ~RR0_DCD;
-
- if (m_wr[1] & WR1_EXT_INT_ENABLE)
- {
- // trigger interrupt
- m_uart->trigger_interrupt(m_index, INT_EXTERNAL);
-
- // latch read register 0
- m_rx_rr0_latch = 1;
- }
- }
- }
-}
-
-
-//-------------------------------------------------
-// ri_w - ring indicator handler
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( z80dart_channel::ri_w )
-{
- LOG(("Z80DART \"%s\" Channel %c : RI %u\n", m_owner->tag(), 'A' + m_index, state));
-
- if (m_ri != state)
- {
- // set ring indicator state
- m_ri = state;
-
- if (!m_rx_rr0_latch)
- {
- if (m_ri)
- m_rr[0] |= RR0_RI;
- else
- m_rr[0] &= ~RR0_RI;
-
- if (m_wr[1] & WR1_EXT_INT_ENABLE)
- {
- // trigger interrupt
- m_uart->trigger_interrupt(m_index, INT_EXTERNAL);
-
- // latch read register 0
- m_rx_rr0_latch = 1;
- }
- }
- }
-}
-
-
-//-------------------------------------------------
-// sync_w - sync handler
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( z80dart_channel::sync_w )
-{
- LOG(("Z80DART \"%s\" Channel %c : SYNC %u\n", m_owner->tag(), 'A' + m_index, state));
-}
-
-
-//-------------------------------------------------
-// rxc_w - receive clock
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( z80dart_channel::rxc_w )
-{
- //LOG(("Z80DART \"%s\" Channel %c : Receiver Clock Pulse\n", m_owner->tag(), m_index + 'A'));
- int clocks = get_clock_mode();
- if (clocks == 1)
- rx_clock_w(state);
- else if(state)
- {
- rx_clock_w(m_rx_clock < clocks/2);
-
- m_rx_clock++;
- if (m_rx_clock == clocks)
- m_rx_clock = 0;
-
- }
-}
-
-
-//-------------------------------------------------
-// txc_w - transmit clock
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( z80dart_channel::txc_w )
-{
- //LOG(("Z80DART \"%s\" Channel %c : Transmitter Clock Pulse\n", m_owner->tag(), m_index + 'A'));
- int clocks = get_clock_mode();
- if (clocks == 1)
- tx_clock_w(state);
- else if(state)
- {
- tx_clock_w(m_tx_clock < clocks/2);
-
- m_tx_clock++;
- if (m_tx_clock == clocks)
- m_tx_clock = 0;
-
- }
-}
-
-
-//-------------------------------------------------
-// update_serial -
-//-------------------------------------------------
-
-void z80dart_channel::update_serial()
-{
- int data_bit_count = get_rx_word_length();
- stop_bits_t stop_bits = get_stop_bits();
-
- parity_t parity;
- if (m_wr[4] & WR4_PARITY_ENABLE)
- {
- if (m_wr[4] & WR4_PARITY_EVEN)
- parity = PARITY_EVEN;
- else
- parity = PARITY_ODD;
- }
- else
- parity = PARITY_NONE;
-
- set_data_frame(1, data_bit_count, parity, stop_bits);
-
- int clocks = get_clock_mode();
-
- if (m_rxc > 0)
- {
- set_rcv_rate(m_rxc / clocks);
- }
-
- if (m_txc > 0)
- {
- set_tra_rate(m_txc / clocks);
- }
- receive_register_reset(); // if stop bits is changed from 0, receive register has to be reset
-}
-
-
-//-------------------------------------------------
-// set_dtr -
-//-------------------------------------------------
-
-void z80dart_channel::set_dtr(int state)
-{
- m_dtr = state;
-
- if (m_index == z80dart_device::CHANNEL_A)
- m_uart->m_out_dtra_cb(m_dtr);
- else
- m_uart->m_out_dtrb_cb(m_dtr);
-}
-
-
-//-------------------------------------------------
-// set_rts -
-//-------------------------------------------------
-
-void z80dart_channel::set_rts(int state)
-{
- if (m_index == z80dart_device::CHANNEL_A)
- m_uart->m_out_rtsa_cb(state);
- else
- m_uart->m_out_rtsb_cb(state);
-}
-
-
-//-------------------------------------------------
-// write_rx -
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER(z80dart_channel::write_rx)
-{
- m_rxd = state;
- //only use rx_w when self-clocked
- if(m_rxc)
- device_serial_interface::rx_w(state);
-}
diff --git a/src/emu/machine/z80dart.h b/src/emu/machine/z80dart.h
deleted file mode 100644
index 2674f84758a..00000000000
--- a/src/emu/machine/z80dart.h
+++ /dev/null
@@ -1,684 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- Intel 8274 Multi-Protocol Serial Controller emulation
- NEC uPD7201 Multiprotocol Serial Communications Controller emulation
- Z80-DART Dual Asynchronous Receiver/Transmitter emulation
- Z80-SIO/0/1/2/3/4 Serial Input/Output Controller emulation
-
-****************************************************************************
- _____ _____
- CLK 1 |* \_/ | 40 Vcc
- _RESET 2 | | 39 _CTSA
- _CDA 3 | | 38 _RTSA
- _RxCB 4 | | 37 TxDA
- _CDB 5 | | 36 _TxCA
- _CTSB 6 | | 35 _RxCA
- _TxCB 7 | | 34 RxDA
- TxDB 8 | | 33 _SYNDETA
- RxDB 9 | | 32 RDYA/RxDRQA
- _RTSB/_SYNDETB 10 | I8274 | 31 _DTRA
- RDYB/_TxDRQA 11 | | 30 _IPO/TxDRQB
- D7 12 | | 29 _IPI/RxDRQB
- D6 13 | | 28 _INT
- D5 14 | | 27 _INTA
- D4 15 | | 26 _DTRB
- D3 16 | | 25 A0
- D2 17 | | 24 A1
- D1 18 | | 23 _CS
- D0 19 | | 22 _RD
- Vss 20 |_____________| 21 _WR
-
- _____ _____
- CLK 1 |* \_/ | 40 Vcc
- _RESET 2 | | 39 _CTSA
- _DCDA 3 | | 38 _RTSA
- _RxCB 4 | | 37 TxDA
- _DCDB 5 | | 36 _TxCA
- _CTSB 6 | | 35 _RxCA
- _TxCB 7 | | 34 RxDA
- TxDB 8 | | 33 _SYNCA
- RxDB 9 | | 32 _WAITA/DRQRxA
- _RTSB/_SYNCB 10 | UPD7201 | 31 _DTRA/_HAO
- _WAITB/_DRQTxA 11 | | 30 _PRO/DRQTxB
- D7 12 | | 29 _PRI/DRQRxB
- D6 13 | | 28 _INT
- D5 14 | | 27 _INTAK
- D4 15 | | 26 _DTRB/_HAI
- D3 16 | | 25 B/_A
- D2 17 | | 24 C/_D
- D1 18 | | 23 _CS
- D0 19 | | 22 _RD
- Vss 20 |_____________| 21 _WR
-
- _____ _____
- D1 1 |* \_/ | 40 D0
- D3 2 | | 39 D2
- D5 3 | | 38 D4
- D7 4 | | 37 D6
- _INT 5 | | 36 _IORQ
- IEI 6 | | 35 _CE
- IEO 7 | | 34 B/_A
- _M1 8 | | 33 C/_D
- Vdd 9 | | 32 _RD
- _W/RDYA 10 | Z80-DART | 31 GND
- _RIA 11 | Z8470 | 30 _W/RDYB
- RxDA 12 | | 29 _RIB
- _RxCA 13 | | 28 RxDB
- _TxCA 14 | | 27 _RxTxCB
- TxDA 15 | | 26 TxDB
- _DTRA 16 | | 25 _DTRB
- _RTSA 17 | | 24 _RTSB
- _CTSA 18 | | 23 _CTSB
- _DCDA 19 | | 22 _DCDB
- CLK 20 |_____________| 21 _RESET
-
- _____ _____
- D1 1 |* \_/ | 40 D0
- D3 2 | | 39 D2
- D5 3 | | 38 D4
- D7 4 | | 37 D6
- _INT 5 | | 36 _IORQ
- IEI 6 | | 35 _CE
- IEO 7 | | 34 B/_A
- _M1 8 | | 33 C/_D
- Vdd 9 | | 32 _RD
- _W/RDYA 10 | Z80-SIO/0 | 31 GND
- _SYNCA 11 | Z8440 | 30 _W/RDYB
- RxDA 12 | | 29 _SYNCB
- _RxCA 13 | | 28 RxDB
- _TxCA 14 | | 27 _RxTxCB
- TxDA 15 | | 26 TxDB
- _DTRA 16 | | 25 _DTRB
- _RTSA 17 | | 24 _RTSB
- _CTSA 18 | | 23 _CTSB
- _DCDA 19 | | 22 _DCDB
- CLK 20 |_____________| 21 _RESET
-
- _____ _____
- D1 1 |* \_/ | 40 D0
- D3 2 | | 39 D2
- D5 3 | | 38 D4
- D7 4 | | 37 D6
- _INT 5 | | 36 _IORQ
- IEI 6 | | 35 _CE
- IEO 7 | | 34 B/_A
- _M1 8 | | 33 C/_D
- Vdd 9 | | 32 _RD
- _W/RDYA 10 | Z80-SIO/1 | 31 GND
- _SYNCA 11 | Z8441 | 30 _W/RDYB
- RxDA 12 | | 29 _SYNCB
- _RxCA 13 | | 28 RxDB
- _TxCA 14 | | 27 _RxCB
- TxDA 15 | | 26 _TxCB
- _DTRA 16 | | 25 TxDB
- _RTSA 17 | | 24 _RTSB
- _CTSA 18 | | 23 _CTSB
- _DCDA 19 | | 22 _DCDB
- CLK 20 |_____________| 21 _RESET
-
- _____ _____
- D1 1 |* \_/ | 40 D0
- D3 2 | | 39 D2
- D5 3 | | 38 D4
- D7 4 | | 37 D6
- _INT 5 | | 36 _IORQ
- IEI 6 | | 35 _CE
- IEO 7 | | 34 B/_A
- _M1 8 | | 33 C/_D
- Vdd 9 | | 32 _RD
- _W/RDYA 10 | Z80-SIO/2 | 31 GND
- _SYNCA 11 | Z8442 | 30 _W/RDYB
- RxDA 12 | | 29 _RxDB
- _RxCA 13 | | 28 _RxCB
- _TxCA 14 | | 27 _TxCB
- TxDA 15 | | 26 TxDB
- _DTRA 16 | | 25 _DTRB
- _RTSA 17 | | 24 _RTSB
- _CTSA 18 | | 23 _CTSB
- _DCDA 19 | | 22 _DCDB
- CLK 20 |_____________| 21 _RESET
-
-***************************************************************************/
-
-#ifndef __Z80DART_H__
-#define __Z80DART_H__
-
-#include "emu.h"
-#include "cpu/z80/z80daisy.h"
-
-
-//**************************************************************************
-// DEVICE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_Z80DART_ADD(_tag, _clock, _rxa, _txa, _rxb, _txb) \
- MCFG_DEVICE_ADD(_tag, Z80DART, _clock) \
- MCFG_Z80DART_OFFSETS(_rxa, _txa, _rxb, _txb)
-
-#define MCFG_Z80SIO0_ADD(_tag, _clock, _rxa, _txa, _rxb, _txb) \
- MCFG_DEVICE_ADD(_tag, Z80SIO0, _clock) \
- MCFG_Z80DART_OFFSETS(_rxa, _txa, _rxb, _txb)
-
-#define MCFG_Z80SIO1_ADD(_tag, _clock, _rxa, _txa, _rxb, _txb) \
- MCFG_DEVICE_ADD(_tag, Z80SIO1, _clock) \
- MCFG_Z80DART_OFFSETS(_rxa, _txa, _rxb, _txb)
-
-#define MCFG_Z80SIO2_ADD(_tag, _clock, _rxa, _txa, _rxb, _txb) \
- MCFG_DEVICE_ADD(_tag, Z80SIO2, _clock) \
- MCFG_Z80DART_OFFSETS(_rxa, _txa, _rxb, _txb)
-
-#define MCFG_Z80SIO3_ADD(_tag, _clock, _rxa, _txa, _rxb, _txb) \
- MCFG_DEVICE_ADD(_tag, Z80SIO3, _clock) \
- MCFG_Z80DART_OFFSETS(_rxa, _txa, _rxb, _txb)
-
-#define MCFG_Z80SIO4_ADD(_tag, _clock, _rxa, _txa, _rxb, _txb) \
- MCFG_DEVICE_ADD(_tag, Z80SIO4, _clock) \
- MCFG_Z80DART_OFFSETS(_rxa, _txa, _rxb, _txb)
-
-#define MCFG_I8274_ADD(_tag, _clock, _rxa, _txa, _rxb, _txb) \
- MCFG_DEVICE_ADD(_tag, I8274, _clock) \
- MCFG_Z80DART_OFFSETS(_rxa, _txa, _rxb, _txb)
-
-#define MCFG_UPD7201_ADD(_tag, _clock, _rxa, _txa, _rxb, _txb) \
- MCFG_DEVICE_ADD(_tag, UPD7201, _clock) \
- MCFG_Z80DART_OFFSETS(_rxa, _txa, _rxb, _txb)
-
-
-#define MCFG_Z80DART_OFFSETS(_rxa, _txa, _rxb, _txb) \
- z80dart_device::configure_channels(*device, _rxa, _txa, _rxb, _txb);
-
-#define MCFG_Z80DART_OUT_TXDA_CB(_devcb) \
- devcb = &z80dart_device::set_out_txda_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_DTRA_CB(_devcb) \
- devcb = &z80dart_device::set_out_dtra_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_RTSA_CB(_devcb) \
- devcb = &z80dart_device::set_out_rtsa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_WRDYA_CB(_devcb) \
- devcb = &z80dart_device::set_out_wrdya_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_SYNCA_CB(_devcb) \
- devcb = &z80dart_device::set_out_synca_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_TXDB_CB(_devcb) \
- devcb = &z80dart_device::set_out_txdb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_DTRB_CB(_devcb) \
- devcb = &z80dart_device::set_out_dtrb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_RTSB_CB(_devcb) \
- devcb = &z80dart_device::set_out_rtsb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_WRDYB_CB(_devcb) \
- devcb = &z80dart_device::set_out_wrdyb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_SYNCB_CB(_devcb) \
- devcb = &z80dart_device::set_out_syncb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_INT_CB(_devcb) \
- devcb = &z80dart_device::set_out_int_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_RXDRQA_CB(_devcb) \
- devcb = &z80dart_device::set_out_rxdrqa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_TXDRQA_CB(_devcb) \
- devcb = &z80dart_device::set_out_txdrqa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_RXDRQB_CB(_devcb) \
- devcb = &z80dart_device::set_out_rxdrqb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DART_OUT_TXDRQB_CB(_devcb) \
- devcb = &z80dart_device::set_out_txdrqb_callback(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> z80dart_channel
-
-class z80dart_device;
-
-class z80dart_channel : public device_t,
- public device_serial_interface
-{
- friend class z80dart_device;
-
-public:
- z80dart_channel(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_serial_interface overrides
- virtual void tra_callback();
- virtual void tra_complete();
- virtual void rcv_callback();
- virtual void rcv_complete();
-
- UINT8 control_read();
- void control_write(UINT8 data);
-
- UINT8 data_read();
- void data_write(UINT8 data);
-
- void receive_data(UINT8 data);
-
- DECLARE_WRITE_LINE_MEMBER( write_rx );
- DECLARE_WRITE_LINE_MEMBER( cts_w );
- DECLARE_WRITE_LINE_MEMBER( dcd_w );
- DECLARE_WRITE_LINE_MEMBER( ri_w );
- DECLARE_WRITE_LINE_MEMBER( rxc_w );
- DECLARE_WRITE_LINE_MEMBER( txc_w );
- DECLARE_WRITE_LINE_MEMBER( sync_w );
-
- int m_rxc;
- int m_txc;
-
- // register state
- UINT8 m_rr[3]; // read register
- UINT8 m_wr[6]; // write register
-
-protected:
- enum
- {
- INT_TRANSMIT = 0,
- INT_EXTERNAL,
- INT_RECEIVE,
- INT_SPECIAL
- };
-
- enum
- {
- RR0_RX_CHAR_AVAILABLE = 0x01,
- RR0_INTERRUPT_PENDING = 0x02,
- RR0_TX_BUFFER_EMPTY = 0x04,
- RR0_DCD = 0x08,
- RR0_RI = 0x10,
- RR0_SYNC_HUNT = 0x10, // not supported
- RR0_CTS = 0x20,
- RR0_TX_UNDERRUN = 0x40, // not supported
- RR0_BREAK_ABORT = 0x80 // not supported
- };
-
- enum
- {
- RR1_ALL_SENT = 0x01,
- RR1_RESIDUE_CODE_MASK = 0x0e, // not supported
- RR1_PARITY_ERROR = 0x10,
- RR1_RX_OVERRUN_ERROR = 0x20,
- RR1_CRC_FRAMING_ERROR = 0x40,
- RR1_END_OF_FRAME = 0x80 // not supported
- };
-
- enum
- {
- WR0_REGISTER_MASK = 0x07,
- WR0_COMMAND_MASK = 0x38,
- WR0_NULL = 0x00,
- WR0_SEND_ABORT = 0x08, // not supported
- WR0_RESET_EXT_STATUS = 0x10,
- WR0_CHANNEL_RESET = 0x18,
- WR0_ENABLE_INT_NEXT_RX = 0x20,
- WR0_RESET_TX_INT = 0x28, // not supported
- WR0_ERROR_RESET = 0x30,
- WR0_RETURN_FROM_INT = 0x38, // not supported
- WR0_CRC_RESET_CODE_MASK = 0xc0, // not supported
- WR0_CRC_RESET_NULL = 0x00, // not supported
- WR0_CRC_RESET_RX = 0x40, // not supported
- WR0_CRC_RESET_TX = 0x80, // not supported
- WR0_CRC_RESET_TX_UNDERRUN = 0xc0 // not supported
- };
-
- enum
- {
- WR1_EXT_INT_ENABLE = 0x01,
- WR1_TX_INT_ENABLE = 0x02,
- WR1_STATUS_VECTOR = 0x04,
- WR1_RX_INT_MODE_MASK = 0x18,
- WR1_RX_INT_DISABLE = 0x00,
- WR1_RX_INT_FIRST = 0x08,
- WR1_RX_INT_ALL_PARITY = 0x10, // not supported
- WR1_RX_INT_ALL = 0x18,
- WR1_WRDY_ON_RX_TX = 0x20, // not supported
- WR1_WRDY_FUNCTION = 0x40, // not supported
- WR1_WRDY_ENABLE = 0x80 // not supported
- };
-
- enum
- {
- WR2_DATA_XFER_INT = 0x00, // not supported
- WR2_DATA_XFER_DMA_INT = 0x01, // not supported
- WR2_DATA_XFER_DMA = 0x02, // not supported
- WR2_DATA_XFER_ILLEGAL = 0x03, // not supported
- WR2_DATA_XFER_MASK = 0x03, // not supported
- WR2_PRIORITY = 0x04, // not supported
- WR2_MODE_8085_1 = 0x00, // not supported
- WR2_MODE_8085_2 = 0x08, // not supported
- WR2_MODE_8086_8088 = 0x10, // not supported
- WR2_MODE_ILLEGAL = 0x18, // not supported
- WR2_MODE_MASK = 0x18, // not supported
- WR2_VECTORED_INT = 0x20, // not supported
- WR2_PIN10_SYNDETB_RTSB = 0x80 // not supported
- };
-
- enum
- {
- WR3_RX_ENABLE = 0x01,
- WR3_SYNC_CHAR_LOAD_INHIBIT= 0x02, // not supported
- WR3_ADDRESS_SEARCH_MODE = 0x04, // not supported
- WR3_RX_CRC_ENABLE = 0x08, // not supported
- WR3_ENTER_HUNT_PHASE = 0x10, // not supported
- WR3_AUTO_ENABLES = 0x20,
- WR3_RX_WORD_LENGTH_MASK = 0xc0,
- WR3_RX_WORD_LENGTH_5 = 0x00,
- WR3_RX_WORD_LENGTH_7 = 0x40,
- WR3_RX_WORD_LENGTH_6 = 0x80,
- WR3_RX_WORD_LENGTH_8 = 0xc0
- };
-
- enum
- {
- WR4_PARITY_ENABLE = 0x01,
- WR4_PARITY_EVEN = 0x02,
- WR4_STOP_BITS_MASK = 0x0c,
- WR4_STOP_BITS_1 = 0x04,
- WR4_STOP_BITS_1_5 = 0x08, // not supported
- WR4_STOP_BITS_2 = 0x0c,
- WR4_SYNC_MODE_MASK = 0x30, // not supported
- WR4_SYNC_MODE_8_BIT = 0x00, // not supported
- WR4_SYNC_MODE_16_BIT = 0x10, // not supported
- WR4_SYNC_MODE_SDLC = 0x20, // not supported
- WR4_SYNC_MODE_EXT = 0x30, // not supported
- WR4_CLOCK_RATE_MASK = 0xc0,
- WR4_CLOCK_RATE_X1 = 0x00,
- WR4_CLOCK_RATE_X16 = 0x40,
- WR4_CLOCK_RATE_X32 = 0x80,
- WR4_CLOCK_RATE_X64 = 0xc0
- };
-
- enum
- {
- WR5_TX_CRC_ENABLE = 0x01, // not supported
- WR5_RTS = 0x02,
- WR5_CRC16 = 0x04, // not supported
- WR5_TX_ENABLE = 0x08,
- WR5_SEND_BREAK = 0x10,
- WR5_TX_WORD_LENGTH_MASK = 0x60,
- WR5_TX_WORD_LENGTH_5 = 0x00,
- WR5_TX_WORD_LENGTH_6 = 0x40,
- WR5_TX_WORD_LENGTH_7 = 0x20,
- WR5_TX_WORD_LENGTH_8 = 0x60,
- WR5_DTR = 0x80
- };
-
- void update_serial();
- void set_dtr(int state);
- void set_rts(int state);
-
- int get_clock_mode();
- stop_bits_t get_stop_bits();
- int get_rx_word_length();
- int get_tx_word_length();
-
- // receiver state
- UINT8 m_rx_data_fifo[3]; // receive data FIFO
- UINT8 m_rx_error_fifo[3]; // receive error FIFO
- UINT8 m_rx_error; // current receive error
- int m_rx_fifo; // receive FIFO pointer
-
- int m_rx_clock; // receive clock pulse count
- int m_rx_first; // first character received
- int m_rx_break; // receive break condition
- UINT8 m_rx_rr0_latch; // read register 0 latched
-
- int m_rxd;
- int m_ri; // ring indicator latch
- int m_cts; // clear to send latch
- int m_dcd; // data carrier detect latch
-
- // transmitter state
- UINT8 m_tx_data; // transmit data register
- int m_tx_clock; // transmit clock pulse count
-
- int m_dtr; // data terminal ready
- int m_rts; // request to send
-
- // synchronous state
- UINT16 m_sync; // sync character
-
- int m_index;
- z80dart_device *m_uart;
-};
-
-
-// ======================> z80dart_device
-
-class z80dart_device : public device_t,
- public device_z80daisy_interface
-{
- friend class z80dart_channel;
-
-public:
- // construction/destruction
- z80dart_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source);
- z80dart_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_txda_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_txda_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dtra_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_dtra_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_rtsa_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_rtsa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_wrdya_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_wrdya_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_synca_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_synca_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_txdb_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_txdb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_dtrb_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_dtrb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_rtsb_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_rtsb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_wrdyb_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_wrdyb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_syncb_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_syncb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_int_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_int_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_rxdrqa_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_rxdrqa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_txdrqa_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_txdrqa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_rxdrqb_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_rxdrqb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_txdrqb_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_txdrqb_cb.set_callback(object); }
-
- static void configure_channels(device_t &device, int rxa, int txa, int rxb, int txb)
- {
- z80dart_device &dev = downcast<z80dart_device &>(device);
- dev.m_rxca = rxa;
- dev.m_txca = txa;
- dev.m_rxcb = rxb;
- dev.m_txcb = txb;
- }
-
- DECLARE_READ8_MEMBER( cd_ba_r );
- DECLARE_WRITE8_MEMBER( cd_ba_w );
- DECLARE_READ8_MEMBER( ba_cd_r );
- DECLARE_WRITE8_MEMBER( ba_cd_w );
-
- DECLARE_READ8_MEMBER( da_r ) { return m_chanA->data_read(); }
- DECLARE_WRITE8_MEMBER( da_w ) { m_chanA->data_write(data); }
- DECLARE_READ8_MEMBER( db_r ) { return m_chanB->data_read(); }
- DECLARE_WRITE8_MEMBER( db_w ) { m_chanB->data_write(data); }
-
- DECLARE_READ8_MEMBER( ca_r ) { return m_chanA->control_read(); }
- DECLARE_WRITE8_MEMBER( ca_w ) { m_chanA->control_write(data); }
- DECLARE_READ8_MEMBER( cb_r ) { return m_chanB->control_read(); }
- DECLARE_WRITE8_MEMBER( cb_w ) { m_chanB->control_write(data); }
-
- // interrupt acknowledge
- int m1_r();
-
- DECLARE_WRITE_LINE_MEMBER( rxa_w ) { m_chanA->write_rx(state); }
- DECLARE_WRITE_LINE_MEMBER( rxb_w ) { m_chanB->write_rx(state); }
- DECLARE_WRITE_LINE_MEMBER( ctsa_w ) { m_chanA->cts_w(state); }
- DECLARE_WRITE_LINE_MEMBER( ctsb_w ) { m_chanB->cts_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dcda_w ) { m_chanA->dcd_w(state); }
- DECLARE_WRITE_LINE_MEMBER( dcdb_w ) { m_chanB->dcd_w(state); }
- DECLARE_WRITE_LINE_MEMBER( ria_w ) { m_chanA->ri_w(state); }
- DECLARE_WRITE_LINE_MEMBER( rib_w ) { m_chanB->ri_w(state); }
- DECLARE_WRITE_LINE_MEMBER( rxca_w ) { m_chanA->rxc_w(state); }
- DECLARE_WRITE_LINE_MEMBER( rxcb_w ) { m_chanB->rxc_w(state); }
- DECLARE_WRITE_LINE_MEMBER( txca_w ) { m_chanA->txc_w(state); }
- DECLARE_WRITE_LINE_MEMBER( txcb_w ) { m_chanB->txc_w(state); }
- DECLARE_WRITE_LINE_MEMBER( rxtxcb_w ) { m_chanB->rxc_w(state); m_chanB->txc_w(state); }
- DECLARE_WRITE_LINE_MEMBER( synca_w ) { m_chanA->sync_w(state); }
- DECLARE_WRITE_LINE_MEMBER( syncb_w ) { m_chanB->sync_w(state); }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual machine_config_constructor device_mconfig_additions() const;
-
- // device_z80daisy_interface overrides
- virtual int z80daisy_irq_state();
- virtual int z80daisy_irq_ack();
- virtual void z80daisy_irq_reti();
-
- // internal interrupt management
- void check_interrupts();
- void reset_interrupts();
- void trigger_interrupt(int index, int state);
- int get_channel_index(z80dart_channel *ch) { return (ch == m_chanA) ? 0 : 1; }
-
- enum
- {
- TYPE_DART,
- TYPE_SIO0,
- TYPE_SIO1,
- TYPE_SIO2,
- TYPE_SIO3,
- TYPE_SIO4,
- TYPE_I8274,
- TYPE_UPD7201
- };
-
- enum
- {
- CHANNEL_A = 0,
- CHANNEL_B
- };
-
- required_device<z80dart_channel> m_chanA;
- required_device<z80dart_channel> m_chanB;
-
- // internal state
- int m_rxca;
- int m_txca;
- int m_rxcb;
- int m_txcb;
-
- devcb_write_line m_out_txda_cb;
- devcb_write_line m_out_dtra_cb;
- devcb_write_line m_out_rtsa_cb;
- devcb_write_line m_out_wrdya_cb;
- devcb_write_line m_out_synca_cb;
-
- devcb_write_line m_out_txdb_cb;
- devcb_write_line m_out_dtrb_cb;
- devcb_write_line m_out_rtsb_cb;
- devcb_write_line m_out_wrdyb_cb;
- devcb_write_line m_out_syncb_cb;
-
- devcb_write_line m_out_int_cb;
- devcb_write_line m_out_rxdrqa_cb;
- devcb_write_line m_out_txdrqa_cb;
- devcb_write_line m_out_rxdrqb_cb;
- devcb_write_line m_out_txdrqb_cb;
-
- int m_int_state[8]; // interrupt state
-
- int m_variant;
-};
-
-
-// ======================> z80sio0_device
-
-class z80sio0_device : public z80dart_device
-{
-public:
- // construction/destruction
- z80sio0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-
-// ======================> z80sio1_device
-
-class z80sio1_device : public z80dart_device
-{
-public:
- // construction/destruction
- z80sio1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-
-// ======================> z80sio2_device
-
-class z80sio2_device : public z80dart_device
-{
-public:
- // construction/destruction
- z80sio2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-
-// ======================> z80sio3_device
-
-class z80sio3_device : public z80dart_device
-{
-public:
- // construction/destruction
- z80sio3_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-
-// ======================> z80sio4_device
-
-class z80sio4_device : public z80dart_device
-{
-public:
- // construction/destruction
- z80sio4_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-
-// ======================> i8274_device
-
-class i8274_device : public z80dart_device
-{
-public:
- // construction/destruction
- i8274_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_READ8_MEMBER( inta_r ) { return m1_r(); };
-};
-
-
-// ======================> upd7201_device
-
-class upd7201_device : public z80dart_device
-{
-public:
- // construction/destruction
- upd7201_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-};
-
-
-// device type definition
-extern const device_type Z80DART_CHANNEL;
-extern const device_type Z80DART;
-extern const device_type Z80SIO0;
-extern const device_type Z80SIO1;
-extern const device_type Z80SIO2;
-extern const device_type Z80SIO3;
-extern const device_type Z80SIO4;
-extern const device_type I8274;
-extern const device_type UPD7201;
-
-
-#endif
diff --git a/src/emu/machine/z80dma.c b/src/emu/machine/z80dma.c
deleted file mode 100644
index 745d22877f0..00000000000
--- a/src/emu/machine/z80dma.c
+++ /dev/null
@@ -1,881 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Couriersud
-/**********************************************************************
-
- Z80 DMA interface and emulation
-
- For datasheet http://www.zilog.com/docs/z80/ps0179.pdf
-
- 2008/01 couriersud
-
- - architecture copied from 8257 DMA
- - significant changes to implementation
- - This is only a minimum implementation to support dkong3 and mario drivers
- - Only memory to memory is tested!
-
- TODO:
- - reset command (C3) is handled improperly
- - rewrite to match documentation
- - implement missing features
- - implement more asserts
- - implement a INPUT_LINE_BUSREQ for Z80. As a workaround,
- HALT is used. This implies burst mode.
-
-**********************************************************************/
-
-#include "emu.h"
-#include "z80dma.h"
-#include "cpu/z80/z80daisy.h"
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-enum
-{
- INT_RDY = 0,
- INT_MATCH,
- INT_END_OF_BLOCK,
- INT_MATCH_END_OF_BLOCK
-};
-
-const int COMMAND_RESET = 0xc3;
-const int COMMAND_RESET_PORT_A_TIMING = 0xc7;
-const int COMMAND_RESET_PORT_B_TIMING = 0xcb;
-const int COMMAND_LOAD = 0xcf;
-const int COMMAND_CONTINUE = 0xd3;
-const int COMMAND_DISABLE_INTERRUPTS = 0xaf;
-const int COMMAND_ENABLE_INTERRUPTS = 0xab;
-const int COMMAND_RESET_AND_DISABLE_INTERRUPTS = 0xa3;
-const int COMMAND_ENABLE_AFTER_RETI = 0xb7;
-const int COMMAND_READ_STATUS_BYTE = 0xbf;
-const int COMMAND_REINITIALIZE_STATUS_BYTE = 0x8b;
-const int COMMAND_INITIATE_READ_SEQUENCE = 0xa7;
-const int COMMAND_FORCE_READY = 0xb3;
-const int COMMAND_ENABLE_DMA = 0x87;
-const int COMMAND_DISABLE_DMA = 0x83;
-const int COMMAND_READ_MASK_FOLLOWS = 0xbb;
-
-const int TM_TRANSFER = 0x01;
-const int TM_SEARCH = 0x02;
-const int TM_SEARCH_TRANSFER = 0x03;
-
-
-
-//**************************************************************************
-// MACROS
-//**************************************************************************
-
-#define LOG 0
-#define DMA_LOG 0
-
-#define REGNUM(_m, _s) (((_m)<<3) + (_s))
-#define GET_REGNUM(_r) (&(_r) - &(WR0))
-#define REG(_m, _s) m_regs[REGNUM(_m,_s)]
-#define WR0 REG(0, 0)
-#define WR1 REG(1, 0)
-#define WR2 REG(2, 0)
-#define WR3 REG(3, 0)
-#define WR4 REG(4, 0)
-#define WR5 REG(5, 0)
-#define WR6 REG(6, 0)
-
-#define PORTA_ADDRESS_L REG(0,1)
-#define PORTA_ADDRESS_H REG(0,2)
-
-#define BLOCKLEN_L REG(0,3)
-#define BLOCKLEN_H REG(0,4)
-
-#define PORTA_TIMING REG(1,1)
-#define PORTB_TIMING REG(2,1)
-
-#define MASK_BYTE REG(3,1)
-#define MATCH_BYTE REG(3,2)
-
-#define PORTB_ADDRESS_L REG(4,1)
-#define PORTB_ADDRESS_H REG(4,2)
-#define INTERRUPT_CTRL REG(4,3)
-#define INTERRUPT_VECTOR REG(4,4)
-#define PULSE_CTRL REG(4,5)
-
-#define READ_MASK REG(6,1)
-
-#define PORTA_ADDRESS ((PORTA_ADDRESS_H<<8) | PORTA_ADDRESS_L)
-#define PORTB_ADDRESS ((PORTB_ADDRESS_H<<8) | PORTB_ADDRESS_L)
-#define BLOCKLEN ((BLOCKLEN_H<<8) | BLOCKLEN_L)
-
-#define PORTA_INC (WR1 & 0x10)
-#define PORTB_INC (WR2 & 0x10)
-#define PORTA_FIXED (((WR1 >> 4) & 0x02) == 0x02)
-#define PORTB_FIXED (((WR2 >> 4) & 0x02) == 0x02)
-#define PORTA_MEMORY (((WR1 >> 3) & 0x01) == 0x00)
-#define PORTB_MEMORY (((WR2 >> 3) & 0x01) == 0x00)
-
-#define PORTA_CYCLE_LEN (4-(PORTA_TIMING & 0x03))
-#define PORTB_CYCLE_LEN (4-(PORTB_TIMING & 0x03))
-
-#define PORTA_IS_SOURCE ((WR0 >> 2) & 0x01)
-#define PORTB_IS_SOURCE (!PORTA_IS_SOURCE)
-#define TRANSFER_MODE (WR0 & 0x03)
-
-#define MATCH_F_SET (m_status &= ~0x10)
-#define MATCH_F_CLEAR (m_status |= 0x10)
-#define EOB_F_SET (m_status &= ~0x20)
-#define EOB_F_CLEAR (m_status |= 0x20)
-
-#define READY_ACTIVE_HIGH ((WR5>>3) & 0x01)
-#define AUTO_RESTART ((WR5>>5) & 0x01)
-
-#define INTERRUPT_ENABLE (WR3 & 0x20)
-#define INT_ON_MATCH (INTERRUPT_CTRL & 0x01)
-#define INT_ON_END_OF_BLOCK (INTERRUPT_CTRL & 0x02)
-#define INT_ON_READY (INTERRUPT_CTRL & 0x40)
-#define STATUS_AFFECTS_VECTOR (INTERRUPT_CTRL & 0x20)
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type Z80DMA = &device_creator<z80dma_device>;
-
-//-------------------------------------------------
-// z80dma_device - constructor
-//-------------------------------------------------
-
-z80dma_device::z80dma_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, Z80DMA, "Z80 DMA", tag, owner, clock, "z80dma", __FILE__),
- device_z80daisy_interface(mconfig, *this),
- m_out_busreq_cb(*this),
- m_out_int_cb(*this),
- m_out_bao_cb(*this),
- m_in_mreq_cb(*this),
- m_out_mreq_cb(*this),
- m_in_iorq_cb(*this),
- m_out_iorq_cb(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void z80dma_device::device_start()
-{
- // resolve callbacks
- m_out_busreq_cb.resolve_safe();
- m_out_int_cb.resolve_safe();
- m_out_bao_cb.resolve_safe();
- m_in_mreq_cb.resolve_safe(0);
- m_out_mreq_cb.resolve_safe();
- m_in_iorq_cb.resolve_safe(0);
- m_out_iorq_cb.resolve_safe();
-
- // allocate timer
- m_timer = machine().scheduler().timer_alloc(FUNC(static_timerproc), (void *)this);
-
- // register for state saving
- save_item(NAME(m_regs));
- save_item(NAME(m_regs_follow));
- save_item(NAME(m_num_follow));
- save_item(NAME(m_cur_follow));
- save_item(NAME(m_status));
- save_item(NAME(m_dma_enabled));
- save_item(NAME(m_vector));
- save_item(NAME(m_ip));
- save_item(NAME(m_ius));
- save_item(NAME(m_addressA));
- save_item(NAME(m_addressB));
- save_item(NAME(m_count));
- save_item(NAME(m_rdy));
- save_item(NAME(m_force_ready));
- save_item(NAME(m_is_read));
- save_item(NAME(m_cur_cycle));
- save_item(NAME(m_latch));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void z80dma_device::device_reset()
-{
- m_status = 0;
- m_rdy = 0;
- m_force_ready = 0;
- m_num_follow = 0;
- m_dma_enabled = 0;
- m_read_num_follow = m_read_cur_follow = 0;
- m_reset_pointer = 0;
- m_is_read = false;
- memset(m_regs, 0, sizeof(m_regs));
- memset(m_regs_follow, 0, sizeof(m_regs_follow));
-
- // disable interrupts
- WR3 &= ~0x20;
- m_ip = 0;
- m_ius = 0;
- m_vector = 0;
-
- update_status();
-}
-
-
-
-//**************************************************************************
-// DAISY CHAIN INTERFACE
-//**************************************************************************
-
-//-------------------------------------------------
-// z80daisy_irq_state - return the overall IRQ
-// state for this device
-//-------------------------------------------------
-
-int z80dma_device::z80daisy_irq_state()
-{
- int state = 0;
-
- if (m_ip)
- {
- // interrupt pending
- state = Z80_DAISY_INT;
- }
- else if (m_ius)
- {
- // interrupt under service
- state = Z80_DAISY_IEO;
- }
-
- if (LOG) logerror("Z80DMA '%s' Interrupt State: %u\n", tag(), state);
-
- return state;
-}
-
-
-//-------------------------------------------------
-// z80daisy_irq_ack - acknowledge an IRQ and
-// return the appropriate vector
-//-------------------------------------------------
-
-int z80dma_device::z80daisy_irq_ack()
-{
- if (m_ip)
- {
- if (LOG) logerror("Z80DMA '%s' Interrupt Acknowledge\n", tag());
-
- // clear interrupt pending flag
- m_ip = 0;
- interrupt_check();
-
- // set interrupt under service flag
- m_ius = 1;
-
- return m_vector;
- }
-
- //logerror("z80dma_irq_ack: failed to find an interrupt to ack!\n");
-
- return 0;
-}
-
-
-//-------------------------------------------------
-// z80daisy_irq_reti - clear the interrupt
-// pending state to allow other interrupts through
-//-------------------------------------------------
-
-void z80dma_device::z80daisy_irq_reti()
-{
- if (m_ius)
- {
- if (LOG) logerror("Z80DMA '%s' Return from Interrupt\n", tag());
-
- // clear interrupt under service flag
- m_ius = 0;
- interrupt_check();
-
- return;
- }
-
- //logerror("z80dma_irq_reti: failed to find an interrupt to clear IEO on!\n");
-}
-
-
-
-//**************************************************************************
-// INTERNAL STATE MANAGEMENT
-//**************************************************************************
-
-//-------------------------------------------------
-// is_ready - ready for DMA transfer?
-//-------------------------------------------------
-
-int z80dma_device::is_ready()
-{
- return (m_force_ready) || (m_rdy == READY_ACTIVE_HIGH);
-}
-
-
-//-------------------------------------------------
-// interrupt_check - update IRQ line state
-//-------------------------------------------------
-
-void z80dma_device::interrupt_check()
-{
- m_out_int_cb(m_ip ? ASSERT_LINE : CLEAR_LINE);
-}
-
-
-//-------------------------------------------------
-// trigger_interrupt - trigger DMA interrupt
-//-------------------------------------------------
-
-void z80dma_device::trigger_interrupt(int level)
-{
- if (!m_ius && INTERRUPT_ENABLE)
- {
- // set interrupt pending flag
- m_ip = 1;
-
- // set interrupt vector
- if (STATUS_AFFECTS_VECTOR)
- {
- m_vector = (INTERRUPT_VECTOR & 0xf9) | (level << 1);
- }
- else
- {
- m_vector = INTERRUPT_VECTOR;
- }
-
- m_status &= ~0x08;
-
- if (LOG) logerror("Z80DMA '%s' Interrupt Pending\n", tag());
-
- interrupt_check();
- }
-}
-
-
-//-------------------------------------------------
-// do_read - perform DMA read
-//-------------------------------------------------
-
-void z80dma_device::do_read()
-{
- UINT8 mode;
-
- mode = TRANSFER_MODE;
- switch(mode) {
- case TM_TRANSFER:
- case TM_SEARCH:
- case TM_SEARCH_TRANSFER:
- if (PORTA_IS_SOURCE)
- {
- if (PORTA_MEMORY)
- m_latch = m_in_mreq_cb(m_addressA);
- else
- m_latch = m_in_iorq_cb(m_addressA);
-
- if (DMA_LOG) logerror("Z80DMA '%s' A src: %04x %s -> data: %02x\n", tag(), m_addressA, PORTA_MEMORY ? "mem" : "i/o", m_latch);
- }
- else
- {
- if (PORTB_MEMORY)
- m_latch = m_in_mreq_cb(m_addressB);
- else
- m_latch = m_in_iorq_cb(m_addressB);
-
- if (DMA_LOG) logerror("Z80DMA '%s' B src: %04x %s -> data: %02x\n", tag(), m_addressB, PORTB_MEMORY ? "mem" : "i/o", m_latch);
- }
- break;
- default:
- logerror("z80dma_do_operation: invalid mode %d!\n", mode);
- break;
- }
-}
-
-
-//-------------------------------------------------
-// do_write - perform DMA write
-//-------------------------------------------------
-
-void z80dma_device::do_transfer_write()
-{
- if (PORTA_IS_SOURCE)
- {
- if (PORTB_MEMORY)
- m_out_mreq_cb((offs_t)m_addressB, m_latch);
- else
- m_out_iorq_cb((offs_t)m_addressB, m_latch);
-
- if (DMA_LOG) logerror("Z80DMA '%s' B dst: %04x %s\n", tag(), m_addressB, PORTB_MEMORY ? "mem" : "i/o");
- }
- else
- {
- if (PORTA_MEMORY)
- m_out_mreq_cb((offs_t)m_addressA, m_latch);
- else
- m_out_iorq_cb((offs_t)m_addressA, m_latch);
-
- if (DMA_LOG) logerror("Z80DMA '%s' A dst: %04x %s\n", tag(), m_addressA, PORTA_MEMORY ? "mem" : "i/o");
- }
-}
-
-void z80dma_device::do_search()
-{
- UINT8 load_byte,match_byte;
- load_byte = m_latch | MASK_BYTE;
- match_byte = MATCH_BYTE | MASK_BYTE;
- //if (LOG) logerror("%02x %02x\n",load_byte,match_byte));
- if (load_byte == match_byte)
- {
- if (INT_ON_MATCH)
- {
- trigger_interrupt(INT_MATCH);
- }
- }
-}
-
-int z80dma_device::do_write()
-{
- int done = 0;
- UINT8 mode;
-
- mode = TRANSFER_MODE;
- if (m_count == 0x0000)
- {
- //FIXME: Any signal here
- }
- switch(mode) {
- case TM_TRANSFER:
- do_transfer_write();
- break;
-
- case TM_SEARCH:
- do_search();
- break;
-
- case TM_SEARCH_TRANSFER:
- do_transfer_write();
- do_search();
- break;
-
- default:
- logerror("z80dma_do_operation: invalid mode %d!\n", mode);
- break;
- }
-
- m_addressA += PORTA_FIXED ? 0 : PORTA_INC ? 1 : -1;
- m_addressB += PORTB_FIXED ? 0 : PORTB_INC ? 1 : -1;
-
- m_count--;
- done = (m_count == 0xFFFF); //correct?
-
- if (done)
- {
- //FIXME: interrupt ?
- }
- return done;
-}
-
-
-//-------------------------------------------------
-// timerproc
-//-------------------------------------------------
-
-void z80dma_device::timerproc()
-{
- int done;
-
- if (--m_cur_cycle)
- {
- return;
- }
-
- if (m_is_read && !is_ready()) return;
-
- if (m_is_read)
- {
- /* TODO: there's a nasty recursion bug with Alpha for Sharp X1 Turbo on the transfers with this function! */
- do_read();
- done = 0;
- m_is_read = false;
- m_cur_cycle = (PORTA_IS_SOURCE ? PORTA_CYCLE_LEN : PORTB_CYCLE_LEN);
- }
- else
- {
- done = do_write();
- m_is_read = true;
- m_cur_cycle = (PORTB_IS_SOURCE ? PORTA_CYCLE_LEN : PORTB_CYCLE_LEN);
- }
-
- if (done)
- {
- m_dma_enabled = 0; //FIXME: Correct?
- m_status = 0x09;
-
- m_status |= !is_ready() << 1; // ready line status
-
- if(TRANSFER_MODE == TM_TRANSFER) m_status |= 0x10; // no match found
-
- update_status();
- if (LOG) logerror("Z80DMA '%s' End of Block\n", tag());
-
- if (INT_ON_END_OF_BLOCK)
- {
- trigger_interrupt(INT_END_OF_BLOCK);
- }
-
- if (AUTO_RESTART)
- {
- if (LOG) logerror("Z80DMA '%s' Auto Restart\n", tag());
-
- m_dma_enabled = 1;
- m_addressA = PORTA_ADDRESS;
- m_addressB = PORTB_ADDRESS;
- m_count = BLOCKLEN;
- m_status |= 0x30;
- }
- }
-}
-
-
-//-------------------------------------------------
-// update_status - update DMA status
-//-------------------------------------------------
-
-void z80dma_device::update_status()
-{
- UINT16 pending_transfer;
- attotime next;
-
- // no transfer is active right now; is there a transfer pending right now?
- pending_transfer = is_ready() & m_dma_enabled;
-
- if (pending_transfer)
- {
- m_is_read = true;
- m_cur_cycle = (PORTA_IS_SOURCE ? PORTA_CYCLE_LEN : PORTB_CYCLE_LEN);
- next = attotime::from_hz(clock());
- m_timer->adjust(
- attotime::zero,
- 0,
- // 1 byte transferred in 4 clock cycles
- next);
- }
- else
- {
- if (m_is_read)
- {
- // no transfers active right now
- m_timer->reset();
- }
- }
-
- // set the busreq line
- m_out_busreq_cb(pending_transfer ? ASSERT_LINE : CLEAR_LINE);
-}
-
-
-
-//**************************************************************************
-// READ/WRITE INTERFACES
-//**************************************************************************
-
-//-------------------------------------------------
-// read - register read
-//-------------------------------------------------
-
-UINT8 z80dma_device::read()
-{
- UINT8 res;
-
- if(m_read_num_follow == 0) // special case: Legend of Kage on X1 Turbo
- res = m_status;
- else {
- res = m_read_regs_follow[m_read_cur_follow];
- }
-
- m_read_cur_follow++;
-
- if(m_read_cur_follow >= m_read_num_follow)
- m_read_cur_follow = 0;
-
- if (LOG) logerror("Z80DMA '%s' Read %02x\n", tag(), res);
-
- return res;
-}
-
-
-//-------------------------------------------------
-// write - register write
-//-------------------------------------------------
-
-void z80dma_device::write(UINT8 data)
-{
- if (m_num_follow == 0)
- {
- m_reset_pointer = 0;
-
- if ((data & 0x87) == 0) // WR2
- {
- if (LOG) logerror("Z80DMA '%s' WR2 %02x\n", tag(), data);
- WR2 = data;
- if (data & 0x40)
- m_regs_follow[m_num_follow++] = GET_REGNUM(PORTB_TIMING);
- }
- else if ((data & 0x87) == 0x04) // WR1
- {
- if (LOG) logerror("Z80DMA '%s' WR1 %02x\n", tag(), data);
- WR1 = data;
- if (data & 0x40)
- m_regs_follow[m_num_follow++] = GET_REGNUM(PORTA_TIMING);
- }
- else if ((data & 0x80) == 0) // WR0
- {
- if (LOG) logerror("Z80DMA '%s' WR0 %02x\n", tag(), data);
- WR0 = data;
- if (data & 0x08)
- m_regs_follow[m_num_follow++] = GET_REGNUM(PORTA_ADDRESS_L);
- if (data & 0x10)
- m_regs_follow[m_num_follow++] = GET_REGNUM(PORTA_ADDRESS_H);
- if (data & 0x20)
- m_regs_follow[m_num_follow++] = GET_REGNUM(BLOCKLEN_L);
- if (data & 0x40)
- m_regs_follow[m_num_follow++] = GET_REGNUM(BLOCKLEN_H);
- }
- else if ((data & 0x83) == 0x80) // WR3
- {
- if (LOG) logerror("Z80DMA '%s' WR3 %02x\n", tag(), data);
- WR3 = data;
- if (data & 0x08)
- m_regs_follow[m_num_follow++] = GET_REGNUM(MASK_BYTE);
- if (data & 0x10)
- m_regs_follow[m_num_follow++] = GET_REGNUM(MATCH_BYTE);
- }
- else if ((data & 0x83) == 0x81) // WR4
- {
- if (LOG) logerror("Z80DMA '%s' WR4 %02x\n", tag(), data);
- WR4 = data;
- if (data & 0x04)
- m_regs_follow[m_num_follow++] = GET_REGNUM(PORTB_ADDRESS_L);
- if (data & 0x08)
- m_regs_follow[m_num_follow++] = GET_REGNUM(PORTB_ADDRESS_H);
- if (data & 0x10)
- m_regs_follow[m_num_follow++] = GET_REGNUM(INTERRUPT_CTRL);
- }
- else if ((data & 0xC7) == 0x82) // WR5
- {
- if (LOG) logerror("Z80DMA '%s' WR5 %02x\n", tag(), data);
- WR5 = data;
- }
- else if ((data & 0x83) == 0x83) // WR6
- {
- if (LOG) logerror("Z80DMA '%s' WR6 %02x\n", tag(), data);
- m_dma_enabled = 0;
-
- WR6 = data;
-
- switch (data)
- {
- case COMMAND_ENABLE_AFTER_RETI:
- fatalerror("Z80DMA '%s' Unimplemented WR6 command %02x\n", tag(), data);
- case COMMAND_READ_STATUS_BYTE:
- if (LOG) logerror("Z80DMA '%s' CMD Read status Byte\n", tag());
- READ_MASK = 1;
- m_read_regs_follow[0] = m_status;
- break;
- case COMMAND_RESET_AND_DISABLE_INTERRUPTS:
- WR3 &= ~0x20;
- m_ip = 0;
- m_ius = 0;
- m_force_ready = 0;
- m_status |= 0x08;
- break;
- case COMMAND_INITIATE_READ_SEQUENCE:
- if (LOG) logerror("Z80DMA '%s' Initiate Read Sequence\n", tag());
- m_read_cur_follow = m_read_num_follow = 0;
- if(READ_MASK & 0x01) { m_read_regs_follow[m_read_num_follow++] = m_status; }
- if(READ_MASK & 0x02) { m_read_regs_follow[m_read_num_follow++] = m_count & 0xff; } //byte counter (low)
- if(READ_MASK & 0x04) { m_read_regs_follow[m_read_num_follow++] = m_count >> 8; } //byte counter (high)
- if(READ_MASK & 0x08) { m_read_regs_follow[m_read_num_follow++] = m_addressA & 0xff; } //port A address (low)
- if(READ_MASK & 0x10) { m_read_regs_follow[m_read_num_follow++] = m_addressA >> 8; } //port A address (high)
- if(READ_MASK & 0x20) { m_read_regs_follow[m_read_num_follow++] = m_addressB & 0xff; } //port B address (low)
- if(READ_MASK & 0x40) { m_read_regs_follow[m_read_num_follow++] = m_addressB >> 8; } //port B address (high)
- break;
- case COMMAND_RESET:
- if (LOG) logerror("Z80DMA '%s' Reset\n", tag());
- m_dma_enabled = 0;
- m_force_ready = 0;
- m_ip = 0;
- m_ius = 0;
- interrupt_check();
- // Needs six reset commands to reset the DMA
- {
- UINT8 WRi;
-
- for(WRi=0;WRi<7;WRi++)
- REG(WRi,m_reset_pointer) = 0;
-
- m_reset_pointer++;
- if(m_reset_pointer >= 6) { m_reset_pointer = 0; }
- }
- m_status = 0x38;
- break;
- case COMMAND_LOAD:
- m_force_ready = 0;
- m_addressA = PORTA_ADDRESS;
- m_addressB = PORTB_ADDRESS;
- m_count = BLOCKLEN;
- m_status |= 0x30;
-
- if (LOG) logerror("Z80DMA '%s' Load A: %x B: %x N: %x\n", tag(), m_addressA, m_addressB, m_count);
- break;
- case COMMAND_DISABLE_DMA:
- if (LOG) logerror("Z80DMA '%s' Disable DMA\n", tag());
- m_dma_enabled = 0;
- break;
- case COMMAND_ENABLE_DMA:
- if (LOG) logerror("Z80DMA '%s' Enable DMA\n", tag());
- m_dma_enabled = 1;
- update_status();
- break;
- case COMMAND_READ_MASK_FOLLOWS:
- if (LOG) logerror("Z80DMA '%s' Set Read Mask\n", tag());
- m_regs_follow[m_num_follow++] = GET_REGNUM(READ_MASK);
- break;
- case COMMAND_CONTINUE:
- if (LOG) logerror("Z80DMA '%s' Continue\n", tag());
- m_count = BLOCKLEN;
- m_dma_enabled = 1;
- //"match not found" & "end of block" status flags zeroed here
- m_status |= 0x30;
- break;
- case COMMAND_RESET_PORT_A_TIMING:
- if (LOG) logerror("Z80DMA '%s' Reset Port A Timing\n", tag());
- PORTA_TIMING = 0;
- break;
- case COMMAND_RESET_PORT_B_TIMING:
- if (LOG) logerror("Z80DMA '%s' Reset Port B Timing\n", tag());
- PORTB_TIMING = 0;
- break;
- case COMMAND_FORCE_READY:
- if (LOG) logerror("Z80DMA '%s' Force Ready\n", tag());
- m_force_ready = 1;
- update_status();
- break;
- case COMMAND_ENABLE_INTERRUPTS:
- if (LOG) logerror("Z80DMA '%s' Enable IRQ\n", tag());
- WR3 |= 0x20;
- break;
- case COMMAND_DISABLE_INTERRUPTS:
- if (LOG) logerror("Z80DMA '%s' Disable IRQ\n", tag());
- WR3 &= ~0x20;
- break;
- case COMMAND_REINITIALIZE_STATUS_BYTE:
- if (LOG) logerror("Z80DMA '%s' Reinitialize status byte\n", tag());
- m_status |= 0x30;
- m_ip = 0;
- break;
- case 0xFB:
- case 0xFF: // TODO: p8k triggers this, it probably crashed.
- if (LOG) logerror("Z80DMA '%s' undocumented command triggered 0x%02X!\n", tag(), data);
- break;
- default:
- printf("Z80DMA '%s' Unknown WR6 command %02x\n", tag(), data);
- }
- }
- else if(data == 0x8e) //newtype on Sharp X1, unknown purpose
- printf("Z80DMA '%s' Unknown base register %02x\n", tag(), data);
- else
- fatalerror("Z80DMA '%s' Unknown base register %02x\n", tag(), data);
- m_cur_follow = 0;
- }
- else
- {
- if (LOG) logerror("Z80DMA '%s' Write %02x\n", tag(), data);
-
- int nreg = m_regs_follow[m_cur_follow];
- m_regs[nreg] = data;
- m_cur_follow++;
- if (m_cur_follow>=m_num_follow)
- m_num_follow = 0;
- if (nreg == REGNUM(4,3))
- {
- m_num_follow=0;
- if (data & 0x08)
- m_regs_follow[m_num_follow++] = GET_REGNUM(PULSE_CTRL);
- if (data & 0x10)
- m_regs_follow[m_num_follow++] = GET_REGNUM(INTERRUPT_VECTOR);
- m_cur_follow = 0;
- }
- else if(m_regs_follow[m_num_follow] == GET_REGNUM(READ_MASK))
- {
- m_read_cur_follow = m_read_num_follow = 0;
-
- if(READ_MASK & 0x01) { m_read_regs_follow[m_read_num_follow++] = m_status; }
- if(READ_MASK & 0x02) { m_read_regs_follow[m_read_num_follow++] = m_count & 0xff; } //byte counter (low)
- if(READ_MASK & 0x04) { m_read_regs_follow[m_read_num_follow++] = m_count >> 8; } //byte counter (high)
- if(READ_MASK & 0x08) { m_read_regs_follow[m_read_num_follow++] = m_addressA & 0xff; } //port A address (low)
- if(READ_MASK & 0x10) { m_read_regs_follow[m_read_num_follow++] = m_addressA >> 8; } //port A address (high)
- if(READ_MASK & 0x20) { m_read_regs_follow[m_read_num_follow++] = m_addressB & 0xff; } //port B address (low)
- if(READ_MASK & 0x40) { m_read_regs_follow[m_read_num_follow++] = m_addressB >> 8; } //port B address (high)
- }
-
- m_reset_pointer++;
- if(m_reset_pointer >= 6) { m_reset_pointer = 0; }
- }
-}
-
-
-//-------------------------------------------------
-// rdy_write_callback - deferred RDY signal write
-//-------------------------------------------------
-
-void z80dma_device::rdy_write_callback(int state)
-{
- // normalize state
- m_rdy = state;
- m_status = (m_status & 0xFD) | (!is_ready() << 1);
-
- update_status();
-
- if (is_ready() && INT_ON_READY)
- {
- trigger_interrupt(INT_RDY);
- }
-}
-
-
-//-------------------------------------------------
-// rdy_w - ready input
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER(z80dma_device::rdy_w)
-{
- if (LOG) logerror("Z80DMA '%s' RDY: %d Active High: %d\n", tag(), state, READY_ACTIVE_HIGH);
- machine().scheduler().synchronize(FUNC(static_rdy_write_callback), state, (void *)this);
-}
-
-
-//-------------------------------------------------
-// wait_w - wait input
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER(z80dma_device::wait_w)
-{
-}
-
-
-//-------------------------------------------------
-// bai_w - bus acknowledge input
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER(z80dma_device::bai_w)
-{
-}
diff --git a/src/emu/machine/z80dma.h b/src/emu/machine/z80dma.h
deleted file mode 100644
index 389112e6f19..00000000000
--- a/src/emu/machine/z80dma.h
+++ /dev/null
@@ -1,165 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Couriersud
-/***************************************************************************
-
- Zilog Z80 DMA Direct Memory Access Controller emulation
-
-****************************************************************************
- _____ _____
- A5 1 |* \_/ | 40 A6
- A4 2 | | 39 A7
- A3 3 | | 38 IEI
- A2 4 | | 37 _INT/_PULSE
- A1 5 | | 36 IEO
- A0 6 | | 35 D0
- CLK 7 | | 34 D1
- _WR 8 | | 33 D2
- _RD 9 | | 32 D3
- _IORQ 10 | Z8410 | 31 D4
- +5V 11 | | 30 GND
- _MREQ 12 | | 29 D5
- _BAO 13 | | 28 D6
- _BAI 14 | | 27 D7
- _BUSREQ 15 | | 26 _M1
- _CE/_WAIT 16 | | 25 RDY
- A15 17 | | 24 A8
- A14 18 | | 23 A9
- A13 19 | | 22 A10
- A12 20 |_____________| 21 A11
-
-***************************************************************************/
-
-#ifndef __Z80DMA__
-#define __Z80DMA__
-
-#include "cpu/z80/z80daisy.h"
-
-
-//**************************************************************************
-// DEVICE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_Z80DMA_OUT_BUSREQ_CB(_devcb) \
- devcb = &z80dma_device::set_out_busreq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DMA_OUT_INT_CB(_devcb) \
- devcb = &z80dma_device::set_out_int_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DMA_OUT_BAO_CB(_devcb) \
- devcb = &z80dma_device::set_out_bao_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DMA_IN_MREQ_CB(_devcb) \
- devcb = &z80dma_device::set_in_mreq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DMA_OUT_MREQ_CB(_devcb) \
- devcb = &z80dma_device::set_out_mreq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DMA_IN_IORQ_CB(_devcb) \
- devcb = &z80dma_device::set_in_iorq_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80DMA_OUT_IORQ_CB(_devcb) \
- devcb = &z80dma_device::set_out_iorq_callback(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-// ======================> z80dma_device
-
-class z80dma_device : public device_t,
- public device_z80daisy_interface
-{
-public:
- // construction/destruction
- z80dma_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_busreq_callback(device_t &device, _Object object) { return downcast<z80dma_device &>(device).m_out_busreq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_int_callback(device_t &device, _Object object) { return downcast<z80dma_device &>(device).m_out_int_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_bao_callback(device_t &device, _Object object) { return downcast<z80dma_device &>(device).m_out_bao_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_mreq_callback(device_t &device, _Object object) { return downcast<z80dma_device &>(device).m_in_mreq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_mreq_callback(device_t &device, _Object object) { return downcast<z80dma_device &>(device).m_out_mreq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_iorq_callback(device_t &device, _Object object) { return downcast<z80dma_device &>(device).m_in_iorq_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_iorq_callback(device_t &device, _Object object) { return downcast<z80dma_device &>(device).m_out_iorq_cb.set_callback(object); }
-
- UINT8 read();
- void write(UINT8 data);
- DECLARE_READ8_MEMBER( read ) { return read(); }
- DECLARE_WRITE8_MEMBER( write ) { write(data); }
-
- DECLARE_WRITE_LINE_MEMBER(rdy_w);
- DECLARE_WRITE_LINE_MEMBER(wait_w);
- DECLARE_WRITE_LINE_MEMBER(bai_w);
-
-private:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- // device_z80daisy_interface overrides
- virtual int z80daisy_irq_state();
- virtual int z80daisy_irq_ack();
- virtual void z80daisy_irq_reti();
-
- // internal helpers
- int is_ready();
- void interrupt_check();
- void trigger_interrupt(int level);
- void do_read();
- int do_write();
- void do_transfer_write();
- void do_search();
-
- static TIMER_CALLBACK( static_timerproc ) { reinterpret_cast<z80dma_device *>(ptr)->timerproc(); }
- void timerproc();
-
- void update_status();
-
- static TIMER_CALLBACK( static_rdy_write_callback ) { reinterpret_cast<z80dma_device *>(ptr)->rdy_write_callback(param); }
- void rdy_write_callback(int state);
-
- // internal state
- devcb_write_line m_out_busreq_cb;
- devcb_write_line m_out_int_cb;
- devcb_write_line m_out_bao_cb;
- devcb_read8 m_in_mreq_cb;
- devcb_write8 m_out_mreq_cb;
- devcb_read8 m_in_iorq_cb;
- devcb_write8 m_out_iorq_cb;
-
- emu_timer *m_timer;
-
- UINT16 m_regs[(6<<3)+1+1];
- UINT8 m_num_follow;
- UINT8 m_cur_follow;
- UINT8 m_regs_follow[5];
- UINT8 m_read_num_follow;
- UINT8 m_read_cur_follow;
- UINT8 m_read_regs_follow[7];
- UINT8 m_status;
- UINT8 m_dma_enabled;
-
- UINT16 m_addressA;
- UINT16 m_addressB;
- UINT16 m_count;
-
- int m_rdy;
- int m_force_ready;
- UINT8 m_reset_pointer;
-
- bool m_is_read;
- UINT8 m_cur_cycle;
- UINT8 m_latch;
-
- // interrupts
- int m_ip; // interrupt pending
- int m_ius; // interrupt under service
- UINT8 m_vector; // interrupt vector
-};
-
-
-// device type definition
-extern const device_type Z80DMA;
-
-#endif
diff --git a/src/emu/machine/z80pio.c b/src/emu/machine/z80pio.c
deleted file mode 100644
index 6463adc8fb7..00000000000
--- a/src/emu/machine/z80pio.c
+++ /dev/null
@@ -1,809 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- Zilog Z80 Parallel Input/Output Controller implementation
-
-***************************************************************************/
-
-/*
-
- TODO:
-
- - if port A is bidirectional, port B does not issue interrupts in bit mode
-
-*/
-
-#include "emu.h"
-#include "z80pio.h"
-#include "cpu/z80/z80daisy.h"
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-// device type definition
-const device_type Z80PIO = &device_creator<z80pio_device>;
-
-//-------------------------------------------------
-// z80pio_device - constructor
-//-------------------------------------------------
-
-z80pio_device::z80pio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, Z80PIO, "Z80 PIO", tag, owner, clock, "z80pio", __FILE__),
- device_z80daisy_interface(mconfig, *this),
- m_out_int_cb(*this),
- m_in_pa_cb(*this),
- m_out_pa_cb(*this),
- m_out_ardy_cb(*this),
- m_in_pb_cb(*this),
- m_out_pb_cb(*this),
- m_out_brdy_cb(*this)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void z80pio_device::device_start()
-{
- m_port[PORT_A].start(this, PORT_A);
- m_port[PORT_B].start(this, PORT_B);
-
- // resolve callbacks
- m_out_int_cb.resolve_safe();
- m_in_pa_cb.resolve_safe(0);
- m_out_pa_cb.resolve_safe();
- m_out_ardy_cb.resolve_safe();
- m_in_pb_cb.resolve_safe(0);
- m_out_pb_cb.resolve_safe();
- m_out_brdy_cb.resolve_safe();
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void z80pio_device::device_reset()
-{
- // loop over ports
- for (int index = PORT_A; index < PORT_COUNT; index++)
- m_port[index].reset();
-}
-
-
-
-//**************************************************************************
-// DAISY CHAIN INTERFACE
-//**************************************************************************
-
-//-------------------------------------------------
-// z80daisy_irq_state - return the overall IRQ
-// state for this device
-//-------------------------------------------------
-
-int z80pio_device::z80daisy_irq_state()
-{
- int state = 0;
-
- for (int index = PORT_A; index < PORT_COUNT; index++)
- {
- pio_port &port = m_port[index];
-
- if (port.m_ius)
- {
- // interrupt under service
- return Z80_DAISY_IEO;
- }
- else if (port.m_ie && port.m_ip)
- {
- // interrupt pending
- state = Z80_DAISY_INT;
- }
- }
-
- return state;
-}
-
-
-//-------------------------------------------------
-// z80daisy_irq_ack - acknowledge an IRQ and
-// return the appropriate vector
-//-------------------------------------------------
-
-int z80pio_device::z80daisy_irq_ack()
-{
- for (int index = PORT_A; index < PORT_COUNT; index++)
- {
- pio_port &port = m_port[index];
-
- if (port.m_ip)
- {
- if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Acknowledge\n", tag(), 'A' + index);
-
- // clear interrupt pending flag
- port.m_ip = false;
-
- // set interrupt under service flag
- port.m_ius = true;
-
- check_interrupts();
-
- return port.m_vector;
- }
- }
-
- //logerror("z80pio_irq_ack: failed to find an interrupt to ack!\n");
-
- return 0;
-}
-
-
-//-------------------------------------------------
-// z80daisy_irq_reti - clear the interrupt
-// pending state to allow other interrupts through
-//-------------------------------------------------
-
-void z80pio_device::z80daisy_irq_reti()
-{
- for (int index = PORT_A; index < PORT_COUNT; index++)
- {
- pio_port &port = m_port[index];
-
- if (port.m_ius)
- {
- if (LOG) logerror("Z80PIO '%s' Port %c Return from Interrupt\n", tag(), 'A' + index);
-
- // clear interrupt under service flag
- port.m_ius = false;
- check_interrupts();
-
- return;
- }
- }
-
- //logerror("z80pio_irq_reti: failed to find an interrupt to clear IEO on!\n");
-}
-
-
-
-//**************************************************************************
-// READ/WRITE HANDLERS
-//**************************************************************************
-
-//-------------------------------------------------
-// read - register read
-//-------------------------------------------------
-
-READ8_MEMBER( z80pio_device::read )
-{
- int index = BIT(offset, 0);
- return BIT(offset, 1) ? control_read() : data_read(index);
-}
-
-//-------------------------------------------------
-// write - register write
-//-------------------------------------------------
-
-WRITE8_MEMBER( z80pio_device::write )
-{
- int index = BIT(offset, 0);
- BIT(offset, 1) ? control_write(index, data) : data_write(index, data);
-}
-
-//-------------------------------------------------
-// read_alt - register read
-//-------------------------------------------------
-
-READ8_MEMBER( z80pio_device::read_alt )
-{
- int index = BIT(offset, 1);
- return BIT(offset, 0) ? control_read() : data_read(index);
-}
-
-//-------------------------------------------------
-// write_alt - register write
-//-------------------------------------------------
-
-WRITE8_MEMBER( z80pio_device::write_alt )
-{
- int index = BIT(offset, 1);
- BIT(offset, 0) ? control_write(index, data) : data_write(index, data);
-}
-
-
-
-//**************************************************************************
-// DEVICE-LEVEL IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// control_read - control register read
-//-------------------------------------------------
-
-UINT8 z80pio_device::control_read()
-{
- return (m_port[PORT_A].m_icw & 0xc0) | (m_port[PORT_B].m_icw >> 4);
-}
-
-
-//-------------------------------------------------
-// check_interrupts - update the interrupt state
-// over all ports
-//-------------------------------------------------
-
-void z80pio_device::check_interrupts()
-{
- int state = CLEAR_LINE;
- bool ius = (m_port[PORT_A].m_ius || m_port[PORT_B].m_ius);
-
- for (int index = PORT_A; index < PORT_COUNT; index++)
- {
- if (LOG) logerror("Z80PIO '%s' Port %c IE %s IP %s IUS %s\n", tag(), 'A' + index, m_port[index].m_ie ? "1":"0", m_port[index].m_ip ? "1":"0", m_port[index].m_ius ? "1":"0");
-
- if (!ius && m_port[index].m_ie && m_port[index].m_ip)
- {
- state = ASSERT_LINE;
- }
- }
-
- if (LOG) logerror("Z80PIO '%s' INT %u\n", tag(), state);
-
- m_out_int_cb(state);
-}
-
-
-
-//**************************************************************************
-// PORT-LEVEL IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// pio_port - constructor
-//-------------------------------------------------
-
-z80pio_device::pio_port::pio_port() :
- m_device(NULL),
- m_index(0),
- m_mode(0),
- m_next_control_word(0),
- m_input(0),
- m_output(0),
- m_ior(0),
- m_rdy(false),
- m_stb(false),
- m_ie(false),
- m_ip(false),
- m_ius(false),
- m_icw(0),
- m_vector(0),
- m_mask(0),
- m_match(false)
-{
-}
-
-
-//-------------------------------------------------
-// start - set up a port during device startup
-//-------------------------------------------------
-
-void z80pio_device::pio_port::start(z80pio_device *device, int index)
-{
- m_device = device;
- m_index = index;
-
- // register for state saving
- m_device->save_item(NAME(m_mode), m_index);
- m_device->save_item(NAME(m_next_control_word), m_index);
- m_device->save_item(NAME(m_input), m_index);
- m_device->save_item(NAME(m_output), m_index);
- m_device->save_item(NAME(m_ior), m_index);
- m_device->save_item(NAME(m_rdy), m_index);
- m_device->save_item(NAME(m_stb), m_index);
- m_device->save_item(NAME(m_ie), m_index);
- m_device->save_item(NAME(m_ip), m_index);
- m_device->save_item(NAME(m_ius), m_index);
- m_device->save_item(NAME(m_icw), m_index);
- m_device->save_item(NAME(m_vector), m_index);
- m_device->save_item(NAME(m_mask), m_index);
- m_device->save_item(NAME(m_match), m_index);
-}
-
-
-//-------------------------------------------------
-// reset - reset a port during device reset
-//-------------------------------------------------
-
-void z80pio_device::pio_port::reset()
-{
- // set mode 1
- set_mode(MODE_INPUT);
-
- // reset interrupt enable flip-flops
- m_icw &= ~ICW_ENABLE_INT;
- m_ie = false;
- m_ip = false;
- m_ius = false;
- m_match = false;
-
- // reset all bits of the data I/O register
- m_ior = 0;
-
- // set all bits of the mask control register
- m_mask = 0xff;
-
- // reset output register
- m_output = 0;
-
- // clear ready line
- set_rdy(false);
-}
-
-
-//-------------------------------------------------
-// trigger_interrupt - trigger an interrupt from
-// this port
-//-------------------------------------------------
-
-void z80pio_device::pio_port::trigger_interrupt()
-{
- m_ip = true;
- if (LOG) logerror("Z80PIO '%s' Port %c Transfer Mode Interrupt Pending\n", m_device->tag(), 'A' + m_index);
-
- check_interrupts();
-}
-
-
-//-------------------------------------------------
-// set_rdy - set the port's RDY line
-//-------------------------------------------------
-
-void z80pio_device::pio_port::set_rdy(bool state)
-{
- if (m_rdy == state) return;
-
- if (LOG) logerror("Z80PIO '%s' Port %c Ready: %u\n", m_device->tag(), 'A' + m_index, state);
-
- m_rdy = state;
- if (m_index == PORT_A)
- m_device->m_out_ardy_cb(state);
- else
- m_device->m_out_brdy_cb(state);
-}
-
-
-//-------------------------------------------------
-// set_mode - set the port's mode
-//-------------------------------------------------
-
-void z80pio_device::pio_port::set_mode(int mode)
-{
- if (LOG) logerror("Z80PIO '%s' Port %c Mode: %u\n", m_device->tag(), 'A' + m_index, mode);
-
- switch (mode)
- {
- case MODE_OUTPUT:
- // enable data output
- if (m_index == PORT_A)
- m_device->m_out_pa_cb((offs_t)0, m_output);
- else
- m_device->m_out_pb_cb((offs_t)0, m_output);
-
- // assert ready line
- set_rdy(true);
-
- // set mode register
- m_mode = mode;
- break;
-
- case MODE_INPUT:
- // set mode register
- m_mode = mode;
- break;
-
- case MODE_BIDIRECTIONAL:
- if (m_index == PORT_B)
- {
- logerror("Z80PIO '%s' Port %c Invalid Mode: %u!\n", m_device->tag(), 'A' + m_index, mode);
- }
- else
- {
- // set mode register
- m_mode = mode;
- }
- break;
-
- case MODE_BIT_CONTROL:
- if ((m_index == PORT_A) || (m_device->m_port[PORT_A].m_mode != MODE_BIDIRECTIONAL))
- {
- // clear ready line
- set_rdy(false);
- }
-
- // disable interrupts until IOR is written
- m_ie = false;
- check_interrupts();
-
- // set logic equation to false
- m_match = false;
-
- // next word is I/O register
- m_next_control_word = IOR;
-
- // set mode register
- m_mode = mode;
- break;
- }
-}
-
-
-//-------------------------------------------------
-// strobe - strobe data in/out of the port
-//-------------------------------------------------
-
-void z80pio_device::pio_port::strobe(bool state)
-{
- if (LOG) logerror("Z80PIO '%s' Port %c Strobe: %u\n", m_device->tag(), 'A' + m_index, state);
-
- if (m_device->m_port[PORT_A].m_mode == MODE_BIDIRECTIONAL)
- {
- if (m_rdy) // port ready
- {
- if (m_stb && !state) // falling edge
- {
- if (m_index == PORT_A)
- m_device->m_out_pa_cb((offs_t)0, m_output);
- else
- m_device->m_port[PORT_A].m_input = m_device->m_in_pa_cb(0);
- }
- else if (!m_stb && state) // rising edge
- {
- trigger_interrupt();
-
- // clear ready line
- set_rdy(false);
- }
- }
- }
- else
- {
- switch (m_mode)
- {
- case MODE_OUTPUT:
- if (m_rdy)
- {
- if (!m_stb && state) // rising edge
- {
- trigger_interrupt();
-
- // clear ready line
- set_rdy(false);
- }
- }
- break;
-
- case MODE_INPUT:
- if (!state)
- {
- // input port data
- if (m_index == PORT_A)
- m_input = m_device->m_in_pa_cb(0);
- else
- m_input = m_device->m_in_pb_cb(0);
- }
- else if (!m_stb && state) // rising edge
- {
- trigger_interrupt();
-
- // clear ready line
- set_rdy(false);
- }
- break;
- }
- }
-
- m_stb = state;
-}
-
-
-//-------------------------------------------------
-// read - port I/O read
-//-------------------------------------------------
-
-UINT8 z80pio_device::pio_port::read()
-{
- UINT8 data = 0xff;
-
- switch (m_mode)
- {
- case MODE_OUTPUT:
- data = m_output;
- break;
-
- case MODE_BIDIRECTIONAL:
- if (m_index == PORT_A)
- data = m_output;
- break;
-
- case MODE_BIT_CONTROL:
- data = m_ior | (m_output & (m_ior ^ 0xff));
- break;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write - port I/O write
-//-------------------------------------------------
-
-void z80pio_device::pio_port::write(UINT8 data)
-{
- if (m_mode == MODE_BIT_CONTROL)
- {
- // latch data
- m_input = data;
-
- // fetch input data (ignore output lines)
- UINT8 data = (m_input & m_ior) | (m_output & ~m_ior);
- UINT8 mask = ~m_mask;
- bool match = false;
-
- data &= mask;
-
- if ((m_icw & 0x60) == 0 && data != mask) match = true;
- else if ((m_icw & 0x60) == 0x20 && data != 0) match = true;
- else if ((m_icw & 0x60) == 0x40 && data == 0) match = true;
- else if ((m_icw & 0x60) == 0x60 && data == mask) match = true;
-
- if (!m_match && match && !m_ius)
- {
- // trigger interrupt
- m_ip = true;
- if (LOG) logerror("Z80PIO '%s' Port %c Bit Control Mode Interrupt Pending\n", m_device->tag(), 'A' + m_index);
- }
-
- m_match = match;
-
- check_interrupts();
- }
-}
-
-
-//-------------------------------------------------
-// control_write - control register write
-//-------------------------------------------------
-
-void z80pio_device::pio_port::control_write(UINT8 data)
-{
- switch (m_next_control_word)
- {
- case ANY:
- if (!BIT(data, 0))
- {
- // load interrupt vector
- m_vector = data;
- if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Vector: %02x\n", m_device->tag(), 'A' + m_index, data);
-
- // set interrupt enable
- m_icw |= ICW_ENABLE_INT;
- m_ie = true;
- check_interrupts();
- }
- else
- {
- switch (data & 0x0f)
- {
- case 0x0f: // select operating mode
- set_mode(data >> 6);
- break;
-
- case 0x07: // set interrupt control word
- m_icw = data;
-
- if (LOG)
- {
- logerror("Z80PIO '%s' Port %c Interrupt Enable: %u\n", m_device->tag(), 'A' + m_index, BIT(data, 7));
- logerror("Z80PIO '%s' Port %c Logic: %s\n", m_device->tag(), 'A' + m_index, BIT(data, 6) ? "AND" : "OR");
- logerror("Z80PIO '%s' Port %c Active %s\n", m_device->tag(), 'A' + m_index, BIT(data, 5) ? "High" : "Low");
- logerror("Z80PIO '%s' Port %c Mask Follows: %u\n", m_device->tag(), 'A' + m_index, BIT(data, 4));
- }
-
- if (m_icw & ICW_MASK_FOLLOWS)
- {
- // disable interrupts until mask is written
- m_ie = false;
-
- // reset pending interrupts
- m_ip = false;
- check_interrupts();
-
- // set logic equation to false
- m_match = false;
-
- // next word is mask control
- m_next_control_word = MASK;
- }
- else
- {
- // set interrupt enable
- m_ie = BIT(m_icw, 7) ? true : false;
- check_interrupts();
- }
- break;
-
- case 0x03: // set interrupt enable flip-flop
- m_icw = (data & 0x80) | (m_icw & 0x7f);
- if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Enable: %u\n", m_device->tag(), 'A' + m_index, BIT(data, 7));
-
- // set interrupt enable
- m_ie = BIT(m_icw, 7) ? true : false;
- check_interrupts();
- break;
-
- default:
- logerror("Z80PIO '%s' Port %c Invalid Control Word: %02x!\n", m_device->tag(), 'A' + m_index, data);
- }
- }
- break;
-
- case IOR: // data direction register
- m_ior = data;
- if (LOG) logerror("Z80PIO '%s' Port %c IOR: %02x\n", m_device->tag(), 'A' + m_index, data);
-
- // set interrupt enable
- m_ie = BIT(m_icw, 7) ? true : false;
- check_interrupts();
-
- // next word is any
- m_next_control_word = ANY;
- break;
-
- case MASK: // interrupt mask
- m_mask = data;
- if (LOG) logerror("Z80PIO '%s' Port %c Mask: %02x\n", m_device->tag(), 'A' + m_index, data);
-
- // set interrupt enable
- m_ie = BIT(m_icw, 7) ? true : false;
- check_interrupts();
-
- // next word is any
- m_next_control_word = ANY;
- break;
- }
-}
-
-
-//-------------------------------------------------
-// data_read - data register read
-//-------------------------------------------------
-
-UINT8 z80pio_device::pio_port::data_read()
-{
- UINT8 data = 0;
-
- switch (m_mode)
- {
- case MODE_OUTPUT:
- data = m_output;
- break;
-
- case MODE_INPUT:
- if (!m_stb)
- {
- // input port data
- if (m_index == PORT_A)
- m_input = m_device->m_in_pa_cb(0);
- else
- m_input = m_device->m_in_pb_cb(0);
- }
-
- data = m_input;
-
- // clear ready line
- set_rdy(false);
-
- // assert ready line
- set_rdy(true);
- break;
-
- case MODE_BIDIRECTIONAL:
- data = m_input;
-
- // clear ready line
- m_device->m_port[PORT_B].set_rdy(false);
-
- // assert ready line
- m_device->m_port[PORT_B].set_rdy(true);
- break;
-
- case MODE_BIT_CONTROL:
- // input port data
- if (m_index == PORT_A)
- m_input = m_device->m_in_pa_cb(0);
- else
- m_input = m_device->m_in_pb_cb(0);
-
- data = (m_input & m_ior) | (m_output & (m_ior ^ 0xff));
- break;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// data_write - data register write
-//-------------------------------------------------
-
-void z80pio_device::pio_port::data_write(UINT8 data)
-{
- switch (m_mode)
- {
- case MODE_OUTPUT:
- // clear ready line
- set_rdy(false);
-
- // latch output data
- m_output = data;
-
- // output data to port
- if (m_index == PORT_A)
- m_device->m_out_pa_cb((offs_t)0, m_output);
- else
- m_device->m_out_pb_cb((offs_t)0, m_output);
-
- // assert ready line
- set_rdy(true);
- break;
-
- case MODE_INPUT:
- // latch output data
- m_output = data;
- break;
-
- case MODE_BIDIRECTIONAL:
- // clear ready line
- set_rdy(false);
-
- // latch output data
- m_output = data;
-
- if (!m_stb)
- {
- // output data to port
- if (m_index == PORT_A)
- m_device->m_out_pa_cb((offs_t)0, data);
- else
- m_device->m_out_pb_cb((offs_t)0, data);
- }
-
- // assert ready line
- set_rdy(true);
- break;
-
- case MODE_BIT_CONTROL:
- // latch output data
- m_output = data;
-
- // output data to port
- if (m_index == PORT_A)
- m_device->m_out_pa_cb((offs_t)0, m_ior | (m_output & (m_ior ^ 0xff)));
- else
- m_device->m_out_pb_cb((offs_t)0, m_ior | (m_output & (m_ior ^ 0xff)));
- break;
- }
-}
diff --git a/src/emu/machine/z80pio.h b/src/emu/machine/z80pio.h
deleted file mode 100644
index 80a458dd4fd..00000000000
--- a/src/emu/machine/z80pio.h
+++ /dev/null
@@ -1,260 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- Zilog Z80 Parallel Input/Output Controller implementation
-
-***************************************************************************
- _____ _____
- D2 1 |* \_/ | 40 D3
- D7 2 | | 39 D4
- D6 3 | | 38 D5
- _CE 4 | | 37 _M1
- C/_D 5 | | 36 _IORQ
- B/_A 6 | | 35 RD
- PA7 7 | | 34 PB7
- PA6 8 | | 33 PB6
- PA5 9 | | 32 PB5
- PA4 10 | Z8420 | 31 PB4
- GND 11 | | 30 PB3
- PA3 12 | | 29 PB2
- PA2 13 | | 28 PB1
- PA1 14 | | 27 PB0
- PA0 15 | | 26 +5V
- _ASTB 16 | | 25 CLK
- _BSTB 17 | | 24 IEI
- ARDY 18 | | 23 _INT
- D0 19 | | 22 IEO
- D1 20 |_____________| 21 BRDY
-
-***************************************************************************/
-
-#ifndef __Z80PIO__
-#define __Z80PIO__
-
-#include "cpu/z80/z80daisy.h"
-
-
-//**************************************************************************
-// DEVICE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_Z80PIO_OUT_INT_CB(_devcb) \
- devcb = &z80pio_device::set_out_int_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80PIO_IN_PA_CB(_devcb) \
- devcb = &z80pio_device::set_in_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80PIO_OUT_PA_CB(_devcb) \
- devcb = &z80pio_device::set_out_pa_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80PIO_OUT_ARDY_CB(_devcb) \
- devcb = &z80pio_device::set_out_ardy_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80PIO_IN_PB_CB(_devcb) \
- devcb = &z80pio_device::set_in_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80PIO_OUT_PB_CB(_devcb) \
- devcb = &z80pio_device::set_out_pb_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80PIO_OUT_BRDY_CB(_devcb) \
- devcb = &z80pio_device::set_out_brdy_callback(*device, DEVCB_##_devcb);
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-// ======================> z80pio_device
-
-class z80pio_device : public device_t,
- public device_z80daisy_interface
-{
-public:
- enum
- {
- PORT_A = 0,
- PORT_B,
- PORT_COUNT
- };
-
- // construction/destruction
- z80pio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_int_callback(device_t &device, _Object object) { return downcast<z80pio_device &>(device).m_out_int_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_pa_callback(device_t &device, _Object object) { return downcast<z80pio_device &>(device).m_in_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pa_callback(device_t &device, _Object object) { return downcast<z80pio_device &>(device).m_out_pa_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_ardy_callback(device_t &device, _Object object) { return downcast<z80pio_device &>(device).m_out_ardy_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_pb_callback(device_t &device, _Object object) { return downcast<z80pio_device &>(device).m_in_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_pb_callback(device_t &device, _Object object) { return downcast<z80pio_device &>(device).m_out_pb_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_brdy_callback(device_t &device, _Object object) { return downcast<z80pio_device &>(device).m_out_brdy_cb.set_callback(object); }
-
- // I/O line access
- int rdy(int which) { return m_port[which].rdy(); }
- void strobe(int which, bool state) { m_port[which].strobe(state); }
- DECLARE_READ_LINE_MEMBER( rdy_a ) { return rdy(PORT_A); }
- DECLARE_READ_LINE_MEMBER( rdy_b ) { return rdy(PORT_B); }
- DECLARE_WRITE_LINE_MEMBER( strobe_a ) { strobe(PORT_A, state); }
- DECLARE_WRITE_LINE_MEMBER( strobe_b ) { strobe(PORT_B, state); }
-
- // control register I/O
- UINT8 control_read();
- void control_write(int offset, UINT8 data) { m_port[offset & 1].control_write(data); }
- void control_a_write(UINT8 data) { control_write(PORT_A, data); }
- void control_b_write(UINT8 data) { control_write(PORT_B, data); }
-
- // data register I/O
- UINT8 data_read(int offset) { return m_port[offset & 1].data_read(); }
- void data_write(int offset, UINT8 data) { m_port[offset & 1].data_write(data); }
- UINT8 data_a_read() { return data_read(PORT_A); }
- UINT8 data_b_read() { return data_read(PORT_B); }
- void data_a_write(UINT8 data) { data_write(PORT_A, data); }
- void data_b_write(UINT8 data) { data_write(PORT_B, data); }
-
- // port I/O
- UINT8 port_read(int offset) { return m_port[offset & 1].read(); }
- void port_write(int offset, UINT8 data) { m_port[offset & 1].write(data); }
- void port_write(int offset, int bit, int state) { port_write(offset, (m_port[offset & 1].m_input & ~(1 << bit)) | (state << bit)); }
- UINT8 port_a_read() { return port_read(PORT_A); }
- UINT8 port_b_read() { return port_read(PORT_B); }
- void port_a_write(UINT8 data) { port_write(PORT_A, data); }
- void port_b_write(UINT8 data) { port_write(PORT_B, data); }
- DECLARE_WRITE8_MEMBER( pa_w ) { port_a_write(data); }
- DECLARE_READ8_MEMBER( pa_r ) { return port_a_read(); }
- DECLARE_WRITE8_MEMBER( pb_w ) { port_b_write(data); }
- DECLARE_READ8_MEMBER( pb_r ) { return port_b_read(); }
- DECLARE_WRITE_LINE_MEMBER( pa0_w ) { port_write(PORT_A, 0, state); }
- DECLARE_WRITE_LINE_MEMBER( pa1_w ) { port_write(PORT_A, 1, state); }
- DECLARE_WRITE_LINE_MEMBER( pa2_w ) { port_write(PORT_A, 2, state); }
- DECLARE_WRITE_LINE_MEMBER( pa3_w ) { port_write(PORT_A, 3, state); }
- DECLARE_WRITE_LINE_MEMBER( pa4_w ) { port_write(PORT_A, 4, state); }
- DECLARE_WRITE_LINE_MEMBER( pa5_w ) { port_write(PORT_A, 5, state); }
- DECLARE_WRITE_LINE_MEMBER( pa6_w ) { port_write(PORT_A, 6, state); }
- DECLARE_WRITE_LINE_MEMBER( pa7_w ) { port_write(PORT_A, 7, state); }
- DECLARE_WRITE_LINE_MEMBER( pb0_w ) { port_write(PORT_B, 0, state); }
- DECLARE_WRITE_LINE_MEMBER( pb1_w ) { port_write(PORT_B, 1, state); }
- DECLARE_WRITE_LINE_MEMBER( pb2_w ) { port_write(PORT_B, 2, state); }
- DECLARE_WRITE_LINE_MEMBER( pb3_w ) { port_write(PORT_B, 3, state); }
- DECLARE_WRITE_LINE_MEMBER( pb4_w ) { port_write(PORT_B, 4, state); }
- DECLARE_WRITE_LINE_MEMBER( pb5_w ) { port_write(PORT_B, 5, state); }
- DECLARE_WRITE_LINE_MEMBER( pb6_w ) { port_write(PORT_B, 6, state); }
- DECLARE_WRITE_LINE_MEMBER( pb7_w ) { port_write(PORT_B, 7, state); }
-
- // standard read/write, with C/D in bit 1, B/A in bit 0
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- // alternate read/write, with C/D in bit 0, B/A in bit 1
- DECLARE_READ8_MEMBER( read_alt );
- DECLARE_WRITE8_MEMBER( write_alt );
-
-private:
- enum
- {
- MODE_OUTPUT = 0,
- MODE_INPUT,
- MODE_BIDIRECTIONAL,
- MODE_BIT_CONTROL
- };
-
- enum
- {
- ANY = 0,
- IOR,
- MASK
- };
-
- enum
- {
- ICW_ENABLE_INT = 0x80,
- ICW_AND_OR = 0x40,
- ICW_AND = 0x40,
- ICW_OR = 0x00,
- ICW_HIGH_LOW = 0x20,
- ICW_HIGH = 0x20,
- ICW_LOW = 0x00,
- ICW_MASK_FOLLOWS = 0x10
- };
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
-
- // device_z80daisy_interface overrides
- virtual int z80daisy_irq_state();
- virtual int z80daisy_irq_ack();
- virtual void z80daisy_irq_reti();
-
- // internal helpers
- void check_interrupts();
-
- // a single PIO port
- class pio_port
- {
- friend class z80pio_device;
-
- public:
- pio_port();
-
- void start(z80pio_device *device, int index);
- void reset();
-
- void trigger_interrupt();
-
- int rdy() const { return m_rdy; }
- void set_rdy(bool state);
- void set_mode(int mode);
- void strobe(bool state);
-
- UINT8 read();
- void write(UINT8 data);
-
- void control_write(UINT8 data);
-
- UINT8 data_read();
- void data_write(UINT8 data);
-
- private:
- void check_interrupts() { m_device->check_interrupts(); }
-
- z80pio_device * m_device;
- int m_index;
-
- int m_mode; // mode register
- int m_next_control_word; // next control word
- UINT8 m_input; // input latch
- UINT8 m_output; // output latch
- UINT8 m_ior; // input/output register
- bool m_rdy; // ready
- bool m_stb; // strobe
-
- // interrupts
- bool m_ie; // interrupt enabled
- bool m_ip; // interrupt pending
- bool m_ius; // interrupt under service
- UINT8 m_icw; // interrupt control word
- UINT8 m_vector; // interrupt vector
- UINT8 m_mask; // interrupt mask
- bool m_match; // logic equation match
- };
-
- // internal state
- pio_port m_port[2];
- devcb_write_line m_out_int_cb;
-
- devcb_read8 m_in_pa_cb;
- devcb_write8 m_out_pa_cb;
- devcb_write_line m_out_ardy_cb;
-
- devcb_read8 m_in_pb_cb;
- devcb_write8 m_out_pb_cb;
- devcb_write_line m_out_brdy_cb;
-};
-
-
-// device type definition
-extern const device_type Z80PIO;
-
-
-#endif
diff --git a/src/emu/machine/z80sti.c b/src/emu/machine/z80sti.c
deleted file mode 100644
index a27295f6ff1..00000000000
--- a/src/emu/machine/z80sti.c
+++ /dev/null
@@ -1,720 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/***************************************************************************
-
- Mostek MK3801 Serial Timer Interrupt Controller (Z80-STI) emulation
-
-***************************************************************************/
-
-/*
-
- TODO:
-
- - timers (other than delay mode)
- - serial I/O
- - reset behavior
-
-*/
-
-#include "emu.h"
-#include "z80sti.h"
-#include "cpu/z80/z80.h"
-#include "cpu/z80/z80daisy.h"
-
-
-
-// device type definition
-const device_type Z80STI = &device_creator<z80sti_device>;
-
-
-
-//**************************************************************************
-// DEBUGGING
-//**************************************************************************
-
-#define VERBOSE 0
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-
-
-//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-// timer C/D control register
-//const int TCDC_TARS = 0x80;
-//const int TCDC_TBRS = 0x08;
-
-// interrupt vector register
-//const int PVR_ISE = 0x08;
-//const int PVR_VR4 = 0x10;
-
-// general purpose I/O interrupt levels
-const int z80sti_device::INT_LEVEL_GPIP[] =
-{
- IR_P0, IR_P1, IR_P2, IR_P3, IR_P4, IR_P5, IR_P6, IR_P7
-};
-
-// timer interrupt levels
-const int z80sti_device::INT_LEVEL_TIMER[] =
-{
- IR_TA, IR_TB, IR_TC, IR_TD
-};
-
-// interrupt vectors
-const UINT8 z80sti_device::INT_VECTOR[] =
-{
- 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e,
- 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e
-};
-
-// timer prescaler divisors
-const int z80sti_device::PRESCALER[] = { 0, 4, 10, 16, 50, 64, 100, 200 };
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// z80sti_device - constructor
-//-------------------------------------------------
-
-z80sti_device::z80sti_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, Z80STI, "Mostek MK3801", tag, owner, clock, "z80sti", __FILE__),
- device_serial_interface(mconfig, *this),
- device_z80daisy_interface(mconfig, *this),
- m_out_int_cb(*this),
- m_in_gpio_cb(*this),
- m_out_gpio_cb(*this),
- m_out_so_cb(*this),
- m_out_tao_cb(*this),
- m_out_tbo_cb(*this),
- m_out_tco_cb(*this),
- m_out_tdo_cb(*this),
- m_rx_clock(0),
- m_tx_clock(0),
- m_gpip(0),
- m_aer(0),
- m_ier(0),
- m_ipr(0),
- m_isr(0),
- m_imr(0)
-{
- for (int i = 0; i < 16; i++)
- {
- m_int_state[i] = 0;
- }
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void z80sti_device::device_start()
-{
- // resolve callbacks
- m_out_int_cb.resolve_safe();
- m_in_gpio_cb.resolve_safe(0);
- m_out_gpio_cb.resolve_safe();
- m_out_so_cb.resolve_safe();
- m_out_tao_cb.resolve_safe();
- m_out_tbo_cb.resolve_safe();
- m_out_tco_cb.resolve_safe();
- m_out_tdo_cb.resolve_safe();
-
- // create the counter timers
- m_timer[TIMER_A] = timer_alloc(TIMER_A);
- m_timer[TIMER_B] = timer_alloc(TIMER_B);
- m_timer[TIMER_C] = timer_alloc(TIMER_C);
- m_timer[TIMER_D] = timer_alloc(TIMER_D);
-
- // create serial receive clock timer
- if (m_rx_clock > 0)
- {
- set_rcv_rate(m_rx_clock);
- }
-
- // create serial transmit clock timer
- if (m_tx_clock > 0)
- {
- set_tra_rate(m_tx_clock);
- }
-
- // state saving
- save_item(NAME(m_gpip));
- save_item(NAME(m_aer));
- save_item(NAME(m_ddr));
- save_item(NAME(m_ier));
- save_item(NAME(m_ipr));
- save_item(NAME(m_isr));
- save_item(NAME(m_imr));
- save_item(NAME(m_pvr));
- save_item(NAME(m_int_state));
- save_item(NAME(m_tabc));
- save_item(NAME(m_tcdc));
- save_item(NAME(m_tdr));
- save_item(NAME(m_tmc));
- save_item(NAME(m_to));
- save_item(NAME(m_scr));
- save_item(NAME(m_ucr));
- save_item(NAME(m_rsr));
- save_item(NAME(m_tsr));
- save_item(NAME(m_udr));
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void z80sti_device::device_reset()
-{
- memset(m_tmc, 0, sizeof(m_tmc));
- memset(m_to, 0, sizeof(m_to));
-
- transmit_register_reset();
- receive_register_reset();
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void z80sti_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- timer_count(id);
-}
-
-
-//-------------------------------------------------
-// tra_callback -
-//-------------------------------------------------
-
-void z80sti_device::tra_callback()
-{
- m_out_so_cb(transmit_register_get_data_bit());
-}
-
-
-//-------------------------------------------------
-// tra_complete -
-//-------------------------------------------------
-
-void z80sti_device::tra_complete()
-{
- // TODO
-}
-
-
-//-------------------------------------------------
-// rcv_complete -
-//-------------------------------------------------
-
-void z80sti_device::rcv_complete()
-{
- // TODO
-}
-
-
-//**************************************************************************
-// DAISY CHAIN INTERFACE
-//**************************************************************************
-
-//-------------------------------------------------
-// z80daisy_irq_state - get interrupt status
-//-------------------------------------------------
-
-int z80sti_device::z80daisy_irq_state()
-{
- int state = 0, i;
-
- // loop over all interrupt sources
- for (i = 15; i >= 0; i--)
- {
- // if we're servicing a request, don't indicate more interrupts
- if (m_int_state[i] & Z80_DAISY_IEO)
- {
- state |= Z80_DAISY_IEO;
- break;
- }
-
- if (BIT(m_imr, i))
- {
- state |= m_int_state[i];
- }
- }
-
- LOG(("Z80STI '%s' Interrupt State: %u\n", tag(), state));
-
- return state;
-}
-
-
-//-------------------------------------------------
-// z80daisy_irq_ack - interrupt acknowledge
-//-------------------------------------------------
-
-int z80sti_device::z80daisy_irq_ack()
-{
- int i;
-
- // loop over all interrupt sources
- for (i = 15; i >= 0; i--)
- {
- // find the first channel with an interrupt requested
- if (m_int_state[i] & Z80_DAISY_INT)
- {
- UINT8 vector = (m_pvr & 0xe0) | INT_VECTOR[i];
-
- // clear interrupt, switch to the IEO state, and update the IRQs
- m_int_state[i] = Z80_DAISY_IEO;
-
- // clear interrupt pending register bit
- m_ipr &= ~(1 << i);
-
- // set interrupt in-service register bit
- m_isr |= (1 << i);
-
- check_interrupts();
-
- LOG(("Z80STI '%s' Interrupt Acknowledge Vector: %02x\n", tag(), vector));
-
- return vector;
- }
- }
-
- logerror("z80sti_irq_ack: failed to find an interrupt to ack!\n");
-
- return 0;
-}
-
-
-//-------------------------------------------------
-// z80daisy_irq_reti - return from interrupt
-//-------------------------------------------------
-
-void z80sti_device::z80daisy_irq_reti()
-{
- int i;
-
- LOG(("Z80STI '%s' Return from Interrupt\n", tag()));
-
- // loop over all interrupt sources
- for (i = 15; i >= 0; i--)
- {
- // find the first channel with an IEO pending
- if (m_int_state[i] & Z80_DAISY_IEO)
- {
- // clear the IEO state and update the IRQs
- m_int_state[i] &= ~Z80_DAISY_IEO;
-
- // clear interrupt in-service register bit
- m_isr &= ~(1 << i);
-
- check_interrupts();
- return;
- }
- }
-
- logerror("z80sti_irq_reti: failed to find an interrupt to clear IEO on!\n");
-}
-
-
-
-//**************************************************************************
-// IMPLEMENTATION
-//**************************************************************************
-
-//-------------------------------------------------
-// check_interrupts - set the interrupt request
-// line state
-//-------------------------------------------------
-
-void z80sti_device::check_interrupts()
-{
- if (m_ipr & m_imr)
- {
- m_out_int_cb(ASSERT_LINE);
- }
- else
- {
- m_out_int_cb(CLEAR_LINE);
- }
-}
-
-
-//-------------------------------------------------
-// take_interrupt - mark an interrupt pending
-//-------------------------------------------------
-
-void z80sti_device::take_interrupt(int level)
-{
- // set interrupt pending register bit
- m_ipr |= 1 << level;
-
- // trigger interrupt
- m_int_state[level] |= Z80_DAISY_INT;
-
- check_interrupts();
-}
-
-
-//-------------------------------------------------
-// read - register read
-//-------------------------------------------------
-
-READ8_MEMBER( z80sti_device::read )
-{
- UINT8 data = 0;
-
- switch (offset & 0x0f)
- {
- case REGISTER_IR:
- switch (m_pvr & 0x07)
- {
- case REGISTER_IR_SCR: data = m_scr; break;
- case REGISTER_IR_TDDR: data = m_tmc[TIMER_D]; break;
- case REGISTER_IR_TCDR: data = m_tmc[TIMER_C]; break;
- case REGISTER_IR_AER: data = m_aer; break;
- case REGISTER_IR_IERB: data = m_ier & 0xff; break;
- case REGISTER_IR_IERA: data = m_ier >> 8; break;
- case REGISTER_IR_DDR: data = m_ddr; break;
- case REGISTER_IR_TCDC: data = m_tcdc; break;
- }
- break;
-
- case REGISTER_GPIP: m_gpip = (m_in_gpio_cb(0) & ~m_ddr) | (m_gpip & m_ddr); data = m_gpip; break;
- case REGISTER_IPRB: data = m_ipr & 0xff; break;
- case REGISTER_IPRA: data = m_ipr >> 8; break;
- case REGISTER_ISRB: data = m_isr & 0xff; break;
- case REGISTER_ISRA: data = m_isr >> 8; break;
- case REGISTER_IMRB: data = m_imr & 0xff; break;
- case REGISTER_IMRA: data = m_imr >> 8; break;
- case REGISTER_PVR: data = m_pvr; break;
- case REGISTER_TABC: data = m_tabc; break;
- case REGISTER_TBDR: data = m_tmc[TIMER_B]; break;
- case REGISTER_TADR: data = m_tmc[TIMER_A]; break;
- case REGISTER_UCR: data = m_ucr; break;
- case REGISTER_RSR: data = m_rsr; break;
- case REGISTER_TSR: data = m_tsr; break;
- case REGISTER_UDR: data = m_udr; break;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write - register write
-//-------------------------------------------------
-
-WRITE8_MEMBER( z80sti_device::write )
-{
- switch (offset & 0x0f)
- {
- case REGISTER_IR:
- switch (m_pvr & 0x07)
- {
- case REGISTER_IR_SCR:
- LOG(("Z80STI '%s' Sync Character Register: %x\n", tag(), data));
- m_scr = data;
- break;
-
- case REGISTER_IR_TDDR:
- LOG(("Z80STI '%s' Timer D Data Register: %x\n", tag(), data));
- m_tdr[TIMER_D] = data;
- break;
-
- case REGISTER_IR_TCDR:
- LOG(("Z80STI '%s' Timer C Data Register: %x\n", tag(), data));
- m_tdr[TIMER_C] = data;
- break;
-
- case REGISTER_IR_AER:
- LOG(("Z80STI '%s' Active Edge Register: %x\n", tag(), data));
- m_aer = data;
- break;
-
- case REGISTER_IR_IERB:
- LOG(("Z80STI '%s' Interrupt Enable Register B: %x\n", tag(), data));
- m_ier = (m_ier & 0xff00) | data;
- check_interrupts();
- break;
-
- case REGISTER_IR_IERA:
- LOG(("Z80STI '%s' Interrupt Enable Register A: %x\n", tag(), data));
- m_ier = (data << 8) | (m_ier & 0xff);
- check_interrupts();
- break;
-
- case REGISTER_IR_DDR:
- LOG(("Z80STI '%s' Data Direction Register: %x\n", tag(), data));
- m_ddr = data;
- break;
-
- case REGISTER_IR_TCDC:
- {
- int tcc = PRESCALER[(data >> 4) & 0x07];
- int tdc = PRESCALER[data & 0x07];
-
- m_tcdc = data;
-
- LOG(("Z80STI '%s' Timer C Prescaler: %u\n", tag(), tcc));
- LOG(("Z80STI '%s' Timer D Prescaler: %u\n", tag(), tdc));
-
- if (tcc)
- m_timer[TIMER_C]->adjust(attotime::from_hz(clock() / tcc), TIMER_C, attotime::from_hz(clock() / tcc));
- else
- m_timer[TIMER_C]->enable(false);
-
- if (tdc)
- m_timer[TIMER_D]->adjust(attotime::from_hz(clock() / tdc), TIMER_D, attotime::from_hz(clock() / tdc));
- else
- m_timer[TIMER_D]->enable(false);
-
- if (BIT(data, 7))
- {
- LOG(("Z80STI '%s' Timer A Reset\n", tag()));
- m_to[TIMER_A] = 0;
-
- m_out_tao_cb(m_to[TIMER_A]);
- }
-
- if (BIT(data, 3))
- {
- LOG(("Z80STI '%s' Timer B Reset\n", tag()));
- m_to[TIMER_B] = 0;
-
- m_out_tbo_cb(m_to[TIMER_B]);
- }
- }
- break;
- }
- break;
-
- case REGISTER_GPIP:
- LOG(("Z80STI '%s' General Purpose I/O Register: %x\n", tag(), data));
- m_gpip = data & m_ddr;
- m_out_gpio_cb((offs_t)0, m_gpip);
- break;
-
- case REGISTER_IPRB:
- {
- int i;
- LOG(("Z80STI '%s' Interrupt Pending Register B: %x\n", tag(), data));
- m_ipr &= (m_ipr & 0xff00) | data;
-
- for (i = 0; i < 16; i++)
- {
- if (!BIT(m_ipr, i) && (m_int_state[i] == Z80_DAISY_INT)) m_int_state[i] = 0;
- }
-
- check_interrupts();
- }
- break;
-
- case REGISTER_IPRA:
- {
- int i;
- LOG(("Z80STI '%s' Interrupt Pending Register A: %x\n", tag(), data));
- m_ipr &= (data << 8) | (m_ipr & 0xff);
-
- for (i = 0; i < 16; i++)
- {
- if (!BIT(m_ipr, i) && (m_int_state[i] == Z80_DAISY_INT)) m_int_state[i] = 0;
- }
-
- check_interrupts();
- }
- break;
-
- case REGISTER_ISRB:
- LOG(("Z80STI '%s' Interrupt In-Service Register B: %x\n", tag(), data));
- m_isr &= (m_isr & 0xff00) | data;
- break;
-
- case REGISTER_ISRA:
- LOG(("Z80STI '%s' Interrupt In-Service Register A: %x\n", tag(), data));
- m_isr &= (data << 8) | (m_isr & 0xff);
- break;
-
- case REGISTER_IMRB:
- LOG(("Z80STI '%s' Interrupt Mask Register B: %x\n", tag(), data));
- m_imr = (m_imr & 0xff00) | data;
- m_isr &= m_imr;
- check_interrupts();
- break;
-
- case REGISTER_IMRA:
- LOG(("Z80STI '%s' Interrupt Mask Register A: %x\n", tag(), data));
- m_imr = (data << 8) | (m_imr & 0xff);
- m_isr &= m_imr;
- check_interrupts();
- break;
-
- case REGISTER_PVR:
- LOG(("Z80STI '%s' Interrupt Vector: %02x\n", tag(), data & 0xe0));
- LOG(("Z80STI '%s' IR Address: %01x\n", tag(), data & 0x07));
- m_pvr = data;
- break;
-
- case REGISTER_TABC:
- {
- int tac = PRESCALER[(data >> 4) & 0x07];
- int tbc = PRESCALER[data & 0x07];
-
- m_tabc = data;
-
- LOG(("Z80STI '%s' Timer A Prescaler: %u\n", tag(), tac));
- LOG(("Z80STI '%s' Timer B Prescaler: %u\n", tag(), tbc));
-
- if (tac)
- m_timer[TIMER_A]->adjust(attotime::from_hz(clock() / tac), TIMER_A, attotime::from_hz(clock() / tac));
- else
- m_timer[TIMER_A]->enable(false);
-
- if (tbc)
- m_timer[TIMER_B]->adjust(attotime::from_hz(clock() / tbc), TIMER_B, attotime::from_hz(clock() / tbc));
- else
- m_timer[TIMER_B]->enable(false);
- }
- break;
-
- case REGISTER_TBDR:
- LOG(("Z80STI '%s' Timer B Data Register: %x\n", tag(), data));
- m_tdr[TIMER_B] = data;
- break;
-
- case REGISTER_TADR:
- LOG(("Z80STI '%s' Timer A Data Register: %x\n", tag(), data));
- m_tdr[TIMER_A] = data;
- break;
-
- case REGISTER_UCR:
- LOG(("Z80STI '%s' USART Control Register: %x\n", tag(), data));
- m_ucr = data;
- break;
-
- case REGISTER_RSR:
- LOG(("Z80STI '%s' Receiver Status Register: %x\n", tag(), data));
- m_rsr = data;
- break;
-
- case REGISTER_TSR:
- LOG(("Z80STI '%s' Transmitter Status Register: %x\n", tag(), data));
- m_tsr = data;
- break;
-
- case REGISTER_UDR:
- LOG(("Z80STI '%s' USART Data Register: %x\n", tag(), data));
- m_udr = data;
- break;
- }
-}
-
-
-//-------------------------------------------------
-// timer_count - timer count down
-//-------------------------------------------------
-
-void z80sti_device::timer_count(int index)
-{
- if (m_tmc[index] == 0x01)
- {
- //LOG(("Z80STI '%s' Timer %c Expired\n", tag(), 'A' + index));
-
- // toggle timer output signal
- m_to[index] = !m_to[index];
-
- switch (index)
- {
- case TIMER_A:
- m_out_tao_cb(m_to[index]);
- break;
- case TIMER_B:
- m_out_tbo_cb(m_to[index]);
- break;
- case TIMER_C:
- m_out_tco_cb(m_to[index]);
- break;
- case TIMER_D:
- m_out_tdo_cb(m_to[index]);
- break;
- }
-
- if (m_ier & (1 << INT_LEVEL_TIMER[index]))
- {
- LOG(("Z80STI '%s' Interrupt Pending for Timer %c\n", tag(), 'A' + index));
-
- // signal timer elapsed interrupt
- take_interrupt(INT_LEVEL_TIMER[index]);
- }
-
- // load timer main counter
- m_tmc[index] = m_tdr[index];
- }
- else
- {
- // count down
- m_tmc[index]--;
- }
-}
-
-
-//-------------------------------------------------
-// gpip_input - GPIP input line write
-//-------------------------------------------------
-
-void z80sti_device::gpip_input(int bit, int state)
-{
- int aer = BIT(m_aer, bit);
- int old_state = BIT(m_gpip, bit);
-
- if ((old_state ^ aer) && !(state ^ aer))
- {
- LOG(("Z80STI '%s' Edge Transition Detected on Bit: %u\n", tag(), bit));
-
- if (m_ier & (1 << INT_LEVEL_GPIP[bit]))
- {
- LOG(("Z80STI '%s' Interrupt Pending for P%u\n", tag(), bit));
-
- take_interrupt(INT_LEVEL_GPIP[bit]);
- }
- }
-
- m_gpip = (m_gpip & ~(1 << bit)) | (state << bit);
-}
-
-WRITE_LINE_MEMBER( z80sti_device::i0_w ) { gpip_input(0, state); }
-WRITE_LINE_MEMBER( z80sti_device::i1_w ) { gpip_input(1, state); }
-WRITE_LINE_MEMBER( z80sti_device::i2_w ) { gpip_input(2, state); }
-WRITE_LINE_MEMBER( z80sti_device::i3_w ) { gpip_input(3, state); }
-WRITE_LINE_MEMBER( z80sti_device::i4_w ) { gpip_input(4, state); }
-WRITE_LINE_MEMBER( z80sti_device::i5_w ) { gpip_input(5, state); }
-WRITE_LINE_MEMBER( z80sti_device::i6_w ) { gpip_input(6, state); }
-WRITE_LINE_MEMBER( z80sti_device::i7_w ) { gpip_input(7, state); }
-
-
-//-------------------------------------------------
-// rc_w - receiver clock
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( z80sti_device::rc_w )
-{
- rx_clock_w(state);
-}
-
-
-//-------------------------------------------------
-// tc_w - transmitter clock
-//-------------------------------------------------
-
-WRITE_LINE_MEMBER( z80sti_device::tc_w )
-{
- tx_clock_w(state);
-}
diff --git a/src/emu/machine/z80sti.h b/src/emu/machine/z80sti.h
deleted file mode 100644
index 1691695147c..00000000000
--- a/src/emu/machine/z80sti.h
+++ /dev/null
@@ -1,250 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Mostek MK3801 Serial Timer Interrupt Controller (Z80-STI) emulation
-
-**********************************************************************
- _____ _____
- TAO 1 |* \_/ | 40 Vcc
- TBO 2 | | 39 RC
- TCO 3 | | 38 SI
- TDO 4 | | 37 SO
- TCK 5 | | 36 TC
- _M1 6 | | 35 A0
- _RES 7 | | 34 A1
- I0 8 | | 33 A2
- I1 9 | | 32 A3
- I2 10 | MK3801 | 31 _WR
- I3 11 | Z80-STI | 30 _CE
- I4 12 | | 29 _RD
- I5 13 | | 28 D7
- I6 14 | | 27 D6
- I7 15 | | 26 D5
- IEI 16 | | 25 D4
- _INT 17 | | 24 D3
- IEO 18 | | 23 D2
- _IORQ 19 | | 22 D1
- Vss 20 |_____________| 21 D0
-
-**********************************************************************/
-
-#ifndef __Z80STI__
-#define __Z80STI__
-
-#include "cpu/z80/z80daisy.h"
-
-
-//**************************************************************************
-// DEVICE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_Z80STI_RXCLOCK(_clock) \
- z80sti_device::set_rx_clock(*device, _clock);
-
-#define MCFG_Z80STI_TXCLOCK(_clock) \
- z80sti_device::set_tx_clock(*device, _clock);
-
-#define MCFG_Z80STI_OUT_INT_CB(_devcb) \
- devcb = &z80sti_device::set_out_int_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80STI_IN_GPIO_CB(_devcb) \
- devcb = &z80sti_device::set_in_gpio_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80STI_OUT_GPIO_CB(_devcb) \
- devcb = &z80sti_device::set_out_gpio_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80STI_OUT_SO_CB(_devcb) \
- devcb = &z80sti_device::set_out_so_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80STI_OUT_TAO_CB(_devcb) \
- devcb = &z80sti_device::set_out_tao_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80STI_OUT_TBO_CB(_devcb) \
- devcb = &z80sti_device::set_out_tbo_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80STI_OUT_TCO_CB(_devcb) \
- devcb = &z80sti_device::set_out_tco_callback(*device, DEVCB_##_devcb);
-
-#define MCFG_Z80STI_OUT_TDO_CB(_devcb) \
- devcb = &z80sti_device::set_out_tdo_callback(*device, DEVCB_##_devcb);
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> z80sti_device
-
-class z80sti_device : public device_t,
- public device_serial_interface,
- public device_z80daisy_interface
-{
-public:
- // construction/destruction
- z80sti_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_out_int_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_int_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_in_gpio_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_in_gpio_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_gpio_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_gpio_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_so_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_so_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_tao_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_tao_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_tbo_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_tbo_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_tco_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_tco_cb.set_callback(object); }
- template<class _Object> static devcb_base &set_out_tdo_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_tdo_cb.set_callback(object); }
-
- static void set_rx_clock(device_t &device, int clock) { downcast<z80sti_device &>(device).m_rx_clock = clock; }
- static void set_tx_clock(device_t &device, int clock) { downcast<z80sti_device &>(device).m_tx_clock = clock; }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( i0_w );
- DECLARE_WRITE_LINE_MEMBER( i1_w );
- DECLARE_WRITE_LINE_MEMBER( i2_w );
- DECLARE_WRITE_LINE_MEMBER( i3_w );
- DECLARE_WRITE_LINE_MEMBER( i4_w );
- DECLARE_WRITE_LINE_MEMBER( i5_w );
- DECLARE_WRITE_LINE_MEMBER( i6_w );
- DECLARE_WRITE_LINE_MEMBER( i7_w );
-
- DECLARE_WRITE_LINE_MEMBER( tc_w );
- DECLARE_WRITE_LINE_MEMBER( rc_w );
-
-private:
- enum
- {
- TIMER_A = 0,
- TIMER_B,
- TIMER_C,
- TIMER_D
- };
-
- enum
- {
- REGISTER_IR = 0,
- REGISTER_GPIP,
- REGISTER_IPRB,
- REGISTER_IPRA,
- REGISTER_ISRB,
- REGISTER_ISRA,
- REGISTER_IMRB,
- REGISTER_IMRA,
- REGISTER_PVR,
- REGISTER_TABC,
- REGISTER_TBDR,
- REGISTER_TADR,
- REGISTER_UCR,
- REGISTER_RSR,
- REGISTER_TSR,
- REGISTER_UDR
- };
-
- enum
- {
- REGISTER_IR_SCR = 0,
- REGISTER_IR_TDDR,
- REGISTER_IR_TCDR,
- REGISTER_IR_AER,
- REGISTER_IR_IERB,
- REGISTER_IR_IERA,
- REGISTER_IR_DDR,
- REGISTER_IR_TCDC
- };
-
- enum
- {
- IR_P0 = 0,
- IR_P1,
- IR_P2,
- IR_P3,
- IR_TD,
- IR_TC,
- IR_P4,
- IR_P5,
- IR_TB,
- IR_XE,
- IR_XB,
- IR_RE,
- IR_RB,
- IR_TA,
- IR_P6,
- IR_P7
- };
-
- static const int INT_LEVEL_GPIP[];
- static const int INT_LEVEL_TIMER[];
- static const UINT8 INT_VECTOR[];
- static const int PRESCALER[];
-
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_serial_interface overrides
- virtual void tra_callback();
- virtual void tra_complete();
- virtual void rcv_complete();
-
- // device_z80daisy_interface overrides
- virtual int z80daisy_irq_state();
- virtual int z80daisy_irq_ack();
- virtual void z80daisy_irq_reti();
-
- // internal helpers
- void check_interrupts();
- void take_interrupt(int level);
- void timer_count(int index);
- void gpip_input(int bit, int state);
-
- // device callbacks
- devcb_write_line m_out_int_cb; // this gets called on each change of the _INT pin (pin 17)
- devcb_read8 m_in_gpio_cb; // this is called on each read of the GPIO pins
- devcb_write8 m_out_gpio_cb; // this is called on each write of the GPIO pins
- devcb_write_line m_out_so_cb; // this gets called for each change of the SO pin (pin 37)
- devcb_write_line m_out_tao_cb; // this gets called for each change of the TAO pin (pin 1)
- devcb_write_line m_out_tbo_cb; // this gets called for each change of the TBO pin (pin 2)
- devcb_write_line m_out_tco_cb; // this gets called for each change of the TCO pin (pin 3)
- devcb_write_line m_out_tdo_cb; // this gets called for each change of the TDO pin (pin 4)
-
- int m_rx_clock; // serial receive clock
- int m_tx_clock; // serial transmit clock
-
- // I/O state
- UINT8 m_gpip; // general purpose I/O register
- UINT8 m_aer; // active edge register
- UINT8 m_ddr; // data direction register
-
- // interrupt state
- UINT16 m_ier; // interrupt enable register
- UINT16 m_ipr; // interrupt pending register
- UINT16 m_isr; // interrupt in-service register
- UINT16 m_imr; // interrupt mask register
- UINT8 m_pvr; // interrupt vector register
- int m_int_state[16]; // interrupt state
-
- // timer state
- UINT8 m_tabc; // timer A/B control register
- UINT8 m_tcdc; // timer C/D control register
- UINT8 m_tdr[4]; // timer data registers
- UINT8 m_tmc[4]; // timer main counters
- int m_to[4]; // timer out latch
-
- // serial state
- UINT8 m_scr; // synchronous character register
- UINT8 m_ucr; // USART control register
- UINT8 m_tsr; // transmitter status register
- UINT8 m_rsr; // receiver status register
- UINT8 m_udr; // USART data register
-
- // timers
- emu_timer *m_timer[4]; // counter timers
-};
-
-
-// device type definition
-extern const device_type Z80STI;
-
-
-
-#endif
diff --git a/src/emu/machine/z8536.c b/src/emu/machine/z8536.c
deleted file mode 100644
index fc5e770b15a..00000000000
--- a/src/emu/machine/z8536.c
+++ /dev/null
@@ -1,1123 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Zilog Z8536 Counter/Timer and Parallel I/O emulation
-
-**********************************************************************/
-
-/*
-
- TODO:
-
- - interrupts
- - vector
- - status affects vector
- - IE/IP/IUS
- - acknowledge
- - daisy chain
- - port I/O
- - counters/timers
-
-*/
-
-#include "emu.h"
-#include "z8536.h"
-
-
-// device type definition
-const device_type Z8536 = &device_creator<z8536_device>;
-
-
-//**************************************************************************
-// MACROS / CONSTANTS
-//**************************************************************************
-
-#define LOG 0
-
-
-static const char *PMS_PTS[] = { "Bit", "Input", "Output", "Bidirectional" };
-static const char *PMS_PMS[] = { "Disabled", "AND", "OR", "OR-PEV" };
-static const char *CTMS_DCS[] = { "Pulse", "One-shot", "Square Wave", "Do not use" };
-
-
-// master interrupt control register
-#define MICR_RESET 0x01 // reset
-#define MICR_RJA 0x02 // right justified address
-#define MICR_CT_VIS 0x04 // counter/timer vector includes status
-#define MICR_PB_VIS 0x08 // port B vector includes status
-#define MICR_PA_VIS 0x10 // port A vector includes status
-#define MICR_NV 0x20 // no vector
-#define MICR_DLC 0x40 // disable lower chain
-#define MICR_MIE 0x80 // master interrupt enable
-
-
-// master configuration control register
-#define MCCR_LC_MASK 0x03 // counter/timer link controls
-#define MCCR_PAE 0x04 // port A enable
-#define MCCR_PLC 0x08 // port link control
-#define MCCR_PCE_CT3E 0x10 // port C and counter/timer 3 enable
-#define MCCR_CT2E 0x20 // counter/timer 2 enable
-#define MCCR_CT1E 0x40 // counter/timer 1 enable
-#define MCCR_PBE 0x80 // port B enable
-
-
-// port mode specification registers
-#define PMS_LPM 0x01 // latch on pattern match
-#define PMS_DTE 0x01 // deskew timer enable
-#define PMS_PMS_MASK 0x06 // pattern mode specification
-#define PMS_IMO 0x08 // interrupt on match only
-#define PMS_SB 0x10 // single buffer
-#define PMS_ITB 0x20 // interrupt on two bytes
-#define PMS_PTS_MASK 0xc0 // port type select
-
-
-// port handshake specification registers
-#define PHS_DTS_MASK 0x07 // deskew time specification
-#define PHS_RWS_MASK 0x38 // request/wait specification
-#define PHS_HTS_MASK 0xc0 // handshake type specification
-
-
-// port command and status registers
-#define PCS_IOE 0x01 // interrupt on error
-#define PCS_PMF 0x02 // pattern match flag (read only)
-#define PCS_IRF 0x04 // input register full (read only)
-#define PCS_ORE 0x08 // output register empty (read only)
-#define PCS_ERR 0x10 // interrupt error (read only)
-#define PCS_IP 0x20 // interrupt pending
-#define PCS_IE 0x40 // interrupt enable
-#define PCS_IUS 0x80 // interrupt under service
-
-
-// counter/timer mode specification registers
-#define CTMS_DCS_MASK 0x03 // output duty cycle
-#define CTMS_REB 0x04 // retrigger enable bit
-#define CTMS_EDE 0x08 // external gate enable
-#define CTMS_ETE 0x10 // external trigger enable
-#define CTMS_ECE 0x20 // external count enable
-#define CTMS_EOE 0x40 // external output enable
-#define CTMS_CSC 0x80 // continuous/single cycle
-
-
-// counter/timer command and status registers
-#define CTCS_CIP 0x01 // count in progress (read only)
-#define CTCS_TCB 0x02 // trigger command bit (write only - read returns 0)
-#define CTCS_GCB 0x04 // gate command bit
-#define CTCS_RCC 0x08 // read counter control (read/set only - cleared by reading CCR LSB)
-#define CTCS_ERR 0x10 // interrupt error (read only)
-#define CTCS_IP 0x20 // interrupt pending
-#define CTCS_IE 0x40 // interrupt enable
-#define CTCS_IUS 0x80 // interrupt under service
-
-
-
-//**************************************************************************
-// INLINE HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// get_interrupt_vector -
-//-------------------------------------------------
-
-void z8536_device::get_interrupt_vector()
-{
- UINT8 vector = 0xff;
-
- if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_MIE)
- {
- if ((m_register[COUNTER_TIMER_3_COMMAND_AND_STATUS] & (CTCS_IP | CTCS_IE | CTCS_IUS)) == (CTCS_IP | CTCS_IE))
- {
- vector = m_register[COUNTER_TIMER_INTERRUPT_VECTOR];
-
- if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_CT_VIS)
- {
- vector = (vector & 0xf9) | 0;
- }
- }
- else if ((m_register[PORT_A_COMMAND_AND_STATUS] & (PCS_IP | PCS_IE | PCS_IUS)) == (PCS_IP | PCS_IE))
- {
- vector = m_register[PORT_A_INTERRUPT_VECTOR];
-
- if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_PA_VIS)
- {
- vector &= 0xf1;
-
- if (((m_register[PORT_A_MODE_SPECIFICATION] & PMS_PMS_MASK) >> 1) == PMS_OR_PEV)
- {
- if (m_match[PORT_A] & 0x80) vector |= 7 << 1;
- else if (m_match[PORT_A] & 0x40) vector |= 6 << 1;
- else if (m_match[PORT_A] & 0x20) vector |= 5 << 1;
- else if (m_match[PORT_A] & 0x10) vector |= 4 << 1;
- else if (m_match[PORT_A] & 0x08) vector |= 3 << 1;
- else if (m_match[PORT_A] & 0x04) vector |= 2 << 1;
- else if (m_match[PORT_A] & 0x02) vector |= 1 << 1;
- else if (m_match[PORT_A] & 0x01) vector |= 0 << 1;
- }
- else
- {
- vector |= (m_register[PORT_A_COMMAND_AND_STATUS] & 0x0e);
- }
- }
- }
- else if ((m_register[COUNTER_TIMER_2_COMMAND_AND_STATUS] & (CTCS_IP | CTCS_IE | CTCS_IUS)) == (CTCS_IP | CTCS_IE))
- {
- vector = m_register[COUNTER_TIMER_INTERRUPT_VECTOR];
-
- if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_CT_VIS)
- {
- vector = (vector & 0xf9) | 2;
- }
- }
- else if ((m_register[PORT_B_COMMAND_AND_STATUS] & (PCS_IP | PCS_IE | PCS_IUS)) == (PCS_IP | PCS_IE))
- {
- vector = m_register[PORT_B_INTERRUPT_VECTOR];
-
- if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_PB_VIS)
- {
- vector &= 0xf1;
-
- if (((m_register[PORT_B_MODE_SPECIFICATION] & PMS_PMS_MASK) >> 1) == PMS_OR_PEV)
- {
- if (m_match[PORT_B] & 0x80) vector |= 7 << 1;
- else if (m_match[PORT_B] & 0x40) vector |= 6 << 1;
- else if (m_match[PORT_B] & 0x20) vector |= 5 << 1;
- else if (m_match[PORT_B] & 0x10) vector |= 4 << 1;
- else if (m_match[PORT_B] & 0x08) vector |= 3 << 1;
- else if (m_match[PORT_B] & 0x04) vector |= 2 << 1;
- else if (m_match[PORT_B] & 0x02) vector |= 1 << 1;
- else if (m_match[PORT_B] & 0x01) vector |= 0 << 1;
- }
- else
- {
- vector |= (m_register[PORT_B_COMMAND_AND_STATUS] & 0x0e);
- }
- }
- }
- else if ((m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS] & (CTCS_IP | CTCS_IE | CTCS_IUS)) == (CTCS_IP | CTCS_IE))
- {
- vector = m_register[COUNTER_TIMER_INTERRUPT_VECTOR];
-
- if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_CT_VIS)
- {
- vector = (vector & 0xf9) | 4;
- }
- }
- }
-
- m_register[CURRENT_VECTOR] = vector;
-}
-
-
-//-------------------------------------------------
-// check_interrupt - check interrupt status
-//-------------------------------------------------
-
-void z8536_device::check_interrupt()
-{
- int state = ASSERT_LINE;
-
- if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_MIE)
- {
- if (((m_register[COUNTER_TIMER_3_COMMAND_AND_STATUS] & (CTCS_IP | CTCS_IE | CTCS_IUS)) == (CTCS_IP | CTCS_IE)) ||
- ((m_register[PORT_A_COMMAND_AND_STATUS] & (PCS_IP | PCS_IE | PCS_IUS)) == (PCS_IP | PCS_IE)) ||
- ((m_register[COUNTER_TIMER_2_COMMAND_AND_STATUS] & (CTCS_IP | CTCS_IE | CTCS_IUS)) == (CTCS_IP | CTCS_IE)) ||
- ((m_register[PORT_B_COMMAND_AND_STATUS] & (PCS_IP | PCS_IE | PCS_IUS)) == (PCS_IP | PCS_IE)) ||
- ((m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS] & (CTCS_IP | CTCS_IE | CTCS_IUS)) == (CTCS_IP | CTCS_IE)))
- {
- state = ASSERT_LINE;
- }
- else
- {
- state = CLEAR_LINE;
- }
- }
- else
- {
- state = CLEAR_LINE;
- }
-
- if (m_irq != state)
- {
- if (LOG) logerror("%s Z8536 '%s' Interrupt: %u\n", machine().describe_context(), tag(), state);
- m_irq = state;
- m_write_irq(state);
- }
-}
-
-
-//-------------------------------------------------
-// read_register - read from register
-//-------------------------------------------------
-
-UINT8 z8536_device::read_register(offs_t offset)
-{
- UINT8 data = 0;
-
- switch (offset)
- {
- case PORT_A_DATA:
- data = m_read_pa(0);
- break;
-
- case PORT_B_DATA:
- data = m_read_pb(0);
- break;
-
- case PORT_C_DATA:
- data = 0xf0 | (m_read_pc(0) & 0x0f);
- break;
-
- case COUNTER_TIMER_1_CURRENT_COUNT_MS_BYTE:
- case COUNTER_TIMER_2_CURRENT_COUNT_MS_BYTE:
- case COUNTER_TIMER_3_CURRENT_COUNT_MS_BYTE:
- {
- int timer = (offset - COUNTER_TIMER_1_CURRENT_COUNT_MS_BYTE) >> 1;
-
- if (m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + timer] & CTCS_RCC)
- {
- // read frozen value
- data = m_register[offset];
- }
- else
- {
- // read current count
- data = m_counter[timer] >> 8;
- }
- }
- break;
-
- case COUNTER_TIMER_1_CURRENT_COUNT_LS_BYTE:
- case COUNTER_TIMER_2_CURRENT_COUNT_LS_BYTE:
- case COUNTER_TIMER_3_CURRENT_COUNT_LS_BYTE:
- {
- int timer = (offset - COUNTER_TIMER_1_CURRENT_COUNT_MS_BYTE) >> 1;
-
- if (m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + timer] & CTCS_RCC)
- {
- // read frozen value
- data = m_register[offset];
- }
- else
- {
- // read current count
- data = m_counter[timer] & 0xff;
- }
-
- // clear RCC bit
- m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + timer] &= ~CTCS_RCC;
- }
- break;
-
- case CURRENT_VECTOR:
- get_interrupt_vector();
- data = m_register[offset];
- break;
-
- default:
- data = m_register[offset];
- break;
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// read_register - masked read from register
-//-------------------------------------------------
-
-UINT8 z8536_device::read_register(offs_t offset, UINT8 mask)
-{
- return read_register(offset) & mask;
-}
-
-
-//-------------------------------------------------
-// write_register - write to register
-//-------------------------------------------------
-
-void z8536_device::write_register(offs_t offset, UINT8 data)
-{
- switch (offset)
- {
- case MASTER_INTERRUPT_CONTROL:
- if (data & MICR_RESET)
- {
- if (LOG) logerror("%s Z8536 '%s' Reset\n", machine().describe_context(), tag());
- device_reset();
- }
- else
- {
- if (m_state == STATE_RESET)
- {
- m_state = STATE_0;
- }
-
- if (LOG)
- {
- if (LOG) logerror("%s Z8536 '%s' Master Interrupt Enable: %u\n", machine().describe_context(), tag(), (data & MICR_MIE) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Disable Lower Chain: %u\n", machine().describe_context(), tag(), (data & MICR_DLC) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' No Vector: %u\n", machine().describe_context(), tag(), (data & MICR_NV) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Port A Vector Includes Status: %u\n", machine().describe_context(), tag(), (data & MICR_PA_VIS) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Port B Vector Includes Status: %u\n", machine().describe_context(), tag(), (data & MICR_PB_VIS) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer Vector Includes Status: %u\n", machine().describe_context(), tag(), (data & MICR_CT_VIS) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Right Justified Address: %u\n", machine().describe_context(), tag(), (data & MICR_RJA) ? 1 : 0);
- }
-
- m_register[offset] = data;
- }
- break;
-
- case MASTER_CONFIGURATION_CONTROL:
- if (LOG)
- {
- if (LOG) logerror("%s Z8536 '%s' Port B Enable: %u\n", machine().describe_context(), tag(), (data & MCCR_PBE) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer 1 Enable: %u\n", machine().describe_context(), tag(), (data & MCCR_CT1E) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer 2 Enable: %u\n", machine().describe_context(), tag(), (data & MCCR_CT2E) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Port C and Counter/Timer 3 Enable: %u\n", machine().describe_context(), tag(), (data & MCCR_PCE_CT3E) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Port A Enable: %u\n", machine().describe_context(), tag(), (data & MCCR_PAE) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Port Link Control: %u\n", machine().describe_context(), tag(), (data & MCCR_PLC) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer Link Controls: %u\n", machine().describe_context(), tag(), data & MCCR_LC_MASK);
- }
-
- m_register[offset] = data;
-
- for (int counter = 0; counter < 3; counter++)
- {
- // clear RCC bit if counter disabled
- if (!counter_enabled(counter)) m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + counter] &= ~CTCS_RCC;
- }
- break;
-
- case PORT_A_INTERRUPT_VECTOR:
- if (LOG) logerror("%s Z8536 '%s' Port A Interrupt Vector: %02x\n", machine().describe_context(), tag(), data);
- m_register[offset] = data;
- break;
-
- case PORT_B_INTERRUPT_VECTOR:
- if (LOG) logerror("%s Z8536 '%s' Port B Interrupt Vector: %02x\n", machine().describe_context(), tag(), data);
- m_register[offset] = data;
- break;
-
- case COUNTER_TIMER_INTERRUPT_VECTOR:
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer Interrupt Vector: %02x\n", machine().describe_context(), tag(), data);
- m_register[offset] = data;
- break;
-
- case PORT_C_DATA_PATH_POLARITY:
- if (LOG) logerror("%s Z8536 '%s' Port C Data Path Polarity: %02x\n", machine().describe_context(), tag(), data);
- m_register[offset] = data;
- break;
-
- case PORT_C_DATA_DIRECTION:
- if (LOG) logerror("%s Z8536 '%s' Port C Data Direction: %02x\n", machine().describe_context(), tag(), data);
- m_register[offset] = data;
- break;
-
- case PORT_C_SPECIAL_IO_CONTROL:
- if (LOG) logerror("%s Z8536 '%s' Port C Special I/O Control: %02x\n", machine().describe_context(), tag(), data);
- m_register[offset] = data;
- break;
-
- case PORT_A_COMMAND_AND_STATUS:
- case PORT_B_COMMAND_AND_STATUS:
- {
- char port = 'A' + offset - PORT_A_COMMAND_AND_STATUS;
-
- if (LOG) logerror("%s Z8536 '%s' Port %c Interrupt on Error: %u\n", machine().describe_context(), tag(), port, (data & PCS_IOE) ? 1 : 0);
-
- switch (data >> 5)
- {
- case IC_CLEAR_IP_IUS: m_register[offset] &= ~(PCS_IP | PCS_IUS); if (LOG) logerror("%s Z8536 '%s' Port %c Clear IP/IUS\n", machine().describe_context(), tag(), port); break;
- case IC_SET_IUS: m_register[offset] |= PCS_IUS; if (LOG) logerror("%s Z8536 '%s' Port %c Set IUS\n", machine().describe_context(), tag(), port); break;
- case IC_CLEAR_IUS: m_register[offset] &= ~PCS_IUS; if (LOG) logerror("%s Z8536 '%s' Port %c Clear IUS\n", machine().describe_context(), tag(), port); break;
- case IC_SET_IP: m_register[offset] |= PCS_IP; if (LOG) logerror("%s Z8536 '%s' Port %c Set IP\n", machine().describe_context(), tag(), port); break;
- case IC_CLEAR_IP: m_register[offset] &= ~PCS_IP; if (LOG) logerror("%s Z8536 '%s' Port %c Clear IP\n", machine().describe_context(), tag(), port); break;
- case IC_SET_IE: m_register[offset] |= PCS_IE; if (LOG) logerror("%s Z8536 '%s' Port %c Set IE\n", machine().describe_context(), tag(), port); break;
- case IC_CLEAR_IE: m_register[offset] &= ~PCS_IE; if (LOG) logerror("%s Z8536 '%s' Port %c Clear IE\n", machine().describe_context(), tag(), port); break;
- }
-
- m_register[offset] = (m_register[offset] & ~PCS_IOE) | (data & PCS_IOE);
-
- match_pattern(offset - PORT_A_COMMAND_AND_STATUS);
- check_interrupt();
- }
- break;
-
- case COUNTER_TIMER_1_COMMAND_AND_STATUS:
- case COUNTER_TIMER_2_COMMAND_AND_STATUS:
- case COUNTER_TIMER_3_COMMAND_AND_STATUS:
- {
- int counter = offset - COUNTER_TIMER_1_COMMAND_AND_STATUS;
-
- if (LOG)
- {
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Trigger Command Bit: %u\n", machine().describe_context(), tag(), counter + 1, (data & CTCS_TCB) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Gate Command Bit: %u\n", machine().describe_context(), tag(), counter + 1, (data & CTCS_GCB) ? 1 : 0);
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Read Counter Control: %u\n", machine().describe_context(), tag(), counter + 1, (data & CTCS_RCC) ? 1 : 0);
- }
-
- switch (data >> 5)
- {
- case IC_CLEAR_IP_IUS: m_register[offset] &= ~(CTCS_IP | CTCS_IUS);if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Clear IP/IUS\n", machine().describe_context(), tag(), counter + 1); break;
- case IC_SET_IUS: m_register[offset] |= CTCS_IUS; if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Set IUS\n", machine().describe_context(), tag(), counter + 1); break;
- case IC_CLEAR_IUS: m_register[offset] &= ~CTCS_IUS; if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Clear IUS\n", machine().describe_context(), tag(), counter + 1); break;
- case IC_SET_IP: m_register[offset] |= CTCS_IP; if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Set IP\n", machine().describe_context(), tag(), counter + 1); break;
- case IC_CLEAR_IP: m_register[offset] &= ~CTCS_IP; if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Clear IP\n", machine().describe_context(), tag(), counter + 1); break;
- case IC_SET_IE: m_register[offset] |= CTCS_IE; if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Set IE\n", machine().describe_context(), tag(), counter + 1); break;
- case IC_CLEAR_IE: m_register[offset] &= ~CTCS_IE; if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Clear IE\n", machine().describe_context(), tag(), counter + 1); break;
- }
-
- // gate command bit
- m_register[offset] = (m_register[offset] & ~CTCS_GCB) | (data & CTCS_GCB);
-
- // trigger command bit
- if (data & CTCS_TCB)
- {
- trigger(counter);
- }
-
- // read counter control
- if (counter_enabled(counter) && (data & CTCS_RCC))
- {
- // freeze current count register
- m_register[offset] |= CTCS_RCC;
- m_register[COUNTER_TIMER_1_CURRENT_COUNT_MS_BYTE + (counter << 1)] = m_counter[counter] >> 8;
- m_register[COUNTER_TIMER_1_CURRENT_COUNT_LS_BYTE + (counter << 1)] = m_counter[counter] & 0xff;
- }
-
- check_interrupt();
- }
- break;
-
- case PORT_A_DATA:
- m_write_pa((offs_t)0, data);
- break;
-
- case PORT_B_DATA:
- m_write_pb((offs_t)0, data);
- break;
-
- case PORT_C_DATA:
- {
- UINT8 mask = (data & 0xf0) | (data >> 4);
-
- m_output[PORT_C] = (m_output[PORT_C] & mask) | ((data & 0x0f) & (mask ^ 0xff));
-
- m_write_pc((offs_t)0, m_output[PORT_C]);
- }
- break;
-
- case COUNTER_TIMER_1_TIME_CONSTANT_MS_BYTE:
- case COUNTER_TIMER_2_TIME_CONSTANT_MS_BYTE:
- case COUNTER_TIMER_3_TIME_CONSTANT_MS_BYTE:
- if (LOG)
- {
- int counter = (offset - COUNTER_TIMER_1_TIME_CONSTANT_MS_BYTE) >> 1;
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Time Constant MSB: %02x\n", machine().describe_context(), tag(), counter + 1, data);
- }
-
- m_register[offset] = data;
- break;
-
- case COUNTER_TIMER_1_TIME_CONSTANT_LS_BYTE:
- case COUNTER_TIMER_2_TIME_CONSTANT_LS_BYTE:
- case COUNTER_TIMER_3_TIME_CONSTANT_LS_BYTE:
- if (LOG)
- {
- int counter = (offset - COUNTER_TIMER_1_TIME_CONSTANT_LS_BYTE) >> 1;
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Time Constant LSB: %02x\n", machine().describe_context(), tag(), counter + 1, data);
- }
-
- m_register[offset] = data;
- break;
-
- case COUNTER_TIMER_1_MODE_SPECIFICATION:
- case COUNTER_TIMER_2_MODE_SPECIFICATION:
- case COUNTER_TIMER_3_MODE_SPECIFICATION:
- if (LOG)
- {
- int counter = offset - COUNTER_TIMER_1_MODE_SPECIFICATION;
- int dcs = data & CTMS_DCS_MASK;
-
- logerror("%s Z8536 '%s' Counter/Timer %u Mode: %s\n", machine().describe_context(), tag(), counter + 1, (data & CTMS_CSC) ? "Continuous" : "Single Cycle");
- logerror("%s Z8536 '%s' Counter/Timer %u External Output Enable: %u\n", machine().describe_context(), tag(), counter + 1, (data & CTMS_EOE) ? 1 : 0);
- logerror("%s Z8536 '%s' Counter/Timer %u External Count Enable: %u\n", machine().describe_context(), tag(), counter + 1, (data & CTMS_ECE) ? 1 : 0);
- logerror("%s Z8536 '%s' Counter/Timer %u External Trigger Enable: %u\n", machine().describe_context(), tag(), counter + 1, (data & CTMS_ETE) ? 1 : 0);
- logerror("%s Z8536 '%s' Counter/Timer %u External Gate Enable: %u\n", machine().describe_context(), tag(), counter + 1, (data & CTMS_EDE) ? 1 : 0);
- logerror("%s Z8536 '%s' Counter/Timer %u Retrigger Enable: %u\n", machine().describe_context(), tag(), counter + 1, (data & CTMS_REB) ? 1 : 0);
- logerror("%s Z8536 '%s' Counter/Timer %u Output Duty Cycle: %s\n", machine().describe_context(), tag(), counter + 1, CTMS_DCS[dcs]);
- }
-
- m_register[offset] = data;
- break;
-
- case PORT_A_MODE_SPECIFICATION:
- case PORT_B_MODE_SPECIFICATION:
- if (LOG)
- {
- char port = BIT(offset, 3) ? 'B' : 'A';
- int pts = (data & PMS_PTS_MASK) >> 6;
- int pms = (data & PMS_PMS_MASK) >> 1;
-
- logerror("%s Z8536 '%s' Port %c Port Type: %s\n", machine().describe_context(), tag(), port, PMS_PTS[pts]);
- logerror("%s Z8536 '%s' Port %c Interrupt on 2 Bytes: %u\n", machine().describe_context(), tag(), port, (data & PMS_ITB) ? 1 : 0);
- logerror("%s Z8536 '%s' Port %c Single Buffer: %u\n", machine().describe_context(), tag(), port, (data & PMS_SB) ? 1 : 0);
- logerror("%s Z8536 '%s' Port %c Interrupt on Match Only: %u\n", machine().describe_context(), tag(), port, (data & PMS_IMO) ? 1 : 0);
- logerror("%s Z8536 '%s' Port %c Pattern Mode: %s\n", machine().describe_context(), tag(), port, PMS_PMS[pms]);
-
- if (pts == PTS_BIT)
- logerror("%s Z8536 '%s' Port %c Latch on Pattern Match: %u\n", machine().describe_context(), tag(), port, (data & PMS_LPM) ? 1 : 0);
- else
- logerror("%s Z8536 '%s' Port %c Deskew Timer Enable: %u\n", machine().describe_context(), tag(), port, (data & PMS_DTE) ? 1 : 0);
- }
-
- m_register[offset] = data;
- break;
-
- case PORT_A_HANDSHAKE_SPECIFICATION:
- case PORT_B_HANDSHAKE_SPECIFICATION:
- // TODO
- break;
-
- case PORT_A_DATA_PATH_POLARITY:
- case PORT_B_DATA_PATH_POLARITY:
- if (LOG) logerror("%s Z8536 '%s' Port %c Data Path Polarity: %02x\n", machine().describe_context(), tag(), BIT(offset, 3) ? 'B' : 'A', data);
- m_register[offset] = data;
- break;
-
- case PORT_A_DATA_DIRECTION:
- case PORT_B_DATA_DIRECTION:
- if (LOG) logerror("%s Z8536 '%s' Port %c Data Direction: %02x\n", machine().describe_context(), tag(), BIT(offset, 3) ? 'B' : 'A', data);
- m_register[offset] = data;
- break;
-
- case PORT_A_SPECIAL_IO_CONTROL:
- case PORT_B_SPECIAL_IO_CONTROL:
- if (LOG) logerror("%s Z8536 '%s' Port %c Special I/O Control: %02x\n", machine().describe_context(), tag(), BIT(offset, 3) ? 'B' : 'A', data);
- m_register[offset] = data;
- break;
-
- case PORT_A_PATTERN_POLARITY:
- case PORT_B_PATTERN_POLARITY:
- if (LOG) logerror("%s Z8536 '%s' Port %c Pattern Polarity: %02x\n", machine().describe_context(), tag(), BIT(offset, 3) ? 'B' : 'A', data);
- m_register[offset] = data;
- break;
-
- case PORT_A_PATTERN_TRANSITION:
- case PORT_B_PATTERN_TRANSITION:
- if (LOG) logerror("%s Z8536 '%s' Port %c Pattern Transition: %02x\n", machine().describe_context(), tag(), BIT(offset, 3) ? 'B' : 'A', data);
- m_register[offset] = data;
- break;
-
- case PORT_A_PATTERN_MASK:
- case PORT_B_PATTERN_MASK:
- if (LOG) logerror("%s Z8536 '%s' Port %c Pattern Mask: %02x\n", machine().describe_context(), tag(), BIT(offset, 3) ? 'B' : 'A', data);
- m_register[offset] = data;
- match_pattern(BIT(offset, 3));
- check_interrupt();
- break;
-
- default:
- logerror("%s: Z8536 '%s' Unimplemented write %02x to register %u\n", machine().describe_context(), tag(), data, offset);
- m_register[offset] = data;
- }
-}
-
-
-//-------------------------------------------------
-// write_register - masked write to register
-//-------------------------------------------------
-
-void z8536_device::write_register(offs_t offset, UINT8 data, UINT8 mask)
-{
- UINT8 combined_data = (data & mask) | (m_register[offset] & (mask ^ 0xff));
-
- write_register(offset, combined_data);
-}
-
-
-//-------------------------------------------------
-// counter_enabled - is counter enabled?
-//-------------------------------------------------
-
-bool z8536_device::counter_enabled(device_timer_id id)
-{
- bool enabled = false;
-
- switch (id)
- {
- case TIMER_1:
- enabled = (m_register[MASTER_CONFIGURATION_CONTROL] & MCCR_CT1E) ? true : false;
- break;
-
- case TIMER_2:
- enabled = (m_register[MASTER_CONFIGURATION_CONTROL] & MCCR_CT2E) ? true : false;
- break;
-
- case TIMER_3:
- enabled = (m_register[MASTER_CONFIGURATION_CONTROL] & MCCR_PCE_CT3E) ? true : false;
- break;
- }
-
- return enabled;
-}
-
-
-//-------------------------------------------------
-// counter_external_output -
-//-------------------------------------------------
-
-bool z8536_device::counter_external_output(device_timer_id id)
-{
- return (m_register[COUNTER_TIMER_1_MODE_SPECIFICATION + id] & CTMS_EOE) ? true : false;
-}
-
-
-//-------------------------------------------------
-// counter_external_count -
-//-------------------------------------------------
-
-bool z8536_device::counter_external_count(device_timer_id id)
-{
- return (m_register[COUNTER_TIMER_1_MODE_SPECIFICATION + id] & CTMS_ECE) ? true : false;
-}
-
-
-//-------------------------------------------------
-// counter_external_trigger -
-//-------------------------------------------------
-
-bool z8536_device::counter_external_trigger(device_timer_id id)
-{
- return (m_register[COUNTER_TIMER_1_MODE_SPECIFICATION + id] & CTMS_ETE) ? true : false;
-}
-
-
-//-------------------------------------------------
-// counter_external_gate -
-//-------------------------------------------------
-
-bool z8536_device::counter_external_gate(device_timer_id id)
-{
- return (m_register[COUNTER_TIMER_1_MODE_SPECIFICATION + id] & CTMS_EDE) ? true : false;
-}
-
-
-//-------------------------------------------------
-// counter_gated -
-//-------------------------------------------------
-
-bool z8536_device::counter_gated(device_timer_id id)
-{
- return (m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] & CTCS_GCB) ? true : false;
-}
-
-
-//-------------------------------------------------
-// count - count down
-//-------------------------------------------------
-
-void z8536_device::count(device_timer_id id)
-{
- if (!counter_gated(id)) return;
- if (!(m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] & CTCS_CIP)) return;
-
- // count down
- m_counter[id]--;
-
- if (m_counter[id] == 0)
- {
- if (m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] & CTCS_IP)
- {
- // set interrupt error bit
- m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] |= CTCS_ERR;
- }
- else
- {
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Interrupt Pending\n", machine().describe_context(), tag(), id + 1);
-
- // set interrupt pending bit
- m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] |= CTCS_IP;
- }
-
- if (m_register[COUNTER_TIMER_1_MODE_SPECIFICATION + id] & CTMS_CSC)
- {
- // reload counter with time constant
- m_counter[id] = (m_register[COUNTER_TIMER_1_TIME_CONSTANT_MS_BYTE + (id << 1)] << 8) | m_register[COUNTER_TIMER_1_TIME_CONSTANT_LS_BYTE + (id << 1)];
- }
- else
- {
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Terminal Count\n", machine().describe_context(), tag(), id + 1);
-
- // clear count in progress bit
- m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] &= ~CTCS_CIP;
- }
-
- check_interrupt();
- }
-}
-
-
-//-------------------------------------------------
-// trigger -
-//-------------------------------------------------
-
-void z8536_device::trigger(device_timer_id id)
-{
- // ignore triggers during countdown if retrigger is disabled
- if (!(m_register[COUNTER_TIMER_1_MODE_SPECIFICATION + id] & CTMS_REB) && (m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] & CTCS_CIP)) return;
-
- if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Trigger\n", machine().describe_context(), tag(), id + 1);
-
- // load counter with time constant
- m_counter[id] = (m_register[COUNTER_TIMER_1_TIME_CONSTANT_MS_BYTE + (id << 1)] << 8) | m_register[COUNTER_TIMER_1_TIME_CONSTANT_LS_BYTE + (id << 1)];
-
- // set count in progress bit
- m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] |= CTCS_CIP;
-}
-
-
-//-------------------------------------------------
-// gate -
-//-------------------------------------------------
-
-void z8536_device::gate(device_timer_id id, int state)
-{
- // TODO
-}
-
-
-//-------------------------------------------------
-// match_pattern -
-//-------------------------------------------------
-
-void z8536_device::match_pattern(int port)
-{
- UINT8 pms = m_register[PORT_A_MODE_SPECIFICATION + (port << 3)];
- UINT8 pm = m_register[PORT_A_PATTERN_MASK + (port << 3)];
- UINT8 ddr = m_register[PORT_A_DATA_DIRECTION + (port << 3)];
-
- switch ((pms & PMS_PMS_MASK) >> 1)
- {
- case PMS_OR_PEV:
- m_match[port] = m_input[port] & ddr & pm;
-
- if (m_match[port])
- {
- if (LOG) logerror("%s Z8536 '%s' Port %c Interrupt Pending\n", machine().describe_context(), tag(), 'A' + port);
- m_register[PORT_A_COMMAND_AND_STATUS + port] |= PCS_IP;
- check_interrupt();
- }
- break;
- }
-}
-
-
-//-------------------------------------------------
-// external_port_w - external port write
-//-------------------------------------------------
-
-void z8536_device::external_port_w(int port, int bit, int state)
-{
- switch (port)
- {
- case PORT_A:
- case PORT_B:
- {
- assert((PORT_A_DATA_DIRECTION + (port << 3)) >= 0 && (PORT_A_DATA_DIRECTION + (port << 3)) < ARRAY_LENGTH(m_register));
- UINT8 ddr = m_register[PORT_A_DATA_DIRECTION + (port << 3)];
-
- if (!BIT(ddr, bit)) return;
-
- if (LOG) logerror("%s Z8536 '%s' Port %c Bit %u: %u\n", machine().describe_context(), tag(), 'A' + port, bit, state);
-
- m_input[port] = (m_input[port] & ~(1 << bit)) | (state << bit);
-
- match_pattern(port);
- }
- break;
-
- case PORT_C:
- break;
- }
-}
-
-
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// z8536_device - constructor
-//-------------------------------------------------
-
-z8536_device::z8536_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, Z8536, "Zilog Z8536", tag, owner, clock, "z8536", __FILE__),
- device_z80daisy_interface(mconfig, *this),
- m_write_irq(*this),
- m_read_pa(*this),
- m_write_pa(*this),
- m_read_pb(*this),
- m_write_pb(*this),
- m_read_pc(*this),
- m_write_pc(*this),
- m_irq(CLEAR_LINE)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void z8536_device::device_start()
-{
- for (int i = 0; i < 3; i++)
- {
- m_input[i] = 0;
- m_output[i] = 0;
- m_buffer[i] = 0;
- m_match[i] = 0;
- }
-
- // allocate timer
- m_timer = timer_alloc();
- m_timer->adjust(attotime::from_hz(clock() / 2), 0, attotime::from_hz(clock() / 2));
-
- // resolve callbacks
- m_write_irq.resolve_safe();
- m_read_pa.resolve_safe(0);
- m_write_pa.resolve_safe();
- m_read_pb.resolve_safe(0);
- m_write_pb.resolve_safe();
- m_read_pc.resolve_safe(0);
- m_write_pc.resolve_safe();
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific reset
-//-------------------------------------------------
-
-void z8536_device::device_reset()
-{
- m_state = STATE_RESET;
-
- for (int i = 0; i < 48; i++)
- {
- m_register[i] = 0;
- }
-
- m_register[MASTER_INTERRUPT_CONTROL] = MICR_RESET;
- m_register[PORT_A_COMMAND_AND_STATUS] = PCS_ORE;
- m_register[PORT_B_COMMAND_AND_STATUS] = PCS_ORE;
- m_register[CURRENT_VECTOR] = 0xff;
-
- m_pointer = 0;
-
- check_interrupt();
-}
-
-
-//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void z8536_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if (counter_enabled(TIMER_1) && !counter_external_count(TIMER_1))
- {
- count(TIMER_1);
- }
-
- if (counter_enabled(TIMER_2) && !counter_external_count(TIMER_2))
- {
- count(TIMER_2);
- }
-
- if (counter_enabled(TIMER_3) && !counter_external_count(TIMER_3))
- {
- count(TIMER_3);
- }
-}
-
-
-
-//**************************************************************************
-// DAISY CHAIN INTERFACE
-//**************************************************************************
-
-//-------------------------------------------------
-// z80daisy_irq_state - return the overall IRQ
-// state for this device
-//-------------------------------------------------
-
-int z8536_device::z80daisy_irq_state()
-{
- return 0;
-}
-
-
-//-------------------------------------------------
-// z80daisy_irq_ack - acknowledge an IRQ and
-// return the appropriate vector
-//-------------------------------------------------
-
-int z8536_device::z80daisy_irq_ack()
-{
- return intack_r();
-}
-
-
-//-------------------------------------------------
-// z80daisy_irq_reti - clear the interrupt
-// pending state to allow other interrupts through
-//-------------------------------------------------
-
-void z8536_device::z80daisy_irq_reti()
-{
-}
-
-
-
-//**************************************************************************
-// INTERNAL STATE MANAGEMENT
-//**************************************************************************
-
-//-------------------------------------------------
-// read - register read
-//-------------------------------------------------
-
-READ8_MEMBER( z8536_device::read )
-{
- UINT8 data = 0;
-
- if (m_state == STATE_RESET)
- {
- // read RESET bit
- data = read_register(m_pointer, 0x01);
- }
- else
- {
- switch (offset & 0x03)
- {
- case PORT_C:
- data = read_register(PORT_C_DATA);
- break;
-
- case PORT_B:
- data = read_register(PORT_B_DATA);
- break;
-
- case PORT_A:
- data = read_register(PORT_A_DATA);
- break;
-
- case CONTROL:
- switch (m_state)
- {
- case STATE_1:
- m_state = STATE_0;
- // fallthru
- case STATE_0:
- data = read_register(m_pointer);
- break;
- }
- break;
- }
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write - register write
-//-------------------------------------------------
-
-WRITE8_MEMBER( z8536_device::write )
-{
- if (m_state == STATE_RESET)
- {
- // write RESET bit
- write_register(m_pointer, data, 0x01);
- }
- else
- {
- switch (offset & 0x03)
- {
- case PORT_C:
- write_register(PORT_C_DATA, data);
- break;
-
- case PORT_B:
- write_register(PORT_B_DATA, data);
- break;
-
- case PORT_A:
- write_register(PORT_A_DATA, data);
- break;
-
- case CONTROL:
- switch (m_state)
- {
- case STATE_0:
- m_pointer = data;
- m_state = STATE_1;
- break;
-
- case STATE_1:
- write_register(m_pointer, data);
- m_state = STATE_0;
- }
- break;
- }
- }
-}
-
-
-//-------------------------------------------------
-// intack_r - interrupt acknowledge
-//-------------------------------------------------
-
-int z8536_device::intack_r()
-{
- get_interrupt_vector();
- int data = m_register[CURRENT_VECTOR];
-
- if (LOG) logerror("%s Z8536 '%s' Interrupt Acknowledge: %02x\n", machine().describe_context(), tag(), data);
-
- // set interrupt under service bit
- if ((m_register[COUNTER_TIMER_3_COMMAND_AND_STATUS] & (CTCS_IP | CTCS_IE)) == (CTCS_IP | CTCS_IE))
- {
- m_register[COUNTER_TIMER_3_COMMAND_AND_STATUS] |= CTCS_IUS;
- }
- else if ((m_register[PORT_A_COMMAND_AND_STATUS] & (PCS_IP | PCS_IE)) == (PCS_IP | PCS_IE))
- {
- m_register[PORT_A_COMMAND_AND_STATUS] |= PCS_IUS;
- }
- else if ((m_register[COUNTER_TIMER_2_COMMAND_AND_STATUS] & (CTCS_IP | CTCS_IE)) == (CTCS_IP | CTCS_IE))
- {
- m_register[COUNTER_TIMER_2_COMMAND_AND_STATUS] |= CTCS_IUS;
- }
- else if ((m_register[PORT_B_COMMAND_AND_STATUS] & (PCS_IP | PCS_IE)) == (PCS_IP | PCS_IE))
- {
- m_register[PORT_B_COMMAND_AND_STATUS] |= PCS_IUS;
- }
- else if ((m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS] & (CTCS_IP | CTCS_IE)) == (CTCS_IP | CTCS_IE))
- {
- m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS] |= CTCS_IUS;
- }
-
- check_interrupt();
-
- if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_NV)
- {
- // no vector
- data = -1;
- }
-
- return data;
-}
diff --git a/src/emu/machine/z8536.h b/src/emu/machine/z8536.h
deleted file mode 100644
index 96c39e0123a..00000000000
--- a/src/emu/machine/z8536.h
+++ /dev/null
@@ -1,353 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Curt Coder
-/**********************************************************************
-
- Zilog Z8536 Counter/Timer and Parallel I/O emulation
-
-**********************************************************************
- _____ _____
- D4 1 |* \_/ | 40 D3
- D5 2 | | 39 D2
- D6 3 | | 38 D1
- D7 4 | | 37 D0
- _RD 5 | | 36 _CE
- _WR 6 | | 35 A1
- GND 7 | | 34 A0
- PB0 8 | | 33 PA0
- PB1 9 | | 32 PA1
- PB2 10 | Z8536 | 31 PA2
- PB3 11 | | 30 PA3
- PB4 12 | | 29 PA4
- PB5 13 | | 28 PA5
- PB6 14 | | 27 PA6
- PB7 15 | | 26 PA7
- PCLK 16 | | 25 _INTACK
- IEI 17 | | 24 _INT
- IEO 18 | | 23 +5 V
- PC0 19 | | 22 PC3
- PC1 20 |_____________| 21 PC2
-
-**********************************************************************/
-
-#pragma once
-
-#ifndef __Z8536__
-#define __Z8536__
-
-#include "emu.h"
-#include "cpu/z80/z80daisy.h"
-
-
-
-//**************************************************************************
-// INTERFACE CONFIGURATION MACROS
-//**************************************************************************
-
-#define MCFG_Z8536_IRQ_CALLBACK(_write) \
- devcb = &z8536_device::set_irq_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_Z8536_PA_IN_CALLBACK(_read) \
- devcb = &z8536_device::set_pa_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_Z8536_PA_OUT_CALLBACK(_write) \
- devcb = &z8536_device::set_pa_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_Z8536_PB_IN_CALLBACK(_read) \
- devcb = &z8536_device::set_pb_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_Z8536_PB_OUT_CALLBACK(_write) \
- devcb = &z8536_device::set_pb_wr_callback(*device, DEVCB_##_write);
-
-#define MCFG_Z8536_PC_IN_CALLBACK(_read) \
- devcb = &z8536_device::set_pc_rd_callback(*device, DEVCB_##_read);
-
-#define MCFG_Z8536_PC_OUT_CALLBACK(_write) \
- devcb = &z8536_device::set_pc_wr_callback(*device, DEVCB_##_write);
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> z8536_device
-
-class z8536_device : public device_t,
- public device_z80daisy_interface
-{
-public:
- // construction/destruction
- z8536_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- template<class _Object> static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<z8536_device &>(device).m_write_irq.set_callback(object); }
- template<class _Object> static devcb_base &set_pa_rd_callback(device_t &device, _Object object) { return downcast<z8536_device &>(device).m_read_pa.set_callback(object); }
- template<class _Object> static devcb_base &set_pa_wr_callback(device_t &device, _Object object) { return downcast<z8536_device &>(device).m_write_pa.set_callback(object); }
- template<class _Object> static devcb_base &set_pb_rd_callback(device_t &device, _Object object) { return downcast<z8536_device &>(device).m_read_pb.set_callback(object); }
- template<class _Object> static devcb_base &set_pb_wr_callback(device_t &device, _Object object) { return downcast<z8536_device &>(device).m_write_pb.set_callback(object); }
- template<class _Object> static devcb_base &set_pc_rd_callback(device_t &device, _Object object) { return downcast<z8536_device &>(device).m_read_pc.set_callback(object); }
- template<class _Object> static devcb_base &set_pc_wr_callback(device_t &device, _Object object) { return downcast<z8536_device &>(device).m_write_pc.set_callback(object); }
-
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
-
- int intack_r();
-
- DECLARE_WRITE_LINE_MEMBER( pa0_w ) { external_port_w(PORT_A, 0, state); }
- DECLARE_WRITE_LINE_MEMBER( pa1_w ) { external_port_w(PORT_A, 1, state); }
- DECLARE_WRITE_LINE_MEMBER( pa2_w ) { external_port_w(PORT_A, 2, state); }
- DECLARE_WRITE_LINE_MEMBER( pa3_w ) { external_port_w(PORT_A, 3, state); }
- DECLARE_WRITE_LINE_MEMBER( pa4_w ) { external_port_w(PORT_A, 4, state); }
- DECLARE_WRITE_LINE_MEMBER( pa5_w ) { external_port_w(PORT_A, 5, state); }
- DECLARE_WRITE_LINE_MEMBER( pa6_w ) { external_port_w(PORT_A, 6, state); }
- DECLARE_WRITE_LINE_MEMBER( pa7_w ) { external_port_w(PORT_A, 7, state); }
-
- DECLARE_WRITE_LINE_MEMBER( pb0_w ) { external_port_w(PORT_B, 0, state); }
- DECLARE_WRITE_LINE_MEMBER( pb1_w ) { external_port_w(PORT_B, 1, state); }
- DECLARE_WRITE_LINE_MEMBER( pb2_w ) { external_port_w(PORT_B, 2, state); }
- DECLARE_WRITE_LINE_MEMBER( pb3_w ) { external_port_w(PORT_B, 3, state); }
- DECLARE_WRITE_LINE_MEMBER( pb4_w ) { external_port_w(PORT_B, 4, state); }
- DECLARE_WRITE_LINE_MEMBER( pb5_w ) { external_port_w(PORT_B, 5, state); }
- DECLARE_WRITE_LINE_MEMBER( pb6_w ) { external_port_w(PORT_B, 6, state); }
- DECLARE_WRITE_LINE_MEMBER( pb7_w ) { external_port_w(PORT_B, 7, state); }
-
- DECLARE_WRITE_LINE_MEMBER( pc0_w ) { external_port_w(PORT_C, 0, state); }
- DECLARE_WRITE_LINE_MEMBER( pc1_w ) { external_port_w(PORT_C, 1, state); }
- DECLARE_WRITE_LINE_MEMBER( pc2_w ) { external_port_w(PORT_C, 2, state); }
- DECLARE_WRITE_LINE_MEMBER( pc3_w ) { external_port_w(PORT_C, 3, state); }
-
-protected:
- // device-level overrides
- virtual void device_start();
- virtual void device_reset();
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
-
- // device_z80daisy_interface overrides
- virtual int z80daisy_irq_state();
- virtual int z80daisy_irq_ack();
- virtual void z80daisy_irq_reti();
-
-private:
- enum
- {
- TIMER_1 = 0,
- TIMER_2,
- TIMER_3
- };
-
- // states
- enum
- {
- STATE_RESET = -1,
- STATE_0,
- STATE_1
- };
-
-
- // ports
- enum
- {
- PORT_C = 0,
- PORT_B,
- PORT_A,
- CONTROL
- };
-
-
- // registers
- enum
- {
- MASTER_INTERRUPT_CONTROL = 0,
- MASTER_CONFIGURATION_CONTROL,
- PORT_A_INTERRUPT_VECTOR,
- PORT_B_INTERRUPT_VECTOR,
- COUNTER_TIMER_INTERRUPT_VECTOR,
- PORT_C_DATA_PATH_POLARITY,
- PORT_C_DATA_DIRECTION,
- PORT_C_SPECIAL_IO_CONTROL,
- PORT_A_COMMAND_AND_STATUS,
- PORT_B_COMMAND_AND_STATUS,
- COUNTER_TIMER_1_COMMAND_AND_STATUS,
- COUNTER_TIMER_2_COMMAND_AND_STATUS,
- COUNTER_TIMER_3_COMMAND_AND_STATUS,
- PORT_A_DATA,
- PORT_B_DATA,
- PORT_C_DATA,
- COUNTER_TIMER_1_CURRENT_COUNT_MS_BYTE,
- COUNTER_TIMER_1_CURRENT_COUNT_LS_BYTE,
- COUNTER_TIMER_2_CURRENT_COUNT_MS_BYTE,
- COUNTER_TIMER_2_CURRENT_COUNT_LS_BYTE,
- COUNTER_TIMER_3_CURRENT_COUNT_MS_BYTE,
- COUNTER_TIMER_3_CURRENT_COUNT_LS_BYTE,
- COUNTER_TIMER_1_TIME_CONSTANT_MS_BYTE,
- COUNTER_TIMER_1_TIME_CONSTANT_LS_BYTE,
- COUNTER_TIMER_2_TIME_CONSTANT_MS_BYTE,
- COUNTER_TIMER_2_TIME_CONSTANT_LS_BYTE,
- COUNTER_TIMER_3_TIME_CONSTANT_MS_BYTE,
- COUNTER_TIMER_3_TIME_CONSTANT_LS_BYTE,
- COUNTER_TIMER_1_MODE_SPECIFICATION,
- COUNTER_TIMER_2_MODE_SPECIFICATION,
- COUNTER_TIMER_3_MODE_SPECIFICATION,
- CURRENT_VECTOR,
- PORT_A_MODE_SPECIFICATION,
- PORT_A_HANDSHAKE_SPECIFICATION,
- PORT_A_DATA_PATH_POLARITY,
- PORT_A_DATA_DIRECTION,
- PORT_A_SPECIAL_IO_CONTROL,
- PORT_A_PATTERN_POLARITY,
- PORT_A_PATTERN_TRANSITION,
- PORT_A_PATTERN_MASK,
- PORT_B_MODE_SPECIFICATION,
- PORT_B_HANDSHAKE_SPECIFICATION,
- PORT_B_DATA_PATH_POLARITY,
- PORT_B_DATA_DIRECTION,
- PORT_B_SPECIAL_IO_CONTROL,
- PORT_B_PATTERN_POLARITY,
- PORT_B_PATTERN_TRANSITION,
- PORT_B_PATTERN_MASK
- };
-
-
- // interrupt control
- enum
- {
- IC_NULL = 0,
- IC_CLEAR_IP_IUS,
- IC_SET_IUS,
- IC_CLEAR_IUS,
- IC_SET_IP,
- IC_CLEAR_IP,
- IC_SET_IE,
- IC_CLEAR_IE
- };
-
-
- // counter/timer link control
- enum
- {
- LC_INDEPENDENT = 0,
- LC_CT1_GATES_CT2,
- LC_CT1_TRIGGERS_CT2,
- LC_CT1_COUNTS_CT2
- };
-
-
- // port type select
- enum
- {
- PTS_BIT = 0,
- PTS_INPUT,
- PTS_OUTPUT,
- PTS_BIDIRECTIONAL
- };
-
-
-
- // pattern mode specification
- enum
- {
- PMS_DISABLE = 0,
- PMS_AND,
- PMS_OR,
- PMS_OR_PEV
- };
-
- // handshake specification
- enum
- {
- HTS_INTERLOCKED = 0,
- HTS_STROBED,
- HTS_PULSED,
- HTS_3_WIRE
- };
-
-
- // request/wait specification
- enum
- {
- RWS_DISABLED = 0,
- RWS_OUTPUT_WAIT,
- RWS_INPUT_WAIT = 3,
- RWS_SPECIAL_REQUEST,
- RWS_OUTPUT_REQUEST,
- RWS_INPUT_REQUEST = 7
- };
-
-
- // pattern specification
- enum
- {
- BIT_MASKED_OFF = 0,
- ANY_TRANSITION,
- ZERO = 4,
- ONE,
- ONE_TO_ZERO,
- ZERO_TO_ONE
- };
-
-
- // output duty cycle
- enum
- {
- DCS_PULSE,
- DCS_ONE_SHOT,
- DCS_SQUARE_WAVE,
- DCS_DO_NOT_USE
- };
-
- void get_interrupt_vector();
- void check_interrupt();
-
- UINT8 read_register(offs_t offset);
- UINT8 read_register(offs_t offset, UINT8 mask);
- void write_register(offs_t offset, UINT8 data);
- void write_register(offs_t offset, UINT8 data, UINT8 mask);
-
- bool counter_enabled(device_timer_id id);
- bool counter_external_output(device_timer_id id);
- bool counter_external_count(device_timer_id id);
- bool counter_external_trigger(device_timer_id id);
- bool counter_external_gate(device_timer_id id);
- bool counter_gated(device_timer_id id);
- void count(device_timer_id id);
- void trigger(device_timer_id id);
- void gate(device_timer_id id, int state);
- void match_pattern(int port);
- void external_port_w(int port, int bit, int state);
-
- devcb_write_line m_write_irq;
-
- devcb_read8 m_read_pa;
- devcb_write8 m_write_pa;
-
- devcb_read8 m_read_pb;
- devcb_write8 m_write_pb;
-
- devcb_read8 m_read_pc;
- devcb_write8 m_write_pc;
-
- // interrupt state
- int m_irq;
-
- // register state
- int m_state;
- UINT8 m_register[48];
- UINT8 m_pointer;
-
- // input/output port state
- UINT8 m_input[3];
- UINT8 m_output[3];
- UINT8 m_buffer[3];
- UINT8 m_match[3];
-
- // timers
- emu_timer *m_timer;
- UINT16 m_counter[3];
-};
-
-
-// device type definition
-extern const device_type Z8536;
-
-
-
-#endif