BBC BASIC for Windows
« 3D Gaming Project »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:51pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1 2 3 4  ...  8 Notify Send Topic Print
 veryhotthread  Author  Topic: 3D Gaming Project  (Read 1758 times)
DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: 3D Gaming Project
« Reply #5 on: Feb 10th, 2016, 12:14pm »

Hi Ric,

I get an error due to the lack of a PROCfacessetup... and I can't just lift it from the original "cube" post since the arrays have changed...

Do you know there is a sortlib which implements Quicksort very quickly? It may or not be a good solution to your problem (and you may want to do it yourself out of principle!).

Best wishes,

D
User IP Logged

Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: 3D Gaming Project
« Reply #6 on: Feb 15th, 2016, 09:56am »

Hi D
I must have exceeded the 9000 characters or so. Copy and paste this onto the end of the cube code and it should work! (Probably)
Code:
      DEF PROCfacessetup
      faces(0,0)=points(0,4)
      faces(1,0)=points(1,4)
      faces(2,0)=points(2,4)
      faces(3,0)=points(0,0)
      faces(4,0)=points(1,0)
      faces(5,0)=points(2,0)
      faces(6,0)=points(0,5)
      faces(7,0)=points(1,5)
      faces(8,0)=points(2,5)
      faces(9,0)=points(0,1)
      faces(10,0)=points(1,1)
      faces(11,0)=points(2,1)
      faces(0,1)=points(0,0)
      faces(1,1)=points(1,0)
      faces(2,1)=points(2,0)
      faces(3,1)=points(0,3)
      faces(4,1)=points(1,3)
      faces(5,1)=points(2,3)
      faces(6,1)=points(0,1)
      faces(7,1)=points(1,1)
      faces(8,1)=points(2,1)
      faces(9,1)=points(0,2)
      faces(10,1)=points(1,2)
      faces(11,1)=points(2,2)
      faces(0,2)=points(0,7)
      faces(1,2)=points(1,7)
      faces(2,2)=points(2,7)
      faces(3,2)=points(0,4)
      faces(4,2)=points(1,4)
      faces(5,2)=points(2,4)
      faces(6,2)=points(0,6)
      faces(7,2)=points(1,6)
      faces(8,2)=points(2,6)
      faces(9,2)=points(0,5)
      faces(10,2)=points(1,5)
      faces(11,2)=points(2,5)
      faces(0,3)=points(0,3)
      faces(1,3)=points(1,3)
      faces(2,3)=points(2,3)
      faces(3,3)=points(0,7)
      faces(4,3)=points(1,7)
      faces(5,3)=points(2,7)
      faces(6,3)=points(0,2)
      faces(7,3)=points(1,2)
      faces(8,3)=points(2,2)
      faces(9,3)=points(0,6)
      faces(10,3)=points(1,6)
      faces(11,3)=points(2,6)
      faces(0,4)=points(0,3)
      faces(1,4)=points(1,3)
      faces(2,4)=points(2,3)
      faces(3,4)=points(0,0)
      faces(4,4)=points(1,0)
      faces(5,4)=points(2,0)
      faces(6,4)=points(0,7)
      faces(7,4)=points(1,7)
      faces(8,4)=points(2,7)
      faces(9,4)=points(0,4)
      faces(10,4)=points(1,4)
      faces(11,4)=points(2,4)
      faces(0,5)=points(0,1)
      faces(1,5)=points(1,1)
      faces(2,5)=points(2,1)
      faces(3,5)=points(0,2)
      faces(4,5)=points(1,2)
      faces(5,5)=points(2,2)
      faces(6,5)=points(0,5)
      faces(7,5)=points(1,5)
      faces(8,5)=points(2,5)
      faces(9,5)=points(0,6)
      faces(10,5)=points(1,6)
      faces(11,5)=points(2,6)
      ENDPROC
      place=0
      FOR loop=0 TO 29
        FOR loopa=0 TO 59
          faces(0,place)=points(0,(loop*61)+loopa)
          faces(1,place)=points(1,(loop*61)+loopa)
          faces(2,place)=points(2,(loop*61)+loopa)
          faces(3,place)=points(0,(loop*61)+loopa+1)
          faces(4,place)=points(1,(loop*61)+loopa+1)
          faces(5,place)=points(2,(loop*61)+loopa+1)
          faces(6,place)=points(0,(loop*61)+loopa+61)
          faces(7,place)=points(1,(loop*61)+loopa+61)
          faces(8,place)=points(2,(loop*61)+loopa+61)
          faces(9,place)=points(0,(loop*61)+loopa+62)
          faces(10,place)=points(1,(loop*61)+loopa+62)
          faces(11,place)=points(2,(loop*61)+loopa+62)
          place+=1
        NEXT
      NEXT
      ENDPROC



      DEF PROCfacesprint
      FOR loop%=0 TO 5
        REM Create LIGHT vector
        lightx=-10000-tempsort(6,loop%)
        lighty=-10000-tempsort(7,loop%)
        lightz=0-tempsort(0,loop%)
        lightveclen=SQR((lightx*lightx)+(lighty*lighty)+(lightz*lightz))
        REM Create unit light vector
        lightx=lightx/lightveclen
        lighty=lighty/lightveclen
        lightz=lightz/lightveclen
        REM Create unit vector
        REM veclen=SQR((tempsort(6,loop%)*tempsort(6,loop%))+(tempsort(7,loop%)*tempsort(7,loop%))+(tempsort(0,loop%)*tempsort(0,loop%)))
        REM tempsort(6,loop%)=tempsort(6,loop%)/veclen
        REM tempsort(7,loop%)=tempsort(7,loop%)/veclen
        REM tempsort(0,loop%)=tempsort(0,loop%)/veclen
        REM Create Normal unit vector
        veclen=SQR((tempsort(14,loop%)*tempsort(14,loop%))+(tempsort(15,loop%)*tempsort(15,loop%))+(tempsort(16,loop%)*tempsort(16,loop%)))
        tempsort(14,loop%)=tempsort(14,loop%)/veclen
        tempsort(15,loop%)=tempsort(15,loop%)/veclen
        tempsort(16,loop%)=tempsort(16,loop%)/veclen
        REM Create angle
        angle=(tempsort(14,loop%)*lightx)+(tempsort(15,loop%)*lighty)+(tempsort(16,loop%)*lightz)
        REM PRINT TAB(0,4);angle
        COLOUR 3,0,255*((angle+1)/2),0
        GCOL 0,3
        jump=tempsort(1,loop%)
        MOVE faces(0,jump)+500,faces(1,jump)+500
        MOVE faces(0,jump)+500,faces(1,jump)+500
        PLOT 85,faces(3,jump)+500,faces(4,jump)+500
        PLOT 85,faces(6,jump)+500,faces(7,jump)+500
        PLOT 85,faces(9,jump)+500,faces(10,jump)+500
        GCOL 0,15
        MOVE tempsort(6,loop%)+500,tempsort(7,loop%)+500
        DRAW tempsort(6,loop%)-(tempsort(14,loop%)*100)+500,tempsort(7,loop%)-(tempsort(15,loop%)*100)+500
        REM WAIT 1
      NEXT
      ENDPROC


      DEF PROCprintZs
      FOR loop%=0 TO 2047
        PRINT "";tempsort(0,loop%);" ";tempsort(1,loop%)
        WAIT 1
      NEXT
      PRINT column
      END
      ENDPROC




      DEF PROCfindvector
      FOR loop%=0 TO 5
        jump=tempsort(1,loop%)
        REM NORMAL VECTOR TO PLANE = [P1-P2=V12 THEN P1-P3=V13 THEN V13*V12 (CROSS PRODUCT){(A*B=(A2B3-A3B2),(A3B1-A1B3),(A1B2-A2B1)}]
        tempsort(8,loop%)=faces(3,jump)-faces(0,jump)
        tempsort(9,loop%)=faces(4,jump)-faces(1,jump)
        tempsort(10,loop%)=faces(5,jump)-faces(2,jump)
        tempsort(11,loop%)=faces(6,jump)-faces(0,jump)
        tempsort(12,loop%)=faces(7,jump)-faces(1,jump)
        tempsort(13,loop%)=faces(8,jump)-faces(2,jump)
        tempsort(14,loop%)=(tempsort(9,loop%)*tempsort(13,loop%))-(tempsort(10,loop%)*tempsort(12,loop%))
        tempsort(15,loop%)=(tempsort(10,loop%)*tempsort(11,loop%))-(tempsort(8,loop%)*tempsort(13,loop%))
        tempsort(16,loop%)=(tempsort(8,loop%)*tempsort(12,loop%))-(tempsort(9,loop%)*tempsort(11,loop%))
      NEXT
      ENDPROC




      DEF PROCerror
      PRINT TAB(0,0)"X";faces(14,loop%),"Y";faces(15,loop%),"Z";faces(16,loop%)
      END
 

Where or how do I find to D3D or sortlib?
Regards Ric
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: 3D Gaming Project
« Reply #7 on: Feb 15th, 2016, 09:58am »

Also, the code for each step is getting longer and exceeding 9000 characters, is there a way of posting larger banks of code?
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: 3D Gaming Project
« Reply #8 on: Feb 15th, 2016, 11:29am »

Hi Ric,

That's pretty impressive! Bring on the full game... grin

In terms of posting code, there is a Wiggio group, though it's not letting me log in at the moment, not sure why - possibly that I've forgotten my password, but it won't send me a reminder either, so it may be more than that. There is also a Yahoo group:

https://groups.yahoo.com/neo/groups/bb4w/conversations/messages

Both have file repositories. You would probably have to join (both are free) in order to post. Then you could post a link, though maybe only members could read it...

Best wishes,

D
User IP Logged

Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: 3D Gaming Project
« Reply #9 on: Feb 17th, 2016, 7:45pm »

It may sound obvious, but in order to create the graphics for the game some kind of plotting routine to take a sprite of x,y and transpose it into a rhomboid is needed.

This code does exactly that and to boot it has been designed to use only interger numbers so it can be easily turned into ASM and only to print the pixels required so if you shrink the sprite size to create depth in a gaming view, it does not waste time over printing its self, ok that bit is only 80% efficient, but that can be worked on!!

Code:
   10 MODE 3
   20 DIM sprite(255,255)
   30 REM *********************************************
   40 REM *          GREATE CHESS BOARD             ***
   50 REM *********************************************
   60 FOR x=0 TO 7
   70   FOR y=0 TO 7
   80     IF (x MOD 2=1 AND y MOD 2=1) OR (x MOD 2=0 AND y MOD 2=0) THEN
   90       FOR xloop=0 TO 31
  100         FOR yloop=0 TO 31
  110           sprite((x*32)+xloop,(y*32)+yloop)=1
  120         NEXT
  130       NEXT
  140     ELSE
  150       FOR xloop=0 TO 31
  160         FOR yloop=0 TO 31
  170           sprite((x*32)+xloop,(y*32)+yloop)=4
  180         NEXT
  190       NEXT
  200     ENDIF
  210   NEXT
  220 NEXT
  230 REM ************************************
  240 REM *        PRINT GRID LINES          *
  250 REM ************************************
  260 
  270 FOR LOOP=0 TO 1000 STEP 100
  280   MOVE LOOP,0
  290   DRAW LOOP,1000
  300   MOVE 0,LOOP
  310   DRAW 1000,LOOP
  320 NEXT
  330 REM ******************************************************************************************
  340 REM *          IF YOU REMOVE THE GOTO 380, THIS PRINTS THE CHESS BOARD ORTHOGANALLY          *
  350 REM *          AT THE COORDINATES 0,0                                                        *
  360 REM ******************************************************************************************
  370 GOTO 450
  380 FOR xloop=0 TO 255
  390   FOR yloop=0 TO 255
  400     GCOL 0,sprite(xloop,yloop)
  410     MOVE (xloop*2),(yloop*2)
  420     DRAW (xloop*2),(yloop*2)
  430   NEXT
  440 NEXT
  450 VDU 23,65,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF :REM *** ANYONE KNOW WHY THIS COMMAND DOESNT WORK?? ***
  460 VDU 5
  470 GCOL 0,15
  480 MOVE 0,1000
  490 PRINT"The origional tile being transfered is a chessboard, 256x256 pixels."
  500 PRINT"Choose the coordinates for nodes 0,1,2 and 3 and watch"
  510 PRINT""
  520 PRINT"Node order is       N2      N3"
  530 PRINT""
  540 PRINT""
  550 PRINT""
  560 PRINT"                    N0      N1"
  570 MOVE 0,500
  580 GCOL 0,0
  590 PRINT"AAAAAAAAAA"
  600 MOVE 0,500
  610 GCOL 0,15
  620 INPUT"N0x ";x0
  630 IF x0<0 OR x0>1000 THEN 570
  640 MOVE 0,450
  650 GCOL 0,0
  660 PRINT"AAAAAAAAAA"
  670 MOVE 0,450
  680 GCOL 0,15
  690 INPUT"N0y ";y0
  700 IF y0<0 OR y0>1000 THEN 640
  710 MOVE 0,400
  720 GCOL 0,0
  730 PRINT"AAAAAAAAAA"
  740 MOVE 0,400
  750 GCOL 0,15
  760 INPUT"N1x ";x1
  770 IF x1<0 OR x1>1000 THEN 710
  780 MOVE 0,350
  790 GCOL 0,0
  800 PRINT"AAAAAAAAAA"
  810 MOVE 0,350
  820 GCOL 0,15
  830 INPUT"N1y ";y1
  840 IF y1<0 OR y1>1000 THEN 780
  850 MOVE 0,300
  860 GCOL 0,0
  870 PRINT"AAAAAAAAAA"
  880 MOVE 0,300
  890 GCOL 0,15
  900 INPUT"N2x ";x2
  910 IF x2<0 OR x2>1000 THEN 850
  920 MOVE 0,250
  930 GCOL 0,0
  940 PRINT"AAAAAAAAAA"
  950 MOVE 0,250
  960 GCOL 0,15
  970 INPUT"N2y ";y2
  980 IF y2<0 OR y2>1000 THEN 920
  990 MOVE 0,200
 1000 GCOL 0,0
 1010 PRINT"AAAAAAAAAA"
 1020 MOVE 0,200
 1030 GCOL 0,15
 1040 INPUT"N3x ";x3
 1050 IF x3<0 OR x3>1000 THEN 990
 1060 MOVE 0,150
 1070 GCOL 0,0
 1080 PRINT"AAAAAAAAAA"
 1090 MOVE 0,150
 1100 GCOL 0,15
 1110 INPUT"N3y ";y3
 1120 IF y3<0 OR y3>1000 THEN 1060
 1130 
 1140 contspritepointerx%=0           : REM *** CREATE THE CONTINOUS VARIABLE FOR THE POSITION OF THE PRINTING DOT IN THE SPRITE ***
 1150 contspritepointery%=0
 1160 
 1170 spritesizex%=256                : REM *** SET UP THE SPRITE SIZE, THIS IS NOT REALLY NECESSARY FOR THIS DEMO, BUT WOULD    ***
 1180 spritesizey%=256                : REM *** NEED TO BE PASSED TO A ROUTINE WHEN DIFFERENT SPRITES ARE USED                   ***
 1190 
 1200 spritepointerx%=0               : REM *** CREATE THE VARIABLES FOR THE EXACT POSITION OF THE DOT BEING PRINTED IN THE      ***
 1210 spritepointery%=0               : REM *** SPRITE                                                                           ***
 1220 
 1230 division%=1048576               : REM *** THE NUMBER USED TO MULTIPLY EVERYTHING SO INTERGERS CAN BE USED 100% OF THE TIME ***
 1240 
 1250 PROCtranslate_face
 1260 GOTO 470
 1270 
 1280 
 1290 
 1300 
 1310 DEF PROCtranslate_face
 1320 
 1330 scale=1                         : REM *** NOT REALLY NEEDED, BUT CAN BE USED TO ENLARGE THE IMAGE PRINTED, BEWARE!!!       ***
 1340 
 1350 spritepointerx%=0
 1360 spritepointery%=0
 1370 
 1380 p0to1length=(SQR(((x1-x0)*(x1-x0)*division%)+((y1-y0)*(y1-y0)*division%)))DIV1024 : REM *** THE CALCULATIONS USED TO       ***
 1390 p0to2length=(SQR(((x2-x0)*(x2-x0)*division%)+((y2-y0)*(y2-y0)*division%)))DIV1024 : REM *** CALCULATE THE LENGTH OF ALL    ***
 1400 p1to3length=(SQR(((x3-x1)*(x3-x1)*division%)+((y3-y1)*(y3-y1)*division%)))DIV1024 : REM *** SIDES OF THE TRANSPOSED        ***
 1410 p2to3length=(SQR(((x3-x2)*(x3-x2)*division%)+((y3-y2)*(y3-y2)*division%)))DIV1024 : REM *** SPRITE SHAPE                   ***
 1420 
 1430 IF p0to1length>p2to3length THEN           : REM ****************************************
 1440 longesthorizontal%=p0to1length            : REM *                                      *
 1450 ELSE                                      : REM * SORT THE 4 SIDES OF THE RHOMBOID     *
 1460 longesthorizontal%=p2to3length            : REM * TRANSPOSED SHAPE AND PLACE THE VALUE *
 1470 ENDIF                                     : REM * INTO THE VARIABLE longestside%       *
 1480 IF p0to2length>p1to3length THEN           : REM *                                      *
 1490 longestvertical%=p0to2length              : REM ****************************************
 1500 ELSE
 1510 longestvertical%=p1to3length
 1520 ENDIF
 1530 IF longestvertical%>longesthorizontal% THEN
 1540 longestside%=longestvertical%
 1550 ELSE
 1560 longestside%=longesthorizontal%
 1570 ENDIF
 1580 
 1590 
 1600 
 1610 spriteincx%=(spritesizex%*division%)DIVlongestside%     : REM *** CALCULATE THE STEP THROUGH THE ORIGIONAL SPRITE (X)   ***
 1620 spriteincy%=(spritesizey%*division%)DIVlongestside%     : REM *** CALCULATE THE STEP THROUGH THE ORIGIONAL SPRITE (Y)   ***
 1630 
 


2nd half of code in the next post!
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: 3D Gaming Project
« Reply #10 on: Feb 17th, 2016, 7:48pm »

2nd half
Code:
 1640 p0to2incx%=(x2-x0)*division%DIVlongestside%             : REM *** CALCULATE THE STEP INN THE SIDE FROM NODES 0 TO 2 (X) ***
 1650 p0to2incy%=(y2-y0)*division%DIVlongestside%             : REM *** CALCULATE THE STEP INN THE SIDE FROM NODES 0 TO 2 (Y) ***
 1660 
 1670 p1to3incx%=(x3-x1)*division%DIVlongestside%             : REM *** CALCULATE THE STEP INN THE SIDE FROM NODES 1 TO 3 (X) ***
 1680 p1to3incy%=(y3-y1)*division%DIVlongestside%             : REM *** CALCULATE THE STEP INN THE SIDE FROM NODES 1 TO 3 (Y) ***
 1690 
 1700 p0to2fpx%=0                                             : REM *** SET THE ORIGIN OF NODE 0 TO 0,0 (SIDE N0 TO N2)       ***
 1710 p0to2fpy%=0
 1720 
 1730 p1to3fpx%=(x1-x0)*division%                             : REM *** SET THE START POINT OF THE SIDE N1 TO N3 IN RELATION  ***
 1740 p1to3fpy%=(y1-y0)*division%                             : REM *** TO N0                                                 ***
 1750 
 1760 REPEAT
 1770 
 1780 linefpx%=p0to2fpx%                                      : REM *** SET THE START POINT OF THE LINE TO BE PRINTED BETWEEN ***
 1790 linefpy%=p0to2fpy%                                      : REM *** LINES N0,N2 AND N1,N3                                 ***
 1800 
 1810 contspritepointerx%=0                                   : REM *** RESET THE CONTINUOUS POINTER FOR THE SPRITE           ***
 1820 spritepointerx%=0                                       : REM *** RESET THE SPRITE POINTER IN THE X PLANE               ***
 1830 
 1840 lineincx%=(p1to3fpx%-p0to2fpx%)/longestside%            : REM *** CALCULATE THE STEPS BETWEEN LINES N0,N2 TO N1,N3 (X)  ***
 1850 lineincy%=(p1to3fpy%-p0to2fpy%)/longestside%            : REM *** CALCULATE THE STEPS BETWEEN LINES N0,N2 TO N1,N3 (Y)  ***
 1860 
 1870 
 1880 REPEAT
 1890 
 1900 GCOL 0,sprite(spritepointerx%,spritepointery%)                            : REM *** RETRIEVE COLOUR OF DOT TO BE DRAWN  ***
 1910 MOVE x0+((linefpx%*scale)DIVdivision%),y0+((linefpy%*scale)DIVdivision%)  : REM *** MOVE TO DRAW POINT                  ***
 1920 DRAW x0+((linefpx%*scale)DIVdivision%),y0+((linefpy%*scale)DIVdivision%)  : REM *** DRAW DOT                            ***
 1930 
 1940 linefpx%+=lineincx%                                     : REM *** INCREASE(STEP) THE POSITION OF THE LINE BETWEEN N0,N2 ***
 1950 linefpy%+=lineincy%                                     : REM *** AND N1,N3 READY FOR THE PLOTTING OF THE NEXT DOT      ***
 1960 
 1970 contspritepointerx%+=spriteincx%                        : REM *** INCREASE CONTINUOUS POINTER (X)                       ***
 1980 spritepointerx%=contspritepointerx%DIVdivision%         : REM *** CALCULATE NEW POINTER POSITION IN ORIGIONAL SPRITE (X)***
 1990 
 2000 UNTIL spritepointerx%>=spritesizex%               : REM *** HAS THE SPRITE POINTER EXCEEDED THE SIZE OF THE SPRITE (X)  ***
 2010 
 2020 p0to2fpx%+=p0to2incx%                             : REM *** INCREASE(STEP) THE LINE N0,N2 FOR THE NEXT PRINTED LINE (X) ***
 2030 p0to2fpy%+=p0to2incy%                             : REM *** INCREASE(STEP) THE LINE N0,N2 FOR THE NEXT PRINTED LINE (Y) ***
 2040 
 2050 p1to3fpx%+=p1to3incx%                             : REM *** INCREASE(STEP) THE LINE N1,N3 FOR THE NEXT PRINTED LINE (X) ***
 2060 p1to3fpy%+=p1to3incy%                             : REM *** INCREASE(STEP) THE LINE N1,N3 FOR THE NEXT PRINTED LINE (Y) ***
 2070 
 2080 contspritepointery%+=spriteincy%                  : REM *** INCREASE CONTINUOUS POINTER (Y)                             ***
 2090 spritepointery%=contspritepointery%DIVdivision%   : REM *** CALCULATE NEW POINTER POSITION IN ORIGIONAL SPRITE (X)      ***
 2100 
 2110 UNTIL spritepointery%=>spritesizey%               : REM *** HAS THE SPRITE POINTER EXCEEDED THE SIZE OF THE SPRITE (Y)  ***
 2120 
 2130 ENDPROC
 


Hope its annotated enough

Enjoy
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: 3D Gaming Project
« Reply #11 on: Feb 18th, 2016, 08:09am »

Hi Ric,

That seems to work nicely, if quite slowly in BASIC - not surprisingly! I'll be interested to see if you can make it fly in assembler.

Of course there are much quicker ways to do this for a chessboard, but I presume it's just a convenient image to analyse, and the ultimate goal would be an image, so you can't just draw triangles.

With regard to your query about the VDU 23 line - what doesn't work? It generates a black square instead of A. You are using it to clear the bit of screen where you are putting your coordinate requests? Wouldn't RECTANGLE FILL be easier?

Best wishes,

D
User IP Logged

Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: 3D Gaming Project
« Reply #12 on: Feb 27th, 2016, 5:16pm »

Evening D and others
Just a quck one for Saturday night.

You were right D, the chess board was just a fancy block of colour to transpose and the goal is a coloured image.

Here is the assembler version, and pretty fast it is too. Code:
      VDU 23,22,1346;674;16,16,16,0
      HIMEM=(LOMEM+500000000) AND -4

      DIM code% NOTEND AND 2047, code% 6143
      DIM data% 2048
      DIM temp% 2048
      DIM sprite% 1368640
      DIM count% 3
      FOR I% = 0 TO 2 STEP 2
  
        P% = code%
  
        [
  
        OPT I%
  
        .starttranspose
  
        mov   eax,         0                 ;    }
        mov   ebx,         0                 ;    } Clear registers
        mov   ecx,         0                 ;    }
        mov   edx,         0                 ;    }
        mov   DWORD        [data%+116],    0 ;    }
        mov   DWORD        [data%+120],    0 ;    }
        mov   DWORD        [data%+124],    0 ;    }
        mov   DWORD        [data%+128],    0 ;    }
  
  
  
        mov   eax,         [data%+8]         ;  }
        sub   eax,         [data%]           ;  } Load Node 1 x in to eax,
        mov   ebx,         eax               ;  } subtract Node 0 x
        mul   ebx                            ;  } Put eax in to ebx and miltply.
        mov   ecx,         eax               ;  } (square eax) And store in ecx.
        mov   eax,         [data%+12]        ;    }
        sub   eax,         [data%+4]         ;    } Load Node 1 y in to eax
        mov   ebx,         eax               ;    } subtract Node 0 y
        mul   ebx                            ;    } Put eax in to ebx and multiply.
        add   eax,         ecx               ;    } (square) And add to ecx.
        mov   ebx,         16384             ;  }
        mul   ebx                            ;  } Multiply ecx by 16384
        mov   [temp%],     eax               ;  } and place result in [temp]
        fild  DWORD [temp%]                  ;    }
        fsqrt                                ;    } Find squareroot of [temp]
        fistp DWORD [temp%]                  ;    }
        mov   eax,         [temp%]           ;  } Divide the root by 128 to
        mov   ebx,         128               ;  } convert the result to the
        mov   edx,         0                 ;  } correct factor.
        div   ebx                            ;  }
        mov   [data%+32],  eax               ;    } Store result in [p0to1l]
  
  
        mov   eax,         [data%+16]        ;
        sub   eax,         [data%]           ;
        mov   ebx,         eax               ;
        mul   ebx                            ;
        mov   ecx,         eax               ;   Find length between
        mov   eax,         [data%+20]        ;   Nodes 2 and 0
        sub   eax,         [data%+4]         ;
        mov   ebx,         eax               ;
        mul   ebx                            ;
        add   eax,         ecx               ;
        mov   ebx,         16384             ;
        mul   ebx                            ;
        mov   [temp%],     eax               ;
        fild  DWORD [temp%]                  ;
        fsqrt                                ;
        fistp DWORD [temp%]                  ;
        mov   eax,         [temp%]           ;
        mov   ebx,         128               ;
        mov   edx,         0                 ;
        div   ebx                            ;
        mov   [data%+36],  eax               ;
  
  
        mov   eax,         [data%+24]        ;
        sub   eax,         [data%+8]         ;
        mov   ebx,         eax               ;
        mul   ebx                            ;
        mov   ecx,         eax               ;   Find length between
        mov   eax,         [data%+28]        ;   Nodes 3 and 1
        sub   eax,         [data%+12]        ;
        mov   ebx,         eax               ;
        mul   ebx                            ;
        add   eax,         ecx               ;
        mov   ebx,         16384             ;
        mul   ebx                            ;
        mov   [temp%],     eax               ;
        fild  DWORD [temp%]                  ;
        fsqrt                                ;
        fistp DWORD [temp%]                  ;
        mov   eax,         [temp%]           ;
        mov   ebx,         128               ;
        mov   edx,         0                 ;
        div   ebx                            ;
        mov   [data%+40],  eax               ;
  
  
        mov   eax,         [data%+24]        ;
        sub   eax,         [data%+16]        ;
        mov   ebx,         eax               ;
        mul   ebx                            ;
        mov   ecx,         eax               ;   Find length between
        mov   eax,         [data%+28]        ;   Nodes 3 and 2
        sub   eax,         [data%+20]        ;
        mov   ebx,         eax               ;
        mul   ebx                            ;
        add   eax,         ecx               ;
        mov   ebx,         16384             ;
        mul   ebx                            ;
        mov   [temp%],     eax               ;
        fild  DWORD [temp%]                  ;
        fsqrt                                ;
        fistp DWORD [temp%]                  ;
        mov   eax,         [temp%]           ;
        mov   ebx,         128               ;
        mov   edx,         0                 ;
        div   ebx                            ;
        mov   [data%+44],  eax               ;
  
  
        mov   eax,         [data%+44]        ;
        cmp   [data%+32],  eax               ;
        jae   higherh                        ;
        mov   [data%+48],  eax               ;  Load longest
        jmp   passa                          ;  horizontal side
        .higherh                             ;  in to the register
        mov   eax,         [data%+32]        ;  [longesthorizontal]
        mov   [data%+48],  eax               ;
  
        .passa
        mov   eax,         [data%+40]        ;
        cmp   [data%+36],  eax               ;
        jae   higherv                        ;
        mov   [data%+52],  eax               ;  Load longest
        jmp   passb                          ;  vertical side
        .higherv                             ;  in to the register
        mov   eax,         [data%+36]        ;  [longestvertical]
        mov   [data%+52],  eax               ;
  
        .passb
        mov   eax,         [data%+52]        ;
        cmp   [data%+48],  eax               ;
        jae   highers                        ;  Load longest
        jmp   passc                          ;  side
        .highers                             ;  in to the register
        mov   eax,         [data%+48]        ;  [longestside]
        .passc                               ;
        sal   eax,         6                 ;
        mov   ebx,         43
        mov   edx,         0
        div   ebx
        mov   [data%+56],  eax               ;
  
        mov   eax,         16384             ;
        mov   ebx,         [data%+60]        ;  Calculate the sprite
        mul   ebx                            ;  step increase in x and
        mov   ebx,         [data%+56]        ;  store result in [data%+68]
        div   ebx                            ;
        mov   [data%+68],  eax               ;
  
        mov   eax,         16384             ;
        mov   ebx,         [data%+64]        ;  Calculate the sprite
        mul   ebx                            ;  step increase in y and
        mov   ebx,         [data%+56]        ;  store result in [data%+72]
        div   ebx                            ;
        mov   [data%+72],  eax               ;
  
        mov   eax,         [data%+16]        ;
        sub   eax,         [data%]           ;
        mov   ebx,         16384             ;  Calculate step from
        mul   ebx                            ;  n0 to n2 in x and store
        mov   ebx,         [data%+56]        ;  in [data%+76]
        cmp   eax,         0                 ;
        jl    p0to2xnegdiv                   ;
        mov   edx,         0                 ;
        div   ebx                            ;
        jmp   p0to2xnegpass                  ;
        .p0to2xnegdiv                        ;
        neg   eax                            ;  }
        mov   edx,         0                 ;  } Produce a negative
        div   ebx                            ;  } division
        neg   eax                            ;  }
        .p0to2xnegpass                       ;
        mov   [data%+76],  eax               ;
  
  
        mov   eax,         [data%+20]        ;
        sub   eax,         [data%+4]         ;
        mov   ebx,         16384             ;  Calculate step from
        mul   ebx                            ;  n0 to n2 in y and store
        mov   ebx,         [data%+56]        ;  in [data%+80]
        cmp   eax,         0                 ;
        jl    p0to2ynegdiv                   ;
        mov   edx,         0                 ;
        div   ebx                            ;
        jmp   p0to2ynegpass                  ;
        .p0to2ynegdiv                        ;
        neg   eax                            ;  }
        mov   edx,         0                 ;  } Produce a negative
        div   ebx                            ;  } division
        neg   eax                            ;  }
        .p0to2ynegpass                       ;
        mov   [data%+80],  eax               ;
  
        

