;; Object tree
-(defun ez-make-obj (&optional name attribs props parent first-child next-sibling)
- (list name attribs props parent first-child next-sibling))
-
-(defun ez-obj-name (obj) (elt obj 0))
-(defun ez-obj-attribs (obj) (elt obj 1))
-(defun ez-obj-props (obj) (elt obj 2))
-(defun ez-obj-parent (obj) (elt obj 3))
-(defun ez-obj-first-child (obj) (elt obj 4))
-(defun ez-obj-next-sibling (obj) (elt obj 5))
-
(defvar ez-property-defaults nil)
(defun ez-load-property-defaults ()
(dotimes (i 31)
(aset ez-property-defaults i (aref ez-memory (+ ez-objtab-addr (* 2 i))))))
+(defun ez-get-obj-addr (obj-id)
+ (+ ez-objtab-addr (* 2 31) (* 9 (- obj-id 1))))
+
+(defun ez-get-obj-parent (obj-id)
+ (let ((addr (ez-get-obj-addr obj-id)))
+ (ez-mem-ref-byte (+ addr 4))))
+
+(defun ez-get-obj-sibling (obj-id)
+ (let ((addr (ez-get-obj-addr obj-id)))
+ (ez-mem-ref-byte (+ addr 5))))
+
+(defun ez-get-obj-child (obj-id)
+ (let ((addr (ez-get-obj-addr obj-id)))
+ (ez-mem-ref-byte (+ addr 6))))
+
+(defun ez-get-obj-plist-addr (obj-id)
+ (let ((addr (ez-get-obj-addr obj-id)))
+ (ez-mem-ref-word (+ addr 7))))
+
+(defun ez-get-obj-name (obj-id)
+ (let ((plist-addr (ez-get-obj-plist-addr obj-id)))
+ (if (> (ez-mem-ref-byte plist-addr) 0)
+ (ez-get-zstring (+ 1 (ez-get-obj-plist-addr obj-id)))
+ nil)))
+
(defun ez-get-obj (obj-id)
(let ((addr (+ ez-objtab-addr
(* 2 31)
(let ((plist-addr (ez-mem-ref-word (+ addr 7))))
(if (> (ez-mem-ref-byte plist-addr) 0)
(ez-get-zstring (+ 1 plist-addr))
- "")))))
+ nil)))))
;; Z-strings
((memq char '(1 2 3)) ;Abbreviation
(setq abbrev-char char))
((= char 4)
- (setq cur (mod (+ cur 1) 2)))
+ (setq cur (mod (+ cur 1) 3)))
((= char 5)
- (setq cur (mod (+ 2 (- cur 1)) 2)))
+ (setq cur (mod (+ 3 (- cur 1)) 3)))
(t
(setq s (concat s (substring (elt ez-zstring-alphabets cur)
char (+ char 1))))
operand-types (cdr operands-and-types)))))
(let ((table-row (assoc (list optype opcode) ez-op-table)))
(unless table-row
- (error "Unsupported op" optype opcode))
+ (error "Unsupported op" instr-pc optype opcode operands operand-types))
(let ((mnemonic (elt table-row 1)))
(message "PC:%x Optype:%s Opcode:%x Mnemonic:%s Operands:%s"
instr-pc optype opcode mnemonic operands))
(setq ez-call-stack (list (ez-make-call-stack-frame ez-start-pc)))
(ez-execute-instr)
+(while (ez-execute-instr))
+
(binformat #x97)
"10010111"
+(ez-get-obj 208)
+(binformat #x57)
+"01010111"
+
ez-call-stack