Art Of Destruction/unexpanded 3D [under construction]

Basic and Machine Language

Moderator: Moderators

User avatar
Kweepa
Vic 20 Scientist
Posts: 1315
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by Kweepa »

Looks good so far!
User avatar
joshuadenmark
Big Mover
Posts: 1218
Joined: Sat Oct 23, 2010 11:32 am
Location: Fr-Havn, Denmark
Occupation: Service engineer

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by joshuadenmark »

I am impress with you coder guys :shock: look really good.
Kind regards, Peter.
____________________________________________________
In need of a wiki logon - PM me
User avatar
pixel
Vic 20 Scientist
Posts: 1351
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by pixel »

Well, this attempt is hopelessly bollocksed on unexpanded machines. Wish I could pick my obsessions. My last hope for unexpanded 3D is something mathematically reduced like Star Strike – black and white in multicolor resolution to get double buffering. Which would look like this:

Image

Ignore the circle. The idea is to use the border color as the screen background, the screen color for frame A, auxiliary color for frame B and character color for overlapping pixels across frames. Switching frames is done by setting the frame A color to the foreground color and frame B to the background color and vice versa. So one can use EOR to draw pixels and AND/OR to convert shared color pixels to the currently shown frame to clean up.

No filled polygons to be expected. No rotations. In the end character management will probably pull the handbrake. Maybe somebody else will get something out of this.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
darkatx
Vic 20 Afficionado
Posts: 471
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by darkatx »

Don't feel bad...if you want speed - you need space...LOL. I'm blowing off the dust on my line routine and making improvements...just need to try out my matrix and see how it looks.
Learning all the time... :)
User avatar
pixel
Vic 20 Scientist
Posts: 1351
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by pixel »

darkatx wrote:Don't feel bad...if you want speed - you need space...LOL. I'm blowing off the dust on my line routine and making improvements...just need to try out my matrix and see how it looks.
At the moment I'm at about 90 cycles per pixel, additional ~150 cycles for crossing char boundaries and ~130 cycles for setting up the loop. All pessimistic worst case estimations. Cleaning up the chars (you'll have to detect chars with no lit pixels as well) will eat up some 30,000 cycles. Not too bad, isn't it?

What 3D game would be worth looking at? I only know about Battle Zone.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
darkatx
Vic 20 Afficionado
Posts: 471
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by darkatx »

Mines all over the place...so your routine is definitely better than mine...think I'm averaging worst case scenario about 140 cycles per pixel period. I was thinking of a dressed down version of Star Wars maybe?
Learning all the time... :)
User avatar
beamrider
Vic 20 Scientist
Posts: 1449
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by beamrider »

I would love to see a port of the Atari 8 bit classic "Star Raiders"...
User avatar
pixel
Vic 20 Scientist
Posts: 1351
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by pixel »

Here's what I've got for lines. Drawing single pixels is already too much. There must be enough left for game logic:

Code: Select all

