Merge branch 'rr1-maint'
[lsnes.git] / src / core / advdumper.cpp
blob50ab9c802584930b670e5baf505f015febbc7f97
1 #include "core/advdumper.hpp"
2 #include "core/command.hpp"
3 #include "core/dispatch.hpp"
4 #include "library/globalwrap.hpp"
5 #include "lua/lua.hpp"
6 #include "library/string.hpp"
8 #include <map>
9 #include <string>
11 namespace
13 globalwrap<std::map<std::string, adv_dumper*>> dumpers;
16 const std::string& adv_dumper::id() throw()
18 return d_id;
21 adv_dumper::~adv_dumper()
23 dumpers().erase(d_id);
24 information_dispatch::do_dumper_update();
27 std::set<adv_dumper*> adv_dumper::get_dumper_set() throw(std::bad_alloc)
29 std::set<adv_dumper*> d;
30 for(auto i : dumpers())
31 d.insert(i.second);
32 return d;
35 adv_dumper::adv_dumper(const std::string& id) throw(std::bad_alloc)
37 d_id = id;
38 dumpers()[d_id] = this;
41 unsigned adv_dumper::target_type_mask = 3;
42 unsigned adv_dumper::target_type_file = 0;
43 unsigned adv_dumper::target_type_prefix = 1;
44 unsigned adv_dumper::target_type_special = 2;
46 template<bool X> void render_video_hud(struct framebuffer<X>& target, struct framebuffer_raw& source, uint32_t hscl,
47 uint32_t vscl, uint32_t roffset, uint32_t goffset, uint32_t boffset, uint32_t lgap, uint32_t tgap,
48 uint32_t rgap, uint32_t bgap, void(*fn)())
50 struct lua_render_context lrc;
51 render_queue rq;
52 lrc.left_gap = lgap;
53 lrc.right_gap = rgap;
54 lrc.bottom_gap = bgap;
55 lrc.top_gap = tgap;
56 lrc.queue = &rq;
57 lrc.width = source.get_width();
58 lrc.height = source.get_height();
59 lua_callback_do_video(&lrc);
60 if(fn)
61 fn();
62 target.set_palette(roffset, goffset, boffset);
63 target.reallocate(lrc.left_gap + source.get_width() * hscl + lrc.right_gap, lrc.top_gap +
64 source.get_height() * vscl + lrc.bottom_gap, false);
65 target.set_origin(lrc.left_gap, lrc.top_gap);
66 target.copy_from(source, hscl, vscl);
67 rq.run(target);
70 template void render_video_hud(struct framebuffer<false>& target, struct framebuffer_raw& source, uint32_t hscl,
71 uint32_t vscl, uint32_t roffset, uint32_t goffset, uint32_t boffset, uint32_t lgap, uint32_t tgap,
72 uint32_t rgap, uint32_t bgap, void(*fn)());
73 template void render_video_hud(struct framebuffer<true>& target, struct framebuffer_raw& source, uint32_t hscl,
74 uint32_t vscl, uint32_t roffset, uint32_t goffset, uint32_t boffset, uint32_t lgap, uint32_t tgap,
75 uint32_t rgap, uint32_t bgap, void(*fn)());