Wednesday, April 15, 2009
#!/usr/bin/env pythonDon't say I've never done anything for you.
# A CRC32 summing utility that functions mostly like md5sum or
# Public domain by Matt Behrens <firstname.lastname@example.org> with NO WARRANTY.
# Usage: crc32sum [<filename> [<filename>...]]
BLOCKSIZE = 0x10000
from zlib import crc32
names = sys.argv[1:]
names = [None]
for name in names:
if name is not None:
f = open(name, 'rb')
f = sys.stdin
name = '-'
crc = None
data = f.read(BLOCKSIZE)
if crc is None:
crc = crc32(data)
crc = crc32(data, crc)
print '%08x\t%s' % ((crc & 0xffffffff), name)
posted by zigg 10:24 PM 0 Comments
Monday, April 13, 2009Nintendo DS Save Host (which I first talked about back in February) to SourceForge. Honestly this is kind of new to me, putting incomplete stuff out there, but I have at least one person I'm talking to already who is interested in early-access stuff.
Having an audience helps a little. It doesn't magick time out of thin air, but it's given me a little more impetus to actually do things. What I did this evening was piece together an algorithm for writing to the 256-byte pages (or 64-Kbyte sectors) that make up the Flash chips on many of the larger Nintendo DS games. On these chips, a page must be erased completely, then rewritten completely, which I suppose is a requirement I could have left in the hands of the client authors, but what's the fun in that? They'd have to download entire pages over the wire, modify them, then send them all back.
So I implemented a routine that will simply let them write at any ol' offset, and it will walk as many pages as the write spans, reading out those which aren't slated for complete replacement so they can be patched, then erasing each page and writing its new content back out again.
It's really kind of ugly at the moment, and it's not hooked up to actual write machinery; it's just proof-of-concept that runs entirely on my laptop. I think it could stand a little improvement; when dealing with 256-byte pages it's okay to read the whole original page in, but if we're patching 48 Kbytes of a 64-Kbyte sector we might not really need to read the whole sector in first, so maybe instead of reading then overwriting the in-memory buffer I might just read in the portions I am not going to overwrite (Is that premature optimization? Probably. But I'm a perfectionist.)
It's a nice feeling of accomplishment, though. Maybe I'll finish this up before summer.
posted by zigg 9:12 PM 0 Comments