As is now usual the post is in two halves so will need to do some careful pasting.

Ric
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: 3D Gaming Project
« Reply #13 on: Feb 27th, 2016, 5:19pm »

Code:
        mov   eax,         [data%+24]        ;
        sub   eax,         [data%+8]         ;
        mov   ebx,         16384             ;  Calculate step from
        mul   ebx                            ;  n1 to n3 in x and store
        mov   ebx,         [data%+56]        ;  in [data%+84]
        cmp   eax,         0                 ;
        jl    p1to3xnegdiv                   ;
        mov   edx,         0                 ;
        div   ebx                            ;
        jmp   p1to3xnegpass                  ;
        .p1to3xnegdiv                        ;
        neg   eax                            ;  }
        mov   edx,         0                 ;  } Produce a negative
        div   ebx                            ;  } division
        neg   eax                            ;  }
        .p1to3xnegpass                       ;
        mov   [data%+84],  eax               ;
  
        mov   eax,         [data%+28]        ;
        sub   eax,         [data%+12]        ;
        mov   ebx,         16384             ;  Calculate step from
        mul   ebx                            ;  n1 to n3 in y and store
        mov   ebx,         [data%+56]        ;  in [data%+88]
        cmp   eax,         0                 ;
        jl    p1to3ynegdiv                   ;
        mov   edx,         0                 ;
        div   ebx                            ;
        jmp   p1to3ynegpass                  ;
        .p1to3ynegdiv                        ;
        neg   eax                            ;  }
        mov   edx,         0                 ;  } Produce a negative
        div   ebx                            ;  } division
        neg   eax                            ;  }
        .p1to3ynegpass                       ;
        mov   [data%+88],  eax               ;
  
        mov   DWORD        [data%+92],  0    ;  Set start point for p0to2
        mov   DWORD        [data%+96],  0    ;  x and y
  
        mov   eax,         [data%+8]         ;
        sub   eax,         [data%]           ;  Set start point for p1to3
        mov   ebx,         16384             ;  in x
        mul   ebx                            ;
        mov   [data%+100], eax               ;
  
        mov   eax,         [data%+12]        ;
        sub   eax,         [data%+4]         ;  Set start point for p1to3
        mov   ebx,         16384             ;  in y
        mul   ebx                            ;
        mov   [data%+104], eax               ;
  
        .startmainloopy
  
        mov   eax,         [data%+92]        ;  Set linefpx to p0to2fpx
        mov   [data%+108], eax               ;
  
        mov   eax,         [data%+96]        ;  Set linefpy to p0to2fpy
        mov   [data%+112], eax               ;
  
        mov   DWORD        [data%+116], 0    ;  Initialise contspritepointerx
        mov   DWORD        [data%+124], 0    ;  Initialise spritepointerx
  
        mov   eax,         [data%+100]       ;
        sub   eax,         [data%+92]        ;  Calculate lineincx and
        mov   ebx,         [data%+56]        ;  store in [data%+132]
        cmp   eax,         0                 ;
        jl    lixnegdiv                      ;
        mov   edx,         0                 ;
        div   ebx                            ;
        jmp   lixnegpass                     ;
        .lixnegdiv                           ;
        neg   eax                            ;  }
        mov   edx,         0                 ;  } Produce a negative
        div   ebx                            ;  } division
        neg   eax                            ;  }
        .lixnegpass                          ;
        mov   [data%+132],  eax              ;
  
        mov   eax,         [data%+104]       ;
        sub   eax,         [data%+96]        ;  Calculate lineincy and
        mov   ebx,         [data%+56]        ;  store in [data%+136]
        cmp   eax,         0                 ;
        jl    liynegdiv                      ;
        mov   edx,         0                 ;
        div   ebx                            ;
        jmp   liynegpass                     ;
        .liynegdiv                           ;
        neg   eax                            ;  }
        mov   edx,         0                 ;  } Produce a negative
        div   ebx                            ;  } division
        neg   eax                            ;  }
        .liynegpass                          ;
        mov   [data%+136],  eax              ;
  
        .startmainloopx
  
        mov   ecx,         0
        mov   edx,         0
        mov   eax,         [data%+108]       ;
        mov   ebx,         16384             ;
        cmp   eax,         0                 ;  Calculate x displacement
        jl    cxdnegdiv                      ;
        mov   edx,         0                 ;
        div   ebx                            ;
        jmp   cxdnegpass                     ;
        .cxdnegdiv                           ;
        neg   eax                            ;  }
        mov   edx,         0                 ;  } Produce a negative
        div   ebx                            ;  } division
        neg   eax                            ;  }
        .cxdnegpass                          ;
        add   eax,         [data%]           ;  for next pixel
        ;  INSERT CHECKS HERE AGAINST X DISPLACEMENT OUTSIDE SCREENSIZE
        ;  AND JUMP TO .pixelpass
        mov   ebx,         4                 ;
        mul   ebx                            ;
        mov   ecx,         eax               ;
  
        mov   eax,         [data%+112]       ;
        mov   ebx,         16384             ;
        cmp   eax,         0                 ;  Calculate y displacement
        jl    cydnegdiv                      ;
        mov   edx,         0                 ;
        div   ebx                            ;
        jmp   cydnegpass                     ;
        .cydnegdiv                           ;
        neg   eax                            ;  }
        mov   edx,         0                 ;  } Produce a negative
        div   ebx                            ;  } division
        neg   eax                            ;  }
        .cydnegpass                          ;
        add   eax,         [data%+4]         ;  for next pixel
        ;  INSERT CHECKS HERE AGAINST Y DISPLACEMENT OUTSIDE SCREENSIZE
        ;  AND JUMP TO .pixelpass
        mov   ebx,         5384              ;
        mul   ebx                            ;
  
        add   ecx,         eax               ;  Sum x and y to create offset for bits%
        push  ecx
  
        mov   edx,         [data%+124]       ;  Load edx with spritepointerx
        sal   edx,         2                 ;  Multiply by 4
        push  edx                            ;
        mov   eax,         [data%+128]       ;  Load eax with spritepointery
        mov   ebx,         [data%+60]        ;  Multiply by spritesizex
        mul   ebx                            ;
        sal   eax,         2                 ;  Multiply by 4 (eax)
        pop   edx                            ;
  
        add   eax,         edx               ;  Add edx to eax to create offset for sprite%
  
        pop   ecx                            ;
        mov   edx,         [^bits%]          ;  Create physical position of next
        add   edx,         ecx               ;  pixel to be printed
  
        mov   ebx,         sprite%           ;  Get colour of pixel to be printed
        add   ebx,         eax               ;  from array sprite%
  
        mov   eax,         [ebx]             ;  Print pixel
        mov   [edx],       eax               ;
  
        .pixelpass
  
        mov   eax,         [data%+132]       ;  Increase linefpx by lineincx
        add   [data%+108], eax               ;
  
        mov   eax,         [data%+136]       ;  Increase linefpy by lineincy
        add   [data%+112], eax               ;
  
        mov   eax,         [data%+68]        ;  Increase contspritepointerx by
        add   [data%+116], eax               ;  spriteincx
  
        mov   DWORD        [temp%],    16384 ;
        fild  DWORD        [data%+116]       ;
        fidiv DWORD        [temp%]           ;  Calculate new value for spritepointerx
        fistp DWORD        [data%+124]       ;  and place back in [data%+124]
  
        mov   eax,         [data%+124]
        cmp   eax,         [data%+60]
  
        jb    NEAR         startmainloopx
  
        mov   eax,         [data%+76]        ;  Increment p0to2fpx by p0to2incx
        add   [data%+92],  eax               ;
  
        mov   eax,         [data%+80]        ;  Increment p0to2fpy by p0to2incy
        add   [data%+96],  eax               ;
  
        mov   eax,         [data%+84]        ;  Increment p1to3fpx by p1to3incx
        add   [data%+100], eax               ;
  
        mov   eax,         [data%+88]        ;  Increment p1to3fpy by p1to3incy
        add   [data%+104], eax               ;
  
        mov   eax,         [data%+72]        ;  Increment contspritepointery
        add   [data%+120], eax               ;  by spriteincy
  
        mov   ecx,          0
        mov   edx,          0
        mov   eax,         [data%+120]       ;
        mov   ebx,         16384             ;  Calculate new value of spritepointery
        div   ebx                            ;  and place back in [data%+128]
        mov   edx,         0                 ;
        mov   [data%+128], eax               ;
  
        mov   eax,         [data%+128]
        cmp   eax,         [data%+64]
        jb    NEAR         startmainloopy
  
        ret
  
        ]
  
      NEXT I%


      



