USR function (*solved*) - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15) +---- Thread: USR function (*solved*) (/showthread.php?tid=435) |
USR function (*solved*) - britlion - 02-26-2012 We seem to have a regression with the latest version: print USR "A" falls over: Traceback (most recent call last): File "zxb.py", line 312, in <module> File "zxb.py", line 246, in main File "zxbtrad.pyc", line 316, in traverse File "zxbtrad.pyc", line 1286, in traverse File "zxbtrad.pyc", line 593, in traverse UnboundLocalError: local variable 'suffix' referenced before assignment Build Failed! Re: USR function - boriel - 02-26-2012 Yes, and strange :?: It was just a typo (fixed). Download the lastest version. Re: USR function (*solved*) - britlion - 02-27-2012 Testing the results of the USR function seems to come up with the right answers, but my "invert a graphic" sub seems to be breaking in strange ways. Can't quite follow why: Is it me doing something silly, or the compiler? It seems to miss a line off the top, and then write gibberish into the next one, before carrying on normally with the last six lines. Is it my emulator (spin)? or my program? I just checked: Does the same thing in Spectaculator. And "Print \b" seems to print a B missing the top before my sub even runs... Code: SUB fastcall hMirror (udg as uInteger) Re: USR function (*solved*) - boriel - 02-27-2012 Probably because the default UDG address PEEK UINTEGER 23675) points to top of memory (ZX Default), which is now being used by the compiled code and the heap. Try this at top of your code: Code: #include <alloc.bas> Note: --spectrum parameter does this by default. Re: USR function (*solved*) - britlion - 02-27-2012 Hmm. If I believe that... Okay - what if I try Code: DIM UDG (7) => {%10000000,%01000000,%00100000,%00010000,%00001000,%00000100,%00000010,%00000001} At the start of the code? That should point it at a safe place, because it's variable space.. However, what it actually does is print a garbled UDG, followed by a mirror of it. Re: USR function (*solved*) - britlion - 02-27-2012 boriel Wrote:Note: --spectrum parameter does this by default. --sinclair, you mean? Or are you adding in other machine specific options? Re: USR function (*solved*) - boriel - 02-27-2012 britlion Wrote:--sinclair, yes (sorry, I'm currently not at home).boriel Wrote:Note: --spectrum parameter does this by default. Try your program with --sinclair. If it works, you can use either --sinclair or the above trick (remember --sinclair adds more compatibilty with Sinclair BASIC, but also more overhead). Re: USR function (*solved*) - boriel - 02-27-2012 britlion Wrote:Hmm. If I believe that... Okay - what if I tryOf course, this is preferred. Well, using malloc, you can later free it and reuse it for other purposes. britlion Wrote:However, what it actually does is print a garbled UDG, followed by a mirror of it.Hmmm. :?: :?: :?: Would need further investigation, I guess. |