Address: accumulated cycles: min. cycles: code: source
1400: 674   :            step_right:                                            
1400: 674 2 : e8             inx
1401: 676 3 : a5 0f          lda pixel_mask
1403: 679 2 : 38             sec
1404: 681 2 : 6a             ror
1405: 683 2 : 90 07          bcc char_right  ; Mask out of byte…
1407: 685 2 : 38             sec
1408: 687 2 : 6a             ror
1409: 689 2 : 90 03          bcc char_right  ; Mask out of byte…
140b: 691 3 : 85 0f          sta pixel_mask
140d: 694 6 : 60             rts
140e: 700   :            char_right:
140e: 700 2 : a9 3f          lda #%00111111
1410: 702 3 : 85 0f          sta pixel_mask
1412: 705 5 : e6 0c          inc scrx
1414: 710 3 : 86 1b          stx line_xreg
1416: 713 3 : 84 1c          sty line_yreg
1418: 716 6 : 20 18 02       jsr scraddr     ; Get address of scrx/scry.
141b: 722 4 : 4c 5c 02       jmp get_char    ; Allocate char for that address.
141e: 726   :            step_left:
141e: 726 2 : ca             dex
141f: 728 3 : a5 0f          lda pixel_mask
1421: 731 2 : 38             sec
1422: 733 2 : 2a             rol
1423: 735 2 : 90 07          bcc char_left   ; Mask out of byte…
1425: 737 2 : 38             sec
1426: 739 2 : 2a             rol
1427: 741 2 : 90 03          bcc char_left   ; Mask out of byte…
1429: 743 3 : 85 0f          sta pixel_mask
142b: 746 6 : 60             rts
142c: 752   :            char_left:
142c: 752 2 : a9 fc          lda #%11111100
142e: 754 3 : 85 0f          sta pixel_mask
1430: 757 5 : c6 0c          dec scrx
1432: 762 3 : 86 1b          stx line_xreg
1434: 765 3 : 84 1c          sty line_yreg
1436: 768 6 : 20 18 02       jsr scraddr
1439: 774 4 : 4c 5c 02       jmp get_char
143c: 778   :            step_down:
143c: 778 2 : c8             iny
143d: 780 2 : 98             tya
143e: 782 2 : 29 07          and #%111
1440: 784 2 : f0 03          beq char_down
1442: 786 5 : e6 12          inc char_y
1444: 791 6 : 60             rts
1445: 797   :            char_down:
1445: 797 2 : a9 00          lda #0
1447: 799 3 : 85 12          sta char_y
1449: 802 5 : e6 0d          inc scry
144b: 807 3 : 86 1b          stx line_xreg
144d: 810 3 : 84 1c          sty line_yreg
144f: 813 6 : 20 18 02       jsr scraddr
1452: 819 4 : 4c 5c 02       jmp get_char
1455: 823   :            step_up:
1455: 823 2 : 88             dey
1456: 825 5 : c6 12          dec char_y
1458: 830 2 : 30 01          bmi char_up
145a: 832 6 : 60             rts
145b: 838   :            char_up:
145b: 838 2 : a9 07          lda #7
145d: 840 3 : 85 12          sta char_y
145f: 843 5 : c6 0d          dec scry
1461: 848 3 : 86 1b          stx line_xreg
1463: 851 3 : 84 1c          sty line_yreg
1465: 854 6 : 20 18 02       jsr scraddr
1468: 860 4 : 4c 5c 02       jmp get_char
146b: 864   :            smtab_increment:
146b: 864   : 00             <step_right <step_down
146c: 864   : 3c             <step_right <step_down
146d: 864   : 00             <step_right <step_up
146e: 864   : 55             <step_right <step_up
146f: 864   : 1e             <step_left <step_down
1470: 864   : 3c             <step_left <step_down
1471: 864   : 1e             <step_left <step_up                                
1472: 864   : 55             <step_left <step_up
1473: 864   :            smtab_step:
1473: 864   : 3c             <step_down <step_right
1474: 864   : 00             <step_down <step_right
1475: 864   : 55             <step_up <step_right
1476: 864   : 00             <step_up <step_right
1477: 864   : 3c             <step_down <step_left
1478: 864   : 1e             <step_down <step_left
1479: 864   : 55             <step_up <step_left
147a: 864   : 1e             <step_up <step_left
147b: 864   :            draw_line:
147b: 864 3 : a5 14          lda x0
147d: 867 2 : aa             tax
147e: 869 2 : 4a             lsr
147f: 871 2 : 4a             lsr
1480: 873 3 : 85 0c          sta scrx
1482: 876 3 : a5 15          lda y0
1484: 879 2 : a8             tay
1485: 881 2 : 4a             lsr
1486: 883 2 : 4a             lsr
1487: 885 2 : 4a             lsr
1488: 887 3 : 85 0d          sta scry
148a: 890 2 : 8a             txa
148b: 892 2 : 29 03          and #3
148d: 894 2 : aa             tax
148e: 896 4 : bd 3f 15       lda multicolor_masks,x
1491: 900 3 : 85 0f          sta pixel_mask
1493: 903 2 : 98             tya
1494: 905 2 : 29 07          and #7
1496: 907 3 : 85 12          sta char_y
1498: 910 2 : a9 e4          lda #opcode_cpx
149a: 912 4 : 8d 1b 15       sta test
149d: 916 2 : a9 17          lda #x1
149f: 918 4 : 8d 1c 15       sta @(++ test)
14a2: 922 2 : a9 00          lda #0
14a4: 924 3 : 85 13          sta octant
14a6: 927 3 : a5 17          lda x1      ; dx = x1 - x0                         
14a8: 930 2 : 38             sec
14a9: 932 3 : e5 14          sbc x0
14ab: 935 2 : 10 05          bpl +p1
14ad: 937 5 : e6 13          inc octant  ; Tell to decrement X.
14af: 942 6 : 20 80 02       jsr neg
14b2: 948   :            p1: sta dx
14b2: 948 3 : 85 16      p1: sta dx
14b4: 951 5 : 06 13          asl octant
14b6: 956 3 : a5 18          lda y1      ; dy = y1 - y0
14b8: 959 2 : 38             sec
14b9: 961 3 : e5 15          sbc y0
14bb: 964 2 : 10 05          bpl +p2
14bd: 966 5 : e6 13          inc octant  ; Tell to decrement Y.
14bf: 971 6 : 20 80 02       jsr neg
14c2: 977   :            p2: sta dy
14c2: 977 3 : 85 19      p2: sta dy
14c4: 980 5 : 06 13          asl octant
14c6: 985 3 : a5 16          lda dx
14c8: 988 3 : c5 19          cmp dy
14ca: 991 2 : b0 14          bcs +no_swap
14cc: 993 5 : e6 13          inc octant  ; Tell to swap X and Y.
14ce: 998 3 : a6 16          ldx dx
14d0: 1001 3 : a4 19         ldy dy
14d2: 1004 3 : 84 16         sty dx
14d4: 1007 3 : 86 19         stx dy
14d6: 1010 2 : a9 c4         lda #opcode_cpy
14d8: 1012 4 : 8d 1b 15      sta test
14db: 1016 2 : a9 18         lda #y1
14dd: 1018 4 : 8d 1c 15      sta @(++ test)
14e0: 1022   :           no_swap:
14e0: 1022 3 : a5 19         lda dy
14e2: 1025 2 : 0a            asl
14e3: 1027 3 : 85 19         sta dy
14e5: 1030 2 : 38            sec         ; D = 2*dy - dx
14e6: 1032 3 : e5 16         sbc dx
14e8: 1035 3 : 85 1a         sta line_d
14ea: 1038 3 : a5 16         lda dx      ; 2dx
14ec: 1041 2 : 0a            asl
14ed: 1043 3 : 85 00         sta tmp                                            
14ef: 1046 3 : a5 19         lda dy      ; 2dy - 2dx
14f1: 1049 2 : 38            sec
14f2: 1051 3 : e5 00         sbc tmp
l14f4: 1054 4 : 8d 2c 15      sta @(++ update)
14f7: 1058 3 : a6 13         ldx octant
14f9: 1061 4 : bd 6b 14      lda smtab_increment,x
14fc: 1065 4 : 8d 20 15      sta @(++ increment)
14ff: 1069 4 : bd 73 14      lda smtab_step,x
1502: 1073 4 : 8d 29 15      sta @(++ step)
1505: 1077 6 : 20 18 02      jsr scraddr
1508: 1083 6 : 20 5c 02      jsr get_char
150b: 1089 3 : a6 14         ldx x0
150d: 1092 3 : a4 15         ldy y0
150f: 1095   :           loop:
150f: 1095 3 : 84 10         sty pixel_yreg
1511: 1098 3 : a4 12         ldy char_y
1513: 1101 5 : b1 04         lda (d),y
1515: 1106 3 : 25 0f         and pixel_mask
1517: 1109 5 : 91 04         sta (d),y
1519: 1114 3 : a4 10         ldy pixel_yreg
151b: 1117   :           test:
151b: 1117 3 : e4 17         cpx x1
151d: 1120 2 : f0 1b         beq +done
151f: 1122   :           increment:
151f: 1122 6 : 20 00 14      jsr step_right
1522: 1128 3 : a5 1a         lda line_d
1524: 1131 2 : f0 0a         beq +n1         ; D = 0
1526: 1133 2 : 30 08         bmi +n1         ; D < 0
1528: 1135   :           step:
1528: 1135 6 : 20 3c 14      jsr step_down
152b: 1141   :           update:
152b: 1141 2 : a9 00         lda #0
152d: 1143 4 : 4c 32 15      jmp add_to_d    ; D = D + (2dy - 2dx)
1530: 1147   :           n1: lda dy          ; D = D + 2dy
1530: 1147 3 : a5 19     n1: lda dy          ; D = D + 2dy
1532: 1150   :           add_to_d:
1532: 1150 2 : 18            clc
1533: 1152 3 : 65 1a         adc line_d
1535: 1155 3 : 85 1a         sta line_d                                         
1537: 1158 4 : 4c 0f 15      jmp -loop
153a: 1162   :           done:
153a: 1162 6 : 60            rts
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
darkatx
Vic 20 Afficionado
Posts: 471
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by darkatx »

