summaryrefslogtreecommitdiff
path: root/examples/rottest
diff options
context:
space:
mode:
authorXavi Del Campo <xavi.dcr@tutanota.com>2020-01-31 10:32:23 +0100
committerXavi Del Campo <xavi.dcr@tutanota.com>2020-01-31 10:32:23 +0100
commit7c24e9a9b02b04dcaf9507acb94091ea70a2c02d (patch)
treec28d0748652ad4b4222309e46e6cfc82c0906220 /examples/rottest
parenta2b7b6bb1cc2f4a3258b7b2dbc92399d151f864d (diff)
downloadpsxsdk-7c24e9a9b02b04dcaf9507acb94091ea70a2c02d.tar.gz
Imported pristine psxsdk-20190410 from official repo
Diffstat (limited to 'examples/rottest')
-rw-r--r--examples/rottest/Makefile9
-rw-r--r--examples/rottest/image.bmpbin0 -> 32694 bytes
-rw-r--r--examples/rottest/rottest.c104
3 files changed, 113 insertions, 0 deletions
diff --git a/examples/rottest/Makefile b/examples/rottest/Makefile
new file mode 100644
index 0000000..be7c0c0
--- /dev/null
+++ b/examples/rottest/Makefile
@@ -0,0 +1,9 @@
+PROJNAME = rottest
+
+include ../project.mk
+
+$(PROJNAME)_extra:
+ mkdir -p cd_root
+ bmp2tim image.bmp cd_root/image.tim 16 -org=320,0
+
+$(PROJNAME)_clean_extra:
diff --git a/examples/rottest/image.bmp b/examples/rottest/image.bmp
new file mode 100644
index 0000000..e08b3af
--- /dev/null
+++ b/examples/rottest/image.bmp
Binary files differ
diff --git a/examples/rottest/rottest.c b/examples/rottest/rottest.c
new file mode 100644
index 0000000..4d4f341
--- /dev/null
+++ b/examples/rottest/rottest.c
@@ -0,0 +1,104 @@
+#include <psx.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+unsigned int prim_list[0x4000];
+unsigned char filebuf[0x40000];
+
+volatile int display_is_old = 0;
+
+void prog_vblank_handler()
+{
+ display_is_old = 1;
+}
+
+int main()
+{
+ FILE *f;
+ GsSprite my_sprite;
+ GsImage my_image;
+ int y = 0;
+ int ro = 0;
+ int sc_x = SCALE_ONE;
+ int sc_y = SCALE_ONE;
+ unsigned short padbuf;
+
+ PSX_Init();
+
+ GsInit();
+ GsSetList(prim_list);
+ GsSetVideoMode(320, 240, EXAMPLES_VMODE);
+
+ GsClearMem();
+ GsSetDrawEnvSimple(0, 256, 320, 240);
+ GsSetDispEnvSimple(0, 0);
+
+ f = fopen("cdrom:\\IMAGE.TIM;1", "rb");
+ fseek(f, 0, SEEK_END);
+ y = ftell(f);
+ fseek(f, 0, SEEK_SET);
+ fread(filebuf, sizeof(char), y, f);
+ fclose(f);
+
+ GsImageFromTim(&my_image, filebuf);
+ GsSpriteFromImage(&my_sprite, &my_image, 1);
+
+ SetVBlankHandler(prog_vblank_handler);
+
+ GsLoadFont(768, 0, 768, 128);
+ while(GsIsWorking());
+
+ while(1)
+ {
+ if(display_is_old)
+ {
+ PSX_ReadPad(&padbuf, NULL);
+ if(padbuf & PAD_LEFT)
+ {
+ ro--;
+ if(ro < 0) ro = 359;
+ }
+
+ if(padbuf & PAD_RIGHT)
+ {
+ ro++;
+ if(ro>=360) ro = 0;
+ }
+
+ if(padbuf & PAD_UP)
+ sc_x+=128;
+
+ if(padbuf & PAD_DOWN)
+ sc_x-=128;
+
+ if(padbuf & PAD_CROSS)
+ sc_y-=128;
+
+ if(padbuf & PAD_CIRCLE)
+ sc_y+=128;
+
+ GsSortCls(0, 0, 0);
+
+ my_sprite.x = 100;
+ my_sprite.y = 100;
+ my_sprite.r = my_sprite.g = my_sprite.b = NORMAL_LUMINOSITY;
+ my_sprite.rotate = ROTATE_ONE*ro;
+ my_sprite.scalex = sc_x;
+ my_sprite.scaley = sc_y;
+ my_sprite.mx = (my_sprite.w/2) * (my_sprite.scalex / 4096);
+ my_sprite.my = (my_sprite.h/2) * (my_sprite.scaley / 4096);
+ GsSortSprite(&my_sprite);
+
+ GsPrintFont(0, 0, "ro=%d\nsc_x=%d\nsc_y=%d", ro, sc_x, sc_y);
+
+ GsDrawList();
+ while(GsIsWorking());
+
+ y=!y;
+ GsSetDrawEnvSimple(0, y?0:256, 320, 240);
+ GsSetDispEnvSimple(0, y?256:0);
+ display_is_old = 0;
+ }
+ }
+}