]> git.sur5r.net Git - cc65/commitdiff
Code review adaptations, removed "cc65_" prefix from functions
authorIrgendwerA8 <c.krueger.b@web.de>
Fri, 29 Mar 2019 21:36:01 +0000 (22:36 +0100)
committerOliver Schmidt <ol.sc@web.de>
Fri, 29 Mar 2019 21:53:04 +0000 (22:53 +0100)
31 files changed:
doc/funcref.sgml
include/cc65.h
include/specialmath.h [deleted file]
libsrc/atari/cputc.s
libsrc/atari/mcbtxtchar.s
libsrc/atari/scroll.s
libsrc/atari/setcursor.s
libsrc/atari5200/cputc.s
libsrc/common/_mul20.s [deleted file]
libsrc/common/_mul40.s [deleted file]
libsrc/common/cc65_idiv32by16r16.s [deleted file]
libsrc/common/cc65_imul16x16r32.s [deleted file]
libsrc/common/cc65_imul8x8r16.s [deleted file]
libsrc/common/cc65_sincos.s [deleted file]
libsrc/common/cc65_udiv32by16r16.s [deleted file]
libsrc/common/cc65_umul16x16r32.s [deleted file]
libsrc/common/cc65_umul16x8r32.s [deleted file]
libsrc/common/cc65_umul8x8r16.s [deleted file]
libsrc/common/idiv32by16r16.s [new file with mode: 0644]
libsrc/common/imul16x16r32.s [new file with mode: 0644]
libsrc/common/imul8x8r16.s [new file with mode: 0644]
libsrc/common/mul20.s [new file with mode: 0644]
libsrc/common/mul40.s [new file with mode: 0644]
libsrc/common/sincos.s [new file with mode: 0644]
libsrc/common/udiv32by16r16.s [new file with mode: 0644]
libsrc/common/umul16x16r32.s [new file with mode: 0644]
libsrc/common/umul16x8r32.s [new file with mode: 0644]
libsrc/common/umul8x8r16.s [new file with mode: 0644]
libsrc/tgi/tgi_arc.c
libsrc/tgi/tgi_pieslice.c
test/val/lib_common_mulxx.c

index f995d29821ce5ea301a770248b5df3c97a8b35b6..c715b3a2abfc1f1168a4444b26906cd5397459da 100644 (file)
@@ -243,16 +243,19 @@ function.
 <sect1><tt/cc65.h/<label id="cc65.h"><p>
 
 <itemize>
-<!-- <item><ref id="cc65_cos" name="cc65_cos"> -->
-<!-- <item><ref id="cc65_idiv32by16r16" name="cc65_idiv32by16r16"> -->
-<!-- <item><ref id="cc65_imul16x16r32" name="cc65_imul16x16r32"> -->
-<!-- <item><ref id="cc65_imul8x8r16" name="cc65_imul8x8r16"> -->
-<!-- <item><ref id="cc65_sin" name="cc65_sin"> -->
-<!-- <item><ref id="cc65_udiv32by16r16" name="cc65_udiv32by16r16"> -->
-<!-- <item><ref id="cc65_umul16x16r32" name="cc65_umul16x16r32"> -->
-<!-- <item><ref id="cc65_umul16x8r32" name="cc65_umul16x8r32"> -->
-<!-- <item><ref id="cc65_umul8x8r16" name="cc65_umul8x8r16"> -->
+
+<!-- <item><ref id="cos" name="cos"> -->
+<!-- <item><ref id="idiv32by16r16" name="idiv32by16r16"> -->
+<!-- <item><ref id="imul16x16r32" name="imul16x16r32"> -->
+<!-- <item><ref id="imul8x8r16" name="imul8x8r16"> -->
+<!-- <item><ref id="sin" name="sin"> -->
+<!-- <item><ref id="udiv32by16r16" name="udiv32by16r16"> -->
+<!-- <item><ref id="umul16x16r32" name="umul16x16r32"> -->
+<!-- <item><ref id="umul16x8r32" name="umul16x8r32"> -->
+<!-- <item><ref id="umul8x8r16" name="umul8x8r16"> -->
 <item><ref id="doesclrscrafterexit" name="doesclrscrafterexit">
+<item><ref id="mul20" name="mul20">
+<item><ref id="mul40" name="mul40">
 </itemize>
 
 (incomplete)
@@ -578,13 +581,6 @@ communication, see also <tt>testcode/lib/ser-test.c</tt>.
 <item><ref id="signal" name="signal">
 </itemize>
 
-<sect1><tt/specialmath.h/<label id="specialmath.h"><p>
-
-<itemize>
-<item><ref id="_mul20" name="_mul20">
-<item><ref id="_mul40" name="_mul40">
-</itemize>
-
 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
 
 (incomplete)
@@ -1026,30 +1022,6 @@ It returns 1 if it does.
 </descrip>
 </quote>
 
-<sect1>_mul20<label id="_mul20"><p>
-
-<quote>
-<descrip>
-<tag/Function/Multiplies argument by 20.
-<tag/Header/<tt/<ref id="specialmath.h" name="specialmath.h">/
-<tag/Declaration/<tt/unsigned int __fastcall__ _mul20(unsigned char value);/
-<tag/Description/Speed optimized function to multiply an 8 bit unsigned value by 20 to get a 16 bit result.
-<tag/Availability/cc65
-</descrip>
-</quote>
-
-<sect1>_mul40<label id="_mul40"><p>
-
-<quote>
-<descrip>
-<tag/Function/Multiplies argument by 40.
-<tag/Header/<tt/<ref id="specialmath.h" name="specialmath.h">/
-<tag/Declaration/<tt/unsigned int __fastcall__ _mul40(unsigned char value);/
-<tag/Description/Speed optimized function to multiply an 8 bit unsigned value by 40 to get a 16 bit result.
-<tag/Availability/cc65
-</descrip>
-</quote>
-
 <sect1>_poserror<label id="_poserror"><p>
 
 <quote>
@@ -5587,6 +5559,29 @@ memory allocated for the driver.
 </descrip>
 </quote>
 
