Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Circle.kc
- import "vera"
- char j = 16;
- void main() {
- vpoke(15,VERA_DC_VIDEO,1);
- vpoke(15,VERA_DC_HSCALE,64);
- vpoke(15,VERA_DC_VSCALE,64);
- vpoke(15,VERA_LAYER1,0);
- vpoke(15,VERA_LAYER0,(7 << 5) | 1);
- vpoke(15,VERA_L0_CTRL1,%00000000);
- vpoke(15,VERA_L0_TILE_BASE_L,0);
- vpoke(15,VERA_L0_TILE_BASE_H,0);
- vaddr(0x10,0x0000);
- for (dword i = 0; i < (320*239); i++) {
- *VERA_ADDR_DATA0 = 0;
- }
- for (int i = 5; i < 200; i += 1) {
- circle(160,100,i);
- j++;
- }
- do {} while (1);
- }
- void circle(int xc, int yc, int r) {
- int x = 0;
- int y = r;
- int p = 3-(r << 1);
- for(int x = 0; x <= y; x ++) {
- if(p < 0) {
- p = p + (x << 2) + 6;
- } else {
- y=y-1;
- p = p + ((x-y) << 2) + 10;
- }
- plot(xc+x,yc-y);
- plot(xc-x,yc-y);
- plot(xc+x,yc+y);
- plot(xc-x,yc+y);
- plot(xc+y,yc-x);
- plot(xc-y,yc-x);
- plot(xc+y,yc+x);
- plot(xc-y,yc+x);
- }
- }
- void plot(int x, int y) {
- if (x < 0 || x >= 320 || y < 0 || y >= 200) {
- return; // bounds check
- }
- word z = (word) y * 320;
- vpoke(0,(word) x+z, j);
- }
- -----8<--- split here ---8<-----
- // Vera.kc
- const char* VERA_ADDR_LO = 0x9f20;
- const char* VERA_ADDR_MID = 0x9f21;
- const char* VERA_ADDR_HI = 0x9f22;
- const char* VERA_ADDR_INC = 0x9f22;
- const char* VERA_ADDR_DATA0 = 0x9f23;
- const char* VERA_ADDR_DATA1 = 0x9f24;
- const char* VERA_CTRL = 0x9f25;
- const word VERA_DC_VIDEO = 0x0000;
- const word VERA_DC_HSCALE = 0x0001;
- const word VERA_DC_VSCALE = 0x0002;
- const word VERA_DC_BORDER_COLOR = 0x0003;
- const word VERA_DC_HSTART_L = 0x0004;
- const word VERA_DC_HSTOP_L = 0x0005;
- const word VERA_DC_VSTART_L = 0x0006;
- const word VERA_DC_VSTOP_L = 0x0007;
- const word VERA_DC_STARTSTOP_H = 0x0008;
- const word VERA_DC_IRQ_LINE_L = 0x0009;
- const word VERA_DC_IRQ_LINE_H = 0x000a;
- const word VERA_LAYER0 = 0x2000;
- const word VERA_L0_CTRL1 = 0x2001;
- const word VERA_L0_TILE_BASE_L = 0x2004;
- const word VERA_L0_TILE_BASE_H = 0x2005;
- const word VERA_LAYER1 = 0x3000;
- const word VERA_L1_CTRL1 = 0x3001;
- const word VERA_L1_TILE_BASE_L = 0x3004;
- const word VERA_L1_TILE_BASE_H = 0x3005;
- void vaddr(char bank, word offset) {
- *VERA_ADDR_LO = (char) offset;
- *VERA_ADDR_MID = (char) (offset >> 8);
- *VERA_ADDR_HI = bank;
- }
- void vpoke(char bank, word offset, char value) {
- *VERA_ADDR_LO = (char) offset;
- *VERA_ADDR_MID = (char) (offset >> 8);
- *VERA_ADDR_HI = bank;
- *VERA_ADDR_DATA0 = value;
- }
- char vpeek(char bank, word offset) {
- *VERA_ADDR_LO = (char) offset;
- *VERA_ADDR_MID = (char) (offset >> 8);
- *VERA_ADDR_HI = bank;
- return *VERA_ADDR_DATA0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement