diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 42 | ||||
-rw-r--r-- | src/uxn/devices/ppu.c | 50 | ||||
-rw-r--r-- | src/uxn/devices/ppu.h | 20 | ||||
-rw-r--r-- | src/uxn/uxn.c | 558 | ||||
-rw-r--r-- | src/uxn/uxn.h | 37 | ||||
-rw-r--r-- | src/uxn/uxn/opcodes.c | 373 |
6 files changed, 346 insertions, 734 deletions
@@ -45,7 +45,7 @@ static Device *devmouse; | |||
45 | static Mouse mouse = {SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2}; | 45 | static Mouse mouse = {SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2}; |
46 | 46 | ||
47 | void | 47 | void |
48 | nil_talk(Device *d, Uint8 b0, Uint8 w) { | 48 | nil_talk(Device *d, u8 b0, u8 w) { |
49 | (void)d; | 49 | (void)d; |
50 | (void)b0; | 50 | (void)b0; |
51 | (void)w; | 51 | (void)w; |
@@ -66,50 +66,50 @@ console_talk(Device *d, u8 b0, u8 w) { | |||
66 | } | 66 | } |
67 | 67 | ||
68 | void | 68 | void |
69 | system_talk(Device *d, Uint8 b0, Uint8 w) { | 69 | system_talk(Device *d, u8 b0, u8 w) { |
70 | if(!w) { | 70 | if(!w) { |
71 | d->dat[0x2] = d->u->wst.ptr; | 71 | d->dat[0x2] = d->u->wst.ptr; |
72 | d->dat[0x3] = d->u->rst.ptr; | 72 | d->dat[0x3] = d->u->rst.ptr; |
73 | } else { | 73 | } else { |
74 | putcolors(&ppu, &d->dat[0x8]); | 74 | putcolors(&d->dat[0x8]); |
75 | } | 75 | } |
76 | (void)b0; | 76 | (void)b0; |
77 | } | 77 | } |
78 | 78 | ||
79 | IWRAM_CODE | 79 | IWRAM_CODE |
80 | void | 80 | void |
81 | screen_talk(Device *d, Uint8 b0, Uint8 w) { | 81 | screen_talk(Device *d, u8 b0, u8 w) { |
82 | if(w && b0 == 0xe) { | 82 | if(w && b0 == 0xe) { |
83 | Uint16 x = mempeek16(d->dat, 0x8); | 83 | u16 x = mempeek16(d->dat, 0x8); |
84 | Uint16 y = mempeek16(d->dat, 0xa); | 84 | u16 y = mempeek16(d->dat, 0xa); |
85 | Uint8 *addr = &d->mem[mempeek16(d->dat, 0xc)]; | 85 | u8 *addr = &d->mem[mempeek16(d->dat, 0xc)]; |
86 | Uint8 *layer = d->dat[0xe] >> 4 & 0x1 ? ppu.fg : ppu.bg; | 86 | u8 *layer = d->dat[0xe] >> 4 & 0x1 ? ppu.fg : ppu.bg; |
87 | Uint8 mode = d->dat[0xe] >> 5; | 87 | u8 mode = d->dat[0xe] >> 5; |
88 | if(!mode) { | 88 | if(!mode) { |
89 | putpixel(&ppu, layer, x, y, d->dat[0xe] & 0x3); | 89 | putpixel(layer, x, y, d->dat[0xe] & 0x3); |
90 | } else if(mode-- & 0x1) { | 90 | } else if(mode-- & 0x1) { |
91 | puticn(&ppu, layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4); | 91 | puticn(layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4); |
92 | } else { | 92 | } else { |
93 | putchr(&ppu, layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4); | 93 | putchr(layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | void | 98 | void |
99 | datetime_talk(Device *d, Uint8 b0, Uint8 w) { | 99 | datetime_talk(Device *d, u8 b0, u8 w) { |
100 | (void)d; | 100 | (void)d; |
101 | (void)b0; | 101 | (void)b0; |
102 | (void)w; | 102 | (void)w; |
103 | } | 103 | } |
104 | 104 | ||
105 | void | 105 | void |
106 | file_talk(Device *d, Uint8 b0, Uint8 w) { | 106 | file_talk(Device *d, u8 b0, u8 w) { |
107 | Uint8 read = b0 == 0xd; | 107 | u8 read = b0 == 0xd; |
108 | if(w && (read || b0 == 0xf)) { | 108 | if(w && (read || b0 == 0xf)) { |
109 | char *name = (char *)&d->mem[mempeek16(d->dat, 0x8)]; | 109 | char *name = (char *)&d->mem[mempeek16(d->dat, 0x8)]; |
110 | Uint16 result = 0, length = mempeek16(d->dat, 0xa); | 110 | u16 result = 0, length = mempeek16(d->dat, 0xa); |
111 | Uint16 offset = mempeek16(d->dat, 0x4); | 111 | u16 offset = mempeek16(d->dat, 0x4); |
112 | Uint16 addr = mempeek16(d->dat, b0 - 1); | 112 | u16 addr = mempeek16(d->dat, b0 - 1); |
113 | int file_idx = fs_open_file(name, read ? OPEN_READ : OPEN_WRITE); | 113 | int file_idx = fs_open_file(name, read ? OPEN_READ : OPEN_WRITE); |
114 | if (file_idx >= 0) { | 114 | if (file_idx >= 0) { |
115 | if (read) { | 115 | if (read) { |
@@ -177,7 +177,7 @@ handle_input(Uxn *u) { | |||
177 | if (control_method == CONTROL_CONTROLLER) { | 177 | if (control_method == CONTROL_CONTROLLER) { |
178 | // TODO: We don't need ifs if we use KEY_INPUTS directly and mayvbe just | 178 | // TODO: We don't need ifs if we use KEY_INPUTS directly and mayvbe just |
179 | // swap some things if needed. | 179 | // swap some things if needed. |
180 | Uint8 *flag = &devctrl->dat[2]; | 180 | u8 *flag = &devctrl->dat[2]; |
181 | if (key_pressed(KEY_A)) { | 181 | if (key_pressed(KEY_A)) { |
182 | *flag |= 0x01; | 182 | *flag |= 0x01; |
183 | } else { | 183 | } else { |
@@ -223,7 +223,7 @@ handle_input(Uxn *u) { | |||
223 | devctrl->dat[3] = 0; | 223 | devctrl->dat[3] = 0; |
224 | } else if (control_method == CONTROL_MOUSE) { | 224 | } else if (control_method == CONTROL_MOUSE) { |
225 | // Detect "mouse key press". | 225 | // Detect "mouse key press". |
226 | Uint8 flag = devmouse->dat[6]; | 226 | u8 flag = devmouse->dat[6]; |
227 | if (key_tap(KEY_B)) { | 227 | if (key_tap(KEY_B)) { |
228 | flag |= 0x01; | 228 | flag |= 0x01; |
229 | } else if (key_released(KEY_B)) { | 229 | } else if (key_released(KEY_B)) { |
@@ -265,7 +265,7 @@ handle_input(Uxn *u) { | |||
265 | 265 | ||
266 | static Uxn u; | 266 | static Uxn u; |
267 | EWRAM_BSS | 267 | EWRAM_BSS |
268 | static Uint8 umem[65536]; | 268 | static u8 umem[65536]; |
269 | 269 | ||
270 | int main(void) { | 270 | int main(void) { |
271 | // Initialize filesystem. | 271 | // Initialize filesystem. |
diff --git a/src/uxn/devices/ppu.c b/src/uxn/devices/ppu.c index 4db8c77..02267f0 100644 --- a/src/uxn/devices/ppu.c +++ b/src/uxn/devices/ppu.c | |||
@@ -20,7 +20,7 @@ WITH REGARD TO THIS SOFTWARE. | |||
20 | #define BG_BACK ((u32*)(MEM_VRAM + KB(64))) | 20 | #define BG_BACK ((u32*)(MEM_VRAM + KB(64))) |
21 | #define TILE_MAP ((u32*)(MEM_VRAM + KB(40))) | 21 | #define TILE_MAP ((u32*)(MEM_VRAM + KB(40))) |
22 | 22 | ||
23 | static Uint32 unpack_icon_lut[256] = { | 23 | static u32 unpack_icon_lut[256] = { |
24 | 0x00000000, 0x00000001, 0x00000010, 0x00000011, 0x00000100, | 24 | 0x00000000, 0x00000001, 0x00000010, 0x00000011, 0x00000100, |
25 | 0x00000101, 0x00000110, 0x00000111, 0x00001000, 0x00001001, | 25 | 0x00000101, 0x00000110, 0x00000111, 0x00001000, 0x00001001, |
26 | 0x00001010, 0x00001011, 0x00001100, 0x00001101, 0x00001110, | 26 | 0x00001010, 0x00001011, 0x00001100, 0x00001101, 0x00001110, |
@@ -75,7 +75,7 @@ static Uint32 unpack_icon_lut[256] = { | |||
75 | 0x11111111 | 75 | 0x11111111 |
76 | }; | 76 | }; |
77 | 77 | ||
78 | static Uint32 unpack_icon_lut_flipx[256] = { | 78 | static u32 unpack_icon_lut_flipx[256] = { |
79 | 0x00000000, 0x10000000, 0x01000000, 0x11000000, 0x00100000, | 79 | 0x00000000, 0x10000000, 0x01000000, 0x11000000, 0x00100000, |
80 | 0x10100000, 0x01100000, 0x11100000, 0x00010000, 0x10010000, | 80 | 0x10100000, 0x01100000, 0x11100000, 0x00010000, 0x10010000, |
81 | 0x01010000, 0x11010000, 0x00110000, 0x10110000, 0x01110000, | 81 | 0x01010000, 0x11010000, 0x00110000, 0x10110000, 0x01110000, |
@@ -133,10 +133,10 @@ static Uint32 unpack_icon_lut_flipx[256] = { | |||
133 | static u32 dirty_tiles[21] = {0}; | 133 | static u32 dirty_tiles[21] = {0}; |
134 | 134 | ||
135 | void | 135 | void |
136 | putcolors(Ppu *p, Uint8 *addr) { | 136 | putcolors(u8 *addr) { |
137 | int i; | 137 | int i; |
138 | for(i = 0; i < 4; ++i) { | 138 | for(i = 0; i < 4; ++i) { |
139 | Uint8 | 139 | u8 |
140 | r = (*(addr + i / 2) >> (!(i % 2) << 2)) & 0x0f, | 140 | r = (*(addr + i / 2) >> (!(i % 2) << 2)) & 0x0f, |
141 | g = (*(addr + 2 + i / 2) >> (!(i % 2) << 2)) & 0x0f, | 141 | g = (*(addr + 2 + i / 2) >> (!(i % 2) << 2)) & 0x0f, |
142 | b = (*(addr + 4 + i / 2) >> (!(i % 2) << 2)) & 0x0f; | 142 | b = (*(addr + 4 + i / 2) >> (!(i % 2) << 2)) & 0x0f; |
@@ -145,12 +145,11 @@ putcolors(Ppu *p, Uint8 *addr) { | |||
145 | (g << 1) | (g >> 3), | 145 | (g << 1) | (g >> 3), |
146 | (b << 1) | (b >> 3)); | 146 | (b << 1) | (b >> 3)); |
147 | } | 147 | } |
148 | (void)p; | ||
149 | } | 148 | } |
150 | 149 | ||
151 | IWRAM_CODE | 150 | IWRAM_CODE |
152 | void | 151 | void |
153 | putpixel(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 color) { | 152 | putpixel(u32 *layer, u16 x, u16 y, u8 color) { |
154 | if (x >= SCREEN_WIDTH || y >= SCREEN_HEIGHT) return; | 153 | if (x >= SCREEN_WIDTH || y >= SCREEN_HEIGHT) return; |
155 | size_t tile_x = x / 8; | 154 | size_t tile_x = x / 8; |
156 | size_t tile_y = y / 8; | 155 | size_t tile_y = y / 8; |
@@ -160,20 +159,19 @@ putpixel(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 color) { | |||
160 | size_t shift = start_col * 4; | 159 | size_t shift = start_col * 4; |
161 | layer[pos] = (layer[pos] & (~(0xF << shift))) | (color << shift); | 160 | layer[pos] = (layer[pos] & (~(0xF << shift))) | (color << shift); |
162 | dirty_tiles[tile_y] |= 1 << tile_x; | 161 | dirty_tiles[tile_y] |= 1 << tile_x; |
163 | (void)p; | ||
164 | } | 162 | } |
165 | 163 | ||
166 | IWRAM_CODE | 164 | IWRAM_CODE |
167 | void | 165 | void |
168 | puticn(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy) { | 166 | puticn(u32 *layer, u16 x, u16 y, u8 *sprite, u8 color, u8 flipx, u8 flipy) { |
169 | Uint8 sprline; | 167 | u8 sprline; |
170 | Uint16 v; | 168 | u16 v; |
171 | Uint32 dirtyflag = (1 << (x >> 3)) | (1 << ((x + 7) >> 3)); | 169 | u32 dirtyflag = (1 << (x >> 3)) | (1 << ((x + 7) >> 3)); |
172 | 170 | ||
173 | Uint32 layerpos = ((y & 7) + (((x >> 3) + (y >> 3) * 32) * 8)); | 171 | u32 layerpos = ((y & 7) + (((x >> 3) + (y >> 3) * 32) * 8)); |
174 | Uint32 *layerptr = &layer[layerpos]; | 172 | u32 *layerptr = &layer[layerpos]; |
175 | Uint32 shift = (x & 7) << 2; | 173 | u32 shift = (x & 7) << 2; |
176 | Uint32 *lut_expand = flipx ? unpack_icon_lut : unpack_icon_lut_flipx; | 174 | u32 *lut_expand = flipx ? unpack_icon_lut : unpack_icon_lut_flipx; |
177 | 175 | ||
178 | if (flipy) flipy = 7; | 176 | if (flipy) flipy = 7; |
179 | 177 | ||
@@ -211,21 +209,20 @@ puticn(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Ui | |||
211 | 209 | ||
212 | dirty_tiles[y >> 3] |= dirtyflag; | 210 | dirty_tiles[y >> 3] |= dirtyflag; |
213 | dirty_tiles[(y + 7) >> 3] |= dirtyflag; | 211 | dirty_tiles[(y + 7) >> 3] |= dirtyflag; |
214 | (void)p; | ||
215 | } | 212 | } |
216 | 213 | ||
217 | IWRAM_CODE | 214 | IWRAM_CODE |
218 | void | 215 | void |
219 | putchr(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, | 216 | putchr(u32 *layer, u16 x, u16 y, u8 *sprite, u8 color, |
220 | Uint8 flipx, Uint8 flipy) { | 217 | u8 flipx, u8 flipy) { |
221 | Uint8 sprline1, sprline2; | 218 | u8 sprline1, sprline2; |
222 | Uint16 v; | 219 | u16 v; |
223 | Uint32 dirtyflag = (1 << (x >> 3)) | (1 << ((x + 7) >> 3)); | 220 | u32 dirtyflag = (1 << (x >> 3)) | (1 << ((x + 7) >> 3)); |
224 | 221 | ||
225 | Uint32 layerpos = ((y & 7) + (((x >> 3) + (y >> 3) * 32) * 8)); | 222 | u32 layerpos = ((y & 7) + (((x >> 3) + (y >> 3) * 32) * 8)); |
226 | Uint32 *layerptr = &layer[layerpos]; | 223 | u32 *layerptr = &layer[layerpos]; |
227 | Uint32 shift = (x & 7) << 2; | 224 | u32 shift = (x & 7) << 2; |
228 | Uint32 *lut_expand = flipx ? unpack_icon_lut : unpack_icon_lut_flipx; | 225 | u32 *lut_expand = flipx ? unpack_icon_lut : unpack_icon_lut_flipx; |
229 | 226 | ||
230 | if (flipy) flipy = 7; | 227 | if (flipy) flipy = 7; |
231 | 228 | ||
@@ -254,7 +251,6 @@ putchr(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, | |||
254 | 251 | ||
255 | dirty_tiles[y >> 3] |= dirtyflag; | 252 | dirty_tiles[y >> 3] |= dirtyflag; |
256 | dirty_tiles[(y + 7) >> 3] |= dirtyflag; | 253 | dirty_tiles[(y + 7) >> 3] |= dirtyflag; |
257 | (void)p; | ||
258 | } | 254 | } |
259 | 255 | ||
260 | IWRAM_CODE | 256 | IWRAM_CODE |
@@ -281,7 +277,7 @@ flipbuf(Ppu *p) { | |||
281 | } | 277 | } |
282 | 278 | ||
283 | int | 279 | int |
284 | initppu(Ppu *p, Uint8 hor, Uint8 ver, Uint8 pad) { | 280 | initppu(Ppu *p, u8 hor, u8 ver, u8 pad) { |
285 | p->hor = hor; | 281 | p->hor = hor; |
286 | p->ver = ver; | 282 | p->ver = ver; |
287 | p->pad = pad; | 283 | p->pad = pad; |
diff --git a/src/uxn/devices/ppu.h b/src/uxn/devices/ppu.h index 213dc75..0356b63 100644 --- a/src/uxn/devices/ppu.h +++ b/src/uxn/devices/ppu.h | |||
@@ -17,20 +17,14 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |||
17 | WITH REGARD TO THIS SOFTWARE. | 17 | WITH REGARD TO THIS SOFTWARE. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | typedef unsigned char Uint8; | ||
21 | typedef unsigned short Uint16; | ||
22 | typedef unsigned int Uint32; | ||
23 | |||
24 | typedef struct Ppu { | 20 | typedef struct Ppu { |
25 | Uint32 *bg, *fg; | 21 | u32 *bg, *fg; |
26 | Uint16 hor, ver, pad, width, height; | 22 | u16 hor, ver, pad, width, height; |
27 | } Ppu; | 23 | } Ppu; |
28 | 24 | ||
29 | int initppu(Ppu *p, Uint8 hor, Uint8 ver, Uint8 pad); | 25 | int initppu(Ppu *p, u8 hor, u8 ver, u8 pad); |
30 | void putcolors(Ppu *p, Uint8 *addr); | 26 | void putcolors(u8 *addr); |
31 | void putpixel(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 color); | 27 | void putpixel(u32 *layer, u16 x, u16 y, u8 color); |
32 | void puticn(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy); | 28 | void puticn(u32 *layer, u16 x, u16 y, u8 *sprite, u8 color, u8 flipx, u8 flipy); |
33 | void putchr(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy); | 29 | void putchr(u32 *layer, u16 x, u16 y, u8 *sprite, u8 color, u8 flipx, u8 flipy); |
34 | void drawppu(Ppu *p); | ||
35 | void drawdebugger(Ppu *p, Uint8 *stack, Uint8 ptr); | ||
36 | #endif // UXNGBA_PPU_H | 30 | #endif // UXNGBA_PPU_H |
diff --git a/src/uxn/uxn.c b/src/uxn/uxn.c index e8ae9f7..2b541d1 100644 --- a/src/uxn/uxn.c +++ b/src/uxn/uxn.c | |||
@@ -17,9 +17,9 @@ WITH REGARD TO THIS SOFTWARE. | |||
17 | 17 | ||
18 | IWRAM_CODE | 18 | IWRAM_CODE |
19 | int | 19 | int |
20 | evaluxn(Uxn *u, Uint16 vec) | 20 | evaluxn(Uxn *u, u16 vec) |
21 | { | 21 | { |
22 | Uint8 instr; | 22 | u8 instr; |
23 | u->ram.ptr = vec; | 23 | u->ram.ptr = vec; |
24 | while(u->ram.ptr) { | 24 | while(u->ram.ptr) { |
25 | instr = u->ram.dat[u->ram.ptr++]; | 25 | instr = u->ram.dat[u->ram.ptr++]; |
@@ -77,7 +77,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
77 | } | 77 | } |
78 | case 0x04: /* DUP */ | 78 | case 0x04: /* DUP */ |
79 | { | 79 | { |
80 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 80 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
81 | u->wst.dat[u->wst.ptr - 1] = a; | 81 | u->wst.dat[u->wst.ptr - 1] = a; |
82 | u->wst.dat[u->wst.ptr] = a; | 82 | u->wst.dat[u->wst.ptr] = a; |
83 | #ifndef NO_STACK_CHECKS | 83 | #ifndef NO_STACK_CHECKS |
@@ -95,7 +95,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
95 | } | 95 | } |
96 | case 0x05: /* SWP */ | 96 | case 0x05: /* SWP */ |
97 | { | 97 | { |
98 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 98 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
99 | u->wst.dat[u->wst.ptr - 2] = a; | 99 | u->wst.dat[u->wst.ptr - 2] = a; |
100 | u->wst.dat[u->wst.ptr - 1] = b; | 100 | u->wst.dat[u->wst.ptr - 1] = b; |
101 | #ifndef NO_STACK_CHECKS | 101 | #ifndef NO_STACK_CHECKS |
@@ -108,7 +108,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
108 | } | 108 | } |
109 | case 0x06: /* OVR */ | 109 | case 0x06: /* OVR */ |
110 | { | 110 | { |
111 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 111 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
112 | u->wst.dat[u->wst.ptr - 2] = b; | 112 | u->wst.dat[u->wst.ptr - 2] = b; |
113 | u->wst.dat[u->wst.ptr - 1] = a; | 113 | u->wst.dat[u->wst.ptr - 1] = a; |
114 | u->wst.dat[u->wst.ptr] = b; | 114 | u->wst.dat[u->wst.ptr] = b; |
@@ -127,7 +127,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
127 | } | 127 | } |
128 | case 0x07: /* ROT */ | 128 | case 0x07: /* ROT */ |
129 | { | 129 | { |
130 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3]; | 130 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3]; |
131 | u->wst.dat[u->wst.ptr - 3] = b; | 131 | u->wst.dat[u->wst.ptr - 3] = b; |
132 | u->wst.dat[u->wst.ptr - 2] = a; | 132 | u->wst.dat[u->wst.ptr - 2] = a; |
133 | u->wst.dat[u->wst.ptr - 1] = c; | 133 | u->wst.dat[u->wst.ptr - 1] = c; |
@@ -141,7 +141,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
141 | } | 141 | } |
142 | case 0x08: /* EQU */ | 142 | case 0x08: /* EQU */ |
143 | { | 143 | { |
144 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 144 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
145 | u->wst.dat[u->wst.ptr - 2] = b == a; | 145 | u->wst.dat[u->wst.ptr - 2] = b == a; |
146 | #ifndef NO_STACK_CHECKS | 146 | #ifndef NO_STACK_CHECKS |
147 | if(u->wst.ptr < 2) { | 147 | if(u->wst.ptr < 2) { |
@@ -154,7 +154,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
154 | } | 154 | } |
155 | case 0x09: /* NEQ */ | 155 | case 0x09: /* NEQ */ |
156 | { | 156 | { |
157 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 157 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
158 | u->wst.dat[u->wst.ptr - 2] = b != a; | 158 | u->wst.dat[u->wst.ptr - 2] = b != a; |
159 | #ifndef NO_STACK_CHECKS | 159 | #ifndef NO_STACK_CHECKS |
160 | if(u->wst.ptr < 2) { | 160 | if(u->wst.ptr < 2) { |
@@ -167,7 +167,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
167 | } | 167 | } |
168 | case 0x0a: /* GTH */ | 168 | case 0x0a: /* GTH */ |
169 | { | 169 | { |
170 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 170 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
171 | u->wst.dat[u->wst.ptr - 2] = b > a; | 171 | u->wst.dat[u->wst.ptr - 2] = b > a; |
172 | #ifndef NO_STACK_CHECKS | 172 | #ifndef NO_STACK_CHECKS |
173 | if(u->wst.ptr < 2) { | 173 | if(u->wst.ptr < 2) { |
@@ -180,7 +180,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
180 | } | 180 | } |
181 | case 0x0b: /* LTH */ | 181 | case 0x0b: /* LTH */ |
182 | { | 182 | { |
183 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 183 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
184 | u->wst.dat[u->wst.ptr - 2] = b < a; | 184 | u->wst.dat[u->wst.ptr - 2] = b < a; |
185 | #ifndef NO_STACK_CHECKS | 185 | #ifndef NO_STACK_CHECKS |
186 | if(u->wst.ptr < 2) { | 186 | if(u->wst.ptr < 2) { |
@@ -193,8 +193,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
193 | } | 193 | } |
194 | case 0x0c: /* JMP */ | 194 | case 0x0c: /* JMP */ |
195 | { | 195 | { |
196 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 196 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
197 | u->ram.ptr += (Sint8)a; | 197 | u->ram.ptr += (s8)a; |
198 | #ifndef NO_STACK_CHECKS | 198 | #ifndef NO_STACK_CHECKS |
199 | if(u->wst.ptr < 1) { | 199 | if(u->wst.ptr < 1) { |
200 | u->wst.error = 1; | 200 | u->wst.error = 1; |
@@ -206,8 +206,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
206 | } | 206 | } |
207 | case 0x0d: /* JCN */ | 207 | case 0x0d: /* JCN */ |
208 | { | 208 | { |
209 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 209 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
210 | if(u->wst.dat[u->wst.ptr - 2]) u->ram.ptr += (Sint8)a; | 210 | if(u->wst.dat[u->wst.ptr - 2]) u->ram.ptr += (s8)a; |
211 | #ifndef NO_STACK_CHECKS | 211 | #ifndef NO_STACK_CHECKS |
212 | if(u->wst.ptr < 2) { | 212 | if(u->wst.ptr < 2) { |
213 | u->wst.error = 1; | 213 | u->wst.error = 1; |
@@ -219,10 +219,10 @@ evaluxn(Uxn *u, Uint16 vec) | |||
219 | } | 219 | } |
220 | case 0x0e: /* JSR */ | 220 | case 0x0e: /* JSR */ |
221 | { | 221 | { |
222 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 222 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
223 | u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; | 223 | u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; |
224 | u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; | 224 | u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; |
225 | u->ram.ptr += (Sint8)a; | 225 | u->ram.ptr += (s8)a; |
226 | #ifndef NO_STACK_CHECKS | 226 | #ifndef NO_STACK_CHECKS |
227 | if(u->wst.ptr < 1) { | 227 | if(u->wst.ptr < 1) { |
228 | u->wst.error = 1; | 228 | u->wst.error = 1; |
@@ -241,7 +241,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
241 | } | 241 | } |
242 | case 0x0f: /* STH */ | 242 | case 0x0f: /* STH */ |
243 | { | 243 | { |
244 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 244 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
245 | u->rst.dat[u->rst.ptr] = a; | 245 | u->rst.dat[u->rst.ptr] = a; |
246 | #ifndef NO_STACK_CHECKS | 246 | #ifndef NO_STACK_CHECKS |
247 | if(u->wst.ptr < 1) { | 247 | if(u->wst.ptr < 1) { |
@@ -261,7 +261,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
261 | } | 261 | } |
262 | case 0x10: /* LDZ */ | 262 | case 0x10: /* LDZ */ |
263 | { | 263 | { |
264 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 264 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
265 | u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, a); | 265 | u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, a); |
266 | #ifndef NO_STACK_CHECKS | 266 | #ifndef NO_STACK_CHECKS |
267 | if(u->wst.ptr < 1) { | 267 | if(u->wst.ptr < 1) { |
@@ -273,8 +273,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
273 | } | 273 | } |
274 | case 0x11: /* STZ */ | 274 | case 0x11: /* STZ */ |
275 | { | 275 | { |
276 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 276 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
277 | Uint8 b = u->wst.dat[u->wst.ptr - 2]; | 277 | u8 b = u->wst.dat[u->wst.ptr - 2]; |
278 | mempoke8(u->ram.dat, a, b); | 278 | mempoke8(u->ram.dat, a, b); |
279 | #ifndef NO_STACK_CHECKS | 279 | #ifndef NO_STACK_CHECKS |
280 | if(u->wst.ptr < 2) { | 280 | if(u->wst.ptr < 2) { |
@@ -287,8 +287,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
287 | } | 287 | } |
288 | case 0x12: /* LDR */ | 288 | case 0x12: /* LDR */ |
289 | { | 289 | { |
290 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 290 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
291 | u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); | 291 | u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (s8)a); |
292 | #ifndef NO_STACK_CHECKS | 292 | #ifndef NO_STACK_CHECKS |
293 | if(u->wst.ptr < 1) { | 293 | if(u->wst.ptr < 1) { |
294 | u->wst.error = 1; | 294 | u->wst.error = 1; |
@@ -299,9 +299,9 @@ evaluxn(Uxn *u, Uint16 vec) | |||
299 | } | 299 | } |
300 | case 0x13: /* STR */ | 300 | case 0x13: /* STR */ |
301 | { | 301 | { |
302 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 302 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
303 | Uint8 b = u->wst.dat[u->wst.ptr - 2]; | 303 | u8 b = u->wst.dat[u->wst.ptr - 2]; |
304 | mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); | 304 | mempoke8(u->ram.dat, u->ram.ptr + (s8)a, b); |
305 | #ifndef NO_STACK_CHECKS | 305 | #ifndef NO_STACK_CHECKS |
306 | if(u->wst.ptr < 2) { | 306 | if(u->wst.ptr < 2) { |
307 | u->wst.error = 1; | 307 | u->wst.error = 1; |
@@ -313,7 +313,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
313 | } | 313 | } |
314 | case 0x14: /* LDA */ | 314 | case 0x14: /* LDA */ |
315 | { | 315 | { |
316 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 316 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
317 | u->wst.dat[u->wst.ptr - 2] = mempeek8(u->ram.dat, a); | 317 | u->wst.dat[u->wst.ptr - 2] = mempeek8(u->ram.dat, a); |
318 | #ifndef NO_STACK_CHECKS | 318 | #ifndef NO_STACK_CHECKS |
319 | if(u->wst.ptr < 2) { | 319 | if(u->wst.ptr < 2) { |
@@ -326,8 +326,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
326 | } | 326 | } |
327 | case 0x15: /* STA */ | 327 | case 0x15: /* STA */ |
328 | { | 328 | { |
329 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 329 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
330 | Uint8 b = u->wst.dat[u->wst.ptr - 3]; | 330 | u8 b = u->wst.dat[u->wst.ptr - 3]; |
331 | mempoke8(u->ram.dat, a, b); | 331 | mempoke8(u->ram.dat, a, b); |
332 | #ifndef NO_STACK_CHECKS | 332 | #ifndef NO_STACK_CHECKS |
333 | if(u->wst.ptr < 3) { | 333 | if(u->wst.ptr < 3) { |
@@ -340,7 +340,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
340 | } | 340 | } |
341 | case 0x16: /* DEI */ | 341 | case 0x16: /* DEI */ |
342 | { | 342 | { |
343 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 343 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
344 | u->wst.dat[u->wst.ptr - 1] = devpeek8(&u->dev[a >> 4], a); | 344 | u->wst.dat[u->wst.ptr - 1] = devpeek8(&u->dev[a >> 4], a); |
345 | #ifndef NO_STACK_CHECKS | 345 | #ifndef NO_STACK_CHECKS |
346 | if(u->wst.ptr < 1) { | 346 | if(u->wst.ptr < 1) { |
@@ -352,7 +352,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
352 | } | 352 | } |
353 | case 0x17: /* DEO */ | 353 | case 0x17: /* DEO */ |
354 | { | 354 | { |
355 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 355 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
356 | devpoke8(&u->dev[a >> 4], a, b); | 356 | devpoke8(&u->dev[a >> 4], a, b); |
357 | #ifndef NO_STACK_CHECKS | 357 | #ifndef NO_STACK_CHECKS |
358 | if(u->wst.ptr < 2) { | 358 | if(u->wst.ptr < 2) { |
@@ -365,7 +365,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
365 | } | 365 | } |
366 | case 0x18: /* ADD */ | 366 | case 0x18: /* ADD */ |
367 | { | 367 | { |
368 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 368 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
369 | u->wst.dat[u->wst.ptr - 2] = b + a; | 369 | u->wst.dat[u->wst.ptr - 2] = b + a; |
370 | #ifndef NO_STACK_CHECKS | 370 | #ifndef NO_STACK_CHECKS |
371 | if(u->wst.ptr < 2) { | 371 | if(u->wst.ptr < 2) { |
@@ -378,7 +378,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
378 | } | 378 | } |
379 | case 0x19: /* SUB */ | 379 | case 0x19: /* SUB */ |
380 | { | 380 | { |
381 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 381 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
382 | u->wst.dat[u->wst.ptr - 2] = b - a; | 382 | u->wst.dat[u->wst.ptr - 2] = b - a; |
383 | #ifndef NO_STACK_CHECKS | 383 | #ifndef NO_STACK_CHECKS |
384 | if(u->wst.ptr < 2) { | 384 | if(u->wst.ptr < 2) { |
@@ -391,7 +391,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
391 | } | 391 | } |
392 | case 0x1a: /* MUL */ | 392 | case 0x1a: /* MUL */ |
393 | { | 393 | { |
394 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 394 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
395 | u->wst.dat[u->wst.ptr - 2] = b * a; | 395 | u->wst.dat[u->wst.ptr - 2] = b * a; |
396 | #ifndef NO_STACK_CHECKS | 396 | #ifndef NO_STACK_CHECKS |
397 | if(u->wst.ptr < 2) { | 397 | if(u->wst.ptr < 2) { |
@@ -404,7 +404,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
404 | } | 404 | } |
405 | case 0x1b: /* DIV */ | 405 | case 0x1b: /* DIV */ |
406 | { | 406 | { |
407 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 407 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
408 | u->wst.dat[u->wst.ptr - 2] = b / a; | 408 | u->wst.dat[u->wst.ptr - 2] = b / a; |
409 | #ifndef NO_STACK_CHECKS | 409 | #ifndef NO_STACK_CHECKS |
410 | if(u->wst.ptr < 2) { | 410 | if(u->wst.ptr < 2) { |
@@ -417,7 +417,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
417 | } | 417 | } |
418 | case 0x1c: /* AND */ | 418 | case 0x1c: /* AND */ |
419 | { | 419 | { |
420 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 420 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
421 | u->wst.dat[u->wst.ptr - 2] = b & a; | 421 | u->wst.dat[u->wst.ptr - 2] = b & a; |
422 | #ifndef NO_STACK_CHECKS | 422 | #ifndef NO_STACK_CHECKS |
423 | if(u->wst.ptr < 2) { | 423 | if(u->wst.ptr < 2) { |
@@ -430,7 +430,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
430 | } | 430 | } |
431 | case 0x1d: /* ORA */ | 431 | case 0x1d: /* ORA */ |
432 | { | 432 | { |
433 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 433 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
434 | u->wst.dat[u->wst.ptr - 2] = b | a; | 434 | u->wst.dat[u->wst.ptr - 2] = b | a; |
435 | #ifndef NO_STACK_CHECKS | 435 | #ifndef NO_STACK_CHECKS |
436 | if(u->wst.ptr < 2) { | 436 | if(u->wst.ptr < 2) { |
@@ -443,7 +443,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
443 | } | 443 | } |
444 | case 0x1e: /* EOR */ | 444 | case 0x1e: /* EOR */ |
445 | { | 445 | { |
446 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 446 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
447 | u->wst.dat[u->wst.ptr - 2] = b ^ a; | 447 | u->wst.dat[u->wst.ptr - 2] = b ^ a; |
448 | #ifndef NO_STACK_CHECKS | 448 | #ifndef NO_STACK_CHECKS |
449 | if(u->wst.ptr < 2) { | 449 | if(u->wst.ptr < 2) { |
@@ -456,7 +456,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
456 | } | 456 | } |
457 | case 0x1f: /* SFT */ | 457 | case 0x1f: /* SFT */ |
458 | { | 458 | { |
459 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 459 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
460 | u->wst.dat[u->wst.ptr - 2] = b >> (a & 0x07) << ((a & 0x70) >> 4); | 460 | u->wst.dat[u->wst.ptr - 2] = b >> (a & 0x07) << ((a & 0x70) >> 4); |
461 | #ifndef NO_STACK_CHECKS | 461 | #ifndef NO_STACK_CHECKS |
462 | if(u->wst.ptr < 2) { | 462 | if(u->wst.ptr < 2) { |
@@ -495,7 +495,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
495 | } | 495 | } |
496 | case 0x24: /* DUP2 */ | 496 | case 0x24: /* DUP2 */ |
497 | { | 497 | { |
498 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 498 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
499 | u->wst.dat[u->wst.ptr - 2] = a >> 8; | 499 | u->wst.dat[u->wst.ptr - 2] = a >> 8; |
500 | u->wst.dat[u->wst.ptr - 1] = a & 0xff; | 500 | u->wst.dat[u->wst.ptr - 1] = a & 0xff; |
501 | u->wst.dat[u->wst.ptr] = a >> 8; | 501 | u->wst.dat[u->wst.ptr] = a >> 8; |
@@ -515,7 +515,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
515 | } | 515 | } |
516 | case 0x25: /* SWP2 */ | 516 | case 0x25: /* SWP2 */ |
517 | { | 517 | { |
518 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 518 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
519 | u->wst.dat[u->wst.ptr - 4] = a >> 8; | 519 | u->wst.dat[u->wst.ptr - 4] = a >> 8; |
520 | u->wst.dat[u->wst.ptr - 3] = a & 0xff; | 520 | u->wst.dat[u->wst.ptr - 3] = a & 0xff; |
521 | u->wst.dat[u->wst.ptr - 2] = b >> 8; | 521 | u->wst.dat[u->wst.ptr - 2] = b >> 8; |
@@ -530,7 +530,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
530 | } | 530 | } |
531 | case 0x26: /* OVR2 */ | 531 | case 0x26: /* OVR2 */ |
532 | { | 532 | { |
533 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 533 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
534 | u->wst.dat[u->wst.ptr - 4] = b >> 8; | 534 | u->wst.dat[u->wst.ptr - 4] = b >> 8; |
535 | u->wst.dat[u->wst.ptr - 3] = b & 0xff; | 535 | u->wst.dat[u->wst.ptr - 3] = b & 0xff; |
536 | u->wst.dat[u->wst.ptr - 2] = a >> 8; | 536 | u->wst.dat[u->wst.ptr - 2] = a >> 8; |
@@ -552,7 +552,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
552 | } | 552 | } |
553 | case 0x27: /* ROT2 */ | 553 | case 0x27: /* ROT2 */ |
554 | { | 554 | { |
555 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)), c = (u->wst.dat[u->wst.ptr - 5] | (u->wst.dat[u->wst.ptr - 6] << 8)); | 555 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)), c = (u->wst.dat[u->wst.ptr - 5] | (u->wst.dat[u->wst.ptr - 6] << 8)); |
556 | u->wst.dat[u->wst.ptr - 6] = b >> 8; | 556 | u->wst.dat[u->wst.ptr - 6] = b >> 8; |
557 | u->wst.dat[u->wst.ptr - 5] = b & 0xff; | 557 | u->wst.dat[u->wst.ptr - 5] = b & 0xff; |
558 | u->wst.dat[u->wst.ptr - 4] = a >> 8; | 558 | u->wst.dat[u->wst.ptr - 4] = a >> 8; |
@@ -569,7 +569,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
569 | } | 569 | } |
570 | case 0x28: /* EQU2 */ | 570 | case 0x28: /* EQU2 */ |
571 | { | 571 | { |
572 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 572 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
573 | u->wst.dat[u->wst.ptr - 4] = b == a; | 573 | u->wst.dat[u->wst.ptr - 4] = b == a; |
574 | #ifndef NO_STACK_CHECKS | 574 | #ifndef NO_STACK_CHECKS |
575 | if(u->wst.ptr < 4) { | 575 | if(u->wst.ptr < 4) { |
@@ -582,7 +582,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
582 | } | 582 | } |
583 | case 0x29: /* NEQ2 */ | 583 | case 0x29: /* NEQ2 */ |
584 | { | 584 | { |
585 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 585 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
586 | u->wst.dat[u->wst.ptr - 4] = b != a; | 586 | u->wst.dat[u->wst.ptr - 4] = b != a; |
587 | #ifndef NO_STACK_CHECKS | 587 | #ifndef NO_STACK_CHECKS |
588 | if(u->wst.ptr < 4) { | 588 | if(u->wst.ptr < 4) { |
@@ -595,7 +595,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
595 | } | 595 | } |
596 | case 0x2a: /* GTH2 */ | 596 | case 0x2a: /* GTH2 */ |
597 | { | 597 | { |
598 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 598 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
599 | u->wst.dat[u->wst.ptr - 4] = b > a; | 599 | u->wst.dat[u->wst.ptr - 4] = b > a; |
600 | #ifndef NO_STACK_CHECKS | 600 | #ifndef NO_STACK_CHECKS |
601 | if(u->wst.ptr < 4) { | 601 | if(u->wst.ptr < 4) { |
@@ -608,7 +608,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
608 | } | 608 | } |
609 | case 0x2b: /* LTH2 */ | 609 | case 0x2b: /* LTH2 */ |
610 | { | 610 | { |
611 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 611 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
612 | u->wst.dat[u->wst.ptr - 4] = b < a; | 612 | u->wst.dat[u->wst.ptr - 4] = b < a; |
613 | #ifndef NO_STACK_CHECKS | 613 | #ifndef NO_STACK_CHECKS |
614 | if(u->wst.ptr < 4) { | 614 | if(u->wst.ptr < 4) { |
@@ -633,7 +633,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
633 | } | 633 | } |
634 | case 0x2d: /* JCN2 */ | 634 | case 0x2d: /* JCN2 */ |
635 | { | 635 | { |
636 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 636 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
637 | if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a; | 637 | if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a; |
638 | #ifndef NO_STACK_CHECKS | 638 | #ifndef NO_STACK_CHECKS |
639 | if(u->wst.ptr < 3) { | 639 | if(u->wst.ptr < 3) { |
@@ -667,7 +667,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
667 | } | 667 | } |
668 | case 0x2f: /* STH2 */ | 668 | case 0x2f: /* STH2 */ |
669 | { | 669 | { |
670 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 670 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
671 | u->rst.dat[u->rst.ptr] = a >> 8; | 671 | u->rst.dat[u->rst.ptr] = a >> 8; |
672 | u->rst.dat[u->rst.ptr + 1] = a & 0xff; | 672 | u->rst.dat[u->rst.ptr + 1] = a & 0xff; |
673 | #ifndef NO_STACK_CHECKS | 673 | #ifndef NO_STACK_CHECKS |
@@ -688,7 +688,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
688 | } | 688 | } |
689 | case 0x30: /* LDZ2 */ | 689 | case 0x30: /* LDZ2 */ |
690 | { | 690 | { |
691 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 691 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
692 | u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, a); | 692 | u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, a); |
693 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a + 1); | 693 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a + 1); |
694 | #ifndef NO_STACK_CHECKS | 694 | #ifndef NO_STACK_CHECKS |
@@ -706,8 +706,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
706 | } | 706 | } |
707 | case 0x31: /* STZ2 */ | 707 | case 0x31: /* STZ2 */ |
708 | { | 708 | { |
709 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 709 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
710 | Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); | 710 | u16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
711 | mempoke16(u->ram.dat, a, b); | 711 | mempoke16(u->ram.dat, a, b); |
712 | #ifndef NO_STACK_CHECKS | 712 | #ifndef NO_STACK_CHECKS |
713 | if(u->wst.ptr < 3) { | 713 | if(u->wst.ptr < 3) { |
@@ -720,9 +720,9 @@ evaluxn(Uxn *u, Uint16 vec) | |||
720 | } | 720 | } |
721 | case 0x32: /* LDR2 */ | 721 | case 0x32: /* LDR2 */ |
722 | { | 722 | { |
723 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 723 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
724 | u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); | 724 | u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (s8)a); |
725 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); | 725 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (s8)a + 1); |
726 | #ifndef NO_STACK_CHECKS | 726 | #ifndef NO_STACK_CHECKS |
727 | if(u->wst.ptr < 1) { | 727 | if(u->wst.ptr < 1) { |
728 | u->wst.error = 1; | 728 | u->wst.error = 1; |
@@ -738,9 +738,9 @@ evaluxn(Uxn *u, Uint16 vec) | |||
738 | } | 738 | } |
739 | case 0x33: /* STR2 */ | 739 | case 0x33: /* STR2 */ |
740 | { | 740 | { |
741 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 741 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
742 | Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); | 742 | u16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
743 | mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); | 743 | mempoke16(u->ram.dat, u->ram.ptr + (s8)a, b); |
744 | #ifndef NO_STACK_CHECKS | 744 | #ifndef NO_STACK_CHECKS |
745 | if(u->wst.ptr < 3) { | 745 | if(u->wst.ptr < 3) { |
746 | u->wst.error = 1; | 746 | u->wst.error = 1; |
@@ -752,7 +752,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
752 | } | 752 | } |
753 | case 0x34: /* LDA2 */ | 753 | case 0x34: /* LDA2 */ |
754 | { | 754 | { |
755 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 755 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
756 | u->wst.dat[u->wst.ptr - 2] = mempeek8(u->ram.dat, a); | 756 | u->wst.dat[u->wst.ptr - 2] = mempeek8(u->ram.dat, a); |
757 | u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, a + 1); | 757 | u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, a + 1); |
758 | #ifndef NO_STACK_CHECKS | 758 | #ifndef NO_STACK_CHECKS |
@@ -765,8 +765,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
765 | } | 765 | } |
766 | case 0x35: /* STA2 */ | 766 | case 0x35: /* STA2 */ |
767 | { | 767 | { |
768 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 768 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
769 | Uint16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 769 | u16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
770 | mempoke16(u->ram.dat, a, b); | 770 | mempoke16(u->ram.dat, a, b); |
771 | #ifndef NO_STACK_CHECKS | 771 | #ifndef NO_STACK_CHECKS |
772 | if(u->wst.ptr < 4) { | 772 | if(u->wst.ptr < 4) { |
@@ -779,7 +779,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
779 | } | 779 | } |
780 | case 0x36: /* DEI2 */ | 780 | case 0x36: /* DEI2 */ |
781 | { | 781 | { |
782 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 782 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
783 | u->wst.dat[u->wst.ptr - 1] = devpeek8(&u->dev[a >> 4], a); | 783 | u->wst.dat[u->wst.ptr - 1] = devpeek8(&u->dev[a >> 4], a); |
784 | u->wst.dat[u->wst.ptr] = devpeek8(&u->dev[a >> 4], a + 1); | 784 | u->wst.dat[u->wst.ptr] = devpeek8(&u->dev[a >> 4], a + 1); |
785 | #ifndef NO_STACK_CHECKS | 785 | #ifndef NO_STACK_CHECKS |
@@ -797,8 +797,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
797 | } | 797 | } |
798 | case 0x37: /* DEO2 */ | 798 | case 0x37: /* DEO2 */ |
799 | { | 799 | { |
800 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 800 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
801 | Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); | 801 | u16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
802 | devpoke16(&u->dev[a >> 4], a, b); | 802 | devpoke16(&u->dev[a >> 4], a, b); |
803 | #ifndef NO_STACK_CHECKS | 803 | #ifndef NO_STACK_CHECKS |
804 | if(u->wst.ptr < 3) { | 804 | if(u->wst.ptr < 3) { |
@@ -811,7 +811,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
811 | } | 811 | } |
812 | case 0x38: /* ADD2 */ | 812 | case 0x38: /* ADD2 */ |
813 | { | 813 | { |
814 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 814 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
815 | u->wst.dat[u->wst.ptr - 4] = (b + a) >> 8; | 815 | u->wst.dat[u->wst.ptr - 4] = (b + a) >> 8; |
816 | u->wst.dat[u->wst.ptr - 3] = (b + a) & 0xff; | 816 | u->wst.dat[u->wst.ptr - 3] = (b + a) & 0xff; |
817 | #ifndef NO_STACK_CHECKS | 817 | #ifndef NO_STACK_CHECKS |
@@ -825,7 +825,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
825 | } | 825 | } |
826 | case 0x39: /* SUB2 */ | 826 | case 0x39: /* SUB2 */ |
827 | { | 827 | { |
828 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 828 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
829 | u->wst.dat[u->wst.ptr - 4] = (b - a) >> 8; | 829 | u->wst.dat[u->wst.ptr - 4] = (b - a) >> 8; |
830 | u->wst.dat[u->wst.ptr - 3] = (b - a) & 0xff; | 830 | u->wst.dat[u->wst.ptr - 3] = (b - a) & 0xff; |
831 | #ifndef NO_STACK_CHECKS | 831 | #ifndef NO_STACK_CHECKS |
@@ -839,7 +839,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
839 | } | 839 | } |
840 | case 0x3a: /* MUL2 */ | 840 | case 0x3a: /* MUL2 */ |
841 | { | 841 | { |
842 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 842 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
843 | u->wst.dat[u->wst.ptr - 4] = (b * a) >> 8; | 843 | u->wst.dat[u->wst.ptr - 4] = (b * a) >> 8; |
844 | u->wst.dat[u->wst.ptr - 3] = (b * a) & 0xff; | 844 | u->wst.dat[u->wst.ptr - 3] = (b * a) & 0xff; |
845 | #ifndef NO_STACK_CHECKS | 845 | #ifndef NO_STACK_CHECKS |
@@ -853,7 +853,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
853 | } | 853 | } |
854 | case 0x3b: /* DIV2 */ | 854 | case 0x3b: /* DIV2 */ |
855 | { | 855 | { |
856 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 856 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
857 | u->wst.dat[u->wst.ptr - 4] = (b / a) >> 8; | 857 | u->wst.dat[u->wst.ptr - 4] = (b / a) >> 8; |
858 | u->wst.dat[u->wst.ptr - 3] = (b / a) & 0xff; | 858 | u->wst.dat[u->wst.ptr - 3] = (b / a) & 0xff; |
859 | #ifndef NO_STACK_CHECKS | 859 | #ifndef NO_STACK_CHECKS |
@@ -867,7 +867,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
867 | } | 867 | } |
868 | case 0x3c: /* AND2 */ | 868 | case 0x3c: /* AND2 */ |
869 | { | 869 | { |
870 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; | 870 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
871 | u->wst.dat[u->wst.ptr - 4] = d & b; | 871 | u->wst.dat[u->wst.ptr - 4] = d & b; |
872 | u->wst.dat[u->wst.ptr - 3] = c & a; | 872 | u->wst.dat[u->wst.ptr - 3] = c & a; |
873 | #ifndef NO_STACK_CHECKS | 873 | #ifndef NO_STACK_CHECKS |
@@ -881,7 +881,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
881 | } | 881 | } |
882 | case 0x3d: /* ORA2 */ | 882 | case 0x3d: /* ORA2 */ |
883 | { | 883 | { |
884 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; | 884 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
885 | u->wst.dat[u->wst.ptr - 4] = d | b; | 885 | u->wst.dat[u->wst.ptr - 4] = d | b; |
886 | u->wst.dat[u->wst.ptr - 3] = c | a; | 886 | u->wst.dat[u->wst.ptr - 3] = c | a; |
887 | #ifndef NO_STACK_CHECKS | 887 | #ifndef NO_STACK_CHECKS |
@@ -895,7 +895,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
895 | } | 895 | } |
896 | case 0x3e: /* EOR2 */ | 896 | case 0x3e: /* EOR2 */ |
897 | { | 897 | { |
898 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; | 898 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
899 | u->wst.dat[u->wst.ptr - 4] = d ^ b; | 899 | u->wst.dat[u->wst.ptr - 4] = d ^ b; |
900 | u->wst.dat[u->wst.ptr - 3] = c ^ a; | 900 | u->wst.dat[u->wst.ptr - 3] = c ^ a; |
901 | #ifndef NO_STACK_CHECKS | 901 | #ifndef NO_STACK_CHECKS |
@@ -909,7 +909,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
909 | } | 909 | } |
910 | case 0x3f: /* SFT2 */ | 910 | case 0x3f: /* SFT2 */ |
911 | { | 911 | { |
912 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 912 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
913 | u->wst.dat[u->wst.ptr - 4] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) >> 8; | 913 | u->wst.dat[u->wst.ptr - 4] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) >> 8; |
914 | u->wst.dat[u->wst.ptr - 3] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) & 0xff; | 914 | u->wst.dat[u->wst.ptr - 3] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) & 0xff; |
915 | #ifndef NO_STACK_CHECKS | 915 | #ifndef NO_STACK_CHECKS |
@@ -948,7 +948,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
948 | } | 948 | } |
949 | case 0x44: /* DUPr */ | 949 | case 0x44: /* DUPr */ |
950 | { | 950 | { |
951 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 951 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
952 | u->rst.dat[u->rst.ptr - 1] = a; | 952 | u->rst.dat[u->rst.ptr - 1] = a; |
953 | u->rst.dat[u->rst.ptr] = a; | 953 | u->rst.dat[u->rst.ptr] = a; |
954 | #ifndef NO_STACK_CHECKS | 954 | #ifndef NO_STACK_CHECKS |
@@ -966,7 +966,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
966 | } | 966 | } |
967 | case 0x45: /* SWPr */ | 967 | case 0x45: /* SWPr */ |
968 | { | 968 | { |
969 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 969 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
970 | u->rst.dat[u->rst.ptr - 2] = a; | 970 | u->rst.dat[u->rst.ptr - 2] = a; |
971 | u->rst.dat[u->rst.ptr - 1] = b; | 971 | u->rst.dat[u->rst.ptr - 1] = b; |
972 | #ifndef NO_STACK_CHECKS | 972 | #ifndef NO_STACK_CHECKS |
@@ -979,7 +979,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
979 | } | 979 | } |
980 | case 0x46: /* OVRr */ | 980 | case 0x46: /* OVRr */ |
981 | { | 981 | { |
982 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 982 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
983 | u->rst.dat[u->rst.ptr - 2] = b; | 983 | u->rst.dat[u->rst.ptr - 2] = b; |
984 | u->rst.dat[u->rst.ptr - 1] = a; | 984 | u->rst.dat[u->rst.ptr - 1] = a; |
985 | u->rst.dat[u->rst.ptr] = b; | 985 | u->rst.dat[u->rst.ptr] = b; |
@@ -998,7 +998,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
998 | } | 998 | } |
999 | case 0x47: /* ROTr */ | 999 | case 0x47: /* ROTr */ |
1000 | { | 1000 | { |
1001 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3]; | 1001 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3]; |
1002 | u->rst.dat[u->rst.ptr - 3] = b; | 1002 | u->rst.dat[u->rst.ptr - 3] = b; |
1003 | u->rst.dat[u->rst.ptr - 2] = a; | 1003 | u->rst.dat[u->rst.ptr - 2] = a; |
1004 | u->rst.dat[u->rst.ptr - 1] = c; | 1004 | u->rst.dat[u->rst.ptr - 1] = c; |
@@ -1012,7 +1012,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1012 | } | 1012 | } |
1013 | case 0x48: /* EQUr */ | 1013 | case 0x48: /* EQUr */ |
1014 | { | 1014 | { |
1015 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1015 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1016 | u->rst.dat[u->rst.ptr - 2] = b == a; | 1016 | u->rst.dat[u->rst.ptr - 2] = b == a; |
1017 | #ifndef NO_STACK_CHECKS | 1017 | #ifndef NO_STACK_CHECKS |
1018 | if(u->rst.ptr < 2) { | 1018 | if(u->rst.ptr < 2) { |
@@ -1025,7 +1025,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1025 | } | 1025 | } |
1026 | case 0x49: /* NEQr */ | 1026 | case 0x49: /* NEQr */ |
1027 | { | 1027 | { |
1028 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1028 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1029 | u->rst.dat[u->rst.ptr - 2] = b != a; | 1029 | u->rst.dat[u->rst.ptr - 2] = b != a; |
1030 | #ifndef NO_STACK_CHECKS | 1030 | #ifndef NO_STACK_CHECKS |
1031 | if(u->rst.ptr < 2) { | 1031 | if(u->rst.ptr < 2) { |
@@ -1038,7 +1038,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1038 | } | 1038 | } |
1039 | case 0x4a: /* GTHr */ | 1039 | case 0x4a: /* GTHr */ |
1040 | { | 1040 | { |
1041 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1041 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1042 | u->rst.dat[u->rst.ptr - 2] = b > a; | 1042 | u->rst.dat[u->rst.ptr - 2] = b > a; |
1043 | #ifndef NO_STACK_CHECKS | 1043 | #ifndef NO_STACK_CHECKS |
1044 | if(u->rst.ptr < 2) { | 1044 | if(u->rst.ptr < 2) { |
@@ -1051,7 +1051,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1051 | } | 1051 | } |
1052 | case 0x4b: /* LTHr */ | 1052 | case 0x4b: /* LTHr */ |
1053 | { | 1053 | { |
1054 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1054 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1055 | u->rst.dat[u->rst.ptr - 2] = b < a; | 1055 | u->rst.dat[u->rst.ptr - 2] = b < a; |
1056 | #ifndef NO_STACK_CHECKS | 1056 | #ifndef NO_STACK_CHECKS |
1057 | if(u->rst.ptr < 2) { | 1057 | if(u->rst.ptr < 2) { |
@@ -1064,8 +1064,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1064 | } | 1064 | } |
1065 | case 0x4c: /* JMPr */ | 1065 | case 0x4c: /* JMPr */ |
1066 | { | 1066 | { |
1067 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1067 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1068 | u->ram.ptr += (Sint8)a; | 1068 | u->ram.ptr += (s8)a; |
1069 | #ifndef NO_STACK_CHECKS | 1069 | #ifndef NO_STACK_CHECKS |
1070 | if(u->rst.ptr < 1) { | 1070 | if(u->rst.ptr < 1) { |
1071 | u->rst.error = 1; | 1071 | u->rst.error = 1; |
@@ -1077,8 +1077,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1077 | } | 1077 | } |
1078 | case 0x4d: /* JCNr */ | 1078 | case 0x4d: /* JCNr */ |
1079 | { | 1079 | { |
1080 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1080 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1081 | if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a; | 1081 | if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (s8)a; |
1082 | #ifndef NO_STACK_CHECKS | 1082 | #ifndef NO_STACK_CHECKS |
1083 | if(u->rst.ptr < 2) { | 1083 | if(u->rst.ptr < 2) { |
1084 | u->rst.error = 1; | 1084 | u->rst.error = 1; |
@@ -1090,10 +1090,10 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1090 | } | 1090 | } |
1091 | case 0x4e: /* JSRr */ | 1091 | case 0x4e: /* JSRr */ |
1092 | { | 1092 | { |
1093 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1093 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1094 | u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; | 1094 | u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; |
1095 | u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; | 1095 | u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; |
1096 | u->ram.ptr += (Sint8)a; | 1096 | u->ram.ptr += (s8)a; |
1097 | #ifndef NO_STACK_CHECKS | 1097 | #ifndef NO_STACK_CHECKS |
1098 | if(u->rst.ptr < 1) { | 1098 | if(u->rst.ptr < 1) { |
1099 | u->rst.error = 1; | 1099 | u->rst.error = 1; |
@@ -1112,7 +1112,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1112 | } | 1112 | } |
1113 | case 0x4f: /* STHr */ | 1113 | case 0x4f: /* STHr */ |
1114 | { | 1114 | { |
1115 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1115 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1116 | u->wst.dat[u->wst.ptr] = a; | 1116 | u->wst.dat[u->wst.ptr] = a; |
1117 | #ifndef NO_STACK_CHECKS | 1117 | #ifndef NO_STACK_CHECKS |
1118 | if(u->rst.ptr < 1) { | 1118 | if(u->rst.ptr < 1) { |
@@ -1132,7 +1132,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1132 | } | 1132 | } |
1133 | case 0x50: /* LDZr */ | 1133 | case 0x50: /* LDZr */ |
1134 | { | 1134 | { |
1135 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1135 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1136 | u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a); | 1136 | u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a); |
1137 | #ifndef NO_STACK_CHECKS | 1137 | #ifndef NO_STACK_CHECKS |
1138 | if(u->rst.ptr < 1) { | 1138 | if(u->rst.ptr < 1) { |
@@ -1144,8 +1144,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1144 | } | 1144 | } |
1145 | case 0x51: /* STZr */ | 1145 | case 0x51: /* STZr */ |
1146 | { | 1146 | { |
1147 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1147 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1148 | Uint8 b = u->rst.dat[u->rst.ptr - 2]; | 1148 | u8 b = u->rst.dat[u->rst.ptr - 2]; |
1149 | mempoke8(u->ram.dat, a, b); | 1149 | mempoke8(u->ram.dat, a, b); |
1150 | #ifndef NO_STACK_CHECKS | 1150 | #ifndef NO_STACK_CHECKS |
1151 | if(u->rst.ptr < 2) { | 1151 | if(u->rst.ptr < 2) { |
@@ -1158,8 +1158,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1158 | } | 1158 | } |
1159 | case 0x52: /* LDRr */ | 1159 | case 0x52: /* LDRr */ |
1160 | { | 1160 | { |
1161 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1161 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1162 | u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); | 1162 | u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (s8)a); |
1163 | #ifndef NO_STACK_CHECKS | 1163 | #ifndef NO_STACK_CHECKS |
1164 | if(u->rst.ptr < 1) { | 1164 | if(u->rst.ptr < 1) { |
1165 | u->rst.error = 1; | 1165 | u->rst.error = 1; |
@@ -1170,9 +1170,9 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1170 | } | 1170 | } |
1171 | case 0x53: /* STRr */ | 1171 | case 0x53: /* STRr */ |
1172 | { | 1172 | { |
1173 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1173 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1174 | Uint8 b = u->rst.dat[u->rst.ptr - 2]; | 1174 | u8 b = u->rst.dat[u->rst.ptr - 2]; |
1175 | mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); | 1175 | mempoke8(u->ram.dat, u->ram.ptr + (s8)a, b); |
1176 | #ifndef NO_STACK_CHECKS | 1176 | #ifndef NO_STACK_CHECKS |
1177 | if(u->rst.ptr < 2) { | 1177 | if(u->rst.ptr < 2) { |
1178 | u->rst.error = 1; | 1178 | u->rst.error = 1; |
@@ -1184,7 +1184,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1184 | } | 1184 | } |
1185 | case 0x54: /* LDAr */ | 1185 | case 0x54: /* LDAr */ |
1186 | { | 1186 | { |
1187 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 1187 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
1188 | u->rst.dat[u->rst.ptr - 2] = mempeek8(u->ram.dat, a); | 1188 | u->rst.dat[u->rst.ptr - 2] = mempeek8(u->ram.dat, a); |
1189 | #ifndef NO_STACK_CHECKS | 1189 | #ifndef NO_STACK_CHECKS |
1190 | if(u->rst.ptr < 2) { | 1190 | if(u->rst.ptr < 2) { |
@@ -1197,8 +1197,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1197 | } | 1197 | } |
1198 | case 0x55: /* STAr */ | 1198 | case 0x55: /* STAr */ |
1199 | { | 1199 | { |
1200 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 1200 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
1201 | Uint8 b = u->rst.dat[u->rst.ptr - 3]; | 1201 | u8 b = u->rst.dat[u->rst.ptr - 3]; |
1202 | mempoke8(u->ram.dat, a, b); | 1202 | mempoke8(u->ram.dat, a, b); |
1203 | #ifndef NO_STACK_CHECKS | 1203 | #ifndef NO_STACK_CHECKS |
1204 | if(u->rst.ptr < 3) { | 1204 | if(u->rst.ptr < 3) { |
@@ -1211,7 +1211,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1211 | } | 1211 | } |
1212 | case 0x56: /* DEIr */ | 1212 | case 0x56: /* DEIr */ |
1213 | { | 1213 | { |
1214 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1214 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1215 | u->rst.dat[u->rst.ptr - 1] = devpeek8(&u->dev[a >> 4], a); | 1215 | u->rst.dat[u->rst.ptr - 1] = devpeek8(&u->dev[a >> 4], a); |
1216 | #ifndef NO_STACK_CHECKS | 1216 | #ifndef NO_STACK_CHECKS |
1217 | if(u->rst.ptr < 1) { | 1217 | if(u->rst.ptr < 1) { |
@@ -1223,7 +1223,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1223 | } | 1223 | } |
1224 | case 0x57: /* DEOr */ | 1224 | case 0x57: /* DEOr */ |
1225 | { | 1225 | { |
1226 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1226 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1227 | devpoke8(&u->dev[a >> 4], a, b); | 1227 | devpoke8(&u->dev[a >> 4], a, b); |
1228 | #ifndef NO_STACK_CHECKS | 1228 | #ifndef NO_STACK_CHECKS |
1229 | if(u->rst.ptr < 2) { | 1229 | if(u->rst.ptr < 2) { |
@@ -1236,7 +1236,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1236 | } | 1236 | } |
1237 | case 0x58: /* ADDr */ | 1237 | case 0x58: /* ADDr */ |
1238 | { | 1238 | { |
1239 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1239 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1240 | u->rst.dat[u->rst.ptr - 2] = b + a; | 1240 | u->rst.dat[u->rst.ptr - 2] = b + a; |
1241 | #ifndef NO_STACK_CHECKS | 1241 | #ifndef NO_STACK_CHECKS |
1242 | if(u->rst.ptr < 2) { | 1242 | if(u->rst.ptr < 2) { |
@@ -1249,7 +1249,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1249 | } | 1249 | } |
1250 | case 0x59: /* SUBr */ | 1250 | case 0x59: /* SUBr */ |
1251 | { | 1251 | { |
1252 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1252 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1253 | u->rst.dat[u->rst.ptr - 2] = b - a; | 1253 | u->rst.dat[u->rst.ptr - 2] = b - a; |
1254 | #ifndef NO_STACK_CHECKS | 1254 | #ifndef NO_STACK_CHECKS |
1255 | if(u->rst.ptr < 2) { | 1255 | if(u->rst.ptr < 2) { |
@@ -1262,7 +1262,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1262 | } | 1262 | } |
1263 | case 0x5a: /* MULr */ | 1263 | case 0x5a: /* MULr */ |
1264 | { | 1264 | { |
1265 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1265 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1266 | u->rst.dat[u->rst.ptr - 2] = b * a; | 1266 | u->rst.dat[u->rst.ptr - 2] = b * a; |
1267 | #ifndef NO_STACK_CHECKS | 1267 | #ifndef NO_STACK_CHECKS |
1268 | if(u->rst.ptr < 2) { | 1268 | if(u->rst.ptr < 2) { |
@@ -1275,7 +1275,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1275 | } | 1275 | } |
1276 | case 0x5b: /* DIVr */ | 1276 | case 0x5b: /* DIVr */ |
1277 | { | 1277 | { |
1278 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1278 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1279 | u->rst.dat[u->rst.ptr - 2] = b / a; | 1279 | u->rst.dat[u->rst.ptr - 2] = b / a; |
1280 | #ifndef NO_STACK_CHECKS | 1280 | #ifndef NO_STACK_CHECKS |
1281 | if(u->rst.ptr < 2) { | 1281 | if(u->rst.ptr < 2) { |
@@ -1288,7 +1288,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1288 | } | 1288 | } |
1289 | case 0x5c: /* ANDr */ | 1289 | case 0x5c: /* ANDr */ |
1290 | { | 1290 | { |
1291 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1291 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1292 | u->rst.dat[u->rst.ptr - 2] = b & a; | 1292 | u->rst.dat[u->rst.ptr - 2] = b & a; |
1293 | #ifndef NO_STACK_CHECKS | 1293 | #ifndef NO_STACK_CHECKS |
1294 | if(u->rst.ptr < 2) { | 1294 | if(u->rst.ptr < 2) { |
@@ -1301,7 +1301,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1301 | } | 1301 | } |
1302 | case 0x5d: /* ORAr */ | 1302 | case 0x5d: /* ORAr */ |
1303 | { | 1303 | { |
1304 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1304 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1305 | u->rst.dat[u->rst.ptr - 2] = b | a; | 1305 | u->rst.dat[u->rst.ptr - 2] = b | a; |
1306 | #ifndef NO_STACK_CHECKS | 1306 | #ifndef NO_STACK_CHECKS |
1307 | if(u->rst.ptr < 2) { | 1307 | if(u->rst.ptr < 2) { |
@@ -1314,7 +1314,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1314 | } | 1314 | } |
1315 | case 0x5e: /* EORr */ | 1315 | case 0x5e: /* EORr */ |
1316 | { | 1316 | { |
1317 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1317 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1318 | u->rst.dat[u->rst.ptr - 2] = b ^ a; | 1318 | u->rst.dat[u->rst.ptr - 2] = b ^ a; |
1319 | #ifndef NO_STACK_CHECKS | 1319 | #ifndef NO_STACK_CHECKS |
1320 | if(u->rst.ptr < 2) { | 1320 | if(u->rst.ptr < 2) { |
@@ -1327,7 +1327,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1327 | } | 1327 | } |
1328 | case 0x5f: /* SFTr */ | 1328 | case 0x5f: /* SFTr */ |
1329 | { | 1329 | { |
1330 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 1330 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
1331 | u->rst.dat[u->rst.ptr - 2] = b >> (a & 0x07) << ((a & 0x70) >> 4); | 1331 | u->rst.dat[u->rst.ptr - 2] = b >> (a & 0x07) << ((a & 0x70) >> 4); |
1332 | #ifndef NO_STACK_CHECKS | 1332 | #ifndef NO_STACK_CHECKS |
1333 | if(u->rst.ptr < 2) { | 1333 | if(u->rst.ptr < 2) { |
@@ -1366,7 +1366,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1366 | } | 1366 | } |
1367 | case 0x64: /* DUP2r */ | 1367 | case 0x64: /* DUP2r */ |
1368 | { | 1368 | { |
1369 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 1369 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
1370 | u->rst.dat[u->rst.ptr - 2] = a >> 8; | 1370 | u->rst.dat[u->rst.ptr - 2] = a >> 8; |
1371 | u->rst.dat[u->rst.ptr - 1] = a & 0xff; | 1371 | u->rst.dat[u->rst.ptr - 1] = a & 0xff; |
1372 | u->rst.dat[u->rst.ptr] = a >> 8; | 1372 | u->rst.dat[u->rst.ptr] = a >> 8; |
@@ -1386,7 +1386,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1386 | } | 1386 | } |
1387 | case 0x65: /* SWP2r */ | 1387 | case 0x65: /* SWP2r */ |
1388 | { | 1388 | { |
1389 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 1389 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
1390 | u->rst.dat[u->rst.ptr - 4] = a >> 8; | 1390 | u->rst.dat[u->rst.ptr - 4] = a >> 8; |
1391 | u->rst.dat[u->rst.ptr - 3] = a & 0xff; | 1391 | u->rst.dat[u->rst.ptr - 3] = a & 0xff; |
1392 | u->rst.dat[u->rst.ptr - 2] = b >> 8; | 1392 | u->rst.dat[u->rst.ptr - 2] = b >> 8; |
@@ -1401,7 +1401,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1401 | } | 1401 | } |
1402 | case 0x66: /* OVR2r */ | 1402 | case 0x66: /* OVR2r */ |
1403 | { | 1403 | { |
1404 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 1404 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
1405 | u->rst.dat[u->rst.ptr - 4] = b >> 8; | 1405 | u->rst.dat[u->rst.ptr - 4] = b >> 8; |
1406 | u->rst.dat[u->rst.ptr - 3] = b & 0xff; | 1406 | u->rst.dat[u->rst.ptr - 3] = b & 0xff; |
1407 | u->rst.dat[u->rst.ptr - 2] = a >> 8; | 1407 | u->rst.dat[u->rst.ptr - 2] = a >> 8; |
@@ -1423,7 +1423,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1423 | } | 1423 | } |
1424 | case 0x67: /* ROT2r */ | 1424 | case 0x67: /* ROT2r */ |
1425 | { | 1425 | { |
1426 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)), c = (u->rst.dat[u->rst.ptr - 5] | (u->rst.dat[u->rst.ptr - 6] << 8)); | 1426 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)), c = (u->rst.dat[u->rst.ptr - 5] | (u->rst.dat[u->rst.ptr - 6] << 8)); |
1427 | u->rst.dat[u->rst.ptr - 6] = b >> 8; | 1427 | u->rst.dat[u->rst.ptr - 6] = b >> 8; |
1428 | u->rst.dat[u->rst.ptr - 5] = b & 0xff; | 1428 | u->rst.dat[u->rst.ptr - 5] = b & 0xff; |
1429 | u->rst.dat[u->rst.ptr - 4] = a >> 8; | 1429 | u->rst.dat[u->rst.ptr - 4] = a >> 8; |
@@ -1440,7 +1440,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1440 | } | 1440 | } |
1441 | case 0x68: /* EQU2r */ | 1441 | case 0x68: /* EQU2r */ |
1442 | { | 1442 | { |
1443 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 1443 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
1444 | u->rst.dat[u->rst.ptr - 4] = b == a; | 1444 | u->rst.dat[u->rst.ptr - 4] = b == a; |
1445 | #ifndef NO_STACK_CHECKS | 1445 | #ifndef NO_STACK_CHECKS |
1446 | if(u->rst.ptr < 4) { | 1446 | if(u->rst.ptr < 4) { |
@@ -1453,7 +1453,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1453 | } | 1453 | } |
1454 | case 0x69: /* NEQ2r */ | 1454 | case 0x69: /* NEQ2r */ |
1455 | { | 1455 | { |
1456 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 1456 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
1457 | u->rst.dat[u->rst.ptr - 4] = b != a; | 1457 | u->rst.dat[u->rst.ptr - 4] = b != a; |
1458 | #ifndef NO_STACK_CHECKS | 1458 | #ifndef NO_STACK_CHECKS |
1459 | if(u->rst.ptr < 4) { | 1459 | if(u->rst.ptr < 4) { |
@@ -1466,7 +1466,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1466 | } | 1466 | } |
1467 | case 0x6a: /* GTH2r */ | 1467 | case 0x6a: /* GTH2r */ |
1468 | { | 1468 | { |
1469 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 1469 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
1470 | u->rst.dat[u->rst.ptr - 4] = b > a; | 1470 | u->rst.dat[u->rst.ptr - 4] = b > a; |
1471 | #ifndef NO_STACK_CHECKS | 1471 | #ifndef NO_STACK_CHECKS |
1472 | if(u->rst.ptr < 4) { | 1472 | if(u->rst.ptr < 4) { |
@@ -1479,7 +1479,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1479 | } | 1479 | } |
1480 | case 0x6b: /* LTH2r */ | 1480 | case 0x6b: /* LTH2r */ |
1481 | { | 1481 | { |
1482 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 1482 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
1483 | u->rst.dat[u->rst.ptr - 4] = b < a; | 1483 | u->rst.dat[u->rst.ptr - 4] = b < a; |
1484 | #ifndef NO_STACK_CHECKS | 1484 | #ifndef NO_STACK_CHECKS |
1485 | if(u->rst.ptr < 4) { | 1485 | if(u->rst.ptr < 4) { |
@@ -1504,7 +1504,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1504 | } | 1504 | } |
1505 | case 0x6d: /* JCN2r */ | 1505 | case 0x6d: /* JCN2r */ |
1506 | { | 1506 | { |
1507 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 1507 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
1508 | if(u->rst.dat[u->rst.ptr - 3]) u->ram.ptr = a; | 1508 | if(u->rst.dat[u->rst.ptr - 3]) u->ram.ptr = a; |
1509 | #ifndef NO_STACK_CHECKS | 1509 | #ifndef NO_STACK_CHECKS |
1510 | if(u->rst.ptr < 3) { | 1510 | if(u->rst.ptr < 3) { |
@@ -1538,7 +1538,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1538 | } | 1538 | } |
1539 | case 0x6f: /* STH2r */ | 1539 | case 0x6f: /* STH2r */ |
1540 | { | 1540 | { |
1541 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 1541 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
1542 | u->wst.dat[u->wst.ptr] = a >> 8; | 1542 | u->wst.dat[u->wst.ptr] = a >> 8; |
1543 | u->wst.dat[u->wst.ptr + 1] = a & 0xff; | 1543 | u->wst.dat[u->wst.ptr + 1] = a & 0xff; |
1544 | #ifndef NO_STACK_CHECKS | 1544 | #ifndef NO_STACK_CHECKS |
@@ -1559,7 +1559,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1559 | } | 1559 | } |
1560 | case 0x70: /* LDZ2r */ | 1560 | case 0x70: /* LDZ2r */ |
1561 | { | 1561 | { |
1562 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1562 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1563 | u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a); | 1563 | u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a); |
1564 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a + 1); | 1564 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a + 1); |
1565 | #ifndef NO_STACK_CHECKS | 1565 | #ifndef NO_STACK_CHECKS |
@@ -1577,8 +1577,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1577 | } | 1577 | } |
1578 | case 0x71: /* STZ2r */ | 1578 | case 0x71: /* STZ2r */ |
1579 | { | 1579 | { |
1580 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1580 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1581 | Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); | 1581 | u16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
1582 | mempoke16(u->ram.dat, a, b); | 1582 | mempoke16(u->ram.dat, a, b); |
1583 | #ifndef NO_STACK_CHECKS | 1583 | #ifndef NO_STACK_CHECKS |
1584 | if(u->rst.ptr < 3) { | 1584 | if(u->rst.ptr < 3) { |
@@ -1591,9 +1591,9 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1591 | } | 1591 | } |
1592 | case 0x72: /* LDR2r */ | 1592 | case 0x72: /* LDR2r */ |
1593 | { | 1593 | { |
1594 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1594 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1595 | u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); | 1595 | u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (s8)a); |
1596 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); | 1596 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (s8)a + 1); |
1597 | #ifndef NO_STACK_CHECKS | 1597 | #ifndef NO_STACK_CHECKS |
1598 | if(u->rst.ptr < 1) { | 1598 | if(u->rst.ptr < 1) { |
1599 | u->rst.error = 1; | 1599 | u->rst.error = 1; |
@@ -1609,9 +1609,9 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1609 | } | 1609 | } |
1610 | case 0x73: /* STR2r */ | 1610 | case 0x73: /* STR2r */ |
1611 | { | 1611 | { |
1612 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1612 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1613 | Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); | 1613 | u16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
1614 | mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); | 1614 | mempoke16(u->ram.dat, u->ram.ptr + (s8)a, b); |
1615 | #ifndef NO_STACK_CHECKS | 1615 | #ifndef NO_STACK_CHECKS |
1616 | if(u->rst.ptr < 3) { | 1616 | if(u->rst.ptr < 3) { |
1617 | u->rst.error = 1; | 1617 | u->rst.error = 1; |
@@ -1623,7 +1623,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1623 | } | 1623 | } |
1624 | case 0x74: /* LDA2r */ | 1624 | case 0x74: /* LDA2r */ |
1625 | { | 1625 | { |
1626 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 1626 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
1627 | u->rst.dat[u->rst.ptr - 2] = mempeek8(u->ram.dat, a); | 1627 | u->rst.dat[u->rst.ptr - 2] = mempeek8(u->ram.dat, a); |
1628 | u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a + 1); | 1628 | u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a + 1); |
1629 | #ifndef NO_STACK_CHECKS | 1629 | #ifndef NO_STACK_CHECKS |
@@ -1636,8 +1636,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1636 | } | 1636 | } |
1637 | case 0x75: /* STA2r */ | 1637 | case 0x75: /* STA2r */ |
1638 | { | 1638 | { |
1639 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 1639 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
1640 | Uint16 b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 1640 | u16 b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
1641 | mempoke16(u->ram.dat, a, b); | 1641 | mempoke16(u->ram.dat, a, b); |
1642 | #ifndef NO_STACK_CHECKS | 1642 | #ifndef NO_STACK_CHECKS |
1643 | if(u->rst.ptr < 4) { | 1643 | if(u->rst.ptr < 4) { |
@@ -1650,7 +1650,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1650 | } | 1650 | } |
1651 | case 0x76: /* DEI2r */ | 1651 | case 0x76: /* DEI2r */ |
1652 | { | 1652 | { |
1653 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1653 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1654 | u->rst.dat[u->rst.ptr - 1] = devpeek8(&u->dev[a >> 4], a); | 1654 | u->rst.dat[u->rst.ptr - 1] = devpeek8(&u->dev[a >> 4], a); |
1655 | u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a + 1); | 1655 | u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a + 1); |
1656 | #ifndef NO_STACK_CHECKS | 1656 | #ifndef NO_STACK_CHECKS |
@@ -1668,8 +1668,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1668 | } | 1668 | } |
1669 | case 0x77: /* DEO2r */ | 1669 | case 0x77: /* DEO2r */ |
1670 | { | 1670 | { |
1671 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 1671 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
1672 | Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); | 1672 | u16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
1673 | devpoke16(&u->dev[a >> 4], a, b); | 1673 | devpoke16(&u->dev[a >> 4], a, b); |
1674 | #ifndef NO_STACK_CHECKS | 1674 | #ifndef NO_STACK_CHECKS |
1675 | if(u->rst.ptr < 3) { | 1675 | if(u->rst.ptr < 3) { |
@@ -1682,7 +1682,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1682 | } | 1682 | } |
1683 | case 0x78: /* ADD2r */ | 1683 | case 0x78: /* ADD2r */ |
1684 | { | 1684 | { |
1685 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 1685 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
1686 | u->rst.dat[u->rst.ptr - 4] = (b + a) >> 8; | 1686 | u->rst.dat[u->rst.ptr - 4] = (b + a) >> 8; |
1687 | u->rst.dat[u->rst.ptr - 3] = (b + a) & 0xff; | 1687 | u->rst.dat[u->rst.ptr - 3] = (b + a) & 0xff; |
1688 | #ifndef NO_STACK_CHECKS | 1688 | #ifndef NO_STACK_CHECKS |
@@ -1696,7 +1696,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1696 | } | 1696 | } |
1697 | case 0x79: /* SUB2r */ | 1697 | case 0x79: /* SUB2r */ |
1698 | { | 1698 | { |
1699 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 1699 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
1700 | u->rst.dat[u->rst.ptr - 4] = (b - a) >> 8; | 1700 | u->rst.dat[u->rst.ptr - 4] = (b - a) >> 8; |
1701 | u->rst.dat[u->rst.ptr - 3] = (b - a) & 0xff; | 1701 | u->rst.dat[u->rst.ptr - 3] = (b - a) & 0xff; |
1702 | #ifndef NO_STACK_CHECKS | 1702 | #ifndef NO_STACK_CHECKS |
@@ -1710,7 +1710,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1710 | } | 1710 | } |
1711 | case 0x7a: /* MUL2r */ | 1711 | case 0x7a: /* MUL2r */ |
1712 | { | 1712 | { |
1713 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 1713 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
1714 | u->rst.dat[u->rst.ptr - 4] = (b * a) >> 8; | 1714 | u->rst.dat[u->rst.ptr - 4] = (b * a) >> 8; |
1715 | u->rst.dat[u->rst.ptr - 3] = (b * a) & 0xff; | 1715 | u->rst.dat[u->rst.ptr - 3] = (b * a) & 0xff; |
1716 | #ifndef NO_STACK_CHECKS | 1716 | #ifndef NO_STACK_CHECKS |
@@ -1724,7 +1724,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1724 | } | 1724 | } |
1725 | case 0x7b: /* DIV2r */ | 1725 | case 0x7b: /* DIV2r */ |
1726 | { | 1726 | { |
1727 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 1727 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
1728 | u->rst.dat[u->rst.ptr - 4] = (b / a) >> 8; | 1728 | u->rst.dat[u->rst.ptr - 4] = (b / a) >> 8; |
1729 | u->rst.dat[u->rst.ptr - 3] = (b / a) & 0xff; | 1729 | u->rst.dat[u->rst.ptr - 3] = (b / a) & 0xff; |
1730 | #ifndef NO_STACK_CHECKS | 1730 | #ifndef NO_STACK_CHECKS |
@@ -1738,7 +1738,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1738 | } | 1738 | } |
1739 | case 0x7c: /* AND2r */ | 1739 | case 0x7c: /* AND2r */ |
1740 | { | 1740 | { |
1741 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; | 1741 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
1742 | u->rst.dat[u->rst.ptr - 4] = d & b; | 1742 | u->rst.dat[u->rst.ptr - 4] = d & b; |
1743 | u->rst.dat[u->rst.ptr - 3] = c & a; | 1743 | u->rst.dat[u->rst.ptr - 3] = c & a; |
1744 | #ifndef NO_STACK_CHECKS | 1744 | #ifndef NO_STACK_CHECKS |
@@ -1752,7 +1752,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1752 | } | 1752 | } |
1753 | case 0x7d: /* ORA2r */ | 1753 | case 0x7d: /* ORA2r */ |
1754 | { | 1754 | { |
1755 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; | 1755 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
1756 | u->rst.dat[u->rst.ptr - 4] = d | b; | 1756 | u->rst.dat[u->rst.ptr - 4] = d | b; |
1757 | u->rst.dat[u->rst.ptr - 3] = c | a; | 1757 | u->rst.dat[u->rst.ptr - 3] = c | a; |
1758 | #ifndef NO_STACK_CHECKS | 1758 | #ifndef NO_STACK_CHECKS |
@@ -1766,7 +1766,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1766 | } | 1766 | } |
1767 | case 0x7e: /* EOR2r */ | 1767 | case 0x7e: /* EOR2r */ |
1768 | { | 1768 | { |
1769 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; | 1769 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
1770 | u->rst.dat[u->rst.ptr - 4] = d ^ b; | 1770 | u->rst.dat[u->rst.ptr - 4] = d ^ b; |
1771 | u->rst.dat[u->rst.ptr - 3] = c ^ a; | 1771 | u->rst.dat[u->rst.ptr - 3] = c ^ a; |
1772 | #ifndef NO_STACK_CHECKS | 1772 | #ifndef NO_STACK_CHECKS |
@@ -1780,7 +1780,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1780 | } | 1780 | } |
1781 | case 0x7f: /* SFT2r */ | 1781 | case 0x7f: /* SFT2r */ |
1782 | { | 1782 | { |
1783 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 1783 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
1784 | u->rst.dat[u->rst.ptr - 4] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) >> 8; | 1784 | u->rst.dat[u->rst.ptr - 4] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) >> 8; |
1785 | u->rst.dat[u->rst.ptr - 3] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) & 0xff; | 1785 | u->rst.dat[u->rst.ptr - 3] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) & 0xff; |
1786 | #ifndef NO_STACK_CHECKS | 1786 | #ifndef NO_STACK_CHECKS |
@@ -1805,7 +1805,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1805 | } | 1805 | } |
1806 | case 0x84: /* DUPk */ | 1806 | case 0x84: /* DUPk */ |
1807 | { | 1807 | { |
1808 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 1808 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
1809 | u->wst.dat[u->wst.ptr] = a; | 1809 | u->wst.dat[u->wst.ptr] = a; |
1810 | u->wst.dat[u->wst.ptr + 1] = a; | 1810 | u->wst.dat[u->wst.ptr + 1] = a; |
1811 | #ifndef NO_STACK_CHECKS | 1811 | #ifndef NO_STACK_CHECKS |
@@ -1823,7 +1823,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1823 | } | 1823 | } |
1824 | case 0x85: /* SWPk */ | 1824 | case 0x85: /* SWPk */ |
1825 | { | 1825 | { |
1826 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 1826 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
1827 | u->wst.dat[u->wst.ptr] = a; | 1827 | u->wst.dat[u->wst.ptr] = a; |
1828 | u->wst.dat[u->wst.ptr + 1] = b; | 1828 | u->wst.dat[u->wst.ptr + 1] = b; |
1829 | #ifndef NO_STACK_CHECKS | 1829 | #ifndef NO_STACK_CHECKS |
@@ -1841,7 +1841,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1841 | } | 1841 | } |
1842 | case 0x86: /* OVRk */ | 1842 | case 0x86: /* OVRk */ |
1843 | { | 1843 | { |
1844 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 1844 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
1845 | u->wst.dat[u->wst.ptr] = b; | 1845 | u->wst.dat[u->wst.ptr] = b; |
1846 | u->wst.dat[u->wst.ptr + 1] = a; | 1846 | u->wst.dat[u->wst.ptr + 1] = a; |
1847 | u->wst.dat[u->wst.ptr + 2] = b; | 1847 | u->wst.dat[u->wst.ptr + 2] = b; |
@@ -1860,7 +1860,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1860 | } | 1860 | } |
1861 | case 0x87: /* ROTk */ | 1861 | case 0x87: /* ROTk */ |
1862 | { | 1862 | { |
1863 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3]; | 1863 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3]; |
1864 | u->wst.dat[u->wst.ptr] = b; | 1864 | u->wst.dat[u->wst.ptr] = b; |
1865 | u->wst.dat[u->wst.ptr + 1] = a; | 1865 | u->wst.dat[u->wst.ptr + 1] = a; |
1866 | u->wst.dat[u->wst.ptr + 2] = c; | 1866 | u->wst.dat[u->wst.ptr + 2] = c; |
@@ -1879,7 +1879,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1879 | } | 1879 | } |
1880 | case 0x88: /* EQUk */ | 1880 | case 0x88: /* EQUk */ |
1881 | { | 1881 | { |
1882 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 1882 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
1883 | u->wst.dat[u->wst.ptr] = b == a; | 1883 | u->wst.dat[u->wst.ptr] = b == a; |
1884 | #ifndef NO_STACK_CHECKS | 1884 | #ifndef NO_STACK_CHECKS |
1885 | if(u->wst.ptr < 2) { | 1885 | if(u->wst.ptr < 2) { |
@@ -1896,7 +1896,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1896 | } | 1896 | } |
1897 | case 0x89: /* NEQk */ | 1897 | case 0x89: /* NEQk */ |
1898 | { | 1898 | { |
1899 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 1899 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
1900 | u->wst.dat[u->wst.ptr] = b != a; | 1900 | u->wst.dat[u->wst.ptr] = b != a; |
1901 | #ifndef NO_STACK_CHECKS | 1901 | #ifndef NO_STACK_CHECKS |
1902 | if(u->wst.ptr < 2) { | 1902 | if(u->wst.ptr < 2) { |
@@ -1913,7 +1913,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1913 | } | 1913 | } |
1914 | case 0x8a: /* GTHk */ | 1914 | case 0x8a: /* GTHk */ |
1915 | { | 1915 | { |
1916 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 1916 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
1917 | u->wst.dat[u->wst.ptr] = b > a; | 1917 | u->wst.dat[u->wst.ptr] = b > a; |
1918 | #ifndef NO_STACK_CHECKS | 1918 | #ifndef NO_STACK_CHECKS |
1919 | if(u->wst.ptr < 2) { | 1919 | if(u->wst.ptr < 2) { |
@@ -1930,7 +1930,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1930 | } | 1930 | } |
1931 | case 0x8b: /* LTHk */ | 1931 | case 0x8b: /* LTHk */ |
1932 | { | 1932 | { |
1933 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 1933 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
1934 | u->wst.dat[u->wst.ptr] = b < a; | 1934 | u->wst.dat[u->wst.ptr] = b < a; |
1935 | #ifndef NO_STACK_CHECKS | 1935 | #ifndef NO_STACK_CHECKS |
1936 | if(u->wst.ptr < 2) { | 1936 | if(u->wst.ptr < 2) { |
@@ -1947,8 +1947,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1947 | } | 1947 | } |
1948 | case 0x8c: /* JMPk */ | 1948 | case 0x8c: /* JMPk */ |
1949 | { | 1949 | { |
1950 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 1950 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
1951 | u->ram.ptr += (Sint8)a; | 1951 | u->ram.ptr += (s8)a; |
1952 | #ifndef NO_STACK_CHECKS | 1952 | #ifndef NO_STACK_CHECKS |
1953 | if(u->wst.ptr < 1) { | 1953 | if(u->wst.ptr < 1) { |
1954 | u->wst.error = 1; | 1954 | u->wst.error = 1; |
@@ -1959,8 +1959,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1959 | } | 1959 | } |
1960 | case 0x8d: /* JCNk */ | 1960 | case 0x8d: /* JCNk */ |
1961 | { | 1961 | { |
1962 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 1962 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
1963 | if(u->wst.dat[u->wst.ptr - 2]) u->ram.ptr += (Sint8)a; | 1963 | if(u->wst.dat[u->wst.ptr - 2]) u->ram.ptr += (s8)a; |
1964 | #ifndef NO_STACK_CHECKS | 1964 | #ifndef NO_STACK_CHECKS |
1965 | if(u->wst.ptr < 2) { | 1965 | if(u->wst.ptr < 2) { |
1966 | u->wst.error = 1; | 1966 | u->wst.error = 1; |
@@ -1971,10 +1971,10 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1971 | } | 1971 | } |
1972 | case 0x8e: /* JSRk */ | 1972 | case 0x8e: /* JSRk */ |
1973 | { | 1973 | { |
1974 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 1974 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
1975 | u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; | 1975 | u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; |
1976 | u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; | 1976 | u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; |
1977 | u->ram.ptr += (Sint8)a; | 1977 | u->ram.ptr += (s8)a; |
1978 | #ifndef NO_STACK_CHECKS | 1978 | #ifndef NO_STACK_CHECKS |
1979 | if(u->wst.ptr < 1) { | 1979 | if(u->wst.ptr < 1) { |
1980 | u->wst.error = 1; | 1980 | u->wst.error = 1; |
@@ -1992,7 +1992,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
1992 | } | 1992 | } |
1993 | case 0x8f: /* STHk */ | 1993 | case 0x8f: /* STHk */ |
1994 | { | 1994 | { |
1995 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 1995 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
1996 | u->rst.dat[u->rst.ptr] = a; | 1996 | u->rst.dat[u->rst.ptr] = a; |
1997 | #ifndef NO_STACK_CHECKS | 1997 | #ifndef NO_STACK_CHECKS |
1998 | if(u->wst.ptr < 1) { | 1998 | if(u->wst.ptr < 1) { |
@@ -2011,7 +2011,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2011 | } | 2011 | } |
2012 | case 0x90: /* LDZk */ | 2012 | case 0x90: /* LDZk */ |
2013 | { | 2013 | { |
2014 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 2014 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
2015 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a); | 2015 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a); |
2016 | #ifndef NO_STACK_CHECKS | 2016 | #ifndef NO_STACK_CHECKS |
2017 | if(u->wst.ptr < 1) { | 2017 | if(u->wst.ptr < 1) { |
@@ -2028,8 +2028,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2028 | } | 2028 | } |
2029 | case 0x91: /* STZk */ | 2029 | case 0x91: /* STZk */ |
2030 | { | 2030 | { |
2031 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 2031 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
2032 | Uint8 b = u->wst.dat[u->wst.ptr - 2]; | 2032 | u8 b = u->wst.dat[u->wst.ptr - 2]; |
2033 | mempoke8(u->ram.dat, a, b); | 2033 | mempoke8(u->ram.dat, a, b); |
2034 | #ifndef NO_STACK_CHECKS | 2034 | #ifndef NO_STACK_CHECKS |
2035 | if(u->wst.ptr < 2) { | 2035 | if(u->wst.ptr < 2) { |
@@ -2041,8 +2041,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2041 | } | 2041 | } |
2042 | case 0x92: /* LDRk */ | 2042 | case 0x92: /* LDRk */ |
2043 | { | 2043 | { |
2044 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 2044 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
2045 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); | 2045 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (s8)a); |
2046 | #ifndef NO_STACK_CHECKS | 2046 | #ifndef NO_STACK_CHECKS |
2047 | if(u->wst.ptr < 1) { | 2047 | if(u->wst.ptr < 1) { |
2048 | u->wst.error = 1; | 2048 | u->wst.error = 1; |
@@ -2058,9 +2058,9 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2058 | } | 2058 | } |
2059 | case 0x93: /* STRk */ | 2059 | case 0x93: /* STRk */ |
2060 | { | 2060 | { |
2061 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 2061 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
2062 | Uint8 b = u->wst.dat[u->wst.ptr - 2]; | 2062 | u8 b = u->wst.dat[u->wst.ptr - 2]; |
2063 | mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); | 2063 | mempoke8(u->ram.dat, u->ram.ptr + (s8)a, b); |
2064 | #ifndef NO_STACK_CHECKS | 2064 | #ifndef NO_STACK_CHECKS |
2065 | if(u->wst.ptr < 2) { | 2065 | if(u->wst.ptr < 2) { |
2066 | u->wst.error = 1; | 2066 | u->wst.error = 1; |
@@ -2071,7 +2071,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2071 | } | 2071 | } |
2072 | case 0x94: /* LDAk */ | 2072 | case 0x94: /* LDAk */ |
2073 | { | 2073 | { |
2074 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 2074 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
2075 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a); | 2075 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a); |
2076 | #ifndef NO_STACK_CHECKS | 2076 | #ifndef NO_STACK_CHECKS |
2077 | if(u->wst.ptr < 2) { | 2077 | if(u->wst.ptr < 2) { |
@@ -2088,8 +2088,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2088 | } | 2088 | } |
2089 | case 0x95: /* STAk */ | 2089 | case 0x95: /* STAk */ |
2090 | { | 2090 | { |
2091 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 2091 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
2092 | Uint8 b = u->wst.dat[u->wst.ptr - 3]; | 2092 | u8 b = u->wst.dat[u->wst.ptr - 3]; |
2093 | mempoke8(u->ram.dat, a, b); | 2093 | mempoke8(u->ram.dat, a, b); |
2094 | #ifndef NO_STACK_CHECKS | 2094 | #ifndef NO_STACK_CHECKS |
2095 | if(u->wst.ptr < 3) { | 2095 | if(u->wst.ptr < 3) { |
@@ -2101,7 +2101,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2101 | } | 2101 | } |
2102 | case 0x96: /* DEIk */ | 2102 | case 0x96: /* DEIk */ |
2103 | { | 2103 | { |
2104 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 2104 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
2105 | u->wst.dat[u->wst.ptr] = devpeek8(&u->dev[a >> 4], a); | 2105 | u->wst.dat[u->wst.ptr] = devpeek8(&u->dev[a >> 4], a); |
2106 | #ifndef NO_STACK_CHECKS | 2106 | #ifndef NO_STACK_CHECKS |
2107 | if(u->wst.ptr < 1) { | 2107 | if(u->wst.ptr < 1) { |
@@ -2118,7 +2118,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2118 | } | 2118 | } |
2119 | case 0x97: /* DEOk */ | 2119 | case 0x97: /* DEOk */ |
2120 | { | 2120 | { |
2121 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 2121 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
2122 | devpoke8(&u->dev[a >> 4], a, b); | 2122 | devpoke8(&u->dev[a >> 4], a, b); |
2123 | #ifndef NO_STACK_CHECKS | 2123 | #ifndef NO_STACK_CHECKS |
2124 | if(u->wst.ptr < 2) { | 2124 | if(u->wst.ptr < 2) { |
@@ -2130,7 +2130,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2130 | } | 2130 | } |
2131 | case 0x98: /* ADDk */ | 2131 | case 0x98: /* ADDk */ |
2132 | { | 2132 | { |
2133 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 2133 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
2134 | u->wst.dat[u->wst.ptr] = b + a; | 2134 | u->wst.dat[u->wst.ptr] = b + a; |
2135 | #ifndef NO_STACK_CHECKS | 2135 | #ifndef NO_STACK_CHECKS |
2136 | if(u->wst.ptr < 2) { | 2136 | if(u->wst.ptr < 2) { |
@@ -2147,7 +2147,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2147 | } | 2147 | } |
2148 | case 0x99: /* SUBk */ | 2148 | case 0x99: /* SUBk */ |
2149 | { | 2149 | { |
2150 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 2150 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
2151 | u->wst.dat[u->wst.ptr] = b - a; | 2151 | u->wst.dat[u->wst.ptr] = b - a; |
2152 | #ifndef NO_STACK_CHECKS | 2152 | #ifndef NO_STACK_CHECKS |
2153 | if(u->wst.ptr < 2) { | 2153 | if(u->wst.ptr < 2) { |
@@ -2164,7 +2164,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2164 | } | 2164 | } |
2165 | case 0x9a: /* MULk */ | 2165 | case 0x9a: /* MULk */ |
2166 | { | 2166 | { |
2167 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 2167 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
2168 | u->wst.dat[u->wst.ptr] = b * a; | 2168 | u->wst.dat[u->wst.ptr] = b * a; |
2169 | #ifndef NO_STACK_CHECKS | 2169 | #ifndef NO_STACK_CHECKS |
2170 | if(u->wst.ptr < 2) { | 2170 | if(u->wst.ptr < 2) { |
@@ -2181,7 +2181,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2181 | } | 2181 | } |
2182 | case 0x9b: /* DIVk */ | 2182 | case 0x9b: /* DIVk */ |
2183 | { | 2183 | { |
2184 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 2184 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
2185 | u->wst.dat[u->wst.ptr] = b / a; | 2185 | u->wst.dat[u->wst.ptr] = b / a; |
2186 | #ifndef NO_STACK_CHECKS | 2186 | #ifndef NO_STACK_CHECKS |
2187 | if(u->wst.ptr < 2) { | 2187 | if(u->wst.ptr < 2) { |
@@ -2198,7 +2198,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2198 | } | 2198 | } |
2199 | case 0x9c: /* ANDk */ | 2199 | case 0x9c: /* ANDk */ |
2200 | { | 2200 | { |
2201 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 2201 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
2202 | u->wst.dat[u->wst.ptr] = b & a; | 2202 | u->wst.dat[u->wst.ptr] = b & a; |
2203 | #ifndef NO_STACK_CHECKS | 2203 | #ifndef NO_STACK_CHECKS |
2204 | if(u->wst.ptr < 2) { | 2204 | if(u->wst.ptr < 2) { |
@@ -2215,7 +2215,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2215 | } | 2215 | } |
2216 | case 0x9d: /* ORAk */ | 2216 | case 0x9d: /* ORAk */ |
2217 | { | 2217 | { |
2218 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 2218 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
2219 | u->wst.dat[u->wst.ptr] = b | a; | 2219 | u->wst.dat[u->wst.ptr] = b | a; |
2220 | #ifndef NO_STACK_CHECKS | 2220 | #ifndef NO_STACK_CHECKS |
2221 | if(u->wst.ptr < 2) { | 2221 | if(u->wst.ptr < 2) { |
@@ -2232,7 +2232,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2232 | } | 2232 | } |
2233 | case 0x9e: /* EORk */ | 2233 | case 0x9e: /* EORk */ |
2234 | { | 2234 | { |
2235 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 2235 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
2236 | u->wst.dat[u->wst.ptr] = b ^ a; | 2236 | u->wst.dat[u->wst.ptr] = b ^ a; |
2237 | #ifndef NO_STACK_CHECKS | 2237 | #ifndef NO_STACK_CHECKS |
2238 | if(u->wst.ptr < 2) { | 2238 | if(u->wst.ptr < 2) { |
@@ -2249,7 +2249,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2249 | } | 2249 | } |
2250 | case 0x9f: /* SFTk */ | 2250 | case 0x9f: /* SFTk */ |
2251 | { | 2251 | { |
2252 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; | 2252 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
2253 | u->wst.dat[u->wst.ptr] = b >> (a & 0x07) << ((a & 0x70) >> 4); | 2253 | u->wst.dat[u->wst.ptr] = b >> (a & 0x07) << ((a & 0x70) >> 4); |
2254 | #ifndef NO_STACK_CHECKS | 2254 | #ifndef NO_STACK_CHECKS |
2255 | if(u->wst.ptr < 2) { | 2255 | if(u->wst.ptr < 2) { |
@@ -2277,7 +2277,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2277 | } | 2277 | } |
2278 | case 0xa4: /* DUP2k */ | 2278 | case 0xa4: /* DUP2k */ |
2279 | { | 2279 | { |
2280 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 2280 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
2281 | u->wst.dat[u->wst.ptr] = a >> 8; | 2281 | u->wst.dat[u->wst.ptr] = a >> 8; |
2282 | u->wst.dat[u->wst.ptr + 1] = a & 0xff; | 2282 | u->wst.dat[u->wst.ptr + 1] = a & 0xff; |
2283 | u->wst.dat[u->wst.ptr + 2] = a >> 8; | 2283 | u->wst.dat[u->wst.ptr + 2] = a >> 8; |
@@ -2297,7 +2297,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2297 | } | 2297 | } |
2298 | case 0xa5: /* SWP2k */ | 2298 | case 0xa5: /* SWP2k */ |
2299 | { | 2299 | { |
2300 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 2300 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
2301 | u->wst.dat[u->wst.ptr] = a >> 8; | 2301 | u->wst.dat[u->wst.ptr] = a >> 8; |
2302 | u->wst.dat[u->wst.ptr + 1] = a & 0xff; | 2302 | u->wst.dat[u->wst.ptr + 1] = a & 0xff; |
2303 | u->wst.dat[u->wst.ptr + 2] = b >> 8; | 2303 | u->wst.dat[u->wst.ptr + 2] = b >> 8; |
@@ -2317,7 +2317,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2317 | } | 2317 | } |
2318 | case 0xa6: /* OVR2k */ | 2318 | case 0xa6: /* OVR2k */ |
2319 | { | 2319 | { |
2320 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 2320 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
2321 | u->wst.dat[u->wst.ptr] = b >> 8; | 2321 | u->wst.dat[u->wst.ptr] = b >> 8; |
2322 | u->wst.dat[u->wst.ptr + 1] = b & 0xff; | 2322 | u->wst.dat[u->wst.ptr + 1] = b & 0xff; |
2323 | u->wst.dat[u->wst.ptr + 2] = a >> 8; | 2323 | u->wst.dat[u->wst.ptr + 2] = a >> 8; |
@@ -2339,7 +2339,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2339 | } | 2339 | } |
2340 | case 0xa7: /* ROT2k */ | 2340 | case 0xa7: /* ROT2k */ |
2341 | { | 2341 | { |
2342 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)), c = (u->wst.dat[u->wst.ptr - 5] | (u->wst.dat[u->wst.ptr - 6] << 8)); | 2342 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)), c = (u->wst.dat[u->wst.ptr - 5] | (u->wst.dat[u->wst.ptr - 6] << 8)); |
2343 | u->wst.dat[u->wst.ptr] = b >> 8; | 2343 | u->wst.dat[u->wst.ptr] = b >> 8; |
2344 | u->wst.dat[u->wst.ptr + 1] = b & 0xff; | 2344 | u->wst.dat[u->wst.ptr + 1] = b & 0xff; |
2345 | u->wst.dat[u->wst.ptr + 2] = a >> 8; | 2345 | u->wst.dat[u->wst.ptr + 2] = a >> 8; |
@@ -2361,7 +2361,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2361 | } | 2361 | } |
2362 | case 0xa8: /* EQU2k */ | 2362 | case 0xa8: /* EQU2k */ |
2363 | { | 2363 | { |
2364 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 2364 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
2365 | u->wst.dat[u->wst.ptr] = b == a; | 2365 | u->wst.dat[u->wst.ptr] = b == a; |
2366 | #ifndef NO_STACK_CHECKS | 2366 | #ifndef NO_STACK_CHECKS |
2367 | if(u->wst.ptr < 4) { | 2367 | if(u->wst.ptr < 4) { |
@@ -2378,7 +2378,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2378 | } | 2378 | } |
2379 | case 0xa9: /* NEQ2k */ | 2379 | case 0xa9: /* NEQ2k */ |
2380 | { | 2380 | { |
2381 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 2381 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
2382 | u->wst.dat[u->wst.ptr] = b != a; | 2382 | u->wst.dat[u->wst.ptr] = b != a; |
2383 | #ifndef NO_STACK_CHECKS | 2383 | #ifndef NO_STACK_CHECKS |
2384 | if(u->wst.ptr < 4) { | 2384 | if(u->wst.ptr < 4) { |
@@ -2395,7 +2395,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2395 | } | 2395 | } |
2396 | case 0xaa: /* GTH2k */ | 2396 | case 0xaa: /* GTH2k */ |
2397 | { | 2397 | { |
2398 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 2398 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
2399 | u->wst.dat[u->wst.ptr] = b > a; | 2399 | u->wst.dat[u->wst.ptr] = b > a; |
2400 | #ifndef NO_STACK_CHECKS | 2400 | #ifndef NO_STACK_CHECKS |
2401 | if(u->wst.ptr < 4) { | 2401 | if(u->wst.ptr < 4) { |
@@ -2412,7 +2412,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2412 | } | 2412 | } |
2413 | case 0xab: /* LTH2k */ | 2413 | case 0xab: /* LTH2k */ |
2414 | { | 2414 | { |
2415 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 2415 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
2416 | u->wst.dat[u->wst.ptr] = b < a; | 2416 | u->wst.dat[u->wst.ptr] = b < a; |
2417 | #ifndef NO_STACK_CHECKS | 2417 | #ifndef NO_STACK_CHECKS |
2418 | if(u->wst.ptr < 4) { | 2418 | if(u->wst.ptr < 4) { |
@@ -2440,7 +2440,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2440 | } | 2440 | } |
2441 | case 0xad: /* JCN2k */ | 2441 | case 0xad: /* JCN2k */ |
2442 | { | 2442 | { |
2443 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 2443 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
2444 | if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a; | 2444 | if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a; |
2445 | #ifndef NO_STACK_CHECKS | 2445 | #ifndef NO_STACK_CHECKS |
2446 | if(u->wst.ptr < 3) { | 2446 | if(u->wst.ptr < 3) { |
@@ -2472,7 +2472,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2472 | } | 2472 | } |
2473 | case 0xaf: /* STH2k */ | 2473 | case 0xaf: /* STH2k */ |
2474 | { | 2474 | { |
2475 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 2475 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
2476 | u->rst.dat[u->rst.ptr] = a >> 8; | 2476 | u->rst.dat[u->rst.ptr] = a >> 8; |
2477 | u->rst.dat[u->rst.ptr + 1] = a & 0xff; | 2477 | u->rst.dat[u->rst.ptr + 1] = a & 0xff; |
2478 | #ifndef NO_STACK_CHECKS | 2478 | #ifndef NO_STACK_CHECKS |
@@ -2492,7 +2492,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2492 | } | 2492 | } |
2493 | case 0xb0: /* LDZ2k */ | 2493 | case 0xb0: /* LDZ2k */ |
2494 | { | 2494 | { |
2495 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 2495 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
2496 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a); | 2496 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a); |
2497 | u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, a + 1); | 2497 | u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, a + 1); |
2498 | #ifndef NO_STACK_CHECKS | 2498 | #ifndef NO_STACK_CHECKS |
@@ -2510,8 +2510,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2510 | } | 2510 | } |
2511 | case 0xb1: /* STZ2k */ | 2511 | case 0xb1: /* STZ2k */ |
2512 | { | 2512 | { |
2513 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 2513 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
2514 | Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); | 2514 | u16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
2515 | mempoke16(u->ram.dat, a, b); | 2515 | mempoke16(u->ram.dat, a, b); |
2516 | #ifndef NO_STACK_CHECKS | 2516 | #ifndef NO_STACK_CHECKS |
2517 | if(u->wst.ptr < 3) { | 2517 | if(u->wst.ptr < 3) { |
@@ -2523,9 +2523,9 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2523 | } | 2523 | } |
2524 | case 0xb2: /* LDR2k */ | 2524 | case 0xb2: /* LDR2k */ |
2525 | { | 2525 | { |
2526 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 2526 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
2527 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); | 2527 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (s8)a); |
2528 | u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); | 2528 | u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr + (s8)a + 1); |
2529 | #ifndef NO_STACK_CHECKS | 2529 | #ifndef NO_STACK_CHECKS |
2530 | if(u->wst.ptr < 1) { | 2530 | if(u->wst.ptr < 1) { |
2531 | u->wst.error = 1; | 2531 | u->wst.error = 1; |
@@ -2541,9 +2541,9 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2541 | } | 2541 | } |
2542 | case 0xb3: /* STR2k */ | 2542 | case 0xb3: /* STR2k */ |
2543 | { | 2543 | { |
2544 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 2544 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
2545 | Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); | 2545 | u16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
2546 | mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); | 2546 | mempoke16(u->ram.dat, u->ram.ptr + (s8)a, b); |
2547 | #ifndef NO_STACK_CHECKS | 2547 | #ifndef NO_STACK_CHECKS |
2548 | if(u->wst.ptr < 3) { | 2548 | if(u->wst.ptr < 3) { |
2549 | u->wst.error = 1; | 2549 | u->wst.error = 1; |
@@ -2554,7 +2554,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2554 | } | 2554 | } |
2555 | case 0xb4: /* LDA2k */ | 2555 | case 0xb4: /* LDA2k */ |
2556 | { | 2556 | { |
2557 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 2557 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
2558 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a); | 2558 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a); |
2559 | u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, a + 1); | 2559 | u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, a + 1); |
2560 | #ifndef NO_STACK_CHECKS | 2560 | #ifndef NO_STACK_CHECKS |
@@ -2572,8 +2572,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2572 | } | 2572 | } |
2573 | case 0xb5: /* STA2k */ | 2573 | case 0xb5: /* STA2k */ |
2574 | { | 2574 | { |
2575 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | 2575 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
2576 | Uint16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 2576 | u16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
2577 | mempoke16(u->ram.dat, a, b); | 2577 | mempoke16(u->ram.dat, a, b); |
2578 | #ifndef NO_STACK_CHECKS | 2578 | #ifndef NO_STACK_CHECKS |
2579 | if(u->wst.ptr < 4) { | 2579 | if(u->wst.ptr < 4) { |
@@ -2585,7 +2585,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2585 | } | 2585 | } |
2586 | case 0xb6: /* DEI2k */ | 2586 | case 0xb6: /* DEI2k */ |
2587 | { | 2587 | { |
2588 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 2588 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
2589 | u->wst.dat[u->wst.ptr] = devpeek8(&u->dev[a >> 4], a); | 2589 | u->wst.dat[u->wst.ptr] = devpeek8(&u->dev[a >> 4], a); |
2590 | u->wst.dat[u->wst.ptr + 1] = devpeek8(&u->dev[a >> 4], a + 1); | 2590 | u->wst.dat[u->wst.ptr + 1] = devpeek8(&u->dev[a >> 4], a + 1); |
2591 | #ifndef NO_STACK_CHECKS | 2591 | #ifndef NO_STACK_CHECKS |
@@ -2603,8 +2603,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2603 | } | 2603 | } |
2604 | case 0xb7: /* DEO2k */ | 2604 | case 0xb7: /* DEO2k */ |
2605 | { | 2605 | { |
2606 | Uint8 a = u->wst.dat[u->wst.ptr - 1]; | 2606 | u8 a = u->wst.dat[u->wst.ptr - 1]; |
2607 | Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); | 2607 | u16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
2608 | devpoke16(&u->dev[a >> 4], a, b); | 2608 | devpoke16(&u->dev[a >> 4], a, b); |
2609 | #ifndef NO_STACK_CHECKS | 2609 | #ifndef NO_STACK_CHECKS |
2610 | if(u->wst.ptr < 3) { | 2610 | if(u->wst.ptr < 3) { |
@@ -2616,7 +2616,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2616 | } | 2616 | } |
2617 | case 0xb8: /* ADD2k */ | 2617 | case 0xb8: /* ADD2k */ |
2618 | { | 2618 | { |
2619 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 2619 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
2620 | u->wst.dat[u->wst.ptr] = (b + a) >> 8; | 2620 | u->wst.dat[u->wst.ptr] = (b + a) >> 8; |
2621 | u->wst.dat[u->wst.ptr + 1] = (b + a) & 0xff; | 2621 | u->wst.dat[u->wst.ptr + 1] = (b + a) & 0xff; |
2622 | #ifndef NO_STACK_CHECKS | 2622 | #ifndef NO_STACK_CHECKS |
@@ -2634,7 +2634,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2634 | } | 2634 | } |
2635 | case 0xb9: /* SUB2k */ | 2635 | case 0xb9: /* SUB2k */ |
2636 | { | 2636 | { |
2637 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 2637 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
2638 | u->wst.dat[u->wst.ptr] = (b - a) >> 8; | 2638 | u->wst.dat[u->wst.ptr] = (b - a) >> 8; |
2639 | u->wst.dat[u->wst.ptr + 1] = (b - a) & 0xff; | 2639 | u->wst.dat[u->wst.ptr + 1] = (b - a) & 0xff; |
2640 | #ifndef NO_STACK_CHECKS | 2640 | #ifndef NO_STACK_CHECKS |
@@ -2652,7 +2652,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2652 | } | 2652 | } |
2653 | case 0xba: /* MUL2k */ | 2653 | case 0xba: /* MUL2k */ |
2654 | { | 2654 | { |
2655 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 2655 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
2656 | u->wst.dat[u->wst.ptr] = (b * a) >> 8; | 2656 | u->wst.dat[u->wst.ptr] = (b * a) >> 8; |
2657 | u->wst.dat[u->wst.ptr + 1] = (b * a) & 0xff; | 2657 | u->wst.dat[u->wst.ptr + 1] = (b * a) & 0xff; |
2658 | #ifndef NO_STACK_CHECKS | 2658 | #ifndef NO_STACK_CHECKS |
@@ -2670,7 +2670,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2670 | } | 2670 | } |
2671 | case 0xbb: /* DIV2k */ | 2671 | case 0xbb: /* DIV2k */ |
2672 | { | 2672 | { |
2673 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 2673 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
2674 | u->wst.dat[u->wst.ptr] = (b / a) >> 8; | 2674 | u->wst.dat[u->wst.ptr] = (b / a) >> 8; |
2675 | u->wst.dat[u->wst.ptr + 1] = (b / a) & 0xff; | 2675 | u->wst.dat[u->wst.ptr + 1] = (b / a) & 0xff; |
2676 | #ifndef NO_STACK_CHECKS | 2676 | #ifndef NO_STACK_CHECKS |
@@ -2688,7 +2688,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2688 | } | 2688 | } |
2689 | case 0xbc: /* AND2k */ | 2689 | case 0xbc: /* AND2k */ |
2690 | { | 2690 | { |
2691 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; | 2691 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
2692 | u->wst.dat[u->wst.ptr] = d & b; | 2692 | u->wst.dat[u->wst.ptr] = d & b; |
2693 | u->wst.dat[u->wst.ptr + 1] = c & a; | 2693 | u->wst.dat[u->wst.ptr + 1] = c & a; |
2694 | #ifndef NO_STACK_CHECKS | 2694 | #ifndef NO_STACK_CHECKS |
@@ -2706,7 +2706,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2706 | } | 2706 | } |
2707 | case 0xbd: /* ORA2k */ | 2707 | case 0xbd: /* ORA2k */ |
2708 | { | 2708 | { |
2709 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; | 2709 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
2710 | u->wst.dat[u->wst.ptr] = d | b; | 2710 | u->wst.dat[u->wst.ptr] = d | b; |
2711 | u->wst.dat[u->wst.ptr + 1] = c | a; | 2711 | u->wst.dat[u->wst.ptr + 1] = c | a; |
2712 | #ifndef NO_STACK_CHECKS | 2712 | #ifndef NO_STACK_CHECKS |
@@ -2724,7 +2724,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2724 | } | 2724 | } |
2725 | case 0xbe: /* EOR2k */ | 2725 | case 0xbe: /* EOR2k */ |
2726 | { | 2726 | { |
2727 | Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; | 2727 | u8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
2728 | u->wst.dat[u->wst.ptr] = d ^ b; | 2728 | u->wst.dat[u->wst.ptr] = d ^ b; |
2729 | u->wst.dat[u->wst.ptr + 1] = c ^ a; | 2729 | u->wst.dat[u->wst.ptr + 1] = c ^ a; |
2730 | #ifndef NO_STACK_CHECKS | 2730 | #ifndef NO_STACK_CHECKS |
@@ -2742,7 +2742,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2742 | } | 2742 | } |
2743 | case 0xbf: /* SFT2k */ | 2743 | case 0xbf: /* SFT2k */ |
2744 | { | 2744 | { |
2745 | Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); | 2745 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
2746 | u->wst.dat[u->wst.ptr] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) >> 8; | 2746 | u->wst.dat[u->wst.ptr] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) >> 8; |
2747 | u->wst.dat[u->wst.ptr + 1] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) & 0xff; | 2747 | u->wst.dat[u->wst.ptr + 1] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) & 0xff; |
2748 | #ifndef NO_STACK_CHECKS | 2748 | #ifndef NO_STACK_CHECKS |
@@ -2771,7 +2771,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2771 | } | 2771 | } |
2772 | case 0xc4: /* DUPkr */ | 2772 | case 0xc4: /* DUPkr */ |
2773 | { | 2773 | { |
2774 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 2774 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
2775 | u->rst.dat[u->rst.ptr] = a; | 2775 | u->rst.dat[u->rst.ptr] = a; |
2776 | u->rst.dat[u->rst.ptr + 1] = a; | 2776 | u->rst.dat[u->rst.ptr + 1] = a; |
2777 | #ifndef NO_STACK_CHECKS | 2777 | #ifndef NO_STACK_CHECKS |
@@ -2789,7 +2789,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2789 | } | 2789 | } |
2790 | case 0xc5: /* SWPkr */ | 2790 | case 0xc5: /* SWPkr */ |
2791 | { | 2791 | { |
2792 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 2792 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
2793 | u->rst.dat[u->rst.ptr] = a; | 2793 | u->rst.dat[u->rst.ptr] = a; |
2794 | u->rst.dat[u->rst.ptr + 1] = b; | 2794 | u->rst.dat[u->rst.ptr + 1] = b; |
2795 | #ifndef NO_STACK_CHECKS | 2795 | #ifndef NO_STACK_CHECKS |
@@ -2807,7 +2807,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2807 | } | 2807 | } |
2808 | case 0xc6: /* OVRkr */ | 2808 | case 0xc6: /* OVRkr */ |
2809 | { | 2809 | { |
2810 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 2810 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
2811 | u->rst.dat[u->rst.ptr] = b; | 2811 | u->rst.dat[u->rst.ptr] = b; |
2812 | u->rst.dat[u->rst.ptr + 1] = a; | 2812 | u->rst.dat[u->rst.ptr + 1] = a; |
2813 | u->rst.dat[u->rst.ptr + 2] = b; | 2813 | u->rst.dat[u->rst.ptr + 2] = b; |
@@ -2826,7 +2826,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2826 | } | 2826 | } |
2827 | case 0xc7: /* ROTkr */ | 2827 | case 0xc7: /* ROTkr */ |
2828 | { | 2828 | { |
2829 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3]; | 2829 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3]; |
2830 | u->rst.dat[u->rst.ptr] = b; | 2830 | u->rst.dat[u->rst.ptr] = b; |
2831 | u->rst.dat[u->rst.ptr + 1] = a; | 2831 | u->rst.dat[u->rst.ptr + 1] = a; |
2832 | u->rst.dat[u->rst.ptr + 2] = c; | 2832 | u->rst.dat[u->rst.ptr + 2] = c; |
@@ -2845,7 +2845,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2845 | } | 2845 | } |
2846 | case 0xc8: /* EQUkr */ | 2846 | case 0xc8: /* EQUkr */ |
2847 | { | 2847 | { |
2848 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 2848 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
2849 | u->rst.dat[u->rst.ptr] = b == a; | 2849 | u->rst.dat[u->rst.ptr] = b == a; |
2850 | #ifndef NO_STACK_CHECKS | 2850 | #ifndef NO_STACK_CHECKS |
2851 | if(u->rst.ptr < 2) { | 2851 | if(u->rst.ptr < 2) { |
@@ -2862,7 +2862,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2862 | } | 2862 | } |
2863 | case 0xc9: /* NEQkr */ | 2863 | case 0xc9: /* NEQkr */ |
2864 | { | 2864 | { |
2865 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 2865 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
2866 | u->rst.dat[u->rst.ptr] = b != a; | 2866 | u->rst.dat[u->rst.ptr] = b != a; |
2867 | #ifndef NO_STACK_CHECKS | 2867 | #ifndef NO_STACK_CHECKS |
2868 | if(u->rst.ptr < 2) { | 2868 | if(u->rst.ptr < 2) { |
@@ -2879,7 +2879,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2879 | } | 2879 | } |
2880 | case 0xca: /* GTHkr */ | 2880 | case 0xca: /* GTHkr */ |
2881 | { | 2881 | { |
2882 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 2882 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
2883 | u->rst.dat[u->rst.ptr] = b > a; | 2883 | u->rst.dat[u->rst.ptr] = b > a; |
2884 | #ifndef NO_STACK_CHECKS | 2884 | #ifndef NO_STACK_CHECKS |
2885 | if(u->rst.ptr < 2) { | 2885 | if(u->rst.ptr < 2) { |
@@ -2896,7 +2896,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2896 | } | 2896 | } |
2897 | case 0xcb: /* LTHkr */ | 2897 | case 0xcb: /* LTHkr */ |
2898 | { | 2898 | { |
2899 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 2899 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
2900 | u->rst.dat[u->rst.ptr] = b < a; | 2900 | u->rst.dat[u->rst.ptr] = b < a; |
2901 | #ifndef NO_STACK_CHECKS | 2901 | #ifndef NO_STACK_CHECKS |
2902 | if(u->rst.ptr < 2) { | 2902 | if(u->rst.ptr < 2) { |
@@ -2913,8 +2913,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2913 | } | 2913 | } |
2914 | case 0xcc: /* JMPkr */ | 2914 | case 0xcc: /* JMPkr */ |
2915 | { | 2915 | { |
2916 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 2916 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
2917 | u->ram.ptr += (Sint8)a; | 2917 | u->ram.ptr += (s8)a; |
2918 | #ifndef NO_STACK_CHECKS | 2918 | #ifndef NO_STACK_CHECKS |
2919 | if(u->rst.ptr < 1) { | 2919 | if(u->rst.ptr < 1) { |
2920 | u->rst.error = 1; | 2920 | u->rst.error = 1; |
@@ -2925,8 +2925,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2925 | } | 2925 | } |
2926 | case 0xcd: /* JCNkr */ | 2926 | case 0xcd: /* JCNkr */ |
2927 | { | 2927 | { |
2928 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 2928 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
2929 | if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a; | 2929 | if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (s8)a; |
2930 | #ifndef NO_STACK_CHECKS | 2930 | #ifndef NO_STACK_CHECKS |
2931 | if(u->rst.ptr < 2) { | 2931 | if(u->rst.ptr < 2) { |
2932 | u->rst.error = 1; | 2932 | u->rst.error = 1; |
@@ -2937,10 +2937,10 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2937 | } | 2937 | } |
2938 | case 0xce: /* JSRkr */ | 2938 | case 0xce: /* JSRkr */ |
2939 | { | 2939 | { |
2940 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 2940 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
2941 | u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; | 2941 | u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; |
2942 | u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; | 2942 | u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; |
2943 | u->ram.ptr += (Sint8)a; | 2943 | u->ram.ptr += (s8)a; |
2944 | #ifndef NO_STACK_CHECKS | 2944 | #ifndef NO_STACK_CHECKS |
2945 | if(u->rst.ptr < 1) { | 2945 | if(u->rst.ptr < 1) { |
2946 | u->rst.error = 1; | 2946 | u->rst.error = 1; |
@@ -2958,7 +2958,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2958 | } | 2958 | } |
2959 | case 0xcf: /* STHkr */ | 2959 | case 0xcf: /* STHkr */ |
2960 | { | 2960 | { |
2961 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 2961 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
2962 | u->wst.dat[u->wst.ptr] = a; | 2962 | u->wst.dat[u->wst.ptr] = a; |
2963 | #ifndef NO_STACK_CHECKS | 2963 | #ifndef NO_STACK_CHECKS |
2964 | if(u->rst.ptr < 1) { | 2964 | if(u->rst.ptr < 1) { |
@@ -2977,7 +2977,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2977 | } | 2977 | } |
2978 | case 0xd0: /* LDZkr */ | 2978 | case 0xd0: /* LDZkr */ |
2979 | { | 2979 | { |
2980 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 2980 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
2981 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a); | 2981 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a); |
2982 | #ifndef NO_STACK_CHECKS | 2982 | #ifndef NO_STACK_CHECKS |
2983 | if(u->rst.ptr < 1) { | 2983 | if(u->rst.ptr < 1) { |
@@ -2994,8 +2994,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
2994 | } | 2994 | } |
2995 | case 0xd1: /* STZkr */ | 2995 | case 0xd1: /* STZkr */ |
2996 | { | 2996 | { |
2997 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 2997 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
2998 | Uint8 b = u->rst.dat[u->rst.ptr - 2]; | 2998 | u8 b = u->rst.dat[u->rst.ptr - 2]; |
2999 | mempoke8(u->ram.dat, a, b); | 2999 | mempoke8(u->ram.dat, a, b); |
3000 | #ifndef NO_STACK_CHECKS | 3000 | #ifndef NO_STACK_CHECKS |
3001 | if(u->rst.ptr < 2) { | 3001 | if(u->rst.ptr < 2) { |
@@ -3007,8 +3007,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3007 | } | 3007 | } |
3008 | case 0xd2: /* LDRkr */ | 3008 | case 0xd2: /* LDRkr */ |
3009 | { | 3009 | { |
3010 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 3010 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
3011 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); | 3011 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (s8)a); |
3012 | #ifndef NO_STACK_CHECKS | 3012 | #ifndef NO_STACK_CHECKS |
3013 | if(u->rst.ptr < 1) { | 3013 | if(u->rst.ptr < 1) { |
3014 | u->rst.error = 1; | 3014 | u->rst.error = 1; |
@@ -3024,9 +3024,9 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3024 | } | 3024 | } |
3025 | case 0xd3: /* STRkr */ | 3025 | case 0xd3: /* STRkr */ |
3026 | { | 3026 | { |
3027 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 3027 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
3028 | Uint8 b = u->rst.dat[u->rst.ptr - 2]; | 3028 | u8 b = u->rst.dat[u->rst.ptr - 2]; |
3029 | mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); | 3029 | mempoke8(u->ram.dat, u->ram.ptr + (s8)a, b); |
3030 | #ifndef NO_STACK_CHECKS | 3030 | #ifndef NO_STACK_CHECKS |
3031 | if(u->rst.ptr < 2) { | 3031 | if(u->rst.ptr < 2) { |
3032 | u->rst.error = 1; | 3032 | u->rst.error = 1; |
@@ -3037,7 +3037,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3037 | } | 3037 | } |
3038 | case 0xd4: /* LDAkr */ | 3038 | case 0xd4: /* LDAkr */ |
3039 | { | 3039 | { |
3040 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 3040 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
3041 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a); | 3041 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a); |
3042 | #ifndef NO_STACK_CHECKS | 3042 | #ifndef NO_STACK_CHECKS |
3043 | if(u->rst.ptr < 2) { | 3043 | if(u->rst.ptr < 2) { |
@@ -3054,8 +3054,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3054 | } | 3054 | } |
3055 | case 0xd5: /* STAkr */ | 3055 | case 0xd5: /* STAkr */ |
3056 | { | 3056 | { |
3057 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 3057 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
3058 | Uint8 b = u->rst.dat[u->rst.ptr - 3]; | 3058 | u8 b = u->rst.dat[u->rst.ptr - 3]; |
3059 | mempoke8(u->ram.dat, a, b); | 3059 | mempoke8(u->ram.dat, a, b); |
3060 | #ifndef NO_STACK_CHECKS | 3060 | #ifndef NO_STACK_CHECKS |
3061 | if(u->rst.ptr < 3) { | 3061 | if(u->rst.ptr < 3) { |
@@ -3067,7 +3067,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3067 | } | 3067 | } |
3068 | case 0xd6: /* DEIkr */ | 3068 | case 0xd6: /* DEIkr */ |
3069 | { | 3069 | { |
3070 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 3070 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
3071 | u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a); | 3071 | u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a); |
3072 | #ifndef NO_STACK_CHECKS | 3072 | #ifndef NO_STACK_CHECKS |
3073 | if(u->rst.ptr < 1) { | 3073 | if(u->rst.ptr < 1) { |
@@ -3084,7 +3084,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3084 | } | 3084 | } |
3085 | case 0xd7: /* DEOkr */ | 3085 | case 0xd7: /* DEOkr */ |
3086 | { | 3086 | { |
3087 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 3087 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
3088 | devpoke8(&u->dev[a >> 4], a, b); | 3088 | devpoke8(&u->dev[a >> 4], a, b); |
3089 | #ifndef NO_STACK_CHECKS | 3089 | #ifndef NO_STACK_CHECKS |
3090 | if(u->rst.ptr < 2) { | 3090 | if(u->rst.ptr < 2) { |
@@ -3096,7 +3096,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3096 | } | 3096 | } |
3097 | case 0xd8: /* ADDkr */ | 3097 | case 0xd8: /* ADDkr */ |
3098 | { | 3098 | { |
3099 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 3099 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
3100 | u->rst.dat[u->rst.ptr] = b + a; | 3100 | u->rst.dat[u->rst.ptr] = b + a; |
3101 | #ifndef NO_STACK_CHECKS | 3101 | #ifndef NO_STACK_CHECKS |
3102 | if(u->rst.ptr < 2) { | 3102 | if(u->rst.ptr < 2) { |
@@ -3113,7 +3113,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3113 | } | 3113 | } |
3114 | case 0xd9: /* SUBkr */ | 3114 | case 0xd9: /* SUBkr */ |
3115 | { | 3115 | { |
3116 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 3116 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
3117 | u->rst.dat[u->rst.ptr] = b - a; | 3117 | u->rst.dat[u->rst.ptr] = b - a; |
3118 | #ifndef NO_STACK_CHECKS | 3118 | #ifndef NO_STACK_CHECKS |
3119 | if(u->rst.ptr < 2) { | 3119 | if(u->rst.ptr < 2) { |
@@ -3130,7 +3130,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3130 | } | 3130 | } |
3131 | case 0xda: /* MULkr */ | 3131 | case 0xda: /* MULkr */ |
3132 | { | 3132 | { |
3133 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 3133 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
3134 | u->rst.dat[u->rst.ptr] = b * a; | 3134 | u->rst.dat[u->rst.ptr] = b * a; |
3135 | #ifndef NO_STACK_CHECKS | 3135 | #ifndef NO_STACK_CHECKS |
3136 | if(u->rst.ptr < 2) { | 3136 | if(u->rst.ptr < 2) { |
@@ -3147,7 +3147,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3147 | } | 3147 | } |
3148 | case 0xdb: /* DIVkr */ | 3148 | case 0xdb: /* DIVkr */ |
3149 | { | 3149 | { |
3150 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 3150 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
3151 | u->rst.dat[u->rst.ptr] = b / a; | 3151 | u->rst.dat[u->rst.ptr] = b / a; |
3152 | #ifndef NO_STACK_CHECKS | 3152 | #ifndef NO_STACK_CHECKS |
3153 | if(u->rst.ptr < 2) { | 3153 | if(u->rst.ptr < 2) { |
@@ -3164,7 +3164,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3164 | } | 3164 | } |
3165 | case 0xdc: /* ANDkr */ | 3165 | case 0xdc: /* ANDkr */ |
3166 | { | 3166 | { |
3167 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 3167 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
3168 | u->rst.dat[u->rst.ptr] = b & a; | 3168 | u->rst.dat[u->rst.ptr] = b & a; |
3169 | #ifndef NO_STACK_CHECKS | 3169 | #ifndef NO_STACK_CHECKS |
3170 | if(u->rst.ptr < 2) { | 3170 | if(u->rst.ptr < 2) { |
@@ -3181,7 +3181,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3181 | } | 3181 | } |
3182 | case 0xdd: /* ORAkr */ | 3182 | case 0xdd: /* ORAkr */ |
3183 | { | 3183 | { |
3184 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 3184 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
3185 | u->rst.dat[u->rst.ptr] = b | a; | 3185 | u->rst.dat[u->rst.ptr] = b | a; |
3186 | #ifndef NO_STACK_CHECKS | 3186 | #ifndef NO_STACK_CHECKS |
3187 | if(u->rst.ptr < 2) { | 3187 | if(u->rst.ptr < 2) { |
@@ -3198,7 +3198,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3198 | } | 3198 | } |
3199 | case 0xde: /* EORkr */ | 3199 | case 0xde: /* EORkr */ |
3200 | { | 3200 | { |
3201 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 3201 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
3202 | u->rst.dat[u->rst.ptr] = b ^ a; | 3202 | u->rst.dat[u->rst.ptr] = b ^ a; |
3203 | #ifndef NO_STACK_CHECKS | 3203 | #ifndef NO_STACK_CHECKS |
3204 | if(u->rst.ptr < 2) { | 3204 | if(u->rst.ptr < 2) { |
@@ -3215,7 +3215,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3215 | } | 3215 | } |
3216 | case 0xdf: /* SFTkr */ | 3216 | case 0xdf: /* SFTkr */ |
3217 | { | 3217 | { |
3218 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; | 3218 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
3219 | u->rst.dat[u->rst.ptr] = b >> (a & 0x07) << ((a & 0x70) >> 4); | 3219 | u->rst.dat[u->rst.ptr] = b >> (a & 0x07) << ((a & 0x70) >> 4); |
3220 | #ifndef NO_STACK_CHECKS | 3220 | #ifndef NO_STACK_CHECKS |
3221 | if(u->rst.ptr < 2) { | 3221 | if(u->rst.ptr < 2) { |
@@ -3243,7 +3243,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3243 | } | 3243 | } |
3244 | case 0xe4: /* DUP2kr */ | 3244 | case 0xe4: /* DUP2kr */ |
3245 | { | 3245 | { |
3246 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 3246 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
3247 | u->rst.dat[u->rst.ptr] = a >> 8; | 3247 | u->rst.dat[u->rst.ptr] = a >> 8; |
3248 | u->rst.dat[u->rst.ptr + 1] = a & 0xff; | 3248 | u->rst.dat[u->rst.ptr + 1] = a & 0xff; |
3249 | u->rst.dat[u->rst.ptr + 2] = a >> 8; | 3249 | u->rst.dat[u->rst.ptr + 2] = a >> 8; |
@@ -3263,7 +3263,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3263 | } | 3263 | } |
3264 | case 0xe5: /* SWP2kr */ | 3264 | case 0xe5: /* SWP2kr */ |
3265 | { | 3265 | { |
3266 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 3266 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
3267 | u->rst.dat[u->rst.ptr] = a >> 8; | 3267 | u->rst.dat[u->rst.ptr] = a >> 8; |
3268 | u->rst.dat[u->rst.ptr + 1] = a & 0xff; | 3268 | u->rst.dat[u->rst.ptr + 1] = a & 0xff; |
3269 | u->rst.dat[u->rst.ptr + 2] = b >> 8; | 3269 | u->rst.dat[u->rst.ptr + 2] = b >> 8; |
@@ -3283,7 +3283,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3283 | } | 3283 | } |
3284 | case 0xe6: /* OVR2kr */ | 3284 | case 0xe6: /* OVR2kr */ |
3285 | { | 3285 | { |
3286 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 3286 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
3287 | u->rst.dat[u->rst.ptr] = b >> 8; | 3287 | u->rst.dat[u->rst.ptr] = b >> 8; |
3288 | u->rst.dat[u->rst.ptr + 1] = b & 0xff; | 3288 | u->rst.dat[u->rst.ptr + 1] = b & 0xff; |
3289 | u->rst.dat[u->rst.ptr + 2] = a >> 8; | 3289 | u->rst.dat[u->rst.ptr + 2] = a >> 8; |
@@ -3305,7 +3305,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3305 | } | 3305 | } |
3306 | case 0xe7: /* ROT2kr */ | 3306 | case 0xe7: /* ROT2kr */ |
3307 | { | 3307 | { |
3308 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)), c = (u->rst.dat[u->rst.ptr - 5] | (u->rst.dat[u->rst.ptr - 6] << 8)); | 3308 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)), c = (u->rst.dat[u->rst.ptr - 5] | (u->rst.dat[u->rst.ptr - 6] << 8)); |
3309 | u->rst.dat[u->rst.ptr] = b >> 8; | 3309 | u->rst.dat[u->rst.ptr] = b >> 8; |
3310 | u->rst.dat[u->rst.ptr + 1] = b & 0xff; | 3310 | u->rst.dat[u->rst.ptr + 1] = b & 0xff; |
3311 | u->rst.dat[u->rst.ptr + 2] = a >> 8; | 3311 | u->rst.dat[u->rst.ptr + 2] = a >> 8; |
@@ -3327,7 +3327,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3327 | } | 3327 | } |
3328 | case 0xe8: /* EQU2kr */ | 3328 | case 0xe8: /* EQU2kr */ |
3329 | { | 3329 | { |
3330 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 3330 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
3331 | u->rst.dat[u->rst.ptr] = b == a; | 3331 | u->rst.dat[u->rst.ptr] = b == a; |
3332 | #ifndef NO_STACK_CHECKS | 3332 | #ifndef NO_STACK_CHECKS |
3333 | if(u->rst.ptr < 4) { | 3333 | if(u->rst.ptr < 4) { |
@@ -3344,7 +3344,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3344 | } | 3344 | } |
3345 | case 0xe9: /* NEQ2kr */ | 3345 | case 0xe9: /* NEQ2kr */ |
3346 | { | 3346 | { |
3347 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 3347 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
3348 | u->rst.dat[u->rst.ptr] = b != a; | 3348 | u->rst.dat[u->rst.ptr] = b != a; |
3349 | #ifndef NO_STACK_CHECKS | 3349 | #ifndef NO_STACK_CHECKS |
3350 | if(u->rst.ptr < 4) { | 3350 | if(u->rst.ptr < 4) { |
@@ -3361,7 +3361,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3361 | } | 3361 | } |
3362 | case 0xea: /* GTH2kr */ | 3362 | case 0xea: /* GTH2kr */ |
3363 | { | 3363 | { |
3364 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 3364 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
3365 | u->rst.dat[u->rst.ptr] = b > a; | 3365 | u->rst.dat[u->rst.ptr] = b > a; |
3366 | #ifndef NO_STACK_CHECKS | 3366 | #ifndef NO_STACK_CHECKS |
3367 | if(u->rst.ptr < 4) { | 3367 | if(u->rst.ptr < 4) { |
@@ -3378,7 +3378,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3378 | } | 3378 | } |
3379 | case 0xeb: /* LTH2kr */ | 3379 | case 0xeb: /* LTH2kr */ |
3380 | { | 3380 | { |
3381 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 3381 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
3382 | u->rst.dat[u->rst.ptr] = b < a; | 3382 | u->rst.dat[u->rst.ptr] = b < a; |
3383 | #ifndef NO_STACK_CHECKS | 3383 | #ifndef NO_STACK_CHECKS |
3384 | if(u->rst.ptr < 4) { | 3384 | if(u->rst.ptr < 4) { |
@@ -3406,7 +3406,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3406 | } | 3406 | } |
3407 | case 0xed: /* JCN2kr */ | 3407 | case 0xed: /* JCN2kr */ |
3408 | { | 3408 | { |
3409 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 3409 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
3410 | if(u->rst.dat[u->rst.ptr - 3]) u->ram.ptr = a; | 3410 | if(u->rst.dat[u->rst.ptr - 3]) u->ram.ptr = a; |
3411 | #ifndef NO_STACK_CHECKS | 3411 | #ifndef NO_STACK_CHECKS |
3412 | if(u->rst.ptr < 3) { | 3412 | if(u->rst.ptr < 3) { |
@@ -3438,7 +3438,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3438 | } | 3438 | } |
3439 | case 0xef: /* STH2kr */ | 3439 | case 0xef: /* STH2kr */ |
3440 | { | 3440 | { |
3441 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 3441 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
3442 | u->wst.dat[u->wst.ptr] = a >> 8; | 3442 | u->wst.dat[u->wst.ptr] = a >> 8; |
3443 | u->wst.dat[u->wst.ptr + 1] = a & 0xff; | 3443 | u->wst.dat[u->wst.ptr + 1] = a & 0xff; |
3444 | #ifndef NO_STACK_CHECKS | 3444 | #ifndef NO_STACK_CHECKS |
@@ -3458,7 +3458,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3458 | } | 3458 | } |
3459 | case 0xf0: /* LDZ2kr */ | 3459 | case 0xf0: /* LDZ2kr */ |
3460 | { | 3460 | { |
3461 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 3461 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
3462 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a); | 3462 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a); |
3463 | u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, a + 1); | 3463 | u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, a + 1); |
3464 | #ifndef NO_STACK_CHECKS | 3464 | #ifndef NO_STACK_CHECKS |
@@ -3476,8 +3476,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3476 | } | 3476 | } |
3477 | case 0xf1: /* STZ2kr */ | 3477 | case 0xf1: /* STZ2kr */ |
3478 | { | 3478 | { |
3479 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 3479 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
3480 | Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); | 3480 | u16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
3481 | mempoke16(u->ram.dat, a, b); | 3481 | mempoke16(u->ram.dat, a, b); |
3482 | #ifndef NO_STACK_CHECKS | 3482 | #ifndef NO_STACK_CHECKS |
3483 | if(u->rst.ptr < 3) { | 3483 | if(u->rst.ptr < 3) { |
@@ -3489,9 +3489,9 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3489 | } | 3489 | } |
3490 | case 0xf2: /* LDR2kr */ | 3490 | case 0xf2: /* LDR2kr */ |
3491 | { | 3491 | { |
3492 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 3492 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
3493 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); | 3493 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (s8)a); |
3494 | u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); | 3494 | u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr + (s8)a + 1); |
3495 | #ifndef NO_STACK_CHECKS | 3495 | #ifndef NO_STACK_CHECKS |
3496 | if(u->rst.ptr < 1) { | 3496 | if(u->rst.ptr < 1) { |
3497 | u->rst.error = 1; | 3497 | u->rst.error = 1; |
@@ -3507,9 +3507,9 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3507 | } | 3507 | } |
3508 | case 0xf3: /* STR2kr */ | 3508 | case 0xf3: /* STR2kr */ |
3509 | { | 3509 | { |
3510 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 3510 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
3511 | Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); | 3511 | u16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
3512 | mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); | 3512 | mempoke16(u->ram.dat, u->ram.ptr + (s8)a, b); |
3513 | #ifndef NO_STACK_CHECKS | 3513 | #ifndef NO_STACK_CHECKS |
3514 | if(u->rst.ptr < 3) { | 3514 | if(u->rst.ptr < 3) { |
3515 | u->rst.error = 1; | 3515 | u->rst.error = 1; |
@@ -3520,7 +3520,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3520 | } | 3520 | } |
3521 | case 0xf4: /* LDA2kr */ | 3521 | case 0xf4: /* LDA2kr */ |
3522 | { | 3522 | { |
3523 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 3523 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
3524 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a); | 3524 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a); |
3525 | u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, a + 1); | 3525 | u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, a + 1); |
3526 | #ifndef NO_STACK_CHECKS | 3526 | #ifndef NO_STACK_CHECKS |
@@ -3538,8 +3538,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3538 | } | 3538 | } |
3539 | case 0xf5: /* STA2kr */ | 3539 | case 0xf5: /* STA2kr */ |
3540 | { | 3540 | { |
3541 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | 3541 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
3542 | Uint16 b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 3542 | u16 b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
3543 | mempoke16(u->ram.dat, a, b); | 3543 | mempoke16(u->ram.dat, a, b); |
3544 | #ifndef NO_STACK_CHECKS | 3544 | #ifndef NO_STACK_CHECKS |
3545 | if(u->rst.ptr < 4) { | 3545 | if(u->rst.ptr < 4) { |
@@ -3551,7 +3551,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3551 | } | 3551 | } |
3552 | case 0xf6: /* DEI2kr */ | 3552 | case 0xf6: /* DEI2kr */ |
3553 | { | 3553 | { |
3554 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 3554 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
3555 | u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a); | 3555 | u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a); |
3556 | u->rst.dat[u->rst.ptr + 1] = devpeek8(&u->dev[a >> 4], a + 1); | 3556 | u->rst.dat[u->rst.ptr + 1] = devpeek8(&u->dev[a >> 4], a + 1); |
3557 | #ifndef NO_STACK_CHECKS | 3557 | #ifndef NO_STACK_CHECKS |
@@ -3569,8 +3569,8 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3569 | } | 3569 | } |
3570 | case 0xf7: /* DEO2kr */ | 3570 | case 0xf7: /* DEO2kr */ |
3571 | { | 3571 | { |
3572 | Uint8 a = u->rst.dat[u->rst.ptr - 1]; | 3572 | u8 a = u->rst.dat[u->rst.ptr - 1]; |
3573 | Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); | 3573 | u16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
3574 | devpoke16(&u->dev[a >> 4], a, b); | 3574 | devpoke16(&u->dev[a >> 4], a, b); |
3575 | #ifndef NO_STACK_CHECKS | 3575 | #ifndef NO_STACK_CHECKS |
3576 | if(u->rst.ptr < 3) { | 3576 | if(u->rst.ptr < 3) { |
@@ -3582,7 +3582,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3582 | } | 3582 | } |
3583 | case 0xf8: /* ADD2kr */ | 3583 | case 0xf8: /* ADD2kr */ |
3584 | { | 3584 | { |
3585 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 3585 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
3586 | u->rst.dat[u->rst.ptr] = (b + a) >> 8; | 3586 | u->rst.dat[u->rst.ptr] = (b + a) >> 8; |
3587 | u->rst.dat[u->rst.ptr + 1] = (b + a) & 0xff; | 3587 | u->rst.dat[u->rst.ptr + 1] = (b + a) & 0xff; |
3588 | #ifndef NO_STACK_CHECKS | 3588 | #ifndef NO_STACK_CHECKS |
@@ -3600,7 +3600,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3600 | } | 3600 | } |
3601 | case 0xf9: /* SUB2kr */ | 3601 | case 0xf9: /* SUB2kr */ |
3602 | { | 3602 | { |
3603 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 3603 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
3604 | u->rst.dat[u->rst.ptr] = (b - a) >> 8; | 3604 | u->rst.dat[u->rst.ptr] = (b - a) >> 8; |
3605 | u->rst.dat[u->rst.ptr + 1] = (b - a) & 0xff; | 3605 | u->rst.dat[u->rst.ptr + 1] = (b - a) & 0xff; |
3606 | #ifndef NO_STACK_CHECKS | 3606 | #ifndef NO_STACK_CHECKS |
@@ -3618,7 +3618,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3618 | } | 3618 | } |
3619 | case 0xfa: /* MUL2kr */ | 3619 | case 0xfa: /* MUL2kr */ |
3620 | { | 3620 | { |
3621 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 3621 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
3622 | u->rst.dat[u->rst.ptr] = (b * a) >> 8; | 3622 | u->rst.dat[u->rst.ptr] = (b * a) >> 8; |
3623 | u->rst.dat[u->rst.ptr + 1] = (b * a) & 0xff; | 3623 | u->rst.dat[u->rst.ptr + 1] = (b * a) & 0xff; |
3624 | #ifndef NO_STACK_CHECKS | 3624 | #ifndef NO_STACK_CHECKS |
@@ -3636,7 +3636,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3636 | } | 3636 | } |
3637 | case 0xfb: /* DIV2kr */ | 3637 | case 0xfb: /* DIV2kr */ |
3638 | { | 3638 | { |
3639 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 3639 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
3640 | u->rst.dat[u->rst.ptr] = (b / a) >> 8; | 3640 | u->rst.dat[u->rst.ptr] = (b / a) >> 8; |
3641 | u->rst.dat[u->rst.ptr + 1] = (b / a) & 0xff; | 3641 | u->rst.dat[u->rst.ptr + 1] = (b / a) & 0xff; |
3642 | #ifndef NO_STACK_CHECKS | 3642 | #ifndef NO_STACK_CHECKS |
@@ -3654,7 +3654,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3654 | } | 3654 | } |
3655 | case 0xfc: /* AND2kr */ | 3655 | case 0xfc: /* AND2kr */ |
3656 | { | 3656 | { |
3657 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; | 3657 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
3658 | u->rst.dat[u->rst.ptr] = d & b; | 3658 | u->rst.dat[u->rst.ptr] = d & b; |
3659 | u->rst.dat[u->rst.ptr + 1] = c & a; | 3659 | u->rst.dat[u->rst.ptr + 1] = c & a; |
3660 | #ifndef NO_STACK_CHECKS | 3660 | #ifndef NO_STACK_CHECKS |
@@ -3672,7 +3672,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3672 | } | 3672 | } |
3673 | case 0xfd: /* ORA2kr */ | 3673 | case 0xfd: /* ORA2kr */ |
3674 | { | 3674 | { |
3675 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; | 3675 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
3676 | u->rst.dat[u->rst.ptr] = d | b; | 3676 | u->rst.dat[u->rst.ptr] = d | b; |
3677 | u->rst.dat[u->rst.ptr + 1] = c | a; | 3677 | u->rst.dat[u->rst.ptr + 1] = c | a; |
3678 | #ifndef NO_STACK_CHECKS | 3678 | #ifndef NO_STACK_CHECKS |
@@ -3690,7 +3690,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3690 | } | 3690 | } |
3691 | case 0xfe: /* EOR2kr */ | 3691 | case 0xfe: /* EOR2kr */ |
3692 | { | 3692 | { |
3693 | Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; | 3693 | u8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
3694 | u->rst.dat[u->rst.ptr] = d ^ b; | 3694 | u->rst.dat[u->rst.ptr] = d ^ b; |
3695 | u->rst.dat[u->rst.ptr + 1] = c ^ a; | 3695 | u->rst.dat[u->rst.ptr + 1] = c ^ a; |
3696 | #ifndef NO_STACK_CHECKS | 3696 | #ifndef NO_STACK_CHECKS |
@@ -3708,7 +3708,7 @@ evaluxn(Uxn *u, Uint16 vec) | |||
3708 | } | 3708 | } |
3709 | case 0xff: /* SFT2kr */ | 3709 | case 0xff: /* SFT2kr */ |
3710 | { | 3710 | { |
3711 | Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); | 3711 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
3712 | u->rst.dat[u->rst.ptr] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) >> 8; | 3712 | u->rst.dat[u->rst.ptr] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) >> 8; |
3713 | u->rst.dat[u->rst.ptr + 1] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) & 0xff; | 3713 | u->rst.dat[u->rst.ptr + 1] = (b >> (a & 0x000f) << ((a & 0x00f0) >> 4)) & 0xff; |
3714 | #ifndef NO_STACK_CHECKS | 3714 | #ifndef NO_STACK_CHECKS |
@@ -3756,7 +3756,7 @@ loaduxn(Uxn *u, char *filepath) | |||
3756 | } | 3756 | } |
3757 | 3757 | ||
3758 | Device * | 3758 | Device * |
3759 | portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *d, Uint8 b0, Uint8 w)) | 3759 | portuxn(Uxn *u, u8 id, char *name, void (*talkfn)(Device *d, u8 b0, u8 w)) |
3760 | { | 3760 | { |
3761 | Device *d = &u->dev[id]; | 3761 | Device *d = &u->dev[id]; |
3762 | d->addr = id * 0x10; | 3762 | d->addr = id * 0x10; |
diff --git a/src/uxn/uxn.h b/src/uxn/uxn.h index 6c6d53e..a4ab428 100644 --- a/src/uxn/uxn.h +++ b/src/uxn/uxn.h | |||
@@ -14,27 +14,22 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |||
14 | WITH REGARD TO THIS SOFTWARE. | 14 | WITH REGARD TO THIS SOFTWARE. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | typedef unsigned char Uint8; | ||
18 | typedef signed char Sint8; | ||
19 | typedef unsigned short Uint16; | ||
20 | typedef signed short Sint16; | ||
21 | |||
22 | #define PAGE_PROGRAM 0x0100 | 17 | #define PAGE_PROGRAM 0x0100 |
23 | 18 | ||
24 | typedef struct { | 19 | typedef struct { |
25 | Uint8 ptr, kptr, error; | 20 | u8 ptr, kptr, error; |
26 | Uint8 dat[256]; | 21 | u8 dat[256]; |
27 | } Stack; | 22 | } Stack; |
28 | 23 | ||
29 | typedef struct { | 24 | typedef struct { |
30 | Uint16 ptr; | 25 | u16 ptr; |
31 | Uint8 *dat; | 26 | u8 *dat; |
32 | } Memory; | 27 | } Memory; |
33 | 28 | ||
34 | typedef struct Device { | 29 | typedef struct Device { |
35 | struct Uxn *u; | 30 | struct Uxn *u; |
36 | Uint8 addr, dat[16], *mem; | 31 | u8 addr, dat[16], *mem; |
37 | void (*talk)(struct Device *d, Uint8, Uint8); | 32 | void (*talk)(struct Device *d, u8, u8); |
38 | } Device; | 33 | } Device; |
39 | 34 | ||
40 | typedef struct Uxn { | 35 | typedef struct Uxn { |
@@ -45,17 +40,17 @@ typedef struct Uxn { | |||
45 | 40 | ||
46 | struct Uxn; | 41 | struct Uxn; |
47 | 42 | ||
48 | static inline void mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; } | 43 | static inline void mempoke8(u8 *m, u16 a, u8 b) { m[a] = b; } |
49 | static inline Uint8 mempeek8(Uint8 *m, Uint16 a) { return m[a]; } | 44 | static inline u8 mempeek8(u8 *m, u16 a) { return m[a]; } |
50 | static inline void mempoke16(Uint8 *m, Uint16 a, Uint16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); } | 45 | static inline void mempoke16(u8 *m, u16 a, u16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); } |
51 | static inline Uint16 mempeek16(Uint8 *m, Uint16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); } | 46 | static inline u16 mempeek16(u8 *m, u16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); } |
52 | static inline void devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); } | 47 | static inline void devpoke8(Device *d, u8 a, u8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); } |
53 | static inline Uint8 devpeek8(Device *d, Uint8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; } | 48 | static inline u8 devpeek8(Device *d, u8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; } |
54 | static inline void devpoke16(Device *d, Uint8 a, Uint16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); } | 49 | static inline void devpoke16(Device *d, u8 a, u16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); } |
55 | static inline Uint16 devpeek16(Device *d, Uint16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); } | 50 | static inline u16 devpeek16(Device *d, u16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); } |
56 | 51 | ||
57 | int loaduxn(Uxn *c, char *filepath); | 52 | int loaduxn(Uxn *c, char *filepath); |
58 | int bootuxn(Uxn *c); | 53 | int bootuxn(Uxn *c); |
59 | int evaluxn(Uxn *u, Uint16 vec); | 54 | int evaluxn(Uxn *u, u16 vec); |
60 | Device *portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *, Uint8, Uint8)); | 55 | Device *portuxn(Uxn *u, u8 id, char *name, void (*talkfn)(Device *, u8, u8)); |
61 | #endif // UXNGBA_UXN_H | 56 | #endif // UXNGBA_UXN_H |
diff --git a/src/uxn/uxn/opcodes.c b/src/uxn/uxn/opcodes.c deleted file mode 100644 index 947755f..0000000 --- a/src/uxn/uxn/opcodes.c +++ /dev/null | |||
@@ -1,373 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (u) 2021 Devine Lu Linvega | ||
3 | Copyright (c) 2021 Adrian "asie" Siekierka | ||
4 | |||
5 | Permission to use, copy, modify, and distribute this software for any | ||
6 | purpose with or without fee is hereby granted, provided that the above | ||
7 | copyright notice and this permission notice appear in all copies. | ||
8 | |||
9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | WITH REGARD TO THIS SOFTWARE. | ||
11 | */ | ||
12 | |||
13 | /* 8-BIT OPCODES */ | ||
14 | |||
15 | case UXN_OPC(0x00): | ||
16 | case UXN_OPC(0x20): { // brk | ||
17 | u->ram.ptr = 0; | ||
18 | } break; | ||
19 | case UXN_OPC(0x01): { // lit | ||
20 | push8(UXN_SRC, mempeek8(u->ram.dat, u->ram.ptr++)); | ||
21 | } break; | ||
22 | case UXN_OPC(0x02): | ||
23 | case UXN_OPC(0x22): { // nop | ||
24 | } break; | ||
25 | case UXN_OPC(0x03): { // pop | ||
26 | UXN_KEEP_SYNC; | ||
27 | pop8(UXN_SRC); | ||
28 | } break; | ||
29 | case UXN_OPC(0x04): { // dup | ||
30 | UXN_KEEP_SYNC; | ||
31 | Uint8 a = pop8(UXN_SRC); | ||
32 | push8(UXN_SRC, a); | ||
33 | push8(UXN_SRC, a); | ||
34 | } break; | ||
35 | case UXN_OPC(0x05): { // swp | ||
36 | UXN_KEEP_SYNC; | ||
37 | Uint8 a = pop8(UXN_SRC); | ||
38 | Uint8 b = pop8(UXN_SRC); | ||
39 | push8(UXN_SRC, a); | ||
40 | push8(UXN_SRC, b); | ||
41 | } break; | ||
42 | case UXN_OPC(0x06): { // ovr | ||
43 | UXN_KEEP_SYNC; | ||
44 | Uint8 a = pop8(UXN_SRC); | ||
45 | Uint8 b = pop8(UXN_SRC); | ||
46 | push8(UXN_SRC, b); | ||
47 | push8(UXN_SRC, a); | ||
48 | push8(UXN_SRC, b); | ||
49 | } break; | ||
50 | case UXN_OPC(0x07): { // rot | ||
51 | UXN_KEEP_SYNC; | ||
52 | Uint8 a = pop8(UXN_SRC); | ||
53 | Uint8 b = pop8(UXN_SRC); | ||
54 | Uint8 c = pop8(UXN_SRC); | ||
55 | push8(UXN_SRC, b); | ||
56 | push8(UXN_SRC, a); | ||
57 | push8(UXN_SRC, c); | ||
58 | } break; | ||
59 | case UXN_OPC(0x08): { // equ | ||
60 | UXN_KEEP_SYNC; | ||
61 | Uint8 a = pop8(UXN_SRC); | ||
62 | Uint8 b = pop8(UXN_SRC); | ||
63 | push8(UXN_SRC, b == a); | ||
64 | } break; | ||
65 | case UXN_OPC(0x09): { // neg | ||
66 | UXN_KEEP_SYNC; | ||
67 | Uint8 a = pop8(UXN_SRC); | ||
68 | Uint8 b = pop8(UXN_SRC); | ||
69 | push8(UXN_SRC, b != a); | ||
70 | } break; | ||
71 | case UXN_OPC(0x0A): { // gth | ||
72 | UXN_KEEP_SYNC; | ||
73 | Uint8 a = pop8(UXN_SRC); | ||
74 | Uint8 b = pop8(UXN_SRC); | ||
75 | push8(UXN_SRC, b > a); | ||
76 | } break; | ||
77 | case UXN_OPC(0x0B): { // lth | ||
78 | UXN_KEEP_SYNC; | ||
79 | Uint8 a = pop8(UXN_SRC); | ||
80 | Uint8 b = pop8(UXN_SRC); | ||
81 | push8(UXN_SRC, b < a); | ||
82 | } break; | ||
83 | case UXN_OPC(0x0C): { // jmp | ||
84 | UXN_KEEP_SYNC; | ||
85 | Uint8 a = pop8(UXN_SRC); | ||
86 | u->ram.ptr += (Sint8)a; | ||
87 | } break; | ||
88 | case UXN_OPC(0x0D): { // jnz | ||
89 | UXN_KEEP_SYNC; | ||
90 | Uint8 a = pop8(UXN_SRC); | ||
91 | if (pop8(UXN_SRC)) | ||
92 | u->ram.ptr += (Sint8)a; | ||
93 | } break; | ||
94 | case UXN_OPC(0x0E): { // jsr | ||
95 | UXN_KEEP_SYNC; | ||
96 | Uint8 a = pop8(UXN_SRC); | ||
97 | push16(UXN_DST, u->ram.ptr); | ||
98 | u->ram.ptr += (Sint8)a; | ||
99 | } break; | ||
100 | case UXN_OPC(0x0F): { // sth | ||
101 | UXN_KEEP_SYNC; | ||
102 | Uint8 a = pop8(UXN_SRC); | ||
103 | push8(UXN_DST, a); | ||
104 | } break; | ||
105 | case UXN_OPC(0x10): { // pek | ||
106 | UXN_KEEP_SYNC; | ||
107 | Uint8 a = pop8(UXN_SRC); | ||
108 | push8(UXN_SRC, mempeek8(u->ram.dat, a)); | ||
109 | } break; | ||
110 | case UXN_OPC(0x11): { // pok | ||
111 | UXN_KEEP_SYNC; | ||
112 | Uint8 a = pop8(UXN_SRC); | ||
113 | Uint8 b = pop8(UXN_SRC); | ||
114 | mempoke8(u->ram.dat, a, b); | ||
115 | } break; | ||
116 | case UXN_OPC(0x12): { // ldr | ||
117 | UXN_KEEP_SYNC; | ||
118 | Uint8 a = pop8(UXN_SRC); | ||
119 | push8(UXN_SRC, mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a)); | ||
120 | } break; | ||
121 | case UXN_OPC(0x13): { // str | ||
122 | UXN_KEEP_SYNC; | ||
123 | Uint8 a = pop8(UXN_SRC); | ||
124 | Uint8 b = pop8(UXN_SRC); | ||
125 | mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); | ||
126 | } break; | ||
127 | case UXN_OPC(0x14): { // lda | ||
128 | UXN_KEEP_SYNC; | ||
129 | Uint16 a = pop16(UXN_SRC); | ||
130 | push8(UXN_SRC, mempeek8(u->ram.dat, a)); | ||
131 | } break; | ||
132 | case UXN_OPC(0x15): { // sta | ||
133 | UXN_KEEP_SYNC; | ||
134 | Uint16 a = pop16(UXN_SRC); | ||
135 | Uint8 b = pop8(UXN_SRC); | ||
136 | mempoke8(u->ram.dat, a, b); | ||
137 | } break; | ||
138 | case UXN_OPC(0x16): { // dei | ||
139 | UXN_KEEP_SYNC; | ||
140 | Uint8 a = pop8(UXN_SRC); | ||
141 | push8(UXN_SRC, devpeek8(&u->dev[a >> 4], a)); | ||
142 | } break; | ||
143 | case UXN_OPC(0x17): { // deo | ||
144 | UXN_KEEP_SYNC; | ||
145 | Uint8 a = pop8(UXN_SRC); | ||
146 | Uint8 b = pop8(UXN_SRC); | ||
147 | devpoke8(&u->dev[a >> 4], a, b); | ||
148 | } break; | ||
149 | case UXN_OPC(0x18): { // add | ||
150 | UXN_KEEP_SYNC; | ||
151 | Uint8 a = pop8(UXN_SRC); | ||
152 | Uint8 b = pop8(UXN_SRC); | ||
153 | push8(UXN_SRC, b + a); | ||
154 | } break; | ||
155 | case UXN_OPC(0x19): { // sub | ||
156 | UXN_KEEP_SYNC; | ||
157 | Uint8 a = pop8(UXN_SRC); | ||
158 | Uint8 b = pop8(UXN_SRC); | ||
159 | push8(UXN_SRC, b - a); | ||
160 | } break; | ||
161 | case UXN_OPC(0x1A): { // mul | ||
162 | UXN_KEEP_SYNC; | ||
163 | Uint8 a = pop8(UXN_SRC); | ||
164 | Uint8 b = pop8(UXN_SRC); | ||
165 | push8(UXN_SRC, b * a); | ||
166 | } break; | ||
167 | case UXN_OPC(0x1B): { // div | ||
168 | UXN_KEEP_SYNC; | ||
169 | Uint8 a = pop8(UXN_SRC); | ||
170 | Uint8 b = pop8(UXN_SRC); | ||
171 | push8(UXN_SRC, b / a); | ||
172 | } break; | ||
173 | case UXN_OPC(0x1C): { // and | ||
174 | UXN_KEEP_SYNC; | ||
175 | Uint8 a = pop8(UXN_SRC); | ||
176 | Uint8 b = pop8(UXN_SRC); | ||
177 | push8(UXN_SRC, b & a); | ||
178 | } break; | ||
179 | case UXN_OPC(0x1D): { // ora | ||
180 | UXN_KEEP_SYNC; | ||
181 | Uint8 a = pop8(UXN_SRC); | ||
182 | Uint8 b = pop8(UXN_SRC); | ||
183 | push8(UXN_SRC, b | a); | ||
184 | } break; | ||
185 | case UXN_OPC(0x1E): { // eor | ||
186 | UXN_KEEP_SYNC; | ||
187 | Uint8 a = pop8(UXN_SRC); | ||
188 | Uint8 b = pop8(UXN_SRC); | ||
189 | push8(UXN_SRC, b ^ a); | ||
190 | } break; | ||
191 | case UXN_OPC(0x1F): { // sft | ||
192 | UXN_KEEP_SYNC; | ||
193 | Uint8 a = pop8(UXN_SRC); | ||
194 | Uint8 b = pop8(UXN_SRC); | ||
195 | push8(UXN_SRC, b >> (a & 0x07) << ((a & 0x70) >> 4)); | ||
196 | } break; | ||
197 | |||
198 | /* 16-BIT OPCODES */ | ||
199 | |||
200 | case UXN_OPC(0x21): { // lit | ||
201 | push16(UXN_SRC, mempeek16(u->ram.dat, u->ram.ptr)); | ||
202 | u->ram.ptr += 2; | ||
203 | } break; | ||
204 | case UXN_OPC(0x23): { // pop | ||
205 | UXN_KEEP_SYNC; | ||
206 | pop16(UXN_SRC); | ||
207 | } break; | ||
208 | case UXN_OPC(0x24): { // dup | ||
209 | UXN_KEEP_SYNC; | ||
210 | Uint16 a = pop16(UXN_SRC); | ||
211 | push16(UXN_SRC, a); | ||
212 | push16(UXN_SRC, a); | ||
213 | } break; | ||
214 | case UXN_OPC(0x25): { // swp | ||
215 | UXN_KEEP_SYNC; | ||
216 | Uint16 a = pop16(UXN_SRC); | ||
217 | Uint16 b = pop16(UXN_SRC); | ||
218 | push16(UXN_SRC, a); | ||
219 | push16(UXN_SRC, b); | ||
220 | } break; | ||
221 | case UXN_OPC(0x26): { // ovr | ||
222 | UXN_KEEP_SYNC; | ||
223 | Uint16 a = pop16(UXN_SRC); | ||
224 | Uint16 b = pop16(UXN_SRC); | ||
225 | push16(UXN_SRC, b); | ||
226 | push16(UXN_SRC, a); | ||
227 | push16(UXN_SRC, b); | ||
228 | } break; | ||
229 | case UXN_OPC(0x27): { // rot | ||
230 | UXN_KEEP_SYNC; | ||
231 | Uint16 a = pop16(UXN_SRC); | ||
232 | Uint16 b = pop16(UXN_SRC); | ||
233 | Uint16 c = pop16(UXN_SRC); | ||
234 | push16(UXN_SRC, b); | ||
235 | push16(UXN_SRC, a); | ||
236 | push16(UXN_SRC, c); | ||
237 | } break; | ||
238 | case UXN_OPC(0x28): { // equ | ||
239 | UXN_KEEP_SYNC; | ||
240 | Uint16 a = pop16(UXN_SRC); | ||
241 | Uint16 b = pop16(UXN_SRC); | ||
242 | push8(UXN_SRC, b == a); | ||
243 | } break; | ||
244 | case UXN_OPC(0x29): { // neg | ||
245 | UXN_KEEP_SYNC; | ||
246 | Uint16 a = pop16(UXN_SRC); | ||
247 | Uint16 b = pop16(UXN_SRC); | ||
248 | push8(UXN_SRC, b != a); | ||
249 | } break; | ||
250 | case UXN_OPC(0x2A): { // gth | ||
251 | UXN_KEEP_SYNC; | ||
252 | Uint16 a = pop16(UXN_SRC); | ||
253 | Uint16 b = pop16(UXN_SRC); | ||
254 | push8(UXN_SRC, b > a); | ||
255 | } break; | ||
256 | case UXN_OPC(0x2B): { // lth | ||
257 | UXN_KEEP_SYNC; | ||
258 | Uint16 a = pop16(UXN_SRC); | ||
259 | Uint16 b = pop16(UXN_SRC); | ||
260 | push8(UXN_SRC, b < a); | ||
261 | } break; | ||
262 | case UXN_OPC(0x2C): { // jmp | ||
263 | UXN_KEEP_SYNC; | ||
264 | u->ram.ptr = pop16(UXN_SRC); | ||
265 | } break; | ||
266 | case UXN_OPC(0x2D): { // jnz | ||
267 | UXN_KEEP_SYNC; | ||
268 | Uint16 a = pop16(UXN_SRC); | ||
269 | if (pop8(UXN_SRC)) | ||
270 | u->ram.ptr = a; | ||
271 | } break; | ||
272 | case UXN_OPC(0x2E): { // jsr | ||
273 | UXN_KEEP_SYNC; | ||
274 | push16(UXN_DST, u->ram.ptr); | ||
275 | u->ram.ptr = pop16(UXN_SRC); | ||
276 | } break; | ||
277 | case UXN_OPC(0x2F): { // sth | ||
278 | UXN_KEEP_SYNC; | ||
279 | Uint16 a = pop16(UXN_SRC); | ||
280 | push16(UXN_DST, a); | ||
281 | } break; | ||
282 | case UXN_OPC(0x30): { // pek | ||
283 | UXN_KEEP_SYNC; | ||
284 | Uint8 a = pop8(UXN_SRC); | ||
285 | push16(UXN_SRC, mempeek16(u->ram.dat, a)); | ||
286 | } break; | ||
287 | case UXN_OPC(0x31): { // pok | ||
288 | UXN_KEEP_SYNC; | ||
289 | Uint8 a = pop8(UXN_SRC); | ||
290 | Uint16 b = pop16(UXN_SRC); | ||
291 | mempoke16(u->ram.dat, a, b); | ||
292 | } break; | ||
293 | case UXN_OPC(0x32): { // ldr | ||
294 | UXN_KEEP_SYNC; | ||
295 | Uint8 a = pop8(UXN_SRC); | ||
296 | push16(UXN_SRC, mempeek16(u->ram.dat, u->ram.ptr + (Sint8)a)); | ||
297 | } break; | ||
298 | case UXN_OPC(0x33): { // str | ||
299 | UXN_KEEP_SYNC; | ||
300 | Uint8 a = pop8(UXN_SRC); | ||
301 | Uint16 b = pop16(UXN_SRC); | ||
302 | mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); | ||
303 | } break; | ||
304 | case UXN_OPC(0x34): { // lda | ||
305 | UXN_KEEP_SYNC; | ||
306 | Uint16 a = pop16(UXN_SRC); | ||
307 | push16(UXN_SRC, mempeek16(u->ram.dat, a)); | ||
308 | } break; | ||
309 | case UXN_OPC(0x35): { // sta | ||
310 | UXN_KEEP_SYNC; | ||
311 | Uint16 a = pop16(UXN_SRC); | ||
312 | Uint16 b = pop16(UXN_SRC); | ||
313 | mempoke16(u->ram.dat, a, b); | ||
314 | } break; | ||
315 | case UXN_OPC(0x36): { // dei | ||
316 | UXN_KEEP_SYNC; | ||
317 | Uint8 a = pop8(UXN_SRC); | ||
318 | push16(UXN_SRC, devpeek16(&u->dev[a >> 4], a)); | ||
319 | } break; | ||
320 | case UXN_OPC(0x37): { // deo | ||
321 | UXN_KEEP_SYNC; | ||
322 | Uint8 a = pop8(UXN_SRC); | ||
323 | Uint16 b = pop16(UXN_SRC); | ||
324 | devpoke16(&u->dev[a >> 4], a, b); | ||
325 | } break; | ||
326 | case UXN_OPC(0x38): { // add | ||
327 | UXN_KEEP_SYNC; | ||
328 | Uint16 a = pop16(UXN_SRC); | ||
329 | Uint16 b = pop16(UXN_SRC); | ||
330 | push16(UXN_SRC, b + a); | ||
331 | } break; | ||
332 | case UXN_OPC(0x39): { // sub | ||
333 | UXN_KEEP_SYNC; | ||
334 | Uint16 a = pop16(UXN_SRC); | ||
335 | Uint16 b = pop16(UXN_SRC); | ||
336 | push16(UXN_SRC, b - a); | ||
337 | } break; | ||
338 | case UXN_OPC(0x3A): { // mul | ||
339 | UXN_KEEP_SYNC; | ||
340 | Uint16 a = pop16(UXN_SRC); | ||
341 | Uint16 b = pop16(UXN_SRC); | ||
342 | push16(UXN_SRC, b * a); | ||
343 | } break; | ||
344 | case UXN_OPC(0x3B): { // div | ||
345 | UXN_KEEP_SYNC; | ||
346 | Uint16 a = pop16(UXN_SRC); | ||
347 | Uint16 b = pop16(UXN_SRC); | ||
348 | push16(UXN_SRC, b / a); | ||
349 | } break; | ||
350 | case UXN_OPC(0x3C): { // and | ||
351 | UXN_KEEP_SYNC; | ||
352 | Uint16 a = pop16(UXN_SRC); | ||
353 | Uint16 b = pop16(UXN_SRC); | ||
354 | push16(UXN_SRC, b & a); | ||
355 | } break; | ||
356 | case UXN_OPC(0x3D): { // ora | ||
357 | UXN_KEEP_SYNC; | ||
358 | Uint16 a = pop16(UXN_SRC); | ||
359 | Uint16 b = pop16(UXN_SRC); | ||
360 | push16(UXN_SRC, b | a); | ||
361 | } break; | ||
362 | case UXN_OPC(0x3E): { // eor | ||
363 | UXN_KEEP_SYNC; | ||
364 | Uint16 a = pop16(UXN_SRC); | ||
365 | Uint16 b = pop16(UXN_SRC); | ||
366 | push16(UXN_SRC, b ^ a); | ||
367 | } break; | ||
368 | case UXN_OPC(0x3F): { // sft | ||
369 | UXN_KEEP_SYNC; | ||
370 | Uint16 a = pop16(UXN_SRC); | ||
371 | Uint16 b = pop16(UXN_SRC); | ||
372 | push16(UXN_SRC, b >> (a & 0x000f) << ((a & 0x00f0) >> 4)); | ||
373 | } break; | ||