From db8bd84a82992d7d29fdd46443c194c1d8ea37fd Mon Sep 17 00:00:00 2001 From: IrgendwerA8 Date: Thu, 21 Mar 2019 20:43:07 +0100 Subject: [PATCH] Changes due to code review. --- doc/specialmath.sgml | 4 ++-- include/specialmath.h | 4 ++-- libsrc/Makefile | 1 - libsrc/atari/cputc.s | 4 ++-- libsrc/atari/mcbtxtchar.s | 4 ++-- libsrc/atari/scroll.s | 6 +++--- libsrc/atari/setcursor.s | 4 ++-- libsrc/atari5200/cputc.s | 4 ++-- .../{specialmath/mul20.s => common/_mul20.s} | 6 +++--- .../{specialmath/mul40.s => common/_mul40.s} | 6 +++--- test/val/lib_common_mulxx.c | 18 ++++++++++++++++++ test/val/lib_specialmath_mulxx.c | 18 ------------------ 12 files changed, 39 insertions(+), 40 deletions(-) rename libsrc/{specialmath/mul20.s => common/_mul20.s} (89%) rename libsrc/{specialmath/mul40.s => common/_mul40.s} (89%) create mode 100644 test/val/lib_common_mulxx.c delete mode 100644 test/val/lib_specialmath_mulxx.c diff --git a/doc/specialmath.sgml b/doc/specialmath.sgml index 18de970eb..5e2fd90a7 100644 --- a/doc/specialmath.sgml +++ b/doc/specialmath.sgml @@ -20,7 +20,7 @@ the target address. A quite common horizontal span for 8-bit systems is 20 or 40

- unsigned int __fastcall__ mul20(unsigned char value); + unsigned int __fastcall__ _mul20(unsigned char value); The 8 bit value is multiplied by 20 and returned as 16 bit value. @@ -28,7 +28,7 @@ The 8 bit value is multiplied by 20 and returned as 16 bit value.

- unsigned int __fastcall__ mul40(unsigned char value); + unsigned int __fastcall__ _mul40(unsigned char value); The 8 bit value is multiplied by 40 and returned as 16 bit value. diff --git a/include/specialmath.h b/include/specialmath.h index fa2f65736..6b6776914 100644 --- a/include/specialmath.h +++ b/include/specialmath.h @@ -33,12 +33,12 @@ /* Multiply an 8 bit unsigned value by 20 and return the 16 bit unsigned result */ -unsigned int __fastcall__ mul20(unsigned char value); +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); +unsigned int __fastcall__ _mul40(unsigned char value); diff --git a/libsrc/Makefile b/libsrc/Makefile index 4e1a3520d..0ebec46b1 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -181,7 +181,6 @@ SRCDIRS += common \ mouse \ runtime \ serial \ - specialmath \ tgi \ zlib diff --git a/libsrc/atari/cputc.s b/libsrc/atari/cputc.s index cf66fdacf..5de39573c 100644 --- a/libsrc/atari/cputc.s +++ b/libsrc/atari/cputc.s @@ -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 diff --git a/libsrc/atari/mcbtxtchar.s b/libsrc/atari/mcbtxtchar.s index 4ff79c651..3c992000c 100644 --- a/libsrc/atari/mcbtxtchar.s +++ b/libsrc/atari/mcbtxtchar.s @@ -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 diff --git a/libsrc/atari/scroll.s b/libsrc/atari/scroll.s index 4bc0d72ed..7c839cd48 100644 --- a/libsrc/atari/scroll.s +++ b/libsrc/atari/scroll.s @@ -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 diff --git a/libsrc/atari/setcursor.s b/libsrc/atari/setcursor.s index c6d844047..33b93ae16 100644 --- a/libsrc/atari/setcursor.s +++ b/libsrc/atari/setcursor.s @@ -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 diff --git a/libsrc/atari5200/cputc.s b/libsrc/atari5200/cputc.s index 185ad8da8..cac66699a 100644 --- a/libsrc/atari5200/cputc.s +++ b/libsrc/atari5200/cputc.s @@ -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/specialmath/mul20.s b/libsrc/common/_mul20.s similarity index 89% rename from libsrc/specialmath/mul20.s rename to libsrc/common/_mul20.s index 3339f7dd2..42ab420e5 100644 --- a/libsrc/specialmath/mul20.s +++ b/libsrc/common/_mul20.s @@ -8,15 +8,15 @@ ; See "LICENSE" file for legal information. ; ; -; unsigned int __fastcall__ mul20(unsigned char value); +; unsigned int __fastcall__ _mul20(unsigned char value); ; ; REMARKS: Function is defined to return with carry-flag cleared .importzp tmp4 - .export _mul20 + .export __mul20 -.proc _mul20 ; = 30 bytes, 41/46 cycles +.proc __mul20 ; = 30 bytes, 41/46 cycles sta tmp4 ; remember value for later addition... ldx #0 ; clear high-byte diff --git a/libsrc/specialmath/mul40.s b/libsrc/common/_mul40.s similarity index 89% rename from libsrc/specialmath/mul40.s rename to libsrc/common/_mul40.s index 110351935..d68a9f7c0 100644 --- a/libsrc/specialmath/mul40.s +++ b/libsrc/common/_mul40.s @@ -8,15 +8,15 @@ ; See "LICENSE" file for legal information. ; ; -; unsigned int __fastcall__ mul40(unsigned char value); +; unsigned int __fastcall__ _mul40(unsigned char value); ; ; REMARKS: Function is defined to return with carry-flag cleared .importzp tmp4 - .export _mul40 + .export __mul40 -.proc _mul40 ; = 33 bytes, 48/53 cycles +.proc __mul40 ; = 33 bytes, 48/53 cycles sta tmp4 ; remember value for later addition... ldx #0 ; clear high-byte diff --git a/test/val/lib_common_mulxx.c b/test/val/lib_common_mulxx.c new file mode 100644 index 000000000..340838a83 --- /dev/null +++ b/test/val/lib_common_mulxx.c @@ -0,0 +1,18 @@ +#include +#include "unittest.h" + +TEST +{ + unsigned i; + + for (i=0; i < 256; ++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); + } +} +ENDTEST diff --git a/test/val/lib_specialmath_mulxx.c b/test/val/lib_specialmath_mulxx.c deleted file mode 100644 index de7cc1e29..000000000 --- a/test/val/lib_specialmath_mulxx.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include "unittest.h" - -TEST -{ - unsigned i; - - for (i=0; i < 256; ++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); - } -} -ENDTEST -- 2.39.2