├── VERSION ├── docs ├── doc.png ├── bc_s.png ├── bdwn.png ├── closed.png ├── nav_f.png ├── nav_g.png ├── nav_h.png ├── open.png ├── tab_a.png ├── tab_b.png ├── tab_h.png ├── tab_s.png ├── splitbar.png ├── sync_off.png ├── sync_on.png ├── folderopen.png ├── folderclosed.png ├── search │ ├── search_l.png │ ├── search_m.png │ ├── search_r.png │ ├── files_0.js │ ├── all_2.js │ ├── enums_0.js │ ├── files_1.js │ ├── functions_2.js │ ├── variables_0.js │ ├── enums_1.js │ ├── functions_0.js │ ├── all_3.js │ ├── functions_1.js │ ├── searchdata.js │ ├── nomatches.html │ ├── enumvalues_0.js │ ├── close.svg │ ├── all_0.html │ ├── all_1.html │ ├── all_2.html │ ├── all_3.html │ ├── enums_0.html │ ├── enums_1.html │ ├── files_0.html │ ├── files_1.html │ ├── enumvalues_0.html │ ├── enumvalues_1.html │ ├── functions_0.html │ ├── functions_1.html │ ├── functions_2.html │ ├── variables_0.html │ ├── all_0.js │ ├── enumvalues_1.js │ ├── mag_sel.svg │ ├── all_1.js │ └── search.css ├── menudata.js ├── index.html ├── globals_vars.html ├── menu.js ├── globals_enum.html ├── globals_func.html ├── dir_d44c64559bbebec7f509842c48db8b23.html ├── files.html ├── dynsections.js ├── gba__sram_8h_source.html ├── globals_eval.html ├── gba__eeprom_8h_source.html ├── gba__sram_8h.html ├── tabs.css ├── globals.html └── err__def_8h.html ├── commitlint.config.js ├── .gitignore ├── CONTRIBUTING.md ├── package.json ├── src ├── err_def.c ├── gba_sram.c └── gba_eeprom.c ├── test ├── detect-save-type │ ├── README.md │ ├── main.c │ └── Makefile ├── sram │ ├── sram.c │ └── Makefile ├── flash-64KB │ ├── flash-64KB.c │ └── Makefile ├── eeprom-8KB │ ├── eeprom-8KB.c │ └── Makefile ├── eeprom-512B │ ├── eeprom-512B.c │ └── Makefile └── flash-128KB │ ├── flash-128KB.c │ └── Makefile ├── .versionrc.js ├── include ├── gba_sram.h ├── err_def.h ├── gba_eeprom.h └── gba_flash.h ├── LICENSE ├── .github └── workflows │ └── main.yml ├── README.md ├── Makefile └── CHANGELOG.md /VERSION: -------------------------------------------------------------------------------- 1 | 3.3.0 -------------------------------------------------------------------------------- /docs/doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/doc.png -------------------------------------------------------------------------------- /docs/bc_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/bc_s.png -------------------------------------------------------------------------------- /docs/bdwn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/bdwn.png -------------------------------------------------------------------------------- /docs/closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/closed.png -------------------------------------------------------------------------------- /docs/nav_f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/nav_f.png -------------------------------------------------------------------------------- /docs/nav_g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/nav_g.png -------------------------------------------------------------------------------- /docs/nav_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/nav_h.png -------------------------------------------------------------------------------- /docs/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/open.png -------------------------------------------------------------------------------- /docs/tab_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/tab_a.png -------------------------------------------------------------------------------- /docs/tab_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/tab_b.png -------------------------------------------------------------------------------- /docs/tab_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/tab_h.png -------------------------------------------------------------------------------- /docs/tab_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/tab_s.png -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {extends: ['@commitlint/config-conventional']} 2 | -------------------------------------------------------------------------------- /docs/splitbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/splitbar.png -------------------------------------------------------------------------------- /docs/sync_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/sync_off.png -------------------------------------------------------------------------------- /docs/sync_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/sync_on.png -------------------------------------------------------------------------------- /docs/folderopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/folderopen.png -------------------------------------------------------------------------------- /docs/folderclosed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/folderclosed.png -------------------------------------------------------------------------------- /docs/search/search_l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/search/search_l.png -------------------------------------------------------------------------------- /docs/search/search_m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/search/search_m.png -------------------------------------------------------------------------------- /docs/search/search_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laqieer/libsavgba/HEAD/docs/search/search_r.png -------------------------------------------------------------------------------- /docs/search/files_0.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['err_5fdef_2eh_42',['err_def.h',['../err__def_8h.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.d 2 | *.o 3 | *.a 4 | *.elf 5 | *.map 6 | *.gba 7 | *.sav 8 | *.zip 9 | 10 | config.toml 11 | 12 | .DS_store 13 | 14 | .husky/ 15 | node_modules/ 16 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | **Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://kcd.im/pull-request) 2 | -------------------------------------------------------------------------------- /docs/search/all_2.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['gba_5feeprom_2eh_35',['gba_eeprom.h',['../gba__eeprom_8h.html',1,'']]], 4 | ['gba_5fflash_2eh_36',['gba_flash.h',['../gba__flash_8h.html',1,'']]], 5 | ['gba_5fsram_2eh_37',['gba_sram.h',['../gba__sram_8h.html',1,'']]] 6 | ]; 7 | -------------------------------------------------------------------------------- /docs/search/enums_0.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['eepromsize_57',['EepromSize',['../gba__eeprom_8h.html#afa60614d77a9f883292adf48fb136dbc',1,'gba_eeprom.h']]], 4 | ['errorcode_58',['ErrorCode',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05f',1,'err_def.h']]] 5 | ]; 6 | -------------------------------------------------------------------------------- /docs/search/files_1.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['gba_5feeprom_2eh_43',['gba_eeprom.h',['../gba__eeprom_8h.html',1,'']]], 4 | ['gba_5fflash_2eh_44',['gba_flash.h',['../gba__flash_8h.html',1,'']]], 5 | ['gba_5fsram_2eh_45',['gba_sram.h',['../gba__sram_8h.html',1,'']]] 6 | ]; 7 | -------------------------------------------------------------------------------- /docs/search/functions_2.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['sram_5fread_53',['sram_read',['../gba__sram_8h.html#ae91ef81379986e93f5cd18821432432e',1,'gba_sram.h']]], 4 | ['sram_5fwrite_54',['sram_write',['../gba__sram_8h.html#a3390ccfe253a2bdbd2ea181fd6382401',1,'gba_sram.h']]] 5 | ]; 6 | -------------------------------------------------------------------------------- /docs/search/variables_0.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['saverrcodes_55',['SavErrCodes',['../err__def_8h.html#aebd6548ae9cb79094b102806fb210cd0',1,'err_def.h']]], 4 | ['saverrmsgs_56',['SavErrMsgs',['../err__def_8h.html#a0ebc9050df14fe3746b4faf394946e98',1,'err_def.h']]] 5 | ]; 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "cz-conventional-changelog": "^3.3.0", 4 | "husky": "^7.0.4", 5 | "standard-version": "^9.3.2" 6 | }, 7 | "scripts": { 8 | "release": "standard-version" 9 | }, 10 | "config": { 11 | "commitizen": { 12 | "path": "./node_modules/cz-conventional-changelog" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /docs/search/enums_1.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['flashdevice_59',['FlashDevice',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92b',1,'gba_flash.h']]], 4 | ['flashmanufacturer_60',['FlashManufacturer',['../gba__flash_8h.html#a483850ee42ee3c9dda119b6ad3bcbf09',1,'gba_flash.h']]], 5 | ['flashsize_61',['FlashSize',['../gba__flash_8h.html#ac043ac24a39be2ae7922627797f564d5',1,'gba_flash.h']]] 6 | ]; 7 | -------------------------------------------------------------------------------- /docs/search/functions_0.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['eeprom_5finit_46',['eeprom_init',['../gba__eeprom_8h.html#a02f6958b12e25c2f4a7e9760d6a83dc1',1,'gba_eeprom.h']]], 4 | ['eeprom_5fread_47',['eeprom_read',['../gba__eeprom_8h.html#a2d8ba544f7b5b7674f1c73f4bdf323c0',1,'gba_eeprom.h']]], 5 | ['eeprom_5fwrite_48',['eeprom_write',['../gba__eeprom_8h.html#ac56a0554dbeff5d17c677df660cb5dba',1,'gba_eeprom.h']]] 6 | ]; 7 | -------------------------------------------------------------------------------- /src/err_def.c: -------------------------------------------------------------------------------- 1 | const char * const SavErrCodes[] = { 2 | "E_SUCCESS", 3 | "E_INVALID_PARAM", 4 | "E_OUT_OF_RANGE", 5 | "E_VERIFY_FAIL", 6 | "E_UNSUPPORTED_DEVICE", 7 | "E_TIMEOUT", 8 | }; 9 | 10 | const char * const SavErrMsgs[] = { 11 | "No error", 12 | "Invalid input parameter", 13 | "Address is out of range", 14 | "Failed to verify written data", 15 | "Device type is not supported", 16 | "Operation timeout", 17 | }; 18 | -------------------------------------------------------------------------------- /docs/search/all_3.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['saverrcodes_38',['SavErrCodes',['../err__def_8h.html#aebd6548ae9cb79094b102806fb210cd0',1,'err_def.h']]], 4 | ['saverrmsgs_39',['SavErrMsgs',['../err__def_8h.html#a0ebc9050df14fe3746b4faf394946e98',1,'err_def.h']]], 5 | ['sram_5fread_40',['sram_read',['../gba__sram_8h.html#ae91ef81379986e93f5cd18821432432e',1,'gba_sram.h']]], 6 | ['sram_5fwrite_41',['sram_write',['../gba__sram_8h.html#a3390ccfe253a2bdbd2ea181fd6382401',1,'gba_sram.h']]] 7 | ]; 8 | -------------------------------------------------------------------------------- /docs/search/functions_1.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['flash_5finit_49',['flash_init',['../gba__flash_8h.html#aff94b5e5322c8d6944577eb78290387c',1,'gba_flash.h']]], 4 | ['flash_5fread_50',['flash_read',['../gba__flash_8h.html#a2290d15f7440e9aff7c210569f80ea96',1,'gba_flash.h']]], 5 | ['flash_5freset_51',['flash_reset',['../gba__flash_8h.html#a72a5873c0849104c17b408a6f4a342cf',1,'gba_flash.h']]], 6 | ['flash_5fwrite_52',['flash_write',['../gba__flash_8h.html#ae5ee71a3c76ec9c8ea79d6229281634d',1,'gba_flash.h']]] 7 | ]; 8 | -------------------------------------------------------------------------------- /docs/search/searchdata.js: -------------------------------------------------------------------------------- 1 | var indexSectionsWithContent = 2 | { 3 | 0: "efgs", 4 | 1: "eg", 5 | 2: "efs", 6 | 3: "s", 7 | 4: "ef", 8 | 5: "ef" 9 | }; 10 | 11 | var indexSectionNames = 12 | { 13 | 0: "all", 14 | 1: "files", 15 | 2: "functions", 16 | 3: "variables", 17 | 4: "enums", 18 | 5: "enumvalues" 19 | }; 20 | 21 | var indexSectionLabels = 22 | { 23 | 0: "All", 24 | 1: "Files", 25 | 2: "Functions", 26 | 3: "Variables", 27 | 4: "Enumerations", 28 | 5: "Enumerator" 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /test/detect-save-type/README.md: -------------------------------------------------------------------------------- 1 | # detect-save-type 2 | A tool to detect backup media type. 3 | 4 | ![SRAM](https://media.discordapp.net/attachments/682141375587680274/861456724882882581/detect-save-type-0.png)![EEPROM](https://media.discordapp.net/attachments/682141375587680274/861456723197689906/detect-save-type-1.png)![Flash 64KB](https://media.discordapp.net/attachments/682141375587680274/861456721600184340/detect-save-type-2.png)![Flash 128KB](https://media.discordapp.net/attachments/682141375587680274/861456720156033044/detect-save-type-3.png) 5 | -------------------------------------------------------------------------------- /docs/search/nomatches.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 |
No Matches
11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /.versionrc.js: -------------------------------------------------------------------------------- 1 | const version = { 2 | "filename": "VERSION", 3 | "type": "plain-text" 4 | } 5 | 6 | module.exports = { 7 | "types": [ 8 | {"type": "feat", "section": "Features"}, 9 | {"type": "fix", "section": "Bug Fixes"}, 10 | {"type": "chore", "hidden": true}, 11 | {"type": "docs", "hidden": true}, 12 | {"type": "style", "hidden": true}, 13 | {"type": "refactor", "hidden": true}, 14 | {"type": "perf", "hidden": true}, 15 | {"type": "test", "hidden": true}, 16 | {"type": "revert", "hidden": true} 17 | ], 18 | "packageFiles": [version], 19 | "bumpFiles": [version] 20 | } 21 | -------------------------------------------------------------------------------- /include/gba_sram.h: -------------------------------------------------------------------------------- 1 | #ifndef GBA_SRAM_H 2 | #define GBA_SRAM_H 3 | 4 | /** 5 | * @brief Read data from SRAM. 6 | * 7 | * @param addr address in SRAM (unit: byte). 8 | * @param data buffer to hold data. 9 | * @param size data size (unit: byte). 10 | * 11 | * @return \c 0 for success, \c non-zero for error. 12 | */ 13 | int sram_read(u32 addr, u8 *data, size_t size); 14 | 15 | /** 16 | * @brief Write data to SRAM. 17 | * 18 | * @param addr address in SRAM (unit: byte). 19 | * @param data buffer to hold data. 20 | * @param size data size (unit: byte). 21 | * 22 | * @return \c 0 for success, \c non-zero for error. 23 | */ 24 | int sram_write(u32 addr, u8 *data, size_t size); 25 | 26 | #endif /* GBA_SRAM_H */ 27 | -------------------------------------------------------------------------------- /include/err_def.h: -------------------------------------------------------------------------------- 1 | #ifndef ERR_DEF_H 2 | #define ERR_DEF_H 3 | 4 | enum ErrorCode { 5 | E_SUCCESS = 0, ///< No error. 6 | E_INVALID_PARAM, ///< Invalid input parameter. 7 | E_OUT_OF_RANGE, ///< Address is out of range. 8 | E_VERIFY_FAIL, ///< Failed to verify written data. 9 | E_UNSUPPORTED_DEVICE, ///< Device type is not supported. 10 | E_TIMEOUT, ///< Operation timeout. 11 | }; 12 | 13 | /** 14 | * @brief Error codes. 15 | * 16 | * Use `SavErrCodes[ErrorCode]` to get error code names. 17 | */ 18 | extern const char * const SavErrCodes[]; 19 | 20 | /** 21 | * @brief Error messages. 22 | * 23 | * Use `SavErrMsgs[ErrorCode]` to get error code messages. 24 | */ 25 | extern const char * const SavErrMsgs[]; 26 | 27 | #endif /* ERR_DEF_H */ 28 | -------------------------------------------------------------------------------- /test/sram/sram.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #define BUFFER_SIZE 50 7 | 8 | int main(void) { 9 | int err; 10 | u8 buffer[BUFFER_SIZE]; 11 | 12 | REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; 13 | 14 | tte_init_chr4c_default(0, BG_CBB(0) | BG_SBB(31)); 15 | 16 | tte_init_con(); 17 | 18 | // Write Test 19 | err = sram_write(0, (u8 *)"SRAM_Vnnn\n", BUFFER_SIZE); 20 | if (err) { 21 | tte_printf("SRAM Write Error: %s\n", SavErrMsgs[err]); 22 | goto end; 23 | } 24 | 25 | // Read Test 26 | err = sram_read(0, buffer, BUFFER_SIZE); 27 | if (err) { 28 | tte_printf("SRAM Read Error: %s\n", SavErrMsgs[err]); 29 | } 30 | tte_write((char *)buffer); 31 | 32 | // Final Result 33 | tte_write("SRAM Test Passed!"); 34 | 35 | end: 36 | irq_init(NULL); 37 | irq_enable(II_VBLANK); 38 | 39 | while (1) { 40 | VBlankIntrWait(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /include/gba_eeprom.h: -------------------------------------------------------------------------------- 1 | #ifndef GBA_EEPROM_H 2 | #define GBA_EEPROM_H 3 | 4 | /** 5 | * @brief EEPROM chip size. 6 | */ 7 | enum EepromSize { 8 | EEPROM_SIZE_512B = 6, ///< 512B (4Kbit) 9 | EEPROM_SIZE_8KB = 14, ///< 8KB (64K) 10 | }; 11 | 12 | /** 13 | * @brief Init EEPROM chip. 14 | * 15 | * Set the size of EEPROM chip. **It should be called once at first.** 16 | * 17 | * @param size EEPROM chip size (\c EEPROM_SIZE_512B / \c EEPROM_SIZE_8KB). 18 | * 19 | * @return \c 0 for success, \c non-zero for error. 20 | */ 21 | int eeprom_init(u8 size); 22 | 23 | /** 24 | * @brief Read data from EEPROM. 25 | * 26 | * @param addr address in EEPROM (unit: 8 bytes). 27 | * @param data buffer to hold data (size: a unit = 8 bytes). 28 | * 29 | * @return \c 0 for success, \c non-zero for error. 30 | */ 31 | int eeprom_read(u32 addr, u16 *data); 32 | 33 | /** 34 | * @brief Write data to EEPROM. 35 | * 36 | * @param addr address in EEPROM (unit: 8 bytes). 37 | * @param data buffer to hold data (size: a unit = 8 bytes). 38 | * 39 | * @return \c 0 for success, \c non-zero for error. 40 | */ 41 | int eeprom_write(u32 addr, u16 *data); 42 | 43 | #endif /* GBA_EEPROM_H */ 44 | -------------------------------------------------------------------------------- /test/flash-64KB/flash-64KB.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #define BUFFER_SIZE 50 7 | 8 | int main(void) { 9 | int err; 10 | u8 buffer[BUFFER_SIZE]; 11 | 12 | REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; 13 | 14 | tte_init_chr4c_default(0, BG_CBB(0) | BG_SBB(31)); 15 | 16 | tte_init_con(); 17 | 18 | // Init Flash 19 | err = flash_init(FLASH_SIZE_64KB); 20 | if (err) { 21 | tte_printf("Flash(64KB) Init Error: %s\n", SavErrMsgs[err]); 22 | goto end; 23 | } 24 | 25 | // Write Test 26 | err = flash_write(0, (u8 *)"FLASH512_Vnnn\n", BUFFER_SIZE); 27 | if (err) { 28 | tte_printf("Flash(64KB) Write Error: %s\n", SavErrMsgs[err]); 29 | goto end; 30 | } 31 | 32 | // Read Test 33 | err = flash_read(0, buffer, BUFFER_SIZE); 34 | if (err) { 35 | tte_printf("Flash(64KB) Read Error: %s\n", SavErrMsgs[err]); 36 | } 37 | tte_write((char *)buffer); 38 | 39 | // Final Result 40 | tte_write("Flash(64KB) Test Passed!"); 41 | 42 | end: 43 | irq_init(NULL); 44 | irq_enable(II_VBLANK); 45 | 46 | while (1) { 47 | VBlankIntrWait(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /docs/search/enumvalues_0.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['e_5finvalid_5fparam_62',['E_INVALID_PARAM',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05fae3f8b3898cff048b2d029c22ea796dde',1,'err_def.h']]], 4 | ['e_5fout_5fof_5frange_63',['E_OUT_OF_RANGE',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05fac95aae50914dd67abb66b03f16cb4e36',1,'err_def.h']]], 5 | ['e_5fsuccess_64',['E_SUCCESS',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05fac3121e429a129b2ccb51a92b7c78c4b4',1,'err_def.h']]], 6 | ['e_5ftimeout_65',['E_TIMEOUT',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05fa0bc27e0d9f5ecbf8ee1468a90724e088',1,'err_def.h']]], 7 | ['e_5funsupported_5fdevice_66',['E_UNSUPPORTED_DEVICE',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05fa5a0a6eaf461148a87347243490149da7',1,'err_def.h']]], 8 | ['e_5fverify_5ffail_67',['E_VERIFY_FAIL',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05fa4dcea7ec7e6647fcf78a4d795f847206',1,'err_def.h']]], 9 | ['eeprom_5fsize_5f512b_68',['EEPROM_SIZE_512B',['../gba__eeprom_8h.html#afa60614d77a9f883292adf48fb136dbcab2fcdb2e599c20e95625537db8c37076',1,'gba_eeprom.h']]], 10 | ['eeprom_5fsize_5f8kb_69',['EEPROM_SIZE_8KB',['../gba__eeprom_8h.html#afa60614d77a9f883292adf48fb136dbcadbdba9cf5f2467f6d5d2f2493000b335',1,'gba_eeprom.h']]] 11 | ]; 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /docs/search/close.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 16 | 18 | image/svg+xml 19 | 21 | 22 | 23 | 24 | 25 | 27 | 31 | 32 | -------------------------------------------------------------------------------- /src/gba_sram.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "err_def.h" 6 | 7 | IWRAM_CODE 8 | static void sram_memcpy(volatile unsigned char *dst, const volatile unsigned char *src, size_t size) { 9 | for (;size > 0;--size) 10 | *dst++ = *src++; 11 | } 12 | 13 | IWRAM_CODE 14 | static unsigned int sram_absmemcmp(const volatile unsigned char *dst, const volatile unsigned char *src, size_t size) { 15 | while (size-- > 0) { 16 | unsigned int a = *dst++; 17 | unsigned int b = *src++; 18 | if (a != b) 19 | return 1; 20 | } 21 | 22 | return 0; 23 | } 24 | 25 | int sram_read(u32 addr, u8 *data, size_t size) { 26 | if (data == NULL) 27 | return E_INVALID_PARAM; 28 | 29 | if (addr > MEM_SRAM) 30 | addr -= MEM_SRAM; 31 | 32 | if (addr + size > SRAM_SIZE) 33 | return E_OUT_OF_RANGE; 34 | 35 | sram_memcpy(data, &sram_mem[addr], size); 36 | 37 | return 0; 38 | } 39 | 40 | int sram_write(u32 addr, u8 *data, size_t size) { 41 | if (data == NULL) 42 | return E_INVALID_PARAM; 43 | 44 | if (addr > MEM_SRAM) 45 | addr -= MEM_SRAM; 46 | 47 | if (addr + size > SRAM_SIZE) 48 | return E_OUT_OF_RANGE; 49 | 50 | sram_memcpy(&sram_mem[addr], data, size); 51 | 52 | if (sram_absmemcmp(&sram_mem[addr], data, size)) 53 | return E_VERIFY_FAIL; 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /test/eeprom-8KB/eeprom-8KB.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #define BUFFER_SIZE 8 7 | 8 | int main(void) { 9 | int err; 10 | u16 buffer[BUFFER_SIZE]; 11 | 12 | REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; 13 | 14 | tte_init_chr4c_default(0, BG_CBB(0) | BG_SBB(31)); 15 | 16 | tte_init_con(); 17 | 18 | // Init EEPROM 19 | err = eeprom_init(EEPROM_SIZE_8KB); 20 | if (err) { 21 | tte_printf("EEPROM(8KB) Init Error: %s\n", SavErrMsgs[err]); 22 | goto end; 23 | } 24 | 25 | // Write Test 26 | err = eeprom_write(0, (u16 *)"EEPROM_Vnnn\n"); 27 | if (err) { 28 | tte_printf("EEPROM(8KB) Write Error: %s\n", SavErrMsgs[err]); 29 | goto end; 30 | } 31 | 32 | err = eeprom_write(1, (u16 *)"nnn\n"); 33 | if (err) { 34 | tte_printf("EEPROM(8KB) Write Error: %s\n", SavErrMsgs[err]); 35 | goto end; 36 | } 37 | 38 | // Read Test 39 | err = eeprom_read(0, buffer); 40 | if (err) { 41 | tte_printf("EEPROM(8KB) Read Error: %s\n", SavErrMsgs[err]); 42 | } 43 | 44 | err = eeprom_read(1, &buffer[4]); 45 | if (err) { 46 | tte_printf("EEPROM(8KB) Read Error: %s\n", SavErrMsgs[err]); 47 | } 48 | tte_write((char *)buffer); 49 | 50 | // Final Result 51 | tte_write("EEPROM(8KB) Test Passed!"); 52 | 53 | end: 54 | irq_init(NULL); 55 | irq_enable(II_VBLANK); 56 | 57 | while (1) { 58 | VBlankIntrWait(); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /test/eeprom-512B/eeprom-512B.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #define BUFFER_SIZE 8 7 | 8 | int main(void) { 9 | int err; 10 | u16 buffer[BUFFER_SIZE]; 11 | 12 | REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; 13 | 14 | tte_init_chr4c_default(0, BG_CBB(0) | BG_SBB(31)); 15 | 16 | tte_init_con(); 17 | 18 | // Init EEPROM 19 | err = eeprom_init(EEPROM_SIZE_512B); 20 | if (err) { 21 | tte_printf("EEPROM(512B) Init Error: %s\n", SavErrMsgs[err]); 22 | goto end; 23 | } 24 | 25 | // Write Test 26 | err = eeprom_write(0, (u16 *)"EEPROM_Vnnn\n"); 27 | if (err) { 28 | tte_printf("EEPROM(512B) Write Error: %s\n", SavErrMsgs[err]); 29 | goto end; 30 | } 31 | 32 | err = eeprom_write(1, (u16 *)"nnn\n"); 33 | if (err) { 34 | tte_printf("EEPROM(512B) Write Error: %s\n", SavErrMsgs[err]); 35 | goto end; 36 | } 37 | 38 | // Read Test 39 | err = eeprom_read(0, buffer); 40 | if (err) { 41 | tte_printf("EEPROM(512B) Read Error: %s\n", SavErrMsgs[err]); 42 | } 43 | 44 | err = eeprom_read(1, &buffer[4]); 45 | if (err) { 46 | tte_printf("EEPROM(512B) Read Error: %s\n", SavErrMsgs[err]); 47 | } 48 | tte_write((char *)buffer); 49 | 50 | // Final Result 51 | tte_write("EEPROM(512B) Test Passed!"); 52 | 53 | end: 54 | irq_init(NULL); 55 | irq_enable(II_VBLANK); 56 | 57 | while (1) { 58 | VBlankIntrWait(); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /test/flash-128KB/flash-128KB.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #define BUFFER_SIZE 50 9 | 10 | int main(void) { 11 | int err; 12 | u8 buffer[BUFFER_SIZE]; 13 | 14 | REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; 15 | 16 | tte_init_chr4c_default(0, BG_CBB(0) | BG_SBB(31)); 17 | 18 | tte_init_con(); 19 | 20 | // Init Flash 21 | err = flash_init(FLASH_SIZE_128KB); 22 | if (err) { 23 | tte_printf("Flash(128KB) Init Error: %s\n", SavErrMsgs[err]); 24 | goto end; 25 | } 26 | 27 | // Write Test 28 | err = flash_write(64 * 1024, (u8 *)"FLASH1M_Vnnn\n", BUFFER_SIZE); 29 | if (err) { 30 | tte_printf("Flash(128KB) Write Error: %s\n", SavErrMsgs[err]); 31 | goto end; 32 | } 33 | 34 | err = flash_write(0, (u8 *)"Error: 0x0E010000 is mirrored to 0x0E000000\n", BUFFER_SIZE); 35 | if (err) { 36 | tte_printf("Flash(128KB) Write Error: %s\n", SavErrMsgs[err]); 37 | goto end; 38 | } 39 | 40 | // Read Test 41 | err = flash_read(64 * 1024, buffer, BUFFER_SIZE); 42 | if (err) { 43 | tte_printf("Flash(128KB) Read Error: %s\n", SavErrMsgs[err]); 44 | } 45 | tte_write((char *)buffer); 46 | 47 | // Final Result 48 | if (memcmp(buffer, "FLASH1M_Vnnn\n", 12) == 0) 49 | tte_write("Flash(128KB) Test Passed!"); 50 | 51 | end: 52 | irq_init(NULL); 53 | irq_enable(II_VBLANK); 54 | 55 | while (1) { 56 | VBlankIntrWait(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: CI 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the main branch 8 | push: 9 | branches: [ main ] 10 | pull_request: 11 | branches: [ main ] 12 | 13 | # Allows you to run this workflow manually from the Actions tab 14 | workflow_dispatch: 15 | 16 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 17 | jobs: 18 | # This workflow contains a single job called "build" 19 | build: 20 | # The type of runner that the job will run on 21 | runs-on: ubuntu-latest 22 | 23 | container: 24 | image: devkitpro/devkitarm:latest 25 | 26 | # Steps represent a sequence of tasks that will be executed as part of the job 27 | steps: 28 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 29 | - uses: actions/checkout@v2 30 | 31 | - name: commit-linter-cli 32 | # You may pin to the exact commit or the version. 33 | # uses: severgroup-tt/actions-commit-linter-cli@95a688358bf8e8b98fd3401991dd90fa30672ba3 34 | uses: severgroup-tt/actions-commit-linter-cli@v1.0.0 35 | 36 | - name: build 37 | run: make 38 | 39 | - name: build test 40 | run: make test 41 | 42 | - uses: actions/upload-artifact@v4 43 | with: 44 | name: library 45 | path: | 46 | lib/libsavgba.a 47 | test/detect-save-type/detect-save-type.gba 48 | -------------------------------------------------------------------------------- /docs/search/all_0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/all_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/all_2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/all_3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/enums_0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/enums_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/files_0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/files_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/enumvalues_0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/enumvalues_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/functions_0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/functions_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/functions_2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/variables_0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Loading...
13 |
14 | 19 |
Searching...
20 |
No Matches
21 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/search/all_0.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['e_5finvalid_5fparam_0',['E_INVALID_PARAM',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05fae3f8b3898cff048b2d029c22ea796dde',1,'err_def.h']]], 4 | ['e_5fout_5fof_5frange_1',['E_OUT_OF_RANGE',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05fac95aae50914dd67abb66b03f16cb4e36',1,'err_def.h']]], 5 | ['e_5fsuccess_2',['E_SUCCESS',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05fac3121e429a129b2ccb51a92b7c78c4b4',1,'err_def.h']]], 6 | ['e_5ftimeout_3',['E_TIMEOUT',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05fa0bc27e0d9f5ecbf8ee1468a90724e088',1,'err_def.h']]], 7 | ['e_5funsupported_5fdevice_4',['E_UNSUPPORTED_DEVICE',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05fa5a0a6eaf461148a87347243490149da7',1,'err_def.h']]], 8 | ['e_5fverify_5ffail_5',['E_VERIFY_FAIL',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05fa4dcea7ec7e6647fcf78a4d795f847206',1,'err_def.h']]], 9 | ['eeprom_5finit_6',['eeprom_init',['../gba__eeprom_8h.html#a02f6958b12e25c2f4a7e9760d6a83dc1',1,'gba_eeprom.h']]], 10 | ['eeprom_5fread_7',['eeprom_read',['../gba__eeprom_8h.html#a2d8ba544f7b5b7674f1c73f4bdf323c0',1,'gba_eeprom.h']]], 11 | ['eeprom_5fsize_5f512b_8',['EEPROM_SIZE_512B',['../gba__eeprom_8h.html#afa60614d77a9f883292adf48fb136dbcab2fcdb2e599c20e95625537db8c37076',1,'gba_eeprom.h']]], 12 | ['eeprom_5fsize_5f8kb_9',['EEPROM_SIZE_8KB',['../gba__eeprom_8h.html#afa60614d77a9f883292adf48fb136dbcadbdba9cf5f2467f6d5d2f2493000b335',1,'gba_eeprom.h']]], 13 | ['eeprom_5fwrite_10',['eeprom_write',['../gba__eeprom_8h.html#ac56a0554dbeff5d17c677df660cb5dba',1,'gba_eeprom.h']]], 14 | ['eepromsize_11',['EepromSize',['../gba__eeprom_8h.html#afa60614d77a9f883292adf48fb136dbc',1,'gba_eeprom.h']]], 15 | ['err_5fdef_2eh_12',['err_def.h',['../err__def_8h.html',1,'']]], 16 | ['errorcode_13',['ErrorCode',['../err__def_8h.html#a59e56af19e754a6aa26a612ebf91d05f',1,'err_def.h']]] 17 | ]; 18 | -------------------------------------------------------------------------------- /docs/menudata.js: -------------------------------------------------------------------------------- 1 | /* 2 | @licstart The following is the entire license notice for the JavaScript code in this file. 3 | 4 | The MIT License (MIT) 5 | 6 | Copyright (C) 1997-2020 by Dimitri van Heesch 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software 9 | and associated documentation files (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all copies or 15 | substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 18 | BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | @licend The above is the entire license notice for the JavaScript code in this file 24 | */ 25 | var menudata={children:[ 26 | {text:"Main Page",url:"index.html"}, 27 | {text:"Files",url:"files.html",children:[ 28 | {text:"File List",url:"files.html"}, 29 | {text:"Globals",url:"globals.html",children:[ 30 | {text:"All",url:"globals.html",children:[ 31 | {text:"e",url:"globals.html#index_e"}, 32 | {text:"f",url:"globals.html#index_f"}, 33 | {text:"s",url:"globals.html#index_s"}]}, 34 | {text:"Functions",url:"globals_func.html"}, 35 | {text:"Variables",url:"globals_vars.html"}, 36 | {text:"Enumerations",url:"globals_enum.html"}, 37 | {text:"Enumerator",url:"globals_eval.html"}]}]}]} 38 | -------------------------------------------------------------------------------- /include/gba_flash.h: -------------------------------------------------------------------------------- 1 | #ifndef GBA_Flash_H 2 | #define GBA_Flash_H 3 | 4 | /** 5 | * @brief Flash chip size. 6 | */ 7 | enum FlashSize { 8 | FLASH_SIZE_AUTO = 0, ///< Auto-detect 9 | FLASH_SIZE_64KB, ///< 64KB(512Kb) 10 | FLASH_SIZE_128KB, ///< 128KB(1Mb) 11 | }; 12 | 13 | /** 14 | * @brief Flash chip manufacturer. 15 | */ 16 | enum FlashManufacturer { 17 | FLASH_MFR_ATMEL = 0x1F, 18 | FLASH_MFR_PANASONIC = 0x32, 19 | FLASH_MFR_SANYO = 0x62, 20 | FLASH_MFR_SST = 0xBF, 21 | FLASH_MFR_MACRONIX = 0xC2, 22 | }; 23 | 24 | /** 25 | * @brief Flash chip device code. 26 | */ 27 | enum FlashDevice { 28 | FLASH_DEV_MX29L010 = 0x09, 29 | FLASH_DEV_LE26FV10N1TS = 0x13, 30 | FLASH_DEV_MN63F805MNP = 0x1B, 31 | FLASH_DEV_MX29L512 = 0x1C, 32 | FLASH_DEV_AT29LV512 = 0x3D, 33 | FLASH_DEV_LE39FW512 = 0xD4, 34 | }; 35 | 36 | /** 37 | * @brief Init Flash chip. 38 | * 39 | * Detect the type (and presence) of FLASH chips. **It should be called once at first.** 40 | * 41 | * @param size Flash chip size (\c FLASH_SIZE_AUTO / \c FLASH_SIZE_64KB / \c FLASH_SIZE_128KB). Use \c FLASH_SIZE_AUTO if you don't know. 42 | * 43 | * @return \c 0 for success, \c non-zero for error. 44 | */ 45 | int flash_init(u8 size); 46 | 47 | /** 48 | * @brief Reset Flash chip. 49 | * 50 | * Erases all memory in chip, erased memory is FFh-filled. 51 | * 52 | * @return \c 0 for success, \c non-zero for error. 53 | */ 54 | int flash_reset(); 55 | 56 | /** 57 | * @brief Read data from Flash (size: 64KB/128KB). 58 | * 59 | * @param addr address in Flash (unit: byte). 60 | * @param data buffer to hold data. 61 | * @param size data size (unit: byte). 62 | * 63 | * @return \c 0 for success, \c non-zero for error. 64 | */ 65 | int flash_read(u32 addr, u8 *data, size_t size); 66 | 67 | /** 68 | * @brief Write data to Flash (size: 64KB/128KB). 69 | * 70 | * **Target sector will be erased.** 71 | * 72 | * @param addr address in Flash (unit: byte). 73 | * @param data buffer to hold data. 74 | * @param size data size (unit: byte). 75 | * 76 | * @return \c 0 for success, \c non-zero for error. 77 | */ 78 | int flash_write(u32 addr, u8 *data, size_t size); 79 | 80 | #endif /* GBA_Flash_H */ 81 | -------------------------------------------------------------------------------- /docs/search/enumvalues_1.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['flash_5fdev_5fat29lv512_70',['FLASH_DEV_AT29LV512',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92ba5be0e50ff4ff87beae37eed23fb59699',1,'gba_flash.h']]], 4 | ['flash_5fdev_5fle26fv10n1ts_71',['FLASH_DEV_LE26FV10N1TS',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92ba26b8dfd79125102206371a13f1f64180',1,'gba_flash.h']]], 5 | ['flash_5fdev_5fle39fw512_72',['FLASH_DEV_LE39FW512',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92bac19c8e22de0f184e4ba6d062aa18e9ad',1,'gba_flash.h']]], 6 | ['flash_5fdev_5fmn63f805mnp_73',['FLASH_DEV_MN63F805MNP',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92ba6bf8acfce89e5aaaa090eee0ebd81310',1,'gba_flash.h']]], 7 | ['flash_5fdev_5fmx29l010_74',['FLASH_DEV_MX29L010',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92ba686b8fd3e04ce30f846d3dce5c5d16b3',1,'gba_flash.h']]], 8 | ['flash_5fdev_5fmx29l512_75',['FLASH_DEV_MX29L512',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92ba37b847fcfdc7996fb7df786cc0a3666f',1,'gba_flash.h']]], 9 | ['flash_5fmfr_5fatmel_76',['FLASH_MFR_ATMEL',['../gba__flash_8h.html#a483850ee42ee3c9dda119b6ad3bcbf09a2eb8505b45b455b92c2ea744bf559e6d',1,'gba_flash.h']]], 10 | ['flash_5fmfr_5fmacronix_77',['FLASH_MFR_MACRONIX',['../gba__flash_8h.html#a483850ee42ee3c9dda119b6ad3bcbf09a4eb26978a7b87bfa44804b1e3476aa8d',1,'gba_flash.h']]], 11 | ['flash_5fmfr_5fpanasonic_78',['FLASH_MFR_PANASONIC',['../gba__flash_8h.html#a483850ee42ee3c9dda119b6ad3bcbf09a3500de851f19eed067dc902920e419e6',1,'gba_flash.h']]], 12 | ['flash_5fmfr_5fsanyo_79',['FLASH_MFR_SANYO',['../gba__flash_8h.html#a483850ee42ee3c9dda119b6ad3bcbf09aae5fd0618f564cad0fa38e3c6320f79a',1,'gba_flash.h']]], 13 | ['flash_5fmfr_5fsst_80',['FLASH_MFR_SST',['../gba__flash_8h.html#a483850ee42ee3c9dda119b6ad3bcbf09a43f58d1fb82224ed0329091bf9ddba51',1,'gba_flash.h']]], 14 | ['flash_5fsize_5f128kb_81',['FLASH_SIZE_128KB',['../gba__flash_8h.html#ac043ac24a39be2ae7922627797f564d5a727ceef6f878c536ef3f1186b6b4c06a',1,'gba_flash.h']]], 15 | ['flash_5fsize_5f64kb_82',['FLASH_SIZE_64KB',['../gba__flash_8h.html#ac043ac24a39be2ae7922627797f564d5a48ed022c40909847349c567bc6ae1f28',1,'gba_flash.h']]], 16 | ['flash_5fsize_5fauto_83',['FLASH_SIZE_AUTO',['../gba__flash_8h.html#ac043ac24a39be2ae7922627797f564d5a645f1d37d4312fcb6597f7b91f85de78',1,'gba_flash.h']]] 17 | ]; 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libsavgba 2 | A library to access various backup media in GBA cartridges 3 | 4 | [![CI](https://github.com/laqieer/libsavgba/actions/workflows/main.yml/badge.svg)](https://github.com/laqieer/libsavgba/actions/workflows/main.yml) 5 | [![CodeFactor](https://www.codefactor.io/repository/github/laqieer/libsavgba/badge)](https://www.codefactor.io/repository/github/laqieer/libsavgba) 6 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) 7 | [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) 8 | [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) 9 | [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Flaqieer%2Flibsavgba.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Flaqieer%2Flibsavgba?ref=badge_shield) 10 | 11 | ## Compatibility 12 | 13 | ### Emulator 14 | 15 | |Save Type|SRAM|EEPROM(512B)|EEPROM(8KB)|Flash(64KB)|Flash(128KB)| 16 | |---|---|---|---|---|---| 17 | |[mGBA](https://mgba.io/)|✔|✔|✔|✔|✔| 18 | |[VisualBoyAdvance-M](https://vba-m.com/)|✔|✔|✔|✔|✔| 19 | |[NanoBoyAdvance](https://github.com/fleroviux/NanoBoyAdvance)|✔|✔|✔|✔|✔| 20 | |[No$GBA](https://www.nogba.com/)|✔|✔|✔|✔|✔| 21 | |[VisualBoyAdvance](http://www.emulator-zone.com/doc.php/gba/vboyadvance.html)|✔|✔|✔|✔|✔| 22 | 23 | ### Flashcart 24 | 25 | |Save Type|SRAM|EEPROM(512B)|EEPROM(8KB)|Flash(64KB)|Flash(128KB)| 26 | |---|---|---|---|---|---| 27 | |[EZ-FLASH OMEGA](https://www.ezflash.cn/product/omega/)|✔|✔|✔|✔|✔| 28 | |[EverDrive-GBA X5](https://krikzz.com/store/home/42-everdrive-gba-x5.html)|✔|✔|✘|✔|✔| 29 | |[SuperCard MINI SD](http://chn.supercard.sc/manual/mini_sd.htm)|✔|✘|✘|✘|✘| 30 | 31 | *EverDrive-GBA X5 doesn't support 8KB EEPROM.* 32 | 33 | *SuperCard MINI SD only supports SRAM.* 34 | 35 | ## [Documentation](https://laqieer.github.io/libsavgba/) 36 | 37 | ## [Source](https://github.com/laqieer/libsavgba) 38 | 39 | ## Build 40 | 41 | `make` 42 | 43 | ## Extra 44 | 45 | [detect-save-type](https://github.com/laqieer/libsavgba/tree/main/test/detect-save-type) 46 | 47 | ## License 48 | [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Flaqieer%2Flibsavgba.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Flaqieer%2Flibsavgba?ref=badge_large) 49 | -------------------------------------------------------------------------------- /test/detect-save-type/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | struct FlashInfo { 8 | u8 device; 9 | u8 manufacturer; 10 | u8 size; 11 | }; 12 | 13 | extern struct FlashInfo gFlashInfo; 14 | 15 | int main(void) { 16 | int err; 17 | 18 | REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; 19 | 20 | tte_init_chr4c_default(0, BG_CBB(0) | BG_SBB(31)); 21 | 22 | tte_init_con(); 23 | 24 | // Test SRAM 25 | err = sram_write(0, (u8 *)"S", 1); 26 | if (!err) { 27 | tte_printf("Save Type: SRAM\n"); 28 | sram_write(0x8000, (u8 *)"R", 1); 29 | u8 a = '\0'; 30 | sram_read(0, &a, 1); 31 | switch (a) { 32 | case 'R': 33 | tte_printf("Size: 32KB\n"); 34 | break; 35 | case 'S': 36 | tte_printf("Size: 64KB\n"); 37 | break; 38 | default: 39 | tte_printf("Size: ?\n"); 40 | break; 41 | } 42 | goto end; 43 | } 44 | 45 | // Test EEPROM 46 | eeprom_init(EEPROM_SIZE_8KB); 47 | u16 data[5] = {1, 2, 3, 4, 5}; 48 | err = eeprom_write(0, data); 49 | if (!err) { 50 | eeprom_read(0, &data[1]); 51 | if (data[1] == 1) { 52 | tte_printf("Save Type: EEPROM\nSize: 8KB\n"); 53 | goto end; 54 | } 55 | } 56 | eeprom_init(EEPROM_SIZE_512B); 57 | data[0] = 1; 58 | data[1] = 2; 59 | err = eeprom_write(0, data); 60 | if (!err) { 61 | eeprom_read(0, &data[1]); 62 | if (data[1] == 1) { 63 | tte_printf("Save Type: EEPROM\nSize: 512B\n"); 64 | goto end; 65 | } 66 | } 67 | 68 | // Test Flash 69 | tte_printf("Save Type: Flash\n"); 70 | err = flash_init(FLASH_SIZE_AUTO); 71 | tte_printf("Manufacturer ID: %X\nDevice ID: %X\n", gFlashInfo.manufacturer, gFlashInfo.device); 72 | switch (gFlashInfo.size) { 73 | case FLASH_SIZE_64KB: 74 | tte_printf("Size: 64KB\n"); 75 | break; 76 | case FLASH_SIZE_128KB: 77 | tte_printf("Size: 128KB\n"); 78 | break; 79 | default: 80 | tte_printf("Size: ?\n"); 81 | break; 82 | } 83 | 84 | end: 85 | irq_init(NULL); 86 | irq_enable(II_VBLANK); 87 | 88 | while (1) { 89 | VBlankIntrWait(); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /docs/search/mag_sel.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 22 | 24 | image/svg+xml 25 | 27 | 28 | 29 | 30 | 31 | 33 | 57 | 63 | 69 | 74 | 75 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | ifeq ($(strip $(DEVKITARM)),) 5 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 6 | endif 7 | ifeq ($(strip $(DEVKITPRO)),) 8 | $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPro) 9 | endif 10 | include $(DEVKITARM)/gba_rules 11 | 12 | BUILD := build 13 | SOURCES := src 14 | INCLUDES := include 15 | 16 | ARCH := -mthumb -mthumb-interwork 17 | 18 | #--------------------------------------------------------------------------------- 19 | # options for code generation 20 | #--------------------------------------------------------------------------------- 21 | CFLAGS := -g -O3 -Wall -Wno-switch -Wno-multichar -Wno-stringop-overflow $(ARCH) $(INCLUDE) 22 | ASFLAGS := -g -Wa,--warn $(ARCH) 23 | 24 | #--------------------------------------------------------------------------------- 25 | ifneq ($(BUILD),$(notdir $(CURDIR))) 26 | 27 | export TARGET := $(CURDIR)/lib/$(notdir $(CURDIR)).a 28 | 29 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) 30 | 31 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 32 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 33 | 34 | export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 35 | 36 | export OFILES := $(OFILES_SRC) 37 | 38 | LIBTONC := $(LIBGBA)/../libtonc 39 | 40 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) -I$(LIBGBA)/include -I$(LIBTONC)/include 41 | export DEPSDIR := $(CURDIR)/build 42 | 43 | TESTS := $(wildcard test/*) 44 | 45 | .PHONY: $(BUILD) test docs version pack release clean $(TESTS) 46 | 47 | $(BUILD): 48 | @[ -d lib ] || mkdir -p lib 49 | @[ -d $@ ] || mkdir -p $@ 50 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 51 | 52 | test: $(TESTS) 53 | $(TESTS): 54 | $(MAKE) -C $@ 55 | 56 | docs: 57 | @doxygen 58 | 59 | version: 60 | @standard-version 61 | 62 | pack: 63 | @zip -r $(notdir $(CURDIR))-`cat VERSION`.zip include lib LICENSE CHANGELOG.md README.md 64 | 65 | release: 66 | @git push --follow-tags origin main 67 | @gh release create v`cat VERSION` $(notdir $(CURDIR))-`cat VERSION`.zip -F CHANGELOG.md 68 | 69 | clean: 70 | @rm -fr $(BUILD) lib *.zip 71 | @for dir in $(TESTS); do \ 72 | $(MAKE) -C $$dir -f Makefile $@; \ 73 | done 74 | 75 | 76 | #--------------------------------------------------------------------------------- 77 | else 78 | 79 | DEPENDS := $(OFILES:.o=.d) 80 | 81 | #--------------------------------------------------------------------------------- 82 | $(TARGET): $(OFILES) 83 | 84 | #--------------------------------------------------------------------------------- 85 | %.a: $(OFILES) 86 | @echo $@ 87 | @rm -f $@ 88 | @$(AR) rcs $@ $(OFILES) 89 | 90 | -include $(DEPENDS) 91 | 92 | endif 93 | #--------------------------------------------------------------------------------- 94 | -------------------------------------------------------------------------------- /docs/search/all_1.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['flash_5fdev_5fat29lv512_14',['FLASH_DEV_AT29LV512',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92ba5be0e50ff4ff87beae37eed23fb59699',1,'gba_flash.h']]], 4 | ['flash_5fdev_5fle26fv10n1ts_15',['FLASH_DEV_LE26FV10N1TS',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92ba26b8dfd79125102206371a13f1f64180',1,'gba_flash.h']]], 5 | ['flash_5fdev_5fle39fw512_16',['FLASH_DEV_LE39FW512',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92bac19c8e22de0f184e4ba6d062aa18e9ad',1,'gba_flash.h']]], 6 | ['flash_5fdev_5fmn63f805mnp_17',['FLASH_DEV_MN63F805MNP',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92ba6bf8acfce89e5aaaa090eee0ebd81310',1,'gba_flash.h']]], 7 | ['flash_5fdev_5fmx29l010_18',['FLASH_DEV_MX29L010',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92ba686b8fd3e04ce30f846d3dce5c5d16b3',1,'gba_flash.h']]], 8 | ['flash_5fdev_5fmx29l512_19',['FLASH_DEV_MX29L512',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92ba37b847fcfdc7996fb7df786cc0a3666f',1,'gba_flash.h']]], 9 | ['flash_5finit_20',['flash_init',['../gba__flash_8h.html#aff94b5e5322c8d6944577eb78290387c',1,'gba_flash.h']]], 10 | ['flash_5fmfr_5fatmel_21',['FLASH_MFR_ATMEL',['../gba__flash_8h.html#a483850ee42ee3c9dda119b6ad3bcbf09a2eb8505b45b455b92c2ea744bf559e6d',1,'gba_flash.h']]], 11 | ['flash_5fmfr_5fmacronix_22',['FLASH_MFR_MACRONIX',['../gba__flash_8h.html#a483850ee42ee3c9dda119b6ad3bcbf09a4eb26978a7b87bfa44804b1e3476aa8d',1,'gba_flash.h']]], 12 | ['flash_5fmfr_5fpanasonic_23',['FLASH_MFR_PANASONIC',['../gba__flash_8h.html#a483850ee42ee3c9dda119b6ad3bcbf09a3500de851f19eed067dc902920e419e6',1,'gba_flash.h']]], 13 | ['flash_5fmfr_5fsanyo_24',['FLASH_MFR_SANYO',['../gba__flash_8h.html#a483850ee42ee3c9dda119b6ad3bcbf09aae5fd0618f564cad0fa38e3c6320f79a',1,'gba_flash.h']]], 14 | ['flash_5fmfr_5fsst_25',['FLASH_MFR_SST',['../gba__flash_8h.html#a483850ee42ee3c9dda119b6ad3bcbf09a43f58d1fb82224ed0329091bf9ddba51',1,'gba_flash.h']]], 15 | ['flash_5fread_26',['flash_read',['../gba__flash_8h.html#a2290d15f7440e9aff7c210569f80ea96',1,'gba_flash.h']]], 16 | ['flash_5freset_27',['flash_reset',['../gba__flash_8h.html#a72a5873c0849104c17b408a6f4a342cf',1,'gba_flash.h']]], 17 | ['flash_5fsize_5f128kb_28',['FLASH_SIZE_128KB',['../gba__flash_8h.html#ac043ac24a39be2ae7922627797f564d5a727ceef6f878c536ef3f1186b6b4c06a',1,'gba_flash.h']]], 18 | ['flash_5fsize_5f64kb_29',['FLASH_SIZE_64KB',['../gba__flash_8h.html#ac043ac24a39be2ae7922627797f564d5a48ed022c40909847349c567bc6ae1f28',1,'gba_flash.h']]], 19 | ['flash_5fsize_5fauto_30',['FLASH_SIZE_AUTO',['../gba__flash_8h.html#ac043ac24a39be2ae7922627797f564d5a645f1d37d4312fcb6597f7b91f85de78',1,'gba_flash.h']]], 20 | ['flash_5fwrite_31',['flash_write',['../gba__flash_8h.html#ae5ee71a3c76ec9c8ea79d6229281634d',1,'gba_flash.h']]], 21 | ['flashdevice_32',['FlashDevice',['../gba__flash_8h.html#a1a5ac84714feab807c1c20cbb8b0e92b',1,'gba_flash.h']]], 22 | ['flashmanufacturer_33',['FlashManufacturer',['../gba__flash_8h.html#a483850ee42ee3c9dda119b6ad3bcbf09',1,'gba_flash.h']]], 23 | ['flashsize_34',['FlashSize',['../gba__flash_8h.html#ac043ac24a39be2ae7922627797f564d5',1,'gba_flash.h']]] 24 | ]; 25 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | libsavgba: Main Page 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 | 21 | 22 | 23 | 28 | 29 | 30 |
24 |
libsavgba 25 |
26 |
A library to access various backup media in GBA cartridges
27 |
31 |
32 | 33 | 34 | 39 | 40 | 41 | 48 | 49 |
50 | 51 |
55 |
56 | 57 | 58 |
59 | 62 |
63 | 64 |
65 |
66 |
libsavgba Documentation
67 |
68 |
69 |
70 | 71 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /docs/globals_vars.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | libsavgba: Globals 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 | 21 | 22 | 23 | 28 | 29 | 30 |
24 |
libsavgba 25 |
26 |
A library to access various backup media in GBA cartridges
27 |
31 |
32 | 33 | 34 | 39 | 40 | 41 | 48 | 49 |
50 | 51 |
55 |
56 | 57 | 58 |
59 | 62 |
63 | 64 |
65 |   73 |
74 | 75 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /docs/menu.js: -------------------------------------------------------------------------------- 1 | /* 2 | @licstart The following is the entire license notice for the JavaScript code in this file. 3 | 4 | The MIT License (MIT) 5 | 6 | Copyright (C) 1997-2020 by Dimitri van Heesch 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software 9 | and associated documentation files (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all copies or 15 | substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 18 | BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | @licend The above is the entire license notice for the JavaScript code in this file 24 | */ 25 | function initMenu(relPath,searchEnabled,serverSide,searchPage,search) { 26 | function makeTree(data,relPath) { 27 | var result=''; 28 | if ('children' in data) { 29 | result+=''; 36 | } 37 | return result; 38 | } 39 | 40 | $('#main-nav').append(makeTree(menudata,relPath)); 41 | $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu'); 42 | if (searchEnabled) { 43 | if (serverSide) { 44 | $('#main-menu').append('
  • '); 45 | } else { 46 | $('#main-menu').append('
  • '); 47 | } 48 | } 49 | $('#main-menu').smartmenus(); 50 | } 51 | /* @license-end */ 52 | -------------------------------------------------------------------------------- /src/gba_eeprom.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "err_def.h" 6 | #include "gba_eeprom.h" 7 | 8 | #define MEM_EEPROM 0x0D000000 9 | #define eeprom_mem ((vu16*)MEM_EEPROM) 10 | 11 | #define EEPROM_512_gEepromSize 6 12 | #define EEPROM_8K_gEepromSize 14 13 | 14 | #define LOOP_CNT_PER_MILLI_SECOND 1000 15 | #define EEPROM_WRITE_TIMEOUT_BY_MILLI_SECOND 10 16 | 17 | u8 gEepromSize; 18 | 19 | void eeprom_memcpy(volatile void *dst, volatile const void *src, size_t size) 20 | { 21 | u16 REG_IME_old = REG_IME; 22 | REG_IME = 0; 23 | REG_WAITCNT = (REG_WAITCNT & (~0x700)) | WS_ROM2_N8; 24 | DMA_TRANSFER(dst, src, size, 3, DMA_ENABLE); 25 | while(REG_DMA3CNT_H & 0x8000); 26 | REG_IME = REG_IME_old; 27 | } 28 | 29 | int eeprom_init(u8 size) 30 | { 31 | if (size == EEPROM_SIZE_512B || size == EEPROM_SIZE_8KB) 32 | gEepromSize = size; 33 | else 34 | return E_UNSUPPORTED_DEVICE; 35 | 36 | return 0; 37 | } 38 | 39 | int eeprom_read(u32 addr, u16 *data) 40 | { 41 | u16 buffer[68]; 42 | 43 | if (data == NULL) 44 | { 45 | return E_INVALID_PARAM; 46 | } 47 | 48 | if (addr >= 1 << gEepromSize) 49 | { 50 | return E_OUT_OF_RANGE; 51 | } 52 | 53 | buffer[0] = 1; 54 | buffer[1] = 1; 55 | buffer[2 + gEepromSize] = 0; 56 | for (int i = 1 + gEepromSize; i >= 2; i--) 57 | { 58 | buffer[i] = addr & 1; 59 | addr = addr >> 1; 60 | } 61 | eeprom_memcpy(eeprom_mem, buffer, 3 + gEepromSize); 62 | 63 | eeprom_memcpy(buffer, eeprom_mem, 68); 64 | 65 | for (int i = 3; i >= 0; i--) 66 | { 67 | data[i] = 0; 68 | for (int j = 0; j < 16; j++) 69 | { 70 | data[i] |= (buffer[4 + 16 * (3 - i) + j] & 1) << (15 - j); 71 | } 72 | } 73 | 74 | return 0; 75 | } 76 | 77 | int eeprom_write_only(u32 addr, u16 *data) 78 | { 79 | u16 buffer[81]; 80 | 81 | if (data == NULL) 82 | { 83 | return E_INVALID_PARAM; 84 | } 85 | 86 | if (addr >= 1 << gEepromSize) 87 | { 88 | return E_OUT_OF_RANGE; 89 | } 90 | 91 | buffer[0] = 1; 92 | buffer[1] = 0; 93 | buffer[66 + gEepromSize] = 0; 94 | for (int i = 1 + gEepromSize; i >= 2; i--) 95 | { 96 | buffer[i] = addr & 1; 97 | addr = addr >> 1; 98 | } 99 | for (int i = 0; i < 4; i++) 100 | { 101 | for (int j = 0; j < 16; j++) 102 | { 103 | buffer[65 + gEepromSize - 16 * i - j] = (data[i] >> j) & 1; 104 | } 105 | } 106 | eeprom_memcpy(eeprom_mem, buffer, 67 + gEepromSize); 107 | 108 | // After the DMA, keep reading from the chip, by normal LDRH [D000000h], until Bit 0 of the returned data becomes “1” (Ready). 109 | // To prevent your program from locking up in case of malfunction, generate a timeout if the chip does not reply after 10ms or longer. 110 | for (vu32 i = 0; i < LOOP_CNT_PER_MILLI_SECOND * EEPROM_WRITE_TIMEOUT_BY_MILLI_SECOND; i++) 111 | if (*eeprom_mem & 1) 112 | return 0; 113 | 114 | return E_TIMEOUT; 115 | } 116 | 117 | int eeprom_write(u32 addr, u16 *data) 118 | { 119 | int err; 120 | u16 buffer[4]; 121 | 122 | err = eeprom_write_only(addr, data); 123 | if (err) 124 | return err; 125 | 126 | err = eeprom_read(addr, buffer); 127 | if (err) 128 | return err; 129 | 130 | if (data[0] != buffer[0] || data[1] != buffer[1] ||data[2] != buffer[2] ||data[3] != buffer[3]) 131 | return E_VERIFY_FAIL; 132 | 133 | return 0; 134 | } 135 | -------------------------------------------------------------------------------- /docs/globals_enum.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | libsavgba: Globals 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 28 | 29 | 30 |
    24 |
    libsavgba 25 |
    26 |
    A library to access various backup media in GBA cartridges
    27 |
    31 |
    32 | 33 | 34 | 39 | 40 | 41 | 48 | 49 |
    50 | 51 |
    55 |
    56 | 57 | 58 |
    59 | 62 |
    63 | 64 |
    65 |   82 |
    83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /docs/globals_func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | libsavgba: Globals 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 28 | 29 | 30 |
    24 |
    libsavgba 25 |
    26 |
    A library to access various backup media in GBA cartridges
    27 |
    31 |
    32 | 33 | 34 | 39 | 40 | 41 | 48 | 49 |
    50 | 51 |
    55 |
    56 | 57 | 58 |
    59 | 62 |
    63 | 64 |
    65 |   94 |
    95 | 96 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ## [3.3.0](https://github.com/laqieer/libsavgba/compare/v3.2.0...v3.3.0) (2021-07-05) 6 | 7 | 8 | ### Features 9 | 10 | * add support to show error codes and error messages ([9e21e59](https://github.com/laqieer/libsavgba/commit/9e21e59eaef13059e55fce8d11c9d55fce0b8396)) 11 | * add verify in eeprom_write ([3fbd992](https://github.com/laqieer/libsavgba/commit/3fbd99282c2e81549b0799ce06f054d6c90864e2)) 12 | * support cross-sector flash write ([0c7e19a](https://github.com/laqieer/libsavgba/commit/0c7e19a760c577e2975a0e9b75701f855c8480e8)) 13 | 14 | ## [3.2.0](https://github.com/laqieer/libsavgba/compare/v3.1.2...v3.2.0) (2021-07-05) 15 | 16 | 17 | ### Features 18 | 19 | * add an extra tool: detect-save-type ([da45a5a](https://github.com/laqieer/libsavgba/commit/da45a5ac5fd289291910426b7f5c9a70cf57ac7a)) 20 | 21 | ### [3.1.2](https://github.com/laqieer/libsavgba/compare/v3.1.1...v3.1.2) (2021-07-03) 22 | 23 | 24 | ### Bug Fixes 25 | 26 | * fix 512B EEPROM's compatibility with EverDrive-GBA X5 ([a2e9b30](https://github.com/laqieer/libsavgba/commit/a2e9b30ea6860bc5493453763aec923509671fed)) 27 | 28 | ### [3.1.1](https://github.com/laqieer/libsavgba/compare/v3.1.0...v3.1.1) (2021-07-03) 29 | 30 | 31 | ### Bug Fixes 32 | 33 | * fix Flash's compatibility with vba and vba-m ([8f9d5e9](https://github.com/laqieer/libsavgba/commit/8f9d5e9ab1abd23f3e346a4106e841d2288722f5)) 34 | 35 | ## [3.1.0](https://github.com/laqieer/libsavgba/compare/v3.0.0...v3.1.0) (2021-07-03) 36 | 37 | 38 | ### Features 39 | 40 | * add backup media support for Atmel's Flash ([e77831e](https://github.com/laqieer/libsavgba/commit/e77831e90c007776125acbb92fd0556ccfd99596)) 41 | 42 | ## [3.0.0](https://github.com/laqieer/libsavgba/compare/v2.0.0...v3.0.0) (2021-07-02) 43 | 44 | 45 | ### ⚠ BREAKING CHANGES 46 | 47 | * add eeprom_init(), rename eeprom_512_read() and eeprom_8K_read() to eeprom_read(), 48 | rename eeprom_512_write() and eeprom_8K_write() to eeprom_write() 49 | 50 | ### Features 51 | 52 | * add 10ms timeout for eeprom_write() ([8053a4d](https://github.com/laqieer/libsavgba/commit/8053a4dced8fc0b5c010f3be756ce10c1bd7916a)) 53 | * unify read and write function for backup media EEPROM ([66abae8](https://github.com/laqieer/libsavgba/commit/66abae8995703028ab3aac52dbeb02c6f43136be)) 54 | 55 | 56 | ### Bug Fixes 57 | 58 | * fix detection after write data to EEPROM ([4e32a74](https://github.com/laqieer/libsavgba/commit/4e32a746f7c1c3e6251dd8552cc808444dee218f)) 59 | * fix out of range detection ([2263825](https://github.com/laqieer/libsavgba/commit/2263825591d1e7edb0f2c7ef8c6227a7282871b8)) 60 | 61 | ## [2.0.0](https://github.com/laqieer/libsavgba/compare/v1.2.0...v2.0.0) (2021-07-02) 62 | 63 | 64 | ### ⚠ BREAKING CHANGES 65 | 66 | * add a parameter to specify the flash size to flash_init(), just pass `0` if you 67 | don't want to specify it, then it will be detected automatically by flash chip identification 68 | operation 69 | 70 | ### Features 71 | 72 | * add backup media support for 128KB Flash ([faefc2b](https://github.com/laqieer/libsavgba/commit/faefc2bcdf0586a17affb70fb2ad4587faf6d432)) 73 | 74 | ## [1.2.0](https://github.com/laqieer/libsavgba/compare/v1.1.0...v1.2.0) (2021-07-02) 75 | 76 | 77 | ### Features 78 | 79 | * add backup media support for 64KB Flash ([e104422](https://github.com/laqieer/libsavgba/commit/e10442283b73391c42d1b8edf57650e5b23f8c83)) 80 | 81 | ## [1.1.0](https://github.com/laqieer/libsavgba/compare/v1.0.0...v1.1.0) (2021-06-30) 82 | 83 | 84 | ### Features 85 | 86 | * add backup media support for EEPROM ([dbe36a0](https://github.com/laqieer/libsavgba/commit/dbe36a016beed6340475e4e21bd332a1bd642a9a)) 87 | 88 | 89 | ### Bug Fixes 90 | 91 | * fix Cart Backup IDs ([2c94c88](https://github.com/laqieer/libsavgba/commit/2c94c88cc657d59ea1ee7e621569f4ea224b768f)) 92 | * fix infinite loop in eeprom_write ([40fb7fe](https://github.com/laqieer/libsavgba/commit/40fb7fe3aac921a0eab94fde70441e13d411e04b)) 93 | 94 | ## 1.0.0 (2021-06-29) 95 | 96 | 97 | ### Features 98 | 99 | * add backup media support for SRAM ([91a9e57](https://github.com/laqieer/libsavgba/commit/91a9e57b3d1fecd1d1af731d7764e2e739adab9c)) 100 | -------------------------------------------------------------------------------- /docs/dir_d44c64559bbebec7f509842c48db8b23.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | libsavgba: include Directory Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 28 | 29 | 30 |
    24 |
    libsavgba 25 |
    26 |
    A library to access various backup media in GBA cartridges
    27 |
    31 |
    32 | 33 | 34 | 39 | 40 | 41 | 48 | 49 | 50 |
    54 |
    55 | 56 | 57 |
    58 | 61 |
    62 | 63 | 67 |
    68 |
    69 |
    70 |
    include Directory Reference
    71 |
    72 |
    73 | 74 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 |

    75 | Files

    file  err_def.h [code]
     
    file  gba_eeprom.h [code]
     
    file  gba_flash.h [code]
     
    file  gba_sram.h [code]
     
    85 |
    86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /docs/files.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | libsavgba: File List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 28 | 29 | 30 |
    24 |
    libsavgba 25 |
    26 |
    A library to access various backup media in GBA cartridges
    27 |
    31 |
    32 | 33 | 34 | 39 | 40 | 41 | 48 | 49 |
    50 | 51 |
    55 |
    56 | 57 | 58 |
    59 | 62 |
    63 | 64 |
    65 |
    66 |
    File List
    67 |
    68 |
    69 |
    Here is a list of all files with brief descriptions:
    70 |
    [detail level 12]
    71 | 72 | 73 | 74 | 75 | 76 |
      include
     err_def.h
     gba_eeprom.h
     gba_flash.h
     gba_sram.h
    77 |
    78 |
    79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/dynsections.js: -------------------------------------------------------------------------------- 1 | /* 2 | @licstart The following is the entire license notice for the JavaScript code in this file. 3 | 4 | The MIT License (MIT) 5 | 6 | Copyright (C) 1997-2020 by Dimitri van Heesch 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software 9 | and associated documentation files (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all copies or 15 | substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 18 | BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | @licend The above is the entire license notice for the JavaScript code in this file 24 | */ 25 | function toggleVisibility(linkObj) 26 | { 27 | var base = $(linkObj).attr('id'); 28 | var summary = $('#'+base+'-summary'); 29 | var content = $('#'+base+'-content'); 30 | var trigger = $('#'+base+'-trigger'); 31 | var src=$(trigger).attr('src'); 32 | if (content.is(':visible')===true) { 33 | content.hide(); 34 | summary.show(); 35 | $(linkObj).addClass('closed').removeClass('opened'); 36 | $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); 37 | } else { 38 | content.show(); 39 | summary.hide(); 40 | $(linkObj).removeClass('closed').addClass('opened'); 41 | $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); 42 | } 43 | return false; 44 | } 45 | 46 | function updateStripes() 47 | { 48 | $('table.directory tr'). 49 | removeClass('even').filter(':visible:even').addClass('even'); 50 | } 51 | 52 | function toggleLevel(level) 53 | { 54 | $('table.directory tr').each(function() { 55 | var l = this.id.split('_').length-1; 56 | var i = $('#img'+this.id.substring(3)); 57 | var a = $('#arr'+this.id.substring(3)); 58 | if (l 2 | 3 | 4 | 5 | 6 | 7 | 8 | libsavgba: include/gba_sram.h Source File 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 28 | 29 | 30 |
    24 |
    libsavgba 25 |
    26 |
    A library to access various backup media in GBA cartridges
    27 |
    31 |
    32 | 33 | 34 | 39 | 40 | 41 | 48 | 49 | 50 |
    54 |
    55 | 56 | 57 |
    58 | 61 |
    62 | 63 | 67 |
    68 |
    69 |
    70 |
    gba_sram.h
    71 |
    72 |
    73 | Go to the documentation of this file.
    1 #ifndef GBA_SRAM_H
    74 |
    2 #define GBA_SRAM_H
    75 |
    3 
    76 |
    13 int sram_read(u32 addr, u8 *data, size_t size);
    77 |
    14 
    78 |
    24 int sram_write(u32 addr, u8 *data, size_t size);
    79 |
    25 
    80 |
    26 #endif /* GBA_SRAM_H */
    81 |
    int sram_write(u32 addr, u8 *data, size_t size)
    Write data to SRAM.
    82 |
    int sram_read(u32 addr, u8 *data, size_t size)
    Read data from SRAM.
    83 |
    84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/search/search.css: -------------------------------------------------------------------------------- 1 | /*---------------- Search Box */ 2 | 3 | #MSearchBox { 4 | white-space : nowrap; 5 | background: white; 6 | border-radius: 0.65em; 7 | box-shadow: inset 0.5px 0.5px 3px 0px #555; 8 | z-index: 102; 9 | } 10 | 11 | #MSearchBox .left { 12 | display: inline-block; 13 | vertical-align: middle; 14 | height: 1.4em; 15 | } 16 | 17 | #MSearchSelect { 18 | display: inline-block; 19 | vertical-align: middle; 20 | height: 1.4em; 21 | padding: 0 0 0 0.3em; 22 | margin: 0; 23 | } 24 | 25 | #MSearchField { 26 | display: inline-block; 27 | vertical-align: middle; 28 | width: 7.5em; 29 | height: 1.1em; 30 | margin: 0 0.15em; 31 | padding: 0; 32 | line-height: 1em; 33 | border:none; 34 | color: #909090; 35 | outline: none; 36 | font-family: Arial, Verdana, sans-serif; 37 | -webkit-border-radius: 0px; 38 | border-radius: 0px; 39 | background: none; 40 | } 41 | 42 | 43 | #MSearchBox .right { 44 | display: inline-block; 45 | vertical-align: middle; 46 | width: 1.4em; 47 | height: 1.4em; 48 | } 49 | 50 | #MSearchClose { 51 | display: none; 52 | font-size: inherit; 53 | background : none; 54 | border: none; 55 | margin: 0; 56 | padding: 0; 57 | outline: none; 58 | 59 | } 60 | 61 | #MSearchCloseImg { 62 | height: 1.4em; 63 | padding: 0.3em; 64 | margin: 0; 65 | } 66 | 67 | .MSearchBoxActive #MSearchField { 68 | color: #000000; 69 | } 70 | 71 | #main-menu > li:last-child { 72 | /* This
  • object is the parent of the search bar */ 73 | display: flex; 74 | justify-content: center; 75 | align-items: center; 76 | height: 36px; 77 | margin-right: 1em; 78 | } 79 | 80 | /*---------------- Search filter selection */ 81 | 82 | #MSearchSelectWindow { 83 | display: none; 84 | position: absolute; 85 | left: 0; top: 0; 86 | border: 1px solid #90A5CE; 87 | background-color: #F9FAFC; 88 | z-index: 10001; 89 | padding-top: 4px; 90 | padding-bottom: 4px; 91 | -moz-border-radius: 4px; 92 | -webkit-border-top-left-radius: 4px; 93 | -webkit-border-top-right-radius: 4px; 94 | -webkit-border-bottom-left-radius: 4px; 95 | -webkit-border-bottom-right-radius: 4px; 96 | -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); 97 | } 98 | 99 | .SelectItem { 100 | font: 8pt Arial, Verdana, sans-serif; 101 | padding-left: 2px; 102 | padding-right: 12px; 103 | border: 0px; 104 | } 105 | 106 | span.SelectionMark { 107 | margin-right: 4px; 108 | font-family: monospace; 109 | outline-style: none; 110 | text-decoration: none; 111 | } 112 | 113 | a.SelectItem { 114 | display: block; 115 | outline-style: none; 116 | color: #000000; 117 | text-decoration: none; 118 | padding-left: 6px; 119 | padding-right: 12px; 120 | } 121 | 122 | a.SelectItem:focus, 123 | a.SelectItem:active { 124 | color: #000000; 125 | outline-style: none; 126 | text-decoration: none; 127 | } 128 | 129 | a.SelectItem:hover { 130 | color: #FFFFFF; 131 | background-color: #3D578C; 132 | outline-style: none; 133 | text-decoration: none; 134 | cursor: pointer; 135 | display: block; 136 | } 137 | 138 | /*---------------- Search results window */ 139 | 140 | iframe#MSearchResults { 141 | width: 60ex; 142 | height: 15em; 143 | } 144 | 145 | #MSearchResultsWindow { 146 | display: none; 147 | position: absolute; 148 | left: 0; top: 0; 149 | border: 1px solid #000; 150 | background-color: #EEF1F7; 151 | z-index:10000; 152 | } 153 | 154 | /* ----------------------------------- */ 155 | 156 | 157 | #SRIndex { 158 | clear:both; 159 | padding-bottom: 15px; 160 | } 161 | 162 | .SREntry { 163 | font-size: 10pt; 164 | padding-left: 1ex; 165 | } 166 | 167 | .SRPage .SREntry { 168 | font-size: 8pt; 169 | padding: 1px 5px; 170 | } 171 | 172 | body.SRPage { 173 | margin: 5px 2px; 174 | } 175 | 176 | .SRChildren { 177 | padding-left: 3ex; padding-bottom: .5em 178 | } 179 | 180 | .SRPage .SRChildren { 181 | display: none; 182 | } 183 | 184 | .SRSymbol { 185 | font-weight: bold; 186 | color: #425E97; 187 | font-family: Arial, Verdana, sans-serif; 188 | text-decoration: none; 189 | outline: none; 190 | } 191 | 192 | a.SRScope { 193 | display: block; 194 | color: #425E97; 195 | font-family: Arial, Verdana, sans-serif; 196 | text-decoration: none; 197 | outline: none; 198 | } 199 | 200 | a.SRSymbol:focus, a.SRSymbol:active, 201 | a.SRScope:focus, a.SRScope:active { 202 | text-decoration: underline; 203 | } 204 | 205 | span.SRScope { 206 | padding-left: 4px; 207 | font-family: Arial, Verdana, sans-serif; 208 | } 209 | 210 | .SRPage .SRStatus { 211 | padding: 2px 5px; 212 | font-size: 8pt; 213 | font-style: italic; 214 | font-family: Arial, Verdana, sans-serif; 215 | } 216 | 217 | .SRResult { 218 | display: none; 219 | } 220 | 221 | div.searchresults { 222 | margin-left: 10px; 223 | margin-right: 10px; 224 | } 225 | 226 | /*---------------- External search page results */ 227 | 228 | .searchresult { 229 | background-color: #F0F3F8; 230 | } 231 | 232 | .pages b { 233 | color: white; 234 | padding: 5px 5px 3px 5px; 235 | background-image: url("../tab_a.png"); 236 | background-repeat: repeat-x; 237 | text-shadow: 0 1px 1px #000000; 238 | } 239 | 240 | .pages { 241 | line-height: 17px; 242 | margin-left: 4px; 243 | text-decoration: none; 244 | } 245 | 246 | .hl { 247 | font-weight: bold; 248 | } 249 | 250 | #searchresults { 251 | margin-bottom: 20px; 252 | } 253 | 254 | .searchpages { 255 | margin-top: 10px; 256 | } 257 | 258 | -------------------------------------------------------------------------------- /docs/globals_eval.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | libsavgba: Globals 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 28 | 29 | 30 |
    24 |
    libsavgba 25 |
    26 |
    A library to access various backup media in GBA cartridges
    27 |
    31 |
    32 | 33 | 34 | 39 | 40 | 41 | 48 | 49 |
    50 | 51 |
    55 |
    56 | 57 | 58 |
    59 | 62 |
    63 | 64 |
    65 |   133 |
    134 | 135 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /test/sram/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/gba_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # the LIBGBA path is defined in gba_rules, but we have to define LIBTONC ourselves 13 | #--------------------------------------------------------------------------------- 14 | LIBTONC := $(DEVKITPRO)/libtonc 15 | 16 | #--------------------------------------------------------------------------------- 17 | # TARGET is the name of the output 18 | # BUILD is the directory where object files & intermediate files will be placed 19 | # SOURCES is a list of directories containing source code 20 | # INCLUDES is a list of directories containing extra header files 21 | # DATA is a list of directories containing binary data 22 | # GRAPHICS is a list of directories containing files to be processed by grit 23 | # 24 | # All directories are specified relative to the project directory where 25 | # the makefile is found 26 | # 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := . 31 | INCLUDES := ../../include 32 | DATA := 33 | MUSIC := 34 | 35 | #--------------------------------------------------------------------------------- 36 | # options for code generation 37 | #--------------------------------------------------------------------------------- 38 | ARCH := -mthumb -mthumb-interwork 39 | 40 | CFLAGS := -g -Wall -O2\ 41 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 42 | $(ARCH) 43 | 44 | CFLAGS += $(INCLUDE) 45 | 46 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 47 | 48 | ASFLAGS := -g $(ARCH) 49 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) 50 | 51 | #--------------------------------------------------------------------------------- 52 | # any extra libraries we wish to link with the project 53 | #--------------------------------------------------------------------------------- 54 | LIBS := -lmm -ltonc -lsavgba 55 | 56 | 57 | #--------------------------------------------------------------------------------- 58 | # list of directories containing libraries, this must be the top level containing 59 | # include and lib. 60 | # the LIBGBA path should remain in this list if you want to use maxmod 61 | #--------------------------------------------------------------------------------- 62 | LIBDIRS := $(LIBGBA) $(LIBTONC) ../../.. 63 | 64 | #--------------------------------------------------------------------------------- 65 | # no real need to edit anything past this point unless you need to add additional 66 | # rules for different file extensions 67 | #--------------------------------------------------------------------------------- 68 | 69 | 70 | ifneq ($(BUILD),$(notdir $(CURDIR))) 71 | #--------------------------------------------------------------------------------- 72 | 73 | export OUTPUT := $(CURDIR)/$(TARGET) 74 | 75 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 76 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 77 | $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) 78 | 79 | export DEPSDIR := $(CURDIR)/$(BUILD) 80 | 81 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 82 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 83 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 84 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 85 | 86 | ifneq ($(strip $(MUSIC)),) 87 | export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) 88 | BINFILES += soundbank.bin 89 | endif 90 | 91 | #--------------------------------------------------------------------------------- 92 | # use CXX for linking C++ projects, CC for standard C 93 | #--------------------------------------------------------------------------------- 94 | ifeq ($(strip $(CPPFILES)),) 95 | #--------------------------------------------------------------------------------- 96 | export LD := $(CC) 97 | #--------------------------------------------------------------------------------- 98 | else 99 | #--------------------------------------------------------------------------------- 100 | export LD := $(CXX) 101 | #--------------------------------------------------------------------------------- 102 | endif 103 | #--------------------------------------------------------------------------------- 104 | 105 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 106 | 107 | export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 108 | 109 | export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) 110 | 111 | export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) 112 | 113 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ 114 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 115 | -I$(CURDIR)/$(BUILD) 116 | 117 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 118 | 119 | .PHONY: $(BUILD) clean 120 | 121 | #--------------------------------------------------------------------------------- 122 | $(BUILD): 123 | @[ -d $@ ] || mkdir -p $@ 124 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 125 | 126 | #--------------------------------------------------------------------------------- 127 | clean: 128 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba $(TARGET).sav 129 | 130 | 131 | #--------------------------------------------------------------------------------- 132 | else 133 | 134 | #--------------------------------------------------------------------------------- 135 | # main targets 136 | #--------------------------------------------------------------------------------- 137 | 138 | $(OUTPUT).gba : $(OUTPUT).elf 139 | 140 | $(OUTPUT).elf : $(OFILES) 141 | 142 | $(OFILES_SOURCES) : $(HFILES) 143 | 144 | #--------------------------------------------------------------------------------- 145 | # The bin2o rule should be copied and modified 146 | # for each extension used in the data directories 147 | #--------------------------------------------------------------------------------- 148 | 149 | #--------------------------------------------------------------------------------- 150 | # rule to build soundbank from music files 151 | #--------------------------------------------------------------------------------- 152 | soundbank.bin soundbank.h : $(AUDIOFILES) 153 | #--------------------------------------------------------------------------------- 154 | @mmutil $^ -osoundbank.bin -hsoundbank.h 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o %_bin.h : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | 165 | -include $(DEPSDIR)/*.d 166 | #--------------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------------- 169 | -------------------------------------------------------------------------------- /test/eeprom-512B/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/gba_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # the LIBGBA path is defined in gba_rules, but we have to define LIBTONC ourselves 13 | #--------------------------------------------------------------------------------- 14 | LIBTONC := $(DEVKITPRO)/libtonc 15 | 16 | #--------------------------------------------------------------------------------- 17 | # TARGET is the name of the output 18 | # BUILD is the directory where object files & intermediate files will be placed 19 | # SOURCES is a list of directories containing source code 20 | # INCLUDES is a list of directories containing extra header files 21 | # DATA is a list of directories containing binary data 22 | # GRAPHICS is a list of directories containing files to be processed by grit 23 | # 24 | # All directories are specified relative to the project directory where 25 | # the makefile is found 26 | # 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := . 31 | INCLUDES := ../../include 32 | DATA := 33 | MUSIC := 34 | 35 | #--------------------------------------------------------------------------------- 36 | # options for code generation 37 | #--------------------------------------------------------------------------------- 38 | ARCH := -mthumb -mthumb-interwork 39 | 40 | CFLAGS := -g -Wall -O2\ 41 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 42 | $(ARCH) 43 | 44 | CFLAGS += $(INCLUDE) 45 | 46 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 47 | 48 | ASFLAGS := -g $(ARCH) 49 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) 50 | 51 | #--------------------------------------------------------------------------------- 52 | # any extra libraries we wish to link with the project 53 | #--------------------------------------------------------------------------------- 54 | LIBS := -lmm -ltonc -lsavgba 55 | 56 | 57 | #--------------------------------------------------------------------------------- 58 | # list of directories containing libraries, this must be the top level containing 59 | # include and lib. 60 | # the LIBGBA path should remain in this list if you want to use maxmod 61 | #--------------------------------------------------------------------------------- 62 | LIBDIRS := $(LIBGBA) $(LIBTONC) ../../.. 63 | 64 | #--------------------------------------------------------------------------------- 65 | # no real need to edit anything past this point unless you need to add additional 66 | # rules for different file extensions 67 | #--------------------------------------------------------------------------------- 68 | 69 | 70 | ifneq ($(BUILD),$(notdir $(CURDIR))) 71 | #--------------------------------------------------------------------------------- 72 | 73 | export OUTPUT := $(CURDIR)/$(TARGET) 74 | 75 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 76 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 77 | $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) 78 | 79 | export DEPSDIR := $(CURDIR)/$(BUILD) 80 | 81 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 82 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 83 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 84 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 85 | 86 | ifneq ($(strip $(MUSIC)),) 87 | export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) 88 | BINFILES += soundbank.bin 89 | endif 90 | 91 | #--------------------------------------------------------------------------------- 92 | # use CXX for linking C++ projects, CC for standard C 93 | #--------------------------------------------------------------------------------- 94 | ifeq ($(strip $(CPPFILES)),) 95 | #--------------------------------------------------------------------------------- 96 | export LD := $(CC) 97 | #--------------------------------------------------------------------------------- 98 | else 99 | #--------------------------------------------------------------------------------- 100 | export LD := $(CXX) 101 | #--------------------------------------------------------------------------------- 102 | endif 103 | #--------------------------------------------------------------------------------- 104 | 105 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 106 | 107 | export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 108 | 109 | export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) 110 | 111 | export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) 112 | 113 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ 114 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 115 | -I$(CURDIR)/$(BUILD) 116 | 117 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 118 | 119 | .PHONY: $(BUILD) clean 120 | 121 | #--------------------------------------------------------------------------------- 122 | $(BUILD): 123 | @[ -d $@ ] || mkdir -p $@ 124 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 125 | 126 | #--------------------------------------------------------------------------------- 127 | clean: 128 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba $(TARGET).sav 129 | 130 | 131 | #--------------------------------------------------------------------------------- 132 | else 133 | 134 | #--------------------------------------------------------------------------------- 135 | # main targets 136 | #--------------------------------------------------------------------------------- 137 | 138 | $(OUTPUT).gba : $(OUTPUT).elf 139 | 140 | $(OUTPUT).elf : $(OFILES) 141 | 142 | $(OFILES_SOURCES) : $(HFILES) 143 | 144 | #--------------------------------------------------------------------------------- 145 | # The bin2o rule should be copied and modified 146 | # for each extension used in the data directories 147 | #--------------------------------------------------------------------------------- 148 | 149 | #--------------------------------------------------------------------------------- 150 | # rule to build soundbank from music files 151 | #--------------------------------------------------------------------------------- 152 | soundbank.bin soundbank.h : $(AUDIOFILES) 153 | #--------------------------------------------------------------------------------- 154 | @mmutil $^ -osoundbank.bin -hsoundbank.h 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o %_bin.h : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | 165 | -include $(DEPSDIR)/*.d 166 | #--------------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------------- 169 | -------------------------------------------------------------------------------- /test/eeprom-8KB/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/gba_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # the LIBGBA path is defined in gba_rules, but we have to define LIBTONC ourselves 13 | #--------------------------------------------------------------------------------- 14 | LIBTONC := $(DEVKITPRO)/libtonc 15 | 16 | #--------------------------------------------------------------------------------- 17 | # TARGET is the name of the output 18 | # BUILD is the directory where object files & intermediate files will be placed 19 | # SOURCES is a list of directories containing source code 20 | # INCLUDES is a list of directories containing extra header files 21 | # DATA is a list of directories containing binary data 22 | # GRAPHICS is a list of directories containing files to be processed by grit 23 | # 24 | # All directories are specified relative to the project directory where 25 | # the makefile is found 26 | # 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := . 31 | INCLUDES := ../../include 32 | DATA := 33 | MUSIC := 34 | 35 | #--------------------------------------------------------------------------------- 36 | # options for code generation 37 | #--------------------------------------------------------------------------------- 38 | ARCH := -mthumb -mthumb-interwork 39 | 40 | CFLAGS := -g -Wall -O2\ 41 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 42 | $(ARCH) 43 | 44 | CFLAGS += $(INCLUDE) 45 | 46 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 47 | 48 | ASFLAGS := -g $(ARCH) 49 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) 50 | 51 | #--------------------------------------------------------------------------------- 52 | # any extra libraries we wish to link with the project 53 | #--------------------------------------------------------------------------------- 54 | LIBS := -lmm -ltonc -lsavgba 55 | 56 | 57 | #--------------------------------------------------------------------------------- 58 | # list of directories containing libraries, this must be the top level containing 59 | # include and lib. 60 | # the LIBGBA path should remain in this list if you want to use maxmod 61 | #--------------------------------------------------------------------------------- 62 | LIBDIRS := $(LIBGBA) $(LIBTONC) ../../.. 63 | 64 | #--------------------------------------------------------------------------------- 65 | # no real need to edit anything past this point unless you need to add additional 66 | # rules for different file extensions 67 | #--------------------------------------------------------------------------------- 68 | 69 | 70 | ifneq ($(BUILD),$(notdir $(CURDIR))) 71 | #--------------------------------------------------------------------------------- 72 | 73 | export OUTPUT := $(CURDIR)/$(TARGET) 74 | 75 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 76 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 77 | $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) 78 | 79 | export DEPSDIR := $(CURDIR)/$(BUILD) 80 | 81 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 82 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 83 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 84 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 85 | 86 | ifneq ($(strip $(MUSIC)),) 87 | export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) 88 | BINFILES += soundbank.bin 89 | endif 90 | 91 | #--------------------------------------------------------------------------------- 92 | # use CXX for linking C++ projects, CC for standard C 93 | #--------------------------------------------------------------------------------- 94 | ifeq ($(strip $(CPPFILES)),) 95 | #--------------------------------------------------------------------------------- 96 | export LD := $(CC) 97 | #--------------------------------------------------------------------------------- 98 | else 99 | #--------------------------------------------------------------------------------- 100 | export LD := $(CXX) 101 | #--------------------------------------------------------------------------------- 102 | endif 103 | #--------------------------------------------------------------------------------- 104 | 105 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 106 | 107 | export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 108 | 109 | export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) 110 | 111 | export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) 112 | 113 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ 114 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 115 | -I$(CURDIR)/$(BUILD) 116 | 117 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 118 | 119 | .PHONY: $(BUILD) clean 120 | 121 | #--------------------------------------------------------------------------------- 122 | $(BUILD): 123 | @[ -d $@ ] || mkdir -p $@ 124 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 125 | 126 | #--------------------------------------------------------------------------------- 127 | clean: 128 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba $(TARGET).sav 129 | 130 | 131 | #--------------------------------------------------------------------------------- 132 | else 133 | 134 | #--------------------------------------------------------------------------------- 135 | # main targets 136 | #--------------------------------------------------------------------------------- 137 | 138 | $(OUTPUT).gba : $(OUTPUT).elf 139 | 140 | $(OUTPUT).elf : $(OFILES) 141 | 142 | $(OFILES_SOURCES) : $(HFILES) 143 | 144 | #--------------------------------------------------------------------------------- 145 | # The bin2o rule should be copied and modified 146 | # for each extension used in the data directories 147 | #--------------------------------------------------------------------------------- 148 | 149 | #--------------------------------------------------------------------------------- 150 | # rule to build soundbank from music files 151 | #--------------------------------------------------------------------------------- 152 | soundbank.bin soundbank.h : $(AUDIOFILES) 153 | #--------------------------------------------------------------------------------- 154 | @mmutil $^ -osoundbank.bin -hsoundbank.h 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o %_bin.h : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | 165 | -include $(DEPSDIR)/*.d 166 | #--------------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------------- 169 | -------------------------------------------------------------------------------- /test/flash-128KB/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/gba_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # the LIBGBA path is defined in gba_rules, but we have to define LIBTONC ourselves 13 | #--------------------------------------------------------------------------------- 14 | LIBTONC := $(DEVKITPRO)/libtonc 15 | 16 | #--------------------------------------------------------------------------------- 17 | # TARGET is the name of the output 18 | # BUILD is the directory where object files & intermediate files will be placed 19 | # SOURCES is a list of directories containing source code 20 | # INCLUDES is a list of directories containing extra header files 21 | # DATA is a list of directories containing binary data 22 | # GRAPHICS is a list of directories containing files to be processed by grit 23 | # 24 | # All directories are specified relative to the project directory where 25 | # the makefile is found 26 | # 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := . 31 | INCLUDES := ../../include 32 | DATA := 33 | MUSIC := 34 | 35 | #--------------------------------------------------------------------------------- 36 | # options for code generation 37 | #--------------------------------------------------------------------------------- 38 | ARCH := -mthumb -mthumb-interwork 39 | 40 | CFLAGS := -g -Wall -O2\ 41 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 42 | $(ARCH) 43 | 44 | CFLAGS += $(INCLUDE) 45 | 46 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 47 | 48 | ASFLAGS := -g $(ARCH) 49 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) 50 | 51 | #--------------------------------------------------------------------------------- 52 | # any extra libraries we wish to link with the project 53 | #--------------------------------------------------------------------------------- 54 | LIBS := -lmm -ltonc -lsavgba 55 | 56 | 57 | #--------------------------------------------------------------------------------- 58 | # list of directories containing libraries, this must be the top level containing 59 | # include and lib. 60 | # the LIBGBA path should remain in this list if you want to use maxmod 61 | #--------------------------------------------------------------------------------- 62 | LIBDIRS := $(LIBGBA) $(LIBTONC) ../../.. 63 | 64 | #--------------------------------------------------------------------------------- 65 | # no real need to edit anything past this point unless you need to add additional 66 | # rules for different file extensions 67 | #--------------------------------------------------------------------------------- 68 | 69 | 70 | ifneq ($(BUILD),$(notdir $(CURDIR))) 71 | #--------------------------------------------------------------------------------- 72 | 73 | export OUTPUT := $(CURDIR)/$(TARGET) 74 | 75 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 76 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 77 | $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) 78 | 79 | export DEPSDIR := $(CURDIR)/$(BUILD) 80 | 81 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 82 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 83 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 84 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 85 | 86 | ifneq ($(strip $(MUSIC)),) 87 | export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) 88 | BINFILES += soundbank.bin 89 | endif 90 | 91 | #--------------------------------------------------------------------------------- 92 | # use CXX for linking C++ projects, CC for standard C 93 | #--------------------------------------------------------------------------------- 94 | ifeq ($(strip $(CPPFILES)),) 95 | #--------------------------------------------------------------------------------- 96 | export LD := $(CC) 97 | #--------------------------------------------------------------------------------- 98 | else 99 | #--------------------------------------------------------------------------------- 100 | export LD := $(CXX) 101 | #--------------------------------------------------------------------------------- 102 | endif 103 | #--------------------------------------------------------------------------------- 104 | 105 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 106 | 107 | export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 108 | 109 | export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) 110 | 111 | export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) 112 | 113 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ 114 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 115 | -I$(CURDIR)/$(BUILD) 116 | 117 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 118 | 119 | .PHONY: $(BUILD) clean 120 | 121 | #--------------------------------------------------------------------------------- 122 | $(BUILD): 123 | @[ -d $@ ] || mkdir -p $@ 124 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 125 | 126 | #--------------------------------------------------------------------------------- 127 | clean: 128 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba $(TARGET).sav 129 | 130 | 131 | #--------------------------------------------------------------------------------- 132 | else 133 | 134 | #--------------------------------------------------------------------------------- 135 | # main targets 136 | #--------------------------------------------------------------------------------- 137 | 138 | $(OUTPUT).gba : $(OUTPUT).elf 139 | 140 | $(OUTPUT).elf : $(OFILES) 141 | 142 | $(OFILES_SOURCES) : $(HFILES) 143 | 144 | #--------------------------------------------------------------------------------- 145 | # The bin2o rule should be copied and modified 146 | # for each extension used in the data directories 147 | #--------------------------------------------------------------------------------- 148 | 149 | #--------------------------------------------------------------------------------- 150 | # rule to build soundbank from music files 151 | #--------------------------------------------------------------------------------- 152 | soundbank.bin soundbank.h : $(AUDIOFILES) 153 | #--------------------------------------------------------------------------------- 154 | @mmutil $^ -osoundbank.bin -hsoundbank.h 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o %_bin.h : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | 165 | -include $(DEPSDIR)/*.d 166 | #--------------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------------- 169 | -------------------------------------------------------------------------------- /test/flash-64KB/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/gba_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # the LIBGBA path is defined in gba_rules, but we have to define LIBTONC ourselves 13 | #--------------------------------------------------------------------------------- 14 | LIBTONC := $(DEVKITPRO)/libtonc 15 | 16 | #--------------------------------------------------------------------------------- 17 | # TARGET is the name of the output 18 | # BUILD is the directory where object files & intermediate files will be placed 19 | # SOURCES is a list of directories containing source code 20 | # INCLUDES is a list of directories containing extra header files 21 | # DATA is a list of directories containing binary data 22 | # GRAPHICS is a list of directories containing files to be processed by grit 23 | # 24 | # All directories are specified relative to the project directory where 25 | # the makefile is found 26 | # 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := . 31 | INCLUDES := ../../include 32 | DATA := 33 | MUSIC := 34 | 35 | #--------------------------------------------------------------------------------- 36 | # options for code generation 37 | #--------------------------------------------------------------------------------- 38 | ARCH := -mthumb -mthumb-interwork 39 | 40 | CFLAGS := -g -Wall -O2\ 41 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 42 | $(ARCH) 43 | 44 | CFLAGS += $(INCLUDE) 45 | 46 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 47 | 48 | ASFLAGS := -g $(ARCH) 49 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) 50 | 51 | #--------------------------------------------------------------------------------- 52 | # any extra libraries we wish to link with the project 53 | #--------------------------------------------------------------------------------- 54 | LIBS := -lmm -ltonc -lsavgba 55 | 56 | 57 | #--------------------------------------------------------------------------------- 58 | # list of directories containing libraries, this must be the top level containing 59 | # include and lib. 60 | # the LIBGBA path should remain in this list if you want to use maxmod 61 | #--------------------------------------------------------------------------------- 62 | LIBDIRS := $(LIBGBA) $(LIBTONC) ../../.. 63 | 64 | #--------------------------------------------------------------------------------- 65 | # no real need to edit anything past this point unless you need to add additional 66 | # rules for different file extensions 67 | #--------------------------------------------------------------------------------- 68 | 69 | 70 | ifneq ($(BUILD),$(notdir $(CURDIR))) 71 | #--------------------------------------------------------------------------------- 72 | 73 | export OUTPUT := $(CURDIR)/$(TARGET) 74 | 75 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 76 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 77 | $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) 78 | 79 | export DEPSDIR := $(CURDIR)/$(BUILD) 80 | 81 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 82 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 83 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 84 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 85 | 86 | ifneq ($(strip $(MUSIC)),) 87 | export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) 88 | BINFILES += soundbank.bin 89 | endif 90 | 91 | #--------------------------------------------------------------------------------- 92 | # use CXX for linking C++ projects, CC for standard C 93 | #--------------------------------------------------------------------------------- 94 | ifeq ($(strip $(CPPFILES)),) 95 | #--------------------------------------------------------------------------------- 96 | export LD := $(CC) 97 | #--------------------------------------------------------------------------------- 98 | else 99 | #--------------------------------------------------------------------------------- 100 | export LD := $(CXX) 101 | #--------------------------------------------------------------------------------- 102 | endif 103 | #--------------------------------------------------------------------------------- 104 | 105 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 106 | 107 | export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 108 | 109 | export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) 110 | 111 | export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) 112 | 113 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ 114 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 115 | -I$(CURDIR)/$(BUILD) 116 | 117 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 118 | 119 | .PHONY: $(BUILD) clean 120 | 121 | #--------------------------------------------------------------------------------- 122 | $(BUILD): 123 | @[ -d $@ ] || mkdir -p $@ 124 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 125 | 126 | #--------------------------------------------------------------------------------- 127 | clean: 128 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba $(TARGET).sav 129 | 130 | 131 | #--------------------------------------------------------------------------------- 132 | else 133 | 134 | #--------------------------------------------------------------------------------- 135 | # main targets 136 | #--------------------------------------------------------------------------------- 137 | 138 | $(OUTPUT).gba : $(OUTPUT).elf 139 | 140 | $(OUTPUT).elf : $(OFILES) 141 | 142 | $(OFILES_SOURCES) : $(HFILES) 143 | 144 | #--------------------------------------------------------------------------------- 145 | # The bin2o rule should be copied and modified 146 | # for each extension used in the data directories 147 | #--------------------------------------------------------------------------------- 148 | 149 | #--------------------------------------------------------------------------------- 150 | # rule to build soundbank from music files 151 | #--------------------------------------------------------------------------------- 152 | soundbank.bin soundbank.h : $(AUDIOFILES) 153 | #--------------------------------------------------------------------------------- 154 | @mmutil $^ -osoundbank.bin -hsoundbank.h 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o %_bin.h : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | 165 | -include $(DEPSDIR)/*.d 166 | #--------------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------------- 169 | -------------------------------------------------------------------------------- /test/detect-save-type/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/gba_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # the LIBGBA path is defined in gba_rules, but we have to define LIBTONC ourselves 13 | #--------------------------------------------------------------------------------- 14 | LIBTONC := $(DEVKITPRO)/libtonc 15 | 16 | #--------------------------------------------------------------------------------- 17 | # TARGET is the name of the output 18 | # BUILD is the directory where object files & intermediate files will be placed 19 | # SOURCES is a list of directories containing source code 20 | # INCLUDES is a list of directories containing extra header files 21 | # DATA is a list of directories containing binary data 22 | # GRAPHICS is a list of directories containing files to be processed by grit 23 | # 24 | # All directories are specified relative to the project directory where 25 | # the makefile is found 26 | # 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := . 31 | INCLUDES := ../../include 32 | DATA := 33 | MUSIC := 34 | 35 | #--------------------------------------------------------------------------------- 36 | # options for code generation 37 | #--------------------------------------------------------------------------------- 38 | ARCH := -mthumb -mthumb-interwork 39 | 40 | CFLAGS := -g -Wall -O2\ 41 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 42 | $(ARCH) 43 | 44 | CFLAGS += $(INCLUDE) 45 | 46 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 47 | 48 | ASFLAGS := -g $(ARCH) 49 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) 50 | 51 | #--------------------------------------------------------------------------------- 52 | # any extra libraries we wish to link with the project 53 | #--------------------------------------------------------------------------------- 54 | LIBS := -lmm -ltonc -lsavgba 55 | 56 | 57 | #--------------------------------------------------------------------------------- 58 | # list of directories containing libraries, this must be the top level containing 59 | # include and lib. 60 | # the LIBGBA path should remain in this list if you want to use maxmod 61 | #--------------------------------------------------------------------------------- 62 | LIBDIRS := $(LIBGBA) $(LIBTONC) ../../.. 63 | 64 | #--------------------------------------------------------------------------------- 65 | # no real need to edit anything past this point unless you need to add additional 66 | # rules for different file extensions 67 | #--------------------------------------------------------------------------------- 68 | 69 | 70 | ifneq ($(BUILD),$(notdir $(CURDIR))) 71 | #--------------------------------------------------------------------------------- 72 | 73 | export OUTPUT := $(CURDIR)/$(TARGET) 74 | 75 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 76 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 77 | $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) 78 | 79 | export DEPSDIR := $(CURDIR)/$(BUILD) 80 | 81 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 82 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 83 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 84 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 85 | 86 | ifneq ($(strip $(MUSIC)),) 87 | export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) 88 | BINFILES += soundbank.bin 89 | endif 90 | 91 | #--------------------------------------------------------------------------------- 92 | # use CXX for linking C++ projects, CC for standard C 93 | #--------------------------------------------------------------------------------- 94 | ifeq ($(strip $(CPPFILES)),) 95 | #--------------------------------------------------------------------------------- 96 | export LD := $(CC) 97 | #--------------------------------------------------------------------------------- 98 | else 99 | #--------------------------------------------------------------------------------- 100 | export LD := $(CXX) 101 | #--------------------------------------------------------------------------------- 102 | endif 103 | #--------------------------------------------------------------------------------- 104 | 105 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 106 | 107 | export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 108 | 109 | export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) 110 | 111 | export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) 112 | 113 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ 114 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 115 | -I$(CURDIR)/$(BUILD) 116 | 117 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 118 | 119 | .PHONY: $(BUILD) clean 120 | 121 | #--------------------------------------------------------------------------------- 122 | $(BUILD): 123 | @[ -d $@ ] || mkdir -p $@ 124 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 125 | 126 | #--------------------------------------------------------------------------------- 127 | clean: 128 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba $(TARGET).sav 129 | 130 | 131 | #--------------------------------------------------------------------------------- 132 | else 133 | 134 | #--------------------------------------------------------------------------------- 135 | # main targets 136 | #--------------------------------------------------------------------------------- 137 | 138 | $(OUTPUT).gba : $(OUTPUT).elf 139 | 140 | $(OUTPUT).elf : $(OFILES) 141 | 142 | $(OFILES_SOURCES) : $(HFILES) 143 | 144 | #--------------------------------------------------------------------------------- 145 | # The bin2o rule should be copied and modified 146 | # for each extension used in the data directories 147 | #--------------------------------------------------------------------------------- 148 | 149 | #--------------------------------------------------------------------------------- 150 | # rule to build soundbank from music files 151 | #--------------------------------------------------------------------------------- 152 | soundbank.bin soundbank.h : $(AUDIOFILES) 153 | #--------------------------------------------------------------------------------- 154 | @mmutil $^ -osoundbank.bin -hsoundbank.h 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o %_bin.h : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | 165 | -include $(DEPSDIR)/*.d 166 | #--------------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------------- 169 | -------------------------------------------------------------------------------- /docs/gba__eeprom_8h_source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | libsavgba: include/gba_eeprom.h Source File 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 28 | 29 | 30 |
    24 |
    libsavgba 25 |
    26 |
    A library to access various backup media in GBA cartridges
    27 |
    31 |
    32 | 33 | 34 | 39 | 40 | 41 | 48 | 49 | 50 |
    54 |
    55 | 56 | 57 |
    58 | 61 |
    62 | 63 | 67 |
    68 |
    69 |
    70 |
    gba_eeprom.h
    71 |
    72 |
    73 | Go to the documentation of this file.
    1 #ifndef GBA_EEPROM_H
    74 |
    2 #define GBA_EEPROM_H
    75 |
    3 
    76 |
    7 enum EepromSize {
    77 | 78 | 79 |
    10 };
    80 |
    11 
    81 |
    21 int eeprom_init(u8 size);
    82 |
    22 
    83 |
    31 int eeprom_read(u32 addr, u16 *data);
    84 |
    32 
    85 |
    41 int eeprom_write(u32 addr, u16 *data);
    86 |
    42 
    87 |
    43 #endif /* GBA_EEPROM_H */
    88 |
    int eeprom_init(u8 size)
    Init EEPROM chip.
    89 |
    int eeprom_read(u32 addr, u16 *data)
    Read data from EEPROM.
    90 |
    int eeprom_write(u32 addr, u16 *data)
    Write data to EEPROM.
    91 |
    EepromSize
    EEPROM chip size.
    Definition: gba_eeprom.h:7
    92 |
    @ EEPROM_SIZE_512B
    512B (4Kbit)
    Definition: gba_eeprom.h:8
    93 |
    @ EEPROM_SIZE_8KB
    8KB (64K)
    Definition: gba_eeprom.h:9
    94 |
    95 | 96 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /docs/gba__sram_8h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | libsavgba: include/gba_sram.h File Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 28 | 29 | 30 |
    24 |
    libsavgba 25 |
    26 |
    A library to access various backup media in GBA cartridges
    27 |
    31 |
    32 | 33 | 34 | 39 | 40 | 41 | 48 | 49 | 50 |
    54 |
    55 | 56 | 57 |
    58 | 61 |
    62 | 63 | 67 |
    68 |
    69 |
    70 | Functions
    71 |
    72 |
    gba_sram.h File Reference
    73 |
    74 |
    75 | 76 |

    Go to the source code of this file.

    77 | 78 | 80 | 81 | 82 | 83 | 84 | 85 | 86 |

    79 | Functions

    int sram_read (u32 addr, u8 *data, size_t size)
     Read data from SRAM. More...
     
    int sram_write (u32 addr, u8 *data, size_t size)
     Write data to SRAM. More...
     
    87 |

    Function Documentation

    88 | 89 |

    ◆ sram_read()

    90 | 91 |
    92 |
    93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 |
    int sram_read (u32 addr,
    u8 * data,
    size_t size 
    )
    118 |
    119 | 120 |

    Read data from SRAM.

    121 |
    Parameters
    122 | 123 | 124 | 125 | 126 |
    addraddress in SRAM (unit: byte).
    databuffer to hold data.
    sizedata size (unit: byte).
    127 |
    128 |
    129 |
    Returns
    0 for success, non-zero for error.
    130 | 131 |
    132 |
    133 | 134 |

    ◆ sram_write()

    135 | 136 |
    137 |
    138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 |
    int sram_write (u32 addr,
    u8 * data,
    size_t size 
    )
    163 |
    164 | 165 |

    Write data to SRAM.

    166 |
    Parameters
    167 | 168 | 169 | 170 | 171 |
    addraddress in SRAM (unit: byte).
    databuffer to hold data.
    sizedata size (unit: byte).
    172 |
    173 |
    174 |
    Returns
    0 for success, non-zero for error.
    175 | 176 |
    177 |
    178 |
    179 | 180 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /docs/tabs.css: -------------------------------------------------------------------------------- 1 | .sm{position:relative;z-index:9999}.sm,.sm ul,.sm li{display:block;list-style:none;margin:0;padding:0;line-height:normal;direction:ltr;text-align:left;-webkit-tap-highlight-color:rgba(0,0,0,0)}.sm-rtl,.sm-rtl ul,.sm-rtl li{direction:rtl;text-align:right}.sm>li>h1,.sm>li>h2,.sm>li>h3,.sm>li>h4,.sm>li>h5,.sm>li>h6{margin:0;padding:0}.sm ul{display:none}.sm li,.sm a{position:relative}.sm a{display:block}.sm a.disabled{cursor:not-allowed}.sm:after{content:"\00a0";display:block;height:0;font:0/0 serif;clear:both;visibility:hidden;overflow:hidden}.sm,.sm *,.sm *:before,.sm *:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.sm-dox{background-image:url("tab_b.png")}.sm-dox a,.sm-dox a:focus,.sm-dox a:hover,.sm-dox a:active{padding:0 12px;padding-right:43px;font-family:"Lucida Grande","Geneva","Helvetica",Arial,sans-serif;font-size:13px;font-weight:bold;line-height:36px;text-decoration:none;text-shadow:0 1px 1px rgba(255,255,255,0.9);color:#283a5d;outline:0}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox a.current{color:#d23600}.sm-dox a.disabled{color:#bbb}.sm-dox a span.sub-arrow{position:absolute;top:50%;margin-top:-14px;left:auto;right:3px;width:28px;height:28px;overflow:hidden;font:bold 12px/28px monospace!important;text-align:center;text-shadow:none;background:rgba(255,255,255,0.5);-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox a.highlighted span.sub-arrow:before{display:block;content:'-'}.sm-dox>li:first-child>a,.sm-dox>li:first-child>:not(ul) a{-moz-border-radius:5px 5px 0 0;-webkit-border-radius:5px;border-radius:5px 5px 0 0}.sm-dox>li:last-child>a,.sm-dox>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul{-moz-border-radius:0 0 5px 5px;-webkit-border-radius:0;border-radius:0 0 5px 5px}.sm-dox>li:last-child>a.highlighted,.sm-dox>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox ul{background:rgba(162,162,162,0.1)}.sm-dox ul a,.sm-dox ul a:focus,.sm-dox ul a:hover,.sm-dox ul a:active{font-size:12px;border-left:8px solid transparent;line-height:36px;text-shadow:none;background-color:white;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox ul ul a,.sm-dox ul ul a:hover,.sm-dox ul ul a:focus,.sm-dox ul ul a:active{border-left:16px solid transparent}.sm-dox ul ul ul a,.sm-dox ul ul ul a:hover,.sm-dox ul ul ul a:focus,.sm-dox ul ul ul a:active{border-left:24px solid transparent}.sm-dox ul ul ul ul a,.sm-dox ul ul ul ul a:hover,.sm-dox ul ul ul ul a:focus,.sm-dox ul ul ul ul a:active{border-left:32px solid transparent}.sm-dox ul ul ul ul ul a,.sm-dox ul ul ul ul ul a:hover,.sm-dox ul ul ul ul ul a:focus,.sm-dox ul ul ul ul ul a:active{border-left:40px solid transparent}@media(min-width:768px){.sm-dox ul{position:absolute;width:12em}.sm-dox li{float:left}.sm-dox.sm-rtl li{float:right}.sm-dox ul li,.sm-dox.sm-rtl ul li,.sm-dox.sm-vertical li{float:none}.sm-dox a{white-space:nowrap}.sm-dox ul a,.sm-dox.sm-vertical a{white-space:normal}.sm-dox .sm-nowrap>li>a,.sm-dox .sm-nowrap>li>:not(ul) a{white-space:nowrap}.sm-dox{padding:0 10px;background-image:url("tab_b.png");line-height:36px}.sm-dox a span.sub-arrow{top:50%;margin-top:-2px;right:12px;width:0;height:0;border-width:4px;border-style:solid dashed dashed dashed;border-color:#283a5d transparent transparent transparent;background:transparent;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted{padding:0 12px;background-image:url("tab_s.png");background-repeat:no-repeat;background-position:right;-moz-border-radius:0!important;-webkit-border-radius:0;border-radius:0!important}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox a:hover span.sub-arrow{border-color:white transparent transparent transparent}.sm-dox a.has-submenu{padding-right:24px}.sm-dox li{border-top:0}.sm-dox>li>ul:before,.sm-dox>li>ul:after{content:'';position:absolute;top:-18px;left:30px;width:0;height:0;overflow:hidden;border-width:9px;border-style:dashed dashed solid dashed;border-color:transparent transparent #bbb transparent}.sm-dox>li>ul:after{top:-16px;left:31px;border-width:8px;border-color:transparent transparent #fff transparent}.sm-dox ul{border:1px solid #bbb;padding:5px 0;background:#fff;-moz-border-radius:5px!important;-webkit-border-radius:5px;border-radius:5px!important;-moz-box-shadow:0 5px 9px rgba(0,0,0,0.2);-webkit-box-shadow:0 5px 9px rgba(0,0,0,0.2);box-shadow:0 5px 9px rgba(0,0,0,0.2)}.sm-dox ul a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-color:transparent transparent transparent #555;border-style:dashed dashed dashed solid}.sm-dox ul a,.sm-dox ul a:hover,.sm-dox ul a:focus,.sm-dox ul a:active,.sm-dox ul a.highlighted{color:#555;background-image:none;border:0!important;color:#555;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent white}.sm-dox span.scroll-up,.sm-dox span.scroll-down{position:absolute;display:none;visibility:hidden;overflow:hidden;background:#fff;height:36px}.sm-dox span.scroll-up:hover,.sm-dox span.scroll-down:hover{background:#eee}.sm-dox span.scroll-up:hover span.scroll-up-arrow,.sm-dox span.scroll-up:hover span.scroll-down-arrow{border-color:transparent transparent #d23600 transparent}.sm-dox span.scroll-down:hover span.scroll-down-arrow{border-color:#d23600 transparent transparent transparent}.sm-dox span.scroll-up-arrow,.sm-dox span.scroll-down-arrow{position:absolute;top:0;left:50%;margin-left:-6px;width:0;height:0;overflow:hidden;border-width:6px;border-style:dashed dashed solid dashed;border-color:transparent transparent #555 transparent}.sm-dox span.scroll-down-arrow{top:8px;border-style:solid dashed dashed dashed;border-color:#555 transparent transparent transparent}.sm-dox.sm-rtl a.has-submenu{padding-right:12px;padding-left:24px}.sm-dox.sm-rtl a span.sub-arrow{right:auto;left:12px}.sm-dox.sm-rtl.sm-vertical a.has-submenu{padding:10px 20px}.sm-dox.sm-rtl.sm-vertical a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-rtl>li>ul:before{left:auto;right:30px}.sm-dox.sm-rtl>li>ul:after{left:auto;right:31px}.sm-dox.sm-rtl ul a.has-submenu{padding:10px 20px!important}.sm-dox.sm-rtl ul a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-vertical{padding:10px 0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox.sm-vertical a{padding:10px 20px}.sm-dox.sm-vertical a:hover,.sm-dox.sm-vertical a:focus,.sm-dox.sm-vertical a:active,.sm-dox.sm-vertical a.highlighted{background:#fff}.sm-dox.sm-vertical a.disabled{background-image:url("tab_b.png")}.sm-dox.sm-vertical a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-style:dashed dashed dashed solid;border-color:transparent transparent transparent #555}.sm-dox.sm-vertical>li>ul:before,.sm-dox.sm-vertical>li>ul:after{display:none}.sm-dox.sm-vertical ul a{padding:10px 20px}.sm-dox.sm-vertical ul a:hover,.sm-dox.sm-vertical ul a:focus,.sm-dox.sm-vertical ul a:active,.sm-dox.sm-vertical ul a.highlighted{background:#eee}.sm-dox.sm-vertical ul a.disabled{background:#fff}} -------------------------------------------------------------------------------- /docs/globals.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | libsavgba: Globals 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 28 | 29 | 30 |
    24 |
    libsavgba 25 |
    26 |
    A library to access various backup media in GBA cartridges
    27 |
    31 |
    32 | 33 | 34 | 39 | 40 | 41 | 48 | 49 |
    50 | 51 |
    55 |
    56 | 57 | 58 |
    59 | 62 |
    63 | 64 |
    65 |
    Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
    66 | 67 |

    - e -

    108 | 109 | 110 |

    - f -

    175 | 176 | 177 |

    - s -

    191 |
    192 | 193 | 196 | 197 | 198 | -------------------------------------------------------------------------------- /docs/err__def_8h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | libsavgba: include/err_def.h File Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 28 | 29 | 30 |
    24 |
    libsavgba 25 |
    26 |
    A library to access various backup media in GBA cartridges
    27 |
    31 |
    32 | 33 | 34 | 39 | 40 | 41 | 48 | 49 | 50 |
    54 |
    55 | 56 | 57 |
    58 | 61 |
    62 | 63 | 67 |
    68 |
    69 |
    70 | Enumerations | 71 | Variables
    72 |
    73 |
    err_def.h File Reference
    74 |
    75 |
    76 | 77 |

    Go to the source code of this file.

    78 | 79 | 81 | 91 | 92 |

    80 | Enumerations

    enum  ErrorCode {
    82 |   E_SUCCESS = 0 83 | , E_INVALID_PARAM 84 | , E_OUT_OF_RANGE 85 | , E_VERIFY_FAIL 86 | ,
    87 |   E_UNSUPPORTED_DEVICE 88 | , E_TIMEOUT 89 |
    90 | }
     
    93 | 95 | 96 | 97 | 98 | 99 | 100 | 101 |

    94 | Variables

    const char *const SavErrCodes []
     Error codes. More...
     
    const char *const SavErrMsgs []
     Error messages. More...
     
    102 |

    Enumeration Type Documentation

    103 | 104 |

    ◆ ErrorCode

    105 | 106 |
    107 |
    108 | 109 | 110 | 111 | 112 |
    enum ErrorCode
    113 |
    114 | 115 | 117 | 119 | 121 | 123 | 125 | 127 |
    Enumerator
    E_SUCCESS 

    No error.

    116 |
    E_INVALID_PARAM 

    Invalid input parameter.

    118 |
    E_OUT_OF_RANGE 

    Address is out of range.

    120 |
    E_VERIFY_FAIL 

    Failed to verify written data.

    122 |
    E_UNSUPPORTED_DEVICE 

    Device type is not supported.

    124 |
    E_TIMEOUT 

    Operation timeout.

    126 |
    128 | 129 |
    130 |
    131 |

    Variable Documentation

    132 | 133 |

    ◆ SavErrCodes

    134 | 135 |
    136 |
    137 | 138 | 139 | 146 | 148 | 149 |
    140 | 141 | 142 | 143 | 144 |
    const char* const SavErrCodes[]
    145 |
    147 | extern
    150 |
    151 | 152 |

    Error codes.

    153 |

    Use SavErrCodes[ErrorCode] to get error code names.

    154 | 155 |
    156 |
    157 | 158 |

    ◆ SavErrMsgs

    159 | 160 |
    161 |
    162 | 163 | 164 | 171 | 173 | 174 |
    165 | 166 | 167 | 168 | 169 |
    const char* const SavErrMsgs[]
    170 |
    172 | extern
    175 |
    176 | 177 |

    Error messages.

    178 |

    Use SavErrMsgs[ErrorCode] to get error code messages.

    179 | 180 |
    181 |
    182 |
    183 | 184 | 187 | 188 | 189 | --------------------------------------------------------------------------------