Basixzone wrote: > > Basixzone - http://members.tripod.com/Basixzone > > ============================================== > BASIX Newsletter - Issue 1 (June 5 1999) The date will need to change, obviously, so will the number... > ============================================== > BASIX Newsletter > Author: Peter Johnson aka. Screech > Web : http://members.tripod.com/Basixzone > Email : Basixzone@listbot.com > ============================================== > CONTENTS > > 1. Welcome! > 2. Resources for BASIC Programming > 3. Advanced keyboard programming > 4. Graphics > 5. Goodbye! > > ============= > 1. Welcome! > ============= > > Welcome to the first BASIX Newsletter! This is the first in a monthly > series of Newsletters, the letter will mainly cover tutorials, but will > also have news on other things to do with BASIC. The main reason I started > this Newsletter was because I read the old BASIX Fanzine(when it was > edited by Peter Cooper) and was inspired to write my own when he stopped. > > ==================================== > 2. Resources for BASIC Programming > ==================================== > > The first place that I would tell you to look are the BASIC Newsgroups: > > alt.lang.basic comp.lang.basic.misc is a good one to list generally. > microsoft.public.basic.dos These are the main set of active ones (IMHO) > there are also many comp.lang.basic newsgroups(too many to list) and microsoft.public.basic series and alt.lang.---basic and loads more with a quick search for BASIC on my server... These tend to be more specific > > Here are some sites: > > http://www.basicguru.com > http://neozones.quickbasic.com > http://www.quickbasic.com > http://www.qbt50.com http://www.qbasic.com <-- Might not be updated much, but still useful I'm going to publicize my own site, which, although not strictly BASIC, still has loads of info on anything I can be bothered to stick in there... http://www.freezone.co.uk/python/bucko/ > If you go to http://members.tripod.com/Basixzone a host of compoilers can > be downloaded including VisualBASIC for DOS and VisualBASIC 3.0 and also > all of the back issues of these Newsletters will be available, but as this > is Issue 1 there aren't any back issues at the > moment! OOOPS VBDOS, PDS, VB3, QB4.5, and loads more from M$, I believe are still quite illegal. I won't turn you in, but others might. > I don't actually know of any good FTP sites, but here is the address of > where all the BASIX Fanzines are kept http://come.to/basixfanzine the > issues 1-8 were edited by Peter Cooper ,but I don't know who edits all of > the newer issues. ftp://x2ftp.oula.fi/pub/msdos/programming/ It's closing down, and I don't have any mirrors, but nevertheless, a good ftp site... > > ================================== > 3. Advanced keyboard programming > ================================== > > Many of you reading this would probably be saying, whats advanced about > programming the keyboard? > Well the answer is, think about all those keys that you cannot use in your > programs; SHIFT, CTRL,ALT, CAPS LOCK. > When you are usually reading from the keyboard, you just use INKEY$, we > cannot use INKEY$ when we need to use all of the special keys so we have > to understand howeverything works. Sorry to say this, but what was here just complicated matters. A beginner reading this tutorial would understand nothing about what was going on, and I didn't learn about interrupts till a while ago. When writing informative articles, I usually find that it's best to stick to stuff that's relevant, not try to describe exactly what goes on, or it can lose the readers interest. > If we wanted to find out which key had been pressed, we just read port 60h > eg. > > KEY = INP(&H60) > > and this gives us the keyboard scan code for the key that has been > pressed, but know I here you say, what is a scan code? A scan code is the > code that is generated every time a key is pressed. > > Keyboard Scan code chart You could have done with mentioning break codes too (the scan code +128 means that the key was lifted), then go on to produce a nice little program that tracks all of the keys (if your quick, I posted one to an NG). > > > ============= > 4. Graphics > ============= > Every computer program involves graphics, from the character-based screens > of DOS to the one > that most people use, SCREEN 13. > To set the graphics mode to SCREEN 13 under QBASIC use the command SCREEN > 13, but under PowerBASIC you should use > ! MOV AX,&H13 > ! INT 10 > this just does the same thing, but in inline assembler. > > SCREEN 13 is the graphics mode used by most programmers because it is fast > and uses 256 colours, the reason that it is fast is because it uses 1 byte > for every pixel, in comparison for other > 16 colour modes which use 1/2 a byte and are difficult to use because of > this. SCREEN 13 stores it's pixels at memory location A000h or &HA000 > because the screen is 320 pixels wide and 200 pixels high then 64000 bytes > are used to store one screen of information(320 x 200 = 64000), this is > why there is only one screen page avaliable to the programmer when he/she > uses this mode. Again, we have stuff that could be a little hard to understand. Say it's in Hexadecimal, and they'll understand better though... But you'll need to put a tutorial in base 2 and 16 somewhere in a newsletter. > To place a pixel on the screen using SCREEN 13 you would use the PSET > command or in our case we are going to write a SUB which will be used > instead of PSET. > > To write a pixel to the screen we muist set the screen mode then POKE a > pixel to an offset of memory location &HA000. The equation for working out > the offset to write the pixel to is simple X% + (Y% * 320) > but we need to change the equation slightly X% + (Y% * 320&) the & simbol > is needed after 320 becuase this is to tell the programming language that > the result should be stored in a long integer to stop the overflow error(I > used to use long integers for X and Y to get over this, but Squeak told me > to do it like this and its faster) > > '------------------- Start Program > 'COL% is the colour you want to use > 'X% is the X location of the pixel you want to place > 'Y% is the Y location of the pixel you want to place > SUB PUTPIXEL (X%, Y%, COL%) > DEF SEG = &HA000 'Change the moemory SEGMENT > POKE (X% + (Y% * 320&)) 'POKE the colour into the memory OFFSET > END SUB > '------------------- End program Minor note: INDENT YOUR SUBS! '------------------- Start Program 'COL% is the colour you want to use 'X% is the X location of the pixel you want to place 'Y% is the Y location of the pixel you want to place SUB PUTPIXEL (X%, Y%, COL%) DEF SEG = &HA000 'Change the moemory SEGMENT POKE (X% + (Y% * 320&)) 'POKE the colour into the memory OFFSET END SUB '------------------- End program Is easier to read... > > If any PowerBASIC programmers know how to do this in inline assembler, I > would like to see it. Next issue changing the Palette using an RGB Palette > function. (Quick ASM proggy) MOV ES, A000h ;Extra Segment = Video buffer MOV BX, X ;BX = X MOV AX, Y ;AX = Y MOV CL, 8 SHL AX, CL ;AX = Y * 256 ADD BX, AX ;BY = X + Y * 256 MOV AX, Y ;AX = Y MOV CL, 6 SHL AX, CL ;AX = Y * 64 ADD BX ;AX = BX + Y * 64 = X + Y * 320 MOV DI, AX ;Offset=Offset of pixel MOV AL, Colour ;AL=Coulou MOV [ES:DI],CL ;Set The pixel Probably could be shorter and/or faster, but it works (I hope - it's untested ~^.^~ and it doesn't store the old stuff Here's the Blast! library version of the same... PUSH DS ;Save the Destination Segment PUSH BP ;Save the Base Pointer MOV BP,SP ;Get the Stack Pointer MOV AX,[BP+10] ;Get the to buffer segment MOV DS,AX ;and set DS to it. MOV SI,[BP+0A] ;Get the Y position. MOV CL,06 ;Multiply it by 64 by using a Shift SHL SI,CL ;Left (SHL) for speed. MOV BX,SI ;Save the result temporarily. MOV CL,02 ;Shift left again to multiply the SHL SI,CL ;Y position by 256, then add that ADD SI,BX ;value to our saved result. MOV BX,[BP+0C] ;Now get the X position and add it ADD SI,BX ;to the result to get our final MOV BX,[BP+0E] ;offset. Then get the To buffer ADD SI,BX ;offset and add the pixel offset. MOV AL,[BP+08] ;Get the pixel color, MOV [SI],AL ;and plot it. POP BP ;Reset the Base Pointer POP DS ;Reset the Destination Segment RETF 000A ;Return to BASIC Program, clean up It's in sub for but hey! What isn't... (it was built for a CALL ABSOLUTE) > ============= > 5. Goodbye! > ============= > > Well thats it for now, but i'll see you all again next month on the 3rd of > July, if you have ANYTHING that you want to send into the Newsletter then > email it to: Basixzone@listbot.com > > Screech > > If you have a friend who wants to subscribe or you do then send a blank > email to: subscribe-Basixzone@listbot.com > > ______________________________________________________________________ > To unsubscribe, write to Basixzone-unsubscribe@listbot.com > Start Your Own FREE Email List at http://www.listbot.com/ Some notes on stuff to add for the next one. See above... By the way, the grammar in this issue is a bit terrible... The bit of the keyboard that I snipped looks like (to quote Terry Pratchett) "a ballistic approach to spelling and puctuation." Obviously the spelling doesn't apply, butthere's a certain lack of punctuation there. I'm sorry about insulting you a bit, if you did find it insulting, so be it, but I speak my mind, and by taking these suggestions into account, you could greatly improve the newsletter. Oh and how about some beginners how o do stuff things too. I'm not against complex stuff, but the newsletter shouldn't be oriented entirely on the expert - read a few fanzines for an example. -- "640K of RAM is all anybody could ever need" - Bill Gates EMail: David@softwear.freeserve.co.uk ICQ: 24444579