src/mess/drivers/cxhumax.c
| r0 | r15173 | |
| 1 | /*************************************************************************** |
| 2 | HUMAX HDCI-2000 ( Conexant CX2417x ) |
| 3 | |
| 4 | http://www.humaxdigital.com/global/products/product_stb_satellite_hdci2000.asp |
| 5 | |
| 6 | Running on Nucleus PLUS - ARM7TDMI ADS v. 1.14 |
| 7 | some Conexant/Nucleus goodies may be found at http://code.google.com/p/cherices/ |
| 8 | |
| 9 | runs up to frame 280 or so... |
| 10 | |
| 11 | ****************************************************************************/ |
| 12 | |
| 13 | #include "emu.h" |
| 14 | #include "includes/cxhumax.h" |
| 15 | |
| 16 | #define VERBOSE_LEVEL ( 0 ) |
| 17 | |
| 18 | INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ...) |
| 19 | { |
| 20 | if (VERBOSE_LEVEL >= n_level) |
| 21 | { |
| 22 | va_list v; |
| 23 | char buf[32768]; |
| 24 | va_start( v, s_fmt); |
| 25 | vsprintf( buf, s_fmt, v); |
| 26 | va_end( v); |
| 27 | logerror( "%s: %s", machine.describe_context( ), buf); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | READ32_MEMBER ( cxhumax_state::cx_gxa_r ) |
| 32 | { |
| 33 | UINT32 res = m_gxa_cmd_regs[offset]; |
| 34 | verboselog( machine(), 9, "(GXA) %08X -> %08X\n", 0xE0600000 + (offset << 2), res); |
| 35 | /* UINT8 gxa_command_number = (offset >> 9) & 0x7F; |
| 36 | verboselog( machine(), 9, " Command: %08X\n", gxa_command_number); |
| 37 | switch (gxa_command_number) { |
| 38 | case GXA_CMD_RW_REGISTER: |
| 39 | switch(offset) { |
| 40 | case GXA_CFG2_REG: |
| 41 | break; |
| 42 | default: |
| 43 | verboselog( machine(), 9, " Unimplemented register - TODO?\n"); |
| 44 | break; |
| 45 | } |
| 46 | break; |
| 47 | default: |
| 48 | // do we need it? |
| 49 | verboselog( machine(), 9, " Unimplemented read command - TODO?\n"); |
| 50 | break; |
| 51 | }*/ |
| 52 | return res; |
| 53 | } |
| 54 | |
| 55 | WRITE32_MEMBER( cxhumax_state::cx_gxa_w ) |
| 56 | { |
| 57 | verboselog( machine(), 9, "(GXA) %08X <- %08X\n", 0xE0600000 + (offset << 2), data); |
| 58 | UINT8 gxa_command_number = (offset >> 9) & 0x7F; |
| 59 | verboselog( machine(), 9, " Command: %08X\n", gxa_command_number); |
| 60 | |
| 61 | /* Clear non persistent data */ |
| 62 | m_gxa_cmd_regs[GXA_CMD_REG] &= 0xfffc0000; |
| 63 | |
| 64 | if (gxa_command_number == GXA_CMD_RW_REGISTER) { |
| 65 | verboselog( machine(), 9, " Register Number: %08X\n", offset & 0xff); |
| 66 | } else { |
| 67 | m_gxa_cmd_regs[GXA_CMD_REG] |= (offset << 2) & 0x3ffff; |
| 68 | verboselog( machine(), 9, " Source Bitmap Selector: %08X\n", (offset >> 6) & 0x7); |
| 69 | verboselog( machine(), 9, " Destination Bitmap Selector: %08X\n", (offset >> 3) & 0x7); |
| 70 | verboselog( machine(), 9, " Parameter Count: %08X\n", offset & 0x7); |
| 71 | } |
| 72 | switch (gxa_command_number) { |
| 73 | case GXA_CMD_RW_REGISTER: |
| 74 | switch(offset) { |
| 75 | case GXA_CFG2_REG: |
| 76 | // clear IRQ_STAT bits if requested |
| 77 | m_gxa_cmd_regs[GXA_CFG2_REG] = (m_gxa_cmd_regs[GXA_CFG2_REG]&(0xfff00000 & ~(data&0x00300000))) | (data & 0x000fffff); |
| 78 | break; |
| 79 | default: |
| 80 | verboselog( machine(), 9, " Unimplemented register - TODO?\n"); |
| 81 | COMBINE_DATA(&m_gxa_cmd_regs[offset]); |
| 82 | break; |
| 83 | } |
| 84 | break; |
| 85 | case GXA_CMD_QMARK: |
| 86 | verboselog( machine(), 9, " QMARK - TODO?\n"); |
| 87 | |
| 88 | /* Set value and copy of WAIT4_VERTICAL bit written by QMARK */ |
| 89 | m_gxa_cmd_regs[GXA_CMD_REG] = (m_gxa_cmd_regs[GXA_CMD_REG] & 0x3ffff) | (data<<24) | ((data&0x10)?1<<23:0); |
| 90 | |
| 91 | /* QMARK command has completed */ |
| 92 | m_gxa_cmd_regs[GXA_CFG2_REG] |= (1<<IRQ_STAT_QMARK); |
| 93 | |
| 94 | // Interrupt |
| 95 | if (m_gxa_cmd_regs[GXA_CFG2_REG] & (1<<IRQ_EN_QMARK)) { |
| 96 | m_intctrl_regs[INTREG(INTGROUP2, INTIRQ)] |= 1<<18; |
| 97 | m_intctrl_regs[INTREG(INTGROUP2, INTSTATCLR)] |= 1<<18; |
| 98 | m_intctrl_regs[INTREG(INTGROUP2, INTSTATSET)] |= 1<<18; |
| 99 | verboselog( machine(), 9, " QMARK INT - TODO?\n"); |
| 100 | } |
| 101 | |
| 102 | if((m_intctrl_regs[INTREG(INTGROUP2, INTIRQ)] & m_intctrl_regs[INTREG(INTGROUP2, INTENABLE)]) |
| 103 | || (m_intctrl_regs[INTREG(INTGROUP1, INTIRQ)] & m_intctrl_regs[INTREG(INTGROUP1, INTENABLE)])) |
| 104 | device_set_input_line(machine().device("maincpu"), ARM7_IRQ_LINE, ASSERT_LINE); |
| 105 | |
| 106 | break; |
| 107 | default: |
| 108 | verboselog( machine(), 9, " Unimplemented command - TODO?\n"); |
| 109 | break; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | WRITE32_MEMBER ( cxhumax_state::flash_w ) |
| 114 | { |
| 115 | offset *= 2; |
| 116 | if(ACCESSING_BITS_0_15) |
| 117 | m_flash->write(offset, data); |
| 118 | if(ACCESSING_BITS_16_31) |
| 119 | m_flash->write(offset+1, data >> 16); |
| 120 | verboselog( machine(), 9, "(FLASH) %08X <- %08X\n", 0xF0000000 + (offset << 2), data); |
| 121 | } |
| 122 | |
| 123 | READ32_MEMBER ( cxhumax_state::flash_r ) |
| 124 | { |
| 125 | UINT32 res = 0; |
| 126 | offset *= 2; |
| 127 | if(ACCESSING_BITS_0_15) |
| 128 | res |= m_flash->read(offset); |
| 129 | if(ACCESSING_BITS_16_31) |
| 130 | res |= m_flash->read(offset+1) << 16; |
| 131 | //if(m_flash->m_flash_mode!=FM_NORMAL) verboselog( machine(), 9, "(FLASH) %08X -> %08X\n", 0xF0000000 + (offset << 2), res); |
| 132 | return res; |
| 133 | } |
| 134 | |
| 135 | READ32_MEMBER ( cxhumax_state::dummy_flash_r ) |
| 136 | { |
| 137 | return 0xFFFFFFFF; |
| 138 | } |
| 139 | |
| 140 | WRITE32_MEMBER ( cxhumax_state::cx_remap_w ) |
| 141 | { |
| 142 | if(!(data&1)) { |
| 143 | verboselog( machine(), 9, "(REMAP) %08X -> %08X\n", 0xE0400014 + (offset << 2), data); |
| 144 | memset(m_ram, 0, 0x400000); // workaround :P |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | READ32_MEMBER( cxhumax_state::cx_scratch_r ) |
| 149 | { |
| 150 | UINT32 data = m_scratch_reg; |
| 151 | verboselog( machine(), 9, "(SCRATCH) %08X -> %08X\n", 0xE0400024 + (offset << 2), data); |
| 152 | |
| 153 | if((cpu_get_pc(m_maincpu)==0xF0003BB8) || (cpu_get_pc(m_maincpu)==0x01003724) || (cpu_get_pc(m_maincpu)==0x00005d8c)) { // HDCI-2000 |
| 154 | //we're in disabled debug_printf |
| 155 | unsigned char* buf = (unsigned char *)alloca(200); |
| 156 | unsigned char temp; |
| 157 | address_space *program = m_maincpu->memory().space(AS_PROGRAM); |
| 158 | |
| 159 | memset(buf,0,200); |
| 160 | |
| 161 | int i = 0; |
| 162 | while ((temp=program->read_byte(cpu_get_reg(m_maincpu, ARM7_R0)+i))) { |
| 163 | buf[i++]=temp; |
| 164 | //m_terminal->write(space, 0, temp); |
| 165 | } |
| 166 | mame_printf_debug("%s", buf); |
| 167 | verboselog( machine(), 9, "(DEBUG) %s", buf); |
| 168 | } |
| 169 | return data; |
| 170 | } |
| 171 | |
| 172 | WRITE32_MEMBER( cxhumax_state::cx_scratch_w ) |
| 173 | { |
| 174 | verboselog( machine(), 9, "(SCRATCH) %08X <- %08X\n", 0xE0400024 + (offset << 2), data); |
| 175 | COMBINE_DATA(&m_scratch_reg); |
| 176 | } |
| 177 | |
| 178 | READ32_MEMBER( cxhumax_state::cx_hsx_r ) |
| 179 | { |
| 180 | UINT32 data = 0; // dummy |
| 181 | verboselog( machine(), 9, "(HSX) %08X -> %08X\n", 0xE0000000 + (offset << 2), data); |
| 182 | return data; |
| 183 | } |
| 184 | |
| 185 | WRITE32_MEMBER( cxhumax_state::cx_hsx_w ) |
| 186 | { |
| 187 | verboselog( machine(), 9, "(HSX) %08X <- %08X\n", 0xE0000000 + (offset << 2), data); |
| 188 | } |
| 189 | |
| 190 | READ32_MEMBER( cxhumax_state::cx_romdescr_r ) |
| 191 | { |
| 192 | UINT32 data = m_romdescr_reg; |
| 193 | verboselog( machine(), 9, "(ROMDESC0) %08X -> %08X\n", 0xE0010000 + (offset << 2), data); |
| 194 | return data; |
| 195 | } |
| 196 | |
| 197 | WRITE32_MEMBER( cxhumax_state::cx_romdescr_w ) |
| 198 | { |
| 199 | verboselog( machine(), 9, "(ROMDESC0) %08X <- %08X\n", 0xE0010000 + (offset << 2), data); |
| 200 | COMBINE_DATA(&m_romdescr_reg); |
| 201 | } |
| 202 | |
| 203 | READ32_MEMBER( cxhumax_state::cx_isaromdescr_r ) |
| 204 | { |
| 205 | UINT32 data = m_isaromdescr_regs[offset]; |
| 206 | verboselog( machine(), 9, "(ISAROMDESC%d) %08X -> %08X\n", offset+1, 0xE0010004 + (offset << 2), data); |
| 207 | return data; |
| 208 | } |
| 209 | |
| 210 | WRITE32_MEMBER( cxhumax_state::cx_isaromdescr_w ) |
| 211 | { |
| 212 | verboselog( machine(), 9, "(ISAROMDESC%d) %08X <- %08X\n", offset+1, 0xE0010004 + (offset << 2), data); |
| 213 | COMBINE_DATA(&m_isaromdescr_regs[offset]); |
| 214 | } |
| 215 | |
| 216 | READ32_MEMBER( cxhumax_state::cx_isadescr_r ) |
| 217 | { |
| 218 | UINT32 data = m_isaromdescr_regs[offset]; |
| 219 | verboselog( machine(), 9, "(ISA_DESC%d) %08X -> %08X\n", offset+4, 0xE0010010 + (offset << 2), data); |
| 220 | return data; |
| 221 | } |
| 222 | |
| 223 | WRITE32_MEMBER( cxhumax_state::cx_isadescr_w ) |
| 224 | { |
| 225 | verboselog( machine(), 9, "(ISA_DESC%d) %08X <- %08X\n", offset+4, 0xE0010010 + (offset << 2), data); |
| 226 | COMBINE_DATA(&m_isaromdescr_regs[offset]); |
| 227 | } |
| 228 | |
| 229 | READ32_MEMBER( cxhumax_state::cx_rommap_r ) |
| 230 | { |
| 231 | UINT32 data = 0; |
| 232 | verboselog( machine(), 9, "(ROM%d_MAP) %08X -> %08X\n", offset, 0xE0010020 + (offset << 2), data); |
| 233 | return data; |
| 234 | } |
| 235 | |
| 236 | WRITE32_MEMBER( cxhumax_state::cx_rommap_w ) |
| 237 | { |
| 238 | verboselog( machine(), 9, "(ROM%d_MAP) %08X <- %08X\n", offset, 0xE0010020 + (offset << 2), data); |
| 239 | } |
| 240 | |
| 241 | READ32_MEMBER( cxhumax_state::cx_rommode_r ) |
| 242 | { |
| 243 | UINT32 data = m_rommode_reg; |
| 244 | verboselog( machine(), 9, "(ROMMODE) %08X -> %08X\n", 0xE0010034 + (offset << 2), data); |
| 245 | return data; |
| 246 | } |
| 247 | |
| 248 | WRITE32_MEMBER( cxhumax_state::cx_rommode_w ) |
| 249 | { |
| 250 | verboselog( machine(), 9, "(ROMMODE) %08X <- %08X\n", 0xE0010034 + (offset << 2), data); |
| 251 | COMBINE_DATA(&m_rommode_reg); |
| 252 | } |
| 253 | |
| 254 | READ32_MEMBER( cxhumax_state::cx_xoemask_r ) |
| 255 | { |
| 256 | UINT32 data = m_xoemask_reg; |
| 257 | verboselog( machine(), 9, "(XOEMASK) %08X -> %08X\n", 0xE0010034 + (offset << 2), data); |
| 258 | return data; |
| 259 | } |
| 260 | |
| 261 | WRITE32_MEMBER( cxhumax_state::cx_xoemask_w ) |
| 262 | { |
| 263 | verboselog( machine(), 9, "(XOEMASK) %08X <- %08X\n", 0xE0010034 + (offset << 2), data); |
| 264 | COMBINE_DATA(&m_xoemask_reg); |
| 265 | } |
| 266 | |
| 267 | READ32_MEMBER( cxhumax_state::cx_pci_r ) |
| 268 | { |
| 269 | UINT32 data = 0; |
| 270 | switch (offset) { |
| 271 | case PCI_CFG_ADDR_REG: |
| 272 | data = m_pci_regs[offset]; break; |
| 273 | case PCI_CFG_DATA_REG: |
| 274 | { |
| 275 | switch (m_pci_regs[PCI_CFG_ADDR_REG]) { |
| 276 | case 0: data = (0x4170<<16) /*Device ID*/ | 0x14f1 /* Vendor ID */; break; |
| 277 | case 8: data = (0x060000 << 8) /* Class Code */ | 0x1f /* Revision ID */; break; |
| 278 | } |
| 279 | } break; |
| 280 | } |
| 281 | verboselog( machine(), 9, "(PCI) %08X -> %08X\n", 0xE0010040 + (offset << 2), data); |
| 282 | return data; |
| 283 | } |
| 284 | |
| 285 | WRITE32_MEMBER( cxhumax_state::cx_pci_w ) |
| 286 | { |
| 287 | verboselog( machine(), 9, "(PCI) %08X <- %08X\n", 0xE0010040 + (offset << 2), data); |
| 288 | COMBINE_DATA(&m_pci_regs[offset]); |
| 289 | } |
| 290 | |
| 291 | READ32_MEMBER( cxhumax_state::cx_extdesc_r ) |
| 292 | { |
| 293 | UINT32 data = m_extdesc_regs[offset]; |
| 294 | verboselog( machine(), 9, "(EXTDESC) %08X -> %08X\n", 0xE0010080 + (offset << 2), data); |
| 295 | return data; |
| 296 | } |
| 297 | |
| 298 | WRITE32_MEMBER( cxhumax_state::cx_extdesc_w ) |
| 299 | { |
| 300 | verboselog( machine(), 9, "(EXTDESC) %08X <- %08X\n", 0xE0010080 + (offset << 2), data); |
| 301 | COMBINE_DATA(&m_extdesc_regs[offset]); |
| 302 | } |
| 303 | |
| 304 | static TIMER_CALLBACK( timer_tick ) |
| 305 | { |
| 306 | cxhumax_state *state = machine.driver_data<cxhumax_state>(); |
| 307 | state->m_timer_regs.timer[param].value++; |
| 308 | if(state->m_timer_regs.timer[param].value==state->m_timer_regs.timer[param].limit) { |
| 309 | /* Reset counter when reaching limit and RESET_CNTR bit is cleared */ |
| 310 | if(!(state->m_timer_regs.timer[param].mode & 2)) |
| 311 | state->m_timer_regs.timer[param].value=0; |
| 312 | |
| 313 | /* Indicate interrupt request if EN_INT bit is set */ |
| 314 | if (state->m_timer_regs.timer[param].mode & 8) { |
| 315 | //printf( "IRQ on Timer %d\n", param ); |
| 316 | verboselog( machine, 9, "(TIMER%d) Interrupt\n", param); |
| 317 | state->m_intctrl_regs[INTREG(INTGROUP2, INTIRQ)] |= INT_TIMER_BIT; /* Timer interrupt */ |
| 318 | state->m_intctrl_regs[INTREG(INTGROUP2, INTSTATCLR)] |= INT_TIMER_BIT; /* Timer interrupt */ |
| 319 | state->m_intctrl_regs[INTREG(INTGROUP2, INTSTATSET)] |= INT_TIMER_BIT; /* Timer interrupt */ |
| 320 | |
| 321 | state->m_timer_regs.timer_irq |= 1<<param; /* Indicate which timer interrupted */ |
| 322 | |
| 323 | /* Interrupt if Timer interrupt is not masked in ITC_INTENABLE_REG */ |
| 324 | if (state->m_intctrl_regs[INTREG(INTGROUP2, INTENABLE)] & INT_TIMER_BIT) |
| 325 | device_set_input_line(machine.device("maincpu"), ARM7_IRQ_LINE, ASSERT_LINE); |
| 326 | } |
| 327 | } |
| 328 | attotime period = attotime::from_hz(XTAL_54MHz)*state->m_timer_regs.timer[param].timebase; |
| 329 | state->m_timer_regs.timer[param].timer->adjust(period,param); |
| 330 | } |
| 331 | |
| 332 | READ32_MEMBER( cxhumax_state::cx_timers_r ) |
| 333 | { |
| 334 | UINT32 data = 0; |
| 335 | UINT8 index = offset>>2; |
| 336 | if(index==16) { |
| 337 | data = m_timer_regs.timer_irq; |
| 338 | //m_timer_regs.timer_irq=0; |
| 339 | verboselog( machine(), 9, "(TIMERIRQ) %08X -> %08X\n", 0xE0430000 + (offset << 2), data); |
| 340 | } |
| 341 | else { |
| 342 | switch (offset&3) { |
| 343 | case TIMER_VALUE: |
| 344 | data = m_timer_regs.timer[index].value; break; |
| 345 | case TIMER_LIMIT: |
| 346 | data = m_timer_regs.timer[index].limit; break; |
| 347 | case TIMER_MODE: |
| 348 | data = m_timer_regs.timer[index].mode; break; |
| 349 | case TIMER_TIMEBASE: |
| 350 | data = m_timer_regs.timer[index].timebase; break; |
| 351 | } |
| 352 | verboselog( machine(), 9, "(TIMER%d) %08X -> %08X\n", offset>>2, 0xE0430000 + (offset << 2), data); |
| 353 | } |
| 354 | return data; |
| 355 | } |
| 356 | |
| 357 | WRITE32_MEMBER( cxhumax_state::cx_timers_w ) |
| 358 | { |
| 359 | UINT8 index = offset>>2; |
| 360 | if(index==16) { |
| 361 | verboselog( machine(), 9, "(TIMERIRQ) %08X <- %08X\n", 0xE0430000 + (offset << 2), data); |
| 362 | COMBINE_DATA(&m_timer_regs.timer_irq); |
| 363 | } |
| 364 | else { |
| 365 | verboselog( machine(), 9, "(TIMER%d) %08X <- %08X\n", index, 0xE0430000 + (offset << 2), data); |
| 366 | switch(offset&3) { |
| 367 | case TIMER_VALUE: |
| 368 | COMBINE_DATA(&m_timer_regs.timer[index].value); break; |
| 369 | case TIMER_LIMIT: |
| 370 | COMBINE_DATA(&m_timer_regs.timer[index].limit); break; |
| 371 | case TIMER_MODE: |
| 372 | COMBINE_DATA(&m_timer_regs.timer[index].mode); |
| 373 | if(data&1) { |
| 374 | attotime period = attotime::from_hz(XTAL_54MHz)*m_timer_regs.timer[index].timebase; |
| 375 | m_timer_regs.timer[index].timer->adjust(period,index); |
| 376 | } else { |
| 377 | m_timer_regs.timer[index].timer->adjust(attotime::never,index); |
| 378 | } break; |
| 379 | case TIMER_TIMEBASE: |
| 380 | COMBINE_DATA(&m_timer_regs.timer[index].timebase); break; |
| 381 | } |
| 382 | /* A timer will hold an interrupt active until any one of that timer’s registers is written. */ |
| 383 | if(m_timer_regs.timer_irq & (1<<index)) { |
| 384 | m_timer_regs.timer_irq &= ~(1<<index); |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | READ32_MEMBER( cxhumax_state::cx_uart2_r ) |
| 390 | { |
| 391 | UINT32 data; |
| 392 | switch (offset) { |
| 393 | case UART_STAT_REG: |
| 394 | /* Transmitter Idle */ |
| 395 | data = UART_STAT_TID_BIT | UART_STAT_TSR_BIT; break; |
| 396 | default: |
| 397 | data = m_uart2_regs[offset]; break; |
| 398 | } |
| 399 | verboselog( machine(), 9, "(UART2) %08X -> %08X\n", 0xE0411000 + (offset << 2), data); |
| 400 | return data; |
| 401 | } |
| 402 | |
| 403 | WRITE32_MEMBER( cxhumax_state::cx_uart2_w ) |
| 404 | { |
| 405 | verboselog( machine(), 9, "(UART2) %08X <- %08X\n", 0xE0411000 + (offset << 2), data); |
| 406 | switch (offset) { |
| 407 | case UART_FIFO_REG: |
| 408 | if(!(m_uart2_regs[UART_FRMC_REG]&UART_FRMC_BDS_BIT)) { |
| 409 | /* Sending byte... add logging */ |
| 410 | m_terminal->write(space, 0, data); |
| 411 | |
| 412 | /* Transmitter Idle Interrupt Enable */ |
| 413 | if(m_uart2_regs[UART_IRQE_REG]&UART_IRQE_TIDE_BIT) { |
| 414 | /* Signal pending INT */ |
| 415 | m_intctrl_regs[INTREG(INTGROUP1, INTIRQ)] |= INT_UART2_BIT; |
| 416 | m_intctrl_regs[INTREG(INTGROUP1, INTSTATCLR)] |= INT_UART2_BIT; |
| 417 | m_intctrl_regs[INTREG(INTGROUP1, INTSTATSET)] |= INT_UART2_BIT; |
| 418 | |
| 419 | /* If INT is enabled at INT Ctrl raise it */ |
| 420 | if(m_intctrl_regs[INTREG(INTGROUP1, INTENABLE)]&INT_UART2_BIT) { |
| 421 | device_set_input_line(machine().device("maincpu"), ARM7_IRQ_LINE, ASSERT_LINE); |
| 422 | } |
| 423 | } |
| 424 | } |
| 425 | default: |
| 426 | COMBINE_DATA(&m_uart2_regs[offset]); break; |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | READ32_MEMBER( cxhumax_state::cx_pll_r ) |
| 431 | { |
| 432 | UINT32 data = m_pll_regs[offset]; |
| 433 | verboselog( machine(), 9, "(PLL) %08X -> %08X\n", 0xE0440000 + (offset << 2), data); |
| 434 | return data; |
| 435 | } |
| 436 | |
| 437 | WRITE32_MEMBER( cxhumax_state::cx_pll_w ) |
| 438 | { |
| 439 | verboselog( machine(), 9, "(PLL) %08X <- %08X\n", 0xE0440000 + (offset << 2), data); |
| 440 | COMBINE_DATA(&m_pll_regs[offset]); |
| 441 | } |
| 442 | |
| 443 | READ32_MEMBER( cxhumax_state::cx_pllprescale_r ) |
| 444 | { |
| 445 | UINT32 data = m_pllprescale_reg; |
| 446 | verboselog( machine(), 9, "(PLLPRESCALE) %08X -> %08X\n", 0xE0440094 + (offset << 2), data); |
| 447 | return data; |
| 448 | } |
| 449 | |
| 450 | WRITE32_MEMBER( cxhumax_state::cx_pllprescale_w ) |
| 451 | { |
| 452 | verboselog( machine(), 9, "(PLLPRESCALE) %08X <- %08X\n", 0xE0440094 + (offset << 2), data); |
| 453 | COMBINE_DATA(&m_pllprescale_reg); |
| 454 | } |
| 455 | |
| 456 | READ32_MEMBER( cxhumax_state::cx_clkdiv_r ) |
| 457 | { |
| 458 | UINT32 data = m_clkdiv_regs[offset]; |
| 459 | verboselog( machine(), 9, "(CLKDIV) %08X -> %08X\n", 0xE0440020 + (offset << 2), data); |
| 460 | return data; |
| 461 | } |
| 462 | |
| 463 | WRITE32_MEMBER( cxhumax_state::cx_clkdiv_w ) |
| 464 | { |
| 465 | verboselog( machine(), 9, "(CLKDIV) %08X <- %08X\n", 0xE0440020 + (offset << 2), data); |
| 466 | COMBINE_DATA(&m_clkdiv_regs[offset]); |
| 467 | } |
| 468 | |
| 469 | READ32_MEMBER( cxhumax_state::cx_chipcontrol_r ) |
| 470 | { |
| 471 | UINT32 data = m_chipcontrol_regs[offset]; |
| 472 | verboselog( machine(), 9, "(CHIPCONTROL) %08X -> %08X\n", 0xE0440100 + (offset << 2), data); |
| 473 | return data; |
| 474 | } |
| 475 | |
| 476 | WRITE32_MEMBER( cxhumax_state::cx_chipcontrol_w ) |
| 477 | { |
| 478 | verboselog( machine(), 9, "(CHIPCONTROL) %08X <- %08X\n", 0xE0440100 + (offset << 2), data); |
| 479 | COMBINE_DATA(&m_chipcontrol_regs[offset]); |
| 480 | } |
| 481 | |
| 482 | READ32_MEMBER( cxhumax_state::cx_intctrl_r ) |
| 483 | { |
| 484 | UINT32 data = m_intctrl_regs[offset]; |
| 485 | verboselog( machine(), 9, "(INTCTRL) %08X -> %08X\n", 0xE0450000 + (offset << 2), data); |
| 486 | return data; |
| 487 | } |
| 488 | |
| 489 | WRITE32_MEMBER( cxhumax_state::cx_intctrl_w ) |
| 490 | { |
| 491 | verboselog( machine(), 9, "(INTCTRL) %08X <- %08X\n", 0xE0450000 + (offset << 2), data); |
| 492 | switch (offset >> 3) { // Decode the group |
| 493 | case 0: // Group 1 |
| 494 | switch(offset & 7) { |
| 495 | case INTSTATCLR: // ITC_INTSTATCLR_REG Group 1 |
| 496 | /* |
| 497 | Bits 15 (PWM), 14 (PIO103) of Group 1 are the logical OR of their lower level interrupt |
| 498 | status bits down within the interrupting module and are not registered. |
| 499 | |
| 500 | The source registers must be cleared to clear these interrupt bits. |
| 501 | */ |
| 502 | data &= ~(INT_PWM_BIT|INT_PIO103_BIT); |
| 503 | |
| 504 | m_intctrl_regs[INTREG(INTGROUP1, INTSTATCLR)] &= ~data; |
| 505 | m_intctrl_regs[INTREG(INTGROUP1, INTSTATSET)] &= ~data; |
| 506 | m_intctrl_regs[INTREG(INTGROUP1, INTIRQ)] &= ~data; |
| 507 | break; |
| 508 | default: |
| 509 | COMBINE_DATA(&m_intctrl_regs[offset]); |
| 510 | break; |
| 511 | } |
| 512 | break; |
| 513 | case 1: // Group 2 |
| 514 | switch(offset & 7) { |
| 515 | case INTSTATCLR: // ITC_INTSTATCLR_REG Group 2 |
| 516 | /* |
| 517 | The timer interrupt service routine must write to one of the timer |
| 518 | registers before clearing the corresponding Interrupt Controller ISR timer |
| 519 | interrupt bit. |
| 520 | |
| 521 | Bit 7 (Timers) of Group 2 is the logical OR of its lower level interrupt |
| 522 | status bits down within the interrupting module and are not registered. |
| 523 | |
| 524 | The source registers must be cleared to clear these interrupt bits. |
| 525 | */ |
| 526 | if(m_timer_regs.timer_irq) data &= ~INT_TIMER_BIT; |
| 527 | |
| 528 | m_intctrl_regs[INTREG(INTGROUP2, INTSTATCLR)] &= ~data; |
| 529 | m_intctrl_regs[INTREG(INTGROUP2, INTSTATSET)] &= ~data; |
| 530 | m_intctrl_regs[INTREG(INTGROUP2, INTIRQ)] &= ~data; |
| 531 | break; |
| 532 | default: |
| 533 | COMBINE_DATA(&m_intctrl_regs[offset]); |
| 534 | break; |
| 535 | } |
| 536 | break; |
| 537 | default: |
| 538 | break; |
| 539 | } |
| 540 | |
| 541 | if(m_i2c1_regs[I2C_STAT_REG]&I2C_INT_BIT) |
| 542 | { |
| 543 | m_intctrl_regs[INTREG(INTGROUP1, INTIRQ)] |= 1<<7; |
| 544 | m_intctrl_regs[INTREG(INTGROUP1, INTSTATCLR)] |= 1<<7; |
| 545 | m_intctrl_regs[INTREG(INTGROUP1, INTSTATSET)] |= 1<<7; |
| 546 | } |
| 547 | |
| 548 | /* check if */ |
| 549 | if((m_intctrl_regs[INTREG(INTGROUP2, INTIRQ)] & m_intctrl_regs[INTREG(INTGROUP2, INTENABLE)]) |
| 550 | || (m_intctrl_regs[INTREG(INTGROUP1, INTIRQ)] & m_intctrl_regs[INTREG(INTGROUP1, INTENABLE)])) |
| 551 | device_set_input_line(machine().device("maincpu"), ARM7_IRQ_LINE, ASSERT_LINE); |
| 552 | else |
| 553 | device_set_input_line(machine().device("maincpu"), ARM7_IRQ_LINE, CLEAR_LINE); |
| 554 | |
| 555 | } |
| 556 | |
| 557 | READ32_MEMBER( cxhumax_state::cx_ss_r ) |
| 558 | { |
| 559 | UINT32 data = 0; |
| 560 | switch(offset) { |
| 561 | case SS_FIFC_REG: |
| 562 | data = m_ss_regs[offset] & 0xFFF0; |
| 563 | break; |
| 564 | default: |
| 565 | data = m_ss_regs[offset]; |
| 566 | break; |
| 567 | } |
| 568 | verboselog( machine(), 9, "(SS) %08X -> %08X\n", 0xE0490000 + (offset << 2), data); |
| 569 | return data; |
| 570 | } |
| 571 | |
| 572 | WRITE32_MEMBER( cxhumax_state::cx_ss_w ) |
| 573 | { |
| 574 | verboselog( machine(), 9, "(SS) %08X <- %08X\n", 0xE0490000 + (offset << 2), data); |
| 575 | switch(offset) { |
| 576 | case SS_CNTL_REG: |
| 577 | if (data&1) { |
| 578 | // "Send" pending data |
| 579 | UINT8 tfd = (m_ss_regs[SS_STAT_REG]>>4) & 0xF; |
| 580 | if ((tfd>1) && (m_ss_tx_fifo[0] == 0) && (m_ss_tx_fifo[1] != 0xFF)) { |
| 581 | // ASCII |
| 582 | printf("%s\n", &m_ss_tx_fifo[1]); |
| 583 | } else { |
| 584 | // UNKNOWN |
| 585 | for (int i=0; i<tfd; i++) { |
| 586 | printf("%02X ", m_ss_tx_fifo[i]); |
| 587 | } |
| 588 | printf("\n"); |
| 589 | } |
| 590 | // Clear TX FIFO |
| 591 | memset(m_ss_tx_fifo,0,sizeof(m_ss_tx_fifo)); |
| 592 | m_ss_regs[SS_STAT_REG] &= 0xFF0F; |
| 593 | } |
| 594 | COMBINE_DATA(&m_ss_regs[offset]); |
| 595 | break; |
| 596 | case SS_FIFO_REG: |
| 597 | { |
| 598 | // Push data into TX FIFO (if it's not full) and adjust transmit FIFO depth |
| 599 | UINT8 tfd = (m_ss_regs[SS_STAT_REG]>>4) & 0xF; |
| 600 | if (tfd<8) { |
| 601 | m_ss_tx_fifo[tfd++] = data; |
| 602 | m_ss_regs[SS_STAT_REG] = (m_ss_regs[SS_STAT_REG] & 0xFF0F) | (tfd<<4); |
| 603 | } |
| 604 | } |
| 605 | break; |
| 606 | case SS_STAT_REG: |
| 607 | // read-only |
| 608 | break; |
| 609 | default: |
| 610 | COMBINE_DATA(&m_ss_regs[offset]); |
| 611 | break; |
| 612 | }; |
| 613 | } |
| 614 | |
| 615 | READ32_MEMBER( cxhumax_state::cx_i2c0_r ) |
| 616 | { |
| 617 | UINT32 data = m_i2c0_regs[offset]; |
| 618 | verboselog( machine(), 9, "(I2C0) %08X -> %08X\n", 0xE04E0000 + (offset << 2), data); |
| 619 | return data; |
| 620 | } |
| 621 | |
| 622 | WRITE32_MEMBER( cxhumax_state::cx_i2c0_w ) |
| 623 | { |
| 624 | verboselog( machine(), 9, "(I2C0) %08X <- %08X\n", 0xE04E0000 + (offset << 2), data); |
| 625 | COMBINE_DATA(&m_i2c0_regs[offset]); |
| 626 | } |
| 627 | |
| 628 | static UINT8 i2cmem_read_byte( device_t *machine, int last) |
| 629 | { |
| 630 | UINT8 data = 0; |
| 631 | int i; |
| 632 | i2cmem_sda_write(machine, 1); |
| 633 | for (i = 0; i < 8; i++) |
| 634 | { |
| 635 | i2cmem_scl_write(machine, 1); |
| 636 | data = (data << 1) + (i2cmem_sda_read( machine ) ? 1 : 0); |
| 637 | i2cmem_scl_write(machine, 0); |
| 638 | } |
| 639 | i2cmem_sda_write(machine, last); |
| 640 | i2cmem_scl_write(machine, 1); |
| 641 | i2cmem_scl_write(machine, 0); |
| 642 | return data; |
| 643 | } |
| 644 | |
| 645 | static void i2cmem_write_byte( device_t *machine, UINT8 data) |
| 646 | { |
| 647 | int i; |
| 648 | for (i = 0; i < 8; i++) |
| 649 | { |
| 650 | i2cmem_sda_write(machine, (data & 0x80) ? 1 : 0); |
| 651 | data = data << 1; |
| 652 | i2cmem_scl_write(machine, 1); |
| 653 | i2cmem_scl_write(machine, 0); |
| 654 | } |
| 655 | i2cmem_sda_write(machine, 1); // ack bit |
| 656 | i2cmem_scl_write(machine, 1); |
| 657 | i2cmem_scl_write(machine, 0); |
| 658 | } |
| 659 | |
| 660 | static void i2cmem_start( device_t *machine ) |
| 661 | { |
| 662 | i2cmem_sda_write(machine, 1); |
| 663 | i2cmem_scl_write(machine, 1); |
| 664 | i2cmem_sda_write(machine, 0); |
| 665 | i2cmem_scl_write(machine, 0); |
| 666 | } |
| 667 | |
| 668 | static void i2cmem_stop( device_t *machine ) |
| 669 | { |
| 670 | i2cmem_sda_write(machine, 0); |
| 671 | i2cmem_scl_write(machine, 1); |
| 672 | i2cmem_sda_write(machine, 1); |
| 673 | i2cmem_scl_write(machine, 0); |
| 674 | } |
| 675 | |
| 676 | READ32_MEMBER( cxhumax_state::cx_i2c1_r ) |
| 677 | { |
| 678 | UINT32 data=0; |
| 679 | switch(offset) { |
| 680 | case I2C_STAT_REG: |
| 681 | data |= i2cmem_sda_read(machine().device("eeprom"))<<3; |
| 682 | // fall |
| 683 | default: |
| 684 | data |= m_i2c1_regs[offset]; break; |
| 685 | } |
| 686 | verboselog( machine(), 9, "(I2C1) %08X -> %08X\n", 0xE04E1000 + (offset << 2), data); |
| 687 | return data; |
| 688 | } |
| 689 | |
| 690 | WRITE32_MEMBER( cxhumax_state::cx_i2c1_w ) |
| 691 | { |
| 692 | verboselog( machine(), 9, "(I2C1) %08X <- %08X\n", 0xE04E1000 + (offset << 2), data); |
| 693 | switch(offset) { |
| 694 | case I2C_CTRL_REG: |
| 695 | if(data&0x10) {// START |
| 696 | i2cmem_start(machine().device("eeprom")); |
| 697 | } |
| 698 | if((data&0x4) || ((data&3)==3)) // I2C READ |
| 699 | { |
| 700 | m_i2c1_regs[I2C_RDATA_REG] = 0; |
| 701 | if(data&0x10) i2cmem_write_byte(machine().device("eeprom"),(data>>24)&0xFF); |
| 702 | if(m_i2c1_regs[I2C_MODE_REG]&(1<<5)) // BYTE_ORDER |
| 703 | { |
| 704 | for(int i=0; i<(data&3); i++) { |
| 705 | m_i2c1_regs[I2C_RDATA_REG] |= i2cmem_read_byte(machine().device("eeprom"),0) << (i*8); |
| 706 | } |
| 707 | m_i2c1_regs[I2C_RDATA_REG] |= i2cmem_read_byte(machine().device("eeprom"),(data&0x20)?1:0) << ((data&3)*8); |
| 708 | } |
| 709 | else |
| 710 | { |
| 711 | for(int i=0; i<(data&3); i++) { |
| 712 | m_i2c1_regs[I2C_RDATA_REG] |= i2cmem_read_byte(machine().device("eeprom"),0); |
| 713 | m_i2c1_regs[I2C_RDATA_REG] <<= 8; |
| 714 | } |
| 715 | m_i2c1_regs[I2C_RDATA_REG] |= i2cmem_read_byte(machine().device("eeprom"),(data&0x20)?1:0); |
| 716 | } |
| 717 | } |
| 718 | else |
| 719 | { |
| 720 | for(int i=0; i<=(data&3); i++) { |
| 721 | i2cmem_write_byte(machine().device("eeprom"),(data>>(24-(i*8))&0xFF)); |
| 722 | } |
| 723 | } |
| 724 | if(data&0x20) {// STOP |
| 725 | i2cmem_stop(machine().device("eeprom")); |
| 726 | } |
| 727 | |
| 728 | /* The interrupt status bit is set at the end of an I2C read or write operation. */ |
| 729 | m_i2c1_regs[I2C_STAT_REG] |= I2C_INT_BIT; |
| 730 | m_i2c1_regs[I2C_STAT_REG] |= I2C_WACK_BIT; |
| 731 | |
| 732 | m_intctrl_regs[INTREG(INTGROUP1, INTIRQ)] |= 1<<7; |
| 733 | m_intctrl_regs[INTREG(INTGROUP1, INTSTATCLR)] |= 1<<7; |
| 734 | m_intctrl_regs[INTREG(INTGROUP1, INTSTATSET)] |= 1<<7; |
| 735 | if (m_intctrl_regs[INTREG(INTGROUP1, INTENABLE)] & (1<<7)) { |
| 736 | verboselog( machine(), 9, "(I2C1) Int\n" ); |
| 737 | device_set_input_line(machine().device("maincpu"), ARM7_IRQ_LINE, ASSERT_LINE); |
| 738 | } |
| 739 | break; |
| 740 | case I2C_STAT_REG: |
| 741 | /* The interrupt status bit may be cleared by writing (anything) to the status register, which also clears the acknowledge status. */ |
| 742 | data&=~(I2C_WACK_BIT|I2C_INT_BIT); |
| 743 | // fall |
| 744 | default: |
| 745 | COMBINE_DATA(&m_i2c1_regs[offset]); |
| 746 | } |
| 747 | } |
| 748 | |
| 749 | READ32_MEMBER( cxhumax_state::cx_i2c2_r ) |
| 750 | { |
| 751 | UINT32 data = m_i2c2_regs[offset]; |
| 752 | verboselog( machine(), 9, "(I2C2) %08X -> %08X\n", 0xE04E2000 + (offset << 2), data); |
| 753 | return data; |
| 754 | } |
| 755 | |
| 756 | WRITE32_MEMBER( cxhumax_state::cx_i2c2_w ) |
| 757 | { |
| 758 | verboselog( machine(), 9, "(I2C2) %08X <- %08X\n", 0xE04E2000 + (offset << 2), data); |
| 759 | COMBINE_DATA(&m_i2c2_regs[offset]); |
| 760 | } |
| 761 | |
| 762 | READ32_MEMBER( cxhumax_state::cx_mc_cfg_r ) |
| 763 | { |
| 764 | UINT32 data = m_mccfg_regs[offset]; |
| 765 | verboselog( machine(), 9, "(MC_CFG) %08X -> %08X\n", 0xE0500300 + (offset << 2), data); |
| 766 | return data; |
| 767 | } |
| 768 | |
| 769 | WRITE32_MEMBER( cxhumax_state::cx_mc_cfg_w ) |
| 770 | { |
| 771 | verboselog( machine(), 9, "(MC_CFG) %08X <- %08X\n", 0xE0500300 + (offset << 2), data); |
| 772 | COMBINE_DATA(&m_mccfg_regs[offset]); |
| 773 | } |
| 774 | |
| 775 | READ32_MEMBER( cxhumax_state::cx_drm0_r ) |
| 776 | { |
| 777 | UINT32 data = m_drm0_regs[offset]; |
| 778 | verboselog( machine(), 9, "(DRM0) %08X -> %08X\n", 0xE0560000 + (offset << 2), data); |
| 779 | switch(offset) { |
| 780 | case 0x14/4: // DRM_STATUS_REG |
| 781 | data |= 1<<21; |
| 782 | data |= 1<<20; |
| 783 | } |
| 784 | return data; |
| 785 | } |
| 786 | |
| 787 | WRITE32_MEMBER( cxhumax_state::cx_drm0_w ) |
| 788 | { |
| 789 | verboselog( machine(), 9, "(DRM0) %08X <- %08X\n", 0xE0560000 + (offset << 2), data); |
| 790 | COMBINE_DATA(&m_drm0_regs[offset]); |
| 791 | } |
| 792 | |
| 793 | READ32_MEMBER( cxhumax_state::cx_drm1_r ) |
| 794 | { |
| 795 | UINT32 data = m_drm1_regs[offset]; |
| 796 | verboselog( machine(), 9, "(DRM1) %08X -> %08X\n", 0xE0570000 + (offset << 2), data); |
| 797 | return data; |
| 798 | } |
| 799 | |
| 800 | WRITE32_MEMBER( cxhumax_state::cx_drm1_w ) |
| 801 | { |
| 802 | verboselog( machine(), 9, "(DRM1) %08X <- %08X\n", 0xE0570000 + (offset << 2), data); |
| 803 | COMBINE_DATA(&m_drm1_regs[offset]); |
| 804 | } |
| 805 | |
| 806 | READ32_MEMBER( cxhumax_state::cx_hdmi_r ) |
| 807 | { |
| 808 | UINT32 data = m_hdmi_regs[offset]; |
| 809 | verboselog( machine(), 9, "(HDMI) %08X -> %08X\n", 0xE05D0800 + (offset << 2), data); |
| 810 | return data; |
| 811 | } |
| 812 | |
| 813 | WRITE32_MEMBER( cxhumax_state::cx_hdmi_w ) |
| 814 | { |
| 815 | verboselog( machine(), 9, "(HDMI) %08X <- %08X\n", 0xE05D0800 + (offset << 2), data); |
| 816 | switch(offset) { |
| 817 | case 0x40/4: // HDMI_CONFIG_REG |
| 818 | if(data&8) m_hdmi_regs[0xc0/4] |= 0x80; |
| 819 | } |
| 820 | COMBINE_DATA(&m_hdmi_regs[offset]); |
| 821 | } |
| 822 | |
| 823 | static VIDEO_START( cxhumax ) |
| 824 | { |
| 825 | } |
| 826 | |
| 827 | /* copy from emu/rendersw.c */ |
| 828 | /*------------------------------------------------------------------------ |
| 829 | ycc_to_rgb - convert YCC to RGB; the YCC pixel |
| 830 | contains Y in the LSB, Cb << 8, and Cr << 16 |
| 831 | This actually a YCbCr conversion, |
| 832 | details my be found in chapter 6.4 ff of |
| 833 | http://softwarecommunity.intel.com/isn/downloads/softwareproducts/pdfs/346495.pdf |
| 834 | The document also contains the constants below as floats. |
| 835 | --------------------------------------------------------------------------*/ |
| 836 | |
| 837 | INLINE UINT8 clamp16_shift8(UINT32 x) |
| 838 | { |
| 839 | return (((INT32) x < 0) ? 0 : (x > 65535 ? 255: x >> 8)); |
| 840 | } |
| 841 | |
| 842 | INLINE UINT32 ycc_to_rgb(UINT32 ycc) |
| 843 | { |
| 844 | /* original equations: |
| 845 | |
| 846 | C = Y - 16 |
| 847 | D = Cb - 128 |
| 848 | E = Cr - 128 |
| 849 | |
| 850 | R = clip(( 298 * C + 409 * E + 128) >> 8) |
| 851 | G = clip(( 298 * C - 100 * D - 208 * E + 128) >> 8) |
| 852 | B = clip(( 298 * C + 516 * D + 128) >> 8) |
| 853 | |
| 854 | R = clip(( 298 * (Y - 16) + 409 * (Cr - 128) + 128) >> 8) |
| 855 | G = clip(( 298 * (Y - 16) - 100 * (Cb - 128) - 208 * (Cr - 128) + 128) >> 8) |
| 856 | B = clip(( 298 * (Y - 16) + 516 * (Cb - 128) + 128) >> 8) |
| 857 | |
| 858 | R = clip(( 298 * Y - 298 * 16 + 409 * Cr - 409 * 128 + 128) >> 8) |
| 859 | G = clip(( 298 * Y - 298 * 16 - 100 * Cb + 100 * 128 - 208 * Cr + 208 * 128 + 128) >> 8) |
| 860 | B = clip(( 298 * Y - 298 * 16 + 516 * Cb - 516 * 128 + 128) >> 8) |
| 861 | |
| 862 | R = clip(( 298 * Y - 298 * 16 + 409 * Cr - 409 * 128 + 128) >> 8) |
| 863 | G = clip(( 298 * Y - 298 * 16 - 100 * Cb + 100 * 128 - 208 * Cr + 208 * 128 + 128) >> 8) |
| 864 | B = clip(( 298 * Y - 298 * 16 + 516 * Cb - 516 * 128 + 128) >> 8) |
| 865 | |
| 866 | Now combine constants: |
| 867 | |
| 868 | R = clip(( 298 * Y + 409 * Cr - 56992) >> 8) |
| 869 | G = clip(( 298 * Y - 100 * Cb - 208 * Cr + 34784) >> 8) |
| 870 | B = clip(( 298 * Y + 516 * Cb - 70688) >> 8) |
| 871 | |
| 872 | Define common = 298 * y - 56992. This will save one addition |
| 873 | |
| 874 | R = clip(( common + 409 * Cr - 0) >> 8) |
| 875 | G = clip(( common - 100 * Cb - 208 * Cr + 91776) >> 8) |
| 876 | B = clip(( common + 516 * Cb - 13696) >> 8) |
| 877 | |
| 878 | */ |
| 879 | UINT8 y = ycc; |
| 880 | UINT8 cb = ycc >> 8; |
| 881 | UINT8 cr = ycc >> 16; |
| 882 | UINT32 r, g, b, common; |
| 883 | |
| 884 | common = 298 * y - 56992; |
| 885 | r = (common + 409 * cr); |
| 886 | g = (common - 100 * cb - 208 * cr + 91776); |
| 887 | b = (common + 516 * cb - 13696); |
| 888 | |
| 889 | /* Now clamp and shift back */ |
| 890 | return MAKE_RGB(clamp16_shift8(r), clamp16_shift8(g), clamp16_shift8(b)); |
| 891 | } |
| 892 | |
| 893 | static SCREEN_UPDATE_RGB32( cxhumax ) |
| 894 | { |
| 895 | int i, j; |
| 896 | |
| 897 | cxhumax_state *state = screen.machine().driver_data<cxhumax_state>(); |
| 898 | |
| 899 | UINT32 osd_pointer = state->m_drm1_regs[DRM_OSD_PTR_REG]; |
| 900 | |
| 901 | if(osd_pointer) |
| 902 | { |
| 903 | UINT32 *ram = state->m_ram; |
| 904 | UINT32 *osd_header = &ram[osd_pointer/4]; |
| 905 | UINT8 *vbuf = (UINT8*)(&ram[osd_header[3]/4]); |
| 906 | UINT32 *palette = &ram[osd_header[7]/4]; |
| 907 | |
| 908 | UINT32 x_disp_start_and_width = osd_header[1]; |
| 909 | UINT32 xdisp_width = (x_disp_start_and_width >> 16) & 0x1fff; |
| 910 | UINT32 xdisp_start = x_disp_start_and_width & 0xfff; |
| 911 | |
| 912 | UINT32 image_height_and_width = osd_header[2]; |
| 913 | UINT32 yimg_height = (image_height_and_width >> 16) & 0x7ff; |
| 914 | UINT32 ximg_width = image_height_and_width & 0x7ff; |
| 915 | |
| 916 | UINT32 y_position_and_region_alpha = osd_header[5]; |
| 917 | UINT32 ydisp_last = (y_position_and_region_alpha >> 12) & 0x7ff; |
| 918 | UINT32 ydisp_start = y_position_and_region_alpha & 0x7ff; |
| 919 | |
| 920 | /* UINT32 first_x = state->m_drm0_regs[DRM_ACTIVE_X_REG] & 0xffff; |
| 921 | UINT32 last_x = (state->m_drm0_regs[DRM_ACTIVE_X_REG] >> 16) & 0xffff; |
| 922 | |
| 923 | UINT32 first_y = state->m_drm0_regs[DRM_ACTIVE_Y_REG] & 0xfff; |
| 924 | UINT32 last_y = (state->m_drm0_regs[DRM_ACTIVE_Y_REG] >> 16) & 0xfff;*/ |
| 925 | |
| 926 | for (j=ydisp_start; j <= ydisp_last; j++) |
| 927 | { |
| 928 | UINT32 *bmp = &bitmap.pix32(j); |
| 929 | |
| 930 | for (i=xdisp_start; i <= (xdisp_start + xdisp_width); i++) |
| 931 | { |
| 932 | if ((i <= (xdisp_start + ximg_width)) && (j <= (ydisp_start + yimg_height))) { |
| 933 | bmp[i] = palette[vbuf[i+((j-ydisp_start)*ximg_width)]]; |
| 934 | } else { |
| 935 | bmp[i] = ycc_to_rgb(state->m_drm1_regs[DRM_BCKGND_REG]); |
| 936 | } |
| 937 | } |
| 938 | } |
| 939 | } |
| 940 | return 0; |
| 941 | } |
| 942 | |
| 943 | static ADDRESS_MAP_START(cxhumax_map, AS_PROGRAM, 32, cxhumax_state) |
| 944 | AM_RANGE(0x00000000, 0x03ffffff) AM_RAM AM_SHARE("ram") AM_MIRROR(0x40000000) // 64?MB RAM |
| 945 | AM_RANGE(0xe0000000, 0xe000ffff) AM_READWRITE(cx_hsx_r, cx_hsx_w) // HSX |
| 946 | AM_RANGE(0xe0010000, 0xe0010003) AM_READWRITE(cx_romdescr_r, cx_romdescr_w) // ROM Descriptor |
| 947 | AM_RANGE(0xe0010004, 0xe001000f) AM_READWRITE(cx_isaromdescr_r, cx_isaromdescr_w) // ISA/ROM Descriptors |
| 948 | AM_RANGE(0xe0010010, 0xe001001f) AM_READWRITE(cx_isadescr_r, cx_isadescr_w) // ISA Descriptors |
| 949 | AM_RANGE(0xe0010020, 0xe001002f) AM_READWRITE(cx_rommap_r, cx_rommap_w) // ROM Mapping |
| 950 | AM_RANGE(0xe0010030, 0xe0010033) AM_READWRITE(cx_rommode_r, cx_rommode_w) // ISA Mode |
| 951 | AM_RANGE(0xe0010034, 0xe0010037) AM_READWRITE(cx_xoemask_r, cx_xoemask_w) // XOE Mask |
| 952 | AM_RANGE(0xe0010040, 0xe0010047) AM_READWRITE(cx_pci_r, cx_pci_w) // PCI |
| 953 | AM_RANGE(0xe0010080, 0xe00100ff) AM_READWRITE(cx_extdesc_r, cx_extdesc_w) // Extended Control |
| 954 | AM_RANGE(0xe0400014, 0xe0400017) AM_WRITE(cx_remap_w) // RST_REMAP_REG |
| 955 | AM_RANGE(0xe0400024, 0xe0400027) AM_READWRITE(cx_scratch_r, cx_scratch_w) // RST_SCRATCH_REG - System Scratch Register |
| 956 | AM_RANGE(0xe0430000, 0xe0430103) AM_READWRITE(cx_timers_r, cx_timers_w) // Timers |
| 957 | AM_RANGE(0xe0411000, 0xe0411033) AM_READWRITE(cx_uart2_r, cx_uart2_w) // UART2 |
| 958 | AM_RANGE(0xe0440000, 0xe0440013) AM_READWRITE(cx_pll_r, cx_pll_w) // PLL Registers |
| 959 | AM_RANGE(0xe0440020, 0xe0440037) AM_READWRITE(cx_clkdiv_r, cx_clkdiv_w) // Clock Divider Registers |
| 960 | AM_RANGE(0xe0440094, 0xe0440097) AM_READWRITE(cx_pllprescale_r, cx_pllprescale_w) // PLL Prescale |
| 961 | AM_RANGE(0xe0440100, 0xe0440173) AM_READWRITE(cx_chipcontrol_r, cx_chipcontrol_w) // Chip Control Registers |
| 962 | AM_RANGE(0xe0450000, 0xe0450037) AM_READWRITE(cx_intctrl_r, cx_intctrl_w) // Interrupt Controller Registers |
| 963 | AM_RANGE(0xe0490000, 0xe0490017) AM_READWRITE(cx_ss_r, cx_ss_w) // Synchronous Serial Port |
| 964 | AM_RANGE(0xe04e0000, 0xe04e001f) AM_READWRITE(cx_i2c0_r, cx_i2c0_w) // I2C0 |
| 965 | AM_RANGE(0xe04e1000, 0xe04e101f) AM_READWRITE(cx_i2c1_r, cx_i2c1_w) // I2C1 |
| 966 | AM_RANGE(0xe04e2000, 0xe04e201f) AM_READWRITE(cx_i2c2_r, cx_i2c2_w) // I2C2 |
| 967 | AM_RANGE(0xe0500300, 0xe050030b) AM_READWRITE(cx_mc_cfg_r, cx_mc_cfg_w) // Memory Controller configuration |
| 968 | AM_RANGE(0xe0560000, 0xe05600fb) AM_READWRITE(cx_drm0_r, cx_drm0_w) // DRM0 |
| 969 | AM_RANGE(0xe0570000, 0xe05700fb) AM_READWRITE(cx_drm1_r, cx_drm1_w) // DRM1 |
| 970 | AM_RANGE(0xe05d0800, 0xe05d0bff) AM_READWRITE(cx_hdmi_r, cx_hdmi_w) // HDMI |
| 971 | AM_RANGE(0xe0600000, 0xe063ffff) AM_READWRITE(cx_gxa_r, cx_gxa_w) // GXA |
| 972 | AM_RANGE(0xe4017000, 0xe40173ff) AM_RAM // HSX - BSP - 1K Video Shared Dual Port RAM (shared with MVP) |
| 973 | AM_RANGE(0xe4080000, 0xe4083fff) AM_RAM // HSX - TSP 0 - 16K Private Instructions/Data and Host-Shared Data |
| 974 | AM_RANGE(0xf0000000, 0xf03fffff) AM_READWRITE(flash_r, flash_w) AM_MIRROR(0xf8000000) // 4MB FLASH (INTEL 28F320J3D) |
| 975 | AM_RANGE(0xf4000000, 0xf43fffff) AM_READ(dummy_flash_r) // do we need it? |
| 976 | ADDRESS_MAP_END |
| 977 | |
| 978 | static INPUT_PORTS_START( cxhumax ) |
| 979 | INPUT_PORTS_END |
| 980 | |
| 981 | static MACHINE_START( cxhumax ) |
| 982 | { |
| 983 | cxhumax_state *state = machine.driver_data<cxhumax_state>(); |
| 984 | state->m_i2cmem = machine.device("eeprom"); |
| 985 | int index = 0; |
| 986 | for(index = 0; index < MAX_CX_TIMERS; index++) |
| 987 | { |
| 988 | state->m_timer_regs.timer[index].timer = machine.scheduler().timer_alloc(FUNC(timer_tick)); |
| 989 | state->m_timer_regs.timer[index].timer->adjust(attotime::never, index); |
| 990 | } |
| 991 | } |
| 992 | |
| 993 | static MACHINE_RESET( cxhumax ) |
| 994 | { |
| 995 | cxhumax_state *state = machine.driver_data<cxhumax_state>(); |
| 996 | |
| 997 | state->m_i2c0_regs[0x08/4] = 0x08; // SDA high |
| 998 | state->m_i2c2_regs[0x08/4] = 0x08; // SDA high |
| 999 | |
| 1000 | UINT8* FLASH = machine.root_device().memregion("flash")->base(); |
| 1001 | memcpy(state->m_ram,FLASH,0x400000); |
| 1002 | |
| 1003 | state->m_chipcontrol_regs[PIN_CONFIG_0_REG] = |
| 1004 | 1 << 0 | /* Short Reset: 0=200ms delay ; 1=1ms delay */ |
| 1005 | 1 << 1 | /* Software config bit. OK */ |
| 1006 | 1 << 4 | /* SDRAM memory controller data width. 0=16bit 1=32bit */ |
| 1007 | 1 << 11 | /* I/O Addr bus width 11=23 bit 10=22bit 01=21bit 00=20bit / PCImode: 0=held in reset 1=normal reset OK? */ |
| 1008 | 0 << 16 | /* 0=PCI mode 1=Standard I/O mode */ |
| 1009 | 1 << 23 | /* 0=PCI device 1=PCI host bridge OK */ |
| 1010 | 1 << 26 | /* 0=SC1 used for NDS 1=SC1 not used for NDS */ |
| 1011 | 1 << 27 | /* 0=8bit ROM 1=16bit ROM */ |
| 1012 | 1 << 28 | /* 0=SC0 used for NDS 1=SC0 not used for NDS */ |
| 1013 | 0 << 29 | /* 0=using SC2 1=not using SC2 */ |
| 1014 | 0 << 30 | /* 0=using SC1 (TDA8004) 1=not using SC1 */ |
| 1015 | 1 << 31; /* 0=Ext clk for boot 1=Int PLL for boot OK */ |
| 1016 | state->m_chipcontrol_regs[SREG_MODE_REG] = 0x0000020F; |
| 1017 | |
| 1018 | memset(state->m_isaromdescr_regs,0,sizeof(state->m_isaromdescr_regs)); |
| 1019 | memset(state->m_isadescr_regs,0,sizeof(state->m_isadescr_regs)); |
| 1020 | state->m_rommode_reg=0; |
| 1021 | state->m_xoemask_reg=0; |
| 1022 | memset(state->m_extdesc_regs,0,sizeof(state->m_extdesc_regs)); |
| 1023 | |
| 1024 | state->m_pll_regs[SREG_MPG_0_INTFRAC_REG] = (0x1A << 25) /* integer */ | 0x5D1764 /* fraction */; |
| 1025 | state->m_pll_regs[SREG_MPG_1_INTFRAC_REG] = (0x1A << 25) /* integer */ | 0x5D1764 /* fraction */; |
| 1026 | state->m_pll_regs[SREG_ARM_INTFRAC_REG] = (0x28 << 25) /* integer */ | 0xCEDE62 /* fraction */; |
| 1027 | state->m_pll_regs[SREG_MEM_INTFRAC_REG] = (0x13 << 25) /* integer */ | 0xC9B26D /* fraction */; |
| 1028 | state->m_pll_regs[SREG_USB_INTFRAC_REG] = (0x08 << 25) /* integer */ | 0x52BF5B /* fraction */; |
| 1029 | |
| 1030 | state->m_clkdiv_regs[SREG_DIV_0_REG] = (2<<0)|(1<<6)|(2<<8)|(2<<14)|(10<<16)|(1<<22)|(10<<24)|(1<<30); |
| 1031 | state->m_clkdiv_regs[SREG_DIV_1_REG] = (5<<0)|(0<<6)|(12<<8)|(0<<14)|(4<<16)|(1<<22)|(5<<24)|(1<<30); |
| 1032 | state->m_clkdiv_regs[SREG_DIV_2_REG] = (22<<0)|(0<<6)|(12<<8)|(1<<14)|(4<<16)|(3<<22); //|(5<<24)|(1<<30);??? |
| 1033 | state->m_clkdiv_regs[SREG_DIV_3_REG] = (5<<0)|(0<<6)|(5<<8)|(0<<14)|(5<<16)|(0<<22)|(5<<24)|(0<<30); |
| 1034 | state->m_clkdiv_regs[SREG_DIV_4_REG] = (8<<0)|(0<<6)|(5<<8)|(0<<14)|(5<<16)|(0<<22)|(5<<24)|(0<<30); |
| 1035 | state->m_clkdiv_regs[SREG_DIV_5_REG] = (8<<0)|(0<<6)|(5<<8)|(0<<14)|(5<<16)|(0<<22); |
| 1036 | |
| 1037 | state->m_pllprescale_reg=0xFFF; |
| 1038 | |
| 1039 | state->m_mccfg_regs[MC_CFG0] = ((state->m_chipcontrol_regs[PIN_CONFIG_0_REG]>>4)&1)<<16; |
| 1040 | state->m_mccfg_regs[MC_CFG1] = 0; |
| 1041 | state->m_mccfg_regs[MC_CFG2] = (7<<8)|(7<<0); |
| 1042 | |
| 1043 | // UART2 |
| 1044 | state->m_uart2_regs[UART_FIFC_REG] = 0x30; |
| 1045 | |
| 1046 | // Clear SS TX FIFO |
| 1047 | memset(state->m_ss_tx_fifo,0,sizeof(state->m_ss_tx_fifo)); |
| 1048 | state->m_ss_regs[SS_BAUD_REG] = 1; // Default SS clock = 13,5MHz |
| 1049 | |
| 1050 | memset(state->m_intctrl_regs,0,sizeof(state->m_intctrl_regs)); |
| 1051 | |
| 1052 | memset(state->m_hdmi_regs,0,sizeof(state->m_hdmi_regs)); |
| 1053 | |
| 1054 | memset(state->m_gxa_cmd_regs,0,sizeof(state->m_gxa_cmd_regs)); |
| 1055 | } |
| 1056 | |
| 1057 | static GENERIC_TERMINAL_INTERFACE( terminal_intf ) |
| 1058 | { |
| 1059 | DEVCB_NULL |
| 1060 | }; |
| 1061 | |
| 1062 | static const i2cmem_interface i2cmem_interface = |
| 1063 | { |
| 1064 | I2CMEM_SLAVE_ADDRESS, 0, 0x2000 |
| 1065 | }; |
| 1066 | |
| 1067 | static MACHINE_CONFIG_START( cxhumax, cxhumax_state ) |
| 1068 | MCFG_CPU_ADD("maincpu", ARM920T, 180000000) // CX24175 (RevC up?) |
| 1069 | MCFG_CPU_PROGRAM_MAP(cxhumax_map) |
| 1070 | |
| 1071 | MCFG_MACHINE_RESET(cxhumax) |
| 1072 | MCFG_MACHINE_START(cxhumax) |
| 1073 | |
| 1074 | MCFG_INTEL_28F320J3D_ADD("flash") |
| 1075 | MCFG_I2CMEM_ADD("eeprom",i2cmem_interface) |
| 1076 | |
| 1077 | /* video hardware */ |
| 1078 | MCFG_SCREEN_ADD("screen", RASTER) |
| 1079 | MCFG_SCREEN_REFRESH_RATE(50) |
| 1080 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 1081 | MCFG_SCREEN_SIZE(1920, 1080) |
| 1082 | MCFG_SCREEN_VISIBLE_AREA(0, 1920-1, 0, 1080-1) |
| 1083 | MCFG_SCREEN_UPDATE_STATIC(cxhumax) |
| 1084 | |
| 1085 | MCFG_PALETTE_LENGTH(2) |
| 1086 | MCFG_PALETTE_INIT(black_and_white) |
| 1087 | |
| 1088 | MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, terminal_intf) |
| 1089 | |
| 1090 | MCFG_VIDEO_START(cxhumax) |
| 1091 | MACHINE_CONFIG_END |
| 1092 | |
| 1093 | ROM_START( hxhdci2k ) |
| 1094 | ROM_REGION( 0x400000, "flash", 0 ) |
| 1095 | ROM_SYSTEM_BIOS( 0, "FW10005", "HDCI REV 1.0 RHDXSCI 1.00.05" ) /* 19 AUG 2008 */ |
| 1096 | ROM_LOAD16_WORD_SWAP( "28f320j3d.bin", 0x000000, 0x400000, BAD_DUMP CRC(63d98942) SHA1(c5b8d701677a3edc25f203854f44953b19c9158d) ) |
| 1097 | |
| 1098 | ROM_REGION16_BE( 0x2000, "eeprom", 0 ) |
| 1099 | ROM_LOAD( "24lc64.bin", 0x0000, 0x2000, NO_DUMP) |
| 1100 | ROM_END |
| 1101 | |
| 1102 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 1103 | SYST( 2008, hxhdci2k, 0, 0, cxhumax, cxhumax, 0, "HUMAX", "HUMAX HDCI-2000", GAME_NOT_WORKING | GAME_NO_SOUND) |