Skip to content

Commit

Permalink
Code review adaptations, removed "cc65_" prefix from functions
Browse files Browse the repository at this point in the history
  • Loading branch information
IrgendwerA8 authored and oliverschmidt committed Mar 29, 2019
1 parent 435f417 commit 3d8c3a4
Show file tree
Hide file tree
Showing 21 changed files with 107 additions and 148 deletions.
75 changes: 35 additions & 40 deletions doc/funcref.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>

Expand Down
28 changes: 19 additions & 9 deletions include/cc65.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,43 +44,53 @@



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.
*/
Expand Down
46 changes: 0 additions & 46 deletions include/specialmath.h

This file was deleted.

4 changes: 2 additions & 2 deletions libsrc/atari/cputc.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

.export _cputcxy, _cputc
.export plot, cputdirect, putchar
.import gotoxy, __mul40
.import gotoxy, _mul40
.importzp tmp4,ptr4
.import _revflag,setcursor

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libsrc/atari/mcbtxtchar.s
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions libsrc/atari/scroll.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

.include "atari.inc"
.importzp tmp1,tmp4,ptr1,ptr2
.import __mul40,_clrscr
.import _mul40,_clrscr
.export __scroll

.proc __scroll
Expand Down Expand Up @@ -40,7 +40,7 @@ down_ok:lda SAVMSC
sta ptr2+1

lda tmp1
jsr __mul40
jsr _mul40
sta tmp4
lda ptr2
sec
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libsrc/atari/setcursor.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
; cursor handling, internal function

.include "atari.inc"
.import cursor,__mul40
.import cursor,_mul40
.export setcursor

.proc setcursor
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libsrc/atari5200/cputc.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

.export _cputcxy, _cputc
.export plot, cputdirect, putchar
.import gotoxy, __mul20
.import gotoxy, _mul20
.importzp ptr4
.import setcursor

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
; CC65 library: 32by16 => 16 signed division
;

.export _cc65_idiv32by16r16
.export _idiv32by16r16
.import idiv32by16r16, incsp4

.include "zeropage.inc"
Expand All @@ -13,7 +13,7 @@
;---------------------------------------------------------------------------
; 32by16 division.

.proc _cc65_idiv32by16r16
.proc _idiv32by16r16

pha ; Save rhs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
; CC65 library: 16x16 => 32 signed multiplication
;

.export _cc65_imul16x16r32
.export _imul16x16r32
.import imul16x16r32, popax

.include "zeropage.inc"
Expand All @@ -14,7 +14,7 @@
; 16x16 => 32 signed multiplication routine.


.proc _cc65_imul16x16r32
.proc _imul16x16r32

sta ptr1
stx ptr1+1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
; CC65 library: 8x8 => 16 signed multiplication
;

.export _cc65_imul8x8r16
.export _imul8x8r16
.import imul8x8r16, popa, ptr1:zp


;---------------------------------------------------------------------------
; 8x8 => 16 signed multiplication routine.


.proc _cc65_imul8x8r16
.proc _imul8x8r16

sta ptr1
jsr popa
Expand Down

2 comments on commit 3d8c3a4

@polluks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sin & cos: What if we have FP someday?

@mrdudz
Copy link
Contributor

@mrdudz mrdudz commented on 3d8c3a4 Mar 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good assertion - i'd prefer some naming scheme that indicates a) its integer and b) what sized integers they take and return (umul8x8r16 etc is a good example, just follow that scheme)

Please sign in to comment.