That's some really tight code - impressive stuff considering you're trying to keep it unexpanded. I know Mike's routine can get down into under 35 cycles in some cases (inner loop) so hitting 90 cycles max is really good! :)
Learning all the time... :)
User avatar
Mike
Herr VC
Posts: 4839
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by Mike »

darkatx wrote:[...]Mike's routine can get down into under 35 cycles in some cases[...]
"Less than 35 cycles/pixel in nearly all cases" would be a slightly more accurate description.

Here's the relevant thread, 'How many cycles per pixel should I expect for drawing lines?', and two demos using this line routine can be found here (vector.prg) and here (EARTH GLOBE 2).
User avatar
pixel
Vic 20 Scientist
Posts: 1351
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by pixel »

*sigh* Guess I'll stick with something sub-Star-Strikey.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
darkatx
Vic 20 Afficionado
Posts: 471
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by darkatx »

Mike wrote:
darkatx wrote:[...]Mike's routine can get down into under 35 cycles in some cases[...]
"Less than 35 cycles/pixel in nearly all cases" would be a slightly more accurate description.
...
I so wanted to say less than 35 cycles period...LOL...I was sure you'd be there to catch me :) LOL

EDIT - what I meant to say (sorry I just came back from playing hockey - maybe I've suffered too many concussions or maybe its just the exhaustion ;) )
I so wanted to say it was less than 35 cycles but I'm not sure because I can't find the thread...so I'm going from memory. Also, it's my bad - I completely forgot that Mike posted code in it - that should have given me more incentive to post it up here. Again, what I like about this place is the wealth of information and people who 'think outside the box' to find elegant solutions to programming obstacles when it comes to our favourite Commodore. :)
Mike you are always welcome! :)
Last edited by darkatx on Tue May 26, 2015 2:50 pm, edited 1 time in total.
Learning all the time... :)
User avatar
Mike
Herr VC
Posts: 4839
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by Mike »

