@Override
        public int read(int address) {
            int data = 0;
            if (currentBit >= 8)
                currentBit = 0;
            switch (address & 0xFFFF) {
                // player 1
                case 0x4016:
                    if (NesGui.getKeyState(NesGui.JOYSTICK_PLAYER1 + currentBit))
                        data = 1;
                    currentBit++;
                    break;
                // player 2
                case 0x4017:
                    if (NesGui.getKeyState(NesGui.JOYSTICK_PLAYER2 + currentBit))
                        data = 1;
                    currentBit++;
                    break;
            }
            return data & 1;
        }