Jump to content
IGNORED

Lynx 3D Experimenting


VladR

Recommended Posts

On ‎6‎/‎28‎/‎2019 at 7:20 AM, 42bs said:

Did some cycle measurements (ideal 65C02, not Lynx) with a small (maybe not 100% optimized) 65C02 line fill.

Here the results:

    ;; two pixels even       66
    ;; two pixels odd        88
    ;; three even          114
    ;; three odd           116

    ;; 2n odd (n>=2)       116+(n-2)*13
    ;; 2n even (n>=2)      100+(n-2)*13
    ;; full line          1114

 

even/odd = X is even or odd.

The cycles per instruction are text-book ones, so the Lynx is slightly worse if a page gets crossed.

 

I thought, I read some info on Suzy's RAM access, but only that it reads 8pixels in a burst for collision check.

 

I have not yet checked Suzy's drawing speed for such, but my guess is it will outperform the CPU from a certain width on. How wide has to be found out ...

Thanks for the numbers. I'm confused by the inner double-pixels: (n-2)*13

Judging from the Full line Number of 1,114c (I reckon it's 80 bytes *13 cycles = 1,040), it appears you mean 13c per byte, correct ?

Yes, that's not 100% optimized. If you unroll a single full scanline (80 pairs of {STA (vidPtr),Y + INY} take just 240 Bytes), you'll get down to (6+2) = 8c / Byte.

 

I've even had 4c per byte on A800 (just single STA, no INY, nothing :) ), but there was barely any memory left. Impossible on Lynx due to outrageously large framebuffer., other than for half of screen. But not needed anyway, as we got Suzy...

 

 

On ‎6‎/‎28‎/‎2019 at 7:20 AM, 42bs said:

I have not yet checked Suzy's drawing speed for such, but my guess is it will outperform the CPU from a certain width on. How wide has to be found out ...

That will actually be one my first CPU vs Suzy benchmarks. Draw Lines with length in range <1,160> on CPU first, then on Suzy and show the results. Very, very curious. There's a 16 MHz beast somewhere there, after all...

 

I do, however, expect, that Suzy's efficiency per pixel will be much lower for short scanlines, than, say, for large bitmaps, where the fixed cost of set-up and outer loops (in silicon) gets amortized over multiple scanlines of the sprite.

 

 

 

Link to comment
Share on other sites

Day 4:

- Implemented scanline drawing via HW (Suzy's sprites)

 

Looks roughly identical to SW rasterizer version to me, though haven't examined it pixel by pixel:

Lynx06_HW_Accelerated_Flatshading.thumb.GIF.d7cfc7b4acef1c9c8d18dd863098ca64.GIF

 

It's still morning for me, so I still have almost full day of work ahead of me. I guess I can start working on benchmarks and start porting it to ASM. If I didn't spend about a day with the Star Raiders distraction, I could have done this on Day 3 already :lol:

Definitely my shortest amount of time to get a working code on a new HW platform...

 

  • Like 1
Link to comment
Share on other sites

I did some scanline analysis (implemented a basic counter) to get a closer estimate of real performance.

 

The StunRunner track has 225 scanlines in total (7+10+19+35+154). The last 2 segments are about 7% of the total, so might as well keep them there for full perspective effect.

I plugged those into my excel spreadsheet and got a number 57,890c for all processing (without rendering, as that will happen on Suzy). That's basically ~1 full frame worth of CPU time (56,467c).

So, even if clearing framebuffer and rendering those scanlines on Suzy would take another 2 frames, it still should run at around 20 fps.

 

The Star Raiders scene only shows 76 scanlines for 3 ships, e.g. just one third. When I plugged that into the excel, I got 19,994 cycles for all processing (no scanline rasterizing). Depending on distance (and thus number of scanlines), it takes between 4,000 - 10,000c per ship.

 

Now, at this moment I don't know how many cycles are left for CPU after screen is cleared, but there is definitely a real possibility of 60 fps gameplay with 1 ship :)

And because there's no clearscreen for second frame at 30fps, we have full ~56,000 cycles available. That's pretty awesome, actually.

 

Here's how the ships look flatshaded. Well, not exactly flatshaded, as I took the liberty and depth-shaded them to see how it'd look and if it's actually visually useable...

Lynx07_StarRaiders_DepthShading.thumb.GIF.7eb420ea4b17231c01d4f57841eb3680.GIF

 

 

Link to comment
Share on other sites

While watching some YT, I encountered Sega 32X's Star Wars and figured I'd give the tunnel a try, seeing as this is an 8-bit CPU at 4 MHz, so why not :lol:

 

My 3D modeling skills from within notepad suck, so this is the best approximation I could come up in 2 hours of "text editor modeling" , but at least I got some stats on scanline number: 577 may be pushing it for Lynx, but in worst case, it could be a run-time cut-scene, where framerate doesn't matter that much :)

 

Lynx08_StarWars_Corridor_Sega32x.thumb.GIF.32b16d20d8ade55be39d0b48f0138425.GIF

 

Base Segment is only 360 Bytes of data. I'm sure it wouldn't quantize too much if I reduced it by 50% to 180. Or further 50% (to 90 Bytes) if I applied mirroring.

 That's what I love about flatshading. Data can be massaged into whatever you want at run-time. And with Lynx's 4,096 color palette, all kinds of run-time lighting settings can be applied.

 

 

Link to comment
Share on other sites

34 minutes ago, VladR said:

While watching some YT, I encountered Sega 32X's Star Wars and figured I'd give the tunnel a try, seeing as this is an 8-bit CPU at 4 MHz, so why not :lol:

 

My 3D modeling skills from within notepad suck, so this is the best approximation I could come up in 2 hours of "text editor modeling" , but at least I got some stats on scanline number: 577 may be pushing it for Lynx, but in worst case, it could be a run-time cut-scene, where framerate doesn't matter that much :)

 

Lynx08_StarWars_Corridor_Sega32x.thumb.GIF.32b16d20d8ade55be39d0b48f0138425.GIF

 

Base Segment is only 360 Bytes of data. I'm sure it wouldn't quantize too much if I reduced it by 50% to 180. Or further 50% (to 90 Bytes) if I applied mirroring.

 That's what I love about flatshading. Data can be massaged into whatever you want at run-time. And with Lynx's 4,096 color palette, all kinds of run-time lighting settings can be applied.

 

 

You always talk about "scan lines" and "flat shading", but it looks you mean each poly is drawn with one color. So why not use Suzy to draw the triangles of the poly?

Or is it because of the multiplication/division needed for this?

Do you use some kind of Bresenham algo for the vertices?

A comparison would be interesting and if your algo is quicker, take the challenge:

 

 

 

Edited by 42bs
fix url
Link to comment
Share on other sites

Yeah - flatshading means each polygon has single, "flat" color, no gradients, no shading.

 

I noticed in the LX.NET's tutorial that using vertical stretching, it should theoretically be possible to draw full triangles, but I doubt it can be extended generically. Highly likely, only nice and regular, and merely slightly angled triangles could be done in single call.

 

But, it's an area that is unique to Lynx and definitely needs more research by me.

 

stnicc ? Looks like it's been done already, so zero challenge in that...

Link to comment
Share on other sites

2 hours ago, VladR said:

I noticed in the LX.NET's tutorial that using vertical stretching, it should theoretically be possible to draw full triangles, but I doubt it can be extended generically. Highly likely, only nice and regular, and merely slightly angled triangles could be done in single call.

Any triangle with two sprites. Use the source Luke!

Link to comment
Share on other sites

I'd say looks good, but I gave up years ago.  Vlad will come in, post a topic, get people excited, then move on in a few weeks.  Been doing this in the Jag forum for 4 or 5 years.  Never released one single binary.  Every little speck of dust distracts him.  This is project #8 that I have seen from him.  Nothing ever completed, nothing posted, no source, no binaries.

 

Pure number wanking.  I did this, I got this many fps, I watched this YouTube video, I have to move again, I have to blah blah blah.  Nothing to see here, move along.  Search the forums for his other stuff posted in Jag forum, Atari 8-bit forum, etc.

  • Like 2
Link to comment
Share on other sites

1 hour ago, Stephen said:

I'd say looks good, but I gave up years ago.  Vlad will come in, post a topic, get people excited, then move on in a few weeks.  Been doing this in the Jag forum for 4 or 5 years.  Never released one single binary.  Every little speck of dust distracts him.  This is project #8 that I have seen from him.  Nothing ever completed, nothing posted, no source, no binaries.

 

Pure number wanking.  I did this, I got this many fps, I watched this YouTube video, I have to move again, I have to blah blah blah.  Nothing to see here, move along.  Search the forums for his other stuff posted in Jag forum, Atari 8-bit forum, etc.

Awwww, I luv U 2 :lol:

 

3 hours ago, Positron5 said:

@VladR

Supplimentary--I've converted Bastian's bll drawtriangle for cc65  and you might find this of interest:

https://atariage.com/forums/topic/262666-cc65-for-windows/?do=findComment&comment=3995454

 

Thanks, I'll check it out !

8 hours ago, 42bs said:

Any triangle with two sprites. Use the source Luke!

I don't want to spoil my surprise, so no peeking yet :)

 

Well, the issue here, as far as I can tell, is that the HW interpolator can only handle one xpAdd per scanline.

Hypothetically, one could try to approximate a non-right-angled triangle but I don't see how it would match at the borders. Holes would be inevitable.

 

I believe you can however split any generic triangle into two right-handed triangles and draw those in separate calls.

 

Am I close or way off the base here ?

Link to comment
Share on other sites

29 minutes ago, 42bs said:

I wonder, will we ever see a binary let alone some sources.

That's the plan - to submit something for the compo, hence it automatically will be public. And I'll need some testing on HW.

 

So, I would really appreciate if you didn't bring here the pathetic (entertaining, nonetheless :lol: ) drama of the Mental Institution of Jaguar subforum, even though I'm sure Steven eagerly reported there his findings from this thread and they will start doing what they do best - e.g. shi*ing in this thread any minute now :)

Wait, sorry - not quite any minute. It's ~4 am over there now. Gotta wait till the nurse distributes them the morning pills first and then It Begins....

ShitPosting.thumb.gif.3a87b082557f73c7b012e51bfaf9d525.gif

 

 

 

Regardless, I'm not worried anymore about the 3D engine part, even though it's currently all in C, as that shouldn't take long to port to ASM.

 

Much more worried about audio. That's one thing I never wrote from scratch. Any useable audio libs for Lynx ?

Link to comment
Share on other sites

Sure. HandyMusic is based on SASS. It is a programmable language where you can call sequences of notes. It also allows for fairly easy frequency slides and volume slides.

 

There is a learning curve. Runs on asm projects. I have recently ported it to cc65 for the competition. If you want to use it I can send the source for cc65 handymusic.

 

Chipper is the de-facto standard lib. Works with everything and has windows based sequencer.

 

ABCmusic is a very simple lib based on the abcmusic standard. You type your music in ASCII.

 

  • Like 1
Link to comment
Share on other sites

21 minutes ago, karri said:

Sure. HandyMusic is based on SASS. It is a programmable language where you can call sequences of notes. It also allows for fairly easy frequency slides and volume slides.

 

There is a learning curve. Runs on asm projects. I have recently ported it to cc65 for the competition. If you want to use it I can send the source for cc65 handymusic.

 

Chipper is the de-facto standard lib. Works with everything and has windows based sequencer.

 

ABCmusic is a very simple lib based on the abcmusic standard. You type your music in ASCII.

 

Thanks for the tips! I have not heard of either of them, unfortunately. I'll start doing some research on them. I can't leave to last minute or it won't happen, I know that much...

 

As a worst-case scenario, if everything else fails,  which one would you recommend to play at least simple sounds (e.g. shooting, engine, clicks, etc.) ?

Link to comment
Share on other sites

Day 5:

- figured how to interface asm with C (within cc65) via separate *.s file and tested it by drawing screen of colorful pixels from Asm. I can print the Asm variables from C, so this is good enough for me now.

- experimented and got the basics of Timers working so I can have some benchmark soon

- It's probably the emulator, but 421,888 cycles worth of CPU code (which is 124,532 us in real life) should have taken only 64*245=15,680 us. That's ~8:1 ratio. Will need to see benchmarks from real HW.

 

Tomorrow I'll use the code above and write the first benchmark comparing scanline drawing between CPU and Suzy.

Link to comment
Share on other sites

8 hours ago, karri said:

Posted by Nop90 on April 12. Search for template in this forum.

Oh, right. That one. From quick look it appears there's 2 version conflicts there resulting in numerous environment and compilation issues (cc65 with your bug fixes that didn't yet make it to cc65 release and tgi). I'd rather not break my working environment or start duplicating them across my hdd.

 

