1 #include "framebuffer.hpp"
9 lcscreen screen_nosignal
;
10 lcscreen screen_corrupt
;
11 extern uint32_t fontdata
[];
15 struct render_list_entry
23 struct render_list_entry rl_nosignal
[] = {
35 struct render_list_entry rl_corrupt
[] = {
57 void draw_special_screen(uint16_t* target
, struct render_list_entry
* rlist
)
62 auto g
= find_glyph(rlist
->codepoint
, 0, 0, 0, x
, y
);
63 for(uint32_t j
= 0; j
< 16; j
++) {
64 for(uint32_t i
= 0; i
< 8; i
++) {
65 uint32_t slice
= g
.second
+ j
/ 4;
66 uint32_t bit
= 31 - ((j
% 4) * 8 + i
);
67 uint32_t value
= (fontdata
[slice
] >> bit
) & 1;
69 uint32_t basex
= rlist
->x
+ rlist
->scale
* i
;
70 uint32_t basey
= rlist
->y
+ rlist
->scale
* j
;
71 for(uint32_t j2
= 0; j2
< rlist
->scale
; j2
++)
72 for(uint32_t i2
= 0; i2
< rlist
->scale
; i2
++)
73 target
[(basey
+ j2
) * 512 + (basex
+ i2
)] = 0x7FFF;
81 void draw_nosignal(uint16_t* target
)
83 for(unsigned i
= 0; i
< 512 * 448; i
++)
85 draw_special_screen(target
, rl_nosignal
);
88 void draw_corrupt(uint16_t* target
)
90 for(unsigned i
= 0; i
< 512 * 448; i
++)
92 draw_special_screen(target
, rl_corrupt
);
95 function_ptr_command
<arg_filename
> take_screenshot("take-screenshot", "Takes a screenshot",
96 "Syntax: take-screenshot <file>\nSaves screenshot to PNG file <file>\n",
97 [](arg_filename file
) throw(std::bad_alloc
, std::runtime_error
) {
98 framebuffer
.save_png(file
);
99 messages
<< "Saved PNG screenshot" << std::endl
;
106 void init_special_screens() throw(std::bad_alloc
)
108 uint16_t buf
[512*448];
110 screen_nosignal
= lcscreen(buf
, 512, 448);
112 screen_corrupt
= lcscreen(buf
, 512, 448);
115 void redraw_framebuffer()
117 uint32_t hscl
= 1, vscl
= 1;
118 if(framebuffer
.width
< 512)
120 if(framebuffer
.height
< 400)
123 struct lua_render_context lrc
;
129 lrc
.width
= framebuffer
.width
* hscl
;
130 lrc
.height
= framebuffer
.height
* vscl
;
131 lrc
.rshift
= main_screen
.active_rshift
;
132 lrc
.gshift
= main_screen
.active_gshift
;
133 lrc
.bshift
= main_screen
.active_bshift
;
134 lua_callback_do_paint(&lrc
);
135 main_screen
.reallocate(framebuffer
.width
* hscl
+ lrc
.left_gap
+ lrc
.right_gap
, framebuffer
.height
* vscl
+
136 lrc
.top_gap
+ lrc
.bottom_gap
, lrc
.left_gap
, lrc
.top_gap
);
137 main_screen
.copy_from(framebuffer
, hscl
, vscl
);
138 //We would want divide by 2, but we'll do it ourselves in order to do mouse.
139 window::set_window_compensation(lrc
.left_gap
, lrc
.top_gap
, 1, 1);
141 window::notify_screen_update();