home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_progs
/
scrnutil
/
scrnshft.lzh
/
SCREENSHIFT
/
MATH.S
< prev
next >
Wrap
Text File
|
1991-08-16
|
2KB
|
59 lines
;**********************************************************************
; Math routines for converting HorizPot/VertPot values
; to and from ViewXOffset/ViewYOffset values
; (I don't want to do it in C!)
; Anson Mah
;
; Declarations:
; extern UWORD xoffset(BYTE), yoffset(BYTE);
; extern BYTE xpot(UWORD), ypot(UWORD);
;**********************************************************************
;
MAXXOFFSET equ $003f
MAXYOFFSET equ $001f
HALFBODY equ $7ffe ; MAXBODY / 2
;
xdef _xoffset
xdef _yoffset
xdef _xpot
xdef _ypot
;
;**********************************************************************
; _xoffset and _yoffset to convert from offset to pot value
;**********************************************************************
;
_xoffset
move.l #MAXXOFFSET,d1 ; load maximum x offset value
bra.s offs ; jump to offset routine
_yoffset
move.l #MAXYOFFSET,d1 ; load maximum y offset value
;
offs move.l 4(sp),d0 ; get ViewOffset value
muls #HALFBODY,d0
divs d1,d0 ; divide by maximum offset value
addi.w #HALFBODY,d0
rts ; return result in d0
;
;**********************************************************************
; _xpot and _ypot to convert from pot to offset value
;**********************************************************************
;
_xpot
move.l #MAXXOFFSET,d1 ; load maximum x offset value
bra.s pot ; jump to pot routine
_ypot
move.l #MAXYOFFSET,d1 ; load maximum y offset value
pot move.l 4(sp),d0 ; get pot value
beq.s 1$
subi.w #1,d0 ; subtract two if not zero (kludge)
beq.s 1$
subi.w #1,d0
1$ subi.w #HALFBODY,d0
muls d1,d0 ; multiply by maximum offset value
divs #HALFBODY,d0
rts ; return result in d0
;
;**********************************************************************
end