Custom Character Questions

Basic and Machine Language

Moderator: Moderators

Post Reply
randolph.pickle
Vic 20 Amateur
Posts: 55
Joined: Thu Nov 27, 2014 10:50 am

Custom Character Questions

Post 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?
User avatar
Kweepa
Vic 20 Scientist
Posts: 1314
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Re: Custom Character Questions

Post 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.
randolph.pickle
Vic 20 Amateur
Posts: 55
Joined: Thu Nov 27, 2014 10:50 am

Re: Custom Character Questions

Post 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 :).
wimoos
Vic 20 Afficionado
Posts: 345
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: Custom Character Questions

Post 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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Post Reply