mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-09-28 15:54:40 +00:00
38 lines
969 B
C
38 lines
969 B
C
|
|
#include "common.h"
|
|
//#link "common.c"
|
|
|
|
byte x = 0; // x scroll position
|
|
byte y = 0; // y scroll position
|
|
byte* scrnbuf; // screen buffer
|
|
|
|
void main(void) {
|
|
clrscr();
|
|
printf("\r\n Hello World!");
|
|
printf("\r\n\r\n This is how we scroll");
|
|
printf("\r\n\r\n One line at a time");
|
|
printf("\r\n\r\n But we don't have time");
|
|
printf("\r\n\r\n To copy all the bytes ");
|
|
VIC.ctrl1 = 0x10; // 24 lines
|
|
VIC.ctrl2 = 0x00; // 38 columns
|
|
|
|
// get screen buffer address
|
|
scrnbuf = (byte*)((VIC.addr << 6) & 0x3c00);
|
|
|
|
// infinite loop
|
|
while (1) {
|
|
x--;
|
|
// set scroll registers
|
|
VIC.ctrl1 = VIC.ctrl1 & 0xf8;
|
|
VIC.ctrl1 |= (y & 7);
|
|
VIC.ctrl2 = VIC.ctrl2 & 0xf8;
|
|
VIC.ctrl2 |= (x & 7);
|
|
// wait for vsync
|
|
waitvsync();
|
|
// every 8 pixels, move screen cells
|
|
if ((x & 7) == 0) {
|
|
memcpy(scrnbuf, scrnbuf+1, 40*8-1);
|
|
}
|
|
}
|
|
}
|