+<sect1>mul20<label id="mul20"><p>
+
+<quote>
+<descrip>
+<tag/Function/Multiplies argument by 20.
+<tag/Header/<tt/<ref id="cc65.h" name="cc65.h">/
+<tag/Declaration/<tt/unsigned int __fastcall__ mul20(unsigned char value);/
+<tag/Description/Speed optimized function to multiply an 8 bit unsigned value by 20 to get a 16 bit result.
+<tag/Availability/cc65
+</descrip>
+</quote>
+
+<sect1>mul40<label id="mul40"><p>
+
+<quote>
+<descrip>
+<tag/Function/Multiplies argument by 40.
+<tag/Header/<tt/<ref id="cc65.h" name="cc65.h">/
+<tag/Declaration/<tt/unsigned int __fastcall__ mul40(unsigned char value);/
+<tag/Description/Speed optimized function to multiply an 8 bit unsigned value by 40 to get a 16 bit result.
+<tag/Availability/cc65
+</descrip>
+</quote>
 
 <sect1>offsetof<label id="offsetof"><p>
 
index 9b7b69a0e177bb8f253987be437df2147e576880..e596e93df070e6415a7fada387cb1904a22583ef 100644 (file)
 
 
 
-long __fastcall__ cc65_idiv32by16r16 (long rhs, int lhs);
+long __fastcall__ idiv32by16r16 (long rhs, int lhs);
 /* Divide a 32 bit signed value by a 16 bit signed value yielding a 16
 ** bit result and a 16 bit remainder. The former is returned in the lower 16
 ** bit of the result, the latter in the upper. If you don't need the
 ** remainder, just assign (or cast) to an int.
 */
 
-unsigned long __fastcall__ cc65_udiv32by16r16 (unsigned long rhs, unsigned lhs);
+unsigned long __fastcall__ udiv32by16r16 (unsigned long rhs, unsigned lhs);
 /* Divide a 32 bit unsigned value by a 16 bit unsigned value yielding a 16
 ** bit result and a 16 bit remainder. The former is returned in the lower 16
 ** bit of the result, the latter in the upper. If you don't need the
 ** remainder, just assign (or cast) to an unsigned.
 */
 
-int __fastcall__ cc65_imul8x8r16 (signed char lhs, signed char rhs);
+int __fastcall__ imul8x8r16 (signed char lhs, signed char rhs);
 /* Multiplicate two signed 8 bit to yield an signed 16 bit result */
 
-long __fastcall__ cc65_imul16x16r32 (int lhs, int rhs);
+long __fastcall__ imul16x16r32 (int lhs, int rhs);
 /* Multiplicate two signed 16 bit to yield a signed 32 bit result */
 
-unsigned __fastcall__ cc65_umul8x8r16 (unsigned char lhs, unsigned char rhs);
+unsigned __fastcall__ umul8x8r16 (unsigned char lhs, unsigned char rhs);
 /* Multiplicate two unsigned 8 bit to yield an unsigned 16 bit result */
 
-unsigned long __fastcall__ cc65_umul16x8r32 (unsigned lhs, unsigned char rhs);
+unsigned long __fastcall__ umul16x8r32 (unsigned lhs, unsigned char rhs);
 /* Multiplicate an unsigned 16 bit by an unsigned 8 bit number yielding a 24
 ** bit unsigned result that is extended to 32 bits for easier handling from C.
 */
 
-unsigned long __fastcall__ cc65_umul16x16r32 (unsigned lhs, unsigned rhs);
+unsigned long __fastcall__ umul16x16r32 (unsigned lhs, unsigned rhs);
 /* Multiplicate two unsigned 16 bit to yield an unsigned 32 bit result */
 
-int __fastcall__ cc65_sin (unsigned x);
+unsigned int __fastcall__ mul20(unsigned char value);
+/* Multiply an 8 bit unsigned value by 20 and return the 16 bit unsigned
+** result
+*/
+
+unsigned int __fastcall__ mul40(unsigned char value);
+/* Multiply an 8 bit unsigned value by 40 and return the 16 bit unsigned
+** result
+*/
+
+int __fastcall__ sin (unsigned x);
 /* Return the sine of the argument, which must be in range 0..360. The result
 ** is in 8.8 fixed point format, which means that 1.0 = $100 and -1.0 = $FF00.
 */
 
-int __fastcall__ cc65_cos (unsigned x);
+int __fastcall__ cos (unsigned x);
 /* Return the cosine of the argument, which must be in range 0..360. The result
 ** is in 8.8 fixed point format, which means that 1.0 = $100 and -1.0 = $FF00.
 */
diff --git a/include/specialmath.h b/include/specialmath.h
deleted file mode 100644 (file)
index 6b67769..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*****************************************************************************/
-/*                                                                           */
-/*                              specialmath.h                                */
-/*                                                                           */
-/*                 Optimized math routines for special usages                */
-/*                                                                           */
-/*                                                                           */
-/*                                                                           */
-/* (C) 2019 Christian 'Irgendwer' Krueger                                    */
-/*                                                                           */
-/* This software is provided 'as-is', without any expressed or implied       */
-/* warranty.  In no event will the authors be held liable for any damages    */
-/* arising from the use of this software.                                    */
-/*                                                                           */
-/* Permission is granted to anyone to use this software for any purpose,     */
-/* including commercial applications, and to alter it and redistribute it    */
-/* freely, subject to the following restrictions:                            */
-/*                                                                           */
-/* 1. The origin of this software must not be misrepresented; you must not   */
-/*    claim that you wrote the original software. If you use this software   */
-/*    in a product, an acknowledgment in the product documentation would be  */
-/*    appreciated but is not required.                                       */
-/* 2. Altered source versions must be plainly marked as such, and must not   */
-/*    be misrepresented as being the original software.                      */
-/* 3. This notice may not be removed or altered from any source              */
-/*    distribution.                                                          */
-/*                                                                           */
-/*****************************************************************************/
-
-#ifndef _SPECIALMATH_H
-#define _SPECIALMATH_H
-
-
-/* Multiply an 8 bit unsigned value by 20 and return the 16 bit unsigned result */
-
-unsigned int __fastcall__ _mul20(unsigned char value);
-
-
-/* Multiply an 8 bit unsigned value by 40 and return the 16 bit unsigned result */
-
-unsigned int __fastcall__ _mul40(unsigned char value);
-
-
-
-/* End of specialmath.h */
-#endif
index 5de39573c33181e2a637e9aa1cd4ad706beb55c3..cf66fdacf02af2f2c66852098f3181cf42b74828 100644 (file)
@@ -7,7 +7,7 @@
 
         .export         _cputcxy, _cputc
         .export         plot, cputdirect, putchar
