Tips And Tricks for Quick Basic Programmers

Graphics / Animation
Mathamatics
Misc.

Graphics / Animation

Faster Pset! DEF SEG = &HA000
POKE X + (Y * 320&), COLOR
Faster Palette! OUT &H3C6 , &HFF
OUT &H3C8 , Color to change
OUT &H3C8 , Red Value (0 to 255)
OUT &H3C8 , Green Value (0 to 255)
OUT &H3C8 , Blue Value (0 to 255)
View Palette! (Screen 12 & 13 Only) OUT &H3C7 , Color to See RGB
Red Value = INP &HC39
Green Value = INP &HC39
Blue Value = INP &HC39
Save Screen (Screen 13) DEF SEG = &HA000
BSAVE "file name (8 chars only)",0
DEF SEG
Load Screen (Screen 13) DEF SEG = &HA000
BLOAD "file name (8 chars only)",0
DEF SEG
Flicker Free Animation WAIT &H3DA, 8
WAIT &H3DA, 8, 8

Go To Top

Mathmatics

Use Integers (% and #). instead of Floating Point (! and &).
They are alot faster and they use up less memory.
When Dividing integers use a / b instead of INT (a/b)
it is alot faster.
Use (A + A) insted of (A * 2) this is faster.
Use (X * X) insted of (X ^ 2) this is also faster.
To find out if number is odd use X AND 1
if it returns 1 then it is a odd number.
To figure out if a number is divisible by another number use
X % Y if it returns 0 X is divisible by Y.
To swap numbers do SWAP a,b instead of
a = c : b = d : a = d : b = c

Go To Top

Misc.

Delay a set number of seconds SUB DELAY (seconds!)
FOR a = 0 TO 70 * seconds!
WAIT &H3DA, 8
WAIT &H3DA, 8, 8
NEXT a
NEXT SUB
Delay as little a 1 / 19 of a seconds
on all computers
SUB DELAY (seconds%)
seconds% = seconds% * 19
DEF SEG = 0
POKE (1132), 0
CountDown:
IF PEEK(1132) < seconds% THEN GOTO CountDown
DEF SEG
END SUB
Simpler delay loop that is not
dependant on machine speed
t& = TIMER
DO: LOOP UNTIL TIMER >= t& + time to delay.
1 = 1 second
Read keyboard faster than
INKEY$ ! (You get the result in the
ASCI code number)
key = INP (&H60)
Clears the keyboard buffer DEF SEG = 0
FOR X = 0 TO 3
POKE (108 + X), PEEK (112 + X)
NEXT X
Preforms a Cold-Boot OUT &H64, HFE

Go To Top

Back To Home Page