Improved uxnasm error report

This commit is contained in:
neauoire 2021-06-17 17:41:55 -07:00
parent ac60a33f39
commit 78c428d215
2 changed files with 6 additions and 5 deletions

View File

@ -18,7 +18,7 @@ typedef signed char Sint8;
typedef unsigned short Uint16; typedef unsigned short Uint16;
typedef struct { typedef struct {
char name[64], items[64][64]; char name[64], items[128][64];
Uint8 len, refs; Uint8 len, refs;
} Macro; } Macro;
@ -267,7 +267,7 @@ parsetoken(char *w)
else if(sihx(w + 1) && slen(w + 1) == 4) else if(sihx(w + 1) && slen(w + 1) == 4)
pushshort(shex(w + 1), 1); pushshort(shex(w + 1), 1);
else else
return 0; return error("Invalid hexadecimal literal", w);
return 1; return 1;
} else if(sihx(w)) { /* raw */ } else if(sihx(w)) { /* raw */
if(slen(w) == 2) if(slen(w) == 2)
@ -281,10 +281,10 @@ parsetoken(char *w)
int i; int i;
for(i = 0; i < m->len; ++i) for(i = 0; i < m->len; ++i)
if(!parsetoken(m->items[i])) if(!parsetoken(m->items[i]))
return 0; return error("Invalid macro", m->name);
return ++m->refs; return ++m->refs;
} }
return 0; return error("Invalid token", w);
} }
int int

View File

@ -89,8 +89,9 @@ screencapture(void)
{ {
const Uint32 format = SDL_PIXELFORMAT_ARGB8888; const Uint32 format = SDL_PIXELFORMAT_ARGB8888;
int w, h; int w, h;
SDL_Surface *surface;
SDL_GetRendererOutputSize(gRenderer, &w, &h); SDL_GetRendererOutputSize(gRenderer, &w, &h);
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, format); surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, format);
SDL_RenderReadPixels(gRenderer, NULL, format, surface->pixels, surface->pitch); SDL_RenderReadPixels(gRenderer, NULL, format, surface->pixels, surface->pitch);
SDL_SaveBMP(surface, "screenshot.bmp"); SDL_SaveBMP(surface, "screenshot.bmp");
SDL_FreeSurface(surface); SDL_FreeSurface(surface);