-        .import         gotoxy, __mul40
+        .import         gotoxy, _mul40
         .importzp       tmp4,ptr4
         .import         _revflag,setcursor
 
@@ -71,7 +71,7 @@ putchar:
         sta     (OLDADR),y
 
         lda     ROWCRS
-        jsr     __mul40         ; destroys tmp4, carry is cleared
+        jsr     _mul40          ; destroys tmp4, carry is cleared
         adc     SAVMSC          ; add start of screen memory
         sta     ptr4
         txa
index 3c992000c5f96fd12a5d4dd193dd8981f608534f..4ff79c651d9e0985bd4b1b9116d6e2a128934738 100644 (file)
@@ -12,7 +12,7 @@
 
         .export         _mouse_txt_callbacks
         .importzp       tmp4
-        .import         __mul40
+        .import         _mul40
         .importzp       mouse_txt_char          ; screen code of mouse cursor
 
         .include        "atari.inc"
@@ -108,7 +108,7 @@ movey:
         lsr     a               ; convert y position to character line
         lsr     a
         lsr     a
-        jsr     __mul40          ; carry is cleared by _mul40
+        jsr     _mul40          ; carry is cleared by _mul40
         adc     SAVMSC
         sta     scrptr
         txa
index 7c839cd481ff4b4dc4f5a8bd11cadcad0bbe5e5c..4bc0d72edc61a9404ea41e2b431b238b4047a030 100644 (file)
@@ -8,7 +8,7 @@
 
         .include        "atari.inc"
         .importzp       tmp1,tmp4,ptr1,ptr2
-        .import         __mul40,_clrscr
+        .import         _mul40,_clrscr
         .export         __scroll
 
 .proc   __scroll
@@ -40,7 +40,7 @@ down_ok:lda     SAVMSC
         sta     ptr2+1
 
         lda     tmp1
-        jsr     __mul40
+        jsr     _mul40
         sta     tmp4
         lda     ptr2
         sec
@@ -103,7 +103,7 @@ up:     sta     tmp1            ; # of lines to scroll
         jmp     _clrscr
 
         ;multiply by 40 (xsize)
-up_ok:  jsr     __mul40         ; carry is cleared by __mul40
+up_ok:  jsr     _mul40          ; carry is cleared by _mul40
         adc     SAVMSC          ; add start of screen mem
         sta     ptr2
         txa
index 33b93ae16cd1bcc736ff4bbe575b1b732386688b..c6d844047fa4ce176e414bb56ac8c40608118d30 100644 (file)
@@ -4,7 +4,7 @@
 ; cursor handling, internal function
 
         .include "atari.inc"
-        .import cursor,__mul40
+        .import cursor,_mul40
         .export setcursor
 
 .proc   setcursor
@@ -14,7 +14,7 @@
         sta     (OLDADR),y
 
         lda     ROWCRS
-        jsr     __mul40         ; function leaves with carry clear!
+        jsr     _mul40          ; function leaves with carry clear!
         adc     SAVMSC          ; add start of screen memory
         sta     OLDADR
         txa
index cac66699a9b9c433a1a90dad6c76443a5ce62a72..185ad8da8ecb7fde1ce52818a3da55e9c2981f49 100644 (file)
@@ -10,7 +10,7 @@
 
         .export         _cputcxy, _cputc
         .export         plot, cputdirect, putchar
-        .import         gotoxy, __mul20
+        .import         gotoxy, _mul20
         .importzp       ptr4
         .import         setcursor
 
@@ -75,7 +75,7 @@ putchar:
         pha                     ; save char
 
         lda     ROWCRS_5200
-        jsr     __mul20         ; destroys tmp4, carry is cleared
+        jsr     _mul20          ; destroys tmp4, carry is cleared
         adc     SAVMSC          ; add start of screen memory
         sta     ptr4
         txa
