Skip to content

Commit

Permalink
video: write video mode to memory address indicating running mode
Browse files Browse the repository at this point in the history
  • Loading branch information
DacoTaco committed Nov 22, 2024
1 parent 385bb95 commit 62ac8b3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
37 changes: 21 additions & 16 deletions gc/ogc/video_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,29 +114,34 @@ distribution.
*/


#define VI_TVMODE(fmt, mode) ( ((fmt) << 2) + (mode) )
#define VI_TVMODE(fmt, mode) ( ((fmt) << 2) + (mode) )

#define VI_TVMODE_NTSC_INT VI_TVMODE(VI_NTSC, VI_INTERLACE)
#define VI_TVMODE_NTSC_DS VI_TVMODE(VI_NTSC, VI_NON_INTERLACE)
#define VI_TVMODE_NTSC_PROG VI_TVMODE(VI_NTSC, VI_PROGRESSIVE)
#define VI_TVMODE_FMT(viTVMode) (viTVMode >> 2)
#define VI_TVMODE_ISFMT(viTVMode, fmt) (VI_TVMODE_FMT(viTVMode) == fmt)

#define VI_TVMODE_PAL_INT VI_TVMODE(VI_PAL, VI_INTERLACE)
#define VI_TVMODE_PAL_DS VI_TVMODE(VI_PAL, VI_NON_INTERLACE)
#define VI_TVMODE_PAL_PROG VI_TVMODE(VI_PAL, VI_PROGRESSIVE)
#define VI_TVMODE_MODE(viTVMode) (viTVMode & 0b11)
#define VI_TVMODE_ISMODE(viTVMode, mode) (VI_TVMODE_MODE(viTVMode) == mode)

#define VI_TVMODE_EURGB60_INT VI_TVMODE(VI_EURGB60, VI_INTERLACE)
#define VI_TVMODE_EURGB60_DS VI_TVMODE(VI_EURGB60, VI_NON_INTERLACE)
#define VI_TVMODE_EURGB60_PROG VI_TVMODE(VI_EURGB60, VI_PROGRESSIVE)
#define VI_TVMODE_NTSC_INT VI_TVMODE(VI_NTSC, VI_INTERLACE)
#define VI_TVMODE_NTSC_DS VI_TVMODE(VI_NTSC, VI_NON_INTERLACE)
#define VI_TVMODE_NTSC_PROG VI_TVMODE(VI_NTSC, VI_PROGRESSIVE)

#define VI_TVMODE_MPAL_INT VI_TVMODE(VI_MPAL, VI_INTERLACE)
#define VI_TVMODE_MPAL_DS VI_TVMODE(VI_MPAL, VI_NON_INTERLACE)
#define VI_TVMODE_MPAL_PROG VI_TVMODE(VI_MPAL, VI_PROGRESSIVE)
#define VI_TVMODE_PAL_INT VI_TVMODE(VI_PAL, VI_INTERLACE)
#define VI_TVMODE_PAL_DS VI_TVMODE(VI_PAL, VI_NON_INTERLACE)
#define VI_TVMODE_PAL_PROG VI_TVMODE(VI_PAL, VI_PROGRESSIVE)

#define VI_TVMODE_DEBUG_INT VI_TVMODE(VI_DEBUG, VI_INTERLACE)
#define VI_TVMODE_EURGB60_INT VI_TVMODE(VI_EURGB60, VI_INTERLACE)
#define VI_TVMODE_EURGB60_DS VI_TVMODE(VI_EURGB60, VI_NON_INTERLACE)
#define VI_TVMODE_EURGB60_PROG VI_TVMODE(VI_EURGB60, VI_PROGRESSIVE)

#define VI_TVMODE_DEBUG_PAL_INT VI_TVMODE(VI_DEBUG_PAL, VI_INTERLACE)
#define VI_TVMODE_DEBUG_PAL_DS VI_TVMODE(VI_DEBUG_PAL, VI_NON_INTERLACE)
#define VI_TVMODE_MPAL_INT VI_TVMODE(VI_MPAL, VI_INTERLACE)
#define VI_TVMODE_MPAL_DS VI_TVMODE(VI_MPAL, VI_NON_INTERLACE)
#define VI_TVMODE_MPAL_PROG VI_TVMODE(VI_MPAL, VI_PROGRESSIVE)

#define VI_TVMODE_DEBUG_INT VI_TVMODE(VI_DEBUG, VI_INTERLACE)

#define VI_TVMODE_DEBUG_PAL_INT VI_TVMODE(VI_DEBUG_PAL, VI_INTERLACE)
#define VI_TVMODE_DEBUG_PAL_DS VI_TVMODE(VI_DEBUG_PAL, VI_NON_INTERLACE)

/*!
* \addtogroup vi_defines List of defines used for the VIDEO subsystem
Expand Down
5 changes: 5 additions & 0 deletions libogc/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,7 @@ static VIRetraceCallback postRetraceCB = NULL;
static VIPositionCallback positionCB = NULL;

static vu16* const _viReg = (u16*)0xCC002000;
static const u32 _videoMode = 0x800000CC;

extern syssram* __SYS_LockSram(void);
extern u32 __SYS_UnlockSram(u32 write);
Expand Down Expand Up @@ -2691,6 +2692,10 @@ void VIDEO_Configure(GXRModeObj *rmode)
#ifdef _VIDEO_DEBUG
printDebugCalculations();
#endif

// set video mode register
write32(_videoMode, VI_TVMODE_FMT(rmode->viTVMode));

_CPU_ISR_Restore(level);
}

Expand Down

0 comments on commit 62ac8b3

Please sign in to comment.