CPCWiki forum

General Category => Programming => Topic started by: AMSDOS on 08:30, 11 August 16

Title: Colour Cycle Program with Cursor Control in BASIC
Post by: AMSDOS on 08:30, 11 August 16

This is just a bit of an example I made using Colour Cycling to produce simple line graphic triangles, which gets deleted as it goes along. All that is happening through the EVERY command in Line 40. In addition the program continues into an Infinite While Loop and have setup a little Cursor Key routine for plotting an "Evil Red Dot" which can move anywhere (including through the Triangles), though when EVERY 10 is reached to do the rotation, there's a holdup with the Keyboard part of the program and wondered if that could be avoided or if that's the way it is? I tried changing to have EVERY 10,1 thinking low priority interrupt mightn't effect the Keyboard INKEY, but it didn't seem to matter if it was 1 or 3 or nothing there at all, though the smaller the number the more noticeable it was.

10 MODE 1
20 s%=1 : f%=2 : d%=0
30 x%=0 : y%=398
40 EVERY 10 GOSUB 1010
50 WHILE 1
60 IF NOT(INKEY(8)) AND (x%>0) THEN oldx%=x% : x%=x%-2 : PLOT x%,y%,3 : PLOT oldx%,y%,0
70 IF NOT(INKEY(1)) AND (x%<638) THEN oldx%=x% : x%=x%+2 : PLOT x%,y%,3 : PLOT oldx%,y%,0
80 IF NOT(INKEY(0)) AND (y%<398) THEN oldy%=y% : y%=y%+2 : PLOT x%,y%,3 : PLOT x%,oldy%,0
90 IF NOT(INKEY(2)) AND (y%>0) THEN oldy%=y% : y%=y%-2 : PLOT x%,y%,3 : PLOT x%,oldy%,0
100 WEND
1010 col%=1
1020 ON s% GOSUB 2000,2050,2150,2100
1030 col%=2
1040 ON f% GOSUB 2000,2050,2150,2100
1050 col%=0
1060 ON d% GOSUB 2000,2050,2150,2100
1070 s%=s%+1 : f%=f%+1 : d%=d%+1
1080 ' CALL &BD19:CALL &BD19
1090  IF d%=5 THEN d%=1
1100  IF s%=5 THEN s%=1
1110  IF f%=5 THEN f%=1
1130 RETURN
2000 PLOT 320,200,col%
2010 DRAW 300,190
2020 DRAW 340,190
2030 DRAW 320,200
2040 RETURN
2050 PLOT 320,208,col%
2060 DRAW 300,198
2070 DRAW 300,218
2080 DRAW 320,208
2090 RETURN
2100 PLOT 320,208,col%
2110 DRAW 340,198
2120 DRAW 340,218
2130 DRAW 320,208
2140 RETURN
2150 PLOT 320,216,col%
2160 DRAW 300,226
2170 DRAW 340,226
2180 DRAW 320,216
2190 RETURN
Title: Re: Colour Cycle Program with Cursor Control in BASIC
Post by: AMSDOS on 11:06, 18 August 16
This is rather embarrassing and foolish of me given I normally just use GOSUB within a loop, and this is no different. Simply:



40 WHILE 1
50 GOSUB 1010



eliminates the slight interruption and runs much better.  ???


One things for sure, EVERY programmer has done this at some point!  :D
Powered by SMFPacks Menu Editor Mod