mirror of
				https://github.com/N64Recomp/N64ModernRuntime.git
				synced 2025-10-30 08:02:29 +00:00 
			
		
		
		
	Fix mods getting duplicated when scanning multiple times, fix incorrect mmap for rdram (#71)
This commit is contained in:
		
							parent
							
								
									e3a8355a19
								
							
						
					
					
						commit
						576fed6cfc
					
				
					 4 changed files with 14 additions and 4 deletions
				
			
		|  | @ -7,9 +7,9 @@ | |||
| 
 | ||||
| namespace recomp { | ||||
|     // 512GB (kseg0 size)
 | ||||
|     constexpr size_t mem_size = 512U * 1024U * 1024U; | ||||
|     // 2GB (Addressable upper half of the address space)
 | ||||
|     constexpr size_t allocation_size = 2048U * 1024U * 1024U; | ||||
|     constexpr size_t mem_size = 512ULL * 1024ULL * 1024ULL; | ||||
|     // 4GB (the full address space)
 | ||||
|     constexpr size_t allocation_size = 4096ULL * 1024ULL * 1024ULL; | ||||
|     // We need a place in rdram to hold the PI handles, so pick an address in extended rdram
 | ||||
|     constexpr int32_t cart_handle = 0x80800000; | ||||
|     constexpr int32_t drive_handle = (int32_t)(cart_handle + sizeof(OSPiHandle)); | ||||
|  |  | |||
|  | @ -232,6 +232,7 @@ namespace recomp { | |||
|             CodeModLoadError load_mod_code(uint8_t* rdram, const std::unordered_map<uint32_t, uint16_t>& section_vrom_map, recomp::mods::ModHandle& mod, int32_t load_address, uint32_t& ram_used, std::string& error_param); | ||||
|             CodeModLoadError resolve_code_dependencies(recomp::mods::ModHandle& mod, std::string& error_param); | ||||
|             void add_opened_mod(ModManifest&& manifest, std::vector<size_t>&& game_indices, std::vector<ModContentTypeId>&& detected_content_types); | ||||
|             void close_mods(); | ||||
| 
 | ||||
|             static void on_code_mod_enabled(ModContext& context, const ModHandle& mod); | ||||
| 
 | ||||
|  |  | |||
|  | @ -460,9 +460,18 @@ void recomp::mods::ModContext::register_game(const std::string& mod_game_id) { | |||
|     mod_game_ids.emplace(mod_game_id, mod_game_ids.size()); | ||||
| } | ||||
| 
 | ||||
| void recomp::mods::ModContext::close_mods() { | ||||
|     opened_mods_by_id.clear(); | ||||
|     opened_mods.clear(); | ||||
|     mod_ids.clear(); | ||||
|     enabled_mods.clear(); | ||||
| } | ||||
| 
 | ||||
| std::vector<recomp::mods::ModOpenErrorDetails> recomp::mods::ModContext::scan_mod_folder(const std::filesystem::path& mod_folder) { | ||||
|     std::vector<recomp::mods::ModOpenErrorDetails> ret{}; | ||||
|     std::error_code ec; | ||||
|     close_mods(); | ||||
| 
 | ||||
|     for (const auto& mod_path : std::filesystem::directory_iterator{mod_folder, std::filesystem::directory_options::skip_permission_denied, ec}) { | ||||
|         bool is_mod = false; | ||||
|         bool requires_manifest = true; | ||||
|  |  | |||
|  | @ -648,7 +648,7 @@ void recomp::start( | |||
|         } | ||||
|     } | ||||
| #else | ||||
|     rdram = (uint8_t*)mmap(NULL, allocation_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); | ||||
|     rdram = (uint8_t*)mmap(NULL, allocation_size, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0); | ||||
|     alloc_failed = rdram == reinterpret_cast<uint8_t*>(MAP_FAILED); | ||||
|     if (!alloc_failed) { | ||||
|         // mprotect returns -1 on failure.
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Wiseguy
						Wiseguy