Skip to content

Instantly share code, notes, and snippets.

@F0bes
Created May 29, 2022 01:40
Show Gist options
  • Save F0bes/fc973a1f71de0c6b4f861b568e47d065 to your computer and use it in GitHub Desktop.
Save F0bes/fc973a1f71de0c6b4f861b568e47d065 to your computer and use it in GitHub Desktop.
Test if FIELD changes when the video mode is set to progressive
#include <kernel.h>
#include <stdio.h>
#include <graph.h>
#include <draw.h>
#include <gs_psm.h>
#define INTC_STAT (*(volatile u32 *)0x1000F000)
#define GSCSR (*(volatile u64 *)0x12001000)
int main(void)
{
framebuffer_t fb;
fb.address = graph_vram_allocate(640, 448, GS_PSM_24, GRAPH_ALIGN_PAGE);
fb.psm = GS_PSM_24;
fb.width = 640;
fb.height = 480;
graph_initialize(fb.address, fb.width, fb.height, fb.psm, 0, 0);
graph_set_mode(GRAPH_MODE_NONINTERLACED, GRAPH_MODE_NTSC, 0, 0);
INTC_STAT = 0xC;
while (!(INTC_STAT & 0x8))
{
}
GSCSR = 0x8;
for(int i = 0; i < 300; i++)
{
INTC_STAT = 0xC;
u32 start_odd = GSCSR & 0x2000;
while (!(INTC_STAT & 0x8))
{
}
u32 end_odd = GSCSR & 0x2000;
printf("FIELD Prev %d Field New %d\n", start_odd, end_odd);
}
SleepThread();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment