static void patch_codeX(int offset, int data, int cpu) {
        int aligned_offset = offset & 0xfffffe;
        UBytePtr RAM = memory_region(REGION_CPU1 + cpu);
        int old_word = RAM.READ_WORD(aligned_offset);

        if ((offset & 1) != 0) {
            data = (old_word & 0xff00) | data;
        } else {
            data = (old_word & 0x00ff) | (data << 8);
        }

        RAM.WRITE_WORD(aligned_offset, data);
    }