public void handler(int offset, int data) {
            UBytePtr RAM = memory_region(REGION_CPU2);
            int length = memory_region_length(REGION_CPU2) - 0x10000;
            int bankaddr;

            bankaddr = (data * 0x4000) & (length - 1);
            cpu_setbank(1, new UBytePtr(RAM, 0x10000 + bankaddr));

            if (errorlog != null && (data & 0xfe) != 0) {
                fprintf(errorlog, "%04x: write %02x to f004\n", cpu_get_pc(), data);
            }
        }