src/mess/drivers/cdi.c
| r5824 | r5825 | |
| 51 | 51 | #include "devices/chd_cd.h" |
| 52 | 52 | |
| 53 | 53 | static UINT16 *ram; |
| 54 | | static UINT16 *pcab_vregs; |
| 55 | 54 | |
| 55 | #define VERBOSE_LEVEL (5) |
| 56 | |
| 57 | INLINE void verboselog(running_machine *machine, int n_level, const char *s_fmt, ...) |
| 58 | { |
| 59 | if( VERBOSE_LEVEL >= n_level ) |
| 60 | { |
| 61 | va_list v; |
| 62 | char buf[ 32768 ]; |
| 63 | va_start( v, s_fmt ); |
| 64 | vsprintf( buf, s_fmt, v ); |
| 65 | va_end( v ); |
| 66 | logerror( "%08x: %s", cpu_get_pc(cputag_get_cpu(machine, "maincpu")), buf ); |
| 67 | } |
| 68 | } |
| 69 | |
| 56 | 70 | /************************* |
| 57 | 71 | * Video Hardware * |
| 58 | 72 | *************************/ |
| 59 | 73 | |
| 60 | | /* |
| 61 | | 66470 |
| 62 | | video and system controller |
| 63 | | 19901219/wjvg |
| 64 | | */ |
| 65 | | /* |
| 66 | | TODO: check this register,doesn't seem to be 100% correct. |
| 67 | | 1fffe0 csr = control and status register |
| 68 | | w 00...... ........ DM = slow timing speed, normal dram mode |
| 69 | | w 01...... ........ DM = fast timing speed, page dram mode |
| 70 | | w 10...... ........ DM = fast timing speed, nibble dram mode |
| 71 | | w 11...... ........ DM = slow timing speed, dual-port vram mode |
| 72 | | w ..1..... ........ TD = 256/64 k dram's |
| 73 | | w ...1.... ........ CG = enable character generator |
| 74 | | w ....1... ........ DD = rom data acknowledge delay |
| 75 | | w .....1.. ........ ED = early dtack |
| 76 | | w ......0. ........ not used |
| 77 | | w .......1 ........ BE = enable bus error (watchdog timer) |
| 78 | | r ........ 1....... DA = vertical display active |
| 79 | | r ........ .1...... FG = set during frame grabbing (if fg in dcr set) |
| 80 | | r ........ ..xxx... not used |
| 81 | | r ........ .....1.. IT2 = intn active |
| 82 | | r ........ ......1. IT1 = pixac free and intn active |
| 83 | | r ........ .......1 BE = bus error generated by watchdog timer |
| 84 | | */ |
| 74 | typedef struct |
| 75 | { |
| 76 | UINT8 csrr; |
| 77 | UINT16 csrw; |
| 78 | UINT8 dcr; |
| 79 | UINT8 vsr; |
| 80 | UINT8 ddr; |
| 81 | UINT8 dcp; |
| 82 | } mcd212_channel_t; |
| 85 | 83 | |
| 86 | | /*63 at post test,6d all the time.*/ |
| 87 | | #define SCC_CSR_VREG (pcab_vregs[0x00/2] & 0xffff) |
| 88 | | #define SCC_CG_VREG ((SCC_CSR_VREG & 0x10)>>4) |
| 84 | typedef struct |
| 85 | { |
| 86 | mcd212_channel_t channel[2]; |
| 87 | } mcd212_t; |
| 89 | 88 | |
| 90 | | /* |
| 91 | | 1fffe2 dcr = display command register |
| 92 | | w 1....... ........ DE = enable display |
| 93 | | w .00..... ........ CF = 20 MHz (or 19.6608 MHz) |
| 94 | | w .01..... ........ CF = 24 MHz |
| 95 | | w .10..... ........ CF = 28.5 MHz |
| 96 | | w .11..... ........ CF = 30 MHz |
| 97 | | w ...1.... ........ FD = 60/50 Hz frame duration |
| 98 | | w ....00.. ........ SM/SS = non-interlaced scan mode |
| 99 | | w ....01.. ........ SM/SS = double frequency scan mode |
| 100 | | w ....10.. ........ SM/SS = interlaced scan mode |
| 101 | | w ....11.. ........ SM/SS = interlaced field repeat scan mode |
| 102 | | w ......1. ........ LS = full screen/border |
| 103 | | w .......1 ........ CM = logical/physical screen |
| 104 | | w ........ 1....... FG = 4/8 bits per pixel |
| 105 | | w ........ .1...... DF = enable frame grabbing |
| 106 | | w ........ ..00.... IC/DC = ICA and DCA inactive |
| 107 | | w ........ ..01.... IC/DC = ICA active, reduced DCA mode (DCA sz=16 byts) |
| 108 | | w ........ ..10.... IC/DC = ICA active, DCA inactive |
| 109 | | w ........ ..11.... IC/DC = ICA active, DCA active (DCA size=64 bytes) |
| 110 | | w ........ ....aaaa VSR:H = video start address (MSB's) |
| 111 | | */ |
| 89 | mcd212_t mcd212; |
| 112 | 90 | |
| 113 | | #define SCC_DCR_VREG (pcab_vregs[0x02/2] & 0xffff) |
| 114 | | #define SCC_DE_VREG ((SCC_DCR_VREG & 0x8000)>>15) |
| 115 | | #define SCC_VSR_VREG_H ((SCC_DCR_VREG & 0xf)>>0) |
| 91 | static READ16_HANDLER(mcd212_r) |
| 92 | { |
| 93 | switch(offset) |
| 94 | { |
| 95 | case 0x00/2: |
| 96 | case 0x10/2: |
| 97 | if(ACCESSING_BITS_0_7) |
| 98 | { |
| 99 | verboselog(space->machine, 2, "mcd212_r: Status Register %d: %02x & %04x\n", (1 - (offset / 8)) + 1, mcd212.channel[1 - (offset / 8)].csrr, mem_mask); |
| 100 | mcd212.channel[1 - (offset / 8)].csrr ^= 0x80; // Simulate drawing / not drawing |
| 101 | return mcd212.channel[1 - (offset / 8)].csrr; |
| 102 | } |
| 103 | break; |
| 104 | case 0x02/2: |
| 105 | case 0x12/2: |
| 106 | verboselog(space->machine, 2, "mcd212_r: Display Command Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, mcd212.channel[1 - (offset / 8)].dcr, mem_mask); |
| 107 | return mcd212.channel[1 - (offset / 8)].dcr; |
| 108 | break; |
| 109 | case 0x04/2: |
| 110 | case 0x14/2: |
| 111 | verboselog(space->machine, 2, "mcd212_r: Video Start Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, mcd212.channel[1 - (offset / 8)].vsr, mem_mask); |
| 112 | return mcd212.channel[1 - (offset / 8)].vsr; |
| 113 | break; |
| 114 | case 0x08/2: |
| 115 | case 0x18/2: |
| 116 | verboselog(space->machine, 2, "mcd212_r: Display Decoder Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, mcd212.channel[1 - (offset / 8)].ddr, mem_mask); |
| 117 | return mcd212.channel[1 - (offset / 8)].ddr; |
| 118 | break; |
| 119 | case 0x0a/2: |
| 120 | case 0x1a/2: |
| 121 | verboselog(space->machine, 2, "mcd212_r: DCA Pointer Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, mcd212.channel[1 - (offset / 8)].dcp, mem_mask); |
| 122 | return mcd212.channel[1 - (offset / 8)].dcp; |
| 123 | break; |
| 124 | default: |
| 125 | verboselog(space->machine, 2, "mcd212_r: Unknown Register %d & %04x\n", (1 - (offset / 8)) + 1, mem_mask); |
| 126 | break; |
| 127 | } |
| 116 | 128 | |
| 117 | | /* |
| 118 | | 1fffe4 vsr = video start register |
| 119 | | w aaaaaaaa aaaaaaaa VSR:L = video start address (LSB's) |
| 120 | | */ |
| 129 | return 0; |
| 130 | } |
| 121 | 131 | |
| 122 | | #define SCC_VSR_VREG_L (pcab_vregs[0x04/2] & 0xffff) |
| 123 | | #define SCC_VSR_VREG ((SCC_VSR_VREG_H)<<16) | (SCC_VSR_VREG_L) |
| 132 | static WRITE16_HANDLER(mcd212_w) |
| 133 | { |
| 134 | switch(offset) |
| 135 | { |
| 136 | case 0x00/2: |
| 137 | case 0x10/2: |
| 138 | verboselog(space->machine, 2, "mcd212_w: Status Register %d: %02x & %04x\n", (1 - (offset / 8)) + 1, data, mem_mask); |
| 139 | COMBINE_DATA(&mcd212.channel[1 - (offset / 8)].csrw); |
| 140 | break; |
| 141 | case 0x02/2: |
| 142 | case 0x12/2: |
| 143 | verboselog(space->machine, 2, "mcd212_w: Display Command Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, data, mem_mask); |
| 144 | COMBINE_DATA(&mcd212.channel[1 - (offset / 8)].dcr); |
| 145 | break; |
| 146 | case 0x04/2: |
| 147 | case 0x14/2: |
| 148 | verboselog(space->machine, 2, "mcd212_w: Video Start Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, data, mem_mask); |
| 149 | COMBINE_DATA(&mcd212.channel[1 - (offset / 8)].vsr); |
| 150 | break; |
| 151 | case 0x08/2: |
| 152 | case 0x18/2: |
| 153 | verboselog(space->machine, 2, "mcd212_w: Display Decoder Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, data, mem_mask); |
| 154 | COMBINE_DATA(&mcd212.channel[1 - (offset / 8)].ddr); |
| 155 | break; |
| 156 | case 0x0a/2: |
| 157 | case 0x1a/2: |
| 158 | verboselog(space->machine, 2, "mcd212_w: DCA Pointer Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, data, mem_mask); |
| 159 | COMBINE_DATA(&mcd212.channel[1 - (offset / 8)].dcp); |
| 160 | break; |
| 161 | default: |
| 162 | verboselog(space->machine, 2, "mcd212_w: Unknown Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, data, mem_mask); |
| 163 | break; |
| 164 | } |
| 165 | } |
| 124 | 166 | |
| 125 | | /* |
| 126 | | 1fffe6 bcr = border colour register |
| 127 | | w ........ nnnnnnnn in 8 bit mode |
| 128 | | w ........ nnnn.... in 4 bit mode |
| 129 | | */ |
| 130 | | /* |
| 131 | | (Note: not present on the original vreg listing) |
| 132 | | 1fffe8 dcr2 = display command register 2 |
| 133 | | w x....... ........ not used |
| 134 | | w .nn..... ........ OM = lower port of the video mode (with CM) |
| 135 | | w ...1.... ........ ID = Indipendent DCA bit |
| 136 | | w ....nn.. ........ MF = Mosaic Factor (2,4,8,16) |
| 137 | | w ......nn ........ FT = File Type (0/1 = bitmap, 2 = RLE, 3 = Mosaic) |
| 138 | | w ........ xxxx.... not used |
| 139 | | w ........ ....aaaa "data" (dunno the purpose...) |
| 140 | | */ |
| 141 | | #define SCC_DCR2_VREG (pcab_vregs[0x08/2] & 0xffff) |
| 142 | | |
| 143 | | /* |
| 144 | | (Note: not present on the original vreg listing) |
| 145 | | 1fffea dcp = ??? |
| 146 | | w aaaaaaaa aaaaaa-- "data" (dunno the purpose...) |
| 147 | | w -------- ------xx not used |
| 148 | | */ |
| 149 | | |
| 150 | | /* |
| 151 | | 1fffec swm = selective write mask register |
| 152 | | w nnnnnnnn ........ mask |
| 153 | | */ |
| 154 | | /* |
| 155 | | 1fffee stm = selective mask register |
| 156 | | w ........ nnnnnnnn mask |
| 157 | | */ |
| 158 | | /* |
| 159 | | 1ffff0 a = source register a |
| 160 | | w nnnnnnnn nnnnnnnn source |
| 161 | | */ |
| 162 | | #define SCC_SRCA_VREG (pcab_vregs[0x10/2] & 0xffff) |
| 163 | | |
| 164 | | /* |
| 165 | | 1ffff2 b = destination register b |
| 166 | | rw nnnnnnnn nnnnnnnn destination |
| 167 | | */ |
| 168 | | |
| 169 | | #define SCC_DSTB_VREG (pcab_vregs[0x12/2] & 0xffff) |
| 170 | | |
| 171 | | /* |
| 172 | | 1ffff4 pcr = pixac command register |
| 173 | | w 1....... ........ 4N = 8/4 bits per pixel |
| 174 | | w .1....00 ....x00. COL = enable colour2 function |
| 175 | | w .1....00 .....01. COL = enable colour1 function |
| 176 | | w .1...0.. .....10. COL = enable bcolour2 function |
| 177 | | w .1...0.. .....11. COL = enable bcolour1 function |
| 178 | | w ..1..000 ....x00. EXC = enable exchange function |
| 179 | | w ..1..000 .....01. EXC = enable swap function |
| 180 | | w ..1..000 .....10. EXC = enable inverted exchange function |
| 181 | | w ..1..000 .....11. EXC = enable inverted swap function |
| 182 | | w ...1..0. ....x00. CPY = enable copy type b function |
| 183 | | w ...1...0 ....x10. CPY = enable copy type a function |
| 184 | | w ...1..0. .....01. CPY = enable patch type b function |
| 185 | | w ...1...0 .....11. CPY = enable patch type a function |
| 186 | | w ....1000 .....00. CMP = enable compare function |
| 187 | | w ....1000 .....10. CMP = enable compact function |
| 188 | | w .....1.. ........ RTL = manipulate right to left |
| 189 | | w ......1. ........ SHK = shrink picture by factor 2 |
| 190 | | w .......1 ........ ZOM = zoom picture by factor 2 |
| 191 | | w ........ nnnn.... LGF = logical function |
| 192 | | w ........ 0000.... LGF = d=r |
| 193 | | w ........ 0001.... LGF = d=~r |
| 194 | | w ........ 0010.... LGF = d=0 |
| 195 | | w ........ 0011.... LGF = d=1 |
| 196 | | w ........ 0100.... LGF = d=~(d^r) |
| 197 | | w ........ 0101.... LGF = d=d^r |
| 198 | | w ........ 0110.... LGF = d=d&r |
| 199 | | w ........ 0111.... LGF = d=~d&r |
| 200 | | w ........ 1000.... LGF = d=~d&~r |
| 201 | | w ........ 1001.... LGF = d=d&~r |
| 202 | | w ........ 1010.... LGF = d=~d|r |
| 203 | | w ........ 1011.... LGF = d=d|r |
| 204 | | w ........ 1100.... LGF = d=d|~r |
| 205 | | w ........ 1101.... LGF = d=~d|~r |
| 206 | | w ........ 1110.... LGF = d=d |
| 207 | | w ........ 1111.... LGF = d=~d |
| 208 | | w ........ ....1... INV = invert transparancy state of source bits |
| 209 | | w ........ .....1.. BIT = copy: enable copy type a |
| 210 | | w ........ .....1.. BIT = colour: enable bcolour/colour |
| 211 | | w ........ .....1.. BIT = compare: compact/compare |
| 212 | | w ........ ......1. TT = perform transparancy test |
| 213 | | w ........ .......0 |
| 214 | | */ |
| 215 | | |
| 216 | | #define SCC_PCR_VREG (pcab_vregs[0x14/2] & 0xffff) |
| 217 | | |
| 218 | | /* |
| 219 | | 1ffff6 mask = mask register |
| 220 | | w ........ ....nnnn mask nibbles/0 |
| 221 | | */ |
| 222 | | /* |
| 223 | | 1ffff8 shift = shift register |
| 224 | | w ......nn ........ shift by .. during source alignment |
| 225 | | */ |
| 226 | | /* |
| 227 | | 1ffffa index = index register |
| 228 | | w ........ ......nn bcolour: use bit .. in the source word |
| 229 | | w ........ ......nn compact: nibble .. will hold the result |
| 230 | | */ |
| 231 | | /* |
| 232 | | 1ffffc fc/bc = foreground/background colour register |
| 233 | | w nnnnnnnn ........ FC = foreground colour |
| 234 | | w ........ nnnnnnnn BC = background colour |
| 235 | | */ |
| 236 | | /* |
| 237 | | 1ffffe tc = transparent colour register |
| 238 | | w nnnnnnnn ........ transparent colour |
| 239 | | */ |
| 240 | | |
| 241 | | |
| 242 | | |
| 243 | 167 | static VIDEO_START(cdi) |
| 244 | 168 | { |
| 245 | | |
| 169 | mcd212.channel[0].csrr = 0x00; |
| 170 | mcd212.channel[1].csrr = 0x00; |
| 246 | 171 | } |
| 247 | 172 | |
| 248 | 173 | static VIDEO_UPDATE(cdi) |
| 249 | 174 | { |
| 250 | | int x,y; |
| 251 | | UINT32 count; |
| 175 | //int x,y; |
| 176 | //UINT32 count; |
| 252 | 177 | |
| 253 | 178 | bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); //TODO |
| 254 | 179 | |
| 255 | | if(!(SCC_DE_VREG)) //display enable |
| 256 | | return 0; |
| 180 | //if(!(SCC_DE_VREG)) //display enable |
| 181 | // return 0; |
| 257 | 182 | |
| 183 | /* |
| 258 | 184 | count = ((SCC_VSR_VREG)/2); |
| 259 | 185 | |
| 260 | 186 | for(y=0;y<300;y++) |
| r5824 | r5825 | |
| 276 | 202 | count++; |
| 277 | 203 | } |
| 278 | 204 | } |
| 205 | */ |
| 279 | 206 | |
| 280 | 207 | return 0; |
| 281 | 208 | } |
| r5824 | r5825 | |
| 285 | 212 | * Memory map information * |
| 286 | 213 | *************************/ |
| 287 | 214 | |
| 288 | | static READ16_HANDLER( test_r ) |
| 215 | typedef struct |
| 289 | 216 | { |
| 290 | | return mame_rand(space->machine); |
| 291 | | } |
| 217 | UINT8 reserved0; |
| 218 | UINT8 data_register; |
| 219 | UINT8 reserved1; |
| 220 | UINT8 address_register; |
| 221 | UINT8 reserved2; |
| 222 | UINT8 status_register; |
| 223 | UINT8 reserved3; |
| 224 | UINT8 control_register; |
| 225 | UINT8 reserved; |
| 226 | UINT8 clock_control_register; |
| 227 | } scc68070_i2c_regs_t; |
| 292 | 228 | |
| 293 | | static WRITE16_HANDLER( paletteram_io_w ) |
| 229 | #define ISR_MST 0x80 // Master |
| 230 | #define ISR_TRX 0x40 // Transmitter |
| 231 | #define ISR_BB 0x20 // Busy |
| 232 | #define ISR_PIN 0x10 // No Pending Interrupt |
| 233 | #define ISR_AL 0x08 // Arbitration Lost |
| 234 | #define ISR_AAS 0x04 // Addressed As Slave |
| 235 | #define ISR_AD0 0x02 // Address Zero |
| 236 | #define ISR_LRB 0x01 // Last Received Bit |
| 237 | |
| 238 | typedef struct |
| 294 | 239 | { |
| 295 | | static int pal_offs,r,g,b,internal_pal_offs; |
| 240 | UINT8 reserved0; |
| 241 | UINT8 mode_register; |
| 242 | UINT8 reserved1; |
| 243 | UINT8 status_register; |
| 244 | UINT8 reserved2; |
| 245 | UINT8 clock_select; |
| 246 | UINT8 reserved3; |
| 247 | UINT8 command_register; |
| 248 | UINT8 reserved4; |
| 249 | UINT8 transmit_holding_register; |
| 250 | UINT8 reserved5; |
| 251 | UINT8 receive_holding_register; |
| 252 | } scc68070_uart_regs_t; |
| 296 | 253 | |
| 297 | | switch(offset*2) |
| 254 | #define UMR_OM 0xc0 |
| 255 | #define UMR_OM_NORMAL 0x00 |
| 256 | #define UMR_OM_ECHO 0x40 |
| 257 | #define UMR_OM_LOOPBACK 0x80 |
| 258 | #define UMR_OM_RLOOP 0xc0 |
| 259 | #define UMR_TXC 0x10 |
| 260 | #define UMR_PC 0x08 |
| 261 | #define UMR_P 0x04 |
| 262 | #define UMR_SB 0x02 |
| 263 | #define UMR_CL 0x01 |
| 264 | |
| 265 | #define USR_RB 0x80 |
| 266 | #define USR_FE 0x40 |
| 267 | #define USR_PE 0x20 |
| 268 | #define USR_OE 0x10 |
| 269 | #define USR_TXEMT 0x08 |
| 270 | #define USR_TXRDY 0x04 |
| 271 | #define USR_RXRDY 0x01 |
| 272 | |
| 273 | typedef struct |
| 274 | { |
| 275 | UINT8 timer_status_register; |
| 276 | UINT8 timer_control_register; |
| 277 | UINT16 reload_register; |
| 278 | UINT16 timer0; |
| 279 | UINT16 timer1; |
| 280 | UINT16 timer2; |
| 281 | } scc68070_timer_regs_t; |
| 282 | |
| 283 | #define TSR_OV0 0x80 |
| 284 | #define TSR_MA1 0x40 |
| 285 | #define TSR_CAP1 0x20 |
| 286 | #define TSR_OV1 0x10 |
| 287 | #define TSR_MA2 0x08 |
| 288 | #define TSR_CAP2 0x04 |
| 289 | #define TSR_OV2 0x02 |
| 290 | |
| 291 | #define TCR_E1 0xc0 |
| 292 | #define TCR_E1_NONE 0x00 |
| 293 | #define TCR_E1_RISING 0x40 |
| 294 | #define TCR_E1_FALLING 0x80 |
| 295 | #define TCR_E1_BOTH 0xc0 |
| 296 | #define TCR_M1 0x30 |
| 297 | #define TCR_M1_NONE 0x00 |
| 298 | #define TCR_M1_MATCH 0x10 |
| 299 | #define TCR_M1_CAPTURE 0x20 |
| 300 | #define TCR_M1_COUNT 0x30 |
| 301 | #define TCR_E2 0x0c |
| 302 | #define TCR_E2_NONE 0x00 |
| 303 | #define TCR_E2_RISING 0x04 |
| 304 | #define TCR_E2_FALLING 0x08 |
| 305 | #define TCR_E2_BOTH 0x0c |
| 306 | #define TCR_M2 0x03 |
| 307 | #define TCR_M2_NONE 0x00 |
| 308 | #define TCR_M2_MATCH 0x01 |
| 309 | #define TCR_M2_CAPTURE 0x02 |
| 310 | #define TCR_M2_COUNT 0x03 |
| 311 | |
| 312 | typedef struct |
| 313 | { |
| 314 | UINT8 channel_status; |
| 315 | UINT8 channel_error; |
| 316 | |
| 317 | UINT8 reserved0[2]; |
| 318 | |
| 319 | UINT8 device_control; |
| 320 | UINT8 operation_control; |
| 321 | UINT8 sequence_control; |
| 322 | UINT8 channel_control; |
| 323 | |
| 324 | UINT8 reserved1[3]; |
| 325 | |
| 326 | UINT8 transfer_counter; |
| 327 | |
| 328 | UINT32 memory_address_counter; |
| 329 | |
| 330 | UINT8 reserved2[4]; |
| 331 | |
| 332 | UINT32 device_address_counter; |
| 333 | |
| 334 | UINT8 reserved3[40]; |
| 335 | } scc68070_dma_channel_t; |
| 336 | |
| 337 | #define CSR_COC 0x80 |
| 338 | #define CSR_NDT 0x20 |
| 339 | #define CSR_ERR 0x10 |
| 340 | #define CSR_CA 0x08 |
| 341 | |
| 342 | #define CER_EC 0x1f |
| 343 | #define CER_NONE 0x00 |
| 344 | #define CER_TIMING 0x02 |
| 345 | #define CER_BUSERR_MEM 0x09 |
| 346 | #define CER_BUSERR_DEV 0x0a |
| 347 | #define CER_SOFT_ABORT 0x11 |
| 348 | |
| 349 | #define DCR1_ERM 0x80 |
| 350 | #define DCR1_DT 0x30 |
| 351 | |
| 352 | #define DCR2_ERM 0x80 |
| 353 | #define DCR2_DT 0x30 |
| 354 | #define DCR2_DS 0x08 |
| 355 | |
| 356 | #define OCR_D 0x80 |
| 357 | #define OCR_D_M2D 0x00 |
| 358 | #define OCR_D_D2M 0x80 |
| 359 | #define OCR_OS 0x30 |
| 360 | #define OCR_OS_BYTE 0x00 |
| 361 | #define OCR_OS_WORD 0x10 |
| 362 | |
| 363 | #define SCR2_MAC 0x0c |
| 364 | #define SCR2_MAC_NONE 0x00 |
| 365 | #define SCR2_MAC_INC 0x04 |
| 366 | #define SCR2_DAC 0x03 |
| 367 | #define SCR2_DAC_NONE 0x00 |
| 368 | #define SCR2_DAC_INC 0x01 |
| 369 | |
| 370 | #define CCR_SO 0x80 |
| 371 | #define CCR_SA 0x10 |
| 372 | #define CCR_INE 0x08 |
| 373 | #define CCR_IPL 0x07 |
| 374 | |
| 375 | typedef struct |
| 376 | { |
| 377 | scc68070_dma_channel_t channel[2]; |
| 378 | } scc68070_dma_regs_t; |
| 379 | |
| 380 | typedef struct |
| 381 | { |
| 382 | UINT16 attr; |
| 383 | UINT16 length; |
| 384 | UINT8 undefined; |
| 385 | UINT8 segment; |
| 386 | UINT16 base; |
| 387 | } scc68070_mmu_desc_t; |
| 388 | |
| 389 | typedef struct |
| 390 | { |
| 391 | UINT8 status; |
| 392 | UINT8 control; |
| 393 | |
| 394 | UINT8 reserved[0x3e]; |
| 395 | |
| 396 | scc68070_mmu_desc_t desc[8]; |
| 397 | } scc68070_mmu_regs_t; |
| 398 | |
| 399 | typedef struct |
| 400 | { |
| 401 | UINT16 lir; |
| 402 | scc68070_i2c_regs_t i2c; |
| 403 | scc68070_uart_regs_t uart; |
| 404 | scc68070_timer_regs_t timers; |
| 405 | UINT8 picr1; |
| 406 | UINT8 picr2; |
| 407 | scc68070_dma_regs_t dma; |
| 408 | scc68070_mmu_regs_t mmu; |
| 409 | } scc68070_regs_t; |
| 410 | |
| 411 | scc68070_regs_t scc68070_regs; |
| 412 | |
| 413 | static READ16_HANDLER( scc68070_periphs_r ) |
| 414 | { |
| 415 | switch(offset) |
| 298 | 416 | { |
| 299 | | case 0: |
| 300 | | pal_offs = data; |
| 417 | // Interupts: 80001001 |
| 418 | case 0x1000/2: // LIR priority level |
| 419 | return scc68070_regs.lir; |
| 420 | |
| 421 | // I2C interface: 80002001 to 80002009 |
| 422 | case 0x2000/2: |
| 423 | if(ACCESSING_BITS_0_7) |
| 424 | { |
| 425 | verboselog(space->machine, 2, "scc68070_periphs_w: I2C Data Register: %04x & %04x\n", scc68070_regs.i2c.data_register, mem_mask); |
| 426 | } |
| 427 | return scc68070_regs.i2c.data_register; |
| 428 | case 0x2002/2: |
| 429 | if(ACCESSING_BITS_0_7) |
| 430 | { |
| 431 | verboselog(space->machine, 2, "scc68070_periphs_w: I2C Address Register: %04x & %04x\n", scc68070_regs.i2c.address_register, mem_mask); |
| 432 | } |
| 433 | return scc68070_regs.i2c.address_register; |
| 434 | case 0x2004/2: |
| 435 | if(ACCESSING_BITS_0_7) |
| 436 | { |
| 437 | verboselog(space->machine, 2, "scc68070_periphs_w: I2C Status Register: %04x & %04x\n", scc68070_regs.i2c.status_register, mem_mask); |
| 438 | } |
| 439 | return scc68070_regs.i2c.status_register; |
| 440 | case 0x2006/2: |
| 441 | if(ACCESSING_BITS_0_7) |
| 442 | { |
| 443 | verboselog(space->machine, 2, "scc68070_periphs_w: I2C Control Register: %04x & %04x\n", scc68070_regs.i2c.control_register, mem_mask); |
| 444 | } |
| 445 | return scc68070_regs.i2c.control_register; |
| 446 | case 0x2008/2: |
| 447 | if(ACCESSING_BITS_0_7) |
| 448 | { |
| 449 | verboselog(space->machine, 2, "scc68070_periphs_w: I2C Clock Control Register: %04x & %04x\n", scc68070_regs.i2c.clock_control_register, mem_mask); |
| 450 | } |
| 451 | return scc68070_regs.i2c.clock_control_register; |
| 452 | |
| 453 | // UART interface: 80002011 to 8000201b |
| 454 | case 0x2010/2: |
| 455 | if(ACCESSING_BITS_0_7) |
| 456 | { |
| 457 | verboselog(space->machine, 2, "scc68070_periphs_r: UART Mode Register: %04x & %04x\n", scc68070_regs.uart.mode_register, mem_mask); |
| 458 | } |
| 459 | return scc68070_regs.uart.mode_register; |
| 460 | case 0x2012/2: |
| 461 | if(ACCESSING_BITS_0_7) |
| 462 | { |
| 463 | verboselog(space->machine, 2, "scc68070_periphs_r: UART Status Register: %04x & %04x\n", scc68070_regs.uart.status_register, mem_mask); |
| 464 | } |
| 465 | return scc68070_regs.uart.status_register | USR_TXRDY | USR_RXRDY; |
| 466 | case 0x2014/2: |
| 467 | if(ACCESSING_BITS_0_7) |
| 468 | { |
| 469 | verboselog(space->machine, 2, "scc68070_periphs_r: UART Clock Select: %04x & %04x\n", scc68070_regs.uart.clock_select, mem_mask); |
| 470 | } |
| 471 | return scc68070_regs.uart.clock_select; |
| 472 | case 0x2016/2: |
| 473 | if(ACCESSING_BITS_0_7) |
| 474 | { |
| 475 | verboselog(space->machine, 2, "scc68070_periphs_r: UART Command Register: %02x & %04x\n", scc68070_regs.uart.command_register, mem_mask); |
| 476 | } |
| 477 | return scc68070_regs.uart.command_register; |
| 478 | case 0x2018/2: |
| 479 | if(ACCESSING_BITS_0_7) |
| 480 | { |
| 481 | verboselog(space->machine, 2, "scc68070_periphs_r: UART Transmit Holding Register: %02x & %04x\n", scc68070_regs.uart.transmit_holding_register, mem_mask); |
| 482 | } |
| 483 | return scc68070_regs.uart.transmit_holding_register; |
| 484 | case 0x201a/2: |
| 485 | if(ACCESSING_BITS_0_7) |
| 486 | { |
| 487 | verboselog(space->machine, 2, "scc68070_periphs_r: UART Receive Holding Register: %02x & %04x\n", scc68070_regs.uart.receive_holding_register, mem_mask); |
| 488 | } |
| 489 | return scc68070_regs.uart.receive_holding_register; |
| 490 | |
| 491 | // Timers: 80002020 to 80002029 |
| 492 | case 0x2020/2: |
| 493 | if(ACCESSING_BITS_0_7) |
| 494 | { |
| 495 | verboselog(space->machine, 2, "scc68070_periphs_r: Timer Status Register: %02x & %04x\n", scc68070_regs.timers.timer_status_register, mem_mask); |
| 496 | } |
| 497 | if(ACCESSING_BITS_8_15) |
| 498 | { |
| 499 | verboselog(space->machine, 2, "scc68070_periphs_r: Timer Control Register: %02x & %04x\n", scc68070_regs.timers.timer_control_register, mem_mask); |
| 500 | } |
| 501 | return (scc68070_regs.timers.timer_control_register << 8) | scc68070_regs.timers.timer_status_register; |
| 301 | 502 | break; |
| 302 | | case 4: |
| 303 | | internal_pal_offs = 0; |
| 503 | case 0x2022/2: |
| 504 | verboselog(space->machine, 2, "scc68070_periphs_r: Timer Reload Register: %04x & %04x\n", scc68070_regs.timers.reload_register, mem_mask); |
| 505 | return scc68070_regs.timers.reload_register; |
| 506 | case 0x2024/2: |
| 507 | verboselog(space->machine, 2, "scc68070_periphs_r: Timer 0: %04x & %04x\n", scc68070_regs.timers.timer0, mem_mask); |
| 508 | return scc68070_regs.timers.timer0; |
| 509 | case 0x2026/2: |
| 510 | verboselog(space->machine, 2, "scc68070_periphs_r: Timer 1: %04x & %04x\n", scc68070_regs.timers.timer1, mem_mask); |
| 511 | return scc68070_regs.timers.timer1; |
| 512 | case 0x2028/2: |
| 513 | verboselog(space->machine, 2, "scc68070_periphs_r: Timer 2: %04x & %04x\n", scc68070_regs.timers.timer2, mem_mask); |
| 514 | return scc68070_regs.timers.timer2; |
| 515 | |
| 516 | // PICR1: 80002045 |
| 517 | case 0x2044/2: |
| 518 | if(ACCESSING_BITS_0_7) |
| 519 | { |
| 520 | verboselog(space->machine, 2, "scc68070_periphs_r: Peripheral Interrupt Control Register 1: %02x & %04x\n", scc68070_regs.picr1, mem_mask); |
| 521 | } |
| 522 | return scc68070_regs.picr1; |
| 523 | |
| 524 | // PICR2: 80002047 |
| 525 | case 0x2046/2: |
| 526 | if(ACCESSING_BITS_0_7) |
| 527 | { |
| 528 | verboselog(space->machine, 2, "scc68070_periphs_r: Peripheral Interrupt Control Register 2: %02x & %04x\n", scc68070_regs.picr2, mem_mask); |
| 529 | } |
| 530 | return scc68070_regs.picr2; |
| 531 | |
| 532 | // DMA controller: 80004000 to 8000406d |
| 533 | case 0x4000/2: |
| 534 | case 0x4040/2: |
| 535 | if(ACCESSING_BITS_0_7) |
| 536 | { |
| 537 | verboselog(space->machine, 2, "scc68070_periphs_r: DMA(%d) Error Register: %04x & %04x\n", (offset - 0x2000) / 32, scc68070_regs.dma.channel[(offset - 0x2000) / 32].channel_error, mem_mask); |
| 538 | } |
| 539 | if(ACCESSING_BITS_8_15) |
| 540 | { |
| 541 | verboselog(space->machine, 2, "scc68070_periphs_r: DMA(%d) Status Register: %04x & %04x\n", (offset - 0x2000) / 32, scc68070_regs.dma.channel[(offset - 0x2000) / 32].channel_status, mem_mask); |
| 542 | } |
| 543 | return (scc68070_regs.dma.channel[(offset - 0x2000) / 32].channel_status << 8) | scc68070_regs.dma.channel[(offset - 0x2000) / 32].channel_error; |
| 304 | 544 | break; |
| 305 | | case 2: |
| 306 | | switch(internal_pal_offs) |
| 545 | case 0x4004/2: |
| 546 | case 0x4044/2: |
| 547 | if(ACCESSING_BITS_0_7) |
| 307 | 548 | { |
| 308 | | case 0: |
| 309 | | r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4); |
| 310 | | internal_pal_offs++; |
| 311 | | break; |
| 312 | | case 1: |
| 313 | | g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4); |
| 314 | | internal_pal_offs++; |
| 315 | | break; |
| 316 | | case 2: |
| 317 | | b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4); |
| 318 | | palette_set_color(space->machine, pal_offs, MAKE_RGB(r, g, b)); |
| 319 | | internal_pal_offs = 0; |
| 320 | | pal_offs++; |
| 321 | | break; |
| 549 | verboselog(space->machine, 2, "scc68070_periphs_r: DMA(%d) Operation Control Register: %02x & %04x\n", (offset - 0x2000) / 32, scc68070_regs.dma.channel[(offset - 0x2000) / 32].operation_control, mem_mask); |
| 322 | 550 | } |
| 551 | if(ACCESSING_BITS_8_15) |
| 552 | { |
| 553 | verboselog(space->machine, 2, "scc68070_periphs_r: DMA(%d) Device Control Register: %02x & %04x\n", (offset - 0x2000) / 32, scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_control, mem_mask); |
| 554 | } |
| 555 | return (scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_control << 8) | scc68070_regs.dma.channel[(offset - 0x2000) / 32].operation_control; |
| 556 | case 0x4006/2: |
| 557 | case 0x4046/2: |
| 558 | if(ACCESSING_BITS_0_7) |
| 559 | { |
| 560 | verboselog(space->machine, 2, "scc68070_periphs_r: DMA(%d) Channel Control Register: %02x & %04x\n", (offset - 0x2000) / 32, scc68070_regs.dma.channel[(offset - 0x2000) / 32].channel_control, mem_mask); |
| 561 | } |
| 562 | if(ACCESSING_BITS_8_15) |
| 563 | { |
| 564 | verboselog(space->machine, 2, "scc68070_periphs_r: DMA(%d) Sequence Control Register: %02x & %04x\n", (offset - 0x2000) / 32, scc68070_regs.dma.channel[(offset - 0x2000) / 32].sequence_control, mem_mask); |
| 565 | } |
| 566 | return (scc68070_regs.dma.channel[(offset - 0x2000) / 32].sequence_control << 8) | scc68070_regs.dma.channel[(offset - 0x2000) / 32].channel_control; |
| 567 | case 0x400a/2: |
| 568 | if(ACCESSING_BITS_0_7) |
| 569 | { |
| 570 | verboselog(space->machine, 2, "scc68070_periphs_r: DMA(%d) Memory Transfer Counter Low: %02x & %04x\n", (offset - 0x2000) / 32, scc68070_regs.dma.channel[(offset - 0x2000) / 32].transfer_counter, mem_mask); |
| 571 | } |
| 572 | if(ACCESSING_BITS_8_15) |
| 573 | { |
| 574 | verboselog(space->machine, 0, "scc68070_periphs_r: DMA(%d) Memory Transfer Counter High (invalid): %04x\n", (offset - 0x2000) / 32, mem_mask); |
| 575 | } |
| 576 | return scc68070_regs.dma.channel[(offset - 0x2000) / 32].transfer_counter; |
| 577 | case 0x400c/2: |
| 578 | case 0x404c/2: |
| 579 | verboselog(space->machine, 2, "scc68070_periphs_r: DMA(%d) Memory Address Counter (High Word): %04x & %04x\n", (offset - 0x2000) / 32, (scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter >> 16), mem_mask); |
| 580 | return (scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter >> 16); |
| 581 | case 0x400e/2: |
| 582 | case 0x404e/2: |
| 583 | verboselog(space->machine, 2, "scc68070_periphs_r: DMA(%d) Memory Address Counter (Low Word): %04x & %04x\n", (offset - 0x2000) / 32, scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter, mem_mask); |
| 584 | return scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter; |
| 585 | case 0x4014/2: |
| 586 | case 0x4054/2: |
| 587 | verboselog(space->machine, 2, "scc68070_periphs_r: DMA(%d) Device Address Counter (High Word): %04x & %04x\n", (offset - 0x2000) / 32, (scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter >> 16), mem_mask); |
| 588 | return (scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter >> 16); |
| 589 | case 0x4016/2: |
| 590 | case 0x4056/2: |
| 591 | verboselog(space->machine, 2, "scc68070_periphs_r: DMA(%d) Device Address Counter (Low Word): %04x & %04x\n", (offset - 0x2000) / 32, scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter, mem_mask); |
| 592 | return scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter; |
| 323 | 593 | |
| 594 | // MMU: 80008000 to 8000807f |
| 595 | case 0x8000/2: // Status / Control register |
| 596 | if(ACCESSING_BITS_0_7) |
| 597 | { // Control |
| 598 | verboselog(space->machine, 2, "scc68070_periphs_r: MMU Control: %02x & %04x\n", scc68070_regs.mmu.control, mem_mask); |
| 599 | return scc68070_regs.mmu.control; |
| 600 | } // Status |
| 601 | else |
| 602 | { |
| 603 | verboselog(space->machine, 2, "scc68070_periphs_r: MMU Status: %02x & %04x\n", scc68070_regs.mmu.status, mem_mask); |
| 604 | return scc68070_regs.mmu.status; |
| 605 | } |
| 324 | 606 | break; |
| 607 | case 0x8040/2: |
| 608 | case 0x8048/2: |
| 609 | case 0x8050/2: |
| 610 | case 0x8058/2: |
| 611 | case 0x8060/2: |
| 612 | case 0x8068/2: |
| 613 | case 0x8070/2: |
| 614 | case 0x8078/2: // Attributes (SD0-7) |
| 615 | verboselog(space->machine, 2, "scc68070_periphs_r: MMU descriptor %d attributes: %04x & %04x\n", (offset - 0x4020) / 4, scc68070_regs.mmu.desc[(offset - 0x4020) / 4].attr, mem_mask); |
| 616 | return scc68070_regs.mmu.desc[(offset - 0x4020) / 4].attr; |
| 617 | case 0x8042/2: |
| 618 | case 0x804a/2: |
| 619 | case 0x8052/2: |
| 620 | case 0x805a/2: |
| 621 | case 0x8062/2: |
| 622 | case 0x806a/2: |
| 623 | case 0x8072/2: |
| 624 | case 0x807a/2: // Segment Length (SD0-7) |
| 625 | verboselog(space->machine, 2, "scc68070_periphs_r: MMU descriptor %d length: %04x & %04x\n", (offset - 0x4020) / 4, scc68070_regs.mmu.desc[(offset - 0x4020) / 4].length, mem_mask); |
| 626 | return scc68070_regs.mmu.desc[(offset - 0x4020) / 4].length; |
| 627 | case 0x8044/2: |
| 628 | case 0x804c/2: |
| 629 | case 0x8054/2: |
| 630 | case 0x805c/2: |
| 631 | case 0x8064/2: |
| 632 | case 0x806c/2: |
| 633 | case 0x8074/2: |
| 634 | case 0x807c/2: // Segment Number (SD0-7, A0=1 only) |
| 635 | if(ACCESSING_BITS_0_7) |
| 636 | { |
| 637 | verboselog(space->machine, 2, "scc68070_periphs_r: MMU descriptor %d segment: %02x & %04x\n", (offset - 0x4020) / 4, scc68070_regs.mmu.desc[(offset - 0x4020) / 4].segment, mem_mask); |
| 638 | return scc68070_regs.mmu.desc[(offset - 0x4020) / 4].segment; |
| 639 | } |
| 640 | break; |
| 641 | case 0x8046/2: |
| 642 | case 0x804e/2: |
| 643 | case 0x8056/2: |
| 644 | case 0x805e/2: |
| 645 | case 0x8066/2: |
| 646 | case 0x806e/2: |
| 647 | case 0x8076/2: |
| 648 | case 0x807e/2: // Base Address (SD0-7) |
| 649 | verboselog(space->machine, 2, "scc68070_periphs_r: MMU descriptor %d base: %04x & %04x\n", (offset - 0x4020) / 4, scc68070_regs.mmu.desc[(offset - 0x4020) / 4].base, mem_mask); |
| 650 | return scc68070_regs.mmu.desc[(offset - 0x4020) / 4].base; |
| 325 | 651 | } |
| 652 | |
| 653 | return 0; |
| 326 | 654 | } |
| 327 | 655 | |
| 328 | | static READ16_HANDLER( philips_66470_r ) |
| 656 | static WRITE16_HANDLER( scc68070_periphs_w ) |
| 329 | 657 | { |
| 330 | 658 | switch(offset) |
| 331 | 659 | { |
| 332 | | // case 0/2: |
| 333 | | // return mame_rand(space->machine); //TODO |
| 334 | | } |
| 660 | // Interupts: 80001001 |
| 661 | case 0x1000/2: // LIR priority level |
| 662 | COMBINE_DATA(&scc68070_regs.lir); |
| 663 | break; |
| 335 | 664 | |
| 336 | | printf("[%04x]\n",offset*2); |
| 665 | // I2C interface: 80002001 to 80002009 |
| 666 | case 0x2000/2: |
| 667 | if(ACCESSING_BITS_0_7) |
| 668 | { |
| 669 | verboselog(space->machine, 2, "scc68070_periphs_w: I2C Data Register: %04x & %04x\n", data, mem_mask); |
| 670 | scc68070_regs.i2c.data_register = data & 0x00ff; |
| 671 | } |
| 672 | break; |
| 673 | case 0x2002/2: |
| 674 | if(ACCESSING_BITS_0_7) |
| 675 | { |
| 676 | verboselog(space->machine, 2, "scc68070_periphs_w: I2C Address Register: %04x & %04x\n", data, mem_mask); |
| 677 | scc68070_regs.i2c.address_register = data & 0x00ff; |
| 678 | } |
| 679 | break; |
| 680 | case 0x2004/2: |
| 681 | if(ACCESSING_BITS_0_7) |
| 682 | { |
| 683 | verboselog(space->machine, 2, "scc68070_periphs_w: I2C Status Register: %04x & %04x\n", data, mem_mask); |
| 684 | scc68070_regs.i2c.status_register = data & 0x00ff; |
| 685 | } |
| 686 | break; |
| 687 | case 0x2006/2: |
| 688 | if(ACCESSING_BITS_0_7) |
| 689 | { |
| 690 | verboselog(space->machine, 2, "scc68070_periphs_w: I2C Control Register: %04x & %04x\n", data, mem_mask); |
| 691 | scc68070_regs.i2c.control_register = data & 0x00ff; |
| 692 | } |
| 693 | break; |
| 694 | case 0x2008/2: |
| 695 | if(ACCESSING_BITS_0_7) |
| 696 | { |
| 697 | verboselog(space->machine, 2, "scc68070_periphs_w: I2C Clock Control Register: %04x & %04x\n", data, mem_mask); |
| 698 | scc68070_regs.i2c.clock_control_register = data & 0x00ff; |
| 699 | } |
| 700 | break; |
| 337 | 701 | |
| 702 | // UART interface: 80002011 to 8000201b |
| 703 | case 0x2010/2: |
| 704 | if(ACCESSING_BITS_0_7) |
| 705 | { |
| 706 | verboselog(space->machine, 2, "scc68070_periphs_w: UART Mode Register: %04x & %04x\n", data, mem_mask); |
| 707 | scc68070_regs.uart.mode_register = data & 0x00ff; |
| 708 | } |
| 709 | break; |
| 710 | case 0x2012/2: |
| 711 | if(ACCESSING_BITS_0_7) |
| 712 | { |
| 713 | verboselog(space->machine, 2, "scc68070_periphs_w: UART Status Register: %04x & %04x\n", data, mem_mask); |
| 714 | scc68070_regs.uart.status_register = data & 0x00ff; |
| 715 | } |
| 716 | break; |
| 717 | case 0x2014/2: |
| 718 | if(ACCESSING_BITS_0_7) |
| 719 | { |
| 720 | verboselog(space->machine, 2, "scc68070_periphs_w: UART Clock Select: %04x & %04x\n", data, mem_mask); |
| 721 | scc68070_regs.uart.clock_select = data & 0x00ff; |
| 722 | } |
| 723 | break; |
| 724 | case 0x2016/2: |
| 725 | if(ACCESSING_BITS_0_7) |
| 726 | { |
| 727 | verboselog(space->machine, 2, "scc68070_periphs_w: UART Command Register: %04x & %04x\n", data, mem_mask); |
| 728 | scc68070_regs.uart.command_register = data & 0x00ff; |
| 729 | } |
| 730 | break; |
| 731 | case 0x2018/2: |
| 732 | if(ACCESSING_BITS_0_7) |
| 733 | { |
| 734 | verboselog(space->machine, 2, "scc68070_periphs_w: UART Transmit Holding Register: %04x & %04x\n", data, mem_mask); |
| 735 | scc68070_regs.uart.transmit_holding_register = data & 0x00ff; |
| 736 | } |
| 737 | break; |
| 738 | case 0x201a/2: |
| 739 | if(ACCESSING_BITS_0_7) |
| 740 | { |
| 741 | verboselog(space->machine, 2, "scc68070_periphs_w: UART Receive Holding Register: %04x & %04x\n", data, mem_mask); |
| 742 | scc68070_regs.uart.receive_holding_register = data & 0x00ff; |
| 743 | } |
| 744 | break; |
| 338 | 745 | |
| 339 | | return pcab_vregs[offset]; |
| 340 | | } |
| 746 | // Timers: 80002020 to 80002029 |
| 747 | case 0x2020/2: |
| 748 | if(ACCESSING_BITS_0_7) |
| 749 | { |
| 750 | verboselog(space->machine, 2, "scc68070_periphs_w: Timer Status Register: %04x & %04x\n", data, mem_mask); |
| 751 | scc68070_regs.timers.timer_status_register = data & 0x00ff; |
| 752 | } |
| 753 | if(ACCESSING_BITS_8_15) |
| 754 | { |
| 755 | verboselog(space->machine, 2, "scc68070_periphs_w: Timer Control Register: %04x & %04x\n", data, mem_mask); |
| 756 | scc68070_regs.timers.timer_control_register = data >> 8; |
| 757 | } |
| 758 | break; |
| 759 | case 0x2022/2: |
| 760 | verboselog(space->machine, 2, "scc68070_periphs_w: Timer Reload Register: %04x & %04x\n", data, mem_mask); |
| 761 | COMBINE_DATA(&scc68070_regs.timers.reload_register); |
| 762 | break; |
| 763 | case 0x2024/2: |
| 764 | verboselog(space->machine, 2, "scc68070_periphs_w: Timer 0: %04x & %04x\n", data, mem_mask); |
| 765 | COMBINE_DATA(&scc68070_regs.timers.timer0); |
| 766 | break; |
| 767 | case 0x2026/2: |
| 768 | verboselog(space->machine, 2, "scc68070_periphs_w: Timer 1: %04x & %04x\n", data, mem_mask); |
| 769 | COMBINE_DATA(&scc68070_regs.timers.timer1); |
| 770 | break; |
| 771 | case 0x2028/2: |
| 772 | verboselog(space->machine, 2, "scc68070_periphs_w: Timer 2: %04x & %04x\n", data, mem_mask); |
| 773 | COMBINE_DATA(&scc68070_regs.timers.timer2); |
| 774 | break; |
| 341 | 775 | |
| 342 | | static WRITE16_HANDLER( philips_66470_w ) |
| 343 | | { |
| 344 | | COMBINE_DATA(&pcab_vregs[offset]); |
| 776 | // PICR1: 80002045 |
| 777 | case 0x2044/2: |
| 778 | if(ACCESSING_BITS_0_7) |
| 779 | { |
| 780 | verboselog(space->machine, 2, "scc68070_periphs_w: Peripheral Interrupt Control Register 1: %04x & %04x\n", data, mem_mask); |
| 781 | scc68070_regs.picr1 = data & 0x00ff; |
| 782 | } |
| 783 | break; |
| 345 | 784 | |
| 346 | | // if(offset == 0x10/2) |
| 347 | | // { |
| 348 | | //printf("%04x %04x %04x\n",data,pcab_vregs[0x12/2],pcab_vregs[0x14/2]); |
| 349 | | //pcab_vregs[0x12/2] = pcab_vregs[0x10/2]; |
| 350 | | // } |
| 785 | // PICR2: 80002047 |
| 786 | case 0x2046/2: |
| 787 | if(ACCESSING_BITS_0_7) |
| 788 | { |
| 789 | verboselog(space->machine, 2, "scc68070_periphs_w: Peripheral Interrupt Control Register 2: %04x & %04x\n", data, mem_mask); |
| 790 | scc68070_regs.picr2 = data & 0x00ff; |
| 791 | } |
| 792 | break; |
| 793 | |
| 794 | // DMA controller: 80004000 to 8000406d |
| 795 | case 0x4000/2: |
| 796 | case 0x4040/2: |
| 797 | if(ACCESSING_BITS_0_7) |
| 798 | { |
| 799 | verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Error (invalid): %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask); |
| 800 | } |
| 801 | if(ACCESSING_BITS_8_15) |
| 802 | { |
| 803 | verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Status: %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask); |
| 804 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].channel_status = data >> 8; |
| 805 | } |
| 806 | break; |
| 807 | case 0x4004/2: |
| 808 | case 0x4044/2: |
| 809 | if(ACCESSING_BITS_0_7) |
| 810 | { |
| 811 | verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Operation Control Register: %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask); |
| 812 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].operation_control = data >> 8; |
| 813 | } |
| 814 | if(ACCESSING_BITS_8_15) |
| 815 | { |
| 816 | verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Device Control Register: %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask); |
| 817 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_control = data >> 8; |
| 818 | } |
| 819 | break; |
| 820 | case 0x4006/2: |
| 821 | case 0x4046/2: |
| 822 | if(ACCESSING_BITS_0_7) |
| 823 | { |
| 824 | verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Channel Control Register: %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask); |
| 825 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].channel_control = data >> 8; |
| 826 | } |
| 827 | if(ACCESSING_BITS_8_15) |
| 828 | { |
| 829 | verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Sequence Control Register: %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask); |
| 830 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].sequence_control = data >> 8; |
| 831 | } |
| 832 | break; |
| 833 | case 0x400a/2: |
| 834 | if(ACCESSING_BITS_0_7) |
| 835 | { |
| 836 | verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Memory Transfer Counter Low: %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask); |
| 837 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].transfer_counter = data >> 8; |
| 838 | } |
| 839 | if(ACCESSING_BITS_8_15) |
| 840 | { |
| 841 | verboselog(space->machine, 0, "scc68070_periphs_w: DMA(%d) Memory Transfer Counter High (invalid): %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask); |
| 842 | } |
| 843 | break; |
| 844 | case 0x400c/2: |
| 845 | case 0x404c/2: |
| 846 | verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Memory Address Counter (High Word): %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask); |
| 847 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter &= mem_mask << 16; |
| 848 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter |= data << 16; |
| 849 | break; |
| 850 | case 0x400e/2: |
| 851 | case 0x404e/2: |
| 852 | verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Memory Address Counter (Low Word): %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask); |
| 853 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter &= (0xffff0000) | mem_mask; |
| 854 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter |= data; |
| 855 | break; |
| 856 | case 0x4014/2: |
| 857 | case 0x4054/2: |
| 858 | verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Device Address Counter (High Word): %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask); |
| 859 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter &= mem_mask << 16; |
| 860 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter |= data << 16; |
| 861 | break; |
| 862 | case 0x4016/2: |
| 863 | case 0x4056/2: |
| 864 | verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Device Address Counter (Low Word): %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask); |
| 865 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter &= (0xffff0000) | mem_mask; |
| 866 | scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter |= data; |
| 867 | break; |
| 868 | |
| 869 | // MMU: 80008000 to 8000807f |
| 870 | case 0x8000/2: // Status / Control register |
| 871 | if(ACCESSING_BITS_0_7) |
| 872 | { // Control |
| 873 | verboselog(space->machine, 2, "scc68070_periphs_w: MMU Control: %04x & %04x\n", data, mem_mask); |
| 874 | scc68070_regs.mmu.control = data & 0x00ff; |
| 875 | } // Status |
| 876 | else |
| 877 | { |
| 878 | verboselog(space->machine, 0, "scc68070_periphs_w: MMU Status (invalid): %04x & %04x\n", data, mem_mask); |
| 879 | } |
| 880 | break; |
| 881 | case 0x8040/2: |
| 882 | case 0x8048/2: |
| 883 | case 0x8050/2: |
| 884 | case 0x8058/2: |
| 885 | case 0x8060/2: |
| 886 | case 0x8068/2: |
| 887 | case 0x8070/2: |
| 888 | case 0x8078/2: // Attributes (SD0-7) |
| 889 | verboselog(space->machine, 2, "scc68070_periphs_w: MMU descriptor %d attributes: %04x & %04x\n", (offset - 0x4020) / 4, data, mem_mask); |
| 890 | COMBINE_DATA(&scc68070_regs.mmu.desc[(offset - 0x4020) / 4].attr); |
| 891 | break; |
| 892 | case 0x8042/2: |
| 893 | case 0x804a/2: |
| 894 | case 0x8052/2: |
| 895 | case 0x805a/2: |
| 896 | case 0x8062/2: |
| 897 | case 0x806a/2: |
| 898 | case 0x8072/2: |
| 899 | case 0x807a/2: // Segment Length (SD0-7) |
| 900 | verboselog(space->machine, 2, "scc68070_periphs_w: MMU descriptor %d length: %04x & %04x\n", (offset - 0x4020) / 4, data, mem_mask); |
| 901 | COMBINE_DATA(&scc68070_regs.mmu.desc[(offset - 0x4020) / 4].length); |
| 902 | break; |
| 903 | case 0x8044/2: |
| 904 | case 0x804c/2: |
| 905 | case 0x8054/2: |
| 906 | case 0x805c/2: |
| 907 | case 0x8064/2: |
| 908 | case 0x806c/2: |
| 909 | case 0x8074/2: |
| 910 | case 0x807c/2: // Segment Number (SD0-7, A0=1 only) |
| 911 | if(ACCESSING_BITS_0_7) |
| 912 | { |
| 913 | verboselog(space->machine, 2, "scc68070_periphs_w: MMU descriptor %d segment: %04x & %04x\n", (offset - 0x4020) / 4, data, mem_mask); |
| 914 | scc68070_regs.mmu.desc[(offset - 0x4020) / 4].segment = data & 0x00ff; |
| 915 | } |
| 916 | break; |
| 917 | case 0x8046/2: |
| 918 | case 0x804e/2: |
| 919 | case 0x8056/2: |
| 920 | case 0x805e/2: |
| 921 | case 0x8066/2: |
| 922 | case 0x806e/2: |
| 923 | case 0x8076/2: |
| 924 | case 0x807e/2: // Base Address (SD0-7) |
| 925 | verboselog(space->machine, 2, "scc68070_periphs_w: MMU descriptor %d base: %04x & %04x\n", (offset - 0x4020) / 4, data, mem_mask); |
| 926 | COMBINE_DATA(&scc68070_regs.mmu.desc[(offset - 0x4020) / 4].base); |
| 927 | break; |
| 928 | } |
| 351 | 929 | } |
| 352 | 930 | |
| 353 | 931 | static ADDRESS_MAP_START( cdi_mem, ADDRESS_SPACE_PROGRAM, 16 ) |
| 354 | | // ADDRESS_MAP_GLOBAL_MASK(0x1fffff) |
| 355 | | AM_RANGE(0x000000, 0x0fffff) AM_RAM AM_BASE(&ram) /*only 0-7ffff accessed in Magic Card*/ |
| 356 | | // AM_RANGE(0x100000, 0x17ffff) AM_RAM AM_REGION("maincpu", 0) |
| 357 | | AM_RANGE(0x180000, 0x1ffbff) AM_ROM AM_REGION("maincpu", 0) |
| 358 | | /* 1ffc00-1ffdff System I/O */ |
| 359 | | AM_RANGE(0x1ffc00, 0x1ffc01) AM_READ(test_r) |
| 360 | | AM_RANGE(0x1ffc40, 0x1ffc41) AM_READ(test_r) |
| 361 | | AM_RANGE(0x1ffd00, 0x1ffd05) AM_WRITE(paletteram_io_w) //RAMDAC |
| 362 | | /*not the right sound chip,unknown type,it should be an ADPCM with 8 channels.*/ |
| 363 | | AM_RANGE(0x1ffd40, 0x1ffd43) AM_DEVWRITE8("ym", ym2413_w, 0x00ff) |
| 364 | | AM_RANGE(0x1ffd80, 0x1ffd81) AM_READ(test_r) |
| 365 | | AM_RANGE(0x1ffd80, 0x1ffd81) AM_WRITENOP //? |
| 366 | | AM_RANGE(0x1fff80, 0x1fffbf) AM_RAM //DRAM I/O, not accessed by this game, CD buffer? |
| 367 | | AM_RANGE(0x1fffe0, 0x1fffff) AM_READWRITE(philips_66470_r,philips_66470_w) AM_BASE(&pcab_vregs) //video registers |
| 368 | | AM_RANGE(0x200000, 0x2fffff) AM_RAM |
| 932 | AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE(&ram) |
| 933 | AM_RANGE(0x00400000, 0x0047ffff) AM_ROM AM_REGION("maincpu", 0) |
| 934 | AM_RANGE(0x00480000, 0x004ffbff) AM_ROM AM_REGION("maincpu", 0) |
| 935 | AM_RANGE(0x004fffe0, 0x004fffff) AM_READWRITE(mcd212_r, mcd212_w) |
| 936 | AM_RANGE(0x00500000, 0x00ffffff) AM_RAM // Wrong... need to find documentation on CDi's RAM mirroring... |
| 937 | AM_RANGE(0x80000000, 0x8000807f) AM_READWRITE(scc68070_periphs_r, scc68070_periphs_w) |
| 369 | 938 | ADDRESS_MAP_END |
| 370 | 939 | |
| 371 | 940 | |
| r5824 | r5825 | |
| 398 | 967 | } |
| 399 | 968 | |
| 400 | 969 | static MACHINE_DRIVER_START( cdi ) |
| 401 | | MDRV_CPU_ADD("maincpu", M68000, CLOCK_A/2) /* SCC-68070 CCA84 datasheet */ |
| 970 | MDRV_CPU_ADD("maincpu", SCC68070, CLOCK_A/2) /* SCC-68070 CCA84 datasheet */ |
| 402 | 971 | MDRV_CPU_PROGRAM_MAP(cdi_mem) |
| 403 | 972 | MDRV_CPU_VBLANK_INT("screen", cdi_irq) /* no interrupts? (it erases the vectors..) */ |
| 404 | 973 | |