The Misty Extension. Written by Billy Allan and Colin Watt Version 1.7 23/06/92 Some notes about the commands: First of all, all the graphics commands assume that you are in low-res. If you want to write a game/demo in medium res then I suggest you write your own bloody extension! None of the commands relate to mono because neither of us has a mono monitor, so we couldn't test any routines we tried. Still, if enough people register... Secondly, all of the addresses passed must be actual. That is, you must pass "start(14)" rather then "14". If you are going to be using one bank a lot, it will be quicker to define a variable which holds the start of the bank rather than work it out every time. Lastly, none of the commands will accept real numbers (ie, those with a # after them). There are two reasons for this. First of all, I never use real numbers in games or demos as they slow things down, and secondly, we don't have enough documentation on having two lots of parameters, one of integers, the other of real. If anyone can supply said information, we would be very pleased. Chuffed even. - - - - - - - - - - - - - - - - - - - - - - - - - - - - Command List: COL (Screen,X,Y) Return the colour on Screen at co-ordinates X,Y. E.g. print col(start(14),100,85) This is a new version of the POINT command. It has three main advantages over it though. First of all, it's twice as fast! Secondly, you can test the point of a screen at any address, as in the example. Thirdly, it will not crash if you test a pixel outside of the screen, so you could test a pixel at 400,900 and it would NOT crash your program! The smart ones among you may have realised that this means it isn't clipped, so do be careful (not so much with this one, but you'd better watch what you're doing with DOT). DOT Scr,X,Y,C Plot a pixel on screen at address Scr, co-ordinates X,Y in colour C. Eg. 10 for T=1 to 100 20 dot logic,rnd(319),rnd(199),rnd(15) 30 next t This is a new version of PLOT, but with the same advantages as the COL command has over POINT. FASTCOPY Screen1,Screen2 Copy Screen1 to Screen2. Eg. fastcopy start(14),logic This is a new version of SCREEN COPY X TO Y. It is much faster than screen copy, it can copy the whole screen in under 1 vbl! It also doesn't care about the address of the screen, so you can enter "fastcopy back+160,logic" which would crash the equivalent screen copy version. SKOPY N,Scr1,X1,Y1,X2,Y2,Scr2,X3,X4 Copies the screen-data from Scr1 to Scr2. X co-ordinates only on 16 boundary! "N" is the number of bitplanes* to copy. Eg. skopy 4,logic,0,0,32,15,physic,160,100 This is a new version of screen copy. It has much the same advantages as FASTCOPY over screen copy, plus the ability to copy different bitplanes Passing the bitplanes as 1 to 4 will use the clipped routine, but if you pass them as 11 to 14 then it will be unclipped. There is a bug in the command which we haven't fixed yet, sorry. If you try to SKOPY from a negative co-ordinate to the same negative co-ordinate in the X-axis the block won't get copied. So, for example, the command "skopy 1,logic,-32,0,64,32,physic,-32,0" wouldn't do anything... This will be corrected in the next update. FLOPRD Buffer,NumSecs,Side,Track,Sector,Drive Read Numsecs starting at Sector and store at Buffer Eg. 10 reserve as work 10,512 20 floprd start(10),1,0,0,1,0 You can achieve the same thing with a TRAP call, but this is slightly faster and easier to remember. Do not pass DRIVE as the drive parameter! I tried it last night and STOS didn't like it very much. FLOPWRT Buffer,NumSecs,Side,Track,Sector,Drive Write sectors to disk. MEDIACH (D) Checks whether the disk in drive D has been changed. Returns: 0 - Definitely changed 1 - Maybe changed 2 - Not changed Eg. print mediach (0) This command can be achieved with a call to TRAP also. At the moment this command doesn't work correctly (I think), but I don't know why! It could be that the documentation I have on the BIOS are incorrect. HARDKEY Returns the contents of the hardware keyboard register. Eg. 10 print "Press SPACE" 20 repeat : until hardkey=57 This was added as some music and assembly routines cuts off the INKEY$ command, and it looks a lot nicer than the PEEK. Do remember to put in a "CLEAR KEY" at the end of your routine though! NDRV Returns the number of drives attached to the computer. Eg. print ndrv This can be achieved with a deek to a system variable, but it was something I thought merited a command seeing as I can never remember the correct address. MOUSEOFF COMPLETELY disable mouse reporting. Eg. 10 showon 20 print "Move the mouse, then press space" 30 repeat : until inkey$=" " 40 mouseoff 50 print "Move the mouse again, then press space" 60 repeat : until inkey$=" " 70 mouseon This is a very useful command for demo-coders. The hide(on) command merely hides the pointer, but if you waggle the mouse around, it will still use upto 30% processor time to move a non-existent pointer! So if your screen/game is just at the bottom of a vbl, you don't need to worry about some prat waggling the mouse around and saying "Oh look, it makes it go all flickery!" MOUSEON Enables mouse reporting after a call to MOUSEOFF. Eg. See MOUSEOFF FREQ Return the frequency of the monitor (50 or 60). Mono is always 70hz, so there's no point in returning it. Eg. print freq This command will become more useful when (stroke if) the SETFREQ command is added... RESVALID Returns TRUE is the reset vector is set and FALSE otherwise. Eg. 10 if resvalid then print "Lard!" This can be very useful for either check for a virus or to see if someone has one of those picture-ripper type programs in that uses the reset vector to install itself. Don't you just love "Swan Rot"? SETRTIM x Sets the value of the REAL timer. Eg. setrtim 0 RTIM Returns the value of the REAL timer. Eg. print rtim These 2 timing commands were added after we had severe problems with some music types and some border-removal routines where the TIMER variable was needed. For instance, after playing some Synth-dream music TIMER would no longer update, which caused quite a lot of problems in games where you were to be invulnerable for the first 3 seconds or whatever. WARMBOOT Causes a reset, as if you had pressed the reset button. Eg. 10 repeat : g$=upper$(inkey$) : until g$<>"" 20 if g$="Q" then warmboot This command can be very useful for making sure people aren't mucking around with your programs. A reset is always dishearting to inept crackers... AESIN Checks whether GEM is initialised or not. Eg. 10 if aesin then ?"Do you like GEM or something?" This command is used to make sure a program that's supposed to run from the AUTO folder isn't being run from the desktop, which can be extremely useful for demo's. BLITTER Checks for a blitter chip. Eg. 10 if blitter then ?"Huh!" I think it's only fair to tell you that this command is untested due to the fact that neither of us have blitters! SILENCE Stops all sounds. Eg. 10 dreg(0)=1 : call start(10) 20 repeat : call start(10)+2 : until inkey$=" " 30 silence Very very useful for clearing those residual notes left when you stop a bit of music. KBSHIFT Returns the values of the shift+special keys. Eg. 10 print "Press BOTH shift keys" 20 repeat 30 until kbshift=3 This command can be useful in games as you can test for combinations of different keys (as in the example). KOPY Src, Dst, Size This is a super-fast version of the COPY command. It will copy Size number of bytes (EVEN!) from address Src to address Dst. Eg. 10 cls back,1 20 kopy back,logic,32000 This command is about twice as fast as COPY. It is very, very useful for disting objects for demo coders. Make sure that the number of bytes you copy is even though! You may not like the consequences if you don't... We would like to thank, from the very bottom of our hearts Neilly of The Gap. You ought to keep a look out for his game which shall be finished soon, and it really is of a rather high quality. It will almost certainly be called 'Live Wire' and is a 50Hz shoot-em-up extravaganza! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Speed: Here are the timings for each command (at least the four which merit timing, I mean, there's not much point timing NDRV is there?). COMMAND TEST BASIC (VBL) COMPILED (VBL) --------------------------------------------------------------- COL 1000 times 28 5 POINT 25 8 --------------------------------------------------------------- DOT 1000 times 28 5 PLOT 27 9 --------------------------------------------------------------- FASTCOPY 50 times 48 46 SCREEN COPY 54 54 --------------------------------------------------------------- SKOPY 4 100 (160x99 block) 31 27 SCREEN COPY 41 37 --------------------------------------------------------------- SKOPY 1 " 21 16 SKOPY 2 " 25 21 SKOPY 3 " 39 34 --------------------------------------------------------------- As you can see, our commands are quite a bit faster! And considering the advantages, I would think that it would be well worth your time registering! Bitplanes: First of all,for those of you who don't know how the ST screen display is set up I will include a short piece about it. The ST screen display is made up of four 'BITPLANES' this is rather like having four translucent pieces of plastic in front of each other. The sixteen colours are made by varying combinations of pixels set in each bit-plane for example:- colour 1 is made by a pixel set in the 1st bitplane colour 2 by one in the 2nd colour 3 is made by a combination of 1 & 2 colour 4 is one in the 3rd colour 5 is one in the 3rd & 1st colour 6 is one in the 3rd & 2nd colour 7 is one in the 3rd , 2nd & 1st colour 8 is one in the 4th Colours 9 - 15 are the same as 1 - 8 but with plane 4 set. Obviously colour 0 is the background and has nothing set For more information on bitplanes read :- Herman Willey : The ST screen display - a new perspective Jonathan Small : Bitplanes - a metaphysical breakdown Alice Hats : A periodic history of multi-planar screen displays SKOPYing - a foreword: To fully understand the use of SKOPY first you have to know one important thing about the SCREEN COPY command. It copies 4 planes and nothing else. This is fine in itself but 4 plane screen copy takes a lot of time - hence the need for something faster, ie a 1, 2 or 3 plane screen copy. This is exactly what SKOPY does. Good points: As well as being fast it means that you can do separate graphics functions on separate bitplanes. For example, you can draw all of your sprites on plane 4 and your background on plane 1. This way they won't erase each other or flicker and you don't have to use a buffer to hold sprite backgrounds. This technique is used extensively in "The Cunning Demos" and the soon to be released "Misty demo" (with a different name probably). Problems (yuk): The main problem is the fact that you have to engineer your palette so that you don't end up with a complete mess. For example, imagine you have a picture which is drawn using colour 1. Now, if you copy a 1 plane image onto plane two all of the areas where the two images meet will be colour three! The only way around this would be to make colour three either the same as colour 1 or the same as colour 2. This has the disadvantage of limiting your palette. It does however, mean that one can make "transparent" sprites/scrollers. By setting the palette so that when your sprite moves over the background the colours displayed where they cross are brighter versions of those in the background, which can produce some very nice effects. Storage: The ST's (low-res) screen is made up of four bitplanes. These are stored as series of 2-byte (1 word) chunks. Each word controls the 16 pixels on it's plane (eg %0000000000000000 means that the 16 pixels are empty, %1000000100010000 means that there is 1 pixel at the far left hand side and two in the middle). So, to address any one plane of the screen, use an offset of 2 bytes from the screens address. EG. skopy 1,logic,0,0,160,100,logic+2,0,0 would copy a 160x100 chunk of bitplane 1 to bitplane 2. skopy 1,logic,0,0,16,20,logic+4,144,100 would copy a 16x20 chunk of bitplane 1 to bitplane 3. skopy 1,logic,0,0,160,100,logic+6,0,0 would copy a 160x100 chunk of bitplane 1 to bitplane 4 skopy 2,logic,0,0,320,200,logic+4,0,0 would copy the whole of bitplanes 1+2 to planes 3+4. Confused: Well, try it out and see! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -