2021-03-07 19:05:08 +00:00
|
|
|
#include "wgt.h"
|
|
|
|
|
|
|
|
block abuf; /* pointer to the active screen */
|
|
|
|
unsigned int currentcolor;
|
2021-03-12 22:02:57 +00:00
|
|
|
short tx = 0,ty = 0,bx = 319,by = 199; /* clipping variables */
|
2021-03-07 19:05:08 +00:00
|
|
|
|
2021-03-11 22:33:27 +00:00
|
|
|
int curx = 0;
|
|
|
|
int cury = 0;
|
|
|
|
|
2021-03-07 19:05:08 +00:00
|
|
|
wgt_sys WGT_SYS;
|
|
|
|
|
|
|
|
// ######## HELPER FUNCTIONS ########
|
|
|
|
|
2021-03-11 22:33:27 +00:00
|
|
|
void *memset(void *dest, unsigned int val, unsigned len)
|
2021-03-07 19:05:08 +00:00
|
|
|
{
|
|
|
|
unsigned int *ptr = dest;
|
|
|
|
while (len-- > 0)
|
|
|
|
*ptr++ = val;
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
2021-03-09 22:37:23 +00:00
|
|
|
void *memcpy(void *dest, const void *src, unsigned len)
|
|
|
|
{
|
2021-03-11 22:33:27 +00:00
|
|
|
unsigned int *d = dest;
|
|
|
|
const unsigned int *s = src;
|
2021-03-09 22:37:23 +00:00
|
|
|
while (len--)
|
|
|
|
*d++ = *s++;
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
2021-03-12 10:28:59 +00:00
|
|
|
void *memcpy_xray(void *dest, const void *src, unsigned len)
|
|
|
|
{
|
|
|
|
unsigned int *d = dest;
|
|
|
|
const unsigned int *s = src;
|
|
|
|
while (len--) {
|
|
|
|
if (*s != 0) {
|
|
|
|
*d++ = *s++;
|
|
|
|
} else {
|
|
|
|
d++;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
2021-03-07 19:05:08 +00:00
|
|
|
int abs(int i)
|
|
|
|
{
|
|
|
|
return i < 0 ? -i : i;
|
|
|
|
}
|
|
|
|
|
|
|
|
int strlen(const char *str)
|
|
|
|
{
|
|
|
|
const char *s;
|
|
|
|
|
|
|
|
for (s = str; *s; ++s);
|
|
|
|
return (s - str);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ######## WGT FUNCTIONS ########
|
|
|
|
|
|
|
|
void wcls (unsigned int col)
|
|
|
|
{
|
|
|
|
memset (abuf, col, WGT_SYS.xres * WGT_SYS.yres);
|
|
|
|
}
|
2021-03-11 22:33:27 +00:00
|
|
|
|
|
|
|
void debugstr(char *str) {
|
2021-03-12 22:02:57 +00:00
|
|
|
if (curx + (strlen(str) * 8) >= 320) {
|
2021-03-11 22:33:27 +00:00
|
|
|
curx = 0; cury += 8;
|
|
|
|
}
|
2021-03-12 22:02:57 +00:00
|
|
|
if (cury + 8 >= 200) {
|
2021-03-11 22:33:27 +00:00
|
|
|
cury = 0;
|
|
|
|
}
|
|
|
|
wtextcolor(vgapal[15]);
|
|
|
|
wouttextxy (curx, cury, NULL, str);
|
|
|
|
|
|
|
|
curx += (strlen(str) * 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
void debugcrlf(void) {
|
|
|
|
curx = 0; cury += 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
void debugreset(void) {
|
|
|
|
curx = 0; cury = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void debugch(unsigned char b) {
|
|
|
|
unsigned int n;
|
|
|
|
int c;
|
|
|
|
for(c=4;c>=0;c-=4) {
|
|
|
|
n=(b>>c)&0xF;
|
|
|
|
n+=n>9?0x37:0x30;
|
|
|
|
debugstr((char *)&n);
|
|
|
|
}
|
|
|
|
debugstr(" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
void debughex(unsigned int d) {
|
|
|
|
unsigned int n;
|
|
|
|
int c;
|
|
|
|
for(c=28;c>=0;c-=4) {
|
|
|
|
n=(d>>c)&0xF;
|
|
|
|
n+=n>9?0x37:0x30;
|
|
|
|
debugstr((char *)&n);
|
|
|
|
}
|
|
|
|
debugstr(" ");
|
|
|
|
}
|