private void setRegister(int register, byte val) {
        // any time we write to a PPU register, the bottom 5 bits of PPUSTATUS reflect that value
        _ppu_status = (byte)((_ppu_status&0xE0)|(val & 0x1F));
        switch (register) {
            case 0:
                setPPUCTRL(val);
                break;  // 0x2000
            case 1:
                setPPUMASK(val);
                break; // 0x2001
            case 3:
                setOAMADDR(val);
                break; // 0x2003
            case 4:
                setOAMDATA(val);
                break; // 0x2004
            case 5:
                setPPUSCROLL(val);
                break; // 0x2005
            case 6:
                setPPUADDR(val);
                break; // 0x2006
            case 7:
                setPPUDATA(val);
                break; // 0x2007
            default:
                _ppuLatch = val;
                break;
        }

    }