Sign in to follow this  
Followers 0
Luig

Need help translating a small c code to autoit

4 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Something to do with http://www.rockbox.org?

Yea you have to define what those things are ("get_reg_offset()" and "chip8_regs.alg") before someone can help you.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0