Pi-Tube Atom VDU: circles

discussion of games, software, hardware & emulators relating to the Acorn Atom
User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Pi-Tube Atom VDU: circles

Postby roland » Wed Mar 29, 2017 9:28 pm

I have been playing to draw circles with the Pi-Tube. I added the Bresenham algorithm to the framebuffer.c file:

Code: Select all

void fb_draw_circle(int xc, int yc, int r, unsigned int colour) {
   int x=0;
   int y=r;
   int p=3-(2*r);

   fb_putpixel(xc+x,yc-y,colour);

   for(x=0;x<=y;x++)
   {
       if (p<0)
           {
           p+=4*x+6;
           }
       else
           {
           y--;
           p+=4*(x-y)+10;
           }

      fb_putpixel(xc+x,yc-y,colour);
      fb_putpixel(xc-x,yc-y,colour);
      fb_putpixel(xc+x,yc+y,colour);
      fb_putpixel(xc-x,yc+y,colour);
      fb_putpixel(xc+y,yc-x,colour);
      fb_putpixel(xc-y,yc-x,colour);
      fb_putpixel(xc+y,yc+x,colour);
      fb_putpixel(xc-y,yc+x,colour);
    }
}


and I assigned PLOT modes 88 to 95 for drawing a circle:

Code: Select all

            } else if (g_mode >= 88 && g_mode < 96) {
               // Draw a circle
               fb_draw_circle(g_x_pos_last1, g_y_pos_last1, g_x_pos, col);
            }


Which means I have to move to the origin of the circle and then PLOT 93,R,R where R is the radius (only the x-coordinate is used, the y is ignored).

When I run a small test program to draw 16 circles I get this result:

IMG_1833.JPG


I can't figure out why the distance between the circles is not linear. Any clues?
Attachments
framebuffer.txt
(23.94 KiB) Downloaded 25 times
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
ctr
Posts: 94
Joined: Wed Jul 16, 2014 2:53 pm

Re: Pi-Tube Atom VDU: cirles

Postby ctr » Thu Mar 30, 2017 12:23 am

I'm not sure exactly what you're running this on, and this is a bit of a stretch, but I think you might have a problem with bit 5 (value 32) in a connector somewhere.

The intended radii of the circles in hex:

Good: 14,28,3C,50,8C,C8,DC,104,118,12C
Bad: 64,78,B4,F0

The bad ones are drawn at:
Bad':44,58,94,D0

Note that the radius of each bad circle has bit 5 set, and it is drawn at the radius with bit 5 clear. Some of the good circles also have bit 5 set in the radius, so the problem appears to be intermittent. Of course, I'm getting this from the picture so I can't be sure the bad radii are exactly right, but it's all a pretty good fit.

User avatar
jgharston
Posts: 2756
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: Pi-Tube Atom VDU: cirles

Postby jgharston » Thu Mar 30, 2017 9:00 am

roland wrote:and I assigned PLOT modes 88 to 95 for drawing a circle:

No! You can't just "assign" plot numbers. 88-95 are "Fill to background". Circles are 144-183. wiki, link.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Pi-Tube Atom VDU: cirles

Postby roland » Thu Mar 30, 2017 11:16 am

jgharston wrote:No! You can't just "assign" plot numbers.


O yes, I can. In fact, I already did :mrgreen:

I wasn't aware of your list of plot codes but I'm glad there is. I will adjust my software to match the standard plot codes. Thanks for your feedback.


I will also check the bit 5 thing but I can't imagine it's a hardware fault because the Pi Zero wouldn't execute commands from the Atom or act like a 6502 co-pro.
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
IanS
Posts: 477
Joined: Mon Aug 31, 2009 6:02 pm

Re: Pi-Tube Atom VDU: cirles

Postby IanS » Thu Mar 30, 2017 9:26 pm

roland wrote:I can't figure out why the distance between the circles is not linear. Any clues?

Do the circles get drawn in the right order, are any drawn our of sequence because a value is overflowing?

At least one will be drawn in black, so not visible. If you draw them all in the same colour, does it look any better?

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Pi-Tube Atom VDU: cirles

Postby roland » Thu Mar 30, 2017 9:37 pm

IanS wrote:At least one will be drawn in black, so not visible. If you draw them all in the same colour, does it look any better?


No, if they are all in the same colour then the picture is the same.
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
ctr
Posts: 94
Joined: Wed Jul 16, 2014 2:53 pm

Re: Pi-Tube Atom VDU: cirles

Postby ctr » Thu Mar 30, 2017 10:44 pm

roland wrote:No, if they are all in the same colour then the picture is the same.


Do you get exactly the same picture every time you draw it in colour? What happens if you plot points (PLOT69) instead of circles? Are they equally spaced?

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Pi-Tube Atom VDU: cirles

Postby roland » Fri Mar 31, 2017 11:09 am

