     // Subfunction are always inlined for performance
     private func drawPixel(_ i: Int) {
         if (state.rasterX >= configuration.visibleX.first || state.rasterX < configuration.visibleX.last - 1) &&
-            (state.raster > configuration.vblankLines.last || state.raster < configuration.vblankLines.first) {
-            if state.rasterX == borderComparison.right {
-                state.nextPipe.mainBorder = true
-            } else if state.rasterX == borderComparison.left {
-                if !state.nextPipe.verticalBorder {
-                    state.nextPipe.mainBorder = false
-                }
-            }
+            (state.rasterX > configuration.vblankLines.last || state.rasterX < configuration.vblankLines.first) {
+            updateSideBorder()
             if state.currentCycle >= 18 && state.currentCycle <= 57 && i == state.pipe.xScroll {
                 state.graphicsShiftRegister = state.pipe.graphicsData
                 state.graphicsMulticolorFlipFlop = true

    private func draw() {
        // vic-ii.txt says Y coord is only checked two times per raster [3.9], but in practice it looks it's checked every cycle. this fixes all dentest tests
        if state.raster == borderComparison.bottom {
            state.nextPipe.verticalBorder = true
        } else if state.raster == borderComparison.top && state.den {
            state.nextPipe.verticalBorder = false
        }
        state.nextPipe.initialRasterX = state.rasterX
        drawPixel(0)

        case 0x15:
            state.me = byte
        case 0x16:
            updateSideBorder()
            state.nextPipe.xScroll = byte & 0x07
            state.csel = byte & 0x08 != 0
            borderComparison.left = state.csel ? 24 : 31
