* * * * * * * * * * * * E X - B A S I C * * * * * * * * * * * * V e r s i o n II B Y C O M P A N I O N ( S O F T W A R E ) C o p y r i g h t 1 9 8 9 Written and produced by J O N A T H A N L E D G A R - Contains over 70 sprites and sprite generator program! - EX-BASIC II Written and produced by Jonathan L Edgar, Companion 1989 Thank you for buying EX-BASIC 2 - A total of 80 new commands have been added to Sinclair BAISC "making it one of the best extended language packages available!" If you have purchased EX-BASIC 2 (V2) as a complete package, please read the EX-BASIC 1 (V1) user guide before reading this manual and use cassette [1]. This manual covers the 14 new commands which are contained in V2 Please note that you can still use the demonstrations and music programs supplied with V1 if you load the V2 operating system. ----- V2 Enables you to do the following extra facilities:- * Scroll a defined WINDOW up, down, left or right pixel by pixel with or without wrap round. * Create title credit scrolling effects (like at the end of television programmes!) * Print sprites on the screen by XOR, OR, AND, NOT and NOP instructions with or without attribute overlay. * Animate sprites by using the supplied 16*16 sprite designer package. * Create a creating alkatraz table to speed up the alkatraz loading system. * Screen reset conditions. 14 New commands are included which will be fully explained in this user guide. On cassette [2] supplied, the cassette format is as follows:- Side -A- FILENAME TYPE OF FILE 1) EX-BASIC 2 Program 2) EX-SCREEN Bytes 3) EX-MC Bytes 4) FONT1 Bytes 5) SPRITES Bytes 6) DEMO Program 7) SPRITE_GEN Program Please load V2 by typing : LOAD "" followed by ENTER - when loaded the computer will ask you if you want to load the demo. Press Y here and press PLAY on the cassette player until the demo starts - these are SOME of the effects that can be produced with V2! If you had typed N to the demo prompt the computer will report a "C Nonsence in BASIC, 9999:1" error - IGNORE this report, and as usual type in the usual RANDOMIZE USR 61434 "start up" command. "FONT1" is the same font as on V1 - LOAD it now by keying in LOAD "FONT1" CODE. Now follows a detailed explanation of the new commands :- *RESET - This command simply resets the screen colours to the switch on condition ie. the same as entering a VDU 56 command. *ALK x - Built in self creating Alkatraz loading generator. This will compile a 13.5K Alkatraz table in memory without the need to create/save/load one from tape with *ZAP. An example is as follows: 10 RANDOMIZE USR 61434 20 LOAD "EX-SCREEN" CODE 16384: REM load in EX-BASIC loading screen 30 *ALK 29000 35 PAUSE 0: REM press any key to save screen 40 *SAVE 29000,6912 50 CLS 60 *LOAD 29000,6912: REM rewind tape and load saved screen in As you can see, it is a time saving command but note that it takes 13.5K in memory so position it CAREFULLY in memory - never let the table go over 54109 where the character set is stored. Scrolling commands The complex scrolling integers are common to the four screen scrolling commands ... It allows BOXED windows to be scrolled on the screen ... You the user can define the size, shape and location of the box on the screen. *PUP x,y;x2,y2 - Scroll window UP. *PDOWN x,y;x2,y2 - Scroll window DOWN. *PLEFT x,y;x2,y2 - Scroll window LEFT. *PRIGHT x,y;x2,y2 - Scroll window RIGHT. Where x is the text column number (START) from 0 to 31. Where y is the text column number (END) from 0 to 31. Where x2 is the pixel row number (START) from 0 to 191. Where y2 is the pixel row number (END) from 0 to 191. For example - If we wish to scroll the FULL SCREEN, our integers would read : *????? 0,31;0,191 - WIDTH of column 0 to Column 31 - HEIGHT of row 0 (top of screen) to row 191 (absolute bottom of screen) We can place this in a program line as follows: 10 RANDOMIZE USR 61434 20 *BRIGHT 0,31;0,191 30 *PUP 0,31;0,191 40 GOTO 20 Lets say we want to scroll a box at text columns 2 to 30, and just text row 10. Bearing in mind that a text row equals 8 pixel rows, we could use: 10 RANDOMIZE USR 16434 15 INPUT m$: PRINT AT 10,0;m$ 20 *PLEFT 2,30;10*8,10*8+8 30 GOTO 20 Now that you have some idea of how text windows are organised on screen you should be able to discover how the scrolling effects were created in the V2 demonstration. Wrap-round You will have noticed that when the screen was scrolling, all the information that would normally "drop" off the side of the screen was placed at the opposite side - This is a feature that can be switched on or off by the *OPTION command ... *OPTION 0 - Disables wrap-round - Any information that would drop off the side of the screen WILL do. Note that *PDOWN will NOT work in this mode. *OPTION 1 - Enables wrap-round - Any information that would drop off the side of the screen will reappear on the opposite side. Try entering this commands before running the above example programs. Sprites Many people will have bought V2 because of the sprite facility. Sprites can be placed at any x/y position on the screen with any of the logical operands - AND, XOR, OR plus NOT and NOP. Under the filename "SPRITES" on the tape, 70 free sprites are contained. Load this file at ANY address - for the benifit of this magazine, lets say 35000 ... LOAD "SPRITES" CODE 35000 A sprite takes up 32 bytes of memory and is twice the size of of a UDG graphic - it can be placed anywhere on the screen, even the lower section of the screen in the same way as BASIC's OVER 1 command enabling the screen to be preserved while sprites travel over the screen. [There is a sprite generator included on the tape under the name of SPRITE_GEN, loaded by LOAD "", which enables you to create your very own sprite graphics. However, we have included over 70 free ones on tape!] Sprites lie at MEMORY locations - AND must be printed on the screen by giving a memory address. Eg. To print our first sprite on tape we use: *SPRITE m,x,y - Where m is a memory location. 35000=sprite1 35032=sprite2 .... Where x and y are like BASIC PRINT AT columns. To print our first sprite we can use: 10 RANDOMIZE USR 61434 20 *SPRITE 35000,0,0: REM sprite1 (35000) at column 0,0 A sold circle should appear on the screen. However, what happens if we want to display sprite number 50 in memory - its a bit annoying having to work out the correct memory location, therefore we have came up with a special FuNction formula - Before our start up command include in the program the following line: 5 DEF FN s(x)=(35000+(x*32))-32 - Where 35000 is the sprite 10 RANDOMIZE USR 61434 load address. To print sprite 8 for example, simply enter *SPRITE FN s(8(),x,y Now we can print sprites by there sprite numbers ... Add to the above program the above lines: 20 FOR F=1 TO 4 30 *SPRITE FN s(f),0,0: *HALT 10 40 NEXT F The following commands explain different sprite printing formats available - namely, *XOR - Logical Exclusive OR *AND - Logical AND *OR - Logical OR *NOT - Invertor *NOP - Normal printing (as above). It is advised to use this command before printing sprites normally. The above commands allow us to print a sprite on the screen in special ways - we normally have been used to the sprite being printed directly on top of the screen display destroying what ever was origionally there. Study the following logic tables with each of the above commands: *XOR ... Sprite bit Screen bit Output bit 1 1 0 Like the BASIC 0 1 1 OVER 1 command 1 0 1 0 0 0 *OR ... 1 1 1 0 1 1 1 0 1 0 0 0 *AND ... 1 1 1 0 1 0 Similar to a 1 0 0 "masked" sprite 0 0 0 *NOT ... 1 Ignored 0 Direct invertor 0 Ignored 1 *NOP ... 1 Ignored 1 Standard print 0 Ignored 0 To demonstrate XOR for example we shall print some text over the screen, print the sprite on top of it, then clear the sprite revealing the origional text ... 5 DEF FN s(x)=(35000+(x*32))-32 10 RANDOMIZE USR 61434 20 *DOUB "Sprites!" Try changing the *XOR in 30 *XOR line 30 to ... AND 40 *SPRITE FN s(10),0,0 OR 50 *HALT 50 NOT NOP ... 70 GOTO 40 to see the effects. The sprites contained on tape under "SPRITES" can be loaded at any address - each sprite number can be calculated with the DEF FN statement as before, and the sprite descriptions are as follows:- SPRITE NO: DESCRIPTION SPRITE NO: DESCRIPTION 01-04 Revolving ball 55-56 Spacecraft 3 05 Blank sprite 57 Top view of car 1 06-07 Spacecraft 1 58 Left of Car 2 08 Balloon 59 Middle of Car 2 09-12 T.V. 60 Right of Car 2 13-16 Monster face 61-63 Ghost 17-20 toilet 64 South West arrow 21-23 jumping man 65 "C" 24-26 helicopter 66 "O" 27-28 Spacecraft 2 67 "M" 29 Hill side 68 "P" 30-32 Plant 69 "A" 33-37 Explosion/Blob 70 "N" 38-40 Walking man 71 "I" 41-42 Fish 72 Insect 43-44 Swan ..... Sprites can be added 45-47 Spider ..... to with the sprite 48-51 Silicon chip ..... designer on tape .... 52-54 craft Example, to animate a walking man we can use the following subroutine: (Include DEF FN statement and RANDOMIZE USSR instruction) 20*SCREEN 1,7: *NOP 30 FOR p=1 TO 20: FOR f=38 TO 40 40*SPRITE FN s(f),10,10: *HALT 3: NEXT f 50 FOR F=40 TO 38 STEP -1: 60*SPRITE FN s(f),10,10: *HALT 3: NEXT f 70 NEXT p Adding a splash of Colour A sprite normally draws itself over the current attribute colours, thus not disturbing any screen colours. It is possible therefore to add a block of colour to the screen, then print the sprite over the colour - the colour can be added by normal PRINT statements or the new SATTR command (Sprite Attribute Set) ... *SATTR x,y TO c - Where x and y are the same as the sprite locations on the screen and c is the colour that that location should change to. "c" is worked out using the same formula as the *COLOUR command ie: c = Paper colour * 8 + ink colour Example, c = [Paper 8] * 8 + [Ink 0] = 56 Add a line 55 in the program above to read: 55 *SATTR 10,10 TO (INT(RND*7((*8+(INT(RND*7): REM random colour *SATTR actually prints a block of colour at sprite locations (x,y), (x,y+1), (x+1,y), (x+1,y+1). Defining sprites by *DOKE When defining UDG or *CHAR characters, we normally use a number from 0 to 255. Sprites use numbers from 0 to 65535 which can be poked into memory with the 16 bit *DOKE command. Sprite DATA is worked out in the same manner as UDG/*CHAR data - try entering the following program: 20 LET st=40000: REM sprites start at 40000 30 *DOKE st,xxx - Place 40 *DOKE st+2,xxx - numbers of 50 *DOKE st+4,xxx - your own 60 *DOKE st+6,xxx - choice into .... these 70 *DOKE st+30,xxx - locations. 70 *SPRITE st,0,0 THE SPRITE GENERATOR PROGRAM Following on from the DEMO program is a sprite generator program which enables you to create your very own sprites and animate them in any way that you wish. Load the program by keying: *OPTION 1: LOAD "" [ENTER] Within several seconds a menu should appear which reads: 1) Define Sprites 2) Save data 3) Load data 4) Full sprite view Each option shall be explained in turn ... [1] A large 16*16 grid will be displayed on screen with the real size representation of the sprite to the right of it. A memory address in decimal and hex is also displayed indicating the current address of the sprite (known as the SPRITE POINTER). Lets alter the sprite pointer ... : Use: "F" to step forward 1 sprite (+32 bytes) "B" to step backward 1 sprite (-32 bytes) SYM SHIFT + "F" to step forward 1/32 of a sprite (+1 byte ) SYM SHIFT + "B" to step backward 1/32 of a sprite (-1 byte ) Move the sprite pointer to exactly 30000. We shall now place a sprite at this address. Press [1] to "enter" the large 16*16 grid. A cross wire cursor should appear at the top left hand corner of the grid and can be moved around with : CURSOR RIGHT: 8 CURSOR UP : 7 SET POINT :CAPS SHIFT CURSOR LEFT : 5 CURSOR DOWN: 6 CLEAR POINT:SYMB SHIFT You will find it quite easy to draw a shape in the grid. Press ENTER to quit the grid mode - We must now store it at the current sprite pointer address, to do this, simply press [4]. Editing sprites We can edit a sprite by selecting the required sprite pointer address (lets say 30128) and then pressing [3] (Print sprite from memory onto grid). If we wish to edit that particular sprite, simply press [1] again, remembering to store it again with [4]. If we wish to clear the grid to create a new sprite, simply press [2] - sometimes this is not needed though, for example, an animation sequence. To recap: Our main controls are as follows: (1) Enter grid (2) Clear gri d (3) Print sprite in grid (4) Store sprite (F) Increase sprite (B) Decrease sprite pointer pointer Useful functions which allow us to manipulate a sprite in the grid are: [Q] - scroll grid left .... [W] - scroll grid right [Z] - scroll grid down .... [A] - scroll grid up [M] allows us to return to the main menu. ---- [2] This allows us to save your sprites onto cassette from the SPRITE POINTER address. You MUST specifiy the finish address or the number of sprites that you wish to save ie. SAVE point,[point+32] - Saves 1 sprite (1 Sprite = 32 bytes) SAVE point,[point+(7*32)] - Saves 7 sprites. (Where "point" is the value of the sprite pointer address) ---- [3] This allows us to load in saved sprites from cassette. If you wish to load in the sprites at the address contained in the file header, type "0" followed by ENTER. If however, you wish to load your sprites at a certain address (say 50000), type "50000" followed by ENTER. Now press PLAY on your cassette player and the sprites will load into memory in the manner that you have requested. ---- [4] This enables us to view the full range of sprites from the sprite pointer - when the computer has finished displaying, press SPACE to return to the main menu. These are all the instructions that you will need to operate the sprite designer correcty. To use the sprites in a program you must first of all save them out to tape with option [3] then clear the computers memory by "NEW", re-load the sprites into memory by : LOAD "" CODE. Each sprite can be printed by our special : DEF FN s(x)=(sprite address pointer+(x*32))-32 *SPRITE s(2),0,0 - Print sprite 2 *SPRITE s(4),2,2 - " " 4 *SPRITE s(7),4,4 - " " 7 EX-BASIC 2 was written and produced by Jonathan Lawrence Edgar Copyright 1989 All rights of Companion. Unauthorised copying, hiring, lending, broadcasting etc of this program is prohibited. The publisher assumes no responsibility for errors, nor liability from damage arising from its use.