Art Of Destruction/unexpanded 3D [under construction]

Basic and Machine Language

Moderator: Moderators

User avatar
darkatx
Vic 20 Afficionado
Posts: 470
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

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

Post by darkatx »

Maybe a racing game? You can sidestep the rotations on that.
Learning all the time... :)
malcontent
Vic 20 Hobbyist
Posts: 129
Joined: Sun Dec 26, 2010 1:51 pm

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

Post by malcontent »

Maybe if you used a 4x4 mode drawing would be quicker (and take less memory). Of course the resolution would be bad. I like the idea of a driving game, or skiing game. The world could be a height map, a byte could define both the leading and trailing edge of the polygon trail.
User avatar
pixel
Vic 20 Scientist
Posts: 1330
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 »

Driving and skiing is too complicated, I'm afraid. If I could make a living with such things I'd be off hacking for expanded machines in no time.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
Mike
Herr VC
Posts: 4816
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: It's ok. From pixel's first response ("... I'll stick with something sub-Star-Strikey ...") I got the impression, that his ambitions might have been severely put down by the sheer comparison of numbers. With me being the messenger of "bad" news:
pixel wrote:I'm very impressed by Mike's line drawing routine. I just don't understand it. [...]
It's still Bresenham. As simple as that.

The routine is designed to plot into a MINIGRAFIK bitmap, but it can be adapted to other screen sizes, as long as those employ a columnwise ordering of the characters for address generation. This way, stepping along the Y-axis is simply done by changing the Y register in LDA/STA (),Y accordingly. When it is necessary to change the character column (lines are always drawn from left to right) all that needs to be done is adding the number of bytes in each bitmap column to the base pointer: in case of MG, 192 bytes. The full address calculation thus only needs to be done once, for the first pixel.

Stepping along the X-axis is done by unrolling the main loop 8-fold, for each bit position. Before the main loop is entered, the init routine checks, whether the instructions to change the Y-coordinate are correct. If they aren't, they are replaced with the appropriate INY/DEY, which is done with 8 store instructions. Furthermore, the line routine can self-modify itself to change between set/reset/invert pixels. Again, the corresponding ORA/AND/EOR instructions are checked, and if necessary, replaced - also their masks (only between ORA/EOR <-> AND).

Two of those big loops are provided, one for |dy|<|dx|, the other for |dy|>=|dx|, and the self-modifications are applied only to that loop that is going to be used. The embedded Bresenham algorithm can avoid most SEC and CLC instructions for SBC and ADC, because where it matters the C flag is known and has the correct value! The number of pixels to draw is kept in the X register, and when counted down to 0, the routine exits.

All in all, the routine weighs in at ~800 bytes. A sensible size for a bitmap on an unexpanded VIC-20 does not exceed 2K + text screen. These three things put together wouldn't leave you with much RAM left for anything else. ;)

But if you let go the restriction of doing unexpanded ... 8)
User avatar
pixel
Vic 20 Scientist
Posts: 1330
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 »

Mike wrote:@darkatx: It's ok. From pixel's first response ("... I'll stick with something sub-Star-Strikey ...") I got the impression, that his ambitions might have been severely put down by the sheer comparison of numbers. With me being the messenger of "bad" news:
Nah, it's just the regular waves of confusion that wash over me. How you arrived at that conclusion would need some explaining to me. I'm not that kind of person. If I pick the hell of a challenge it's my problem when I get frustrated, not other people's fault, isn't it? I don't get aggressive for no reason. I might just shut down and impatience is killing me until everything bubbled back up, rearranged. Already too much said about me…
Mike wrote:
pixel wrote:I'm very impressed by Mike's line drawing routine. I just don't understand it. [...]
It's still Bresenham. As simple as that.


But if you let go the restriction of doing unexpanded ... 8)
Thanks for the outline. :)

4x4 pixels is really rough. Better to knock that off on an ZX81. ;)

VICtragic just showed us the right kind of game for this challenge with his Galaxy Renegade, didn't he? Every sprite being a bitmap of its own could really boost this.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
Post Reply