Wire Frame Graphics

Anything QL Software or Programming Related.
Derek_Stewart
QL Wafer Drive
Posts: 1088
Joined: Mon Dec 20, 2010 11:40 am
Location: Runcorn, Cheshire, UK

Wire Frame Graphics

Postby Derek_Stewart » Sun Jun 03, 2018 10:23 am

Hi,

Here is a conversion on a QBASIC programme I did in 1989 from Computer News Weekly:

Which is a simple wire frame cube rotating in space, requires Toolkit 2, as I used variables for the screen channels.

Code: Select all

10 REMark Computer Weekly Dec 1989
20 REMark QBASIC conversion to QDOS
30 :
100 rx = 60
110 ry = 25
120 cx = 200
130 cy = 200
140 inc = 0
150 t=0
160 cube_speed=5
170 ch=FOPEN('scr_256x200a80x20')
180 IF ch<0:PRINT #0,'Error ';ERNUM :STOP
185 IF VER$=='hba': COLOUR_QL
190 SCALE #ch,500,0,0
200 PAPER#ch,7
210 BORDER#ch,1,255
220 CLS#ch
230 REPeat LOOP
240   cube cx,cy,100,50,120,.1
250 END REPeat LOOP
260 :
270 DEFine PROCedure cube (cx,cy,rx,ry,h,inc)
280   DIM x(3),y(3)
290   t=t+inc
300   FOR i = 0 TO 3
310     x(i)=cx+rx*COS(t+PI*i/2)
320     y(i)=cy+ry*SIN(t+PI*i/2)
330   END FOR i
340   drawcube h,0
350   PAUSE cube_speed
360   drawcube h,7
370 END DEFine cube
380 :
390 DEFine PROCedure drawcube (h,c)
400   INK #ch,c
410   POINT #ch,x(0), y(0)
420   FOR i=1 TO 3
430     LINE#ch,x(i-1),y(i-1)  TO x(i),y(i)
440   END FOR i
450   LINE #ch,x(3),y(3) TO x(0), y(0)
460   FOR i=0 TO 3
470     POINT #ch,x(i),y(i)
480     LINE_R #ch,0,0 TO 0,h
490   END FOR i
500   POINT #ch,x(0),y(0)+h
510   FOR i=1 TO 3
520     LINE #ch,x(i-1),y(i-1)+h TO x(i),y(i)+h
530   END FOR i
540   LINE #ch,x(3),y(3)+h TO x(0),y(0)+h
550 END DEFine drawcube


I did an enhanced bouncing bouncing cube based on the above:

Code: Select all

100 Initialise
110 REPeat LOOP
120   cube cx,cy,xsize,ysize,height,inc
130   IF xflag
140     IF cx<=96: xflag=0:rinc
150     cx=cx-cube_step
160   ELSE
170     IF cx>=378: xflag=1:rinc
180     cx=cx+cube_step
190   END IF
200   IF yflag
210     IF cy>=330: yflag=0:rinc
220     cy=cy+cube_step
230   ELSE
240     IF cy<=48: yflag=1:rinc
250     cy=cy-cube_step
260   END IF
270 END REPeat LOOP
280 :
290 DEFine PROCedure Initialise
300   DIM x(3),y(3)
310   t=0
320   cube_step=1
330   rx=80
340   ry=50
350   cx=RND(100,300)
360   cy=RND(100,300)
370   xsize=100
380   ysize=50
390   height=120
400   inc=.1
410   scal=500
420   xflag=0
430   yflag=0
440   cube_speed=1
450   ch=FOPEN('scr_256x193a120x20')
460   IF VER$=="hba": COLOUR_QL
470   SCALE #ch,scal,0,0
480   PAPER#ch,7
490   INK#ch,0
500   BORDER#ch,1,255
510   CLS#ch
520 END DEFine Initialise
530 :
540 DEFine PROCedure cube (cx,cy,rx,ry,h,inc)
550   t=t+inc
560   FOR i = 0 TO 3
570     x(i)=cx+rx*COS(t+PI*i/2)
580     y(i)=cy+ry*SIN(t+PI*i/2)
590   END FOR i
600   drawcube h,0
610   PAUSE cube_speed
620   drawcube h,7
630 END DEFine cube
640 :
650 DEFine PROCedure drawcube (h,c)
655   LOCal i
660   INK #ch,c
670   POINT #ch,x(0), y(0)
680   FOR i=1TO 3
685     LINE#ch,x(i-1),y(i-1)  TO x(i),y(i)
687   END FOR i
690   LINE #ch,x(3),y(3) TO x(0), y(0)
700   FOR i=0 TO 3
705     POINT #ch,x(i),y(i):LINE_R #ch,0,0 TO 0,h
707   END FOR i
710   POINT #ch,x(0),y(0)+h
720   FOR i=1 TO 3: LINE #ch,x(i-1),y(i-1)+h TO x(i),y(i)+h
725      LINE #ch,x(i-1),y(i-1)+h TO x(i),y(i)+h
727   END FOR i
730   LINE #ch,x(3),y(3)+h TO x(0),y(0)+h
740 END DEFine drawcube
750 :
760 DEFine PROCedure rinc
770  inc=RND(1,9)/10
775  cube_step=RND(1,9)
780 END DEFine rinc


