Homebrew [WIP] 3DeSmume (DS emulator for 3DS)

DarkRioru

reach for the stars
Member
Joined
Aug 29, 2015
Messages
2,114
Trophies
0
Age
26
Location
looking up at the stars
Website
steamcommunity.com
XP
1,882
Country
United States
You should let users customize visuals, that would be interesting.

--------------------- MERGED ---------------------------


Nonononono, I wasn't calling you a noob, I was just adding on to someones statement, sorry if i offended you :(
I know that, I was being called a noob yesterday because I wanted the legend of zelda symphony ds homebrew app on my 3ds menu but couldn't because of no way of using ds homebrew, I was trying to state that others were wrong about ds homebrew not being a thing... now that it is, me and other people can rest easy at night knowing that this is now a thing being birthed out of the cartrage slot and into the world of 3ds homebrew :) hope ds homebrew can work with 3Desmume
 

itsthenavy

Well-Known Member
Member
Joined
Sep 3, 2015
Messages
102
Trophies
0
Age
31
XP
175
Country
United States
Don't take a screenshot, dump the memory to a file
Gotta agree with this. You can compare your expected value with what you get, then fix based on the differences you see.

Something seems a bit off about your bit shifting operations. Are you not losing a bit off of red with that shift left?
 

Perska

Active Member
Newcomer
Joined
Aug 22, 2015
Messages
34
Trophies
0
XP
112
Country
Finland
Ok, so here's what I'm currently doing:

Code:
unsigned int ARGB1555toARGB8888(unsigned short c)
{
    const unsigned int r = c&0x8000, g = c&0x7C00, b = c&0x03E0, a = c&0x1F;
    const unsigned int rgb = (r << 12) | (g << 9) | (b << 6);
    return ((rgb >> 5) | (a*0x1FE00) & 0x070707);
}

Any ideas? It definitely produces a more clear picture, but there is a lot of blue.
Found this from Stack Overflow, maybe it'll help?
http://stackoverflow.com/questions/6194449/converting-bitmap-from-argb1555-to-rgb8888
That's in C++, but I'm pretty sure it should work with regular C.
 

shutterbug2000

Cubic NINJHAX!
OP
Member
Joined
Oct 11, 2014
Messages
1,088
Trophies
0
Age
29
XP
4,878
Country
United States

itsthenavy

Well-Known Member
Member
Joined
Sep 3, 2015
Messages
102
Trophies
0
Age
31
XP
175
Country
United States
Gotta agree with this. You can compare your expected value with what you get, then fix based on the differences you see.

Something seems a bit off about your bit shifting operations. Are you not losing a bit off of red with that shift left?
Actually while I'm at it your bit masking seems way off. c&0x8000 would get you only the leftmost bit, wouldn't it? That's the alpha bit, not the 5 red bits. I can't compile right now otherwise I'd check.
 

DarkRioru

reach for the stars
Member
Joined
Aug 29, 2015
Messages
2,114
Trophies
0
Age
26
Location
looking up at the stars
Website
steamcommunity.com
XP
1,882
Country
United States
For those asking about DLDI:

The lack of a working dldi for the 3DS/DSi sd card was one of the main reasons I began work on this.
So yes, eventually there will be dldi.
yes thank you!!! you are an emulation god!!!! first windows 95 then dos and now this? you are on a roll!!!
 

UraKn0x

Official senpai
Member
Joined
Mar 20, 2014
Messages
370
Trophies
0
XP
735
Country
France
Ok, so that function gives me a hex color code of 0xffffff. Yet it draws blue? Wha?
Have you considered just changing the endianess of the color you get? Try this
C:
#define changeEndianess16(x) (((x & 0x8000) >> 15) | ((x & 0x4000) >> 13) | ((x & 0x2000) >> 11) | ((x & 0x1000) >> 9) | ((x & 0x0800) >> 7) | ((x & 0x0400) >> 5) | ((x & 0x0200) >> 3) | ((x & 0x0100) >> 1) | ((x & 0x80) << 1) | ((x & 0x40) << 3) | ((x & 0x20) << 5) | ((x & 0x10) << 7) | ((x & 0x08) << 9) | ((x & 0x04) << 11) | ((x & 0x02) << 13) | ((x & 0x01) << 15))
I haven't tried this code but I don't see any reason it wouldn't work
 
