Hacking libds2a unofficial

Deleted member 319809

MAH BOI/GURL
Member
Joined
Dec 22, 2012
Messages
900
Trophies
0
XP
461
Country
Canada
Frankly, I just became fully confused by the versions involved here.

There's 0.13 beta, which I unknowingly compiled against for a whole month. Then there's 1.2, which you say is 0.12 (worse than 0.13 beta) but I don't see any problems with it at all, and that's the version that improved CATSFC to the point of 95%+ controller sync in CATSFC 1.28. Then there's your version, based on 0.13 beta, communicating with an unknown libds2b.a. I have one more version too in the master branch of the git repository for CATSFC, which is an unknown version but with DMA in it.

edit: What you could do is compile my latest master (stable) branch with your SDK, replacing ds2_setCPUclocklevel with ds2_setCPULevel and the names of some DMA functions, and tell me what happens when you tap Options. If it crashes right away, then that's a problem with fat_getDiskSpaceInfo. If it doesn't, then try your CPU clocks.
 

BassAceGold

Testicles
OP
Member
Joined
Aug 14, 2006
Messages
496
Trophies
1
XP
441
Country
Canada
Here is the change log that is included in v0.13 (the version file)
2010.12.8
ds2sdk 0.13beta
do some modifications of communication protocol to improve communication speed.But for compatibility with older versions,
Speed increase is not obvious.
increase the audio buffer from 4 to 16.
support audio queue priority.
support for multiple audio sample rates, eg.11025Hz, 22050Hz, 44100Hz, 48000Hz, 96000Hz and so on.
added interleave data format for audio data transfer.
added the function ds2_setAudio.

2010.10.10
ds2sdk 0.12beta
fixed serval bugs on file system
fixed the bug in ds2_getrawInput function
using float point algorithm to improve accuracy of timer
added ds2io_initb

2010.8.6
ds2sdk 0.11beta
fixed bug of ds2_init() function in libds2b.a

2010.7.23
ds2sdk 0.1beta
the original beta version
this version do not employ any OS

The version file included in 1.2 only contains changes up to 2010.10.10

The 1.2 code does not contain a ds2_setAudio function.

Here is the set audio function information:
Code:
/*
*    Function: set audio info
*    audio_samples_freq:  default freq 44100Hz
*  audio_sample_bit: 16bit
*    audio_samples_lenght: sholud be 128*n, 128 <= audio_samples_lenght <= 4096
*  channels: 2
*  data_format: 0: interleave(L R L R L R L R ...) 1: group(L L L L ...R R R R ...)
*/
void ds2_setAudio( unsigned int audio_samples_freq, int audio_sample_bit, unsigned int audio_samples_lenght, int channels, int data_format );
 

BassAceGold

Testicles
OP
Member
Joined
Aug 14, 2006
Messages
496
Trophies
1
XP
441
Country
Canada
Right, my unofficial libds2a already contains sources to 0.13 and improvements. All you need to do is just extract in the right location and it's ready to go.

I can confirm that fat_getDiskSpaceInfo still freezes though. I'll look into it.


More info:
It freezes when it calls getDirSize, which recursively scans through each directory and counts the total disk space used by all the files. I'm thinking there might be a faster way to do this.

Even more info: The function tries to dereference a null pointer, will post fixed version soon.
 

Deleted member 319809

MAH BOI/GURL
Member
Joined
Dec 22, 2012
Messages
900
Trophies
0
XP
461
Country
Canada
Well, I now see why you have to transplant stuff individually from 0.12 ("1.2")'s libsrc/base. You have to do that because the communication between 0.12's libds2b.a and the DS is different from 0.13's libds2b.a (whose source is not provided - wtf?) and the DS, so you can't just copy everything from 0.12 libsrc/base into 0.13. On the other hand, you can copy stuff over from 0.12 when they don't deal with DSTwo-DS communication.

The mixup is over, and a new version of CATSFC Stable and CATSFC Experimental (CPU level ver.) should be available soon with the merged SDKs. CATSFC Stable will use your DMA functions, but will use vanilla SDK CPU levels. CATSFC Experimental will have overclocking in it.
 

Deleted member 319809

MAH BOI/GURL
Member
Joined
Dec 22, 2012
Messages
900
Trophies
0
XP
461
Country
Canada
Nope. I can't use solely 0.13. I extracted only 0.13 into /opt/ds2sdk, then overwrote it properly with your changes, and it has the controller status failure.

With 0.12, it's perfect.

