Jump to content

Need help translating a small c code to autoit


Luig
 Share

Recommended Posts

Ok I want to translate:

#define get_reg_offset(opcode)          (chip8_regs.alg+(opcode>>8))
#define get_reg_value(opcode)           (*get_reg_offset(opcode))

To Au3. So far I got:

Func get_reg_offset($opcode)
    Return DllStructGetData($chip_regs, 'alg') + BitShift($opcode, 8))
EndFunc

Func get_reg_value($opcode)
    Return ptr(get_reg_offset($opcode))
EndFunc

I know I am missing something because how do I read the value since ptr only makes a pointer. How do I then read the value from the pointer?

Edited by Luig
Link to comment
Share on other sites

  • 4 weeks later...
  • Moderators

No idea what .alg type is, but I might try something like this:

Func get_reg_value($opcode)
    ; assuming get_reg_offset is a mem address
    Local $talgval = DllStructCreate("long", Ptr(get_reg_offset($opcode))
    Return DllStructGetData($talgval, 1)
EndFunc

Without ptr() might work as well, no idea really without playing with the code myself.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...