Dr. Jim's QL Dumping Ground

Anything QL Software or Programming Related.
EmmBee
Trump Card
Posts: 240
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Dr. Jim's QL Dumping Ground

Post by EmmBee »

TMD2003 wrote: - but I will get that "G" problem fixed. Somehow...
I may have found something ...

2165 IF h%(n)>16 THEN d2h_carry(n)

Perhaps it should be >15 ... That could explain why it only happens with 16 and not any greater values.


User avatar
TMD2003
Trump Card
Posts: 168
Joined: Sat Oct 10, 2020 12:18 pm

Re: Dr. Jim's QL Dumping Ground

Post by TMD2003 »

You are correct, and it was that simple. When I was making this version I effectively copied the procedure for decimal-to-binary from hbc8_bas and converted it to decimal-to-hex. The original line in hbc8_bas was:

2180 IF b%(n)>1 THEN bit_carry(n)

I've now corrected the download link - and the package now includes both the corrected v1.1 (ayb_bas) and the decimal-to-binary v0.8 (aybold_bas, formerly hbc8_bas) for good measure, as well as an updated text file.

GET IT HERE, and marvel at it working properly!


Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
TMD2003
Trump Card
Posts: 168
Joined: Sat Oct 10, 2020 12:18 pm

Re: Dr. Jim's QL Dumping Ground

Post by TMD2003 »

I will briefly awake from hiding under a rock, because earlier today I remembered a project I thought of taking on. It's a QL version of Kaleidoscope, originally written for the ZX81.

When I was a nipper and I had this issue of Sinclair Programs to hand I typed in this program on the Spectrum as-is, and after changing those PRINT AT 23,0;s to get it to work, what I had was a small version of the pattern at the bottom left of the screen. The Spectrum plots a single pixel, the ZX81 plots a quarter of a character square...

I've since managed to make various Spectrum versions that scale the "pixels" up to ZX81-size and colour them, whether with a PLOT/DRAW combination or PRINTing the ROM graphics (both work well but the latter is faster) - but the QL's version is going to be considerably trickier. Whether I want to get an exact 4x4 pixel square (so that the blocks look square on QPC2) or some other proportion to compensate for the QL's odd pixel dimensions, I won't be able to use LINE/FILL or BLOCK, because these will all be affected by the SCALE and will be distorted. To get perfect symmetry, I'm going to have to POKE directly to the screen, and that's going to mean getting as much of a grip on the QL's screen layout as I have with the Spectrum's. I had the positioning worked out last time I looked into it, but not the colours. The chances are I'll use MODE 8 for it.

This should be possible, but it might take me a while!


Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: Dr. Jim's QL Dumping Ground

Post by mk79 »

TMD2003 wrote:I won't be able to use LINE/FILL or BLOCK, because these will all be affected by the SCALE and will be distorted.
No, BLOCK uses pixel coordinates.

Marcel


Derek_Stewart
Font of All Knowledge
Posts: 3931
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Dr. Jim's QL Dumping Ground

Post by Derek_Stewart »

TMD2003 wrote:I will briefly awake from hiding under a rock, because earlier today I remembered a project I thought of taking on. It's a QL version of Kaleidoscope, originally written for the ZX81.
First attempt:

Code: Select all

100 REMark ZX81 programme: Kaleidoscope
110 REMark Sinclair QL version
120 :
130 setup_screen
140 :
150 LET n=INT(RND*250)+200
160 FOR a=1 TO n
170   LET v =INT (RND*22)
180   LET h = INT (RND*32)
190   LET rv = 21+(22-v)
200   LET rh = 31+(32-v)
210   PLOT h,v
220   PLOT rh,rv
230   PLOT h,rv
240 END FOR a
250 :
260 REMark Emulate ZX81 PLOT command
270 :
280 DEFine PROCedure PLOT(x,y)
290   POINT #ch;x,y
300   LINE_R #ch;0,0 TO x,y
310 END DEFine PLOT
320 :
330 REMark setup screen
335 :
340 DEFine PROCedure setup_screen
350   ch=FOPEN("scr_255x256a0x0")
360   PAPER #ch;7
370   INK #ch;0
380   CLS #ch
390   SCALE #ch;175,0,0
400 END DEFine setup_screen


