serial debugging fail
[retrocrawl] / src / game.c
index 97c1895..8afa769 100644 (file)
@@ -1,7 +1,10 @@
+#include <stdio.h>
 #include <string.h>
 #include "game.h"
 #include "gfx.h"
+#include "copper.h"
 #include "data.h"
+#include "sprite.h"
 
 #include "hwregs.h"    /* XXX */
 
 
 void draw_tile(int tid, int x, int y, int light);
 
+static uint16_t *sprdata[NUM_HWSPRITES];
+static uint16_t *sprdata2[NUM_HWSPRITES];
+
+/* hardcoded test sprite */
+static struct sprite test_sprite;
+static struct sprite test_sprite2;
 
 int game_init(void)
 {
+       int i;
+
+       printf("hello world\n");
+
        REG_COLOR0 = 0x221;
        REG_COLOR1 = 0x222;
        REG_COLOR2 = 0x332;
@@ -22,6 +35,31 @@ int game_init(void)
        REG_COLOR6 = 0x654;
        REG_COLOR7 = 0x765;
 
+       for(i=0; i<16; i++) {
+               REG_COLOR_PTR[i + 16] = sprpal[i];
+       }
+
+       sprdata[0] = sprdata2[0] = spr0a;
+       sprdata[1] = sprdata2[1] = spr0b;
+       sprdata[2] = sprdata2[2] = spr1a;
+       sprdata[3] = sprdata2[3] = spr1b;
+       sprdata[4] = sprdata2[4] = spr2a;
+       sprdata[5] = sprdata2[5] = spr2b;
+
+       test_sprite.width = test_sprite.height = 48;
+       test_sprite.origx = 24;
+       test_sprite.origy = 24;
+       test_sprite.img = test_sprite.mask = 0;
+       test_sprite.hwslices = 3;
+       for(i=0; i<8; i++) {
+               test_sprite.hwspr[i] = i < 6 ? sprdata[i] : 0;
+       }
+
+       test_sprite2 = test_sprite;
+       for(i=0; i<8; i++) {
+               test_sprite2.hwspr[i] = i < 6 ? sprdata2[i] : 0;
+       }
+
        return 0;
 }
 
@@ -42,6 +80,11 @@ void game_draw(void)
                }
                yoffs += TILE_H / 2;
        }
+
+       begin_sprites();
+       draw_sprite(&test_sprite, 160, 80);
+       draw_sprite(&test_sprite2, 160, 160);
+       end_sprites();
 }