Last edited by UraKn0x,

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,491
Country
United States
Ok, so here's what I'm currently doing:

Code:
unsigned int ARGB1555toARGB8888(unsigned short c)
{
    const unsigned int r = c&0x8000, g = c&0x7C00, b = c&0x03E0, a = c&0x1F;
    const unsigned int rgb = (r << 12) | (g << 9) | (b << 6);
    return ((rgb >> 5) | (a*0x1FE00) & 0x070707);
}

Any ideas? It definitely produces a more clear picture, but there is a lot of blue.

Try this...

Code:
unsigned int ARGB1555toRGBA8(unsigned short c)
{
    const unsigned int a = c&0x8000, r = c&0x7C00, g = c&0x03E0, b = c&0x1F;
    const unsigned int rgb = (r << 17) | (g << 14) | (b << 11);
    return ((a * 0xFF) >> 15) | rgb | ((rgb >> 5) & 0x07070700);
}

If the source format is really ARGB, then your masking variables are incorrect. Notice how your "a" variable mask has a range of 5 bits when it's supposed to have just 1 bit. Since it's meant to be for the blue component, then that's likely why you're getting a lot of blue. Also, there is no ARGB8 format on 3DS. The alpha portion is on the opposite side, making it RGB8. So, we have to shift each RGB component to the left by 8 bits. Alpha is set to either be on or off, so we multiply by 255 (max value for 8-bit), and shift down, making the resulting value either 255 or 0. Everything else is similar to the original code you pulled from.

Be warned, I did not test this. All I did was use Win10's calculator with the Programmer setting to verify shifting of values to be correct.
 

shutterbug2000

Cubic NINJHAX!
OP
Member
Joined
Oct 11, 2014
Messages
1,088
Trophies
0
Age
29
XP
4,878
Country
United States
Try this...

Code:
unsigned int ARGB1555toRGBA8(unsigned short c)
{
    const unsigned int a = c&0x8000, r = c&0x7C00, g = c&0x03E0, b = c&0x1F;
    const unsigned int rgb = (r << 17) | (g << 14) | (b << 11);
    return ((a * 0xFF) >> 15) | rgb | ((rgb >> 5) & 0x07070700);
}

If the source format is really ARGB, then your masking variables are incorrect. Notice how your "a" variable mask has a range of 5 bits when it's supposed to have just 1 bit. Since it's meant to be for the blue component, then that's likely why you're getting a lot of blue. Also, there is no ARGB8 format on 3DS. The alpha portion is on the opposite side, making it RGB8. So, we have to shift each RGB component to the left by 8 bits. Alpha is set to either be on or off, so we multiply by 255 (max value for 8-bit), and shift down, making the resulting value either 255 or 0. Everything else is similar to the original code you pulled from.

Be warned, I did not test this. All I did was use Win10's calculator with the Programmer setting to verify shifting of values to be correct.

Close. It's wayyyyy closer then ever before, but it's like blues and oranges are being flipped on the MPDS title screen. Should I try swapping red and blue?
 

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,491
Country
United States
Close. It's wayyyyy closer then ever before, but it's like blues and oranges are being flipped on the MPDS title screen. Should I try swapping red and blue?

That's what I was thinking after posting that. It's likely the source format is not ARGB, but ABGR. Let me fiddle with my code a sec.

Try this...

Code:
unsigned int ABGR1555toRGBA8(unsigned short c)
{
    const unsigned int a = c&0x8000, b = c&0x7C00, g = c&0x03E0, r = c&0x1F;
    const unsigned int rgb = (r << 27) | (g << 14) | (b << 1);
    return ((a * 0xFF) >> 15) | rgb | ((rgb >> 5) & 0x07070700);
}

lol, if you get errors pertaining to the function name, it's because I swapped the R and B there too to match what it's doing.
 
Last edited by DiscostewSM,
  • Like
Reactions: Pandaxclone2

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Right onto uremums 3d printed dildo