jak-project/test/goalc/source_templates/with_game/test-bitfield-access.gc
water111 21fbdce7aa
[Compiler] Bitfield Types (#146)
* add the ability to define and read bitfield types

* new set

* add bitfield setting

* add static bitfields
2020-11-29 18:01:30 -05:00

21 lines
564 B
Common Lisp

(deftype test-bf-type (int32)
((f1 int16 :offset 0)
(f2 uint8 :offset 16)
(f3 int8 :size 3 :offset 24)
(f4 uint8 :size 2 :offset 27)
(f5 int8 :size 2 :offset 29)
)
)
(deftype test-bf-type2 (int64)
((f1 int16 :offset 0)
(f2 uint8 :offset 16)
(f3 float :offset 24)
)
)
(let ((temp (the test-bf-type #xf9f2f344))
(temp2 (the test-bf-type2 #x133f456789012345)))
(format #t "~A" (< (fabs (- 1.7711 (+ 1.0 (-> temp2 f3)))) 0.002))
(format #t "~X~X~X~X~X~%" (-> temp f1) (-> temp f2) (-> temp f3) (-> temp f4) (-> temp f5))
)