============================================== BASIX Newsletter - Issue 1 (June 5 1999) ============================================== 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 microsoft.public.basic.dos there are also many comp.lang.basic newsgroups(too many to list) Here are some sites: http://www.basicguru.com http://neozones.quickbasic.com http://www.quickbasic.com http://www.qbt50.com 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! 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. ================================== 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. When you press a key on the keyboard, an interrupt is generated (IRQ1), when this interrupt is generated an interrupt handler is called. This interrupt handler is the keyboard handler it reads from I/O port 60h and then decides what to do with the byte after it has read it. What it does with the byte depends entirely on which key is pressed (see the chart below). |--------------------|----------------------------------------------------------| | Key | What happens | |--------------------|----------------------------------------------------------| | CTRL + ALT + DEL | memory location 0040:0072h is set to 1234h and POST | | | resumes control of the system. | | CTRL / ALT / SHIFT | Memory locations 0040:0017h and 0040:0018h are updated | | CTRL + BREAK | Interrupt 1Bh is called | | PRINT SCREEN | Interrupt 05h is called | |--------------------|----------------------------------------------------------| 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 |-------------|-----------------|----------------|----------------| | ESC 01 | U 16 | | or \ 2B | F6 40 | | ! or 1 02 | I 17 | Z 2C | F7 41 | | @ or 2 03 | O 18 | X 2D | F8 42 | | # or 3 04 | P 19 | C 2E | F9 43 | | $ or 4 05 | { or [ 1A | V 2F | F10 44 | | % or 5 06 | } or ] 1B | B 30 | NUMLOCK 45 | | ^ or 6 07 | ENTER 1C | N 31 | SCROLL LOCK 46 | | & or 7 08 | CTRL 1D | M 32 | HOME or 7 47 | | * or 8 09 | A 1E | < or , 33 | UP or 8 48 | | ( or 9 0A | S 1F | > or . 34 | PGUP or 9 49 | | ) or 0 0B | D 20 | ? or / 35 | - 4A | | _ or - 0C | F 21 | RIGHT SHIFT 36 | LEFT or 4 4B | | + or = 0D | G 22 | PRTSC or * 37 | 5 4C | | LEFT 0E | H 23 | ALT 38 | RIGHT or 6 4D | | TAB 0F | J 24 | SPACEBAR 39 | + 4E | | Q 10 | K 25 | CAPSLOCK 3A | END or 1 4F | | W 11 | L 26 | F1 3B | DOWN or 2 50 | | E 12 | : or ; 27 | F2 3C | PGDN or 3 51 | | R 13 | " or ' 28 | F3 3D | INS or 0 52 | | T 14 | or ` 29 | F4 3E | DEL or . 53 | | Y 15 | LEFT SHIFT 2A | F5 3F | | |-------------|-----------------|----------------|----------------| ============= 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 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. 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 If any PowerBASIC programmers know how to do this is inline assembler, I would like to see it. Next issue changing the Palette using an RGB Palette function. ============= 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