-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
snes: treat Unknown mapping as an error
- Loading branch information
1 parent
d34a7e1
commit 5e983df
Showing
4 changed files
with
46 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,60 @@ | ||
package mapping | ||
|
||
import ( | ||
"fmt" | ||
"sni/protos/sni" | ||
"sni/snes/mapping/exhirom" | ||
"sni/snes/mapping/hirom" | ||
"sni/snes/mapping/lorom" | ||
) | ||
|
||
var ErrUnknownMapping = fmt.Errorf("cannot map an address with an Unknown mapping; call MappingDetect or MappingSet first") | ||
|
||
func TranslateAddress( | ||
address uint32, | ||
space sni.AddressSpace, | ||
mapping sni.MemoryMapping, | ||
deviceSpace sni.AddressSpace, | ||
) uint32 { | ||
) (deviceAddress uint32, err error) { | ||
switch space { | ||
case sni.AddressSpace_Raw: | ||
return address | ||
return address, nil | ||
case sni.AddressSpace_FxPakPro: | ||
switch deviceSpace { | ||
case sni.AddressSpace_Raw: | ||
return address | ||
return address, nil | ||
case sni.AddressSpace_FxPakPro: | ||
return address | ||
return address, nil | ||
case sni.AddressSpace_SnesABus: | ||
switch mapping { | ||
case sni.MemoryMapping_LoROM: | ||
return lorom.PakAddressToBus(address) | ||
return lorom.PakAddressToBus(address), nil | ||
case sni.MemoryMapping_HiROM: | ||
return hirom.PakAddressToBus(address) | ||
return hirom.PakAddressToBus(address), nil | ||
case sni.MemoryMapping_ExHiROM: | ||
return exhirom.PakAddressToBus(address) | ||
return exhirom.PakAddressToBus(address), nil | ||
default: | ||
return 0, ErrUnknownMapping | ||
} | ||
} | ||
case sni.AddressSpace_SnesABus: | ||
switch deviceSpace { | ||
case sni.AddressSpace_Raw: | ||
return address | ||
return address, nil | ||
case sni.AddressSpace_SnesABus: | ||
return address | ||
return address, nil | ||
case sni.AddressSpace_FxPakPro: | ||
switch mapping { | ||
case sni.MemoryMapping_LoROM: | ||
return lorom.BusAddressToPak(address) | ||
return lorom.BusAddressToPak(address), nil | ||
case sni.MemoryMapping_HiROM: | ||
return hirom.BusAddressToPak(address) | ||
return hirom.BusAddressToPak(address), nil | ||
case sni.MemoryMapping_ExHiROM: | ||
return exhirom.BusAddressToPak(address) | ||
return exhirom.BusAddressToPak(address), nil | ||
default: | ||
return 0, ErrUnknownMapping | ||
} | ||
} | ||
} | ||
return address | ||
return address, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters