|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
gibberishh Cheater Reputation: 1
Joined: 30 Aug 2021 Posts: 37
|
Posted: Sun Mar 19, 2023 10:32 am Post subject: Dropdown Options for Binary Type |
|
|
I'm playing an old DOS game which has a fairly weird way of storing some data. This one in particular has me stumped:
Turn Undead is enabled if any of the 4 lower bits at a particular address are enabled. 1000 is just as good as 0100, 0010, 0001, 0110, 1100, etc.
My memrec is of type binary, length 4 starting at bit 0, display as binary.
I wish to display a dropdown so that if any of these bits is 1, it shows 'Available' otherwise it should show Unavailable. User can edit this value (e.g., to give a Fighter or Druid turn undead).
My dropdown allows manual entry. Its options currently are:
1:Available (any of the 4 digits need to be 1)
11:Available
111:Available
1111:Available
0:Unavailable
I have not given all the possible permutations to keep the list short. However, obviously it doesn't show 'Available' for other numbers like 0100. Is there a better way to display and allow edit of these values? Note that the higher 4 bits hold different data so while the byte value does change, I don't want to mess with those bits. For editing I'm okay with the user editing just the first bit (simply entering or choosing 1). However the game does assign different bits to different characters. I created 20 clerics and many of them have different bits assigned (often more than 1). From what I have been able to ascertain, these bits are used to determine Turn Undead only. There is no other use for them within the game that I can find.
Thanks
_________________
It's not cheating. It's playing by my rules. |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1252
|
Posted: Sun Mar 19, 2023 12:04 pm Post subject: |
|
|
I'm just trying to understand;
You have an address and it will read the scan results as "Binary" and add the available results to a list.
(This could be a memo and list address + value + 4 byte binary)
When an address is double-clicked in the list, you can edit it to give it a new value.
(Or you can batch edit all available results.)
Here's a code that formats the integer results as a 4-byte long binary to get you started.
I hope you keep asking or explaining with some more code.
Code: | function binaryBitsFormat(num,bits)
result = 0
if num<=0 then -- result: 0 = 0000
print("error")
else
local function toBits()
bits = bits or math.max(1, select(2, math.frexp(num)))
local t = {}
for b = bits, 1, -1 do
t[b] = math.fmod(num, 2)
num = math.floor((num - t[b]) / 2)
end
return t
end
res1 = toBits()
result = table.concat(res1)
end
return result
end
val1 = binaryBitsFormat(7,4) -- 0111 (7 = 111)
val2 = binaryBitsFormat(210,8) -- 11010010
print("val1: "..val1)
print("val2: "..val2)
for i = 0, 255 do
val3 = binaryBitsFormat(i,8)
print(i.." = "..val3)
end |
_________________
|
|
Back to top |
|
|
gibberishh Cheater Reputation: 1
Joined: 30 Aug 2021 Posts: 37
|
Posted: Sun Mar 19, 2023 1:18 pm Post subject: |
|
|
The game sets 1 (or more) of 4 bits to indicate whether that character can turn undead. That is the weird part.
Editing: I don't care which bit the player edits. That is not an issue.
Display: If Turn Undead is available on a character, I want to show the text 'Available' as the memrec value. Otherwise I want to show 'Unavailable' as the memrec value.
AFAIK, the only way to achieve this is to use the following dropdown options:
0:Unavailable
1:Available
10:Available
100:Available
1000:Available
11:Available
110:Available
1100:Available
1010:Available
1001:Available
1110:Available
111:Available
I'm trying to find a way to shorten this list, if it is possible. Obviously, since I am removing some options from that list, the word 'Available' does not display in the value column. Only the digits are displayed.
_________________
It's not cheating. It's playing by my rules. |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4289
|
Posted: Sun Mar 19, 2023 1:24 pm Post subject: |
|
|
Edit: I'm dumb, just use this:
Code: | 0:Disabled
1:Enabled
*:Enabled | Make sure all 3 boxes are checked and the memrec is set to show as decimal, not binary
You could use a custom value type to force the value to be effectively 0 or 1.
Code: | alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(TypeName,256)
alloc(ByteSize,4)
alloc(UsesFloat,1)
alloc(UsesString,1)
alloc(MaxStringSize,2)
alloc(CallMethod,1)
TypeName:
db 'LowNib Bool',0
ByteSize:
dd 1
UsesFloat:
db 0
UsesString:
db 0
MaxStringSize:
dw #100
CallMethod:
db 1
// cdecl int ConvertRoutine(unsigned char *input, PTR_UINT address);
ConvertRoutine:
[64-bit]
//rcx=address of input
//rdx=address
xor eax,eax
test byte ptr[rcx],F
setne al
ret
[/64-bit]
[32-bit]
push ebp
mov ebp,esp
//[ebp+8]=address of input
//[ebp+c]=address
mov ecx,[ebp+8]
xor eax,eax
test byte ptr [ecx],F
setne al
pop ebp
ret
[/32-bit]
// cdecl void ConvertBackRoutine(int i, PTR_UINT address, unsigned char *output);
ConvertBackRoutine:
[64-bit]
//ecx=input
//rdx=address
//r8=address of output
test ecx,ecx
setne byte ptr [r8]
ret
[/64-bit]
[32-bit]
push ebp
mov ebp,esp
//[ebp+8]=input
//[ebp+c]=address
//[ebp+10]=address of output
mov eax,[ebp+8]
mov ecx,[ebp+10]
test eax,eax
setne byte ptr[ecx]
pop ebp
ret
[/32-bit]
|
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Tue Mar 21, 2023 9:58 am Post subject: |
|
|
gibberishh wrote: | The game sets 1 (or more) of 4 bits to indicate whether that character can turn undead. That is the weird part.
Editing: I don't care which bit the player edits. That is not an issue.
Display: If Turn Undead is available on a character, I want to show the text 'Available' as the memrec value. Otherwise I want to show 'Unavailable' as the memrec value.
AFAIK, the only way to achieve this is to use the following dropdown options:
0:Unavailable
1:Available
10:Available
100:Available
1000:Available
11:Available
110:Available
1100:Available
1010:Available
1001:Available
1110:Available
111:Available
I'm trying to find a way to shorten this list, if it is possible. Obviously, since I am removing some options from that list, the word 'Available' does not display in the value column. Only the digits are displayed. |
maybe try to do binary type, instead of making a separate system of dropdown list?
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|