src/mess/drivers/cdi.c
| r6055 | r6056 | |
| 944 | 944 | cdrom_read_data(cdic_regs.cd, lba, buffer, CD_TRACK_RAW_DONTCARE); |
| 945 | 945 | for(index = 6; index < 2352/2; index++) |
| 946 | 946 | { |
| 947 | | if(cdic_regs.time == 0x00332300 || cdic_regs.time == 0x00332400) |
| 948 | | { |
| 949 | | //printf( "%02x %02x ", buffer[index*2], buffer[index*2 + 1] ); |
| 950 | | } |
| 951 | 947 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1]; |
| 952 | 948 | } |
| 953 | | //printf( "\n" ); |
| 954 | 949 | |
| 955 | 950 | cdic_regs.time += 0x100; |
| 956 | 951 | if((cdic_regs.time & 0x00000f00) == 0xa00) |
| r6055 | r6056 | |
| 1175 | 1170 | UINT8 xbus_interrupt_enable; |
| 1176 | 1171 | |
| 1177 | 1172 | UINT8 lcd_state[16]; |
| 1173 | |
| 1174 | UINT16 real_mouse_x; |
| 1175 | UINT16 real_mouse_y; |
| 1176 | |
| 1177 | UINT16 fake_mouse_x; |
| 1178 | UINT16 fake_mouse_y; |
| 1178 | 1179 | } slave_regs_t; |
| 1179 | 1180 | |
| 1180 | 1181 | static slave_regs_t slave_regs; |
| r6055 | r6056 | |
| 1206 | 1207 | UINT16 y = input_port_read(machine, "MOUSEY"); |
| 1207 | 1208 | UINT8 buttons = input_port_read(machine, "MOUSEBTN"); |
| 1208 | 1209 | |
| 1210 | UINT16 old_mouse_x = slave_regs.real_mouse_x; |
| 1211 | UINT16 old_mouse_y = slave_regs.real_mouse_y; |
| 1212 | |
| 1213 | slave_regs.real_mouse_x = x & 0x3ff; |
| 1214 | slave_regs.real_mouse_y = y & 0x3ff; |
| 1215 | |
| 1216 | if(slave_regs.real_mouse_x == 0xffff) |
| 1217 | { |
| 1218 | slave_regs.fake_mouse_x = slave_regs.real_mouse_x; |
| 1219 | slave_regs.fake_mouse_y = slave_regs.real_mouse_y; |
| 1220 | } |
| 1221 | else |
| 1222 | { |
| 1223 | old_mouse_x = 0xffff; |
| 1224 | old_mouse_y = 0xffff; |
| 1225 | slave_regs.fake_mouse_x = x & 0x3ff; |
| 1226 | slave_regs.fake_mouse_y = y & 0x3ff; |
| 1227 | } |
| 1228 | |
| 1229 | slave_regs.fake_mouse_x += (slave_regs.real_mouse_x - old_mouse_x); |
| 1230 | slave_regs.fake_mouse_y += (slave_regs.real_mouse_y - old_mouse_y); |
| 1231 | |
| 1232 | x = slave_regs.fake_mouse_x; |
| 1233 | y = slave_regs.fake_mouse_y; |
| 1234 | |
| 1209 | 1235 | if(slave_regs.polling_active) |
| 1210 | 1236 | { |
| 1211 | 1237 | slave_prepare_readback(machine, ATTOTIME_IN_HZ(10000), 0, 4, ((x & 0x380) >> 7) | (buttons << 4), x & 0x7f, (y & 0x380) >> 7, y & 0x7f, 0xf7); |
| r6055 | r6056 | |
| 1251 | 1277 | return 0xff; |
| 1252 | 1278 | } |
| 1253 | 1279 | |
| 1280 | static void set_mouse_position(running_machine* machine) |
| 1281 | { |
| 1282 | UINT16 x, y; |
| 1283 | |
| 1284 | printf( "old fake mouse x: %04x\n", slave_regs.fake_mouse_x ); |
| 1285 | printf( "old fake mouse y: %04x\n", slave_regs.fake_mouse_y ); |
| 1286 | |
| 1287 | slave_regs.fake_mouse_y = (slave_regs.fake_mouse_y & 0xff80) | (slave_regs.in_buf[1] & 0x7f); |
| 1288 | slave_regs.fake_mouse_x = (slave_regs.fake_mouse_x & 0xff80) | (slave_regs.in_buf[2] & 0x7f); |
| 1289 | |
| 1290 | x = slave_regs.fake_mouse_x; |
| 1291 | y = slave_regs.fake_mouse_y; |
| 1292 | |
| 1293 | printf( "new fake mouse x: %04x\n", slave_regs.fake_mouse_x ); |
| 1294 | printf( "new fake mouse y: %04x\n", slave_regs.fake_mouse_y ); |
| 1295 | |
| 1296 | if(slave_regs.polling_active) |
| 1297 | { |
| 1298 | slave_prepare_readback(machine, ATTOTIME_IN_HZ(10000), 0, 4, (x & 0x380) >> 7, x & 0x7f, (y & 0x380) >> 7, y & 0x7f, 0xf7); |
| 1299 | } |
| 1300 | } |
| 1301 | |
| 1254 | 1302 | static WRITE16_HANDLER( slave_w ) |
| 1255 | 1303 | { |
| 1256 | 1304 | switch(offset) |
| r6055 | r6056 | |
| 1273 | 1321 | case 0xe8: case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed: case 0xee: case 0xef: |
| 1274 | 1322 | case 0xf0: case 0xf1: case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf6: case 0xf7: |
| 1275 | 1323 | case 0xf8: case 0xf9: case 0xfa: case 0xfb: case 0xfc: case 0xfd: case 0xfe: case 0xff: // Update Mouse Position |
| 1276 | | //perform_mouse_update(space->machine); |
| 1324 | set_mouse_position(space->machine); |
| 1277 | 1325 | memset(slave_regs.in_buf, 0, 17); |
| 1278 | 1326 | slave_regs.in_index = 0; |
| 1279 | 1327 | slave_regs.in_count = 0; |
| r6055 | r6056 | |
| 1789 | 1837 | case 0xb0: case 0xb1: case 0xb2: case 0xb3: case 0xb4: case 0xb5: case 0xb6: case 0xb7: |
| 1790 | 1838 | case 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe: case 0xbf: |
| 1791 | 1839 | verboselog(machine, 11, " %04xxxxx: %d: CLUT[%d] = %08x\n", channel * 0x20, channel, mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80), value ); |
| 1792 | | mcd212.channel[channel].clut[mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80)] = value; |
| 1840 | mcd212.channel[0].clut[mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80)] = value; |
| 1793 | 1841 | break; |
| 1794 | 1842 | case 0xc0: // Image Coding Method |
| 1795 | 1843 | if(channel == 0) |
| r6055 | r6056 | |
| 1814 | 1862 | break; |
| 1815 | 1863 | case 0xc3: // CLUT Bank Register |
| 1816 | 1864 | verboselog(machine, 11, " %04xxxxx: %d: CLUT Bank Register = %08x\n", channel * 0x20, channel, value & 3); |
| 1817 | | mcd212.channel[channel].clut_bank = value & 0x00000003; |
| 1865 | mcd212.channel[channel].clut_bank = channel ? (2 | (value & 0x00000001)) : (value & 0x00000003); |
| 1818 | 1866 | break; |
| 1819 | 1867 | case 0xc4: // Transparent Color A |
| 1820 | 1868 | if(channel == 0) |
| r6055 | r6056 | |
| 1887 | 1935 | case 0xd5: |
| 1888 | 1936 | case 0xd6: |
| 1889 | 1937 | case 0xd7: |
| 1890 | | verboselog(machine, 11, " %04xxxxx: %d: Region Control %d = %08x\n", channel * 0x20, channel, reg & 7, value ); |
| 1938 | verboselog(machine, 6, " %04xxxxx: %d: Region Control %d = %08x\n", channel * 0x20, channel, reg & 7, value ); |
| 1891 | 1939 | mcd212.channel[channel].region_control[reg & 7] = value; |
| 1892 | 1940 | break; |
| 1893 | 1941 | case 0xd8: // Backdrop Color |
| r6055 | r6056 | |
| 2049 | 2097 | UINT32 addr = (mcd212.channel[channel].dca & 0x0007ffff) / 2; //(mcd212_get_dcp(channel) & 0x0007ffff) / 2; // mcd212.channel[channel].dca / 2; |
| 2050 | 2098 | UINT32 cmd = 0; |
| 2051 | 2099 | UINT32 count = 0; |
| 2052 | | UINT32 max = 64; //(mcd212.channel[channel].dcr & MCD212_DCR_CM) ? 64 : 32; |
| 2100 | UINT32 max = 64; |
| 2053 | 2101 | UINT8 addr_changed = 0; |
| 2054 | 2102 | //printf( "max = %d\n", max ); |
| 2055 | 2103 | while(1) |
| r6055 | r6056 | |
| 2130 | 2178 | break; |
| 2131 | 2179 | } |
| 2132 | 2180 | } |
| 2181 | if(!addr_changed) |
| 2182 | { |
| 2183 | if(count < max) |
| 2184 | { |
| 2185 | addr += (max - count) >> 1; |
| 2186 | } |
| 2187 | } |
| 2133 | 2188 | mcd212.channel[channel].dca = addr * 2; |
| 2134 | 2189 | } |
| 2135 | 2190 | |
| r6055 | r6056 | |
| 2179 | 2234 | return (UINT8)in; |
| 2180 | 2235 | } |
| 2181 | 2236 | |
| 2237 | INLINE UINT8 BYTE_TO_CLUT7(int channel, UINT8 byte) |
| 2238 | { |
| 2239 | if(channel) |
| 2240 | { |
| 2241 | return 0x80 + (byte & 0x7f); |
| 2242 | } |
| 2243 | else |
| 2244 | { |
| 2245 | return byte & 0x7f; |
| 2246 | } |
| 2247 | } |
| 2248 | |
| 2182 | 2249 | static void mcd212_process_vsr(running_machine *machine, int channel, UINT32 *pixels) |
| 2183 | 2250 | { |
| 2184 | 2251 | UINT8 *data = channel ? (UINT8*)planeb : (UINT8*)planea; |
| r6055 | r6056 | |
| 2192 | 2259 | //printf( "vsr before: %08x: ", vsr ); |
| 2193 | 2260 | //fflush(stdout); |
| 2194 | 2261 | |
| 2195 | | if(!icm) |
| 2262 | if(!icm || !vsr) |
| 2196 | 2263 | { |
| 2197 | 2264 | for(; x < 768; x++) |
| 2198 | 2265 | { |
| r6055 | r6056 | |
| 2288 | 2355 | { |
| 2289 | 2356 | for(; x < 768; x++) |
| 2290 | 2357 | { |
| 2291 | | pixels[x++] = mcd212.channel[channel].clut[((channel == 1) ? 0x80 : 0x00) + (byte & 0x7f)]; |
| 2292 | | pixels[x] = mcd212.channel[channel].clut[((channel == 1) ? 0x80 : 0x00) + (byte & 0x7f)]; |
| 2358 | pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte)]; |
| 2359 | pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte)]; |
| 2293 | 2360 | byte = data[vsr++ ^ 1]; |
| 2294 | 2361 | } |
| 2295 | 2362 | mcd212_set_vsr(channel, vsr - 1); |
| r6055 | r6056 | |
| 2326 | 2393 | // Go to the end of the line |
| 2327 | 2394 | for(; x < 768; x++) |
| 2328 | 2395 | { |
| 2329 | | pixels[x++] = mcd212.channel[channel].clut[byte & 0x7f]; |
| 2330 | | pixels[x] = mcd212.channel[channel].clut[byte & 0x7f]; |
| 2396 | pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte & 0x7f)]; |
| 2397 | pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte & 0x7f)]; |
| 2331 | 2398 | } |
| 2332 | 2399 | done = 1; |
| 2333 | 2400 | mcd212_set_vsr(channel, vsr); |
| r6055 | r6056 | |
| 2339 | 2406 | //fflush(stdout); |
| 2340 | 2407 | for(; x < end && x < 768; x++) |
| 2341 | 2408 | { |
| 2342 | | pixels[x++] = mcd212.channel[channel].clut[byte & 0x7f]; |
| 2343 | | pixels[x] = mcd212.channel[channel].clut[byte & 0x7f]; |
| 2409 | pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte & 0x7f)]; |
| 2410 | pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte & 0x7f)]; |
| 2344 | 2411 | } |
| 2345 | 2412 | if(x >= 768) |
| 2346 | 2413 | { |
| r6055 | r6056 | |
| 2352 | 2419 | else |
| 2353 | 2420 | { |
| 2354 | 2421 | // Single pixel |
| 2355 | | pixels[x++] = mcd212.channel[channel].clut[byte & 0x7f]; |
| 2356 | | pixels[x++] = mcd212.channel[channel].clut[byte & 0x7f]; |
| 2422 | pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte & 0x7f)]; |
| 2423 | pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte & 0x7f)]; |
| 2357 | 2424 | if(x >= 768) |
| 2358 | 2425 | { |
| 2359 | 2426 | done = 1; |
| r6055 | r6056 | |
| 2728 | 2795 | |
| 2729 | 2796 | cdic_regs.z_buffer = 0; |
| 2730 | 2797 | cdic_regs.channel = 0xffffffff; |
| 2798 | |
| 2799 | slave_regs.real_mouse_x = 0xffff; |
| 2800 | slave_regs.real_mouse_y = 0xffff; |
| 2731 | 2801 | } |
| 2732 | 2802 | |
| 2733 | 2803 | /************************* |