2018-08-13 22:17:36 +00:00
|
|
|
|
2018-08-12 23:59:08 +00:00
|
|
|
#include <cv.h>
|
|
|
|
#include <cvu.h>
|
2017-05-02 13:09:53 +00:00
|
|
|
|
2018-11-29 23:55:20 +00:00
|
|
|
#include "common.h"
|
2017-05-02 13:09:53 +00:00
|
|
|
|
2018-11-29 23:55:20 +00:00
|
|
|
char starfield_base_char = 240;
|
2017-05-02 13:09:53 +00:00
|
|
|
|
2018-11-29 23:55:20 +00:00
|
|
|
const char star_yoffsets[32] = {
|
|
|
|
31, 11, 25, 10, 21, 1, 9, 6,
|
|
|
|
22, 3, 7, 14, 15, 18, 0, 29,
|
|
|
|
30, 5, 16, 28, 20, 12, 24, 17,
|
|
|
|
13, 8, 26, 19, 23, 27, 2, 4
|
|
|
|
};
|
2017-05-02 13:09:53 +00:00
|
|
|
|
2018-11-29 23:55:20 +00:00
|
|
|
byte starfield_get_tile_xy(byte x, byte y) {
|
|
|
|
return ((star_yoffsets[x] + y) & 15) + starfield_base_char;
|
2017-05-02 13:09:53 +00:00
|
|
|
}
|
|
|
|
|
2018-11-29 23:55:20 +00:00
|
|
|
void starfield_setup() {
|
|
|
|
for (byte x=0; x<32; x++) {
|
|
|
|
for (byte y=0; y<28; y++) {
|
|
|
|
putchar(x, y, starfield_get_tile_xy(x, y));
|
|
|
|
}
|
|
|
|
cvu_voutb(COLOR_FG(CV_COLOR_WHITE),
|
|
|
|
COLOR+((starfield_base_char+x)>>3));
|
|
|
|
}
|
2017-05-02 13:09:53 +00:00
|
|
|
}
|
|
|
|
|
2018-11-29 23:55:20 +00:00
|
|
|
void starfield_update() {
|
|
|
|
static byte oldcounter;
|
|
|
|
const byte mask = 0x7f; // 128 star bytes
|
|
|
|
byte counter = vint_counter;
|
|
|
|
word base = PATTERN + starfield_base_char * 8;
|
|
|
|
// erase old star, create new star in pattern table
|
|
|
|
cvu_voutb(0, base + (oldcounter & mask));
|
|
|
|
cvu_voutb(8, base + (counter & mask));
|
|
|
|
oldcounter = counter;
|
|
|
|
}
|
2017-05-02 13:09:53 +00:00
|
|
|
|
2018-11-29 23:55:20 +00:00
|
|
|
#ifdef __MAIN__
|
2017-05-02 13:09:53 +00:00
|
|
|
|
2018-11-29 23:55:20 +00:00
|
|
|
//#link "common.c"
|
2017-05-02 13:09:53 +00:00
|
|
|
|
2018-11-29 23:55:20 +00:00
|
|
|
void main() {
|
|
|
|
vdp_setup();
|
|
|
|
cv_set_vint_handler(&vint_handler);
|
|
|
|
starfield_setup();
|
|
|
|
cv_set_screen_active(true);
|
|
|
|
while(1) {
|
|
|
|
wait_vsync();
|
|
|
|
starfield_update();
|
|
|
|
}
|
2017-05-02 13:09:53 +00:00
|
|
|
}
|
2018-11-29 23:55:20 +00:00
|
|
|
|
|
|
|
#endif
|