u32 end = addr + (cheatsList[i].value >> 16);
u32 end = addr + ((cheatsList[i].value >> 16) << 1);
void cheatsCheckKeys(u32 keys, u32 extended){  for(int i = 0; i < cheatsNumber; i++) {    if(!cheatsList[i].enabled) {      // make sure we skip other lines in this code      i += getCodeLength(i)-1;      continue;    }    switch(cheatsList[i].size) {    case INT_8_BIT_WRITE:      CPUWriteByte(cheatsList[i].address, cheatsList[i].value);      break;    case INT_16_BIT_WRITE:      CPUWriteHalfWord(cheatsList[i].address, cheatsList[i].value);      break;    case INT_32_BIT_WRITE:      CPUWriteMemory(cheatsList[i].address, cheatsList[i].value);      break;    case GSA_16_BIT_ROM_PATCH:      if((cheatsList[i].status & 1) == 0) {        if(CPUReadHalfWord(cheatsList[i].address) != cheatsList[i].value) {          cheatsList[i].oldValue = CPUReadHalfWord(cheatsList[i].address);          cheatsList[i].status |= 1;          CHEAT_PATCH_ROM_16BIT(cheatsList[i].address, cheatsList[i].value);        }      }      break;    case GSA_8_BIT_GS_WRITE:      if(extended & 4) {        CPUWriteByte(cheatsList[i].address, cheatsList[i].value);      }      break;    case GSA_16_BIT_GS_WRITE:      if(extended & 4) {        CPUWriteHalfWord(cheatsList[i].address, cheatsList[i].value);         }      break;    case GSA_32_BIT_GS_WRITE:      if(extended & 4) {        CPUWriteMemory(cheatsList[i].address, cheatsList[i].value);           }      break;    case CBA_IF_KEYS_PRESSED:      if(cheatsList[i].address == 0x20) {        if((keys & cheatsList[i].value) != cheatsList[i].value) {          i++;        }      } else if(cheatsList[i].value != keys) {        i++;      }      break;    case CBA_IF_TRUE:      if(CPUReadHalfWord(cheatsList[i].address) != cheatsList[i].value) {        i++;      }      break;    case CBA_SLIDE_CODE:      {        u32 address = cheatsList[i].address;        u16 value = cheatsList[i].value;        i++;        if(i < cheatsNumber) {          int count = cheatsList[i].address;          int inc = cheatsList[i].value;          for(int x = 0; x < count; x++) {            CPUWriteHalfWord(address, value);            address += inc;          }        }      }      break;    case CBA_IF_FALSE:      if(CPUReadHalfWord(cheatsList[i].address) == cheatsList[i].value) {        i++;      }      break;    case CBA_AND:      CPUWriteHalfWord(cheatsList[i].address,                       CPUReadHalfWord(cheatsList[i].address) &                       cheatsList[i].value);      break;    case GSA_8_BIT_GS_WRITE2:      i++;      if(i < cheatsNumber) {        if(extended & 4) {          CPUWriteByte(cheatsList[i-1].address, cheatsList[i].address);        }      }      break;    case GSA_16_BIT_GS_WRITE2:      i++;      if(i < cheatsNumber) {        if(extended & 4) {          CPUWriteHalfWord(cheatsList[i-1].address, cheatsList[i].address);        }      }      break;    case GSA_32_BIT_GS_WRITE2:      i++;      if(i < cheatsNumber) {        if(extended & 4) {          CPUWriteMemory(cheatsList[i-1].address, cheatsList[i].address);        }      }      break;    case GSA_16_BIT_ROM_PATCH2:      i++;      if(i < cheatsNumber) {        if((cheatsList[i-1].status & 1) == 0) {          u32 addr = ((cheatsList[i-1].address & 0x00FFFFFF) << 1) + 0x8000000;          if(CPUReadHalfWord(addr) != (cheatsList[i].address & 0xFFFF)) {            cheatsList[i-1].oldValue = CPUReadHalfWord(addr);            cheatsList[i-1].status |= 1;            CHEAT_PATCH_ROM_16BIT(addr,cheatsList[i].address & 0xFFFF);          }        }      }      break;    case GSA_8_BIT_SLIDE:      i++;      if(i < cheatsNumber) {        u32 addr = cheatsList[i-1].address;        u8 value = cheatsList[i].address;        int vinc = (cheatsList[i].value >> 24) & 255;        int count = (cheatsList[i].value >> 16) & 255;        int ainc = (cheatsList[i].value & 0xffff);        while(count > 0) {          CPUWriteByte(addr, value);          value += vinc;          addr += ainc;          count--;        }      }      break;    case GSA_16_BIT_SLIDE:      i++;      if(i < cheatsNumber) {        u32 addr = cheatsList[i-1].address;        u16 value = cheatsList[i].address;        int vinc = (cheatsList[i].value >> 24) & 255;        int count = (cheatsList[i].value >> 16) & 255;        int ainc = (cheatsList[i].value & 0xffff)*2;        while(count > 0) {          CPUWriteHalfWord(addr, value);          value += vinc;          addr += ainc;          count--;        }      }      break;    case GSA_32_BIT_SLIDE:      i++;      if(i < cheatsNumber) {        u32 addr = cheatsList[i-1].address;        u32 value = cheatsList[i].address;        int vinc = (cheatsList[i].value >> 24) & 255;        int count = (cheatsList[i].value >> 16) & 255;        int ainc = (cheatsList[i].value & 0xffff)*4;        while(count > 0) {          CPUWriteMemory(addr, value);          value += vinc;          addr += ainc;          count--;        }      }      break;    case GSA_8_BIT_IF_TRUE:      if(CPUReadByte(cheatsList[i].address) != cheatsList[i].value) {        i++;      }      break;    case GSA_32_BIT_IF_TRUE:      if(CPUReadMemory(cheatsList[i].address) != cheatsList[i].value) {        i++;      }      break;    case GSA_8_BIT_IF_FALSE:      if(CPUReadByte(cheatsList[i].address) == cheatsList[i].value) {        i++;      }      break;    case GSA_32_BIT_IF_FALSE:      if(CPUReadMemory(cheatsList[i].address) == cheatsList[i].value) {        i++;      }      break;    case GSA_8_BIT_FILL:      {        u32 addr = cheatsList[i].address;        u8 v = cheatsList[i].value & 0xff;        u32 end = addr + (cheatsList[i].value >> 8);        do {          CPUWriteByte(addr, v);          addr++;        } while (addr <= end);      }      break;    case GSA_16_BIT_FILL:      {        u32 addr = cheatsList[i].address;        u16 v = cheatsList[i].value & 0xffff;        u32 end = addr + (cheatsList[i].value >> 16);        do {          CPUWriteHalfWord(addr, v);          addr+=2;        } while (addr <= end);      }      break;    case GSA_8_BIT_IF_TRUE2:      if(CPUReadByte(cheatsList[i].address) != cheatsList[i].value) {        i+=2;      }      break;    case GSA_16_BIT_IF_TRUE2:      if(CPUReadHalfWord(cheatsList[i].address) != cheatsList[i].value) {        i+=2;      }      break;    case GSA_32_BIT_IF_TRUE2:      if(CPUReadMemory(cheatsList[i].address) != cheatsList[i].value) {        i+=2;      }      break;    case GSA_8_BIT_IF_FALSE2:      if(CPUReadByte(cheatsList[i].address) == cheatsList[i].value) {        i+=2;      }      break;    case GSA_16_BIT_IF_FALSE2:      if(CPUReadHalfWord(cheatsList[i].address) == cheatsList[i].value) {        i+=2;      }      break;    case GSA_32_BIT_IF_FALSE2:      if(CPUReadMemory(cheatsList[i].address) == cheatsList[i].value) {        i+=2;      }      break;    }  }}