Regards,

Derek
User avatar
jivrt
Chuggy Microdrive
Posts: 59
Joined: Sun Feb 17, 2013 6:16 pm
Location: Puerto Varas, Chile

Re: Wire Frame Graphics

Postby jivrt » Sun Jun 03, 2018 4:00 pm

Derek,
After pasting in a word processor how do I get the program on the ql medium, for example q-emulator?


Enviado desde mi iPhone utilizando Tapatalk


Original BBQL 1985, bought my me in Spain with JM ROM
Tetroid TDI with CF card, ROM switcher, power regulator, Gold Card clone and Backplane
Uses: teaching my children to program
stevepoole
Trump Card
Posts: 178
Joined: Mon Nov 24, 2014 2:03 pm

Re: Wire Frame Graphics

Postby stevepoole » Sun Jun 03, 2018 5:39 pm

Hi,
Here's another old wire-frame tumbling morphing tetrahedra... to type in.
Steve.

100 REMark tetrahedra_tumble_bas, 1984
110 CLEAR: CLS : sc=100: SCALE sc,0,0
120 DIM x(4),y(4), xx(4),yy(4)
130 :
140 FOR i=1 TO 4
150 xx(i)=RND(-1,1): yy(i)=RND(-1,1)
160 x(i)=RND(sc) : y(i)=RND(sc)
170 END FOR i
180 :
190 REPeat loop
200 FOR i=1 TO 4
210 x(i)=rnx(x(i)): y(i)=rny(y(i))
220 LINE x(1),y(1) TO x(2),y(2) TO x(3),y(3) TO x(1),y(1) TO x(4),y(4) TO x(2),y(2), x(3),y(3) TO x(4),y(4)
230 END FOR i
240 PAUSE 1: CLS
250 END REPeat loop
260 :
270 DEFine FuNction rny(y)
280 y=y+yy(i)
290 IF y<=0 OR y>=sc : yy(i)=-yy(i)
300 RETurn y
310 END DEFine
320 :
330 DEFine FuNction rnx(x)
340 x=x+xx(i)
350 IF x<=0 OR x>=sc: xx(i)=-xx(i)
360 RETurn x
370 END DEFine
380 ::


Derek_Stewart
QL Wafer Drive
Posts: 1088
Joined: Mon Dec 20, 2010 11:40 am
Location: Runcorn, Cheshire, UK

Re: Wire Frame Graphics

Postby Derek_Stewart » Sun Jun 03, 2018 6:44 pm

jivrt wrote:Derek,
After pasting in a word processor how do I get the program on the ql medium, for example q-emulator?


Enviado desde mi iPhone utilizando Tapatalk

Hi,

Assuming you have the registered copy of Q-emulator, just point one of the vacant MDV slots to the directory where the programme is located and load the basic programme.


Regards,

Derek
RWAP
RWAP Master
Posts: 2504
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Wire Frame Graphics

Postby RWAP » Sun Jun 03, 2018 7:50 pm

