commit a450959e9f8a6aa72eceb36c781a57603684de0a
parent 6d0b51fa7f99a59f20e62c0e3ce2166b09f7faf9
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date: Sun, 1 Jan 2023 18:26:28 -0800
Removed extraneous j variable
Diffstat:
3 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/build.sh b/build.sh
@@ -46,8 +46,6 @@ rm -f ./bin/*
if [ $format = 1 ];
then
echo "Formatting.."
- clang-format -i src/uxn.h
- clang-format -i src/uxn.c
clang-format -i src/devices/system.h
clang-format -i src/devices/system.c
clang-format -i src/devices/screen.h
diff --git a/src/uxn.c b/src/uxn.c
@@ -11,18 +11,16 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
-/* clang-format off */
-
/* a,b,c: general use. bs: byte/short bool. src, dst: stack ptrs, swapped in return mode.
pc: program counter. sp: ptr to src stack ptr. kptr: "keep" mode copy of src stack ptr.
- x,y: macro in params. d: macro in device. j,k,dev: macro temp variables. o: macro out param. */
+ x,y: macro in params. d: macro in device. j: macro temp variables. o: macro out param. */
#define HALT(c) { return uxn_halt(u, instr, (c), pc - 1); }
#define LITERAL { if(bs) { PEEK16(a, pc) PUSH16(src, a) pc += 2; } else { a = u->ram[pc]; PUSH8(src, a) pc += 1; } }
#define CALL { if(bs){ PEEK16(a, pc) PUSH16(u->rst, pc + 2) pc = a; } else { a = u->ram[pc]; PUSH16(u->rst, pc + 1) pc += (Sint8)a + 2; } }
#define JUMP(x) { if(bs) pc = (x); else pc += (Sint8)(x); }
#define PUSH8(s, x) { if(s->ptr == 0xff) HALT(2) s->dat[s->ptr++] = (x); }
-#define PUSH16(s, x) { if((j = s->ptr) >= 0xfe) HALT(2) k = (x); s->dat[j] = k >> 8; s->dat[j + 1] = k; s->ptr = j + 2; }
+#define PUSH16(s, x) { if((j = s->ptr) >= 0xfe) HALT(2) s->dat[j] = (x) >> 8; s->dat[j + 1] = (x); s->ptr = j + 2; }
#define PUSH(s, x) { if(bs) { PUSH16(s, (x)) } else { PUSH8(s, (x)) } }
#define POP8(o) { if(!(j = *sp)) HALT(1) o = (Uint16)src->dat[--j]; *sp = j; }
#define POP16(o) { if((j = *sp) <= 1) HALT(1) o = src->dat[j - 1]; o += src->dat[j - 2] << 8; *sp = j - 2; }
@@ -36,7 +34,7 @@ WITH REGARD TO THIS SOFTWARE.
int
uxn_eval(Uxn *u, Uint16 pc)
{
- unsigned int a, b, c, j, k, bs, instr;
+ unsigned int a, b, c, j, bs, instr;
Uint8 kptr, *sp;
Stack *src, *dst;
if(!pc || u->dev[0x0f]) return 0;
@@ -87,8 +85,6 @@ uxn_eval(Uxn *u, Uint16 pc)
return 1;
}
-/* clang-format on */
-
int
uxn_boot(Uxn *u, Uint8 *ram, Dei *dei, Deo *deo)
{
diff --git a/src/uxn.h b/src/uxn.h
@@ -39,6 +39,6 @@ typedef struct Uxn {
typedef Uint8 Dei(Uxn *u, Uint8 addr);
typedef void Deo(Uxn *u, Uint8 addr, Uint8 value);
+int uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr);
int uxn_boot(Uxn *u, Uint8 *ram, Dei *dei, Deo *deo);
int uxn_eval(Uxn *u, Uint16 pc);
-int uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr);