mirror of
				https://github.com/N64Recomp/N64ModernRuntime.git
				synced 2025-10-30 08:02:29 +00:00 
			
		
		
		
	Fix eeprom probe and remove redundant eeprom size checks (#70)
This commit is contained in:
		
							parent
							
								
									d5c81d0a6b
								
							
						
					
					
						commit
						e3a8355a19
					
				
					 1 changed files with 5 additions and 14 deletions
				
			
		|  | @ -7,20 +7,19 @@ void save_write(RDRAM_ARG PTR(void) rdram_address, uint32_t offset, uint32_t cou | |||
| void save_read(RDRAM_ARG PTR(void) rdram_address, uint32_t offset, uint32_t count); | ||||
| 
 | ||||
| constexpr int eeprom_block_size = 8; | ||||
| constexpr int eep4_size = 4096; | ||||
| constexpr int eep4_block_count = eep4_size / eeprom_block_size; | ||||
| constexpr int eep16_size = 16384; | ||||
| constexpr int eep16_block_count = eep16_size / eeprom_block_size; | ||||
| 
 | ||||
| extern "C" void osEepromProbe_recomp(uint8_t* rdram, recomp_context* ctx) { | ||||
|     switch (recomp::get_save_type()) { | ||||
|         case recomp::SaveType::AllowAll: | ||||
|         case recomp::SaveType::Eep16k: | ||||
|             ctx->r2 = 0x02; // EEPROM_TYPE_16K
 | ||||
|             break; | ||||
|         case recomp::SaveType::Eep4k: | ||||
|             ctx->r2 = 0x01; // EEPROM_TYPE_4K
 | ||||
|             break; | ||||
|         default: | ||||
|             ctx->r2 = 0x00; | ||||
|             break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -34,9 +33,6 @@ extern "C" void osEepromWrite_recomp(uint8_t* rdram, recomp_context* ctx) { | |||
|     gpr buffer = ctx->r6; | ||||
|     int32_t nbytes = eeprom_block_size; | ||||
| 
 | ||||
|     assert(!(nbytes & 7)); | ||||
|     assert(eep_address * eeprom_block_size + nbytes <= eep16_size); | ||||
| 
 | ||||
|     save_write(rdram, buffer, eep_address * eeprom_block_size, nbytes); | ||||
| 
 | ||||
|     ctx->r2 = 0; | ||||
|  | @ -52,8 +48,7 @@ extern "C" void osEepromLongWrite_recomp(uint8_t* rdram, recomp_context* ctx) { | |||
|     gpr buffer = ctx->r6; | ||||
|     int32_t nbytes = ctx->r7; | ||||
| 
 | ||||
|     assert(!(nbytes & 7)); | ||||
|     assert(eep_address * eeprom_block_size + nbytes <= eep16_size); | ||||
|     assert((nbytes % eeprom_block_size) == 0); | ||||
| 
 | ||||
|     save_write(rdram, buffer, eep_address * eeprom_block_size, nbytes); | ||||
| 
 | ||||
|  | @ -70,9 +65,6 @@ extern "C" void osEepromRead_recomp(uint8_t* rdram, recomp_context* ctx) { | |||
|     gpr buffer = ctx->r6; | ||||
|     int32_t nbytes = eeprom_block_size; | ||||
| 
 | ||||
|     assert(!(nbytes & 7)); | ||||
|     assert(eep_address * eeprom_block_size + nbytes <= eep16_size); | ||||
| 
 | ||||
|     save_read(rdram, buffer, eep_address * eeprom_block_size, nbytes); | ||||
| 
 | ||||
|     ctx->r2 = 0; | ||||
|  | @ -88,8 +80,7 @@ extern "C" void osEepromLongRead_recomp(uint8_t* rdram, recomp_context* ctx) { | |||
|     gpr buffer = ctx->r6; | ||||
|     int32_t nbytes = ctx->r7; | ||||
| 
 | ||||
|     assert(!(nbytes & 7)); | ||||
|     assert(eep_address * eeprom_block_size + nbytes <= eep16_size); | ||||
|     assert((nbytes % eeprom_block_size) == 0); | ||||
| 
 | ||||
|     save_read(rdram, buffer, eep_address * eeprom_block_size, nbytes); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Wiseguy
						Wiseguy