3D graphics: Linear Algebra in neslib.h
Moderator: Moderators
-
- Posts: 6
- Joined: Fri Jun 04, 2021 4:40 am
3D graphics: Linear Algebra in neslib.h
Hi people! Nice to meet you all!
I want to program some 3D graphics on my NES. Is there any matrix operators or linear algebra functionality in neslib? Or do you know if anyone has already made a library for this?
Could I just use a seperate 3D specific C library together with neslib as long as I only use 8-bit datatypes?
I am new to neslib. I appreciate any help on this topic.
I want to program some 3D graphics on my NES. Is there any matrix operators or linear algebra functionality in neslib? Or do you know if anyone has already made a library for this?
Could I just use a seperate 3D specific C library together with neslib as long as I only use 8-bit datatypes?
I am new to neslib. I appreciate any help on this topic.
Re: 3D graphics: Linear Algebra in neslib.h
No, there's no preexisting linear algebra there. You'll have to implement it yourself, I fear.
-
- Posts: 6
- Joined: Fri Jun 04, 2021 4:40 am
Re: 3D graphics: Linear Algebra in neslib.h
Could I import a linear algebra library and use functions from it? Or am I restricted to the functions in neslib if I want to compile for NES?
Re: 3D graphics: Linear Algebra in neslib.h
You can try to use any C library. They may or may not compile with cc65. What your real problem will be is having it fast enough.
Re: 3D graphics: Linear Algebra in neslib.h
If you you're worried about the performance of 3D code on the NES at all, you'll probably have to write everything from scratch. If you do everything "by the book", using standard formulas, you can pretty much give up on any chance of getting a decent frame rate. To get anything remotely fluid on the NES you're gonna need look-up tables, approximations, interpolations, and whatever other tricks you can think of.
-
- Posts: 6
- Joined: Fri Jun 04, 2021 4:40 am
Re: 3D graphics: Linear Algebra in neslib.h
I am not gonna worry about performance on my first try, I just want to try to implement it. I will probably want to look into raising performance afterwards though. I have to see much time I want to commit to this
I see the code for Elite is published on the web, with notes and comments. I think its written in assembly though, but it will probably teach me a thing or two.
I see the code for Elite is published on the web, with notes and comments. I think its written in assembly though, but it will probably teach me a thing or two.
Re: 3D graphics: Linear Algebra in neslib.h
For as-close-as-can-be to a ready-made library, you might want to check out this very old article in C= Hacking:marius4560 wrote: ↑Sun Jun 06, 2021 4:30 am I am not gonna worry about performance on my first try, I just want to try to implement it. I will probably want to look into raising performance afterwards though. I have to see much time I want to commit to this
I see the code for Elite is published on the web, with notes and comments. I think its written in assembly though, but it will probably teach me a thing or two.
http://www.ffd2.com/fridge/chacking/c=hacking18.txt
You'd probably have to rewrite parts of the code to work on NES, and figure out how to make it work with your C code. All part of the fun though
IIRC correctly the articles (or those in previous editions) also cover a lot of the groundwork of efficient 3d math on the 6502, such as the trick of a table-of-squares for fast multiplications.
- Controllerhead
- Posts: 314
- Joined: Tue Nov 13, 2018 4:58 am
- Location: $4016
- Contact:
Re: 3D graphics: Linear Algebra in neslib.h
I've only seen the BBC Micro version published; the NES code would probably be very different. It's also PAL only as there is more time in vBlank.marius4560 wrote: ↑Sun Jun 06, 2021 4:30 am I see the code for Elite is published on the web, with notes and comments. I think its written in assembly though, but it will probably teach me a thing or two.
-
- Posts: 6
- Joined: Fri Jun 04, 2021 4:40 am
Re: 3D graphics: Linear Algebra in neslib.h
Oh that is perfect thanks!
For as-close-as-can-be to a ready-made library, you might want to check out this very old article in C= Hacking:
http://www.ffd2.com/fridge/chacking/c=hacking18.txt
You'd probably have to rewrite parts of the code to work on NES, and figure out how to make it work with your C code. All part of the fun though
IIRC correctly the articles (or those in previous editions) also cover a lot of the groundwork of efficient 3d math on the 6502, such as the trick of a table-of-squares for fast multiplications.
-
- Posts: 6
- Joined: Fri Jun 04, 2021 4:40 am
Re: 3D graphics: Linear Algebra in neslib.h
Yes but its the same proccessor, figured I might learn something from itI've only seen the BBC Micro version published; the NES code would probably be very different. It's also PAL only as there is more time in vBlank.
- Controllerhead
- Posts: 314
- Joined: Tue Nov 13, 2018 4:58 am
- Location: $4016
- Contact:
Re: 3D graphics: Linear Algebra in neslib.h
I'm sure you absolutely can! Keep in mind though that retro console / computer code is very tied to the hardware it runs on; unlike modern code which is much more platform agnostic.marius4560 wrote: ↑Tue Jun 08, 2021 1:36 am Yes but its the same proccessor, figured I might learn something from it
-
- Posts: 6
- Joined: Fri Jun 04, 2021 4:40 am
Re: 3D graphics: Linear Algebra in neslib.h
Especially the graphics chip I suspect. Do you know anything about drawing lines from point to point instead of using sprites on the NES?I'm sure you absolutely can! Keep in mind though that retro console / computer code is very tied to the hardware it runs on; unlike modern code which is much more platform agnostic.
-
- Posts: 1565
- Joined: Tue Feb 07, 2017 2:03 am
Re: 3D graphics: Linear Algebra in neslib.h
the NES doesn't have a bitmap mode, so you have choose where you want a line, allocated tiles, plot the line in the tiles, and then put the tiles on the screen.
If a tile already exists at the position then you add the line to the existing tile.
The NES is really a bad machine to learn to do this on.
If a tile already exists at the position then you add the line to the existing tile.
The NES is really a bad machine to learn to do this on.