I downloaded chipper source code. Looks like it's old enough to be compatible with cc65 out of the box, so I presume it should compile. Even if it doesn't, there's audio code inside that I could use for learning purposes (in worst case).

 

I still need to find out what's the license on chipper. It certainly is not mentioned in the source code. Probably on the site, somewhere in that wall of text...

Link to comment
Share on other sites

On 10/18/2018 at 2:14 AM, VladR said:

Few announcements:

 

1. SAC Gamers Expo, Sacramento,CA: Dec 09,2018 :

- I bought a stand as an exhibitor there

- I will have a playable version there, there will be a gameplay video before that

 

17 hours ago, VladR said:

That's the plan - to submit something for the compo, hence it automatically will be public. And I'll need some testing on HW.

 

So, I would really appreciate if you didn't bring here the pathetic (entertaining, nonetheless :lol: ) drama of the Mental Institution of Jaguar subforum, even though I'm sure Steven eagerly reported there his findings from this thread and they will start doing what they do best - e.g. shi*ing in this thread any minute now :)

 

Will your submission for the compo be available just like your playable 500 level RPG/Road Rash/STUN Runner/HERO game? Or will there be taxes or a juice diet that prevents this? 

  • Like 1
  • Haha 2
Link to comment
Share on other sites

46 minutes ago, madman said:

 

