X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Ffract.c;h=a17550b9752c27588036e182009b15e538473807;hp=15da79db549eda1c87434e393f0c440a53ddc303;hb=21c4bd88e7ddd930ac83c54cbe7399af0e188b67;hpb=aefd23e483457daa7eeb4987827e72df83886eaa diff --git a/src/fract.c b/src/fract.c index 15da79d..a17550b 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", @@ -49,9 +48,8 @@ static void destroy(void) static void draw(void) { - int i, j, len, x, y; - unsigned short *pixels = fb_pixels; - struct vec2x walkpos[WALK_SIZE]; + int i, j; + unsigned short *pixels = vmem_back; cx = mouse_x; cy = mouse_y; @@ -63,29 +61,9 @@ 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 = vmem_back; pixels[mouse_y * fb_width + mouse_x] = 0xffe; - - swap_buffers(fb_pixels); + swap_buffers(vmem_back); } static long normalize_coord(long x, long range) @@ -94,12 +72,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; @@ -124,30 +96,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; -}