6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 16, 2024 1:18 pm

All times are UTC




Post new topic Reply to topic  [ 609 posts ]  Go to page Previous  1 ... 25, 26, 27, 28, 29, 30, 31 ... 41  Next
Author Message
PostPosted: Sat Apr 06, 2013 1:36 am 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
8BIT wrote:
The BCC loop1 was correct. I somehow erased the loop1 label. It has been added back. That should fix the skewed lines...

It does correct the problem. :)
8BIT wrote:
...There are two sections with comments " dx,dy optimization." Try commenting these sections out to see if the sloppiness goes away. Cycles will increase again, but I have another possible option to fix that...

486,231 cycles with your optimizations and 15,787,440 cycels without. Everything looks good!
8BIT wrote:
Two questions about the .b core.

1) Can you do branching (bcc, bne, etc) beyond 128 bytes now?
...
2) Does the BIT command now place bit15 and bit14 in the N an V flags?
...

1) Everything that used to be 256 bytes in the 6502, is now 65536 bytes in the 65O16.x. So it follows that branches can go half this in either direction as you have pointed out, i.e. 32K.
2) I've never used the BIT command when I've programmed the 6502. These opcodes remain untested in the .b core, but it won't be difficult to put them to the test!

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Last edited by ElEctric_EyE on Sat Apr 06, 2013 2:26 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 06, 2013 1:50 am 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
BTW, I've been thinking, there should be a pixel counter for the circle routine (in software). This would then lead to a more fair speed test for the same pixel count against the line drawing routine.

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 06, 2013 4:41 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
ok, Line16.d.asm is on its way. I will make the new test optimization without BIT (the end result will be the same).

Look for it on the next hour.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 06, 2013 5:21 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
Here's line16.d.asm

The optimization is updated. There are also two other versions commented out that can be used if the stated conditions are true. I also fixed the branching to remove excess JMP instructions.

Next would be to use more accumulators inside the loops to increase speed.

Daryl

FYI, the drawing routine basically subtracts the start and end X & Y points to derive the difference between them, or slope steps (DX & DY). It uses DX & DY as an (now 16 bit) increment value to IX & IY (16 bits too). If after adding either IX or IY carry, then X1 and/or Y1 are incremented/decremented and the new point is plotted. As you can see, since DX in your example is only about 630, it takes about 100 interrations of adding 630 to IX to before it carries and the next point gets plotted. By multiplying DX and DY by 2 (left shift) until they get close to 65,535 without going over, we can reduce the # of iterrations needed to produce the carry. My first optimization shifts left until bit 15 is set in either DX or DY. That caused the degraded line as a carry happens almost every time. The latest optimization shifts DX and DY left until bit 14 is set in either. Now there will be a two or three iterrations before a carry happens. I hope this reduces the degrading while keeping the cycle counts lower.


Attachments:
Line16.d.asm [5.4 KiB]
Downloaded 56 times

_________________
Please visit my website -> https://sbc.rictor.org/


Last edited by 8BIT on Sat Apr 06, 2013 3:04 pm, edited 1 time in total.
Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 06, 2013 12:11 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
Ok, testing version 'D' without the 'BIT' optimizations. 741,374 cycles!
Testing with the 2nd BIT optimization active: 741,257 cycles.
Testing with the 1st BIT optimization active: 741,308 cycles.
They all look the same... We'll have to see if the degredation is tolerable when the lines are moving. Daryl, thanks for your hard work!


Attachments:
P1000986.JPG
P1000986.JPG [ 197.09 KiB | Viewed 980 times ]

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502
Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 06, 2013 3:06 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
Hmmm.... I will do some more research as to why the degredation occurs.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 06, 2013 10:49 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
I have to redo the tests because there are 2 places in your code where the DX/DY optimizations are made. I only was working with 1 and ignoring the other. Sorry!

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 06, 2013 11:12 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
Although it didn't change the looks of the line, cycles went down to 741140. I'm going to start optimizing from my end now. Here is the new line plot, version 'E'. I've chosen the fastest of your dx/dy optimizations and they're being utilized both times in your routine. First I'll replace the JSR for plot pixel. This is the biggest improvement.


Attachments:
Line16.e.asm [4.68 KiB]
Downloaded 59 times

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502
Top
 Profile  
Reply with quote  
PostPosted: Sun Apr 07, 2013 10:42 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
I've halted my optimizations...
This morning I plotted a circle with the lines. Replaced 2 of the lines with 1 vertical and 1 horizontal to make sure they work. They did... But the line error was more noticeable plotted against the circle. Looks like the lines were too thick up against the circle.

I decided to go back to ground zero, to when Daryl's Bresenham line routine first worked, and then double check all the additions to the line plotting code 1 step at a time and one thing is evident at first glance: There is no check for when DX=0 or DY=0 after the original.

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 08, 2013 3:54 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
ElEctric_EyE wrote:
I decided to go back to ground zero, to when Daryl's Bresenham line routine first worked, and then double check all the additions to the line plotting code 1 step at a time and one thing is evident at first glance: There is no check for when DX=0 or DY=0 after the original.


Are you saying that even with the optimize sections commented out, you are getting distorted lines?

I removed the those checks for DX=0 and DY=0 as it was already being done and was redundant. if DX is 0, then its a vertical line. DY=0 is a horizontal line. Both get tested for and jump to the optimized code, therefore, testing for either inside the sloped-line code was a waste.

At CONT, I store DX and then BEQ VERT. Right above NHZ, I BEQ HORZ after calculating DY. Hope that clears that up.

I'm still scratching my head over the why the optimization results in degraded lines. I plan to dump some test code when I get time to see what's happening.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 08, 2013 11:10 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
8BIT wrote:
Are you saying that even with the optimize sections commented out, you are getting distorted lines?...

That's correct. I just now reloaded 'Line16.e.asm', commented out the DX&DY optimize code and the error is still there. I'm not exactly sure what this means, but I think it would be better for me to go backwards and compare version '.d' then '.c' etc. instead of starting from ground zero like I originally thought.

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 08, 2013 11:16 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
I must have dumped something along the way. I will also look over the old files for something wrong.

thanks

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 08, 2013 11:21 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
I went back and looked at the original pic when I first had success. I must have been so excited I didn't notice the error, so your optimizing is good to go. :D
With the circle plotted along with some diagonal lines crossing it, I can see it looks like for every single horizontal pixel that should be plotted, it is plotting 2, side by side.

EDIT: The error is nothing like I was experiencing here, just double wide horizontal:

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 08, 2013 11:44 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
8BIT wrote:
I must have dumped something along the way. I will also look over the old files for something wrong.

thanks

Daryl

No, don't spend your time yet. I will go to ISim now and resolve this, now I'm thinking it's an optical illusion or something.

Here's a pic of what I'm seeing though:


Attachments:
P1000988.JPG
P1000988.JPG [ 385.65 KiB | Viewed 810 times ]

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502
Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 09, 2013 12:23 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
This pic more clearly shows the problem I'm having.
The coordinates of the line on the left is (0,0) to (100,101). The other is (10,0) to (110,100). Is this the correct action of your algorithm?

EDIT: I should've pointed out that this is the version 'E' with the DX&DY optimizations commented out.
Interesting, I just uncommented the optimizations. The second pic is the 1 optimization that was fastest. Same result with the other 2 optimizations.


Attachments:
P1000990.JPG
P1000990.JPG [ 168.55 KiB | Viewed 786 times ]
P1000991.JPG
P1000991.JPG [ 168.59 KiB | Viewed 786 times ]

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 609 posts ]  Go to page Previous  1 ... 25, 26, 27, 28, 29, 30, 31 ... 41  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: