Browse code

Created working stack space in case of previous evaluxn overflow

Andrew Alderwick authored on 14/07/2021 19:19:29
Showing 4 changed files
... ...
@@ -324,6 +324,7 @@ evaluxn(Uxn *u, Uint16 vec)
324 324
 {
325 325
 	Uint8 instr;
326 326
 	u->ram.ptr = vec;
327
+	if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8;
327 328
 	while(u->ram.ptr) {
328 329
 		instr = u->ram.dat[u->ram.ptr++];
329 330
 		switch(instr) {
... ...
@@ -232,6 +232,7 @@ evaluxn(Uxn *u, Uint16 vec)
232 232
 {
233 233
 	Uint8 instr;
234 234
 	u->ram.ptr = vec;
235
+	if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8;
235 236
 	while(u->ram.ptr) {
236 237
 		instr = u->ram.dat[u->ram.ptr++];
237 238
 		switch(instr) {
... ...
@@ -56,6 +56,7 @@ evaluxn(Uxn *u, Uint16 vec)
56 56
 {
57 57
 	Uint8 instr;
58 58
 	u->ram.ptr = vec;
59
+	if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8;
59 60
 	while(u->ram.ptr) {
60 61
 		instr = u->ram.dat[u->ram.ptr++];
61 62
 		switch(instr) {
... ...
@@ -159,6 +159,7 @@ evaluxn(Uxn *u, Uint16 vec)
159 159
 	u->ram.ptr = vec;
160 160
 	u->wst.error = 0;
161 161
 	u->rst.error = 0;
162
+	if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8;
162 163
 	while(u->ram.ptr)
163 164
 		if(!stepuxn(u, u->ram.dat[u->ram.ptr++]))
164 165
 			return 0;