Good point to test that. I'll try with points and lines in the next few days.
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Pi-Tube Atom VDU: cirles

Postby roland » Fri Mar 31, 2017 6:42 pm

I have made a small test program for drawing lines and that show similar faults. Those can also be related to bit 5 and perhaps also timing problems in the communication between the Atom and the Pi Zero. You can watch a low quality movie at https://youtu.be/vuL4M8_lj7Q
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
hoglet
Posts: 6604
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Pi-Tube Atom VDU: cirles

Postby hoglet » Fri Mar 31, 2017 7:21 pm

That's not good :shock:

What speed are you running the Atom at?

Does changing the clock jumper on the Atom Tube interface make any difference?

Which Pi model are you using and how fast is it being clocked?

PiTubeDirect has moved on quite a bit, but in a way that's possibly now incompatible with the work on the atom_vdu branch. Specifically, the latest PiTubeDirect takes over the GPU for and uses it for Tube emulation, which makes it much more robust. With this version, using the GPU for triangle drawing would no longer be possible. What I'm not sure about is whether we could still make use of a simple frame buffer.

As you are working on this again, I might do some experiments over the weekend with adding the frame buffer code back in to the latest version.

Dave

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Pi-Tube Atom VDU: cirles

Postby roland » Fri Mar 31, 2017 8:32 pm

I enabled the frame buffer debugging and I see this in the serial console:

Code: Select all

move 20,0      => plot 4 20 0                                                                     
draw 20,1024   => plot 5 20 1024                                                                 
move 40,0      => plot 4 40 0                                                                     
move 40,1024   => plot 5 40 1024                                                                 
move 60,0      => plot 4 60 0                                                                     
move 60,1024   => plot 5 60 1024                                                                 
move 80,0      => plot 4 80 0                                                                     
move 80,1024   => plot 5 80 1024                                                                 
move 100,0     => plot 5 68 0                                                                     
move 100,1024  => plot 4 68 1024                                                                 


100 decimal is 01100100
68 decimal is 01000100

which proves ctr's conclusion that bit 5 is faulty.

My Atom is running at 1 MHz. The Pi Zero is running at 1GHz:

Code: Select all

#uncomment to overclock the arm. 700 MHz is the default.
arm_freq=1000
core_freq=400
force_turbo=1
disable_pvt=1


Changing the clock jumper doesn't change this behaviour. I'm still using the "Bolton 2016" version of the source code, so the new features cannot cause any problems.


:idea: I added some more printf statements and I found out that in normal Atom mode bit 5 was not reset. But in BBC Basic it does. Then I saw the :idea: :idea: :idea: The VDU drives masks bit 5 to avoid the inverted characters. And that is also killing my plot statements. So now I have the find out how to disable that bit 5 mask. But that's something for another day :lol:
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
hoglet
Posts: 6604
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Pi-Tube Atom VDU: cirles

Postby hoglet » Fri Mar 31, 2017 8:44 pm

Are you running BBC Basic on the PiTubeDirect 6502 Co Pro?

If so, then possibly the issue is here:
https://github.com/hoglet67/AtomTubeHos ... .asm#L1295

If you use VGA80 on the Atom host side, then the masking gets skipped.

Dave

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Pi-Tube Atom VDU: cirles

Postby roland » Fri Mar 31, 2017 9:42 pm

Yes, I'm running BBC basic on the copro. Running in VGA80 mode requires a little mod because this vdu doesn't send all screen data to the Pi.

So I hacked the TUBE client and forced the GodilFlag always to be 0x80. That fixes the problem ... however you should have DEBUG_VDU off otherwise the Pi cannot keep up with the Atom.

IMG_1837.JPG


IMG_1838.JPG


Sorry JGH, I didn't change the plot codes yet :-
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
hoglet
Posts: 6604
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Pi-Tube Atom VDU: cirles

Postby hoglet » Fri Mar 31, 2017 9:53 pm

Great you have this working properly now.
hoglet wrote:As you are working on this again, I might do some experiments over the weekend with adding the frame buffer code back in to the latest version.

I've just hacked the "atom_vdu" frame buffer code into the latest build of PiTubeDirect, and it still works! So I would like to find a way to include this functionality in the next-but-one PiTubeDirect release (called Diamondback).

But there are a couple of things we might need to re-think:

1. Using the GPU for drawing will no longer be possible. This is because running the tube emulation is now it's full-time job. But as you have found, writing graphics primitives is fun, so this is an opportunity not a problem.

2. Using address line A3 and mapping the new VDU FIFO to &FEF8/&FEF9 is not now possible. This is because of the way the ARM core and the GPU are communicating via a 8-byte block of shared IO registers. It isn't possible to expand this to 16-bytes, because there isn't a "spare" area of IO registers this large. We can however make use of &FEF2 and &FEF4 to implement the VDU FIFO, but we need to find a way to make the two VDU FIFO status bits visible to the tube host.

