Merge pull request #12 from open-goal/v/file-jump-commands

This commit is contained in:
Tyler Wilding 2022-04-15 19:44:00 -04:00 committed by GitHub
commit f6c7dc9b3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 2812 additions and 572 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
node_modules
*.vsix
out/

7
.vscode/launch.json vendored
View file

@ -9,9 +9,14 @@
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: watch"
}
]
}

20
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,20 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

2533
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -16,7 +16,30 @@
"type": "git",
"url": "https://github.com/open-goal/opengoal-vscode"
},
"main": "./out/extension.js",
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"lint": "eslint . --ext .ts,.tsx",
"watch": "tsc -watch -p ./"
},
"activationEvents": [
"onLanguage:opengoal",
"onLanguage:opengoal-goos",
"onLanguage:opengoal-ir",
"onCommand:extension.helloWorld"
],
"contributes": {
"commands": [
{
"command": "opengoal.switchFile",
"title": "OpenGOAL - Switch File"
},
{
"command": "opengoal.decomp.openMostRecentIRFile",
"title": "OpenGOAL - Decomp - Open Recent IR2 File"
}
],
"configurationDefaults": {
"[opengoal-ir]": {
"editor.bracketPairColorization.enabled": false
@ -203,7 +226,8 @@
"opengoal-goos"
],
"extensions": [
".gs"
".gs",
".gp"
],
"icon": {
"light": "./icons/opengoal-goos.png",
@ -253,5 +277,13 @@
"path": "./snippets/opengoal.json"
}
]
},
"devDependencies": {
"@types/node": "^12.12.0",
"@types/vscode": "^1.34.0",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"eslint": "^8.13.0",
"typescript": "^4.6.3"
}
}

39
src/RecentFiles.ts Normal file
View file

@ -0,0 +1,39 @@
import * as vscode from "vscode";
import * as path from "path";
export class RecentFiles {
recentFiles: Array<string> = [];
workspaceState: vscode.Memento;
constructor(context: vscode.ExtensionContext) {
this.workspaceState = context.workspaceState;
this.recentFiles = this.workspaceState.get("recents", []);
}
addFile(filePath: string) {
console.log(`Adding - ${filePath}`);
// dont add duplicates
// if it exists, take it out and put it on the top
const idx = this.indexOf(filePath);
console.log(idx);
if (idx !== -1) {
this.recentFiles.splice(idx, 1);
}
this.recentFiles.unshift(filePath);
if (this.recentFiles.length >= 100) {
this.recentFiles.slice(0, 100);
}
}
includes(filePath: string) {
return this.recentFiles.find((str) => str === filePath);
}
indexOf(filePath: string) {
return this.recentFiles.findIndex((str) => str === filePath);
}
searchByPrefix(text: string) {
return this.recentFiles.find((str) => str.endsWith(text));
}
}

37
src/extension.ts Normal file
View file

@ -0,0 +1,37 @@
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from "vscode";
import { RecentFiles } from "./RecentFiles";
import * as fileUtils from "./utils/FileUtils";
let recentFiles: RecentFiles;
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
recentFiles = new RecentFiles(context);
if (vscode.window.activeTextEditor?.document != undefined) {
recentFiles.addFile(vscode.window.activeTextEditor?.document.fileName);
}
// Commands
// - All
context.subscriptions.push(
vscode.commands.registerCommand("opengoal.switchFile", fileUtils.switchFile)
);
// - Decompiling
context.subscriptions.push(
vscode.commands.registerCommand(
"opengoal.decomp.openMostRecentIRFile",
() => fileUtils.openFile(recentFiles.searchByPrefix("_ir2.asm"))
)
);
// Events
context.subscriptions.push(
vscode.window.onDidChangeActiveTextEditor((editor) => {
if (editor?.document != undefined) {
recentFiles.addFile(editor?.document.fileName);
}
})
);
}

33
src/utils/FileUtils.ts Normal file
View file

@ -0,0 +1,33 @@
import * as vscode from "vscode";
import * as path from "path";
import * as fs from "fs";
const fileSwitchingAssoc = {
"_ir2.asm": "_disasm.gc",
"_disasm.gc": "_ir2.asm",
};
export function switchFile() {
const currPath = vscode.window.activeTextEditor?.document.fileName;
if (currPath === undefined) {
return;
}
const currName = path.basename(currPath);
for (const [key, value] of Object.entries(fileSwitchingAssoc)) {
if (currName.endsWith(key)) {
// Get everything before the suffix, check if a file with the associated suffix exists
let prefix = currName.slice(0, -key.length);
let switchFileName = prefix + value;
let switchFilePath = path.join(path.dirname(currPath), switchFileName);
vscode.window.showTextDocument(vscode.Uri.file(switchFilePath));
return;
}
}
}
export function openFile(filePath: string | undefined) {
if (filePath === undefined) {
return;
}
vscode.window.showTextDocument(vscode.Uri.file(filePath));
}

97
test/sample_disasm.gc Normal file
View file

