rename to only use js instead of jso

This commit is contained in:
John Alanbrook 2024-09-25 20:51:20 -05:00
parent 1e4a142030
commit f95249f147
7 changed files with 41 additions and 42 deletions

View file

@ -294,3 +294,7 @@ TAGINC != find . -name "*.[chj]"
tags: $(TAGINC) tags: $(TAGINC)
@echo Making tags. @echo Making tags.
@etags $(TAGINC) @etags $(TAGINC)
MYFILES != (ls scripts/*.js* source/engine/*.[ch] source/engine/sound/*.[ch])
pretty:
clang-format -i $(MYFILES)

View file

@ -232,7 +232,7 @@ var editor = {
Object.dainty_assign(this.desktop, this.stash); Object.dainty_assign(this.desktop, this.stash);
} }
this.selectlist = []; this.selectlist = [];
editor.camera = world.spawn("scripts/camera2d.jso"); editor.camera = world.spawn("scripts/camera2d");
editor.camera._ed.selectable = false; editor.camera._ed.selectable = false;
game.camera = editor.camera; game.camera = editor.camera;
}, },

View file

@ -728,6 +728,7 @@ var ur_from_file = function(file) {
} }
game.loadurs = function() { game.loadurs = function() {
return;
ur = {}; ur = {};
ur._list = []; ur._list = [];
/* FIND ALL URS IN A PROJECT */ /* FIND ALL URS IN A PROJECT */

View file

@ -1,6 +1,6 @@
/* /*
TYPES OF PROFILING TYPES OF PROFILING
cpu gathering - gets stack frames randomly for a few seconds cpu gathering - gets stack frames randomly for a few seconds
frames - user defined to see how long engine takes frames - user defined to see how long engine takes
@ -10,22 +10,21 @@
memory - can see how much memory is allocated and from where memory - can see how much memory is allocated and from where
*/ */
var t_units = ["ns", "us", "ms", "s", "ks", "Ms"]; var t_units = [ "ns", "us", "ms", "s", "ks", "Ms" ];
function calc_cpu (fn, times, diff = 0) {
var series = [];
function calc_cpu(fn, times, diff=0)
{
var series = [];
for (var i = 0; i < times; i++) { for (var i = 0; i < times; i++) {
var st = profile.now(); var st = profile.now();
fn(i); fn (i);
series.push(profile.now()-st-diff); series.push(profile.now() - st - diff);
} }
return series; return series;
} }
function empty_fn() {} function empty_fn () {}
profile.cpu = function profile_cpu(fn, times = 1, q = "unnamed") { profile.cpu = function profile_cpu(fn, times = 1, q = "unnamed") {
var retgather = gathering_cpu; var retgather = gathering_cpu;
@ -51,7 +50,7 @@ var callgraph = {};
profile.rawstacks = {}; profile.rawstacks = {};
profile.cpu_cg = callgraph; profile.cpu_cg = callgraph;
function add_callgraph(fn, line, time) { function add_callgraph (fn, line, time) {
var cc = callgraph[line]; var cc = callgraph[line];
if (!cc) { if (!cc) {
var cc = {}; var cc = {};
@ -151,7 +150,7 @@ profile.cpu_frame = function()
} }
var filecache = {}; var filecache = {};
function get_line(file, line) { function get_line (file, line) {
var text = filecache[file]; var text = filecache[file];
if (!text) { if (!text) {
var f = io.slurp(file); var f = io.slurp(file);
@ -162,22 +161,19 @@ function get_line(file, line) {
filecache[file] = io.slurp(file).split('\n'); filecache[file] = io.slurp(file).split('\n');
text = filecache[file]; text = filecache[file];
} }
if (typeof text === 'string') return text; if (typeof text === 'string') return text;
text = text[Number(line)-1]; text = text[Number (line) - 1];
if (!text) return "NULL"; if (!text) return "NULL";
return text.trim(); return text.trim();
} }
profile.stop_cpu_instr = function() profile.stop_cpu_instr = function () { return; }
{
return;
}
profile.best_t = function (t) { profile.best_t = function (t) {
var qq = 0; var qq = 0;
while (t > 1000 && qq < t_units.length-1) { while (t > 1000 && qq < t_units.length - 1) {
t /= 1000; t /= 1000;
qq++; qq++;
} }
@ -185,11 +181,13 @@ profile.best_t = function (t) {
return `${t.toPrecision(4)} ${t_units[qq]}`; return `${t.toPrecision(4)} ${t_units[qq]}`;
}; };
profile.report = function (start, msg = "[undefined report]") { console.info(`${msg} in ${profile.best_t(profile.now() - start)}`); }; profile.report = function (start, msg = "[undefined report]") {
console.info(`${msg} in ${profile.best_t(profile.now() - start)}`);
};
/* /*
Frame averages are an instrumented profiling technique. Place frame() calls in your code to get a call graph for things you are interested in. Frame averages are an instrumented profiling technique. Place frame() calls
in your code to get a call graph for things you are interested in.
*/ */
var frame_avg = false; var frame_avg = false;
@ -314,26 +312,28 @@ function addreport(group, line, start) {
return t; return t;
}; };
function printreport(cache, name) { function printreport (cache, name) {
var report = `==${name}==` + "\n"; var report = `==${name}==` +
"\n";
var reports = []; var reports = [];
for (var i in cache) { for (var i in cache) {
var time = cache[i].reduce((a,b)=>a+b); var time = cache[i].reduce((a, b) => a + b);
reports.push({ reports.push({
time:time, time : time,
name:i, name : i,
hits:cache[i].length, hits : cache[i].length,
avg:time/cache[i].length avg : time / cache[i].length
}); });
} }
reports = reports.sort((a,b) => { reports = reports.sort((a, b) => {
if (a.avg<b.avg) return 1; if (a.avg < b.avg) return 1;
return -1; return -1;
}); });
for (var rep of reports) for (var rep of reports)
report += `${rep.name} ${profile.best_t(rep.avg)} (${rep.hits} hits) (total ${profile.best_t(rep.time)})\n`; report += `${rep.name} ${profile.best_t(rep.avg)} (${
rep.hits} hits) (total ${profile.best_t(rep.time)})\n`;
return report; return report;
}; };
@ -341,12 +341,10 @@ function printreport(cache, name) {
profile.data = {}; profile.data = {};
profile.curframe = 0; profile.curframe = 0;
function prof_add_stats(obj, stat) function prof_add_stats (obj, stat) {
{
for (var i in stat) { for (var i in stat) {
obj[i] ??= []; obj[i] ??= [];
if (obj[i].last() !== stat[i]) if (obj[i].last() !== stat[i]) obj[i][profile.curframe] = stat[i];
obj[i][profile.curframe] = stat[i];
} }
} }

View file

@ -401,9 +401,7 @@ var Event = {
global.mixin("scripts/spline"); global.mixin("scripts/spline");
global.mixin("scripts/components"); global.mixin("scripts/components");
global.mixin("scripts/actor"); global.mixin("scripts/actor");
global.mixin("scripts/entity"); global.mixin("scripts/entity");
function world_start() { function world_start() {

View file

@ -1,2 +0,0 @@
this.phys = physics.static;
this.add_component(component.sprite);