mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-10-31 19:42:39 +00:00
Switch void context increments from pre to post
This commit is contained in:
parent
1ce8b9bc27
commit
2a825de2fd
7 changed files with 24 additions and 24 deletions
|
@ -90,7 +90,7 @@ audio_get_vu(UxnAudio *c)
|
|||
int i;
|
||||
Sint32 sum[2] = {0, 0};
|
||||
if(!c->advance || !c->period) return 0;
|
||||
for(i = 0; i < 2; ++i) {
|
||||
for(i = 0; i < 2; i++) {
|
||||
if(!c->volume[i]) continue;
|
||||
sum[i] = 1 + envelope(c, c->age) * c->volume[i] / 0x800;
|
||||
if(sum[i] > 0xf) sum[i] = 0xf;
|
||||
|
|
|
@ -127,7 +127,7 @@ file_stat(void *dest, Uint16 len)
|
|||
{
|
||||
char *basename = strrchr(current_filename, '/');
|
||||
if(basename != NULL)
|
||||
++basename;
|
||||
basename++;
|
||||
else
|
||||
basename = current_filename;
|
||||
return get_entry(dest, len, current_filename, basename, 0);
|
||||
|
|
|
@ -56,7 +56,7 @@ static void
|
|||
screen_blit(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy, Uint8 twobpp)
|
||||
{
|
||||
int v, h, opaque = blending[4][color];
|
||||
for(v = 0; v < 8; ++v) {
|
||||
for(v = 0; v < 8; v++) {
|
||||
Uint16 c = sprite[v] | (twobpp ? sprite[v + 8] : 0) << 8;
|
||||
for(h = 7; h >= 0; --h, c >>= 1) {
|
||||
Uint8 ch = (c & 1) | ((c >> 7) & 2);
|
||||
|
@ -109,7 +109,7 @@ void
|
|||
screen_clear(UxnScreen *p, Layer *layer)
|
||||
{
|
||||
Uint32 i, size = p->width * p->height;
|
||||
for(i = 0; i < size; ++i)
|
||||
for(i = 0; i < size; i++)
|
||||
layer->pixels[i] = 0x00;
|
||||
layer->changed = 1;
|
||||
}
|
||||
|
@ -118,9 +118,9 @@ void
|
|||
screen_redraw(UxnScreen *p, Uint32 *pixels)
|
||||
{
|
||||
Uint32 i, size = p->width * p->height, palette[16];
|
||||
for(i = 0; i < 16; ++i)
|
||||
for(i = 0; i < 16; i++)
|
||||
palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)];
|
||||
for(i = 0; i < size; ++i)
|
||||
for(i = 0; i < size; i++)
|
||||
pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]];
|
||||
p->fg.changed = p->bg.changed = 0;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ void
|
|||
screen_debug(UxnScreen *p, Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory)
|
||||
{
|
||||
Uint8 i, x, y, b;
|
||||
for(i = 0; i < 0x20; ++i) {
|
||||
for(i = 0; i < 0x20; i++) {
|
||||
x = ((i % 8) * 3 + 1) * 8, y = (i / 8 + 1) * 8, b = stack[i];
|
||||
/* working stack */
|
||||
screen_blit(p, &p->fg, x, y, font[(b >> 4) & 0xf], 1 + (wptr == i) * 0x7, 0, 0, 0);
|
||||
|
@ -144,7 +144,7 @@ screen_debug(UxnScreen *p, Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory)
|
|||
screen_blit(p, &p->fg, 0x8, y + 0x10, font[(rptr >> 4) & 0xf], 0x2, 0, 0, 0);
|
||||
screen_blit(p, &p->fg, 0x10, y + 0x10, font[rptr & 0xf], 0x2, 0, 0, 0);
|
||||
/* guides */
|
||||
for(x = 0; x < 0x10; ++x) {
|
||||
for(x = 0; x < 0x10; x++) {
|
||||
screen_write(p, &p->fg, x, p->height / 2, 2);
|
||||
screen_write(p, &p->fg, p->width - x, p->height / 2, 2);
|
||||
screen_write(p, &p->fg, p->width / 2, p->height - x, 2);
|
||||
|
|
|
@ -60,7 +60,7 @@ uxn_eval(Uxn *u, Uint16 pc)
|
|||
switch(instr & 0x1f) {
|
||||
/* Stack */
|
||||
case 0x00: /* LIT */ if(bs) { PEEK16(a, pc) PUSH16(src, a) pc += 2; }
|
||||
else { a = u->ram[pc]; PUSH8(src, a) ++pc; } break;
|
||||
else { a = u->ram[pc]; PUSH8(src, a) pc++; } break;
|
||||
case 0x01: /* INC */ POP(a) PUSH(src, a + 1) break;
|
||||
case 0x02: /* POP */ POP(a) break;
|
||||
case 0x03: /* DUP */ POP(a) PUSH(src, a) PUSH(src, a) break;
|
||||
|
@ -110,7 +110,7 @@ uxn_boot(Uxn *u, Uint8 *memory)
|
|||
{
|
||||
Uint32 i;
|
||||
char *cptr = (char *)u;
|
||||
for(i = 0; i < sizeof(*u); ++i)
|
||||
for(i = 0; i < sizeof(*u); i++)
|
||||
cptr[i] = 0x00;
|
||||
u->ram = memory;
|
||||
return 1;
|
||||
|
|
18
src/uxnasm.c
18
src/uxnasm.c
|
@ -57,8 +57,8 @@ static char ops[][4] = {
|
|||
static int scmp(char *a, char *b, int len) { int i = 0; while(a[i] == b[i]) if(!a[i] || ++i >= len) return 1; return 0; } /* string compare */
|
||||
static int sihx(char *s) { int i = 0; char c; while((c = s[i++])) if(!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f')) return 0; return i > 1; } /* string is hexadecimal */
|
||||
static int shex(char *s) { int n = 0, i = 0; char c; while((c = s[i++])) if(c >= '0' && c <= '9') n = n * 16 + (c - '0'); else if(c >= 'a' && c <= 'f') n = n * 16 + 10 + (c - 'a'); return n; } /* string to num */
|
||||
static int slen(char *s) { int i = 0; while(s[i]) ++i; return i; } /* string length */
|
||||
static char *scpy(char *src, char *dst, int len) { int i = 0; while((dst[i] = src[i]) && i < len - 2) ++i; dst[i + 1] = '\0'; return dst; } /* string copy */
|
||||
static int slen(char *s) { int i = 0; while(s[i]) i++; return i; } /* string length */
|
||||
static char *scpy(char *src, char *dst, int len) { int i = 0; while((dst[i] = src[i]) && i < len - 2) i++; dst[i + 1] = '\0'; return dst; } /* string copy */
|
||||
static char *scat(char *dst, const char *src) { char *ptr = dst + slen(dst); while(*src) *ptr++ = *src++; *ptr = '\0'; return dst; } /* string cat */
|
||||
|
||||
/* clang-format on */
|
||||
|
@ -82,7 +82,7 @@ static Macro *
|
|||
findmacro(char *name)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < p.mlen; ++i)
|
||||
for(i = 0; i < p.mlen; i++)
|
||||
if(scmp(p.macros[i].name, name, 64))
|
||||
return &p.macros[i];
|
||||
return NULL;
|
||||
|
@ -92,7 +92,7 @@ static Label *
|
|||
findlabel(char *name)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < p.llen; ++i)
|
||||
for(i = 0; i < p.llen; i++)
|
||||
if(scmp(p.labels[i].name, name, 64))
|
||||
return &p.labels[i];
|
||||
return NULL;
|
||||
|
@ -102,7 +102,7 @@ static Uint8
|
|||
findopcode(char *s)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 0x20; ++i) {
|
||||
for(i = 0; i < 0x20; i++) {
|
||||
int m = 0;
|
||||
if(!scmp(ops[i], s, 3))
|
||||
continue;
|
||||
|
@ -116,7 +116,7 @@ findopcode(char *s)
|
|||
i |= (1 << 7); /* mode: keep */
|
||||
else
|
||||
return 0; /* failed to match */
|
||||
++m;
|
||||
m++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ parse(char *w, FILE *f)
|
|||
writeshort(shex(w), 0);
|
||||
/* macro */
|
||||
else if((m = findmacro(w))) {
|
||||
for(i = 0; i < m->len; ++i)
|
||||
for(i = 0; i < m->len; i++)
|
||||
if(!parse(m->items[i], f))
|
||||
return 0;
|
||||
return 1;
|
||||
|
@ -346,7 +346,7 @@ resolve(void)
|
|||
{
|
||||
Label *l;
|
||||
int i;
|
||||
for(i = 0; i < p.rlen; ++i) {
|
||||
for(i = 0; i < p.rlen; i++) {
|
||||
Reference *r = &p.refs[i];
|
||||
switch(r->rune) {
|
||||
case '.':
|
||||
|
@ -399,7 +399,7 @@ static void
|
|||
review(char *filename)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < p.llen; ++i)
|
||||
for(i = 0; i < p.llen; i++)
|
||||
if(p.labels[i].name[0] >= 'A' && p.labels[i].name[0] <= 'Z')
|
||||
continue; /* Ignore capitalized labels(devices) */
|
||||
else if(!p.labels[i].refs)
|
||||
|
|
|
@ -32,8 +32,8 @@ inspect(Stack *s, char *name)
|
|||
{
|
||||
Uint8 x, y;
|
||||
fprintf(stderr, "\n%s\n", name);
|
||||
for(y = 0; y < 0x04; ++y) {
|
||||
for(x = 0; x < 0x08; ++x) {
|
||||
for(y = 0; y < 0x04; y++) {
|
||||
for(x = 0; x < 0x08; x++) {
|
||||
Uint8 p = y * 0x08 + x;
|
||||
fprintf(stderr,
|
||||
p == s->ptr ? "[%02x]" : " %02x ",
|
||||
|
@ -181,7 +181,7 @@ main(int argc, char **argv)
|
|||
/* empty */ uxn_port(&u, 0xe, nil_dei, nil_deo);
|
||||
/* empty */ uxn_port(&u, 0xf, nil_dei, nil_deo);
|
||||
|
||||
for(i = 1; i < argc; ++i) {
|
||||
for(i = 1; i < argc; i++) {
|
||||
if(!loaded++) {
|
||||
if(!load(&u, argv[i]))
|
||||
return error("Load", "Failed");
|
||||
|
|
|
@ -65,7 +65,7 @@ audio_callback(void *u, Uint8 *stream, int len)
|
|||
int i, running = 0;
|
||||
Sint16 *samples = (Sint16 *)stream;
|
||||
SDL_memset(stream, 0, len);
|
||||
for(i = 0; i < POLYPHONY; ++i)
|
||||
for(i = 0; i < POLYPHONY; i++)
|
||||
running += audio_render(&uxn_audio[i], samples, samples + len / 2);
|
||||
if(!running)
|
||||
SDL_PauseAudioDevice(audio_id, 1);
|
||||
|
@ -520,7 +520,7 @@ main(int argc, char **argv)
|
|||
/* set default zoom */
|
||||
if(SDL_GetCurrentDisplayMode(0, &DM) == 0)
|
||||
set_zoom(DM.w / 1280);
|
||||
for(i = 1; i < argc; ++i) {
|
||||
for(i = 1; i < argc; i++) {
|
||||
/* get default zoom from flags */
|
||||
if(strcmp(argv[i], "-s") == 0) {
|
||||
if(i < argc - 1)
|
||||
|
|
Loading…
Reference in a new issue