2020-12-11 21:47:11 -05:00
|
|
|
#include <ultra64.h>
|
|
|
|
|
#include <PR/gs2dex.h>
|
2020-12-12 16:20:37 -05:00
|
|
|
#include <PR/gu.h>
|
2020-12-15 22:57:04 -05:00
|
|
|
#include <stdarg.h>
|
2020-12-11 21:47:11 -05:00
|
|
|
|
2020-12-15 17:46:07 -05:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2020-12-11 21:47:11 -05:00
|
|
|
#include "s2d_draw.h"
|
2020-12-11 22:51:58 -05:00
|
|
|
#include "s2d_print.h"
|
2020-12-15 17:46:07 -05:00
|
|
|
#include "s2d_ustdlib.h"
|
2020-12-11 21:47:11 -05:00
|
|
|
|
2020-12-12 15:33:14 -05:00
|
|
|
int saved_degrees = 0;
|
2020-12-15 22:57:04 -05:00
|
|
|
int s2d_colorFrames = 0;
|
2020-12-15 17:46:07 -05:00
|
|
|
|
2020-12-12 18:50:26 -05:00
|
|
|
|
2020-12-13 18:31:42 -05:00
|
|
|
extern u32 gGlobalTimer;
|
|
|
|
|
|
2020-12-15 23:10:28 -05:00
|
|
|
void s2d_snprint(int x, int y, const char *str, uObjMtx *buf, int len) {
|
2020-12-11 21:47:11 -05:00
|
|
|
char *p = str;
|
2020-12-12 18:50:26 -05:00
|
|
|
int tx = 0, ty = 0;
|
2020-12-15 22:57:04 -05:00
|
|
|
int tmp_len = 0;
|
2020-12-15 23:06:09 -05:00
|
|
|
int orig_x = x;
|
|
|
|
|
int orig_y = y;
|
2020-12-12 19:45:53 -05:00
|
|
|
// int r = 0, g = 0, b = 0, a = 0;
|
2020-12-12 15:33:14 -05:00
|
|
|
if (*p == '\0') return;
|
2020-12-11 22:51:58 -05:00
|
|
|
do {
|
2020-12-11 21:47:11 -05:00
|
|
|
char r = *p;
|
2020-12-12 18:50:26 -05:00
|
|
|
int s, rd;
|
2020-12-15 22:57:04 -05:00
|
|
|
|
|
|
|
|
|
2020-12-11 21:47:11 -05:00
|
|
|
switch (r) {
|
2020-12-11 22:51:58 -05:00
|
|
|
case CH_SCALE:
|
2020-12-13 18:31:42 -05:00
|
|
|
CH_SKIP(p);
|
2020-12-12 18:50:26 -05:00
|
|
|
s = s2d_atoi(p, &p);
|
2020-12-11 21:47:11 -05:00
|
|
|
myScale = s;
|
|
|
|
|
break;
|
2020-12-11 22:51:58 -05:00
|
|
|
case CH_ROT:
|
2020-12-13 18:31:42 -05:00
|
|
|
CH_SKIP(p);
|
2020-12-12 18:50:26 -05:00
|
|
|
rd = s2d_atoi(p, &p);
|
2020-12-12 15:33:14 -05:00
|
|
|
saved_degrees = rd;
|
|
|
|
|
myDegrees = rd;
|
2020-12-11 21:47:11 -05:00
|
|
|
break;
|
2020-12-11 22:51:58 -05:00
|
|
|
case CH_TRANSLATE:
|
2020-12-13 18:31:42 -05:00
|
|
|
CH_SKIP(p);
|
2020-12-12 20:28:07 -05:00
|
|
|
x = s2d_atoi(p, &p);
|
2020-12-13 18:31:42 -05:00
|
|
|
CH_SKIP(p);
|
|
|
|
|
CH_SKIP(p);
|
2020-12-12 20:28:07 -05:00
|
|
|
y = s2d_atoi(p, &p);
|
2020-12-12 15:33:14 -05:00
|
|
|
break;
|
2020-12-12 19:45:53 -05:00
|
|
|
case CH_COLOR:
|
2020-12-15 22:57:04 -05:00
|
|
|
s2d_colorFrames++;
|
2020-12-13 18:31:42 -05:00
|
|
|
CH_SKIP(p);
|
2020-12-12 19:45:53 -05:00
|
|
|
s2d_red = s2d_atoi(p, &p);
|
2020-12-13 18:31:42 -05:00
|
|
|
CH_SKIP(p); CH_SKIP(p);
|
2020-12-12 21:56:36 -05:00
|
|
|
|
2020-12-12 19:45:53 -05:00
|
|
|
s2d_green = s2d_atoi(p, &p);
|
2020-12-13 18:31:42 -05:00
|
|
|
CH_SKIP(p); CH_SKIP(p);
|
2020-12-12 21:56:36 -05:00
|
|
|
|
2020-12-12 19:45:53 -05:00
|
|
|
s2d_blue = s2d_atoi(p, &p);
|
2020-12-13 18:31:42 -05:00
|
|
|
CH_SKIP(p); CH_SKIP(p);
|
2020-12-12 21:56:36 -05:00
|
|
|
|
2020-12-12 19:45:53 -05:00
|
|
|
s2d_alpha = s2d_atoi(p, &p);
|
|
|
|
|
break;
|
2020-12-15 23:06:09 -05:00
|
|
|
case '\n':
|
|
|
|
|
x = orig_x;
|
|
|
|
|
y += TEX_HEIGHT;
|
|
|
|
|
break;
|
2020-12-11 21:47:11 -05:00
|
|
|
default:
|
2020-12-15 22:57:04 -05:00
|
|
|
// if (s2d_colorFrames > 2) {
|
|
|
|
|
// s2d_colorFrames = 0;
|
|
|
|
|
// s2d_red = s2d_green = s2d_blue = 255;
|
|
|
|
|
// s2d_alpha = 255;
|
|
|
|
|
// }
|
|
|
|
|
if (r != '\0') {
|
|
|
|
|
if (myDegrees == 0)
|
|
|
|
|
draw_s2d_glyph(r, (x += (8 * myScale)) + tx, y + ty, (buf++));
|
|
|
|
|
else
|
|
|
|
|
draw_s2d_glyph(r, (x += ((8 * myScale))) + tx, y + ty, (buf++));
|
|
|
|
|
}
|
2020-12-11 21:47:11 -05:00
|
|
|
}
|
2020-12-12 16:20:37 -05:00
|
|
|
// myDegrees += saved_degrees;
|
2020-12-15 17:46:07 -05:00
|
|
|
if (*p == '\0') break;
|
2020-12-13 22:24:18 -05:00
|
|
|
p++;
|
2020-12-15 22:57:04 -05:00
|
|
|
tmp_len++;
|
|
|
|
|
} while (tmp_len < len);
|
2020-12-11 22:51:58 -05:00
|
|
|
myScale = 1;
|
2020-12-12 15:33:14 -05:00
|
|
|
myDegrees = 0;
|
2020-12-15 21:21:02 -05:00
|
|
|
// saved_degrees = 0;
|
2020-12-12 18:50:26 -05:00
|
|
|
tx = 0;
|
|
|
|
|
ty = 0;
|
2020-12-11 21:47:11 -05:00
|
|
|
}
|
2020-12-11 22:51:58 -05:00
|
|
|
|
2020-12-15 22:57:04 -05:00
|
|
|
void s2d_print(int x, int y, const char *str, uObjMtx *buf) {
|
|
|
|
|
s2d_snprint(x, y, str, buf, s2d_strlen(str));
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-15 23:10:28 -05:00
|
|
|
void s2d_type_print(int x, int y, const char *str, uObjMtx *buf, int *pos) {
|
2020-12-15 17:46:07 -05:00
|
|
|
int len = s2d_strlen(str);
|
|
|
|
|
|
2020-12-15 22:57:04 -05:00
|
|
|
s2d_snprint(x, y, str, buf, *pos);
|
2020-12-15 17:46:07 -05:00
|
|
|
if (s2d_timer % 2 == 0) {
|
2020-12-15 22:57:04 -05:00
|
|
|
if (*pos < len) {
|
|
|
|
|
(*pos)++;
|
|
|
|
|
}
|
2020-12-15 17:46:07 -05:00
|
|
|
}
|
2020-12-13 22:24:18 -05:00
|
|
|
}
|
|
|
|
|
|
2020-12-15 23:10:28 -05:00
|
|
|
void s2d_vsprint(int x, int y, uObjMtx *buf, const char *str, ...) {
|
2020-12-15 22:57:04 -05:00
|
|
|
va_list args;
|
|
|
|
|
va_start(args, str);
|
2020-12-15 23:06:09 -05:00
|
|
|
// vsprintf(str, )
|
2020-12-15 22:57:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|