added separator character to be able to separate parameters and numbers without a space

This commit is contained in:
farisawan-2000
2021-01-09 21:53:27 -05:00
parent 5a3770e8b2
commit e6e134fff6
5 changed files with 35 additions and 7 deletions

View File

@@ -70,8 +70,11 @@ void s2d_snprint(int x, int y, const char *str, uObjMtx *buf, int len) {
x += TAB_WIDTH_V;
y += TEX_HEIGHT;
break;
// case CH_SEPARATOR:
// CH_SKIP(p);
// break;
default:
if (current_char != '\0') {
if (current_char != '\0' && current_char != CH_SEPARATOR) {
draw_s2d_glyph(current_char, x, y, (buf++));
(x += (s2d_kerning_table[current_char] * myScale));
}

View File

@@ -7,6 +7,7 @@
#define COLOR "\x83" // COLOR (r) (g) (b) (a)
#define DROPSHADOW "\x84" // DROPSHADOW (no params)
#define BACKGROUND "\x85" // BACKGROUND (w) (h) (alpha)
#define SEPARATOR "\x86"
#define CH_SCALE '\x80'
#define CH_ROT '\x81'
@@ -14,6 +15,7 @@
#define CH_COLOR '\x83'
#define CH_DROPSHADOW '\x84'
#define CH_BACKGROUND '\x85'
#define CH_SEPARATOR '\x86'
// ASCII standard escape codes
#define CH_NEWLINE '\n'

View File

@@ -1,6 +1,6 @@
// ustdlib means un-standard library
// i'm going to abuse so much of my power here lol
#include "s2d_print.h"
// int s2d_atoi(char *s, char **s2) {
// int ret = 0;
// int isNegative = (*s == '-');
@@ -25,12 +25,12 @@ int s2d_atoi(char *s, char **s2) {
s++;
(*s2)++;
}
for (; *s != '\0' && *s != ' ' && *s >= '0' && *s <= '9'; s++) {
for (; *s != '\0' && *s != ' ' && *s != CH_SEPARATOR && *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;
if (!(*(s+1) != '\0' && *(s+1) != CH_SEPARATOR && *(s+1) != ' ' && *(s+1) >= '0' && *(s+1) <= '9')) break;
(*s2)++;
}
if (isNegative) ret *= -1;
@@ -40,7 +40,7 @@ int s2d_atoi(char *s, char **s2) {
int s2d_ilen(char *s) {
int ret = 0;
char *p = s;
while (*p >= '0' && *p <= '9') {
while (*p >= '0' && *p <= '9' && *p != CH_SEPARATOR) {
ret++;
p++;
}

Binary file not shown.

View File

@@ -195,10 +195,33 @@ int main(void) {
// printf("%d\n", s2d_atoi(s, &s));
// printf("%s\n", s);
// s2d_print(0,0, t);
while (pos != strlen(my2)) {
char laStrBuf[0x100];
char ff[0x100];
sprintf(ff,
"%s %d:"
TRANSLATE "134 93" "%s:"
, "Floor", 213, "Seed");
sprintf(
laStrBuf,
"%s"
TRANSLATE "138 93" "%s"
TRANSLATE "138 110" "%s"
TRANSLATE "138 130" "%s"
, "The Basement", "LLRRABAB", "Continue", "End Run");
while (pos != strlen(laStrBuf)) {
// s2d_type_print(0, 0, myS, &pos);
printf("%d %s\n",s2d_ilen(my2 + pos), my2 + pos);
printf("%d %s\n",s2d_ilen(laStrBuf + pos), laStrBuf + pos);
pos++;
}
pos = 0;
while (pos != strlen(ff)) {
// s2d_type_print(0, 0, myS, &pos);
printf("%d %s\n",s2d_ilen(ff + pos), ff + pos);
pos++;
}
// laStrBuf[strlen(laStrBuf)] = "\x1";
// laStrBuf[strlen(laStrBuf)+1] = "\x1";
// printf("%s\n", laStrBuf);
// printf("%d\n", s2d_ilen(sss + 1));
}