my failure of pagfx+libnds

Deleted member 591971

Well-Known Member
OP
Member
Joined
Apr 10, 2022
Messages
216
Trophies
0
XP
922
alright so i was working on the pa2lib library, i wanted to get the graphics working but i am dumb enought. I documented some of this stuff into my website (https://aerglass.github.io/PAlib-technical-docs/ to be exact, there isn't a link anywhere else on the internet)

i took at look at the pagfx stuff and the PAlib source code and i got a idea on what it is doing.

first of all what i did was copying and renaming the converted stuff, and imported it directly into a NFlib proyect, This worked really well. But to be honest this is what i am not here for, I wanted backwards compatibility with PAlib proyects.

the second thing i done was taking a look to the PAlib's source code and figured out how the hell did the PA_LoadBackground function worked, After I wasted 90 hours of my life trying to understand trash code I decided to directly take a random libnds example and directly dmaCopy all of that info into the vram, what i got was corrupted graphics.

the third thing i done was stealing source code from Fewnity (yeah, https://github.com/Fewnity/T-Rex-Runner-Game-Nintendo-DS) to see how the hell did tiled backgrounds worked in libnds. I directly dmaCopyied all of that including the gfx, map and pal, of the stuff that I needed, what i got was even more corrupted graphics than it already was.

the fourth and last thing i have done was stealing also code from pa2lib's loadbg function (which is directly pulled from nds_nflib) and remade the same function by replacing the nitrofiles with the graphics stored into RAM, it gave me tons of compiling errors saying that invalid convertion const void to file, i tried stealing grit stuff into my code but that breaks compatibility + it did not work.

yeah what i am supposed to do on here? i am pretty sure that mad devkitpro devs will rant on this post because i am supporting a outdated library from 2005.
 

DanTheManMS

aka Ricochet Otter
Member
Joined
Jun 2, 2007
Messages
4,453
Trophies
1
Age
34
Location
Georgia
XP
752
Country
United States
I cannot offer any expertise or advice unfortunately, but I am in support of your project for one reason and one reason only: there was this Zelda fangame made with PALib that utilized the PAFS filesystem, built upon the GBFS (Game Boy File System) originally made by Tepples for the GBA and was thus only ever compatible with slot-2 GBA flash carts with DS compatibility.

If you can somehow resurrect https://www.gamebrew.org/wiki/New_Zelda into being compiled in a format that will work on a slot-1 DS cart, you will be my hero. Though I just realized after typing all this up, there is no sourcecode. Archive.org doesn't have a copy of Zelda.nds.sc.zip anymore. Dangit.
 
  • Like
Reactions: Flame and Takokeshi

Deleted member 591971

Well-Known Member
OP
Member
Joined
Apr 10, 2022
Messages
216
Trophies
0
XP
922
I FOUND USEFUL INFO. I was browsing in Spanish for stuff related to PAlib, mainly the Spanish PAlib's scene is way better than any other language, you got guides, documentation, games and even more stuff, this is litterall heaven for me

One guy actually tried to make this a long time ago (more than 11 year ago). If someone knows who is ShinMazingerZLib NDS then perfect, he was able to get PAGfx working on his lib.

Also i got a beauty of what, 210 PAGES! A pdf containing PAlib and 3D stuff.
 
  • Like
Reactions: lifehackerhansol

Takokeshi

Well-Known Member
Member
Joined
Mar 7, 2022
Messages
532
Trophies
0
Location
-
XP
1,046
Country
Antarctica
I cannot offer any expertise or advice unfortunately, but I am in support of your project for one reason and one reason only: there was this Zelda fangame made with PALib that utilized the PAFS filesystem, built upon the GBFS (Game Boy File System) originally made by Tepples for the GBA and was thus only ever compatible with slot-2 GBA flash carts with DS compatibility.

If you can somehow resurrect https://www.gamebrew.org/wiki/New_Zelda into being compiled in a format that will work on a slot-1 DS cart, you will be my hero. Though I just realized after typing all this up, there is no sourcecode. Archive.org doesn't have a copy of Zelda.nds.sc.zip anymore. Dangit.
Ohhh nice, finally an use for my ez4. I didn't know this game existed, it sounds like it's worth the playthrough.
 

Deleted member 591971

Well-Known Member
OP
Member
Joined
Apr 10, 2022
Messages
216
Trophies
0
XP
922
GUYS I GOT IT WORKING BY USING THE PALIB MAKEFILE.

i mean that was really painful, especially considering my libnds knowledge (dmaCopy is a good way to corrupt graphics btw)
Now i am gonna have to break my brain trying to make a makefile from scratch using some PAlib stuff, I guess

If there was a way of loading stuff from RAM and not from NITROFS in NFlib then this will be a lot easier

So this is what I learned:

PAGfx DOES NOT fully convert the graphics, PAGfx converts the graphics to C files which then are passed through a program that converts it to assembly code that can THEN be used by libnds
 
  • Like
Reactions: Flame

Deleted member 591971

Well-Known Member
OP
Member
Joined
Apr 10, 2022
Messages
216
Trophies
0
XP
922
GUYS I GOT IT WORKING BY USING THE PALIB MAKEFILE.

i mean that was really painful, especially considering my libnds knowledge (dmaCopy is a good way to corrupt graphics btw)
Now i am gonna have to break my brain trying to make a makefile from scratch using some PAlib stuff, I guess

If there was a way of loading stuff from RAM and not from NITROFS in NFlib then this will be a lot easier

So this is what I learned:

PAGfx DOES NOT fully convert the graphics, PAGfx converts the graphics to C files which then are passed through a program that converts it to assembly code that can THEN be used by libnds
does not work on modern devkitARM (i was able to get it working on PAlib's devkitARM)

it has to do something with bin2s

*cries
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,035
Country
United States
It is unlikely that dmaCopy is corrupting graphics. It is more likely that you are using it incorrectly or neglecting to consider that you need to flush the data cache with DC_FlushRange as dmaCopy bypasses the cpu data cache and reads from memory directly.
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
yeah anything ARM9 has enabled cache and with it things get corrupted if not handled this way:


ARM9: When reading data from source memory into cached destination memory (like EWRAM 0x02000000)
1) Perform the read from source memory into cached destination memory (DLDI, memory, etc)
2) Then call dc_flush_range(); on said cached destination memory

ARM9: When writing data from cached source memory (like EWRAM 0x02000000) into destination memory
1) Call dc_flush_range(); on said cached source memory
2) Then perform the write from cached source memory into destination memory (DLDI, memory, etc)
 
