Silly Season has come round again (you know, that time of the year we
used to think of as Christmas). Anyway, I had the idea I might knock
up a simple Tetris, and perhaps just manage to sneak it into the Crap
Games competition before closing time. I have a nearly-playable
version lying around somewhere that I never quite finished. One reason
was that I became bitterly disillusioned with it when I tried to run
it in Q-emulator - it was just too slow - totally unplayable, even at
Gold Card speeds!
The shapes were made using BLOCK commands, and although I could
probably have speeded up loops and such here and there it became clear
to me that it would never work satisfactorily on QL hardware -
something that was an important design goal.
So, a few days ago I had this brilliant idea to use characters instead
of blocks to draw the shapes. Surely, that should be miles quicker?!
So before rearranging my whole game, I tested the idea. I wrote a
sketch in QD in QPC2 and tested out just a simple shape and let it
gently drift down the screen. Then I transferred to Q-emulator: JS,
640k, 512x256 mode 0, QL speed. LOAD.., .., .. Something wrong? Nope,
thats just how long it takes (How DID we put up with it back then?!!)
So I switched to GoldCard speed. A little better..
Code: Select all
100 cw = FOPEN("con_")
102 stc$ = '#*X©' & chr$(31): rem Star chars
104 papc = 0: rem Paper colour
106 spd% = 2: tio% = 0: rem Speed / timeout
108 wsx% = scr_xlim(#cw): rem Use whole screen
110 wsy% = scr_ylim(#cw)
112 mxx% = wsx% - 9 * 6: rem x-limit
114 mxy% = wsy% - 10: mxy2% = mxy% / 2: rem y-limit
116 nos% = wsx% / 50: rem Number of stars
118 fc% = 0: tl% = fc%: rem Fallen count, total lines
120 if disp_type = 0: mode 8: mxx% = mxx% - 6
122 window#cw; wsx%, wsy%, 0, 0: paper#cw; papc: cls#cw
124 :
126 randomise
128 dim starc%(nos%), starv%(nos%, 1), starx%(nos%), stary%(nos%), star%(nos%)
130 for i% = 0 to nos%: NewStar: stary%(i%) = rnd(0 to mxy2%)
132 :
134 rep lp
136 for i% = 0 to nos%
138 if starv%(i%, 1) = 0 then
140 starv%(i%, 1) = starv%(i%, 0): rem Individual speed
142 else
144 starv%(i%, 1) = starv%(i%, 1) - 1
146 next i%: exit i%
148 endif
150 :
152 y% = stary%(i%): stary%(i%) = stary%(i%) + spd%
154 if stary%(i%) >= mxy% then
156 NewStar: rem Star landed. Replace
158 fc% = fc% + 1
160 if fc% = nos% then
162 mxy% = mxy% - 10: tl% = tl% + 10: fc% = 0
164 if tl% > mxy2%: k$ = inkey$(#cw; 150): exit lp: rem Snowed under: Stop!
166 endif
168 next i%: exit i%
170 else
172 DrwX#cw; starx%(i%), y%, star%(i%), papc
174 DrwX#cw; starx%(i%), stary%(i%), star%(i%), starc%(i%)
176 endif
178 end for i%
180 :
182 k% = code(inkey$(#cw; tio%))
184 sel on k%: = 27: exit lp: = 32: pause#cw
186 endrep lp
188 quit
190 :
192 def proc DrwX(ch, xp%, yp%, s%, c%)
194 LOCal x%, y%, p%
196 y% = yp%
198 INK#ch; c%
200 DL 36, ' X X'
202 DL 30, ' X X'
204 DL 48, 'X X X X X'
206 DL 30, ' X X'
208 DL 36, ' X X'
210 enddef DrwX
212 :
214 def proc DL(l%, l$)
216 if y% >= mxy%: ret
218 p% = 1
220 for x% = xp% to xp% + l% step 6
222 if l$(p%) = 'X': cursor#ch; x% , y%: bput#ch; s%
224 p% = p% + 1
226 endfor x%
228 y% = y% + 10
230 enddef DL
232 :
234 def proc NewStar
236 starc%(i%) = rnd(6 to 7): rem Mainly white/yellow
238 if not rnd(0 to 5): starc%(i%) = rnd(papc + 1 to 5): rem The odd coloured star
240 starv%(i%, 0) = rnd(1 to 6): rem Individual speed
242 starx%(i%) = rnd(0 to mxx%): rem x-position
244 stary%(i%) = 0: rem Start at top
246 star%(i%) = code(stc$(rnd(1 to 5))): rem Star type
248 enddef NewStar
250 :
The first thing I had to do was hobble the program by taking out all
the quick integer FOR loops and SELects. Turns out TK2's BPUT, and
even PAUSE,.. are not the same as SMSQ/E's. Other small differences,
incongruities and anomalies had to be weeded out, too.
It sort of worked,, but I needed more colour, so I switched to mode 8.
Editing and faffing around, with no decent last line recall,
overlapping windows scribbling all over each other, having to re-type
the name for every save, etc, etc, was just terrible, so I loaded the
PE as well so as not to loose my mind completely.
It soon became abundantly clear that this was never going to work. I
kept the flow for a while to see how it felt working on a QL again.
Thats how I ended up with this first instalment of an annual
Crap
Christmas Card Tradition. (I wont put this in the topic title as it
could deter some people from presenting their very
non-crap Christmas
card offerings!)
Its ghastly, I know, but you may find it soothing to watch while you
slit your wrists as the ten thousandth repetition of Jingle Bells
wafts through your kitchen window from a nearby shopping mall..
So this version here is mainly for SMSQ/E in any mode - QL or GD2, and
a large, full screen display. It wont bring any seasonal cheer, I
expect, but one or two budding S*BASIC programmers may find something
to interest them - and anyone else, something to crinkle their noses
about. I wont publish the mode 8 QL version, its pointless. It looks
more or less the same if you run it at full speed in Q-emulator,
except for the dicky screen. The compiled version may at least
function in a QL (+(S)GC), but dont expect it to jingle your bells..
TL;DR:
EX the SBASIC version, or LRUN it in a daughter SBASIC, or F10 it in
QD, or do the usual with the compiled version. <SPACE> to pause, <ESC>
to exit.