mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-21 05:11:58 +02:00
Update to v093r13 release.
byuu says: This WIP removes nall/input.hpp entirely, and implements the new universal cheat format for FC/SFC/GB/GBC/SGB. GBA is going to be tricky since there's some consternation around byte/word/dword overrides. It's also not immediately obvious to me how to implement the code search in logarithmic time, due to the optional compare value. Lastly, the cheat values inside cheats.bml seem to be broken for the SFC. Likely there's a bug somewhere in the conversion process. Obviously I'll have to fix that before v094. I received no feedback on the universal cheat format. If nobody adds anything before v094, then I don't want to hear any complaining about the formatting :P
This commit is contained in:
31
nall/image/static.hpp
Normal file
31
nall/image/static.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef NALL_IMAGE_STATIC_HPP
|
||||
#define NALL_IMAGE_STATIC_HPP
|
||||
|
||||
namespace nall {
|
||||
|
||||
unsigned image::bitDepth(uint64_t color) {
|
||||
unsigned depth = 0;
|
||||
if(color) while((color & 1) == 0) color >>= 1;
|
||||
while((color & 1) == 1) { color >>= 1; depth++; }
|
||||
return depth;
|
||||
}
|
||||
|
||||
unsigned image::bitShift(uint64_t color) {
|
||||
unsigned shift = 0;
|
||||
if(color) while((color & 1) == 0) { color >>= 1; shift++; }
|
||||
return shift;
|
||||
}
|
||||
|
||||
uint64_t image::normalize(uint64_t color, unsigned sourceDepth, unsigned targetDepth) {
|
||||
if(sourceDepth == 0 || targetDepth == 0) return 0;
|
||||
while(sourceDepth < targetDepth) {
|
||||
color = (color << sourceDepth) | color;
|
||||
sourceDepth += sourceDepth;
|
||||
}
|
||||
if(targetDepth < sourceDepth) color >>= (sourceDepth - targetDepth);
|
||||
return color;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user