sgdk
|
00001 00010 #ifndef _EVERDRIVE 00011 #define _EVERDRIVE 00012 00013 #if (MODULE_EVERDRIVE != 0) 00014 00015 //config register bits 00016 #define _SS 0 00017 #define _FULL_SPEED 1 00018 #define _SPI16 2 00019 #define _GAME_MODE 3 00020 #define _SMS_MODE 4 00021 #define _HARD_RESET 5 00022 #define _RAM_MODE_1 6 00023 #define _RAM_ON 7 00024 #define _VBL_CATCH 8 00025 #define _MEGAKEY_ON 9 00026 #define _MEGAKEY_REGION_1 10 00027 #define _SSF_MODE_ON 11 00028 #define _RAM_FS 12 00029 #define _CART 13 00030 00031 //state register bits 00032 #define _SPI_READY 0 00033 #define _RY 1 00034 #define _SMS_KEY 2 00035 #define _SD_CART 3 00036 00037 //everdrive hardware registers 00038 #define SPI_PORT *((volatile u16*) (0xA13000)) 00039 #define CFG_PORT *((volatile u16*) (0xA13002)) 00040 #define VBL_PORT *((volatile u16*) (0xA13004)) 00041 #define SRAM_BANK_PORT *((volatile u16*) (0xA13006)) 00042 #define VER_PORT *((volatile u16*) (0xA13008)) 00043 #define ROM_MAP_PORT *((volatile u16*) (0xA1300a)) 00044 00045 00046 #define CFGC(bit)(cfg &= ~(1 << bit), CFG_PORT = cfg) 00047 #define CFGS(bit)(cfg |= (1 << bit), CFG_PORT = cfg) 00048 00049 #define IS_RY (CFG_PORT & (1 << _RY)) 00050 #define IS_SPI_READY (CFG_PORT & (1 << _SPI_READY)) 00051 #define IS_SMS_KEY_PRESSED (CFG_PORT & (1 << _SMS_KEY)) 00052 #define IS_SD_SLOT_EMPTY (CFG_PORT & (1 << _SD_CART)) 00053 00054 #define SPI_HI_SPEED_ON CFGS(_FULL_SPEED) 00055 #define SPI_HI_SPEED_OFF CFGC(_FULL_SPEED) 00056 00057 #define SPI16_ON CFGS(_SPI16); 00058 #define SPI16_OFF CFGC(_SPI16); 00059 00060 #define SS_ON CFGC(_SS) 00061 #define SS_OFF CFGS(_SS) 00062 00063 #define CART_ON CFGC(_CART) 00064 #define CART_OFF CFGS(_CART) 00065 00066 #define RAM_ON CFGS(_RAM_ON); 00067 #define RAM_OFF CFGC(_RAM_ON); 00068 00069 #define VBL_CATCH_ON CFGS(_VBL_CATCH); 00070 #define VBL_CATCH_OFF CFGC(_VBL_CATCH); 00071 00072 #define SPI_BUSY while(!IS_SPI_READY) 00073 #define EPR_BUSY while(!IS_RY) 00074 00075 00076 00077 extern u16 cfg; 00078 00079 00080 //SD/MMC card initialization. should be run just one times, aer this cart will be ready for work 00081 //will return 0 success 00082 u8 evd_mmcInit(); 00083 00084 00085 //read block (512b) from SD/MMC card. mmc_addr should be multiple to 512 00086 //will return 0 success 00087 u8 evd_mmcRdBlock(u32 mmc_addr, u8 *stor); 00088 00089 00090 //write block (512b) to SD/MMC card. mmc_addr should be multiple to 512 00091 //will return 0 success 00092 u8 evd_mmcWrBlock(u32 mmc_addr, u8 *data_ptr); 00093 00094 00095 //erase flash memry sector(64kb). rom_addr should be multiple to 64k. 00096 //code of this function should be placed in ram because rom memory inaccessible while erase process 00097 //WARNING! this function may damage cart bios if sectors in range 0 - 0x40000 will be erased 00098 void evd_eprEraseBlock(u32 rom_addr); 00099 00100 00101 //write data to flash memory. len should be multiple to 4. 00102 //each byte of flah memory should be erased before writeing by evd_eprEraseBlock 00103 //code of this function should be placed in ram because rom memory inaccessible while writeing process 00104 //WARNING! this function may damage cart bios if memory will be writen in area 0 - 0x40000 00105 void evd_eprProgBlock(u16 *data, u32 rom_addr, u32 len); 00106 00107 00108 //everdrive initialization. 00109 //def_rom_bank = 0 if app placed in 0-0x400000 area, 1 if in 0x400000-0x800000 arae 00110 //_is_ram_app = 0 if app assembled for work in rom, 1 if app assembleed for work in ram 00111 void evd_init(u16 def_rom_bank, u8 _is_ram_app); 00112 00113 00114 #endif // MODULE_EVERDRIVE 00115 00116 #endif