Subject: Tightening code

From: Owen <[email-masked]>
Date: Sun, 6 Mar 2011 16:11:31 -0500

Question... Can someone direct me to the keyboard shortcuts list for XB dealing with tokens?  I'm squeezing bytes.  :)

Firebrandmusic.net

---

From: "jacques" <[email-masked]>
Date: Sun, 6 Mar 2011 17:59:20 -0400

Owen,

I do not think that using these instead of XB statements will save you any 
bytes. If you have not yet done so you might try replacing frequently used 
numbers with a variable. Place @ =1 near the start of your program and 
everywhere 1 appears replace it with @. There is a program that does this 
for you but the name escapes me at the moment.

The following is on the wtech site under ti-faq:
-----------------------------------------------------
This addition came later, here is how you can enter them from the keyboard!

The tokens which can be entered from the keyboard are tokens 129 to 159 ,
176 to 183 and 187. These 40 tokens can be entered into a program by
pressing CTRL and the applicable key after a line number. Whether entered
as  upper or lower case does not matter. Initially nothing appears but the
statement or command appears when the line is listed. This is not the full
range of tokens but the others cannot be accessed from the keyboard. They
would require using a combination of shift and/or FCTN keys which seem to
override the CTRL key. There is a token associated to each key on the TI
keyboard except for the ENTER key, the space, CTRL and FCTN keys and one
other being CTRL , (comma) which produces character 128. This key seems to
produce a token but not one which I recognize or can use. FCTN V will also
produce a token which is blank being character 127 or DEL.

A listing of these tokens is as follows:

 #  Token              Ctrl
129 ELSE                 A
130 ::                   B
131 !                    C
132 IF                   D
133 GO                   E
134 GOTO                 F
135 GOSUB                G
136 RETURN               H
137 DEF                  I
138 DIM                  J
139 END                  K
140 FOR                  L
141 LET                  M
142 BREAK                N
143 UNBREAK              O
144 TRACE                P
145 UNTRACE              Q
146 INPUT                R
147 DATA                 S
148 RESTORE              T
149 RANDOMIZE            U
150 NEXT                 V
151 READ                 W
152 STOP                 X
153 DELETE               Y
154 REM                  Z

155 ON                   .
156 PRINT                ;
157 CALL                 =
158 OPTION               8
159 OPEN                 9
176 THEN                 0
177 TO                   1
178 STEP                 2
179 ,                    3
180 ;                    4
181 :                    5
182 )                    6
183 (                    7
187 AND                  /
-------------------------------------------

Have fun,

Jacques

----- Original Message ----- 
From: "Owen" <[email-masked]>
To: <[email-masked]>
Sent: Sunday, March 06, 2011 5:11 PM
Subject: [TI994A] Tightening code

Question... Can someone direct me to the keyboard shortcuts list for XB 
dealing with tokens?  I'm squeezing bytes.  :)

Firebrandmusic.net

---

From: Owen Brand <[email-masked]>
Date: Sun, 6 Mar 2011 17:30:08 -0500

Thank you Jacques.  I've compacted my code down pretty tight at this
point... I'm kind of just looking to prepare because I have another giant
chunk of code that's about to be merged into the main program and it'll put
me up against the size barrier.  Luckily, I'll still have about 2k to work
with, but I still have some bells and whistles to implement...

Stripping all the REM statements freed up some space, moving several
duplicate conditional elements in a IF THEN ELSE statement to a single GOSUB
helped alot too.  I'm basically just going for efficiency.  I WILL be
needing just about all the high memory for code, and so the streamlining
process is where I am now.  =)  Thanks for the quotes and suggestions.

Owen

---

From: "Tursi" <[email-masked]>
Date: Sun, 6 Mar 2011 15:36:47 -0800

>duplicate conditional elements in a IF THEN ELSE statement to a >single 
>GOSUB helped alot too.  I'm basically just going for efficiency.  I WILL be 
>needing just about all the high memory for code, and so >the streamlining 

Good, but like Jacques says, don't waste your time carefully retyping all 
the tokens as control characters. They are already stored in memory as those 
single-byte characters, so you won't save any memory at all. That's the 
whole purpose of tokens - to store a BASIC word as a single byte - and it's 
really only fluke that you can type the raw token instead of the word and 
have it work.