ok, may be three posts!!!!!!!!!!
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: 3D Gaming Project
« Reply #14 on: Feb 27th, 2016, 5:26pm »

Post three!!

Code:
      DIM BITMAPINFOHEADER{Size%, Width%, Height%, Planes{l&,h&}, BitCount{l&,h&}, Compression%, SizeImage%, XPelsPerMeter%, YPelsPerMeter%, ClrUsed%, ClrImportant%}
      DIM bmi{Header{} = BITMAPINFOHEADER{}}
      bmi.Header.Size% = DIM(BITMAPINFOHEADER{})
      bmi.Header.Width% = 1346
      bmi.Header.Height% = 674
      bmi.Header.Planes.l& = 1
      bmi.Header.BitCount.l& = 32

      SYS "CreateDIBSection", @memhdc%, bmi{}, 0, ^bits%, 0, 0 TO hbitmap%
      IF hbitmap%=0 ERROR 100, "Couldn't create DIBSection"

      SYS "SelectObject", @memhdc%, hbitmap% TO oldhbm%
      SYS "DeleteObject", oldhbm%
      SYS "InvalidateRect", @hwnd%, 0, 0


      FOR x=0 TO 7
        FOR y=0 TO 7
          IF (x MOD 2=1 AND y MOD 2=1) OR (x MOD 2=0 AND y MOD 2=0) THEN
            FOR xloop=0 TO 31
              FOR yloop=0 TO 31
                ?(sprite%+(((x*128)+(xloop*4))+((((y*32)+yloop)*1024))))=255
                ?(sprite%+(((x*128)+(xloop*4))+((((y*32)+yloop)*1024))+1))=0
                ?(sprite%+(((x*128)+(xloop*4))+((((y*32)+yloop)*1024))+2))=0
                ?(sprite%+(((x*128)+(xloop*4))+((((y*32)+yloop)*1024))+3))=0
              NEXT
            NEXT
          ELSE
            FOR xloop=0 TO 31
              FOR yloop=0 TO 31
                ?(sprite%+(((x*128)+(xloop*4))+((((y*32)+yloop)*1024))))=0
                ?(sprite%+(((x*128)+(xloop*4))+((((y*32)+yloop)*1024))+1))=255
                ?(sprite%+(((x*128)+(xloop*4))+((((y*32)+yloop)*1024))+2))=0
                ?(sprite%+(((x*128)+(xloop*4))+((((y*32)+yloop)*1024))+3))=0
              NEXT
            NEXT
          ENDIF
        NEXT
      NEXT

      REPEAT
        ?(data%+61)=1
        ?(data%+65)=1
        CLS
        SYS "InvalidateRect", @hwnd%, 0, 0
        PRINT"The origional tile being transfered is a chessboard, 256x256 pixels."
        PRINT"Choose the coordinates for nodes 0,1,2 and 3 and watch"
        PRINT""
        PRINT"Max distance between nodes is 350 point to point!!!!!!"
        PRINT""
        PRINT"Node order is       N2      N3"
        PRINT""
        PRINT""
        PRINT""
        PRINT"                    N0      N1"
  
        FOR loop=0 TO 3
          PRINTTAB(0,10+(loop*2))"Nx";loop
          INPUTTAB(4,10+(loop*2))"";nodex
          ?(data%+(loop*8))=nodex MOD 256
          ?(data%+(loop*8+1))=nodex DIV 256
          PRINTTAB(0,10+(loop*2)+1)"Ny";loop
          INPUTTAB(4,10+(loop*2)+1)"";nodey
          ?(data%+(loop*8+4))=nodey MOD 256
          ?(data%+(loop*8+5))=nodey DIV 256
        NEXT
        TIME=0
        CALL starttranspose
        SYS "InvalidateRect", @hwnd%, 0, 0
        PRINT "Time taken : ";TIME
        PRINTTAB(30,40)"Press any key to do it again"
        Key%=0
        *FX 15,1
        REPEAT
    
          Key%=INKEY(100)
    
        UNTIL Key%<>-1
  
      UNTIL FALSE











      REM   data      nodex0
      REM   data+4    nodey0
      REM   data+8    nodex1
      REM   data+12   nodey1
      REM   data+16   nodex2
      REM   data+20   nodey2
      REM   data+24   nodex3
      REM   data+28   nodey3
      REM   data+32   p0to1length
      REM   data+36   p0to2length
      REM   data+40   p1to3length
      REM   data+44   p2to3length
      REM   data+48   longesthorizontal
      REM   data+52   longestvertical
      REM   data+56   longestside
      REM   data+60   spritesizex
      REM   data+64   spritesizey
      REM   data+68   spriteincx
      REM   data+72   spriteincy
      REM   data+76   p0to2incx
      REM   data+80   p0to2incy
      REM   data+84   p1to3incx
      REM   data+88   p1to3incy
      REM   data+92   p0to2fpx
      REM   data+96   p0to2fpy
      REM   data+100  p1to3fpx
      REM   data+104  p1to3fpy
      REM   data+108  linefpx
      REM   data+112  linefpy
      REM   data+116  contspritepointerx
      REM   data+120  contspritepointery
      REM   data+124  spritepointerx
      REM   data+128  spritepointery
      REM   data+132  lineincx
      REM   data+136  lineincy
 