Dave

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Pi-Tube Atom VDU: cirles

Postby roland » Fri Mar 31, 2017 10:34 pm

Personally I prefer the graphics over the copro for the Atom. I can attach the matchbox for copro stuff and the Pi for graphics.

So maybe we should have to versions of the Pi copro ... ?
256K + 6502 Inside
MAN WOMAN :shock:

dp11
Posts: 702
Joined: Sun Aug 12, 2012 8:47 pm

Re: Pi-Tube Atom VDU: cirles

Postby dp11 » Sat Apr 01, 2017 6:56 am

Do we actually need FIFO status bits ? The quickest the atom can send bytes is every few uS . So the pi should have plenty of cycles. This I'm assuming will go into the new tube command execute handler which ends up running at fiq level.

User avatar
hoglet
Posts: 6604
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Pi-Tube Atom VDU: cirles

Postby hoglet » Sat Apr 01, 2017 7:16 am

roland wrote:Personally I prefer the graphics over the copro for the Atom. I can attach the matchbox for copro stuff and the Pi for graphics.

So maybe we should have to versions of the Pi copro ... ?

If you are want to keep using (and building on) the version in the atom_vdu branch, that's also fine by me.

It's just this version is no longer being maintained, and is probably not going to be very reliable on the Atom at 2MHz.
dp11 wrote:Do we actually need FIFO status bits ? The quickest the atom can send bytes is every few uS . So the pi should have plenty of cycles. This I'm assuming will go into the new tube command execute handler which ends up running at fiq level.

Certain VDU commands (such as circle drawing, triangle filling) can be generated by the Atom faster than they can be executed on the Pi. Even if buffered, that buffer could eventually fill up.

To be honest, I haven't thought through how this might work in the new architecture. I certainly don't want to be doing the drawing from FIQ context, which is how it's currently working.

One option is a new "Co Pro" that does nothing but processes VDU commands.

But I do still like the idea of the VDU being in addition to the existing Co Processors, possibly by using one of the other exception contexts.

Dave

User avatar
BigEd
Posts: 1482
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: Pi-Tube Atom VDU: circles

Postby BigEd » Sun Apr 02, 2017 5:50 pm

Can we run two threads, one on each of the two GPU cores in the Pi?? Or do I misunderstand? (One thread for Tube, one for VDU.)

User avatar
hoglet
Posts: 6604
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Pi-Tube Atom VDU: circles

Postby hoglet » Sun Apr 02, 2017 6:16 pm

BigEd wrote:Can we run two threads, one on each of the two GPU cores in the Pi?? Or do I misunderstand? (One thread for Tube, one for VDU.)

I don't believe we know how to execute code on the second GPU core (if is even exists).

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Pi-Tube Atom VDU: circles

Postby roland » Sun Apr 02, 2017 6:23 pm

And I don't believe the Pi Zero has that many cores, has it?
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
hoglet
Posts: 6604
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Pi-Tube Atom VDU: circles

Postby hoglet » Sun Apr 02, 2017 7:07 pm

roland wrote:And I don't believe the Pi Zero has that many cores, has it?

Surprisingly, there is some evidence that the non-ARM processor that is part of the GPU is actually dual core on all Pi models.

If you look on this page, about half way down:
https://github.com/hermanhermitage/vide ... 5-Overview

Scalar/Vector Processor (VPU)
- Dual Core VideoCore IV® Multimedia Co-Processor


Some more "discussion" here:
https://www.element14.com/community/thr ... hread=true

This page seems to suggest it's "dual issue" rather than "dual core":
https://github.com/hermanhermitage/vide ... iderations

Dave

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Pi-Tube Atom VDU: circles

Postby roland » Sun Apr 02, 2017 7:17 pm

That' a bit too technical for me :-k I'll stick to drawing simple graphics like these:

IMG_1843.JPG


The next step will be some area filling. But first I'll read some documentation how that is exactly implemented on other Acorn systems. And the ellipse is a nice challenge too. =P~
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Pi-Tube Atom VDU: circles

Postby roland » Sat Apr 08, 2017 8:07 pm

Three new primitives:
  • Ellipse outline (axis-aligned)
  • Ellipse filled (axis-aligned)
  • Parallelogram filled

IMG_1857.JPG
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Pi-Tube Atom VDU: circles

Postby roland » Sat Apr 08, 2017 9:45 pm

And another feature: horizontal fill to right until background colour:

FullSizeRender(1).jpg


This is fun to write \:D/
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Pi-Tube Atom VDU: circles

Postby roland » Sun Apr 16, 2017 7:32 pm

Inspired by the Easter eggs that we ate today I taught my Atom and Pi to draw one:

IMG_1876.JPG


This is done with PLOT 77, horizontal line fill until none-background pixel found.
256K + 6502 Inside
MAN WOMAN :shock:


Return to “acorn atom”

Who is online

Users browsing this forum: Google [Bot] and 2 guests