ソースを参照

Fix struct declarations

Streetwalrus Einstein 10 年 前
コミット
2fa901aa58
共有5 個のファイルを変更した16 個の追加14 個の削除を含む
  1. 1 1
      src/graphics.c
  2. 4 3
      src/graphics.h
  3. 1 1
      src/main.c
  4. 4 4
      src/map.c
  5. 6 5
      src/map.h

+ 1 - 1
src/graphics.c

@@ -91,7 +91,7 @@ void draw_pixel(unsigned x, unsigned y, unsigned short color)
 		buffer_back[x + (y * 320)] = color;
 }
 
-void draw_sprite_sheet(const unsigned short *sheet, int x, int y, const Rect *window)
+void draw_sprite_sheet(const unsigned short *sheet, int x, int y, const Rect_t *window)
 {
 	unsigned short color;
 	int w = window->w + x;

+ 4 - 3
src/graphics.h

@@ -1,10 +1,11 @@
 #ifndef SRC_GRAPHICS_H
 #define SRC_GRAPHICS_H
 
-typedef struct
+typedef struct Rect Rect_t;
+struct Rect
 {
 	int x, y, w, h;
-} Rect;
+};
 
 /*
  * Buffer management
@@ -29,7 +30,7 @@ void lcd_vsync();
  */
 
 void draw_pixel(unsigned x, unsigned y, unsigned short color);
-void draw_sprite_sheet(const unsigned short *sheet, int x, int y, const Rect *window);
+void draw_sprite_sheet(const unsigned short *sheet, int x, int y, const Rect_t *window);
 
 
 /*

+ 1 - 1
src/main.c

@@ -12,7 +12,7 @@ int main(int argc, char *argv[])
 	buffer_allocate();
 	timer_init(0);
 
-	Map map;
+	Map_t map;
 	map.w = 15;
 	map.h = 21;
 

+ 4 - 4
src/map.c

@@ -7,7 +7,7 @@
 static void map_walk_speed_load(unsigned time);
 static unsigned map_walk_speed_read(unsigned time, unsigned div);
 
-void map_draw(unsigned x, unsigned y, const Map map)
+void map_draw(unsigned x, unsigned y, const Map_t map)
 {
 	x += 20;
 	y += 12;
@@ -16,7 +16,7 @@ void map_draw(unsigned x, unsigned y, const Map map)
 	unsigned offset_y = y % 24 * -1;
 
 	unsigned i, j;
-	Rect sprite;
+	Rect_t sprite;
 	sprite.y = 0;
 	sprite.w = 24;
 	sprite.h = 24;
@@ -29,7 +29,7 @@ void map_draw(unsigned x, unsigned y, const Map map)
 	}
 }
 
-unsigned map_collide(unsigned x, unsigned y, const Map map)
+unsigned map_collide(unsigned x, unsigned y, const Map_t map)
 {
 	(void) x;
 	(void) y;
@@ -48,7 +48,7 @@ static unsigned map_walk_speed_read(unsigned time, unsigned div)
 	return (time - timer_read(0)) / div;
 }
 
-void map_walk(unsigned x, unsigned y, Map map)
+void map_walk(unsigned x, unsigned y, Map_t map)
 {
 	unsigned i, walk_time, walk_div;
 

+ 6 - 5
src/map.h

@@ -1,16 +1,17 @@
 #ifndef SRC_MAP_H
 #define SRC_MAP_H
 
-typedef struct
+typedef struct Map Map_t;
+struct Map
 {
 	unsigned w;
 	unsigned h;
 	unsigned *layer0;
 	unsigned *layer1;
-} Map;
+};
 
-void map_draw(unsigned x, unsigned y, const Map map);
-unsigned map_collide(unsigned x, unsigned y, const Map map);
-void map_walk(unsigned x, unsigned y, Map map);
+void map_draw(unsigned x, unsigned y, const Map_t map);
+unsigned map_collide(unsigned x, unsigned y, const Map_t map);
+void map_walk(unsigned x, unsigned y, Map_t map);
 
 #endif