Last edited by Coto,

Deleted member 591971

Well-Known Member
OP
Member
Joined
Apr 10, 2022
Messages
216
Trophies
0
XP
922
Hi, sorry for no updates for a month, school has been killing me and i do not have much time.

The PA_Makefile seems about right on the newer devkitARM i'll try to fix it to make it work on modern libnds but now i do not have time, there won't be updates for a while (about for 2 weeks) so yeah.
It is unlikely that dmaCopy is corrupting graphics. It is more likely that you are using it incorrectly or neglecting to consider that you need to flush the data cache with DC_FlushRange as dmaCopy bypasses the cpu data cache and reads from memory directly.
yeah anything ARM9 has enabled cache and with it things get corrupted if not handled this way:
alright, i did a quick test, i did DC_FlushRange and the result was... Even more corrupted graphics. After all i think it has to do more with the Makefile rather than the source file because with the PA_Makefile and the older devkitARM version it worked perfectly. I tried on the same configuration but on my linux main machine and it also worked perfectly, now i have to recreate/modify the Makefile, i am going to die.
 

Deleted member 591971

Well-Known Member
OP
Member
Joined
Apr 10, 2022
Messages
216
Trophies
0
XP
922
i got it working on modern devkitARM/libnds. no joke.

i feel like a god

Edit: for those who asked how:
That was one of the dias that i think to myself: "What is I did something really stupid" its was not dangerous, i was just wasting my own time. Compiling native PAlib code on the modern devkitARM, that only includes PAlib, not EFS or ASlib.

so after thinking, i got my PAlib file, compiled it, made arround 5 changes to the source and that worked, the PA_Makefile was broken too, I wasnt able to fix it but after wasting around 3 hours of my life on trying to find the thing, i thought to myself: "Wait, this can help with PA2lib", while PA2lib uses some PAlib source, it isnt quite as useful. So I toon a look at the PA_Makefile again... just to find a enviroment variable which point to devkitARM/bin

yeah.. THATS BIN2S LOCATION

After finding the folder of the proyects (which took about 3 hours and needed some changes) i made a enviroment variable that points to devkitARM/bin, the rest was done, the rules, everything else i made it before

That was great, but uh, how do i implement it to existing nflib source (pa2lib is in some ways renamed NFlib )

i guess i will take the existing PA_LoadBg func and modify its content to load stuff off RAM instead of NITROFS/FAT, which is also useful because in some PAlib release they added the FAT loading stuff (made by knightfox btw) but then removed it because it was "buggy"

I honestly didnt think PAlib's source was really a hell like it is, JUST TAKE A LOOK AT PA_NOTHING, ITS LITERALLY NOTHING. Multiple functions that do the same, Useless stuff like mode7 or stuff that is easier with libnds After seeing the diference i can see why PAlib is hated. I regret using PAlib ever on my life. (I still use it because of ASlib mp3 support and maxmod not being able to play mp3, i cant still do stream play though. After i figure out the hole thing i will switch to better libnds/nflib

If there are typos, sorry i typed this with my phone screen
 
Last edited by Deleted member 591971,

DanTheManMS

aka Ricochet Otter
Member
Joined
Jun 2, 2007
Messages
4,453
Trophies
1
Age
34
Location
Georgia
XP
752
Country
United States
I honestly didnt think PAlib's source was really a hell like it is, JUST TAKE A LOOK AT PA_NOTHING, ITS LITERALLY NOTHING. Multiple functions that do the same, Useless stuff like mode7 or stuff that is easier with libnds After seeing the diference i can see why PAlib is hated. I regret using PAlib ever on my life.
I can see why Wintermute hated PALib with a burning passion, based on this post XD
 

Deleted member 591971

Well-Known Member
OP
Member
Joined
Apr 10, 2022
Messages
216
Trophies
0
XP
922
Finally, implemented into PA2lib.

yeyyyyyyyy now there will be a new PA2lib release soon after 3 months. It requires a custom makefile with the rules, i have created one but somehow it lacks nitrofs support
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    OctoAori20 @ OctoAori20: Welp