darkatx wrote:I so wanted to say less than 35 cycles period...LOL...I was sure you'd be there to catch me :) LOL
So if you knew better, why couldn't you already have pointed pixel to those threads before me, but let me instead appear as the a**hole crashing the party?
User avatar
darkatx
Vic 20 Afficionado
Posts: 471
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by darkatx »

I clarified my post above...
And you are definitely not crashing, I'm glad you swooped in when ya did...your insights are always appreciated :)
Last edited by darkatx on Tue May 26, 2015 2:52 pm, edited 1 time in total.
Learning all the time... :)
User avatar
pixel
Vic 20 Scientist
Posts: 1351
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Art Of Destruction/unexpanded 3D [under construction]

Post by pixel »

:shock:

Dudes!? *gulp* I thought the party was still on…

I'm very impressed by Mike's line drawing routine. I just don't understand it. Gotta let the confusion pass by because I take everybody's input very seriously. And I'm gagging for a crate of beer in midst of a desert. :mrgreen:

When I see Star Wars (is that BASIC?) or Star Raiders I think "no need for vectors at all". Or the stars would spoil everything. Rotating things is also a no-go. As well as unrolling. Originally I figured 16 lines at 10 frames might be doable. Seems so now. But all in all I feel translation and projection is the only math that could be included. That's why I fell back to square one with Star Strike. As I said before in another thread: when it comes to math I'm an utterly complete loser. Guess only a good psychiatrist could get me off that idea. With something very strong that has side effects like death.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
Post Reply