ceedj Posted April 17, 2006 Share Posted April 17, 2006 (edited) Just wondering if anyone knows how BW's MB sets up arrays. Looking at R*'s code, I see that 0004: (set global int) can either be 0004: $Custom = 0 or 0004: $Custom(1) = 0 (this is true with 0006: (set local int) as well) How does the MB do this, converting the (1) into something readable by the SA.exe? I looked at the ReadMe, and it seems he built something into the compiler that calls the proper int opcode (for int, float, string or variable) depending on how you set it up. For example, I think if you type in [email protected] = 0$CustomArray(@1,10i) = 0$CustomArray(1) = 1$CustomArray(2) = 2$CustomArray(3) = 3$CustomArray(4) = 4$CustomArray(5) = 5$CustomArray(6) = 6$CustomArray(7) = 7$CustomArray(8) = 8$CustomArray(9) = 9 it compiles as this: 0006: @1 = 00006: @1(1) = 10006: @1(2) = 20006: @1(3) = 30006: @1(4) = 40006: @1(5) = 50006: @1(6) = 60006: @1(7) = 70006: @1(8) = 80006: @1(9) = 9 I want to set up a function to define arrays in the GTASA Hook (there's already a function to reference them...) How is 0006: @1(1) read by the compiler? Thanks! Edited April 17, 2006 by ceedj I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets Link to comment Share on other sites More sharing options...
Y_Less Posted April 17, 2006 Share Posted April 17, 2006 Ahh, I can explain that (if this is what you asked in you PM, sorry, I didn't understand). If you use $customarray it will obviously be a global array, not a local. Basically, the arrays are an address and an offset * 4 so, using old MB DMA notation: 4??(0) Would be an array, starting at DMA position 4 (4 bytes into the SCM, technically in the middle of a jump, but we'll ignore that for now), and 0 positions into it (AFAIK the array positions are all 4 bytes, but there may be data types for larger arrays) 4??(1) Is one position in, so it's 4 bytes after 4??, this is exactly the same as 8??, 8??(0) or 0??(2) When the code is compiled I think there is a whole load of new data types for local arrays, global arrays, float arrays, 8byte arrays. I did have a link to a list of the types and some explanations but can't find it atm. Link to comment Share on other sites More sharing options...
ceedj Posted April 17, 2006 Author Share Posted April 17, 2006 Ahh, I can explain that (if this is what you asked in you PM, sorry, I didn't understand). If you use $customarray it will obviously be a global array, not a local. Um, whoops. That WAS kind of silly. Yeah, the answer in the PM was helpful in "getting" it, but I need MB equivilant because normal C/C++ code doesn't play too nicely inside of the hooks "theScript" code. I think I can set up another function using what you explained above, similar to the G (global define) function. I will study this more. Thanks very much! I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets Link to comment Share on other sites More sharing options...
J-Fox.GEMM Posted April 18, 2006 Share Posted April 18, 2006 Ehm... Y not using normal Arrays in C++ ? Link to comment Share on other sites More sharing options...
ceedj Posted April 18, 2006 Author Share Posted April 18, 2006 Ehm... Y not using normal Arrays in C++ ? because normal C/C++ code doesn't play too nicely inside of the hooks "theScript" code. I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets Link to comment Share on other sites More sharing options...
random_download Posted April 22, 2006 Share Posted April 22, 2006 Arraytypes:07 = global, any, integer/float08 = local, any, integer/float0c = global, any, fixed-string0d = local, any, fixed-string12 = global, any, variable-string13 = local, any, variable-stringDatatypes:00 = any/local, i01 = any/local, f02 = any/local, s03 = any/local, v80 = any/global, i81 = any/global, f82 = any/global, s83 = any/global, vByte: ArraytypeWord: Array varWord: Index varByte: Array sizeByte: DatatypeParams:01 = int {DWord: 32-bit Integer}02 = int/float global var {Word: global var}03 = int/float local var {Word: local var}04 = int {Byte: 8-bit integer}05 = int {Word: 16-bit Integer}06 = float {Single: Float}07 = int/float global array {Word: global array, Word: int var, Byte: size, Byte: indextype}08 = int/float local array {Word: local array, Word: int var, Byte: size, Byte: indextype}09 = 8bytestring {Char: string}0a = 8bytestring global var {Word: global var}0b = 8bytestring local var {Word: local var}0c = 8bytestring global array {Word: global array, Word: int var, Byte: size, Byte: indextype}0d = 8bytestring local array {Word: local array, Word: int var, Byte: size, Byte: indextype}0e = 16bytestring {Byte: Size, Char: string}10 = 16bytestring global var {Word: global var}11 = 16bytestring local var {Word: local var}12 = 16bytestring global array {Word: global array, Word: int var, Byte: size, Byte: indextype}13 = 16bytestring local array {Word: local array, Word: int var, Byte: size, Byte: indextype} Not sure if that is totally correct, made it a while ago. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now