So I'll provide instructions to download 1.2, 0.13 and merge only the DMA and zlib changes.

Actually... the instructions WERE right. I just forgot to replace the libds2b.a from 0.13 with 1.2's when I followed them. 0.13's gcc, 1.2's libds2b.a, THEN your source for libds2a.a, all overwritten in that sequence, should be good.
 

Deleted member 319809

MAH BOI/GURL
Member
Joined
Dec 22, 2012
Messages
900
Trophies
0
XP
461
Country
Canada
I can confirm that with the above sequence (0.13's gcc, 0.12/1.2, "libBAG") it works. The card capacity option also works and actually states the current FREE SPACE for the card, in my case "6876.5 MB" (previous CATSFC versions showed the card's total capacity, constant for any given card, in my case "14.5 GB"), but at least for me it delays entry into the /Options menu by 2 seconds.

Perhaps you could gather the free-cluster counter at the start of the FAT?

http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/fatgen103.doc

"For this reason, a provision is made to store the “last known” free cluster count on the FAT32 volume so that it does not have to be computed ..."

EDIT: ds2_mdelay and ds2_udelay are commented out in R2-fix2/core/ds2_cpuclock.c!
 

BassAceGold

Testicles
OP
Member
Joined
Aug 14, 2006
Messages
496
Trophies
1
XP
441
Country
Canada
Actually, looking at the source of CATSFC, the interface is outputing the free space instead of the disk total.

in the show_card_space() function around line 2780:
num_byte = freespace;
/free space should be total

The code in fat_getDiskSpace info is exactly the same in both SDK releases, however mine just makes the currentFile pointer, actually point to something so a null pointer isn't dereferenced in loop. fat_getDiskSpace does multiple things, it grabs the total disk size, the used space and then calculates the free space.

To grab the used space, it'll recursively scan from the root directory your entire card and tally up all the file sizes. If you just want the total disk size, you'll need to create your own function to do so. There is kind of a hacky way to do so:


Code:
//create a temporary file
FILE *tempFile = fopen(".temp", "wb");
if(!tempFile)
    return 0;
 
//grab the number of sectors on card
unsigned int totalSectors = tempFile->partition->numberOfSectors;
 
//close file
fclose(tempFile);
return totalSectors;

Should return a value that fat_getDiskSpaceInfo would.


I shall re-upload the current library with the timer stuff uncommented, I was testing stuff and forgot to uncomment them.


And for your input stuff, are you essentially saying you're just using the libds2b.a + ds2_firmware.dat from 1.2, and then using this new libds2a.a from 0.13?

http://filetrip.net/dl?d9M9BrjpXP
Re-uploaded sources!
 

Deleted member 319809

MAH BOI/GURL
Member
Joined
Dec 22, 2012
Messages
900
Trophies
0
XP
461
Country
Canada
There's no AUDIO_BUFFER_COUNT in your modified library.

Code:
nebuleon@alakazam ~/dstwo/libsrc$ find -type f -print0 | xargs -0 grep -Fn AUDIO_BUFFER_COUNT
nebuleon@alakazam ~/dstwo/libsrc$
 

Deleted member 319809

MAH BOI/GURL
Member
Joined
Dec 22, 2012
Messages
900
Trophies
0
XP
461
Country
Canada
Whew. I thought I had lost my branches with this messing around. I was merging from master into experimental and almost lost my master branch when I merged from experimental into it.

I'll wait for your next archive to come in, and then I'll spend another hour recovering from that.

nvm, started writing before you but you got your post in first
 

Deleted member 319809

MAH BOI/GURL
Member
Joined
Dec 22, 2012
Messages
900
Trophies
0
XP
461
Country
Canada
Alright, I recovered successfully from the multiple changes to my SDK directory.

Please pull from my experimental branch again: https://github.com/ShadauxCat/CATSFC/tree/experimental

It should compile against your library with no changes.

Of note is that /Options doesn't crash anymore, but, like the main branch, it does take 2 seconds to get the free space on my card. And "Card capacity" is a misnomer right now. Anyway, it's more practical for a user to know how much space they have FREE on their card, so s/he knows whether the card can store an additional save state. So if it were to become quicker, that'd be ace (alternatively just call HighFrequencyCPU and LowFrequencyCPU in others_menu_init).

420 MHz and up still crash oddly on my card. 404 MHz also crashes sometimes.
 
  • Like
Reactions: Margen67

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    K3Nv2 @ K3Nv2: Att did offer a $500gc tempting to use it for 6 months and cancel