Thanks guys/gals!!!!! alot easier to understand now. Heh time for me to get to work and test the opcodes out.
Well I do have one more question. How do i read this memory layout. There is a small rectangle and a larger rectangle that is double the size. The small rectangle should indicated that its only 1 byte long right. And the large rectangle should be 2 bytes long. So what does the [B1 / B2] stand for?
Opcode: 0x16
Short name: IFSW
Long name: If (Signed Word)
Memory layout
[ 0x16 ][ B1 / B2][ A ][ V ][ C ][ E ]
// Signed word conditional with byte relative jump
case IFSW: // 0x16
{
u8 memory_bank_1 = GetU8(script_position + 1) >> 4;
u8 memory_bank_2 = GetU8(script_position + 1) & 0x0F;
u16 offset_1 = GetU16LE(script_position + 2);
u16 offset_2 = GetU16LE(script_position + 4);
s16 value1 = GAMESTATE->MemoryBankGet(memory_bank_1, offset_1);
s16 value2 = GAMESTATE->MemoryBankGet(memory_bank_2, offset_2);
u8 relation = GetU8(script_position + 6);
u8 jump = GetU8(script_position + 7);
bool result = false;
switch (relation)
{
case 0x00: result = (value1 == value2); break;
case 0x01: result = (value1 != value2); break;
case 0x02: result = (value1 > value2); break;
case 0x03: result = (value1 < value2); break;
case 0x04: result = (value1 >= value2); break;
case 0x05: result = (value1 <= value2); break;
case 0x06: result = (value1 & value2); break;
case 0x07: result = (value1 ^ value2); break;
case 0x08: result = (value1 | value2); break;
case 0x09: result = (value1 & (1 << value2)); break;
case 0x0A: result = !(value1 & (1 << value2)); break;
default: LOGGER->Log(LOGGER_WARNING, "Strange relation: %02x", relation);
}
if (result != true)
{
script_position += jump - 1;
}
if (CONFIG->m_DumpScript == true)
{
LOGGER->Log(LOGGER_INFO, "%s(bank%02x[%04x] = %04x, bank%02x[%04x] = %04x, relation = %02x, jump = %04x)", opcodes_names[opcode].c_str(), memory_bank_1, offset_1, value1, memory_bank_2, offset_2, value2, relation, jump);
}
}
break;