memory cards (in progress) (#868)

* c++ memory card stuff

* saving kinda works

* load working

* more progress

* clean up
This commit is contained in:
water111
2021-10-01 23:12:34 -04:00
committed by GitHub
parent 254a29851e
commit 845802ca45
56 changed files with 3069 additions and 692 deletions
+1 -1
View File
@@ -4643,7 +4643,7 @@
:flag-assert #x1000000068
(:methods
(new (symbol type int) _type_ 0)
(want-file (_type_ string int handle float) int 9)
(set-pending-file (_type_ string int handle float) int 9)
(update (_type_) int 10)
(inactive? (_type_) symbol 11)
(file-status (_type_ string int) symbol 12)
@@ -504,7 +504,8 @@
"unpack-comp-huf":[2, 4, 5, 6, 7, 8, 9],
"blerc-execute":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33],
"(method 11 fact-info-target)":[42],
"(code format-card auto-save)":[3, 4, 5, 6, 7, 8],
"(anon-function 9 game-save)":[3, 4, 5, 6, 7, 8],
//"(anon-function 9 game-save)":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
"particle-adgif":[0, 1, 2, 3, 4, 5, 7],
"sp-launch-particles-var":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66],
"(method 11 sparticle-launch-control)": [ 27, 28, 35, 46, 48, 49, 77],
+20 -1
View File
@@ -2,6 +2,7 @@
#include "decompiler/util/data_decompile.h"
#include "common/goos/PrettyPrinter.h"
#include "common/util/print_float.h"
#include "common/util/assert.h"
namespace decompiler {
// sparticle fields.
@@ -102,6 +103,7 @@ enum class FieldKind {
NO_FANCY_DECOMP,
FUNCTION,
USERDATA,
ROT_X,
INVALID
};
@@ -125,7 +127,7 @@ const SparticleFieldDecomp field_kinds[68] = {
{true, FieldKind::METER_WITH_RAND}, // SPT_Y = 11
{true, FieldKind::FLOAT_WITH_RAND}, // SPT_Z = 12
{true, FieldKind::METER_WITH_RAND}, // SPT_SCALE_X = 13
{true, FieldKind::PLAIN_INT}, // SPT_ROT_X = 14
{true, FieldKind::ROT_X}, // SPT_ROT_X = 14
{true, FieldKind::DEGREES_WITH_RAND}, // SPT_ROT_Y = 15
{true, FieldKind::DEGREES_WITH_RAND}, // SPT_ROT_Z = 16
{true, FieldKind::METER_WITH_RAND}, // SPT_SCALE_Y = 17
@@ -294,6 +296,7 @@ goos::Object decompile_sparticle_userdata(const std::vector<LinkedWord>& words,
return original;
}
}
goos::Object decompile_sparticle_int_init(const std::vector<LinkedWord>& words,
const std::string& field_name,
const std::string& flag_name) {
@@ -307,9 +310,22 @@ goos::Object decompile_sparticle_int_init(const std::vector<LinkedWord>& words,
fmt::format("(sp-int {} {})", field_name, word_as_s32(words.at(1))));
}
goos::Object decompile_sparticle_rot_x(const std::vector<LinkedWord>& words,
const std::string& field_name,
const std::string& flag_name) {
if (flag_name == "int-with-rand" || flag_name == "float-with-rand") {
return decompile_sparticle_float_with_rand_init(words, field_name, flag_name);
} else {
return decompile_sparticle_int_init(words, field_name, flag_name);
}
}
goos::Object decompile_sparticle_int_with_rand_init(const std::vector<LinkedWord>& words,
const std::string& field_name,
const std::string& flag_name) {
if (flag_name != "plain-v1") {
fmt::print("Bad {} {}\n", field_name, flag_name);
}
assert(flag_name == "plain-v1");
if (word_as_s32(words.at(2)) == 0 && word_as_s32(words.at(3)) == 1) {
return decompile_sparticle_int_init(words, field_name, flag_name);
@@ -588,6 +604,9 @@ goos::Object decompile_sparticle_field_init(const TypeSpec& type,
case FieldKind::USERDATA:
result = decompile_sparticle_userdata(obj_words, field_name, flag_name, normal);
break;
case FieldKind::ROT_X:
result = decompile_sparticle_rot_x(obj_words, field_name, flag_name);
break;
default:
assert(false);
}