6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 15, 2024 5:49 am

All times are UTC




Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Mon Apr 02, 2012 1:33 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
I've been thinking for a while, what would it take to build a small 3d graphic board that would be easy to use(interface) and not too complicated(or complex). As for the hardware, if it is going to be old school, maybe a 68020 might do the job(or the 65816), but i think maybe the atmega1284 might be a better solution(the hardware should be able to quickly calculate trigonometric and other mathematical functions)... As for the software, i think it should be written in C, so it can be ported to other hardware... Now i am not sure how it would generate hi resolution video signal, the best thing that i managed to get working is the mc6847, but i suppose that the TMS9918 would not be too difficult to interface(also smaller resolution means better 3d performance)...

I was unable to find anything similar on Google, any comments, suggestions, or if someone wants to accept the challenge, that would be also great.

Anyway it would be cool to see a 6502 based computer to run some sort of 3d software...


Last edited by Dajgoro on Wed Nov 07, 2012 10:35 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 02, 2012 4:22 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Maybe an FPGA based solution would work. That way you can combine 3D with the actual video generator. Even a cheap Spartan-6 like we're using for the 65org16 project has 16 DSP units consisting of a multiplier and an accumulator. These would be well suited to running matrix operations at a very nice speed.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 02, 2012 4:26 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
That sounds good, but i don't have proper means for dealing with fpga(unless somebody is willing to do this)...
And how could a C compiler work with 65org16 core?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 02, 2012 5:18 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
No, there's no C compiler for the 65org16, and I don't think there will ever be one.

But, it seems to me that any board capable of producing 3D graphics, with a CPU suitable as a compiler target would be perfectly fine running on its own. Why would you even bother attaching it to a 6502 computer ?

With the FPGA idea I was more thinking along the lines of a video generator with some sort of 3D support built into it. Of course, the problem is that 3D graphics is fairly complex, especially if you want to do any kind of high end stuff. If you try to keep it as simple as possible, for instance some sort of accelerator that will take care of drawing Elite-like graphics, with a 6502 just providing the coordinates, it would get into the range where an amateur could do it (although for someone new to FPGA, I would not recommend it as a first project :)

By the way, FPGA development is well within reach of any interested amateur. I taught myself how to do it with a $100 Spartan 3 board I ordered from the Xilinx web shop, including a manual, CD with software, and a cheap parallel port programming cable. I think the prices have gone up a little, and you'll probably want a USB cable now, but it is still quite affordable.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 02, 2012 6:17 pm 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
Somewhere, there has to be an open source 65816 or 65C02 compiler, some rewriting of the outputs would be in order here?

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 02, 2012 6:44 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10977
Location: England
Arlet wrote:
No, there's no C compiler for the 65org16, and I don't think there will ever be one.

Actually, Dr Jefyll found a possible lead some time ago:
Re-targeting a C compiler (eg: for 65Org16)
(but this point is a bit off-topic here...)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 02, 2012 11:54 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
A C compiler for the 65org16 would be a great thing.
As for the 3d adventure, the 3d board might be used with Arduino and other mcu boards...
I once managed to make a simple 3d render code in QBasic, it can display dots(with a few tweaks it could display lines(meshes)), but this board should do much more. The first model(if ever made) should be able to display custom meshes, colored objects, maybe some primitive textures, and no particle effects. It should be also able to move objects and a simple collision detector would be great.
I was thinking about the atmega1284 with the 8087 fpu(available cheaply on ebay), the code would be made so that the fpu might be easily exchanged with something better... I didn't study the 8087 datasheets yet, but it sounds promising. Also i do have some books about 3d in general... As for video generation, i still don't have a simple, but powerful enough solution. Maybe a cpld-fpga upgraded version of the mc6847 CRTC would do the job. But the idea is also to keep the cost low, so other people can reproduce(or buy) this board cheaply.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 03, 2012 3:11 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Did anyone experiment with avr trigonometric calculations, or with the 8087?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 03, 2012 5:48 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Anyway, i was looking around, and it seems that the atmega1284 is not easy to find, and also my universal programmer doesn't support it!
So i was wondering what would be a good and cheap alternative to the atmega1284, maybe a cpu(65C816, or 8088???). The question is also valid if someone wants to make an embedded device that has to do lots of math in trough hole technology.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 03, 2012 6:11 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
Dajgoro wrote:
Did anyone experiment with avr trigonometric calculations, or with the 8087?

