/** * Control for vout display */ static int Control(vout_display_t *vd, int query, va_list args) { VLC_UNUSED(args); vout_display_sys_t *sys = vd->sys; switch (query) { case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE: /* We have to ignore what is requested */ vout_display_SendEventPicturesInvalid(vd); return VLC_SUCCESS; case VOUT_DISPLAY_RESET_PICTURES: if (sys->pool) picture_pool_Release(sys->pool); sys->pool = NULL; vd->fmt.i_width = aa_imgwidth(sys->aa_context); vd->fmt.i_height = aa_imgheight(sys->aa_context); return VLC_SUCCESS; case VOUT_DISPLAY_HIDE_MOUSE: aa_hidemouse(sys->aa_context); return VLC_SUCCESS; default: msg_Err(vd, "Unsupported query in vout display aalib"); return VLC_EGENERIC; } }
struct aa_edit *aa_createedit(aa_context * c, int x, int y, int size, char *s, int maxsize) { struct aa_edit *e; if (x < 0) x = 0; if (y < 0) y = 0; if (x >= aa_imgwidth(c) - 1) x = aa_imgwidth(c) - 2; if (y >= aa_imgheight(c) - 1) y = aa_imgwidth(c) - 2; if (x + size >= aa_imgwidth(c)) size = aa_imgwidth(c) - 1 - x; e = malloc(sizeof(struct aa_edit)); if (e == NULL) return NULL; e->maxsize = maxsize; e->data = s; e->cursor = strlen(s); e->clearafterpress = 1; e->x = x; e->y = y; e->size = size; e->c = c; e->printpos = 0; aa_editdisplay(e); return (e); }
static void dvojprujezd2(int starttime, char *text1, char *text2) { int pos = (getwidth(2) * strlen(text1) + 1); centerprint(-pos / 2 + (aa_imgwidth(context) + pos * 1.2) * STATE / (endtime - starttime), aa_imgheight(context) / 3, 2, 255, text1, 0); pos = (getwidth(2) * strlen(text2) + 1); centerprint(aa_imgwidth(context) + pos / 2 - (aa_imgwidth(context) + pos * 1.2) * STATE / (endtime - starttime), 2 * aa_imgheight(context) / 3, 2, 255, text2, 0); }
static void draw_creature(const client_creature_t *creature, void *opaque) { int x = creature->x / (256 / SCALE) - ox; int y = creature->y / (256 / SCALE) - oy; if (x < 0 || x >= aa_imgwidth(context) || y < 0 || y >= aa_imgheight(context)) return; bitmap[y * aa_imgwidth(context) + x] = 0xFF; }
void drawprujezd(char *mesg, int starttime) { int state = STATE; double height = aa_imgheight(context) / 3 + aa_imgheight(context) / 4 * cos(state / (double) LTIME); double width = (double) aa_imgwidth(context) * 0.75 * 2.0 / 3.0 / 3; int pos = aa_imgwidth(context) - width * state / LTIME; print(pos + height, (aa_imgheight(context) - height) / 2, width, height, font, 255, mesg); }
static void AA_ResizeHandler(aa_context *context) { aa_resize(context); local_this->hidden->x_ratio = ((double)aa_imgwidth(context)) / ((double)local_this->screen->w); local_this->hidden->y_ratio = ((double)aa_imgheight(context)) / ((double)local_this->screen->h); fastscale (local_this->hidden->buffer, aa_image(context), local_this->hidden->w, aa_imgwidth (context), local_this->hidden->h, aa_imgheight (context)); aa_renderpalette(context, local_this->hidden->palette, local_this->hidden->rparams, 0, 0, aa_scrwidth(context), aa_scrheight(context)); aa_flush(context); }
static void pryc() { float size = 3 + (STATE) * 10.0 / MAXTIME; float radius = (STATE) * aa_imgwidth(context) / MAXTIME; float yradius = (STATE) * aa_imgheight(context) / MAXTIME; int xm = aa_imgwidth(context) / 2; int ym = aa_imgheight(context) / 3; clrscr(); centerprint(xm + radius * sin(STATE / 100000.0), ym + yradius * cos(STATE / 300000.0), size, 128, "The", 0); centerprint(xm + radius * sin(STATE / 150000.0), 2 * ym + yradius * cos(STATE / 400000.0), size, 128, "END", 0); }
void devezen1() { bckup = (char *) malloc(aa_imgwidth(context) * aa_imgheight(context)); memcpy(bckup, context->imagebuffer, aa_imgwidth(context) * aa_imgheight(context)); tographics(); bckup1 = (char *) malloc(aa_imgwidth(context) * aa_imgheight(context)); memcpy(bckup1, context->imagebuffer, aa_imgwidth(context) * aa_imgheight(context)); drawptr = toblack1; timestuff(0, NULL, toblack1, 5000000); free(bckup); free(bckup1); }
static void morphdraw() { int s = STATE > 0 ? (STATE < MTIME ? STATE : MTIME) : 0; int mul = s * 256 / MTIME; int mul1 = 256 - mul; int i; int size = aa_imgwidth(context) * (aa_imgheight(context) - YSTART * 2); char *c = context->imagebuffer + aa_imgwidth(context) * 2 * YSTART; for (i = 0; i < size; i++, c++) { *c = (source[i] * mul1 + target[i] * mul) >> 8; } aa_fastrender(context, 0, YSTART, aa_scrwidth(context), aa_scrheight(context)); aa_flush(context); emscripten_sleep(1); }
void Paddle::moveRight() { if( x2 == aa_imgwidth(context) ) { return; } x1+=3; x2+=3; }
static void ui_do_julia(double xx, double yy) { int oldw = zcontext->width, oldh = zcontext->height; float size; unsigned char *vold = zcontext->vbuff; incalculation = 1; zcontext->pre = xx, zcontext->pim = yy; if (zcontext->windowwidth > zcontext->windowheight) size = zcontext->windowheight; else size = zcontext->windowwidth; zcontext->width = zcontext->width * size / zcontext->windowwidth - 1; zcontext->height = zcontext->height * size / zcontext->windowheight - 1; if (!dual) zcontext->vbuff += (oldw - zcontext->width) / 2; else zcontext->vbuff += (oldw / 2 - zcontext->width) / 2; do_julia(zcontext, zcontext->pre, zcontext->pim); if (dual) { zcontext->currentformula = formulas + 1; zcontext->vbuff += aa_imgwidth(context) / 2; do_julia(zcontext, zcontext->pre, zcontext->pim); zcontext->currentformula = formulas; } zcontext->width = oldw; zcontext->height = oldh; zcontext->vbuff = vold; ui_display(); }
/***************************************************************************** * Manage: handle aa events ***************************************************************************** * This function should be called regularly by video output thread. It manages * console events. It returns a non null value on error. *****************************************************************************/ static int Manage( vout_thread_t *p_vout ) { int event, x, y, b; event = aa_getevent( p_vout->p_sys->aa_context, 0 ); switch ( event ) { case AA_MOUSE: aa_getmouse( p_vout->p_sys->aa_context, &x, &y, &b ); if ( b & AA_BUTTON3 ) { intf_thread_t *p_intf; p_intf = vlc_object_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE ); if( p_intf ) { p_intf->b_menu_change = 1; vlc_object_release( p_intf ); } } break; case AA_RESIZE: p_vout->i_changes |= VOUT_SIZE_CHANGE; aa_resize( p_vout->p_sys->aa_context ); p_vout->p_sys->i_width = aa_imgwidth( p_vout->p_sys->aa_context ); p_vout->p_sys->i_height = aa_imgheight( p_vout->p_sys->aa_context ); break; default: break; } return( 0 ); }
void scene9(void) { int width, height, scanline; int i, formula = 1; char *buffer1; signal(SIGFPE, SIG_IGN); width = aa_imgwidth(context); height = aa_imgheight(context); scanline = width; buffer1 = context->imagebuffer; params->bright = -255; params->dither = AA_NONE; zcontext = make_context(width, height, scanline, 0, 1, flip_buffers, ui_waitfunc, buffer1, buffer1, get_pixelwidth(width), get_pixelheight(height)); if (!zcontext) { exit(-1); } set_formula(zcontext, formula); for (i = 0; i < 255; i++) { zcontext->colors[i] = (i * 15) % 255 + 1; } zcontext->colors[0] = 0; zcontext->num_colors = 255; tbreak = 2; zcontext->maxiter = 255; fastmode--; zcontext->range = 8; zcontext->incoloringmode = 0; zcontext->coloringmode = 0; zcontext->plane = 0; starttime = endtime; sef = 1; eef = 0; is = -1; rs = -1; ie = 2; re = -2; timestuff(0, NULL, juliov, ETIME2); sef = 0; eef = 0; is = ie, rs = re; ie = 2; re = 2; timestuff(0, NULL, juliov, ETIME2); sef = 0; eef = 0; is = ie, rs = re; ie = -2; re = 2; timestuff(0, NULL, juliov, ETIME2); sef = 0; eef = 1; is = ie, rs = re; ie = 2; re = -2; timestuff(0, NULL, juliov, ETIME2); context->imagebuffer = buffer1; params->bright = 0; params->dither = AA_FLOYD_S; }
/***************************************************************************** * Create: allocates aa video thread output method ***************************************************************************** * This function allocates and initializes a aa vout method. *****************************************************************************/ static int Create( vlc_object_t *p_this ) { vout_thread_t *p_vout = (vout_thread_t *)p_this; /* Allocate structure */ p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); if( p_vout->p_sys == NULL ) { msg_Err( p_vout, "out of memory" ); return( 1 ); } /* Don't parse any options, but take $AAOPTS into account */ aa_parseoptions( NULL, NULL, NULL, NULL ); if (!(p_vout->p_sys->aa_context = aa_autoinit(&aa_defparams))) { msg_Err( p_vout, "cannot initialize aalib" ); return( 1 ); } p_vout->pf_init = Init; p_vout->pf_end = End; p_vout->pf_manage = Manage; p_vout->pf_render = Render; p_vout->pf_display = Display; p_vout->p_sys->i_width = aa_imgwidth(p_vout->p_sys->aa_context); p_vout->p_sys->i_height = aa_imgheight(p_vout->p_sys->aa_context); aa_autoinitkbd( p_vout->p_sys->aa_context, 0 ); aa_autoinitmouse( p_vout->p_sys->aa_context, AA_MOUSEPRESSMASK ); aa_hidemouse( p_vout->p_sys->aa_context ); return( 0 ); }
/** * This function allocates and initializes a aa vout method. */ static int Open(vlc_object_t *object) { vout_display_t *vd = (vout_display_t *)object; vout_display_sys_t *sys; #ifndef _WIN32 if (!vlc_xlib_init (object)) return VLC_EGENERIC; #endif /* Allocate structure */ vd->sys = sys = calloc(1, sizeof(*sys)); if (!sys) return VLC_ENOMEM; /* Don't parse any options, but take $AAOPTS into account */ aa_parseoptions(NULL, NULL, NULL, NULL); /* */ sys->aa_context = aa_autoinit(&aa_defparams); if (!sys->aa_context) { msg_Err(vd, "cannot initialize aalib"); goto error; } vout_display_DeleteWindow(vd, NULL); aa_autoinitkbd(sys->aa_context, 0); aa_autoinitmouse(sys->aa_context, AA_MOUSEALLMASK); /* */ video_format_t fmt = vd->fmt; fmt.i_chroma = VLC_CODEC_RGB8; fmt.i_width = aa_imgwidth(sys->aa_context); fmt.i_height = aa_imgheight(sys->aa_context); fmt.i_visible_width = fmt.i_width; fmt.i_visible_height = fmt.i_height; /* Setup vout_display now that everything is fine */ vd->fmt = fmt; vd->info.has_pictures_invalid = true; vd->info.needs_event_thread = true; vd->pool = Pool; vd->prepare = Prepare; vd->display = PictureDisplay; vd->control = Control; vd->manage = Manage; /* Inspect initial configuration and send correction events * FIXME how to handle aspect ratio with aa ? */ vout_display_SendEventDisplaySize(vd, fmt.i_width, fmt.i_height); return VLC_SUCCESS; error: if (sys && sys->aa_context) aa_close(sys->aa_context); free(sys); return VLC_EGENERIC; }
void blur(int n) { unsigned char *pos = context->imagebuffer, *posend = pos + aa_imgwidth(context) * aa_imgheight(context); while (pos < posend) { (*pos) >>= n; pos++; } }
void drawzoomer(char *mesg, int starttime, int pos) { float width = 1000000.0 / (STATE); if (width > 1.0) { int color = (width - 1) * 255; if (color > 255) color = 255; centerprint(aa_imgwidth(context) / 2, pos * aa_imgheight(context) / 6, width, color, mesg, 0); } }
static void ui_display(void) { displayed = 1; aa_render(context, params, 0, 0, aa_imgwidth(context), aa_imgheight(context)); aa_flush(context); #if 0 if (numbertype != FORMULA) rotate_continue(); #endif }
void centerprint(int x, int y, double size, int color, char *text, int mode) { if (!dual || !mode) { double height = aa_imgheight(context) / size; double width = height * (double) aa_imgwidth(context) * 0.75 / aa_imgheight(context) * aa_mmheight(context) / aa_mmwidth(context); print(x - (width * strlen(text)) / 2, y - height / 2, width, height, font, color, text); } else { if (mode & 1) { double height = aa_imgheight(context) / size; double width = height * (double) aa_imgwidth(context) * 0.75 / aa_imgheight(context) * aa_mmheight(context) / aa_mmwidth(context); print(x / 2 - (width * strlen(text)) / 2, y - height / 2, width, height, font, color, text); } if (mode & 2) { double height = aa_imgheight(context) / size; double width = height * (double) aa_imgwidth(context) * 0.75 / aa_imgheight(context) * aa_mmheight(context) / aa_mmwidth(context); print(aa_imgwidth(context) / 2 + x / 2 - (width * strlen(text)) / 2, y - height / 2, width, height, font, color, text); } } }
SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags) { int mode; if ( AA_buffer ) { SDL_free( AA_buffer ); } AA_buffer = SDL_malloc(width * height); if ( ! AA_buffer ) { SDL_SetError("Couldn't allocate buffer for requested mode"); return(NULL); } /* printf("Setting mode %dx%d\n", width, height); */ SDL_memset(aa_image(AA_context), 0, aa_imgwidth(AA_context) * aa_imgheight(AA_context)); SDL_memset(AA_buffer, 0, width * height); /* Allocate the new pixel format for the screen */ if ( ! SDL_ReallocFormat(current, 8, 0, 0, 0, 0) ) { return(NULL); } /* Set up the new mode framebuffer */ current->flags = SDL_FULLSCREEN; AA_w = current->w = width; AA_h = current->h = height; current->pitch = current->w; current->pixels = AA_buffer; AA_x_ratio = ((double)aa_imgwidth(AA_context)) / ((double)width); AA_y_ratio = ((double)aa_imgheight(AA_context)) / ((double)height); /* Set the blit function */ this->UpdateRects = AA_DirectUpdate; /* We're done */ return(current); }
Paddle::Paddle(aa_context *c, int align) { context = c; this->align=align; x1 = aa_imgwidth(context) / 2 - 6; x2 = x1 + 12; if( align == TOP ) { y1 = 2; } else { y1 = aa_imgheight(context) - 5; } y2 = y1 + 3; }
void message(char *text, int starttime) { int state = STATE; if (state > 0 && state < MAXPOS) { double pp = state * M_PI / MAXPOS * 2; double width = (1 + cos(pp)) * 5 + 2; int pos = aa_imgheight(context) - aa_imgheight(context) * state / MAXPOS; if (width <= 0) return; centerprint(aa_imgwidth(context) / 2, pos, width, sin(pp / 2) * 255, text, 0); } }
static void toblack1() { int x, y, mul1, mul2 = 0, pos; int minpos = 0; unsigned char *b1 = bckup, *b2 = bckup1; pos = STAGE * (aa_imgheight(context) + aa_imgheight(context)) / (endtime - starttime) - aa_imgheight(context); for (y = 0; y < aa_imgheight(context); y++) { mul1 = (y - pos); if (mul1 < 0) mul1 = 0; else mul1 = mul1 * 256 * 4 / aa_imgheight(context); if (mul1 > 256) mul1 = 256; mul2 = (y - pos - aa_imgheight(context)); if (mul2 < 0) mul2 = 0; else mul2 = mul2 * 256 * 8 / aa_imgheight(context); if (mul2 > 256) mul2 = 256; if (mul2 == 0) minpos = y; mul1 -= mul2; for (x = 0; x < aa_imgwidth(context); x++) { aa_putpixel(context, x, y, (mul1 * (int) (*b1) + mul2 * (int) (*b2)) / 256); b1++; b2++; } } minpos = pos + 3 * aa_imgheight(context) / 4; if (minpos < 0) minpos = 0; if (minpos > aa_imgheight(context)) minpos = aa_imgheight(context); aa_render(context, params, 0, 0, aa_imgwidth(context), minpos); aa_flush(context); emscripten_sleep(1); }
void aa_flush(aa_context * c) { if (c->driver->print != NULL) aa_display(c, 0, 0, aa_imgwidth(c), aa_imgheight(c)); if (c->driver->flush != NULL) { int cursor=c->mousemode; if(cursor&&c->mousedriver!=NULL&&(c->mousedriver->flags&AA_HIDECURSOR)) aa_hidemouse(c); c->driver->flush(c); if(cursor&&c->mousedriver!=NULL&&(c->mousedriver->flags&AA_HIDECURSOR)) aa_showmouse(c); } }
void drawhorotoc(char *mesg, char *mesg1, int starttime) { int state = STATE; int width = aa_imgwidth(context); int height = aa_imgheight(context); float ratio = ((float) state / ETIME2); if (state < ETIME2 && state > 0) { print(0, 0, width / strlen(mesg), height * ratio, font, 255, mesg); print(0, height * ratio, width / strlen(mesg1), height * (1 - ratio), font, 255, mesg1); } if (state > ETIME2) print(0, 0, width / strlen(mesg), height, font, 255, mesg); }
static GstFlowReturn gst_aasink_render (GstBaseSink * basesink, GstBuffer * buffer) { GstAASink *aasink; aasink = GST_AASINK (basesink); GST_DEBUG ("render"); gst_aasink_scale (aasink, GST_BUFFER_DATA (buffer), /* src */ aa_image (aasink->context), /* dest */ aasink->width, /* sw */ aasink->height, /* sh */ aa_imgwidth (aasink->context), /* dw */ aa_imgheight (aasink->context)); /* dh */ aa_render (aasink->context, &aasink->ascii_parms, 0, 0, aa_imgwidth (aasink->context), aa_imgheight (aasink->context)); aa_flush (aasink->context); aa_getevent (aasink->context, FALSE); return GST_FLOW_OK; }
static GstFlowReturn gst_aasink_show_frame (GstVideoSink * videosink, GstBuffer * buffer) { GstAASink *aasink; GstVideoFrame frame; aasink = GST_AASINK (videosink); GST_DEBUG ("show frame"); if (!gst_video_frame_map (&frame, &aasink->info, buffer, GST_MAP_READ)) goto invalid_frame; gst_aasink_scale (aasink, GST_VIDEO_FRAME_PLANE_DATA (&frame, 0), /* src */ aa_image (aasink->context), /* dest */ GST_VIDEO_INFO_WIDTH (&aasink->info), /* sw */ GST_VIDEO_INFO_HEIGHT (&aasink->info), /* sh */ GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 0), /* ss */ aa_imgwidth (aasink->context), /* dw */ aa_imgheight (aasink->context)); /* dh */ aa_render (aasink->context, &aasink->ascii_parms, 0, 0, aa_imgwidth (aasink->context), aa_imgheight (aasink->context)); aa_flush (aasink->context); aa_getevent (aasink->context, FALSE); gst_video_frame_unmap (&frame); return GST_FLOW_OK; /* ERRORS */ invalid_frame: { GST_DEBUG_OBJECT (aasink, "invalid frame"); return GST_FLOW_ERROR; } }
/** * Prepare a picture for display */ static void Prepare(vout_display_t *vd, picture_t *picture) { vout_display_sys_t *sys = vd->sys; assert(vd->fmt.i_width == aa_imgwidth(sys->aa_context) && vd->fmt.i_height == aa_imgheight(sys->aa_context)); #if 0 if (picture->format.p_palette) { for (int i = 0; i < 256; i++) { aa_setpalette(vd->sys->palette, 256 - i, red[ i ], green[ i ], blue[ i ]); } } #else VLC_UNUSED(picture); #endif aa_fastrender(sys->aa_context, 0, 0, vd->fmt.i_width, vd->fmt.i_height); }
/** * Return a pool of direct buffers */ static picture_pool_t *Pool(vout_display_t *vd, unsigned count) { vout_display_sys_t *sys = vd->sys; VLC_UNUSED(count); if (!sys->pool) { picture_resource_t rsc; memset(&rsc, 0, sizeof(rsc)); rsc.p[0].p_pixels = aa_image(sys->aa_context); rsc.p[0].i_pitch = aa_imgwidth(sys->aa_context); rsc.p[0].i_lines = aa_imgheight(sys->aa_context); picture_t *p_picture = picture_NewFromResource(&vd->fmt, &rsc); if (!p_picture) return NULL; sys->pool = picture_pool_New(1, &p_picture); } return sys->pool; }
static void AA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) { int i; SDL_Rect *rect; fastscale (AA_buffer, aa_image(AA_context), AA_w, aa_imgwidth (AA_context), AA_h, aa_imgheight (AA_context)); #if 1 aa_renderpalette(AA_context, AA_palette, AA_rparams, 0, 0, aa_scrwidth(AA_context), aa_scrheight(AA_context)); #else /* Render only the rectangles in the list */ printf("Update rects : "); for ( i=0; i < numrects; ++i ) { rect = &rects[i]; printf("(%d,%d-%d,%d)", rect->x, rect->y, rect->w, rect->h); aa_renderpalette(AA_context, AA_palette, AA_rparams, rect->x * AA_x_ratio, rect->y * AA_y_ratio, rect->w * AA_x_ratio, rect->h * AA_y_ratio); } printf("\n"); #endif SDL_mutexP(AA_mutex); aa_flush(AA_context); SDL_mutexV(AA_mutex); return; }