started working on interrupts
[psx_test1] / src / main.c
1 #include "intr.h"
2 #include "gpu.h"
3 #include "gte.h"
4 #include "psxregs.h"
5 #include "sintab.h"
6
7 static struct gpu_gvert triangle[] = {{0xff0000}, {0x00ff00}, {0x0000ff}};
8
9 static struct gte_svector svtri[] = {
10         {-0x1000, -0x800}, {0, 0x1000}, {0x1000, -0x800}
11 };
12
13 int dbg;
14
15 int main(void)
16 {
17         int i;
18         unsigned int frame = 0;
19         int16_t rotmat[9] = {0x1000, 0, 0, 0, 0x1000, 0, 0, 0, 0x1000};
20         int trans[3] = {160, 120, 0};
21         int resv[3];
22         int yoffs = 0;
23
24         intr_init();
25
26         gte_init();
27
28         gpu_reset();
29         gpu_setmode(320, 264, 15, 50);
30         gpu_display(1);
31
32         REG_GP0 = GPCMD(GP0_TEXPG) | TEXPG_DITHER;
33
34         for(;;) {
35                 rotmat[0] = rotmat[4] = COS(frame);
36                 rotmat[1] = SIN(frame);
37                 rotmat[3] = -SIN(frame);
38
39                 gte_loadrot(rotmat);
40                 //gte_loadtrans(trans);
41                 for(i=0; i<3; i++) {
42                         gte_loadsvec0(svtri + i);
43                         gte_cmd_rot();
44                         gte_getvec(resv);
45
46                         triangle[i].x = (resv[0] >> 6);
47                         triangle[i].y = (resv[1] >> 6);
48                 }
49
50                 /* use previous frame yoffs as display area */
51                 gpu_dispstart(0, yoffs);
52
53                 /* set yoffs to the new back buffer */
54                 yoffs = (frame++ & 1) ? 0 : 264;
55
56                 gpu_cliprect(0, yoffs, 320, 264 + yoffs);
57                 gpu_origin(160, 130 + yoffs);
58
59                 gpu_fillrect(0, yoffs, 320, 264, 0x202020);
60
61                 gpu_draw_gouraud(GP0_GTRI, triangle, 3);
62
63                 for(i=0; i<8192; i++) {
64                         asm volatile("nop; nop; nop; nop");
65                 }
66         }
67         return 0;
68 }