#include #include #include #include #include #include #include #include #include #pragma region(main, 0x0a00, 0xc800, , , {code, data, bss, heap, stack} ) #define Color ((char *)0xc800) #define Hires ((char *)0xe000) Bitmap Screen = { Hires, nullptr, 40, 25, 320 }; ClipRect SRect = { 0, 0, 320, 200 } char chk[] = {0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55}; char white[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; char black[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; Matrix4 wmat, pmat, tmat, rmat; Vector3 vlight; void init(void) { mmap_set(MMAP_NO_BASIC); vic_setmode(VICM_HIRES, Color, Hires); vic.color_back = VCOL_WHITE; vic.color_border = VCOL_WHITE; mmap_trampoline(); mmap_set(MMAP_NO_ROM); memset(Color, 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); for(int ix=0; ix 0) { c = 8 - (int)(f * 9); if (c < 5) patt = 0xff; } bm_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, NineShadesOfGrey[c]); bm_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, LINOP_SET); bm_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, LINOP_SET); bm_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, LINOP_SET); bm_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, LINOP_SET); } mmap_set(MMAP_NO_BASIC); getch(); restore(); return 0; }