2013-10-28 19:13:01 +00:00
using System ;
using System.Linq ;
2014-05-19 01:06:44 +00:00
using LuaInterface ;
2013-11-01 14:51:51 +00:00
namespace BizHawk.Client.Common
2013-10-28 19:13:01 +00:00
{
2013-10-31 16:10:20 +00:00
public class MemoryLuaLibrary : LuaLibraryBase
2013-10-28 19:13:01 +00:00
{
2013-12-30 01:58:44 +00:00
private int _currentMemoryDomain ; // Main memory by default
2013-10-31 16:10:20 +00:00
2014-05-19 01:06:44 +00:00
public MemoryLuaLibrary ( Lua lua )
{
2014-05-20 20:34:51 +00:00
Lua = lua ;
2014-05-19 01:06:44 +00:00
}
2014-02-03 20:48:01 +00:00
public override string Name { get { return "memory" ; } }
2013-10-28 19:13:01 +00:00
#region Memory Library Helpers
2013-10-31 16:10:20 +00:00
private static int U2S ( uint u , int size )
{
2014-01-26 02:43:28 +00:00
var s = ( int ) u ;
2013-10-31 16:10:20 +00:00
s < < = 8 * ( 4 - size ) ;
s > > = 8 * ( 4 - size ) ;
return s ;
}
2014-01-26 02:43:28 +00:00
private int ReadSignedLittleCore ( int addr , int size )
2013-10-28 19:13:01 +00:00
{
2014-01-26 02:43:28 +00:00
return U2S ( ReadUnsignedLittle ( addr , size ) , size ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
private uint ReadUnsignedLittle ( int addr , int size )
2013-10-28 19:13:01 +00:00
{
uint v = 0 ;
2014-01-26 02:43:28 +00:00
for ( var i = 0 ; i < size ; + + i )
{
v | = ReadUnsignedByte ( addr + i ) < < ( 8 * i ) ;
}
2013-10-28 19:13:01 +00:00
return v ;
}
2014-01-26 02:43:28 +00:00
private int ReadSignedBig ( int addr , int size )
2013-10-28 19:13:01 +00:00
{
2014-01-26 02:43:28 +00:00
return U2S ( ReadUnsignedBig ( addr , size ) , size ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
private uint ReadUnsignedBig ( int addr , int size )
2013-10-28 19:13:01 +00:00
{
uint v = 0 ;
2014-01-26 02:43:28 +00:00
for ( var i = 0 ; i < size ; + + i )
2013-10-31 16:10:20 +00:00
{
2014-01-26 02:43:28 +00:00
v | = ReadUnsignedByte ( addr + i ) < < ( 8 * ( size - 1 - i ) ) ;
2013-10-31 16:10:20 +00:00
}
2014-01-26 02:43:28 +00:00
2013-10-28 19:13:01 +00:00
return v ;
}
2014-01-26 02:43:28 +00:00
private void WriteSignedLittle ( int addr , int v , int size )
2013-10-28 19:13:01 +00:00
{
2014-01-26 02:43:28 +00:00
WriteUnsignedLittle ( addr , ( uint ) v , size ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
private void WriteUnsignedLittle ( int addr , uint v , int size )
2013-10-28 19:13:01 +00:00
{
2014-01-26 02:43:28 +00:00
for ( var i = 0 ; i < size ; + + i )
2013-10-31 16:10:20 +00:00
{
2014-01-26 02:43:28 +00:00
WriteUnsignedByte ( addr + i , ( v > > ( 8 * i ) ) & 0xFF ) ;
2013-10-31 16:10:20 +00:00
}
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
private void WriteSignedBig ( int addr , int v , int size )
2013-10-28 19:13:01 +00:00
{
2014-01-26 02:43:28 +00:00
WriteUnsignedBig ( addr , ( uint ) v , size ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
private void WriteUnsignedBig ( int addr , uint v , int size )
2013-10-28 19:13:01 +00:00
{
2014-01-26 02:43:28 +00:00
for ( var i = 0 ; i < size ; + + i )
{
WriteUnsignedByte ( addr + i , ( v > > ( 8 * ( size - 1 - i ) ) ) & 0xFF ) ;
}
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
private uint ReadUnsignedByte ( int addr )
2013-10-28 19:13:01 +00:00
{
2013-12-30 01:58:44 +00:00
return Global . Emulator . MemoryDomains [ _currentMemoryDomain ] . PeekByte ( addr ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
private void WriteUnsignedByte ( int addr , uint v )
2013-10-28 19:13:01 +00:00
{
2013-12-30 01:58:44 +00:00
Global . Emulator . MemoryDomains [ _currentMemoryDomain ] . PokeByte ( addr , ( byte ) v ) ;
2013-10-28 19:13:01 +00:00
}
#endregion
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"getmemorydomainlist" ,
2014-01-26 18:36:27 +00:00
"Returns a string of the memory domains for the loaded platform core. List will be a single string delimited by line feeds"
2014-01-26 02:43:28 +00:00
) ]
2014-05-19 01:06:44 +00:00
public LuaTable GetMemoryDomainList ( )
2013-10-28 19:13:01 +00:00
{
2014-05-20 20:34:51 +00:00
var table = Lua . NewTable ( ) ;
2014-05-19 01:06:44 +00:00
for ( int i = 0 ; i < Global . Emulator . MemoryDomains . Count ; i + + )
{
table [ i ] = Global . Emulator . MemoryDomains [ i ] . Name ;
}
return table ;
2013-10-28 19:13:01 +00:00
}
2014-05-19 01:13:26 +00:00
[ LuaMethodAttributes (
"readbyterange" ,
"Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the address is the key)."
) ]
public LuaTable ReadByteRange ( int addr , int length )
{
var lastAddr = length + addr ;
2014-05-20 20:34:51 +00:00
var table = Lua . NewTable ( ) ;
2014-05-19 01:42:41 +00:00
if ( lastAddr < Global . Emulator . MemoryDomains [ _currentMemoryDomain ] . Size )
{
for ( var i = addr ; i < = lastAddr ; i + + )
{
var a = string . Format ( "{0:X2}" , i ) ;
var v = Global . Emulator . MemoryDomains [ _currentMemoryDomain ] . PeekByte ( i ) ;
var vs = string . Format ( "{0:X2}" , ( int ) v ) ;
table [ a ] = vs ;
}
}
else
2014-05-19 01:13:26 +00:00
{
2014-05-19 01:42:41 +00:00
Log ( "Warning: Attempted read " + lastAddr + " outside memory domain size of " +
Global . Emulator . MemoryDomains [ _currentMemoryDomain ] . Size +
" in memory.readbyterange()" ) ;
2014-05-19 01:13:26 +00:00
}
return table ;
}
[ LuaMethodAttributes (
"writebyterange" ,
"Writes the given values to the given addresses as unsigned bytes"
) ]
public void WriteByteRange ( LuaTable memoryblock )
{
foreach ( var address in memoryblock . Keys )
{
2014-05-19 01:42:41 +00:00
var addr = LuaInt ( address ) ;
if ( addr < Global . Emulator . MemoryDomains [ _currentMemoryDomain ] . Size )
{
Global . Emulator . MemoryDomains [ _currentMemoryDomain ] . PokeByte (
addr ,
( byte ) LuaInt ( memoryblock [ address ] ) ) ;
}
else
{
Log ( "Warning: Attempted read " + addr + " outside memory domain size of " +
Global . Emulator . MemoryDomains [ _currentMemoryDomain ] . Size +
" in memory.writebyterange()" ) ;
}
2014-05-19 01:13:26 +00:00
}
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"getcurrentmemorydomain" ,
2014-01-26 18:36:27 +00:00
"Returns a string name of the current memory domain selected by Lua. The default is Main memory"
2014-01-26 02:43:28 +00:00
) ]
public string GetCurrentMemoryDomain ( )
2013-10-28 19:13:01 +00:00
{
2013-12-30 01:58:44 +00:00
return Global . Emulator . MemoryDomains [ _currentMemoryDomain ] . Name ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"getcurrentmemorydomainsize" ,
2014-01-26 18:36:27 +00:00
"Returns the number of bytes of the current memory domain selected by Lua. The default is Main memory"
2014-01-26 02:43:28 +00:00
) ]
public int GetCurrentMemoryDomainSize ( )
2013-10-28 19:13:01 +00:00
{
2013-12-30 01:58:44 +00:00
return Global . Emulator . MemoryDomains [ _currentMemoryDomain ] . Size ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"readbyte" ,
2014-01-26 18:36:27 +00:00
"gets the value from the given address as an unsigned byte"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public uint ReadByte ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadUnsignedByte ( addr ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"readfloat" ,
2014-01-26 18:36:27 +00:00
"Reads the given address as a 32-bit float value from the main memory domain with th e given endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public float ReadFloat ( int addr , bool bigendian )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
var val = Global . Emulator . MemoryDomains [ _currentMemoryDomain ] . PeekDWord ( addr , bigendian ) ;
2014-01-26 02:43:28 +00:00
var bytes = BitConverter . GetBytes ( val ) ;
return BitConverter . ToSingle ( bytes , 0 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"writebyte" ,
2014-01-26 18:36:27 +00:00
"Writes the given value to the given address as an unsigned byte"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteByte ( int addr , uint value )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
WriteUnsignedByte ( addr , value ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"writefloat" ,
2014-01-26 18:36:27 +00:00
"Writes the given 32-bit float value to the given address and endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteFloat ( int addr , double value , bool bigendian )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
var dv = ( float ) value ;
2014-01-26 02:43:28 +00:00
var bytes = BitConverter . GetBytes ( dv ) ;
var v = BitConverter . ToUInt32 ( bytes , 0 ) ;
2014-01-27 01:15:56 +00:00
Global . Emulator . MemoryDomains [ _currentMemoryDomain ] . PokeDWord ( addr , v , bigendian ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"usememorydomain" ,
2014-01-26 18:36:27 +00:00
"Attempts to set the current memory domain to the given domain. If the name does not match a valid memory domain, the function returns false, else it returns true"
2014-01-26 02:43:28 +00:00
) ]
public bool UseMemoryDomain ( string domain )
2013-10-28 19:13:01 +00:00
{
2014-01-26 02:43:28 +00:00
for ( var i = 0 ; i < Global . Emulator . MemoryDomains . Count ; i + + )
2013-10-28 19:13:01 +00:00
{
2014-01-26 02:43:28 +00:00
if ( Global . Emulator . MemoryDomains [ i ] . Name = = domain )
2013-10-28 19:13:01 +00:00
{
2014-01-26 02:43:28 +00:00
_currentMemoryDomain = i ;
2013-10-28 19:13:01 +00:00
return true ;
}
}
return false ;
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_s8" ,
2014-01-26 18:36:27 +00:00
"read signed byte"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public int ReadS8 ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ( sbyte ) ReadUnsignedByte ( addr ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_u8" ,
2014-01-26 18:36:27 +00:00
"read unsigned byte"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public uint ReadU8 ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadUnsignedByte ( addr ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_s16_le" ,
2014-01-26 18:36:27 +00:00
"read signed 2 byte value, little endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public int ReadS16Little ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadSignedLittleCore ( addr , 2 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_s24_le" ,
2014-01-26 18:36:27 +00:00
"read signed 24 bit value, little endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public int ReadS24Little ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadSignedLittleCore ( addr , 3 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_s32_le" ,
2014-01-26 18:36:27 +00:00
"read signed 4 byte value, little endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public int ReadS32Little ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadSignedLittleCore ( addr , 4 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_u16_le" ,
2014-01-26 18:36:27 +00:00
"read unsigned 2 byte value, little endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public uint ReadU16Little ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadUnsignedLittle ( addr , 2 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_u24_le" ,
2014-01-26 18:36:27 +00:00
"read unsigned 24 bit value, little endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public uint ReadU24Little ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadUnsignedLittle ( addr , 3 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_u32_le" ,
2014-01-26 18:36:27 +00:00
"read unsigned 4 byte value, little endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public uint ReadU32Little ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadUnsignedLittle ( addr , 4 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_s16_be" ,
2014-01-26 18:36:27 +00:00
"read signed 2 byte value, big endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public int ReadS16Big ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadSignedBig ( addr , 2 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_s24_be" ,
2014-01-26 18:36:27 +00:00
"read signed 24 bit value, big endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public int ReadS24Big ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadSignedBig ( addr , 3 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_s32_be" ,
2014-01-26 18:36:27 +00:00
"read signed 4 byte value, big endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public int ReadS32Big ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadSignedBig ( addr , 4 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_u16_be" ,
2014-01-26 18:36:27 +00:00
"read unsigned 2 byte value, big endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public uint ReadU16Big ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadUnsignedBig ( addr , 2 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"read_u24_be" ,
2014-01-26 18:36:27 +00:00
"read unsigned 24 bit value, big endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public uint ReadU24Big ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadUnsignedBig ( addr , 3 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"u32_be" ,
2014-01-26 18:36:27 +00:00
"read unsigned 4 byte value, big endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public uint ReadU32Big ( int addr )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
return ReadUnsignedBig ( addr , 4 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_s8" ,
2014-01-26 18:36:27 +00:00
"write signed byte"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteS8 ( int addr , uint value )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
WriteUnsignedByte ( addr , value ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
2014-05-06 17:29:52 +00:00
"write_u8" ,
2014-01-26 18:36:27 +00:00
"write unsigned byte"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteU8 ( int addr , uint value )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
WriteUnsignedByte ( addr , value ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_s16_le" ,
2014-01-26 18:36:27 +00:00
"write signed 2 byte value, little endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteS16Little ( int addr , int value )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
WriteSignedLittle ( addr , value , 2 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_s24_le" ,
2014-01-26 18:36:27 +00:00
"write signed 24 bit value, little endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteS24Little ( int addr , int value )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
WriteSignedLittle ( addr , value , 3 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_s32_le" ,
2014-01-26 18:36:27 +00:00
"write signed 4 byte value, little endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteS32Little ( int addr , int value )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
WriteSignedLittle ( addr , value , 4 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_u16_le" ,
2014-01-26 18:36:27 +00:00
"write unsigned 2 byte value, little endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteU16Little ( int addr , uint value )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
WriteUnsignedLittle ( addr , value , 2 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_u24_le" ,
2014-01-26 18:36:27 +00:00
"write unsigned 24 bit value, little endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteU24Little ( int addr , uint value )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
WriteUnsignedLittle ( addr , value , 3 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_u32_le" ,
2014-01-26 18:36:27 +00:00
"write unsigned 4 byte value, little endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteU32Little ( int addr , uint value )
2013-10-28 19:13:01 +00:00
{
2014-01-27 01:15:56 +00:00
WriteUnsignedLittle ( addr , value , 4 ) ;
2013-10-28 19:13:01 +00:00
}
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_s16_be" ,
2014-01-26 18:36:27 +00:00
"write signed 2 byte value, big endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteS16Big ( int addr , int value )
2014-01-26 02:43:28 +00:00
{
2014-01-27 01:15:56 +00:00
WriteSignedBig ( addr , value , 2 ) ;
2014-01-26 02:43:28 +00:00
}
2013-10-28 19:13:01 +00:00
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_s24_be" ,
2014-01-26 18:36:27 +00:00
"write signed 24 bit value, big endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteS24Big ( int addr , int value )
2014-01-26 02:43:28 +00:00
{
2014-01-27 01:15:56 +00:00
WriteSignedBig ( addr , value , 3 ) ;
2014-01-26 02:43:28 +00:00
}
2013-10-28 19:13:01 +00:00
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_s32_be" ,
2014-01-26 18:36:27 +00:00
"write signed 4 byte value, big endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteS32Big ( int addr , int value )
2014-01-26 02:43:28 +00:00
{
2014-01-27 01:15:56 +00:00
WriteSignedBig ( addr , value , 4 ) ;
2014-01-26 02:43:28 +00:00
}
2013-10-28 19:13:01 +00:00
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_u16_be" ,
2014-01-26 18:36:27 +00:00
"write unsigned 2 byte value, big endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteU16Big ( int addr , uint value )
2014-01-26 02:43:28 +00:00
{
2014-01-27 01:15:56 +00:00
WriteUnsignedBig ( addr , value , 2 ) ;
2014-01-26 02:43:28 +00:00
}
2013-10-28 19:13:01 +00:00
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_u24_be" ,
2014-01-26 18:36:27 +00:00
"write unsigned 24 bit value, big endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteU24Big ( int addr , uint value )
2014-01-26 02:43:28 +00:00
{
2014-01-27 01:15:56 +00:00
WriteUnsignedBig ( addr , value , 3 ) ;
2014-01-26 02:43:28 +00:00
}
2013-10-28 19:13:01 +00:00
2014-01-26 02:43:28 +00:00
[ LuaMethodAttributes (
"write_u32_be" ,
2014-01-26 18:36:27 +00:00
"write unsigned 4 byte value, big endian"
2014-01-26 02:43:28 +00:00
) ]
2014-01-27 01:15:56 +00:00
public void WriteU32Big ( int addr , uint value )
2014-01-26 02:43:28 +00:00
{
2014-01-27 01:15:56 +00:00
WriteUnsignedBig ( addr , value , 4 ) ;
2013-10-28 19:13:01 +00:00
}
}
}