Things that take memory -- every number takes 8 bytes, but a variable takes 
as many bytes as there are characters in the name (thus Jacques' suggestion 
of replacing common numbers like '1' with a small variable like '@' - save 7 
bytes each time). Strings take a byte plus a byte for each character in the 
string, as well the two quotes also take a byte each. If you have strings 
that you use more than once, definitely store them in variables. The word 
"CALL" is tokenized to one byte, but everything /after/ the CALL is stored 
as text, so if you have anything done more than once, consider a subroutine. 
Likewise, if you are using custom SUBs, the length of those names eats up 
memory (where a GOSUB does not).

Also, if you have a lot of strings, and I think you might, consider storing 
them in a disk file and reading them into a variable array at the beginning 
of your program. Since strings are stored in VRAM, you can save the program 
space they would otherwise take up only to be copied to VRAM later.

That's all I can think of off the top of my head, I think we may have better 
XB programmers here than me. :)

---

From: Owen Brand <[email-masked]>
Date: Sun, 6 Mar 2011 18:46:39 -0500

Thanks for the suggestions!

I actually freed up a bunch of space by moving all my character definitions
to the LOAD program, so that helped quite a bit.  =)  This is something I
had done a couple months ago, but switched back for testing purposes... (so
I didn't have to SAVE the main program and then RUN the LOAD program)

I'm looking at about 4k more free space now.  Tons of room.  Appreciated,
guys!

On Sun, Mar 6, 2011 at 6:36 PM, Tursi <[email-masked]> wrote:

> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

---

From: Owen Brand <[email-masked]>
Date: Mon, 7 Mar 2011 01:54:29 -0500

The chunk of code I was trying to reduce went from 6.5k down to 4k.  An
overwhelming success.  Thanks for your help guys.  =)

Owen

On Sun, Mar 6, 2011 at 6:46 PM, Owen Brand <[email-masked]> wrote:

>   On Sun, Mar 6, 2011 at 6:36 PM, Tursi <[email-masked]>wrote:
>

---

From: Owen Brand <[email-masked]>
Date: Mon, 7 Mar 2011 01:55:35 -0500

Sorry... if you include the character defs that moved to the LOAD program,
the code went from 13k down to 4k.  =)

On Mon, Mar 7, 2011 at 1:54 AM, Owen Brand <[email-masked]> wrote:

>   On Sun, Mar 6, 2011 at 6:46 PM, Owen Brand <[email-masked]>wrote:
>
>> I actually freed up a bunch of space by moving all my character
>> definitions to the LOAD program, so that helped quite a bit.  =)  This is
>> something I had done a couple months ago, but switched back for testing
>> purposes... (so I didn't have to SAVE the main program and then RUN the LOAD
>> program)
>>

---

From: "Dan O'Quinn" <[email-masked]>
Date: Mon, 7 Mar 2011 08:26:59 -0500

prescanit will optimize your xbasic code
I couldn't find the program on whtec (it's probably there)
you can find info on prescanit here
p32 in the June 1987 MICROpendium
btw that issue is on ebay # 280247748428
dan

---

From: Owen Brand <[email-masked]>
Date: Mon, 7 Mar 2011 10:16:48 -0500

Hey Dan,
   I actually have a copy of PrescanIt.  I wasn't aware that it would
optimize text and string information though... I actually have an old 5.25
floppy of PreScanIt, but it is corrupted.  Luckily, the Atariage.com TI-99
forum has been critical in recovering all these great programming
resources...

I guess I should give it a go and see how much "optimizing" actually
occurs.  =)  Thanks for the suggestion, as I wouldn't have even tried
PrescanIt until I was finished with the program.

If anyone wants a copy of PrescanIt, I would be happy to post it here to the
list, with Tony's OK.
Thanks

Owen

---

From: "jacques" <[email-masked]>
Date: Mon, 7 Mar 2011 11:35:53 -0400

PreScanIt is on the wht site as file 51B under the Lima Library section.

Jacques

----- Original Message ----- 
From: "Owen Brand" <[email-masked]>
To: <[email-masked]>
Sent: Monday, March 07, 2011 11:16 AM
Subject: Re: [TI994A] Tightening code

Hey Dan,

Owen

---

From: Jeffrey White <[email-masked]>
Date: Mon, 7 Mar 2011 09:17:19 -0800 (PST)

XB-Basher, by Mike Dodd I believe, is another tool for tightening XB code.

Jeff White

________________________________
From: Dan O'Quinn <[email-masked]>
To: [email-masked]
Sent: Mon, March 7, 2011 8:26:59 AM
Subject: Re: [TI994A] Tightening code

<snip>

---

From: Owen <[email-masked]>
Date: Mon, 7 Mar 2011 12:23:35 -0500

Never heard of it.  :) I'll go check it out.  Thanks

Firebrandmusic.net