diff options
| author | John Wilbert M. Villamor <lameguy64@gmail.com> | 2020-01-06 09:39:20 +0800 |
|---|---|---|
| committer | John Wilbert M. Villamor <lameguy64@gmail.com> | 2020-01-06 09:39:20 +0800 |
| commit | c98ad0e7dbc48c928aaea0f78214c7ed6556417d (patch) | |
| tree | bcbafb8547eceb867f342bfe504377e13a5533a9 /examples/hello/main.c | |
| parent | 87ded2ccb9db9bf3b2ed40a0b02b663179d5868f (diff) | |
| download | psn00bsdk-c98ad0e7dbc48c928aaea0f78214c7ed6556417d.tar.gz | |
Some minor updates, added CD-ROM library documentation
Diffstat (limited to 'examples/hello/main.c')
| -rw-r--r-- | examples/hello/main.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/examples/hello/main.c b/examples/hello/main.c new file mode 100644 index 0000000..6cd03f9 --- /dev/null +++ b/examples/hello/main.c @@ -0,0 +1,85 @@ +#include <stdio.h> +#include <psxgpu.h> +#include <psxgte.h> +#include <psxetc.h> + +#define PAL + +#ifdef PAL + +#define SCREEN_XRES 320 +#define SCREEN_YRES 256 + +#else + +#define SCREEN_XRES 320 +#define SCREEN_YRES 240 + +#endif + +typedef struct DB +{ + DISPENV disp; + DRAWENV draw; +} DB; + +DB db[2]; +int db_active; + +void init(void) +{ + ResetGraph(0); + + SetDefDispEnv(&db[0].disp, 0, 0, SCREEN_XRES, SCREEN_YRES); + SetDefDispEnv(&db[1].disp, 0, SCREEN_YRES, SCREEN_XRES, SCREEN_YRES); + + SetDefDrawEnv(&db[0].draw, 0, SCREEN_YRES, SCREEN_XRES, SCREEN_YRES); + SetDefDrawEnv(&db[1].draw, 0, 0, SCREEN_XRES, SCREEN_YRES); + + db[0].draw.isbg = 1; + setRGB0(&db[0].draw, 63, 0, 127); + db[1].draw.isbg = 1; + setRGB0(&db[1].draw, 63, 0, 127); + +#ifdef PAL + SetVideoMode(MODE_PAL); + db[0].disp.screen.y = 18; + db[1].disp.screen.y = 18; + db[0].disp.screen.h = 256; + db[1].disp.screen.h = 256; +#endif + + PutDispEnv(&db[0].disp); + PutDrawEnv(&db[0].draw); + db_active = 0; + + FntLoad(960, 0); + FntOpen(0, 8, SCREEN_XRES, SCREEN_YRES-16, 0, 100); +} + +void display(void) +{ + FntFlush(-1); + DrawSync(0); + VSync(0); + + db_active = !db_active; + PutDispEnv(&db[db_active].disp); + PutDrawEnv(&db[db_active].draw); + SetDispMask(1); +} + +int main(int argc, const char *argv[]) +{ + int count = 0; + + init(); + + while(1) + { + FntPrint(-1, "HELLO WORLD\n"); + FntPrint(-1, "COUNTER=%d\n", count); + display(); + count++; + } +}
\ No newline at end of file |
