Repository navigation
Conversation
| REG_VCOUNT = DISPLAY_HEIGHT + 1; // prep for being in VBlank period | ||
| } | ||
|
|
||
| static const u16 posToTex[] |
There was a problem hiding this comment.
Hey. Sorry I've not got round to looking at this (and TBH ports are not a priority for this project)
Some questions:
- Did you use AI for this?
- What is this array? Why is it needed? You are mapping gba pixels to 3ds pixels, but why do you need a precomputed array for this? (smells of AI)
- Why does this need to use SDL for sound output? You'd think you could just output audio directly.
There was a problem hiding this comment.
Hello, apologies for the poor quality of the port.
- I did not use any AI for this. I was very tempted to for the banner logos to make imagemagick scripts to convert the ones in the graphic folders but it is not allowed.
- The 3DS stores its textures in a way that requires all textures to be swizzled, and they are not in a simple 1d array. I got the original algorithm for this from here. The array maps pixels so they can be viewed properly on the 3DS. It was originally a function, but I precomputed it into a table with a small separate program to try and improve performance, as the performance was 5-25 fps. I think it had a minimal effect, but when I saw the precomputed table, I realised that the swizzled texture kept pixels together in pairs, so I could map pixels and copy them to the texture in pairs also, which was what ultimately improved performance the most. I can see if there is any noticeable change in performance, and rework the port to reuse the function instead of the precomputed table.
- I cannot lie, it was just because I was extremely lazy and did not want to touch 3DS audio, because I haven't learnt it(I normally use SDL for audio in my 3DS projects). I can try to learn it, and implement it directly.
I cannot upload the program I made to precompute it so I will just paste it here.
#include <iostream>
static size_t posToTex(size_t index)
{
const int width = 512;
const int x = index % 400;
const int y = index / 400;
// printf("%i , %i \n", x, y);
return ((((y >> 3) * (width >> 3) + (x >> 3)) << 6)
+ ((x & 1) | ((y & 1) << 1) | ((x & 2) << 1) | ((y & 2) << 2) | ((x & 4) << 2) | ((y & 4) << 3)));
}
int main(){
for(int i = 0; i < 400*240; i++) {
if(i % 2 == 0)
std::cout << posToTex(i)/2 << ", ";
if(i % 16 == 0) std::cout << "\n";
}
}
There was a problem hiding this comment.
Thanks for the info. You could just pre-compute this table at start-up if it does have a performance improvement. Having a static array compiled like this is just way to long to keep in source.
There was a problem hiding this comment.
I just updated it to be computed at start-up. I didn't see any noticeable change in performance, but I measured the speed of the table and the speed of the function using the 3DS' built-in tick counter, and the table was faster by roughly 350 microseconds.
3DS Port using citro2d for video, and SDL2 for audio. idk if I was supposed put my name in the credits so I didn't do it.
stage_results.c