Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Atari BASIC
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Advanced techniques== ===Strings as a way to manipulate memory=== The base addresses of a string is stored in a variable table. String addresses can be redirected to point to arbitrary areas of RAM. This allows the rapid memory-shifting routines underlying string and substring assignment can be applied from BASIC to the memory used for the screen or player/missile graphics. This is particularly useful for achieving rapid vertical movement of player/missile images directly from Atari BASIC. ===Random access via DATA/RESTORE=== Numeric variables and expressions can be used as the parameter for the <code>RESTORE</code> statement, allowing <code>DATA</code> statements to be randomly accessed through code such as {{code|2=basic|RESTORE ROOMBASE+ROOMNUMBER:READ DESCRIPTION$, TREASURE$, EXITS}}. This can also be used to emulate static string arrays: {{code|2=basic|RESTORE STRBASE+INDEX:READ A$:PRINT A$}}. ===Error handling with TRAP=== The <code>TRAP</code> statement jumps to a line number when an error occurs, and this reduces the need for manual error-checking. For example, when drawing graphics on the screen it is not necessary to check whether lines go beyond screen boundaries of the current graphics mode. This error state can be trapped, and the error handled if necessary. ===Includes=== The <code>ENTER</code> command reads source code from a device and merges it into the current program, as if the user had typed it in. This allows programs to be saved out in sections via <code>LIST</code>, reading them in using <code>ENTER</code> to merge or replace existing code. By using blocks of line numbers that do not overlap, programmers can build libraries of subroutines and merge them into new programs as needed. ===Self-modifying code=== The editor can be set-up to repeatedly read input from the screen until an EOF is reached. This allows a program to write new program code followed by a <code>CONT</code> statement to the screen then, positioning the screen cursor at the start of the new code, <code>STOP</code> the running program, causing the new code to be read in then execution be continued by the <code>CONT</code> statement. ===Embedded machine language=== Atari BASIC can call machine code subroutines stored in strings or <code>POKE</code>ed into memory. The 256 byte area starting at address 1536 ($0600) is often used for this purpose. Machine code is invoked with the <code>USR</code> function. The first parameter is the address of the subroutine and the following values are parameters. If the code is stored in a string named <code>ROUTINE$</code> it can be called with two parameters as {{code|2=cbmbas|1=ANSWER=USR(ADR(ROUTINE$),VAR1,VAR2)}}. Parameters are pushed onto the hardware stack as 16-bit integers in the order specified in the <code>USR</code> call in low byte, high byte order. A final byte is pushed indicating the number of arguments. The machine language code must remove these values before returning via the <code>RTS</code> instruction. A 16-bit value can be returned to BASIC by placing it in addresses 212 and 213 ($D4 and $D5).
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Atari BASIC
(section)
Add topic