diff --git a/libsrc/common/_mul20.s b/libsrc/common/_mul20.s
deleted file mode 100644 (file)
index 42ab420..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-; mul20.s
-;
-; This file is part of
-; cc65 - a freeware C compiler for 6502 based systems
-;
-; https://github.com/cc65/cc65
-;
-; See "LICENSE" file for legal information.
-;
-;
-; unsigned int __fastcall__ _mul20(unsigned char value);
-; 
-; REMARKS: Function is defined to return with carry-flag cleared
-
-
-        .importzp       tmp4
-        .export         __mul20
-
-.proc   __mul20                 ; = 30 bytes, 41/46 cycles
-
-        sta     tmp4            ; remember value for later addition...
-        ldx     #0              ; clear high-byte
-        asl     a               ; * 2
-        bcc     mul4            ; high-byte affected?
-        ldx     #2              ; this will be the 1st high-bit soon...
-
-mul4:   asl     a               ; * 4                  
-        bcc     mul5            ; high-byte affected?
-        inx                     ; => yes, apply to 0 high-bit
-        clc                     ; prepare addition
-
-mul5:   adc     tmp4            ; * 5
-        bcc     mul10           ; high-byte affected?
-        inx                     ; yes, correct...
-
-mul10:  stx     tmp4            ; continue with classic shifting...
-        
-        asl     a               ; * 10
-        rol     tmp4                                    
-
-        asl     a               ; * 20 
-        rol     tmp4
-
-        ldx     tmp4            ; deliver high-byte in X
-        rts
-
-.endproc
diff --git a/libsrc/common/_mul40.s b/libsrc/common/_mul40.s
deleted file mode 100644 (file)
index d68a9f7..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-; mul40.s
-;
-; This file is part of
-; cc65 - a freeware C compiler for 6502 based systems
-;
-; https://github.com/cc65/cc65
-;
-; See "LICENSE" file for legal information.
-;
-;
-; unsigned int __fastcall__ _mul40(unsigned char value);
-; 
-; REMARKS: Function is defined to return with carry-flag cleared
-
-
-        .importzp       tmp4
-        .export         __mul40
-
-.proc   __mul40                 ; = 33 bytes, 48/53 cycles
-
-        sta     tmp4            ; remember value for later addition...
-        ldx     #0              ; clear high-byte
-        asl     a               ; * 2
-        bcc     mul4            ; high-byte affected?
-        ldx     #2              ; this will be the 1st high-bit soon...
-
-mul4:   asl     a               ; * 4                  
-        bcc     mul5            ; high-byte affected?
-        inx                     ; => yes, apply to 0 high-bit
-        clc                     ; prepare addition
-
-mul5:   adc     tmp4            ; * 5
-        bcc     mul10           ; high-byte affected?
-        inx                     ; yes, correct...
-
-mul10:  stx     tmp4            ; continue with classic shifting...
-        
-        asl     a               ; * 10
-        rol     tmp4                                    
-
-        asl     a               ; * 20 
-        rol     tmp4
-
-        asl     a               ; * 40
-        rol     tmp4
-
-        ldx     tmp4            ; deliver high-byte in X
-        rts
-
-.endproc
diff --git a/libsrc/common/cc65_idiv32by16r16.s b/libsrc/common/cc65_idiv32by16r16.s
deleted file mode 100644 (file)
index 9c30984..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-;
-; Ullrich von Bassewitz, 2009-11-04
-;
-; CC65 library: 32by16 => 16 signed division
-;
-
-        .export         _cc65_idiv32by16r16
-        .import         idiv32by16r16, incsp4
-
-        .include        "zeropage.inc"
-
-
-;---------------------------------------------------------------------------
-; 32by16 division.
-
-.proc   _cc65_idiv32by16r16
-
-        pha                     ; Save rhs
-
-; Copy from stack to zeropage. This assumes ptr1 and ptr2 are adjacent.
-
-        ldy     #3
-@L1:    lda     (sp),y
-        sta     ptr1,y
-        dey
-        bpl     @L1
-
-        lda     #4
-        clc
-        adc     sp
-        sta     sp
-        bcc     @L2
-        inc     sp+1
-
-@L2:    pla                     ; Old rhs
-        jmp     idiv32by16r16
-
-.endproc
-
diff --git a/libsrc/common/cc65_imul16x16r32.s b/libsrc/common/cc65_imul16x16r32.s
deleted file mode 100644 (file)
index b4e82de..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-;
-; Ullrich von Bassewitz, 2010-11-03
-;
-; CC65 library: 16x16 => 32 signed multiplication
-;
-
-        .export         _cc65_imul16x16r32
-        .import         imul16x16r32, popax
-
-        .include        "zeropage.inc"
-
-
-;---------------------------------------------------------------------------
-; 16x16 => 32 signed multiplication routine.
-
-
-.proc   _cc65_imul16x16r32
-
-        sta     ptr1
-        stx     ptr1+1
-        jsr     popax
-        jmp     imul16x16r32
-
-.endproc
-
diff --git a/libsrc/common/cc65_imul8x8r16.s b/libsrc/common/cc65_imul8x8r16.s
deleted file mode 100644 (file)
index 0e7d547..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-;
-; 2014-03-27, Oliver Schmidt
-; 2014-05-08, Greg King
-;
-; CC65 library: 8x8 => 16 signed multiplication
-;
-
-        .export         _cc65_imul8x8r16
-        .import         imul8x8r16, popa, ptr1:zp
-
-
-;---------------------------------------------------------------------------
-; 8x8 => 16 signed multiplication routine.
-
-
-.proc   _cc65_imul8x8r16
-
-        sta     ptr1
-        jsr     popa
-        jmp     imul8x8r16
-
-.endproc
diff --git a/libsrc/common/cc65_sincos.s b/libsrc/common/cc65_sincos.s
deleted file mode 100644 (file)
index 6baba8b..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-;
-; Fixed point cosine/sine functions.
-;
-; int __fastcall__ cc65_sin (unsigned x);
-; int __fastcall__ cc65_cos (unsigned x);
-;
-; Returns the cosine/sine for the given argument as angular degree.
-; Valid argument range is 0..360 for both functions. They will return
-; garbage if the argument is not in a valid range. Result is in 8.8 fixed
-; point format, so $100 is 1.0 and $FF00 is -1.0.
-;
-;
-; Ullrich von Bassewitz, 2009-10-29
-;
-
-        .export         _cc65_cos, _cc65_sin
-
-
-; ---------------------------------------------------------------------------
-; Sinus table covering values from 0..86° as 0.8 fixed point values. Values
-; for 87..90° are actually 1.0 (= $100), will therefore not fit in the table
-; and are covered specially in the code below.
-
-.rodata
-
-_cc65_sintab:
-        .byte   $00, $04, $09, $0D, $12, $16, $1B, $1F, $24, $28
-        .byte   $2C, $31, $35, $3A, $3E, $42, $47, $4B, $4F, $53
-        .byte   $58, $5C, $60, $64, $68, $6C, $70, $74, $78, $7C
-        .byte   $80, $84, $88, $8B, $8F, $93, $96, $9A, $9E, $A1
-        .byte   $A5, $A8, $AB, $AF, $B2, $B5, $B8, $BB, $BE, $C1
-        .byte   $C4, $C7, $CA, $CC, $CF, $D2, $D4, $D7, $D9, $DB
-        .byte   $DE, $E0, $E2, $E4, $E6, $E8, $EA, $EC, $ED, $EF
-        .byte   $F1, $F2, $F3, $F5, $F6, $F7, $F8, $F9, $FA, $FB
-        .byte   $FC, $FD, $FE, $FE, $FF, $FF, $FF
-
-
-
-; ---------------------------------------------------------------------------
-; Cosine function. Is actually implemented as cos(x) = sin(x+90)
-
-.code
-
-_cc65_cos:
-
-; cos(x) = sin(x+90)
-
-        clc
-        adc     #90
-        bcc     @L1
-        inx
-
-; If x is now larger than 360, we need to subtract 360.
-
-@L1:    cpx     #>360
-        bne     @L2
-        cmp     #<360
-@L2:    bcc     _cc65_sin
-
-        sbc     #<360
-        bcs     @L3
-        dex
-@L3:    dex
-
-; ---------------------------------------------------------------------------
-; Sine function. Uses
-;
-;       table lookup            for 0..89°
-;       sin(x) = sin(180-x)     for 90°..179°
-;       sin(x) = -sin(x-180)    for 180..360°
-;
-; Plus special handling for the values missing in the table.
-
-_cc65_sin:
-
-; If the high byte is non zero, argument is > 255
-
-        cpx     #0
-        bne     L3
-        cmp     #180
-        bcs     L4
-
-; 0..179°
-
-        cmp     #90
-        bcc     L1
-
-; 90..179°. Value is identical to sin(180-val). Carry is set on entry.
-;
-;       180-val := -val + 180.
-; With
-;       -val := (val ^ $FF) + 1
-; we get
-;       180-val = (val ^ $FF) + 1 + 180
-; Since carry is set, we can drop the "+ 1".
-;
-
-        eor     #$FF
-        adc     #180            ; 180-val
-
-; 0..89°. Values for 87..90° are actually 1.0. Since this format doesn't fit
-; into the table, we have to check for it manually.
-
-L1:     cmp     #87
-        bcc     L2
-
-; The value is 1.0
-
-        ldx     #>(1 << 8)
-        lda     #<(1 << 8)
-        rts
-
-; 0..86°. Read the value from the table.
-
-L2:     tay
-        ldx     #0
-        lda     _cc65_sintab,y
-        rts
-
-; 180..360°. sin(x) = -sin(x-180). Since the argument is in range 0..180
-; after the subtraction, we don't need to handle the high byte.
-
-L3:     sec
-L4:     sbc     #180
-
-        cmp     #90
-        bcc     L5
-
-; 270..360°. Value is identical to -sin(180-val). Carry is set on entry.
-;
-;       180-val := -val + 180.
-; With
-;       -val := (val ^ $FF) + 1
-; we get
-;       180-val = (val ^ $FF) + 1 + 180
-; Since carry is set, we can drop the "+ 1".
-;
-
-        eor     #$FF
-        adc     #180            ; 180-val
-
-; 180..269°. Values for 267..269° are actually -1.0. Since this format doesn't
-; fit into the table, we have to check for it manually.
-
-L5:     ldx     #$FF
-        cmp     #87
-        bcc     L6
-
-; The value is -1.0
-
-        lda     #<(-1 << 8)
-        rts
-
-; 180..266°. Read the value from the table. Carry is clear on entry.
-
-L6:     tay
-        txa                     ; A = $FF
-        eor     _cc65_sintab,y
-        adc     #1
-        bcc     L7
-        inx
-L7:     rts
-
-
diff --git a/libsrc/common/cc65_udiv32by16r16.s b/libsrc/common/cc65_udiv32by16r16.s
deleted file mode 100644 (file)
index 9cad63b..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-;
-; Ullrich von Bassewitz, 2009-11-04
-;
-; CC65 library: 32by16 => 16 unsigned division
-;
-
-        .export         _cc65_udiv32by16r16
-        .import         udiv32by16r16m, incsp4
-
-        .include        "zeropage.inc"
-
-
-;---------------------------------------------------------------------------
-; 32by16 division.
-
-.proc   _cc65_udiv32by16r16
-
-        sta     ptr3
-        stx     ptr3+1                  ; Store rhs
-
-; Copy from stack to zeropage. This assumes ptr1 and ptr2 are adjacent.
-
-        ldy     #3
-@L1:    lda     (sp),y
-        sta     ptr1,y
-        dey
-        bpl     @L1
-
-        lda     #4
-        clc
-        adc     sp
-        sta     sp
-        bcc     @L2
-        inc     sp+1
-
-@L2:    jmp     udiv32by16r16m
-
-.endproc
-
diff --git a/libsrc/common/cc65_umul16x16r32.s b/libsrc/common/cc65_umul16x16r32.s
deleted file mode 100644 (file)
index 0e7ed76..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-;
-; Ullrich von Bassewitz, 2010-11-03
-;
-; CC65 library: 16x16 => 32 unsigned multiplication
-;
-
-        .export         _cc65_umul16x16r32
-        .import         umul16x16r32, popax
-
-        .include        "zeropage.inc"
-
-
-;---------------------------------------------------------------------------
-; 16x16 => 32 unsigned multiplication routine.
-
-.proc   _cc65_umul16x16r32
-
-        sta     ptr1
-        stx     ptr1+1
-        jsr     popax
-        jmp     umul16x16r32
-
-.endproc
-
-
diff --git a/libsrc/common/cc65_umul16x8r32.s b/libsrc/common/cc65_umul16x8r32.s
deleted file mode 100644 (file)
index 8af3493..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-;
-; Ullrich von Bassewitz, 2011-07-10
-;
-; CC65 library: 16x8 => 32 unsigned multiplication
-;
-
-        .export         _cc65_umul16x8r32
-        .import         umul8x16r24, popax
-
-        .include        "zeropage.inc"
-
-
-;---------------------------------------------------------------------------
-; 16x8 => 32 unsigned multiplication routine. We use 8x16 => 24 and clear
-; the high byte of the result
-
-.proc   _cc65_umul16x8r32
-
-        sta     ptr1
-        lda     #0
-        sta     sreg+1                  ; Clear high byte of result
-        jsr     popax
-        jmp     umul8x16r24
-
-.endproc
-
-
diff --git a/libsrc/common/cc65_umul8x8r16.s b/libsrc/common/cc65_umul8x8r16.s
deleted file mode 100644 (file)
index cf3b26b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-;
-; Oliver Schmidt, 2014-03-27
-;
-; CC65 library: 8x8 => 16 unsigned multiplication
-;
-
-        .export         _cc65_umul8x8r16
-        .import         umul8x8r16, popa, ptr1:zp
-
-
-;---------------------------------------------------------------------------
-; 8x8 => 16 unsigned multiplication routine.
-
-
-.proc   _cc65_umul8x8r16
-
-        sta     ptr1
-        jsr     popa
-        jmp     umul8x8r16
-
-.endproc
diff --git a/libsrc/common/idiv32by16r16.s b/libsrc/common/idiv32by16r16.s
new file mode 100644 (file)
index 0000000..7df78f4
--- /dev/null
@@ -0,0 +1,39 @@
+;
+; Ullrich von Bassewitz, 2009-11-04
+;
+; CC65 library: 32by16 => 16 signed division
+;
+
+        .export         _idiv32by16r16
+        .import         idiv32by16r16, incsp4
+
+        .include        "zeropage.inc"
+
+
+;---------------------------------------------------------------------------
+; 32by16 division.
+
+.proc   _idiv32by16r16
+
+        pha                     ; Save rhs
+
+; Copy from stack to zeropage. This assumes ptr1 and ptr2 are adjacent.
+
+        ldy     #3
+@L1:    lda     (sp),y
+        sta     ptr1,y
+        dey
+        bpl     @L1
+
+        lda     #4
+        clc
+        adc     sp
+        sta     sp
+        bcc     @L2
+        inc     sp+1
+
+@L2:    pla                     ; Old rhs
+        jmp     idiv32by16r16
+
+.endproc
+
diff --git a/libsrc/common/imul16x16r32.s b/libsrc/common/imul16x16r32.s
new file mode 100644 (file)
index 0000000..e08d11c
--- /dev/null
@@ -0,0 +1,25 @@
+;
+; Ullrich von Bassewitz, 2010-11-03
+;
+; CC65 library: 16x16 => 32 signed multiplication
+;
+
+        .export         _imul16x16r32
+        .import         imul16x16r32, popax
+
+        .include        "zeropage.inc"
+
+
+;---------------------------------------------------------------------------
+; 16x16 => 32 signed multiplication routine.
+
+
+.proc   _imul16x16r32
+
+        sta     ptr1
+        stx     ptr1+1
+        jsr     popax
+        jmp     imul16x16r32
+
+.endproc
+
diff --git a/libsrc/common/imul8x8r16.s b/libsrc/common/imul8x8r16.s
new file mode 100644 (file)
index 0000000..9987f6e
--- /dev/null
@@ -0,0 +1,22 @@
+;
+; 2014-03-27, Oliver Schmidt
+; 2014-05-08, Greg King
+;
+; CC65 library: 8x8 => 16 signed multiplication
+;
+
+        .export         _imul8x8r16
+        .import         imul8x8r16, popa, ptr1:zp
+
+
+;---------------------------------------------------------------------------
+; 8x8 => 16 signed multiplication routine.
+
+
+.proc   _imul8x8r16
+
+        sta     ptr1
+        jsr     popa
+        jmp     imul8x8r16
+
+.endproc
diff --git a/libsrc/common/mul20.s b/libsrc/common/mul20.s
new file mode 100644 (file)
index 0000000..4035b94
--- /dev/null
@@ -0,0 +1,47 @@
+; mul20.s
+;
+; This file is part of
+; cc65 - a freeware C compiler for 6502 based systems
+;
+; https://github.com/cc65/cc65
+;
+; See "LICENSE" file for legal information.
+;
+;
+; unsigned int __fastcall__ mul20(unsigned char value);
+; 
+; REMARKS: Function is defined to return with carry-flag cleared
+
+
+        .importzp       tmp4
+        .export         _mul20
+
+.proc   _mul20                  ; = 30 bytes, 41/46 cycles
+
+        sta     tmp4            ; remember value for later addition...
+        ldx     #0              ; clear high-byte
+        asl     a               ; * 2
+        bcc     mul4            ; high-byte affected?
+        ldx     #2              ; this will be the 1st high-bit soon...
+
+mul4:   asl     a               ; * 4
+        bcc     mul5            ; high-byte affected?
+        inx                     ; => yes, apply to 0 high-bit
+        clc                     ; prepare addition
+
+mul5:   adc     tmp4            ; * 5
+        bcc     mul10           ; high-byte affected?
+        inx                     ; yes, correct...
+
+mul10:  stx     tmp4            ; continue with classic shifting...
+        
+        asl     a               ; * 10
+        rol     tmp4
+
+        asl     a               ; * 20
+        rol     tmp4
+
+        ldx     tmp4            ; deliver high-byte in X
+        rts
+
+.endproc
diff --git a/libsrc/common/mul40.s b/libsrc/common/mul40.s
new file mode 100644 (file)
index 0000000..f240fc4
--- /dev/null
@@ -0,0 +1,50 @@
+; mul40.s
+;
+; This file is part of
+; cc65 - a freeware C compiler for 6502 based systems
+;
+; https://github.com/cc65/cc65
+;
+; See "LICENSE" file for legal information.
+;
+;
+; unsigned int __fastcall__ mul40(unsigned char value);
+; 
+; REMARKS: Function is defined to return with carry-flag cleared
+
+
+        .importzp       tmp4
+        .export         _mul40
+
+.proc   _mul40                  ; = 33 bytes, 48/53 cycles
+
+        sta     tmp4            ; remember value for later addition...
+        ldx     #0              ; clear high-byte
+        asl     a               ; * 2
+        bcc     mul4            ; high-byte affected?
+        ldx     #2              ; this will be the 1st high-bit soon...
+
+mul4:   asl     a               ; * 4
+        bcc     mul5            ; high-byte affected?
+        inx                     ; => yes, apply to 0 high-bit
+        clc                     ; prepare addition
+
+mul5:   adc     tmp4            ; * 5
+        bcc     mul10           ; high-byte affected?
+        inx                     ; yes, correct...
+
+mul10:  stx     tmp4            ; continue with classic shifting...
+        
+        asl     a               ; * 10
+        rol     tmp4
+
+        asl     a               ; * 20
+        rol     tmp4
+
+        asl     a               ; * 40
+        rol     tmp4
+
+        ldx     tmp4            ; deliver high-byte in X
+        rts
+
+.endproc
diff --git a/libsrc/common/sincos.s b/libsrc/common/sincos.s
new file mode 100644 (file)
index 0000000..7cdcb71
--- /dev/null
@@ -0,0 +1,164 @@
+;
+; Fixed point cosine/sine functions.
+;
+; int __fastcall__ cc65_sin (unsigned x);
+; int __fastcall__ cc65_cos (unsigned x);
+;
+; Returns the cosine/sine for the given argument as angular degree.
+; Valid argument range is 0..360 for both functions. They will return
+; garbage if the argument is not in a valid range. Result is in 8.8 fixed
+; point format, so $100 is 1.0 and $FF00 is -1.0.
+;
+;
+; Ullrich von Bassewitz, 2009-10-29
+;
+
+        .export         _cos, _sin
+
+
+; ---------------------------------------------------------------------------
+; Sinus table covering values from 0..86° as 0.8 fixed point values. Values
+; for 87..90° are actually 1.0 (= $100), will therefore not fit in the table
+; and are covered specially in the code below.
+
+.rodata
+
+_sintab:
+        .byte   $00, $04, $09, $0D, $12, $16, $1B, $1F, $24, $28
+        .byte   $2C, $31, $35, $3A, $3E, $42, $47, $4B, $4F, $53
+        .byte   $58, $5C, $60, $64, $68, $6C, $70, $74, $78, $7C
+        .byte   $80, $84, $88, $8B, $8F, $93, $96, $9A, $9E, $A1
+        .byte   $A5, $A8, $AB, $AF, $B2, $B5, $B8, $BB, $BE, $C1
+        .byte   $C4, $C7, $CA, $CC, $CF, $D2, $D4, $D7, $D9, $DB
+        .byte   $DE, $E0, $E2, $E4, $E6, $E8, $EA, $EC, $ED, $EF
+        .byte   $F1, $F2, $F3, $F5, $F6, $F7, $F8, $F9, $FA, $FB
+        .byte   $FC, $FD, $FE, $FE, $FF, $FF, $FF
+
+
+
+; ---------------------------------------------------------------------------
+; Cosine function. Is actually implemented as cos(x) = sin(x+90)
+
+.code
+
+_cos:
+
+; cos(x) = sin(x+90)
+
+        clc
+        adc     #90
+        bcc     @L1
+        inx
+
+; If x is now larger than 360, we need to subtract 360.
+
+@L1:    cpx     #>360
+        bne     @L2
+        cmp     #<360
+@L2:    bcc     _sin
+
+        sbc     #<360
+        bcs     @L3
+        dex
+@L3:    dex
+
+; ---------------------------------------------------------------------------
+; Sine function. Uses
+;
+;       table lookup            for 0..89°
+;       sin(x) = sin(180-x)     for 90°..179°
+;       sin(x) = -sin(x-180)    for 180..360°
+;
+; Plus special handling for the values missing in the table.
+
+_sin:
+
+; If the high byte is non zero, argument is > 255
+
+        cpx     #0
+        bne     L3
+        cmp     #180
+        bcs     L4
+
+; 0..179°
+
+        cmp     #90
+        bcc     L1
+
+; 90..179°. Value is identical to sin(180-val). Carry is set on entry.
+;
+;       180-val := -val + 180.
+; With
+;       -val := (val ^ $FF) + 1
+; we get
+;       180-val = (val ^ $FF) + 1 + 180
+; Since carry is set, we can drop the "+ 1".
+;
+
+        eor     #$FF
+        adc     #180            ; 180-val
+
+; 0..89°. Values for 87..90° are actually 1.0. Since this format doesn't fit
+; into the table, we have to check for it manually.
+
+L1:     cmp     #87
+        bcc     L2
+
+; The value is 1.0
+
+        ldx     #>(1 << 8)
+        lda     #<(1 << 8)
+        rts
+
+; 0..86°. Read the value from the table.
+
+L2:     tay
+        ldx     #0
+        lda     _sintab,y
+        rts
+
+; 180..360°. sin(x) = -sin(x-180). Since the argument is in range 0..180
+; after the subtraction, we don't need to handle the high byte.
+
+L3:     sec
+L4:     sbc     #180
+
+        cmp     #90
+        bcc     L5
+
+; 270..360°. Value is identical to -sin(180-val). Carry is set on entry.
+;
+;       180-val := -val + 180.
+; With
+;       -val := (val ^ $FF) + 1
+; we get
+;       180-val = (val ^ $FF) + 1 + 180
+; Since carry is set, we can drop the "+ 1".
+;
+
+        eor     #$FF
+        adc     #180            ; 180-val
+
+; 180..269°. Values for 267..269° are actually -1.0. Since this format doesn't
+; fit into the table, we have to check for it manually.
+
+L5:     ldx     #$FF
+        cmp     #87
+        bcc     L6
+
+; The value is -1.0
+
+        lda     #<(-1 << 8)
+        rts
+
+; 180..266°. Read the value from the table. Carry is clear on entry.
+
+L6:     tay
+        txa                     ; A = $FF
+        eor     _sintab,y
+        adc     #1
+        bcc     L7
+        inx
+L7:     rts
+
+
diff --git a/libsrc/common/udiv32by16r16.s b/libsrc/common/udiv32by16r16.s
new file mode 100644 (file)
index 0000000..a1d5f4e
--- /dev/null
@@ -0,0 +1,39 @@
+;
+; Ullrich von Bassewitz, 2009-11-04
+;
+; CC65 library: 32by16 => 16 unsigned division
+;
+
+        .export         _udiv32by16r16
+        .import         udiv32by16r16m, incsp4
+
+        .include        "zeropage.inc"
+
+
+;---------------------------------------------------------------------------
+; 32by16 division.
+
+.proc   _udiv32by16r16
+
+        sta     ptr3
+        stx     ptr3+1                  ; Store rhs
+
+; Copy from stack to zeropage. This assumes ptr1 and ptr2 are adjacent.
+
+        ldy     #3
+@L1:    lda     (sp),y
+        sta     ptr1,y
+        dey
+        bpl     @L1
+
+        lda     #4
+        clc
+        adc     sp
+        sta     sp
+        bcc     @L2
+        inc     sp+1
+
+@L2:    jmp     udiv32by16r16m
+
+.endproc
+
diff --git a/libsrc/common/umul16x16r32.s b/libsrc/common/umul16x16r32.s
new file mode 100644 (file)
index 0000000..674b55f
--- /dev/null
@@ -0,0 +1,25 @@
+;
+; Ullrich von Bassewitz, 2010-11-03
+;
+; CC65 library: 16x16 => 32 unsigned multiplication
+;
+
+        .export         _umul16x16r32
+        .import         umul16x16r32, popax
+
+        .include        "zeropage.inc"
+
+
+;---------------------------------------------------------------------------
+; 16x16 => 32 unsigned multiplication routine.
+
+.proc   _umul16x16r32
+
+        sta     ptr1
+        stx     ptr1+1
+        jsr     popax
+        jmp     umul16x16r32
+
+.endproc
+
+
diff --git a/libsrc/common/umul16x8r32.s b/libsrc/common/umul16x8r32.s
new file mode 100644 (file)
index 0000000..83a3d9c
--- /dev/null
@@ -0,0 +1,27 @@
+;
+; Ullrich von Bassewitz, 2011-07-10
+;
+; CC65 library: 16x8 => 32 unsigned multiplication
+;
+
+        .export         _umul16x8r32
+        .import         umul8x16r24, popax
+
+        .include        "zeropage.inc"
+
+
+;---------------------------------------------------------------------------
+; 16x8 => 32 unsigned multiplication routine. We use 8x16 => 24 and clear
+; the high byte of the result
+
+.proc   _umul16x8r32
+
+        sta     ptr1
+        lda     #0
+        sta     sreg+1                  ; Clear high byte of result
+        jsr     popax
+        jmp     umul8x16r24
+
+.endproc
+
+
diff --git a/libsrc/common/umul8x8r16.s b/libsrc/common/umul8x8r16.s
new file mode 100644 (file)
index 0000000..8a3d462
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Oliver Schmidt, 2014-03-27
+;
+; CC65 library: 8x8 => 16 unsigned multiplication
+;
+
+        .export         _umul8x8r16
+        .import         umul8x8r16, popa, ptr1:zp
+
+
+;---------------------------------------------------------------------------
+; 8x8 => 16 unsigned multiplication routine.
+
+
+.proc   _umul8x8r16
+
+        sta     ptr1
+        jsr     popa
+        jmp     umul8x8r16
+
+.endproc
index e505b7b6921ee6958afa6c92416854c2fc6dfddb..94cc593cebd8f09d78da7afd5a6672c48d83256f 100644 (file)
@@ -70,16 +70,16 @@ void __fastcall__ tgi_arc (int x, int y, unsigned char rx, unsigned char ry,
     }
 
     /* Calculate the start coords */
