//TESH.scrollpos=0
//TESH.alwaysfold=0
library Bytecode uses CodeVar // Prototype design written by Jesus4Lyf.
globals
private constant integer ZERO=1024
integer POINTERTOZERO//=0x0FBE1EE0 // Memory location for bj_meleeTwinkedHeroes[ZERO].
private constant integer HEXPAIRSPERINDEX=4
endglobals
// Complete abstraction.
private function GetPointerToIndex takes integer i returns integer
return POINTERTOZERO+(i-ZERO)*HEXPAIRSPERINDEX // HEX pairs per array index.
endfunction
private function WriteToIndex takes integer i, integer data returns nothing
set bj_meleeTwinkedHeroes[i]=data
endfunction
function TestPointer takes nothing returns nothing
call WriteToIndex(ZERO,0x0C00F5F7)
call WriteToIndex(ZERO+1,0x11111111)
call BJDebugMsg(ToHex(CodeVar.create(function GetRandomDirectionDeg)))
endfunction
function SetPointer takes nothing returns nothing
set POINTERTOZERO=CodeVar.create(function GetRandomDirectionDeg)+0xC92D8
endfunction
// Complete abstraction.
globals
private constant integer BYTECODESIZE=512
private integer LASTBYTECODE=0
// Bytecodes
private constant integer ENDFUNCTION=0x27000000
endglobals
struct Bytecode
integer lastwrite
private method seal takes nothing returns nothing
call WriteToIndex(this.lastwrite+1,ENDFUNCTION)
endmethod
private method append takes integer line returns nothing
set this.lastwrite=this.lastwrite+1
call WriteToIndex(this.lastwrite,line)
endmethod
static method create takes nothing returns Bytecode
// Increment global indexer.
local Bytecode this=LASTBYTECODE+BYTECODESIZE
set LASTBYTECODE=this
// Initialise.
set this.lastwrite=this-1
call this.seal()
// Return.
return this
endmethod
method getCodeVar takes nothing returns CodeVar
return GetPointerToIndex(this)
endmethod
method addCall takes integer funcID, integer param returns nothing
// Set 1.
call this.append(0x0C000000)
call this.append(param)
call this.append(0x13000000)
call this.append(0x00000000)
// Set 2.
call this.append(0x16000000)
call this.append(funcID)
call this.append(0x0B010000)
call this.append(0x00000000)
// End function.
call this.seal()
endmethod
endstruct
endlibrary