View previous topic :: View next topic |
Author |
Message |
Razi Expert Cheater Reputation: 1
Joined: 17 Jan 2018 Posts: 202
|
Posted: Sun Jun 03, 2018 1:44 am Post subject: How to read/write 7/9 bit value? |
|
|
How to read/write 7/9 bit value? I need to read/write 9 bit value with CEComboBox. And read/write 7 bit value (starting from second bit) with edit box.
In the game, each item in the item list is stored as a word value with the quantity, expressed as a 7-bit value, concatenated with the item's index, expressed as a 9-bit value between the range of 0-320. In Binary: QQQQQQQXXXXXXXXX Where X is the index and Q is the quantity.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sun Jun 03, 2018 2:10 am Post subject: |
|
|
read quantity:
Code: |
quantity=(wordvalue >> 9) & 0x7f
|
write quantity:
Code: |
wordvalue=(wordvalue & 0x1ff) | (quantity << 9)
|
read index:
Code: |
index=wordvalue & 0x1ff;
|
write index:
Code: |
wordvalue=(wordvalue & 0xfe00) | index
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Razi Expert Cheater Reputation: 1
Joined: 17 Jan 2018 Posts: 202
|
Posted: Mon Jun 04, 2018 2:40 am Post subject: |
|
|
I can read index with code:
Code: | for x = 1, 20 do
local offset = x*2-2
cacheTable_CEEditsiteminv[x].ItemIndex = (bAnd(0xFFFF, readInteger(0x009E8ACC+offset))) & 0x1ff
if bAnd(0xFFFF, readInteger(0x009E8ACC+offset)) == 0xFFFF then
cacheTable_CEEditsiteminv[x].ItemIndex = 0x140
end
end
|
And can read quantity with code:
Code: | for x = 1, 20 do
local offset = x*2-2
cacheTable_CEEditsqtyinv[x].Text = (bAnd(0xFFFF, readInteger(0x009E8ACC+offset)) >> 9) & 0x7f
end |
But I can't write index with next code:
Code: | for x = 1, 20 do
cacheTable_CEEditsiteminv[x].OnSelect = function(sender)
local offset1 = x*2-2
index=(bAnd(0xFFFF, readInteger(0x009E8ACC+offset))) & 0x1ff --I think that the error lies in these two lines
wordvalue1= (wordToByteTable(sender.ItemIndex) & 0xfe00) | index
writeBytes(0x009E8ACC+offset1, wordvalue1)
end
end |
And can't write quantity with next code:
Code: | for x = 1, 20 do
local offset = x*2-2
local currentCEEditsqtyinv = cacheTable_CEEditsqtyinv[x]
cacheTable_CEEditsqtyinv[x].OnKeyPress = function(sender, key)
timer.Enabled = false
local a = tonumber(sender.Text)
if (a~=nil) and isKeyPressed(VK_RETURN) then
quantity=(bAnd(0xFFFF, readInteger(0x009E8ACC+offset)) >> 9) & 0x7f --I think that the error lies in these two lines
wordvalue=(wordToByteTable(currentCEEditsqtyinv.Text) & 0x1ff) | (quantity << 9)
writeBytes(0x009E8ACC + offset, wordvalue)
timer.Enabled = true
end
return key
end
end |
What i'm doing wrong?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Mon Jun 04, 2018 3:52 am Post subject: |
|
|
I think wordToByteTable(sender.ItemIndex) is wrong as sender.ItemIndex is at most the number of records-1 in the list
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Razi Expert Cheater Reputation: 1
Joined: 17 Jan 2018 Posts: 202
|
Posted: Tue Jun 05, 2018 8:58 am Post subject: |
|
|
For newbies like me. I can write index with next code:
Code: | UDF1.CEComboBox184.OnSelect = function(sender)
quantity=((byteTableToWord(readBytes(0x009E8ACC, 2,true))) >> 9) & 0x7f
wordvalue1=((UDF1.CEComboBox184.ItemIndex) & 0x1ff) | (quantity << 9)
writeBytes(0x009E8ACC, wordToByteTable(wordvalue1))
end |
And can write quantity with next code:
Code: | UDF1.CEEdit300.OnKeyPress = function(sender, key)
timer.Enabled = false
local a = tonumber(sender.Text)
if (a~=nil) and isKeyPressed(VK_RETURN) then
index=(byteTableToWord(readBytes(0x009E8ACC, 2,true))) & 0x1FF
wordvalue=((UDF1.CEEdit300.Text) & 0x7f) << 9 | index
writeBytes(0x009E8ACC, wordToByteTable(wordvalue))
timer.Enabled = true
end
return key
end |
|
|
Back to top |
|
|
|