X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Ffract.c;h=6eeb6787611475468edfa3e68593674f335184a5;hp=0245b72766b8049967f84a32952e26fdf1aa28f5;hb=3398fc6c4188104048f99b650a6cb90beda9b6ed;hpb=757e7697c9a4434df6f3fdf3234de504bb4636bc diff --git a/src/fract.c b/src/fract.c index 0245b72..6eeb678 100644 --- a/src/fract.c +++ b/src/fract.c @@ -12,7 +12,6 @@ static int init(void); static void destroy(void); static void draw(void); static int julia(long x, long y, long cx, long cy, int max_iter); -static int calc_walk(struct vec2x *path, long x, long y, int max_steps); static struct screen scr = { "fract", @@ -22,7 +21,7 @@ static struct screen scr = { draw }; -static long aspect_24x8 = (long)(1.3333333 * 256.0); +/*static long aspect_24x8 = (long)(1.3333333 * 256.0);*/ static long xscale_24x8 = (long)(1.3333333 * 1.2 * 256.0); static long yscale_24x8 = (long)(1.2 * 256.0); static int cx, cy; @@ -44,14 +43,10 @@ static void destroy(void) { } -#define PACK_RGB16(r, g, b) \ - (((((r) >> 3) & 0x1f) << 11) | ((((g) >> 2) & 0x3f) << 5) | (((b) >> 3) & 0x1f)) - static void draw(void) { - int i, j, len, x, y; + int i, j; unsigned short *pixels = fb_pixels; - struct vec2x walkpos[WALK_SIZE]; cx = mouse_x; cy = mouse_y; @@ -64,26 +59,8 @@ static void draw(void) } pixels = fb_pixels; - - if((len = calc_walk(walkpos, mouse_x, mouse_y, WALK_SIZE))) { - x = walkpos[0].x >> 16; - y = walkpos[0].y >> 16; - - for(i=1; i> 16; - int y1 = walkpos[i].y >> 16; - - if(clip_line(&x0, &y0, &x1, &y1, 0, 0, fb_width - 1, fb_height - 1)) { - draw_line(x0, y0, x1, y1, PACK_RGB16(32, 128, 255)); - } - x = x1; - y = y1; - } - } - pixels[mouse_y * fb_width + mouse_x] = 0xffe; + swap_buffers(0); } static long normalize_coord(long x, long range) @@ -92,12 +69,6 @@ static long normalize_coord(long x, long range) return (x << 17) / range - 65536; } -static long device_coord(long x, long range) -{ - /* (x + 1) / 2 * (range - 1) */ - return ((x + 65536) >> 1) * (range - 1); -} - static int julia(long x, long y, long cx, long cy, int max_iter) { int i; @@ -122,30 +93,3 @@ static int julia(long x, long y, long cx, long cy, int max_iter) return i < max_iter ? (256 * i / max_iter) : 0; } - -static int calc_walk(struct vec2x *path, long x, long y, int max_steps) -{ - int i; - long cx, cy; - - /* convert to fixed point roughly [-1, 1] */ - x = cx = (normalize_coord(x, fb_width) >> 8) * xscale_24x8; - y = cy = (normalize_coord(y, fb_height) >> 8) * yscale_24x8; - - for(i=0; i> 8; - long py = y >> 8; - - path[i].x = device_coord((x << 8) / xscale_24x8, fb_width); - path[i].y = device_coord((y << 8) / yscale_24x8, fb_height); - - if(px * px + py * py > (4 << 16)) { - break; - } - x = px * px - py * py + cx; - y = (px * py << 1) + cy; - } - - return i; -}