Skip to content

Commit b71c26b

Browse files
committed
made <graphy.h> consistent with <graphx.h>
1 parent 3a2a8c8 commit b71c26b

1 file changed

Lines changed: 40 additions & 71 deletions

File tree

src/graphy/graphy.h

Lines changed: 40 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -612,23 +612,6 @@ gfy_ConvertToNewRLETSprite(sprite_in, malloc)
612612
2 + gfy_GetZX7SpriteWidth(_Sprite) * gfy_GetZX7SpriteHeight(_Sprite); \
613613
})
614614

615-
#if defined(__cplusplus) && __cplusplus >= 201103L
616-
# define GRAPHY_NOEXCEPT noexcept
617-
#else /* __cplusplus */
618-
# define GRAPHY_NOEXCEPT __attribute__((__nothrow__, __leaf__))
619-
#endif /* __cplusplus */
620-
#define GRAPHY_PURE GRAPHY_NOEXCEPT __attribute__((__pure__))
621-
#define GRAPHY_CONST GRAPHY_NOEXCEPT __attribute__((__const__))
622-
#define GRAPHY_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
623-
#define GRAPHY_NONNULL_IF_NONZERO(...) __attribute__((__nonnull_if_nonzero__(__VA_ARGS__)))
624-
#define GRAPHY_RETURNS_NONNULL __attribute__((__returns_nonnull__))
625-
#define GRAPHY_STRING_ARG(...) __attribute__((__null_terminated_string_arg__(__VA_ARGS__), __nonnull__(__VA_ARGS__)))
626-
#if 0
627-
# define GRAPHY_ALLOCATOR __attribute__((__malloc__))
628-
#else
629-
# define GRAPHY_ALLOCATOR
630-
#endif
631-
632615
/**
633616
* Initializes the `graphy` library context.
634617
*
@@ -669,7 +652,7 @@ gfy_sprite_t *gfy_AllocSprite(
669652
uint8_t width,
670653
uint8_t height,
671654
void *(*malloc_routine)(size_t)
672-
) GRAPHY_ALLOCATOR GRAPHY_NONNULL(3);
655+
) __attribute__((__nonnull__(3)));
673656

674657
/**
675658
* Draws a tilemap.
@@ -683,7 +666,7 @@ void gfy_Tilemap(
683666
const gfy_tilemap_t *tilemap,
684667
uint24_t x_offset,
685668
uint24_t y_offset
686-
) GRAPHY_NONNULL(1);
669+
);
687670

688671
/**
689672
* Draws an unclipped tilemap.
@@ -697,7 +680,7 @@ void gfy_Tilemap_NoClip(
697680
const gfy_tilemap_t *tilemap,
698681
uint24_t x_offset,
699682
uint24_t y_offset
700-
) GRAPHY_NONNULL(1);
683+
);
701684

702685
/**
703686
* Draws a transparent tilemap.
@@ -711,7 +694,7 @@ void gfy_TransparentTilemap(
711694
const gfy_tilemap_t *tilemap,
712695
uint24_t x_offset,
713696
uint24_t y_offset
714-
) GRAPHY_NONNULL(1);
697+
);
715698

716699
/**
717700
* Draws an unclipped transparent tilemap.
@@ -725,7 +708,7 @@ void gfy_TransparentTilemap_NoClip(
725708
const gfy_tilemap_t *tilemap,
726709
uint24_t x_offset,
727710
uint24_t y_offset
728-
) GRAPHY_NONNULL(1);
711+
);
729712

730713
/**
731714
* Gets a pointer to a particular sprite tileset index.
@@ -739,20 +722,7 @@ uint8_t *gfy_TilePtr(
739722
const gfy_tilemap_t *tilemap,
740723
uint24_t x_offset,
741724
uint24_t y_offset
742-
) GRAPHY_PURE GRAPHY_NONNULL(1) GRAPHY_RETURNS_NONNULL;
743-
744-
static inline __attribute__((__always_inline__))
745-
uint8_t *inline_gfy_TilePtr(const gfy_tilemap_t *tilemap, uint24_t x_offset, uint24_t y_offset) {
746-
if (__builtin_constant_p(tilemap) && __builtin_constant_p(x_offset) && __builtin_constant_p(y_offset)) {
747-
uint24_t map_row = x_offset / tilemap->tile_width;
748-
uint24_t map_col = y_offset / tilemap->tile_height;
749-
uint24_t map_index = map_row + (map_col * tilemap->width);
750-
return &(tilemap->map[map_index]);
751-
}
752-
return gfy_TilePtr(tilemap, x_offset, y_offset);
753-
}
754-
755-
#define gfy_TilePtr(tilemap, x_offset, y_offset) inline_gfy_TilePtr(tilemap, x_offset, y_offset)
725+
) __attribute__((__pure__));
756726

757727
/**
758728
* Gets a pointer to a particular sprite tileset index.
@@ -803,7 +773,7 @@ void gfy_SetPalette(
803773
const void *palette,
804774
uint24_t size,
805775
uint8_t offset
806-
) GRAPHY_NONNULL(1);
776+
);
807777

808778
/**
809779
* Fills the screen with a given palette index.
@@ -847,13 +817,12 @@ uint8_t gfy_GetPixel(uint24_t x, uint8_t y);
847817
* @param[in] y1 Second Y coordinate.
848818
*/
849819
void gfy_Line(
850-
int24_t x0,
851-
int24_t y0,
852-
int24_t x1,
853-
int24_t y1
820+
int x0,
821+
int y0,
822+
int x1,
823+
int y1
854824
);
855825

