diff --git a/s2d_parse.c b/s2d_parse.c index 94a23bd4..bd63ea0f 100644 --- a/s2d_parse.c +++ b/s2d_parse.c @@ -66,7 +66,7 @@ void s2d_print(int x, int y, const char *str, uObjMtx *buf) { } while (*p != '\0'); myScale = 1; myDegrees = 0; - saved_degrees = 0; + // saved_degrees = 0; tx = 0; ty = 0; } diff --git a/s2d_ustdlib.c b/s2d_ustdlib.c index 183c0e7b..619957ec 100644 --- a/s2d_ustdlib.c +++ b/s2d_ustdlib.c @@ -1,6 +1,23 @@ // ustdlib means un-standard library // i'm going to abuse so much of my power here lol +// int s2d_atoi(char *s, char **s2) { +// int ret = 0; +// int isNegative = (*s == '-'); +// if (isNegative) { +// s++; +// (*s2)++; +// } +// while (*s != '\0' && *s != ' ' && *s >= '0' && *s <= '9') { +// ret *= 10; +// ret += *s - '0'; +// s++; +// (*s2)++; +// } +// if (isNegative) ret *= -1; +// return ret; +// } + int s2d_atoi(char *s, char **s2) { int ret = 0; int isNegative = (*s == '-'); @@ -16,7 +33,6 @@ int s2d_atoi(char *s, char **s2) { if (!(*(s+1) != '\0' && *(s+1) != ' ' && *(s+1) >= '0' && *(s+1) <= '9')) break; (*s2)++; } - // (*s2)--; if (isNegative) ret *= -1; return ret; } diff --git a/x86_testing_ground/a.out b/x86_testing_ground/a.out new file mode 100755 index 00000000..2170664a Binary files /dev/null and b/x86_testing_ground/a.out differ diff --git a/x86_testing_ground/atoi.c b/x86_testing_ground/atoi.c index 48fee781..c853b04f 100644 --- a/x86_testing_ground/atoi.c +++ b/x86_testing_ground/atoi.c @@ -13,6 +13,9 @@ // if (isNegative) ret *= -1; // return ret; // } +#include +#include +#include #define SCALE "\x80" // SCALE (some scale) #define ROTATE "\x81" // ROTATE (degrees) // TODO: maybe add axis? #define TRANSLATE "\x82" // TRANSLATE (x) (y) @@ -119,6 +122,25 @@ int s2d_ilen(char *s) { } return ret; } + +int s2d_atoi2(char *s) { + int ret = 0; + int isNegative = (*s == '-'); + if (isNegative) { + s++; + } + for (; *s != '\0' && *s != ' ' && *s >= '0' && *s <= '9'; s++) { + ret *= 10; + if (*s >= '0' && *s <= '9') + ret += *s - '0'; + else break; + if (!(*(s+1) != '\0' && *(s+1) != ' ' && *(s+1) >= '0' && *(s+1) <= '9')) break; + } + // (*s2)--; + if (isNegative) ret *= -1; + return ret; +} + void s2d_type_print(int x, int y, char *str, int *pos) { char *temp_str = str; char tmp = temp_str[*pos]; @@ -134,7 +156,9 @@ void s2d_type_print(int x, int y, char *str, int *pos) { (*pos) += s2d_ilen(str + *pos+2) + 1; break; case CH_ROT: - (*pos) += 2; + printf("ROTATE %s %d\n", str + *pos + 1, s2d_ilen(str + *pos + 1)); + (*pos) += s2d_ilen(str + *pos + 2); + break; } // temp_str[*pos] = '\0'; // s2d_print(x, y, temp_str); @@ -145,6 +169,7 @@ void s2d_type_print(int x, int y, char *str, int *pos) { if (*pos < len) (*pos)++; // } + printf("%d %c\n", *pos, str[*pos]); } @@ -153,10 +178,10 @@ char sss[] = SCALE "2"; // "big chungus"; char myS[] = "small test" - SCALE "2" + ROTATE "2" "big test" - SCALE "0001" - "small chungus"; + ROTATE "26" + "italic chungus"; int pos; int main(void) { @@ -165,7 +190,6 @@ int main(void) { // s2d_print(0,0, t); while (pos != strlen(myS)) { s2d_type_print(0, 0, myS, &pos); - printf("%d %c\n", pos, myS[pos]); } // printf("%d\n", s2d_ilen(sss + 1)); } \ No newline at end of file