Will your submission for the compo be available just like your playable 500 level RPG/Road Rash/STUN Runner/HERO game? Or will there be taxes or a juice diet that prevents this? 

And here comes patient No 2 from the East Wing. What took you so long :lol: ?

 

I'm getting worried about you. Are you taking all your meds as prescribed ? They're clearly not working efficiently. You know they'll administer electroshock therapy, when they find out,  eventually...

Link to comment
Share on other sites

Patient number 3 checking in.

 

2 carabinieri went to the movie theater to watch a horse racing movie, at a certain point a horse race begins and carabiniere no. 1 asks no.2 if he wants to bet on the winner, he agrees so they proceed with the bet, no.1 says he bets on the white horse and no.2 happily takes the brown horse.

At the end of the race the brown horse wins and so carabiniere no.1 wants to pay the dues as agreed, carabiniere no.2 though tells him that he cannot accept the payment because he already watched the movie so he knew how the race would end and he apologizes for not having revealed it earlier, carabiniere no.1 responds that he too watched the movie a few times already but this time he was sure the white horse looked much more prepared.

 

To be fair even a broken clock is right twice a day, let's see how this turns out .... this time he seems much more prepared.

Link to comment
Share on other sites

Disregarding the smelly Jaguar Fumes brought here by The Regime Collaborants, I got some first interesting benchmark data.

 

