diff options
author | FIX94 <fix94.1@gmail.com> | 2016-04-09 18:03:04 +0200 |
---|---|---|
committer | FIX94 <fix94.1@gmail.com> | 2016-04-09 18:03:04 +0200 |
commit | 2abebc4d066c038594dc667be210990c4c1dce30 (patch) | |
tree | c4475472b9d055f92dfa303c0d8f48b8b5fc4a8d | |
parent | 2fdb5e638e023408697be8950e776e8f8ffd2590 (diff) | |
download | gen3uploader-2abebc4d066c038594dc667be210990c4c1dce30.tar.gz gen3uploader-2abebc4d066c038594dc667be210990c4c1dce30.tar.bz2 gen3uploader-2abebc4d066c038594dc667be210990c4c1dce30.zip |
fixed up eeprom support
-rw-r--r-- | gba/source/libSave.c | 17 | ||||
-rw-r--r-- | source/main.c | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/gba/source/libSave.c b/gba/source/libSave.c index 1ae8162..d545a5f 100644 --- a/gba/source/libSave.c +++ b/gba/source/libSave.c | |||
@@ -88,7 +88,8 @@ typedef enum { false, true } bool; | |||
88 | #define REG_DM3SAD (*(volatile u32*)0x40000D4) | 88 | #define REG_DM3SAD (*(volatile u32*)0x40000D4) |
89 | #define REG_DM3DAD (*(volatile u32*)0x40000D8) | 89 | #define REG_DM3DAD (*(volatile u32*)0x40000D8) |
90 | #define REG_DM3CNT (*(volatile u32*)0x40000DC) | 90 | #define REG_DM3CNT (*(volatile u32*)0x40000DC) |
91 | 91 | #define REG_DM3CNT_H (*(volatile u16*)0x40000DE) | |
92 | #define REG_WAITCNT (*(volatile u16*)0x4000204) | ||
92 | 93 | ||
93 | //----------------------------------------------------------------------- | 94 | //----------------------------------------------------------------------- |
94 | // Common EEPROM Routines | 95 | // Common EEPROM Routines |
@@ -96,16 +97,20 @@ typedef enum { false, true } bool; | |||
96 | 97 | ||
97 | void EEPROM_SendPacket( u16* packet, int size ) | 98 | void EEPROM_SendPacket( u16* packet, int size ) |
98 | { | 99 | { |
100 | REG_WAITCNT = (REG_WAITCNT & 0xF8FF) | 0x0300; | ||
99 | REG_DM3SAD = (u32)packet; | 101 | REG_DM3SAD = (u32)packet; |
100 | REG_DM3DAD = (u32)EEPROM_ADDRESS; | 102 | REG_DM3DAD = (u32)EEPROM_ADDRESS; |
101 | REG_DM3CNT = 0x80000000 + size; | 103 | REG_DM3CNT = 0x80000000 + size; |
104 | while((REG_DM3CNT_H & 0x8000) != 0) ; | ||
102 | } | 105 | } |
103 | 106 | ||
104 | void EEPROM_ReceivePacket( u16* packet, int size ) | 107 | void EEPROM_ReceivePacket( u16* packet, int size ) |
105 | { | 108 | { |
109 | REG_WAITCNT = (REG_WAITCNT & 0xF8FF) | 0x0300; | ||
106 | REG_DM3SAD = (u32)EEPROM_ADDRESS; | 110 | REG_DM3SAD = (u32)EEPROM_ADDRESS; |
107 | REG_DM3DAD = (u32)packet; | 111 | REG_DM3DAD = (u32)packet; |
108 | REG_DM3CNT = 0x80000000 + size; | 112 | REG_DM3CNT = 0x80000000 + size; |
113 | while((REG_DM3CNT_H & 0x8000) != 0) ; | ||
109 | } | 114 | } |
110 | 115 | ||
111 | //----------------------------------------------------------------------- | 116 | //----------------------------------------------------------------------- |
@@ -187,7 +192,7 @@ void EEPROM_Write_512B( volatile u8 offset, u8* source ) // source must point to | |||
187 | in_byte = *in_pos++; | 192 | in_byte = *in_pos++; |
188 | for( bit = 7; bit >= 0; --bit ) | 193 | for( bit = 7; bit >= 0; --bit ) |
189 | { | 194 | { |
190 | *out_pos++ = in_byte>>bit; | 195 | *out_pos++ = (in_byte>>bit)&1; |
191 | } | 196 | } |
192 | } | 197 | } |
193 | 198 | ||
@@ -641,6 +646,7 @@ u32 SaveSize(u8* data, s32 gamesize) | |||
641 | 646 | ||
642 | u32 *pak= ((u32*)0x08000000); | 647 | u32 *pak= ((u32*)0x08000000); |
643 | s32 x; | 648 | s32 x; |
649 | u16 i; | ||
644 | s32 size = gamesize/4; | 650 | s32 size = gamesize/4; |
645 | 651 | ||
646 | 652 | ||
@@ -658,10 +664,9 @@ u32 SaveSize(u8* data, s32 gamesize) | |||
658 | case 0x52504545: | 664 | case 0x52504545: |
659 | if ((pak[x+1] & 0x00FFFFFF) == 0x005F4D4F){ | 665 | if ((pak[x+1] & 0x00FFFFFF) == 0x005F4D4F){ |
660 | GetSave_EEPROM_8KB(data); | 666 | GetSave_EEPROM_8KB(data); |
661 | if (memcmp(data,data+0x200,8) != 0 || | 667 | for(i = 8; i < 0x800; i += 8) { |
662 | memcmp(data,data+0x400,8) != 0 || | 668 | if(memcmp(data, data+i, 8) != 0) |
663 | memcmp(data,data+0x600,8) != 0){ | 669 | return 0x2000; // EEPROM_8KB |
664 | return 0x2000; //EEPROM_8KB | ||
665 | } | 670 | } |
666 | return 0x200; // EEPROM_512B | 671 | return 0x200; // EEPROM_512B |
667 | } | 672 | } |
diff --git a/source/main.c b/source/main.c index ee23263..9a1b01a 100644 --- a/source/main.c +++ b/source/main.c | |||
@@ -23,7 +23,7 @@ void printmain() | |||
23 | { | 23 | { |
24 | printf("\x1b[2J"); | 24 | printf("\x1b[2J"); |
25 | printf("\x1b[37m"); | 25 | printf("\x1b[37m"); |
26 | printf("GBA Link Cable Dumper v1.1 by FIX94\n"); | 26 | printf("GBA Link Cable Dumper v1.2 by FIX94\n"); |
27 | printf("Save Support based on SendSave by Chishm\n"); | 27 | printf("Save Support based on SendSave by Chishm\n"); |
28 | } | 28 | } |
29 | 29 | ||