1919#define FRATA_Y_INITIAL 2
2020#define FRATA_X 16
2121
22- #define LEFT_ARROW 0x2190
23- #define UP_ARROW 0x2191
24- #define RIGHT_ARROW 0x2192
25- #define DOWN_ARROW 0x2193
26-
27- #define COPYRIGHT 0x00A9
28- #define DIAMOND 0x2666
29-
30- #define AC_ACUTE 0x00C1
31- #define AC_TILDE 0x00C3
32- #define C_CEDILLA 0x00C7
33- #define EC_ACUTE 0x00C9
34- #define OC_TILDE 0x00D5
35- #define AS_GRAVE 0x00E0
36- #define AS_ACUTE 0x00E1
37- #define AS_TILDE 0x00E3
38- #define S_CEDILLA 0x00E7
39- #define ES_ACUTE 0x00E9
40- #define ES_CIRCF 0x00EA
41- #define IS_ACUTE 0x00ED
42- #define OS_ACUTE 0x00F3
43- #define OS_TILDE 0x00F5
44- #define US_ACUTE 0x00FA
45-
46- typedef int_fast32_t i32 ;
47- typedef int_fast16_t i16 ;
48-
49- typedef uint_fast64_t u64 ;
50- typedef uint_fast32_t u32 ;
51- typedef uint_fast16_t u16 ;
52- typedef uint_fast8_t u8 ;
22+ #define LEFT_ARROW 0x2190
23+ #define UP_ARROW 0x2191
24+ #define RIGHT_ARROW 0x2192
25+ #define DOWN_ARROW 0x2193
26+
27+ #define COPYRIGHT 0x00A9
28+ #define DIAMOND 0x2666
29+
30+ #define AC_ACUTE 0x00C1
31+ #define AC_TILDE 0x00C3
32+ #define C_CEDILLA 0x00C7
33+ #define EC_ACUTE 0x00C9
34+ #define OC_TILDE 0x00D5
35+ #define AS_GRAVE 0x00E0
36+ #define AS_ACUTE 0x00E1
37+ #define AS_TILDE 0x00E3
38+ #define S_CEDILLA 0x00E7
39+ #define ES_ACUTE 0x00E9
40+ #define ES_CIRCF 0x00EA
41+ #define IS_ACUTE 0x00ED
42+ #define OS_ACUTE 0x00F3
43+ #define OS_TILDE 0x00F5
44+ #define US_ACUTE 0x00FA
45+
46+ #define i32 int_fast32_t
47+ #define i16 int_fast16_t
48+
49+ #define u64 uint_fast64_t
50+ #define u32 uint_fast32_t
51+ #define u16 uint_fast16_t
52+ #define u8 uint_fast8_t
53+
54+ #define ru16 register uint_fast16_t
55+ #define ru8 register uint_fast8_t
56+ #define cu16 const uint_fast16_t
57+ #define cu8 const uint_fast8_t
58+
59+ #define ci32 const int_fast32_t
60+ #define ci16 const int_fast16_t
5361
5462enum Scr {
5563 INITIAL = 0 ,
@@ -125,7 +133,7 @@ typedef struct GameData {
125133
126134void InitScreen (void );
127135void Quit (GameData * );
128- void Error (GameData * , i32 , const char * Func );
136+ void Error (GameData * , ci32 , const char * Func );
129137
130138void CheckWindowSize (GameData * );
131139
@@ -149,23 +157,23 @@ void SaveScorePlayer(FILE*, ScEntry);
149157void CreateIfDoesntExist (GameData * );
150158void OpenFile (GameData * );
151159
152- void IsGameOver (GameData * , u16 );
160+ void IsGameOver (GameData * , cu16 );
153161void UpdateLevel (GameData * );
154162
155163void MoveHoles (GameData * );
156164void CalculateColision (GameData * );
157165void GenerateNewHole (GameData * );
158166
159- void PrintLine (u8 , u8 , i16 , u16 );
160- void PrintColumn (u8 , u8 , i16 , u16 );
161- void PrintHole (u8 , u8 , i16 , u16 );
167+ void PrintLine (cu8 , u8 , ci16 , u16 );
168+ void PrintColumn (u8 , cu8 , ci16 , u16 );
169+ void PrintHole (u8 , cu8 , ci16 , cu16 );
162170void PrintDiamond (u16 );
163171
164172void DrawStreetLane (void );
165173void DrawLifePoints (GameData * );
166174void DrawLevelIndicator (GameData * );
167175
168- void DrawFrata (u8 , u8 );
176+ void DrawFrata (cu8 , cu8 );
169177void DrawHoles (GameData * );
170178
171179void ChangeScreen (GameData * , enum Scr );
@@ -206,7 +214,7 @@ void Quit(GameData* Game) {
206214
207215}
208216
209- void Error (GameData * Game , i32 Errsv , const char * Func ) {
217+ void Error (GameData * Game , ci32 Errsv , const char * Func ) {
210218
211219 if (Func != NULL )
212220 fprintf (stderr , "%s: " , Func );
@@ -510,7 +518,7 @@ void CopyStruct_ScEntry(ScEntry* Dst, ScEntry* Src) {
510518 */
511519u16 CountEntries (FILE * File ) {
512520
513- u16 count = 0 ;
521+ ru16 count = 0 ;
514522 ScEntry Entry ;
515523
516524 while ((fscanf (File , "%" SCNu64 " %d %d %d" , & (Entry .Score ),
@@ -530,7 +538,7 @@ u16 CountEntries(FILE* File) {
530538 */
531539void FillEntries (GameData * Game ) {
532540
533- u16 i ;
541+ ru16 i ;
534542 for (i = 0 ; i < Game -> Scores .np ; i ++ ) {
535543
536544 fscanf (Game -> Scores .File , "%" SCNu64 " %d %d %d" , & (Game -> Scores .Players [i ].Score ),
@@ -592,7 +600,7 @@ void CreateIfDoesntExist(GameData* Game) {
592600 */
593601void OpenFile (GameData * Game ) {
594602
595- u16 n ;
603+ ru16 n ;
596604
597605 CreateIfDoesntExist (Game );
598606
@@ -618,7 +626,7 @@ void OpenFile(GameData* Game) {
618626/*
619627 * Reduz a quantidade de vidas e verifica se é Game Over
620628 */
621- void IsGameOver (GameData * Game , u16 i ) {
629+ void IsGameOver (GameData * Game , cu16 i ) {
622630
623631 Game -> Life -- ;
624632
@@ -680,7 +688,7 @@ void UpdateLevel(GameData* Game) {
680688 */
681689void MoveHoles (GameData * Game ) {
682690
683- u16 i ;
691+ ru16 i ;
684692
685693 /* Quando refresh for >= 100, movemos os buracos */
686694 if (Game -> Refresh >= 100 ) {
@@ -702,7 +710,7 @@ void MoveHoles(GameData* Game) {
702710 */
703711void CalculateColision (GameData * Game ) {
704712
705- u16 i ;
713+ ru16 i ;
706714
707715 for (i = 0 ; i < Game -> nb ; i ++ ) {
708716
@@ -722,7 +730,7 @@ void CalculateColision(GameData* Game) {
722730void GenerateNewHole (GameData * Game ) {
723731
724732 bool existe = false;
725- u16 i ;
733+ ru16 i ;
726734
727735 for (i = 0 ; i < Game -> nb ; i ++ ) {
728736
@@ -755,7 +763,7 @@ void GenerateNewHole(GameData* Game) {
755763 * Desenha uma linha de algo
756764 * n é a quantidade de espaços
757765 */
758- void PrintLine (u8 y , u8 x , i16 Color , u16 n ) {
766+ void PrintLine (cu8 y , u8 x , ci16 Color , u16 n ) {
759767
760768 for (; n > 0 ; n -- )
761769 tb_string (x ++ , y , TB_WHITE , Color , " " );
@@ -766,7 +774,7 @@ void PrintLine(u8 y, u8 x, i16 Color, u16 n) {
766774 * Desenha uma coluna de algo
767775 * n é a quantidade de espaços
768776 */
769- void PrintColumn (u8 y , u8 x , i16 Color , u16 n ){
777+ void PrintColumn (u8 y , cu8 x , ci16 Color , u16 n ){
770778
771779 for ( ; n > 0 ; n -- )
772780 tb_string (x , y ++ , TB_WHITE , Color , " " );
@@ -776,7 +784,7 @@ void PrintColumn(u8 y, u8 x, i16 Color, u16 n){
776784/*
777785 * Desenha um buraco na tela inicial de tamanho n
778786 */
779- void PrintHole (u8 y , u8 x , i16 Color , u16 n ){
787+ void PrintHole (u8 y , cu8 x , ci16 Color , cu16 n ){
780788
781789 u8 w = (n / 2 );
782790
@@ -837,7 +845,7 @@ void DrawLevelIndicator(GameData* Game) {
837845/*
838846 * Desenha o Frata na tela, na posição y e x
839847 */
840- void DrawFrata (u8 y , u8 x ) {
848+ void DrawFrata (cu8 y , cu8 x ) {
841849
842850 PrintLine (y + 2 , x , TB_MAGENTA , 9 );
843851
@@ -860,7 +868,7 @@ void DrawFrata(u8 y, u8 x) {
860868 */
861869void DrawHoles (GameData * Game ) {
862870
863- u16 i ;
871+ ru16 i ;
864872
865873 for (i = 0 ; i < Game -> nb ; i ++ ) {
866874
@@ -894,7 +902,7 @@ void ChangeScreen(GameData* Game, enum Scr NextScreen) {
894902 */
895903void DrawScr_Initial (void ) {
896904
897- u8 j ;
905+ ru8 j ;
898906
899907 for ( j = 20 ; j < 24 ; j ++ )
900908 PrintColumn (1 , j , TB_CYAN , 9 ); // coluna de L
@@ -1029,7 +1037,7 @@ void DrawScr_Level(GameData* Game) {
10291037 */
10301038void DrawScr_Pause (void ) {
10311039
1032- u8 x ;
1040+ ru8 x ;
10331041
10341042 PrintLine (4 , 17 , TB_YELLOW , 5 );
10351043 PrintLine (6 , 17 , TB_YELLOW , 5 );
@@ -1098,7 +1106,7 @@ void DrawScr_Pause(void) {
10981106 */
10991107void DrawScr_GameOver (GameData * Game ) {
11001108
1101- u8 y , x ;
1109+ ru8 y , x ;
11021110
11031111 /*QUADRADOS ESQUERDA*/
11041112
@@ -1340,7 +1348,7 @@ void DrawScr_GameOver(GameData* Game) {
13401348 */
13411349void DrawScr_Ranking (GameData * Game ) {
13421350
1343- u8 x ;
1351+ ru8 x ;
13441352
13451353 //tabela
13461354 for (x = 17 ; x < 78 ; x ++ )
@@ -1463,7 +1471,7 @@ void DrawScr_SaveScore(GameData* Game) {
14631471
14641472 ClearScreen ();
14651473
1466- u8 x ;
1474+ ru8 x ;
14671475
14681476 //s
14691477 PrintLine (7 , 22 , TB_BLUE , 5 );
@@ -1574,7 +1582,7 @@ void DrawScr_SaveScore(GameData* Game) {
15741582 */
15751583void DrawScr_AboutPage_1 (void ){
15761584
1577- u8 i ;
1585+ ru8 i ;
15781586
15791587 /* Desenha ABOUT na tela */
15801588
@@ -1683,7 +1691,7 @@ void DrawScr_AboutPage_2(void){
16831691
16841692
16851693 /* Imprime as linhas de divisão da tela */
1686- u8 i ;
1694+ ru8 i ;
16871695
16881696 for (i = 3 ; i < 23 ; i ++ ) {
16891697 tb_char (50 , i , TB_WHITE , TB_BLUE , ' ' );
@@ -1785,7 +1793,7 @@ void ClearScreen(void) {
17851793
17861794 tb_clear_buffer ();
17871795
1788- u8 y ;
1796+ ru8 y ;
17891797
17901798 for (y = 0 ; y < 24 ; y ++ )
17911799 tb_empty (1 , y , TB_BLACK , 103 );
0 commit comments