Super Expander 64
Encyclopedia
The Super Expander 64 was a cartridge-based extension to the built in BASIC
BASIC
BASIC is a family of general-purpose, high-level programming languages whose design philosophy emphasizes ease of use - the name is an acronym from Beginner's All-purpose Symbolic Instruction Code....

 V2 interpreter of the then immensely popular Commodore 64
Commodore 64
The Commodore 64 is an 8-bit home computer introduced by Commodore International in January 1982.Volume production started in the spring of 1982, with machines being released on to the market in August at a price of US$595...

 home computer
Home computer
Home computers were a class of microcomputers entering the market in 1977, and becoming increasingly common during the 1980s. They were marketed to consumers as affordable and accessible computers that, for the first time, were intended for the use of a single nontechnical user...

: Since the 64 was developed in a hurry, Commodore simply adapted the BASIC V2 from the PET
Commodore PET
The Commodore PET was a home/personal computer produced from 1977 by Commodore International...

 line of computers and the VIC 20 for their new machine, with no support for the advanced sound and graphics capabilities of the 64. To make use of the advanced hardware, BASIC programmers needed to memorize hardware addresses and "POKE
PEEK and POKE
In computing, PEEK is a BASIC programming language extension used for reading the contents of a memory cell at a specified address. The corresponding command to set the contents of a memory cell is POKE.-Statement syntax:...

" commands directly to the memory-mapped devices. Later 8-bit systems from Commodore had BASIC interpreters enhanced to support the special hardware, and with the Super Expander 64 cartridge, Commodore 64 users could "retrofit" their machine with a BASIC to match the hardware capabilities.

The extra code was mapped into the "lower cartridge" 8 kilobytes area at $8000-$9FFF, thus reducing the 38911 bytes for user programs by said 8K.

Graphics

After initializing the screen for "high-resolution" (320 x 200 monochrome pixels) or multicolor (160 wide x 200 pixels in four colors) graphics with the GRAPHIC command, one could draw lines, circles, ellipses, arcs, boxes and more using the DRAW, CIRCLE, and BOX commands. PAINT would "flood-fill" an area enclosed by lines, e.g. the interior of a CIRCLE or BOX. A CHAR command was used to "print" characters from the character generator ROM onto the bitmap graphics screen. SSHAPE and GSHAPE would store the contents of a rectangular area of the high-res graphics into a string variable, and GSHAPE would "stamp" it back onto the screen at arbitrary locations. Such "graphics-in-a-string" could also be used to transfer something drawn on the hi-res screen into one of the eight sprite patterns.

Sprites

Besides a range of commands to initialize, position and move sprites (or Movable Object Blocks as Commodore called them; hardware-supported graphic elements that could move freely on the screen independently of other graphics and text on the screen), Super Expander had a built in tool to edit the pattern of 8 sprites (called upon with the SPRDEF command), either in high-res (24 x 21 pixels) or multicolor (12 wide x 21 pixels) mode.

There was even a way of implementing "interrupts" in the BASIC program if two sprites collided, if a sprite collided with other graphics and/or text on the screen, or if an attached light pen was activated. A COLINT command set up the interrupt, pointing to the beginning BASIC line number of the "interrupt handler", which had to end in a RETURN statement (part of standard, unexpanded BASIC) in order to transfer control back to the interrupted, "mainline" part of the program.

Sound

Playing a sequence of musical notes was hooked onto the standard BASIC "PRINT" command by the use of a special "control character", much like the cursor control, color changes and other control characters. E.g. PRINT CHR$(6);"CDEFGAB" played a rising scale. Commands like TIME and TUNE was used to set the playback tempo and the timbre of the note sequence.

A "quirk" of this feature is that by typing the special control character (by pressing CTRL + F) along with a quote mark, then deleting the quote mark, the machine would "play" whatever was typed while editing the program; hit the G key, and the machine played a "Pling!" with the pitch of a G note...!

Hardware I/O

Functions like RJOY, RPEN and RPOT would read the state of a connected joystick, light pen, or analog "paddle". In combination with the sprite-motion-related commands, it only took a single line of BASIC code to make a sprite move in the direction indicated by a connected joystick.

Miscellaneous

A KEY command was available, which would set up the four function keys on the 64's keyboard to "enter" an arbitrary string. By default, these keys were set up to type commands like RUN, LIST, SPRDEF, GRAPHICS and others, but the user could change this using the KEY command in either direct mode or under program control.

Technical issues

All the versions of BASIC on Commodore's 8-bit machines used a scheme of replacing BASIC keywords with single-byte code -- e.g. the word "PRINT" would be substituted by a single byte value, or token, rather than the five ASCII-codes for the five letters in the word. Super Expander added more commands than this system could accommodate, so a system of two-byte tokens for the new commands was implemented.

Because of a quirk in the BASIC interpreter (the handling of the "THEN-part" of an IF/THEN construct didn't jump through a vector in RAM but instead took a direct JuMP to the standard, unexpanded BASIC command decoding routine), IF/THEN statements needed to have an extra colon (:) inserted right after the THEN keyword, if the following command was one of Super Expander's non-standard BASIC keywords. For instance, IF (condition) THEN DRAW ... would yield a ?SYNTAX ERROR message — one had to write it like IF (condition) THEN:DRAW ... — note the colon between THEN and the Super Expander-added command DRAW.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK