private void setControl(byte val) {
//        System.out.println("SetControl:" + ByteFormatter.formatBits((byte)val));
        chr4KMode = ((val & 0x10) == 0x10);
        int prgMode = ((val >> 2) & 0x3);
        if (prgMode < 2) {
            using32PRGBank = true;
            lowBankFixed = false;
        } else if (prgMode == 2) {
            lowBankFixed = true;
            lowPrgBank = 0;
        } else {
            lowBankFixed = false;
            highPrgBank = (prgData.length / 0x4000) - 1;
        }
        mirror = (val & 0x3);
        if(_ppuRef != null) {
    // Mirroring (0: one-screen, lower bank; 1: one-screen, upper bank;
    //         2: vertical; 3: horizontal)
        switch (mirror) {
            case 0:  _ppuRef.setMirroringMode(0,0,0,0); // all are $2000
                break;
            case 1:  _ppuRef.setMirroringMode(1,1,1,1); // all are $2400
                break;
            case 2:  _ppuRef.setVerticalMirroringMode(); 
                break;
            case 3:
            default:
                // never gets here
                _ppuRef.setHorizontalMirroringMode(); 
                break;
        }
        }
    }