jak-project/test/goalc/source_templates/with_game/test-basic-vector-math.gc
Tyler Wilding 65206823ef
Compiler - Implementing more VU Instructions (Part 1 of 2) (#221)
* A little project cleanup

* Script to grep decompiler results

* Compiler: Implement VNOP -> FNOP (.nop.vf)


temp: test new addition

* Compiler: Implement VMUL.xyzw (.mul.vf)


squash: cleaning up files i don't want to accidentally stage

* Compiler: Implement V[ADD|SUB|MUL].dest instructions

* Compiler:  Implement V[ADD|SUB|MUL][x|y|w|z].dest instructions

* Compiler: Implement V[MIN|MAX]{[x|y|z|w]}.dest instructions

* Compiler: Implement V[ABS]{[x|y|z|w]}.dest instructions

* Cleanup review feedback before adding tests and docs

* Tests: Added missing emitter tests

* tests/compiler: Comprehensively test all new instructions

* docs: Add documentation for newly supported operations

* Remove unused vector-h function

* Address review feedback
2021-02-05 15:00:17 -05:00

24 lines
641 B
Common Lisp

(defun test-basic-vector-math ()
(let ((vector-0 (new 'stack 'vector))
(vector-1 (new 'stack 'vector))
(vector-2 (new 'stack 'vector)))
(set! (-> vector-0 x) 1.0)
(set! (-> vector-0 y) 2.0)
(set! (-> vector-0 z) 3.0)
(set! (-> vector-0 w) 4.0)
(set! (-> vector-1 x) 10.0)
(set! (-> vector-1 y) 20.0)
(set! (-> vector-1 z) 30.0)
(set! (-> vector-1 w) 40.1)
(.nop.vf)
(vector-! vector-2 vector-1 vector-0)
(.nop.vf)
; 9 + 18 + 27 = 54.0000
(format #t "~f~%" (+ (-> vector-2 x) (-> vector-2 y) (-> vector-2 z) (-> vector-2 w)))
)
)
(test-basic-vector-math)