@ -0,0 +1,97 @@
;;-*-Lisp-*-
;; COMMENTS
; line comment
;; line comment
;;; '''""""line comment""!@"!!""!()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#|
a block comment
'-"""''
''""
;;;!()
|#
;; BUILT-IN FUNCTIONS
(.nop)
(.ret)
(.push :color #f s0)
(.pop :color #f s0)
(rlet ((vf1 :class vf))
(.jr :color #f s0)
(.sub sp 16)
(.add sp 16)
(.load-sym :sext #f sp *kernel-sp*)
(.mov v1-0 vf1)
(.lvf vf1 (&-> arg0 times 0 quad))
(.svf (&-> arg0 color 0 quad) vf4)
(.mov.vf vf6 vf0 :mask #b1000)
(.blend.vf vf1 vf1 vf0 :mask #b1000)
(.nop.vf)
(.wait.vf)
(.xor.vf vf26 vf26 vf26)
(.xor.p r0 r0 r0)
(.max.vf vf3 vf3 vf5 :mask #b111)
(.max.x.vf vf28 vf28 vf0 :mask #b1000)
(.add.mul.vf vf1 vf0 vf1 acc :mask #b1000)
(.sub.mul.w.vf vf1 vf0 vf1 acc :mask #b1000)
(.outer.product.vf vf14 vf13 vf12 acc)
(.outer.product.a.vf acc vf12 vf13)
(.outer.product.b.vf vf14 vf13 vf12 acc)
(.abs.vf vf23 vf12)
(:clear)
;; use defmacro to define goos macros.
(define defmacro defsmacro)
(define defun desfun)
(defun gc-file->o-file (filename)
"Get the name of the object file for the given GOAL (*.gc) source file."
(string-append "out/obj/" (stem filename) ".o")
)
(defmacro goal-src (src-file &rest deps)
"Add a GOAL source file with the given dependencies"
`(defstep :in ,(string-append "goal_src/" src-file)
;; use goal compiler
:tool 'goalc
;; will output the obj file
:out '(,(gc-file->o-file src-file))
;; dependencies are the obj files
:dep '(,@(apply gc-file->o-file deps))
)
)
(defun make-src-sequence-elt (current previous prefix)
"Helper for goal-src-sequence"
`(defstep :in ,(string-append "goal_src/" prefix current)
:tool 'goalc
:out '(,(gc-file->o-file current))
:dep '(#|"iso/KERNEL.CGO"|#
,(gc-file->o-file previous))
)
)
(defmacro goal-src-sequence (prefix &key (deps '()) &rest sequence)
"Add a sequence of GOAL files (each depending on the previous) in the given directory,
with all depending on the given deps."
(let* ((first-thing `(goal-src ,(string-append prefix (first sequence)) ,@deps))
(result (cons first-thing '()))
(iter result))
(let ((prev (first sequence))
(in-iter (rest sequence)))
(while (not (null? in-iter))
;; (fmt #t "{} dep on {}\n" (first in-iter) prev)
(let ((next (make-src-sequence-elt (first in-iter) prev prefix)))
(set-cdr! iter (cons next '()))
(set! iter (cdr iter)))
(set! prev (car in-iter))
(set! in-iter (cdr in-iter))))
`(begin ,@result)))

View file

@ -1,395 +1,3 @@
;------------------------------------------
; top-level segment
;------------------------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; .function (top-level-login air)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;stack: total 0x00, fp? 0 ra? 0 ep? 1
;; Warnings:
;; INFO: Return type mismatch function vs none.
B0:
lui v1, L18 ;; [ 0] (set! v1-0 L18) [] -> [v1: (function vector (inline-array air-box) int symbol) ]
ori v1, v1, L18
sw v1, point-in-air?(s7) ;; [ 1] (s.w! point-in-air? v1-0)
;; [v1: (function vector (inline-array air-box) int symbol) ] -> []
lui v1, L1 ;; [ 2] (set! v1-1 L1)
;; [] -> [v1: (function vector vector (inline-array air-box) int symbol) ]
ori v1, v1, L1
sw v1, points-in-air?(s7) ;; [ 3] (s.w! points-in-air? v1-1)
;; [v1: (function vector vector (inline-array air-box) int symbol) ] -> []
lw v1, *debug-segment*(s7);; [ 4] (set! v1-2 *debug-segment*) [] -> [v1: symbol ]
beq s7, v1, L40 ;; [ 5] (b! (not v1-2) L40 (nop!)) [v1: symbol ] -> []
sll r0, r0, 0
B1:
lui v1, L29 ;; [ 6] (set! v0-0 L29) [] -> [v0: (function bucket-id air-box symbol) ]
ori v0, v1, L29
sw v0, add-debug-air-box(s7);; [ 7] (s.w! add-debug-air-box v0-0) [v0: (function bucket-id air-box symbol) ] -> []
beq r0, r0, L41 ;; [ 8] (b! #t L41 (nop!)) [] -> []
sll r0, r0, 0
B2:
L40:
lw v0, nothing(s7) ;; [ 9] (set! v0-1 nothing) [] -> [v0: (function none) ]
sw v0, add-debug-air-box(s7);; [ 10] (s.w! add-debug-air-box v0-1) [v0: (function none) ] -> []
B3:
L41:
jr ra
daddu sp, sp, r0
;;-*-OpenGOAL-Start-*-
(top-level-function
()
(set! point-in-air? L18)
(set! points-in-air? L1)
(if *debug-segment*
(set! add-debug-air-box L29)
(set! add-debug-air-box (the-as (function bucket-id air-box symbol) nothing))
)
(none)
)
;;-*-OpenGOAL-End-*-
;; .endfunction
L42:
.word 0x0
.word 0x0
;------------------------------------------
; debug segment
;------------------------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; .function add-debug-air-box
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;stack: total 0x80, fp? 1 ra? 1 ep? 1
;stack_vars: 32 bytes at 16
;gprs: gp s5 s4 s3 s2
;; Warnings:
;; Used lq/sq
;; v1-0: air-box a0-0: bucket-id a0-1: symbol a1-0: air-box a1-1: vector s2-0: uint
;; s4-0: vector s5-0: vector f0-4: float f0-6: float f1-5: float f2-1: float
L29:
daddiu sp, sp, -128
sd ra, 0(sp)
sd fp, 8(sp)
or fp, t9, r0
sq s2, 48(sp)
sq s3, 64(sp)
sq s4, 80(sp)
sq s5, 96(sp)
sq gp, 112(sp)
B0:
or gp, a0, r0 ;; [ 0] (set! arg0 arg0) [a0: bucket-id ] -> [gp: bucket-id ]
or s3, a1, r0 ;; [ 1] (set! arg1 arg1) [a1: air-box ] -> [s3: air-box ]
lw t9, camera-pos(s7) ;; [ 2] (set! t9-0 camera-pos) [] -> [t9: (function vector) ]
jalr ra, t9 ;; [ 3] (call!) [t9: (function vector) ] -> [v0: vector ]
sll v0, ra, 0
or a1, v0, r0 ;; [ 4] (set! a1-1 v0-0) [v0: vector ] -> [a1: vector ]
daddiu s5, sp, 16 ;; [ 5] (set! s5-0 (+ sp-0 16)) [sp: <uninitialized> ] -> [s5: vector ]
daddiu s4, sp, 32 ;; [ 6] (set! s4-0 (+ sp-0 32)) [sp: <uninitialized> ] -> [s4: vector ]
lwc1 f0, 12(s3) ;; [ 7] (set! f0-0 (l.f (+ arg1 12))) [s3: air-box ] -> []
lwc1 f0, 28(s3) ;; [ 8] (set! f0-1 (l.f (+ arg1 28))) [s3: air-box ] -> []
ld s2, L39(fp) ;; [ 9] (set! s2-0 (l.d L39)) [] -> [s2: uint ]
or v1, s3, r0 ;; [ 10] (set! v1-0 arg1) [s3: air-box ] -> [v1: air-box ]
lwc1 f0, 4(v1) ;; [ 11] (set! f0-2 (l.f (+ v1-0 4))) [v1: air-box ] -> []
lwc1 f1, 4(a1) ;; [ 12] (set! f1-0 (l.f (+ a1-1 4))) [a1: vector ] -> []
c.lt.s f0, f1 ;; [ 13] (b! (>=.s f0-2 f1-0) L34 (set! a0-1 #f)) [] -> [a0: '#f ]
bc1f L34
or a0, s7, r0
B1:
lwc1 f0, 0(a1) ;; [ 14] (set! f0-3 (l.f a1-1)) [a1: vector ] -> []
lwc1 f1, 0(v1) ;; [ 15] (set! f1-1 (l.f v1-0)) [v1: air-box ] -> []
sub.s f0, f0, f1 ;; [ 16] (set! f0-4 (-.s f0-3 f1-1)) [] -> []
lwc1 f1, 8(a1) ;; [ 17] (set! f1-2 (l.f (+ a1-1 8))) [a1: vector ] -> []
lwc1 f2, 8(v1) ;; [ 18] (set! f2-0 (l.f (+ v1-0 8))) [v1: air-box ] -> []
sub.s f2, f1, f2 ;; [ 19] (set! f2-1 (-.s f1-2 f2-0)) [] -> []
or a0, s7, r0 ;; [ 20] (set! a0-1 #f) [] -> [a0: '#f ]
lwc1 f1, 12(v1) ;; [ 21] (set! f1-3 (l.f (+ v1-0 12))) [v1: air-box ] -> []
mul.s f1, f0, f1 ;; [ 22] (set! f1-4 (*.s f0-4 f1-3)) [] -> []
lwc1 f3, 28(v1) ;; [ 23] (set! f3-0 (l.f (+ v1-0 28))) [v1: air-box ] -> []
mul.s f3, f2, f3 ;; [ 24] (set! f3-1 (*.s f2-1 f3-0)) [] -> []
add.s f1, f1, f3 ;; [ 25] (set! f1-5 (+.s f1-4 f3-1)) [] -> []
lwc1 f3, 12(v1) ;; [ 26] (set! f3-2 (l.f (+ v1-0 12))) [v1: air-box ] -> []
mul.s f2, f2, f3 ;; [ 27] (set! f2-2 (*.s f2-1 f3-2)) [] -> []
lwc1 f3, 28(v1) ;; [ 28] (set! f3-3 (l.f (+ v1-0 28))) [v1: air-box ] -> []
mul.s f0, f0, f3 ;; [ 29] (set! f0-5 (*.s f0-4 f3-3)) [] -> []
sub.s f0, f2, f0 ;; [ 30] (set! f0-6 (-.s f2-2 f0-5)) [] -> []
mtc1 f2, r0 ;; [ 31] (set! f2-3 0) [] -> []
c.lt.s f1, f2 ;; [ 32] (b! (>=.s f1-5 f2-3) L30 (set! a1-2 #t)) [] -> [a1: symbol ]
bc1f L30
daddiu a1, s7, 8
B2:
or a1, s7, r0 ;; [ 33] (set! a1-2 #f) [] -> [a1: '#f ]
B3:
L30:
beql s7, a1, L33 ;; [ 34] (bl! (not a1-2) L33 (no-delay!)) [a1: symbol ] -> []
B4:
or v1, a1, r0 ;; [ 35] (set! v1-1 a1-2) [a1: symbol ] -> [v1: symbol ]
B5:
mtc1 f2, r0 ;; [ 36] (set! f2-4 0) [] -> []
c.lt.s f0, f2 ;; [ 37] (b! (>=.s f0-6 f2-4) L31 (set! a1-3 #t)) [] -> [a1: symbol ]
bc1f L31
daddiu a1, s7, 8
B6:
or a1, s7, r0 ;; [ 38] (set! a1-3 #f) [] -> [a1: '#f ]
B7:
L31:
beql s7, a1, L33 ;; [ 39] (bl! (not a1-3) L33 (no-delay!)) [a1: symbol ] -> []
B8:
or v1, a1, r0 ;; [ 40] (set! v1-1 a1-3) [a1: symbol ] -> [v1: symbol ]
B9:
lwc1 f2, 16(v1) ;; [ 41] (set! f2-5 (l.f (+ v1-0 16))) [v1: air-box ] -> []
c.lt.s f1, f2 ;; [ 42] (b! (<.s f1-5 f2-5) L32 (set! a1-4 #t)) [] -> [a1: symbol ]
bc1t L32
daddiu a1, s7, 8
B10:
or a1, s7, r0 ;; [ 43] (set! a1-4 #f) [] -> [a1: '#f ]
B11:
L32:
beql s7, a1, L33 ;; [ 44] (bl! (not a1-4) L33 (no-delay!)) [a1: symbol ] -> []
B12:
or v1, a1, r0 ;; [ 45] (set! v1-1 a1-4) [a1: symbol ] -> [v1: symbol ]
B13:
lwc1 f1, 24(v1) ;; [ 46] (set! f1-6 (l.f (+ v1-0 24))) [v1: air-box ] -> []
c.lt.s f0, f1 ;; [ 47] (b! (<.s f0-6 f1-6) L33 (set! v1-1 #t)) [] -> [v1: symbol ]
bc1t L33
daddiu v1, s7, 8
B14:
or v1, s7, r0 ;; [ 48] (set! v1-1 #f) [] -> [v1: '#f ]
B15:
L33:
beq s7, v1, L34 ;; [ 49] (b! (not v1-1) L34 (set! v1-2 #f)) [v1: symbol ] -> [v1: '#f ]
or v1, s7, r0
B16:
daddiu a0, s7, #t ;; [ 50] (set! a0-1 #t) [] -> [a0: symbol ]
or v1, a0, r0 ;; [ 51] (set! v1-3 a0-1) [a0: symbol ] -> [v1: symbol ]
B17:
L34:
beq s7, a0, L35 ;; [ 52] (b! (not a0-1) L35 (set! v1-4 #f)) [a0: symbol ] -> [v1: '#f ]
or v1, s7, r0
B18:
ld s2, L38(fp) ;; [ 53] (set! s2-0 (l.d L38)) [] -> [s2: uint ]
or v1, s2, r0 ;; [ 54] (set! v1-5 s2-0) [s2: uint ] -> [v1: uint ]
B19:
L35:
lwc1 f0, 4(s3) ;; [ 55] (set! f0-7 (l.f (+ arg1 4))) [s3: air-box ] -> []
swc1 f0, 4(s5) ;; [ 56] (s.f! (+ s5-0 4) f0-7) [s5: vector ] -> []
lwc1 f0, 4(s3) ;; [ 57] (set! f0-8 (l.f (+ arg1 4))) [s3: air-box ] -> []
swc1 f0, 4(s4) ;; [ 58] (s.f! (+ s4-0 4) f0-8) [s4: vector ] -> []
lwc1 f0, L37(fp) ;; [ 59] (set! f0-9 (l.f L37)) [] -> []
swc1 f0, 12(s5) ;; [ 60] (s.f! (+ s5-0 12) f0-9) [s5: vector ] -> []
lwc1 f0, L37(fp) ;; [ 61] (set! f0-10 (l.f L37)) [] -> []
swc1 f0, 12(s4) ;; [ 62] (s.f! (+ s4-0 12) f0-10) [s4: vector ] -> []
lwc1 f0, 0(s3) ;; [ 63] (set! f0-11 (l.f arg1)) [s3: air-box ] -> []
swc1 f0, 0(s5) ;; [ 64] (s.f! s5-0 f0-11) [s5: vector ] -> []
lwc1 f0, 8(s3) ;; [ 65] (set! f0-12 (l.f (+ arg1 8))) [s3: air-box ] -> []
swc1 f0, 8(s5) ;; [ 66] (s.f! (+ s5-0 8) f0-12) [s5: vector ] -> []
lwc1 f0, 0(s3) ;; [ 67] (set! f0-13 (l.f arg1)) [s3: air-box ] -> []
lwc1 f1, 12(s3) ;; [ 68] (set! f1-7 (l.f (+ arg1 12))) [s3: air-box ] -> []
lwc1 f2, 16(s3) ;; [ 69] (set! f2-6 (l.f (+ arg1 16))) [s3: air-box ] -> []
mul.s f1, f1, f2 ;; [ 70] (set! f1-8 (*.s f1-7 f2-6)) [] -> []
add.s f0, f0, f1 ;; [ 71] (set! f0-14 (+.s f0-13 f1-8)) [] -> []
swc1 f0, 0(s4) ;; [ 72] (s.f! s4-0 f0-14) [s4: vector ] -> []
lwc1 f0, 8(s3) ;; [ 73] (set! f0-15 (l.f (+ arg1 8))) [s3: air-box ] -> []
lwc1 f1, 28(s3) ;; [ 74] (set! f1-9 (l.f (+ arg1 28))) [s3: air-box ] -> []
lwc1 f2, 16(s3) ;; [ 75] (set! f2-7 (l.f (+ arg1 16))) [s3: air-box ] -> []
mul.s f1, f1, f2 ;; [ 76] (set! f1-10 (*.s f1-9 f2-7)) [] -> []
add.s f0, f0, f1 ;; [ 77] (set! f0-16 (+.s f0-15 f1-10)) [] -> []
swc1 f0, 8(s4) ;; [ 78] (s.f! (+ s4-0 8) f0-16) [s4: vector ] -> []
lw t9, add-debug-line(s7) ;; [ 79] (set! t9-1 add-debug-line)
;; [] -> [t9: (function symbol bucket-id vector vector rgba symbol rgba symbol) ]
daddiu a0, s7, #t ;; [ 80] (set! a0-2 #t) [] -> [a0: symbol ]
or a1, gp, r0 ;; [ 81] (set! a1-5 arg0) [gp: bucket-id ] -> [a1: bucket-id ]
or a2, s5, r0 ;; [ 82] (set! a2-0 s5-0) [s5: vector ] -> [a2: vector ]
or a3, s4, r0 ;; [ 83] (set! a3-0 s4-0) [s4: vector ] -> [a3: vector ]
or t0, s2, r0 ;; [ 84] (set! t0-0 s2-0) [s2: uint ] -> [t0: uint ]
or t1, s7, r0 ;; [ 85] (set! t1-0 #f) [] -> [t1: '#f ]
addiu t2, r0, -1 ;; [ 86] (set! t2-0 -1) [] -> [t2: <integer -1> ]
jalr ra, t9 ;; [ 87] (call! a0-2 a1-5 a2-0 a3-0 t0-0 t1-0 t2-0)
;; [a0: symbol a1: bucket-id a2: vector a3: vector t0: uint t1: '#f t2: <integer -1> t9: (function symbol bucket-id vector vector rgba symbol rgba symbol) ] -> [v0: symbol ]
sll v0, ra, 0
or v1, s5, r0 ;; [ 88] (set! v1-6 s5-0) [s5: vector ] -> [v1: vector ]
or a0, s4, r0 ;; [ 89] (set! a0-3 s4-0) [s4: vector ] -> [a0: vector ]
lq a0, 0(a0) ;; [ 90] (set! a0-4 (l.q a0-3)) [a0: vector ] -> [a0: uint128 ]
sq a0, 0(v1) ;; [ 91] (s.q! v1-6 a0-4) [v1: vector a0: uint128 ] -> []
lwc1 f0, 0(s5) ;; [ 92] (set! f0-17 (l.f s5-0)) [s5: vector ] -> []
lwc1 f1, 28(s3) ;; [ 93] (set! f1-11 (l.f (+ arg1 28))) [s3: air-box ] -> []
neg.s f1, f1 ;; [ 94] (set! f1-12 (neg.s f1-11)) [] -> []
lwc1 f2, 24(s3) ;; [ 95] (set! f2-8 (l.f (+ arg1 24))) [s3: air-box ] -> []
mul.s f1, f1, f2 ;; [ 96] (set! f1-13 (*.s f1-12 f2-8)) [] -> []
add.s f0, f0, f1 ;; [ 97] (set! f0-18 (+.s f0-17 f1-13)) [] -> []
swc1 f0, 0(s4) ;; [ 98] (s.f! s4-0 f0-18) [s4: vector ] -> []
lwc1 f0, 8(s5) ;; [ 99] (set! f0-19 (l.f (+ s5-0 8))) [s5: vector ] -> []
lwc1 f1, 12(s3) ;; [100] (set! f1-14 (l.f (+ arg1 12))) [s3: air-box ] -> []
lwc1 f2, 24(s3) ;; [101] (set! f2-9 (l.f (+ arg1 24))) [s3: air-box ] -> []
mul.s f1, f1, f2 ;; [102] (set! f1-15 (*.s f1-14 f2-9)) [] -> []
add.s f0, f0, f1 ;; [103] (set! f0-20 (+.s f0-19 f1-15)) [] -> []
swc1 f0, 8(s4) ;; [104] (s.f! (+ s4-0 8) f0-20) [s4: vector ] -> []
lw t9, add-debug-line(s7) ;; [105] (set! t9-2 add-debug-line)
;; [] -> [t9: (function symbol bucket-id vector vector rgba symbol rgba symbol) ]
daddiu a0, s7, #t ;; [106] (set! a0-5 #t) [] -> [a0: symbol ]
or a1, gp, r0 ;; [107] (set! a1-6 arg0) [gp: bucket-id ] -> [a1: bucket-id ]
or a2, s5, r0 ;; [108] (set! a2-1 s5-0) [s5: vector ] -> [a2: vector ]
or a3, s4, r0 ;; [109] (set! a3-1 s4-0) [s4: vector ] -> [a3: vector ]
or t0, s2, r0 ;; [110] (set! t0-1 s2-0) [s2: uint ] -> [t0: uint ]
or t1, s7, r0 ;; [111] (set! t1-1 #f) [] -> [t1: '#f ]
addiu t2, r0, -1 ;; [112] (set! t2-1 -1) [] -> [t2: <integer -1> ]
jalr ra, t9 ;; [113] (call! a0-5 a1-6 a2-1 a3-1 t0-1 t1-1 t2-1)
;; [a0: symbol a1: bucket-id a2: vector a3: vector t0: uint t1: '#f t2: <integer -1> t9: (function symbol bucket-id vector vector rgba symbol rgba symbol) ] -> [v0: symbol ]
sll v0, ra, 0
lwc1 f0, 0(s3) ;; [114] (set! f0-21 (l.f arg1)) [s3: air-box ] -> []
lwc1 f1, 28(s3) ;; [115] (set! f1-16 (l.f (+ arg1 28))) [s3: air-box ] -> []
neg.s f1, f1 ;; [116] (set! f1-17 (neg.s f1-16)) [] -> []
lwc1 f2, 24(s3) ;; [117] (set! f2-10 (l.f (+ arg1 24))) [s3: air-box ] -> []
mul.s f1, f1, f2 ;; [118] (set! f1-18 (*.s f1-17 f2-10)) [] -> []
add.s f0, f0, f1 ;; [119] (set! f0-22 (+.s f0-21 f1-18)) [] -> []
swc1 f0, 0(s5) ;; [120] (s.f! s5-0 f0-22) [s5: vector ] -> []
lwc1 f0, 8(s3) ;; [121] (set! f0-23 (l.f (+ arg1 8))) [s3: air-box ] -> []
lwc1 f1, 12(s3) ;; [122] (set! f1-19 (l.f (+ arg1 12))) [s3: air-box ] -> []
lwc1 f2, 24(s3) ;; [123] (set! f2-11 (l.f (+ arg1 24))) [s3: air-box ] -> []
mul.s f1, f1, f2 ;; [124] (set! f1-20 (*.s f1-19 f2-11)) [] -> []
add.s f0, f0, f1 ;; [125] (set! f0-24 (+.s f0-23 f1-20)) [] -> []
swc1 f0, 8(s5) ;; [126] (s.f! (+ s5-0 8) f0-24) [s5: vector ] -> []
lw t9, add-debug-line(s7) ;; [127] (set! t9-3 add-debug-line)
;; [] -> [t9: (function symbol bucket-id vector vector rgba symbol rgba symbol) ]
daddiu a0, s7, #t ;; [128] (set! a0-6 #t) [] -> [a0: symbol ]
or a1, gp, r0 ;; [129] (set! a1-7 arg0) [gp: bucket-id ] -> [a1: bucket-id ]
or a2, s5, r0 ;; [130] (set! a2-2 s5-0) [s5: vector ] -> [a2: vector ]
or a3, s4, r0 ;; [131] (set! a3-2 s4-0) [s4: vector ] -> [a3: vector ]
or t0, s2, r0 ;; [132] (set! t0-2 s2-0) [s2: uint ] -> [t0: uint ]
or t1, s7, r0 ;; [133] (set! t1-2 #f) [] -> [t1: '#f ]
addiu t2, r0, -1 ;; [134] (set! t2-2 -1) [] -> [t2: <integer -1> ]
jalr ra, t9 ;; [135] (call! a0-6 a1-7 a2-2 a3-2 t0-2 t1-2 t2-2)
;; [a0: symbol a1: bucket-id a2: vector a3: vector t0: uint t1: '#f t2: <integer -1> t9: (function symbol bucket-id vector vector rgba symbol rgba symbol) ] -> [v0: symbol ]
sll v0, ra, 0
lwc1 f0, 0(s3) ;; [136] (set! f0-25 (l.f arg1)) [s3: air-box ] -> []
swc1 f0, 0(s4) ;; [137] (s.f! s4-0 f0-25) [s4: vector ] -> []
lwc1 f0, 8(s3) ;; [138] (set! f0-26 (l.f (+ arg1 8))) [s3: air-box ] -> []
swc1 f0, 8(s4) ;; [139] (s.f! (+ s4-0 8) f0-26) [s4: vector ] -> []
lw t9, add-debug-line(s7) ;; [140] (set! t9-4 add-debug-line)
;; [] -> [t9: (function symbol bucket-id vector vector rgba symbol rgba symbol) ]
daddiu a0, s7, #t ;; [141] (set! a0-7 #t) [] -> [a0: symbol ]
or t1, s7, r0 ;; [142] (set! t1-3 #f) [] -> [t1: '#f ]
addiu t2, r0, -1 ;; [143] (set! t2-3 -1) [] -> [t2: <integer -1> ]
or a1, gp, r0 ;; [144] (set! a1-8 arg0) [gp: bucket-id ] -> [a1: bucket-id ]
or a2, s5, r0 ;; [145] (set! a2-3 s5-0) [s5: vector ] -> [a2: vector ]
or a3, s4, r0 ;; [146] (set! a3-3 s4-0) [s4: vector ] -> [a3: vector ]
or t0, s2, r0 ;; [147] (set! t0-3 s2-0) [s2: uint ] -> [t0: uint ]
jalr ra, t9 ;; [148] (call! a0-7 a1-8 a2-3 a3-3 t0-3 t1-3 t2-3)
;; [a0: symbol a1: bucket-id a2: vector a3: vector t0: uint t1: '#f t2: <integer -1> t9: (function symbol bucket-id vector vector rgba symbol rgba symbol) ] -> [v0: symbol ]
sll v0, ra, 0
ld ra, 0(sp)
ld fp, 8(sp)
lq gp, 112(sp)
lq s5, 96(sp)
lq s4, 80(sp)
lq s3, 64(sp)
lq s2, 48(sp)
jr ra
daddiu sp, sp, 128
;;-*-OpenGOAL-Start-*-
(defun add-debug-air-box ((arg0 bucket-id) (arg1 air-box))
(local-vars (a0-1 symbol))
(let ((a1-1 (camera-pos))
(s5-0 (new 'stack-no-clear 'vector))
(s4-0 (new 'stack-no-clear 'vector))
)
(-> arg1 cos-angle)
(-> arg1 sin-angle)
(let ((s2-0 (the-as uint #x800000ff)))
(let ((v1-0 arg1))
(set! a0-1
(when (< (-> v1-0 height-level) (-> a1-1 y))
(let ((f0-4 (- (-> a1-1 x) (-> v1-0 x-pos)))
(f2-1 (- (-> a1-1 z) (-> v1-0 z-pos)))
)
(set! a0-1 #f)
(let ((f1-5 (+ (* f0-4 (-> v1-0 cos-angle)) (* f2-1 (-> v1-0 sin-angle))))
(f0-6 (- (* f2-1 (-> v1-0 cos-angle)) (* f0-4 (-> v1-0 sin-angle))))
)
(if (and (>= f1-5 0.0) (>= f0-6 0.0) (< f1-5 (-> v1-0 x-length)) (< f0-6 (-> v1-0 z-length)))
(set! a0-1 #t)
)
)
)
a0-1
)
)
)
(if a0-1
(set! s2-0 (the-as uint #x8000ff00))
)
(set! (-> s5-0 y) (-> arg1 height-level))
(set! (-> s4-0 y) (-> arg1 height-level))
(set! (-> s5-0 w) 1.0)
(set! (-> s4-0 w) 1.0)
(set! (-> s5-0 x) (-> arg1 x-pos))
(set! (-> s5-0 z) (-> arg1 z-pos))
(set! (-> s4-0 x) (+ (-> arg1 x-pos) (* (-> arg1 cos-angle) (-> arg1 x-length))))
(set! (-> s4-0 z) (+ (-> arg1 z-pos) (* (-> arg1 sin-angle) (-> arg1 x-length))))
(add-debug-line #t arg0 s5-0 s4-0 (the-as rgba s2-0) #f (the-as rgba -1))
(set! (-> s5-0 quad) (-> s4-0 quad))
(set! (-> s4-0 x) (+ (-> s5-0 x) (* (- (-> arg1 sin-angle)) (-> arg1 z-length))))
(set! (-> s4-0 z) (+ (-> s5-0 z) (* (-> arg1 cos-angle) (-> arg1 z-length))))
(add-debug-line #t arg0 s5-0 s4-0 (the-as rgba s2-0) #f (the-as rgba -1))
(set! (-> s5-0 x) (+ (-> arg1 x-pos) (* (- (-> arg1 sin-angle)) (-> arg1 z-length))))
(set! (-> s5-0 z) (+ (-> arg1 z-pos) (* (-> arg1 cos-angle) (-> arg1 z-length))))
(add-debug-line #t arg0 s5-0 s4-0 (the-as rgba s2-0) #f (the-as rgba -1))
(set! (-> s4-0 x) (-> arg1 x-pos))
(set! (-> s4-0 z) (-> arg1 z-pos))
(add-debug-line #t arg0 s5-0 s4-0 (the-as rgba s2-0) #f (the-as rgba -1))
)
)
)
;;-*-OpenGOAL-End-*-
;; .endfunction
L36:
.word 0x0
.word 0x0
L37:
.word 0x3f800000
L38:
.word 0x8000ff00
.word 0x0
L39:
.word 0x800000ff
.word 0x0
;------------------------------------------
; main segment
;------------------------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; .function points-in-air?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -680,180 +288,3 @@ defun
;;-*-OpenGOAL-End-*-
;; .endfunction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; .function point-in-air?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;stack: total 0x00, fp? 0 ra? 0 ep? 1
;; v1-0: int a0-0: vector a1-0: (inline-array air-box)
;; a2-0: int a3-1: air-box t0-0: symbol
;; t1-0: vector f0-2: float f0-4: float
;; f1-5: float f2-1: float
B0:
L18:
addiu v1, r0, 0 ;; [ 0] (set! v1-0 0) [] -> [v1: <integer 0> ]
beq r0, r0, L26 ;; [ 1] (b! #t L26 (nop!)) [] -> []
sll r0, r0, 0
B1:
L19:
or t1, a0, r0 ;; [ 2] (set! t1-0 arg0) [a0: vector ] -> [t1: vector ]
dsll a3, v1, 5 ;; [ 3] (set! a3-0 (sll v1-0 5)) [v1: int ] -> [a3: <value x 32> ]
daddu a3, a1, a3 ;; [ 4] (set! a3-1 (+ arg1 a3-0))
;; [a1: (inline-array air-box) a3: <value x 32> ] -> [a3: air-box ]
lwc1 f0, 4(a3) ;; [ 5] (set! f0-0 (l.f (+ a3-1 4))) [a3: air-box ] -> []
lwc1 f1, 4(t1) ;; [ 6] (set! f1-0 (l.f (+ t1-0 4))) [t1: vector ] -> []
c.lt.s f0, f1 ;; [ 7] (b! (>=.s f0-0 f1-0) L24 (set! t0-0 #f)) [] -> [t0: '#f ]
bc1f L24
or t0, s7, r0
B2:
lwc1 f0, 0(t1) ;; [ 8] (set! f0-1 (l.f t1-0)) [t1: vector ] -> []
lwc1 f1, 0(a3) ;; [ 9] (set! f1-1 (l.f a3-1)) [a3: air-box ] -> []
sub.s f0, f0, f1 ;; [ 10] (set! f0-2 (-.s f0-1 f1-1)) [] -> []
lwc1 f1, 8(t1) ;; [ 11] (set! f1-2 (l.f (+ t1-0 8))) [t1: vector ] -> []
lwc1 f2, 8(a3) ;; [ 12] (set! f2-0 (l.f (+ a3-1 8))) [a3: air-box ] -> []
sub.s f2, f1, f2 ;; [ 13] (set! f2-1 (-.s f1-2 f2-0)) [] -> []
or t0, s7, r0 ;; [ 14] (set! t0-0 #f) [] -> [t0: '#f ]
lwc1 f1, 12(a3) ;; [ 15] (set! f1-3 (l.f (+ a3-1 12))) [a3: air-box ] -> []
mul.s f1, f0, f1 ;; [ 16] (set! f1-4 (*.s f0-2 f1-3)) [] -> []
lwc1 f3, 28(a3) ;; [ 17] (set! f3-0 (l.f (+ a3-1 28))) [a3: air-box ] -> []
mul.s f3, f2, f3 ;; [ 18] (set! f3-1 (*.s f2-1 f3-0)) [] -> []
add.s f1, f1, f3 ;; [ 19] (set! f1-5 (+.s f1-4 f3-1)) [] -> []
lwc1 f3, 12(a3) ;; [ 20] (set! f3-2 (l.f (+ a3-1 12))) [a3: air-box ] -> []
mul.s f2, f2, f3 ;; [ 21] (set! f2-2 (*.s f2-1 f3-2)) [] -> []
lwc1 f3, 28(a3) ;; [ 22] (set! f3-3 (l.f (+ a3-1 28))) [a3: air-box ] -> []
mul.s f0, f0, f3 ;; [ 23] (set! f0-3 (*.s f0-2 f3-3)) [] -> []
sub.s f0, f2, f0 ;; [ 24] (set! f0-4 (-.s f2-2 f0-3)) [] -> []
mtc1 f2, r0 ;; [ 25] (set! f2-3 0) [] -> []
c.lt.s f1, f2 ;; [ 26] (b! (>=.s f1-5 f2-3) L20 (set! t1-1 #t)) [] -> [t1: symbol ]
bc1f L20
daddiu t1, s7, 8
B3:
or t1, s7, r0 ;; [ 27] (set! t1-1 #f) [] -> [t1: '#f ]
B4:
L20:
beql s7, t1, L23 ;; [ 28] (bl! (not t1-1) L23 (no-delay!)) [t1: symbol ] -> []
B5:
or a3, t1, r0 ;; [ 29] (set! a3-2 t1-1) [t1: symbol ] -> [a3: symbol ]
B6:
mtc1 f2, r0 ;; [ 30] (set! f2-4 0) [] -> []
c.lt.s f0, f2 ;; [ 31] (b! (>=.s f0-4 f2-4) L21 (set! t1-2 #t)) [] -> [t1: symbol ]
bc1f L21
daddiu t1, s7, 8
B7:
or t1, s7, r0 ;; [ 32] (set! t1-2 #f) [] -> [t1: '#f ]
B8:
L21:
beql s7, t1, L23 ;; [ 33] (bl! (not t1-2) L23 (no-delay!)) [t1: symbol ] -> []
B9:
or a3, t1, r0 ;; [ 34] (set! a3-2 t1-2) [t1: symbol ] -> [a3: symbol ]
B10:
lwc1 f2, 16(a3) ;; [ 35] (set! f2-5 (l.f (+ a3-1 16))) [a3: air-box ] -> []
c.lt.s f1, f2 ;; [ 36] (b! (<.s f1-5 f2-5) L22 (set! t1-3 #t)) [] -> [t1: symbol ]
bc1t L22
daddiu t1, s7, 8
B11:
or t1, s7, r0 ;; [ 37] (set! t1-3 #f) [] -> [t1: '#f ]
B12:
L22:
beql s7, t1, L23 ;; [ 38] (bl! (not t1-3) L23 (no-delay!)) [t1: symbol ] -> []
B13:
or a3, t1, r0 ;; [ 39] (set! a3-2 t1-3) [t1: symbol ] -> [a3: symbol ]
B14:
lwc1 f1, 24(a3) ;; [ 40] (set! f1-6 (l.f (+ a3-1 24))) [a3: air-box ] -> []
c.lt.s f0, f1 ;; [ 41] (b! (<.s f0-4 f1-6) L23 (set! a3-2 #t)) [] -> [a3: symbol ]
bc1t L23
daddiu a3, s7, 8
B15:
or a3, s7, r0 ;; [ 42] (set! a3-2 #f) [] -> [a3: '#f ]
B16:
L23:
beq s7, a3, L24 ;; [ 43] (b! (not a3-2) L24 (set! a3-3 #f)) [a3: symbol ] -> [a3: '#f ]
or a3, s7, r0
B17:
daddiu t0, s7, #t ;; [ 44] (set! t0-0 #t) [] -> [t0: symbol ]
or a3, t0, r0 ;; [ 45] (set! a3-4 t0-0) [t0: symbol ] -> [a3: symbol ]
B18:
L24:
beq s7, t0, L25 ;; [ 46] (b! (not t0-0) L25 (set! a3-5 #f)) [t0: symbol ] -> [a3: '#f ]
or a3, s7, r0
B19:
daddiu v1, s7, #t ;; [ 47] (set! v1-1 #t) [] -> [v1: symbol ]
or v0, v1, r0 ;; [ 48] (set! v0-0 v1-1) [v1: symbol ] -> [v0: symbol ]
beq r0, r0, L27 ;; [ 49] (b! #t L27 (nop!)) [] -> []
sll r0, r0, 0
B20:
or v1, r0, r0 ;; [ 50] (set! v1-0 0) [] -> [v1: <uninitialized> ]
B21:
L25:
daddiu v1, v1, 1 ;; [ 51] (set! v1-0 (+ v1-0 1)) [v1: int ] -> [v1: <integer 1 + int> ]
B22:
L26:
slt a3, v1, a2 ;; [ 52] (b! (<.si v1-0 arg2) L19 (nop!)) [v1: int a2: int ] -> []
bne a3, r0, L19
sll r0, r0, 0
B23:
or v1, s7, r0 ;; [ 53] (set! v1-2 #f) [] -> [v1: '#f ]
or v1, s7, r0 ;; [ 54] (set! v1-3 #f) [] -> [v1: '#f ]
or v0, s7, r0 ;; [ 55] (set! v0-0 #f) [] -> [v0: '#f ]
B24:
L27:
jr ra
daddu sp, sp, r0
;;-*-OpenGOAL-Start-*-
(defun point-in-air? ((arg0 vector) (arg1 (inline-array air-box)) (arg2 int))
(local-vars (t0-0 symbol))
(dotimes (v1-0 arg2)
(let ((t1-0 arg0)
(a3-1 (-> arg1 v1-0))
)
(set! t0-0
(when (< (-> a3-1 height-level) (-> t1-0 y))
(let ((f0-2 (- (-> t1-0 x) (-> a3-1 x-pos)))
(f2-1 (- (-> t1-0 z) (-> a3-1 z-pos)))
)
(set! t0-0 #f)
(let ((f1-5 (+ (* f0-2 (-> a3-1 cos-angle)) (* f2-1 (-> a3-1 sin-angle))))
(f0-4 (- (* f2-1 (-> a3-1 cos-angle)) (* f0-2 (-> a3-1 sin-angle))))
)
(if (and (>= f1-5 0.0) (>= f0-4 0.0) (< f1-5 (-> a3-1 x-length)) (< f0-4 (-> a3-1 z-length)))
(set! t0-0 #t)
)
)
)
t0-0
)
)
)
(if t0-0
(return #t)
)
)
#f
)
;;-*-OpenGOAL-End-*-
;; .endfunction
L28:
.word 0x0
.word 0x0

12
tsconfig.json Normal file
View file

@ -0,0 +1,12 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2020",
"lib": ["es2020"],
"outDir": "out",
"sourceMap": true,
"strict": true,
"rootDir": "src"
},
"exclude": ["node_modules", ".vscode-test"]
}