1#ifndef YAZE_APP_EMU_PROTO_CONVERTER_H_
2#define YAZE_APP_EMU_PROTO_CONVERTER_H_
7#include "protos/emulator_service.pb.h"
16inline InputButton FromProtoButton(agent::Button button) {
34inline BreakpointKind FromProtoBreakpointType(agent::BreakpointType type) {
45inline CpuKind FromProtoCpuType(agent::CpuType cpu) {
57inline agent::Button ToProtoButton(
InputButton button) {
71 default:
return agent::BUTTON_UNSPECIFIED;
75inline agent::BreakpointType ToProtoBreakpointType(
BreakpointKind kind) {
82 default:
return agent::BREAKPOINT_TYPE_UNSPECIFIED;
86inline agent::CpuType ToProtoCpuType(
CpuKind kind) {
90 default:
return agent::CPU_TYPE_UNSPECIFIED;
98inline void ToProtoCpuState(
const CpuStateSnapshot& src,
99 agent::CPUState* dst) {
108 dst->set_status(src.status);
109 dst->set_flag_n(src.flag_n);
110 dst->set_flag_v(src.flag_v);
111 dst->set_flag_z(src.flag_z);
112 dst->set_flag_c(src.flag_c);
113 dst->set_cycles(src.cycles);
116inline void ToProtoBreakpointInfo(
const BreakpointSnapshot& src,
117 agent::BreakpointInfo* dst) {
119 dst->set_address(src.address);
120 dst->set_type(ToProtoBreakpointType(src.kind));
121 dst->set_cpu(ToProtoCpuType(src.cpu));
122 dst->set_enabled(src.enabled);
123 dst->set_condition(src.condition);
124 dst->set_description(src.description);
125 dst->set_hit_count(src.hit_count);
128inline void ToProtoBreakpointHitResponse(
129 const BreakpointHitResult& src,
130 agent::BreakpointHitResponse* dst) {
131 dst->set_hit(src.hit);
132 ToProtoBreakpointInfo(src.breakpoint, dst->mutable_breakpoint());
133 ToProtoCpuState(src.cpu_state, dst->mutable_cpu_state());
136inline void ToProtoGameState(
const GameSnapshot& src,
137 agent::GameStateResponse* dst) {
138 dst->set_game_mode(src.game_mode);
139 dst->set_link_state(src.link_state);
140 dst->set_link_pos_x(src.link_pos_x);
141 dst->set_link_pos_y(src.link_pos_y);
142 dst->set_link_health(src.link_health);
143 if (!src.screenshot_png.empty()) {
144 dst->set_screenshot_png(src.screenshot_png.data(),
145 src.screenshot_png.size());