Day 6:

- wrote both a Suzy-based and CPU-based scanline drawing in assembler. Set the scanline length to 160 pixels.

- Plugged it into the yesterday's timer (64 us, set to repeat 128 times).

- Somehow, in the same timeframe (128 * 64 us), CPU managed to draw the 160-pixel scanline 336x while Suzy only 259x, so CPU is 30% faster :)

 

So, Suzy is actually slower on my emulator :lol: And it's not a 3-pixel scanline, it's full 160 pixels! That's the best case Suzy can hope for, though mostly it'll be much much shorter scanline.

Obviously, I don't believe that could possibly be the case with the real HW, but it's pretty funny nonetheless.

I gotta clean the code up, perhaps provide some text messages too and make sure I'm using exact same timer data before I provide a download.

Link to comment
Share on other sites

The way I have been using Chipper is to keep the instruments the same for the entire game. So you declare all your instruments, music and sound effects in the same song. That song should then get exported for cc65. It will look like this:

.include "soundbs.mac"
.export _musicptr

            .segment "TUNES_RODATA"

_musicptr:
    .word CHANNEL_0, CHANNEL_1, CHANNEL_2, MACHINEGUN, HELICOPTER, EXPLOSION, ENEMY

PATTERN_LENGTH   .set  1920

CHANNEL_0:
        PATTERN ENVIROS
        DO 0
        PATTERN PATTERN_01
        PATTERN PATTERN_05
        PATTERN PATTERN_81
        PATTERN PATTERN_09
        PATTERN PATTERN_13
        PATTERN PATTERN_13
        PATTERN PATTERN_17
        PATTERN PATTERN_17
        PATTERN PATTERN_85
        PATTERN PATTERN_81
        PATTERN PATTERN_25
        LOOP
CHAN_STOP

The lines "DO 0" and "LOOP" were inserted by me for looping forever.

I also add more sound effects by adding more elements to the _musicptr struct.

 

In C-code I use:

 

static void initlynx() {
    tgi_install(&tgi_static_stddrv);
    tgi_init();
    joy_install(&joy_static_stddrv);
    lynx_snd_init();
    CLI();
};


typedef struct {
    unsigned char *music0;
    unsigned char *music1;
    unsigned char *music2;
    unsigned char *machinegun;
    unsigned char *helicopter;
    unsigned char *explosion;
    unsigned char *enemy;
} song_t;

extern song_t musicptr;


        lynx_load((int)&TUNES_FILENR);
        lynx_snd_pause();
        lynx_snd_play(0, musicptr.music0);
        lynx_snd_play(1, musicptr.music1);
        lynx_snd_play(2, musicptr.music2);
        lynx_snd_continue();

The chipper use timer7 at 240 Hz.
 

And you only have 4 channels (0..3) so use them wisely.

 

You can interrupt the previous sound with a new sound like:

lynx_snd_play(3, musicptr.helicopter);

lynx_snd_play(3, musicptr.explosion);

The helicopter sound is cut out into an explosion.

I have some examples of sounds from Flappy bird testing at https://whitelynx.fi/sounds/

  • Thanks 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...