Regards,

Derek
User avatar
TMD2003
Trump Card
Posts: 168
Joined: Sat Oct 10, 2020 12:18 pm

Re: Dr. Jim's QL Dumping Ground

Post by TMD2003 »

mk79 wrote:No, BLOCK uses pixel coordinates.
Well, that's interesting. Am I right in thinking it'll be useful to plot single pixels? I've been looking for a way to do that.
Derek_Stewart wrote:100 REMark ZX81 programme: Kaleidoscope
Crikey, that was quick - however, this isn't what the original does. For the ZX81, PLOT 0,0 makes a 4x4 square from 0,0 to 3,3 - then PLOT 1,0 would be a 4x4 square from 4,0 to 7,3. That should be easy enough to emulate with BLOCK, now that it's more obvious how it works. It's not the same coordinate system, so I will attempt to recreate my own ZX81 PLOT this way.

Onwards!


Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: Dr. Jim's QL Dumping Ground

Post by mk79 »

TMD2003 wrote:
mk79 wrote:No, BLOCK uses pixel coordinates.
Well, that's interesting. Am I right in thinking it'll be useful to plot single pixels? I've been looking for a way to do that.
Sure. No speed records will lay this way, but it's easy to use and does work.
If I wanted to draw more complex patterns I'd personally draw sprites using QPtr and the pointer environment. There are basic examples in the QPtr manual under the SPHDR command.


stevepoole
Super Gold Card
Posts: 712
Joined: Mon Nov 24, 2014 2:03 pm

Re: Dr. Jim's QL Dumping Ground

Post by stevepoole »

Hi TMD,

I take it you enjoy the challenge of converting an old ZX81 program for the QL ?

If you wish I can let you have a full-blown fast QL Kaleidoscope program which works on any QL platform....

Please let me know, and I can post it here.

Steve.


User avatar
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

Re: Dr. Jim's QL Dumping Ground

Post by Andrew »

Derek_Stewart wrote: First attempt:
I think you missed a Plot command - and a close#ch
I do not understand why you used Line_R in plot procedure - ZX81 Plot only puts a pixel on screen, afaik.

I changed a bit your code and this is what I got:
I dropped the For command and used a Repeat loop instead, as 200 to 400 points on screen were too few to look interesting on the large QL screen
I addded line 260 - randmly change ink from black to white to prevent the screen getting all black
I added line 270 - pressing Space will end the program

#1 - 2x2 zones on screen
The output is not interesting enough, as the simetry is only visible in the center of the screen. Also it takes ages on QL speed! But on emulator, fast speed, the screen gets black quite fast, so I added some randon ink change
If you run it on unexpanded QL then comment line 260

Code: Select all

100 REMark ZX81 programme: Kaleidoscope
110 REMark Sinclair QL version #1, 2x2 areas
120 :
130 setup_screen
140 :
150 REPeat loop
160   LET v =INT (RND(127))
170   LET h = INT (RND(255))
180   LET rv = 128+(127-v)
190   LET rh = 256+(255-h)
200   PLOT h,v
210   PLOT rh,v
220   PLOT rh,rv
230   PLOT h,rv
240   IF RND>.97 THEN ik=(ik+7)MOD 14: INK#ch, ik : END IF
250   IF KEYROW(1) && 64 THEN EXIT loop
260 END REPeat loop
270 CLOSE#ch
280 :
290 REMark Emulate ZX81 PLOT command
300 :
310 DEFine PROCedure PLOT(x,y)
320   POINT #ch,x*.7375,y
330 END DEFine PLOT
340 :
350 REMark setup screen
360 :
370 DEFine PROCedure setup_screen
380   ch=FOPEN("scr_512x256a0x0")
390   PAPER #ch;7
400   ik=0: INK #ch,ik
410   CLS #ch
420   SCALE #ch;255,0,0
430   RANDOMISE (DATE)
440 END DEFine setup_screen
#1 - 2x2 zones on screen but the "pixels" are now 4x4 blocks and the resolution is lowerd to 128x64 "pixels"
Probably mimics the ZX81 better

