1 REM Ins{nd av Hans Holmberg <2838>    1987-05-24 04.05.38 (DUMP)
       BEGIN:   ORG 8000H
                             ;
                             ;IN:A =Tal, BC =vinkel i grader
                             ;
                             ;UT:A =A*cos BC
                             ;
       COS:     AND A
                RET Z
                PUSH DE
                CALL COSOMV
                JR SIN2
                             ;
                             ;IN:A =Tal, BC =vinkel i grader
                             ;
                             ;UT:A =A*sin BC
                             ;
       SIN:     AND A
                RET Z
                PUSH DE
                CALL SINOMV
       SIN2:    LD HL,TAB
                ADD HL,BC
                LD E,(HL)
                LD D,0
                LD H,D
                LD L,D
                LD B,8
                CALL MULT
                ADD HL,HL
                LD A,H
                POP DE
                RET NC
                CPL
                RET
                ;
                ;
       COSOMV:  PUSH AF
                LD A,B
                AND A
                JR NZ,COSOMV2
                LD A,C
                CP 90
                JR NC,COSOMV2
                LD HL,360
                ADD HL,BC
                LD B,H
                LD C,L
       COSOMV2: POP AF
                LD H,B
                LD L,C
                LD BC,90
                AND A
                SBC HL,BC
                JR SINOMV2
       SINOMV:  LD H,B
                LD L,C
       SINOMV2: LD BC,180
                AND A
                SBC HL,BC
                JR NC,SINOMV3
                ADD HL,BC
       SINOMV3: LD H,B
                LD L,C
                RET
                ;
       MULT:    LD B,8
       MULT2:   AND A
                RET Z
                SRL A
                JR NC,MULT3
                ADD HL,DE
       MULT3:   EX DE,HL
                ADD HL,HL
                EX DE,HL
                DJNZ MULT2
                RET
                ;
       TAB:     EQU $        ;Sin/cos tab med 180 v{rden
                ;            ;x=int(sin(v)*256) d{r v=0-179 grader
       TABEND:  EQU $+180    ;
                ;
                END
                ;
                ;(C) Hans Holmberg 1986
                ;