The sprite to be printed is in full 32bit colour and would benefit from a photo etc to really try it out. Does anyone know if you can openin#x a .bmp etc so I can easily import a picture?

Ric
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: 3D Gaming Project
« Reply #15 on: Mar 1st, 2016, 08:14am »

Hi Ric,

That looks pretty impressive! If you can really redraw it in one centisecond that gives you quite a bit in hand to actually run the game.

Loading bitmaps: yes, several options. You can use:

*LOAD to load a file to a memory address (you would need to reserve enough space first)

*DISPLAY will load a bitmap file and stick it on the screen - I suspect you may be able to use that to load the image into a DIBSection you could manipulate, but I don't offhand know if you could do that without it appearing on the display - my guess is that it will get loaded into whatever bitmap is selected to the BB4W device context. You might be able to do it by
doing *REFRESH OFF,
selecting the DIBSection into the device context
*DISPLAYing your picture
Deselecting it and reselecting the default display bitmap

In the manual, under "displaying GIF and JPEG images", there is a more general routine for loading an image. If you look at the line

SYS !(!gpp%+32), ....

You will see you specify a device context to render to: in this case memhdc%. I suspect if you had another device context with your DIBSection you could specify that here, and thus be able to load a wide range of picture types to it, to work on "offscreen". Note that that call also appears to allow you to scale the input image to output bitmap (or part of it).