I have not, but I've been doing trig and log functions in 16-bit fixed-point/scaled-integer on the 6502 which is much more efficient than having the computer handle the overhead of floating-point, and I also have made Intel Hex files for programming large EPROMs with look-up tables for these functions so you quickly get every bit correct without calculating. I plan to put them on my website. [Edit, June 2012: Done, posted at http://WilsonMinesCo.com/16bitMathTables/index.html .] I'm working on another article at the moment though, one that I started many years ago and then left to collect dust, unfinished. In scaled-integer, representing the 360° circle as $1:0000 (ie 65,536), you get .0055° resolution, or around 21 arc-seconds. It works out nicely because for example 359° +1° is still 0°, and 45°-90° is still 315° or -45°, the sine of 0° is the same as the sine of 360° or of 720°, etc..

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 09, 2012 12:11 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
What about an atmega16, with external ram, and 192x256, 8 bit colors?
I am not sure how the framebuffer would get updated without disrupting the picture(without using 2 ram modules)?

Edit: My question is how do i make a functioning composite video generator circuit that has the required properties(or where do i get one)?


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 13, 2012 3:00 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
I will try to go with this project, but first i am going to write the program in C and test it in my pc, i am still working on a reliable video display emulator, here is the code, written in Visual Studio 2010, Visual C++:
Code:
// CGA.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "CGA.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// The one and only application object

CWinApp theApp;

using namespace std;
void OnDraw(CDC* pDC);
char frameBuffer[192][256]={0};
int c=100;

void GdiOut(HDC hdc)//this function is not boilerplate
{
 HPEN hPen, hPenOld;
 HBRUSH hBrush, hBrushOld;
 char luma;
 for(int x=0;x<256;x++)
    for(int y=0;y<128;y++)
    {
       //Initial colors
       luma=(frameBuffer[y][x]&192)/4/4/2;
       BYTE bRed = (frameBuffer[y][x]&3)*16*luma;
       BYTE bGreen = (frameBuffer[y][x]&12)*4*luma;
       BYTE bBlue = (frameBuffer[y][x]&48)*luma;//needs some adjusments

       //Pen color
       COLORREF cPen = RGB(bRed, bGreen, bBlue);
       COLORREF cBrush = RGB(233,GetGValue(cPen), 255);
       hPen = CreatePen(PS_SOLID, 0, cPen);
       hBrush = CreateSolidBrush(cBrush);
       hPenOld = (HPEN)SelectObject(hdc, hPen);
       hBrushOld = (HBRUSH)SelectObject(hdc, hBrush);

       Rectangle(hdc, (x*2)+c, (y*2)+c, (x*2)+2+c, (y*2)+2+c);
 
       DeleteObject(hPen);
       SelectObject(hdc, hBrushOld);
       DeleteObject(hBrush);
    }
}
void drawScreen(){//this function is not boilerplate

    HDC screenDC = ::GetDC(NULL);
   HDC hdc = GetDC(NULL);
   GdiOut(hdc);

}