-    x1 = x + tgi_imulround (rx, cc65_cos (sa));
-    y1 = y - tgi_imulround (ry, cc65_sin (sa));
+    x1 = x + tgi_imulround (rx, cos (sa));
+    y1 = y - tgi_imulround (ry, sin (sa));
     do {
         sa += inc;
         if (sa >= ea) {
             sa = ea;
             done = 1;
         }
-        x2 = x + tgi_imulround (rx, cc65_cos (sa));
-        y2 = y - tgi_imulround (ry, cc65_sin (sa));
+        x2 = x + tgi_imulround (rx, cos (sa));
+        y2 = y - tgi_imulround (ry, sin (sa));
         tgi_line (x1, y1, x2, y2);
         x1 = x2;
         y1 = y2;
index 60d2f1d13c303f3fddead20ba8b416e072bd3341..b119b9b2de658e23a26d3d2751e30207b9e8f327 100644 (file)
@@ -57,8 +57,8 @@ void __fastcall__ tgi_pieslice (int x, int y, unsigned char rx, unsigned char ry
     tgi_arc (x, y, rx, ry, sa, ea);
 
     /* ... and close it */
-    tgi_line (x, y, x + tgi_imulround (rx, cc65_cos (sa)), y - tgi_imulround (ry, cc65_sin (sa)));
-    tgi_line (x, y, x + tgi_imulround (rx, cc65_cos (ea)), y - tgi_imulround (ry, cc65_sin (ea)));
+    tgi_line (x, y, x + tgi_imulround (rx, cos (sa)), y - tgi_imulround (ry, sin (sa)));
+    tgi_line (x, y, x + tgi_imulround (rx, cos (ea)), y - tgi_imulround (ry, sin (ea)));
 }
 
 
index 340838a8380ac74162f6fed9f872754f2aeeb829..cf5f089e9aa577ea257c01032c78b10faf39210b 100644 (file)
@@ -1,4 +1,4 @@
-#include <specialmath.h>
+#include <cc65.h>
 #include "unittest.h"
 
 TEST
@@ -7,12 +7,12 @@ TEST
     
     for (i=0; i < 256; ++i)
     {
-        ASSERT_AreEqual(i*20, _mul20(i), "%u", "Invalid 'mul20(%u)' calculation!" COMMA i);
+        ASSERT_AreEqual(i*20, mul20(i), "%u", "Invalid 'mul20(%u)' calculation!" COMMA i);
     }
 
     for (i=0; i < 256; ++i)
     {
-        ASSERT_AreEqual(i*40, _mul40(i), "%u", "Invalid 'mul40(%u)' calculation!" COMMA i);
+        ASSERT_AreEqual(i*40, mul40(i), "%u", "Invalid 'mul40(%u)' calculation!" COMMA i);
     }
 }
 ENDTEST