Core Native GBA 0.0.17
create your own game-engine with just lua for nitendo game boy advance console.
Loading...
Searching...
No Matches
geoclip.c
Go to the documentation of this file.
1#include "zeebo.h"
2
3/**
4 * @brief adjusts a rectangle within the screen
5 * @param [in,out] posx
6 * @param [in,out] posy
7 * @param [in,out] width
8 * @param [in,out] height
9 * @return fits on the screen
10 */
11uint8_t geoclip_rect(int32_t *posx, int32_t *posy, int32_t *width, int32_t *height)
12{
13 if (*posx < 0) {
14 *width += *posx;
15 *posx = 0;
16 }
17
18 if (*posy < 0) {
19 *height += *posy;
20 *posy = 0;
21 }
22
23 if ((*posx + *width) > 240) {
24 *width = 240 - *posx;
25 }
26
27 if ((*posy + *height) > 160) {
28 *height = 160 - *posy;
29 }
30
31 if (*width < 0) {
32 *width = 0;
33 }
34
35 if (*height < 0) {
36 *height = 0;
37 }
38
39 return (*height > 0) && (*width > 0);
40}
41
42/**
43 * @todo use cohen, liang-barsky, clipping de retA, cos, ou another method do clip drop line.
44 * @brief adjusts a line within the screen
45 * @param [in,out] x1
46 * @param [in,out] y1
47 * @param [in,out] x2
48 * @param [in,out] y2
49 * @return fits on the screen
50 */
51uint8_t geoclip_line(int32_t *x1, int32_t *y1, int32_t *x2, int32_t *y2)
52{
53 return 1;
54}
uint8_t geoclip_rect(int32_t *posx, int32_t *posy, int32_t *width, int32_t *height)
adjusts a rectangle within the screen
Definition geoclip.c:11
uint8_t geoclip_line(int32_t *x1, int32_t *y1, int32_t *x2, int32_t *y2)
adjusts a line within the screen
Definition geoclip.c:51