mirror of
https://github.com/open-goal/jak-project
synced 2026-07-09 06:53:45 -04:00
Merge pull request #759 from water111/w/sprite-distort-stub
[decomp] decompile sprite-distort without vu1 stuff
This commit is contained in:
@@ -770,6 +770,20 @@ TypeState AsmOp::propagate_types_internal(const TypeState& input,
|
||||
}
|
||||
}
|
||||
|
||||
// srl out, bitfield, int
|
||||
if (m_instr.kind == InstructionKind::SRL) {
|
||||
auto type = dts.ts.lookup_type(result.get(m_src[0]->reg()).typespec());
|
||||
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
|
||||
if (as_bitfield) {
|
||||
int sa = m_instr.src[1].get_imm();
|
||||
int offset = sa;
|
||||
int size = 32 - offset;
|
||||
auto field = find_field(dts.ts, as_bitfield, offset, size, {});
|
||||
result.get(m_dst->reg()) = TP_Type::make_from_ts(coerce_to_reg_type(field.type()));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_dst.has_value()) {
|
||||
auto kind = m_dst->reg().get_kind();
|
||||
if (kind == Reg::FPR) {
|
||||
|
||||
@@ -199,28 +199,11 @@ std::string add_indent(const std::string& in, int indent, bool indent_first_line
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string write_from_top_level(const Function& top_level,
|
||||
const DecompilerTypeSystem& dts,
|
||||
const LinkedObjectFile& file,
|
||||
const std::unordered_set<std::string>& skip_functions) {
|
||||
auto top_form = top_level.ir2.top_form;
|
||||
if (!top_form) {
|
||||
return ";; ERROR: top level function was not converted to expressions. Cannot decompile.\n\n";
|
||||
}
|
||||
|
||||
auto& env = top_level.ir2.env;
|
||||
if (!env.has_type_analysis()) {
|
||||
return ";; ERROR: top level has no type analysis. Cannot decompile.\n\n";
|
||||
}
|
||||
|
||||
if (!env.has_local_vars()) {
|
||||
return ";; ERROR: top level has no local vars. Cannot decompile.\n\n";
|
||||
}
|
||||
|
||||
if (!env.has_reg_use()) {
|
||||
return ";; ERROR: top level has no register use analysis. Cannot decompile.\n\n";
|
||||
}
|
||||
|
||||
std::string write_from_top_level_form(Form* top_form,
|
||||
const DecompilerTypeSystem& dts,
|
||||
const LinkedObjectFile& file,
|
||||
const std::unordered_set<std::string>& skip_functions,
|
||||
const Env& env) {
|
||||
std::vector<FormElement*> forms = top_form->elts();
|
||||
assert(!forms.empty());
|
||||
|
||||
@@ -232,7 +215,7 @@ std::string write_from_top_level(const Function& top_level,
|
||||
|
||||
std::string result;
|
||||
// local vars:
|
||||
auto var_dec = env.local_var_type_list(top_level.ir2.top_form, 0);
|
||||
auto var_dec = env.local_var_type_list(top_form, 0);
|
||||
if (var_dec.local_vars) {
|
||||
result += pretty_print::to_string(*var_dec.local_vars);
|
||||
result += '\n';
|
||||
@@ -424,6 +407,24 @@ std::string write_from_top_level(const Function& top_level,
|
||||
}
|
||||
}
|
||||
|
||||
if (!something_matched) {
|
||||
auto as_cne = f.try_as_element<CondNoElseElement>();
|
||||
if (as_cne && as_cne->entries.size() == 1) {
|
||||
auto& entry = as_cne->entries.at(0);
|
||||
// a bit gross...
|
||||
if (entry.condition->to_string(env) == "*debug-segment*") {
|
||||
something_matched = true;
|
||||
// forms = entry.body->elts();
|
||||
result += ";; this part is debug only\n";
|
||||
result += "(when *debug-segment*\n";
|
||||
|
||||
result += write_from_top_level_form(entry.body, dts, file, skip_functions, env);
|
||||
|
||||
result += ")\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!something_matched) {
|
||||
auto empty = dynamic_cast<EmptyElement*>(x);
|
||||
if (empty) {
|
||||
@@ -450,4 +451,29 @@ std::string write_from_top_level(const Function& top_level,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string write_from_top_level(const Function& top_level,
|
||||
const DecompilerTypeSystem& dts,
|
||||
const LinkedObjectFile& file,
|
||||
const std::unordered_set<std::string>& skip_functions) {
|
||||
auto top_form = top_level.ir2.top_form;
|
||||
if (!top_form) {
|
||||
return ";; ERROR: top level function was not converted to expressions. Cannot decompile.\n\n";
|
||||
}
|
||||
|
||||
auto& env = top_level.ir2.env;
|
||||
if (!env.has_type_analysis()) {
|
||||
return ";; ERROR: top level has no type analysis. Cannot decompile.\n\n";
|
||||
}
|
||||
|
||||
if (!env.has_local_vars()) {
|
||||
return ";; ERROR: top level has no local vars. Cannot decompile.\n\n";
|
||||
}
|
||||
|
||||
if (!env.has_reg_use()) {
|
||||
return ";; ERROR: top level has no register use analysis. Cannot decompile.\n\n";
|
||||
}
|
||||
|
||||
return write_from_top_level_form(top_form, dts, file, skip_functions, env);
|
||||
}
|
||||
} // namespace decompiler
|
||||
@@ -5201,6 +5201,45 @@
|
||||
:flag-assert #x900000010
|
||||
)
|
||||
|
||||
(defenum font-color
|
||||
:type uint64
|
||||
(default 0)
|
||||
(white 1)
|
||||
(gray 2)
|
||||
(orange-red 3)
|
||||
(bright-orange-red 4)
|
||||
(dark-yellow 5)
|
||||
(bright-green 6)
|
||||
(dark-blue 7)
|
||||
(light-blue 8)
|
||||
(dark-pink 9)
|
||||
(lighter-blue 10)
|
||||
(dark-light-blue 11)
|
||||
(dim-white 12)
|
||||
(dim-gray 13)
|
||||
(orange-red-2 14)
|
||||
(yellow-green 15)
|
||||
(dark-green 16)
|
||||
(another-gray 17)
|
||||
(dark-dark-green 18)
|
||||
(flat-dark-purple 19)
|
||||
(yellow 20)
|
||||
(blue-white 21)
|
||||
(flat-dark-gray 22)
|
||||
(flat-gray 23)
|
||||
(flat-pink 24)
|
||||
(flat-red 25)
|
||||
(flat-green 26)
|
||||
(flat-purple 27)
|
||||
(lighter-lighter-blue 28)
|
||||
(yellow-orange 29)
|
||||
(yellow-green-2 30)
|
||||
(another-light-blue 31)
|
||||
(another-default 32)
|
||||
(red-orange 33)
|
||||
(another-orange-red 34)
|
||||
)
|
||||
|
||||
(deftype font-context (basic)
|
||||
((origin vector :inline :offset-assert 16)
|
||||
(strip-gif vector :inline :offset-assert 32)
|
||||
@@ -5208,7 +5247,7 @@
|
||||
(height float :offset-assert 52)
|
||||
(projection float :offset-assert 56)
|
||||
(context-vec vector :inline :offset 48) ;; added
|
||||
(color int64 :offset-assert 64)
|
||||
(color font-color :offset-assert 64)
|
||||
(color-s32 int32 :offset 64) ;; added for asm
|
||||
(flags uint32 :offset-assert 72)
|
||||
(flags-signed int32 :offset 72) ;; added for asm
|
||||
@@ -5220,7 +5259,7 @@
|
||||
:size-assert #x58
|
||||
:flag-assert #x1400000058
|
||||
(:methods
|
||||
(new (symbol type matrix int int float int uint) _type_ 0)
|
||||
(new (symbol type matrix int int float font-color uint) _type_ 0)
|
||||
(set-mat! (font-context matrix) font-context 9)
|
||||
(set-origin! (font-context int int) font-context 10)
|
||||
(set-depth! (font-context int) font-context 11)
|
||||
@@ -5228,7 +5267,7 @@
|
||||
(set-width! (font-context int) font-context 13)
|
||||
(set-height! (font-context int) font-context 14)
|
||||
(set-projection! (font-context float) font-context 15)
|
||||
(set-color! (font-context int) font-context 16)
|
||||
(set-color! (font-context font-color) font-context 16)
|
||||
(set-flags! (font-context uint) font-context 17)
|
||||
(set-start-line! (font-context uint) font-context 18)
|
||||
(set-scale! (font-context float) font-context 19)
|
||||
@@ -5264,9 +5303,9 @@
|
||||
(justify vector 64 :inline :offset-assert 944)
|
||||
(color-shadow vector4w :inline :offset-assert 1968)
|
||||
(color-table char-color 64 :inline :offset-assert 1984)
|
||||
(last-color uint64 :offset-assert 3008)
|
||||
(last-color font-color :offset-assert 3008)
|
||||
(last-color-32 int32 :offset 3008)
|
||||
(save-last-color uint64 :offset-assert 3016)
|
||||
(save-last-color font-color :offset-assert 3016)
|
||||
(save-last-color-32 int32 :offset 3016) ;; added
|
||||
(buf basic :offset-assert 3024)
|
||||
(str-ptr uint32 :offset-assert 3028)
|
||||
@@ -5324,7 +5363,7 @@
|
||||
(define-extern set-display-env (function display-env int int int int int int display-env))
|
||||
(define-extern set-draw-env (function draw-env int int int int int int draw-env))
|
||||
(define-extern get-video-mode (function symbol))
|
||||
(define-extern draw-string-xy (function string dma-buffer int int int int none))
|
||||
(define-extern draw-string-xy (function string dma-buffer int int font-color int none))
|
||||
(define-extern set-draw-env-offset (function draw-env int int int draw-env))
|
||||
(define-extern put-display-alpha-env (function display-env none))
|
||||
(define-extern set-display2 (function display int int int int int display))
|
||||
@@ -15100,7 +15139,7 @@
|
||||
((flags int32 :offset-assert 0)
|
||||
(bucket bucket-id :offset-assert 4)
|
||||
(pos vector :inline :offset-assert 16)
|
||||
(color uint64 :offset-assert 32)
|
||||
(color font-color :offset-assert 32)
|
||||
(offset vector2h :inline :offset-assert 40)
|
||||
(str string :offset-assert 44)
|
||||
)
|
||||
@@ -15123,16 +15162,16 @@
|
||||
(define-extern debug-set-camera-pos-rot! (function vector matrix int))
|
||||
(define-extern drawable-frag-count (function drawable int))
|
||||
(define-extern add-debug-light (function symbol bucket-id light vector string symbol))
|
||||
(define-extern add-debug-text-3d (function symbol bucket-id string vector rgba vector2h symbol))
|
||||
(define-extern add-debug-text-3d (function symbol bucket-id string vector font-color vector2h symbol))
|
||||
(define-extern add-debug-x (function symbol bucket-id vector rgba symbol))
|
||||
(define-extern add-debug-curve (function symbol bucket-id pointer int (inline-array vector) int rgba symbol))
|
||||
(define-extern add-debug-sphere (function symbol bucket-id vector float rgba symbol))
|
||||
(define-extern get-debug-text-3d (function debug-text-3d))
|
||||
(define-extern internal-draw-debug-text-3d (function bucket-id string vector rgba vector2h pointer))
|
||||
(define-extern internal-draw-debug-text-3d (function bucket-id string vector font-color vector2h pointer))
|
||||
(define-extern get-debug-line (function debug-line))
|
||||
(define-extern internal-draw-debug-line (function bucket-id vector vector rgba symbol rgba pointer))
|
||||
(define-extern draw-string (function string dma-buffer font-context float))
|
||||
(define-extern transform-float-point (function vector vector vector))
|
||||
(define-extern transform-float-point (function vector vector4w vector4w))
|
||||
(define-extern add-debug-point (function symbol bucket-id vector symbol)) ;; unused
|
||||
(define-extern add-debug-outline-triangle (function symbol bucket-id vector vector vector rgba symbol))
|
||||
(define-extern add-debug-triangle-normal (function symbol bucket-id vector vector vector rgba symbol))
|
||||
@@ -15141,7 +15180,7 @@
|
||||
(define-extern debug-draw-buffers (function symbol))
|
||||
(define-extern add-debug-line2d (function symbol bucket-id vector vector vector symbol))
|
||||
(define-extern add-debug-box (function symbol bucket-id vector vector rgba symbol))
|
||||
(define-extern add-debug-sphere-with-transform (function symbol bucket-id vector float matrix rgba symbol))
|
||||
(define-extern add-debug-sphere-with-transform (function symbol bucket-id vector meters matrix rgba symbol))
|
||||
(define-extern add-debug-spheres (function symbol bucket-id (inline-array vector) int rgba symbol))
|
||||
(define-extern add-debug-circle (function symbol bucket-id vector float rgba matrix symbol))
|
||||
(define-extern add-debug-rot-matrix (function symbol bucket-id matrix vector matrix))
|
||||
@@ -17367,7 +17406,7 @@
|
||||
|
||||
;; - Functions
|
||||
|
||||
(define-extern set-font-color-alpha (function int int none))
|
||||
(define-extern set-font-color-alpha (function font-color int none))
|
||||
(define-extern load-game-text-info (function string symbol kheap int))
|
||||
(define-extern load-level-text-files (function int none))
|
||||
(define-extern draw-debug-text-box (function font-context none))
|
||||
|
||||
@@ -1652,7 +1652,14 @@
|
||||
[119, "a0", "(pointer int32)"],
|
||||
[124, "v1", "vector"],
|
||||
[154, "v1", "vector"],
|
||||
[[172, 189], "a1", "dma-packet"]
|
||||
[[172, 189], "a1", "dma-packet"],
|
||||
[[199, 203], "a0", "dma-packet"],
|
||||
[[207, 211], "a0", "vector4w"],
|
||||
[[216, 221], "a0", "dma-packet"],
|
||||
[[248, 265], "a1", "dma-packet"],
|
||||
[[273, 277], "a1", "dma-packet"],
|
||||
[[281, 285], "a1", "vector4w"],
|
||||
[[289, 294], "v1", "dma-packet"]
|
||||
],
|
||||
|
||||
"debug-menu-make-from-template": [
|
||||
|
||||
@@ -1386,9 +1386,9 @@
|
||||
|
||||
"display-loop": {
|
||||
"vars": {
|
||||
"s3-0":"debug-buf",
|
||||
"gp-0":"disp",
|
||||
"s5-2":"debug-txt-buf"
|
||||
"s3-0": "debug-buf",
|
||||
"gp-0": "disp",
|
||||
"s5-2": "debug-txt-buf"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2224,7 +2224,6 @@
|
||||
"v1-11": ["v1-11", "dma-packet"]
|
||||
}
|
||||
},
|
||||
"add-debug-light": { "vars": { "s1-0": ["s1-0", "rgba"] } },
|
||||
|
||||
"generic-init-buffers": {
|
||||
"vars": {
|
||||
@@ -3035,101 +3034,101 @@
|
||||
},
|
||||
|
||||
"(method 15 trajectory)": {
|
||||
"vars":{
|
||||
"s5-0":"prev-pos",
|
||||
"s4-0":"pos",
|
||||
"s3-0":"num-segments",
|
||||
"f0-1":"t-eval"
|
||||
"vars": {
|
||||
"s5-0": "prev-pos",
|
||||
"s4-0": "pos",
|
||||
"s3-0": "num-segments",
|
||||
"f0-1": "t-eval"
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
"set-font-color-alpha": {
|
||||
"args":["idx", "alpha"]
|
||||
"args": ["idx", "alpha"]
|
||||
},
|
||||
|
||||
"print-game-text-scaled": {
|
||||
"args":["str", "scale", "font-ctxt", "alpha"]
|
||||
"args": ["str", "scale", "font-ctxt", "alpha"]
|
||||
},
|
||||
|
||||
"print-game-text": {
|
||||
"args":["str", "font-ctxt", "alpha", "offset-thing"]
|
||||
"args": ["str", "font-ctxt", "alpha", "offset-thing"]
|
||||
},
|
||||
|
||||
"display-frame-start": {
|
||||
"args":["disp", "new-frame-idx", "odd-even"],
|
||||
"args": ["disp", "new-frame-idx", "odd-even"],
|
||||
"vars": {
|
||||
"f30-0":"time-ratio",
|
||||
"s3-0":"scaled-seconds",
|
||||
"s3-1":"new-frame"
|
||||
"f30-0": "time-ratio",
|
||||
"s3-0": "scaled-seconds",
|
||||
"s3-1": "new-frame"
|
||||
}
|
||||
},
|
||||
|
||||
"display-frame-finish": {
|
||||
"args":["disp"],
|
||||
"args": ["disp"],
|
||||
"vars": {
|
||||
"s4-0":"this-frame",
|
||||
"s5-0":"this-calc-buf",
|
||||
"s3-0":"bucket-idx",
|
||||
"v1-7":"this-global-buf",
|
||||
"a0-16":"global-buf",
|
||||
"v1-19":"calc-current",
|
||||
"a2-1":"calc-start",
|
||||
"s4-1":"global-current",
|
||||
"s5-1":"global-start",
|
||||
"s3-1":"global-end"
|
||||
"s4-0": "this-frame",
|
||||
"s5-0": "this-calc-buf",
|
||||
"s3-0": "bucket-idx",
|
||||
"v1-7": "this-global-buf",
|
||||
"a0-16": "global-buf",
|
||||
"v1-19": "calc-current",
|
||||
"a2-1": "calc-start",
|
||||
"s4-1": "global-current",
|
||||
"s5-1": "global-start",
|
||||
"s3-1": "global-end"
|
||||
}
|
||||
},
|
||||
|
||||
"display-sync": {
|
||||
"args":["disp"],
|
||||
"args": ["disp"],
|
||||
"vars": {
|
||||
"s4-0":"frame-idx",
|
||||
"s5-0":"syncv-result",
|
||||
"s3-0":"dma-buf-to-send",
|
||||
"a1-4":"next-frame"
|
||||
"s4-0": "frame-idx",
|
||||
"s5-0": "syncv-result",
|
||||
"s3-0": "dma-buf-to-send",
|
||||
"a1-4": "next-frame"
|
||||
}
|
||||
},
|
||||
|
||||
"draw-string": {
|
||||
"args":["str-in", "context"],
|
||||
"args": ["str-in", "context"],
|
||||
"vars": {
|
||||
"v1-5":"fw",
|
||||
"a1-1":"dma-out",
|
||||
"t2-0":"flags",
|
||||
"a3-0":"has-flag-size24",
|
||||
"a3-1":"font-table-12",
|
||||
"a3-2":"font-table-to-use",
|
||||
"t0-0":"q-lo-tmpl",
|
||||
"t1-0":"q-hi-tmpl",
|
||||
"t3-0":"in-color",
|
||||
"t3-1":"color-array-prod",
|
||||
"t4-0":"fw+col",
|
||||
"t3-2":"q-verts-0p",
|
||||
"t5-0":"q-verts-1p",
|
||||
"t3-3":"q-verts-2p",
|
||||
"t4-1":"q-verts-3p",
|
||||
"t5-1":"q-verts-1t",
|
||||
"t5-2":"q-verts-1",
|
||||
"t3-4":"q-verts-2t",
|
||||
"t3-5":"q-verts-2",
|
||||
"t6-0":"q-verts-0t",
|
||||
"t6-1":"q-verts-0",
|
||||
"t4-2":"q-verts-3t",
|
||||
"t4-3":"q-verts-3",
|
||||
"t3-6":"fw2",
|
||||
"t4-4":"str-char",
|
||||
"t5-3":"not-sc-lit1",
|
||||
"t5-4":"not-sc-~",
|
||||
"t4-14":"fc-cr",
|
||||
"r0-0":"r0",
|
||||
"r0-1":"r0",
|
||||
"r0-2":"r0",
|
||||
"r0-3":"r0"
|
||||
|
||||
|
||||
|
||||
"v1-5": "fw",
|
||||
"a1-1": "dma-out",
|
||||
"t2-0": "flags",
|
||||
"a3-0": "has-flag-size24",
|
||||
"a3-1": "font-table-12",
|
||||
"a3-2": "font-table-to-use",
|
||||
"t0-0": "q-lo-tmpl",
|
||||
"t1-0": "q-hi-tmpl",
|
||||
"t3-0": "in-color",
|
||||
"t3-1": "color-array-prod",
|
||||
"t4-0": "fw+col",
|
||||
"t3-2": "q-verts-0p",
|
||||
"t5-0": "q-verts-1p",
|
||||
"t3-3": "q-verts-2p",
|
||||
"t4-1": "q-verts-3p",
|
||||
"t5-1": "q-verts-1t",
|
||||
"t5-2": "q-verts-1",
|
||||
"t3-4": "q-verts-2t",
|
||||
"t3-5": "q-verts-2",
|
||||
"t6-0": "q-verts-0t",
|
||||
"t6-1": "q-verts-0",
|
||||
"t4-2": "q-verts-3t",
|
||||
"t4-3": "q-verts-3",
|
||||
"t3-6": "fw2",
|
||||
"t4-4": "str-char",
|
||||
"t5-3": "not-sc-lit1",
|
||||
"t5-4": "not-sc-~",
|
||||
"t4-14": "fc-cr",
|
||||
"r0-0": "r0",
|
||||
"r0-1": "r0",
|
||||
"r0-2": "r0",
|
||||
"r0-3": "r0"
|
||||
}
|
||||
},
|
||||
|
||||
"add-debug-outline-triangle": {
|
||||
"args":["enable", "bucket", "p0", "p1", "p2", "color"]
|
||||
},
|
||||
"aaaaaaaaaaaaaaaaaaaaaaa": {}
|
||||
}
|
||||
|
||||
@@ -1246,11 +1246,20 @@ std::vector<std::string> decompile_bitfield_enum_from_int(const TypeSpec& type,
|
||||
assert(type_info);
|
||||
assert(type_info->is_bitfield());
|
||||
|
||||
std::vector<std::string> bit_sorted_names;
|
||||
for (auto& field : type_info->entries()) {
|
||||
u64 mask = ((u64)1) << field.second;
|
||||
bit_sorted_names.push_back(field.first);
|
||||
}
|
||||
std::sort(bit_sorted_names.begin(), bit_sorted_names.end(),
|
||||
[&](const std::string& a, const std::string& b) {
|
||||
return type_info->entries().at(a) < type_info->entries().at(b);
|
||||
});
|
||||
|
||||
for (auto& field_name : bit_sorted_names) {
|
||||
u64 mask = ((u64)1) << type_info->entries().at(field_name);
|
||||
if (value & mask) {
|
||||
reconstructed |= mask;
|
||||
result.push_back(field.first);
|
||||
result.push_back(field_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -540,7 +540,7 @@ void DirectRenderer::handle_xyzf2_packed(const u8* data, SharedRenderState* rend
|
||||
u8 f = (upper >> 36);
|
||||
bool adc = upper & (1ull << 47);
|
||||
assert(!adc);
|
||||
assert(!f);
|
||||
// assert(!f);
|
||||
handle_xyzf2_common(x, y, z, f, render_state);
|
||||
}
|
||||
|
||||
@@ -619,7 +619,8 @@ void DirectRenderer::handle_xyzf2_common(u32 x,
|
||||
if (m_prim_buffer.is_full()) {
|
||||
flush_pending(render_state);
|
||||
}
|
||||
assert(f == 0);
|
||||
// assert(f == 0);
|
||||
|
||||
m_prim_building.building_st.at(m_prim_building.building_idx) = m_prim_building.st_reg;
|
||||
m_prim_building.building_rgba.at(m_prim_building.building_idx) = m_prim_building.rgba_reg;
|
||||
m_prim_building.building_vert.at(m_prim_building.building_idx) = {x << 16, y << 16, z};
|
||||
@@ -669,39 +670,44 @@ void DirectRenderer::handle_xyzf2_common(u32 x,
|
||||
}
|
||||
|
||||
} break;
|
||||
// case GsPrim::Kind::LINE: {
|
||||
// if (m_prim_building.building_idx == 1) {
|
||||
// math::Vector<double, 3> pt0 = m_prim_building.building_vert[0].cast<double>();
|
||||
// math::Vector<double, 3> pt1 = m_prim_building.building_vert[1].cast<double>();
|
||||
// auto normal = (pt1 - pt0).normalized().cross({0, 0, 1});
|
||||
//
|
||||
// double line_width = (1 << 28);
|
||||
// fmt::print("Line:\n ");
|
||||
// fmt::print(" {} {} {} {}\n", m_prim_building.building_vert[0].x(),
|
||||
// m_prim_building.building_vert[0].y(),
|
||||
// m_prim_building.building_vert[1].x(),
|
||||
// m_prim_building.building_vert[1].y());
|
||||
// // debug_print_vtx(m_prim_building.building_vert[0]);
|
||||
// // debug_print_vtx(m_prim_building.building_vert[1]);
|
||||
//
|
||||
// math::Vector<double, 3> a = pt0 + normal * line_width;
|
||||
// math::Vector<double, 3> b = pt1 + normal * line_width;
|
||||
// math::Vector<double, 3> c = pt0 - normal * line_width;
|
||||
// math::Vector<double, 3> d = pt1 - normal * line_width;
|
||||
//
|
||||
// // ACB:
|
||||
// m_prim_buffer.push(m_prim_building.building_rgba[0], a.cast<u32>(), {});
|
||||
// m_prim_buffer.push(m_prim_building.building_rgba[0], c.cast<u32>(), {});
|
||||
// m_prim_buffer.push(m_prim_building.building_rgba[1], b.cast<u32>(), {});
|
||||
// // b c d
|
||||
// m_prim_buffer.push(m_prim_building.building_rgba[1], b.cast<u32>(), {});
|
||||
// m_prim_buffer.push(m_prim_building.building_rgba[0], c.cast<u32>(), {});
|
||||
// m_prim_buffer.push(m_prim_building.building_rgba[1], d.cast<u32>(), {});
|
||||
// //
|
||||
//
|
||||
// m_prim_building.building_idx = 0;
|
||||
// }
|
||||
// } break;
|
||||
|
||||
case GsPrim::Kind::TRI:
|
||||
if (m_prim_building.building_idx == 3) {
|
||||
m_prim_building.building_idx = 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
m_prim_buffer.push(m_prim_building.building_rgba[i], m_prim_building.building_vert[i],
|
||||
m_prim_building.building_st[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GsPrim::Kind::LINE: {
|
||||
if (m_prim_building.building_idx == 2) {
|
||||
math::Vector<double, 3> pt0 = m_prim_building.building_vert[0].cast<double>();
|
||||
math::Vector<double, 3> pt1 = m_prim_building.building_vert[1].cast<double>();
|
||||
auto normal = (pt1 - pt0).normalized().cross({0, 0, 1});
|
||||
|
||||
double line_width = (1 << 19);
|
||||
// debug_print_vtx(m_prim_building.building_vert[0]);
|
||||
// debug_print_vtx(m_prim_building.building_vert[1]);
|
||||
|
||||
math::Vector<double, 3> a = pt0 + normal * line_width;
|
||||
math::Vector<double, 3> b = pt1 + normal * line_width;
|
||||
math::Vector<double, 3> c = pt0 - normal * line_width;
|
||||
math::Vector<double, 3> d = pt1 - normal * line_width;
|
||||
|
||||
// ACB:
|
||||
m_prim_buffer.push(m_prim_building.building_rgba[0], a.cast<u32>(), {});
|
||||
m_prim_buffer.push(m_prim_building.building_rgba[0], c.cast<u32>(), {});
|
||||
m_prim_buffer.push(m_prim_building.building_rgba[1], b.cast<u32>(), {});
|
||||
// b c d
|
||||
m_prim_buffer.push(m_prim_building.building_rgba[1], b.cast<u32>(), {});
|
||||
m_prim_buffer.push(m_prim_building.building_rgba[0], c.cast<u32>(), {});
|
||||
m_prim_buffer.push(m_prim_building.building_rgba[1], d.cast<u32>(), {});
|
||||
//
|
||||
|
||||
m_prim_building.building_idx = 0;
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
fmt::print("prim type {} is unsupported.\n", (int)m_prim_building.kind);
|
||||
assert(false);
|
||||
|
||||
@@ -70,7 +70,7 @@ void OpenGLRenderer::init_bucket_renderers() {
|
||||
*/
|
||||
void OpenGLRenderer::render(DmaFollower dma, int window_width_px, int window_height_px) {
|
||||
setup_frame(window_width_px, window_height_px);
|
||||
draw_test_triangle();
|
||||
// draw_test_triangle();
|
||||
// render the buckets!
|
||||
dispatch_buckets(dma);
|
||||
}
|
||||
|
||||
@@ -467,9 +467,9 @@
|
||||
(.mul.x.vf acc vf24 vf28)
|
||||
(.add.mul.y.vf acc vf25 vf28 acc)
|
||||
(.add.mul.z.vf acc vf26 vf28 acc)
|
||||
(.add.mul.w.vf vf28 vf27 vf0 acc)
|
||||
(.add.w.vf vf23 vf0 vf0)
|
||||
(.mul.vf vf31 vf28 vf29)
|
||||
(.add.mul.w.vf vf28 vf27 vf0 acc) ;; matrix mult.
|
||||
(.add.w.vf vf23 vf0 vf0) ;; clear w.
|
||||
(.mul.vf vf31 vf28 vf29) ;; scale.
|
||||
;;(TODO.VCLIP vf31 vf31)
|
||||
(let ((clip (vu-clip vf31 0)))
|
||||
(.div.vf Q vf0 vf31 :fsf #b11 :ftf #b11)
|
||||
|
||||
+182
-147
@@ -5,8 +5,12 @@
|
||||
;; name in dgo: debug
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
;; This file contains functions for debug drawing.
|
||||
;; In general, the 3d functions draw using the camera and the 2d functions draw in screen coordinated.
|
||||
;; Most functions take a boolean as their first argument. If the boolean is set to #f, it will skip drawing the point.
|
||||
|
||||
(defun transform-float-point ((in vector) (out vector))
|
||||
|
||||
(defun transform-float-point ((in vector) (out vector4w))
|
||||
"Transform point in and store the result in out.
|
||||
This uses the cached vf register transformation matrix
|
||||
Note that the input/output order of the arguments is swapped from usual"
|
||||
@@ -44,7 +48,8 @@
|
||||
;; They do a DMA packet per thing drawn.
|
||||
|
||||
(defun-debug add-debug-point ((enable-draw symbol) (bucket bucket-id) (pt vector))
|
||||
"Draw a point."
|
||||
"Draw a point.
|
||||
The point is actually a pretty large square with some weird rgb gradient."
|
||||
(if (not enable-draw)
|
||||
(return #f)
|
||||
)
|
||||
@@ -60,8 +65,9 @@
|
||||
(new 'static 'gif-tag64 :nloop 1 :eop 1 :pre 1 :nreg 8 :prim (gif-prim tri-strip))
|
||||
(gs-reg-list rgbaq xyzf2 rgbaq xyzf2 rgbaq xyzf2 rgbaq xyzf2)
|
||||
)
|
||||
|
||||
(set! (-> s5-0 vector 1 x) 255)
|
||||
|
||||
;; upper point is red
|
||||
(set! (-> s5-0 vector 1 x) 255) ;; r
|
||||
(set! (-> s5-0 vector 1 y) 128)
|
||||
(set! (-> s5-0 vector 1 z) 128)
|
||||
(set! (-> s5-0 vector 1 w) 128)
|
||||
@@ -70,16 +76,18 @@
|
||||
(-> s5-0 quad 1)
|
||||
(-> s5-0 quad 0)
|
||||
)
|
||||
|
||||
|
||||
;; left point is green
|
||||
(+! (-> s5-0 vector 0 x) -256)
|
||||
(+! (-> s5-0 vector 0 y) -160)
|
||||
(set! (-> s5-0 vector 1 x) 128)
|
||||
(set! (-> s5-0 vector 1 y) 255)
|
||||
(set! (-> s5-0 vector 1 y) 255) ;; g
|
||||
(dma-buffer-add-uint128 v1-7
|
||||
(-> s5-0 quad 1)
|
||||
(-> s5-0 quad 0)
|
||||
)
|
||||
|
||||
|
||||
;; right point is blue
|
||||
(+! (-> s5-0 vector 0 x) 512)
|
||||
(set! (-> s5-0 vector 1 y) 128)
|
||||
(set! (-> s5-0 vector 1 z) 255)
|
||||
@@ -87,7 +95,8 @@
|
||||
(-> s5-0 quad 1)
|
||||
(-> s5-0 quad 0)
|
||||
)
|
||||
|
||||
|
||||
;; bottom point is red again
|
||||
(+! (-> s5-0 vector 0 x) -256)
|
||||
(+! (-> s5-0 vector 0 y) -160)
|
||||
(set! (-> s5-0 vector 1 x) 255)
|
||||
@@ -104,170 +113,171 @@
|
||||
)
|
||||
|
||||
|
||||
(defun-debug internal-draw-debug-line ((arg0 bucket-id) (arg1 vector) (arg2 vector) (arg3 rgba) (arg4 symbol) (arg5 rgba))
|
||||
(let ((sv-80 arg2)
|
||||
(s2-0 arg3)
|
||||
(s3-0 arg4)
|
||||
(s5-0 arg5)
|
||||
)
|
||||
(let ((a0-4 (current-display-frame debug-buf)))
|
||||
(if (< (the-as uint (shr (+ (&- (-> a0-4 end) (the-as uint (-> a0-4 base))) 15) 4)) (the-as uint #x8000))
|
||||
(defun-debug internal-draw-debug-line ((bucket bucket-id) (p0 vector) (p1 vector) (first-color rgba) (mode symbol) (second-color rgba))
|
||||
"Draw a debug line from p0 to p1. Mode can be:
|
||||
'fade, 'fade-depth, or #f.
|
||||
second-color can be -1 to just use the same color.
|
||||
"
|
||||
(let ((a0-4 (current-display-frame debug-buf)))
|
||||
(if (< (the-as uint (shr (+ (&- (-> a0-4 end) (the-as uint (-> a0-4 base))) 15) 4)) (the-as uint #x8000))
|
||||
(return (the-as pointer #f))
|
||||
)
|
||||
)
|
||||
(if (or (zero? (+ s5-0 (the-as uint 1)))
|
||||
(= s5-0 (static-rgba #xff #xff #xff #xff))
|
||||
)
|
||||
(set! s5-0 s2-0)
|
||||
)
|
||||
(case s3-0
|
||||
(('fade)
|
||||
(set! s5-0 (new 'static 'rgba
|
||||
:r (shr (-> s5-0 r) 1)
|
||||
:g (shr (-> s5-0 g) 1)
|
||||
:b (shr (-> s5-0 b) 1)
|
||||
:a (-> s5-0 a)
|
||||
))
|
||||
)
|
||||
)
|
||||
(let ((s4-0 (new 'stack 'vector4w-2))
|
||||
(s1-0 (new 'stack 'vector4w-2))
|
||||
)
|
||||
(if (or (zero? (+ second-color (the-as uint 1)))
|
||||
(= second-color (static-rgba #xff #xff #xff #xff))
|
||||
)
|
||||
(set! (-> arg1 w) 1.0)
|
||||
(set! (-> sv-80 w) 1.0)
|
||||
|
||||
(when (and (transform-point-qword! (-> s4-0 vector 0) arg1)
|
||||
(transform-point-qword! (-> s4-0 vector 1) sv-80)
|
||||
)
|
||||
(with-dma-buffer-add-bucket ((v1-28 (current-display-frame debug-buf)) (current-display-frame bucket-group) arg0)
|
||||
|
||||
(with-cnt-vif-block (v1-28)
|
||||
(dma-buffer-add-gif-tag v1-28 (new 'static 'gif-tag64 :nloop 1 :eop 1 :pre 1 :nreg 4
|
||||
:prim (gif-prim line))
|
||||
(gs-reg-list rgbaq xyzf2 rgbaq xyzf2)
|
||||
)
|
||||
(case s3-0
|
||||
(set! second-color first-color)
|
||||
)
|
||||
(case mode
|
||||
(('fade)
|
||||
(set! second-color (new 'static 'rgba
|
||||
:r (shr (-> second-color r) 1)
|
||||
:g (shr (-> second-color g) 1)
|
||||
:b (shr (-> second-color b) 1)
|
||||
:a (-> second-color a)
|
||||
))
|
||||
)
|
||||
)
|
||||
(let ((s4-0 (new 'stack 'vector4w-2))
|
||||
(s1-0 (new 'stack 'vector4w-2))
|
||||
)
|
||||
(set! (-> p0 w) 1.0)
|
||||
(set! (-> p1 w) 1.0)
|
||||
|
||||
(when (and (transform-point-qword! (-> s4-0 vector 0) p0)
|
||||
(transform-point-qword! (-> s4-0 vector 1) p1)
|
||||
)
|
||||
(with-dma-buffer-add-bucket ((v1-28 (current-display-frame debug-buf)) (current-display-frame bucket-group) bucket)
|
||||
(with-cnt-vif-block (v1-28)
|
||||
(dma-buffer-add-gif-tag v1-28 (new 'static 'gif-tag64 :nloop 1 :eop 1 :pre 1 :nreg 4
|
||||
:prim (gif-prim line))
|
||||
(gs-reg-list rgbaq xyzf2 rgbaq xyzf2)
|
||||
)
|
||||
(case mode
|
||||
(('fade-depth)
|
||||
(let ((f0-3 (fminmax (* (1/ #xffffff) (the float (-> s4-0 vector 0 z))) 0.2 1.0)))
|
||||
(set! (-> s1-0 vector 0 x) (the int (* (the float (-> s2-0 r)) f0-3)))
|
||||
(set! (-> s1-0 vector 0 y) (the int (* (the float (-> s2-0 g)) f0-3)))
|
||||
(set! (-> s1-0 vector 0 z) (the int (* (the float (-> s2-0 b)) f0-3)))
|
||||
(set! (-> s1-0 vector 0 x) (the int (* (the float (-> first-color r)) f0-3)))
|
||||
(set! (-> s1-0 vector 0 y) (the int (* (the float (-> first-color g)) f0-3)))
|
||||
(set! (-> s1-0 vector 0 z) (the int (* (the float (-> first-color b)) f0-3)))
|
||||
)
|
||||
(set! (-> s1-0 vector 0 w) (the-as int (-> s2-0 a)))
|
||||
(set! (-> s1-0 vector 0 w) (the-as int (-> first-color a)))
|
||||
)
|
||||
(else
|
||||
(set! (-> s1-0 vector 0 x) (the-as int (-> s2-0 r)))
|
||||
(set! (-> s1-0 vector 0 y) (the-as int (-> s2-0 g)))
|
||||
(set! (-> s1-0 vector 0 z) (the-as int (-> s2-0 b)))
|
||||
(set! (-> s1-0 vector 0 w) (the-as int (-> s2-0 a)))
|
||||
)
|
||||
(set! (-> s1-0 vector 0 x) (the-as int (-> first-color r)))
|
||||
(set! (-> s1-0 vector 0 y) (the-as int (-> first-color g)))
|
||||
(set! (-> s1-0 vector 0 z) (the-as int (-> first-color b)))
|
||||
(set! (-> s1-0 vector 0 w) (the-as int (-> first-color a)))
|
||||
)
|
||||
)
|
||||
(cond
|
||||
((= s3-0 'fade-depth)
|
||||
(let ((f0-7 (fminmax (* (1/ #xffffff) (the float (-> s4-0 vector 1 z))) 0.2 1.0)))
|
||||
(set! (-> s1-0 vector 1 x) (the int (* (the float (-> s5-0 r)) f0-7)))
|
||||
(set! (-> s1-0 vector 1 y) (the int (* (the float (-> s5-0 g)) f0-7)))
|
||||
(set! (-> s1-0 vector 1 z) (the int (* (the float (-> s5-0 b)) f0-7)))
|
||||
)
|
||||
(set! (-> s1-0 vector 1 w) (the-as int (-> s5-0 a)))
|
||||
)
|
||||
(else
|
||||
(set! (-> s1-0 vector 1 x) (the-as int (-> s5-0 r)))
|
||||
(set! (-> s1-0 vector 1 y) (the-as int (-> s5-0 g)))
|
||||
(set! (-> s1-0 vector 1 z) (the-as int (-> s5-0 b)))
|
||||
(set! (-> s1-0 vector 1 w) (the-as int (-> s5-0 a)))
|
||||
)
|
||||
)
|
||||
(+! (-> s4-0 vector 0 z) -8192)
|
||||
(+! (-> s4-0 vector 1 z) -8192)
|
||||
(dma-buffer-add-uint128 v1-28 (-> s1-0 quad 0)
|
||||
(-> s4-0 quad 0)
|
||||
(-> s1-0 quad 1)
|
||||
(-> s4-0 quad 1)
|
||||
)
|
||||
(cond
|
||||
((= mode 'fade-depth)
|
||||
(let ((f0-7 (fminmax (* (1/ #xffffff) (the float (-> s4-0 vector 1 z))) 0.2 1.0)))
|
||||
(set! (-> s1-0 vector 1 x) (the int (* (the float (-> second-color r)) f0-7)))
|
||||
(set! (-> s1-0 vector 1 y) (the int (* (the float (-> second-color g)) f0-7)))
|
||||
(set! (-> s1-0 vector 1 z) (the int (* (the float (-> second-color b)) f0-7)))
|
||||
)
|
||||
(set! (-> s1-0 vector 1 w) (the-as int (-> second-color a)))
|
||||
)
|
||||
(else
|
||||
(set! (-> s1-0 vector 1 x) (the-as int (-> second-color r)))
|
||||
(set! (-> s1-0 vector 1 y) (the-as int (-> second-color g)))
|
||||
(set! (-> s1-0 vector 1 z) (the-as int (-> second-color b)))
|
||||
(set! (-> s1-0 vector 1 w) (the-as int (-> second-color a)))
|
||||
)
|
||||
)
|
||||
(+! (-> s4-0 vector 0 z) -8192)
|
||||
(+! (-> s4-0 vector 1 z) -8192)
|
||||
(dma-buffer-add-uint128 v1-28 (-> s1-0 quad 0)
|
||||
(-> s4-0 quad 0)
|
||||
(-> s1-0 quad 1)
|
||||
(-> s4-0 quad 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(defun-debug internal-draw-debug-text-3d ((arg0 bucket-id) (arg1 string) (arg2 vector) (arg3 rgba) (arg4 vector2h))
|
||||
(defun-debug internal-draw-debug-text-3d ((bucket bucket-id) (str string) (location vector) (font-color-id font-color) (offset vector2h))
|
||||
"Draw text at the given location (in 3D), with a 2D offset."
|
||||
(let ((s2-0 (new 'stack-no-clear 'vector4w)))
|
||||
(set! (-> s2-0 quad) (the-as uint128 0))
|
||||
(when (transform-point-qword! (the-as vector4w s2-0) arg2)
|
||||
|
||||
(with-dma-buffer-add-bucket ((s3-0 (current-display-frame debug-buf)) (current-display-frame bucket-group) arg0)
|
||||
|
||||
(when (transform-point-qword! (the-as vector4w s2-0) location)
|
||||
|
||||
(with-dma-buffer-add-bucket ((s3-0 (current-display-frame debug-buf)) (current-display-frame bucket-group) bucket)
|
||||
|
||||
(let ((a2-2 (new 'stack 'font-context *font-default-matrix*
|
||||
(+ (+ (-> arg4 x) -1792) (/ (-> s2-0 x) 16))
|
||||
(- (+ (+ (-> arg4 y) -8) (/ (-> s2-0 y) 16))
|
||||
(-> *video-parms* screen-miny)
|
||||
)
|
||||
0.0
|
||||
(the-as int arg3)
|
||||
(the-as uint 3)
|
||||
)))
|
||||
(+ (+ (-> offset x) -1792) (/ (-> s2-0 x) 16))
|
||||
(- (+ (+ (-> offset y) -8) (/ (-> s2-0 y) 16))
|
||||
(-> *video-parms* screen-miny)
|
||||
)
|
||||
0.0
|
||||
font-color-id
|
||||
(the-as uint 3)
|
||||
)))
|
||||
(let ((v1-9 a2-2))
|
||||
(set! (-> v1-9 origin z) (the float (/ (-> s2-0 z) 16)))
|
||||
)
|
||||
(draw-string arg1 s3-0 a2-2)
|
||||
(draw-string str s3-0 a2-2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun-debug add-debug-outline-triangle ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 vector) (arg5 rgba))
|
||||
(when arg0
|
||||
(add-debug-line #t arg1 arg2 arg3 arg5 #f (the-as rgba -1))
|
||||
(add-debug-line #t arg1 arg3 arg4 arg5 #f (the-as rgba -1))
|
||||
(add-debug-line #t arg1 arg4 arg2 arg5 #f (the-as rgba -1))
|
||||
(defun-debug add-debug-outline-triangle ((enable symbol) (bucket bucket-id) (p0 vector) (p1 vector) (p2 vector) (color rgba))
|
||||
"Draw outline of a triangle using lines."
|
||||
(when enable
|
||||
(add-debug-line #t bucket p0 p1 color #f (the-as rgba -1))
|
||||
(add-debug-line #t bucket p1 p2 color #f (the-as rgba -1))
|
||||
(add-debug-line #t bucket p2 p0 color #f (the-as rgba -1))
|
||||
)
|
||||
#f
|
||||
)
|
||||
|
||||
(defun-debug add-debug-triangle-normal ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 vector) (arg5 rgba))
|
||||
|
||||
(when arg0
|
||||
(defun-debug add-debug-triangle-normal ((enable symbol) (bucket bucket-id) (p0 vector) (p1 vector) (p2 vector) (color rgba))
|
||||
"Draw the normal of a triangle, with length of 1 meter."
|
||||
(when enable
|
||||
(let ((s4-0 (new 'stack-no-clear 'vector))
|
||||
(s3-0 (vector-3pt-cross! (new 'stack-no-clear 'vector) arg2 arg3 arg4))
|
||||
(s3-0 (vector-3pt-cross! (new 'stack-no-clear 'vector) p0 p1 p2))
|
||||
)
|
||||
(vector-float/! s3-0 s3-0 (* (1/ METER_LENGTH) (vector-length s3-0)))
|
||||
(vector+! s4-0 arg2 arg3)
|
||||
(vector+! s4-0 s4-0 arg4)
|
||||
(vector+! s4-0 p0 p1)
|
||||
(vector+! s4-0 s4-0 p2)
|
||||
(vector-float/! s4-0 s4-0 3.0)
|
||||
(vector+! s3-0 s3-0 s4-0)
|
||||
(add-debug-line #t arg1 s4-0 s3-0 arg5 #f (the-as rgba -1))
|
||||
(add-debug-line #t bucket s4-0 s3-0 color #f (the-as rgba -1))
|
||||
)
|
||||
)
|
||||
#f
|
||||
)
|
||||
|
||||
(defun-debug add-debug-flat-triangle ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 vector) (arg5 rgba))
|
||||
(if (not arg0)
|
||||
(defun-debug add-debug-flat-triangle ((enable-draw symbol) (bucket bucket-id) (p0 vector) (p1 vector) (p2 vector) (color rgba))
|
||||
"Draw a triangle with flat shading"
|
||||
(if (not enable-draw)
|
||||
(return #f)
|
||||
)
|
||||
(let ((s5-0 (new 'stack 'vector4w-3))
|
||||
(s4-0 (new 'stack 'vector4w-3))
|
||||
)
|
||||
(set! (-> arg2 w) 1.0)
|
||||
(set! (-> arg3 w) 1.0)
|
||||
(set! (-> arg4 w) 1.0)
|
||||
(when (and (transform-point-qword! (-> s5-0 vector 0) arg2)
|
||||
(transform-point-qword! (-> s5-0 vector 1) arg3)
|
||||
(transform-point-qword! (-> s5-0 vector 2) arg4)
|
||||
(set! (-> p0 w) 1.0)
|
||||
(set! (-> p1 w) 1.0)
|
||||
(set! (-> p2 w) 1.0)
|
||||
(when (and (transform-point-qword! (-> s5-0 vector 0) p0)
|
||||
(transform-point-qword! (-> s5-0 vector 1) p1)
|
||||
(transform-point-qword! (-> s5-0 vector 2) p2)
|
||||
)
|
||||
(with-dma-buffer-add-bucket ((v1-9 (current-display-frame debug-buf)) (current-display-frame bucket-group) arg1)
|
||||
(with-dma-buffer-add-bucket ((v1-9 (current-display-frame debug-buf)) (current-display-frame bucket-group) bucket)
|
||||
|
||||
(with-cnt-vif-block (v1-9)
|
||||
(dma-buffer-add-gif-tag v1-9 (new 'static 'gif-tag64 :nloop 1 :eop 1 :pre 1 :nreg 6 :prim (gif-prim tri))
|
||||
(gs-reg-list rgbaq xyzf2 rgbaq xyzf2 rgbaq xyzf2)
|
||||
)
|
||||
(set! (-> s4-0 vector 0 x) (the-as int (-> arg5 r)))
|
||||
(set! (-> s4-0 vector 0 y) (the-as int (-> arg5 g)))
|
||||
(set! (-> s4-0 vector 0 z) (the-as int (-> arg5 b)))
|
||||
(set! (-> s4-0 vector 0 w) (the-as int (-> arg5 a)))
|
||||
(set! (-> s4-0 vector 0 x) (the-as int (-> color r)))
|
||||
(set! (-> s4-0 vector 0 y) (the-as int (-> color g)))
|
||||
(set! (-> s4-0 vector 0 z) (the-as int (-> color b)))
|
||||
(set! (-> s4-0 vector 0 w) (the-as int (-> color a)))
|
||||
(set! (-> s5-0 vector 0 z) (+ (-> s5-0 vector 0 z) -8192))
|
||||
(set! (-> s5-0 vector 1 z) (+ (-> s5-0 vector 1 z) -8192))
|
||||
(set! (-> s5-0 vector 2 z) (+ (-> s5-0 vector 2 z) -8192))
|
||||
@@ -285,6 +295,16 @@
|
||||
#f
|
||||
)
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Buffered debug draw
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; Some of the debug draw stuff just adds a line to a list of lines to draw.
|
||||
;; This is used when pausing - the actual calls to debug-draw-line won't happen, but
|
||||
;; we won't clear the debug draw buffer so they will still be drawn.
|
||||
|
||||
|
||||
(when *debug-segment*
|
||||
|
||||
(deftype debug-line (structure)
|
||||
@@ -305,7 +325,7 @@
|
||||
((flags int32 :offset-assert 0)
|
||||
(bucket bucket-id :offset-assert 4)
|
||||
(pos vector :inline :offset-assert 16)
|
||||
(color uint64 :offset-assert 32)
|
||||
(color font-color :offset-assert 32)
|
||||
(offset vector2h :inline :offset-assert 40)
|
||||
(str string :offset-assert 44)
|
||||
)
|
||||
@@ -323,20 +343,22 @@
|
||||
:flag-assert #x90000000c
|
||||
)
|
||||
|
||||
(define *debug-lines* (the (inline-array debug-line) (malloc 'debug #x100000)))
|
||||
(define *debug-lines-trk* (new 'debug 'debug-tracking-thang))
|
||||
(set! (-> *debug-lines-trk* allocated-length) 16384)
|
||||
;; allocate debug draw buffers
|
||||
(define *debug-lines* (the (inline-array debug-line) (malloc 'debug #x100000)))
|
||||
(define *debug-lines-trk* (new 'debug 'debug-tracking-thang))
|
||||
(set! (-> *debug-lines-trk* allocated-length) 16384)
|
||||
(define *debug-text-3ds* (the (inline-array debug-text-3d) (malloc 'debug #x6000)))
|
||||
(define *debug-text-3d-trk* (new 'debug 'debug-tracking-thang))
|
||||
(set! (-> *debug-text-3d-trk* allocated-length) 512)
|
||||
|
||||
(define *debug-text-3ds* (the (inline-array debug-text-3d) (malloc 'debug #x6000)))
|
||||
(define *debug-text-3d-trk* (new 'debug 'debug-tracking-thang))
|
||||
(set! (-> *debug-text-3d-trk* allocated-length) 512)
|
||||
|
||||
(dotimes (i (-> *debug-text-3d-trk* allocated-length))
|
||||
(set! (-> *debug-text-3ds* i str) (new 'debug 'string 80 (the string #f)))
|
||||
)
|
||||
(dotimes (i (-> *debug-text-3d-trk* allocated-length))
|
||||
(set! (-> *debug-text-3ds* i str) (new 'debug 'string 80 (the string #f)))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(defun-debug get-debug-line ()
|
||||
"Allocate a debug-line from the list."
|
||||
(cond
|
||||
((< (-> *debug-lines-trk* length) (-> *debug-lines-trk* allocated-length))
|
||||
(+! (-> *debug-lines-trk* length) 1)
|
||||
@@ -349,6 +371,7 @@
|
||||
)
|
||||
|
||||
(defun-debug get-debug-text-3d ()
|
||||
"Allocate a debug text 3d from the list."
|
||||
(cond
|
||||
((< (-> *debug-text-3d-trk* length) (-> *debug-text-3d-trk* allocated-length))
|
||||
(+! (-> *debug-text-3d-trk* length) 1)
|
||||
@@ -361,6 +384,7 @@
|
||||
)
|
||||
|
||||
(defun-debug debug-reset-buffers ()
|
||||
"Clear all allocated debug things"
|
||||
(set! (-> *debug-lines-trk* length) 0)
|
||||
(set! (-> *debug-text-3d-trk* length) 0)
|
||||
(set! *debug-draw-pauseable* #f)
|
||||
@@ -368,6 +392,7 @@
|
||||
)
|
||||
|
||||
(defun-debug debug-draw-buffers ()
|
||||
"Draw all debug lines and debug text."
|
||||
(dotimes (gp-0 (-> *debug-lines-trk* length))
|
||||
(let ((v1-1 (-> *debug-lines* gp-0)))
|
||||
(internal-draw-debug-line
|
||||
@@ -386,7 +411,7 @@
|
||||
(-> v1-8 bucket)
|
||||
(-> v1-8 str)
|
||||
(-> v1-8 pos)
|
||||
(the-as rgba (-> v1-8 color))
|
||||
(-> v1-8 color)
|
||||
(-> v1-8 offset)
|
||||
)
|
||||
)
|
||||
@@ -394,23 +419,24 @@
|
||||
#f
|
||||
)
|
||||
|
||||
(defun-debug add-debug-line ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 rgba) (arg5 symbol) (arg6 rgba))
|
||||
(when arg0
|
||||
(defun-debug add-debug-line ((enable-draw symbol) (bucket bucket-id) (p0 vector) (p1 vector) (color rgba) (mode symbol) (color2 rgba))
|
||||
"Draw a debug line between p0 and p1, in 3D."
|
||||
(when enable-draw
|
||||
(cond
|
||||
(*debug-draw-pauseable*
|
||||
(let ((v1-2 (get-debug-line)))
|
||||
(when v1-2
|
||||
(set! (-> v1-2 bucket) arg1)
|
||||
(set! (-> v1-2 v1 quad) (-> arg2 quad))
|
||||
(set! (-> v1-2 v2 quad) (-> arg3 quad))
|
||||
(set! (-> v1-2 color) arg4)
|
||||
(set! (-> v1-2 color2) arg6)
|
||||
(set! (-> v1-2 mode) arg5)
|
||||
(set! (-> v1-2 bucket) bucket)
|
||||
(set! (-> v1-2 v1 quad) (-> p0 quad))
|
||||
(set! (-> v1-2 v2 quad) (-> p1 quad))
|
||||
(set! (-> v1-2 color) color)
|
||||
(set! (-> v1-2 color2) color2)
|
||||
(set! (-> v1-2 mode) mode)
|
||||
)
|
||||
)
|
||||
)
|
||||
(else
|
||||
(internal-draw-debug-line arg1 arg2 arg3 arg4 arg5 arg6)
|
||||
(internal-draw-debug-line bucket p0 p1 color mode color2)
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -418,6 +444,7 @@
|
||||
)
|
||||
|
||||
(defun-debug add-debug-line2d ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 vector))
|
||||
"Draw a line in screen coordinates"
|
||||
(if (not arg0)
|
||||
(return #f)
|
||||
)
|
||||
@@ -452,6 +479,7 @@
|
||||
)
|
||||
|
||||
(defun-debug add-debug-box ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 rgba))
|
||||
"Draw an axis-aligned box"
|
||||
(let ((s5-0 (new-stack-vector0)))
|
||||
(set! (-> s5-0 quad) (-> arg2 quad))
|
||||
(let ((s1-0 (new-stack-vector0)))
|
||||
@@ -500,6 +528,7 @@
|
||||
)
|
||||
|
||||
(defun-debug add-debug-x ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 rgba))
|
||||
"Draw an X in the xz plane"
|
||||
(if (not arg0)
|
||||
(return #f)
|
||||
)
|
||||
@@ -516,7 +545,8 @@
|
||||
#f
|
||||
)
|
||||
|
||||
(defun-debug add-debug-text-3d ((arg0 symbol) (arg1 bucket-id) (arg2 string) (arg3 vector) (arg4 rgba) (arg5 vector2h))
|
||||
(defun-debug add-debug-text-3d ((arg0 symbol) (arg1 bucket-id) (arg2 string) (arg3 vector) (arg4 font-color) (arg5 vector2h))
|
||||
"Draw text at the given point. arg4 is the font-color index. arg5 is an offset and can be #f."
|
||||
(when arg0
|
||||
(cond
|
||||
(*debug-draw-pauseable*
|
||||
@@ -536,7 +566,7 @@
|
||||
0
|
||||
)
|
||||
)
|
||||
(set! (-> v1-2 color) (the-as uint arg4))
|
||||
(set! (-> v1-2 color) arg4)
|
||||
(let ((a0-6 0)
|
||||
(a1-2 (-> arg2 data))
|
||||
(v1-4 (-> v1-2 str data))
|
||||
@@ -565,7 +595,9 @@
|
||||
#f
|
||||
)
|
||||
|
||||
(defun-debug add-debug-sphere-with-transform ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 float) (arg4 matrix) (arg5 rgba))
|
||||
(defun-debug add-debug-sphere-with-transform ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 meters) (arg4 matrix) (arg5 rgba))
|
||||
"Transform the given point by the given transform, then draw a debug sphere there. The orientation of the debug sphere itself
|
||||
is not changed by the transform, just its origin."
|
||||
(rlet ((acc :class vf)
|
||||
(vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
@@ -594,20 +626,23 @@
|
||||
)
|
||||
)
|
||||
|
||||
(defun-debug add-debug-sphere ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 float) (arg4 rgba))
|
||||
(defun-debug add-debug-sphere ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 meters) (arg4 rgba))
|
||||
"Add a debug sphere at the given point. arg3 is radius."
|
||||
(if arg0
|
||||
(add-debug-sphere-from-table arg1 arg2 arg3 arg4)
|
||||
)
|
||||
#f
|
||||
)
|
||||
|
||||
(defun-debug add-debug-text-sphere ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 float) (arg4 string) (arg5 rgba))
|
||||
(defun-debug add-debug-text-sphere ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 meters) (arg4 string) (arg5 rgba))
|
||||
"Add a debug sphere at the given point, withe some text. The color is for the sphere - the text is color 0."
|
||||
(add-debug-sphere arg0 arg1 arg2 arg3 arg5)
|
||||
(add-debug-text-3d arg0 arg1 arg4 arg2 (new 'static 'rgba) (the-as vector2h #f))
|
||||
(add-debug-text-3d arg0 arg1 arg4 arg2 (font-color default) (the-as vector2h #f))
|
||||
#f
|
||||
)
|
||||
|
||||
(defun-debug add-debug-spheres ((arg0 symbol) (arg1 bucket-id) (arg2 (inline-array vector)) (arg3 int) (arg4 rgba))
|
||||
"Add a bunch of spheres. The radius is taken from the w component of the origin."
|
||||
(when arg0
|
||||
(let ((s4-0 (-> arg2 0)))
|
||||
(countdown (s3-0 arg3)
|
||||
@@ -786,7 +821,7 @@
|
||||
(if (!= arg5 0.0)
|
||||
(set! (-> sv-96 y) arg5)
|
||||
)
|
||||
(add-debug-text-3d #t arg1 (string-format "~d" s0-0) sv-96 (the rgba 1) (the vector2h #f))
|
||||
(add-debug-text-3d #t arg1 (string-format "~d" s0-0) sv-96 (font-color white) (the vector2h #f))
|
||||
(add-debug-x #t arg1 sv-96 (if (= s0-0 arg6)
|
||||
(static-rgba #xff #xff #xff #x80)
|
||||
arg4
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
(set! (-> gp-0 root-menu) #f)
|
||||
(set! (-> gp-0 joypad-func) #f)
|
||||
(set! (-> gp-0 joypad-item) #f)
|
||||
(set! (-> gp-0 font) (new 'debug 'font-context *font-default-matrix* 0 0 0.0 0 (the-as uint 3)))
|
||||
(set! (-> gp-0 font) (new 'debug 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (the-as uint 3)))
|
||||
gp-0
|
||||
)
|
||||
)
|
||||
@@ -618,9 +618,9 @@
|
||||
(defun debug-menu-item-submenu-render ((arg0 debug-menu-item-submenu) (arg1 int) (arg2 int) (arg3 int) (arg4 symbol))
|
||||
(let ((s5-0 (-> arg0 parent context font)))
|
||||
(set-origin! s5-0 arg1 arg2)
|
||||
(set! (-> s5-0 color) (cond ((zero? arg3) 12)
|
||||
(arg4 11)
|
||||
(else 13)
|
||||
(set! (-> s5-0 color) (cond ((zero? arg3) (font-color dim-white))
|
||||
(arg4 (font-color dark-light-blue))
|
||||
(else (font-color dim-gray))
|
||||
))
|
||||
(with-dma-buffer-add-bucket ((s3-0 (current-display-frame debug-buf))
|
||||
(current-display-frame bucket-group)
|
||||
@@ -638,17 +638,17 @@
|
||||
(set! (-> v1-2 color) (cond
|
||||
((> (-> arg0 hilite-timer) 0)
|
||||
(1-! (-> arg0 hilite-timer))
|
||||
10
|
||||
(font-color lighter-blue)
|
||||
)
|
||||
((< (-> arg0 hilite-timer) 0)
|
||||
(1+! (-> arg0 hilite-timer))
|
||||
14
|
||||
(font-color orange-red-2)
|
||||
)
|
||||
((nonzero? arg3)
|
||||
13
|
||||
(font-color dim-gray)
|
||||
)
|
||||
(else
|
||||
12
|
||||
(font-color dim-white)
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -666,19 +666,19 @@
|
||||
(set-origin! v1-2 arg1 arg2)
|
||||
(set! (-> v1-2 color) (cond
|
||||
((= (-> arg0 is-on) 'invalid)
|
||||
19
|
||||
(font-color flat-dark-purple)
|
||||
)
|
||||
((-> arg0 is-on)
|
||||
(if (zero? arg3)
|
||||
15
|
||||
16
|
||||
(font-color yellow-green)
|
||||
(font-color dark-green)
|
||||
)
|
||||
)
|
||||
((zero? arg3)
|
||||
17
|
||||
(font-color another-gray)
|
||||
)
|
||||
(else
|
||||
18
|
||||
(font-color dark-dark-green)
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -697,15 +697,15 @@
|
||||
(set! (-> s5-0 color) (cond
|
||||
((zero? arg3)
|
||||
(if (-> arg0 grabbed-joypad-p)
|
||||
10
|
||||
12
|
||||
(font-color lighter-blue)
|
||||
(font-color dim-white)
|
||||
)
|
||||
)
|
||||
(arg4
|
||||
11
|
||||
(font-color dark-light-blue)
|
||||
)
|
||||
(else
|
||||
13
|
||||
(font-color dim-gray)
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -796,8 +796,8 @@
|
||||
(while (not (null? s1-1))
|
||||
(when (= s0-1 arg3)
|
||||
(set! (-> arg0 context font color) (if (nonzero? arg4)
|
||||
13
|
||||
12
|
||||
(font-color dim-gray)
|
||||
(font-color dim-white)
|
||||
)
|
||||
)
|
||||
(set-origin! (-> arg0 context font) s3-1 s2-1)
|
||||
|
||||
@@ -642,7 +642,7 @@
|
||||
(bucket-id debug-draw1)
|
||||
(-> obj name)
|
||||
(-> obj trans)
|
||||
(new 'static 'rgba :r #x1)
|
||||
(font-color white)
|
||||
(new 'static 'vector2h :data (new 'static 'array int16 2 0 8))
|
||||
)
|
||||
(let ((a3-2 (vector-z-quaternion! (new-stack-vector0) (-> obj quat))))
|
||||
|
||||
@@ -1146,7 +1146,7 @@
|
||||
(when *display-deci-count*
|
||||
(let ((s2-1 draw-string-xy))
|
||||
(format (clear *temp-string*) "~D" *deci-count*)
|
||||
(s2-1 *temp-string* debug-buf 448 210 0 3)
|
||||
(s2-1 *temp-string* debug-buf 448 210 (font-color default) 3)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1183,7 +1183,7 @@
|
||||
(if (= *master-mode* 'pause)
|
||||
(draw-string-xy
|
||||
(lookup-text! *common-text* (game-text-id pause) #f)
|
||||
s3-1 256 160 3 39)
|
||||
s3-1 256 160 (font-color orange-red) 39)
|
||||
)
|
||||
|
||||
;; draw console text on screen
|
||||
@@ -1192,7 +1192,7 @@
|
||||
s3-1
|
||||
(the int (-> *font-context* origin x))
|
||||
a3-8
|
||||
0
|
||||
(font-color default)
|
||||
3
|
||||
)
|
||||
)
|
||||
|
||||
@@ -16,6 +16,45 @@
|
||||
;; 16
|
||||
;; 32 (use size 24)
|
||||
|
||||
(defenum font-color
|
||||
:type uint64
|
||||
(default 0)
|
||||
(white 1)
|
||||
(gray 2)
|
||||
(orange-red 3)
|
||||
(bright-orange-red 4)
|
||||
(dark-yellow 5)
|
||||
(bright-green 6)
|
||||
(dark-blue 7)
|
||||
(light-blue 8)
|
||||
(dark-pink 9)
|
||||
(lighter-blue 10)
|
||||
(dark-light-blue 11)
|
||||
(dim-white 12)
|
||||
(dim-gray 13)
|
||||
(orange-red-2 14)
|
||||
(yellow-green 15)
|
||||
(dark-green 16)
|
||||
(another-gray 17)
|
||||
(dark-dark-green 18)
|
||||
(flat-dark-purple 19)
|
||||
(yellow 20)
|
||||
(blue-white 21)
|
||||
(flat-dark-gray 22)
|
||||
(flat-gray 23)
|
||||
(flat-pink 24)
|
||||
(flat-red 25)
|
||||
(flat-green 26)
|
||||
(flat-purple 27)
|
||||
(lighter-lighter-blue 28)
|
||||
(yellow-orange 29)
|
||||
(yellow-green-2 30)
|
||||
(another-light-blue 31)
|
||||
(another-default 32)
|
||||
(red-orange 33)
|
||||
(another-orange-red 34)
|
||||
)
|
||||
|
||||
(deftype char-verts (structure)
|
||||
((pos vector 4 :inline :offset-assert 0)
|
||||
(color vector 4 :inline :offset-assert 64)
|
||||
@@ -51,7 +90,7 @@
|
||||
(height float :offset-assert 52)
|
||||
(projection float :offset-assert 56)
|
||||
(context-vec vector :inline :offset 48) ;; added
|
||||
(color int64 :offset-assert 64)
|
||||
(color font-color :offset-assert 64)
|
||||
(color-s32 int32 :offset 64) ;; added for asm
|
||||
(flags uint32 :offset-assert 72)
|
||||
(flags-signed int32 :offset 72) ;; added for asm
|
||||
@@ -63,7 +102,7 @@
|
||||
:size-assert #x58
|
||||
:flag-assert #x1400000058
|
||||
(:methods
|
||||
(new (symbol type matrix int int float int uint) _type_ 0)
|
||||
(new (symbol type matrix int int float font-color uint) _type_ 0)
|
||||
(set-mat! (font-context matrix) font-context 9)
|
||||
(set-origin! (font-context int int) font-context 10)
|
||||
(set-depth! (font-context int) font-context 11)
|
||||
@@ -71,7 +110,7 @@
|
||||
(set-width! (font-context int) font-context 13)
|
||||
(set-height! (font-context int) font-context 14)
|
||||
(set-projection! (font-context float) font-context 15)
|
||||
(set-color! (font-context int) font-context 16)
|
||||
(set-color! (font-context font-color) font-context 16)
|
||||
(set-flags! (font-context uint) font-context 17)
|
||||
(set-start-line! (font-context uint) font-context 18)
|
||||
(set-scale! (font-context float) font-context 19)
|
||||
@@ -130,7 +169,7 @@
|
||||
obj
|
||||
)
|
||||
|
||||
(defmethod set-color! font-context ((obj font-context) (color int))
|
||||
(defmethod set-color! font-context ((obj font-context) (color font-color))
|
||||
(declare (inline))
|
||||
|
||||
(set! (-> obj color) color)
|
||||
@@ -158,18 +197,7 @@
|
||||
obj
|
||||
)
|
||||
|
||||
(defmethod
|
||||
new
|
||||
font-context
|
||||
((allocation symbol)
|
||||
(type-to-make type)
|
||||
(mat matrix)
|
||||
(x int)
|
||||
(y int)
|
||||
(z float)
|
||||
(color int)
|
||||
(flags uint)
|
||||
)
|
||||
(defmethod new font-context ((allocation symbol) (type-to-make type) (mat matrix) (x int) (y int) (z float) (color font-color) (flags uint))
|
||||
(let
|
||||
((obj
|
||||
(object-new allocation type-to-make (the-as int (-> type-to-make size)))
|
||||
@@ -245,9 +273,9 @@
|
||||
(justify vector 64 :inline :offset-assert 944)
|
||||
(color-shadow vector4w :inline :offset-assert 1968)
|
||||
(color-table char-color 64 :inline :offset-assert 1984)
|
||||
(last-color uint64 :offset-assert 3008)
|
||||
(last-color font-color :offset-assert 3008)
|
||||
(last-color-32 int32 :offset 3008)
|
||||
(save-last-color uint64 :offset-assert 3016)
|
||||
(save-last-color font-color :offset-assert 3016)
|
||||
(save-last-color-32 int32 :offset 3016) ;; added
|
||||
(buf basic :offset-assert 3024)
|
||||
(str-ptr uint32 :offset-assert 3028)
|
||||
@@ -722,4 +750,4 @@
|
||||
|
||||
|
||||
(define-extern draw-string (function string dma-buffer font-context float))
|
||||
|
||||
(define-extern draw-string-xy (function string dma-buffer int int font-color int none))
|
||||
@@ -2231,7 +2231,7 @@
|
||||
)
|
||||
)
|
||||
|
||||
(defun draw-string-xy ((arg0 string) (arg1 dma-buffer) (arg2 int) (arg3 int) (arg4 int) (arg5 int))
|
||||
(defun draw-string-xy ((arg0 string) (arg1 dma-buffer) (arg2 int) (arg3 int) (arg4 font-color) (arg5 int))
|
||||
;(format #t "call to ds: ~A~%" arg0)
|
||||
(let ((a2-2 (new 'stack 'font-context
|
||||
*font-default-matrix*
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
;; name in dgo: display
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
;; todo - move to font-h
|
||||
(define-extern draw-string-xy (function string dma-buffer int int int int none))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; TIME
|
||||
@@ -282,8 +280,8 @@
|
||||
)
|
||||
|
||||
|
||||
(define *font-context* (new 'global 'font-context *font-default-matrix* 0 24 0.0 0 (the uint 3)))
|
||||
(define *pause-context* (new 'global 'font-context *font-default-matrix* 256 170 0.0 3 (the uint 3)))
|
||||
(define *font-context* (new 'global 'font-context *font-default-matrix* 0 24 0.0 (font-color default) (the uint 3)))
|
||||
(define *pause-context* (new 'global 'font-context *font-default-matrix* 256 170 0.0 (font-color orange-red) (the uint 3)))
|
||||
|
||||
|
||||
|
||||
@@ -412,7 +410,7 @@
|
||||
(cond
|
||||
(*profile-ticks*
|
||||
(draw-string-xy (string-format "~5D" (-> worst-time-cache (/ bar-pos 10)))
|
||||
buf 488 (+ bar-pos 8) 0 17)
|
||||
buf 488 (+ bar-pos 8) (font-color default) 17)
|
||||
(the float (-> worst-time-cache (/ bar-pos 10)))
|
||||
)
|
||||
(else
|
||||
@@ -424,7 +422,7 @@
|
||||
(the float *ticks-per-frame*)
|
||||
)))
|
||||
(draw-string-xy (string-format "~5,,2f" f30-0) buf 488 (+ bar-pos 8)
|
||||
(if (>= f30-0 100.0) 3 0) ;; turn red if over 100.
|
||||
(if (>= f30-0 100.0) (font-color orange-red) (font-color default)) ;; turn red if over 100.
|
||||
17
|
||||
)
|
||||
f30-0
|
||||
|
||||
@@ -5,3 +5,426 @@
|
||||
;; name in dgo: sprite-distort
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
;; The sprite-distort is a VU1 renderer.
|
||||
;; It likely does some of the effects with sprites.
|
||||
|
||||
;; Scratch information used by the sprite-distorter.
|
||||
(deftype sprite-distorter-sine-tables (basic)
|
||||
((aspx float :offset-assert 4)
|
||||
(aspy float :offset-assert 8)
|
||||
(entry vector 128 :inline :offset-assert 16)
|
||||
(ientry qword 9 :inline :offset-assert 2064)
|
||||
(giftag gs-gif-tag :inline :offset-assert 2208)
|
||||
(color qword :inline :offset-assert 2224)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x8c0
|
||||
:flag-assert #x9000008c0
|
||||
)
|
||||
|
||||
(define *sprite-distorter-sine-tables* (new 'global 'sprite-distorter-sine-tables))
|
||||
|
||||
(defun sprite-distorter-generate-tables ()
|
||||
"Regenerate sprite-distorter tables. This should be done whenever the aspect ratio changes"
|
||||
(let ((gp-0 *sprite-distorter-sine-tables*))
|
||||
(let ((s3-0 0)
|
||||
(s5-0 0)
|
||||
(s4-0 3)
|
||||
(f28-0 (- (-> *math-camera* perspective vector 0 x)))
|
||||
(f30-0 (- (-> *math-camera* perspective vector 1 y)))
|
||||
)
|
||||
(when (or (!= f28-0 (-> gp-0 aspx)) (!= f30-0 (-> gp-0 aspy)))
|
||||
(set! (-> gp-0 aspx) f28-0)
|
||||
(set! (-> gp-0 aspy) f30-0)
|
||||
(while (< s4-0 12)
|
||||
(set! (-> gp-0 ientry s5-0 vector4w x) (+ s3-0 352))
|
||||
(+! s5-0 1)
|
||||
(dotimes (s2-0 s4-0)
|
||||
(let ((f26-0 (* 65536.0 (/ (the float s2-0) (the float s4-0)))))
|
||||
(set-vector!
|
||||
(-> gp-0 entry s3-0)
|
||||
(* (sin f26-0) f28-0)
|
||||
(* (cos f26-0) f30-0)
|
||||
0.0
|
||||
0.0
|
||||
)
|
||||
(let ((s3-1 (+ s3-0 1)))
|
||||
(set-vector!
|
||||
(-> gp-0 entry s3-1)
|
||||
(* (* 0.001953125 f28-0) (sin f26-0))
|
||||
(* (* 0.00390625 f30-0) (cos f26-0))
|
||||
0.0
|
||||
0.0
|
||||
)
|
||||
(set! s3-0 (+ s3-1 1))
|
||||
)
|
||||
)
|
||||
)
|
||||
(+! s4-0 1)
|
||||
)
|
||||
(set-vector! (-> gp-0 entry s3-0) 0.0 f30-0 0.0 0.0)
|
||||
(let ((v1-17 (+ s3-0 1)))
|
||||
(set-vector! (-> gp-0 entry v1-17) 0.0 (* 0.00390625 f30-0) 0.0 0.0)
|
||||
(+ v1-17 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set! (-> gp-0 giftag tag)
|
||||
(new 'static 'gif-tag64
|
||||
:nloop #x1
|
||||
:eop #x1
|
||||
:pre #x1
|
||||
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :tme #x1)
|
||||
:nreg #xf
|
||||
)
|
||||
)
|
||||
(set! (-> gp-0 giftag regs)
|
||||
(new 'static 'gif-tag-regs
|
||||
:regs0 (gif-reg-id st)
|
||||
:regs1 (gif-reg-id rgbaq)
|
||||
:regs2 (gif-reg-id xyzf2)
|
||||
:regs3 (gif-reg-id st)
|
||||
:regs4 (gif-reg-id rgbaq)
|
||||
:regs5 (gif-reg-id xyzf2)
|
||||
:regs6 (gif-reg-id st)
|
||||
:regs7 (gif-reg-id rgbaq)
|
||||
:regs8 (gif-reg-id xyzf2)
|
||||
:regs9 (gif-reg-id st)
|
||||
:regs10 (gif-reg-id rgbaq)
|
||||
:regs11 (gif-reg-id xyzf2)
|
||||
:regs12 (gif-reg-id st)
|
||||
:regs13 (gif-reg-id rgbaq)
|
||||
:regs14 (gif-reg-id xyzf2)
|
||||
)
|
||||
)
|
||||
(set! (-> gp-0 color vector4w x) 128)
|
||||
(set! (-> gp-0 color vector4w y) 128)
|
||||
(set! (-> gp-0 color vector4w z) 128)
|
||||
(set! (-> gp-0 color vector4w w) 128)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
|
||||
;; TODO
|
||||
(define sprite-distort-vu1-block (the-as vu-function 0))
|
||||
|
||||
|
||||
(defun sprite-init-distorter ((arg0 dma-buffer) (arg1 uint))
|
||||
"Set up DMA for setting up the sprite-distorter renderer"
|
||||
(let* ((v1-0 arg0)
|
||||
(a2-0 (the-as object (-> v1-0 base)))
|
||||
)
|
||||
(set! (-> (the-as dma-packet a2-0) dma) (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)))
|
||||
(set! (-> (the-as dma-packet a2-0) vif0) (new 'static 'vif-tag))
|
||||
(set! (-> (the-as dma-packet a2-0) vif1) (new 'static 'vif-tag :imm #x7 :cmd (vif-cmd direct) :msk #x1))
|
||||
(set! (-> v1-0 base) (&+ (the-as pointer a2-0) 16))
|
||||
)
|
||||
(let* ((v1-1 arg0)
|
||||
(a2-2 (the-as object (-> v1-1 base)))
|
||||
)
|
||||
(set! (-> (the-as gs-gif-tag a2-2) tag)
|
||||
(new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x6)
|
||||
)
|
||||
(set! (-> (the-as gs-gif-tag a2-2) regs)
|
||||
(new 'static 'gif-tag-regs
|
||||
:regs0 (gif-reg-id a+d)
|
||||
:regs1 (gif-reg-id a+d)
|
||||
:regs2 (gif-reg-id a+d)
|
||||
:regs3 (gif-reg-id a+d)
|
||||
:regs4 (gif-reg-id a+d)
|
||||
:regs5 (gif-reg-id a+d)
|
||||
:regs6 (gif-reg-id a+d)
|
||||
:regs7 (gif-reg-id a+d)
|
||||
:regs8 (gif-reg-id a+d)
|
||||
:regs9 (gif-reg-id a+d)
|
||||
:regs10 (gif-reg-id a+d)
|
||||
:regs11 (gif-reg-id a+d)
|
||||
:regs12 (gif-reg-id a+d)
|
||||
:regs13 (gif-reg-id a+d)
|
||||
:regs14 (gif-reg-id a+d)
|
||||
:regs15 (gif-reg-id a+d)
|
||||
)
|
||||
)
|
||||
(set! (-> v1-1 base) (&+ (the-as pointer a2-2) 16))
|
||||
)
|
||||
(let* ((v1-2 arg0)
|
||||
(a2-4 (-> v1-2 base))
|
||||
)
|
||||
(set! (-> (the-as (pointer gs-zbuf) a2-4) 0)
|
||||
(new 'static 'gs-zbuf :zbp #x1c0 :psm (gs-psm ct24) :zmsk #x1)
|
||||
)
|
||||
(set! (-> (the-as (pointer gs-reg64) a2-4) 1) (gs-reg64 zbuf-1))
|
||||
(set! (-> (the-as (pointer gs-tex0) a2-4) 2)
|
||||
(new 'static 'gs-tex0 :tbw #x8 :tw #x9 :th #x8 :tbp0 (* arg1 32))
|
||||
)
|
||||
(set! (-> (the-as (pointer gs-reg64) a2-4) 3) (gs-reg64 tex0-1))
|
||||
(set! (-> (the-as (pointer gs-tex1) a2-4) 4)
|
||||
(new 'static 'gs-tex1 :mmag #x1 :mmin #x1)
|
||||
)
|
||||
(set! (-> (the-as (pointer gs-reg64) a2-4) 5) (gs-reg64 tex1-1))
|
||||
(set! (-> (the-as (pointer gs-miptbp) a2-4) 6) (new 'static 'gs-miptbp))
|
||||
(set! (-> (the-as (pointer gs-reg64) a2-4) 7) (gs-reg64 miptbp1-1))
|
||||
(set! (-> (the-as (pointer gs-clamp) a2-4) 8)
|
||||
(new 'static 'gs-clamp
|
||||
:wms (gs-tex-wrap-mode region-clamp)
|
||||
:wmt (gs-tex-wrap-mode region-clamp)
|
||||
:maxu #x1ff
|
||||
:maxv (-> *video-parms* screen-masky)
|
||||
)
|
||||
)
|
||||
(set! (-> (the-as (pointer gs-reg64) a2-4) 9) (gs-reg64 clamp-1))
|
||||
(set! (-> (the-as (pointer gs-alpha) a2-4) 10)
|
||||
(new 'static 'gs-alpha :b #x1 :d #x1)
|
||||
)
|
||||
(set! (-> (the-as (pointer gs-reg64) a2-4) 11) (gs-reg64 alpha-1))
|
||||
(set! (-> v1-2 base) (&+ a2-4 96))
|
||||
)
|
||||
(let* ((v1-3 arg0)
|
||||
(a1-15 (the-as object (-> v1-3 base)))
|
||||
)
|
||||
(set! (-> (the-as dma-packet a1-15) dma)
|
||||
(new 'static 'dma-tag
|
||||
:qwc #x8b
|
||||
:id (dma-tag-id ref)
|
||||
:addr (the-as uint (-> *sprite-distorter-sine-tables* entry))
|
||||
)
|
||||
)
|
||||
(set! (-> (the-as dma-packet a1-15) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
|
||||
(set! (-> (the-as dma-packet a1-15) vif1) (new 'static 'vif-tag :imm #x160 :num #x8b :cmd (vif-cmd unpack-v4-32)))
|
||||
(set! (-> v1-3 base) (&+ (the-as pointer a1-15) 16))
|
||||
)
|
||||
(dma-buffer-add-vu-function arg0 sprite-distort-vu1-block 1)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun sprite-draw-distorters ((arg0 dma-buffer))
|
||||
"Set up DMA for the sprite-distorter renderer"
|
||||
(local-vars
|
||||
(v1-25 int)
|
||||
(sv-16 sprite-vec-data-2d)
|
||||
(sv-32 pointer)
|
||||
(sv-48 pointer)
|
||||
)
|
||||
(rlet ((acc :class vf)
|
||||
(Q :class vf)
|
||||
(vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf10 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
(vf4 :class vf)
|
||||
(vf5 :class vf)
|
||||
(vf6 :class vf)
|
||||
(vf8 :class vf)
|
||||
(vf9 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.lvf vf8 (&-> *math-camera* hmge-scale quad))
|
||||
(let ((s0-0 (-> arg0 base))
|
||||
(s4-0 0)
|
||||
(s5-0 0)
|
||||
)
|
||||
(&+! (-> arg0 base) 16)
|
||||
(let* ((s3-0 *sprite-aux-list*)
|
||||
(s2-0 (-> s3-0 entry))
|
||||
)
|
||||
(dotimes (s1-0 s2-0)
|
||||
(set! sv-16 (-> s3-0 data s1-0))
|
||||
(let ((a0-1 (the-as object (-> arg0 base))))
|
||||
(set! sv-32 (&+ (the-as pointer a0-1) 16))
|
||||
(set! sv-48 (&+ (the-as pointer a0-1) 32))
|
||||
(cond
|
||||
((= (-> sv-16 matrix) 1)
|
||||
(.lvf vf3 (&-> *math-camera* sprite-2d vector 0 quad))
|
||||
(.lvf vf4 (&-> *math-camera* sprite-2d vector 1 quad))
|
||||
(.lvf vf5 (&-> *math-camera* sprite-2d vector 2 quad))
|
||||
(.lvf vf6 (&-> *math-camera* sprite-2d vector 3 quad))
|
||||
(.lvf vf9 (&-> *math-camera* sprite-2d-hvdf quad))
|
||||
)
|
||||
(else
|
||||
(.lvf vf3 (&-> *math-camera* camera-temp vector 0 quad))
|
||||
(.lvf vf4 (&-> *math-camera* camera-temp vector 1 quad))
|
||||
(.lvf vf5 (&-> *math-camera* camera-temp vector 2 quad))
|
||||
(.lvf vf6 (&-> *math-camera* camera-temp vector 3 quad))
|
||||
(.lvf vf9 (&-> *math-camera* hvdf-off quad))
|
||||
)
|
||||
)
|
||||
(.lvf vf1 (&-> sv-16 x-y-z-sx quad))
|
||||
(.lvf vf2 (&-> sv-16 color quad))
|
||||
(.mul.w.vf acc vf6 vf0)
|
||||
(.add.mul.x.vf acc vf3 vf1 acc)
|
||||
(.add.mul.y.vf acc vf4 vf1 acc)
|
||||
(.add.mul.z.vf vf1 vf5 vf1 acc)
|
||||
(.mul.vf vf10 vf1 vf8)
|
||||
(.div.vf Q vf0 vf10 :fsf #b11 :ftf #b11)
|
||||
;;(TODO.VCLIP vf10 vf10)
|
||||
(b! (zero? (-> sv-16 flag)) cfg-21)
|
||||
(.wait.vf)
|
||||
(.mul.vf vf1 vf1 Q :mask #b111)
|
||||
(.mul.vf vf2 vf2 Q :mask #b111)
|
||||
;;(.cfc2.i v1-25 Clipping)
|
||||
(set! v1-25 (vu-clip vf10 0)) ;; safe to just drop the higher bits.
|
||||
(b! (logtest? v1-25 63) cfg-21 :delay (.add.vf vf1 vf1 vf9))
|
||||
(.max.x.vf vf1 vf1 vf0 :mask #b1000)
|
||||
(.svf (&-> (the-as vector a0-1) quad) vf1)
|
||||
(.svf (&-> (the-as vector sv-48) quad) vf2)
|
||||
(set! (-> (the-as vector a0-1) w) 255.0)
|
||||
(set! (-> (the-as (pointer float) sv-32)) (* 0.001953125 (+ -1792.0 (-> (the-as vector a0-1) x))))
|
||||
(set! (-> (the-as vector sv-32) y)
|
||||
(* 0.00390625
|
||||
(+ (+ -2048.0 (the float (-> *video-parms* screen-hy)))
|
||||
(-> (the-as vector a0-1) y)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set! (-> (the-as vector sv-32) z) 1.0)
|
||||
(when (or (< (-> sv-16 flag) 3) (< 11 (-> sv-16 flag)))
|
||||
(format 0 "Turns = ~D!!!~%" (-> sv-16 flag))
|
||||
(set! (-> (the-as (pointer int32) sv-16) 4) 11)
|
||||
)
|
||||
(set! (-> (the-as (pointer int32) sv-32) 3) (-> sv-16 flag))
|
||||
(let* ((f0-7 (- (-> *math-camera* perspective vector 1 y)))
|
||||
(f2-4 (-> (the-as vector sv-32) y))
|
||||
(f4-0 (+ f2-4 (* (-> (the-as (pointer float) sv-48)) f0-7)))
|
||||
(f3-0 256.0)
|
||||
(f1-7 (-> (the-as (pointer float) sv-48)))
|
||||
)
|
||||
(if (< (the float (-> *video-parms* screen-sy)) f4-0)
|
||||
(set! f3-0 (/ (- (the float (-> *video-parms* screen-sy)) f2-4) f0-7))
|
||||
)
|
||||
(if (< 128.0 f3-0)
|
||||
(set! f3-0 128.0)
|
||||
)
|
||||
(when (< f3-0 f1-7)
|
||||
(let ((v1-55 (/ f3-0 f1-7)))
|
||||
(.mov vf1 v1-55)
|
||||
)
|
||||
(.mul.x.vf vf2 vf2 vf1)
|
||||
(.svf (&-> (the-as vector sv-48) quad) vf2)
|
||||
)
|
||||
)
|
||||
(&+! (-> arg0 base) 48)
|
||||
(+! s4-0 1)
|
||||
(when (= s4-0 85)
|
||||
(let ((v1-62 (-> arg0 base)))
|
||||
(set! (-> arg0 base) s0-0)
|
||||
(let* ((a0-8 arg0)
|
||||
(a1-3 (the-as object (-> a0-8 base)))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet a1-3) dma)
|
||||
(new 'static 'dma-tag :id (dma-tag-id cnt) :qwc (* 3 s4-0))
|
||||
)
|
||||
(set! (-> (the-as dma-packet a1-3) vif0) (new 'static 'vif-tag))
|
||||
(set!
|
||||
(-> (the-as dma-packet a1-3) vif1)
|
||||
(new 'static 'vif-tag
|
||||
:cmd (vif-cmd unpack-v4-32)
|
||||
:imm (shr (shl (+ (* 3 s5-0) 512) 54) 54)
|
||||
:num (* 3 s4-0)
|
||||
)
|
||||
)
|
||||
(set! (-> a0-8 base) (&+ (the-as pointer a1-3) 16))
|
||||
)
|
||||
(set! (-> arg0 base) v1-62)
|
||||
)
|
||||
(set! s4-0 0)
|
||||
(+! s5-0 85)
|
||||
(when (= s5-0 170)
|
||||
(let* ((v1-65 arg0)
|
||||
(a0-9 (the-as object (-> v1-65 base)))
|
||||
)
|
||||
(set! (-> (the-as dma-packet a0-9) dma) (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt)))
|
||||
(set! (-> (the-as dma-packet a0-9) vif0) (new 'static 'vif-tag))
|
||||
(set! (-> (the-as dma-packet a0-9) vif1) (new 'static 'vif-tag :imm #x1ff :num #x1 :cmd (vif-cmd unpack-v4-32)))
|
||||
(set! (-> v1-65 base) (&+ (the-as pointer a0-9) 16))
|
||||
)
|
||||
(let* ((v1-66 arg0)
|
||||
(a0-11 (the-as object (-> v1-66 base)))
|
||||
)
|
||||
(set! (-> (the-as vector4w a0-11) x) s5-0)
|
||||
(set! (-> (the-as vector4w a0-11) y) 0)
|
||||
(set! (-> (the-as vector4w a0-11) z) 0)
|
||||
(set! (-> (the-as vector4w a0-11) w) 0)
|
||||
(set! (-> v1-66 base) (&+ (the-as pointer a0-11) 16))
|
||||
)
|
||||
(let* ((v1-67 arg0)
|
||||
(a0-13 (the-as object (-> v1-67 base)))
|
||||
)
|
||||
(set! (-> (the-as dma-packet a0-13) dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
|
||||
(set! (-> (the-as dma-packet a0-13) vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1))
|
||||
(set! (-> (the-as dma-packet a0-13) vif1) (new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1))
|
||||
(set! (-> v1-67 base) (&+ (the-as pointer a0-13) 16))
|
||||
)
|
||||
(set! s5-0 0)
|
||||
)
|
||||
(set! s0-0 (-> arg0 base))
|
||||
(&+! (-> arg0 base) 16)
|
||||
)
|
||||
(label cfg-21)
|
||||
)
|
||||
)
|
||||
(cond
|
||||
((zero? s4-0)
|
||||
(set! (-> arg0 base) s0-0)
|
||||
(nop!)
|
||||
0
|
||||
)
|
||||
(else
|
||||
(let ((v1-74 (-> arg0 base)))
|
||||
(set! (-> arg0 base) s0-0)
|
||||
(let* ((a0-15 arg0)
|
||||
(a1-10 (the-as object (-> a0-15 base)))
|
||||
)
|
||||
(set! (-> (the-as dma-packet a1-10) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc (* 3 s4-0)))
|
||||
(set! (-> (the-as dma-packet a1-10) vif0) (new 'static 'vif-tag))
|
||||
(set! (-> (the-as dma-packet a1-10) vif1)
|
||||
(new 'static 'vif-tag
|
||||
:cmd (vif-cmd unpack-v4-32)
|
||||
:imm (shr (shl (+ (* 3 s5-0) 512) 54) 54)
|
||||
:num (* 3 s4-0)
|
||||
)
|
||||
)
|
||||
(set! (-> a0-15 base) (&+ (the-as pointer a1-10) 16))
|
||||
)
|
||||
(set! (-> arg0 base) v1-74)
|
||||
)
|
||||
)
|
||||
)
|
||||
(let ((v1-75 (+ s4-0 s5-0)))
|
||||
(when (nonzero? v1-75)
|
||||
(let* ((a0-17 arg0)
|
||||
(a1-12 (the-as object (-> a0-17 base)))
|
||||
)
|
||||
(set! (-> (the-as dma-packet a1-12) dma) (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt)))
|
||||
(set! (-> (the-as dma-packet a1-12) vif0) (new 'static 'vif-tag))
|
||||
(set! (-> (the-as dma-packet a1-12) vif1) (new 'static 'vif-tag :imm #x1ff :num #x1 :cmd (vif-cmd unpack-v4-32)))
|
||||
(set! (-> a0-17 base) (&+ (the-as pointer a1-12) 16))
|
||||
)
|
||||
(let* ((a0-18 arg0)
|
||||
(a1-14 (the-as object (-> a0-18 base)))
|
||||
)
|
||||
(set! (-> (the-as vector4w a1-14) x) v1-75)
|
||||
(set! (-> (the-as vector4w a1-14) y) 0)
|
||||
(set! (-> (the-as vector4w a1-14) z) 0)
|
||||
(set! (-> (the-as vector4w a1-14) w) 0)
|
||||
(set! (-> a0-18 base) (&+ (the-as pointer a1-14) 16))
|
||||
)
|
||||
(let ((v1-77 (the-as object (-> arg0 base))))
|
||||
(set! (-> (the-as dma-packet v1-77) dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
|
||||
(set! (-> (the-as dma-packet v1-77) vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1))
|
||||
(set! (-> (the-as dma-packet v1-77) vif1) (new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1))
|
||||
(set! (-> arg0 base) (&+ (the-as pointer v1-77) 16))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
(the-as bucket-id s3-0)
|
||||
*temp-string*
|
||||
(-> obj process root trans)
|
||||
(new 'static 'rgba :r #x3)
|
||||
(font-color orange-red)
|
||||
(the-as vector2h #f)
|
||||
)
|
||||
)
|
||||
@@ -77,7 +77,7 @@
|
||||
(the-as bucket-id s1-0)
|
||||
*temp-string*
|
||||
s4-1
|
||||
(new 'static 'rgba :r #x4)
|
||||
(font-color bright-orange-red)
|
||||
(the-as vector2h #f)
|
||||
)
|
||||
)
|
||||
@@ -403,7 +403,7 @@
|
||||
(the-as bucket-id s3-0)
|
||||
*temp-string*
|
||||
(-> obj process root trans)
|
||||
(new 'static 'rgba :r #x3)
|
||||
(font-color orange-red)
|
||||
(the-as vector2h #f)
|
||||
)
|
||||
)
|
||||
@@ -449,7 +449,7 @@
|
||||
(the-as bucket-id s1-0)
|
||||
*temp-string*
|
||||
s4-1
|
||||
(new 'static 'rgba :r #x4)
|
||||
(font-color bright-orange-red)
|
||||
(the-as vector2h #f)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(draw-string-xy *temp-string* dma-buf 32 (+ (* 12 slot-idx) 8) 3 1)
|
||||
(draw-string-xy *temp-string* dma-buf 32 (+ (* 12 slot-idx) 8) (font-color orange-red) 1)
|
||||
)
|
||||
)
|
||||
(none)
|
||||
|
||||
@@ -734,12 +734,12 @@
|
||||
(dotimes (ch 24)
|
||||
(draw-string-xy
|
||||
(if (zero? (-> *sound-iop-info* chinfo ch)) "." "X")
|
||||
buf (+ (* ch 16) 16) 48 0 1)
|
||||
buf (+ (* ch 16) 16) 48 (font-color default) 1)
|
||||
)
|
||||
(dotimes (ch 24)
|
||||
(draw-string-xy
|
||||
(if (zero? (-> *sound-iop-info* chinfo (+ ch 24))) "." "X")
|
||||
buf (+ (* ch 16) 16) 64 0 1)
|
||||
buf (+ (* ch 16) 16) 64 (font-color default) 1)
|
||||
)
|
||||
0
|
||||
)
|
||||
@@ -748,11 +748,11 @@
|
||||
(draw-string-xy
|
||||
(string-format "~8D [~4D]" (-> *sound-iop-info* freemem)
|
||||
(shr (-> *sound-iop-info* freemem) 10))
|
||||
buf 32 96 0 1)
|
||||
buf 32 96 (font-color default) 1)
|
||||
(draw-string-xy
|
||||
(string-format "~8D [~4D]" (-> *sound-iop-info* freemem2)
|
||||
(shr (-> *sound-iop-info* freemem2) 10))
|
||||
buf 32 64 0 1)
|
||||
buf 32 64 (font-color default) 1)
|
||||
0
|
||||
)
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
0
|
||||
0
|
||||
0.0
|
||||
0
|
||||
(font-color default)
|
||||
(the-as uint 3)
|
||||
)
|
||||
)
|
||||
@@ -137,7 +137,7 @@
|
||||
(gp-0 2815)
|
||||
(s3-0 0)
|
||||
(s2-0 #t)
|
||||
(s5-0 (new 'stack 'font-context *font-default-matrix* 31 0 0.0 0 (the-as uint 3)))
|
||||
(s5-0 (new 'stack 'font-context *font-default-matrix* 31 0 0.0 (font-color default) (the-as uint 3)))
|
||||
)
|
||||
(let ((v1-2 s5-0))
|
||||
(set! (-> v1-2 width) (the float 450))
|
||||
|
||||
@@ -357,7 +357,7 @@
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun set-font-color-alpha ((idx int) (alpha int))
|
||||
(defun set-font-color-alpha ((idx font-color) (alpha int))
|
||||
"Set the alpha for a given color index"
|
||||
(set! (-> *font-work* color-table idx color 0 a) alpha)
|
||||
(set! (-> *font-work* color-table idx color 1 a) alpha)
|
||||
@@ -436,7 +436,7 @@
|
||||
(the int (-> font-ctxt origin x))
|
||||
(the int (-> font-ctxt origin y))
|
||||
0.0
|
||||
0
|
||||
(font-color default)
|
||||
(the-as uint 3)
|
||||
)
|
||||
)
|
||||
@@ -603,7 +603,7 @@
|
||||
(set-font-color-alpha (-> font-ctxt color) offset-thing)
|
||||
(draw-string *game-text-line* s1-1 gp-0)
|
||||
(set-font-color-alpha (-> font-ctxt color) 128)
|
||||
(set! (-> gp-0 color) (the-as int (-> *font-work* last-color)))
|
||||
(set! (-> gp-0 color) (-> *font-work* last-color))
|
||||
(let ((a3-3 (-> s1-1 base)))
|
||||
(let ((v1-127 (the-as object (-> s1-1 base))))
|
||||
(set!
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
;; This file demonstrates how to use the debug draw.
|
||||
|
||||
;; To run this:
|
||||
|
||||
#|
|
||||
(make-group "iso") ;; build the game
|
||||
(lt) ;; connect to the runtime
|
||||
(lg) ;; have the runtime load the game engine
|
||||
(test-play) ;; start the game loop
|
||||
(ml "goal_src/examples/debug-draw-example.gc") ;; build and load this file.
|
||||
|#
|
||||
|
||||
(defun hack-update-camera ((location vector) (inv-rot matrix))
|
||||
"Debugging function to set the camera's position and orientation"
|
||||
;; update to compute the perspective matrix.
|
||||
(update-math-camera
|
||||
*math-camera*
|
||||
(-> *setting-control* current video-mode)
|
||||
(-> *setting-control* current aspect-ratio)
|
||||
)
|
||||
|
||||
;; copy the input rotation
|
||||
(matrix-copy! (-> *math-camera* inv-camera-rot) inv-rot)
|
||||
;; inverse of rotation matrix matrix is its transpose
|
||||
(matrix-transpose! (-> *math-camera* camera-rot) (-> *math-camera* inv-camera-rot))
|
||||
|
||||
;; fake some value here
|
||||
(set! (-> *math-camera* fov-correction-factor) 1.0)
|
||||
|
||||
;; do the math
|
||||
(set! (-> *math-camera* trans quad) (-> location quad))
|
||||
(let ((cam-temp (-> *math-camera* camera-temp))
|
||||
(cam-rot (-> *math-camera* camera-rot))
|
||||
(inv-cam-rot (-> *math-camera* inv-camera-rot))
|
||||
(cam-trans (-> *math-camera* trans))
|
||||
)
|
||||
(let ((rotated-trans (new-stack-vector0)))
|
||||
(set! (-> rotated-trans x) (- (-> cam-trans x)))
|
||||
(set! (-> rotated-trans y) (- (-> cam-trans y)))
|
||||
(set! (-> rotated-trans z) (- (-> cam-trans z)))
|
||||
(set! (-> rotated-trans w) 1.0)
|
||||
(vector-matrix*! rotated-trans rotated-trans cam-rot)
|
||||
(set! (-> cam-rot vector 3 quad) (-> rotated-trans quad))
|
||||
)
|
||||
(matrix*! cam-temp cam-rot (-> *math-camera* perspective))
|
||||
(set! (-> inv-cam-rot vector 3 quad) (-> cam-trans quad))
|
||||
)
|
||||
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun test-function ((iter int))
|
||||
"This function draws the debug stuff. You can edit this, then reload this file to play with it."
|
||||
|
||||
;; val will increase from 0 to 1, then reset back to 0.
|
||||
(let* ((frame (the float (mod (* 4 iter) 1600)))
|
||||
(val (/ frame 1600.0)))
|
||||
(format *stdcon* "~0kval ~f~%" val)
|
||||
|
||||
;; orbit the camera around in a circle with radius 5 m.
|
||||
(let* ((rad (meters 5.0))
|
||||
(x (* rad (sin (* (degrees 360.0) val))))
|
||||
(z (* rad (cos (* (degrees 360.0) val))))
|
||||
(cam-pos (new 'stack 'vector))
|
||||
(cam-inv-rot (new 'stack 'matrix))
|
||||
)
|
||||
;; this matrix will look directly at the origin...
|
||||
(set! (-> cam-pos x) x)
|
||||
(set! (-> cam-pos z) z)
|
||||
(set! (-> cam-pos y) (meters 2.))
|
||||
(forward-down->inv-matrix cam-inv-rot cam-pos (new 'static 'vector :y 1.0))
|
||||
|
||||
;; if the camera is here.
|
||||
(set! (-> cam-pos x) (- 0. x))
|
||||
(set! (-> cam-pos z) (- 0. z))
|
||||
(set! (-> cam-pos y) (meters -2.))
|
||||
(hack-update-camera cam-pos cam-inv-rot)
|
||||
|
||||
|
||||
;; create some test points
|
||||
(let ((p0 (new 'static 'vector :x (meters .8) :y (meters .2) :z (meters 2.0)))
|
||||
(p1 (new 'static 'vector :x (meters .3) :y (meters .3) :z (meters 2.5)))
|
||||
(p2 (new 'static 'vector :x (meters .5) :y (meters .7) :z (meters 1.5)))
|
||||
)
|
||||
|
||||
;;(add-debug-point #t (bucket-id debug-draw0) (new 'static 'vector))
|
||||
(add-debug-x #t (bucket-id debug-draw0) (new 'static 'vector) (new 'static 'rgba :g #x80 :a #x80))
|
||||
(add-debug-box #t (bucket-id debug-draw0) p0 p2 (new 'static 'rgba :b #x80 :a #x80))
|
||||
(add-debug-flat-triangle #t (bucket-id debug-draw0) p0 p1 p2 (new 'static 'rgba :r #x80))
|
||||
(add-debug-text-3d #t (bucket-id debug-draw0) "triangle!" p0 (font-color yellow-green) (the vector2h #f))
|
||||
(add-debug-sphere #t (bucket-id debug-draw0) p2 (meters 0.5) (new 'static 'rgba :r #x80))
|
||||
)
|
||||
)
|
||||
|
||||
;; these also work
|
||||
;; (draw-end-credits (the int frame))
|
||||
;; (draw-title-credits val)
|
||||
|
||||
)
|
||||
(none)
|
||||
)
|
||||
|
||||
|
||||
(defun launch-test-process ()
|
||||
"Call this to launch a process that draws the debug demo"
|
||||
(let ((proc (get-process *nk-dead-pool* process 1024)))
|
||||
(activate proc *active-pool* 'test *kernel-dram-stack*)
|
||||
(run-next-time-in-process proc (lambda ()
|
||||
(let ((iter 0))
|
||||
(while #t
|
||||
(test-function iter)
|
||||
(suspend)
|
||||
(+! iter 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
proc)
|
||||
|
||||
)
|
||||
|
||||
;; This will spawn a process the first time this file is loaded
|
||||
(define-perm *test-process* process (launch-test-process))
|
||||
|
||||
(defun kill-test-procs ()
|
||||
"Kill all processes started by launch-test-process"
|
||||
(kill-by-name "test" *active-pool*)
|
||||
)
|
||||
|
||||
(set! *display-profile* #t)
|
||||
@@ -107,7 +107,9 @@ bool Debugger::attach_and_break() {
|
||||
m_continue_info.subtract_1 = false;
|
||||
|
||||
// this may fail if you crash at exactly the wrong time. todo - remove?
|
||||
assert(info.kind == xdbg::SignalInfo::BREAK);
|
||||
if (info.kind != xdbg::SignalInfo::BREAK) {
|
||||
fmt::print("[Debugger] got signal {} when expecting break.\n", (int)info.kind);
|
||||
}
|
||||
|
||||
// open the memory of the process
|
||||
if (!xdbg::open_memory(m_debug_context.tid, &m_memory_handle)) {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extensions":
|
||||
[
|
||||
"gc"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
%YAML 1.2
|
||||
---
|
||||
# http://www.sublimetext.com/docs/3/syntax.html
|
||||
name: goal
|
||||
file_extensions:
|
||||
- gc
|
||||
scope: source.goal
|
||||
contexts:
|
||||
main:
|
||||
|
||||
# Important keywords for blocks/control flow/etc
|
||||
- match: \b(?i:begin|block|return-from|cond|when|if|unless|let|else|while|rlet|countdown|dotimes)\b
|
||||
scope: keyword.control.goal
|
||||
|
||||
# Less important keywords
|
||||
- match: \b(?i:the-as|the|logior|logand|ash|cons|car|cdr|new|break|none|method-of-type|method-of-object|declare|and|not|suspend|lambda)\b
|
||||
scope: keyword.operator.goal
|
||||
|
||||
# Definition forms like (def thing value)
|
||||
- match: \b(?i:(defun|defmacro|deftype|define|defconstant|defun-debug|define-extern))\b\s+([\w\-!?<>]*)
|
||||
scope: meta.function.goal
|
||||
captures:
|
||||
1: keyword.declaration.function.goal
|
||||
2: entity.name.function.goal
|
||||
|
||||
# Special case for defmethod
|
||||
- match: \b(?i:(defmethod))\b\s+([\w\-!?<>]*)\b\s+([\w\-!?<>]*)
|
||||
scope: meta.function.goal
|
||||
captures:
|
||||
1: keyword.declaration.function.goal
|
||||
2: entity.name.function.goal
|
||||
3: entity.name.class.lisgoalp
|
||||
|
||||
# Special case for set. Need a special case because of the !, and don't want to match reset!
|
||||
- match: \b(?i:set!|neq\?|eq\?|zero\?)
|
||||
scope: keyword.operator.goal
|
||||
|
||||
- match: (?i:->)
|
||||
scope: keyword.operator.goal
|
||||
|
||||
# Quoted symbols. I abuse these as "parameter"
|
||||
- match: (?i:'([\w\-!?<>]+))
|
||||
scope: variable.parameter.goal
|
||||
|
||||
# Block comments
|
||||
- match: '#\|'
|
||||
scope: punctuation.definition.comment.begin.goal
|
||||
push:
|
||||
- meta_scope: comment.block.goal
|
||||
- include: block-comment
|
||||
- match: '\|#'
|
||||
scope: punctuation.definition.comment.end.goal
|
||||
pop: true
|
||||
|
||||
# Normal Comments
|
||||
- match: (;).*$\n?
|
||||
scope: comment.line.semicolon.goal
|
||||
captures:
|
||||
1: punctuation.definition.comment.goal
|
||||
|
||||
# Built-in, numeric type
|
||||
- match: \b(uint128|int128|float|int64|uint64|int32|uint32|int16|uint16|int8|uint8|binteger|int|uint|pointer)\b
|
||||
scope: storage.type
|
||||
|
||||
- match: (?i:#t|#f|'\(\))
|
||||
scope: constant.language.goal
|
||||
|
||||
- match: '(#)(\w|[\\+-=<>''."&#])+'
|
||||
scope: constant.character.goal
|
||||
captures:
|
||||
1: constant.character.goal # change this to change the color of the prefix.
|
||||
|
||||
- match: (\*)(\S*)(\*)
|
||||
scope: variable.function.goal
|
||||
|
||||
- match: :(\S*)
|
||||
scope: variable.function.goal
|
||||
|
||||
|
||||
- match: '"'
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.goal
|
||||
push:
|
||||
- meta_scope: string.quoted.double.goal
|
||||
- match: '"'
|
||||
captures:
|
||||
0: punctuation.definition.string.end.goal
|
||||
pop: true
|
||||
- match: \\.
|
||||
scope: constant.character.escape.goal
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"languages": {
|
||||
"goal": {
|
||||
"detect": ".*\\.(gc)$",
|
||||
"default_indent": "function",
|
||||
"regex":
|
||||
["(with-gensyms|defenum|countdown|while|defglobalconstant|desfun|defsmacro|catch|defvar|defclass|defconstant|defcustom|defparameter|defconst|define-condition|define-modify-macro|",
|
||||
"defsetf|defun|defgeneric|define-setf-method|define-self-expander|defmacro|defsubst|deftype|defmethod|",
|
||||
"defpackage|defstruct|dolist|dotimes|lambda|let|let\\*|prog1|prog2|unless|when)$"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
move the goal.sublime-syntax file to your Packages/User directory. To find this, you can go to Preferences -> Browse Packages -> User.
|
||||
|
||||
To enable the syntax highlighting, set the language to goal. It should show up in the "User" category.
|
||||
|
||||
For formatting, install the lispindent plugin and move the lispindent config file to the same User folder.
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 3 of type debug-vertex-stats
|
||||
;; INFO: this function exists in multiple non-identical object files
|
||||
(defmethod inspect debug-vertex-stats ((obj debug-vertex-stats))
|
||||
(format #t "[~8x] ~A~%" obj (-> obj type))
|
||||
(format #t "~Tlength: ~D~%" (-> obj length))
|
||||
|
||||
+1857
File diff suppressed because it is too large
Load Diff
+72
-58
@@ -51,7 +51,16 @@
|
||||
(set! (-> gp-0 joypad-item) #f)
|
||||
(set!
|
||||
(-> gp-0 font)
|
||||
(new 'debug 'font-context *font-default-matrix* 0 0 0.0 0 (the-as uint 3))
|
||||
(new
|
||||
'debug
|
||||
'font-context
|
||||
*font-default-matrix*
|
||||
0
|
||||
0
|
||||
0.0
|
||||
(font-color default)
|
||||
(the-as uint 3)
|
||||
)
|
||||
)
|
||||
gp-0
|
||||
)
|
||||
@@ -1025,16 +1034,17 @@
|
||||
(set! (-> v1-2 origin x) (the float arg1))
|
||||
(set! (-> v1-2 origin y) (the float a0-1))
|
||||
)
|
||||
(set! (-> s5-0 color) (cond
|
||||
((zero? arg3)
|
||||
12
|
||||
)
|
||||
(arg4
|
||||
11
|
||||
)
|
||||
(else
|
||||
13
|
||||
)
|
||||
(set! (-> s5-0 color) (the-as font-color (cond
|
||||
((zero? arg3)
|
||||
12
|
||||
)
|
||||
(arg4
|
||||
11
|
||||
)
|
||||
(else
|
||||
13
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(let* ((s3-0 (-> *display* frames (-> *display* on-screen) frame debug-buf))
|
||||
@@ -1080,21 +1090,22 @@
|
||||
(set! (-> a0-1 origin x) (the float arg1))
|
||||
(set! (-> a0-1 origin y) (the float a1-1))
|
||||
)
|
||||
(set! (-> v1-2 color) (cond
|
||||
((> (-> arg0 hilite-timer) 0)
|
||||
(+! (-> arg0 hilite-timer) -1)
|
||||
10
|
||||
)
|
||||
((< (-> arg0 hilite-timer) 0)
|
||||
(+! (-> arg0 hilite-timer) 1)
|
||||
14
|
||||
)
|
||||
((nonzero? arg3)
|
||||
13
|
||||
)
|
||||
(else
|
||||
12
|
||||
)
|
||||
(set! (-> v1-2 color) (the-as font-color (cond
|
||||
((> (-> arg0 hilite-timer) 0)
|
||||
(+! (-> arg0 hilite-timer) -1)
|
||||
10
|
||||
)
|
||||
((< (-> arg0 hilite-timer) 0)
|
||||
(+! (-> arg0 hilite-timer) 1)
|
||||
14
|
||||
)
|
||||
((nonzero? arg3)
|
||||
13
|
||||
)
|
||||
(else
|
||||
12
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(let* ((s4-0 (-> *display* frames (-> *display* on-screen) frame debug-buf))
|
||||
@@ -1134,22 +1145,23 @@
|
||||
(set! (-> a0-1 origin x) (the float arg1))
|
||||
(set! (-> a0-1 origin y) (the float a1-1))
|
||||
)
|
||||
(set! (-> v1-2 color) (cond
|
||||
((= (-> arg0 is-on) 'invalid)
|
||||
19
|
||||
)
|
||||
((-> arg0 is-on)
|
||||
(if (zero? arg3)
|
||||
15
|
||||
16
|
||||
)
|
||||
)
|
||||
((zero? arg3)
|
||||
17
|
||||
)
|
||||
(else
|
||||
18
|
||||
)
|
||||
(set! (-> v1-2 color) (the-as font-color (cond
|
||||
((= (-> arg0 is-on) 'invalid)
|
||||
19
|
||||
)
|
||||
((-> arg0 is-on)
|
||||
(if (zero? arg3)
|
||||
15
|
||||
16
|
||||
)
|
||||
)
|
||||
((zero? arg3)
|
||||
17
|
||||
)
|
||||
(else
|
||||
18
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(let* ((s4-0 (-> *display* frames (-> *display* on-screen) frame debug-buf))
|
||||
@@ -1189,19 +1201,20 @@
|
||||
(set! (-> v1-2 origin x) (the float arg1))
|
||||
(set! (-> v1-2 origin y) (the float a0-1))
|
||||
)
|
||||
(set! (-> s5-0 color) (cond
|
||||
((zero? arg3)
|
||||
(if (-> arg0 grabbed-joypad-p)
|
||||
10
|
||||
12
|
||||
)
|
||||
)
|
||||
(arg4
|
||||
11
|
||||
)
|
||||
(else
|
||||
13
|
||||
)
|
||||
(set! (-> s5-0 color) (the-as font-color (cond
|
||||
((zero? arg3)
|
||||
(if (-> arg0 grabbed-joypad-p)
|
||||
10
|
||||
12
|
||||
)
|
||||
)
|
||||
(arg4
|
||||
11
|
||||
)
|
||||
(else
|
||||
13
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(let* ((s1-0 (-> *display* frames (-> *display* on-screen) frame debug-buf))
|
||||
@@ -1364,9 +1377,10 @@
|
||||
)
|
||||
(while (not (null? s1-1))
|
||||
(when (= s0-1 arg3)
|
||||
(set! (-> arg0 context font color) (if (nonzero? arg4)
|
||||
13
|
||||
12
|
||||
(set! (-> arg0 context font color) (the-as font-color (if (nonzero? arg4)
|
||||
13
|
||||
12
|
||||
)
|
||||
)
|
||||
)
|
||||
(let ((v1-16 (-> arg0 context font))
|
||||
|
||||
+1
-1
@@ -608,7 +608,7 @@
|
||||
(if (> (-> arg0 spr) 0)
|
||||
(format arg1 " :spr ~d" (-> arg0 spr))
|
||||
)
|
||||
(if (> (the-as uint (-> arg0 irq)) 0)
|
||||
(if (> (-> arg0 irq) 0)
|
||||
(format arg1 " :irq ~d" (-> arg0 irq))
|
||||
)
|
||||
(if (> (-> arg0 pce) 0)
|
||||
|
||||
+5
-7
@@ -16,11 +16,9 @@
|
||||
;; definition for symbol *camera-engine*, type engine
|
||||
(define *camera-engine* (new 'global 'engine 'camera-eng 128))
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(if *debug-segment*
|
||||
(set! *debug-engine* (new 'debug 'engine 'debug 512))
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; this part is debug only
|
||||
(when *debug-segment*
|
||||
;; definition for symbol *debug-engine*, type engine
|
||||
(define *debug-engine* (new 'debug 'engine 'debug 512))
|
||||
|
||||
)
|
||||
|
||||
+19
-19
@@ -53,25 +53,25 @@
|
||||
|
||||
;; definition of type font-context
|
||||
(deftype font-context (basic)
|
||||
((origin vector :inline :offset-assert 16)
|
||||
(strip-gif vector :inline :offset-assert 32)
|
||||
(width float :offset-assert 48)
|
||||
(height float :offset-assert 52)
|
||||
(projection float :offset-assert 56)
|
||||
(context-vec vector :inline :offset 48)
|
||||
(color int64 :offset-assert 64)
|
||||
(color-s32 int32 :offset 64)
|
||||
(flags uint32 :offset-assert 72)
|
||||
(flags-signed int32 :offset 72)
|
||||
(mat matrix :offset-assert 76)
|
||||
(start-line uint32 :offset-assert 80)
|
||||
(scale float :offset-assert 84)
|
||||
((origin vector :inline :offset-assert 16)
|
||||
(strip-gif vector :inline :offset-assert 32)
|
||||
(width float :offset-assert 48)
|
||||
(height float :offset-assert 52)
|
||||
(projection float :offset-assert 56)
|
||||
(context-vec vector :inline :offset 48)
|
||||
(color font-color :offset-assert 64)
|
||||
(color-s32 int32 :offset 64)
|
||||
(flags uint32 :offset-assert 72)
|
||||
(flags-signed int32 :offset 72)
|
||||
(mat matrix :offset-assert 76)
|
||||
(start-line uint32 :offset-assert 80)
|
||||
(scale float :offset-assert 84)
|
||||
)
|
||||
:method-count-assert 20
|
||||
:size-assert #x58
|
||||
:flag-assert #x1400000058
|
||||
(:methods
|
||||
(new (symbol type matrix int int float int uint) _type_ 0)
|
||||
(new (symbol type matrix int int float font-color uint) _type_ 0)
|
||||
(set-mat! (font-context matrix) font-context 9)
|
||||
(set-origin! (font-context int int) font-context 10)
|
||||
(set-depth! (font-context int) font-context 11)
|
||||
@@ -79,7 +79,7 @@
|
||||
(set-width! (font-context int) font-context 13)
|
||||
(set-height! (font-context int) font-context 14)
|
||||
(set-projection! (font-context float) font-context 15)
|
||||
(set-color! (font-context int) font-context 16)
|
||||
(set-color! (font-context font-color) font-context 16)
|
||||
(set-flags! (font-context uint) font-context 17)
|
||||
(set-start-line! (font-context uint) font-context 18)
|
||||
(set-scale! (font-context float) font-context 19)
|
||||
@@ -146,7 +146,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 16 of type font-context
|
||||
(defmethod set-color! font-context ((obj font-context) (color int))
|
||||
(defmethod set-color! font-context ((obj font-context) (color font-color))
|
||||
(set! (-> obj color) color)
|
||||
obj
|
||||
)
|
||||
@@ -179,7 +179,7 @@
|
||||
(x int)
|
||||
(y int)
|
||||
(z float)
|
||||
(color int)
|
||||
(color font-color)
|
||||
(flags uint)
|
||||
)
|
||||
(let
|
||||
@@ -258,9 +258,9 @@
|
||||
(justify vector 64 :inline :offset-assert 944)
|
||||
(color-shadow vector4w :inline :offset-assert 1968)
|
||||
(color-table char-color 64 :inline :offset-assert 1984)
|
||||
(last-color uint64 :offset-assert 3008)
|
||||
(last-color font-color :offset-assert 3008)
|
||||
(last-color-32 int32 :offset 3008)
|
||||
(save-last-color uint64 :offset-assert 3016)
|
||||
(save-last-color font-color :offset-assert 3016)
|
||||
(save-last-color-32 int32 :offset 3016)
|
||||
(buf basic :offset-assert 3024)
|
||||
(str-ptr uint32 :offset-assert 3028)
|
||||
|
||||
+22
-7
@@ -259,7 +259,16 @@
|
||||
;; definition for symbol *font-context*, type font-context
|
||||
(define
|
||||
*font-context*
|
||||
(new 'global 'font-context *font-default-matrix* 0 24 0.0 0 (the-as uint 3))
|
||||
(new
|
||||
'global
|
||||
'font-context
|
||||
*font-default-matrix*
|
||||
0
|
||||
24
|
||||
0.0
|
||||
(font-color default)
|
||||
(the-as uint 3)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for symbol *pause-context*, type font-context
|
||||
@@ -272,7 +281,7 @@
|
||||
256
|
||||
170
|
||||
0.0
|
||||
3
|
||||
(font-color orange-red)
|
||||
(the-as uint 3)
|
||||
)
|
||||
)
|
||||
@@ -457,7 +466,7 @@
|
||||
(*profile-ticks*
|
||||
(let ((s3-0 draw-string-xy))
|
||||
(format (clear *temp-string*) "~5D" (-> worst-time-cache (/ bar-pos 10)))
|
||||
(s3-0 *temp-string* buf 488 (+ bar-pos 8) 0 17)
|
||||
(s3-0 *temp-string* buf 488 (+ bar-pos 8) (font-color default) 17)
|
||||
)
|
||||
(the float (-> worst-time-cache (/ bar-pos 10)))
|
||||
)
|
||||
@@ -472,10 +481,16 @@
|
||||
)
|
||||
(let ((s4-1 draw-string-xy))
|
||||
(format (clear *temp-string*) "~5,,2f" f30-0)
|
||||
(s4-1 *temp-string* buf 488 (+ bar-pos 8) (if (>= f30-0 100.0)
|
||||
3
|
||||
0
|
||||
)
|
||||
(s4-1
|
||||
*temp-string*
|
||||
buf
|
||||
488
|
||||
(+ bar-pos 8)
|
||||
(the-as font-color (if (>= f30-0 100.0)
|
||||
3
|
||||
0
|
||||
)
|
||||
)
|
||||
17
|
||||
)
|
||||
)
|
||||
|
||||
@@ -0,0 +1,516 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition of type sprite-distorter-sine-tables
|
||||
(deftype sprite-distorter-sine-tables (basic)
|
||||
((aspx float :offset-assert 4)
|
||||
(aspy float :offset-assert 8)
|
||||
(entry vector 128 :inline :offset-assert 16)
|
||||
(ientry qword 9 :inline :offset-assert 2064)
|
||||
(giftag gs-gif-tag :inline :offset-assert 2208)
|
||||
(color qword :inline :offset-assert 2224)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x8c0
|
||||
:flag-assert #x9000008c0
|
||||
)
|
||||
|
||||
;; definition for method 3 of type sprite-distorter-sine-tables
|
||||
(defmethod
|
||||
inspect
|
||||
sprite-distorter-sine-tables
|
||||
((obj sprite-distorter-sine-tables))
|
||||
(format #t "[~8x] ~A~%" obj (-> obj type))
|
||||
(format #t "~Taspx: ~f~%" (-> obj aspx))
|
||||
(format #t "~Taspy: ~f~%" (-> obj aspy))
|
||||
(format #t "~Tentry[128] @ #x~X~%" (-> obj entry))
|
||||
(format #t "~Tientry[9] @ #x~X~%" (-> obj ientry))
|
||||
(format #t "~Tgiftag: #<qword @ #x~X>~%" (-> obj giftag))
|
||||
(format #t "~Tcolor: #<qword @ #x~X>~%" (-> obj color))
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for symbol *sprite-distorter-sine-tables*, type sprite-distorter-sine-tables
|
||||
(define
|
||||
*sprite-distorter-sine-tables*
|
||||
(new 'global 'sprite-distorter-sine-tables)
|
||||
)
|
||||
|
||||
;; definition for function sprite-distorter-generate-tables
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
(defun sprite-distorter-generate-tables ()
|
||||
(let ((gp-0 *sprite-distorter-sine-tables*))
|
||||
(let ((s3-0 0)
|
||||
(s5-0 0)
|
||||
(s4-0 3)
|
||||
(f28-0 (- (-> *math-camera* perspective vector 0 x)))
|
||||
(f30-0 (- (-> *math-camera* perspective vector 1 y)))
|
||||
)
|
||||
(when (or (!= f28-0 (-> gp-0 aspx)) (!= f30-0 (-> gp-0 aspy)))
|
||||
(set! (-> gp-0 aspx) f28-0)
|
||||
(set! (-> gp-0 aspy) f30-0)
|
||||
(while (< s4-0 12)
|
||||
(set! (-> gp-0 ientry s5-0 vector4w x) (+ s3-0 352))
|
||||
(+! s5-0 1)
|
||||
(dotimes (s2-0 s4-0)
|
||||
(let ((f26-0 (* 65536.0 (/ (the float s2-0) (the float s4-0)))))
|
||||
(set-vector!
|
||||
(-> gp-0 entry s3-0)
|
||||
(* (sin f26-0) f28-0)
|
||||
(* (cos f26-0) f30-0)
|
||||
0.0
|
||||
0.0
|
||||
)
|
||||
(let ((s3-1 (+ s3-0 1)))
|
||||
(set-vector!
|
||||
(-> gp-0 entry s3-1)
|
||||
(* (* 0.001953125 f28-0) (sin f26-0))
|
||||
(* (* 0.00390625 f30-0) (cos f26-0))
|
||||
0.0
|
||||
0.0
|
||||
)
|
||||
(set! s3-0 (+ s3-1 1))
|
||||
)
|
||||
)
|
||||
)
|
||||
(+! s4-0 1)
|
||||
)
|
||||
(set-vector! (-> gp-0 entry s3-0) 0.0 f30-0 0.0 0.0)
|
||||
(let ((v1-17 (+ s3-0 1)))
|
||||
(set-vector! (-> gp-0 entry v1-17) 0.0 (* 0.00390625 f30-0) 0.0 0.0)
|
||||
(+ v1-17 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set!
|
||||
(-> gp-0 giftag tag)
|
||||
(new 'static 'gif-tag64
|
||||
:nloop #x1
|
||||
:eop #x1
|
||||
:pre #x1
|
||||
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :tme #x1)
|
||||
:nreg #xf
|
||||
)
|
||||
)
|
||||
(set!
|
||||
(-> gp-0 giftag regs)
|
||||
(new 'static 'gif-tag-regs
|
||||
:regs0 (gif-reg-id st)
|
||||
:regs1 (gif-reg-id rgbaq)
|
||||
:regs2 (gif-reg-id xyzf2)
|
||||
:regs3 (gif-reg-id st)
|
||||
:regs4 (gif-reg-id rgbaq)
|
||||
:regs5 (gif-reg-id xyzf2)
|
||||
:regs6 (gif-reg-id st)
|
||||
:regs7 (gif-reg-id rgbaq)
|
||||
:regs8 (gif-reg-id xyzf2)
|
||||
:regs9 (gif-reg-id st)
|
||||
:regs10 (gif-reg-id rgbaq)
|
||||
:regs11 (gif-reg-id xyzf2)
|
||||
:regs12 (gif-reg-id st)
|
||||
:regs13 (gif-reg-id rgbaq)
|
||||
:regs14 (gif-reg-id xyzf2)
|
||||
)
|
||||
)
|
||||
(set! (-> gp-0 color vector4w x) 128)
|
||||
(set! (-> gp-0 color vector4w y) 128)
|
||||
(set! (-> gp-0 color vector4w z) 128)
|
||||
(set! (-> gp-0 color vector4w w) 128)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for symbol sprite-distort-vu1-block, type vu-function
|
||||
(define sprite-distort-vu1-block (the-as vu-function 0))
|
||||
|
||||
;; definition for function sprite-init-distorter
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
(defun sprite-init-distorter ((arg0 dma-buffer) (arg1 uint))
|
||||
(let* ((v1-0 arg0)
|
||||
(a2-0 (the-as object (-> v1-0 base)))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet a2-0) dma)
|
||||
(new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt))
|
||||
)
|
||||
(set! (-> (the-as dma-packet a2-0) vif0) (new 'static 'vif-tag))
|
||||
(set!
|
||||
(-> (the-as dma-packet a2-0) vif1)
|
||||
(new 'static 'vif-tag :imm #x7 :cmd (vif-cmd direct) :msk #x1)
|
||||
)
|
||||
(set! (-> v1-0 base) (&+ (the-as pointer a2-0) 16))
|
||||
)
|
||||
(let* ((v1-1 arg0)
|
||||
(a2-2 (the-as object (-> v1-1 base)))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as gs-gif-tag a2-2) tag)
|
||||
(new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x6)
|
||||
)
|
||||
(set!
|
||||
(-> (the-as gs-gif-tag a2-2) regs)
|
||||
(new 'static 'gif-tag-regs
|
||||
:regs0 (gif-reg-id a+d)
|
||||
:regs1 (gif-reg-id a+d)
|
||||
:regs2 (gif-reg-id a+d)
|
||||
:regs3 (gif-reg-id a+d)
|
||||
:regs4 (gif-reg-id a+d)
|
||||
:regs5 (gif-reg-id a+d)
|
||||
:regs6 (gif-reg-id a+d)
|
||||
:regs7 (gif-reg-id a+d)
|
||||
:regs8 (gif-reg-id a+d)
|
||||
:regs9 (gif-reg-id a+d)
|
||||
:regs10 (gif-reg-id a+d)
|
||||
:regs11 (gif-reg-id a+d)
|
||||
:regs12 (gif-reg-id a+d)
|
||||
:regs13 (gif-reg-id a+d)
|
||||
:regs14 (gif-reg-id a+d)
|
||||
:regs15 (gif-reg-id a+d)
|
||||
)
|
||||
)
|
||||
(set! (-> v1-1 base) (&+ (the-as pointer a2-2) 16))
|
||||
)
|
||||
(let* ((v1-2 arg0)
|
||||
(a2-4 (-> v1-2 base))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as (pointer gs-zbuf) a2-4) 0)
|
||||
(new 'static 'gs-zbuf :zbp #x1c0 :psm (gs-psm ct24) :zmsk #x1)
|
||||
)
|
||||
(set! (-> (the-as (pointer gs-reg64) a2-4) 1) (gs-reg64 zbuf-1))
|
||||
(set!
|
||||
(-> (the-as (pointer gs-tex0) a2-4) 2)
|
||||
(new 'static 'gs-tex0 :tbw #x8 :tw #x9 :th #x8 :tbp0 (* arg1 32))
|
||||
)
|
||||
(set! (-> (the-as (pointer gs-reg64) a2-4) 3) (gs-reg64 tex0-1))
|
||||
(set!
|
||||
(-> (the-as (pointer gs-tex1) a2-4) 4)
|
||||
(new 'static 'gs-tex1 :mmag #x1 :mmin #x1)
|
||||
)
|
||||
(set! (-> (the-as (pointer gs-reg64) a2-4) 5) (gs-reg64 tex1-1))
|
||||
(set! (-> (the-as (pointer gs-miptbp) a2-4) 6) (new 'static 'gs-miptbp))
|
||||
(set! (-> (the-as (pointer gs-reg64) a2-4) 7) (gs-reg64 miptbp1-1))
|
||||
(set!
|
||||
(-> (the-as (pointer gs-clamp) a2-4) 8)
|
||||
(new 'static 'gs-clamp
|
||||
:wms (gs-tex-wrap-mode region-clamp)
|
||||
:wmt (gs-tex-wrap-mode region-clamp)
|
||||
:maxu #x1ff
|
||||
:maxv (-> *video-parms* screen-masky)
|
||||
)
|
||||
)
|
||||
(set! (-> (the-as (pointer gs-reg64) a2-4) 9) (gs-reg64 clamp-1))
|
||||
(set!
|
||||
(-> (the-as (pointer gs-alpha) a2-4) 10)
|
||||
(new 'static 'gs-alpha :b #x1 :d #x1)
|
||||
)
|
||||
(set! (-> (the-as (pointer gs-reg64) a2-4) 11) (gs-reg64 alpha-1))
|
||||
(set! (-> v1-2 base) (&+ a2-4 96))
|
||||
)
|
||||
(let* ((v1-3 arg0)
|
||||
(a1-15 (the-as object (-> v1-3 base)))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet a1-15) dma)
|
||||
(new 'static 'dma-tag
|
||||
:qwc #x8b
|
||||
:id (dma-tag-id ref)
|
||||
:addr (the-as uint (-> *sprite-distorter-sine-tables* entry))
|
||||
)
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet a1-15) vif0)
|
||||
(new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet a1-15) vif1)
|
||||
(new 'static 'vif-tag :imm #x160 :num #x8b :cmd (vif-cmd unpack-v4-32))
|
||||
)
|
||||
(set! (-> v1-3 base) (&+ (the-as pointer a1-15) 16))
|
||||
)
|
||||
(dma-buffer-add-vu-function arg0 sprite-distort-vu1-block 1)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for function sprite-draw-distorters
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
;; WARN: Inline assembly instruction marked with TODO - [TODO.VCLIP]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping]
|
||||
;; Used lq/sq
|
||||
(defun sprite-draw-distorters ((arg0 dma-buffer))
|
||||
(local-vars
|
||||
(v1-14 float)
|
||||
(v1-20 float)
|
||||
(v1-25 int)
|
||||
(v1-57 float)
|
||||
(sv-16 sprite-vec-data-2d)
|
||||
(sv-32 pointer)
|
||||
(sv-48 pointer)
|
||||
)
|
||||
(rlet ((acc :class vf)
|
||||
(Q :class vf)
|
||||
(vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf10 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
(vf4 :class vf)
|
||||
(vf5 :class vf)
|
||||
(vf6 :class vf)
|
||||
(vf8 :class vf)
|
||||
(vf9 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.lvf vf8 (&-> *math-camera* hmge-scale quad))
|
||||
(let ((s0-0 (-> arg0 base))
|
||||
(s4-0 0)
|
||||
(s5-0 0)
|
||||
)
|
||||
(&+! (-> arg0 base) 16)
|
||||
(let* ((s3-0 *sprite-aux-list*)
|
||||
(s2-0 (-> s3-0 entry))
|
||||
)
|
||||
(dotimes (s1-0 s2-0)
|
||||
(set! sv-16 (-> s3-0 data s1-0))
|
||||
(let ((a0-1 (the-as object (-> arg0 base))))
|
||||
(set! sv-32 (&+ (the-as pointer a0-1) 16))
|
||||
(set! sv-48 (&+ (the-as pointer a0-1) 32))
|
||||
(cond
|
||||
((= (-> sv-16 matrix) 1)
|
||||
(.lvf vf3 (&-> *math-camera* sprite-2d vector 0 quad))
|
||||
(.lvf vf4 (&-> *math-camera* sprite-2d vector 1 quad))
|
||||
(.lvf vf5 (&-> *math-camera* sprite-2d vector 2 quad))
|
||||
(.lvf vf6 (&-> *math-camera* sprite-2d vector 3 quad))
|
||||
(.lvf vf9 (&-> *math-camera* sprite-2d-hvdf quad))
|
||||
(.mov v1-14 vf9)
|
||||
)
|
||||
(else
|
||||
(.lvf vf3 (&-> *math-camera* camera-temp vector 0 quad))
|
||||
(.lvf vf4 (&-> *math-camera* camera-temp vector 1 quad))
|
||||
(.lvf vf5 (&-> *math-camera* camera-temp vector 2 quad))
|
||||
(.lvf vf6 (&-> *math-camera* camera-temp vector 3 quad))
|
||||
(.lvf vf9 (&-> *math-camera* hvdf-off quad))
|
||||
(.mov v1-20 vf9)
|
||||
)
|
||||
)
|
||||
(.lvf vf1 (&-> sv-16 x-y-z-sx quad))
|
||||
(.lvf vf2 (&-> sv-16 color quad))
|
||||
(.mul.w.vf acc vf6 vf0)
|
||||
(.add.mul.x.vf acc vf3 vf1 acc)
|
||||
(.add.mul.y.vf acc vf4 vf1 acc)
|
||||
(.add.mul.z.vf vf1 vf5 vf1 acc)
|
||||
(.mul.vf vf10 vf1 vf8)
|
||||
(.div.vf Q vf0 vf10 :fsf #b11 :ftf #b11)
|
||||
(TODO.VCLIP vf10 vf10)
|
||||
(b! (zero? (-> sv-16 flag)) cfg-21)
|
||||
(.wait.vf)
|
||||
(.mul.vf vf1 vf1 Q :mask #b111)
|
||||
(.mul.vf vf2 vf2 Q :mask #b111)
|
||||
(.cfc2.i v1-25 Clipping)
|
||||
(b! (logtest? v1-25 63) cfg-21 :delay (.add.vf vf1 vf1 vf9))
|
||||
(.max.x.vf vf1 vf1 vf0 :mask #b1000)
|
||||
(.svf (&-> (the-as vector a0-1) quad) vf1)
|
||||
(.svf (&-> (the-as vector sv-48) quad) vf2)
|
||||
(set! (-> (the-as vector a0-1) w) 255.0)
|
||||
(set!
|
||||
(-> (the-as (pointer float) sv-32))
|
||||
(* 0.001953125 (+ -1792.0 (-> (the-as vector a0-1) x)))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as vector sv-32) y)
|
||||
(*
|
||||
0.00390625
|
||||
(+
|
||||
(+ -2048.0 (the float (-> *video-parms* screen-hy)))
|
||||
(-> (the-as vector a0-1) y)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set! (-> (the-as vector sv-32) z) 1.0)
|
||||
(when (or (< (-> sv-16 flag) 3) (< 11 (-> sv-16 flag)))
|
||||
(format 0 "Turns = ~D!!!~%" (-> sv-16 flag))
|
||||
(set! (-> (the-as (pointer int32) sv-16) 4) 11)
|
||||
)
|
||||
(set! (-> (the-as (pointer int32) sv-32) 3) (-> sv-16 flag))
|
||||
(let* ((f0-7 (- (-> *math-camera* perspective vector 1 y)))
|
||||
(f2-4 (-> (the-as vector sv-32) y))
|
||||
(f4-0 (+ f2-4 (* (-> (the-as (pointer float) sv-48)) f0-7)))
|
||||
(f3-0 256.0)
|
||||
(f1-7 (-> (the-as (pointer float) sv-48)))
|
||||
)
|
||||
(if (< (the float (-> *video-parms* screen-sy)) f4-0)
|
||||
(set! f3-0 (/ (- (the float (-> *video-parms* screen-sy)) f2-4) f0-7))
|
||||
)
|
||||
(if (< 128.0 f3-0)
|
||||
(set! f3-0 128.0)
|
||||
)
|
||||
(when (< f3-0 f1-7)
|
||||
(let ((v1-55 (/ f3-0 f1-7)))
|
||||
(.mov vf1 v1-55)
|
||||
)
|
||||
(.mul.x.vf vf2 vf2 vf1)
|
||||
(.svf (&-> (the-as vector sv-48) quad) vf2)
|
||||
(.mov v1-57 vf2)
|
||||
)
|
||||
)
|
||||
(&+! (-> arg0 base) 48)
|
||||
(+! s4-0 1)
|
||||
(when (= s4-0 85)
|
||||
(let ((v1-62 (-> arg0 base)))
|
||||
(set! (-> arg0 base) s0-0)
|
||||
(let* ((a0-8 arg0)
|
||||
(a1-3 (the-as object (-> a0-8 base)))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet a1-3) dma)
|
||||
(new 'static 'dma-tag :id (dma-tag-id cnt) :qwc (* 3 s4-0))
|
||||
)
|
||||
(set! (-> (the-as dma-packet a1-3) vif0) (new 'static 'vif-tag))
|
||||
(set!
|
||||
(-> (the-as dma-packet a1-3) vif1)
|
||||
(new 'static 'vif-tag
|
||||
:cmd (vif-cmd unpack-v4-32)
|
||||
:imm (shr (shl (+ (* 3 s5-0) 512) 54) 54)
|
||||
:num (* 3 s4-0)
|
||||
)
|
||||
)
|
||||
(set! (-> a0-8 base) (&+ (the-as pointer a1-3) 16))
|
||||
)
|
||||
(set! (-> arg0 base) v1-62)
|
||||
)
|
||||
(set! s4-0 0)
|
||||
(+! s5-0 85)
|
||||
(when (= s5-0 170)
|
||||
(let* ((v1-65 arg0)
|
||||
(a0-9 (the-as object (-> v1-65 base)))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet a0-9) dma)
|
||||
(new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt))
|
||||
)
|
||||
(set! (-> (the-as dma-packet a0-9) vif0) (new 'static 'vif-tag))
|
||||
(set!
|
||||
(-> (the-as dma-packet a0-9) vif1)
|
||||
(new 'static 'vif-tag :imm #x1ff :num #x1 :cmd (vif-cmd unpack-v4-32))
|
||||
)
|
||||
(set! (-> v1-65 base) (&+ (the-as pointer a0-9) 16))
|
||||
)
|
||||
(let* ((v1-66 arg0)
|
||||
(a0-11 (the-as object (-> v1-66 base)))
|
||||
)
|
||||
(set! (-> (the-as vector4w a0-11) x) s5-0)
|
||||
(set! (-> (the-as vector4w a0-11) y) 0)
|
||||
(set! (-> (the-as vector4w a0-11) z) 0)
|
||||
(set! (-> (the-as vector4w a0-11) w) 0)
|
||||
(set! (-> v1-66 base) (&+ (the-as pointer a0-11) 16))
|
||||
)
|
||||
(let* ((v1-67 arg0)
|
||||
(a0-13 (the-as object (-> v1-67 base)))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet a0-13) dma)
|
||||
(new 'static 'dma-tag :id (dma-tag-id cnt))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet a0-13) vif0)
|
||||
(new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1)
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet a0-13) vif1)
|
||||
(new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1)
|
||||
)
|
||||
(set! (-> v1-67 base) (&+ (the-as pointer a0-13) 16))
|
||||
)
|
||||
(set! s5-0 0)
|
||||
)
|
||||
(set! s0-0 (-> arg0 base))
|
||||
(&+! (-> arg0 base) 16)
|
||||
)
|
||||
(label cfg-21)
|
||||
)
|
||||
)
|
||||
(cond
|
||||
((zero? s4-0)
|
||||
(set! (-> arg0 base) s0-0)
|
||||
(nop!)
|
||||
0
|
||||
)
|
||||
(else
|
||||
(let ((v1-74 (-> arg0 base)))
|
||||
(set! (-> arg0 base) s0-0)
|
||||
(let* ((a0-15 arg0)
|
||||
(a1-10 (the-as object (-> a0-15 base)))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet a1-10) dma)
|
||||
(new 'static 'dma-tag :id (dma-tag-id cnt) :qwc (* 3 s4-0))
|
||||
)
|
||||
(set! (-> (the-as dma-packet a1-10) vif0) (new 'static 'vif-tag))
|
||||
(set!
|
||||
(-> (the-as dma-packet a1-10) vif1)
|
||||
(new 'static 'vif-tag
|
||||
:cmd (vif-cmd unpack-v4-32)
|
||||
:imm (shr (shl (+ (* 3 s5-0) 512) 54) 54)
|
||||
:num (* 3 s4-0)
|
||||
)
|
||||
)
|
||||
(set! (-> a0-15 base) (&+ (the-as pointer a1-10) 16))
|
||||
)
|
||||
(set! (-> arg0 base) v1-74)
|
||||
)
|
||||
)
|
||||
)
|
||||
(let ((v1-75 (+ s4-0 s5-0)))
|
||||
(when (nonzero? v1-75)
|
||||
(let* ((a0-17 arg0)
|
||||
(a1-12 (the-as object (-> a0-17 base)))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet a1-12) dma)
|
||||
(new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt))
|
||||
)
|
||||
(set! (-> (the-as dma-packet a1-12) vif0) (new 'static 'vif-tag))
|
||||
(set!
|
||||
(-> (the-as dma-packet a1-12) vif1)
|
||||
(new 'static 'vif-tag :imm #x1ff :num #x1 :cmd (vif-cmd unpack-v4-32))
|
||||
)
|
||||
(set! (-> a0-17 base) (&+ (the-as pointer a1-12) 16))
|
||||
)
|
||||
(let* ((a0-18 arg0)
|
||||
(a1-14 (the-as object (-> a0-18 base)))
|
||||
)
|
||||
(set! (-> (the-as vector4w a1-14) x) v1-75)
|
||||
(set! (-> (the-as vector4w a1-14) y) 0)
|
||||
(set! (-> (the-as vector4w a1-14) z) 0)
|
||||
(set! (-> (the-as vector4w a1-14) w) 0)
|
||||
(set! (-> a0-18 base) (&+ (the-as pointer a1-14) 16))
|
||||
)
|
||||
(let ((v1-77 (the-as object (-> arg0 base))))
|
||||
(set!
|
||||
(-> (the-as dma-packet v1-77) dma)
|
||||
(new 'static 'dma-tag :id (dma-tag-id cnt))
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet v1-77) vif0)
|
||||
(new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1)
|
||||
)
|
||||
(set!
|
||||
(-> (the-as dma-packet v1-77) vif1)
|
||||
(new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1)
|
||||
)
|
||||
(set! (-> arg0 base) (&+ (the-as pointer v1-77) 16))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
+12
-26
@@ -2944,9 +2944,9 @@
|
||||
(when
|
||||
(and
|
||||
(nonzero? (-> id page))
|
||||
(< (the-as uint (-> id page)) (the-as uint (-> *texture-page-dir* length)))
|
||||
(< (-> id page) (the-as uint (-> *texture-page-dir* length)))
|
||||
)
|
||||
(let ((dir-entry (-> *texture-page-dir* entries (the-as uint (-> id page)))))
|
||||
(let ((dir-entry (-> *texture-page-dir* entries (-> id page))))
|
||||
(when (not (-> dir-entry page))
|
||||
(let ((old-alloc-func (-> *texture-pool* allocate-func)))
|
||||
(set! (-> *texture-pool* allocate-func) alloc-func)
|
||||
@@ -3016,14 +3016,10 @@
|
||||
(not
|
||||
(or
|
||||
(zero? (-> arg0 page))
|
||||
(>=
|
||||
(the-as uint (-> arg0 page))
|
||||
(the-as uint (-> *texture-page-dir* length))
|
||||
)
|
||||
(>= (-> arg0 page) (the-as uint (-> *texture-page-dir* length)))
|
||||
)
|
||||
)
|
||||
(let
|
||||
((dir-entry (-> *texture-page-dir* entries (the-as uint (-> arg0 page)))))
|
||||
(let ((dir-entry (-> *texture-page-dir* entries (-> arg0 page))))
|
||||
(if (not (-> dir-entry link))
|
||||
(set!
|
||||
(-> dir-entry link)
|
||||
@@ -3066,12 +3062,12 @@
|
||||
(let ((link-slot (&-> link-arr 0))
|
||||
(shader (the-as adgif-shader (* (-> link-arr 0 shader) 16)))
|
||||
)
|
||||
(while (nonzero? (the-as int shader))
|
||||
(while (nonzero? (the-as uint shader))
|
||||
(b!
|
||||
(< (the-as int (- (the-as int shader) (the-as int mem-start))) 0)
|
||||
(< (the-as int (- (the-as uint shader) (the-as uint mem-start))) 0)
|
||||
cfg-7
|
||||
:delay
|
||||
(set! dist-past-end (- (the-as int shader) mem-end))
|
||||
(set! dist-past-end (- (the-as uint shader) mem-end))
|
||||
)
|
||||
(b! (>= (the-as int dist-past-end) 0) cfg-7 :delay (nop!))
|
||||
(let ((t4-2 (-> shader next)))
|
||||
@@ -3352,16 +3348,9 @@
|
||||
(when
|
||||
(and
|
||||
(nonzero? (-> tex-id page))
|
||||
(<
|
||||
(the-as uint (-> tex-id page))
|
||||
(the-as uint (-> *texture-page-dir* length))
|
||||
)
|
||||
(< (-> tex-id page) (the-as uint (-> *texture-page-dir* length)))
|
||||
)
|
||||
(let
|
||||
((dir-entry
|
||||
(-> *texture-page-dir* entries (the-as uint (-> tex-id page)))
|
||||
)
|
||||
)
|
||||
(let ((dir-entry (-> *texture-page-dir* entries (-> tex-id page))))
|
||||
(when
|
||||
(and
|
||||
(< (-> tex-id index) (the-as uint (-> dir-entry length)))
|
||||
@@ -3402,12 +3391,9 @@
|
||||
(when
|
||||
(and
|
||||
(nonzero? (-> v1-4 page))
|
||||
(<
|
||||
(the-as uint (-> v1-4 page))
|
||||
(the-as uint (-> *texture-page-dir* length))
|
||||
)
|
||||
(< (-> v1-4 page) (the-as uint (-> *texture-page-dir* length)))
|
||||
)
|
||||
(let ((a1-7 (-> *texture-page-dir* entries (the-as uint (-> v1-4 page)))))
|
||||
(let ((a1-7 (-> *texture-page-dir* entries (-> v1-4 page))))
|
||||
(when
|
||||
(and (< (-> v1-4 index) (the-as uint (-> a1-7 length))) (-> a1-7 link))
|
||||
(set! (-> arg0 next shader) (-> a1-7 link next (-> v1-4 index) shader))
|
||||
@@ -3539,7 +3525,7 @@
|
||||
(the-as object (* (-> entry-link next entry-list-length shader) 16))
|
||||
)
|
||||
)
|
||||
(while (nonzero? (the-as int v1-40))
|
||||
(while (nonzero? (the-as uint v1-40))
|
||||
(nop!)
|
||||
(+! a3-7 1)
|
||||
(set! v1-40 (* (-> (the-as adgif-shader v1-40) next shader) 16))
|
||||
|
||||
+1
-1
@@ -591,7 +591,7 @@
|
||||
(defmethod should-display? nav-control ((obj nav-control))
|
||||
(and
|
||||
*display-nav-marks*
|
||||
(nonzero? (logand (-> obj flags) (nav-control-flags display-marks bit0)))
|
||||
(nonzero? (logand (-> obj flags) (nav-control-flags bit0 display-marks)))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
+4
-4
@@ -25,7 +25,7 @@
|
||||
(the-as bucket-id s3-0)
|
||||
*temp-string*
|
||||
(-> obj process root trans)
|
||||
(new 'static 'rgba :r #x3)
|
||||
(font-color orange-red)
|
||||
(the-as vector2h #f)
|
||||
)
|
||||
)
|
||||
@@ -73,7 +73,7 @@
|
||||
(the-as bucket-id s1-0)
|
||||
*temp-string*
|
||||
s4-1
|
||||
(new 'static 'rgba :r #x4)
|
||||
(font-color bright-orange-red)
|
||||
(the-as vector2h #f)
|
||||
)
|
||||
)
|
||||
@@ -395,7 +395,7 @@
|
||||
(the-as bucket-id s3-0)
|
||||
*temp-string*
|
||||
(-> obj process root trans)
|
||||
(new 'static 'rgba :r #x3)
|
||||
(font-color orange-red)
|
||||
(the-as vector2h #f)
|
||||
)
|
||||
)
|
||||
@@ -441,7 +441,7 @@
|
||||
(the-as bucket-id s1-0)
|
||||
*temp-string*
|
||||
s4-1
|
||||
(new 'static 'rgba :r #x4)
|
||||
(font-color bright-orange-red)
|
||||
(the-as vector2h #f)
|
||||
)
|
||||
)
|
||||
|
||||
+8
-1
@@ -142,7 +142,14 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(draw-string-xy *temp-string* dma-buf 32 (+ (* 12 slot-idx) 8) 3 1)
|
||||
(draw-string-xy
|
||||
*temp-string*
|
||||
dma-buf
|
||||
32
|
||||
(+ (* 12 slot-idx) 8)
|
||||
(font-color orange-red)
|
||||
1
|
||||
)
|
||||
)
|
||||
)
|
||||
0
|
||||
|
||||
+4
-4
@@ -1021,7 +1021,7 @@
|
||||
arg0
|
||||
(+ (* s5-0 16) 16)
|
||||
48
|
||||
0
|
||||
(font-color default)
|
||||
1
|
||||
)
|
||||
)
|
||||
@@ -1033,7 +1033,7 @@
|
||||
arg0
|
||||
(+ (* s5-1 16) 16)
|
||||
64
|
||||
0
|
||||
(font-color default)
|
||||
1
|
||||
)
|
||||
)
|
||||
@@ -1049,7 +1049,7 @@
|
||||
(-> *sound-iop-info* freemem)
|
||||
(shr (-> *sound-iop-info* freemem) 10)
|
||||
)
|
||||
(s5-0 *temp-string* arg0 32 96 0 1)
|
||||
(s5-0 *temp-string* arg0 32 96 (font-color default) 1)
|
||||
)
|
||||
(let ((s5-1 draw-string-xy))
|
||||
(format
|
||||
@@ -1058,7 +1058,7 @@
|
||||
(-> *sound-iop-info* freemem2)
|
||||
(shr (-> *sound-iop-info* freemem2) 10)
|
||||
)
|
||||
(s5-1 *temp-string* arg0 32 64 0 1)
|
||||
(s5-1 *temp-string* arg0 32 64 (font-color default) 1)
|
||||
)
|
||||
0
|
||||
)
|
||||
|
||||
+11
-2
@@ -84,7 +84,7 @@
|
||||
0
|
||||
0
|
||||
0.0
|
||||
0
|
||||
(font-color default)
|
||||
(the-as uint 3)
|
||||
)
|
||||
)
|
||||
@@ -165,7 +165,16 @@
|
||||
(s3-0 0)
|
||||
(s2-0 #t)
|
||||
(s5-0
|
||||
(new 'stack 'font-context *font-default-matrix* 31 0 0.0 0 (the-as uint 3))
|
||||
(new
|
||||
'stack
|
||||
'font-context
|
||||
*font-default-matrix*
|
||||
31
|
||||
0
|
||||
0.0
|
||||
(font-color default)
|
||||
(the-as uint 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(let ((v1-2 s5-0))
|
||||
|
||||
+7
-6
@@ -1884,14 +1884,15 @@
|
||||
(new 'global 'dead-pool 1 8192 '*camera-master-dead-pool*)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(if *debug-segment*
|
||||
(set!
|
||||
*debug-dead-pool*
|
||||
(new 'debug 'dead-pool-heap '*debug-dead-pool* 768 #x100000)
|
||||
)
|
||||
;; this part is debug only
|
||||
(when *debug-segment*
|
||||
;; definition for symbol *debug-dead-pool*, type dead-pool-heap
|
||||
(define
|
||||
*debug-dead-pool*
|
||||
(new 'debug 'dead-pool-heap '*debug-dead-pool* 768 #x100000)
|
||||
)
|
||||
|
||||
)
|
||||
;; definition for symbol *nk-dead-pool*, type dead-pool-heap
|
||||
(define *nk-dead-pool* (new 'global 'dead-pool-heap '*nk-dead-pool* 768 #xf6000))
|
||||
|
||||
|
||||
@@ -3759,7 +3759,7 @@ nav-enemy-default-event-handler
|
||||
)
|
||||
(logior!
|
||||
(-> obj nav flags)
|
||||
(nav-control-flags display-marks bit0 bit3 bit5 bit6 bit7)
|
||||
(nav-control-flags bit0 display-marks bit3 bit5 bit6 bit7)
|
||||
)
|
||||
(set! (-> obj nav gap-event) 'jump)
|
||||
(dummy-26 (-> obj nav))
|
||||
|
||||
@@ -143,6 +143,9 @@ const std::unordered_set<std::string> g_functions_to_skip_compiling = {
|
||||
// stats-h
|
||||
"(method 11 perf-stat)", "(method 12 perf-stat)",
|
||||
|
||||
// sprite-distorter
|
||||
"sprite-draw-distorters", // uses clipping flag.
|
||||
|
||||
// sync-info
|
||||
"(method 15 sync-info)", // needs display stuff first
|
||||
"(method 15 sync-info-eased)", // needs display stuff first
|
||||
|
||||
Reference in New Issue
Block a user