#166386 - zigg - Sat Feb 07, 2009 6:05 am
I'm working on a DS-based server that will allow a PC to read and write arbitrary sections of a game card's save chip. I figure this will be useful to easily write software that does the same thing that my old Band Brothers Save Tool did, without rewriting the entire chip each time and hopefully a bit easier on the whole.
Be kind with the following--I don't do C all that often, and I only know a few real basic things about DS architecture. :)
I'm compiling against r24 and dswifi 0.3.6. Here's today's code: http://www.zigg.com/tmp/savehost-20090206.tar.gz
Anyway, I've run into two problems today:
1. I seem to need some voodoo to get send() to actually send everything out.
The voodoo in question is the swiWaitForVBlank calls. Basically, I've lifted this pattern from savsender. If I don't add those calls, my dumped save ends up dropping bytes. (BTW, SAVEHOST_BLOCK_SIZE is currently 256, something else I lifted from savsender. I don't know how efficient that is, to be honest.)
Is there a better way to solve this problem?
2. The enclosed card.c is enhanced to support the 64Mbit save chip from Band Brothers DX--though I can't quite verify that it works 100% yet because I haven't successfully dumped more than about 480KBytes of the 8MBytes--my app hangs around that time each time I try. (I'm using the enclosed client/savedump.py, which just needs an IP address and will dump the save data to stdout. I did it with my old 256KByte Band Brothers save and it worked perfectly.)
Is there something I'm doing wrong? I guess I'm sort of asking someone to read all my code there, but I really have no idea where to start.
Thanks much for any help.[/code]
Be kind with the following--I don't do C all that often, and I only know a few real basic things about DS architecture. :)
I'm compiling against r24 and dswifi 0.3.6. Here's today's code: http://www.zigg.com/tmp/savehost-20090206.tar.gz
Anyway, I've run into two problems today:
1. I seem to need some voodoo to get send() to actually send everything out.
Code: |
for(buf_p = buf; (buf_p - buf) < size; buf_p += SAVEHOST_BLOCK_SIZE) {
iprintf("\n\x1b[1Asending: %u:%u ", (buf_p - buf), min(size - (buf_p - buf), SAVEHOST_BLOCK_SIZE)); send(sock, buf_p, min(size - (buf_p - buf), SAVEHOST_BLOCK_SIZE), 0); /* seems to work for savsender, maybe useful here too? */ swiWaitForVBlank(); swiWaitForVBlank(); } |
The voodoo in question is the swiWaitForVBlank calls. Basically, I've lifted this pattern from savsender. If I don't add those calls, my dumped save ends up dropping bytes. (BTW, SAVEHOST_BLOCK_SIZE is currently 256, something else I lifted from savsender. I don't know how efficient that is, to be honest.)
Is there a better way to solve this problem?
2. The enclosed card.c is enhanced to support the 64Mbit save chip from Band Brothers DX--though I can't quite verify that it works 100% yet because I haven't successfully dumped more than about 480KBytes of the 8MBytes--my app hangs around that time each time I try. (I'm using the enclosed client/savedump.py, which just needs an IP address and will dump the save data to stdout. I did it with my old 256KByte Band Brothers save and it worked perfectly.)
Is there something I'm doing wrong? I guess I'm sort of asking someone to read all my code there, but I really have no idea where to start.
Thanks much for any help.[/code]