void atari_ntsc_init( atari_ntsc_t* ntsc, atari_ntsc_setup_t const* setup, atari_ntsc_in_t const* palette ) { int entry; init_t impl; if ( !setup ) setup = &atari_ntsc_composite; init( &impl, setup ); // Palette stores R/G/B data for 'atari_ntsc_palette_size' entries for ( entry = 0; entry < atari_ntsc_palette_size; entry++ ) { float r = impl.to_float [*palette++]; float g = impl.to_float [*palette++]; float b = impl.to_float [*palette++]; float y, i, q = RGB_TO_YIQ( r, g, b, y, i ); // Generate kernel int ir, ig, ib = YIQ_TO_RGB( y, i, q, impl.to_rgb, int, ir, ig ); atari_ntsc_rgb_t rgb = PACK_RGB( ir, ig, ib ); if ( ntsc ) { atari_ntsc_rgb_t* kernel = ntsc->table [entry]; gen_kernel( &impl, y, i, q, kernel ); correct_errors( rgb, kernel ); } } }
void atari_ntsc_init( atari_ntsc_t* ntsc, atari_ntsc_setup_t const* setup ) { /* Atari change: no alternating burst phases - remove merge_fields variable. */ int entry; init_t impl; /* Atari change: NES palette generation and reading removed. Atari palette generation is located in colours_ntsc.c, and colours are read from setup->yiq_palette. */ if ( !setup ) setup = &atari_ntsc_composite; init( &impl, setup ); /* Atari change: no alternating burst phases - remove code for merge_fields. */ for ( entry = 0; entry < atari_ntsc_palette_size; entry++ ) { /* Atari change: Instead of palette generation, load colours from setup->yiq_palette. */ double y; double i; double q; { double *yiq_ptr = setup->yiq_palette + 3 * entry; y = *yiq_ptr++; i = *yiq_ptr++; q = *yiq_ptr++; } i *= rgb_unit; q *= rgb_unit; y *= rgb_unit; y += rgb_offset; /* Generate kernel */ { int r, g, b = YIQ_TO_RGB( y, i, q, impl.to_rgb, int, r, g ); /* blue tends to overflow, so clamp it */ atari_ntsc_rgb_t rgb = PACK_RGB( r, g, (b < 0x3E0 ? b: 0x3E0) ); if ( setup->palette_out ) RGB_PALETTE_OUT( rgb, &setup->palette_out [entry * 3] ); if ( ntsc ) { atari_ntsc_rgb_t* kernel = ntsc->table [entry]; gen_kernel( &impl, y, i, q, kernel ); /* Atari change: no alternating burst phases - remove code for merge_fields. */ correct_errors( rgb, kernel ); } } } }