text
stringlengths 0
99.6k
|
|---|
SPRITEXY ( X Y -- )
|
Sets x y position of current sprite. Coordinate values are the same as for the turtle. Note that negative values are legal, and will cause the sprite to move offscreen at the left or bottom. Example:
|
S1 -1 100 SPRITEXY ( move the current sprite one pixel off of the screen.)
|
WIDE-SPRITE ( flag -- )
|
If flag is true, the current sprite will be made wider. Example:
|
S1 TRUE WIDE-SPRITE ( make sprite 1 wider)
|
S2 FALSE WIDE-SPRITE ( make sprite 2 narrow)
|
HIGH-SPRITE ( flag -- )
|
Same as wide-sprite, but makes the current sprite taller or shorter. Example:
|
S3 TRUE HIGH-SPRITE ( make sprite 3 taller)
|
SPRITECOVER ( flag -- )
|
If flag is true, the current sprite will cover the background. If flag is false, the current sprite will be transparent. Example:
|
S1 TRUE SPRITECOVER ( have sprite #1 cover its background.)
|
SPRITEBANG ( -- flag)
|
Leaves a true flag if the current sprite has banged into another sprite, and a false otherwise. Note that sprites can bang into each other even when off screen. Example:
|
: MOVEIT S1 319 0 DO I 150 SPRITEXY SPRITEBANG IF " BOOM! " I 150 G$ LEAVE THEN
|
LOOP ;
|
DATABANG ( -- flag)
|
Same as SPRITEBANG, but leaves true if the current sprite has banged into non-sprite data on the screen. Note that sprites can bang into data even when off screen.
|
For more information on defining sprites, as well as more details on multi-colored sprites, please see the programmers reference guide.
|
*fp0
|
*lk:blazin.doc6
|
*hd3:Blazin' Forth Documentation,Appendix,-#-
|
*cn1;1: Accessing CBM disk files.*cn0
|
Since Forth uses a virtual memory arrangement and the screen concept to manage the disk, I felt that providing words to access CBM disk files would be a waste of memory space. Blazin' Forth contains all the primitives necessary to write words to access CBM disk files, or other serial devices. This appendix describes how to do this from Forth, for users whose applications require such access.
|
(OPEN) ( file# device# sa address-of-filename filename-length -- error code)
|
This word requires 5 parameters, as described above. This is the same as from BASIC, with the exception of the address of filename, and the length of the filename. The address can be any memory location which stores a legal filename. Using Blazin' Forths string handling words, an open statement would look like this:
|
8 8 8 " LETTERS,S,R" COUNT (OPEN)
|
Which opens a sequential file called "LETTERS" for a read, with logical file# 8, on device 8, with a secondary address of 8. Note that (OPEN) returns an error code, which is 0 (false) if everything was ok, and otherwise is one of the error codes as described in the Programmers Reference Guide. This error code may be processed by your program, ignored, or you may use the Blazin' Forth word IOERR. (see IOERR for more info on this.)
|
If you intend to use (OPEN) a lot, you will probably want to define a different version:
|
: OPEN COUNT (OPEN) IOERR ;
|
With this new word, the OPEN statement becomes:
|
8 8 8 " LETTERS,S,R" OPEN
|
If you need to open a file to a device which doesn't require a filename, such as a printer or plotter, just use a zero as the filename and length:
|
4 4 0 0 0 (OPEN) IOERR
|
The above will open a channel to a printer connected as device #4.
|
CLOSE ( File# -- )
|
This will close an already open file. Example:
|
8 CLOSE ( closes file# 8 )
|
To send or receive data from the device, you will need the following words:
|
(CMDOUT) ( File# -- errorcode)
|
This is an I/O redirection word. Executing this word will cause all system output to be directed to the logical file whose number is on the stack. All system output words: EMIT , SPACES , TYPE , ." .( etc. will direct data to this device. Note that you must have opened a channel to the file before using this word. The error code is suitable for being read by IOERR . Example:
|
8 (CMDOUT) IOERR ( send all output to file# 8 )
|
(CMDIN) ( File# -- errorcode)
|
Another I/O redirection word. Executing this word will cause all system input to be obtained from the file whose number is on the stack. All system input words, EXPECT KEY ?KEY etc. will recieve data from this file. Note that you must have previously opened a channel to the file before using this word. The error code is suitable for being read by IOERR. Example:
|
8 (CMDIN) IOERR ( get all input from file# 8)
|
CMDOUT ( -- )
|
Executing this word will restore the default input and output channels. All input will now come from the keyboard, and all output will be sent to the screen. Note that all files remain open.
|
IOERR ( errorcode -- )
|
This word will execute an error abort if the value on the top of the stack is non-zero. It will decode the error# and type the appropriate message. Note that if you do not want your application to halt on an error, you should not use this word.
|
Using the above words, it is a simple matter to send or receive data from a disk. For example:
|
: GET# ( FILE# -- character )
|
(CMDIN) IOERR ?KEY CMDOFF ;
|
This defines a word which works exactly like GET# in BASIC. Note the use of CMDOFF at the end of the word to restore default devices. This is generally the best practice to follow, since the serial bus does not handle multiple channels being connected all that well.
|
The following word is an example of how to implement PRINT# in Forth:
|
: PRINT# ( address file# -- )
|
(CMDOUT) IOERR COUNT TYPE ( send text at address to disk)
|
CMDOFF ( restore default devices) ;
|
If you require more exotic file handling words, they are also easy to define. Just follow the examples given above. The following are also useful in handling disk serial bus access:
|
(?DISC) ( --- flag )
|
This word reads the disk error channel, leaving a true flag if a disk error has occurred. This is useful if you want your program to handle errors, since the higher level ?DISC will abort on an error. Note that the command channel must be opened before using this word. Example:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.