mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-12 09:18:11 +03:00
Initial DAP implementation
So far only basic debugging functionality is implemented (breakpoints, stepping, stack traces/variables). This is not tested against an established DAP client. My intention is to create a custom GUI frontend and extend the protocol to support xsystem4-specific features, such as inspecting the scene. (This work is underway.) Instruction references are hex-encoded address strings. Clients do not need to obtain them from DAP requests. This is outside the spec, but it is needed for a binary-only debugger. Functions that write directly to stdout (e.g. printf) should generally not be used any more. Instead, use either sys_message (which respects sys_silent) or log_message (which will send the message to the debugger if DAP is enabled). stderr can be used as normal.
This commit is contained in:
+38
-38
@@ -60,11 +60,11 @@ static const char *fog_type_name(enum RE_fog_type type)
|
||||
static void print_motion(const char *name, struct motion *m, int indent)
|
||||
{
|
||||
if (m->instance->type == RE_ITYPE_BILLBOARD) {
|
||||
indent_printf(indent, "%s = {state=%s, frame=%f, range=(%d,%d), loop_range=(%d,%d)},\n",
|
||||
indent_message(indent, "%s = {state=%s, frame=%f, range=(%d,%d), loop_range=(%d,%d)},\n",
|
||||
name, motion_state_name(m->state), m->current_frame,
|
||||
(int)m->frame_begin, (int)m->frame_end, (int)m->loop_frame_begin, (int)m->loop_frame_end);
|
||||
} else if (m->mot) {
|
||||
indent_printf(indent, "%s = {name=\"%s\", state=%s, frame=%f},\n",
|
||||
indent_message(indent, "%s = {name=\"%s\", state=%s, frame=%f},\n",
|
||||
name, m->mot->name, motion_state_name(m->state), m->current_frame);
|
||||
}
|
||||
}
|
||||
@@ -73,85 +73,85 @@ static void print_instance(struct RE_instance *inst, int index, int indent)
|
||||
{
|
||||
if (!inst)
|
||||
return;
|
||||
indent_printf(indent, "instance[%d] = {\n", index);
|
||||
indent_message(indent, "instance[%d] = {\n", index);
|
||||
indent++;
|
||||
|
||||
indent_printf(indent, "type = %s,\n", instance_type_name(inst->type));
|
||||
indent_message(indent, "type = %s,\n", instance_type_name(inst->type));
|
||||
if (inst->type == RE_ITYPE_DIRECTIONAL_LIGHT || inst->type == RE_ITYPE_SPECULAR_LIGHT) {
|
||||
indent_printf(indent, "vec = {x=%f, y=%f, z=%f},\n", SPREAD_VEC3(inst->vec));
|
||||
indent_printf(indent, "diffuse = {r=%f, g=%f, b=%f},\n", SPREAD_VEC3(inst->diffuse));
|
||||
indent_printf(indent, "globe_diffuse = {r=%f, g=%f, b=%f},\n", SPREAD_VEC3(inst->globe_diffuse));
|
||||
indent_message(indent, "vec = {x=%f, y=%f, z=%f},\n", SPREAD_VEC3(inst->vec));
|
||||
indent_message(indent, "diffuse = {r=%f, g=%f, b=%f},\n", SPREAD_VEC3(inst->diffuse));
|
||||
indent_message(indent, "globe_diffuse = {r=%f, g=%f, b=%f},\n", SPREAD_VEC3(inst->globe_diffuse));
|
||||
} else {
|
||||
indent_printf(indent, "draw = %d,\n", inst->draw);
|
||||
indent_printf(indent, "pos = {x=%f, y=%f, z=%f},\n", SPREAD_VEC3(inst->pos));
|
||||
indent_printf(indent, "scale = {x=%f, y=%f, z=%f},\n", SPREAD_VEC3(inst->scale));
|
||||
indent_printf(indent, "ambient = {r=%f, g=%f, b=%f},\n", SPREAD_VEC3(inst->ambient));
|
||||
indent_message(indent, "draw = %d,\n", inst->draw);
|
||||
indent_message(indent, "pos = {x=%f, y=%f, z=%f},\n", SPREAD_VEC3(inst->pos));
|
||||
indent_message(indent, "scale = {x=%f, y=%f, z=%f},\n", SPREAD_VEC3(inst->scale));
|
||||
indent_message(indent, "ambient = {r=%f, g=%f, b=%f},\n", SPREAD_VEC3(inst->ambient));
|
||||
}
|
||||
if (inst->model) {
|
||||
indent_printf(indent, "path = \"%s\",\n", inst->model->path);
|
||||
indent_printf(indent, "aabb = {min = {x=%f, y=%f, z=%f}, max = {x=%f, y=%f, z=%f}},\n",
|
||||
indent_message(indent, "path = \"%s\",\n", inst->model->path);
|
||||
indent_message(indent, "aabb = {min = {x=%f, y=%f, z=%f}, max = {x=%f, y=%f, z=%f}},\n",
|
||||
SPREAD_VEC3(inst->model->aabb[0]), SPREAD_VEC3(inst->model->aabb[1]));
|
||||
}
|
||||
if (inst->motion) {
|
||||
indent_printf(indent, "fps = %f,\n", inst->fps);
|
||||
indent_message(indent, "fps = %f,\n", inst->fps);
|
||||
print_motion("motion", inst->motion, indent);
|
||||
}
|
||||
if (inst->next_motion)
|
||||
print_motion("next_motion", inst->next_motion, indent);
|
||||
if (inst->motion_blend)
|
||||
indent_printf(indent, "motion_blend_rate = %f,\n", inst->motion_blend_rate);
|
||||
indent_message(indent, "motion_blend_rate = %f,\n", inst->motion_blend_rate);
|
||||
if (inst->effect)
|
||||
indent_printf(indent, "path = \"%s\",\n", inst->effect->pae->path);
|
||||
indent_message(indent, "path = \"%s\",\n", inst->effect->pae->path);
|
||||
|
||||
indent--;
|
||||
indent_printf(indent, "},\n");
|
||||
indent_message(indent, "},\n");
|
||||
}
|
||||
|
||||
static void print_back_cg(struct RE_back_cg *bcg, int index, int indent)
|
||||
{
|
||||
if (!bcg->name && !bcg->no)
|
||||
return;
|
||||
indent_printf(indent, "backCG[%d] = {\n", index);
|
||||
indent_message(indent, "backCG[%d] = {\n", index);
|
||||
indent++;
|
||||
|
||||
if (bcg->no)
|
||||
indent_printf(indent, "no = %d,\n", bcg->no);
|
||||
indent_message(indent, "no = %d,\n", bcg->no);
|
||||
if (bcg->name)
|
||||
indent_printf(indent, "name = \"%s\",\n", bcg->name ? bcg->name->text : "");
|
||||
indent_printf(indent, "pos = {x=%f, y=%f},\n", bcg->x, bcg->y);
|
||||
indent_printf(indent, "blend_rate = %f,\n", bcg->blend_rate);
|
||||
indent_printf(indent, "mag = %f,\n", bcg->mag);
|
||||
indent_printf(indent, "show = %d,\n", bcg->show);
|
||||
indent_message(indent, "name = \"%s\",\n", bcg->name ? bcg->name->text : "");
|
||||
indent_message(indent, "pos = {x=%f, y=%f},\n", bcg->x, bcg->y);
|
||||
indent_message(indent, "blend_rate = %f,\n", bcg->blend_rate);
|
||||
indent_message(indent, "mag = %f,\n", bcg->mag);
|
||||
indent_message(indent, "show = %d,\n", bcg->show);
|
||||
|
||||
indent--;
|
||||
indent_printf(indent, "},\n");
|
||||
indent_message(indent, "},\n");
|
||||
}
|
||||
|
||||
void RE_debug_print(struct sact_sprite *sp, int indent)
|
||||
{
|
||||
struct RE_plugin *p = (struct RE_plugin *)sp->plugin;
|
||||
|
||||
indent_printf(indent, "name = \"%s\",\n", p->plugin.name);
|
||||
indent_printf(indent, "camera = {x=%f, y=%f, z=%f, pitch=%f, roll=%f, yaw=%f},\n",
|
||||
indent_message(indent, "name = \"%s\",\n", p->plugin.name);
|
||||
indent_message(indent, "camera = {x=%f, y=%f, z=%f, pitch=%f, roll=%f, yaw=%f},\n",
|
||||
SPREAD_VEC3(p->camera.pos), p->camera.pitch, p->camera.roll, p->camera.yaw);
|
||||
indent_printf(indent, "shadow_map_light_dir = {x=%f, y=%f, z=%f},\n", SPREAD_VEC3(p->shadow_map_light_dir));
|
||||
indent_printf(indent, "shadow_bias = %f,\n", p->shadow_bias);
|
||||
indent_message(indent, "shadow_map_light_dir = {x=%f, y=%f, z=%f},\n", SPREAD_VEC3(p->shadow_map_light_dir));
|
||||
indent_message(indent, "shadow_bias = %f,\n", p->shadow_bias);
|
||||
|
||||
indent_printf(indent, "fog_type = %s,\n", fog_type_name(p->fog_type));
|
||||
indent_message(indent, "fog_type = %s,\n", fog_type_name(p->fog_type));
|
||||
switch (p->fog_type) {
|
||||
case RE_FOG_NONE:
|
||||
break;
|
||||
case RE_FOG_LINEAR:
|
||||
indent_printf(indent, "fog_near = %f, fog_far = %f,\n", p->fog_near, p->fog_far);
|
||||
indent_printf(indent, "fog_color = {r=%f, g=%f, b=%f},\n", SPREAD_VEC3(p->fog_color));
|
||||
indent_message(indent, "fog_near = %f, fog_far = %f,\n", p->fog_near, p->fog_far);
|
||||
indent_message(indent, "fog_color = {r=%f, g=%f, b=%f},\n", SPREAD_VEC3(p->fog_color));
|
||||
break;
|
||||
case RE_FOG_LIGHT_SCATTERING:
|
||||
indent_printf(indent, "ls_beta_r = %f, ls_beta_m = %f,\n", p->ls_beta_r, p->ls_beta_m);
|
||||
indent_printf(indent, "ls_g = %f,\n", p->ls_g);
|
||||
indent_printf(indent, "ls_distance = %f,\n", p->ls_distance);
|
||||
indent_printf(indent, "ls_light_dir = {x=%f, y=%f, z=%f},\n", SPREAD_VEC3(p->ls_light_dir));
|
||||
indent_printf(indent, "ls_light_color = {r=%f, g=%f, b=%f},\n", SPREAD_VEC3(p->ls_light_color));
|
||||
indent_printf(indent, "ls_sun_color = {r=%f, g=%f, b=%f},\n", SPREAD_VEC3(p->ls_sun_color));
|
||||
indent_message(indent, "ls_beta_r = %f, ls_beta_m = %f,\n", p->ls_beta_r, p->ls_beta_m);
|
||||
indent_message(indent, "ls_g = %f,\n", p->ls_g);
|
||||
indent_message(indent, "ls_distance = %f,\n", p->ls_distance);
|
||||
indent_message(indent, "ls_light_dir = {x=%f, y=%f, z=%f},\n", SPREAD_VEC3(p->ls_light_dir));
|
||||
indent_message(indent, "ls_light_color = {r=%f, g=%f, b=%f},\n", SPREAD_VEC3(p->ls_light_color));
|
||||
indent_message(indent, "ls_sun_color = {r=%f, g=%f, b=%f},\n", SPREAD_VEC3(p->ls_sun_color));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user