Hope that's helpful. If David Williams is still reading, he might have better ideas.

D
User IP Logged

Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: 3D Gaming Project
« Reply #16 on: Mar 1st, 2016, 5:59pm »

Thanks D
I will look into the *DISPLAY method as that would enable a straight edit on the screen.

With regards to the speed of the assembler routine, I have calculated that in order to fill the whole screen I can only refresh about 10fps without any gaming instructions. Really this needs to be upwards of 40fps for HD games so a faster routine is required, I am working on floating point calculations, but never done before so may be a while.
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: 3D Gaming Project
« Reply #17 on: Mar 23rd, 2016, 09:01am »

Thanks for the hint D, I now have a picture of my son rotating on the cube. The routine to print the sprites is now a combination of asm and fpasm. With no gaming code yet it will run at approx. 55fps. Not bad but I was hoping for more. It is now to big to add here as a code snippet (approx 40000 chars) so I will look for another method of distribution.
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx Re: 3D Gaming Project
« Reply #18 on: Mar 23rd, 2016, 9:50pm »

DDRM would know how the following technique could be done in BBC basic, or perhaps Richard would know.
1) offset a secondary window for the size of image you want to create
2) capture the image in a sprite
3) post the sprite on the main display window
4) clear the offset window and repeat
This would create flicker free animation and would allow redraws to be done off screen
Also, this would minimize memory use because you are using the same sprite for image capture/ transfer/ display
« Last Edit: Mar 23rd, 2016, 9:53pm by michael » User IP Logged

I like making program generators and like reinventing the wheel
Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: 3D Gaming Project
« Reply #19 on: Mar 24th, 2016, 5:20pm »

Thanks Michael,
I am sure for a man moving across the screen that would work, but the 55fps is for the whole screen rendering a 3d landscape like most modern games. My calculations work out that this will drop to 40fps with game play code. The sprite in question is just one of many used to create the landscape, and using the four corners as nodes can be skewed to create full 3d with depth perception. Originally my challenge to myself was to learn asm and write a 3d game, it's going OK so far. If I moved to a modern laptop this would aid speed as mine currently is a measly 1.9Ghz.
Regards Ric
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
Pages: 1 2 3 4  ...  8 Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls