src/emu/cpu/psx/mdec.c
| r0 | r11507 | |
| 1 | /*
|
| 2 | * PlayStation Motion Decoder emulator
|
| 3 | *
|
| 4 | * Copyright 2003-2011 smf
|
| 5 | *
|
| 6 | */
|
| 7 | |
| 8 | #include "emu.h"
|
| 9 | #include "dma.h"
|
| 10 | #include "mdec.h"
|
| 11 | #include "includes/psx.h"
|
| 12 | |
| 13 | #define VERBOSE_LEVEL ( 0 )
|
| 14 | |
| 15 | INLINE void ATTR_PRINTF(3,4) verboselog( running_machine& machine, int n_level, const char *s_fmt, ... )
|
| 16 | {
|
| 17 | if( VERBOSE_LEVEL >= n_level )
|
| 18 | {
|
| 19 | va_list v;
|
| 20 | char buf[ 32768 ];
|
| 21 | va_start( v, s_fmt );
|
| 22 | vsprintf( buf, s_fmt, v );
|
| 23 | va_end( v );
|
| 24 | logerror( "%s: %s", machine.describe_context(), buf );
|
| 25 | }
|
| 26 | }
|
| 27 | |
| 28 | const device_type PSX_MDEC = &device_creator<psxmdec_device>;
|
| 29 | |
| 30 | psxmdec_device::psxmdec_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
| 31 | : device_t(mconfig, PSX_MDEC, "PSX MDEC", tag, owner, clock)
|
| 32 | {
|
| 33 | }
|
| 34 | |
| 35 | void psxmdec_device::device_reset()
|
| 36 | {
|
| 37 | n_0_command = 0;
|
| 38 | n_0_address = 0;
|
| 39 | n_0_size = 0;
|
| 40 | n_1_command = 0;
|
| 41 | n_1_status = 0;
|
| 42 | n_offset = 0;
|
| 43 | n_decoded = 0;
|
| 44 | }
|
| 45 | |
| 46 | void psxmdec_device::device_post_load()
|
| 47 | {
|
| 48 | mdec_cos_precalc();
|
| 49 | }
|
| 50 | |
| 51 | void psxmdec_device::device_start()
|
| 52 | {
|
| 53 | for( int n = 0; n < 256; n++ )
|
| 54 | {
|
| 55 | p_n_clamp8[ n ] = 0;
|
| 56 | p_n_clamp8[ n + 256 ] = n;
|
| 57 | p_n_clamp8[ n + 512 ] = 255;
|
| 58 | |
| 59 | p_n_r5[ n ] = 0;
|
| 60 | p_n_r5[ n + 256 ] = ( n >> 3 );
|
| 61 | p_n_r5[ n + 512 ] = ( 255 >> 3 );
|
| 62 | |
| 63 | p_n_g5[ n ] = 0;
|
| 64 | p_n_g5[ n + 256 ] = ( n >> 3 ) << 5;
|
| 65 | p_n_g5[ n + 512 ] = ( 255 >> 3 ) << 5;
|
| 66 | |
| 67 | p_n_b5[ n ] = 0;
|
| 68 | p_n_b5[ n + 256 ] = ( n >> 3 ) << 10;
|
| 69 | p_n_b5[ n + 512 ] = ( 255 >> 3 ) << 10;
|
| 70 | }
|
| 71 | |
| 72 | state_save_register_global( machine(), n_0_command );
|
| 73 | state_save_register_global( machine(), n_0_address );
|
| 74 | state_save_register_global( machine(), n_0_size );
|
| 75 | state_save_register_global( machine(), n_1_command );
|
| 76 | state_save_register_global( machine(), n_1_status );
|
| 77 | state_save_register_global_array( machine(), p_n_quantize_y );
|
| 78 | state_save_register_global_array( machine(), p_n_quantize_uv );
|
| 79 | state_save_register_global_array( machine(), p_n_cos );
|
| 80 | }
|
| 81 | |
| 82 | #ifdef UNUSED_FUNCTION
|
| 83 | INLINE void psxwriteword( UINT32 *p_n_psxram, UINT32 n_address, UINT16 n_data )
|
| 84 | {
|
| 85 | *( (UINT16 *)( (UINT8 *)p_n_psxram + WORD_XOR_LE( n_address ) ) ) = n_data;
|
| 86 | }
|
| 87 | #endif
|
| 88 | |
| 89 | INLINE UINT16 psxreadword( UINT32 *p_n_psxram, UINT32 n_address )
|
| 90 | {
|
| 91 | return *( (UINT16 *)( (UINT8 *)p_n_psxram + WORD_XOR_LE( n_address ) ) );
|
| 92 | }
|
| 93 | |
| 94 | static const UINT32 m_p_n_mdec_zigzag[ DCTSIZE2 ] =
|
| 95 | {
|
| 96 | 0, 1, 8, 16, 9, 2, 3, 10,
|
| 97 | 17, 24, 32, 25, 18, 11, 4, 5,
|
| 98 | 12, 19, 26, 33, 40, 48, 41, 34,
|
| 99 | 27, 20, 13, 6, 7, 14, 21, 28,
|
| 100 | 35, 42, 49, 56, 57, 50, 43, 36,
|
| 101 | 29, 22, 15, 23, 30, 37, 44, 51,
|
| 102 | 58, 59, 52, 45, 38, 31, 39, 46,
|
| 103 | 53, 60, 61, 54, 47, 55, 62, 63
|
| 104 | };
|
| 105 | |
| 106 | void psxmdec_device::mdec_cos_precalc()
|
| 107 | {
|
| 108 | UINT32 n_x;
|
| 109 | UINT32 n_y;
|
| 110 | UINT32 n_u;
|
| 111 | UINT32 n_v;
|
| 112 | INT32 *p_n_precalc = p_n_cos_precalc;
|
| 113 | |
| 114 | for( n_y = 0; n_y < 8; n_y++ )
|
| 115 | {
|
| 116 | for( n_x = 0; n_x < 8; n_x++ )
|
| 117 | {
|
| 118 | for( n_v = 0; n_v < 8; n_v++ )
|
| 119 | {
|
| 120 | for( n_u = 0; n_u < 8; n_u++ )
|
| 121 | {
|
| 122 | *( p_n_precalc++ ) =
|
| 123 | ( ( p_n_cos[ ( n_u * 8 ) + n_x ] *
|
| 124 | p_n_cos[ ( n_v * 8 ) + n_y ] ) >> ( 30 - MDEC_COS_PRECALC_BITS ) );
|
| 125 | }
|
| 126 | }
|
| 127 | }
|
| 128 | }
|
| 129 | }
|
| 130 | |
| 131 | void psxmdec_device::mdec_idct( INT32 *p_n_src, INT32 *p_n_dst )
|
| 132 | {
|
| 133 | INT32 *p_n_precalc = p_n_cos_precalc;
|
| 134 | |
| 135 | for( UINT32 n_yx = 0; n_yx < DCTSIZE2; n_yx++ )
|
| 136 | {
|
| 137 | INT32 p_n_z[ 8 ];
|
| 138 | INT32 *p_n_data = p_n_src;
|
| 139 | |
| 140 | memset( p_n_z, 0, sizeof( p_n_z ) );
|
| 141 | |
| 142 | for( UINT32 n_vu = 0; n_vu < DCTSIZE2 / 8; n_vu++ )
|
| 143 | {
|
| 144 | p_n_z[ 0 ] += p_n_data[ 0 ] * p_n_precalc[ 0 ];
|
| 145 | p_n_z[ 1 ] += p_n_data[ 1 ] * p_n_precalc[ 1 ];
|
| 146 | p_n_z[ 2 ] += p_n_data[ 2 ] * p_n_precalc[ 2 ];
|
| 147 | p_n_z[ 3 ] += p_n_data[ 3 ] * p_n_precalc[ 3 ];
|
| 148 | p_n_z[ 4 ] += p_n_data[ 4 ] * p_n_precalc[ 4 ];
|
| 149 | p_n_z[ 5 ] += p_n_data[ 5 ] * p_n_precalc[ 5 ];
|
| 150 | p_n_z[ 6 ] += p_n_data[ 6 ] * p_n_precalc[ 6 ];
|
| 151 | p_n_z[ 7 ] += p_n_data[ 7 ] * p_n_precalc[ 7 ];
|
| 152 | p_n_data += 8;
|
| 153 | p_n_precalc += 8;
|
| 154 | }
|
| 155 | |
| 156 | *( p_n_dst++ ) = ( p_n_z[ 0 ] + p_n_z[ 1 ] + p_n_z[ 2 ] + p_n_z[ 3 ] +
|
| 157 | p_n_z[ 4 ] + p_n_z[ 5 ] + p_n_z[ 6 ] + p_n_z[ 7 ] ) >> ( MDEC_COS_PRECALC_BITS + 2 );
|
| 158 | }
|
| 159 | }
|
| 160 | |
| 161 | INLINE UINT16 mdec_unpack_run( UINT16 n_packed )
|
| 162 | {
|
| 163 | return n_packed >> 10;
|
| 164 | }
|
| 165 | |
| 166 | INLINE INT32 mdec_unpack_val( UINT16 n_packed )
|
| 167 | {
|
| 168 | return ( ( (INT32)n_packed ) << 22 ) >> 22;
|
| 169 | }
|
| 170 | |
| 171 | UINT32 psxmdec_device::mdec_unpack( UINT32 n_address )
|
| 172 | {
|
| 173 | psx_machine *p_psx = machine().driver_data<psx_state>()->m_p_psx;
|
| 174 | UINT32 *p_n_psxram = p_psx->p_n_psxram;
|
| 175 | |
| 176 | UINT8 n_z;
|
| 177 | INT32 n_qscale;
|
| 178 | UINT16 n_packed;
|
| 179 | INT32 *p_n_block;
|
| 180 | INT32 p_n_unpacked[ 64 ];
|
| 181 | INT32 *p_n_q;
|
| 182 | |
| 183 | p_n_q = p_n_quantize_uv;
|
| 184 | p_n_block = m_p_n_unpacked;
|
| 185 | |
| 186 | for( UINT32 n_block = 0; n_block < 6; n_block++ )
|
| 187 | {
|
| 188 | memset( p_n_unpacked, 0, sizeof( p_n_unpacked ) );
|
| 189 | |
| 190 | if( n_block == 2 )
|
| 191 | {
|
| 192 | p_n_q = p_n_quantize_y;
|
| 193 | }
|
| 194 | n_packed = psxreadword( p_n_psxram, n_address );
|
| 195 | n_address += 2;
|
| 196 | if( n_packed == 0xfe00 )
|
| 197 | {
|
| 198 | break;
|
| 199 | }
|
| 200 | |
| 201 | n_qscale = mdec_unpack_run( n_packed );
|
| 202 | p_n_unpacked[ 0 ] = mdec_unpack_val( n_packed ) * p_n_q[ 0 ];
|
| 203 | |
| 204 | n_z = 0;
|
| 205 | for( ;; )
|
| 206 | {
|
| 207 | n_packed = psxreadword( p_n_psxram, n_address );
|
| 208 | n_address += 2;
|
| 209 | |
| 210 | if( n_packed == 0xfe00 )
|
| 211 | {
|
| 212 | break;
|
| 213 | }
|
| 214 | n_z += mdec_unpack_run( n_packed ) + 1;
|
| 215 | if( n_z > 63 )
|
| 216 | {
|
| 217 | break;
|
| 218 | }
|
| 219 | p_n_unpacked[ m_p_n_mdec_zigzag[ n_z ] ] = ( mdec_unpack_val( n_packed ) * p_n_q[ n_z ] * n_qscale ) / 8;
|
| 220 | }
|
| 221 | mdec_idct( p_n_unpacked, p_n_block );
|
| 222 | p_n_block += DCTSIZE2;
|
| 223 | }
|
| 224 | return n_address;
|
| 225 | }
|
| 226 | |
| 227 | INLINE INT32 mdec_cr_to_r( INT32 n_cr )
|
| 228 | {
|
| 229 | return ( 1435 * n_cr ) >> 10;
|
| 230 | }
|
| 231 | |
| 232 | INLINE INT32 mdec_cr_to_g( INT32 n_cr )
|
| 233 | {
|
| 234 | return ( -731 * n_cr ) >> 10;
|
| 235 | }
|
| 236 | |
| 237 | INLINE INT32 mdec_cb_to_g( INT32 n_cb )
|
| 238 | {
|
| 239 | return ( -351 * n_cb ) >> 10;
|
| 240 | }
|
| 241 | |
| 242 | INLINE INT32 mdec_cb_to_b( INT32 n_cb )
|
| 243 | {
|
| 244 | return ( 1814 * n_cb ) >> 10;
|
| 245 | }
|
| 246 | |
| 247 | UINT16 psxmdec_device::mdec_clamp_r5( INT32 n_r ) const
|
| 248 | {
|
| 249 | return p_n_r5[ n_r + 128 + 256 ];
|
| 250 | }
|
| 251 | |
| 252 | UINT16 psxmdec_device::mdec_clamp_g5( INT32 n_g ) const
|
| 253 | {
|
| 254 | return p_n_g5[ n_g + 128 + 256 ];
|
| 255 | }
|
| 256 | |
| 257 | UINT16 psxmdec_device::mdec_clamp_b5( INT32 n_b ) const
|
| 258 | {
|
| 259 | return p_n_b5[ n_b + 128 + 256 ];
|
| 260 | }
|
| 261 | |
| 262 | void psxmdec_device::mdec_makergb15( UINT32 n_address, INT32 n_r, INT32 n_g, INT32 n_b, INT32 *p_n_y, UINT16 n_stp )
|
| 263 | {
|
| 264 | p_n_output[ WORD_XOR_LE( n_address + 0 ) / 2 ] = n_stp |
|
| 265 | mdec_clamp_r5( p_n_y[ 0 ] + n_r ) |
|
| 266 | mdec_clamp_g5( p_n_y[ 0 ] + n_g ) |
|
| 267 | mdec_clamp_b5( p_n_y[ 0 ] + n_b );
|
| 268 | |
| 269 | p_n_output[ WORD_XOR_LE( n_address + 2 ) / 2 ] = n_stp |
|
| 270 | mdec_clamp_r5( p_n_y[ 1 ] + n_r ) |
|
| 271 | mdec_clamp_g5( p_n_y[ 1 ] + n_g ) |
|
| 272 | mdec_clamp_b5( p_n_y[ 1 ] + n_b );
|
| 273 | }
|
| 274 | |
| 275 | void psxmdec_device::mdec_yuv2_to_rgb15( void )
|
| 276 | {
|
| 277 | INT32 n_r;
|
| 278 | INT32 n_g;
|
| 279 | INT32 n_b;
|
| 280 | INT32 n_cb;
|
| 281 | INT32 n_cr;
|
| 282 | INT32 *p_n_cb;
|
| 283 | INT32 *p_n_cr;
|
| 284 | INT32 *p_n_y;
|
| 285 | UINT32 n_x;
|
| 286 | UINT32 n_y;
|
| 287 | UINT32 n_z;
|
| 288 | UINT16 n_stp;
|
| 289 | int n_address = 0;
|
| 290 | |
| 291 | if( ( n_0_command & ( 1L << 25 ) ) != 0 )
|
| 292 | {
|
| 293 | n_stp = 0x8000;
|
| 294 | }
|
| 295 | else
|
| 296 | {
|
| 297 | n_stp = 0x0000;
|
| 298 | }
|
| 299 | |
| 300 | p_n_cr = &m_p_n_unpacked[ 0 ];
|
| 301 | p_n_cb = &m_p_n_unpacked[ DCTSIZE2 ];
|
| 302 | p_n_y = &m_p_n_unpacked[ DCTSIZE2 * 2 ];
|
| 303 | |
| 304 | for( n_z = 0; n_z < 2; n_z++ )
|
| 305 | {
|
| 306 | for( n_y = 0; n_y < 4; n_y++ )
|
| 307 | {
|
| 308 | for( n_x = 0; n_x < 4; n_x++ )
|
| 309 | {
|
| 310 | n_cr = *( p_n_cr );
|
| 311 | n_cb = *( p_n_cb );
|
| 312 | n_r = mdec_cr_to_r( n_cr );
|
| 313 | n_g = mdec_cr_to_g( n_cr ) + mdec_cb_to_g( n_cb );
|
| 314 | n_b = mdec_cb_to_b( n_cb );
|
| 315 | |
| 316 | mdec_makergb15( ( n_address + 0 ), n_r, n_g, n_b, p_n_y, n_stp );
|
| 317 | mdec_makergb15( ( n_address + 32 ), n_r, n_g, n_b, p_n_y + 8, n_stp );
|
| 318 | |
| 319 | n_cr = *( p_n_cr + 4 );
|
| 320 | n_cb = *( p_n_cb + 4 );
|
| 321 | n_r = mdec_cr_to_r( n_cr );
|
| 322 | n_g = mdec_cr_to_g( n_cr ) + mdec_cb_to_g( n_cb );
|
| 323 | n_b = mdec_cb_to_b( n_cb );
|
| 324 | |
| 325 | mdec_makergb15( ( n_address + 16 ), n_r, n_g, n_b, p_n_y + DCTSIZE2, n_stp );
|
| 326 | mdec_makergb15( ( n_address + 48 ), n_r, n_g, n_b, p_n_y + DCTSIZE2 + 8, n_stp );
|
| 327 | |
| 328 | p_n_cr++;
|
| 329 | p_n_cb++;
|
| 330 | p_n_y += 2;
|
| 331 | n_address += 4;
|
| 332 | }
|
| 333 | p_n_cr += 4;
|
| 334 | p_n_cb += 4;
|
| 335 | p_n_y += 8;
|
| 336 | n_address += 48;
|
| 337 | }
|
| 338 | p_n_y += DCTSIZE2;
|
| 339 | }
|
| 340 | n_decoded = ( 16 * 16 ) / 2;
|
| 341 | }
|
| 342 | |
| 343 | UINT16 psxmdec_device::mdec_clamp8( INT32 n_r ) const
|
| 344 | {
|
| 345 | return p_n_clamp8[ n_r + 128 + 256 ];
|
| 346 | }
|
| 347 | |
| 348 | void psxmdec_device::mdec_makergb24( UINT32 n_address, INT32 n_r, INT32 n_g, INT32 n_b, INT32 *p_n_y, UINT32 n_stp )
|
| 349 | {
|
| 350 | p_n_output[ WORD_XOR_LE( n_address + 0 ) / 2 ] = ( mdec_clamp8( p_n_y[ 0 ] + n_g ) << 8 ) | mdec_clamp8( p_n_y[ 0 ] + n_r );
|
| 351 | p_n_output[ WORD_XOR_LE( n_address + 2 ) / 2 ] = ( mdec_clamp8( p_n_y[ 1 ] + n_r ) << 8 ) | mdec_clamp8( p_n_y[ 0 ] + n_b );
|
| 352 | p_n_output[ WORD_XOR_LE( n_address + 4 ) / 2 ] = ( mdec_clamp8( p_n_y[ 1 ] + n_b ) << 8 ) | mdec_clamp8( p_n_y[ 1 ] + n_g );
|
| 353 | }
|
| 354 | |
| 355 | void psxmdec_device::mdec_yuv2_to_rgb24( void )
|
| 356 | {
|
| 357 | INT32 n_r;
|
| 358 | INT32 n_g;
|
| 359 | INT32 n_b;
|
| 360 | INT32 n_cb;
|
| 361 | INT32 n_cr;
|
| 362 | INT32 *p_n_cb;
|
| 363 | INT32 *p_n_cr;
|
| 364 | INT32 *p_n_y;
|
| 365 | UINT32 n_x;
|
| 366 | UINT32 n_y;
|
| 367 | UINT32 n_z;
|
| 368 | UINT32 n_stp;
|
| 369 | int n_address = 0;
|
| 370 | |
| 371 | if( ( n_0_command & ( 1L << 25 ) ) != 0 )
|
| 372 | {
|
| 373 | n_stp = 0x80008000;
|
| 374 | }
|
| 375 | else
|
| 376 | {
|
| 377 | n_stp = 0x00000000;
|
| 378 | }
|
| 379 | |
| 380 | p_n_cr = &m_p_n_unpacked[ 0 ];
|
| 381 | p_n_cb = &m_p_n_unpacked[ DCTSIZE2 ];
|
| 382 | p_n_y = &m_p_n_unpacked[ DCTSIZE2 * 2 ];
|
| 383 | |
| 384 | for( n_z = 0; n_z < 2; n_z++ )
|
| 385 | {
|
| 386 | for( n_y = 0; n_y < 4; n_y++ )
|
| 387 | {
|
| 388 | for( n_x = 0; n_x < 4; n_x++ )
|
| 389 | {
|
| 390 | n_cr = *( p_n_cr );
|
| 391 | n_cb = *( p_n_cb );
|
| 392 | n_r = mdec_cr_to_r( n_cr );
|
| 393 | n_g = mdec_cr_to_g( n_cr ) + mdec_cb_to_g( n_cb );
|
| 394 | n_b = mdec_cb_to_b( n_cb );
|
| 395 | |
| 396 | mdec_makergb24( ( n_address + 0 ), n_r, n_g, n_b, p_n_y, n_stp );
|
| 397 | mdec_makergb24( ( n_address + 48 ), n_r, n_g, n_b, p_n_y + 8, n_stp );
|
| 398 | |
| 399 | n_cr = *( p_n_cr + 4 );
|
| 400 | n_cb = *( p_n_cb + 4 );
|
| 401 | n_r = mdec_cr_to_r( n_cr );
|
| 402 | n_g = mdec_cr_to_g( n_cr ) + mdec_cb_to_g( n_cb );
|
| 403 | n_b = mdec_cb_to_b( n_cb );
|
| 404 | |
| 405 | mdec_makergb24( ( n_address + 24 ), n_r, n_g, n_b, p_n_y + DCTSIZE2, n_stp );
|
| 406 | mdec_makergb24( ( n_address + 72 ), n_r, n_g, n_b, p_n_y + DCTSIZE2 + 8, n_stp );
|
| 407 | |
| 408 | p_n_cr++;
|
| 409 | p_n_cb++;
|
| 410 | p_n_y += 2;
|
| 411 | n_address += 6;
|
| 412 | }
|
| 413 | p_n_cr += 4;
|
| 414 | p_n_cb += 4;
|
| 415 | p_n_y += 8;
|
| 416 | n_address += 72;
|
| 417 | }
|
| 418 | p_n_y += DCTSIZE2;
|
| 419 | }
|
| 420 | n_decoded = ( 24 * 16 ) / 2;
|
| 421 | }
|
| 422 | |
| 423 | void psxmdec_device::dma_write( UINT32 n_address, INT32 n_size )
|
| 424 | {
|
| 425 | psx_machine *p_psx = machine().driver_data<psx_state>()->m_p_psx;
|
| 426 | UINT32 *p_n_psxram = p_psx->p_n_psxram;
|
| 427 | int n_index;
|
| 428 | |
| 429 | verboselog( machine(), 2, "mdec0_write( %08x, %08x )\n", n_address, n_size );
|
| 430 | |
| 431 | switch( n_0_command >> 28 )
|
| 432 | {
|
| 433 | case 0x3:
|
| 434 | verboselog( machine(), 1, "mdec decode %08x %08x %08x\n", n_0_command, n_address, n_size );
|
| 435 | n_0_address = n_address;
|
| 436 | n_0_size = n_size * 4;
|
| 437 | n_1_status |= ( 1L << 29 );
|
| 438 | break;
|
| 439 | case 0x4:
|
| 440 | verboselog( machine(), 1, "mdec quantize table %08x %08x %08x\n", n_0_command, n_address, n_size );
|
| 441 | n_index = 0;
|
| 442 | while( n_size > 0 )
|
| 443 | {
|
| 444 | if( n_index < DCTSIZE2 )
|
| 445 | {
|
| 446 | p_n_quantize_y[ n_index + 0 ] = ( p_n_psxram[ n_address / 4 ] >> 0 ) & 0xff;
|
| 447 | p_n_quantize_y[ n_index + 1 ] = ( p_n_psxram[ n_address / 4 ] >> 8 ) & 0xff;
|
| 448 | p_n_quantize_y[ n_index + 2 ] = ( p_n_psxram[ n_address / 4 ] >> 16 ) & 0xff;
|
| 449 | p_n_quantize_y[ n_index + 3 ] = ( p_n_psxram[ n_address / 4 ] >> 24 ) & 0xff;
|
| 450 | }
|
| 451 | else if( n_index < DCTSIZE2 * 2 )
|
| 452 | {
|
| 453 | p_n_quantize_uv[ n_index + 0 - DCTSIZE2 ] = ( p_n_psxram[ n_address / 4 ] >> 0 ) & 0xff;
|
| 454 | p_n_quantize_uv[ n_index + 1 - DCTSIZE2 ] = ( p_n_psxram[ n_address / 4 ] >> 8 ) & 0xff;
|
| 455 | p_n_quantize_uv[ n_index + 2 - DCTSIZE2 ] = ( p_n_psxram[ n_address / 4 ] >> 16 ) & 0xff;
|
| 456 | p_n_quantize_uv[ n_index + 3 - DCTSIZE2 ] = ( p_n_psxram[ n_address / 4 ] >> 24 ) & 0xff;
|
| 457 | }
|
| 458 | n_index += 4;
|
| 459 | n_address += 4;
|
| 460 | n_size--;
|
| 461 | }
|
| 462 | break;
|
| 463 | case 0x6:
|
| 464 | verboselog( machine(), 1, "mdec cosine table %08x %08x %08x\n", n_0_command, n_address, n_size );
|
| 465 | n_index = 0;
|
| 466 | while( n_size > 0 )
|
| 467 | {
|
| 468 | p_n_cos[ n_index + 0 ] = (INT16)( ( p_n_psxram[ n_address / 4 ] >> 0 ) & 0xffff );
|
| 469 | p_n_cos[ n_index + 1 ] = (INT16)( ( p_n_psxram[ n_address / 4 ] >> 16 ) & 0xffff );
|
| 470 | n_index += 2;
|
| 471 | n_address += 4;
|
| 472 | n_size--;
|
| 473 | }
|
| 474 | mdec_cos_precalc();
|
| 475 | break;
|
| 476 | default:
|
| 477 | verboselog( machine(), 0, "mdec unknown command %08x %08x %08x\n", n_0_command, n_address, n_size );
|
| 478 | break;
|
| 479 | }
|
| 480 | }
|
| 481 | |
| 482 | void psxmdec_device::dma_read( UINT32 n_address, INT32 n_size )
|
| 483 | {
|
| 484 | psx_machine *p_psx = machine().driver_data<psx_state>()->m_p_psx;
|
| 485 | UINT32 *p_n_psxram = p_psx->p_n_psxram;
|
| 486 | UINT32 n_this;
|
| 487 | UINT32 n_nextaddress;
|
| 488 | |
| 489 | verboselog( machine(), 2, "mdec1_read( %08x, %08x )\n", n_address, n_size );
|
| 490 | if( ( n_0_command & ( 1L << 29 ) ) != 0 && n_0_size != 0 )
|
| 491 | {
|
| 492 | while( n_size > 0 )
|
| 493 | {
|
| 494 | if( n_decoded == 0 )
|
| 495 | {
|
| 496 | if( (int)n_0_size <= 0 )
|
| 497 | {
|
| 498 | mame_printf_debug( "ran out of data %08x\n", n_size );
|
| 499 | n_0_size = 0;
|
| 500 | break;
|
| 501 | }
|
| 502 | |
| 503 | n_nextaddress = mdec_unpack( n_0_address );
|
| 504 | n_0_size -= n_nextaddress - n_0_address;
|
| 505 | n_0_address = n_nextaddress;
|
| 506 | |
| 507 | if( ( n_0_command & ( 1L << 27 ) ) != 0 )
|
| 508 | {
|
| 509 | mdec_yuv2_to_rgb15();
|
| 510 | }
|
| 511 | else
|
| 512 | {
|
| 513 | mdec_yuv2_to_rgb24();
|
| 514 | }
|
| 515 | n_offset = 0;
|
| 516 | }
|
| 517 | |
| 518 | n_this = n_decoded;
|
| 519 | if( n_this > n_size )
|
| 520 | {
|
| 521 | n_this = n_size;
|
| 522 | }
|
| 523 | n_decoded -= n_this;
|
| 524 | |
| 525 | memcpy( (UINT8 *)p_n_psxram + n_address, (UINT8 *)p_n_output + n_offset, n_this * 4 );
|
| 526 | n_offset += n_this * 4;
|
| 527 | n_address += n_this * 4;
|
| 528 | n_size -= n_this;
|
| 529 | }
|
| 530 | |
| 531 | if( (int)n_0_size < 0 )
|
| 532 | {
|
| 533 | mame_printf_debug( "ran out of data %d\n", n_0_size );
|
| 534 | }
|
| 535 | }
|
| 536 | else
|
| 537 | {
|
| 538 | mame_printf_debug( "mdec1_read no conversion :%08x:%08x:\n", n_0_command, n_0_size );
|
| 539 | }
|
| 540 | n_1_status &= ~( 1L << 29 );
|
| 541 | }
|
| 542 | |
| 543 | WRITE32_MEMBER( psxmdec_device::write )
|
| 544 | {
|
| 545 | switch( offset )
|
| 546 | {
|
| 547 | case 0:
|
| 548 | verboselog( machine(), 2, "mdec 0 command %08x\n", data );
|
| 549 | n_0_command = data;
|
| 550 | break;
|
| 551 | case 1:
|
| 552 | verboselog( machine(), 2, "mdec 1 command %08x\n", data );
|
| 553 | n_1_command = data;
|
| 554 | break;
|
| 555 | }
|
| 556 | }
|
| 557 | |
| 558 | READ32_MEMBER( psxmdec_device::read )
|
| 559 | {
|
| 560 | switch( offset )
|
| 561 | {
|
| 562 | case 0:
|
| 563 | verboselog( machine(), 2, "mdec 0 status %08x\n", 0 );
|
| 564 | return 0;
|
| 565 | case 1:
|
| 566 | verboselog( machine(), 2, "mdec 1 status %08x\n", n_1_status );
|
| 567 | return n_1_status;
|
| 568 | }
|
| 569 | return 0;
|
| 570 | }
|