📄 atheos.cpp
字号:
delete ath_links_app; return stracpy((unsigned char *)"Could not create pipe.\n"); } fcntl(rpipe, F_SETFL, O_NONBLOCK); fcntl(wpipe, F_SETFL, O_NONBLOCK); set_handlers(rpipe, ath_get_event, NULL, NULL, NULL); ath_app_thread_id = spawn_thread("links_app", ath_app_thread, 0, 0, NULL); resume_thread(ath_app_thread_id); if ((d = new Desktop)) { ath_cs_desktop = d->GetColorSpace(); ath_x_size = d->GetResolution().x; ath_y_size = d->GetResolution().y; delete d; } else { ath_cs_desktop = CS_NO_COLOR_SPACE; ath_x_size = 640; ath_y_size = 480; } ath_win_y_size = ath_y_size * 9 / 10; ath_win_x_size = ath_win_y_size; /* fprintf(stderr, "%d %d\n", ath_x_size, ath_y_size); fprintf(stderr, "%d %d\n", ath_win_x_size, ath_win_y_size); */ ath_win_y_pos = (ath_y_size - ath_win_y_size) / 2; ath_win_x_pos = ath_x_size - ath_win_x_size - ath_win_y_pos; if (/*ath_cs_desktop == CS_RGB32 ||*/ ath_cs_desktop == CS_RGB24 || ath_cs_desktop == CS_RGB16 || ath_cs_desktop == CS_RGB15) ath_cs_bmp = ath_cs_desktop; else if (ath_cs_desktop == CS_RGB32 || ath_cs_desktop == CS_RGBA32) ath_cs_bmp = CS_RGB24; else ath_cs_bmp = CS_RGB15; switch (ath_cs_bmp) { case CS_RGB24: atheos_driver.depth = 0xc3; break; case CS_RGB16: atheos_driver.depth = 0x82; break; case CS_RGB15: atheos_driver.depth = 0x7a; break; default: internal((unsigned char *)"unknown depth"); } return NULL;}void ath_shutdown_driver(){ debug((unsigned char *)"D"); close(rpipe); close(wpipe); set_handlers(rpipe, NULL, NULL, NULL, NULL); ath_lock->Unlock(); debug((unsigned char *)"DD"); ath_links_app->PostMessage(M_TERMINATE); debug((unsigned char *)"E"); /*delete ath_lock; ath_lock = NULL;*/ debug((unsigned char *)"F");}struct graphics_device *ath_init_device(){ LinksView *view; LinksWindow *win; struct graphics_device *dev = (struct graphics_device *)mem_calloc(sizeof(struct graphics_device)); if (!dev) return NULL; dev->drv = &atheos_driver; debug((unsigned char *)"1"); win = new LinksWindow(Rect(ath_win_x_pos, ath_win_y_pos, ath_win_x_pos + ath_win_x_size, ath_win_y_pos + ath_win_y_size)); debug((unsigned char *)"2"); if (!win) { mem_free(dev); return NULL; } debug((unsigned char *)"3"); view = new LinksView(win); if (!view) { delete win; mem_free(dev); return NULL; } view->dev = dev; dev->driver_data = view; ath_get_size(dev); memcpy(&dev->clip, &dev->size, sizeof(struct rect)); debug((unsigned char *)"4"); win->Show(); win->MakeFocus(); debug((unsigned char *)"5"); return dev;}void ath_shutdown_device(struct graphics_device *dev){ LinksWindow *win = lv(dev)->win; unregister_bottom_half(do_flush, dev); lv(dev)->dev = NULL; win->PostMessage(M_TERMINATE); mem_free(dev);}void ath_set_title(struct graphics_device *dev, unsigned char *title){ LinksWindow *win = lv(dev)->win; lock_dev(dev); win->SetTitle((string)(char *)title); lv(dev)->d_flush(); unlock_dev(dev);}/*int ath_get_filled_bitmap(struct bitmap *bmp, long color){ internal((unsigned char *)"nedopsano"); return 0;}*/int ath_get_empty_bitmap(struct bitmap *bmp){ fprintf(stderr, "bmp\n"); Bitmap *b = new Bitmap(bmp->x, bmp->y, ath_cs_bmp, Bitmap::SHARE_FRAMEBUFFER); if (!b) { bmp->data = NULL; return 0; } bmp->data = b->LockRaster(); bmp->skip = b->GetBytesPerRow(); bmp->flags = b; return 0;}void ath_register_bitmap(struct bitmap *bmp){ Bitmap *b = (Bitmap *)bmp->flags; b->UnlockRaster();}void *ath_prepare_strip(struct bitmap *bmp, int top, int lines){ fprintf(stderr, "preps\n"); Bitmap *b = (Bitmap *)bmp->flags; bmp->data = b->LockRaster(); bmp->skip = b->GetBytesPerRow(); return ((char *)bmp->data) + bmp->skip * top;}void ath_commit_strip(struct bitmap *bmp, int top, int lines){ Bitmap *b = (Bitmap *)bmp->flags; b->UnlockRaster();}void ath_unregister_bitmap(struct bitmap *bmp){ fprintf(stderr, "unb\n"); Bitmap *b = (Bitmap *)bmp->flags; delete b;}void ath_draw_bitmap(struct graphics_device *dev, struct bitmap *bmp, int x, int y){ fprintf(stderr, "drawb\n"); Bitmap *b = (Bitmap *)bmp->flags; lock_dev(dev); lv(dev)->DrawBitmap(b, b->GetBounds(), Rect(x, y, x + bmp->x - 1, y + bmp->y - 1)); lv(dev)->d_flush(); unlock_dev(dev);}void ath_draw_bitmaps(struct graphics_device *dev, struct bitmap **bmp, int n, int x, int y){ LinksView *lvv = lv(dev); lock_dev(dev); while (n--) { Bitmap *b = (Bitmap *)(*bmp)->flags; lvv->DrawBitmap(b, b->GetBounds(), Rect(x, y, x + (*bmp)->x, y + (*bmp)->y)); x += (*bmp)->x; bmp++; } lv(dev)->d_flush(); unlock_dev(dev);}long ath_get_color(int rgb){ if (small_color) { get_color32(c, rgb); return *(long *)(void *)&c; } else return rgb & 0xffffff;}void ath_fill_area(struct graphics_device *dev, int x1, int y1, int x2, int y2, long color){ fprintf(stderr, "fill\n"); if (x1 >= x2 || y1 >= y2) return; lock_dev(dev); if (small_color) lv(dev)->FillRect(Rect(x1, y1, x2 - 1, y2 - 1), *(Color32_s *)(void *)&color); else lv(dev)->FillRect(Rect(x1, y1, x2 - 1, y2 - 1), get_color32(, color)); lv(dev)->d_flush(); unlock_dev(dev);}void ath_draw_hline(struct graphics_device *dev, int x1, int y, int x2, long color){ fprintf(stderr, "hline\n"); if (x1 >= x2) return; lock_dev(dev); if (small_color) lv(dev)->SetFgColor(*(Color32_s *)(void *)&color); else lv(dev)->SetFgColor(get_color32(, color)); lv(dev)->DrawLine(Point(IPoint(x1, y)), Point(IPoint(x2 - 1, y))); lv(dev)->d_flush(); unlock_dev(dev);}void ath_draw_vline(struct graphics_device *dev, int x, int y1, int y2, long color){ fprintf(stderr, "vline\n"); if (y1 >= y2) return; lock_dev(dev); if (small_color) lv(dev)->SetFgColor(*(Color32_s *)(void *)&color); else lv(dev)->SetFgColor(get_color32(, color)); lv(dev)->DrawLine(Point(IPoint(x, y1)), Point(IPoint(x, y2 - 1))); lv(dev)->d_flush(); unlock_dev(dev);}int ath_hscroll(struct graphics_device *dev, struct rect_set **ignore, int sc){ fprintf(stderr, "hscroll\n"); if (dev->clip.x1 >= dev->clip.x2 || dev->clip.y1 >= dev->clip.y2) return 0; if (sc <= dev->clip.x1 - dev->clip.x2) return 1; if (sc >= dev->clip.x2 - dev->clip.x1) return 1; lock_dev0(dev); if (sc > 0) lv(dev)->ScrollRect(Rect(dev->clip.x1, dev->clip.y1, dev->clip.x2 - sc - 1, dev->clip.y2 - 1), Rect(dev->clip.x1 + sc, dev->clip.y1, dev->clip.x2 - 1, dev->clip.y2 - 1)); else lv(dev)->ScrollRect(Rect(dev->clip.x1 - sc, dev->clip.y1, dev->clip.x2 - 1, dev->clip.y2 - 1), Rect(dev->clip.x1, dev->clip.y1, dev->clip.x2 + sc - 1, dev->clip.y2 - 1)); lv(dev)->d_flush(); unlock_dev(dev); return 1;}int ath_vscroll(struct graphics_device *dev, struct rect_set **ignore, int sc){ fprintf(stderr, "vscroll\n"); if (!sc || dev->clip.x1 >= dev->clip.x2 || dev->clip.y1 >= dev->clip.y2) return 0; if (sc <= dev->clip.y1 - dev->clip.y2) return 1; if (sc >= dev->clip.y2 - dev->clip.y1) return 1; lock_dev0(dev); if (sc > 0) lv(dev)->ScrollRect(Rect(dev->clip.x1, dev->clip.y1, dev->clip.x2 - 1, dev->clip.y2 - sc - 1), Rect(dev->clip.x1, dev->clip.y1 + sc, dev->clip.x2 - 1, dev->clip.y2 - 1)); else lv(dev)->ScrollRect(Rect(dev->clip.x1, dev->clip.y1 - sc, dev->clip.x2 - 1, dev->clip.y2 - 1), Rect(dev->clip.x1, dev->clip.y1, dev->clip.x2 - 1, dev->clip.y2 + sc - 1)); lv(dev)->d_flush(); unlock_dev(dev); return 1;}void ath_set_clip_area(struct graphics_device *dev, struct rect *r){ fprintf(stderr, "setc\n"); memcpy(&dev->clip, r, sizeof(struct rect)); lock_dev(dev); lv(dev)->SetDrawingRegion(Region(IRect(r->x1, r->y1, r->x2 - 1, r->y2 - 1))); unlock_dev(dev);}struct graphics_driver atheos_driver = { (unsigned char *)"atheos", ath_init_driver, ath_init_device, ath_shutdown_device, ath_shutdown_driver, ath_get_driver_param, ath_get_empty_bitmap, /*ath_get_filled_bitmap,*/ ath_register_bitmap, ath_prepare_strip, ath_commit_strip, ath_unregister_bitmap, ath_draw_bitmap, ath_draw_bitmaps, ath_get_color, ath_fill_area, ath_draw_hline, ath_draw_vline, ath_hscroll, ath_vscroll, ath_set_clip_area, dummy_block, dummy_unblock, ath_set_title, NULL, /* exec */ 0, /* depth */ 0, 0, /* size */ 0, /* flags */ 0, /* codepage */ NULL, /* shell */};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -