home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
fish
/
system_utils
/
windows&screens
/
sm
/
math.s
< prev
next >
Wrap
Text File
|
1990-10-23
|
2KB
|
70 lines
CSECT "text",0,,2,2
;**********************************************************************
; Math routines for converting HorizPot/VertPot values
; to and from ViewXOffset/ViewYOffset values
; (I don't want to do it in C!)
; Anson Mah
;
; changes for Lettuce-C by Ølli
;
; 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
; ^^^^ commented due lattice will load directly into D0
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
; ^^^^ see abouve
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