Elementary memory access
This part of Ikarus makes it possible to read and write memory as different data types - integers, strings, arrays of integers or strings and bytes.
If address <= 0
, an error is thrown. Otherwise, an attempt is made to read or write at this address. If the address falls into invalid range, for example in a code segment, access violation will occur (Gothic crashes). In the case of string operations, it is also necessary that at the specified position a valid zString already exists.
Initialization
The best way to initialize all Ikarus functions is to call MEM_InitAll()
in the Init_Global()
initialization function.
Warning
If you want to use Ikarus in Gothic 1, it is best to define your own Init_Global()
function and call it from every world initialization function.
Implementation
Read functions
MEM_ReadInt
MEM_ReadInt
Reads int from the address
.
var int address
Memory address to read from
Return value
The function returns an integer value if the address is correct.
MEM_ReadString
MEM_ReadString
Reads string from the address
.
var int address
Memory address to read from
Return value
The function returns string if the address is correct.
MEM_ReadByte
MEM_ReadByte
Reads byte from the address
.
var int address
Memory address to read from
Return value
The function returns byte value if the address is correct.
MEM_ReadIntArray
MEM_ReadIntArray
Reads int from the array at the arrayAddress
.
var int arrayAddress
Memory address of arrayvar int offset
Array offset (array index)
Return value
The function returns integer value from the array if the address is correct.
MEM_ReadStringArray
Info
MEM_ReadStringArray
has been already moved to the LeGo PermMem package.
MEM_ReadByteArray
MEM_ReadByteArray
Reads byte from the array at the arrayAddress
.
var int arrayAddress
Memory address of arrayvar int offset
Array offset (array index)
Return value
The function returns byte from the array if the address is correct.
Write functions
MEM_WriteInt
MEM_WriteInt
Writes int value in the address
.
var int address
Memory address to write intovar int value
Integer value to write
MEM_WriteString
MEM_WriteString
Writes string in the address
.
var int address
Memory address to write intovar int value
String to write
MEM_WriteByte
MEM_WriteByte
Only the byte at address address
is changed here, not a whole four-byte word. That is, the three subsequent bytes remain untouched. If 0 <= val < 256
does not apply in MEM_WriteByte
, a warning is issued and val is trimmed accordingly. In particular, shouldn't be negative numbers are passed.
var int address
Memory address to write intovar int value
Byte to write
MEM_WriteIntArray
MEM_WriteIntArray
Writes int value in the array at arrayAddress
.
var int arrayAddress
Memory address of arrayvar int offset
Array offset (array index)var int value
Integer value to write
MEM_WriteStringArray
MEM_WriteStringArray
Writes string value in the array at arrayAddress
.
var int arrayAddress
Memory address of arrayvar int offset
Array offset (array index)var string value
String to write
MEM_WriteByteArray
MEM_WriteByteArray
Writes byte value in the array at arrayAddress
.
var int arrayAddress
Memory address of arrayvar int offset
Array offset (array index)var int value
Byte to write