This also fixes#958
Original commits:
* initial work on cart save crypto/wearleveling
* add support for n3ds only save crypto
* use existing crc16 impl for save blockmap
* fix missing aeskey select for card2 save decrypt
* fix old/new cart media being swapped
* fix 1 MiB save chips / blockmap type 2
* move cart save wearleveling/crypto to separate file
* try 2nd wearlevel header on fail + minor fixes
* save_ctr: zero out savectx before reading fallback header
* Add cart_id2 to gamecart.h
This prepares changes to fix private header dumps.
The name ID2 matches Lotus3 (see Switchbrew) since it's evident Lotus3 is just a continuation of the 3DS cart controller
* Add Cart_GetID2() to protocol.h
This prepares changes to fix private header dumps.
The name ID2 matches Lotus3 (see Switchbrew) since it's evident Lotus3 is just a continuation of the 3DS cart controller.
* gc protocol: Add support to get ID2
This renames the unknowna0_cmd to its proper name and the A0_Response to CartID2, matching Lotus3 terminology.
* Store ID2 in private header at +0x44
The ID2 contains important information that in particular determines the cryptographic keys used. It is impossible to decrypt a dump of cart<->controller communications without knowing the ID2 or trying all possible keys.
This behavior matches Gateway. I suppose that it was presumed that Gateway would always store zeroes there because regular cartridges on retail would always report zero and then everybody just copied this false assumption.
* fix build (gamecart.c): memset->memcpy
* fix build (protocol.c): Fix dupe definition of Cart_GetID()
- removed most of lodepng's optional features
- lodepng now uses the already existing CRC32 code instead of using its own copy
- fixed GIC interrupt priority