Page 1 of 1

Custom Character Questions

Posted: Tue Jan 20, 2015 1:09 pm
by randolph.pickle
Hi everyone. I have a few questions about setting up custom characters that I was hoping you guys could clear up.

In the old books and magazines, most folks setup 52 and 56, and then CLR to protect the memory used by their characters. From what I've read on the forums, setting 52 is not necessary, and it is good practice to setup 55 as well as 56 (which I agree with). I don't like cargo cult, so I need a few things cleared up.

Why doesn't 52 need to be setup?

What exactly is the CLR command doing in this context? I know it frees up memory taken by variables, arrays, and strings, but what EXACTLY does it do?

Re: Custom Character Questions

Posted: Tue Jan 20, 2015 3:52 pm
by Kweepa
The shortest 'clean' approach is this, I think:

Code: Select all

poke55,0:poke56,28:clr
which sets the top of free memory, and then calls CLR which will delete all variables and therefore set 52/53 (the bottom of strings) to the top of free memory.

Re: Custom Character Questions

Posted: Tue Jan 20, 2015 5:23 pm
by randolph.pickle
Thanks for the reply.
which will delete all variables and therefore set 52/53 (the bottom of strings) to the top of free memory.
I had a hunch that was what was going on. Thanks for clearing it up.

On a side note, when I started doing research on custom characters, I noticed that 52 is setup in the part of the Programmer's Reference Manual that covers them. I imagine that back then folks saw that and did it without considering whether it was actually necessary. Oh, well :).

Re: Custom Character Questions

Posted: Wed Jan 21, 2015 12:41 am
by wimoos
Kweepa wrote:The shortest 'clean' approach is this, I think:

Code: Select all

poke55,0:poke56,28:clr
which sets the top of free memory, and then calls CLR which will delete all variables and therefore set 52/53 (the bottom of strings) to the top of free memory.
In addition to clearing all the variables, CLR also resets the CPU stack (forgetting all FOR/NEXT loops and all GOSUB calls) and CLR closes all files.

Regards,

Wim.