Convert Window Screen Coord to Game Screen Coord (and Vice-Versa)

If you don't have SAMPFUNCS and needs to convert between Window Screen Coordinate System and Game Screen Coordinate System, try using these converter snippets:

Code:
:Opcode0B5F // 0AB1: @Opcode0B5F 2 _ConvertWindowScreenXY 981.23 492.41 _toGameScreenXY 30@ 31@
    // convert to gamescreencoordX
0A8D: 23@ = read_memory 0xC17044 size 4 virtual_protect 0 // full screen X
008F: 23@ = integer 23@ to_float
0A8D: 22@ = read_memory 0x859520 size 4 virtual_protect 0 // screen X scale
006B: 23@ *= 22@ // pixels per gamecoordwidth
0073: 0@ /= 23@ // (float)

    // convert to gamescreencoordY
0A8D: 23@ = read_memory 0xC17048 size 4 virtual_protect 0 // full screen Y
008F: 23@ = integer 23@ to_float
0A8D: 22@ = read_memory 0x859524 size 4 virtual_protect 0 // screen Y scale
006B: 23@ *= 22@ // pixels per gamecoordheight
0073: 1@ /= 23@ // (float)
ret 2 0@ 1@

Code:
:Opcode0B60 // 0AB1: @Opcode0B60 2 _ConvertGameScreenXY 981.23 492.41 _toWindowScreenXY 30@ 31@
    // convert to windowscreencoordX
0A8D: 23@ = read_memory 0xC17044 size 4 virtual_protect 0 // full screen X
008F: 23@ = integer 23@ to_float
0A8D: 22@ = read_memory 0x859520 size 4 virtual_protect 0 // screen X scale
006B: 23@ *= 22@ // pixels per gamecoordwidth
006B: 0@ *= 23@ // (float)

    // convert to windowscreencoordY
0A8D: 23@ = read_memory 0xC17048 size 4 virtual_protect 0 // full screen Y
008F: 23@ = integer 23@ to_float
0A8D: 22@ = read_memory 0x859524 size 4 virtual_protect 0 // screen Y scale
006B: 23@ *= 22@ // pixels per gamecoordheight
006B: 1@ *= 23@ // (float)
ret 2 0@ 1@
 
Top