Any 6809 tips for 3D
category: general [glöplog]
Its seems to me the 6809 was much less used in computers, of course there is the coco/dragon and a few japanese machines. The Vectrex too, which is what I have been messing with :)
I'm wondering if anyone has any ideas on how the cpu can be best used, I'm thinking mainly that it has some 16bit functionality and a hardware unsigned MUL. But how could this be used to get some 3D maybe combine the MUL with the use of tables?
I'm wondering if anyone has any ideas on how the cpu can be best used, I'm thinking mainly that it has some 16bit functionality and a hardware unsigned MUL. But how could this be used to get some 3D maybe combine the MUL with the use of tables?
Don't forget the French Thomson machines!
In particular, 3D on 6809 makes me think of http://dcmoto.free.fr/programmes/anima-3d/index.html for which the source is available: http://pulkomandy.tk/projects/thomson/browser/Thomson/code/3rdparty/sources2-hcl/ANIMA3D.ASM
In particular, 3D on 6809 makes me think of http://dcmoto.free.fr/programmes/anima-3d/index.html for which the source is available: http://pulkomandy.tk/projects/thomson/browser/Thomson/code/3rdparty/sources2-hcl/ANIMA3D.ASM
wanting to do the exact same thing so watching for tips
mikiex, did you see this?
@Fell I did see that a while ago , I did find the doc a bit confusing to what he was doing.
It doesn't look quite what I am looking for, I have an idea to make a 3d engine that only has rotation in one axis and has perspective + clipping.
It doesn't look quite what I am looking for, I have an idea to make a 3d engine that only has rotation in one axis and has perspective + clipping.
@PulkoMandy looks interesting, maybe there is more Thomson stuff... I have seen a couple of good raycasters around also...
Roids has a couple of tricks:
http://www.6809.org.uk/dragon/demo/
http://www.6809.org.uk/dragon/demo/
Interesting topic, I've been thinking about this myself!
If I've read the specifications correctly, the MUL instruction is 11 cycles, which I guess faster than any of the methods commonly used on 8-bit CPUs which lack multiplication, meaning that the 6809 should be able to do 3D rotations way faster than comparable systems.
However, I don't know if the fact that the MUL is only working on signed values could become a problem? Normally for 3D rotations you work with signed values, so I would guess you would have to compensate for this somehow.
If I've read the specifications correctly, the MUL instruction is 11 cycles, which I guess faster than any of the methods commonly used on 8-bit CPUs which lack multiplication, meaning that the 6809 should be able to do 3D rotations way faster than comparable systems.
However, I don't know if the fact that the MUL is only working on signed values could become a problem? Normally for 3D rotations you work with signed values, so I would guess you would have to compensate for this somehow.
Sdw: i guess your first "signed" should have read "unsigned" -> shouldn´t this be workaroundable via some negativeFlag? Oh, wait, extra-stores&reads...i see.
Isn't signed and unsigned multiplication fully equivalent bit-wise, assuming you don't care about overflow?
yep... and if you use an unsigned sin table in your ROM, happy days, very little of yer standard transform/project method actually needs to change.
to ebay I go, vectrex bidding like a pro
I thought the unsigned MUL does work as signed... but then I have not fully tested that.
But then I have seen a 6809 routine (A) signed 8bit * (B) unsigned 8bit = signed 16bit
If A is positive it just MUL
If A is negative it made A positive, then MUL, then make the result negative.
But then I have seen a 6809 routine (A) signed 8bit * (B) unsigned 8bit = signed 16bit
If A is positive it just MUL
If A is negative it made A positive, then MUL, then make the result negative.
Also would it be better to use Log tables, I've not looked into them enough and not seen enough examples of use to understand exactly how they are used:
6502 example : http://codebase64.org/doku.php?id=base:8bit_logarithm_table_generator_routine
6502 example : http://codebase64.org/doku.php?id=base:8bit_logarithm_table_generator_routine
Lets narrow this down, how to do the fastest 3d projection on the 6809 ??
Aww yissss, this will be a fun thread I can tell :) Hopefully I'll have some code to share soon, am supposed to be working on... other things ;)
first off. an simple 3d to 2d-projection formula looks like this:
(where x' and y' are screen coordinates, while x,y and z are object or world-coords)
scale is the field of view and can be found by:
i suppose you could narrow it down to log-table lookup. maybe you dont even need the scale(?) or you could just use one pow2 number for that in case of bit-shifting.
(where x' and y' are screen coordinates, while x,y and z are object or world-coords)
Code:
x' = scalex * x / z
y' = scaley * y / z
scale is the field of view and can be found by:
Code:
scalex = xres / tan(xang / 2)
scaley = yres / tan(yang / 2)
i suppose you could narrow it down to log-table lookup. maybe you dont even need the scale(?) or you could just use one pow2 number for that in case of bit-shifting.
Hardy: Yes, exactly the 6809 mul is specified as working on *unisgned* values, not signed, that was a typo by me.
FreeFull: Having done some tests, it seems like it actually is exactly equivalent, yeah!
I hadn't even thought that it might be so, since the datasheet specifically stated "unsigned multiplication", I assumed there would be a difference compared to signed!
Then it should be possible to do at least the rotation part of the 3D stuff quickly.
The projection is a bit worse since we have a division there, perhaps a workaround could be done with a table of (1/z) values and then doing:
x'=x*zinvtab[z]
y'=y*zinvtab[z]
FreeFull: Having done some tests, it seems like it actually is exactly equivalent, yeah!
I hadn't even thought that it might be so, since the datasheet specifically stated "unsigned multiplication", I assumed there would be a difference compared to signed!
Then it should be possible to do at least the rotation part of the 3D stuff quickly.
The projection is a bit worse since we have a division there, perhaps a workaround could be done with a table of (1/z) values and then doing:
x'=x*zinvtab[z]
y'=y*zinvtab[z]
Sdw
You mean similar to this:
http://codebase64.org/doku.php?id=magazines:chacking8
search for "Implementation: Projections" on that page
You mean similar to this:
http://codebase64.org/doku.php?id=magazines:chacking8
search for "Implementation: Projections" on that page
You want 6809 tips for 3D? That's a very specific number of tips that you want ;-)
the question is very unspecific. on 8bit you usually taylor your whole approach towards of what you want to achieve, a generic approach is too slow.
but codebase64, and especially Steve Judd's genious 3d articles in C= Hacking will give you excellent tips on how to solve all the problems.
but codebase64, and especially Steve Judd's genious 3d articles in C= Hacking will give you excellent tips on how to solve all the problems.