Skip to content

Commit

Permalink
Support video inversion in 9/12 bit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
IanSB committed Mar 30, 2022
1 parent 00a34a0 commit a1dbf3b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/defs.h
Expand Up @@ -67,13 +67,16 @@
#define BIT_INTERLACED_VIDEO 0x80 // bit 7, if set then interlaced video detected or teletext enabled
#define BIT_CLEAR 0x100 // bit 8, indicates the frame buffer should be cleared
#define BITDUP_ENABLE_FFOSD 0x100 // bit 8, indicates FFOSD is enabled
#define BIT_VSYNC 0x200 // bit 9, indicates the red vsync indicator should be displayed
#define BIT_VSYNC 0x200 // bit 9, indicates the red v sync indicator should be displayed
#define BIT_VSYNC_MARKER 0x400 // bit 10, indicates current line should be replaced by the red vsync indicator
#define BIT_DEBUG 0x800 // bit 11, indicates the debug grid should be displayed

#define OFFSET_LAST_BUFFER 12 // bit 12-13 LAST_BUFFER
#define MASK_LAST_BUFFER (3 << OFFSET_LAST_BUFFER)

#define BITDUP_RGB_INVERT 0x1000 //bit 12, indicates 9/12 bit RGB should be inverted
#define BITDUP_Y_INVERT 0x2000 //bit 13, indicates 9/12 bit G should be inverted

#define OFFSET_CURR_BUFFER 14 // bit 14-15 CURR_BUFFER
#define MASK_CURR_BUFFER (3 << OFFSET_CURR_BUFFER)

Expand Down Expand Up @@ -344,6 +347,8 @@ typedef struct {
#define NTSC_LAST_IIGS_SHIFT 8
#define NTSC_FFOSD_ENABLE 0x200 //not actually ntsc but uses a spare bit
#define NTSC_DONE_FIRST 0x400
#define NTSC_RGB_INVERT 0x800


#define BBC_VERSION 0x79
#define RGB_VERSION 0x94
Expand Down
3 changes: 3 additions & 0 deletions src/geometry.c
Expand Up @@ -555,6 +555,9 @@ void geometry_get_fb_params(capture_info_t *capinfo) {
if (get_invert() == INVERT_Y) {
capinfo->ntscphase |= NTSC_Y_INVERT;
}
if (get_invert() == INVERT_RGB) {
capinfo->ntscphase |= NTSC_RGB_INVERT;
}
if (get_hdmi_standby()) {
capinfo->ntscphase |= NTSC_HDMI_BLANK_ENABLE;
}
Expand Down
11 changes: 11 additions & 0 deletions src/macros.S
Expand Up @@ -1279,6 +1279,17 @@ skip_psync_loop_simple_fast_loop\@:
tst r3, #BIT_VSYNC_MARKER
eorne r11, r11, #0x0f000000
eorne r11, r11, #0x00000f00

tst r3, #BITDUP_RGB_INVERT
eorne r11, r11, #0x0f000000
eorne r11, r11, #0x00000f00
eorne r11, r11, #0x00ff0000
eorne r11, r11, #0x000000ff

tst r3, #BITDUP_Y_INVERT
eorne r11, r11, #0x00f00000
eorne r11, r11, #0x000000f0

tst r3, #BIT_NO_SCANLINES | BIT_INTERLACED_VIDEO
ldreq r12, =param_intensity
ldreq r12, [r12]
Expand Down
6 changes: 6 additions & 0 deletions src/rgb_to_fb.S
Expand Up @@ -812,11 +812,17 @@ mod10:
push {r3}

bic r3, #BITDUP_ENABLE_GREY_DETECT | BITDUP_ENABLE_FFOSD
bic r3, #BITDUP_RGB_INVERT | BITDUP_Y_INVERT
ldr r0, ntsc_status
tst r0, #NTSC_HDMI_BLANK_ENABLE
orrne r3, r3, #BITDUP_ENABLE_GREY_DETECT
tst r0, #NTSC_FFOSD_ENABLE
orrne r3, r3, #BITDUP_ENABLE_FFOSD
tst r0, #NTSC_RGB_INVERT
orrne r3, r3, #BITDUP_RGB_INVERT
tst r0, #NTSC_Y_INVERT
orrne r3, r3, #BITDUP_Y_INVERT

bic r3, #BITDUP_IIGS_DETECT
ldr r0, param_autoswitch
cmp r0, #AUTOSWITCH_IIGS
Expand Down

0 comments on commit a1dbf3b

Please sign in to comment.