Code: Select all

100 REMark ZX81 programme: Kaleidoscope
110 REMark Sinclair QL version #2 - 2x2 areas, 4x4pixels
120 :
130 setup_screen
140 :
150 LET n=INT(RND*250)+2000
160 REPeat loop
170   LET v =INT (RND(31))
180   LET h = INT (RND(63))
190   LET rv = 32+(31-v)
200   LET rh = 64+(63-h)
210   PLOT h,v
220   PLOT rh,v
230   PLOT rh,rv
240   PLOT h,rv
250   IF RND>.97 THEN ik=(ik+7)MOD 14: END IF
260   IF KEYROW(1) && 64 THEN EXIT loop
270 END REPeat loop
280 CLOSE#ch
290 :
300 REMark Emulate ZX81 PLOT command
310 :
320 DEFine PROCedure PLOT(x,y)
330   BLOCK#ch, 4,4, x*4,y*4, ik
340 END DEFine PLOT
350 :
360 REMark setup screen
370 :
380 DEFine PROCedure setup_screen
390   ch=FOPEN("scr_512x256a0x0")
400   PAPER #ch;7
410   ik=0
420   CLS #ch
430   RANDOMISE(DATE)
440 END DEFine setup_screen
#3 8x4 zones, so we have more zones where the symetry is observable.
It generates the most interesting images (well, interesting as far as random pixels can be)
For best impression run it at GC or SGC speed.

Code: Select all

100 REMark ZX81 programme: Kaleidoscope
110 REMark Sinclair QL version #3 - 8x4
120 :
130 setup_screen
140 :
150 REPeat loop
160   v =INT (RND(63))
170   h = INT (RND(63))
180   FOR j=0 TO 1
190     FOR i=0 TO 3
200       PLOT h+i*128,v+j*128
210       PLOT 127+i*128-h,v+j*128
220       PLOT h+i*128,127+j*128-v
230       PLOT 127+i*128-h,127+j*128-v
240     NEXT i
250   NEXT j
260   IF RND>.97 THEN ik=(ik+7)MOD 14: INK#ch, ik : END IF
270   IF KEYROW(1) && 64 THEN EXIT loop
280 END REPeat loop
290 CLOSE#ch
300 :
310 REMark Emulate ZX81 PLOT command
320 :
330 DEFine PROCedure PLOT(x,y)
340   POINT #ch,x*.7375,y
350 END DEFine PLOT
360 :
370 REMark setup screen
380 :
390 DEFine PROCedure setup_screen
400   ch=FOPEN("scr_512x256a0x0")
410   PAPER #ch;7
420   ik=0: INK #ch,ik
430   CLS #ch
440   SCALE #ch;255,0,0
450   RANDOMISE (DATE)
460 END DEFine setup_screen


Derek_Stewart
Font of All Knowledge
Posts: 3931
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Dr. Jim's QL Dumping Ground

Post by Derek_Stewart »

Hi Andrew,

Sorry for the mistake, I must of been thing of the Spectrum DRAW command.

According to the ZX81 manual: PLOT x,y colours the pixel at x,y black.

Mot sure what RANDOMISE (DATE) is doing.

As usual, there is many ways to make s solution on S*BASIC.

ZX81 and Spectrum BASIC are very limiting yo produce structured programming.

I think this programme has already being done on BATON...


Regards,

Derek
Post Reply