home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / disks / disk390.lzh / SM / math.s < prev    next >
Text File  |  1990-10-23  |  2KB  |  70 lines

  1.     CSECT    "text",0,,2,2
  2.  
  3.  
  4. ;**********************************************************************
  5. ; Math routines for converting HorizPot/VertPot values
  6. ; to and from ViewXOffset/ViewYOffset values
  7. ; (I don't want to do it in C!)
  8. ; Anson Mah
  9. ;
  10. ; changes for Lettuce-C by Ølli
  11. ;
  12. ; Declarations:
  13. ;  extern UWORD xoffset(BYTE), yoffset(BYTE);
  14. ;  extern BYTE xpot(UWORD), ypot(UWORD);
  15. ;**********************************************************************
  16. ;
  17. MAXXOFFSET    equ    $003f
  18. MAXYOFFSET    equ    $001f
  19. HALFBODY    equ    $7ffe    ; MAXBODY / 2
  20. ;
  21.     xdef    @xoffset
  22.     xdef    @yoffset
  23.     xdef    @xpot
  24.     xdef    @ypot
  25. ;
  26. ;**********************************************************************
  27. ; _xoffset and _yoffset to convert from offset to pot value
  28. ;**********************************************************************
  29. ;
  30. @xoffset
  31.     move.l    #MAXXOFFSET,d1    ; load maximum x offset value
  32.     bra.s    offs        ; jump to offset routine
  33. @yoffset
  34.     move.l    #MAXYOFFSET,d1    ; load maximum y offset value
  35. ;
  36. offs
  37. ;    move.l    4(sp),d0        ; get ViewOffset value
  38. ; ^^^^ commented due lattice will load directly into D0
  39.  
  40.     muls    #HALFBODY,d0
  41.     divs    d1,d0        ; divide by maximum offset value
  42.     addi.w    #HALFBODY,d0
  43.     rts            ; return result in d0
  44. ;
  45. ;**********************************************************************
  46. ; _xpot and _ypot to convert from pot to offset value
  47. ;**********************************************************************
  48. ;
  49. @xpot
  50.     move.l    #MAXXOFFSET,d1    ; load maximum x offset value
  51.     bra.s    pot        ; jump to pot routine
  52. @ypot
  53.     move.l    #MAXYOFFSET,d1    ; load maximum y offset value
  54.  
  55. pot
  56. ;    move.l    4(sp),d0        ; get pot value
  57. ; ^^^^ see abouve
  58.  
  59.     beq.s    1$
  60.     subi.w    #1,d0        ; subtract two if not zero (kludge)
  61.     beq.s    1$
  62.     subi.w    #1,d0
  63. 1$    subi.w    #HALFBODY,d0
  64.     muls    d1,d0        ; multiply by maximum offset value
  65.     divs    #HALFBODY,d0
  66.     rts            ; return result in d0
  67. ;
  68. ;**********************************************************************
  69.     end
  70.