diff --git a/src/capture_line_ntsc_8bpp.S b/src/capture_line_ntsc_8bpp.S index 707e45bc..4ade397b 100644 --- a/src/capture_line_ntsc_8bpp.S +++ b/src/capture_line_ntsc_8bpp.S @@ -1320,56 +1320,40 @@ loop_8bppd_auto: .macro CAPTURE_SIX_BITS_16BPP_0 reg // Pixel 0 in GPIO 7.. 2 -> 7.. 0 // Pixel 1 in GPIO 13.. 8 -> 15.. 8 - mov \reg, #0 - tst r8, #(0x01 << PIXEL_BASE) - orrne \reg, #0x04 - tst r8, #(0x02 << PIXEL_BASE) - orrne \reg, #0x02 - tst r8, #(0x04 << PIXEL_BASE) - orrne \reg, #0x01 + and r9, r8, #(0x07 << PIXEL_BASE) tst r8, #(0x10 << PIXEL_BASE) - orrne \reg, #0x08 + orrne r9, r9, #(0x08 << PIXEL_BASE) + mov \reg, r9, lsr #PIXEL_BASE .endm .macro CAPTURE_SIX_BITS_16BPP_1 reg // Pixel 2 in GPIO 7.. 2 -> 23..16 // Pixel 3 in GPIO 13.. 8 -> 31..24 - tst r8, #(0x01 << (PIXEL_BASE + 6)) - orrne \reg, #0x0400 - tst r8, #(0x02 << (PIXEL_BASE + 6)) - orrne \reg, #0x0200 - tst r8, #(0x04 << (PIXEL_BASE + 6)) - orrne \reg, #0x0100 + and r9, r8, #(0x07 << (PIXEL_BASE + 6)) tst r8, #(0x10 << (PIXEL_BASE + 6)) - orrne \reg, #0x0800 + orrne r9, r9, #(0x08 << (PIXEL_BASE + 6)) + orr \reg, \reg, r9, lsl #(8 - (PIXEL_BASE + 6)) .endm .macro CAPTURE_SIX_BITS_16BPP_2 reg // Pixel 0 in GPIO 7.. 2 -> 7.. 0 // Pixel 1 in GPIO 13.. 8 -> 15.. 8 - tst r8, #(0x01 << PIXEL_BASE) - orrne \reg, #0x040000 - tst r8, #(0x02 << PIXEL_BASE) - orrne \reg, #0x020000 - tst r8, #(0x04 << PIXEL_BASE) - orrne \reg, #0x010000 + and r9, r8, #(0x07 << PIXEL_BASE) tst r8, #(0x10 << PIXEL_BASE) - orrne \reg, #0x080000 + orrne r9, r9, #(0x08 << PIXEL_BASE) + orr \reg, \reg, r9, lsl #(16 - PIXEL_BASE) .endm .macro CAPTURE_SIX_BITS_16BPP_3 reg // Pixel 2 in GPIO 7.. 2 -> 23..16 // Pixel 3 in GPIO 13.. 8 -> 31..24 - tst r8, #(0x01 << (PIXEL_BASE + 6)) - orrne \reg, #0x04000000 - tst r8, #(0x02 << (PIXEL_BASE + 6)) - orrne \reg, #0x02000000 - tst r8, #(0x04 << (PIXEL_BASE + 6)) - orrne \reg, #0x01000000 + and r9, r8, #(0x07 << (PIXEL_BASE + 6)) tst r8, #(0x10 << (PIXEL_BASE + 6)) - orrne \reg, #0x08000000 + orrne r9, r9, #(0x08 << (PIXEL_BASE + 6)) + orr \reg, \reg, r9, lsl #(24 - (PIXEL_BASE + 6)) .endm + .global cga_process_artifact .global cga_render_words diff --git a/src/vid_cga_comp.c b/src/vid_cga_comp.c index 7fce5035..43795335 100644 --- a/src/vid_cga_comp.c +++ b/src/vid_cga_comp.c @@ -76,6 +76,13 @@ double max_v; int video_ri, video_rq, video_gi, video_gq, video_bi, video_bq; static int ntsc_type; +unsigned int swap_R_B(int IRGB) { + //r & b are swapped in RGBtoHDMI so rearrange to match + int r_new = (IRGB & 0x04) >> 2; + int ig_new = (IRGB & 0x0a); + int b_new = (IRGB & 0x01) << 2; + return b_new | ig_new | r_new; +} void update_cga16_color() { int x; @@ -155,8 +162,8 @@ void update_cga16_color() { for (x = 0; x < 1024; ++x) { int phase = (x + ntsc_pixel_phase) & 3; - int right = (x >> 2) & 15; - int left = (x >> 6) & 15; + int right = swap_R_B((x >> 2) & 0x0f); + int left = swap_R_B((x >> 6) & 0x0f); int rc = right; int lc = left; //if ((cgamode & 4) != 0) { @@ -176,8 +183,8 @@ void update_cga16_color() { CGA_Composite_Table[x] = (int) (v*mode_contrast + mode_brightness); } - i = CGA_Composite_Table[6*68] - CGA_Composite_Table[6*68 + 2]; - q = CGA_Composite_Table[6*68 + 1] - CGA_Composite_Table[6*68 + 3]; + i = CGA_Composite_Table[3*68] - CGA_Composite_Table[3*68 + 2]; + q = CGA_Composite_Table[3*68 + 1] - CGA_Composite_Table[3*68 + 3]; a = tau*(33 + 90 + hue_offset + mode_hue)/360.0; c = cos(a);