blob: ad3c1af4c1c3af11c4110a5b83c1cf4210a0d610 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include "nes/app/application.hh"
#include "nes/app/input/input-device-keyboard.hh"
#include "nes/app/input/input-device-controller.hh"
#include "nes/app/graphics/renderer.hh"
#include "nes/app/graphics/color.hh"
#include "nes/app/graphics/mask-tile.hh"
#include "nes/app/graphics/image-tile.hh"
#include "nes/common/display.hh"
#include <iostream>
namespace nes
{
namespace
{
constexpr auto file = std::string_view{ "/Users/hannes/Documents/temp/supermario.nes" };
} // namespace
application::application(display& display, input_device_keyboard& keyboard)
: display_{ display }
, input_manager_{ keyboard }
, console_{ cartridge::from_file(file), display_ }
{
if (console_.get_status() != status::success)
{
std::cerr << "Unable to load cartridge: " << to_string(console_.get_status()) << std::endl;
std::abort();
}
}
auto application::frame(std::chrono::microseconds const elapsed_time) -> void
{
/*console_.ref_controller_1().set_pressed(input_manager_.get_input_1().read_mask());
console_.ref_controller_2().set_pressed(input_manager_.get_input_2().read_mask());
console_.step(elapsed_time);
if (console_.get_status() != status::success)
{
std::cerr << "Invalid state: " << to_string(console_.get_status()) << std::endl;
std::abort();
}*/
auto r = app::renderer{ display_ };
r.render_fill(app::color::background_primary);
r.render_mask_tile(10, 5, app::tiles::letter_a, app::color::foreground_primary);
r.render_image_tile(5, 5, app::tiles::test);
display_.switch_buffers();
}
} // namespace nes
|