public void handler() {
            int A, i, j;
            UBytePtr RAM = memory_region(REGION_CPU1);

            /* The first CPU ROM has the address and data lines scrambled */
            for (A = 0; A < 0x2000; A++) {
                int[] bit = new int[13];

                for (i = 0; i < 13; i++) {
                    bit[i] = (A >> i) & 1;
                }

                j
                        = (bit[11] << 0)
                        + (bit[0] << 1)
                        + (bit[2] << 2)
                        + (bit[4] << 3)
                        + (bit[6] << 4)
                        + (bit[8] << 5)
                        + (bit[10] << 6)
                        + (bit[12] << 7)
                        + (bit[1] << 8)
                        + (bit[3] << 9)
                        + (bit[5] << 10)
                        + (bit[7] << 11)
                        + (bit[9] << 12);

                for (i = 0; i < 8; i++) {
                    bit[i] = (RAM.read(A + 0x10000) >> i) & 1;
                }

                RAM.write(j,
                        (bit[5] << 0)
                        + (bit[0] << 1)
                        + (bit[3] << 2)
                        + (bit[6] << 3)
                        + (bit[1] << 4)
                        + (bit[4] << 5)
                        + (bit[7] << 6)
                        + (bit[2] << 7));
            }
        }