mirror of
https://github.com/elliotnunn/boot3.git
synced 2024-12-27 14:29:42 +00:00
5b0f0cc134
Resource forks are included only for .rsrc files. These are DeRezzed into their data fork. 'ckid' resources, from the Projector VCS, are not included. The Tools directory, containing mostly junk, is also excluded.
330 lines
6.8 KiB
Plaintext
330 lines
6.8 KiB
Plaintext
;
|
|
; File: Angles.m.a
|
|
;
|
|
; Contains: xxx put contents here (or delete the whole line) xxx
|
|
;
|
|
; Written by: xxx put name of writer here (or delete the whole line) xxx
|
|
;
|
|
; Copyright: © 1988-1990 by Apple Computer, Inc., all rights reserved.
|
|
;
|
|
; Change History (most recent first):
|
|
;
|
|
; <2> 10/10/90 JL Change FixRatio to MFixRatio to avoid conflict with Traps.a
|
|
; <1.1> 11/11/88 CCH Fixed Header.
|
|
; <1.0> 11/9/88 CCH Adding to EASE.
|
|
; <1.2> 10/12/88 CCH Changed Òm.GrafType.aÓ to ÒGrafType.m.aÓ.
|
|
; <1.1> 5/18/88 MSH Changed inclides to use m.GRAPHTYPES to work under EASE.
|
|
; <1.0> 2/11/88 BBM Adding file for the first time into EASEÉ
|
|
;
|
|
; To Do:
|
|
;
|
|
|
|
;EASE$$$ READ ONLY COPY of file ÒANGLES.m.aÓ
|
|
; 1.1 CCH 11/11/1988 Fixed Header.
|
|
; 1.0 CCH 11/ 9/1988 Adding to EASE.
|
|
; OLD REVISIONS BELOW
|
|
; 1.2 CCH 10/12/1988 Changed Òm.GrafType.aÓ to ÒGrafType.m.aÓ.
|
|
; 1.1 MSH 5/18/88 Changed inclides to use m.GRAPHTYPES to work under EASE.
|
|
; 1.0 BBM 2/11/88 Adding file for the first time into EASEÉ
|
|
; END EASE MODIFICATION HISTORY
|
|
BLANKS ON
|
|
STRING ASIS
|
|
|
|
INCLUDE 'GrafTypes.m.a'
|
|
|
|
AngleFromSlope FUNC EXPORT
|
|
EXPORT SlopeFromAngle
|
|
;-----------------------------------------------------
|
|
;
|
|
; FUNCTION AngleFromSlope(slope: Fixed): INTEGER;
|
|
;
|
|
; Scans slope table for angle and returns angle 0..180
|
|
;
|
|
MOVE.L 4(SP),D0 ;GET SLOPE
|
|
SMI D2 ;REMEMBER IF IT WAS NEGATIVE
|
|
BPL.S NOTNEG ;CONTINUE IF POSITIVE
|
|
NEG.L D0 ;ELSE MAKE SLOPE POS
|
|
NOTNEG SUB.L #500,D0 ;BIAS THE COMPARE
|
|
MOVE.L D0,4(SP)
|
|
LEA CONTINUE,A0 ;POINT TO TABLE OF SLOPES
|
|
MOVEQ #-1,D1 ;INIT ANGLE COUNT
|
|
SCAN ADD.W #1,D1
|
|
MOVE.W D1,D0
|
|
CLR.L -(SP)
|
|
BRA.S A2SLOPE
|
|
CONTINUE
|
|
MOVE.L 8(SP),D0 ;GET SLOPE
|
|
CMP.L (SP)+,D0 ;SCAN THRU SLOPE TABLE
|
|
BGT.S SCAN
|
|
MOVE #180,D0
|
|
SUB D1,D0 ;CALC 180-ANGLE = 90..180
|
|
TST.B D2 ;WAS DH POS ?
|
|
BPL.S DONE ;NO, RETURN 90..180
|
|
MOVE D1,D0 ;YES, RETURN 0..90
|
|
DONE MOVE.L (SP)+,(SP) ;STRIP PARAM
|
|
MOVE.W D0,4(SP) ;RETURN FUNCTION RESULT
|
|
RTS
|
|
|
|
|
|
|
|
;----------------------------------------------------------------
|
|
;
|
|
; FUNCTION SlopeFromAngle(angle: INTEGER): Fixed;
|
|
;
|
|
; calculate the fixed point slope of a line, DH/DV = -65536 * Tan(angle).
|
|
; Input angle is treated MOD 180.
|
|
;
|
|
SlopeFromAngle
|
|
MOVE.L (SP)+,A0 ;POP RETURN ADDR
|
|
MOVE (SP)+,D0 ;GET INTEGER ANGLE
|
|
EXT.L D0 ;SIGN EXTEND FOR DIVIDE
|
|
DIVS #180,D0 ;TREAT ANGLE MOD 180
|
|
SWAP D0 ;GET THE REMAINDER
|
|
TST D0 ;WAS IT NEGATIVE ?
|
|
BPL.S OK1 ;NO, CONTINUE
|
|
ADD #180,D0 ;YES, PUT IN RANGE 0..179
|
|
OK1 MOVE #$8000,(SP)
|
|
A2SLOPE CMP #90,D0
|
|
BLE.S OK2
|
|
CLR.W (SP)
|
|
SUB #180,D0
|
|
NEG D0
|
|
OK2 CMP #45,D0
|
|
BLT.S SHARE
|
|
ADD #1,(SP)
|
|
CMP #64,D0
|
|
BLT.S SHARE
|
|
MOVE.B SLOPE-91(D0),1(SP)
|
|
BPL.S SHARE
|
|
OR.B #$7F,(SP)
|
|
SHARE ADD D0,D0
|
|
MOVE.W SLOPE(D0),2(SP)
|
|
CHECK BCLR #7,(SP)
|
|
BEQ.S OK3
|
|
NEG.L (SP)
|
|
OK3 JMP (A0)
|
|
|
|
|
|
|
|
; .BYTE $01 ;45
|
|
; .BYTE $01
|
|
; .BYTE $01
|
|
; .BYTE $01
|
|
; .BYTE $01
|
|
; .BYTE $01 ;50
|
|
; .BYTE $01
|
|
; .BYTE $01
|
|
; .BYTE $01
|
|
; .BYTE $01
|
|
; .BYTE $01 ;55
|
|
; .BYTE $01
|
|
; .BYTE $01
|
|
; .BYTE $01
|
|
; .BYTE $01
|
|
; .BYTE $01 ;60
|
|
; .BYTE $01
|
|
; .BYTE $01
|
|
DC.B $01
|
|
DC.B $02
|
|
DC.B $02 ;65
|
|
DC.B $02
|
|
DC.B $02
|
|
DC.B $02
|
|
DC.B $02
|
|
DC.B $02 ;70
|
|
DC.B $02
|
|
DC.B $03
|
|
DC.B $03
|
|
DC.B $03
|
|
DC.B $03 ;75
|
|
DC.B $04
|
|
DC.B $04
|
|
DC.B $04
|
|
DC.B $05
|
|
DC.B $05 ;80
|
|
DC.B $06
|
|
DC.B $07
|
|
DC.B $08
|
|
DC.B $09
|
|
DC.B $0B ;85
|
|
DC.B $0E
|
|
DC.B $13
|
|
DC.B $1C
|
|
DC.B $39
|
|
DC.B $FF ;90
|
|
SLOPE
|
|
DC.W $0000 ;0
|
|
DC.W $0478
|
|
DC.W $08F1
|
|
DC.W $0D6B
|
|
DC.W $11E7
|
|
DC.W $1666 ;5
|
|
DC.W $1AE8
|
|
DC.W $1F6F
|
|
DC.W $23FA
|
|
DC.W $288C
|
|
DC.W $2D24 ;10
|
|
DC.W $31C3
|
|
DC.W $366A
|
|
DC.W $3B1A
|
|
DC.W $3FD4
|
|
DC.W $4498 ;15
|
|
DC.W $4968
|
|
DC.W $4E44
|
|
DC.W $532E
|
|
DC.W $5826
|
|
DC.W $5D2D ;20
|
|
DC.W $6245
|
|
DC.W $676E
|
|
DC.W $6CAA
|
|
DC.W $71FB
|
|
DC.W $7760 ;25
|
|
DC.W $7CDC
|
|
DC.W $8270
|
|
DC.W $881E
|
|
DC.W $8DE7
|
|
DC.W $93CD ;30
|
|
DC.W $99D2
|
|
DC.W $9FF7
|
|
DC.W $A640
|
|
DC.W $ACAD
|
|
DC.W $B341 ;35
|
|
DC.W $B9FF
|
|
DC.W $C0E9
|
|
DC.W $C802
|
|
DC.W $CF4E
|
|
DC.W $D6CF ;40
|
|
DC.W $DE8A
|
|
DC.W $E681
|
|
DC.W $EEB9
|
|
DC.W $F737
|
|
DC.W $0000 ;45
|
|
DC.W $0919
|
|
DC.W $1287
|
|
DC.W $1C51
|
|
DC.W $267F
|
|
DC.W $3117 ;50
|
|
DC.W $3C22
|
|
DC.W $47AA
|
|
DC.W $53B9
|
|
DC.W $605B
|
|
DC.W $6D9B ;55
|
|
DC.W $7B89
|
|
DC.W $8A35
|
|
DC.W $99AF
|
|
DC.W $AA0E
|
|
DC.W $BB68 ;60
|
|
DC.W $CDD6
|
|
DC.W $E177
|
|
DC.W $F66E
|
|
DC.W $0CE1
|
|
DC.W $24FE ;65
|
|
DC.W $3EFC
|
|
DC.W $5B19
|
|
DC.W $799F
|
|
DC.W $9AE7
|
|
DC.W $BF5B ;70
|
|
DC.W $E77A
|
|
DC.W $13E3
|
|
DC.W $4556
|
|
DC.W $7CC7
|
|
DC.W $BB68 ;75
|
|
DC.W $02C2
|
|
DC.W $54DB
|
|
DC.W $B462
|
|
DC.W $2501
|
|
DC.W $ABD9 ;80
|
|
DC.W $5051
|
|
DC.W $1D88
|
|
DC.W $24F3
|
|
DC.W $83AD
|
|
DC.W $6E17 ;85
|
|
DC.W $4CF5
|
|
DC.W $14BD
|
|
DC.W $A2D7
|
|
DC.W $4A30
|
|
DC.W $FFFF ;90
|
|
|
|
|
|
PtToAngle PROC EXPORT
|
|
IMPORT AngleFromSlope
|
|
;--------------------------------------------------------------
|
|
;
|
|
; PROCEDURE PtToAngle(r: Rect; pt: Point; VAR angle: INTEGER);
|
|
;
|
|
; Given a rectangle and a point, return the angle subtended by pt.
|
|
;
|
|
; A6 OFFSETS OF PARAMETERS AFTER LINK:
|
|
;
|
|
PARAMSIZE EQU 12 ;TOTAL BYTES OF PARAMS
|
|
RECT EQU PARAMSIZE+8-4 ;ADDR OF RECT
|
|
PT EQU RECT-4 ;POINT
|
|
ANGLE EQU PT-4 ;ADDR OF INTEGER;
|
|
|
|
LINK A6,#0 ;NO LOCALS
|
|
MOVEM.L D6-D7/A4,-(SP) ;SAVE REGS
|
|
MOVE.L RECT(A6),A4 ;POINT TO RECT
|
|
|
|
MOVE BOTTOM(A4),D0
|
|
ADD TOP(A4),D0
|
|
ASR #1,D0 ;CENTER.V := (TOP+BOTTOM)/2
|
|
MOVE PT+V(A6),D1
|
|
SUB D0,D1 ;DV := PT.V - CENTER.V
|
|
|
|
MOVE RIGHT(A4),D0
|
|
ADD LEFT(A4),D0
|
|
ASR #1,D0 ;CENTER.H := (LEFT+RIGHT)/2
|
|
MOVE PT+H(A6),D7
|
|
SUB D0,D7 ;DH := PT.H - CENTER.H
|
|
BNE.S DHOK ;CONTINUE IF DH <> 0
|
|
TST D1 ;WAS DV > 0 ?
|
|
BLE.S ZERO ;NO, RETURN ANGLE = 0
|
|
MOVE #180,D0 ;YES, RETURN ANGLE = 180
|
|
BRA.S DONE
|
|
|
|
DHOK CLR.L -(SP) ;ROOM FOR FCN RESULT
|
|
MOVE D7,-(SP) ;PUSH DH
|
|
MOVE D1,-(SP) ;PUSH DV
|
|
_MFixRatio ;CALC SLOPE := DH/DV
|
|
MOVE.L (SP)+,D6 ;GET SLOPE RESULT
|
|
|
|
CLR.L -(SP) ;ROOM FOR FCN RESULT
|
|
MOVE BOTTOM(A4),D0
|
|
SUB TOP(A4),D0
|
|
MOVE D0,-(SP) ;PUSH HEIGHT
|
|
MOVE RIGHT(A4),D0
|
|
SUB LEFT(A4),D0
|
|
MOVE D0,-(SP) ;PUSH WIDTH
|
|
_MFixRatio ;CALC ASPECT := HT/WD
|
|
MOVE.L (SP)+,D0 ;GET ASPECT RESULT
|
|
|
|
CLR.L -(SP) ;ROOM FOR FCN RESULT
|
|
MOVE.L D6,-(SP) ;PUSH SLOPE
|
|
MOVE.L D0,-(SP) ;PUSH ASPECT
|
|
_MFixMul ;CALC SLOPE*ASPECT
|
|
MOVE.L (SP)+,D0 ;GET RESULT SLOPE2
|
|
|
|
CLR.W -(SP) ;ROOM FOR FCN RESULT
|
|
MOVE.L D0,-(SP) ;PUSH SLOPE2
|
|
JSR AngleFromSlope ;SCAN FOR ARCTAN
|
|
MOVE (SP)+,D0 ;GET RESULT ANGLE
|
|
|
|
TST D7 ;WAS DH POSITIVE ?
|
|
BPL.S DONE ;YES, CONTINUE
|
|
ADD #180,D0 ;NO, ADD 180 TO ANG
|
|
CMP #360,D0 ;IS RESULT = 360 ?
|
|
BNE.S DONE ;NO, CONTINUE
|
|
ZERO CLR D0 ;YES, ANGLE := 0
|
|
DONE MOVE.L ANGLE(A6),A0 ;GET VAR ADDR
|
|
MOVE D0,(A0) ;STORE INTO ANGLE
|
|
MOVEM.L (SP)+,D6-D7/A4 ;RESTORE REGS
|
|
UNLINK PARAMSIZE,'PTTOANGL'
|
|
|
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|