int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{

   int nRetCode = 0;

   HMODULE hModule = ::GetModuleHandle(NULL);

   if (hModule != NULL)
   {
      // initialize MFC and print and error on failure
      if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
      {
         // TODO: change error code to suit your needs
         _tprintf(_T("Fatal Error: MFC initialization failed\n"));
         nRetCode = 1;
      }
      else//----------------------------------------------------------------- the code above is boilerplate code
      {// int main() {
         int px,py,in;
         float points[100][4]={
            {1,-10,10,110},
            {1,0,10,110},
            {1,10,10,110},
            {11,10,10,110},
            {25,5,10,210},
            {25,10,10,210},
            {30,5,10,210},
            {30,10,10,210},
            {35,-10,10,200},
            {35,0,10,200},
            {35,10,10,200},
            {45,10,10,200},
            {-30,-11,25,189},
            {-30,-15,30,157},
            {-30,-20,25,140},
            {-30,-25,40,155},
            {-30,-30,45,179}
         };
         int numz=20;
         printf("Pomak u z? (npr 2)");
         do
         {
            for(int j=0;j<192;j++)
               for(int i=0;i<256;i++)
                  frameBuffer[j][i]=0;//moco
         
            for(int n=0;n<numz;n++)
            {
               px = int((points[n][0] / points[n][2] * 20.0) + 128);
               py = int((points[n][1] / points[n][2] * 20.0) + 96);
               //printf("%f %f %f %f %d %d\n",points[n][0],points[n][1],points[n][2],points[n][3],px,py);
               if(px > 0 && px < 256)
                  if(py > 0 && py < 192)
                     frameBuffer[py][px]=points[n][3];
            
            }
         
            drawScreen();
            scanf("%d",&in);
            for(int n=0;n<numz;n++)
               points[n][2]+=in;
         }while(in);
         //system("echo off");
         //system("pause>nul");
      }// return 0; }
   }//-------------------------------------------------------------------------------- the code below is boilerplate code (with exceptions)
   else
   {
      // TODO: change error code to suit your needs
      _tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
      nRetCode = 1;
   }

   return nRetCode;
}

This is the main file, CGA the name does not mean Color Graphic Adapter, it something else that i already forgot what it meant...

This example emulates the screen, and renders some points in a LOL formation, you may zoom in and out.

Does anybody know a better solution for generating color graphics in C/C++?

As for the hardware, i am still undecided how would it work, it is maybe best if it would consist of two mcu-s, one for loading, managing, and controlling(moving rotating, ect...) objects, and one for rendering objects. They would be connected trough a common ram, but i would prefer a solution where there is a big bus, controlled by a cpld/fpga, and any mcu may access to the common ram, framebuffer, and to the 8087. But i still have no idea how to wire this up, without creating a queue when the devices are accessing different hardware components(example: one mcu access the common ram, the other the framebuffer).


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 14, 2012 9:15 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
For start, maybe is best to go with the TMC9918, or maybe some better video ic?
Also in the datasheet of the tms, there is an interesting feature:
-Unique planar representation for 3D simulation
And i am not really sure what this does...


Top
 Profile  
Reply with quote  
PostPosted: Sun Apr 15, 2012 3:50 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
I hope i get Arlet's founding to work(from the CRTC core topic). I could build the module using lots of components, just to get the prototype(i mean the entire 3d system) working, after that, it could be integrated as a soft core, since the software is written in C, the cpu that processes 3d can be replaced.
Has anyone tested the code i gave before, since it works fine on my computer, but works terribly on my roommates laptop. I am hoping to find a solution that would work on Windows and Linux at the same time...


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 24, 2012 3:30 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
I've found all the necessary components on ebay, but i am not sure if i should buy them yet, at the end this projects gets kinda expensive. Also is there anyone who would volunteer to take over this project, if i should get too busy with other things(faculty), of course i would yhip you the components and hardware?

ebay component list:
Code:
1pcs HM628128LP-7 DIP-32 CMOS StaticUS US $5.00 + Shipping US $1.50

5x PLCC IC Socket Straight solder dip 84 pins  US $2.09 + Shipping US $3.10

MC68882FN40A Manu:MOT Encapsulation:PLCC-68  US $6.00 + Shipping US $4.00

PLCC68 PLCC 68-pin Socket BROWN Standard thru-hole US $1.09 + Shipping US $2.99

1pc XC9572PC84 IC XC9572 XILINX US $13.29

1pcs ATMEGA32A-PU MCU 32K FLASH 16MHZ 40-PDIP ATMEGA32 US $9.96 2x

IC CXA1645P SONY DIP-24 US $1.95

//NOS Xilinx XC95108-15PC84C XC95108 CPLD 108 MACROCELL PLCC84 x 1PC US $15.99
//I bought this item, since is rare on ebay, and it might be used for other projects as well...

Subtotal (9 items):   US $55.37
Shipping to 52210:   US $11.59

Total:   US $66.96


I found the MC68882, and it is cheaper than the 8087, and of course more powerful.

Edit: The system would consist of two AtMega32, one XC9572(for connecting the two mcu, ram and fpu), MC68882 shared fpu, some ram, and the XC95108 based video generator. The mcu and fpu should run on a common 16MHz clock...


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 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: