------------------------------------------------------------------------------- PROBLEM ATTIC PROBLEM ATTIC ------------------------------------------------------------------------------- We try to solve your problems with Arnold - nothing is too simple or too complicated for our experts Just one more time The December issue suggested that people might send in programs to simulate bingo. Here is a one-liner. Characters with an up-arrow are control codes. For example, the ^G in front of 'Press a Key' means type Control-G - which will sound a beep when the program runs. ______________________________________________________________________________ | | [Listing - BINGO.BAS] |______________________________________________________________________________ S Fearnley Drayton, Abingdon Okay, you win. But I tell you, it's the last time, and only because it's one line. The AA offices are knee-deep in bingo programs. It has got to the stage where Bob barely has the strength to (ahem) wade to his joystick. Thank you for the overwhelming response. Please, no more! (Note a peculiar Control-Zero near the right margin of the listing's third printed line. The others are Control-O - the letter. We apologise that the slashed zero is not yet working on our new typesetter - just as we'd perfected it on the old one!) / \ / \ / \ T Y P E - I N S /_________________\ ______________________________________________________________________________ | Variable height | We have had slow double-height, fast double-height, Basic double-height and | machinecode double-height routines in past issues. A sensible follow-up would | be a program for variable height or width. You have John Keneally of Exeter | to thank for this. | The main routine is from line 6000 on. John has included a small demo | which shows off the program's power. If you wish to use it in your own | listings, the following variables must be set up: | a$ the string to display | x,y graphic coordinates | mx,my magnification factors - horizontal and vertical | dx,dy change in horizontal and vertical position for each successive | character. Expressed as a proportion of the character size. For | normal horizontal writing make dx=1 and dy=0. | gink pen colour | | | [Listing - VHEIGHT.BAS] | | ______________________________________________________________________________| 3D loops Here is a fine routine from JD Crabtree of Darlington, using a simple algorithm. It draws up 15 symmetrical patterns of increasig complexity and refinement. The shapes are based on rotating and interweaving circles and ellipses. The demo takes around seven minutes to complete - well worth the time. It just goes to show that Basic is capable of complex and powerful mathematical functions. __________________________ | | | [Listing - 3DLOOPS.BAS] | |__________________________| _____________________________________________________________________________ | | |Landscapes | |Last issue we reviewed the Landscape Utility. This month Martyn Harrison of | |Stockton-on-Tees has written an extremely short routine to do virtually the | |same: create landscapes. This is an excellent piece of programming - no need | |to shell out £19. With a little modification, it should be fairly simple to | |incorporate routines to draw clouds, trees and so on. | |_____________________________________________________________________________| [Listing - LANDSCAP.BAS] ______________________________________________________________________________ | | Multi-coloured modes | Ever wanted twice as many colours in all modes? TA Shah of Blackburn, | Lancashire, has written a fantastic utility that will allow four colours in | mode 2, eight in mode 1 and all 27 in mode 0. As a consequence of the | programming technique involved, when you issue a MODE command, the screen | will flicker and look unsightly. To overcome this, several RSX commands have | been included - these are commands preceded by a bar (|). | These are the extra commands and how to use them: | |MODE,n changes to mode n - fairly obvious. | |INK sets all the inks to be used by the interrupt routine. The inks are | set by the operating system's usual INK command, but instead of the inks | flashing when the second colour is used, the first number is used to display | one colour and the second to display the other. You use it following the | usual command, like this: | INK 1,3,6:|INK | This will display 2 separate colours on different parts of the screen - they | will not flash. | |SIZE,n sets the size of the display area for the different colours. n | must be a whole number between 1 and 5: | 1 displays only one colour | 2 - a quarter one colour | 3 - half one colour and half the other | 4 - three-quarters one colour | 5 - all the other colour. | |ON switches on the interrupt routine. | |OFF returns your Amstrad to normal. | When the routines are on, all colours are changed because they are being | flipped in the pallette memory. The second program is a demo, showing off | exactly what it can do. | | [Listing - MULTICOL.BAS] +-------------------------+ | | [Listing - MULTIDEM.BAS | | +-------------------------+ |______________________________________________________________________________ Budgie Ever wanted an absolutely useless program to make Arnold chirp like a budgie? Your prayers have been answered. Ian Cookson of Coventry has come up with an ideal solution. It may not be much use, but will teach you a little about sound production. Anyway, it's pleasant listening. [Listing - BUDGIE.BAS] _____________________________________________________________________________ | | |Rotating triangle | |The following program from Michael Pease of Norwich is a simple wire-frame | |graphics demonstration. The program creates a triangular image, which it then| |rotates around an invisible axis. | |_____________________________________________________________________________| [Listing - TRIANGLE.BAS] _____________________________________________________________________________ | | | | |Screen flip | |Richard Turner of Northampton has provided a mini-listing that turns a screen| |upside-down. A simple Call to location &9C40 sets this in motion. | | | |_____________________________________________________________________________| | | | | | [Listing - SCRFLIP.BAS] | | | |_____________________________________________________________________________| ______________________________________________________________________________ | | Electronic rainbow | Messrs Keldorff and Havmand in Denmark have written a program that will allow | you to create some totally meaningless yet satisfying effects. Using a | joystick or the cursor cluster, patterns can be produced which, when the fire | button or copy key are pressed, will come to life. It's done by palette | switching, a CPC speciality. | If you wish to use a joystick, remove line 20. For a green-screen | monitor, remove line 160. | | [Listing - RAINBOW.BAS] | | ______________________________________________________________________________| Window saver As you know, it is possible to create windows under Amstrad Basic. These can open at any position on the screen - a maximum of seven at a time. One annoyance, though, is that if one window is defined on top of another, the contents of the bottom one are lost forever. David Lincoln of Beeston, Nottingham, has produced a program that will save areas of the screen into memory. These can be called back at any time - not necessarily to the same position. To load and save a window, you are provided with two RSX commands: |W.SAVE,a,b,c,d,e |W.LOAD,a,b,c,d,e In both cases, a is the left position of the window, b its right, c top, d bottom. The final parameter, e, is the memory address where the window is to be stored. By varying it, you can store more than one window. Anywhere from &4000 to &6000 is as good a place as any to start storing a window. If the whole screen is saved, though, you need &4000 bytes and the start address must be near to &4000. Obviously, the same address value must be used when restoring a window. It may be loaded back to a different screen position, as long as the height and width are not altered. For example: |W.SAVE,10,20,10,20,&4000 |W.LOAD,30,40,10,20,&4000 will generate a second copy of the first window, 10 characters to the right. It is possible to calculate the number of bytes needed for the window in memory: L*D*8, where L is the number of rows of characters in the window, and D = (right of window - left of window)*(width of character). The width of the character varies according to the current mode setting. It will be 1 in mode 2, 2 in mode 1 and 4 in mode 0. To save the program as a binary file, type: SAVE"WINDOW.BIN",B,&A080,&F9. To reload, type in direct mode: MEMORY &A000:LOAD"WINDOW.BIN":CALL &A080 [Listing - WINDOW.BAS] _____________________________________________________________________________ | | | | | AGRAL-86 | | That dynamic Danish duo, Rasmus Keldorff and Mads Havmand have written | | AGRAL - A GRAphical Language. Agral is a very short version of the | | well-known language Logo. These are the commands that Agral accepts: | | WALK x move x units (backwards when x is negative) | | TURN x turn right by x degrees (left when x is negative) | | ANGLE x sets cursor to bearing x degrees | | CLEAR x changes the background colour to x and clears both text and | | graphics screen | | PENCIL x changes the drawing colour: 0=delete, 1=yellow, 2=green, | | 3=orange | | LOOP x no nestling allowed. As the name suggests, you can repeat or | | loop several commands | | END starts execution of your program | | To help you on your way, here is a small routine to try: | | | | > LOOP 10 | | > WALK 100 | | > TURN 90 | | > WALK 100 | | > TURN 90 | | > WALK 100 | | > TURN 90 | | > WALK 100 | | > TURN 126 | | > END | | | | | | [Listing - AGRAL-86.BAS] | | | |_____________________________________________________________________________| _____________________________________________________________________________ | | | | |The 3D world | |Continuing with three-dimensional perspective, we have a wire world for you, | |programmed by Jason Erskine of Newhaven. Its short size belies its execution | |time. | | | |_____________________________________________________________________________| [Listing - 3DWORLD.BAS] _____________________________________________ | ___ _____ _____ ___ ___ | | | | / \ | | | | \ / \ | | |____| | | | | | |___/ \___ | | | | | | | | | | \ | | | | \___/ | | | | \___/ | | | | The page where you can help others reach | | enlightenment with their CPC | | | |_____________________________________________| Fat keys for Tasword If EK Scott (Problem Attic, October) really wants to use 2k for key definitions, the following short program will do the trick. Whether it will be of much use is another matter. Tasword doesn't leave a lot of room for files as it is, and after this program is run the whole of the tutor file will no longer fit. You get a File Full message after 185 lines. [Listing - 2KKEYDEF.BAS] The routine can be used in any other program. It permits up to 255 characters on one key - for example, type KEY 139,STRING$(255,"A") and pressing the small Enter key will give hundreds of AAAAs. The program can be modified quite easily to give more or less memory for expansion keys. For example, change all 9Fs in the program to 97 and change the sixth data item, 08, to 10 to get 4k for expansions. Alex Aird Birmingham ------------------------------------------------------------------------------- Putting Ascii in its place Here is a shortish routine that I'm sure will be of interest to many readers. It can transfer Ascii files from tape to disk or vice-versa. Alternatively, you can view the text file, rather like the Type command in the CP/M operating system. The program is self-explanatory. [Listing - ASCTRANS.BAS] RJ Mc Gregor Bristol ------------------------------------------------------------------------------- Complementing sound digitizer I have written a program, Sound Bank, to complement Digitizer (AA 15) for 6128 users. It lets you store digitized sounds in the upper four banks of memory. This leaves full Basic memory untouched bar that which contains the digitizer program. The memory available to store the digitized sound is 64k, which by my calculations gives approximately 45 seconds of sound. Type the following in direct mode - make sure n is between 0 and &3FFF: MEMORY &8FFF:LOAD "DIGITIZE.BIN" CALL &9000:OUT &7F00,196:|R,&4000,n SAVE"bank1",b,&4000,n CALL &9000:OUT &7F00,197:|R,&4000,n SAVE"bank2",b,&4000,n CALL &9000:OUT &7F00,198:|R,&4000,n SAVE"bank3",b,&4000,n CALL &9000:OUT &7F00,199:|R,&4000,n SAVE"bank4",b,&4000,n Each bank is saved separately, so four files will be saved to disk. The OUT commands in this program change the bank to which data is sent. OUT &7F00,192, for example, is the CPC's normal memory. OUT &7F00,196 moves the first bank into the memory locations &4000 to &8000. Type in the Sound Bank listing and save it to the same disc that holds both Digitizer and your digitized sounds. Sound Bank will automatically load the Digitizer code and your digitized samples - and pressing the correct keys will treat your ears. [Listing - SOUNDBNK.BAS] Andrew Walker Horndean, Portsmouth ------------------------------------------------------------------------------- [The letters below were published in the "Reaction" column in the April 1987 issue (#19). Landscapes was originally published as Fourier Synthesis in the May 1985 issue of Your Computer (Vol.5 No.5), and was written by Brian James.] Not nice, Martyn! I'm just contacting you to say how much I liked the type-in Landscapes by Brian James (March '85). Oops - silly me. I mean Martyn Harrison (Feb '87). Anyone can make a mistake, I suppose, especially when the program was featured in an article in Your Computer May 1985 as 'Fourier Synthesis' by Brian James along with a review of his Landscape Creator - for £5 at the time. I wouldn't be large, green and angry apart from the fact that MH didn't even bother to change variable names etc. V. Angry Bridgemary (via Prestel) We do apologize to Brian James for accidentally infringing his copyright. Unfortunately Martyn Harrison's small type-in payment has already gone out to him. We await his apology. The least he could do is send the cheque to Brian James. * Martyn Harrison didn't do much more than use the CLR key to put his name in line 2. By the way, I think the Landscape Utility is well worth its price. For me it was the decisive reason to buy an Amstrad CPC! This program is incredible! I do not believe it would be so simple to modify the short Fourier-synthesis program, just adding some clouds and trees, to make the Landscape Utility. Guenter Grimm Mainz, W Germany