/************************************************************************/ /* Fill 'display buffer' with text then display it */ /* in a split screen. Use cursor keys to scroll the top half */ /************************************************************************/ demo_split_screen() { #define KEY_ESC 0x011B #define KEY_UP 0x4800 #define KEY_DOWN 0x5000 #define KEY_LEFT 0x4B00 #define KEY_RIGHT 0x4D00 #define KEY_ENTER 0x1C0D #define MONO 5 #define VMONO 7 static char digits[] = {"0123456789"}; static char text[] = {"This is line 000"}; int i, line, key, size, port; /*--- Fill display buffer with text --- */ /* (cannot use printf since we want to go below line 25) */ for (i = 0; i < 400; i++) { text[15] = digits[i % 10]; /* Add line number */ text[14] = digits[(i/10)%10]; text[13] = digits[(i/100)%10]; write_string(i, 0, text); /* Draw next text line */ } /*--- Smoothly move in the split line --- */ size = get_scanlines()/2; /* Last split to do */ for (i = get_scanlines(); i > size; i--)/* Loop over scanline */ split_screen(i); /* to smoothly move in */ /*--- Use cursor keys to control the scroll --- */ /* Each line of text takes 80 bytes, so to scroll down one */ /* line, we set START ADDRESS register in CRTC to 80 more */ line = 0; /* Initialize line pos */ /* Set CRTC address */ if (get_display_type() == MONO || get_display_type() == VMONO) port = 0x3B4; else port = 0x3D4; while((key = get_key()) != KEY_ENTER) { switch (key) { case KEY_UP: /* Scroll up one line */ line = (line > 0) ? --line : 0; break; case KEY_DOWN: /* Scroll down one line */ line++; break; default: break; } write_register(port,0x0D); /* Select CRTC START LO */ write_register(port+1, line * 80); /* Write low */ write_register(port,0x0C); /* Select CRTC START HI */ write_register(port+1,(line * 80)>>8); /* Write high */ } /* Reset CRT START ADDRESS to 0 (no scroll) */ write_register(port,0x0D); /* Select CRTC START LO */ write_register(port+1,0); /* Write low */ write_register(port,0x0C); /* Select CRTC START HI */ write_register(port+1,0); /* Write high */ /* Remove the split */ size = get_scanlines(); /* Last split to do */ for (i = get_scanlines()/2; i <= size; i++) /* Loop over */ split_screen(i); /* to smoothly move out */ }