@4 _______________ ___ ___ ___ ___ _ _ ___|___|___|_______|___|_ ___ ___ ___ _|_ _|_ _|_ _|_ ___ ___ _|_ ___|___|___|___|___|___|___|_______|___|___|___|___|___|___|___|__ _|__ |___|___#3HINTS TIPS@4_|_ _| #3AND SNIPPETS@4___|__ |___|_ __|___ ___|___|___|___ ___|___|___| __|___|___|_ |___|___|___|__ @1 Wait for a key press: --------------------- K$="": WHILE K$="": K$=INKEY$: WEND REM K$ holds the key that was pressed Check to see if machine has more than 1 meg ------------------------------------------- IF CHIP FREE+FAST FREE > 512*1024 then PRINT "1 MEG + DETECTED" Save some memory ---------------- SET SPRITE BUFFER 16 (If not using any sprites/bobs. saves about 10k) CLOSE WORKBENCH (saves around 40k) CLOSE EDITOR (saves about 26k) Is disk in DF0: write protected or not? --------------------------------------- POKE $BFD100,%10000 `Change to %1000 FOR DF1: A=BTST (3,$BFE001) IF A=-1 THEN PRINT "DISK WRITE ENABLED" IF A= 0 THEN PRINT "DISK WRITE PROTECTED" Change mouse pointer colours ---------------------------- COLOUR 17,$FFF COLOUR 18,$123 COLOUR 19,$0 Print a line of anything ------------------------ PRINT STRING$ ("^",80) ` will print 80 ^ on screen PRINT SPACE$ (80) `Will print 80 spaces Note: You can put anything inside the " " of the first line and change the 80 to any number you wish the equivalent line to be: PRINT"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^etc" Clear just a portion of the screen ----------------------------------- CLS 12,14,39 to 305,70 The 12 is a colour the 14,39 is the top right coordinates of the portion to clear and the 305,70 is the bottom left coordinates This can be a very useful command but is overlooked by a lot of people Display palette --------------- Here is a neat little four liner that will display the colours of the current palette in use, like in an art package. FOR L=0 TO 15: INK L `set to loop 16 times 0-15 BAR (L+1)*16,170 TO (L+2)*16,177 `Draw a filled box in INK colour(L NEXT L `If L is less than 15 repeat loop STOP `Loop finished This will draw 16 filled boxes using the BAR instruction. each box will be filled with the current INK colour which is changed by the FOR NEXT loop using INK L, L starts off with the value 0 and every time the program hits the NEXT L line it checks L is less than 15 and if so adds 1 to L, when L eventually is equal to 15 the loop is completed and the STOP instruction is executed ending the program. Screen wipe ----------------- This is the screen wipe used on the loading screen of Amoszine 1. INK 0 FOR X=0 TO 319 DRAW 0,199 TO X,0 NEXT X FOR Y=1 TO 199 DRAW 0,199 TO 319,Y NEXT Y Centre Text V2 -------------- This is a handy routine that will centre any text inside T$ on to the screen This works for both horizontally and vertically, unlike the CENTRE command. T$="MONGOLIAN INTRUDERS FROM PLANET RED" ` Put some text in T$ A=LEN(T$) ` How long is it? TEXT SCREEN WIDTH/2 - (A*8/2), SCREEN HEIGHT/2,T$` See below First we put the message we want printed into T$ and then A is told to hold the length of T$. TEXT is very similar to print except it can place the TEXT cursor anywhere on screen to a pixel, where as LOCATE and PRINT can only be defined by 8 pixels (or one character square if you like.) SCREEN WIDTH returns the WIDTH of the SCREEN and SCREEN HEIGHT does what you would expect. The calculation performed gives the exact central x,y position on the screen to place the text in T$, for example SCREEN HEIGHT/2 will be exactly half way down the screen, SCREEN WIDTH/2 half way across. This is the routine Lee Bamber wrote for the clock we use in Amoszine. ---------------------------------------------------------------------- REM Clock, By Lee Bamber for Amoszine REM Set up vars for hours minutes and seconds Time=Timer:Times=0:Timem=0:Timeh=0 Rem your main loop Do Gosub CONSTRUCT_TIME Loop REM The subroutine CONSTRUCT_TIME: Time$=((Timer-time)/50) If Times>=60 Times=0:Time=Timer Inc Timem If Timem>=60 Timem=0 Inc timeh Endif Endif REM The following two lines should be all on one, I couldn't fit it on here. Time$=Mid$(Str$(100+Timeh),3,2)+":"+Mid$(Str$(100+Timem),3,2)+":"+Mid$ (Str$(100+Times),3,2 Pen 1:Paper 0:Home:Print Time$ Return @3 Please send in your best tips or snippets of code for this column. Steve.