856-
857826
/**
858827
* Draws an unclipped line.
859828
*
@@ -878,9 +847,9 @@ void gfy_Line_NoClip(
878847
* @param[in] length Length of line.
879848
*/
880849
void gfy_HorizLine(
881-
int24_t x,
882-
int24_t y,
883-
int24_t length
850+
int x,
851+
int y,
852+
int length
884853
);
885854

886855
/**
@@ -906,9 +875,9 @@ void gfy_HorizLine_NoClip(
906875
* @param[in] length Length of line
907876
*/
908877
void gfy_VertLine(
909-
int24_t x,
910-
int24_t y,
911-
int24_t length
878+
int x,
879+
int y,
880+
int length
912881
);
913882

914883
/**
@@ -933,11 +902,11 @@ void gfy_VertLine_NoClip(
933902
* @param[in] width Width of rectangle.
934903
* @param[in] height Height of rectangle.
935904
*/
936-
void gfy_Rectangle(
937-
int24_t x,
938-
int24_t y,
939-
int24_t width,
940-
int24_t height
905+
void gfy_Rectangle(
906+
int x,
907+
int y,
908+
int width,
909+
int height
941910
);
942911

943912
/**
@@ -964,10 +933,10 @@ void gfy_Rectangle_NoClip(
964933
* @param[in] height Height of rectangle.
965934
*/
966935
void gfy_FillRectangle(
967-
int24_t x,
968-
int24_t y,
969-
int24_t width,
970-
int24_t height
936+
int x,
937+
int y,
938+
int width,
939+
int height
971940
);
972941

973942
/**
@@ -993,8 +962,8 @@ void gfy_FillRectangle_NoClip(
993962
* @param[in] radius The radius of the circle.
994963
*/
995964
void gfy_Circle(
996-
int24_t x,
997-
int24_t y,
965+
int x,
966+
int y,
998967
uint24_t radius
999968
);
1000969

@@ -1006,8 +975,8 @@ void gfy_Circle(
1006975
* @param[in] radius The radius of the circle.
1007976
*/
1008977
void gfy_FillCircle(
1009-
int24_t x,
1010-
int24_t y,
978+
int x,
979+
int y,
1011980
uint24_t radius
1012981
);
1013982

@@ -1079,7 +1048,7 @@ void gfy_Ellipse(int24_t x, int24_t y, uint24_t a, uint24_t b);
10791048
* @param[in] points Pointer to x and y pairs.
10801049
* @param[in] num_points Number of x and y pairs.
10811050
*/
1082-
void gfy_Polygon(const int24_t *points, size_t num_points) GRAPHY_NONNULL(1);
1051+
void gfy_Polygon(const int *points, size_t num_points);
10831052

10841053
/**
10851054
* Draws an unclipped polygon outline
@@ -1097,7 +1066,7 @@ void gfy_Polygon(const int24_t *points, size_t num_points) GRAPHY_NONNULL(1);
10971066
* @param[in] points Pointer to x and y pairs
10981067
* @param[in] num_points Number of x and y pairs
10991068
*/
1100-
void gfy_Polygon_NoClip(const int24_t *points, size_t num_points) GRAPHY_NONNULL(1);
1069+
void gfy_Polygon_NoClip(const int *points, size_t num_points);
11011070

11021071
/**
11031072
* Draws a clipped filled triangle.
@@ -1129,12 +1098,12 @@ void gfy_FillTriangle(
11291098
* @param[in] y2 Third Y coordinate.
11301099
*/
11311100
void gfy_FillTriangle_NoClip(
1132-
int24_t x0,
1133-
int24_t y0,
1134-
int24_t x1,
1135-
int24_t y1,
1136-
int24_t x2,
1137-
int24_t y2
1101+
int x0,
1102+
int y0,
1103+
int x1,
1104+
int y1,
1105+
int x2,
1106+
int y2
11381107
);
11391108

11401109
/**
@@ -1248,9 +1217,9 @@ void gfy_BlitColumns(gfy_location_t src, uint24_t x_loc, uint24_t num_columns);
12481217

12491218
/**
12501219
* Copies a rectangular region between graphics buffers or to the same graphics buffer.
1251-
* The behavior is undefined when the rectangles overlap.
1220+
* Overlapping rectangles are supported, using memmove-like copy semantics.
12521221
* No clipping is performed as it is a copy not a draw.
1253-
* @param[in] src Graphics buffer to copy from.i
1222+
* @param[in] src Graphics buffer to copy from.
12541223
* @param[in] dst Graphics buffer to copy to.
12551224
* @param[in] src_x X coordinate on src.
12561225
* @param[in] src_y Y coordinate on src.

0 commit comments

Comments
 (0)