Derek_Stewart wrote:
jivrt wrote:Derek,
After pasting in a word processor how do I get the program on the ql medium, for example q-emulator?


Enviado desde mi iPhone utilizando Tapatalk

Hi,

Assuming you have the registered copy of Q-emulator, just point one of the vacant MDV slots to the directory where the programme is located and load the basic programme.


Be careful though as most WIndows editors will change the line endings. Notepad++ and TotalEdit Pro allow you to save a file with linux (chr$(10)) line endings


stevepoole
Trump Card
Posts: 178
Joined: Mon Nov 24, 2014 2:03 pm

Re: Wire Frame Graphics

Postby stevepoole » Sun Jun 03, 2018 10:00 pm

Hi,
Thanks Rich : You need to have downloaded free NOTEPAD++ onto your PC and installed it.

On the QL Forum : copy and paste the code you want into notepad. Then double_click the 'Format-windows' text on the notepad bottom line.

Go into files (top left corner), click on save under, say G:\filename, (for a dos5_usb_key)

Then on QPC2 : COPY dos5_filename.txt to dos5_filename_bas

Then LRUN dos5_filename_bas !

This is is ideal for long files...

Regards,
Steve.


User avatar
jivrt
Chuggy Microdrive
Posts: 59
Joined: Sun Feb 17, 2013 6:16 pm
Location: Puerto Varas, Chile

Re: Wire Frame Graphics

Postby jivrt » Sun Jun 03, 2018 10:45 pm

stevepoole wrote:Hi,
Thanks Rich : You need to have downloaded free NOTEPAD++ onto your PC and installed it.

On the QL Forum : copy and paste the code you want into notepad. Then double_click the 'Format-windows' text on the notepad bottom line.

Go into files (top left corner), click on save under, say G:\filename, (for a dos5_usb_key)

Then on QPC2 : COPY dos5_filename.txt to dos5_filename_bas

Then LRUN dos5_filename_bas !

This is is ideal for long files...

Regards,
Steve.

Wow! Thanks to all. Now I understand. I didn’t know notepad+++ existed.


Enviado desde mi iPhone utilizando Tapatalk


Original BBQL 1985, bought my me in Spain with JM ROM
Tetroid TDI with CF card, ROM switcher, power regulator, Gold Card clone and Backplane
Uses: teaching my children to program
User avatar
vanpeebles
Commissario Pebbli
Posts: 1952
Joined: Sat Nov 20, 2010 7:13 pm
Location: North East UK

Re: Wire Frame Graphics

Postby vanpeebles » Mon Jun 04, 2018 10:30 am

notepad++ is great for QL files, I use it all the time :)


Derek_Stewart
QL Wafer Drive
Posts: 1088
Joined: Mon Dec 20, 2010 11:40 am
Location: Runcorn, Cheshire, UK

Re: Wire Frame Graphics

Postby Derek_Stewart » Mon Jun 04, 2018 12:02 pm

Hi,

Another way to get the programme into the QL environment, would be to copy the programme in the web browser to the clipboard and use SMSQmulator command JVASGET to copy the clipboard to SCRAP and paste the SCRAP into QD. The programme can be run in QD with the SBAS thing loaded or saved basic file and LRUN as normal. Assuming that the SCRAP Thing is loaded as part of MENU_REXT.

The size of the SCRAP buffer is limited, so large section of text would have to copied and pasted in smaller sections


Regards,

Derek
User avatar
pjw
Gold Card
Posts: 391
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: Wire Frame Graphics

Postby pjw » Mon Jun 04, 2018 2:54 pm

Or use my tiny StuffScrap utilty:
<plug>
"A utility to stuff the contents of the Scrap Buffer into a keyboard queue. Allows you to copy text from QD editor or other scrap-aware programs into keyboard queues. Copy text from Windows into a QL keyboard queue. Works only on QPC2 or SMSQmulator and needs the Scrap Thing, part of the now free QMenu suite." Available from Dilwyn's.
</plug>


Per
For every complex problem there is an answer that is clear, simple, and wrong.
- H. L. Mencken

Return to “Software & Programming”

Who is online

Users browsing this forum: No registered users and 1 guest