#include #include #include #include #include #include #include #include #include #pragma region(main, 0x0a00, 0xc800, , , {code, data, bss, heap, stack} ) #define Color1 ((char *)0xc800) #define Color2 ((char *)0xd800) #define Hires ((char *)0xe000) Bitmap Screen = { Hires, nullptr, 40, 25, 320 }; ClipRect SRect = { 0, 0, 320, 200 } Matrix4 wmat, pmat, tmat, rmat; Vector3 vlight; void init(void) { mmap_set(MMAP_NO_BASIC); vic_setmode(VICM_HIRES_MC, Color1, Hires); vic.color_back = VCOL_DARK_GREY; vic.color_border = VCOL_DARK_GREY; mmap_trampoline(); mmap_set(MMAP_NO_ROM); memset(Color1, 0xcf, 1000); memset(Color2, 0x01, 1000); memset(Hires, 0, 8000); } void restore(void) { vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000); mmap_set(MMAP_ROM); } struct Point { int x, y; }; #define HALF 15 #define FULL (HALF + HALF) #define SIZE (FULL + 1) #define QFULL (FULL * FULL) Vector3 v[SIZE][SIZE]; Point p[SIZE][SIZE]; float z[SIZE][SIZE]; struct Surf { float z; char x, y; } surfs[QFULL]; void qsort(Surf * n, int s) { if (s > 1) { Surf pn = n[0]; int pi = 0; for(int i=1; i pn.z) { n[pi] = n[i]; pi++; n[i] = n[pi] } } n[pi] = pn; qsort(n, pi); qsort(n + pi + 1, s - pi - 1); } } int main(void) { init(); bm_put_string(&Screen, &SRect, 0, 0, "Preparing function", BLTOP_COPY); mat4_ident(&wmat); mat4_make_perspective(&pmat, 0.5 * PI, 1.0, 0.0, 200.0); bm_put for(int ix=0; ix 0) { c = 1 + (int)(f * 6); if (c > 4) patt = 0; } bmmc_quad_fill(&Screen, &SRect, p[iy + 0][ix + 0].x, p[iy + 0][ix + 0].y, p[iy + 0][ix + 1].x, p[iy + 0][ix + 1].y, p[iy + 1][ix + 1].x, p[iy + 1][ix + 1].y, p[iy + 1][ix + 0].x, p[iy + 1][ix + 0].y, MixedColors[c >> 1][(c + 1) >> 1]); #if 0 bmmc_line(&Screen, &SRect, p[iy + 0][ix + 0].x, p[iy + 0][ix + 0].y, p[iy + 0][ix + 1].x, p[iy + 0][ix + 1].y, patt); bmmc_line(&Screen, &SRect, p[iy + 1][ix + 0].x, p[iy + 1][ix + 0].y, p[iy + 1][ix + 1].x, p[iy + 1][ix + 1].y, patt); bmmc_line(&Screen, &SRect, p[iy + 0][ix + 0].x, p[iy + 0][ix + 0].y, p[iy + 1][ix + 0].x, p[iy + 1][ix + 0].y, patt); bmmc_line(&Screen, &SRect, p[iy + 0][ix + 1].x, p[iy + 0][ix + 1].y, p[iy + 1][ix + 1].x, p[iy + 1][ix + 1].y, patt); #endif } mmap_set(MMAP_NO_BASIC); getch(); restore(); return 0; }