With the default settings, the CIO will count 26 HSYNC transitions (52 lines of the display covered in this time) and generate a interrupt. At VSYNC the counter is reset so that the interrupts are synchronised.
I do not know the exact function of the counter's of Port B. I have looked at the schematics, and it appears to control the video hardware. Maybe the KC compact has a programmable pixel clock, if it does, then the base resolution can be changed.
CPC Interrupts: