;Copyright (C) 2008 Pierre Baudemont ; ; This file is part of bf. ; ; bf is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; bf is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with bf; if not, write to the Free Software ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ;------------------------------------------------------------------------------; ;|vat lib - vat_var_open |; ;|given a var SYM name ( \ or , the last will search in |; ;|the current folder ), return the adress of its RAM page |; ;| |; ;|STACK PARAMS (push in this order): |; ;|- var name, which must be a SYM_STR ! (null byte at the beginning and at |; ;|the end of the string, and the pointeur must ref the final zero byte !) |; ;| |; ;|RETURN |; ;|- a0 : adress of the var page, null on error (ex: var not found, ...) |; ;------------------------------------------------------------------------------; section ".data" include "OS.h" xdef vat_var_open vat_var_open: ; save the used registries move.l a2,-(a7) ; put the ROM CALL table adr in a2 move.l $C8,a2 ; perform the SymFindPtr ROM CALL clr.w -(a7) ; search the given folder move.l 10(a7),-(a7) ; get the name from the stack (param) move.l SymFindPtr*4(a2),a0 ; adr of the ROM CALL put in a0 jsr (a0) ; perform the ROM CALL, result in a0 addq.l #6,a7 ; clean the stack ; if a0 is null, an error occurred (ex: var not found,...) move.l a0,d0 tst.l d0 beq error ; on an error go to the end of the function (return null) ; perform the HeapDeref ROM CALL move.w 12(a0),-(a7) ; HeapDeref needs the handle as param move.l HeapDeref*4(a2),a0 jsr (a0) ; result in a0 addq.l #2,a7 ; clean the stack error: ; restore the saved registries move.l (a7)+,a2 rts