From 85760e0c531d127f2a52e1d87a6f02214c98a5fd Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Feb 2016 22:13:05 +0100 Subject: [PATCH 001/199] initial import from old sources --- libsrc/c128/kbrepeat.s | 22 ++++++++++++++++++++++ libsrc/c64/kbrepeat.s | 22 ++++++++++++++++++++++ libsrc/pet/kbrepeat.s | 22 ++++++++++++++++++++++ libsrc/plus4/kbrepeat.s | 22 ++++++++++++++++++++++ libsrc/vic20/kbrepeat.s | 22 ++++++++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 libsrc/c128/kbrepeat.s create mode 100644 libsrc/c64/kbrepeat.s create mode 100644 libsrc/pet/kbrepeat.s create mode 100644 libsrc/plus4/kbrepeat.s create mode 100644 libsrc/vic20/kbrepeat.s diff --git a/libsrc/c128/kbrepeat.s b/libsrc/c128/kbrepeat.s new file mode 100644 index 000000000..f515e4ca3 --- /dev/null +++ b/libsrc/c128/kbrepeat.s @@ -0,0 +1,22 @@ + + .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate + + .include "c128/c128.inc" + +_kbrepeat: + ldx KBDREPEAT ; get old value + sta KBDREPEAT ; store new value + txa ; return old value + rts + +_kbrepeatdelay: + ldx KBDREPEATDELAY ; get old value + sta KBDREPEATDELAY ; store new value + txa ; return old value + rts + +_kbrepeatrate: + ldx KBDREPEATRATE ; get old value + sta KBDREPEATRATE ; store new value + txa ; return old value + rts diff --git a/libsrc/c64/kbrepeat.s b/libsrc/c64/kbrepeat.s new file mode 100644 index 000000000..b6c33250b --- /dev/null +++ b/libsrc/c64/kbrepeat.s @@ -0,0 +1,22 @@ + + .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate + + .include "c64/c64.inc" + +_kbrepeat: + ldx KBDREPEAT ; get old value + sta KBDREPEAT ; store new value + txa ; return old value + rts + +_kbrepeatdelay: + ldx KBDREPEATDELAY ; get old value + sta KBDREPEATDELAY ; store new value + txa ; return old value + rts + +_kbrepeatrate: + ldx KBDREPEATRATE ; get old value + sta KBDREPEATRATE ; store new value + txa ; return old value + rts diff --git a/libsrc/pet/kbrepeat.s b/libsrc/pet/kbrepeat.s new file mode 100644 index 000000000..44d60575f --- /dev/null +++ b/libsrc/pet/kbrepeat.s @@ -0,0 +1,22 @@ + + .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate + + .include "pet/pet.inc" + +_kbrepeat: + ldx KBDREPEAT ; get old value + sta KBDREPEAT ; store new value + txa ; return old value + rts + +_kbrepeatdelay: + ldx KBDREPEATDELAY ; get old value + sta KBDREPEATDELAY ; store new value + txa ; return old value + rts + +_kbrepeatrate: + ldx KBDREPEATRATE ; get old value + sta KBDREPEATRATE ; store new value + txa ; return old value + rts diff --git a/libsrc/plus4/kbrepeat.s b/libsrc/plus4/kbrepeat.s new file mode 100644 index 000000000..8636d0e33 --- /dev/null +++ b/libsrc/plus4/kbrepeat.s @@ -0,0 +1,22 @@ + + .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate + + .include "plus4/plus4.inc" + +_kbrepeat: + ldx KBDREPEAT ; get old value + sta KBDREPEAT ; store new value + txa ; return old value + rts + +_kbrepeatdelay: + ldx KBDREPEATDELAY ; get old value + sta KBDREPEATDELAY ; store new value + txa ; return old value + rts + +_kbrepeatrate: + ldx KBDREPEATRATE ; get old value + sta KBDREPEATRATE ; store new value + txa ; return old value + rts diff --git a/libsrc/vic20/kbrepeat.s b/libsrc/vic20/kbrepeat.s new file mode 100644 index 000000000..5a4ad96f6 --- /dev/null +++ b/libsrc/vic20/kbrepeat.s @@ -0,0 +1,22 @@ + + .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate + + .include "vic20/vic20.inc" + +_kbrepeat: + ldx KBDREPEAT ; get old value + sta KBDREPEAT ; store new value + txa ; return old value + rts + +_kbrepeatdelay: + ldx KBDREPEATDELAY ; get old value + sta KBDREPEATDELAY ; store new value + txa ; return old value + rts + +_kbrepeatrate: + ldx KBDREPEATRATE ; get old value + sta KBDREPEATRATE ; store new value + txa ; return old value + rts From eb96a90e5fe642102b5b81dc1e031641ed362c29 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Feb 2016 22:35:46 +0100 Subject: [PATCH 002/199] initial import from old sources --- libsrc/c128/waitvblank.s | 20 ++++++++++++++++++++ libsrc/c64/waitvblank.s | 20 ++++++++++++++++++++ libsrc/cbm510/waitvblank.s | 37 +++++++++++++++++++++++++++++++++++++ libsrc/vic20/waitvblank.s | 16 ++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 libsrc/c128/waitvblank.s create mode 100644 libsrc/c64/waitvblank.s create mode 100644 libsrc/cbm510/waitvblank.s create mode 100644 libsrc/vic20/waitvblank.s diff --git a/libsrc/c128/waitvblank.s b/libsrc/c128/waitvblank.s new file mode 100644 index 000000000..a3904d858 --- /dev/null +++ b/libsrc/c128/waitvblank.s @@ -0,0 +1,20 @@ + + .export _waitvblank + + .include "c128/c128.inc" + +_waitvblank: + lda PALFLAG + beq @ntsc + ldx #(312-24)-256 + .byte $2c +@ntsc: + ldx #(262-4)-256 +@l1: + lda VIC_CTRL1 + and #$80 + beq @l1 +@l2: + cpx VIC_HLINE + bcs @l2 + rts diff --git a/libsrc/c64/waitvblank.s b/libsrc/c64/waitvblank.s new file mode 100644 index 000000000..09570f873 --- /dev/null +++ b/libsrc/c64/waitvblank.s @@ -0,0 +1,20 @@ + + .export _waitvblank + + .include "c64/c64.inc" + +_waitvblank: + lda PALFLAG + beq @ntsc + ldx #(312-24)-256 + .byte $2c +@ntsc: + ldx #(262-4)-256 +@l1: + lda VIC_CTRL1 + and #$80 + beq @l1 +@l2: + cpx VIC_HLINE + bcs @l2 + rts diff --git a/libsrc/cbm510/waitvblank.s b/libsrc/cbm510/waitvblank.s new file mode 100644 index 000000000..30cbf072f --- /dev/null +++ b/libsrc/cbm510/waitvblank.s @@ -0,0 +1,37 @@ + + .export _waitvblank + .import PALFLAG + .import sys_bank, restore_bank + + .importzp vic + + .include "cbm510/cbm510.inc" + +_waitvblank: + rts ; FIXME + + jsr sys_bank ; Switch to the system bank + + lda PALFLAG + beq ntsc + ldx #(312-24)-256 + .byte $2c +ntsc: + ldx #(262-2)-256 + + sei + ldy #VIC_CTRL1 +l1: + lda (vic),y + and #$80 + beq l1 + +;?!? +; ldy #VIC_HLINE +; txa +;l2: +; cmp (vic),y +; bcs l2 + + cli + jmp restore_bank diff --git a/libsrc/vic20/waitvblank.s b/libsrc/vic20/waitvblank.s new file mode 100644 index 000000000..b99c74bed --- /dev/null +++ b/libsrc/vic20/waitvblank.s @@ -0,0 +1,16 @@ + .export _waitvblank + + .include "vic20/vic20.inc" + +_waitvblank: + lda PALFLAG + beq @ntsc + ldx #(312-8)/2 + .byte $2c +@ntsc: + ldx #(262-8)/2 +@l2: + cpx VIC_HLINE + bcs @l2 + rts + From 1f12a06f7cc2ae79a800fe3faed727513364091b Mon Sep 17 00:00:00 2001 From: Piotr Fusik Date: Mon, 13 Feb 2017 19:41:05 +0100 Subject: [PATCH 003/199] Disallow global variable declarations with an initializer. E.g. extern int i = 42; --- src/cc65/compile.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 9f1ab29f5..f01ddf6c5 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -144,17 +144,14 @@ static void Parse (void) ** ** - if it is not a typedef or function, ** - if we don't had a storage class given ("int i") - ** - if the storage class is explicitly specified as static, - ** - or if there is an initialization. + ** or the storage class is explicitly specified as static. ** ** This means that "extern int i;" will not get storage allocated. */ if ((Decl.StorageClass & SC_FUNC) != SC_FUNC && (Decl.StorageClass & SC_TYPEMASK) != SC_TYPEDEF && ((Spec.Flags & DS_DEF_STORAGE) != 0 || - (Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC || - ((Decl.StorageClass & SC_EXTERN) != 0 && - CurTok.Tok == TOK_ASSIGN))) { + (Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC)) { /* We will allocate storage */ Decl.StorageClass |= SC_STORAGE | SC_DEF; From 730d01a25f3440bd5bdca3a3cf8068287ff52f6a Mon Sep 17 00:00:00 2001 From: Piotr Fusik Date: Mon, 13 Feb 2017 21:04:45 +0100 Subject: [PATCH 004/199] Global uninitialized variable is only a tentative definition. Closes #204 --- src/cc65/compile.c | 55 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/cc65/compile.c b/src/cc65/compile.c index f01ddf6c5..85a2e9939 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -154,7 +154,7 @@ static void Parse (void) (Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC)) { /* We will allocate storage */ - Decl.StorageClass |= SC_STORAGE | SC_DEF; + Decl.StorageClass |= SC_STORAGE; } /* If this is a function declarator that is not followed by a comma @@ -187,6 +187,9 @@ static void Parse (void) /* Allow initialization */ if (CurTok.Tok == TOK_ASSIGN) { + /* This is a definition */ + Entry->Flags |= SC_DEF; + /* We cannot initialize types of unknown size, or ** void types in ISO modes. */ @@ -234,18 +237,14 @@ static void Parse (void) Entry->Flags &= ~(SC_STORAGE | SC_DEF); } - /* Allocate storage if it is still needed */ - if (Entry->Flags & SC_STORAGE) { - - /* Switch to the BSS segment */ - g_usebss (); - - /* Define a label */ - g_defgloblabel (Entry->Name); - - /* Allocate space for uninitialized variable */ - g_res (Size); - } + /* A global (including static) uninitialized variable + ** is only a tentative definition. For example, this is valid: + ** int i; + ** int i; + ** static int j; + ** static int j = 42; + ** Code for these will be generated in FinishCompile. + */ } } @@ -300,7 +299,7 @@ void Compile (const char* FileName) struct tm* TM; /* Since strftime is locale dependent, we need the abbreviated month names - ** in english. + ** in English. */ static const char MonthNames[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", @@ -397,20 +396,26 @@ void Compile (const char* FileName) void FinishCompile (void) /* Emit literals, externals, debug info, do cleanup and optimizations */ { - SymTable* SymTab; - SymEntry* Func; + SymEntry* Entry; - /* Walk over all functions, doing cleanup, optimizations ... */ - SymTab = GetGlobalSymTab (); - Func = SymTab->SymHead; - while (Func) { - if (SymIsOutputFunc (Func)) { + /* Walk over all global symbols: + ** - for functions do cleanup, optimizations ... + ** - generate code for uninitialized global variables + */ + for (Entry = GetGlobalSymTab ()->SymHead; Entry; Entry = Entry->NextSym) { + if (SymIsOutputFunc (Entry)) { /* Function which is defined and referenced or extern */ - MoveLiteralPool (Func->V.F.LitPool); - CS_MergeLabels (Func->V.F.Seg->Code); - RunOpt (Func->V.F.Seg->Code); + MoveLiteralPool (Entry->V.F.LitPool); + CS_MergeLabels (Entry->V.F.Seg->Code); + RunOpt (Entry->V.F.Seg->Code); + } else if ((Entry->Flags & (SC_STORAGE | SC_DEF | SC_STATIC)) == (SC_STORAGE | SC_STATIC)) { + /* Tentative definition of uninitialized global variable */ + g_usebss (); + g_defgloblabel (Entry->Name); + g_res (SizeOf (Entry->Type)); + /* Mark as defined, so that it will be exported not imported */ + Entry->Flags |= SC_DEF; } - Func = Func->NextSym; } /* Output the literal pool */ From 31f19fbc6579a57186cc44e06e8494a34b9de057 Mon Sep 17 00:00:00 2001 From: Piotr Fusik Date: Mon, 13 Feb 2017 21:10:21 +0100 Subject: [PATCH 005/199] Issue an error for duplicate global variables. Previously it was an assembler error. --- src/cc65/compile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 85a2e9939..9cdeaf7e5 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -188,6 +188,10 @@ static void Parse (void) if (CurTok.Tok == TOK_ASSIGN) { /* This is a definition */ + if (SymIsDef (Entry)) { + Error ("Global variable `%s' has already been defined", + Entry->Name); + } Entry->Flags |= SC_DEF; /* We cannot initialize types of unknown size, or From 5988ec37cdce1655b14159a3a20a5493ba5459fd Mon Sep 17 00:00:00 2001 From: Piotr Fusik Date: Wed, 15 Feb 2017 18:51:27 +0100 Subject: [PATCH 006/199] Revert "Disallow global variable declarations with an initializer." This reverts commit 1f12a06f7cc2ae79a800fe3faed727513364091b. --- src/cc65/compile.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 9cdeaf7e5..48a5c29d3 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -144,14 +144,17 @@ static void Parse (void) ** ** - if it is not a typedef or function, ** - if we don't had a storage class given ("int i") - ** or the storage class is explicitly specified as static. + ** - if the storage class is explicitly specified as static, + ** - or if there is an initialization. ** ** This means that "extern int i;" will not get storage allocated. */ if ((Decl.StorageClass & SC_FUNC) != SC_FUNC && (Decl.StorageClass & SC_TYPEMASK) != SC_TYPEDEF && ((Spec.Flags & DS_DEF_STORAGE) != 0 || - (Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC)) { + (Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC || + ((Decl.StorageClass & SC_EXTERN) != 0 && + CurTok.Tok == TOK_ASSIGN))) { /* We will allocate storage */ Decl.StorageClass |= SC_STORAGE; From 6afcc370edbd77d494fc6378a20de0023be6981f Mon Sep 17 00:00:00 2001 From: IrgendwerA8 Date: Sat, 25 Feb 2017 20:19:34 +0100 Subject: [PATCH 007/199] Optimization of two string functions (size & speed). --- libsrc/common/strcat.s | 48 ++++++++------------ libsrc/common/strchr.s | 47 ++++++++++--------- testcode/lib/strcat-test.c | 93 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 52 deletions(-) create mode 100644 testcode/lib/strcat-test.c diff --git a/libsrc/common/strcat.s b/libsrc/common/strcat.s index 7784d89f7..279bfe65b 100644 --- a/libsrc/common/strcat.s +++ b/libsrc/common/strcat.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 31.05.1998 +; Christian Krueger: 2013-Jul-24, minor optimization ; ; char* strcat (char* dest, const char* src); ; @@ -12,44 +13,35 @@ _strcat: sta ptr1 ; Save src stx ptr1+1 jsr popax ; Get dest - sta ptr2 - stx ptr2+1 sta tmp3 ; Remember for function return - ldy #0 + tay + lda #0 + sta ptr2 ; access from page start, y contains low byte + stx ptr2+1 -; find end of dest - -sc1: lda (ptr2),y - beq sc2 +findEndOfDest: + lda (ptr2),y + beq endOfDestFound iny - bne sc1 + bne findEndOfDest inc ptr2+1 - bne sc1 + bne findEndOfDest -; end found, get offset in y into pointer +endOfDestFound: + sty ptr2 ; advance pointer to last y position + ldy #0 ; reset new y-offset -sc2: tya - clc - adc ptr2 - sta ptr2 - bcc sc3 - inc ptr2+1 - -; copy src - -sc3: ldy #0 -sc4: lda (ptr1),y +copyByte: + lda (ptr1),y sta (ptr2),y - beq sc5 + beq done iny - bne sc4 + bne copyByte inc ptr1+1 inc ptr2+1 - bne sc4 + bne copyByte ; like bra here -; done, return pointer to dest - -sc5: lda tmp3 ; X does still contain high byte +; return pointer to dest +done: lda tmp3 ; X does still contain high byte rts - diff --git a/libsrc/common/strchr.s b/libsrc/common/strchr.s index 308381b06..0bd55d0e1 100644 --- a/libsrc/common/strchr.s +++ b/libsrc/common/strchr.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 31.05.1998 +; Christian Krueger, 2013-Aug-04, minor optimization ; ; const char* strchr (const char* s, int c); ; @@ -9,40 +10,38 @@ .importzp ptr1, tmp1 _strchr: - sta tmp1 ; Save c - jsr popax ; get s - sta ptr1 - stx ptr1+1 - ldy #0 + sta tmp1 ; Save c + jsr popax ; get s + tay ; low byte of pointer to y + stx ptr1+1 + lda #0 + sta ptr1 ; ptr access page wise -Loop: lda (ptr1),y ; Get next char - beq EOS ; Jump on end of string - cmp tmp1 ; Found? - beq Found ; Jump if yes +Loop: lda (ptr1),y ; Get next char + beq EOS ; Jump on end of string + cmp tmp1 ; Found? + beq Found ; Jump if yes iny - bne Loop - inc ptr1+1 - bne Loop ; Branch always + bne Loop + inc ptr1+1 + bne Loop ; Branch always ; End of string. Check if we're searching for the terminating zero -EOS: lda tmp1 ; Get the char we're searching for - bne NotFound ; Jump if not searching for terminator +EOS: + lda tmp1 ; Get the char we're searching for + bne NotFound ; Jump if not searching for terminator -; Found. Calculate pointer to c. +; Found. Set pointer to c. -Found: ldx ptr1+1 ; Load high byte of pointer - tya ; Low byte offset - clc - adc ptr1 - bcc Found1 - inx -Found1: rts +Found: + ldx ptr1+1 ; Load high byte of pointer + tya ; low byte is in y + rts ; Not found, return NULL NotFound: - lda #0 + lda #0 tax rts - diff --git a/testcode/lib/strcat-test.c b/testcode/lib/strcat-test.c new file mode 100644 index 000000000..edd614fc4 --- /dev/null +++ b/testcode/lib/strcat-test.c @@ -0,0 +1,93 @@ +#include +#include +#include + +#define SourceStringSize 257 // test correct page passing (>256) + +static char SourceString[SourceStringSize+1]; // +1 room for terminating null +static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer + + +int main (void) +{ + unsigned i,j; + char* p; + + /* Print a header */ + printf ("strcat(): "); + + for (i=0; i < SourceStringSize; ++i) + SourceString[i] = (i%128)+1; + + SourceString[i] = 0; + + if (strlen(SourceString) != SourceStringSize) + { + printf ("Fail: Source string initialization or 'strlen()' problem!\n"); + printf ("Expected length: %u but is %u!\n", SourceStringSize, strlen(SourceString)); + exit (EXIT_FAILURE); + } + + /* Ensure empty destination string */ + DestinationString[0] = 0; + + if (strlen(DestinationString) != 0) + { + printf ("Fail: Destination string initialization or 'strlen()' problem!\n"); + printf ("Expected length: %u but is %u!\n", 0, strlen(DestinationString)); + exit (EXIT_FAILURE); + } + + /* Test concatenation to empty buffer */ + + p = strcat(DestinationString, SourceString); + + if (strlen(DestinationString) != SourceStringSize) + { + printf ("Fail: String concatenation to empty buffer!\n"); + printf ("Expected length: %u but is %u!\n", SourceStringSize, strlen(DestinationString)); + exit (EXIT_FAILURE); + } + + /* Test concatenation to non empty buffer */ + + p = strcat(DestinationString, SourceString); + + if (strlen(DestinationString) != 2*SourceStringSize) + { + printf ("Fail: String concatenation to non-empty buffer!\n"); + printf ("Expected length: %u but is %u!\n", 2*SourceStringSize, strlen(DestinationString)); + exit (EXIT_FAILURE); + } + + /* Test return value */ + + if (p != DestinationString) + { + printf ("Invalid return value!\n"); + exit (EXIT_FAILURE); + } + + /* Test contents */ + + for(j=0; j <2; ++j) + for(i=0; i < SourceStringSize; ++i) + { + unsigned position = j*SourceStringSize+i; + unsigned current = DestinationString[position]; + unsigned expected = (i%128)+1; + if (current != expected) + { + printf ("Fail: Unexpected destination buffer contents at position %u!\n", position); + printf ("Expected %u, but is %u!\n", expected, current); + exit (EXIT_FAILURE); + } + } + + /* Test passed */ + printf ("Passed\n"); + return EXIT_SUCCESS; +} + + + From c240d42a9e36f565f03d00eab80b9a2c5aa99ae3 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 Date: Sun, 26 Feb 2017 20:03:05 +0100 Subject: [PATCH 008/199] Added "strrchr" optimizaion a matching unit test and tiny unit test framework. (Documentation for that will follow later) --- include/unittest.h | 89 +++++++++++++++++++++++++++++++++++++ libsrc/common/strrchr.s | 58 +++++++++++------------- testcode/lib/strcat-test.c | 65 ++++++--------------------- testcode/lib/strrchr-test.c | 38 ++++++++++++++++ 4 files changed, 167 insertions(+), 83 deletions(-) create mode 100644 include/unittest.h create mode 100644 testcode/lib/strrchr-test.c diff --git a/include/unittest.h b/include/unittest.h new file mode 100644 index 000000000..a58bbb937 --- /dev/null +++ b/include/unittest.h @@ -0,0 +1,89 @@ +/*****************************************************************************/ +/* */ +/* unittest.h */ +/* */ +/* Unit test helper macros */ +/* */ +/* */ +/* */ +/* (C) 2017 Christian 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 _UNITTEST_H +#define _UNITTEST_H + +#include +#include + +#ifndef COMMA +#define COMMA , +#endif + +#define TEST int main(void) \ + {\ + printf("%s: ",__FILE__); + +#define ENDTEST printf("Passed\n"); \ + return EXIT_SUCCESS; \ + } + +#define ASSERT_IsTrue(a,b) if (!(a)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(b);\ + printf("\n");\ + printf("Expected status should be true but wasn't!\n");\ + exit(EXIT_FAILURE);\ + } + +#define ASSERT_IsFalse(a,b) if ((a)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(b);\ + printf("\n");\ + printf("Expected status should be false but wasn't!\n");\ + exit(EXIT_FAILURE);\ + } + +#define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(d);\ + printf("\n");\ + printf("Expected value: "c", but is "c"!\n", (a), (b));\ + exit(EXIT_FAILURE);\ + } + +#define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(d);\ + printf("\n");\ + printf("Expected value not: "c", but is "c"!\n", (a), (b));\ + exit(EXIT_FAILURE);\ + } + +/* End of unittest.h */ +#endif + + + + diff --git a/libsrc/common/strrchr.s b/libsrc/common/strrchr.s index bd7389e76..3e4fb0810 100644 --- a/libsrc/common/strrchr.s +++ b/libsrc/common/strrchr.s @@ -1,47 +1,41 @@ ; ; Ullrich von Bassewitz, 31.05.1998 +; Christian Krueger: 2013-Aug-01, optimization ; ; char* strrchr (const char* s, int c); ; .export _strrchr .import popax - .importzp ptr1, ptr2, tmp1 + .importzp ptr1, tmp1, tmp2 _strrchr: - sta tmp1 ; Save c - jsr popax ; get s - sta ptr1 - stx ptr1+1 - lda #0 ; function result = NULL - sta ptr2 - sta ptr2+1 - tay + sta tmp1 ; Save c + jsr popax ; get s + tay ; low byte to y + stx ptr1+1 + ldx #0 ; default function result is NULL, X is high byte... + stx tmp2 ; tmp2 is low-byte + stx ptr1 ; low-byte of source string is in Y, so clear real one... + +testChar: + lda (ptr1),y ; get char + beq finished ; jump if end of string + cmp tmp1 ; found? + bne nextChar ; jump if no -L1: lda (ptr1),y ; get next char - beq L3 ; jump if end of string - cmp tmp1 ; found? - bne L2 ; jump if no +charFound: + sty tmp2 ; y has low byte of location, save it + ldx ptr1+1 ; x holds high-byte of result -; Remember a pointer to the character +nextChar: + iny + bne testChar + inc ptr1+1 + bne testChar ; here like bra... - tya - clc - adc ptr1 - sta ptr2 - lda ptr1+1 - adc #$00 - sta ptr2+1 +; return the pointer to the last occurrence -; Next char - -L2: iny - bne L1 - inc ptr1+1 - bne L1 ; jump always - -; Return the pointer to the last occurrence - -L3: lda ptr2 - ldx ptr2+1 +finished: + lda tmp2 ; high byte in X is already correct... rts diff --git a/testcode/lib/strcat-test.c b/testcode/lib/strcat-test.c index edd614fc4..fdc987288 100644 --- a/testcode/lib/strcat-test.c +++ b/testcode/lib/strcat-test.c @@ -1,5 +1,4 @@ -#include -#include +#include #include #define SourceStringSize 257 // test correct page passing (>256) @@ -8,65 +7,38 @@ static char SourceString[SourceStringSize+1]; // +1 room for terminating null static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer -int main (void) +TEST { unsigned i,j; char* p; - - /* Print a header */ - printf ("strcat(): "); - + for (i=0; i < SourceStringSize; ++i) SourceString[i] = (i%128)+1; SourceString[i] = 0; - if (strlen(SourceString) != SourceStringSize) - { - printf ("Fail: Source string initialization or 'strlen()' problem!\n"); - printf ("Expected length: %u but is %u!\n", SourceStringSize, strlen(SourceString)); - exit (EXIT_FAILURE); - } + ASSERT_AreEqual(SourceStringSize, strlen(SourceString), "%u", "Source string initialization or 'strlen()' problem!"); /* Ensure empty destination string */ DestinationString[0] = 0; - if (strlen(DestinationString) != 0) - { - printf ("Fail: Destination string initialization or 'strlen()' problem!\n"); - printf ("Expected length: %u but is %u!\n", 0, strlen(DestinationString)); - exit (EXIT_FAILURE); - } - + ASSERT_AreEqual(0, strlen(DestinationString), "%u", "Destination string initialization or 'strlen()' problem!"); + /* Test concatenation to empty buffer */ - p = strcat(DestinationString, SourceString); - - if (strlen(DestinationString) != SourceStringSize) - { - printf ("Fail: String concatenation to empty buffer!\n"); - printf ("Expected length: %u but is %u!\n", SourceStringSize, strlen(DestinationString)); - exit (EXIT_FAILURE); - } - + strcat(DestinationString, SourceString); + + ASSERT_AreEqual(SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to empty buffer!"); + /* Test concatenation to non empty buffer */ p = strcat(DestinationString, SourceString); - if (strlen(DestinationString) != 2*SourceStringSize) - { - printf ("Fail: String concatenation to non-empty buffer!\n"); - printf ("Expected length: %u but is %u!\n", 2*SourceStringSize, strlen(DestinationString)); - exit (EXIT_FAILURE); - } + ASSERT_AreEqual(2*SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to non-empty buffer!"); /* Test return value */ - if (p != DestinationString) - { - printf ("Invalid return value!\n"); - exit (EXIT_FAILURE); - } + ASSERT_IsTrue(p == DestinationString,"Invalid return value!"); /* Test contents */ @@ -76,18 +48,9 @@ int main (void) unsigned position = j*SourceStringSize+i; unsigned current = DestinationString[position]; unsigned expected = (i%128)+1; - if (current != expected) - { - printf ("Fail: Unexpected destination buffer contents at position %u!\n", position); - printf ("Expected %u, but is %u!\n", expected, current); - exit (EXIT_FAILURE); - } + ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position); } - - /* Test passed */ - printf ("Passed\n"); - return EXIT_SUCCESS; } - +ENDTEST diff --git a/testcode/lib/strrchr-test.c b/testcode/lib/strrchr-test.c new file mode 100644 index 000000000..9c1c70032 --- /dev/null +++ b/testcode/lib/strrchr-test.c @@ -0,0 +1,38 @@ +#include +#include + +static char TestString[] = "01234567890123456789"; // two times the same string +static char Found[256]; + +TEST +{ + unsigned len; + unsigned i; + char* p; + + len = strlen(TestString)/2; // test only one half of the string, to find last appearance + + /* Search for all characters in the string, including the terminator */ + for (i = 0; i < len; ++i) + { + /* Search for this char */ + p = strrchr (TestString, TestString[i]); + ASSERT_AreEqual(i+len, p-TestString, "%u", "Unexpected location of character '%c' found!" COMMA TestString[i]); + + /* Mark the char as checked */ + Found[TestString[i]] = 1; + } + + /* Search for all other characters and make sure they aren't found */ + for (i = 0; i < 256; ++i) + { + if (!Found[i]) + { + p = strrchr (TestString, i); + ASSERT_IsFalse(p, "Unexpected location of character '%c' found!" COMMA TestString[i]); + } + } +} +ENDTEST + + From 3d28f5ca9089bd7f16ce77efeba0c66752932a07 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 Date: Sun, 26 Feb 2017 22:36:19 +0100 Subject: [PATCH 009/199] Fixed indentation --- include/unittest.h | 78 ++++++++++++++++++------------------- libsrc/common/strcat.s | 47 +++++++++++----------- testcode/lib/strcat-test.c | 4 +- testcode/lib/strrchr-test.c | 4 +- 4 files changed, 66 insertions(+), 67 deletions(-) diff --git a/include/unittest.h b/include/unittest.h index a58bbb937..bd355bb0c 100644 --- a/include/unittest.h +++ b/include/unittest.h @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2017 Christian Krueger */ +/* (C) 2017 Christian 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 */ @@ -37,49 +37,49 @@ #define COMMA , #endif -#define TEST int main(void) \ - {\ - printf("%s: ",__FILE__); +#define TEST int main(void) \ + {\ + printf("%s: ",__FILE__); -#define ENDTEST printf("Passed\n"); \ - return EXIT_SUCCESS; \ - } +#define ENDTEST printf("Passed\n"); \ + return EXIT_SUCCESS; \ + } -#define ASSERT_IsTrue(a,b) if (!(a)) \ - {\ - printf("Fail at line %d:\n",__LINE__);\ - printf(b);\ - printf("\n");\ - printf("Expected status should be true but wasn't!\n");\ - exit(EXIT_FAILURE);\ - } +#define ASSERT_IsTrue(a,b) if (!(a)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(b);\ + printf("\n");\ + printf("Expected status should be true but wasn't!\n");\ + exit(EXIT_FAILURE);\ + } -#define ASSERT_IsFalse(a,b) if ((a)) \ - {\ - printf("Fail at line %d:\n",__LINE__);\ - printf(b);\ - printf("\n");\ - printf("Expected status should be false but wasn't!\n");\ - exit(EXIT_FAILURE);\ - } +#define ASSERT_IsFalse(a,b) if ((a)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(b);\ + printf("\n");\ + printf("Expected status should be false but wasn't!\n");\ + exit(EXIT_FAILURE);\ + } -#define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \ - {\ - printf("Fail at line %d:\n",__LINE__);\ - printf(d);\ - printf("\n");\ - printf("Expected value: "c", but is "c"!\n", (a), (b));\ - exit(EXIT_FAILURE);\ - } +#define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(d);\ + printf("\n");\ + printf("Expected value: "c", but is "c"!\n", (a), (b));\ + exit(EXIT_FAILURE);\ + } -#define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \ - {\ - printf("Fail at line %d:\n",__LINE__);\ - printf(d);\ - printf("\n");\ - printf("Expected value not: "c", but is "c"!\n", (a), (b));\ - exit(EXIT_FAILURE);\ - } +#define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(d);\ + printf("\n");\ + printf("Expected value not: "c", but is "c"!\n", (a), (b));\ + exit(EXIT_FAILURE);\ + } /* End of unittest.h */ #endif diff --git a/libsrc/common/strcat.s b/libsrc/common/strcat.s index 279bfe65b..9be65386f 100644 --- a/libsrc/common/strcat.s +++ b/libsrc/common/strcat.s @@ -10,38 +10,37 @@ .importzp ptr1, ptr2, tmp3 _strcat: - sta ptr1 ; Save src - stx ptr1+1 - jsr popax ; Get dest - sta tmp3 ; Remember for function return - tay - lda #0 - sta ptr2 ; access from page start, y contains low byte - stx ptr2+1 + sta ptr1 ; Save src + stx ptr1+1 + jsr popax ; Get dest + sta tmp3 ; Remember for function return + tay + lda #0 + sta ptr2 ; access from page start, y contains low byte + stx ptr2+1 findEndOfDest: - lda (ptr2),y - beq endOfDestFound + lda (ptr2),y + beq endOfDestFound iny - bne findEndOfDest - inc ptr2+1 - bne findEndOfDest + bne findEndOfDest + inc ptr2+1 + bne findEndOfDest endOfDestFound: - sty ptr2 ; advance pointer to last y position - ldy #0 ; reset new y-offset + sty ptr2 ; advance pointer to last y position + ldy #0 ; reset new y-offset copyByte: - lda (ptr1),y - sta (ptr2),y - beq done + lda (ptr1),y + sta (ptr2),y + beq done iny - bne copyByte - inc ptr1+1 - inc ptr2+1 - bne copyByte ; like bra here + bne copyByte + inc ptr1+1 + inc ptr2+1 + bne copyByte ; like bra here ; return pointer to dest -done: lda tmp3 ; X does still contain high byte +done: lda tmp3 ; X does still contain high byte rts - diff --git a/testcode/lib/strcat-test.c b/testcode/lib/strcat-test.c index fdc987288..2e00b80cb 100644 --- a/testcode/lib/strcat-test.c +++ b/testcode/lib/strcat-test.c @@ -3,7 +3,7 @@ #define SourceStringSize 257 // test correct page passing (>256) -static char SourceString[SourceStringSize+1]; // +1 room for terminating null +static char SourceString[SourceStringSize+1]; // +1 room for terminating null static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer @@ -48,7 +48,7 @@ TEST unsigned position = j*SourceStringSize+i; unsigned current = DestinationString[position]; unsigned expected = (i%128)+1; - ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position); + ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position); } } ENDTEST diff --git a/testcode/lib/strrchr-test.c b/testcode/lib/strrchr-test.c index 9c1c70032..d2c2a20e4 100644 --- a/testcode/lib/strrchr-test.c +++ b/testcode/lib/strrchr-test.c @@ -1,7 +1,7 @@ #include #include -static char TestString[] = "01234567890123456789"; // two times the same string +static char TestString[] = "01234567890123456789"; // two times the same string static char Found[256]; TEST @@ -10,7 +10,7 @@ TEST unsigned i; char* p; - len = strlen(TestString)/2; // test only one half of the string, to find last appearance + len = strlen(TestString)/2; // test only one half of the string, to find last appearance /* Search for all characters in the string, including the terminator */ for (i = 0; i < len; ++i) From 09de875330a4ca5eeabf91a21e774758c1de4417 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 Date: Tue, 28 Feb 2017 08:05:11 +0100 Subject: [PATCH 010/199] Changed the location of unittest.h --- testcode/lib/strcat-test.c | 2 +- testcode/lib/strrchr-test.c | 2 +- {include => testcode/lib}/unittest.h | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename {include => testcode/lib}/unittest.h (100%) diff --git a/testcode/lib/strcat-test.c b/testcode/lib/strcat-test.c index 2e00b80cb..58119e27a 100644 --- a/testcode/lib/strcat-test.c +++ b/testcode/lib/strcat-test.c @@ -1,5 +1,5 @@ -#include #include +#include "unittest.h" #define SourceStringSize 257 // test correct page passing (>256) diff --git a/testcode/lib/strrchr-test.c b/testcode/lib/strrchr-test.c index d2c2a20e4..a72c44db9 100644 --- a/testcode/lib/strrchr-test.c +++ b/testcode/lib/strrchr-test.c @@ -1,5 +1,5 @@ -#include #include +#include "unittest.h" static char TestString[] = "01234567890123456789"; // two times the same string static char Found[256]; diff --git a/include/unittest.h b/testcode/lib/unittest.h similarity index 100% rename from include/unittest.h rename to testcode/lib/unittest.h From 99f3c7d01d598061ff386a3b057b6db43e759eb0 Mon Sep 17 00:00:00 2001 From: Greg King Date: Wed, 1 Mar 2017 06:29:53 -0500 Subject: [PATCH 011/199] Fixed a makefile: "yaccdbg.c" includes "yacc.c". So, yaccdbg must depend on both of them. --- test/ref/Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/ref/Makefile b/test/ref/Makefile index 09dd96d44..6f0bd1bc1 100644 --- a/test/ref/Makefile +++ b/test/ref/Makefile @@ -1,4 +1,3 @@ - # makefile for the regression tests that generate output which has to be # compared with reference output @@ -24,7 +23,7 @@ WORKDIR := ..$S..$Stestwrk DIFF := $(WORKDIR)/bdiff CC := gcc -CFLAGS := -O2 -Wall -W -Wextra -fwrapv -fno-strict-overflow +CFLAGS := -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow .PHONY: all clean @@ -34,6 +33,11 @@ TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c= all: $(REFS) $(TESTS) +# "yaccdbg.c" includes "yacc.c". +# yaccdbg's built files must depend on both of them. + +$(WORKDIR)/yaccdbg.ref: yacc.c + $(WORKDIR)/%.ref: %.c $(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host $(WORKDIR)$S$*.host > $@ @@ -48,6 +52,8 @@ $(WORKDIR)/switch.%rg: CC65FLAGS += -Wc --all-cdecl $(WORKDIR)/yacc.%rg: CC65FLAGS += -Wc --all-cdecl $(WORKDIR)/yaccdbg%prg: CC65FLAGS += -Wc --all-cdecl +$(WORKDIR)/yaccdbg%prg: yacc.c + $(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref $(CL65) $(CC65FLAGS) $< -o $@ $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out From 8f0ea644dddfaf9c41718ff055f4b77f0b8f43ad Mon Sep 17 00:00:00 2001 From: Greg King Date: Wed, 1 Mar 2017 06:36:25 -0500 Subject: [PATCH 012/199] Fixed a pointer-difference, comparison-with-zero expression. Some GCC C compilers can't subtract higher pointers from lower pointers properly, when those pointers must be scaled (because they point to objects that are wider than a char). The scaling is done as unsigned which makes the difference positive instead of negative. So, a broken expression was changed into a direct comparison between the two pointers. --- test/ref/yacc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ref/yacc.c b/test/ref/yacc.c index 5768f80d0..d0b9190e4 100644 --- a/test/ref/yacc.c +++ b/test/ref/yacc.c @@ -562,7 +562,7 @@ yylook() } # ifdef LEXDEBUG - if((*(lsp-1)-yysvec-1)<0) + if (*(lsp-1) < yysvec + 1) { fprintf(yyout,"yylook: stopped (end)\n"); } From 9558ebf86c60339fec73895a70c39292469173a2 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Sat, 4 Mar 2017 10:04:32 +0100 Subject: [PATCH 013/199] creativision/crt0.s: enable display interrupts in display controller configuration Otherwise the joystick zero page locations won't get updated. --- libsrc/creativision/crt0.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/creativision/crt0.s b/libsrc/creativision/crt0.s index 6faec38eb..420ac71ef 100644 --- a/libsrc/creativision/crt0.s +++ b/libsrc/creativision/crt0.s @@ -81,7 +81,7 @@ irq2: jmp BIOS_IRQ2_ADDR ; VDP Setup ; This sets to Graphics Mode 1 .byte $00 ; Register 0 - .byte $C0 ; Register 1 16K RAM, Active Display, Mode 1 + .byte $E0 ; Register 1 16K RAM, Active Display, Mode 1, VBI enabled .byte $04 ; Register 2 Name Table at $1000 - $12FF .byte $60 ; Register 3 Colour Table at $1800 - $181F .byte $00 ; Register 4 Pattern Table at $0000 - $07FF From 81115aa82625f2b7e773b29844a3a7af589cdb95 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 Date: Sun, 5 Mar 2017 02:09:12 +0100 Subject: [PATCH 014/199] Added further optimizations and unit tests. --- libsrc/common/memmove.s | 11 +-- libsrc/common/strcat.s | 6 +- libsrc/common/strchr.s | 6 +- libsrc/common/strcspn.s | 78 +++++++-------- libsrc/common/strlen.s | 5 +- libsrc/common/strncat.s | 96 ++++++++++--------- libsrc/common/strspn.s | 80 ++++++++-------- libsrc/runtime/axlong.s | 16 ++-- test/val/{atoi-test.c => lib_common_atoi.c} | 0 test/val/lib_common_memmove.c | 61 ++++++++++++ .../val/lib_common_strcat.c | 2 - .../val/lib_common_strchr.c | 39 +++----- test/val/lib_common_strcspn.c | 26 +++++ test/val/lib_common_strncat.c | 54 +++++++++++ .../val/{strtol-test.c => lib_common_strol.c} | 0 .../val/lib_common_strrchr.c | 0 test/val/lib_common_strspn.c | 24 +++++ .../{strtoul-test.c => lib_common_strtoul.c} | 0 {testcode/lib => test/val}/unittest.h | 0 19 files changed, 327 insertions(+), 177 deletions(-) rename test/val/{atoi-test.c => lib_common_atoi.c} (100%) create mode 100644 test/val/lib_common_memmove.c rename testcode/lib/strcat-test.c => test/val/lib_common_strcat.c (99%) rename testcode/lib/strchr-test.c => test/val/lib_common_strchr.c (50%) create mode 100644 test/val/lib_common_strcspn.c create mode 100644 test/val/lib_common_strncat.c rename test/val/{strtol-test.c => lib_common_strol.c} (100%) rename testcode/lib/strrchr-test.c => test/val/lib_common_strrchr.c (100%) create mode 100644 test/val/lib_common_strspn.c rename test/val/{strtoul-test.c => lib_common_strtoul.c} (100%) rename {testcode/lib => test/val}/unittest.h (100%) diff --git a/libsrc/common/memmove.s b/libsrc/common/memmove.s index 9c33124f1..666447cd8 100644 --- a/libsrc/common/memmove.s +++ b/libsrc/common/memmove.s @@ -1,6 +1,6 @@ ; ; 2003-08-20, Ullrich von Bassewitz -; 2009-09-13, Christian Krueger -- performance increase (about 20%) +; 2009-09-13, Christian Krueger -- performance increase (about 20%), 2013-07-25 improved unrolling ; 2015-10-23, Greg King ; ; void* __fastcall__ memmove (void* dest, const void* src, size_t size); @@ -61,13 +61,10 @@ PageSizeCopy: ; assert Y = 0 dec ptr1+1 ; adjust base... dec ptr2+1 dey ; in entry case: 0 -> FF - lda (ptr1),y ; need to copy this 'intro byte' - sta (ptr2),y ; to 'land' later on Y=0! (as a result of the '.repeat'-block!) - dey ; FF ->FE @copyBytes: - .repeat 2 ; Unroll this a bit to make it faster... - lda (ptr1),y - sta (ptr2),y + .repeat 3 ; unroll this a bit to make it faster... + lda (ptr1),y ; important: unrolling three times gives a nice + sta (ptr2),y ; 255/3 = 85 loop which ends at 0 dey .endrepeat @copyEntry: ; in entry case: 0 -> FF diff --git a/libsrc/common/strcat.s b/libsrc/common/strcat.s index 9be65386f..74fef0759 100644 --- a/libsrc/common/strcat.s +++ b/libsrc/common/strcat.s @@ -1,6 +1,6 @@ ; ; Ullrich von Bassewitz, 31.05.1998 -; Christian Krueger: 2013-Jul-24, minor optimization +; Christian Krueger: 2013-Jul-24, minor optimizations ; ; char* strcat (char* dest, const char* src); ; @@ -15,8 +15,12 @@ _strcat: jsr popax ; Get dest sta tmp3 ; Remember for function return tay +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz ptr2 +.else lda #0 sta ptr2 ; access from page start, y contains low byte +.endif stx ptr2+1 findEndOfDest: diff --git a/libsrc/common/strchr.s b/libsrc/common/strchr.s index 0bd55d0e1..48bb8822b 100644 --- a/libsrc/common/strchr.s +++ b/libsrc/common/strchr.s @@ -14,8 +14,12 @@ _strchr: jsr popax ; get s tay ; low byte of pointer to y stx ptr1+1 +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz ptr1 +.else lda #0 - sta ptr1 ; ptr access page wise + sta ptr1 ; access from page start, y contains low byte +.endif Loop: lda (ptr1),y ; Get next char beq EOS ; Jump on end of string diff --git a/libsrc/common/strcspn.s b/libsrc/common/strcspn.s index 8fd567ae4..3f7b42ed1 100644 --- a/libsrc/common/strcspn.s +++ b/libsrc/common/strcspn.s @@ -1,54 +1,54 @@ ; ; Ullrich von Bassewitz, 11.06.1998 +; Christian Krueger: 05-Aug-2013, optimization ; ; size_t strcspn (const char* s1, const char* s2); ; .export _strcspn - .import popax - .importzp ptr1, ptr2, tmp1, tmp2, tmp3 + .import popax, _strlen + .importzp ptr1, ptr2, tmp1, tmp2 _strcspn: - sta ptr2 ; Save s2 - stx ptr2+1 - jsr popax ; Get s1 - sta ptr1 - stx ptr1+1 - ldx #0 ; low counter byte - stx tmp1 ; high counter byte - ldy #$00 + jsr _strlen ; get length in a/x and transfer s2 to ptr1 + ; Note: It does not make sense to + ; have more than 255 test chars, so + ; we don't support a high byte here! (ptr1+1 is + ; also unchanged in strlen then (important!)) + ; -> the original implementation also + ; ignored this case -L1: lda (ptr1),y ; get next char from s1 - beq L6 ; jump if done - sta tmp2 ; save char + sta tmp1 ; tmp1 = strlen of test chars + jsr popax ; get and save s1 + sta ptr2 ; to ptr2 + stx ptr2+1 + ldx #0 ; low counter byte + stx tmp2 ; high counter byte + +loadChar: + ldy #0 + lda (ptr2),y ; get next char from s1 + beq leave ; handly byte of s1 +advance: + inc ptr2 ; advance string position to test + bne check + inc ptr2+1 + dey ; correct next iny (faster/shorter than bne...) + +checkNext: iny - bne L2 - inc ptr1+1 -L2: sty tmp3 ; save index into s1 +check: cpy tmp1 ; compare with length of test character string + beq endOfTestChars + cmp (ptr1),y ; found matching char? + bne checkNext - ldy #0 ; get index into s2 -L3: lda (ptr2),y ; - beq L4 ; jump if done - cmp tmp2 - beq L6 - iny - bne L3 - -; The character was not found in s2. Increment the counter and start over - -L4: ldy tmp3 ; reload index - inx - bne L1 - inc tmp1 - bne L1 - -; The character was found, or we reached the end of s1. Return count of -; characters - -L6: txa ; get low counter byte - ldx tmp1 ; get high counter byte +leave: txa ; restore position of finding + ldx tmp2 ; and return rts - - +endOfTestChars: + inx + bne loadChar + inc tmp2 + bne loadChar ; like bra... diff --git a/libsrc/common/strlen.s b/libsrc/common/strlen.s index b583eea50..1a51edb11 100644 --- a/libsrc/common/strlen.s +++ b/libsrc/common/strlen.s @@ -1,6 +1,10 @@ ; ; Ullrich von Bassewitz, 31.05.1998 ; +; Note: strspn & strcspn call internally this function and rely on +; the usage of only ptr1 here! Keep in mind when appling changes +; and check the other implementations too! +; ; int strlen (const char* s); ; @@ -23,4 +27,3 @@ L1: lda (ptr1),y L9: tya ; get low byte of counter, hi's all set rts - diff --git a/libsrc/common/strncat.s b/libsrc/common/strncat.s index b7bb04b2a..42717853f 100644 --- a/libsrc/common/strncat.s +++ b/libsrc/common/strncat.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 31.05.1998 +; Christian Krueger: 12-Aug-2013, minor optimizations ; ; char* strncat (char* dest, const char* src, size_t n); ; @@ -9,64 +10,65 @@ .importzp ptr1, ptr2, ptr3, tmp1, tmp2 _strncat: - eor #$FF ; one's complement to count upwards - sta tmp1 - txa - eor #$FF - sta tmp2 - jsr popax ; get src - sta ptr1 - stx ptr1+1 - jsr popax ; get dest - sta ptr2 - stx ptr2+1 - sta ptr3 ; remember for function return - stx ptr3+1 - ldy #0 + eor #$FF ; one's complement to count upwards + sta tmp1 + txa + eor #$FF + sta tmp2 + + jsr popax ; get src + sta ptr1 + stx ptr1+1 + + jsr popax ; get dest + sta ptr3 ; remember for function return + stx ptr3+1 + stx ptr2+1 + tay ; low byte as offset in Y +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz ptr2 +.else + ldx #0 + stx ptr2 ; destination on page boundary +.endif ; find end of dest -L1: lda (ptr2),y - beq L2 - iny - bne L1 - inc ptr2+1 - bne L1 +L1: lda (ptr2),y + beq L2 + iny + bne L1 + inc ptr2+1 + bne L1 -; end found, get offset in y into pointer - -L2: tya - clc - adc ptr2 - sta ptr2 - bcc L3 - inc ptr2+1 +; end found, apply offset to dest ptr and reset y +L2: sty ptr2 ; copy src. We've put the ones complement of the count into the counter, so ; we'll increment the counter on top of the loop -L3: ldy #0 - ldx tmp1 ; low counter byte +L3: ldy #0 + ldx tmp1 ; low counter byte -L4: inx - bne L5 - inc tmp2 - beq L6 ; jump if done -L5: lda (ptr1),y - sta (ptr2),y - beq L7 - iny - bne L4 - inc ptr1+1 - inc ptr2+1 - bne L4 +L4: inx + bne L5 + inc tmp2 + beq L6 ; jump if done +L5: lda (ptr1),y + sta (ptr2),y + beq L7 + iny + bne L4 + inc ptr1+1 + inc ptr2+1 + bne L4 ; done, set the trailing zero and return pointer to dest -L6: lda #0 - sta (ptr2),y -L7: lda ptr3 - ldx ptr3+1 - rts +L6: lda #0 + sta (ptr2),y +L7: lda ptr3 + ldx ptr3+1 + rts diff --git a/libsrc/common/strspn.s b/libsrc/common/strspn.s index f8b8fff2a..3316f0dab 100644 --- a/libsrc/common/strspn.s +++ b/libsrc/common/strspn.s @@ -1,56 +1,54 @@ ; ; Ullrich von Bassewitz, 11.06.1998 +; Christian Krueger: 08-Aug-2013, optimization ; ; size_t strspn (const char* s1, const char* s2); ; .export _strspn - .import popax - .importzp ptr1, ptr2, tmp1, tmp2, tmp3 + .import popax, _strlen + .importzp ptr1, ptr2, tmp1, tmp2 _strspn: - sta ptr2 ; Save s2 - stx ptr2+1 - jsr popax ; get s1 - sta ptr1 - stx ptr1+1 - ldx #0 ; low counter byte - stx tmp1 ; high counter byte - ldy #$00 + jsr _strlen ; get length in a/x and transfer s2 to ptr1 + ; Note: It does not make sense to + ; have more than 255 test chars, so + ; we don't support a high byte here! (ptr1+1 is + ; also unchanged in strlen then (important!)) + ; -> the original implementation also + ; ignored this case -L1: lda (ptr1),y ; get next char from s1 - beq L6 ; jump if done - sta tmp2 ; save char + sta tmp1 ; tmp1 = strlen of test chars + jsr popax ; get and save s1 + sta ptr2 ; to ptr2 + stx ptr2+1 + ldx #0 ; low counter byte + stx tmp2 ; high counter byte + +loadChar: + ldy #0 + lda (ptr2),y ; get next char from s1 + beq leave ; handly byte of s1 +advance: + inc ptr2 ; advance string position to test + bne check + inc ptr2+1 + dey ; correct next iny (faster/shorter than bne...) + +checkNext: iny - bne L2 - inc ptr1+1 -L2: sty tmp3 ; save index into s1 +check: cpy tmp1 ; compare with length of test character string + beq leave + cmp (ptr1),y ; found matching char? + bne checkNext - ldy #0 ; get index into s2 -L3: lda (ptr2),y ; - beq L6 ; jump if done - cmp tmp2 - beq L4 - iny - bne L3 - -; The character was found in s2. Increment the counter and start over - -L4: ldy tmp3 ; reload index +foundTestChar: inx - bne L1 - inc tmp1 - bne L1 + bne loadChar + inc tmp2 + bne loadChar ; like bra... -; The character was not found, or we reached the end of s1. Return count of -; characters - -L6: txa ; get low counter byte - ldx tmp1 ; get high counter byte +leave: txa ; restore position of finding + ldx tmp2 ; and return rts - - - - - - + \ No newline at end of file diff --git a/libsrc/runtime/axlong.s b/libsrc/runtime/axlong.s index 6d97b5025..02d0a825c 100644 --- a/libsrc/runtime/axlong.s +++ b/libsrc/runtime/axlong.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 25.10.2000 +; Christian Krueger, 02-Mar-2017, some bytes saved ; ; CC65 runtime: Convert int in ax into a long ; @@ -9,18 +10,13 @@ ; Convert AX from int to long in EAX +axlong: ldy #$ff + cpx #$80 ; Positive? + bcs store ; No, apply $FF + axulong: ldy #0 - sty sreg +store: sty sreg sty sreg+1 rts -axlong: cpx #$80 ; Positive? - bcc axulong ; Yes, handle like unsigned type - ldy #$ff - sty sreg - sty sreg+1 - rts - - - diff --git a/test/val/atoi-test.c b/test/val/lib_common_atoi.c similarity index 100% rename from test/val/atoi-test.c rename to test/val/lib_common_atoi.c diff --git a/test/val/lib_common_memmove.c b/test/val/lib_common_memmove.c new file mode 100644 index 000000000..dd5801569 --- /dev/null +++ b/test/val/lib_common_memmove.c @@ -0,0 +1,61 @@ +#include +#include "unittest.h" + +#define BufferSize 384 // test correct page passing (>256, multiple of 128 here) + +static char Buffer[BufferSize+3]; // +1 to move up (and down) + + + +TEST +{ + unsigned i, v; + char* p; + + for (i=0; i < BufferSize; ++i) + Buffer[i+1] = (i%128); + + Buffer[0] = 255; // to check if start position is untouched + Buffer[BufferSize+2] = 255; // to check if end position is untouched + + // copy upwards + p = memmove(Buffer+2, Buffer+1, BufferSize); + + // check buffer consistency before target + ASSERT_AreEqual(255, (unsigned)Buffer[0], "%u", "Unexpected value before range!"); + + // check buffer consistency at starting point + ASSERT_AreEqual(0, (unsigned)Buffer[1], "%u", "Unexpected value at range start!"); + + // check buffer consistency after range + ASSERT_AreEqual(255, (unsigned)Buffer[BufferSize+2], "%u", "Unexpected value after range!"); + + // check buffer values + for (i=0; i < BufferSize; ++i) + { + ASSERT_AreEqual(i%128, (unsigned)Buffer[i+2], "%u", "Unexpected value in buffer at position %u!" COMMA i+2); + } + + v = Buffer[BufferSize+1]; // rember value of first untouched end-byte + + // copy downwards + p = memmove(Buffer+1, Buffer+2, BufferSize); + + // check buffer consistency before target + ASSERT_AreEqual(255, (unsigned)Buffer[0], "%u", "Unexpected value before range!"); + + // check buffer consistency at end point + ASSERT_AreEqual(v, (unsigned)Buffer[BufferSize+1], "%u", "Unexpected value at range end!"); + + // check buffer consistency after range + ASSERT_AreEqual(255, (unsigned)Buffer[BufferSize+2], "%u", "Unexpected value after range!"); + + // check buffer values + for (i=0; i < BufferSize; ++i) + { + ASSERT_AreEqual(i%128, (unsigned)Buffer[i+1], "%u", "Unexpected value in buffer at position %u!" COMMA i+1); + } +} +ENDTEST + + diff --git a/testcode/lib/strcat-test.c b/test/val/lib_common_strcat.c similarity index 99% rename from testcode/lib/strcat-test.c rename to test/val/lib_common_strcat.c index 58119e27a..1872053a4 100644 --- a/testcode/lib/strcat-test.c +++ b/test/val/lib_common_strcat.c @@ -52,5 +52,3 @@ TEST } } ENDTEST - - diff --git a/testcode/lib/strchr-test.c b/test/val/lib_common_strchr.c similarity index 50% rename from testcode/lib/strchr-test.c rename to test/val/lib_common_strchr.c index 7aba1de1e..a48d287e5 100644 --- a/testcode/lib/strchr-test.c +++ b/test/val/lib_common_strchr.c @@ -1,7 +1,5 @@ -#include -#include #include - +#include "unittest.h" /* Test string. Must NOT have duplicate characters! */ @@ -11,49 +9,34 @@ static char Found[256]; -int main (void) +TEST { unsigned Len; unsigned I; char* P; - /* Print a header */ - printf ("strchr(): "); - /* Get the length of the string */ Len = strlen (S); /* Search for all characters in the string, including the terminator */ - for (I = 0; I < Len+1; ++I) { - + for (I = 0; I < Len+1; ++I) + { /* Search for this char */ P = strchr (S, S[I]); /* Check if we found it */ - if (P == 0 || (P - S) != I) { - printf ("Failed for code 0x%02X, offset %u!\n", S[I], I); - printf ("P = %04X offset = %04X\n", P, P-S); - exit (EXIT_FAILURE); - } - + ASSERT_IsFalse(P == 0 || (P - S) != I, "For code 0x%02X, offset %u!\nP = %04X offset = %04X\n" COMMA S[I] COMMA I COMMA P COMMA P-S); /* Mark the char as checked */ Found[S[I]] = 1; } /* Search for all other characters and make sure they aren't found */ - for (I = 0; I < 256; ++I) { - if (Found[I] == 0) { - if (strchr (S, (char)I) != 0) { - printf ("Failed for code 0x%02X\n", I); - exit (EXIT_FAILURE); - } + for (I = 0; I < 256; ++I) + { + if (Found[I] == 0) + { + ASSERT_IsFalse(strchr (S, (char)I), "Failed for code 0x%02X\n" COMMA I); } } - - /* Test passed */ - printf ("Passed\n"); - return EXIT_SUCCESS; } - - - +ENDTEST diff --git a/test/val/lib_common_strcspn.c b/test/val/lib_common_strcspn.c new file mode 100644 index 000000000..10935a78e --- /dev/null +++ b/test/val/lib_common_strcspn.c @@ -0,0 +1,26 @@ +#include +#include "unittest.h" + +#define EstimatedStringSize 384 // test correct page passing (>256) + +static char EstimatedString[EstimatedStringSize+1]; // +1 room for terminating null +static char* EmptyTestChars=""; // strlen equivalent... +static char* TestChars="1234567890"; // we like to find numbers + +TEST +{ + unsigned i; + + for (i=0; i < EstimatedStringSize; ++i) + EstimatedString[i] = (i%26)+'A'; // put ABCD... into the string to be estimated + + ASSERT_AreEqual(strlen(EstimatedString), strcspn(EstimatedString, TestChars), "%u", "Unxpected position returned for non-participant case!"); + + EstimatedString[EstimatedStringSize/2] = TestChars[strlen(TestChars-1)]; + ASSERT_AreEqual(EstimatedStringSize/2, strcspn(EstimatedString, TestChars), "%u", "Unxpected position returned for participant case!"); + + ASSERT_AreEqual(strlen(EstimatedString), strcspn(EstimatedString, EmptyTestChars), "%u", "Unxpected position returned for empty test case!"); +} +ENDTEST + + diff --git a/test/val/lib_common_strncat.c b/test/val/lib_common_strncat.c new file mode 100644 index 000000000..dd6df9147 --- /dev/null +++ b/test/val/lib_common_strncat.c @@ -0,0 +1,54 @@ +#include +#include "unittest.h" + +#define SourceStringSize 384 // test correct page passing (>256, multiple of 128 here) + +static char SourceString[SourceStringSize+1]; // +1 room for terminating null +static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer + + +TEST +{ + unsigned i; + char* p; + + for (i=0; i < SourceStringSize; ++i) + SourceString[i] = (i%128)+1; + + SourceString[i] = 0; + + ASSERT_AreEqual(SourceStringSize, strlen(SourceString), "%u", "Source string initialization or 'strlen()' problem!"); + + /* Ensure empty destination string */ + DestinationString[0] = 0; + + ASSERT_AreEqual(0, strlen(DestinationString), "%u", "Destination string initialization or 'strlen()' problem!"); + + /* Test "unlimted" concatenation to empty buffer */ + + strncat(DestinationString, SourceString, 1024); + + ASSERT_AreEqual(SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to empty buffer!"); + + /* Test limited concatenation to non empty buffer */ + + p = strncat(DestinationString, SourceString, 128); + + ASSERT_AreEqual(SourceStringSize+128, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to non-empty buffer!"); + + /* Test return value */ + + ASSERT_IsTrue(p == DestinationString, "Invalid return value!"); + + /* Test contents */ + + for(i=0; i < strlen(DestinationString); ++i) + { + unsigned current = DestinationString[i]; + unsigned expected = (i%128)+1; + ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA i); + } +} +ENDTEST + + diff --git a/test/val/strtol-test.c b/test/val/lib_common_strol.c similarity index 100% rename from test/val/strtol-test.c rename to test/val/lib_common_strol.c diff --git a/testcode/lib/strrchr-test.c b/test/val/lib_common_strrchr.c similarity index 100% rename from testcode/lib/strrchr-test.c rename to test/val/lib_common_strrchr.c diff --git a/test/val/lib_common_strspn.c b/test/val/lib_common_strspn.c new file mode 100644 index 000000000..96a006469 --- /dev/null +++ b/test/val/lib_common_strspn.c @@ -0,0 +1,24 @@ +#include +#include "unittest.h" + +#define EstimatedStringSize 384 // test correct page passing (>256) + +static char EstimatedString[EstimatedStringSize+1]; // +1 room for terminating null +static char* EmptyTestChars=""; // empty test case... +static char* TestChars="1234567890"; // we like to find numbers + +TEST +{ + unsigned i; + + for (i=0; i < EstimatedStringSize; ++i) + EstimatedString[i] = (i%10)+'0'; // put 0123... into the string to be estimated + + ASSERT_AreEqual(strlen(EstimatedString), strspn(EstimatedString, TestChars), "%u", "Unxpected position returned for all participant case!"); + + EstimatedString[EstimatedStringSize/2] = 'X'; + ASSERT_AreEqual(EstimatedStringSize/2, strspn(EstimatedString, TestChars), "%u", "Unxpected position returned for breaking case!"); + + ASSERT_AreEqual(0, strspn(EstimatedString, EmptyTestChars), "%u", "Unxpected position returned for empty test case!"); +} +ENDTEST diff --git a/test/val/strtoul-test.c b/test/val/lib_common_strtoul.c similarity index 100% rename from test/val/strtoul-test.c rename to test/val/lib_common_strtoul.c diff --git a/testcode/lib/unittest.h b/test/val/unittest.h similarity index 100% rename from testcode/lib/unittest.h rename to test/val/unittest.h From 8d1b80e6fd7c4f3feef1fe7f56a321966bf59cd8 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 Date: Sun, 5 Mar 2017 11:38:55 +0100 Subject: [PATCH 015/199] Fixed CPU-flag usage which fails on build server?! --- libsrc/common/strcat.s | 1 + libsrc/common/strchr.s | 1 + libsrc/common/strncat.s | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libsrc/common/strcat.s b/libsrc/common/strcat.s index 74fef0759..7dce2f78a 100644 --- a/libsrc/common/strcat.s +++ b/libsrc/common/strcat.s @@ -8,6 +8,7 @@ .export _strcat .import popax .importzp ptr1, ptr2, tmp3 + .macpack cpu _strcat: sta ptr1 ; Save src diff --git a/libsrc/common/strchr.s b/libsrc/common/strchr.s index 48bb8822b..15c743776 100644 --- a/libsrc/common/strchr.s +++ b/libsrc/common/strchr.s @@ -8,6 +8,7 @@ .export _strchr .import popax .importzp ptr1, tmp1 + .macpack cpu _strchr: sta tmp1 ; Save c diff --git a/libsrc/common/strncat.s b/libsrc/common/strncat.s index 42717853f..e0fa39cc0 100644 --- a/libsrc/common/strncat.s +++ b/libsrc/common/strncat.s @@ -8,7 +8,8 @@ .export _strncat .import popax .importzp ptr1, ptr2, ptr3, tmp1, tmp2 - + .macpack cpu + _strncat: eor #$FF ; one's complement to count upwards sta tmp1 From 371e8efb7966268dbb86668f15813a36dd26d32e Mon Sep 17 00:00:00 2001 From: IrgendwerA8 Date: Tue, 7 Mar 2017 19:16:31 +0100 Subject: [PATCH 016/199] temporarily disable optimizations altogether until a fine grain control is implemented on Makefile level only disabling the compiler option -Os --- test/val/lib_common_memmove.c | 4 ++++ test/val/lib_common_strcat.c | 4 ++++ test/val/lib_common_strcspn.c | 4 ++++ test/val/lib_common_strncat.c | 4 ++++ test/val/lib_common_strspn.c | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/test/val/lib_common_memmove.c b/test/val/lib_common_memmove.c index dd5801569..6c04e1951 100644 --- a/test/val/lib_common_memmove.c +++ b/test/val/lib_common_memmove.c @@ -1,3 +1,7 @@ +// temporarily disable optimizations altogether until a fine grain control +// is implemented on Makefile level only disabling the compiler option -Os +#pragma optimize (off) + #include #include "unittest.h" diff --git a/test/val/lib_common_strcat.c b/test/val/lib_common_strcat.c index 1872053a4..6389d5651 100644 --- a/test/val/lib_common_strcat.c +++ b/test/val/lib_common_strcat.c @@ -1,3 +1,7 @@ +// temporarily disable optimizations altogether until a fine grain control +// is implemented on Makefile level only disabling the compiler option -Os +#pragma optimize (off) + #include #include "unittest.h" diff --git a/test/val/lib_common_strcspn.c b/test/val/lib_common_strcspn.c index 10935a78e..06838c435 100644 --- a/test/val/lib_common_strcspn.c +++ b/test/val/lib_common_strcspn.c @@ -1,3 +1,7 @@ +// temporarily disable optimizations altogether until a fine grain control +// is implemented on Makefile level only disabling the compiler option -Os +#pragma optimize (off) + #include #include "unittest.h" diff --git a/test/val/lib_common_strncat.c b/test/val/lib_common_strncat.c index dd6df9147..84d904fa0 100644 --- a/test/val/lib_common_strncat.c +++ b/test/val/lib_common_strncat.c @@ -1,3 +1,7 @@ +// temporarily disable optimizations altogether until a fine grain control +// is implemented on Makefile level only disabling the compiler option -Os +#pragma optimize (off) + #include #include "unittest.h" diff --git a/test/val/lib_common_strspn.c b/test/val/lib_common_strspn.c index 96a006469..693a1136a 100644 --- a/test/val/lib_common_strspn.c +++ b/test/val/lib_common_strspn.c @@ -1,3 +1,7 @@ +// temporarily disable optimizations altogether until a fine grain control +// is implemented on Makefile level only disabling the compiler option -Os +#pragma optimize (off) + #include #include "unittest.h" From 97e3472c8701c2b7b89e8d4d98f693a25277c187 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Wed, 8 Mar 2017 13:16:40 +0100 Subject: [PATCH 017/199] creativision.inc: add symbolic names for joystick direction values --- asminc/creativision.inc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/asminc/creativision.inc b/asminc/creativision.inc index 59b26101b..83a63ba07 100644 --- a/asminc/creativision.inc +++ b/asminc/creativision.inc @@ -36,6 +36,24 @@ ZP_JOY1_DIR = $13 ZP_JOY0_BUTTONS = $16 ZP_JOY1_BUTTONS = $17 +;** Joystick direction values (ZP_JOY0_DIR/ZP_JOY1_DIR) +JOY_N = $49 +JOY_NNE = $48 +JOY_NE = $47 +JOY_ENE = $46 +JOY_E = $45 +JOY_ESE = $44 +JOY_SE = $43 +JOY_SSE = $42 +JOY_S = $41 +JOY_SSW = $40 +JOY_SW = $4F +JOY_WSW = $4E +JOY_W = $4D +JOY_WNW = $4C +JOY_NW = $4B +JOY_NNW = $4A + ;** BIOS BIOS_IRQ1_ADDR = $FF3F BIOS_IRQ2_ADDR = $FF52 From 64c4cef90140e97e018b82ddb37760af79df5a17 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Wed, 8 Mar 2017 13:19:53 +0100 Subject: [PATCH 018/199] Implement diagonal direction handling in creativision joystick driver. --- libsrc/creativision/joy/creativision-stdjoy.s | 274 +++++++++++------- 1 file changed, 166 insertions(+), 108 deletions(-) diff --git a/libsrc/creativision/joy/creativision-stdjoy.s b/libsrc/creativision/joy/creativision-stdjoy.s index 37b927d08..3f167464a 100644 --- a/libsrc/creativision/joy/creativision-stdjoy.s +++ b/libsrc/creativision/joy/creativision-stdjoy.s @@ -1,60 +1,69 @@ ; ; Standard joystick driver for the Creativision. ; -; Christian Groessler, 2017-02-06 +; Christian Groessler, 2017-03-08 ; - .include "zeropage.inc" + .include "zeropage.inc" - .include "joy-kernel.inc" - .include "joy-error.inc" - .include "creativision.inc" + .include "joy-kernel.inc" + .include "joy-error.inc" + .include "creativision.inc" - .macpack module + .macpack module ; ------------------------------------------------------------------------ ; Header. Includes jump table - module_header _creativisionstd_joy + module_header _creativisionstd_joy ; Driver signature - .byte $6A, $6F, $79 ; "joy" - .byte JOY_API_VERSION ; Driver API version number + .byte $6A, $6F, $79 ; "joy" + .byte JOY_API_VERSION ; Driver API version number ; Library reference - .addr $0000 + .addr $0000 -; Button state masks (8 values) +; Symbolic names for joystick masks (similar names like the defines in joystick.h, but not related to them) - .byte $10 ; JOY_UP - .byte $04 ; JOY_DOWN - .byte $20 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $01 ; JOY_FIRE (button #1) - .byte $02 ; JOY_FIRE2 (button #2) - .byte $00 ; Future expansion - .byte $00 ; Future expansion +JOY_UP = $10 +JOY_DOWN = $04 +JOY_LEFT = $20 +JOY_RIGHT = $08 +JOY_FIRE = $01 +JOY_FIRE2 = $02 + +; Joystick state masks (8 values) + + .byte JOY_UP + .byte JOY_DOWN + .byte JOY_LEFT + .byte JOY_RIGHT + .byte JOY_FIRE + .byte JOY_FIRE2 + .byte $00 ; Future expansion + .byte $00 ; Future expansion ; Jump table. - .addr INSTALL - .addr UNINSTALL - .addr COUNT - .addr READJOY - .addr 0 ; IRQ entry not used + .addr INSTALL + .addr UNINSTALL + .addr COUNT + .addr READJOY + .addr 0 ; IRQ entry not used ; ------------------------------------------------------------------------ ; Constants -JOY_COUNT = 2 ; Number of joysticks we support +JOY_COUNT = 2 ; Number of joysticks we support ; ------------------------------------------------------------------------ ; Code - .code + .code ; ------------------------------------------------------------------------ ; INSTALL routine. Is called after the driver is loaded into memory. If @@ -63,131 +72,180 @@ JOY_COUNT = 2 ; Number of joysticks we support ; Must return an JOY_ERR_xx code in a/x. ; -INSTALL: - lda #JOY_ERR_OK - ldx #0 -; rts ; Fall through +INSTALL: lda #JOY_ERR_OK + ldx #0 +; rts ; Fall through ; ------------------------------------------------------------------------ ; UNINSTALL routine. Is called before the driver is removed from memory. ; Can do cleanup or whatever. Must not return anything. ; -UNINSTALL: - rts +UNINSTALL: rts ; ------------------------------------------------------------------------ ; COUNT: Return the total number of available joysticks in a/x. ; -COUNT: - lda #JOY_COUNT - rts +COUNT: lda #JOY_COUNT + rts ; ------------------------------------------------------------------------ ; READ: Read a particular joystick passed in A. ; -READJOY: - and #1 ; fix joystick number - bne READJOY_1 ; read right joystick +READJOY: and #1 ; fix joystick number + bne READJOY_1 ; read right joystick ; Read left joystick - ldx ZP_JOY0_DIR - lda ZP_JOY0_BUTTONS - jmp convert ; convert joystick state to sane cc65 values + ldx ZP_JOY0_DIR + lda ZP_JOY0_BUTTONS + jmp convert ; convert joystick state to cc65 values ; Read right joystick -READJOY_1: - - ldx ZP_JOY1_DIR - lda ZP_JOY1_BUTTONS - lsr a - lsr a - ;jmp convert ; convert joystick state to sane cc65 values - ; fall thru... +READJOY_1: ldx ZP_JOY1_DIR + lda ZP_JOY1_BUTTONS + lsr a + lsr a + ;jmp convert ; convert joystick state to cc65 values + ; fall thru... ; ------------------------------------------------------------------------ ; convert: make runtime lib compatible values -; A - buttons -; X - direction +; inputs: +; A - buttons +; X - direction ; convert: - ldy #0 - sty retval ; initialize return value ; ------ ; buttons: - ; Port values are for the left hand joystick (right hand joystick - ; values were shifted to the right to be identical). - ; Why are there two bits indicating a pressed trigger? - ; According to the "Second book of programs for the Dick Smith Wizard" - ; (pg. 88ff), the left hand fire button gives the value of - ; %00010001 and the right hand button gives %00100010 - ; Why two bits? Am I missing something? Can there be cases that just - ; one of those bits is set? - ; We just test if any of those two bits is not zero... +; Port values are for the left hand joystick (right hand joystick +; values were shifted to the right to be identical). +; Why are there two bits indicating a pressed trigger? +; According to the "Second book of programs for the Dick Smith Wizard" +; (pg. 88ff), the left hand fire button gives the value of +; %00010001 and the right hand button gives %00100010 +; Why two bits? Can there be cases that just one of those bits is set? +; Until these questions have been answered, we only use the lower two +; bits and ignore the upper ones... - tay - and #%00010001 - beq cnv_1 - - inc retval ; left button pressed - -cnv_1: tya - and #%00100010 - beq cnv_2 - - lda #$02 - ora retval - sta retval ; right button pressed + and #%00000011 ; button status came in in A, strip high bits + sta retval ; initialize 'retval' with button status ; ------ ; direction: -cnv_2: txa - ; tested with https://sourceforge.net/projects/creativisionemulator - ; $49 - %01001001 - up - ; $41 - %01000001 - down - ; $4D - %01001101 - left - ; $45 - %01000101 - right - ; - ; are these correct? "Second book of programs for the Dick Smith Wizard" pg. 85 says something different - ; ignored for now... - ; $85 - %10000101 - up + right - ; $8D - %10001101 - down + left - ; $89 - %10001001 - up + left - ; $85 - %10000101 - down + right (emulator bug?) +; CV has a 16-direction joystick +; +; port values: (compass points) +; N - $49 - %01001001 +; NNE - $48 - %01001000 +; NE - $47 - %01000111 +; ENE - $46 - %01000110 +; E - $45 - %01000101 +; ESE - $44 - %01000100 +; SE - $43 - %01000011 +; SSE - $42 - %01000010 +; S - $41 - %01000001 +; SSW - $40 - %01000000 +; SW - $4F - %01001111 +; WSW - $4E - %01001110 +; W - $4D - %01001101 +; WNW - $4C - %01001100 +; NW - $4B - %01001011 +; NNW - $4A - %01001010 +; center - $00 - %00000000 +; +; mapping to cc65 definitions (4-direction joystick with 8 possible directions thru combinations) +; N, E, S, W -> JOY_UP, JOY_RIGHT, JOY_DOWN, JOY_LEFT +; NE, SE, SW, NW -> (JOY_UP | JOY_RIGHT), (JOY_DOWN | JOY_RIGHT), (JOY_DOWN | JOY_LEFT), (JOY_UP | JOY_LEFT) +; NNE, ENE, ESE, SSE, SSW, WSW, WNW, NNW: +; toggle between straight and diagonal direction for every call, e.g. +; NNE: +; call to READJOY: return JOY_UP | JOY_RIGHT +; call to READJOY: return JOY_UP +; call to READJOY: return JOY_UP | JOY_RIGHT +; call to READJOY: return JOY_UP +; call to READJOY: return JOY_UP | JOY_RIGHT +; etc... - bit testbit ; bit #0 set? - beq done ; no, no direction + txa ; move direction status into A + beq done ; center position (no bits are set), nothing to do - and #%00001100 ; mask out other bits - lsr a - lsr a - tax - lda #%00000100 ; init bitmask -loop: dex - bmi done2 - asl a - bne loop + and #$0F ; get rid of the "$40" bit + bit bit0 ; is it a "three letter" direction (NNE, ENE, etc.)? + beq special ; yes (bit #0 is zero) -done2: ora retval - rts + lsr a ; create index into table + tax + lda dirtable,x +done: ora retval ; include "button" bits + ldx #0 + rts -done: lda retval - rts +; NNE, ENE, ESE, SSE, SSW, WSW, WNW, NNW + +special: lsr a + tax + + lda toggler ; toggle the toggler + eor #$01 + sta toggler + bne spec_1 ; toggler is 1, use spectable_1 entry + + lda spectable_0,x ; toggler is 0, use spectable_0 entry + bne done ; jump always + +spec_1: lda spectable_1,x + bne done ; jump always ; ------------------------------------------------------------------------ ; - .data -testbit:.byte $01 + .rodata + + ; a mapping table of "port values" to "cc65 values" + ; port value had been shifted one bit to the right (range 0..7) +dirtable: .byte JOY_DOWN ; S + .byte JOY_DOWN | JOY_RIGHT ; SE + .byte JOY_RIGHT ; E + .byte JOY_UP | JOY_RIGHT ; NE + .byte JOY_UP ; N + .byte JOY_UP | JOY_LEFT ; NW + .byte JOY_LEFT ; W + .byte JOY_DOWN | JOY_LEFT ; SW + + ; two "special" mapping tables for three-letter directions (NNE, etc.) +spectable_0: .byte JOY_DOWN ; SSW + .byte JOY_DOWN ; SSE + .byte JOY_RIGHT ; ESE + .byte JOY_RIGHT ; ENE + .byte JOY_RIGHT ; NNE + .byte JOY_UP ; NNW + .byte JOY_LEFT ; WNW + .byte JOY_LEFT ; WSW + +spectable_1: .byte JOY_DOWN | JOY_LEFT ; SSW + .byte JOY_DOWN | JOY_RIGHT ; SSE + .byte JOY_DOWN | JOY_RIGHT ; ESE + .byte JOY_UP | JOY_RIGHT ; ENE + .byte JOY_UP | JOY_RIGHT ; NNE + .byte JOY_UP | JOY_LEFT ; NNW + .byte JOY_UP | JOY_LEFT ; WNW + .byte JOY_DOWN | JOY_LEFT ; WSW ; ------------------------------------------------------------------------ ; - .bss -retval: .res 0 +bit0: .byte $01 + +; ------------------------------------------------------------------------ +; + .bss +toggler: .res 1 +retval: .res 1 + + .end From b332064cb5f2cd42e1c495d8e1cefcfd735d088e Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Thu, 9 Mar 2017 14:39:08 +0100 Subject: [PATCH 019/199] Just some minor style fix. --- libsrc/Makefile | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index 54b54860c..cb3517c7e 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -15,24 +15,24 @@ CBMS = c128 \ GEOS = geos-apple \ geos-cbm -TARGETS = apple2 \ - apple2enh \ - atari \ - atarixl \ - atari2600 \ - atari5200 \ - atmos \ +TARGETS = apple2 \ + apple2enh \ + atari \ + atarixl \ + atari2600 \ + atari5200 \ + atmos \ creativision \ - $(CBMS) \ - $(GEOS) \ - gamate \ - lynx \ - nes \ - osic1p \ - pce \ - sim6502 \ - sim65c02 \ - supervision\ + $(CBMS) \ + $(GEOS) \ + gamate \ + lynx \ + nes \ + osic1p \ + pce \ + sim6502 \ + sim65c02 \ + supervision \ telestrat DRVTYPES = emd \ @@ -41,13 +41,13 @@ DRVTYPES = emd \ ser \ tgi -OUTPUTDIRS := lib \ - asminc \ - cfg \ - include \ - $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)))\ - $(subst ../,,$(wildcard ../target/*/drv/*))\ - $(subst ../,,$(wildcard ../target/*/util))\ +OUTPUTDIRS := lib \ + asminc \ + cfg \ + include \ + $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*))) \ + $(subst ../,,$(wildcard ../target/*/drv/*)) \ + $(subst ../,,$(wildcard ../target/*/util)) .PHONY: all mostlyclean clean install zip lib $(TARGETS) From d2c89d2ba9d0030c538257a74a5d732cbdca6a0b Mon Sep 17 00:00:00 2001 From: Piotr Fusik Date: Thu, 9 Mar 2017 19:14:31 +0100 Subject: [PATCH 020/199] "static int n; int n;" is an error. Fixes test/err/static-4.c regression. --- src/cc65/symtab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index fdf459873..3275332c5 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -821,7 +821,7 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags) } /* An extern declaration must not change the current linkage. */ - if (IsFunc || (Flags & (SC_EXTERN | SC_DEF)) == SC_EXTERN) { + if (IsFunc || (Flags & (SC_EXTERN | SC_STORAGE)) == SC_EXTERN) { Flags &= ~SC_EXTERN; } From ce0cf853867e7f1c51075499c264e7d48e845190 Mon Sep 17 00:00:00 2001 From: Piotr Fusik Date: Thu, 9 Mar 2017 20:40:20 +0100 Subject: [PATCH 021/199] Add regression test for #204. --- test/val/static-fwd-decl.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/val/static-fwd-decl.c diff --git a/test/val/static-fwd-decl.c b/test/val/static-fwd-decl.c new file mode 100644 index 000000000..420640d97 --- /dev/null +++ b/test/val/static-fwd-decl.c @@ -0,0 +1,35 @@ +/* + !!DESCRIPTION!! static forward declarations + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Bob Andrews +*/ + +/* + see: https://github.com/cc65/cc65/issues/204 +*/ + +#pragma warn(error, on) + +typedef struct _DIRMENU +{ + const char *name; + struct _DIRMENU *dest; +} DIRMENU; + +static DIRMENU rmenu; + +static DIRMENU lmenu = { + "left", + &rmenu +}; + +static DIRMENU rmenu = { + "right", + &lmenu +}; + +int main(void) +{ + return lmenu.dest == &rmenu && rmenu.dest == &lmenu ? 0 : 1; +} From 6c3873316b31f86b61ea11b67055ac66b2b66ebd Mon Sep 17 00:00:00 2001 From: Piotr Fusik Date: Thu, 9 Mar 2017 20:49:20 +0100 Subject: [PATCH 022/199] Add regression tests for duplicate global/static variables detected by the compiler. --- test/err/duplicate-global.c | 20 ++++++++++++++++++++ test/err/duplicate-static.c | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/err/duplicate-global.c create mode 100644 test/err/duplicate-static.c diff --git a/test/err/duplicate-global.c b/test/err/duplicate-global.c new file mode 100644 index 000000000..bd4fcc24a --- /dev/null +++ b/test/err/duplicate-global.c @@ -0,0 +1,20 @@ +/* + !!DESCRIPTION!! duplicate globals + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/191 +*/ + +#pragma warn(error, on) + +int n = 0; +int n = 0; /* should give an error */ + +int main(void) +{ + return n; +} diff --git a/test/err/duplicate-static.c b/test/err/duplicate-static.c new file mode 100644 index 000000000..394cc1e09 --- /dev/null +++ b/test/err/duplicate-static.c @@ -0,0 +1,20 @@ +/* + !!DESCRIPTION!! duplicate static variables + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/191 +*/ + +#pragma warn(error, on) + +static int n = 0; +static int n = 0; /* should give an error */ + +int main(void) +{ + return n; +} From 05d1b8072b580b1a68e09a76f21c9b8599af7028 Mon Sep 17 00:00:00 2001 From: Piotr Fusik Date: Thu, 9 Mar 2017 21:18:48 +0100 Subject: [PATCH 023/199] Add regression tests for duplicate globals with different linkage. --- test/err/duplicate-global-static.c | 18 ++++++++++++++++++ test/err/duplicate-static-global.c | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 test/err/duplicate-global-static.c create mode 100644 test/err/duplicate-static-global.c diff --git a/test/err/duplicate-global-static.c b/test/err/duplicate-global-static.c new file mode 100644 index 000000000..6aa27f5b7 --- /dev/null +++ b/test/err/duplicate-global-static.c @@ -0,0 +1,18 @@ +/* + !!DESCRIPTION!! global duplicated with static variable + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/191 +*/ + +int n = 0; +static int n = 0; /* should give an error */ + +int main(void) +{ + return n; +} diff --git a/test/err/duplicate-static-global.c b/test/err/duplicate-static-global.c new file mode 100644 index 000000000..6e5e70a37 --- /dev/null +++ b/test/err/duplicate-static-global.c @@ -0,0 +1,18 @@ +/* + !!DESCRIPTION!! static duplicated with global variable + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/191 +*/ + +static int n = 0; +int n = 0; /* should give an error */ + +int main(void) +{ + return n; +} From 8a81f9c0c842611a9d329ca8902ec3d8ba9a221f Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Fri, 10 Mar 2017 11:21:14 +0100 Subject: [PATCH 024/199] Fix line endings (CRLF -> LF) on all affected files. --- asminc/opcodes.inc | 1018 +++++++++++++++++------------------ asminc/smc.inc | 534 +++++++++--------- include/osic1p.h | 94 ++-- include/zlib.h | 344 ++++++------ libsrc/c64/emd/c64-65816.s | 752 +++++++++++++------------- libsrc/osic1p/cgetc.s | 100 ++-- libsrc/osic1p/osic1p.inc | 8 +- libsrc/osic1p/osiscreen.inc | 364 ++++++------- test/ref/divmod.c | 74 +-- test/ref/init.c | 190 +++---- test/ref/pointer2.c | 224 ++++---- test/ref/switch2.c | 514 +++++++++--------- test/ref/varargs.c | 202 +++---- testcode/lib/mul-test.c | 340 ++++++------ 14 files changed, 2379 insertions(+), 2379 deletions(-) diff --git a/asminc/opcodes.inc b/asminc/opcodes.inc index 7c52871d2..96cdefb65 100644 --- a/asminc/opcodes.inc +++ b/asminc/opcodes.inc @@ -1,509 +1,509 @@ -; opcodes.inc -; ca65 6502 - opcode definitions, mainly for self modifying code -; -; Christian Krüger, latest change: 18-Sep-2010 -; -; 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. -; - -; Opcode-Table -; ------------ -; Post fix explanation: -; imm = #$00 -; zp = $00 -; zpx = $00,X -; zpy = $00,Y -; izp = ($00) -; izx = ($00,X) -; izy = ($00),Y -; abs = $0000 -; abx = $0000,X -; aby = $0000,Y -; ind = ($0000) -; iax = ($0000,X) -; rel = $0000 (PC-relative) (supressed here) - -.macpack cpu - -OPC_BRK = $00 -OPC_ORA_izx = $01 -OPC_ORA_zp = $05 -OPC_ASL_zp = $06 -OPC_PHP = $08 -OPC_ORA_imm = $09 -OPC_ASL = $0A -OPC_ORA_abs = $0D -OPC_ASL_abs = $0E - -OPC_BPL = $10 -OPC_ORA_izy = $11 -OPC_ORA_zpx = $15 -OPC_ASL_zpx = $16 -OPC_CLC = $18 -OPC_ORA_aby = $19 -OPC_ORA_abx = $1D -OPC_ASL_abx = $1E - -OPC_JSR_abs = $20 -OPC_AND_izx = $21 -OPC_BIT_zp = $24 -OPC_AND_zp = $25 -OPC_ROL_zp = $26 -OPC_PLP = $28 -OPC_AND_imm = $29 -OPC_ROL = $2A -OPC_BIT_abs = $2C -OPC_AND_abs = $2D -OPC_ROL_abs = $2E - -OPC_BMI = $30 -OPC_AND_izy = $31 -OPC_AND_zpx = $35 -OPC_ROL_zpx = $36 -OPC_SEC = $38 -OPC_AND_aby = $39 -OPC_AND_abx = $3D -OPC_ROL_abx = $3E - - -OPC_RTI = $40 -OPC_EOR_izx = $41 -OPC_EOR_zp = $45 -OPC_LSR_zp = $46 -OPC_PHA = $48 -OPC_EOR_imm = $49 -OPC_LSR = $4A -OPC_JMP_abs = $4C -OPC_EOR_abs = $4D -OPC_LSR_abs = $4E - -OPC_BVC = $50 -OPC_EOR_izy = $51 -OPC_EOR_zpx = $55 -OPC_LSR_zpx = $56 -OPC_CLI = $58 -OPC_EOR_aby = $59 -OPC_EOR_abx = $5D -OPC_LSR_abx = $5E - -OPC_RTS = $60 -OPC_ADC_izx = $61 -OPC_ADC_zp = $65 -OPC_ROR_zp = $66 -OPC_PLA = $68 -OPC_ADC_imm = $69 -OPC_ROR = $6A -OPC_JMP_ind = $6C -OPC_ADC_abs = $6D -OPC_ROR_abs = $6E - -OPC_BVS = $70 -OPC_ADC_izy = $71 -OPC_ADC_zpx = $75 -OPC_ROR_zpx = $76 -OPC_SEI = $78 -OPC_ADC_aby = $79 -OPC_ADC_abx = $7D -OPC_ROR_abx = $7E - -OPC_STA_izx = $81 -OPC_STY_zp = $84 -OPC_STA_zp = $85 -OPC_STX_zp = $86 -OPC_DEY = $88 -OPC_TXA = $8A -OPC_STY_abs = $8C -OPC_STA_abs = $8D -OPC_STX_abs = $8E - -OPC_BCC = $90 -OPC_STA_izy = $91 -OPC_STY_zpx = $94 -OPC_STA_zpx = $95 -OPC_STX_zpy = $96 -OPC_TYA = $98 -OPC_STA_aby = $99 -OPC_TXS = $9A -OPC_STA_abx = $9D - -OPC_LDY_imm = $A0 -OPC_LDA_izx = $A1 -OPC_LDX_imm = $A2 -OPC_LDY_zp = $A4 -OPC_LDA_zp = $A5 -OPC_LDX_zp = $A6 -OPC_TAY = $A8 -OPC_LDA_imm = $A9 -OPC_TAX = $AA -OPC_LDY_abs = $AC -OPC_LDA_abs = $AD -OPC_LDX_abs = $AE - -OPC_BCS = $B0 -OPC_LDA_izy = $B1 -OPC_LDY_zpx = $B4 -OPC_LDA_zpx = $B5 -OPC_LDX_zpy = $B6 -OPC_CLV = $B8 -OPC_LDA_aby = $B9 -OPC_TSX = $BA -OPC_LDY_abx = $BC -OPC_LDA_abx = $BD -OPC_LDX_aby = $BE - -OPC_CPY_imm = $C0 -OPC_CMP_izx = $C1 -OPC_CPY_zp = $C4 -OPC_CMP_zp = $C5 -OPC_DEC_zp = $C6 -OPC_INY = $C8 -OPC_CMP_imm = $C9 -OPC_DEX = $CA -OPC_CPY_abs = $CC -OPC_CMP_abs = $CD -OPC_DEC_abs = $CE - -OPC_BNE = $D0 -OPC_CMP_izy = $D1 -OPC_CMP_zpx = $D5 -OPC_DEC_zpx = $D6 -OPC_CLD = $D8 -OPC_CMP_aby = $D9 -OPC_CMP_abx = $DD -OPC_DEC_abx = $DE - -OPC_CPX_imm = $E0 -OPC_SBC_izx = $E1 -OPC_CPX_zp = $E4 -OPC_SBC_zp = $E5 -OPC_INC_zp = $E6 -OPC_INX = $E8 -OPC_SBC_imm = $E9 -OPC_NOP = $EA -OPC_CPX_abs = $EC -OPC_SBC_abs = $ED -OPC_INC_abs = $EE - - -OPC_BEQ = $F0 -OPC_SBC_izy = $F1 -OPC_SBC_zpx = $F5 -OPC_INC_zpx = $F6 -OPC_SED = $F8 -OPC_SBC_aby = $F9 -OPC_SBC_abx = $FD -OPC_INC_abx = $FE - - -.if (.cpu .bitand ::CPU_ISET_65SC02) - -; OPC_NOP = $02 ; doublet -; OPC_NOP = $03 ; doublet -OPC_TSB_zp = $04 -; OPC_NOP = $0B ; doublet -OPC_TSB_abs = $0C - -OPC_ORA_izp = $12 -; OPC_NOP = $13 ; doublet -OPC_TRB_zp = $14 -OPC_INC = $1A -; OPC_NOP = $1B ; doublet -OPC_TRB_abs = $1C - -; OPC_NOP = $22 ; doublet -; OPC_NOP = $23 ; doublet -; OPC_NOP = $2B ; doublet - -OPC_AND_izp = $32 -; OPC_NOP = $33 ; doublet -OPC_BIT_zpx = $34 -OPC_DEC = $3A -; OPC_NOP = $3B ; doublet -OPC_BIT_abx = $3C - -; OPC_NOP = $42 ; doublet -; OPC_NOP = $43 ; doublet -; OPC_NOP = $44 ; doublet -; OPC_NOP = $4B ; doublet - -OPC_EOR_izp = $52 -; OPC_NOP = $53 ; doublet -; OPC_NOP = $54 ; doublet -; OPC_NOP = $5A ; doublet -; OPC_NOP = $5B ; doublet -OPC_EOR_abx = $5C - -; OPC_NOP = $62 ; doublet -; OPC_NOP = $63 ; doublet -OPC_STZ_zp = $64 -; OPC_NOP = $6B ; doublet - -OPC_ADC_izp = $72 -; OPC_NOP = $73 ; doublet -OPC_STZ_zpx = $74 -OPC_PLY = $7A -; OPC_NOP = $7B ; doublet -OPC_JMP_iax = $7C - -OPC_BRA = $80 -; OPC_NOP = $82 ; doublet -; OPC_NOP = $83 ; doublet -OPC_BIT_imm = $89 -; OPC_NOP = $8B ; doublet - -OPC_STA_izp = $92 -; OPC_NOP = $93 ; doublet -; OPC_NOP = $9B ; doublet -OPC_STZ_abs = $9C -OPC_STZ_abx = $9E - -; OPC_NOP = $A3 ; doublet -; OPC_NOP = $AB ; doublet - -OPC_LDA_izp = $B2 -; OPC_NOP = $B3 ; doublet -; OPC_NOP = $BB ; doublet - -; OPC_NOP = $C2 ; doublet -; OPC_NOP = $C3 ; doublet -; OPC_NOP = $CB ; doublet - -OPC_CMP_izp = $D2 -; OPC_NOP = $D3 ; doublet -; OPC_NOP = $D4 ; doublet -OPC_PHX = $DA -; OPC_NOP = $DB ; doublet -; OPC_NOP = $DC ; doublet - -; OPC_NOP = $E2 ; doublet -; OPC_NOP = $E3 ; doublet -; OPC_NOP = $EB ; doublet - -OPC_SBC_izp = $F2 -; OPC_NOP = $F3 ; doublet -; OPC_NOP = $F4 ; doublet -OPC_PLX = $FA -; OPC_NOP = $FB ; doublet -; OPC_NOP = $FC ; doublet - - -.if (.cpu .bitand ::CPU_ISET_65C02) - -; bit instructions for 65C02 - -OPC_RMB0 = $07 -OPC_RMB1 = $17 -OPC_RMB2 = $27 -OPC_RMB3 = $37 -OPC_RMB4 = $47 -OPC_RMB5 = $57 -OPC_RMB6 = $67 -OPC_RMB7 = $77 - -OPC_SMB0 = $87 -OPC_SMB1 = $97 -OPC_SMB2 = $A7 -OPC_SMB3 = $B7 -OPC_SMB4 = $C7 -OPC_SMB5 = $D7 -OPC_SMB6 = $E7 -OPC_SMB7 = $F7 - -OPC_BBR0 = $0F -OPC_BBR1 = $1F -OPC_BBR2 = $2F -OPC_BBR3 = $3F -OPC_BBR4 = $4F -OPC_BBR5 = $5F -OPC_BBR6 = $6F -OPC_BBR7 = $7F - -OPC_BBS0 = $8F -OPC_BBS1 = $9F -OPC_BBS2 = $AF -OPC_BBS3 = $BF -OPC_BBS4 = $CF -OPC_BBS5 = $DF -OPC_BBS6 = $EF -OPC_BBS7 = $FF - -.else - -; no bit instructions for 65SC02 - -; OPC_NOP = $07 ; doublet -; OPC_NOP = $17 ; doublet -; OPC_NOP = $27 ; doublet -; OPC_NOP = $37 ; doublet -; OPC_NOP = $47 ; doublet -; OPC_NOP = $57 ; doublet -; OPC_NOP = $67 ; doublet -; OPC_NOP = $77 ; doublet -; OPC_NOP = $87 ; doublet -; OPC_NOP = $97 ; doublet -; OPC_NOP = $A7 ; doublet -; OPC_NOP = $B7 ; doublet -; OPC_NOP = $C7 ; doublet -; OPC_NOP = $D7 ; doublet -; OPC_NOP = $E7 ; doublet -; OPC_NOP = $F7 ; doublet -; OPC_NOP = $0F ; doublet -; OPC_NOP = $1F ; doublet -; OPC_NOP = $2F ; doublet -; OPC_NOP = $3F ; doublet -; OPC_NOP = $4F ; doublet -; OPC_NOP = $5F ; doublet -; OPC_NOP = $6F ; doublet -; OPC_NOP = $7F ; doublet -; OPC_NOP = $8F ; doublet -; OPC_NOP = $9F ; doublet -; OPC_NOP = $AF ; doublet -; OPC_NOP = $BF ; doublet -; OPC_NOP = $CF ; doublet -; OPC_NOP = $DF ; doublet -; OPC_NOP = $EF ; doublet -; OPC_NOP = $FF ; doublet - -.endif - -.elseif (.cpu .bitand ::CPU_ISET_6502X) - -; stable, undocumented opcodes - -; OPC_KIL = $02 ; unstable -OPC_SLO_izx = $03 -OPC_NOP_zp = $04 -OPC_SLO_zp = $07 -OPC_ANC_imm = $0B -OPC_NOP_abs = $0C -OPC_SLO_abs = $0F - -; OPC_KIL = $12 ; unstable -OPC_SLO_izy = $13 -OPC_NOP_zpx = $14 -OPC_SLO_zpx = $17 -;OPC_NOP = $1A -OPC_SLO_aby = $1B -OPC_NOP_abx = $1C -OPC_SLO_abx = $1F - -; OPC_KIL = $22 ; unstable -OPC_RLA_izx = $23 -OPC_RLA_zp = $27 -OPC_ANC_imm = $2B -OPC_RLA_abs = $2F - -; OPC_KIL = $32 ; unstable -OPC_RLA_izy = $33 -OPC_NOP_zpx = $34 -OPC_RLA_zpx = $37 -; OPC_NOP = $3A ; doublet -OPC_RLA_aby = $3B -OPC_NOP_abx = $3C -OPC_RLA_abx = $3F - -; OPC_KIL = $42 ; unstable -OPC_SRE_izx = $43 -OPC_NOP_zp = $44 -OPC_SRE_zp = $47 -OPC_ALR_imm = $4B -OPC_SRE_abs = $4F - -; OPC_KIL = $52 ; unstable -OPC_SRE_izy = $53 -OPC_NOP_zpx = $54 -OPC_SRE_zpx = $57 -; OPC_NOP = $5A ; doublet -OPC_SRE_aby = $5B -OPC_NOP_abx = $5C -OPC_SRE_abx = $5F - -; OPC_KIL = $62 -OPC_RRA_izx = $63 -OPC_NOP_zp = $64 -OPC_RRA_zp = $67 -OPC_ARR_imm = $6B -OPC_RRA_abs = $6F - -; OPC_KIL = $72 -OPC_RRA_izy = $73 -OPC_NOP_zpx = $74 -OPC_RRA_zpx = $77 -; OPC_NOP = $7A ; doublet -OPC_RRA_aby = $7B -OPC_NOP_abx = $7C -OPC_RRA_abx = $7F - -OPC_NOP_imm = $80 -; OPC_NOP_imm = $82 ; doublet -OPC_SAX_izx = $83 -OPC_SAX_zp = $87 -; OPC_NOP_imm = $89 ; doublet -; OPC_XAA = $8B ; unstable -OPC_SAX_abs = $8F - -; OPC_KIL = $92 ; unstable -; OPC_AHX_izy = $93 ; unstable -OPC_SAX_zpy = $97 -; OPC_TAS_aby = $9B ; unstable -; OPC_SHY_abx = $9C ; unstable -; OPC_SHX_aby = $9E ; unstable -; OPC_AHX_aby = $9F ; unstable - -OPC_LAX_izx = $A3 -OPC_LAX_zp = $A7 -; OPC_LAX_imm = $AB ; unstable -OPC_LAX_abs = $AF - -; OPC_KIL = $B2 ; unstable -OPC_LAX_izy = $B3 -OPC_LAX_zpy = $B7 -OPC_LAS_aby = $BB -OPC_LAX_aby = $BF - -; OPC_NOP_imm = $C2 ; doublet -OPC_DCP_izx = $C3 -OPC_DCP_zp = $C7 -OPC_AXS_imm = $CB -OPC_DCP_abs = $CF - -; OPC_KIL = $D2 ; unstable -OPC_DCP_izy = $D3 -OPC_NOP_zpx = $D4 -OPC_DCP_zpx = $D7 -OPC_NOP_DA = $DA -OPC_DCP_aby = $DB -OPC_NOP_abx = $DC -OPC_DCP_abx = $DF - -; OPC_NOP_imm = $E2 ; doublet -OPC_ISC_izx = $E3 -OPC_ISC_zp = $E7 -; OPC_SBC_imm = $EB ; doublet -OPC_ISC_abs = $EF - -; OPC_KIL = $F2 ; unstable -OPC_ISC_izy = $F3 -OPC_NOP_zpx = $F4 -OPC_ISC_zpx = $F7 -OPC_NOP_FA = $FA -OPC_ISC_aby = $FB -OPC_NOP_abx = $FC -OPC_ISC_abx = $FF - -.endif +; opcodes.inc +; ca65 6502 - opcode definitions, mainly for self modifying code +; +; Christian Krüger, latest change: 18-Sep-2010 +; +; 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. +; + +; Opcode-Table +; ------------ +; Post fix explanation: +; imm = #$00 +; zp = $00 +; zpx = $00,X +; zpy = $00,Y +; izp = ($00) +; izx = ($00,X) +; izy = ($00),Y +; abs = $0000 +; abx = $0000,X +; aby = $0000,Y +; ind = ($0000) +; iax = ($0000,X) +; rel = $0000 (PC-relative) (supressed here) + +.macpack cpu + +OPC_BRK = $00 +OPC_ORA_izx = $01 +OPC_ORA_zp = $05 +OPC_ASL_zp = $06 +OPC_PHP = $08 +OPC_ORA_imm = $09 +OPC_ASL = $0A +OPC_ORA_abs = $0D +OPC_ASL_abs = $0E + +OPC_BPL = $10 +OPC_ORA_izy = $11 +OPC_ORA_zpx = $15 +OPC_ASL_zpx = $16 +OPC_CLC = $18 +OPC_ORA_aby = $19 +OPC_ORA_abx = $1D +OPC_ASL_abx = $1E + +OPC_JSR_abs = $20 +OPC_AND_izx = $21 +OPC_BIT_zp = $24 +OPC_AND_zp = $25 +OPC_ROL_zp = $26 +OPC_PLP = $28 +OPC_AND_imm = $29 +OPC_ROL = $2A +OPC_BIT_abs = $2C +OPC_AND_abs = $2D +OPC_ROL_abs = $2E + +OPC_BMI = $30 +OPC_AND_izy = $31 +OPC_AND_zpx = $35 +OPC_ROL_zpx = $36 +OPC_SEC = $38 +OPC_AND_aby = $39 +OPC_AND_abx = $3D +OPC_ROL_abx = $3E + + +OPC_RTI = $40 +OPC_EOR_izx = $41 +OPC_EOR_zp = $45 +OPC_LSR_zp = $46 +OPC_PHA = $48 +OPC_EOR_imm = $49 +OPC_LSR = $4A +OPC_JMP_abs = $4C +OPC_EOR_abs = $4D +OPC_LSR_abs = $4E + +OPC_BVC = $50 +OPC_EOR_izy = $51 +OPC_EOR_zpx = $55 +OPC_LSR_zpx = $56 +OPC_CLI = $58 +OPC_EOR_aby = $59 +OPC_EOR_abx = $5D +OPC_LSR_abx = $5E + +OPC_RTS = $60 +OPC_ADC_izx = $61 +OPC_ADC_zp = $65 +OPC_ROR_zp = $66 +OPC_PLA = $68 +OPC_ADC_imm = $69 +OPC_ROR = $6A +OPC_JMP_ind = $6C +OPC_ADC_abs = $6D +OPC_ROR_abs = $6E + +OPC_BVS = $70 +OPC_ADC_izy = $71 +OPC_ADC_zpx = $75 +OPC_ROR_zpx = $76 +OPC_SEI = $78 +OPC_ADC_aby = $79 +OPC_ADC_abx = $7D +OPC_ROR_abx = $7E + +OPC_STA_izx = $81 +OPC_STY_zp = $84 +OPC_STA_zp = $85 +OPC_STX_zp = $86 +OPC_DEY = $88 +OPC_TXA = $8A +OPC_STY_abs = $8C +OPC_STA_abs = $8D +OPC_STX_abs = $8E + +OPC_BCC = $90 +OPC_STA_izy = $91 +OPC_STY_zpx = $94 +OPC_STA_zpx = $95 +OPC_STX_zpy = $96 +OPC_TYA = $98 +OPC_STA_aby = $99 +OPC_TXS = $9A +OPC_STA_abx = $9D + +OPC_LDY_imm = $A0 +OPC_LDA_izx = $A1 +OPC_LDX_imm = $A2 +OPC_LDY_zp = $A4 +OPC_LDA_zp = $A5 +OPC_LDX_zp = $A6 +OPC_TAY = $A8 +OPC_LDA_imm = $A9 +OPC_TAX = $AA +OPC_LDY_abs = $AC +OPC_LDA_abs = $AD +OPC_LDX_abs = $AE + +OPC_BCS = $B0 +OPC_LDA_izy = $B1 +OPC_LDY_zpx = $B4 +OPC_LDA_zpx = $B5 +OPC_LDX_zpy = $B6 +OPC_CLV = $B8 +OPC_LDA_aby = $B9 +OPC_TSX = $BA +OPC_LDY_abx = $BC +OPC_LDA_abx = $BD +OPC_LDX_aby = $BE + +OPC_CPY_imm = $C0 +OPC_CMP_izx = $C1 +OPC_CPY_zp = $C4 +OPC_CMP_zp = $C5 +OPC_DEC_zp = $C6 +OPC_INY = $C8 +OPC_CMP_imm = $C9 +OPC_DEX = $CA +OPC_CPY_abs = $CC +OPC_CMP_abs = $CD +OPC_DEC_abs = $CE + +OPC_BNE = $D0 +OPC_CMP_izy = $D1 +OPC_CMP_zpx = $D5 +OPC_DEC_zpx = $D6 +OPC_CLD = $D8 +OPC_CMP_aby = $D9 +OPC_CMP_abx = $DD +OPC_DEC_abx = $DE + +OPC_CPX_imm = $E0 +OPC_SBC_izx = $E1 +OPC_CPX_zp = $E4 +OPC_SBC_zp = $E5 +OPC_INC_zp = $E6 +OPC_INX = $E8 +OPC_SBC_imm = $E9 +OPC_NOP = $EA +OPC_CPX_abs = $EC +OPC_SBC_abs = $ED +OPC_INC_abs = $EE + + +OPC_BEQ = $F0 +OPC_SBC_izy = $F1 +OPC_SBC_zpx = $F5 +OPC_INC_zpx = $F6 +OPC_SED = $F8 +OPC_SBC_aby = $F9 +OPC_SBC_abx = $FD +OPC_INC_abx = $FE + + +.if (.cpu .bitand ::CPU_ISET_65SC02) + +; OPC_NOP = $02 ; doublet +; OPC_NOP = $03 ; doublet +OPC_TSB_zp = $04 +; OPC_NOP = $0B ; doublet +OPC_TSB_abs = $0C + +OPC_ORA_izp = $12 +; OPC_NOP = $13 ; doublet +OPC_TRB_zp = $14 +OPC_INC = $1A +; OPC_NOP = $1B ; doublet +OPC_TRB_abs = $1C + +; OPC_NOP = $22 ; doublet +; OPC_NOP = $23 ; doublet +; OPC_NOP = $2B ; doublet + +OPC_AND_izp = $32 +; OPC_NOP = $33 ; doublet +OPC_BIT_zpx = $34 +OPC_DEC = $3A +; OPC_NOP = $3B ; doublet +OPC_BIT_abx = $3C + +; OPC_NOP = $42 ; doublet +; OPC_NOP = $43 ; doublet +; OPC_NOP = $44 ; doublet +; OPC_NOP = $4B ; doublet + +OPC_EOR_izp = $52 +; OPC_NOP = $53 ; doublet +; OPC_NOP = $54 ; doublet +; OPC_NOP = $5A ; doublet +; OPC_NOP = $5B ; doublet +OPC_EOR_abx = $5C + +; OPC_NOP = $62 ; doublet +; OPC_NOP = $63 ; doublet +OPC_STZ_zp = $64 +; OPC_NOP = $6B ; doublet + +OPC_ADC_izp = $72 +; OPC_NOP = $73 ; doublet +OPC_STZ_zpx = $74 +OPC_PLY = $7A +; OPC_NOP = $7B ; doublet +OPC_JMP_iax = $7C + +OPC_BRA = $80 +; OPC_NOP = $82 ; doublet +; OPC_NOP = $83 ; doublet +OPC_BIT_imm = $89 +; OPC_NOP = $8B ; doublet + +OPC_STA_izp = $92 +; OPC_NOP = $93 ; doublet +; OPC_NOP = $9B ; doublet +OPC_STZ_abs = $9C +OPC_STZ_abx = $9E + +; OPC_NOP = $A3 ; doublet +; OPC_NOP = $AB ; doublet + +OPC_LDA_izp = $B2 +; OPC_NOP = $B3 ; doublet +; OPC_NOP = $BB ; doublet + +; OPC_NOP = $C2 ; doublet +; OPC_NOP = $C3 ; doublet +; OPC_NOP = $CB ; doublet + +OPC_CMP_izp = $D2 +; OPC_NOP = $D3 ; doublet +; OPC_NOP = $D4 ; doublet +OPC_PHX = $DA +; OPC_NOP = $DB ; doublet +; OPC_NOP = $DC ; doublet + +; OPC_NOP = $E2 ; doublet +; OPC_NOP = $E3 ; doublet +; OPC_NOP = $EB ; doublet + +OPC_SBC_izp = $F2 +; OPC_NOP = $F3 ; doublet +; OPC_NOP = $F4 ; doublet +OPC_PLX = $FA +; OPC_NOP = $FB ; doublet +; OPC_NOP = $FC ; doublet + + +.if (.cpu .bitand ::CPU_ISET_65C02) + +; bit instructions for 65C02 + +OPC_RMB0 = $07 +OPC_RMB1 = $17 +OPC_RMB2 = $27 +OPC_RMB3 = $37 +OPC_RMB4 = $47 +OPC_RMB5 = $57 +OPC_RMB6 = $67 +OPC_RMB7 = $77 + +OPC_SMB0 = $87 +OPC_SMB1 = $97 +OPC_SMB2 = $A7 +OPC_SMB3 = $B7 +OPC_SMB4 = $C7 +OPC_SMB5 = $D7 +OPC_SMB6 = $E7 +OPC_SMB7 = $F7 + +OPC_BBR0 = $0F +OPC_BBR1 = $1F +OPC_BBR2 = $2F +OPC_BBR3 = $3F +OPC_BBR4 = $4F +OPC_BBR5 = $5F +OPC_BBR6 = $6F +OPC_BBR7 = $7F + +OPC_BBS0 = $8F +OPC_BBS1 = $9F +OPC_BBS2 = $AF +OPC_BBS3 = $BF +OPC_BBS4 = $CF +OPC_BBS5 = $DF +OPC_BBS6 = $EF +OPC_BBS7 = $FF + +.else + +; no bit instructions for 65SC02 + +; OPC_NOP = $07 ; doublet +; OPC_NOP = $17 ; doublet +; OPC_NOP = $27 ; doublet +; OPC_NOP = $37 ; doublet +; OPC_NOP = $47 ; doublet +; OPC_NOP = $57 ; doublet +; OPC_NOP = $67 ; doublet +; OPC_NOP = $77 ; doublet +; OPC_NOP = $87 ; doublet +; OPC_NOP = $97 ; doublet +; OPC_NOP = $A7 ; doublet +; OPC_NOP = $B7 ; doublet +; OPC_NOP = $C7 ; doublet +; OPC_NOP = $D7 ; doublet +; OPC_NOP = $E7 ; doublet +; OPC_NOP = $F7 ; doublet +; OPC_NOP = $0F ; doublet +; OPC_NOP = $1F ; doublet +; OPC_NOP = $2F ; doublet +; OPC_NOP = $3F ; doublet +; OPC_NOP = $4F ; doublet +; OPC_NOP = $5F ; doublet +; OPC_NOP = $6F ; doublet +; OPC_NOP = $7F ; doublet +; OPC_NOP = $8F ; doublet +; OPC_NOP = $9F ; doublet +; OPC_NOP = $AF ; doublet +; OPC_NOP = $BF ; doublet +; OPC_NOP = $CF ; doublet +; OPC_NOP = $DF ; doublet +; OPC_NOP = $EF ; doublet +; OPC_NOP = $FF ; doublet + +.endif + +.elseif (.cpu .bitand ::CPU_ISET_6502X) + +; stable, undocumented opcodes + +; OPC_KIL = $02 ; unstable +OPC_SLO_izx = $03 +OPC_NOP_zp = $04 +OPC_SLO_zp = $07 +OPC_ANC_imm = $0B +OPC_NOP_abs = $0C +OPC_SLO_abs = $0F + +; OPC_KIL = $12 ; unstable +OPC_SLO_izy = $13 +OPC_NOP_zpx = $14 +OPC_SLO_zpx = $17 +;OPC_NOP = $1A +OPC_SLO_aby = $1B +OPC_NOP_abx = $1C +OPC_SLO_abx = $1F + +; OPC_KIL = $22 ; unstable +OPC_RLA_izx = $23 +OPC_RLA_zp = $27 +OPC_ANC_imm = $2B +OPC_RLA_abs = $2F + +; OPC_KIL = $32 ; unstable +OPC_RLA_izy = $33 +OPC_NOP_zpx = $34 +OPC_RLA_zpx = $37 +; OPC_NOP = $3A ; doublet +OPC_RLA_aby = $3B +OPC_NOP_abx = $3C +OPC_RLA_abx = $3F + +; OPC_KIL = $42 ; unstable +OPC_SRE_izx = $43 +OPC_NOP_zp = $44 +OPC_SRE_zp = $47 +OPC_ALR_imm = $4B +OPC_SRE_abs = $4F + +; OPC_KIL = $52 ; unstable +OPC_SRE_izy = $53 +OPC_NOP_zpx = $54 +OPC_SRE_zpx = $57 +; OPC_NOP = $5A ; doublet +OPC_SRE_aby = $5B +OPC_NOP_abx = $5C +OPC_SRE_abx = $5F + +; OPC_KIL = $62 +OPC_RRA_izx = $63 +OPC_NOP_zp = $64 +OPC_RRA_zp = $67 +OPC_ARR_imm = $6B +OPC_RRA_abs = $6F + +; OPC_KIL = $72 +OPC_RRA_izy = $73 +OPC_NOP_zpx = $74 +OPC_RRA_zpx = $77 +; OPC_NOP = $7A ; doublet +OPC_RRA_aby = $7B +OPC_NOP_abx = $7C +OPC_RRA_abx = $7F + +OPC_NOP_imm = $80 +; OPC_NOP_imm = $82 ; doublet +OPC_SAX_izx = $83 +OPC_SAX_zp = $87 +; OPC_NOP_imm = $89 ; doublet +; OPC_XAA = $8B ; unstable +OPC_SAX_abs = $8F + +; OPC_KIL = $92 ; unstable +; OPC_AHX_izy = $93 ; unstable +OPC_SAX_zpy = $97 +; OPC_TAS_aby = $9B ; unstable +; OPC_SHY_abx = $9C ; unstable +; OPC_SHX_aby = $9E ; unstable +; OPC_AHX_aby = $9F ; unstable + +OPC_LAX_izx = $A3 +OPC_LAX_zp = $A7 +; OPC_LAX_imm = $AB ; unstable +OPC_LAX_abs = $AF + +; OPC_KIL = $B2 ; unstable +OPC_LAX_izy = $B3 +OPC_LAX_zpy = $B7 +OPC_LAS_aby = $BB +OPC_LAX_aby = $BF + +; OPC_NOP_imm = $C2 ; doublet +OPC_DCP_izx = $C3 +OPC_DCP_zp = $C7 +OPC_AXS_imm = $CB +OPC_DCP_abs = $CF + +; OPC_KIL = $D2 ; unstable +OPC_DCP_izy = $D3 +OPC_NOP_zpx = $D4 +OPC_DCP_zpx = $D7 +OPC_NOP_DA = $DA +OPC_DCP_aby = $DB +OPC_NOP_abx = $DC +OPC_DCP_abx = $DF + +; OPC_NOP_imm = $E2 ; doublet +OPC_ISC_izx = $E3 +OPC_ISC_zp = $E7 +; OPC_SBC_imm = $EB ; doublet +OPC_ISC_abs = $EF + +; OPC_KIL = $F2 ; unstable +OPC_ISC_izy = $F3 +OPC_NOP_zpx = $F4 +OPC_ISC_zpx = $F7 +OPC_NOP_FA = $FA +OPC_ISC_aby = $FB +OPC_NOP_abx = $FC +OPC_ISC_abx = $FF + +.endif diff --git a/asminc/smc.inc b/asminc/smc.inc index d5752a5f5..0583f79e0 100644 --- a/asminc/smc.inc +++ b/asminc/smc.inc @@ -1,267 +1,267 @@ -; smc.mac -; ca65 Macro-Pack for Self Modifying Code (SMC) -; -; (c) Christian Krüger, latest change: 17-Jul-2016 -; -; 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. -; - -.define _SMCDesignator .mid(0, .tcount(label) - 1, label) .ident(.concat(.string(.right(1, label)), "_SMC")) -.define _SMCAlias .mid(0, .tcount(alias) - 1, alias) .ident(.concat(.string(.right(1, alias)), "_SMC")) -.define SMC_AbsAdr $FADE -.define SMC_ZpAdr $00 -.define SMC_Opcode nop -.define SMC_Value $42 - -.macro SMC_OperateOnValue opcode, label - opcode _SMCDesignator+1 -.endmacro - -.macro SMC_OperateOnLowByte opcode, label - SMC_OperateOnValue opcode, label -.endmacro - -.macro SMC_OperateOnHighByte opcode, label - opcode _SMCDesignator + 2 -.endmacro - -.macro SMC_Import alias -.import _SMCAlias -.endmacro - -.macro SMC_Export alias, label -.export _SMCAlias := _SMCDesignator -.endmacro - -.macro SMC label, statement -_SMCDesignator: statement -.endmacro - -.macro SMC_TransferOpcode label, opcode, register -.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) - lda #opcode - sta _SMCDesignator -.elseif .match ({register}, x) - ldx #opcode - stx _SMCDesignator -.elseif .match ({register}, y) - ldy #opcode - sty _SMCDesignator -.else - .error "Invalid usage of macro 'SMC_TransferOpcode'" -.endif -.endmacro - -.macro SMC_LoadOpcode label, register -.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) - lda _SMCDesignator -.elseif .match ({register}, x) - ldx _SMCDesignator -.elseif .match ({register}, y) - ldy _SMCDesignator -.else - .error "Invalid usage of macro 'SMC_LoadOpcode'" -.endif -.endmacro - -.macro SMC_StoreOpcode label, register -.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) - sta _SMCDesignator -.elseif .match ({register}, x) - stx _SMCDesignator -.elseif .match ({register}, y) - sty _SMCDesignator -.else - .error "Invalid usage of macro 'SMC_StoreOpcode'" -.endif -.endmacro - -.macro SMC_ChangeBranch label, destination, register -.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) - lda #(<(destination - _SMCDesignator -2)) - sta _SMCDesignator+1 -.elseif .match ({register}, x) - ldx #(<(destination - _SMCDesignator - 2)) - stx _SMCDesignator+1 -.elseif .match ({register}, y) - ldy #(<(destination - _SMCDesignator - 2)) - sty _SMCDesignator+1 -.else - .error "Invalid usage of macro 'SMC_ChangeBranch'" -.endif -.endmacro - -.macro SMC_TransferValue label, value, register -.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) - lda value - sta _SMCDesignator+1 -.elseif .match ({register}, x) - ldx value - stx _SMCDesignator+1 -.elseif .match ({register}, y) - ldy value - sty _SMCDesignator+1 -.else - .error "Invalid usage of macro 'SMC_TransferValue'" -.endif -.endmacro - -.macro SMC_LoadValue label, register -.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) - lda _SMCDesignator+1 -.elseif .match ({register}, x) - ldx _SMCDesignator+1 -.elseif .match ({register}, y) - ldy _SMCDesignator+1 -.else - .error "Invalid usage of macro 'SMC_LoadValue'" -.endif -.endmacro - -.macro SMC_StoreValue label, register -.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) - sta _SMCDesignator+1 -.elseif .match ({register}, x) - stx _SMCDesignator+1 -.elseif .match ({register}, y) - sty _SMCDesignator+1 -.else - .error "Invalid usage of macro 'SMC_StoreValue'" -.endif -.endmacro - - -.macro SMC_TransferLowByte label, value, register -SMC_TransferValue label, value, register -.endmacro - -.macro SMC_LoadLowByte label, register -SMC_LoadValue label, register -.endmacro - -.macro SMC_StoreLowByte label, register -SMC_StoreValue label, register -.endmacro - -.macro SMC_TransferHighByte label, value, register -.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) - lda value - sta _SMCDesignator+2 -.elseif .match ({register}, x) - ldx value - stx _SMCDesignator+2 -.elseif .match ({register}, y) - ldy value - sty _SMCDesignator+2 -.else - .error "Invalid usage of macro 'SMC_TransferHighByte'" -.endif -.endmacro - -.macro SMC_LoadHighByte label, register -.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) - lda _SMCDesignator+2 -.elseif .match ({register}, x) - ldx _SMCDesignator+2 -.elseif .match ({register}, y) - ldy _SMCDesignator+2 -.else - .error "Invalid usage of macro 'SMC_LoadHighByte'" -.endif -.endmacro - -.macro SMC_StoreHighByte label, register -.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) - sta _SMCDesignator+2 -.elseif .match ({register}, x) - stx _SMCDesignator+2 -.elseif .match ({register}, y) - sty _SMCDesignator+2 -.else - .error "Invalid usage of macro 'SMC_StoreHighByte'" -.endif -.endmacro - -.macro SMC_TransferAddressSingle label, address, register -.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, ) - .if (.match (.left (1, {address}), #)) - ; immediate mode - lda #<(.right (.tcount ({address})-1, {address})) - sta _SMCDesignator+1 - lda #>(.right (.tcount ({address})-1, {address})) - sta _SMCDesignator+2 - .else - ; assume absolute or zero page - lda address - sta _SMCDesignator+1 - lda 1+(address) - sta _SMCDesignator+2 - .endif -.elseif .match ((register), x) - .if (.match (.left (1, {address}), #)) - ; immediate mode - ldx #<(.right (.tcount ({address})-1, {address})) - stx _SMCDesignator+1 - ldx #>(.right (.tcount ({address})-1, {address})) - stx _SMCDesignator+2 - .else - ; assume absolute or zero page - ldx address - stx _SMCDesignator+1 - ldx 1+(address) - stx _SMCDesignator+2 - .endif -.elseif .match ((register), y) - .if (.match (.left (1, {address}), #)) - ; immediate mode - ldy #<(.right (.tcount ({address})-1, {address})) - sty _SMCDesignator+1 - ldy #>(.right (.tcount ({address})-1, {address})) - sty _SMCDesignator+2 - .else - ; assume absolute or zero page - ldy address - sty _SMCDesignator+1 - ldy 1+(address) - sty _SMCDesignator+2 - .endif -.else - .error "Invalid usage of macro 'SMC_TransferAddressSingle'" -.endif -.endmacro - -.macro SMC_TransferAddress label, address -.if (.match (.left (1, {address}), #)) - ; immediate mode - lda #<(.right (.tcount ({address})-1, {address})) - sta _SMCDesignator+1 - ldx #>(.right (.tcount ({address})-1, {address})) - stx _SMCDesignator+2 -.else - ; assume absolute or zero page - lda {address} - sta _SMCDesignator+1 - ldx 1+{address} - stx _SMCDesignator)+2 -.endif -.endmacro - -.macro SMC_StoreAddress label - sta _SMCDesignator+1 - stx _SMCDesignator+2 -.endmacro +; smc.mac +; ca65 Macro-Pack for Self Modifying Code (SMC) +; +; (c) Christian Krüger, latest change: 17-Jul-2016 +; +; 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. +; + +.define _SMCDesignator .mid(0, .tcount(label) - 1, label) .ident(.concat(.string(.right(1, label)), "_SMC")) +.define _SMCAlias .mid(0, .tcount(alias) - 1, alias) .ident(.concat(.string(.right(1, alias)), "_SMC")) +.define SMC_AbsAdr $FADE +.define SMC_ZpAdr $00 +.define SMC_Opcode nop +.define SMC_Value $42 + +.macro SMC_OperateOnValue opcode, label + opcode _SMCDesignator+1 +.endmacro + +.macro SMC_OperateOnLowByte opcode, label + SMC_OperateOnValue opcode, label +.endmacro + +.macro SMC_OperateOnHighByte opcode, label + opcode _SMCDesignator + 2 +.endmacro + +.macro SMC_Import alias +.import _SMCAlias +.endmacro + +.macro SMC_Export alias, label +.export _SMCAlias := _SMCDesignator +.endmacro + +.macro SMC label, statement +_SMCDesignator: statement +.endmacro + +.macro SMC_TransferOpcode label, opcode, register +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda #opcode + sta _SMCDesignator +.elseif .match ({register}, x) + ldx #opcode + stx _SMCDesignator +.elseif .match ({register}, y) + ldy #opcode + sty _SMCDesignator +.else + .error "Invalid usage of macro 'SMC_TransferOpcode'" +.endif +.endmacro + +.macro SMC_LoadOpcode label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + lda _SMCDesignator +.elseif .match ({register}, x) + ldx _SMCDesignator +.elseif .match ({register}, y) + ldy _SMCDesignator +.else + .error "Invalid usage of macro 'SMC_LoadOpcode'" +.endif +.endmacro + +.macro SMC_StoreOpcode label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + sta _SMCDesignator +.elseif .match ({register}, x) + stx _SMCDesignator +.elseif .match ({register}, y) + sty _SMCDesignator +.else + .error "Invalid usage of macro 'SMC_StoreOpcode'" +.endif +.endmacro + +.macro SMC_ChangeBranch label, destination, register +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda #(<(destination - _SMCDesignator -2)) + sta _SMCDesignator+1 +.elseif .match ({register}, x) + ldx #(<(destination - _SMCDesignator - 2)) + stx _SMCDesignator+1 +.elseif .match ({register}, y) + ldy #(<(destination - _SMCDesignator - 2)) + sty _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_ChangeBranch'" +.endif +.endmacro + +.macro SMC_TransferValue label, value, register +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda value + sta _SMCDesignator+1 +.elseif .match ({register}, x) + ldx value + stx _SMCDesignator+1 +.elseif .match ({register}, y) + ldy value + sty _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_TransferValue'" +.endif +.endmacro + +.macro SMC_LoadValue label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + lda _SMCDesignator+1 +.elseif .match ({register}, x) + ldx _SMCDesignator+1 +.elseif .match ({register}, y) + ldy _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_LoadValue'" +.endif +.endmacro + +.macro SMC_StoreValue label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + sta _SMCDesignator+1 +.elseif .match ({register}, x) + stx _SMCDesignator+1 +.elseif .match ({register}, y) + sty _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_StoreValue'" +.endif +.endmacro + + +.macro SMC_TransferLowByte label, value, register +SMC_TransferValue label, value, register +.endmacro + +.macro SMC_LoadLowByte label, register +SMC_LoadValue label, register +.endmacro + +.macro SMC_StoreLowByte label, register +SMC_StoreValue label, register +.endmacro + +.macro SMC_TransferHighByte label, value, register +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda value + sta _SMCDesignator+2 +.elseif .match ({register}, x) + ldx value + stx _SMCDesignator+2 +.elseif .match ({register}, y) + ldy value + sty _SMCDesignator+2 +.else + .error "Invalid usage of macro 'SMC_TransferHighByte'" +.endif +.endmacro + +.macro SMC_LoadHighByte label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + lda _SMCDesignator+2 +.elseif .match ({register}, x) + ldx _SMCDesignator+2 +.elseif .match ({register}, y) + ldy _SMCDesignator+2 +.else + .error "Invalid usage of macro 'SMC_LoadHighByte'" +.endif +.endmacro + +.macro SMC_StoreHighByte label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + sta _SMCDesignator+2 +.elseif .match ({register}, x) + stx _SMCDesignator+2 +.elseif .match ({register}, y) + sty _SMCDesignator+2 +.else + .error "Invalid usage of macro 'SMC_StoreHighByte'" +.endif +.endmacro + +.macro SMC_TransferAddressSingle label, address, register +.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, ) + .if (.match (.left (1, {address}), #)) + ; immediate mode + lda #<(.right (.tcount ({address})-1, {address})) + sta _SMCDesignator+1 + lda #>(.right (.tcount ({address})-1, {address})) + sta _SMCDesignator+2 + .else + ; assume absolute or zero page + lda address + sta _SMCDesignator+1 + lda 1+(address) + sta _SMCDesignator+2 + .endif +.elseif .match ((register), x) + .if (.match (.left (1, {address}), #)) + ; immediate mode + ldx #<(.right (.tcount ({address})-1, {address})) + stx _SMCDesignator+1 + ldx #>(.right (.tcount ({address})-1, {address})) + stx _SMCDesignator+2 + .else + ; assume absolute or zero page + ldx address + stx _SMCDesignator+1 + ldx 1+(address) + stx _SMCDesignator+2 + .endif +.elseif .match ((register), y) + .if (.match (.left (1, {address}), #)) + ; immediate mode + ldy #<(.right (.tcount ({address})-1, {address})) + sty _SMCDesignator+1 + ldy #>(.right (.tcount ({address})-1, {address})) + sty _SMCDesignator+2 + .else + ; assume absolute or zero page + ldy address + sty _SMCDesignator+1 + ldy 1+(address) + sty _SMCDesignator+2 + .endif +.else + .error "Invalid usage of macro 'SMC_TransferAddressSingle'" +.endif +.endmacro + +.macro SMC_TransferAddress label, address +.if (.match (.left (1, {address}), #)) + ; immediate mode + lda #<(.right (.tcount ({address})-1, {address})) + sta _SMCDesignator+1 + ldx #>(.right (.tcount ({address})-1, {address})) + stx _SMCDesignator+2 +.else + ; assume absolute or zero page + lda {address} + sta _SMCDesignator+1 + ldx 1+{address} + stx _SMCDesignator)+2 +.endif +.endmacro + +.macro SMC_StoreAddress label + sta _SMCDesignator+1 + stx _SMCDesignator+2 +.endmacro diff --git a/include/osic1p.h b/include/osic1p.h index 57fe0cd24..d6ab5fee1 100644 --- a/include/osic1p.h +++ b/include/osic1p.h @@ -1,47 +1,47 @@ -/*****************************************************************************/ -/* */ -/* osic1p.h */ -/* */ -/* Challenger 1P system specific definitions */ -/* */ -/* */ -/* */ -/* (C) 2015 Stephan Muehlstrasser */ -/* */ -/* */ -/* 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 _OSIC1P_H -#define _OSIC1P_H - -/* Check for errors */ -#if !defined(__OSIC1P__) -# error "This module may only be used when compiling for the Challenger 1P!" -#endif - -/* The following #defines will cause the matching functions calls in conio.h -** to be overlaid by macros with the same names, saving the function call -** overhead. -*/ -#define _textcolor(color) COLOR_WHITE -#define _bgcolor(color) COLOR_BLACK -#define _bordercolor(color) COLOR_BLACK - -#endif +/*****************************************************************************/ +/* */ +/* osic1p.h */ +/* */ +/* Challenger 1P system specific definitions */ +/* */ +/* */ +/* */ +/* (C) 2015 Stephan Muehlstrasser */ +/* */ +/* */ +/* 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 _OSIC1P_H +#define _OSIC1P_H + +/* Check for errors */ +#if !defined(__OSIC1P__) +# error "This module may only be used when compiling for the Challenger 1P!" +#endif + +/* The following #defines will cause the matching functions calls in conio.h +** to be overlaid by macros with the same names, saving the function call +** overhead. +*/ +#define _textcolor(color) COLOR_WHITE +#define _bgcolor(color) COLOR_BLACK +#define _bordercolor(color) COLOR_BLACK + +#endif diff --git a/include/zlib.h b/include/zlib.h index 8fa6a2bd1..8ced89800 100644 --- a/include/zlib.h +++ b/include/zlib.h @@ -1,172 +1,172 @@ -/*****************************************************************************/ -/* */ -/* zlib.h */ -/* */ -/* Decompression routines for the 'deflate' format */ -/* */ -/* */ -/* */ -/* (C) 2000-2015 Piotr Fusik */ -/* */ -/* This file is based on the zlib.h from 'zlib' general purpose compression */ -/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler. */ -/* */ -/* Jean-loup Gailly Mark Adler */ -/* jloup@gzip.org madler@alumni.caltech.edu */ -/* */ -/* 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 _ZLIB_H -#define _ZLIB_H - -#define Z_OK 0 -#define Z_DATA_ERROR (-3) -/* Return codes for uncompress() */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported) */ - -#define Z_NULL 0 - - -unsigned __fastcall__ inflatemem (char* dest, const char* source); -/* - Decompresses the source buffer into the destination buffer. - Returns the size of the uncompressed data (number of bytes written starting - from dest). - - This function expects data in the DEFLATE format, described in RFC - (Request for Comments) 1951 in the file - ftp://ds.internic.net/rfc/rfc1951.txt. - - This function does not exist in the original zlib. Its implementation - using original zlib might be following: - - unsigned inflatemem (char* dest, const char* source) - { - z_stream stream; - - stream.next_in = (Bytef*) source; - stream.avail_in = 65535; - - stream.next_out = dest; - stream.avail_out = 65535; - - stream.zalloc = (alloc_func) 0; - stream.zfree = (free_func) 0; - - inflateInit2(&stream, -MAX_WBITS); - inflate(&stream, Z_FINISH); - inflateEnd(&stream); - - return stream.total_out; - } -*/ - - -int __fastcall__ uncompress (char* dest, unsigned* destLen, - const char* source, unsigned sourceLen); -/* - Original zlib description: - - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted. - - Implementation notes: - - This function expects data in the ZLIB format, described in RFC 1950 - in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is - essentially the DEFLATE format plus a very small header and Adler-32 - checksum. - - Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation. -*/ - - -unsigned long __fastcall__ adler32 (unsigned long adler, const char* buf, - unsigned len); - -/* - Original zlib description: - - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is NULL, this function returns - the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. Usage example: - - unsigned long adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); - - Implementation notes: - - This function isn't actually much faster than crc32(), but it is smaller - and does not use any lookup tables. -*/ - - -unsigned long __fastcall__ crc32 (unsigned long crc, const char* buf, - unsigned len); -/* - Original zlib description: - - Update a running crc with the bytes buf[0..len-1] and return the updated - crc. If buf is NULL, this function returns the required initial value - for the crc. Pre- and post-conditioning (one's complement) is performed - within this function so it shouldn't be done by the application. - Usage example: - - unsigned long crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); - - Implementation notes: - - This function uses statically allocated 1 KB lookup table. The table is - initialised before it is used for the first time (that is, if buffer is - NULL or length is zero, then the lookup table isn't initialised). -*/ - - -/* end of zlib.h */ -#endif - - - +/*****************************************************************************/ +/* */ +/* zlib.h */ +/* */ +/* Decompression routines for the 'deflate' format */ +/* */ +/* */ +/* */ +/* (C) 2000-2015 Piotr Fusik */ +/* */ +/* This file is based on the zlib.h from 'zlib' general purpose compression */ +/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler. */ +/* */ +/* Jean-loup Gailly Mark Adler */ +/* jloup@gzip.org madler@alumni.caltech.edu */ +/* */ +/* 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 _ZLIB_H +#define _ZLIB_H + +#define Z_OK 0 +#define Z_DATA_ERROR (-3) +/* Return codes for uncompress() */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported) */ + +#define Z_NULL 0 + + +unsigned __fastcall__ inflatemem (char* dest, const char* source); +/* + Decompresses the source buffer into the destination buffer. + Returns the size of the uncompressed data (number of bytes written starting + from dest). + + This function expects data in the DEFLATE format, described in RFC + (Request for Comments) 1951 in the file + ftp://ds.internic.net/rfc/rfc1951.txt. + + This function does not exist in the original zlib. Its implementation + using original zlib might be following: + + unsigned inflatemem (char* dest, const char* source) + { + z_stream stream; + + stream.next_in = (Bytef*) source; + stream.avail_in = 65535; + + stream.next_out = dest; + stream.avail_out = 65535; + + stream.zalloc = (alloc_func) 0; + stream.zfree = (free_func) 0; + + inflateInit2(&stream, -MAX_WBITS); + inflate(&stream, Z_FINISH); + inflateEnd(&stream); + + return stream.total_out; + } +*/ + + +int __fastcall__ uncompress (char* dest, unsigned* destLen, + const char* source, unsigned sourceLen); +/* + Original zlib description: + + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. + + Implementation notes: + + This function expects data in the ZLIB format, described in RFC 1950 + in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is + essentially the DEFLATE format plus a very small header and Adler-32 + checksum. + + Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation. +*/ + + +unsigned long __fastcall__ adler32 (unsigned long adler, const char* buf, + unsigned len); + +/* + Original zlib description: + + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + unsigned long adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); + + Implementation notes: + + This function isn't actually much faster than crc32(), but it is smaller + and does not use any lookup tables. +*/ + + +unsigned long __fastcall__ crc32 (unsigned long crc, const char* buf, + unsigned len); +/* + Original zlib description: + + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + unsigned long crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); + + Implementation notes: + + This function uses statically allocated 1 KB lookup table. The table is + initialised before it is used for the first time (that is, if buffer is + NULL or length is zero, then the lookup table isn't initialised). +*/ + + +/* end of zlib.h */ +#endif + + + diff --git a/libsrc/c64/emd/c64-65816.s b/libsrc/c64/emd/c64-65816.s index bf44a0ecc..39f323d28 100644 --- a/libsrc/c64/emd/c64-65816.s +++ b/libsrc/c64/emd/c64-65816.s @@ -1,376 +1,376 @@ -; -; Extended memory driver for 65816 based extra RAM. Driver works without -; problems when statically linked. -; -; Marco van den Heuvel, 2015-12-01 -; - - .include "zeropage.inc" - - .include "em-kernel.inc" - .include "em-error.inc" - - - .macpack generic - .macpack module - - -; ------------------------------------------------------------------------ -; Header. Includes jump table - - module_header _c64_65816_emd - -; Driver signature - - .byte $65, $6d, $64 ; "emd" - .byte EMD_API_VERSION ; EM API version number - -; Library reference - - .addr $0000 - -; Jump table - - .addr INSTALL - .addr UNINSTALL - .addr PAGECOUNT - .addr MAP - .addr USE - .addr COMMIT - .addr COPYFROM - .addr COPYTO - -; ------------------------------------------------------------------------ -; Data. - -.bss -isnotscpu: .res 1 ; SuperCPU not present -curpage: .res 1 ; Current page number -curbank: .res 1 ; Current bank number (+1) -bankcount: .res 1 ; Number of available banks (pages = banks * 256) -window: .res 256 ; Memory "window" - -.code - -; ------------------------------------------------------------------------ -; INSTALL routine. Is called after the driver is loaded into memory. If -; possible, check if the hardware is present and determine the amount of -; memory available. -; Must return an EM_ERR_xx code in a/x. -; - -INSTALL: - sei - clc - sed - lda #$99 - adc #$01 ; on 65C02, 65SC02, 65CE02, 65802 and 65816 sets the zero flag correctly - cld - bne @not_present - clc -.P816 - sep #$01 ; nop #$01 on 65C02/65SC02 and lda ($01,s),y on 65CE02 -.P02 - bcc @not_present - lda $d0bc - and #$80 - sta isnotscpu - lda $07e8 - pha ; save value incase it was used somewhere else - ldx #$ff -@fillloop: ; fill from top (bank 255) to bottom - txa - pha -.P816 - plb ; pull dbr -.P02 - stx $07e8 - dex - cpx #$ff - bne @fillloop - inx -@compareloop: ; check from bottom to top - txa - pha -.P816 - plb -.P02 - cmp $07e8 - bne @found_pages -.P816 - inc -.P02 - sta $07e8 - cmp $07e8 - bne @found_pages - inx - bne @compareloop -@found_pages: - dex - lda #$00 - pha -.P816 - plb -.P02 - pla - sta $07e8 - cli - lda isnotscpu - bne @noextradex - dex -@noextradex: - stx bankcount - lda #EM_ERR_OK - rts -@not_present: - cli - lda #EM_ERR_NO_DEVICE -; rts ; Run into UNINSTALL instead - - -; ------------------------------------------------------------------------ -; UNINSTALL routine. Is called before the driver is removed from memory. -; Can do cleanup or whatever. Must not return anything. -; - -UNINSTALL: - rts - - -; ------------------------------------------------------------------------ -; PAGECOUNT: Return the total number of available pages in a/x. -; - -PAGECOUNT: - lda #$00 ; a whole bank is either usable or not - ldx bankcount - rts - -; ------------------------------------------------------------------------ -; MAP: Map the page in a/x into memory and return a pointer to the page in -; a/x. The contents of the currently mapped page (if any) may be discarded -; by the driver. -; - -MAP: sta curpage ; Remember the new page - stx curbank ; Remember the new bank - - sta ptr2+1 ; src address low - lda #$00 - sta ptr2 ; src address high - inx - ldy isnotscpu ; check if not scpu - bne @notscpu - inx -@notscpu: - stx tmp2 ; src bank - - sta tmp1 ; dst bank - - sta ptr3+1 ; length high - lda #$ff - sta ptr3 ; length low - - lda #window - stx ptr1+1 ; dst address high - - jsr transfer - - rts - -; ------------------------------------------------------------------------ -; USE: Tell the driver that the window is now associated with a given page. - -USE: sta curpage ; Remember the page - stx curbank ; Remember the bank - lda #window ; Return the window - rts - -; ------------------------------------------------------------------------ -; COMMIT: Commit changes in the memory window to extended storage. - -COMMIT: lda curpage ; Get the current page - sta ptr1+1 ; dst high - ldx #$00 - stx ptr1 ; dst low - - lda #window - sta ptr2+1 ; src high - - stx ptr3+1 ; length high - lda #$ff - sta ptr3 ; length low - - stx tmp2 ; src bank - ldy curbank ; Get the current bank - iny - ldx isnotscpu - bne @notascpu - iny -@notascpu: - sty tmp1 ; dst bank - - jsr transfer - - rts - -; ------------------------------------------------------------------------ -; COPYFROM: Copy from extended into linear memory. A pointer to a structure -; describing the request is passed in a/x. -; The function must not return anything. -; - -COPYFROM: - sta ptr4 - stx ptr4+1 ; Save the passed em_copy pointer - - ldy #EM_COPY::COUNT+1 ; start at the end of the struct - lda (ptr4),y ; get high byte of count - tax - dey - lda (ptr4),y ; get low byte of count - bne @nodex - dex -@nodex: -.P816 - dec -.P02 - sta ptr3 ; length low - stx ptr3+1 ; length high - dey - lda (ptr4),y ; get bank -.P816 - inc -.P02 - ldx isnotscpu - bne @notscpu64 -.P816 - inc -.P02 -@notscpu64: - sta tmp2 ; src bank - dey - lda (ptr4),y ; get page - sta ptr2+1 ; src high - dey - lda (ptr4),y ; get offset in page - sta ptr2 ; src low - dey - lda (ptr4),y ; get memory buffer high - sta ptr1+1 ; dst high - dey - lda (ptr4),y ; get memory buffer low - sta ptr1 ; dst low - lda #$00 - sta tmp1 ; dst bank - - jsr transfer - - rts - -; ------------------------------------------------------------------------ -; COPYTO: Copy from linear into extended memory. A pointer to a structure -; describing the request is passed in a/x. -; The function must not return anything. -; - -COPYTO: sta ptr4 - stx ptr4+1 ; Save the passed em_copy pointer - - ldy #EM_COPY::COUNT+1 ; start at the end of the struct - lda (ptr4),y ; get high byte of count - tax - dey - lda (ptr4),y ; get low byte of count - bne @nodex2 - dex -@nodex2: -.P816 - dec -.P02 - sta ptr3 ; length low - txa - sta ptr3+1 ; length high - dey - lda (ptr4),y ; get bank -.P816 - inc -.P02 - ldx isnotscpu - bne @notascpu64 -.P816 - inc -.P02 -@notascpu64: - sta tmp1 ; dst bank - dey - lda (ptr4),y ; get page - sta ptr1+1 ; dst high - dey - lda (ptr4),y ; get page offset - sta ptr1 ; dst low - dey - lda (ptr4),y ; get memory buffer high - sta ptr2+1 ; src low - dey - lda (ptr4),y ; get memory buffer low - sta ptr2 ; src high - lda #$00 - sta tmp2 ; src bank - - jsr transfer - - rts - -; ------------------------------------------------------------------------ -; Helper function for moving a block, the following is used: -; ptr1: dst -; ptr2: src -; ptr3: length -; tmp1: dst bank -; tmp2: src bank - -transfer: -.P816 -.A8 -.I8 - sei - pha - phx - phy - ldx tmp1 ; load srcbank - stx @move+1 ; store srcbank in move + 1 - ldy tmp2 ; load dstbank - sty @move+2 ; store dstbank in move + 2 - clc ; switch to native mode - xce - php ; save status bits - rep #%00110000 ; set A and index to 16bit -.A16 -.I16 - ldy ptr1 - ldx ptr2 - lda ptr3 -@move: - mvn 0,0 - plp ; restore status bits -.A8 -.I8 - lda #$00 - pha - plb ; restore dbr - sec - xce ; switch to emul mode - ply - plx - pla - cli - rts -.P02 +; +; Extended memory driver for 65816 based extra RAM. Driver works without +; problems when statically linked. +; +; Marco van den Heuvel, 2015-12-01 +; + + .include "zeropage.inc" + + .include "em-kernel.inc" + .include "em-error.inc" + + + .macpack generic + .macpack module + + +; ------------------------------------------------------------------------ +; Header. Includes jump table + + module_header _c64_65816_emd + +; Driver signature + + .byte $65, $6d, $64 ; "emd" + .byte EMD_API_VERSION ; EM API version number + +; Library reference + + .addr $0000 + +; Jump table + + .addr INSTALL + .addr UNINSTALL + .addr PAGECOUNT + .addr MAP + .addr USE + .addr COMMIT + .addr COPYFROM + .addr COPYTO + +; ------------------------------------------------------------------------ +; Data. + +.bss +isnotscpu: .res 1 ; SuperCPU not present +curpage: .res 1 ; Current page number +curbank: .res 1 ; Current bank number (+1) +bankcount: .res 1 ; Number of available banks (pages = banks * 256) +window: .res 256 ; Memory "window" + +.code + +; ------------------------------------------------------------------------ +; INSTALL routine. Is called after the driver is loaded into memory. If +; possible, check if the hardware is present and determine the amount of +; memory available. +; Must return an EM_ERR_xx code in a/x. +; + +INSTALL: + sei + clc + sed + lda #$99 + adc #$01 ; on 65C02, 65SC02, 65CE02, 65802 and 65816 sets the zero flag correctly + cld + bne @not_present + clc +.P816 + sep #$01 ; nop #$01 on 65C02/65SC02 and lda ($01,s),y on 65CE02 +.P02 + bcc @not_present + lda $d0bc + and #$80 + sta isnotscpu + lda $07e8 + pha ; save value incase it was used somewhere else + ldx #$ff +@fillloop: ; fill from top (bank 255) to bottom + txa + pha +.P816 + plb ; pull dbr +.P02 + stx $07e8 + dex + cpx #$ff + bne @fillloop + inx +@compareloop: ; check from bottom to top + txa + pha +.P816 + plb +.P02 + cmp $07e8 + bne @found_pages +.P816 + inc +.P02 + sta $07e8 + cmp $07e8 + bne @found_pages + inx + bne @compareloop +@found_pages: + dex + lda #$00 + pha +.P816 + plb +.P02 + pla + sta $07e8 + cli + lda isnotscpu + bne @noextradex + dex +@noextradex: + stx bankcount + lda #EM_ERR_OK + rts +@not_present: + cli + lda #EM_ERR_NO_DEVICE +; rts ; Run into UNINSTALL instead + + +; ------------------------------------------------------------------------ +; UNINSTALL routine. Is called before the driver is removed from memory. +; Can do cleanup or whatever. Must not return anything. +; + +UNINSTALL: + rts + + +; ------------------------------------------------------------------------ +; PAGECOUNT: Return the total number of available pages in a/x. +; + +PAGECOUNT: + lda #$00 ; a whole bank is either usable or not + ldx bankcount + rts + +; ------------------------------------------------------------------------ +; MAP: Map the page in a/x into memory and return a pointer to the page in +; a/x. The contents of the currently mapped page (if any) may be discarded +; by the driver. +; + +MAP: sta curpage ; Remember the new page + stx curbank ; Remember the new bank + + sta ptr2+1 ; src address low + lda #$00 + sta ptr2 ; src address high + inx + ldy isnotscpu ; check if not scpu + bne @notscpu + inx +@notscpu: + stx tmp2 ; src bank + + sta tmp1 ; dst bank + + sta ptr3+1 ; length high + lda #$ff + sta ptr3 ; length low + + lda #window + stx ptr1+1 ; dst address high + + jsr transfer + + rts + +; ------------------------------------------------------------------------ +; USE: Tell the driver that the window is now associated with a given page. + +USE: sta curpage ; Remember the page + stx curbank ; Remember the bank + lda #window ; Return the window + rts + +; ------------------------------------------------------------------------ +; COMMIT: Commit changes in the memory window to extended storage. + +COMMIT: lda curpage ; Get the current page + sta ptr1+1 ; dst high + ldx #$00 + stx ptr1 ; dst low + + lda #window + sta ptr2+1 ; src high + + stx ptr3+1 ; length high + lda #$ff + sta ptr3 ; length low + + stx tmp2 ; src bank + ldy curbank ; Get the current bank + iny + ldx isnotscpu + bne @notascpu + iny +@notascpu: + sty tmp1 ; dst bank + + jsr transfer + + rts + +; ------------------------------------------------------------------------ +; COPYFROM: Copy from extended into linear memory. A pointer to a structure +; describing the request is passed in a/x. +; The function must not return anything. +; + +COPYFROM: + sta ptr4 + stx ptr4+1 ; Save the passed em_copy pointer + + ldy #EM_COPY::COUNT+1 ; start at the end of the struct + lda (ptr4),y ; get high byte of count + tax + dey + lda (ptr4),y ; get low byte of count + bne @nodex + dex +@nodex: +.P816 + dec +.P02 + sta ptr3 ; length low + stx ptr3+1 ; length high + dey + lda (ptr4),y ; get bank +.P816 + inc +.P02 + ldx isnotscpu + bne @notscpu64 +.P816 + inc +.P02 +@notscpu64: + sta tmp2 ; src bank + dey + lda (ptr4),y ; get page + sta ptr2+1 ; src high + dey + lda (ptr4),y ; get offset in page + sta ptr2 ; src low + dey + lda (ptr4),y ; get memory buffer high + sta ptr1+1 ; dst high + dey + lda (ptr4),y ; get memory buffer low + sta ptr1 ; dst low + lda #$00 + sta tmp1 ; dst bank + + jsr transfer + + rts + +; ------------------------------------------------------------------------ +; COPYTO: Copy from linear into extended memory. A pointer to a structure +; describing the request is passed in a/x. +; The function must not return anything. +; + +COPYTO: sta ptr4 + stx ptr4+1 ; Save the passed em_copy pointer + + ldy #EM_COPY::COUNT+1 ; start at the end of the struct + lda (ptr4),y ; get high byte of count + tax + dey + lda (ptr4),y ; get low byte of count + bne @nodex2 + dex +@nodex2: +.P816 + dec +.P02 + sta ptr3 ; length low + txa + sta ptr3+1 ; length high + dey + lda (ptr4),y ; get bank +.P816 + inc +.P02 + ldx isnotscpu + bne @notascpu64 +.P816 + inc +.P02 +@notascpu64: + sta tmp1 ; dst bank + dey + lda (ptr4),y ; get page + sta ptr1+1 ; dst high + dey + lda (ptr4),y ; get page offset + sta ptr1 ; dst low + dey + lda (ptr4),y ; get memory buffer high + sta ptr2+1 ; src low + dey + lda (ptr4),y ; get memory buffer low + sta ptr2 ; src high + lda #$00 + sta tmp2 ; src bank + + jsr transfer + + rts + +; ------------------------------------------------------------------------ +; Helper function for moving a block, the following is used: +; ptr1: dst +; ptr2: src +; ptr3: length +; tmp1: dst bank +; tmp2: src bank + +transfer: +.P816 +.A8 +.I8 + sei + pha + phx + phy + ldx tmp1 ; load srcbank + stx @move+1 ; store srcbank in move + 1 + ldy tmp2 ; load dstbank + sty @move+2 ; store dstbank in move + 2 + clc ; switch to native mode + xce + php ; save status bits + rep #%00110000 ; set A and index to 16bit +.A16 +.I16 + ldy ptr1 + ldx ptr2 + lda ptr3 +@move: + mvn 0,0 + plp ; restore status bits +.A8 +.I8 + lda #$00 + pha + plb ; restore dbr + sec + xce ; switch to emul mode + ply + plx + pla + cli + rts +.P02 diff --git a/libsrc/osic1p/cgetc.s b/libsrc/osic1p/cgetc.s index 9161645c7..f05ad33e0 100644 --- a/libsrc/osic1p/cgetc.s +++ b/libsrc/osic1p/cgetc.s @@ -1,50 +1,50 @@ -; -; char cgetc (void); -; - - .constructor initcgetc - .export _cgetc - .import cursor - - .include "osic1p.inc" - .include "extzp.inc" - .include "zeropage.inc" - -; Initialize one-character buffer that is filled by kbhit() - .segment "ONCE" -initcgetc: - lda #$00 - sta CHARBUF ; No character in buffer initially - rts - -; Input routine from 65V PROM MONITOR, show cursor if enabled - .code -_cgetc: - lda CHARBUF ; character in buffer available? - beq nobuffer - tax ; save character in X - lda #$00 - sta CHARBUF ; empty buffer - beq restorex ; restore X and return -nobuffer: - lda cursor ; show cursor? - beq nocursor - ldy CURS_X - lda (SCREEN_PTR),y ; fetch current character - sta tmp1 ; save it - lda #$A1 ; full white square - sta (SCREEN_PTR),y ; store at cursor position -nocursor: - jsr INPUTC ; get input character in A - ldx cursor - beq done ; was cursor on? - tax ; save A in X - lda tmp1 ; fetch saved character - ldy CURS_X - sta (SCREEN_PTR),y ; store at cursor position - -restorex: - txa ; restore saved character from X -done: - ldx #$00 ; high byte of int return value - rts +; +; char cgetc (void); +; + + .constructor initcgetc + .export _cgetc + .import cursor + + .include "osic1p.inc" + .include "extzp.inc" + .include "zeropage.inc" + +; Initialize one-character buffer that is filled by kbhit() + .segment "ONCE" +initcgetc: + lda #$00 + sta CHARBUF ; No character in buffer initially + rts + +; Input routine from 65V PROM MONITOR, show cursor if enabled + .code +_cgetc: + lda CHARBUF ; character in buffer available? + beq nobuffer + tax ; save character in X + lda #$00 + sta CHARBUF ; empty buffer + beq restorex ; restore X and return +nobuffer: + lda cursor ; show cursor? + beq nocursor + ldy CURS_X + lda (SCREEN_PTR),y ; fetch current character + sta tmp1 ; save it + lda #$A1 ; full white square + sta (SCREEN_PTR),y ; store at cursor position +nocursor: + jsr INPUTC ; get input character in A + ldx cursor + beq done ; was cursor on? + tax ; save A in X + lda tmp1 ; fetch saved character + ldy CURS_X + sta (SCREEN_PTR),y ; store at cursor position + +restorex: + txa ; restore saved character from X +done: + ldx #$00 ; high byte of int return value + rts diff --git a/libsrc/osic1p/osic1p.inc b/libsrc/osic1p/osic1p.inc index eabeaf79e..aaa03ba61 100644 --- a/libsrc/osic1p/osic1p.inc +++ b/libsrc/osic1p/osic1p.inc @@ -1,4 +1,4 @@ -; Addresses -INPUTC := $FD00 ; Input character from keyboard -RESET := $FF00 ; Reset address, show boot prompt -KBD := $DF00 ; Polled keyboard register +; Addresses +INPUTC := $FD00 ; Input character from keyboard +RESET := $FF00 ; Reset address, show boot prompt +KBD := $DF00 ; Polled keyboard register diff --git a/libsrc/osic1p/osiscreen.inc b/libsrc/osic1p/osiscreen.inc index fc8324781..9399d7eee 100644 --- a/libsrc/osic1p/osiscreen.inc +++ b/libsrc/osic1p/osiscreen.inc @@ -1,183 +1,183 @@ -; -; Macro definitions for screen layout modules -; - - .include "extzp.inc" - -.linecont + - -; -; Internal function for screensize() -; -.macro osi_screensize ScrWidth, ScrHeight - ; Macro implementation of internal screensize - ; function for given width and height in - ; characters - - .export screensize - -.proc screensize - ldx #ScrWidth - ldy #ScrHeight - rts -.endproc -.endmacro - -; -; void clrscr (void); -; -.macro osi_clrscr ScrBase, ScrRamSize - - .export _clrscr - -.proc _clrscr - lda #ScrBase ; memset appropriately - jsr pushax - - lda #' ' - ldx #$00 - jsr pushax - - lda #ScrRamSize - jsr _memset - - lda #$00 ; Cursor in upper left corner - sta CURS_X - sta CURS_Y - - jmp plot ; Set the cursor position -.endproc - -.endmacro - -; -; cputc/cputcxy for Challenger 1P -; Based on PET/CBM implementation -; - -.macro osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \ - ScrollDist, ScrLo, ScrHi - - ; Number of characters to move for scrolling - ; by one line -ScrollLength = (ScrHeight - 1) * ScrollDist - -; -; void cputcxy (unsigned char x, unsigned char y, char c); -; void cputc (char c); -; - .export _cputcxy, _cputc, cputdirect, putchar - .export newline, plot - -_cputcxy: - pha ; Save C - jsr gotoxy ; Set cursor, drop x and y - pla ; Restore C - -; Plot a character - also used as internal function - -_cputc: cmp #$0A ; CR? - bne L1 - lda #0 - sta CURS_X - beq plot ; Recalculate pointers - -L1: cmp #$0D ; LF? - beq newline ; Recalculate pointers - -cputdirect: - jsr putchar ; Write the character to the screen - -; Advance cursor position, register Y contains horizontal position after -; putchar - - cpy #(ScrWidth - 1) ; Check whether line is full - bne L3 - jsr newline ; New line - ldy #$FF ; + cr -L3: iny - sty CURS_X - rts - -newline: - inc CURS_Y - lda CURS_Y - cmp #ScrHeight ; Screen height - bne plot - dec CURS_Y ; Bottom of screen reached, scroll - - ; Scroll destination address - lda #<(ScrBase + ScrFirstChar) - ldx #>(ScrBase + ScrFirstChar) - jsr pushax - - ; Scroll source address - lda #<(ScrBase + ScrFirstChar + ScrollDist) - ldx #>(ScrBase + ScrFirstChar + ScrollDist) - jsr pushax - - ; Number of characters to move - lda #ScrollLength - jsr _memmove - - ; Address of first character in last line - ; of screen - lda #<(ScrBase + ScrFirstChar + ScrollLength) - sta ptr1 - lda #>(ScrBase + ScrFirstChar + ScrollLength) - sta ptr1+1 - - ldy #ScrWidth ; Fill last line with blanks - lda #' ' -clrln: sta (ptr1),y - dey - bpl clrln - -plot: ldy CURS_Y - lda ScrLo,y - sta SCREEN_PTR - lda ScrHi,y - sta SCREEN_PTR+1 - rts - -; Write one character to the screen without doing anything else, return X -; position in register Y - -putchar: - ldy CURS_X - sta (SCREEN_PTR),y ; Set char - rts - -.endmacro - -.macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \ - ScrWidth, ScrHeight, ScrollDist - - .import gotoxy - .import _memmove, _memset, pushax - .importzp ptr1 - -.rodata - -; Screen address tables - offset to real screen -ScrTabLo: - .repeat ScrHeight, I - .byte <(ScrBase + ScrFirstChar + I * ScrollDist) - .endrep - -ScrTabHi: - .repeat ScrHeight, I - .byte >(ScrBase + ScrFirstChar + I * ScrollDist) - .endrep - -.code - -osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \ - ScrollDist, ScrTabLo, ScrTabHi -osi_screensize ScrWidth, ScrHeight -osi_clrscr ScrBase, ScrRamSize - +; +; Macro definitions for screen layout modules +; + + .include "extzp.inc" + +.linecont + + +; +; Internal function for screensize() +; +.macro osi_screensize ScrWidth, ScrHeight + ; Macro implementation of internal screensize + ; function for given width and height in + ; characters + + .export screensize + +.proc screensize + ldx #ScrWidth + ldy #ScrHeight + rts +.endproc +.endmacro + +; +; void clrscr (void); +; +.macro osi_clrscr ScrBase, ScrRamSize + + .export _clrscr + +.proc _clrscr + lda #ScrBase ; memset appropriately + jsr pushax + + lda #' ' + ldx #$00 + jsr pushax + + lda #ScrRamSize + jsr _memset + + lda #$00 ; Cursor in upper left corner + sta CURS_X + sta CURS_Y + + jmp plot ; Set the cursor position +.endproc + +.endmacro + +; +; cputc/cputcxy for Challenger 1P +; Based on PET/CBM implementation +; + +.macro osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \ + ScrollDist, ScrLo, ScrHi + + ; Number of characters to move for scrolling + ; by one line +ScrollLength = (ScrHeight - 1) * ScrollDist + +; +; void cputcxy (unsigned char x, unsigned char y, char c); +; void cputc (char c); +; + .export _cputcxy, _cputc, cputdirect, putchar + .export newline, plot + +_cputcxy: + pha ; Save C + jsr gotoxy ; Set cursor, drop x and y + pla ; Restore C + +; Plot a character - also used as internal function + +_cputc: cmp #$0A ; CR? + bne L1 + lda #0 + sta CURS_X + beq plot ; Recalculate pointers + +L1: cmp #$0D ; LF? + beq newline ; Recalculate pointers + +cputdirect: + jsr putchar ; Write the character to the screen + +; Advance cursor position, register Y contains horizontal position after +; putchar + + cpy #(ScrWidth - 1) ; Check whether line is full + bne L3 + jsr newline ; New line + ldy #$FF ; + cr +L3: iny + sty CURS_X + rts + +newline: + inc CURS_Y + lda CURS_Y + cmp #ScrHeight ; Screen height + bne plot + dec CURS_Y ; Bottom of screen reached, scroll + + ; Scroll destination address + lda #<(ScrBase + ScrFirstChar) + ldx #>(ScrBase + ScrFirstChar) + jsr pushax + + ; Scroll source address + lda #<(ScrBase + ScrFirstChar + ScrollDist) + ldx #>(ScrBase + ScrFirstChar + ScrollDist) + jsr pushax + + ; Number of characters to move + lda #ScrollLength + jsr _memmove + + ; Address of first character in last line + ; of screen + lda #<(ScrBase + ScrFirstChar + ScrollLength) + sta ptr1 + lda #>(ScrBase + ScrFirstChar + ScrollLength) + sta ptr1+1 + + ldy #ScrWidth ; Fill last line with blanks + lda #' ' +clrln: sta (ptr1),y + dey + bpl clrln + +plot: ldy CURS_Y + lda ScrLo,y + sta SCREEN_PTR + lda ScrHi,y + sta SCREEN_PTR+1 + rts + +; Write one character to the screen without doing anything else, return X +; position in register Y + +putchar: + ldy CURS_X + sta (SCREEN_PTR),y ; Set char + rts + +.endmacro + +.macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \ + ScrWidth, ScrHeight, ScrollDist + + .import gotoxy + .import _memmove, _memset, pushax + .importzp ptr1 + +.rodata + +; Screen address tables - offset to real screen +ScrTabLo: + .repeat ScrHeight, I + .byte <(ScrBase + ScrFirstChar + I * ScrollDist) + .endrep + +ScrTabHi: + .repeat ScrHeight, I + .byte >(ScrBase + ScrFirstChar + I * ScrollDist) + .endrep + +.code + +osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \ + ScrollDist, ScrTabLo, ScrTabHi +osi_screensize ScrWidth, ScrHeight +osi_clrscr ScrBase, ScrRamSize + .endmacro \ No newline at end of file diff --git a/test/ref/divmod.c b/test/ref/divmod.c index 68a0198e1..8fcc951a6 100644 --- a/test/ref/divmod.c +++ b/test/ref/divmod.c @@ -1,38 +1,38 @@ -/* - !!DESCRIPTION!! div/mod test - !!ORIGIN!! - !!LICENCE!! public domain -*/ - -#include - -void printc(signed char a,signed char b){ -signed char x=a/b,y=a%b,z=a*b; - printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); -} -void prints(short a,short b){ -short x=a/b,y=a%b,z=a*b; - printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); -} -void printl(long a,long b){ -long x=a/b,y=a%b,z=a*b; - printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z); -} - -int main(void) { - printl( 3,-2); - printl(-3,-2); - printl(-3, 2); - printl( 3, 2); - printf("-\n"); - prints( 3,-2); - prints(-3,-2); - prints(-3, 2); - prints( 3, 2); - printf("-\n"); - printc( 3,-2); - printc(-3,-2); - printc(-3, 2); - printc( 3, 2); +/* + !!DESCRIPTION!! div/mod test + !!ORIGIN!! + !!LICENCE!! public domain +*/ + +#include + +void printc(signed char a,signed char b){ +signed char x=a/b,y=a%b,z=a*b; + printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); +} +void prints(short a,short b){ +short x=a/b,y=a%b,z=a*b; + printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); +} +void printl(long a,long b){ +long x=a/b,y=a%b,z=a*b; + printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z); +} + +int main(void) { + printl( 3,-2); + printl(-3,-2); + printl(-3, 2); + printl( 3, 2); + printf("-\n"); + prints( 3,-2); + prints(-3,-2); + prints(-3, 2); + prints( 3, 2); + printf("-\n"); + printc( 3,-2); + printc(-3,-2); + printc(-3, 2); + printc( 3, 2); return 0; -} +} diff --git a/test/ref/init.c b/test/ref/init.c index 5a5816753..44cd544fd 100644 --- a/test/ref/init.c +++ b/test/ref/init.c @@ -1,95 +1,95 @@ -/* - !!DESCRIPTION!! variable initialization - !!ORIGIN!! LCC 4.1 Testsuite - !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC -*/ - -#include "common.h" -/* todo: add back conditional stuff here ! */ - -typedef struct { int codes[3]; char name[6]; } Word; - -#ifdef NO_IMPLICIT_FUNC_PROTOTYPES - -#ifdef NO_OLD_FUNC_DECL -f(); -void g(Word *p); -h(); -#else -f(); -g(); -h(); -#endif - -#endif - -/* -Word words[] = { - 1, 2, 3,"if", - { { 4, 5 }, { 'f', 'o', 'r' } }, - 6, 7, 8, {"else"}, - { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', }, - { 0 }, -}, *wordlist = words; -*/ - -Word words[] = { - {{1, 2, 3},"if"}, - { { 4, 5 }, { 'f', 'o', 'r' } }, - {{6, 7, 8}, "else"}, - { { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }}, - {{ 0 }}, -}, *wordlist = words; - -/*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/ -int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } }; -int *y[] = { x[0], x[1], x[2], 0 }; - -main() -{ - int i, j; - - for (i = 0; y[i]; i++) { - for (j = 0; y[i][j]; j++) - printf(" %d", y[i][j]); - printf("\n"); - } - f(); - g(wordlist); - return 0; -} - -f() { - static char *keywords[] = {"if", "for", "else", "while", 0, }; - char **p; - - for (p = keywords; *p; p++) - printf("%s\n", *p); -} - -#ifdef NO_OLD_FUNC_DECL -void g(Word *p) -#else -g(p) -Word *p; -#endif -{ - int i; - - for ( ; p->codes[0]; p++) { - for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++) - printf("%d ", p->codes[i]); - printf("%s\n", p->name); - } - h(); -} - -h() -{ - int i; - - for (i = 0; i < sizeof(words)/sizeof(Word); i++) - printf("%d %d %d %s\n", words[i].codes[0], - words[i].codes[1], words[i].codes[2], - &words[i].name[0]); -} +/* + !!DESCRIPTION!! variable initialization + !!ORIGIN!! LCC 4.1 Testsuite + !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC +*/ + +#include "common.h" +/* todo: add back conditional stuff here ! */ + +typedef struct { int codes[3]; char name[6]; } Word; + +#ifdef NO_IMPLICIT_FUNC_PROTOTYPES + +#ifdef NO_OLD_FUNC_DECL +f(); +void g(Word *p); +h(); +#else +f(); +g(); +h(); +#endif + +#endif + +/* +Word words[] = { + 1, 2, 3,"if", + { { 4, 5 }, { 'f', 'o', 'r' } }, + 6, 7, 8, {"else"}, + { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', }, + { 0 }, +}, *wordlist = words; +*/ + +Word words[] = { + {{1, 2, 3},"if"}, + { { 4, 5 }, { 'f', 'o', 'r' } }, + {{6, 7, 8}, "else"}, + { { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }}, + {{ 0 }}, +}, *wordlist = words; + +/*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/ +int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } }; +int *y[] = { x[0], x[1], x[2], 0 }; + +main() +{ + int i, j; + + for (i = 0; y[i]; i++) { + for (j = 0; y[i][j]; j++) + printf(" %d", y[i][j]); + printf("\n"); + } + f(); + g(wordlist); + return 0; +} + +f() { + static char *keywords[] = {"if", "for", "else", "while", 0, }; + char **p; + + for (p = keywords; *p; p++) + printf("%s\n", *p); +} + +#ifdef NO_OLD_FUNC_DECL +void g(Word *p) +#else +g(p) +Word *p; +#endif +{ + int i; + + for ( ; p->codes[0]; p++) { + for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++) + printf("%d ", p->codes[i]); + printf("%s\n", p->name); + } + h(); +} + +h() +{ + int i; + + for (i = 0; i < sizeof(words)/sizeof(Word); i++) + printf("%d %d %d %s\n", words[i].codes[0], + words[i].codes[1], words[i].codes[2], + &words[i].name[0]); +} diff --git a/test/ref/pointer2.c b/test/ref/pointer2.c index d8c064ef3..29f9e3de4 100644 --- a/test/ref/pointer2.c +++ b/test/ref/pointer2.c @@ -1,112 +1,112 @@ -/* - !!DESCRIPTION!! pointer test - !!ORIGIN!! - !!LICENCE!! public domain -*/ - -#include "common.h" -#include - -/* - check behaviour on incompletely declared arrays -*/ - -char i1[]; - -void test1(void) { -int a; - - a=sizeof(i1[0]); - printf("%04x - ",a); - if(sizeof(i1[0])==sizeof(char)) { - /* gcc gives size of element */ - printf("sizeof(i1[0]) gives size of element\n"); - } - if(sizeof(i1[0])==sizeof(char*)) { - printf("sizeof(i1[0]) gives size of pointer to element\n"); - } -} - -/* - check behaviour on string init -*/ - -char t1[]="abcde"; -char t2[]={"abcde"}; - -char *t3="abcde"; -char *t4={"abcde"}; - -void test2(void) { -char c1,c2,c3,c4; -int i,e=0; - for(i=0;i<5;i++){ - c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i]; -/* printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */ - printf("%c %c %c %c\n",c1,c2,c3,c4); - if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1; - } - if(e) printf("test2 failed.\n"); - else printf("test2 ok.\n"); -} - -/* - check behaviour on extern-declarations inside functions -*/ - -typedef struct { - char *name; - void *func; -} A3; - -#ifdef NO_SLOPPY_STRUCT_INIT -A3 a3[] = { - { "test3", (void*) NULL }, - { "test3", (void*) NULL }, -}; -#else -/*gcc warning: missing braces around initializer (near initialization for `a3[0]') - this type of struct-initialization seems to be kinda common */ -A3 a3[] = { - "test3", (void*) NULL , - "test3", (void*) NULL , -}; -#endif - -void test3a(A3 *list, int number){ - printf("%s %d\n",list->name,number); -} - -static void test31(void) -{ - extern A3 a3[]; - test3a(a3, -1); -} - -#if 0 -/* this variation compiles and works with cc65, but gives an error with gcc :=P */ -static void test32(void) -{ - extern A3 *a3; - test3a(a3, -1); -} -#endif - -static void test30(void) -{ - test3a(a3, -1); -} - -/* - todo: add test on function pointers in the form of (*func)(arg) ... - cc65 seems to have problems here aswell ;/ -*/ - -int main(void) { - test1(); - test2(); - test30(); - test31(); -/* test32(); */ - return 0; -} +/* + !!DESCRIPTION!! pointer test + !!ORIGIN!! + !!LICENCE!! public domain +*/ + +#include "common.h" +#include + +/* + check behaviour on incompletely declared arrays +*/ + +char i1[]; + +void test1(void) { +int a; + + a=sizeof(i1[0]); + printf("%04x - ",a); + if(sizeof(i1[0])==sizeof(char)) { + /* gcc gives size of element */ + printf("sizeof(i1[0]) gives size of element\n"); + } + if(sizeof(i1[0])==sizeof(char*)) { + printf("sizeof(i1[0]) gives size of pointer to element\n"); + } +} + +/* + check behaviour on string init +*/ + +char t1[]="abcde"; +char t2[]={"abcde"}; + +char *t3="abcde"; +char *t4={"abcde"}; + +void test2(void) { +char c1,c2,c3,c4; +int i,e=0; + for(i=0;i<5;i++){ + c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i]; +/* printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */ + printf("%c %c %c %c\n",c1,c2,c3,c4); + if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1; + } + if(e) printf("test2 failed.\n"); + else printf("test2 ok.\n"); +} + +/* + check behaviour on extern-declarations inside functions +*/ + +typedef struct { + char *name; + void *func; +} A3; + +#ifdef NO_SLOPPY_STRUCT_INIT +A3 a3[] = { + { "test3", (void*) NULL }, + { "test3", (void*) NULL }, +}; +#else +/*gcc warning: missing braces around initializer (near initialization for `a3[0]') + this type of struct-initialization seems to be kinda common */ +A3 a3[] = { + "test3", (void*) NULL , + "test3", (void*) NULL , +}; +#endif + +void test3a(A3 *list, int number){ + printf("%s %d\n",list->name,number); +} + +static void test31(void) +{ + extern A3 a3[]; + test3a(a3, -1); +} + +#if 0 +/* this variation compiles and works with cc65, but gives an error with gcc :=P */ +static void test32(void) +{ + extern A3 *a3; + test3a(a3, -1); +} +#endif + +static void test30(void) +{ + test3a(a3, -1); +} + +/* + todo: add test on function pointers in the form of (*func)(arg) ... + cc65 seems to have problems here aswell ;/ +*/ + +int main(void) { + test1(); + test2(); + test30(); + test31(); +/* test32(); */ + return 0; +} diff --git a/test/ref/switch2.c b/test/ref/switch2.c index e75cfe71e..7a9bcecd7 100644 --- a/test/ref/switch2.c +++ b/test/ref/switch2.c @@ -1,262 +1,262 @@ -/* - !!DESCRIPTION!! switch test - !!ORIGIN!! - !!LICENCE!! public domain -*/ - -/*#define STANDALONE*/ - -#include - +/* + !!DESCRIPTION!! switch test + !!ORIGIN!! + !!LICENCE!! public domain +*/ + +/*#define STANDALONE*/ + +#include + void testlimits(int i) { - printf("%d:",i); - + printf("%d:",i); + switch(i) { - case -1: /* works */ - /* case 0xffff: */ /* 'range error' (-1) */ - - printf("-1\n"); - break; - /* max int */ - -/* case 0x7fff: */ /* works */ - case 32767: /* works */ - /* case 32768: */ /* 'range error' (correct for that one!) */ - - printf("max\n"); - break; - /* min int */ - - case -32768: /* 'warning. constant is long' */ - /* case 0x8000: */ /* 'range error' */ - /* case -32769: */ /* 'range error' (correct for that one!) */ - printf("min\n"); - break; - } - printf("\n"); -} - -void testdefault1(unsigned char i) { -/* we want a signed char */ -#ifdef REFCC - -#ifdef REFCC_UNSIGNED_CHARS -signed char k; -#else -char k; -#endif - -#else - -#ifdef UNSIGNED_CHARS -signed char k; -#else -char k; -#endif - -#endif - - for(;i<254;) { - k = i; - printf(">%d\n",i);i++; - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - case 6: - break; - case 7: - break; - case 8: - break; - case 9: - break; - case 10: - break; - case 11: - break; - case 12: - break; - case 13: - break; - case 14: - break; - case 15: - break; - case 17: - break; - /* triggers bug ? */ - /* gcc warning: case label value exceeds maximum value for type */ - /* cc65 error: range error */ - - /* - case 170: - break; - */ - case 18: - break; - case 19: - break; - case 20: - break; - case 21: - break; - case 22: - break; - case 23: - break; - case 24: - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - case 5: - break; - case 6: - case 7: - break; - case 8: - case 9: - break; - } - break; - case 100: - break; - default: - printf(">>>default\n"); - /* triggers bug if this break; is missing? */ - /* break; */ - } - } -} - -void testdefault2(unsigned char i) { -/* we want a unsigned char */ -#ifdef REFCC - -#ifdef REFCC_UNSIGNED_CHARS -char k; -#else -unsigned char k; -#endif - -#else - -#ifdef UNSIGNED_CHARS -char k; -#else -unsigned char k; -#endif - -#endif - - for(;i<254;) { - k = i; - printf(">%d\n",i);i++; - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - case 6: - break; - case 7: - break; - case 8: - break; - case 9: - break; - case 10: - break; - case 11: - break; - case 12: - break; - case 13: - break; - case 14: - break; - case 15: - break; - case 17: - break; - /* triggers bug ? */ - - case 170: - break; - - case 18: - break; - case 19: - break; - case 20: - break; - case 21: - break; - case 22: - break; - case 23: - break; - case 24: - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - case 5: - break; - case 6: - case 7: - break; - case 8: - case 9: - break; - } - break; - case 100: - break; - default: - printf(">>>default\n"); - /* triggers bug if this break; is missing? */ - /* break; */ - } - } + case -1: /* works */ + /* case 0xffff: */ /* 'range error' (-1) */ + + printf("-1\n"); + break; + /* max int */ + +/* case 0x7fff: */ /* works */ + case 32767: /* works */ + /* case 32768: */ /* 'range error' (correct for that one!) */ + + printf("max\n"); + break; + /* min int */ + + case -32768: /* 'warning. constant is long' */ + /* case 0x8000: */ /* 'range error' */ + /* case -32769: */ /* 'range error' (correct for that one!) */ + printf("min\n"); + break; + } + printf("\n"); +} + +void testdefault1(unsigned char i) { +/* we want a signed char */ +#ifdef REFCC + +#ifdef REFCC_UNSIGNED_CHARS +signed char k; +#else +char k; +#endif + +#else + +#ifdef UNSIGNED_CHARS +signed char k; +#else +char k; +#endif + +#endif + + for(;i<254;) { + k = i; + printf(">%d\n",i);i++; + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + break; + case 13: + break; + case 14: + break; + case 15: + break; + case 17: + break; + /* triggers bug ? */ + /* gcc warning: case label value exceeds maximum value for type */ + /* cc65 error: range error */ + + /* + case 170: + break; + */ + case 18: + break; + case 19: + break; + case 20: + break; + case 21: + break; + case 22: + break; + case 23: + break; + case 24: + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + case 5: + break; + case 6: + case 7: + break; + case 8: + case 9: + break; + } + break; + case 100: + break; + default: + printf(">>>default\n"); + /* triggers bug if this break; is missing? */ + /* break; */ + } + } +} + +void testdefault2(unsigned char i) { +/* we want a unsigned char */ +#ifdef REFCC + +#ifdef REFCC_UNSIGNED_CHARS +char k; +#else +unsigned char k; +#endif + +#else + +#ifdef UNSIGNED_CHARS +char k; +#else +unsigned char k; +#endif + +#endif + + for(;i<254;) { + k = i; + printf(">%d\n",i);i++; + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + break; + case 13: + break; + case 14: + break; + case 15: + break; + case 17: + break; + /* triggers bug ? */ + + case 170: + break; + + case 18: + break; + case 19: + break; + case 20: + break; + case 21: + break; + case 22: + break; + case 23: + break; + case 24: + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + case 5: + break; + case 6: + case 7: + break; + case 8: + case 9: + break; + } + break; + case 100: + break; + default: + printf(">>>default\n"); + /* triggers bug if this break; is missing? */ + /* break; */ + } + } } int main(void) { - testlimits(32767); - testlimits(-32768); - testlimits(-1); - - testdefault1(1); - testdefault1(2); - testdefault1(3); - testdefault1(4); - - testdefault2(1); - testdefault2(2); - testdefault2(3); - testdefault2(4); - - return 0; -} + testlimits(32767); + testlimits(-32768); + testlimits(-1); + + testdefault1(1); + testdefault1(2); + testdefault1(3); + testdefault1(4); + + testdefault2(1); + testdefault2(2); + testdefault2(3); + testdefault2(4); + + return 0; +} diff --git a/test/ref/varargs.c b/test/ref/varargs.c index 11fd33b38..3d61fdbd0 100644 --- a/test/ref/varargs.c +++ b/test/ref/varargs.c @@ -1,105 +1,105 @@ /* - !!DESCRIPTION!! varargs test - !!ORIGIN!! - !!LICENCE!! public domain -*/ - -#include -#include -#include - -void chk0(char *format,...); -void chk1(int fd,char *format,...); - -#if 0 -// old workaround for broken varargs - -void chk0(char *format,...){ - __asm__ ("pha"); // save argument size - { -//va_list ap; -char *ap; -char *_format; -static char string[0x100]; - -// va_start(ap,format); - __asm__ ("pla"); // restore argument size - __asm__ ("ldx #$00"); // clear hibyte of AX - ap=__AX__; - ap+=(char*)&format; - // get value of format - ap-=2; - _format=*((char**)ap); - -// vsprintf(string,format,ap); - vsprintf(&string[0],_format,ap); - printf("format:%s,string:%s\n",_format,string); -// va_end(ap); - - } -} - -void chk1(int fd,char *format,...){ - __asm__ ("pha"); // save argument size - { -//va_list ap; -char *ap; -char *_format; -int _fd; -static char string[0x100]; - -// va_start(ap,format); - __asm__ ("pla"); // restore argument size - __asm__ ("ldx #$00"); // clear hibyte of AX - ap=__AX__; - ap+=(char*)&format; - // get value of fd - ap-=2; - _fd=*((int*)ap); - // get value of format - ap-=2; - _format=*((char**)ap); - -// vsprintf(string,format,ap); - vsprintf(&string[0],_format,ap); - printf("fd:%d,format:%s,string:%s\n",_fd,_format,string); -// va_end(ap); - - } -} - -#endif - -void chk0(char *format,...){ -va_list ap; -static char string[0x100]; - va_start(ap,format); - vsprintf(string,format,ap); - printf("format:%s,string:%s\n",format,string); - va_end(ap); -} - -void chk1(int fd,char *format,...){ -va_list ap; -static char string[0x100]; - - va_start(ap,format); - - vsprintf(string,format,ap); - printf("fd:%d,format:%s,string:%s\n",fd,format,string); - va_end(ap); + !!DESCRIPTION!! varargs test + !!ORIGIN!! + !!LICENCE!! public domain +*/ + +#include +#include +#include + +void chk0(char *format,...); +void chk1(int fd,char *format,...); + +#if 0 +// old workaround for broken varargs + +void chk0(char *format,...){ + __asm__ ("pha"); // save argument size + { +//va_list ap; +char *ap; +char *_format; +static char string[0x100]; + +// va_start(ap,format); + __asm__ ("pla"); // restore argument size + __asm__ ("ldx #$00"); // clear hibyte of AX + ap=__AX__; + ap+=(char*)&format; + // get value of format + ap-=2; + _format=*((char**)ap); + +// vsprintf(string,format,ap); + vsprintf(&string[0],_format,ap); + printf("format:%s,string:%s\n",_format,string); +// va_end(ap); + + } } -int main(int argc,char **argv) { - printf("varargs test\n"); - - printf("\nchk0/0:\n");chk0("chk0 %s","arg0"); - printf("\nchk0/1:\n");chk0("chk0 %s %s","arg0","arg1"); - printf("\nchk0/2:\n");chk0("chk0 %s %s %s","arg0","arg1","arg2"); - - printf("\nchk1/0:\n");chk1(0xfd,"chk1 %s","arg0"); - printf("\nchk1/1:\n");chk1(0xfd,"chk1 %s %s","arg0","arg1"); - printf("\nchk1/2:\n");chk1(0xfd,"chk1 %s %s %s","arg0","arg1","arg2"); - +void chk1(int fd,char *format,...){ + __asm__ ("pha"); // save argument size + { +//va_list ap; +char *ap; +char *_format; +int _fd; +static char string[0x100]; + +// va_start(ap,format); + __asm__ ("pla"); // restore argument size + __asm__ ("ldx #$00"); // clear hibyte of AX + ap=__AX__; + ap+=(char*)&format; + // get value of fd + ap-=2; + _fd=*((int*)ap); + // get value of format + ap-=2; + _format=*((char**)ap); + +// vsprintf(string,format,ap); + vsprintf(&string[0],_format,ap); + printf("fd:%d,format:%s,string:%s\n",_fd,_format,string); +// va_end(ap); + + } +} + +#endif + +void chk0(char *format,...){ +va_list ap; +static char string[0x100]; + va_start(ap,format); + vsprintf(string,format,ap); + printf("format:%s,string:%s\n",format,string); + va_end(ap); +} + +void chk1(int fd,char *format,...){ +va_list ap; +static char string[0x100]; + + va_start(ap,format); + + vsprintf(string,format,ap); + printf("fd:%d,format:%s,string:%s\n",fd,format,string); + va_end(ap); +} + +int main(int argc,char **argv) { + printf("varargs test\n"); + + printf("\nchk0/0:\n");chk0("chk0 %s","arg0"); + printf("\nchk0/1:\n");chk0("chk0 %s %s","arg0","arg1"); + printf("\nchk0/2:\n");chk0("chk0 %s %s %s","arg0","arg1","arg2"); + + printf("\nchk1/0:\n");chk1(0xfd,"chk1 %s","arg0"); + printf("\nchk1/1:\n");chk1(0xfd,"chk1 %s %s","arg0","arg1"); + printf("\nchk1/2:\n");chk1(0xfd,"chk1 %s %s %s","arg0","arg1","arg2"); + return 0; -} +} diff --git a/testcode/lib/mul-test.c b/testcode/lib/mul-test.c index 2daf5aa06..f9db3f641 100644 --- a/testcode/lib/mul-test.c +++ b/testcode/lib/mul-test.c @@ -1,170 +1,170 @@ -/* mul-test.c -- Test the multiplication operator. */ - -#include -#include -#include - - -/* Number of elements in the progress bar. Use a power of 2, to avoid the -** multiplication (which is about to be tested). -*/ -#define BAR_ELEMENTS 32U - -#if defined(__CBM__) -static const unsigned char revers_bar[8] = { - 0, 0, 0, 0, 0, 1, 1, 1 -}; -static const unsigned char small_bar[8] = { - ' ', 0xa5, 0xb4, 0xb5, 0xa1, 0xb6, 0xaa, 0xa7 -}; - -#elif defined(__ATARI__) -#endif - -/* Screen co-ordinates for the progress meter */ -static unsigned char Width, Height; -static unsigned char X, Y; - -static void ProgressMeter (unsigned Val) -/* Print the progress bar. */ -{ - gotoxy (X, Y); - cprintf (" %5lu/65536\r\n", (unsigned long) Val); - revers (1); - cclear (Val / (unsigned)(65536U / BAR_ELEMENTS)); - -/* Commodore and Atari computers can show eight times greater precision. */ -#if defined(__CBM__) - Val = (Val / (unsigned)(65536U / BAR_ELEMENTS / 8)) % 8; - revers (revers_bar[Val]); - cputc (small_bar[Val]); - -#elif defined(__ATARI__) -#endif - - revers (0); -} - - - -int main(void) -{ - char C; - - /* Clock variables */ - clock_t Ticks; - clock_t Wait; - unsigned Days; - unsigned Hours; - unsigned Minu; - unsigned Sec; - unsigned Milli; - - /* Actual test variables */ - register unsigned lhs = 0; - register unsigned rhs = 0; - register unsigned res; - - /* Clear the screen, and output an informational message. */ - clrscr (); - screensize (&Width, &Height); - cprintf ("This program does an exhaustive test of\r\n" - "the multiplication routine. It runs for\r\n" - "several days; so, please wait very\r\n" - "patiently (or, speed up your emulator).\r\n" - "\n" - "Progress: "); - - /* Remember the current position for the progress bar */ - X = wherex (); - Y = wherey (); - - /* Mark the maximum limit of the bar. */ - revers (1); - cputcxy (BAR_ELEMENTS, Y, ' '); - cputcxy (BAR_ELEMENTS, Y + 1, ' '); - revers (0); - -/* [Targets that have clock() will define CLOCKS_PER_SEC.] */ -#ifdef CLOCKS_PER_SEC - - /* Start timing the test. */ - Ticks = clock(); -#endif - - do { - - /* Update the progress bar */ - ProgressMeter (lhs); - -/* Enable this to test the progress-meter code. -** (And, run emulators at their maximun speed.) -*/ -#if 0 - continue; -#endif - - /* Do one row of tests */ - res = 0; - do { - if (lhs * rhs != res) { -#ifdef CLOCKS_PER_SEC - Wait = clock (); -#endif - gotoxy (0, Y+3); - cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res); - cprintf ("Press a key -- 'Q' to quit. "); - cursor (1); - C = toupper (cgetc ()); - cclearxy (0, Y+3, Width); - cclearxy (0, Y+4, Width); - -#ifdef CLOCKS_PER_SEC - - /* Don't time the user's interaction. */ - Ticks += clock () - Wait; -#endif - - if (C == 'Q') { - goto Done; - } - } - - if (kbhit () && toupper (cgetc ()) == 'Q') { - goto Done; - } - - res += lhs; - } while (++rhs != 0); - - } while (++lhs != 0); - -Done: -#ifdef CLOCKS_PER_SEC - - /* Calculate the time used */ - Ticks = clock() - Ticks; - Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC; - Sec = (unsigned) (Ticks / CLOCKS_PER_SEC); - Minu = Sec / 60; - Hours = Minu / 60; - Days = Hours / 24; - Hours %= 24; - Minu %= 60; - Sec %= 60; - - /* Print the time used */ - gotoxy (0, Y+3); - cprintf ("Time used:\r\n" - " %u days,\r\n" - " %u hours,\r\n" - " %u minutes,\r\n" - " %u.%03u seconds.\n", Days, Hours, Minu, Sec, Milli); -#endif - - cprintf ("\rTap a key, to exit. "); - cgetc(); - return 0; -} - - +/* mul-test.c -- Test the multiplication operator. */ + +#include +#include +#include + + +/* Number of elements in the progress bar. Use a power of 2, to avoid the +** multiplication (which is about to be tested). +*/ +#define BAR_ELEMENTS 32U + +#if defined(__CBM__) +static const unsigned char revers_bar[8] = { + 0, 0, 0, 0, 0, 1, 1, 1 +}; +static const unsigned char small_bar[8] = { + ' ', 0xa5, 0xb4, 0xb5, 0xa1, 0xb6, 0xaa, 0xa7 +}; + +#elif defined(__ATARI__) +#endif + +/* Screen co-ordinates for the progress meter */ +static unsigned char Width, Height; +static unsigned char X, Y; + +static void ProgressMeter (unsigned Val) +/* Print the progress bar. */ +{ + gotoxy (X, Y); + cprintf (" %5lu/65536\r\n", (unsigned long) Val); + revers (1); + cclear (Val / (unsigned)(65536U / BAR_ELEMENTS)); + +/* Commodore and Atari computers can show eight times greater precision. */ +#if defined(__CBM__) + Val = (Val / (unsigned)(65536U / BAR_ELEMENTS / 8)) % 8; + revers (revers_bar[Val]); + cputc (small_bar[Val]); + +#elif defined(__ATARI__) +#endif + + revers (0); +} + + + +int main(void) +{ + char C; + + /* Clock variables */ + clock_t Ticks; + clock_t Wait; + unsigned Days; + unsigned Hours; + unsigned Minu; + unsigned Sec; + unsigned Milli; + + /* Actual test variables */ + register unsigned lhs = 0; + register unsigned rhs = 0; + register unsigned res; + + /* Clear the screen, and output an informational message. */ + clrscr (); + screensize (&Width, &Height); + cprintf ("This program does an exhaustive test of\r\n" + "the multiplication routine. It runs for\r\n" + "several days; so, please wait very\r\n" + "patiently (or, speed up your emulator).\r\n" + "\n" + "Progress: "); + + /* Remember the current position for the progress bar */ + X = wherex (); + Y = wherey (); + + /* Mark the maximum limit of the bar. */ + revers (1); + cputcxy (BAR_ELEMENTS, Y, ' '); + cputcxy (BAR_ELEMENTS, Y + 1, ' '); + revers (0); + +/* [Targets that have clock() will define CLOCKS_PER_SEC.] */ +#ifdef CLOCKS_PER_SEC + + /* Start timing the test. */ + Ticks = clock(); +#endif + + do { + + /* Update the progress bar */ + ProgressMeter (lhs); + +/* Enable this to test the progress-meter code. +** (And, run emulators at their maximun speed.) +*/ +#if 0 + continue; +#endif + + /* Do one row of tests */ + res = 0; + do { + if (lhs * rhs != res) { +#ifdef CLOCKS_PER_SEC + Wait = clock (); +#endif + gotoxy (0, Y+3); + cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res); + cprintf ("Press a key -- 'Q' to quit. "); + cursor (1); + C = toupper (cgetc ()); + cclearxy (0, Y+3, Width); + cclearxy (0, Y+4, Width); + +#ifdef CLOCKS_PER_SEC + + /* Don't time the user's interaction. */ + Ticks += clock () - Wait; +#endif + + if (C == 'Q') { + goto Done; + } + } + + if (kbhit () && toupper (cgetc ()) == 'Q') { + goto Done; + } + + res += lhs; + } while (++rhs != 0); + + } while (++lhs != 0); + +Done: +#ifdef CLOCKS_PER_SEC + + /* Calculate the time used */ + Ticks = clock() - Ticks; + Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC; + Sec = (unsigned) (Ticks / CLOCKS_PER_SEC); + Minu = Sec / 60; + Hours = Minu / 60; + Days = Hours / 24; + Hours %= 24; + Minu %= 60; + Sec %= 60; + + /* Print the time used */ + gotoxy (0, Y+3); + cprintf ("Time used:\r\n" + " %u days,\r\n" + " %u hours,\r\n" + " %u minutes,\r\n" + " %u.%03u seconds.\n", Days, Hours, Minu, Sec, Milli); +#endif + + cprintf ("\rTap a key, to exit. "); + cgetc(); + return 0; +} + + From acb7c6130274d7c2ad91ac82c6b64b741fa47d97 Mon Sep 17 00:00:00 2001 From: Greg King Date: Fri, 10 Mar 2017 08:47:48 -0500 Subject: [PATCH 025/199] Removed a pointless cc65 command-line option from the samples makefile. "-Oi --codesize 500" is the same as "-O --codesize 200 --codesize 500". That first "--codesize" is replaced by the second one. Don't set it twice. --- samples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Makefile b/samples/Makefile index edfeca689..949940022 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -90,7 +90,7 @@ LDFLAGS_tgidemo_atarixl = --start-addr 0x4000 %: %.s .c.o: - $(CC) $(CFLAGS) -Oirs --codesize 500 -T -g -t $(SYS) $< + $(CC) $(CFLAGS) -Ors --codesize 500 -T -g -t $(SYS) $< $(AS) $(<:.c=.s) .s.o: From 73261ea48f84ccca6ce3608fab6a9c8802ddb874 Mon Sep 17 00:00:00 2001 From: Greg King Date: Sat, 11 Mar 2017 15:11:15 -0500 Subject: [PATCH 026/199] Fixed a pointer test again -- but, it's better than in pull request #391. This time, the expression compares the pointer directly, instead of comparing the pointer's target. The new expression avoids an array underrun. --- test/ref/yacc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/ref/yacc.c b/test/ref/yacc.c index d0b9190e4..ab72e24c0 100644 --- a/test/ref/yacc.c +++ b/test/ref/yacc.c @@ -562,13 +562,13 @@ yylook() } # ifdef LEXDEBUG - if (*(lsp-1) < yysvec + 1) + if (lsp == yylstate) { fprintf(yyout,"yylook: stopped (end)\n"); } else { - fprintf(yyout,"yylook: stopped at %d with\n",*(lsp-1)-yysvec-1); + fprintf(yyout,"yylook: stopped at %d with:\n",*(lsp-1)-(yysvec+1)); } # endif while (lsp-- > yylstate) @@ -594,7 +594,7 @@ yylook() yyleng = yylastch-yytext+1; yytext[yyleng] = 0; # ifdef LEXDEBUG - fprintf(yyout,"\nyylook: match action %d\n",*yyfnd); + fprintf(yyout,"yylook: match action %d\n",*yyfnd); fprintf(yyout,"yylook: done loops: %d\n",testbreak); # endif return(*yyfnd++); From 2e8d792f9a1b55bb19942e02b91b1294dbc37e87 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 12 Mar 2017 18:13:18 +0100 Subject: [PATCH 027/199] Added .gitattributes to force LF line endings on commit. --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..176a458f9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto From 750a527100526dfd33e31152819a87533ca95d1f Mon Sep 17 00:00:00 2001 From: Greg King Date: Sun, 12 Mar 2017 12:55:31 -0400 Subject: [PATCH 028/199] Made C's sizeof operator work with initialized void variables. Added regression tests that check cc65's handling of void variables. --- doc/cc65.sgml | 47 +++++++++++++--------- src/cc65/datatype.c | 7 +++- src/cc65/declare.c | 10 +++-- test/err/void-empty.c | 9 +++++ test/err/void-size2.c | 11 +++++ test/val/void-size1.c | 56 ++++++++++++++++++++++++++ testcode/lib/atari/displaylist.c | 69 +++++++++++++++----------------- 7 files changed, 147 insertions(+), 62 deletions(-) create mode 100644 test/err/void-empty.c create mode 100644 test/err/void-size2.c create mode 100644 test/val/void-size1.c diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 80dba89b8..6a08cc3c3 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -4,7 +4,7 @@ cc65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:gregdk@users.sf.net" name="Greg King"> -<date>2016-06-11 +<date>2017-02-27 <abstract> cc65 is a C compiler for 6502 targets. It supports several 6502 based home @@ -687,30 +687,37 @@ This cc65 version has some extensions to the ISO C standard. string. <p> -<item> cc65 allows the initialization of <tt/void/ variables. This may be - used to create variable structures that are more compatible with - interfaces written for assembler languages. Here is an example: +<item> cc65 allows the initialization of <tt/void/ variables. This may be + used to create arbitrary structures that are more compatible with + interfaces written for assembler languages. Here is an example: - <tscreen><verb> - void GCmd = { (char)3, (unsigned)0x2000, (unsigned)0x3000 }; - </verb></tscreen> + <tscreen><verb> + void GCmd = { (char)3, (unsigned)0x2000, (unsigned)0x3000 }; + </verb></tscreen> - This will be translated as follows: + That will be translated as follows: - <tscreen><verb> - _GCmd: - .byte 3 - .word $2000 - .word $3000 - </verb></tscreen> + <tscreen><verb> + _GCmd: + .byte 3 + .word $2000 + .word $3000 + </verb></tscreen> - Since the variable is of type <tt/void/ you may not use it as is. - However, taking the address of the variable results in a <tt/void*/ - which may be passed to any function expecting a pointer. + Since the variable is of type <tt/void/, you may not use it as-is. + However, taking the address of the variable results in a <tt/void*/ + which may be passed to any function expecting a pointer. Also, the + <tt/sizeof/ operator will give the length of the initializer: - See the <url url="geos.html" name="GEOS library document"> for examples - on how to use this feature. - <p> + <tscreen><verb> + GLen = sizeof GCmd; + </verb></tscreen> + + will assign the value 5 to <tt/GLen/. + + See the <url url="geos.html" name="GEOS library document"> for examples + on how to use that feature. + <p> <item> cc65 implements flexible array struct members as defined in the C99 ISO standard. As an extension, these fields may be initialized. There are diff --git a/src/cc65/datatype.c b/src/cc65/datatype.c index 8c9d6dcb0..2d54316cd 100644 --- a/src/cc65/datatype.c +++ b/src/cc65/datatype.c @@ -389,7 +389,10 @@ unsigned SizeOf (const Type* T) switch (UnqualifiedType (T->C)) { case T_VOID: - return 0; /* Assume voids have size zero */ + /* A void variable is a cc65 extension. + ** Get its size (in bytes). + */ + return T->A.U; /* Beware: There's a chance that this triggers problems in other parts of the compiler. The solution is to fix the callers, because calling @@ -438,7 +441,7 @@ unsigned SizeOf (const Type* T) /* Array with unspecified size */ return 0; } else { - return T->A.L * SizeOf (T + 1); + return T->A.U * SizeOf (T + 1); } default: diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 163084835..7b543aa55 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -891,6 +891,7 @@ static void ParseTypeSpec (DeclSpec* D, long Default, TypeCode Qualifiers) case TOK_VOID: NextToken (); D->Type[0].C = T_VOID; + D->Type[0].A.U = 0; D->Type[1].C = T_END; break; @@ -2114,7 +2115,7 @@ NextMember: -static unsigned ParseVoidInit (void) +static unsigned ParseVoidInit (Type* T) /* Parse an initialization of a void variable (special cc65 extension). ** Return the number of bytes initialized. */ @@ -2181,6 +2182,9 @@ static unsigned ParseVoidInit (void) /* Closing brace */ ConsumeRCurly (); + /* Number of bytes determined by initializer */ + T->A.U = Size; + /* Return the number of bytes initialized */ return Size; } @@ -2216,8 +2220,8 @@ static unsigned ParseInitInternal (Type* T, int AllowFlexibleMembers) case T_VOID: if (IS_Get (&Standard) == STD_CC65) { - /* Special cc65 extension in non ANSI mode */ - return ParseVoidInit (); + /* Special cc65 extension in non-ANSI mode */ + return ParseVoidInit (T); } /* FALLTHROUGH */ diff --git a/test/err/void-empty.c b/test/err/void-empty.c new file mode 100644 index 000000000..900918222 --- /dev/null +++ b/test/err/void-empty.c @@ -0,0 +1,9 @@ +/* + !!DESCRIPTION!! Uninitialized void variables + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +void test; +const void list; diff --git a/test/err/void-size2.c b/test/err/void-size2.c new file mode 100644 index 000000000..3d4f13322 --- /dev/null +++ b/test/err/void-size2.c @@ -0,0 +1,11 @@ +/* + !!DESCRIPTION!! Size of void cast + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +unsigned test (void) +{ + return sizeof ((void)12345); +} diff --git a/test/val/void-size1.c b/test/val/void-size1.c new file mode 100644 index 000000000..0c2dccaa7 --- /dev/null +++ b/test/val/void-size1.c @@ -0,0 +1,56 @@ +/* + !!DESCRIPTION!! Getting the size of a void-type variable (cc65 extension) + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +static const void list1 = { + (char)1, + (char)2, + (char)3, + (char)4, + (char)5, + (char)6, + (char)7, + (char)8, + (char)9, + (char)0 +}; + +static void list2 = { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 0 +}; + +void list3 = { + (char)1, + (char)2, + (char)3, + (char)4, + &list1, + (char)6, + (char)7, + (char)8, + (char)9, + &list2 +}; + +/* We know that the expression is constant; don't tell us. */ + +#pragma warn (const-comparison, off) + +int main (void) +{ + return sizeof list1 != 10 + || sizeof list2 != 20 + || sizeof list3 != 12; +} diff --git a/testcode/lib/atari/displaylist.c b/testcode/lib/atari/displaylist.c index 04c599878..ae1931e64 100644 --- a/testcode/lib/atari/displaylist.c +++ b/testcode/lib/atari/displaylist.c @@ -1,59 +1,55 @@ /* -** testprogram for ANTIC instructions as defined in "_antic.h" +** test program for ANTIC instructions as defined in "_antic.h" ** ** 23-Feb-2017, Christian Krueger */ #include <conio.h> #include <atari.h> -#include <peekpoke.h> -#include <string.h> -// code is only for testing purposes, as screen and display list are not aligned +// code is only for testing purposes, as screen and display list are not aligned, // and jumps not set! unsigned char DummyScreen[400]; void DisplayList = { - DL_BLK1, - DL_BLK2, - DL_BLK3, - DL_BLK4, - DL_BLK5, - DL_BLK6, - DL_BLK7, - DL_DLI(DL_BLK8), - DL_LMS(DL_CHR40x8x1), - DummyScreen, - DL_HSCROL(DL_CHR40x10x1), - DL_VSCROL(DL_CHR40x8x4), - DL_CHR40x16x4, - DL_LMS(DL_HSCROL(DL_VSCROL(DL_DLI(DL_CHR20x8x2)))), - DummyScreen+120, - DL_CHR20x16x2, - DL_MAP40x8x4, - DL_MAP80x4x2, - DL_MAP80x4x4, - DL_MAP160x2x2, - DL_MAP160x1x2, - DL_MAP160x2x4, - DL_MAP160x1x4, - DL_MAP320x1x1, - DL_JVB, - DL_JMP + DL_BLK1, + DL_BLK2, + DL_BLK3, + DL_BLK4, + DL_BLK5, + DL_BLK6, + DL_BLK7, + DL_DLI(DL_BLK8), + DL_LMS(DL_CHR40x8x1), + DummyScreen, + DL_HSCROL(DL_CHR40x10x1), + DL_VSCROL(DL_CHR40x8x4), + DL_CHR40x16x4, + DL_LMS(DL_HSCROL(DL_VSCROL(DL_DLI(DL_CHR20x8x2)))), + DummyScreen+120, + DL_CHR20x16x2, + DL_MAP40x8x4, + DL_MAP80x4x2, + DL_MAP80x4x4, + DL_MAP160x2x2, + DL_MAP160x1x2, + DL_MAP160x2x4, + DL_MAP160x1x4, + DL_MAP320x1x1, + DL_JVB, + DL_JMP }; -unsigned char dlend = 0; +/* We know that the sizeof expression is constant; don't tell us. */ + +#pragma warn (const-comparison, off) int main(void) { - // unfortunately "sizeof()" doesn't work with void data - // (Error: Size of data type is unknown) - // so we trick with the addresses at front and end... - - int returnValue = (((unsigned int)&dlend-(unsigned int)&DisplayList) != 28); // assure only one byte per instruction! + int returnValue = (sizeof DisplayList != 28); // assure only one byte per instruction! clrscr(); if (returnValue) @@ -66,4 +62,3 @@ main(void) return returnValue; } - From 0de44517ac5780b59969dd92ad081d5a68b2dc47 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sun, 12 Mar 2017 23:21:43 +0100 Subject: [PATCH 029/199] few 6502 and some 65SC02 optimizations --- libsrc/runtime/add.s | 59 ++++++++++++++++++++++++--------------- libsrc/runtime/along.s | 17 +++++------ libsrc/runtime/laddeq.s | 12 ++++++-- libsrc/runtime/land.s | 14 +++++++++- libsrc/runtime/leave.s | 19 +++++++++++++ libsrc/runtime/lmod.s | 9 +++++- libsrc/runtime/lmul.s | 15 +++++++++- libsrc/runtime/lor.s | 16 +++++++++-- libsrc/runtime/lpop.s | 6 ++++ libsrc/runtime/lpush.s | 16 +++++++++-- libsrc/runtime/lrsub.s | 19 +++++++++++-- libsrc/runtime/lsave.s | 10 +++---- libsrc/runtime/lsub.s | 9 ++++-- libsrc/runtime/lsubeq.s | 15 +++++++--- libsrc/runtime/ludiv.s | 15 +++++++++- libsrc/runtime/lumod.s | 8 ++++++ libsrc/runtime/lxor.s | 17 +++++++++-- libsrc/runtime/makebool.s | 23 ++++++--------- libsrc/runtime/or.s | 10 ++++++- libsrc/runtime/rsub.s | 12 ++++++-- libsrc/runtime/staxspi.s | 7 +++++ libsrc/runtime/swap.s | 12 +++++++- libsrc/runtime/xor.s | 10 ++++++- 23 files changed, 272 insertions(+), 78 deletions(-) diff --git a/libsrc/runtime/add.s b/libsrc/runtime/add.s index 6fb2dacf7..e644671c0 100644 --- a/libsrc/runtime/add.s +++ b/libsrc/runtime/add.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 05.08.1998 +; Christian Krueger, 11-Mar-2017, spend two bytes for one cycle, improved 65SC02 optimization ; ; CC65 runtime: add ints ; @@ -8,32 +9,46 @@ ; called a lot! .export tosadda0, tosaddax - .importzp sp + .importzp sp, tmp1 .macpack cpu tosadda0: ldx #0 tosaddax: - clc -.if (.cpu .bitand CPU_ISET_65SC02) - adc (sp) ; 65SC02 version - saves 2 cycles - ldy #1 -.else - ldy #0 - adc (sp),y ; lo byte - iny -.endif - pha ; save it - txa - adc (sp),y ; hi byte - tax - clc - lda sp - adc #2 - sta sp - bcc L1 - inc sp+1 -L1: pla ; Restore low byte - rts + clc ; (2) +.if (.cpu .bitand ::CPU_ISET_65SC02) + + adc (sp) ; (7) + tay ; (9) + inc sp ; (14) + bne hiadd ; (17) + inc sp+1 ; (-1+5) +hiadd: txa ; (19) + adc (sp) ; (24) + tax ; (26) + inc sp ; (31) + bne done ; (34) + inc sp+1 ; (-1+5) +done: tya ; (36) + +.else + + ldy #0 ; (4) + adc (sp),y ; (9) lo byte + iny ; (11) + sta tmp1 ; (14) save it + txa ; (16) + adc (sp),y ; (21) hi byte + tax ; (23) + clc ; (25) + lda sp ; (28) + adc #2 ; (30) + sta sp ; (33) + bcc L1 ; (36) + inc sp+1 ; (-1+5) +L1: lda tmp1 ; (39) restore low byte + +.endif + rts ; (6502: 45 cycles, 26 bytes <-> 65SC02: 42 cycles, 22 bytes ) diff --git a/libsrc/runtime/along.s b/libsrc/runtime/along.s index 661b3124a..25eb78c45 100644 --- a/libsrc/runtime/along.s +++ b/libsrc/runtime/along.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 23.11.2002 +; Christian Krueger, 11-Mar-2017, saved 5 bytes ; ; CC65 runtime: Convert char in ax into a long ; @@ -9,16 +10,12 @@ ; Convert A from char to long in EAX +along: ldx #$ff + cmp #$80 ; Positive? + bcs store ; no, apply $FF + aulong: ldx #0 - stx sreg +store: stx sreg stx sreg+1 rts - -along: cmp #$80 ; Positive? - bcc aulong ; Yes, handle like unsigned type - ldx #$ff - stx sreg - stx sreg+1 - rts - - + \ No newline at end of file diff --git a/libsrc/runtime/laddeq.s b/libsrc/runtime/laddeq.s index 2632ec909..57bec0629 100644 --- a/libsrc/runtime/laddeq.s +++ b/libsrc/runtime/laddeq.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 07.04.2000 +; Christian Krueger, 12-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: += operator ; @@ -10,6 +11,7 @@ .export laddeq1, laddeqa, laddeq .importzp sreg, ptr1, tmp1 + .macpack cpu laddeq1: lda #$01 @@ -20,14 +22,20 @@ laddeqa: stx sreg+1 laddeq: sty ptr1+1 ; Store high byte of address - ldy #$00 ; Address low byte clc +.if (.cpu .bitand ::CPU_ISET_65SC02) + adc (ptr1) + sta (ptr1) + ldy #$01 ; Address byte 1 +.else + ldy #$00 ; Address low byte adc (ptr1),y sta (ptr1),y + iny ; Address byte 1 +.endif pha ; Save byte 0 of result for later - iny ; Address byte 1 txa adc (ptr1),y ; Load byte 1 sta (ptr1),y diff --git a/libsrc/runtime/land.s b/libsrc/runtime/land.s index 506c071a4..6ea4e5bcb 100644 --- a/libsrc/runtime/land.s +++ b/libsrc/runtime/land.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 06.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: and on longs ; @@ -8,17 +9,28 @@ .import addysp1 .importzp sp, sreg, tmp1 + .macpack cpu tosand0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif tosandeax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + and (sp) ; byte 0 + ldy #1 +.else ldy #0 and (sp),y ; byte 0 - sta tmp1 iny +.endif + sta tmp1 txa and (sp),y ; byte 1 tax diff --git a/libsrc/runtime/leave.s b/libsrc/runtime/leave.s index 8f4e055f5..4a9ff7994 100644 --- a/libsrc/runtime/leave.s +++ b/libsrc/runtime/leave.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 06.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: function epilogue ; @@ -13,6 +14,8 @@ .import addysp .importzp sp + .macpack cpu + leave00: lda #0 leave0: ldx #0 @@ -24,6 +27,20 @@ leavey0: ldx #0 ; return < 256 leavey: jsr addysp ; drop stack frame + +.if (.cpu .bitand ::CPU_ISET_65SC02) + +leave: tay ; save A a sec + lda (sp) ; that's the pushed arg size + sec ; Count the byte, the count's stored in + adc sp + sta sp + bcc L1 + inc sp+1 +L1: tya ; Get return value back + +.else + leave: pha ; save A a sec ldy #0 lda (sp),y ; that's the pushed arg size @@ -33,5 +50,7 @@ leave: pha ; save A a sec bcc L1 inc sp+1 L1: pla ; Get return value back + +.endif rts diff --git a/libsrc/runtime/lmod.s b/libsrc/runtime/lmod.s index 74deb23f0..caeb0c4f6 100644 --- a/libsrc/runtime/lmod.s +++ b/libsrc/runtime/lmod.s @@ -1,6 +1,6 @@ ; ; Ullrich von Bassewitz, 07.08.1998 -; +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; CC65 runtime: modulo operation for long signed ints ; @@ -11,10 +11,17 @@ .import poplsargs, udiv32, negeax .importzp sreg, ptr1, ptr2, tmp1, tmp3, tmp4 + .macpack cpu + tosmod0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif tosmodeax: jsr poplsargs ; Get arguments from stack, adjust sign diff --git a/libsrc/runtime/lmul.s b/libsrc/runtime/lmul.s index 7ad2b2aa4..860d58cba 100644 --- a/libsrc/runtime/lmul.s +++ b/libsrc/runtime/lmul.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 13.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: multiplication for long (unsigned) ints ; @@ -8,20 +9,32 @@ .import addysp1 .importzp sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4 + .macpack cpu + tosmul0ax: tosumul0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif tosmuleax: tosumuleax: mul32: sta ptr1 stx ptr1+1 ; op2 now in ptr1/sreg +.if (.cpu .bitand ::CPU_ISET_65SC02) + lda (sp) + ldy #1 +.else ldy #0 lda (sp),y - sta ptr3 iny +.endif + sta ptr3 lda (sp),y sta ptr3+1 iny diff --git a/libsrc/runtime/lor.s b/libsrc/runtime/lor.s index a74b33059..94ab3c890 100644 --- a/libsrc/runtime/lor.s +++ b/libsrc/runtime/lor.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 06.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: or on longs ; @@ -8,17 +9,28 @@ .import addysp1 .importzp sp, sreg, tmp1 + .macpack cpu tosor0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg - sty sreg+1 + sty sreg+1 +.endif tosoreax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + ora (sp) + ldy #1 +.else ldy #0 ora (sp),y ; byte 0 - sta tmp1 iny +.endif + sta tmp1 txa ora (sp),y ; byte 1 tax diff --git a/libsrc/runtime/lpop.s b/libsrc/runtime/lpop.s index 7d281db52..ffff5ffc1 100644 --- a/libsrc/runtime/lpop.s +++ b/libsrc/runtime/lpop.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 29.12.1999 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: long pop ; @@ -8,6 +9,7 @@ .import incsp4 .importzp sp, sreg + .macpack cpu popeax: ldy #3 lda (sp),y @@ -18,8 +20,12 @@ popeax: ldy #3 dey lda (sp),y tax +.if (.cpu .bitand ::CPU_ISET_65SC02) + lda (sp) +.else dey lda (sp),y +.endif jmp incsp4 diff --git a/libsrc/runtime/lpush.s b/libsrc/runtime/lpush.s index 074b4320a..4fed77f05 100644 --- a/libsrc/runtime/lpush.s +++ b/libsrc/runtime/lpush.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 06.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: long push ; @@ -11,13 +12,20 @@ .import decsp4 .importzp sp, sreg + .macpack cpu + pushl0: lda #0 tax push0ax: - ldy #0 +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else + ldy #$00 sty sreg sty sreg+1 +.endif pusheax: pha ; decsp will destroy A (but not X) jsr decsp4 @@ -30,8 +38,12 @@ pusheax: dey txa sta (sp),y - dey pla +.if (.cpu .bitand ::CPU_ISET_65SC02) + sta (sp) +.else + dey sta (sp),y +.endif rts diff --git a/libsrc/runtime/lrsub.s b/libsrc/runtime/lrsub.s index fd519ca4f..928164f40 100644 --- a/libsrc/runtime/lrsub.s +++ b/libsrc/runtime/lrsub.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 05.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: long sub reversed ; @@ -11,18 +12,30 @@ .import addysp1 .importzp sp, sreg, tmp1 + .macpack cpu + tosrsub0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif -tosrsubeax: - ldy #0 +tosrsubeax: sec +.if (.cpu .bitand ::CPU_ISET_65SC02) + sbc (sp) + ldy #1 +.else + ldy #0 sbc (sp),y ; byte 0 + iny +.endif sta tmp1 ; use as temp storage txa - iny sbc (sp),y ; byte 1 tax iny diff --git a/libsrc/runtime/lsave.s b/libsrc/runtime/lsave.s index fa21e463e..82703073a 100644 --- a/libsrc/runtime/lsave.s +++ b/libsrc/runtime/lsave.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 08.08.1998 +; Christian Krueger, 11-Mar-2017, optimization ; ; CC65 runtime: save ax into temp storage/restore ax from temp storage ; @@ -10,11 +11,10 @@ saveeax: sta regsave stx regsave+1 - lda sreg - sta regsave+2 - lda sreg+1 - sta regsave+3 - lda regsave + ldy sreg + sty regsave+2 + ldy sreg+1 + sty regsave+3 rts resteax: diff --git a/libsrc/runtime/lsub.s b/libsrc/runtime/lsub.s index 926d52e51..6f80491ca 100644 --- a/libsrc/runtime/lsub.s +++ b/libsrc/runtime/lsub.s @@ -1,6 +1,6 @@ ; ; Ullrich von Bassewitz, 05.08.1998 -; +; Christian Krueger, 11-Mar-2017, ímproved 65SC02 optimization ; CC65 runtime: long sub ; @@ -14,14 +14,19 @@ .macpack cpu tossub0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif tossubeax: sec eor #$FF -.if (.cpu .bitand CPU_ISET_65SC02) +.if (.cpu .bitand ::CPU_ISET_65SC02) adc (sp) ; 65SC02 version - saves 2 cycles ldy #1 .else diff --git a/libsrc/runtime/lsubeq.s b/libsrc/runtime/lsubeq.s index 9f5853d29..5e3d25783 100644 --- a/libsrc/runtime/lsubeq.s +++ b/libsrc/runtime/lsubeq.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 07.04.2000 +; Christian Krueger, 12-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: -= operator ; @@ -10,6 +11,7 @@ .export lsubeq1, lsubeqa, lsubeq .importzp sreg, ptr1 + .macpack cpu lsubeq1: lda #$01 @@ -20,15 +22,20 @@ lsubeqa: stx sreg+1 lsubeq: sty ptr1+1 ; Store high byte of address - ldy #$00 ; Address low byte + sec - eor #$FF + .if (.cpu .bitand ::CPU_ISET_65SC02) + adc (ptr1) ; Subtract byte 0 + sta (ptr1) + ldy #$01 ; Address byte 1 + .else + ldy #$00 ; Address low byte adc (ptr1),y ; Subtract byte 0 sta (ptr1),y + iny ; Address byte 1 + .endif pha ; Save byte 0 of result for later - - iny ; Address byte 1 txa eor #$FF adc (ptr1),y ; Subtract byte 1 diff --git a/libsrc/runtime/ludiv.s b/libsrc/runtime/ludiv.s index 149c98a78..54af4780e 100644 --- a/libsrc/runtime/ludiv.s +++ b/libsrc/runtime/ludiv.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 17.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: division for long unsigned ints ; @@ -8,10 +9,17 @@ .import addysp1 .importzp sp, sreg, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 + .macpack cpu + tosudiv0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif tosudiveax: jsr getlop ; Get the paramameters @@ -30,10 +38,15 @@ getlop: sta ptr3 ; Put right operand in place lda sreg+1 sta ptr4+1 +.if (.cpu .bitand ::CPU_ISET_65SC02) + lda (sp) + ldy #1 +.else ldy #0 ; Put left operand in place lda (sp),y - sta ptr1 iny +.endif + sta ptr1 lda (sp),y sta ptr1+1 iny diff --git a/libsrc/runtime/lumod.s b/libsrc/runtime/lumod.s index e290e1167..241801a90 100644 --- a/libsrc/runtime/lumod.s +++ b/libsrc/runtime/lumod.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 27.09.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: modulo operation for long unsigned ints ; @@ -8,10 +9,17 @@ .import getlop, udiv32 .importzp sreg, tmp3, tmp4, ptr2 + .macpack cpu + tosumod0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif tosumodeax: jsr getlop ; Get the paramameters diff --git a/libsrc/runtime/lxor.s b/libsrc/runtime/lxor.s index ce21ef35b..4ec9a4129 100644 --- a/libsrc/runtime/lxor.s +++ b/libsrc/runtime/lxor.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 06.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: xor on longs ; @@ -8,16 +9,28 @@ .import addysp1 .importzp sp, sreg, tmp1 + .macpack cpu + tosxor0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif -tosxoreax: +tosxoreax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + eor (sp) ; byte 0 + ldy #1 +.else ldy #0 eor (sp),y ; byte 0 - sta tmp1 iny +.endif + sta tmp1 txa eor (sp),y ; byte 1 tax diff --git a/libsrc/runtime/makebool.s b/libsrc/runtime/makebool.s index a15b24b93..643f418aa 100644 --- a/libsrc/runtime/makebool.s +++ b/libsrc/runtime/makebool.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 05.10.1998 +; Christian Krueger, 11-Mar-2017, optimization ; ; CC65 runtime: Make boolean according to flags ; @@ -9,14 +10,14 @@ boolne: bne ret1 - ldx #$00 +ret0: ldx #$00 txa rts -booleq: beq ret1 - ldx #$00 - txa +booleq: bne ret0 +ret1: ldx #$00 + lda #$01 rts @@ -44,17 +45,9 @@ boolult: boolugt: - beq L1 + beq ret0 booluge: - bcs ret1 -L1: ldx #$00 + ldx #$00 txa + rol a rts - - -ret1: ldx #$00 - lda #$01 - rts - - - diff --git a/libsrc/runtime/or.s b/libsrc/runtime/or.s index 8570c0cd7..1c2c4125e 100644 --- a/libsrc/runtime/or.s +++ b/libsrc/runtime/or.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 05.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: or on ints ; @@ -8,13 +9,20 @@ .import addysp1 .importzp sp, tmp1 + .macpack cpu + tosora0: ldx #$00 tosorax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + ora (sp) + ldy #1 +.else ldy #0 ora (sp),y - sta tmp1 iny +.endif + sta tmp1 txa ora (sp),y tax diff --git a/libsrc/runtime/rsub.s b/libsrc/runtime/rsub.s index 475a69e76..69ee6da22 100644 --- a/libsrc/runtime/rsub.s +++ b/libsrc/runtime/rsub.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 05.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: sub ints reversed ; @@ -8,6 +9,8 @@ .import addysp1 .importzp sp, tmp1 + .macpack cpu + ; ; AX = AX - TOS ; @@ -15,12 +18,17 @@ tosrsuba0: ldx #0 tosrsubax: - ldy #0 sec +.if (.cpu .bitand CPU_ISET_65SC02) + sbc (sp) + ldy #1 +.else + ldy #0 sbc (sp),y ; lo byte + iny +.endif sta tmp1 ; save lo byte txa - iny sbc (sp),y ; hi byte tax lda tmp1 diff --git a/libsrc/runtime/staxspi.s b/libsrc/runtime/staxspi.s index 90738e0d2..3114f449c 100644 --- a/libsrc/runtime/staxspi.s +++ b/libsrc/runtime/staxspi.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 26.10.2000 +; Christian Krueger, 12-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: Store a/x indirect into address at top of stack with index ; @@ -8,6 +9,8 @@ .import incsp2 .importzp sp, tmp1, ptr1 + .macpack cpu + .proc staxspidx sty tmp1 ; Save Y @@ -15,8 +18,12 @@ ldy #1 lda (sp),y sta ptr1+1 +.if (.cpu .bitand ::CPU_ISET_65SC02) + lda (sp) +.else dey lda (sp),y +.endif sta ptr1 ; Address now in ptr1 ldy tmp1 ; Restore Y iny ; Address high byte diff --git a/libsrc/runtime/swap.s b/libsrc/runtime/swap.s index e91eeca31..d4a74df5f 100644 --- a/libsrc/runtime/swap.s +++ b/libsrc/runtime/swap.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 06.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: swap ax with TOS ; @@ -7,6 +8,8 @@ .export swapstk .importzp sp, ptr4 + .macpack cpu + swapstk: sta ptr4 stx ptr4+1 @@ -15,11 +18,18 @@ swapstk: tax lda ptr4+1 sta (sp),y +.if (.cpu .bitand ::CPU_ISET_65SC02) + lda (sp) + tay + lda ptr4 + sta (sp) + tya +.else dey lda (sp),y pha lda ptr4 sta (sp),y pla +.endif rts ; whew! - diff --git a/libsrc/runtime/xor.s b/libsrc/runtime/xor.s index 825c576d1..e03922926 100644 --- a/libsrc/runtime/xor.s +++ b/libsrc/runtime/xor.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 05.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: xor on ints ; @@ -8,13 +9,20 @@ .import addysp1 .importzp sp, tmp1 + .macpack cpu + tosxora0: ldx #$00 tosxorax: +.if (.cpu .bitand CPU_ISET_65SC02) + eor (sp) + ldy #1 +.else ldy #0 eor (sp),y - sta tmp1 iny +.endif + sta tmp1 txa eor (sp),y tax From a3d8829be92032d262cbea686c400a098e9e5242 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Fri, 17 Mar 2017 21:42:51 +0100 Subject: [PATCH 030/199] Creativison changes. This change includes some cleanups, removal of mainargs.s (game console programs never have arguments), and a workaround for a problem I'm seeing. The problem is that sometimes (in fact, more often than not) the clrscr() call in testcode/lib/joy-test.c writes some garbage chars on the screen (most often a "P"). Could be my hardware (I haven't seen it on MAME), but to me the root cause is still unknown. --- asminc/creativision.inc | 7 ++++--- cfg/creativision.cfg | 2 +- libsrc/creativision/clrscr.s | 6 +++--- libsrc/creativision/cputc.s | 6 +++--- libsrc/creativision/crt0.s | 15 ++++++++++----- libsrc/creativision/mainargs.s | 22 ---------------------- 6 files changed, 21 insertions(+), 37 deletions(-) delete mode 100644 libsrc/creativision/mainargs.s diff --git a/asminc/creativision.inc b/asminc/creativision.inc index 83a63ba07..49d55a342 100644 --- a/asminc/creativision.inc +++ b/asminc/creativision.inc @@ -10,10 +10,10 @@ CURSOR_X = $3C CURSOR_Y = $3D ;** VDP -VDP_CONTROL_W = $3001 -VDP_DATA_W = $3000 -VDP_STATUS_R = $2001 VDP_DATA_R = $2000 +VDP_STATUS_R = $2001 +VDP_DATA_W = $3000 +VDP_CONTROL_W = $3001 ;** PIA PIA0_DATA = $1000 @@ -58,3 +58,4 @@ JOY_NNW = $4A BIOS_IRQ1_ADDR = $FF3F BIOS_IRQ2_ADDR = $FF52 BIOS_NMI_RESET_ADDR = $F808 +BIOS_WRITE_VDP_REG = $FE1F diff --git a/cfg/creativision.cfg b/cfg/creativision.cfg index 06e39b36f..9e4ecd8ce 100644 --- a/cfg/creativision.cfg +++ b/cfg/creativision.cfg @@ -4,7 +4,7 @@ SYMBOLS { MEMORY { ZP: file = "", define = yes, start = $0020, size = $00E0; RAM: file = "", define = yes, start = $01FA, size = $0206; - ROM: file = %O, define = yes, start = $B000, size = $1000; + ROM: file = %O, define = yes, start = $B000, size = $1000, fill = yes, fillval = $FF; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; diff --git a/libsrc/creativision/clrscr.s b/libsrc/creativision/clrscr.s index 9e7238345..3c4856446 100644 --- a/libsrc/creativision/clrscr.s +++ b/libsrc/creativision/clrscr.s @@ -18,7 +18,7 @@ _clrscr: lda #$50 ; VRAM offset high ($10 OR $40) sta VDP_CONTROL_W - lda #$C0 ; Space from ROM setup + lda #$40 ; Space char from ROM setup ldx #0 ldy #3 @@ -34,8 +34,8 @@ L1: sta VDP_DATA_W lda #0 sta CURSOR_X sta CURSOR_Y - sta <SCREEN_PTR + sta SCREEN_PTR lda #$10 - sta >SCREEN_PTR + sta SCREEN_PTR+1 rts diff --git a/libsrc/creativision/cputc.s b/libsrc/creativision/cputc.s index ff60494b9..437b738b2 100644 --- a/libsrc/creativision/cputc.s +++ b/libsrc/creativision/cputc.s @@ -96,8 +96,8 @@ BAD_CHAR: jmp plot ;----------------------------------------------------------------------------- -; Initialize the conio subsystem. Code goes into the INIT segment, which may -; be reused after startup. +; Initialize the conio subsystem. "INIT" segment is nothing special on the +; Creativision, it is part of the "ROM" memory. .segment "INIT" @@ -122,4 +122,4 @@ LL: lda boxchars,x bne LL cli - jmp plot + jmp plot diff --git a/libsrc/creativision/crt0.s b/libsrc/creativision/crt0.s index 420ac71ef..5185ff237 100644 --- a/libsrc/creativision/crt0.s +++ b/libsrc/creativision/crt0.s @@ -31,9 +31,6 @@ entry: ldx #<__RAM_START__ - 1 txs - ; Start interrupts - cli - ; Clear the BSS data jsr zerobss @@ -49,13 +46,21 @@ entry: ; Call module constructors jsr initlib + ; enable vertical blank interrupts in the display controller + lda #$E0 ; 16K RAM, Active Display, Mode 1, VBI enabled + ldx #$01 ; Register 1 + jsr BIOS_WRITE_VDP_REG + + ; Start interrupts + cli + ; Call main() jsr callmain ; Call module destructors. This is also the _exit entry. _exit: jsr donelib - ; TODO: Replace with some sort of reset + ; A Creativision program isn't supposed to exit. loop: jmp loop ; ------------------------------------------------------------------------ @@ -81,7 +86,7 @@ irq2: jmp BIOS_IRQ2_ADDR ; VDP Setup ; This sets to Graphics Mode 1 .byte $00 ; Register 0 - .byte $E0 ; Register 1 16K RAM, Active Display, Mode 1, VBI enabled + .byte $C0 ; Register 1 16K RAM, Active Display, Mode 1, VBI disabled .byte $04 ; Register 2 Name Table at $1000 - $12FF .byte $60 ; Register 3 Colour Table at $1800 - $181F .byte $00 ; Register 4 Pattern Table at $0000 - $07FF diff --git a/libsrc/creativision/mainargs.s b/libsrc/creativision/mainargs.s deleted file mode 100644 index cda76d8d0..000000000 --- a/libsrc/creativision/mainargs.s +++ /dev/null @@ -1,22 +0,0 @@ -; -; Ullrich von Bassewitz, 2003-03-07 -; -; Setup arguments for main -; - - - .constructor initmainargs, 24 - .import __argc, __argv - - -;--------------------------------------------------------------------------- -; Get possible command-line arguments. Goes into the special INIT segment, -; which may be reused after the startup code is run - -.segment "INIT" - -.proc initmainargs - - rts - -.endproc From 360372420bf1592345a0f8977924ce88102d00ec Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 18 Mar 2017 16:33:08 +0100 Subject: [PATCH 031/199] Added 65SC02 support for simulator. --- src/sim65/6502.c | 662 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 546 insertions(+), 116 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index e6f358295..b6559ee46 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -11,6 +11,7 @@ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ +/* Mar-2017, Christian Krueger, added support for 65SC02 */ /* */ /* This software is provided 'as-is', without any expressed or implied */ /* warranty. In no event will the authors be held liable for any damages */ @@ -31,7 +32,14 @@ /* */ /*****************************************************************************/ - +/* Known bugs and limitations of the 65C02 simulation: + * support currently only on the level of 65SC02: + BBRx, BBSx, RMBx, SMBx, WAI and STP are unsupported + * BCD flag handling equals 6502 (unchecked if bug is simulated or wrong for + 6502) + * one cycle win for fetch-modify-write instructions ignored + (e.g. ROL abs,x takes only 6 cycles if no page break occurs) + */ #include "memory.h" #include "error.h" @@ -205,7 +213,22 @@ int PrintCycles; unsigned Addr; \ Cycles = 5; \ ZPAddr = MemReadByte (Regs.PC+1); \ - Addr = MemReadZPWord (ZPAddr) + Regs.YR; \ + Addr = MemReadZPWord (ZPAddr); \ + if (PAGE_CROSS (Addr, Regs.YR)) \ + ++Cycles; \ + Addr += Regs.YR; \ + Regs.AC = Regs.AC op MemReadByte (Addr); \ + TEST_ZF (Regs.AC); \ + TEST_SF (Regs.AC); \ + Regs.PC += 2 + +/* (zp) */ +#define AC_OP_ZPIND(op) \ + unsigned char ZPAddr; \ + unsigned Addr; \ + Cycles = 5; \ + ZPAddr = MemReadByte (Regs.PC+1); \ + Addr = MemReadZPWord (ZPAddr); \ Regs.AC = Regs.AC op MemReadByte (Addr); \ TEST_ZF (Regs.AC); \ TEST_SF (Regs.AC); \ @@ -234,6 +257,8 @@ int PrintCycles; } \ TEST_CF (Regs.AC); \ SET_OF ((res < -128) || (res > 127)); \ + if (CPU!=CPU_6502) \ + ++Cycles; \ } else { \ Regs.AC += rhs + GET_CF (); \ TEST_ZF (Regs.AC); \ @@ -313,6 +338,8 @@ int PrintCycles; TEST_SF (res); \ SET_CF (res <= 0xFF); \ SET_OF (((old^rhs) & (old^res) & 0x80)); \ + if (CPU!=CPU_6502) \ + ++Cycles; \ } else { \ Regs.AC -= rhs + (!GET_CF ()); \ TEST_ZF (Regs.AC); \ @@ -362,6 +389,21 @@ static void OPC_6502_01 (void) +static void OPC_65SC02_04 (void) +/* Opcode $04: TSB zp */ +{ + unsigned char ZPAddr; + unsigned char Val; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Val = MemReadByte (ZPAddr); + SET_ZF ((Val & Regs.AC) == 0); + MemWriteByte (ZPAddr, (unsigned char)(Val | Regs.AC)); + Regs.PC += 2; +} + + + static void OPC_6502_05 (void) /* Opcode $05: ORA zp */ { @@ -419,6 +461,21 @@ static void OPC_6502_0A (void) +static void OPC_65SC02_0C (void) +/* Opcode $0C: TSB abs */ +{ + unsigned Addr; + unsigned char Val; + Cycles = 6; + Addr = MemReadByte (Regs.PC+1); + Val = MemReadByte (Addr); + SET_ZF ((Val & Regs.AC) == 0); + MemWriteByte (Addr, (unsigned char) (Val | Regs.AC)); + Regs.PC += 3; +} + + + static void OPC_6502_0D (void) /* Opcode $0D: ORA abs */ { @@ -460,6 +517,29 @@ static void OPC_6502_11 (void) +static void OPC_65SC02_12 (void) +/* Opcode $12: ORA (zp) */ +{ + AC_OP_ZPIND (|); +} + + + +static void OPC_65SC02_14 (void) +/* Opcode $14: TRB zp */ +{ + unsigned char ZPAddr; + unsigned char Val; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Val = MemReadByte (ZPAddr); + SET_ZF ((Val & Regs.AC) == 0); + MemWriteByte (ZPAddr, (unsigned char)(Val & ~Regs.AC)); + Regs.PC += 2; +} + + + static void OPC_6502_15 (void) /* Opcode $15: ORA zp,x */ { @@ -503,6 +583,33 @@ static void OPC_6502_19 (void) +static void OPC_65SC02_1A (void) +/* Opcode $1A: INC a */ +{ + Cycles = 2; + Regs.AC = (Regs.AC + 1) & 0xFF; + TEST_ZF (Regs.AC); + TEST_SF (Regs.AC); + Regs.PC += 1; +} + + + +static void OPC_65SC02_1C (void) +/* Opcode $1C: TRB abs */ +{ + unsigned Addr; + unsigned char Val; + Cycles = 6; + Addr = MemReadByte (Regs.PC+1); + Val = MemReadByte (Addr); + SET_ZF ((Val & Regs.AC) == 0); + MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC)); + Regs.PC += 3; +} + + + static void OPC_6502_1D (void) /* Opcode $1D: ORA abs,x */ { @@ -675,6 +782,30 @@ static void OPC_6502_31 (void) +static void OPC_65SC02_32 (void) +/* Opcode $32: AND (zp) */ +{ + AC_OP_ZPIND (&); +} + + + +static void OPC_65SC02_34 (void) +/* Opcode $34: BIT zp,x */ +{ + unsigned char ZPAddr; + unsigned char Val; + Cycles = 4; + ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; + Val = MemReadByte (ZPAddr); + SET_SF (Val & 0x80); + SET_OF (Val & 0x40); + SET_ZF ((Val & Regs.AC) == 0); + Regs.PC += 2; +} + + + static void OPC_6502_35 (void) /* Opcode $35: AND zp,x */ { @@ -716,6 +847,36 @@ static void OPC_6502_39 (void) +static void OPC_65SC02_3A (void) +/* Opcode $3A: DEC a */ +{ + Cycles = 2; + Regs.AC = (Regs.AC - 1) & 0xFF; + TEST_ZF (Regs.AC); + TEST_SF (Regs.AC); + Regs.PC += 1; +} + + + +static void OPC_65SC02_3C (void) +/* Opcode $3C: BIT abs,x */ +{ + unsigned Addr; + unsigned char Val; + Cycles = 4; + Addr = MemReadByte (Regs.PC+1) + if (PAGE_CROSS (Addr, Regs.XR)) + ++Cycles; + Val = MemReadByte (Addr + Regs.XR;); + SET_SF (Val & 0x80); + SET_OF (Val & 0x40); + SET_ZF ((Val & Regs.AC) == 0); + Regs.PC += 3; +} + + + static void OPC_6502_3D (void) /* Opcode $3D: AND abs,x */ { @@ -758,6 +919,15 @@ static void OPC_6502_41 (void) +static void OPC_65C02_44 (void) +/* Opcode $44: 'zp' 3 cycle NOP */ +{ + Cycles = 3; + Regs.PC += 2; +} + + + static void OPC_6502_45 (void) /* Opcode $45: EOR zp */ { @@ -868,6 +1038,14 @@ static void OPC_6502_51 (void) +static void OPC_65SC02_52 (void) +/* Opcode $52: EOR (zp) */ +{ + AC_OP_ZPIND (^); +} + + + static void OPC_6502_55 (void) /* Opcode $55: EOR zp,x */ { @@ -912,6 +1090,25 @@ static void OPC_6502_59 (void) +static void OPC_65SC02_5A (void) +/* Opcode $5A: PHY */ +{ + Cycles = 3; + PUSH (Regs.YR); + Regs.PC += 1; +} + + + +static void OPC_65C02_5C (void) +/* Opcode $5C: 'Absolute' 8 cycle NOP */ +{ + Cycles = 8; + Regs.PC += 3; +} + + + static void OPC_6502_5D (void) /* Opcode $5D: EOR abs,x */ { @@ -963,6 +1160,18 @@ static void OPC_6502_61 (void) +static void OPC_65SC02_64 (void) +/* Opcode $64: STZ zp */ +{ + unsigned char ZPAddr; + Cycles = 3; + ZPAddr = MemReadByte (Regs.PC+1); + MemWriteByte (ZPAddr, 0); + Regs.PC += 2; +} + + + static void OPC_6502_65 (void) /* Opcode $65: ADC zp */ { @@ -1026,19 +1235,28 @@ static void OPC_6502_6C (void) /* Opcode $6C: JMP (ind) */ { unsigned PC, Lo, Hi; - Cycles = 5; PC = Regs.PC; Lo = MemReadWord (PC+1); - /* Emulate the 6502 bug */ - Regs.PC = MemReadByte (Lo); - Hi = (Lo & 0xFF00) | ((Lo + 1) & 0xFF); - Regs.PC |= (MemReadByte (Hi) << 8); + if (CPU==CPU_6502) + { + /* Emulate the 6502 bug */ + Cycles = 5; + Regs.PC = MemReadByte (Lo); + Hi = (Lo & 0xFF00) | ((Lo + 1) & 0xFF); + Regs.PC |= (MemReadByte (Hi) << 8); - /* Output a warning if the bug is triggered */ - if (Hi != Lo + 1) { - Warning ("6502 indirect jump bug triggered at $%04X, ind addr = $%04X", - PC, Lo); + /* Output a warning if the bug is triggered */ + if (Hi != Lo + 1) + { + Warning ("6502 indirect jump bug triggered at $%04X, ind addr = $%04X", + PC, Lo); + } + } + else + { + Cycles = 6; + Regs.PC = MemReadWord(Lo); } } @@ -1106,6 +1324,32 @@ static void OPC_6502_71 (void) +static void OPC_65SC02_72 (void) +/* Opcode $72: ADC (zp) */ +{ + unsigned char ZPAddr; + unsigned Addr; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Addr = MemReadZPWord (ZPAddr); + ADC (MemReadByte (Addr)); + Regs.PC += 2; +} + + + +static void OPC_65SC02_74 (void) +/* Opcode $74: STZ zp,x */ +{ + unsigned char ZPAddr; + Cycles = 4; + ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; + MemWriteByte (ZPAddr, 0); + Regs.PC += 2; +} + + + static void OPC_6502_75 (void) /* Opcode $75: ADC zp,x */ { @@ -1158,6 +1402,30 @@ static void OPC_6502_79 (void) +static void OPC_65SC02_7A (void) +/* Opcode $7A: PLY */ +{ + Cycles = 4; + Regs.YR = POP (); + TEST_ZF (Regs.YR); + TEST_SF (Regs.YR); + Regs.PC += 1; +} + + + +static void OPC_65SC02_7C (void) +/* Opcode $7C: JMP (ind,X) */ +{ + unsigned PC, Adr; + Cycles = 6; + PC = Regs.PC; + Adr = MemReadWord (PC+1); + Regs.PC = MemReadWord(Adr+Regs.XR); +} + + + static void OPC_6502_7D (void) /* Opcode $7D: ADC abs,x */ { @@ -1188,6 +1456,14 @@ static void OPC_6502_7E (void) +static void OPC_65SC02_80 (void) +/* Opcode $80: BRA */ +{ + BRANCH (1); +} + + + static void OPC_6502_81 (void) /* Opcode $81: STA (zp,x) */ { @@ -1250,6 +1526,20 @@ static void OPC_6502_88 (void) +static void OPC_65SC02_89 (void) +/* Opcode $89: BIT #imm */ +{ + unsigned char Val; + Cycles = 2; + Val = MemReadByte (Regs.PC+1); + SET_SF (Val & 0x80); + SET_OF (Val & 0x40); + SET_ZF ((Val & Regs.AC) == 0); + Regs.PC += 2; +} + + + static void OPC_6502_8A (void) /* Opcode $8A: TXA */ { @@ -1320,6 +1610,20 @@ static void OPC_6502_91 (void) +static void OPC_65SC02_92 (void) +/* Opcode $92: sta (zp) */ +{ + unsigned char ZPAddr; + unsigned Addr; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Addr = MemReadZPWord (ZPAddr); + MemWriteByte (Addr, Regs.AC); + Regs.PC += 2; +} + + + static void OPC_6502_94 (void) /* Opcode $94: STY zp,x */ { @@ -1390,6 +1694,18 @@ static void OPC_6502_9A (void) +static void OPC_65SC02_9C (void) +/* Opcode $9C: STZ abs */ +{ + unsigned Addr; + Cycles = 4; + Addr = MemReadWord (Regs.PC+1); + MemWriteByte (Addr, 0); + Regs.PC += 3; +} + + + static void OPC_6502_9D (void) /* Opcode $9D: STA abs,x */ { @@ -1402,6 +1718,18 @@ static void OPC_6502_9D (void) +static void OPC_65SC02_9E (void) +/* Opcode $9E: STZ abs,x */ +{ + unsigned Addr; + Cycles = 5; + Addr = MemReadWord (Regs.PC+1) + Regs.XR; + MemWriteByte (Addr, 0); + Regs.PC += 3; +} + + + static void OPC_6502_A0 (void) /* Opcode $A0: LDY #imm */ { @@ -1589,6 +1917,22 @@ static void OPC_6502_B1 (void) +static void OPC_65SC02_B2 (void) +/* Opcode $B2: LDA (zp) */ +{ + unsigned char ZPAddr; + unsigned Addr; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Addr = MemReadZPWord (ZPAddr); + Regs.AC = MemReadByte (Addr); + TEST_ZF (Regs.AC); + TEST_SF (Regs.AC); + Regs.PC += 2; +} + + + static void OPC_6502_B4 (void) /* Opcode $B4: LDY zp,x */ { @@ -1884,6 +2228,20 @@ static void OPC_6502_D1 (void) +static void OPC_65SC02_D2 (void) +/* Opcode $D2: CMP (zp) */ +{ + unsigned ZPAddr; + unsigned Addr; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Addr = MemReadWord (ZPAddr); + CMP (Regs.AC, MemReadByte (Addr)); + Regs.PC += 2; +} + + + static void OPC_6502_D5 (void) /* Opcode $D5: CMP zp,x */ { @@ -1937,6 +2295,16 @@ static void OPC_6502_D9 (void) +static void OPC_65SC02_DA (void) +/* Opcode $DA: PHX */ +{ + Cycles = 3; + PUSH (Regs.XR); + Regs.PC += 1; +} + + + static void OPC_6502_DD (void) /* Opcode $DD: CMP abs,x */ { @@ -2064,6 +2432,42 @@ static void OPC_6502_EA (void) +static void OPC_65C02_NOP11(void) +/* Opcode 'Illegal' 1 cycle NOP */ +{ + Cycles = 1; + Regs.PC += 1; +} + + + +static void OPC_65C02_NOP22 (void) +/* Opcode 'Illegal' 2 byte 2 cycle NOP */ +{ + Cycles = 2; + Regs.PC += 2; +} + + + +static void OPC_65C02_NOP24 (void) +/* Opcode 'Illegal' 2 byte 4 cycle NOP */ +{ + Cycles = 4; + Regs.PC += 2; +} + + + +static void OPC_65C02_NOP34 (void) +/* Opcode 'Illegal' 3 byte 4 cycle NOP */ +{ + Cycles = 4; + Regs.PC += 3; +} + + + static void OPC_6502_EC (void) /* Opcode $EC: CPX abs */ { @@ -2129,6 +2533,20 @@ static void OPC_6502_F1 (void) +static void OPC_65SC02_F2 (void) +/* Opcode $F2: SBC (zp) */ +{ + unsigned char ZPAddr; + unsigned Addr; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Addr = MemReadZPWord (ZPAddr); + SBC (MemReadByte (Addr)); + Regs.PC += 2; +} + + + static void OPC_6502_F5 (void) /* Opcode $F5: SBC zp,x */ { @@ -2180,6 +2598,18 @@ static void OPC_6502_F9 (void) +static void OPC_65SC02_FA (void) +/* Opcode $7A: PLX */ +{ + Cycles = 4; + Regs.XR = POP (); + TEST_ZF (Regs.XR); + TEST_SF (Regs.XR); + Regs.PC += 1; +} + + + static void OPC_6502_FD (void) /* Opcode $FD: SBC abs,x */ { @@ -2483,260 +2913,260 @@ static const OPFunc OP6502Table[256] = { static const OPFunc OP65C02Table[256] = { OPC_6502_00, OPC_6502_01, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $02 + OPC_65C02_NOP11, // $03 + OPC_65SC02_04, OPC_6502_05, OPC_6502_06, - OPC_Illegal, + OPC_Illegal, // $07: RMB0 currently unsupported OPC_6502_08, OPC_6502_09, OPC_6502_0A, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP11, // $0B + OPC_65SC02_0C, OPC_6502_0D, OPC_6502_0E, - OPC_Illegal, + OPC_Illegal, // $0F: BBR0 currently unsupported OPC_6502_10, OPC_6502_11, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_12, + OPC_65C02_NOP11, // $13 + OPC_65SC02_14, OPC_6502_15, OPC_6502_16, - OPC_Illegal, + OPC_Illegal, // $17: RMB1 currently unsupported OPC_6502_18, OPC_6502_19, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_1A, + OPC_65C02_NOP11, // $1B + OPC_65SC02_1C, OPC_6502_1D, OPC_6502_1E, - OPC_Illegal, + OPC_Illegal, // $1F: BBR1 currently unsupported OPC_6502_20, OPC_6502_21, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $22 + OPC_65C02_NOP11, // $23 OPC_6502_24, OPC_6502_25, OPC_6502_26, - OPC_Illegal, + OPC_Illegal, // $27: RMB2 currently unsupported OPC_6502_28, OPC_6502_29, OPC_6502_2A, - OPC_Illegal, + OPC_65C02_NOP11, // $2B OPC_6502_2C, OPC_6502_2D, OPC_6502_2E, - OPC_Illegal, + OPC_Illegal, // $2F: BBR2 currently unsupported OPC_6502_30, OPC_6502_31, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_32, + OPC_65C02_NOP11, // $33 + OPC_65SC02_34, OPC_6502_35, OPC_6502_36, - OPC_Illegal, + OPC_Illegal, // $37: RMB3 currently unsupported OPC_6502_38, OPC_6502_39, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_3A, + OPC_65C02_NOP11, // $3B + OPC_65SC02_3C, OPC_6502_3D, OPC_6502_3E, - OPC_Illegal, + OPC_Illegal, // $3F: BBR3 currently unsupported OPC_6502_40, OPC_6502_41, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $42 + OPC_65C02_NOP11, // $43 + OPC_65C02_44, // $44 OPC_6502_45, OPC_6502_46, - OPC_Illegal, + OPC_Illegal, // $47: RMB4 currently unsupported OPC_6502_48, OPC_6502_49, OPC_6502_4A, - OPC_Illegal, + OPC_65C02_NOP11, // $4B OPC_6502_4C, OPC_6502_4D, OPC_6502_4E, - OPC_Illegal, + OPC_Illegal, // $4F: BBR4 currently unsupported OPC_6502_50, OPC_6502_51, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_52, + OPC_65C02_NOP11, // $53 + OPC_65C02_NOP24, // $54 OPC_6502_55, OPC_6502_56, - OPC_Illegal, + OPC_Illegal, // $57: RMB5 currently unsupported OPC_6502_58, OPC_6502_59, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_5A, + OPC_65C02_NOP11, // $5B + OPC_65C02_5C, OPC_6502_5D, OPC_6502_5E, - OPC_Illegal, + OPC_Illegal, // $5F: BBR5 currently unsupported OPC_6502_60, OPC_6502_61, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $62 + OPC_65C02_NOP11, // $63 + OPC_65SC02_64, OPC_6502_65, OPC_6502_66, - OPC_Illegal, + OPC_Illegal, // $67: RMB6 currently unsupported OPC_6502_68, OPC_6502_69, OPC_6502_6A, - OPC_Illegal, + OPC_65C02_NOP11, // $6B OPC_65C02_6C, OPC_6502_6D, OPC_6502_6E, - OPC_Illegal, + OPC_Illegal, // $6F: BBR6 currently unsupported OPC_6502_70, OPC_6502_71, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_72, + OPC_65C02_NOP11, // $73 + OPC_65SC02_74, OPC_6502_75, OPC_6502_76, - OPC_Illegal, + OPC_Illegal, // $77: RMB7 currently unsupported OPC_6502_78, OPC_6502_79, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_7A, + OPC_65C02_NOP11, // $7B + OPC_65SC02_7C, OPC_6502_7D, OPC_6502_7E, - OPC_Illegal, - OPC_Illegal, + OPC_Illegal, // $7F: BBR7 currently unsupported + OPC_65SC02_80, OPC_6502_81, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $82 + OPC_65C02_NOP11, // $83 OPC_6502_84, OPC_6502_85, OPC_6502_86, - OPC_Illegal, + OPC_Illegal, // $87: SMB0 currently unsupported OPC_6502_88, - OPC_Illegal, + OPC_65SC02_89, OPC_6502_8A, - OPC_Illegal, + OPC_65C02_NOP11, // $8B OPC_6502_8C, OPC_6502_8D, OPC_6502_8E, - OPC_Illegal, + OPC_Illegal, // $8F: BBS0 currently unsupported OPC_6502_90, OPC_6502_91, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_92, + OPC_65C02_NOP11, // $93 OPC_6502_94, OPC_6502_95, OPC_6502_96, - OPC_Illegal, + OPC_Illegal, // $97: SMB1 currently unsupported OPC_6502_98, OPC_6502_99, OPC_6502_9A, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP11, // $9B + OPC_65SC02_9C, OPC_6502_9D, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_9E, + OPC_Illegal, // $9F: BBS1 currently unsupported OPC_6502_A0, OPC_6502_A1, OPC_6502_A2, - OPC_Illegal, + OPC_65C02_NOP11, // $A3 OPC_6502_A4, OPC_6502_A5, OPC_6502_A6, - OPC_Illegal, + OPC_Illegal, // $A7: SMB2 currently unsupported OPC_6502_A8, OPC_6502_A9, OPC_6502_AA, - OPC_Illegal, + OPC_65C02_NOP11, // $AB OPC_6502_AC, OPC_6502_AD, OPC_6502_AE, - OPC_Illegal, + OPC_Illegal, // $AF: BBS2 currently unsupported OPC_6502_B0, OPC_6502_B1, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_B2, + OPC_65C02_NOP11, // $B3 OPC_6502_B4, OPC_6502_B5, OPC_6502_B6, - OPC_Illegal, + OPC_Illegal, // $B7: SMB3 currently unsupported OPC_6502_B8, OPC_6502_B9, OPC_6502_BA, - OPC_Illegal, + OPC_65C02_NOP11, // $BB OPC_6502_BC, OPC_6502_BD, OPC_6502_BE, - OPC_Illegal, + OPC_Illegal, // $BF: BBS3 currently unsupported OPC_6502_C0, OPC_6502_C1, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $C2 + OPC_65C02_NOP11, // $C3 OPC_6502_C4, OPC_6502_C5, OPC_6502_C6, - OPC_Illegal, + OPC_Illegal, // $C7: SMB4 currently unsupported OPC_6502_C8, OPC_6502_C9, OPC_6502_CA, - OPC_Illegal, + OPC_Illegal, // $CB: WAI currently unsupported OPC_6502_CC, OPC_6502_CD, OPC_6502_CE, - OPC_Illegal, + OPC_Illegal, // $CF: BBS4 currently unsupported OPC_6502_D0, OPC_6502_D1, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_D2, + OPC_65C02_NOP11, // $D3 + OPC_65C02_NOP24, // $D4 OPC_6502_D5, OPC_6502_D6, - OPC_Illegal, + OPC_Illegal, // $D7: SMB5 currently unsupported OPC_6502_D8, OPC_6502_D9, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_DA, + OPC_Illegal, // $DB: STP currently unsupported + OPC_65C02_NOP34, // $DC OPC_6502_DD, OPC_6502_DE, - OPC_Illegal, + OPC_Illegal, // $DF: BBS5 currently unsupported OPC_6502_E0, OPC_6502_E1, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $E2 + OPC_65C02_NOP11, // $E3 OPC_6502_E4, OPC_6502_E5, OPC_6502_E6, - OPC_Illegal, + OPC_Illegal, // $E7: SMB6 currently unsupported OPC_6502_E8, OPC_6502_E9, OPC_6502_EA, - OPC_Illegal, + OPC_65C02_NOP11, // $EB OPC_6502_EC, OPC_6502_ED, OPC_6502_EE, - OPC_Illegal, + OPC_Illegal, // $EF: BBS6 currently unsupported OPC_6502_F0, OPC_6502_F1, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_F2, + OPC_65C02_NOP11, // $F3 + OPC_65C02_NOP24, // $F4 OPC_6502_F5, OPC_6502_F6, - OPC_Illegal, + OPC_Illegal, // $F7: SMB7 currently unsupported OPC_6502_F8, OPC_6502_F9, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_FA, + OPC_65C02_NOP11, // $FB + OPC_65C02_NOP34, // $FC OPC_6502_FD, OPC_6502_FE, - OPC_Illegal, + OPC_Illegal, // $FF: BBS7 currently unsupported }; From 4ba34f2a69b14b04a6fef142ab4174b8b1b2fe65 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 18 Mar 2017 16:54:00 +0100 Subject: [PATCH 032/199] fixed scrambled semicolon --- src/sim65/6502.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index b6559ee46..bd5abcac7 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -865,10 +865,10 @@ static void OPC_65SC02_3C (void) unsigned Addr; unsigned char Val; Cycles = 4; - Addr = MemReadByte (Regs.PC+1) + Addr = MemReadByte (Regs.PC+1); if (PAGE_CROSS (Addr, Regs.XR)) ++Cycles; - Val = MemReadByte (Addr + Regs.XR;); + Val = MemReadByte (Addr + Regs.XR); SET_SF (Val & 0x80); SET_OF (Val & 0x40); SET_ZF ((Val & Regs.AC) == 0); From c50e4d25e20ddae2384a8d8a6a6d55e75c4836ec Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 18 Mar 2017 16:56:36 +0100 Subject: [PATCH 033/199] additional fix for scrambled code (sorry) --- src/sim65/6502.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index bd5abcac7..af82f00f7 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -865,7 +865,7 @@ static void OPC_65SC02_3C (void) unsigned Addr; unsigned char Val; Cycles = 4; - Addr = MemReadByte (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); if (PAGE_CROSS (Addr, Regs.XR)) ++Cycles; Val = MemReadByte (Addr + Regs.XR); From 0985655ac748656b7f7d80fa3695bd21a4fdf6f9 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 18 Mar 2017 17:02:22 +0100 Subject: [PATCH 034/199] Fixed bug in original sim65 implementation (reason for C&P error in last commit) --- src/sim65/6502.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index af82f00f7..996334295 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -1447,7 +1447,7 @@ static void OPC_6502_7E (void) unsigned Addr; unsigned Val; Cycles = 7; - Addr = MemReadByte (Regs.PC+1) + Regs.XR; + Addr = MemReadWord (Regs.PC+1) + Regs.XR; Val = MemReadByte (Addr); ROR (Val); MemWriteByte (Addr, Val); From ad003e59919028a6563d88cd8ef16c66474b2aa3 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 18 Mar 2017 20:27:41 +0100 Subject: [PATCH 035/199] style changes --- src/sim65/6502.c | 122 +++++++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 58 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index 996334295..eeaeeca22 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -215,7 +215,9 @@ int PrintCycles; ZPAddr = MemReadByte (Regs.PC+1); \ Addr = MemReadZPWord (ZPAddr); \ if (PAGE_CROSS (Addr, Regs.YR)) \ + { \ ++Cycles; \ + } \ Addr += Regs.YR; \ Regs.AC = Regs.AC op MemReadByte (Addr); \ TEST_ZF (Regs.AC); \ @@ -257,8 +259,10 @@ int PrintCycles; } \ TEST_CF (Regs.AC); \ SET_OF ((res < -128) || (res > 127)); \ - if (CPU!=CPU_6502) \ + if (CPU != CPU_6502) \ + { \ ++Cycles; \ + } \ } else { \ Regs.AC += rhs + GET_CF (); \ TEST_ZF (Regs.AC); \ @@ -338,8 +342,10 @@ int PrintCycles; TEST_SF (res); \ SET_CF (res <= 0xFF); \ SET_OF (((old^rhs) & (old^res) & 0x80)); \ - if (CPU!=CPU_6502) \ + if (CPU != CPU_6502) \ + { \ ++Cycles; \ + } \ } else { \ Regs.AC -= rhs + (!GET_CF ()); \ TEST_ZF (Regs.AC); \ @@ -396,7 +402,7 @@ static void OPC_65SC02_04 (void) unsigned char Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); SET_ZF ((Val & Regs.AC) == 0); MemWriteByte (ZPAddr, (unsigned char)(Val | Regs.AC)); Regs.PC += 2; @@ -419,7 +425,7 @@ static void OPC_6502_06 (void) unsigned Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr) << 1; + Val = MemReadByte (ZPAddr) << 1; MemWriteByte (ZPAddr, (unsigned char) Val); TEST_ZF (Val & 0xFF); TEST_SF (Val); @@ -468,7 +474,7 @@ static void OPC_65SC02_0C (void) unsigned char Val; Cycles = 6; Addr = MemReadByte (Regs.PC+1); - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); SET_ZF ((Val & Regs.AC) == 0); MemWriteByte (Addr, (unsigned char) (Val | Regs.AC)); Regs.PC += 3; @@ -491,7 +497,7 @@ static void OPC_6502_0E (void) unsigned Val; Cycles = 6; Addr = MemReadWord (Regs.PC+1); - Val = MemReadByte (Addr) << 1; + Val = MemReadByte (Addr) << 1; MemWriteByte (Addr, (unsigned char) Val); TEST_ZF (Val & 0xFF); TEST_SF (Val); @@ -532,7 +538,7 @@ static void OPC_65SC02_14 (void) unsigned char Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); SET_ZF ((Val & Regs.AC) == 0); MemWriteByte (ZPAddr, (unsigned char)(Val & ~Regs.AC)); Regs.PC += 2; @@ -555,7 +561,7 @@ static void OPC_6502_16 (void) unsigned Val; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Val = MemReadByte (ZPAddr) << 1; + Val = MemReadByte (ZPAddr) << 1; MemWriteByte (ZPAddr, (unsigned char) Val); TEST_ZF (Val & 0xFF); TEST_SF (Val); @@ -602,7 +608,7 @@ static void OPC_65SC02_1C (void) unsigned char Val; Cycles = 6; Addr = MemReadByte (Regs.PC+1); - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); SET_ZF ((Val & Regs.AC) == 0); MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC)); Regs.PC += 3; @@ -625,7 +631,7 @@ static void OPC_6502_1E (void) unsigned Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; - Val = MemReadByte (Addr) << 1; + Val = MemReadByte (Addr) << 1; MemWriteByte (Addr, (unsigned char) Val); TEST_ZF (Val & 0xFF); TEST_SF (Val); @@ -640,7 +646,7 @@ static void OPC_6502_20 (void) { unsigned Addr; Cycles = 6; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); Regs.PC += 2; PUSH (PCH); PUSH (PCL); @@ -666,7 +672,7 @@ static void OPC_6502_24 (void) unsigned char Val; Cycles = 3; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); SET_SF (Val & 0x80); SET_OF (Val & 0x40); SET_ZF ((Val & Regs.AC) == 0); @@ -690,7 +696,7 @@ static void OPC_6502_26 (void) unsigned Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); ROL (Val); MemWriteByte (ZPAddr, Val); Regs.PC += 2; @@ -734,7 +740,7 @@ static void OPC_6502_2C (void) unsigned char Val; Cycles = 4; Addr = MemReadByte (Regs.PC+1); - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); SET_SF (Val & 0x80); SET_OF (Val & 0x40); SET_ZF ((Val & Regs.AC) == 0); @@ -758,7 +764,7 @@ static void OPC_6502_2E (void) unsigned Val; Cycles = 6; Addr = MemReadWord (Regs.PC+1); - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); ROL (Val); MemWriteByte (Addr, Val); Regs.PC += 3; @@ -797,7 +803,7 @@ static void OPC_65SC02_34 (void) unsigned char Val; Cycles = 4; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); SET_SF (Val & 0x80); SET_OF (Val & 0x40); SET_ZF ((Val & Regs.AC) == 0); @@ -821,7 +827,7 @@ static void OPC_6502_36 (void) unsigned Val; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); ROL (Val); MemWriteByte (ZPAddr, Val); Regs.PC += 2; @@ -892,7 +898,7 @@ static void OPC_6502_3E (void) unsigned Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); ROL (Val); MemWriteByte (Addr, Val); Regs.PC += 2; @@ -943,7 +949,7 @@ static void OPC_6502_46 (void) unsigned char Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); SET_CF (Val & 0x01); Val >>= 1; MemWriteByte (ZPAddr, Val); @@ -1011,7 +1017,7 @@ static void OPC_6502_4E (void) unsigned char Val; Cycles = 6; Addr = MemReadWord (Regs.PC+1); - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); SET_CF (Val & 0x01); Val >>= 1; MemWriteByte (Addr, Val); @@ -1061,7 +1067,7 @@ static void OPC_6502_56 (void) unsigned char Val; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); SET_CF (Val & 0x01); Val >>= 1; MemWriteByte (ZPAddr, Val); @@ -1124,7 +1130,7 @@ static void OPC_6502_5E (void) unsigned char Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); SET_CF (Val & 0x01); Val >>= 1; MemWriteByte (Addr, Val); @@ -1153,7 +1159,7 @@ static void OPC_6502_61 (void) unsigned Addr; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); ADC (MemReadByte (Addr)); Regs.PC += 2; } @@ -1191,7 +1197,7 @@ static void OPC_6502_66 (void) unsigned Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); ROR (Val); MemWriteByte (ZPAddr, Val); Regs.PC += 2; @@ -1238,7 +1244,7 @@ static void OPC_6502_6C (void) PC = Regs.PC; Lo = MemReadWord (PC+1); - if (CPU==CPU_6502) + if (CPU == CPU_6502) { /* Emulate the 6502 bug */ Cycles = 5; @@ -1369,7 +1375,7 @@ static void OPC_6502_76 (void) unsigned Val; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); ROR (Val); MemWriteByte (ZPAddr, Val); Regs.PC += 2; @@ -1392,7 +1398,7 @@ static void OPC_6502_79 (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); if (PAGE_CROSS (Addr, Regs.YR)) { ++Cycles; } @@ -1431,7 +1437,7 @@ static void OPC_6502_7D (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); if (PAGE_CROSS (Addr, Regs.XR)) { ++Cycles; } @@ -1448,7 +1454,7 @@ static void OPC_6502_7E (void) unsigned Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); ROR (Val); MemWriteByte (Addr, Val); Regs.PC += 3; @@ -1471,7 +1477,7 @@ static void OPC_6502_81 (void) unsigned Addr; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); MemWriteByte (Addr, Regs.AC); Regs.PC += 2; } @@ -1531,7 +1537,7 @@ static void OPC_65SC02_89 (void) { unsigned char Val; Cycles = 2; - Val = MemReadByte (Regs.PC+1); + Val = MemReadByte (Regs.PC+1); SET_SF (Val & 0x80); SET_OF (Val & 0x40); SET_ZF ((Val & Regs.AC) == 0); @@ -1603,7 +1609,7 @@ static void OPC_6502_91 (void) unsigned Addr; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadZPWord (ZPAddr) + Regs.YR; + Addr = MemReadZPWord (ZPAddr) + Regs.YR; MemWriteByte (Addr, Regs.AC); Regs.PC += 2; } @@ -1617,7 +1623,7 @@ static void OPC_65SC02_92 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); MemWriteByte (Addr, Regs.AC); Regs.PC += 2; } @@ -1677,7 +1683,7 @@ static void OPC_6502_99 (void) { unsigned Addr; Cycles = 5; - Addr = MemReadWord (Regs.PC+1) + Regs.YR; + Addr = MemReadWord (Regs.PC+1) + Regs.YR; MemWriteByte (Addr, Regs.AC); Regs.PC += 3; } @@ -1711,7 +1717,7 @@ static void OPC_6502_9D (void) { unsigned Addr; Cycles = 5; - Addr = MemReadWord (Regs.PC+1) + Regs.XR; + Addr = MemReadWord (Regs.PC+1) + Regs.XR; MemWriteByte (Addr, Regs.AC); Regs.PC += 3; } @@ -1723,7 +1729,7 @@ static void OPC_65SC02_9E (void) { unsigned Addr; Cycles = 5; - Addr = MemReadWord (Regs.PC+1) + Regs.XR; + Addr = MemReadWord (Regs.PC+1) + Regs.XR; MemWriteByte (Addr, 0); Regs.PC += 3; } @@ -1853,7 +1859,7 @@ static void OPC_6502_AC (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); Regs.YR = MemReadByte (Addr); TEST_ZF (Regs.YR); TEST_SF (Regs.YR); @@ -1867,7 +1873,7 @@ static void OPC_6502_AD (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); Regs.AC = MemReadByte (Addr); TEST_ZF (Regs.AC); TEST_SF (Regs.AC); @@ -1881,7 +1887,7 @@ static void OPC_6502_AE (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); Regs.XR = MemReadByte (Addr); TEST_ZF (Regs.XR); TEST_SF (Regs.XR); @@ -1905,7 +1911,7 @@ static void OPC_6502_B1 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); if (PAGE_CROSS (Addr, Regs.YR)) { ++Cycles; } @@ -1924,7 +1930,7 @@ static void OPC_65SC02_B2 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); Regs.AC = MemReadByte (Addr); TEST_ZF (Regs.AC); TEST_SF (Regs.AC); @@ -2082,7 +2088,7 @@ static void OPC_6502_C1 (void) unsigned Addr; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); CMP (Regs.AC, MemReadByte (Addr)); Regs.PC += 2; } @@ -2120,7 +2126,7 @@ static void OPC_6502_C6 (void) unsigned char Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr) - 1; + Val = MemReadByte (ZPAddr) - 1; MemWriteByte (ZPAddr, Val); TEST_ZF (Val); TEST_SF (Val); @@ -2168,7 +2174,7 @@ static void OPC_6502_CC (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); CMP (Regs.YR, MemReadByte (Addr)); Regs.PC += 3; } @@ -2180,7 +2186,7 @@ static void OPC_6502_CD (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); CMP (Regs.AC, MemReadByte (Addr)); Regs.PC += 3; } @@ -2218,7 +2224,7 @@ static void OPC_6502_D1 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadWord (ZPAddr); + Addr = MemReadWord (ZPAddr); if (PAGE_CROSS (Addr, Regs.YR)) { ++Cycles; } @@ -2235,7 +2241,7 @@ static void OPC_65SC02_D2 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadWord (ZPAddr); + Addr = MemReadWord (ZPAddr); CMP (Regs.AC, MemReadByte (Addr)); Regs.PC += 2; } @@ -2327,7 +2333,7 @@ static void OPC_6502_DE (void) unsigned char Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; - Val = MemReadByte (Addr) - 1; + Val = MemReadByte (Addr) - 1; MemWriteByte (Addr, Val); TEST_ZF (Val); TEST_SF (Val); @@ -2353,7 +2359,7 @@ static void OPC_6502_E1 (void) unsigned Addr; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); SBC (MemReadByte (Addr)); Regs.PC += 2; } @@ -2391,7 +2397,7 @@ static void OPC_6502_E6 (void) unsigned char Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr) + 1; + Val = MemReadByte (ZPAddr) + 1; MemWriteByte (ZPAddr, Val); TEST_ZF (Val); TEST_SF (Val); @@ -2485,7 +2491,7 @@ static void OPC_6502_ED (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); SBC (MemReadByte (Addr)); Regs.PC += 3; } @@ -2499,7 +2505,7 @@ static void OPC_6502_EE (void) unsigned char Val; Cycles = 6; Addr = MemReadWord (Regs.PC+1); - Val = MemReadByte (Addr) + 1; + Val = MemReadByte (Addr) + 1; MemWriteByte (Addr, Val); TEST_ZF (Val); TEST_SF (Val); @@ -2523,7 +2529,7 @@ static void OPC_6502_F1 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); if (PAGE_CROSS (Addr, Regs.YR)) { ++Cycles; } @@ -2540,7 +2546,7 @@ static void OPC_65SC02_F2 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); SBC (MemReadByte (Addr)); Regs.PC += 2; } @@ -2566,7 +2572,7 @@ static void OPC_6502_F6 (void) unsigned char Val; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Val = MemReadByte (ZPAddr) + 1; + Val = MemReadByte (ZPAddr) + 1; MemWriteByte (ZPAddr, Val); TEST_ZF (Val); TEST_SF (Val); @@ -2588,7 +2594,7 @@ static void OPC_6502_F9 (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); if (PAGE_CROSS (Addr, Regs.YR)) { ++Cycles; } @@ -2615,7 +2621,7 @@ static void OPC_6502_FD (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); if (PAGE_CROSS (Addr, Regs.XR)) { ++Cycles; } @@ -2632,7 +2638,7 @@ static void OPC_6502_FE (void) unsigned char Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; - Val = MemReadByte (Addr) + 1; + Val = MemReadByte (Addr) + 1; MemWriteByte (Addr, Val); TEST_ZF (Val); TEST_SF (Val); From 2048d6cfb5c29b798bd459a31192f19f4d675219 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sat, 18 Mar 2017 20:57:12 +0100 Subject: [PATCH 036/199] Removed top blank line. --- libsrc/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index cb3517c7e..f4aa03101 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -1,4 +1,3 @@ - ifneq ($(shell echo),) CMD_EXE = 1 endif From e14e13abf4850c16bade80f3519faf2760b322d2 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 18 Mar 2017 22:52:13 +0100 Subject: [PATCH 037/199] fixed curly brackets for single line scopes --- src/sim65/6502.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index eeaeeca22..0320dd895 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -214,8 +214,7 @@ int PrintCycles; Cycles = 5; \ ZPAddr = MemReadByte (Regs.PC+1); \ Addr = MemReadZPWord (ZPAddr); \ - if (PAGE_CROSS (Addr, Regs.YR)) \ - { \ + if (PAGE_CROSS (Addr, Regs.YR)) { \ ++Cycles; \ } \ Addr += Regs.YR; \ @@ -259,8 +258,7 @@ int PrintCycles; } \ TEST_CF (Regs.AC); \ SET_OF ((res < -128) || (res > 127)); \ - if (CPU != CPU_6502) \ - { \ + if (CPU != CPU_6502) { \ ++Cycles; \ } \ } else { \ @@ -342,8 +340,7 @@ int PrintCycles; TEST_SF (res); \ SET_CF (res <= 0xFF); \ SET_OF (((old^rhs) & (old^res) & 0x80)); \ - if (CPU != CPU_6502) \ - { \ + if (CPU != CPU_6502) { \ ++Cycles; \ } \ } else { \ From 66634ef6834438324104d6f1708a0358bd3e31ae Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 19 Mar 2017 17:48:12 +0100 Subject: [PATCH 038/199] Cleaned up test Makefiles. --- test/Makefile | 23 ++------ test/assembler/.gitignore | 3 - test/assembler/Makefile | 91 ++++++++++++++++++------------ test/disassembler/Makefile | 76 ++++++++++++++++--------- test/err/Makefile | 21 ++++--- test/misc/Makefile | 90 ++++++++++++++++++------------ test/ref/Makefile | 110 ++++++++++++++++--------------------- test/val/Makefile | 65 +++++++++------------- 8 files changed, 253 insertions(+), 226 deletions(-) delete mode 100644 test/assembler/.gitignore diff --git a/test/Makefile b/test/Makefile index 4817e70e0..a02bd91fb 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,43 +1,30 @@ - -# top-level makefile for the regression tests +# top-level Makefile for the regression tests # You can comment this special target when you debug the regression tests. # Then, make will give you more progress reports. .SILENT: ifneq ($(shell echo),) - CMD_EXE := 1 + CMD_EXE = 1 endif ifdef CMD_EXE - EXE := .exe - MKDIR = mkdir $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1) else - EXE := - MKDIR = mkdir $1 RMDIR = $(RM) -r $1 endif -WORKDIR := ../testwrk - -CC := gcc +WORKDIR = ../testwrk .PHONY: all dotests continue mostlyclean clean all: dotests -$(WORKDIR): - $(call MKDIR,$(WORKDIR)) - -$(WORKDIR)/bdiff$(EXE): bdiff.c | $(WORKDIR) - $(CC) -O2 -o $@ $< - .NOTPARALLEL: dotests: mostlyclean continue -continue: $(WORKDIR)/bdiff$(EXE) +continue: @$(MAKE) -C assembler all @$(MAKE) -C disassembler all @$(MAKE) -C val all @@ -46,6 +33,8 @@ continue: $(WORKDIR)/bdiff$(EXE) @$(MAKE) -C misc all mostlyclean: + @$(MAKE) -C assembler clean + @$(MAKE) -C disassembler clean @$(MAKE) -C val clean @$(MAKE) -C ref clean @$(MAKE) -C err clean diff --git a/test/assembler/.gitignore b/test/assembler/.gitignore deleted file mode 100644 index c0c74a35e..000000000 --- a/test/assembler/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.o -*.bin -*.lst diff --git a/test/assembler/Makefile b/test/assembler/Makefile index 5d38847f5..fb840446c 100644 --- a/test/assembler/Makefile +++ b/test/assembler/Makefile @@ -1,45 +1,68 @@ +# Makefile for the assembler regression tests -# makefile for the assembler regression tests +ifneq ($(shell echo),) + CMD_EXE = 1 +endif -BINDIR = ../../bin -WORKDIR := ../../testwrk +ifdef CMD_EXE + EXE = .exe + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) + DEL = del /f $(subst /,\,$1) +else + EXE = + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 + DEL = $(RM) $1 +endif -BASE_TARGETS = 6502 6502x 65sc02 65c02 -BASE_TARGETS += 4510 huc6280 +CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) -OPCODE_TARGETS = $(BASE_TARGETS) -CPUDETECT_TARGETS = $(BASE_TARGETS) +WORKDIR = ../../testwrk/asm -CPUDETECT_TARGETS += 65816 +DIFF = $(WORKDIR)/bdiff$(EXE) -# default target defined later -all: +CC = gcc +CFLAGS = -O2 -# generate opcode targets and expand target list -define opcode -OPCODE_TARGETLIST += $$(WORKDIR)/$(1)-opcodes.bin -$$(WORKDIR)/$(1)-opcodes.bin: $(1)-opcodes.s - @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-opcodes.lst --obj-path $$(WORKDIR) -o $$@ $$< - @diff -q $(1)-opcodes.ref $$@ || (cat $$(WORKDIR)/$(1)-opcodes.lst ; exit 1) - @echo ca65 --cpu $(1) opcodes ok - @rm -f $(1)-opcodes.o #workaround for #168 -endef -$(foreach target,$(OPCODE_TARGETS),$(eval $(call opcode,$(target)))) +.PHONY: all clean -# generate cpudetect targets and expand target list -define cpudetect -CPUDETECT_TARGETLIST += $$(WORKDIR)/$(1)-cpudetect.bin -$$(WORKDIR)/$(1)-cpudetect.bin: cpudetect.s - @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-cpudetect.lst --obj-path $$(WORKDIR) -o $$@ $$< - @diff -q $(1)-cpudetect.ref $$@ || (cat $$(WORKDIR)/$(1)-cpudetect.lst ; exit 1) - @echo ca65 --cpu $(1) cpudetect ok - @rm -f cpudetect.o #workaround for #168 -endef -$(foreach target,$(CPUDETECT_TARGETS),$(eval $(call cpudetect,$(target)))) +OPCODE_REFS := $(wildcard *-opcodes.ref) +OPCODE_CPUS = $(foreach ref,$(OPCODE_REFS),$(ref:%-opcodes.ref=%)) +OPCODE_BINS = $(foreach cpu,$(OPCODE_CPUS),$(WORKDIR)/$(cpu)-opcodes.bin) -# now that all targets have been generated, get to the manual ones -all: $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST) - @# +CPUDETECT_REFS := $(wildcard *-cpudetect.ref) +CPUDETECT_CPUS = $(foreach ref,$(CPUDETECT_REFS),$(ref:%-cpudetect.ref=%)) +CPUDETECT_BINS = $(foreach cpu,$(CPUDETECT_CPUS),$(WORKDIR)/$(cpu)-cpudetect.bin) -.PHONY: all $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST) +all: $(OPCODE_BINS) $(CPUDETECT_BINS) +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) + +$(DIFF): ../bdiff.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $@ $< + +define OPCODE_template + +$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(DIFF) + $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $$@ $$< + $(DIFF) $$@ $1-opcodes.ref + +endef # OPCODE_template + +$(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu)))) + +define CPUDETECT_template + +$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(DIFF) + $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $$@ $$< + $(DIFF) $$@ $1-cpudetect.ref + +endef # CPUDETECT_template + +$(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu)))) + +clean: + @$(call RMDIR,$(WORKDIR)) + @$(call DEL,$(OPCODE_REFS:.ref=.o) cpudetect.o) diff --git a/test/disassembler/Makefile b/test/disassembler/Makefile index 2621b0c20..f8942ef73 100644 --- a/test/disassembler/Makefile +++ b/test/disassembler/Makefile @@ -1,42 +1,64 @@ +# Makefile for the disassembler regression tests -# makefile for the disassembler regression tests +ifneq ($(shell echo),) + CMD_EXE = 1 +endif -BINDIR = ../../bin -WORKDIR := ../../testwrk +ifdef CMD_EXE + EXE = .exe + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) + DEL = del /f $(subst /,\,$1) +else + EXE = + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 + DEL = $(RM) $1 +endif -#BASE_TARGETS = 6502 6502x 65sc02 65c02 -#BASE_TARGETS += 4510 huc6280 -BASE_TARGETS = 4510 +CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) +DA65 := $(if $(wildcard ../../bin/da65*),../../bin/da65,da65) + +WORKDIR = ../../testwrk/dasm + +DIFF = $(WORKDIR)/bdiff$(EXE) + +CC = gcc +CFLAGS = -O2 START = --start-addr 0x8000 -DISASS_TARGETS = $(BASE_TARGETS) +.PHONY: all clean + +SOURCES := $(wildcard *.s) +CPUS = $(foreach src,$(SOURCES),$(src:%-disass.s=%)) +BINS = $(foreach cpu,$(CPUS),$(WORKDIR)/$(cpu)-reass.bin) # default target defined later -all: +all: $(BINS) -# generate opcode targets and expand target list -define disass -DISASS_TARGETLIST += $$(WORKDIR)/$(1)-reass.bin $$(WORKDIR)/$(1)-reass.s $$(WORKDIR)/$(1)-disass.bin +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) -$$(WORKDIR)/$(1)-disass.bin: $(1)-disass.s - @$$(BINDIR)/cl65 --cpu $(1) -t none $(START) --obj-path $$(WORKDIR) -o $$@ $$< - @rm -f $(1)-disass.o #workaround for #168 +$(DIFF): ../bdiff.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $@ $< -$$(WORKDIR)/$(1)-reass.s: $$(WORKDIR)/$(1)-disass.bin - @$$(BINDIR)/da65 --cpu $(1) $(START) -o $$@ $$< +define DISASS_template -$$(WORKDIR)/$(1)-reass.bin: $$(WORKDIR)/$(1)-reass.s - @$$(BINDIR)/cl65 --cpu $(1) -t none $(START) --obj-path $$(WORKDIR) -o $$@ $$< - @rm -f $(1)-reass.o #workaround for #168 - @cmp $$@ $$(WORKDIR)/$(1)-disass.bin - @echo da65 --cpu $(1) ok -endef -$(foreach target,$(DISASS_TARGETS),$(eval $(call disass,$(target)))) +$(WORKDIR)/$1-disass.bin: $1-disass.s | $(WORKDIR) + $(CL65) --cpu $1 -t none $(START) -o $$@ $$< -# now that all targets have been generated, get to the manual ones -all: $(DISASS_TARGETLIST) - @# +$(WORKDIR)/$1-reass.s: $(WORKDIR)/$1-disass.bin + $(DA65) --cpu $1 $(START) -o $$@ $$< -.PHONY: all $(DISASS_TARGETLIST) +$(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(DIFF) + $(CL65) --cpu $1 -t none $(START) -o $$@ $$< + $(DIFF) $$@ $(WORKDIR)/$1-disass.bin +endef # DISASS_template + +$(foreach cpu,$(CPUS),$(eval $(call DISASS_template,$(cpu)))) + +clean: + @$(call RMDIR,$(WORKDIR)) + @$(call DEL,$(SOURCES:.s=.o)) diff --git a/test/err/Makefile b/test/err/Makefile index bc4226acb..2bcc1d264 100644 --- a/test/err/Makefile +++ b/test/err/Makefile @@ -1,24 +1,27 @@ -# makefile for the tests that MUST NOT compile +# Makefile for the tests that MUST NOT compile ifneq ($(shell echo),) - CMD_EXE := 1 + CMD_EXE = 1 endif ifdef CMD_EXE - NOT := - # Hack - DEL = -del /f $(subst /,\,$1) + NOT = - # Hack + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) else - NOT := ! - DEL = $(RM) $1 + NOT = ! + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 endif CC65 := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65) -WORKDIR := ../../testwrk +WORKDIR = ../../testwrk/err .PHONY: all clean -TESTS := $(patsubst %.c,$(WORKDIR)/%.s,$(wildcard *.c)) +SOURCES := $(wildcard *.c) +TESTS = $(patsubst %.c,$(WORKDIR)/%.s,$(SOURCES)) all: $(TESTS) @@ -26,4 +29,4 @@ $(WORKDIR)/%.s: %.c $(NOT) $(CC65) -o $@ $< clean: - @$(call DEL,$(TESTS)) + @$(call RMDIR,$(WORKDIR)) diff --git a/test/misc/Makefile b/test/misc/Makefile index 918316c6c..6512a9fd9 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -1,63 +1,85 @@ - -# makefile for the remaining tests that need special care in one way or another +# Makefile for the remaining tests that need special care in one way or another ifneq ($(shell echo),) - CMD_EXE := 1 + CMD_EXE = 1 endif ifdef CMD_EXE - S := $(subst /,\,/) - NOT := - # Hack - DEL = -del /f $(subst /,\,$1) + S = $(subst /,\,/) + NOT = - # Hack + EXE = .exe + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) + DEL = del /f $(subst /,\,$1) else - S := / - NOT := ! + S = / + NOT = ! + EXE = + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 DEL = $(RM) $1 endif -CC65FLAGS := -t sim6502 -SIM65FLAGS := -x 200000000 +CC65FLAGS = -t sim6502 +SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) -WORKDIR := ..$S..$Stestwrk -DIFF := $(WORKDIR)/bdiff +WORKDIR = ..$S..$Stestwrk$Smisc + +OPTIONS = g O Os Osi Osir Oi Oir Or + +DIFF = $(WORKDIR)$Sbdiff$(EXE) + +CC = gcc +CFLAGS = -O2 .PHONY: all clean SOURCES := $(wildcard *.c) -TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg)) +TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg)) all: $(TESTS) +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) + +$(DIFF): ../bdiff.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $@ $< + +define PRG_template + # should compile, but then hangs in an endless loop -$(WORKDIR)/endless%prg: endless.c - $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@ - $(NOT) $(SIM65) $(SIM65FLAGS) $@ +$(WORKDIR)/endless.$1.prg: endless.c | $(WORKDIR) + $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + $(NOT) $(SIM65) $(SIM65FLAGS) $$@ # these need reference data that can't be generated by a host-compiled program, # in a useful way -$(WORKDIR)/limits%prg: limits.c - $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/limits.out - $(DIFF) $(WORKDIR)/limits.out limits.ref +$(WORKDIR)/limits.$1.prg: limits.c $(DIFF) + $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.out + $(DIFF) $(WORKDIR)/limits.$1.out limits.ref # the rest are tests that fail currently for one reason or another -$(WORKDIR)/fields%prg: fields.c - @echo "FIXME: " $@ "currently will fail." - $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@ - -$(SIM65) $(SIM65FLAGS) $@ -$(WORKDIR)/sitest%prg: sitest.c - @echo "FIXME: " $@ "currently will fail." - -$(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@ -# -$(SIM65) $(SIM65FLAGS) $@ -$(WORKDIR)/cc65141011%prg: cc65141011.c - @echo "FIXME: " $@ "currently can fail." - $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@ - -$(SIM65) $(SIM65FLAGS) $@ +$(WORKDIR)/fields.$1.prg: fields.c | $(WORKDIR) + @echo "FIXME: " $$@ "currently will fail." + $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + -$(SIM65) $(SIM65FLAGS) $$@ +$(WORKDIR)/sitest.$1.prg: sitest.c | $(WORKDIR) + @echo "FIXME: " $$@ "currently will fail." + -$(CL65) $(CC65FLAGS) -$1 -o $$@ $$< +# -$(SIM65) $(SIM65FLAGS) $$@ +$(WORKDIR)/cc65141011.$1.prg: cc65141011.c | $(WORKDIR) + @echo "FIXME: " $$@ "currently can fail." + $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + -$(SIM65) $(SIM65FLAGS) $$@ + +endef # PRG_template + +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option)))) clean: - @$(call DEL,$(TESTS)) + @$(call RMDIR,$(WORKDIR)) @$(call DEL,$(SOURCES:.c=.o)) - @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.out)) diff --git a/test/ref/Makefile b/test/ref/Makefile index 6f0bd1bc1..7bd10cf14 100644 --- a/test/ref/Makefile +++ b/test/ref/Makefile @@ -1,102 +1,84 @@ -# makefile for the regression tests that generate output which has to be +# Makefile for the regression tests that generate output which has to be # compared with reference output ifneq ($(shell echo),) - CMD_EXE := 1 + CMD_EXE = 1 endif ifdef CMD_EXE - S := $(subst /,\,/) - DEL = -del /f $(subst /,\,$1) + S = $(subst /,\,/) + EXE = .exe + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) + DEL = del /f $(subst /,\,$1) else - S := / + S = / + EXE = + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 DEL = $(RM) $1 endif -CC65FLAGS := -t sim6502 -SIM65FLAGS := -x 200000000 +CC65FLAGS = -t sim6502 +SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) -WORKDIR := ..$S..$Stestwrk -DIFF := $(WORKDIR)/bdiff +WORKDIR = ..$S..$Stestwrk$Sref -CC := gcc -CFLAGS := -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow +OPTIONS = g O Os Osi Osir Oi Oir Or + +DIFF = $(WORKDIR)$Sbdiff$(EXE) + +CC = gcc +CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow .PHONY: all clean SOURCES := $(wildcard *.c) -REFS := $(SOURCES:%.c=$(WORKDIR)/%.ref) -TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg)) +REFS = $(SOURCES:%.c=$(WORKDIR)/%.ref) +TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg)) all: $(REFS) $(TESTS) -# "yaccdbg.c" includes "yacc.c". -# yaccdbg's built files must depend on both of them. +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) -$(WORKDIR)/yaccdbg.ref: yacc.c - -$(WORKDIR)/%.ref: %.c - $(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host +$(WORKDIR)/%.ref: %.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(WORKDIR)$S$*.host > $@ +$(DIFF): ../bdiff.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $@ $< + # Some files have "K & R"-style syntax. Therefore, some forward # function-declarations don't match the later function definitions. # Those programs fail when fastcall is used; but, the cdecl calling convention # tolerates those conflicts. Therefore, make their functions default to cdecl. # -$(WORKDIR)/init%prg: CC65FLAGS += -Wc --all-cdecl -$(WORKDIR)/switch.%rg: CC65FLAGS += -Wc --all-cdecl -$(WORKDIR)/yacc.%rg: CC65FLAGS += -Wc --all-cdecl -$(WORKDIR)/yaccdbg%prg: CC65FLAGS += -Wc --all-cdecl +$(WORKDIR)/init.%.prg \ +$(WORKDIR)/switch.%.prg \ +$(WORKDIR)/yacc.%.prg \ +$(WORKDIR)/yaccdbg.%.prg: CC65FLAGS += -Wc --all-cdecl -$(WORKDIR)/yaccdbg%prg: yacc.c +# "yaccdbg.c" includes "yacc.c". +# yaccdbg's built files must depend on both of them. +# +$(WORKDIR)/yaccdbg.ref: yacc.c +$(WORKDIR)/yaccdbg.%.prg: yacc.c -$(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref - $(CL65) $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref +define PRG_template -$(WORKDIR)/%.o.prg: %.c $(WORKDIR)/%.ref - $(CL65) -O $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref +$(WORKDIR)/%.$1.prg: %.c $(WORKDIR)/%.ref $(DIFF) + $(CL65) $$(CC65FLAGS) -$1 -o $$@ $$< + $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.out + $(DIFF) $(WORKDIR)/$$*.out $(WORKDIR)/$$*.ref -$(WORKDIR)/%.os.prg: %.c $(WORKDIR)/%.ref - $(CL65) -Os $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref +endef # PRG_template -$(WORKDIR)/%.osi.prg: %.c $(WORKDIR)/%.ref - $(CL65) -Osi $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref - -$(WORKDIR)/%.osir.prg: %.c $(WORKDIR)/%.ref - $(CL65) -Osir $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref - -$(WORKDIR)/%.oi.prg: %.c $(WORKDIR)/%.ref - $(CL65) -Oi $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref - -$(WORKDIR)/%.oir.prg: %.c $(WORKDIR)/%.ref - $(CL65) -Oir $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref - -$(WORKDIR)/%.or.prg: %.c $(WORKDIR)/%.ref - $(CL65) -Or $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option)))) clean: - @$(call DEL,$(TESTS)) + @$(call RMDIR,$(WORKDIR)) @$(call DEL,$(SOURCES:.c=.o)) - @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.out)) - @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.ref)) - @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.host)) diff --git a/test/val/Makefile b/test/val/Makefile index 4ad8160ef..8a07045ee 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -1,70 +1,59 @@ - -# makefile for the regression tests that return an error code on failure +# Makefile for the regression tests that return an error code on failure ifneq ($(shell echo),) - CMD_EXE := 1 + CMD_EXE = 1 endif ifdef CMD_EXE - DEL = -del /f $(subst /,\,$1) + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) + DEL = del /f $(subst /,\,$1) else + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 DEL = $(RM) $1 endif -CC65FLAGS := -t sim6502 -SIM65FLAGS := -x 200000000 +CC65FLAGS = -t sim6502 +SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65) -WORKDIR := ../../testwrk +WORKDIR = ../../testwrk/val + +OPTIONS = g O Os Osi Osir Oi Oir Or .PHONY: all clean SOURCES := $(wildcard *.c) -TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg)) +TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg)) all: $(TESTS) +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) + # Some files have "K & R"-style syntax. Therefore, some forward # function-declarations don't match the later function definitions. # Those programs fail when fastcall is used; but, the cdecl calling convention # tolerates those conflicts. Therefore, make their functions default to cdecl. # -$(WORKDIR)/cq4%prg $(WORKDIR)/cq71.%rg $(WORKDIR)/cq81%prg $(WORKDIR)/cq84%prg: CC65FLAGS += -Wc --all-cdecl +$(WORKDIR)/cq4.%.prg \ +$(WORKDIR)/cq71.%.prg \ +$(WORKDIR)/cq81.%.prg \ +$(WORKDIR)/cq84.%.prg: CC65FLAGS += -Wc --all-cdecl -$(WORKDIR)/%.prg: %.c - $(CL65) $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ +define PRG_template -$(WORKDIR)/%.o.prg: %.c - $(CL65) -O $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ +$(WORKDIR)/%.$1.prg: %.c | $(WORKDIR) + $(CL65) $$(CC65FLAGS) -$1 -o $$@ $$< + $(SIM65) $(SIM65FLAGS) $$@ -$(WORKDIR)/%.os.prg: %.c - $(CL65) -Os $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ +endef # PRG_template -$(WORKDIR)/%.osi.prg: %.c - $(CL65) -Osi $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ - -$(WORKDIR)/%.osir.prg: %.c - $(CL65) -Osir $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ - -$(WORKDIR)/%.oi.prg: %.c - $(CL65) -Oi $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ - -$(WORKDIR)/%.oir.prg: %.c - $(CL65) -Oir $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ - -$(WORKDIR)/%.or.prg: %.c - $(CL65) -Or $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option)))) clean: - @$(call DEL,$(TESTS)) + @$(call RMDIR,$(WORKDIR)) @$(call DEL,$(SOURCES:.c=.o)) From ff9b77b6cc96fbdfd06e7f4d6442d4b8c4dd9f86 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 19 Mar 2017 17:57:25 +0100 Subject: [PATCH 039/199] Shortened test subdir names. --- test/Makefile | 8 ++++---- test/{assembler => asm}/4510-cpudetect.ref | Bin test/{assembler => asm}/4510-opcodes.ref | Bin test/{assembler => asm}/4510-opcodes.s | 0 test/{assembler => asm}/6502-cpudetect.ref | Bin test/{assembler => asm}/6502-opcodes.ref | Bin test/{assembler => asm}/6502-opcodes.s | 0 test/{assembler => asm}/6502x-cpudetect.ref | Bin test/{assembler => asm}/6502x-opcodes.ref | Bin test/{assembler => asm}/6502x-opcodes.s | 0 test/{assembler => asm}/65816-cpudetect.ref | Bin test/{assembler => asm}/65c02-cpudetect.ref | Bin test/{assembler => asm}/65c02-opcodes.ref | Bin test/{assembler => asm}/65c02-opcodes.s | 0 test/{assembler => asm}/65sc02-cpudetect.ref | Bin test/{assembler => asm}/65sc02-opcodes.ref | Bin test/{assembler => asm}/65sc02-opcodes.s | 0 test/{assembler => asm}/Makefile | 0 test/{assembler => asm}/README | 0 test/{assembler => asm}/cpudetect.s | 0 test/{assembler => asm}/huc6280-cpudetect.ref | Bin test/{assembler => asm}/huc6280-opcodes.ref | Bin test/{assembler => asm}/huc6280-opcodes.s | 0 test/{assembler => asm}/m740-opcodes.s | 0 test/{disassembler => dasm}/4510-disass.s | 0 test/{disassembler => dasm}/Makefile | 0 26 files changed, 4 insertions(+), 4 deletions(-) rename test/{assembler => asm}/4510-cpudetect.ref (100%) rename test/{assembler => asm}/4510-opcodes.ref (100%) rename test/{assembler => asm}/4510-opcodes.s (100%) rename test/{assembler => asm}/6502-cpudetect.ref (100%) rename test/{assembler => asm}/6502-opcodes.ref (100%) rename test/{assembler => asm}/6502-opcodes.s (100%) rename test/{assembler => asm}/6502x-cpudetect.ref (100%) rename test/{assembler => asm}/6502x-opcodes.ref (100%) rename test/{assembler => asm}/6502x-opcodes.s (100%) rename test/{assembler => asm}/65816-cpudetect.ref (100%) rename test/{assembler => asm}/65c02-cpudetect.ref (100%) rename test/{assembler => asm}/65c02-opcodes.ref (100%) rename test/{assembler => asm}/65c02-opcodes.s (100%) rename test/{assembler => asm}/65sc02-cpudetect.ref (100%) rename test/{assembler => asm}/65sc02-opcodes.ref (100%) rename test/{assembler => asm}/65sc02-opcodes.s (100%) rename test/{assembler => asm}/Makefile (100%) rename test/{assembler => asm}/README (100%) rename test/{assembler => asm}/cpudetect.s (100%) rename test/{assembler => asm}/huc6280-cpudetect.ref (100%) rename test/{assembler => asm}/huc6280-opcodes.ref (100%) rename test/{assembler => asm}/huc6280-opcodes.s (100%) rename test/{assembler => asm}/m740-opcodes.s (100%) rename test/{disassembler => dasm}/4510-disass.s (100%) rename test/{disassembler => dasm}/Makefile (100%) diff --git a/test/Makefile b/test/Makefile index a02bd91fb..d0bee8ed8 100644 --- a/test/Makefile +++ b/test/Makefile @@ -25,16 +25,16 @@ all: dotests dotests: mostlyclean continue continue: - @$(MAKE) -C assembler all - @$(MAKE) -C disassembler all + @$(MAKE) -C asm all + @$(MAKE) -C dasm all @$(MAKE) -C val all @$(MAKE) -C ref all @$(MAKE) -C err all @$(MAKE) -C misc all mostlyclean: - @$(MAKE) -C assembler clean - @$(MAKE) -C disassembler clean + @$(MAKE) -C asm clean + @$(MAKE) -C dasm clean @$(MAKE) -C val clean @$(MAKE) -C ref clean @$(MAKE) -C err clean diff --git a/test/assembler/4510-cpudetect.ref b/test/asm/4510-cpudetect.ref similarity index 100% rename from test/assembler/4510-cpudetect.ref rename to test/asm/4510-cpudetect.ref diff --git a/test/assembler/4510-opcodes.ref b/test/asm/4510-opcodes.ref similarity index 100% rename from test/assembler/4510-opcodes.ref rename to test/asm/4510-opcodes.ref diff --git a/test/assembler/4510-opcodes.s b/test/asm/4510-opcodes.s similarity index 100% rename from test/assembler/4510-opcodes.s rename to test/asm/4510-opcodes.s diff --git a/test/assembler/6502-cpudetect.ref b/test/asm/6502-cpudetect.ref similarity index 100% rename from test/assembler/6502-cpudetect.ref rename to test/asm/6502-cpudetect.ref diff --git a/test/assembler/6502-opcodes.ref b/test/asm/6502-opcodes.ref similarity index 100% rename from test/assembler/6502-opcodes.ref rename to test/asm/6502-opcodes.ref diff --git a/test/assembler/6502-opcodes.s b/test/asm/6502-opcodes.s similarity index 100% rename from test/assembler/6502-opcodes.s rename to test/asm/6502-opcodes.s diff --git a/test/assembler/6502x-cpudetect.ref b/test/asm/6502x-cpudetect.ref similarity index 100% rename from test/assembler/6502x-cpudetect.ref rename to test/asm/6502x-cpudetect.ref diff --git a/test/assembler/6502x-opcodes.ref b/test/asm/6502x-opcodes.ref similarity index 100% rename from test/assembler/6502x-opcodes.ref rename to test/asm/6502x-opcodes.ref diff --git a/test/assembler/6502x-opcodes.s b/test/asm/6502x-opcodes.s similarity index 100% rename from test/assembler/6502x-opcodes.s rename to test/asm/6502x-opcodes.s diff --git a/test/assembler/65816-cpudetect.ref b/test/asm/65816-cpudetect.ref similarity index 100% rename from test/assembler/65816-cpudetect.ref rename to test/asm/65816-cpudetect.ref diff --git a/test/assembler/65c02-cpudetect.ref b/test/asm/65c02-cpudetect.ref similarity index 100% rename from test/assembler/65c02-cpudetect.ref rename to test/asm/65c02-cpudetect.ref diff --git a/test/assembler/65c02-opcodes.ref b/test/asm/65c02-opcodes.ref similarity index 100% rename from test/assembler/65c02-opcodes.ref rename to test/asm/65c02-opcodes.ref diff --git a/test/assembler/65c02-opcodes.s b/test/asm/65c02-opcodes.s similarity index 100% rename from test/assembler/65c02-opcodes.s rename to test/asm/65c02-opcodes.s diff --git a/test/assembler/65sc02-cpudetect.ref b/test/asm/65sc02-cpudetect.ref similarity index 100% rename from test/assembler/65sc02-cpudetect.ref rename to test/asm/65sc02-cpudetect.ref diff --git a/test/assembler/65sc02-opcodes.ref b/test/asm/65sc02-opcodes.ref similarity index 100% rename from test/assembler/65sc02-opcodes.ref rename to test/asm/65sc02-opcodes.ref diff --git a/test/assembler/65sc02-opcodes.s b/test/asm/65sc02-opcodes.s similarity index 100% rename from test/assembler/65sc02-opcodes.s rename to test/asm/65sc02-opcodes.s diff --git a/test/assembler/Makefile b/test/asm/Makefile similarity index 100% rename from test/assembler/Makefile rename to test/asm/Makefile diff --git a/test/assembler/README b/test/asm/README similarity index 100% rename from test/assembler/README rename to test/asm/README diff --git a/test/assembler/cpudetect.s b/test/asm/cpudetect.s similarity index 100% rename from test/assembler/cpudetect.s rename to test/asm/cpudetect.s diff --git a/test/assembler/huc6280-cpudetect.ref b/test/asm/huc6280-cpudetect.ref similarity index 100% rename from test/assembler/huc6280-cpudetect.ref rename to test/asm/huc6280-cpudetect.ref diff --git a/test/assembler/huc6280-opcodes.ref b/test/asm/huc6280-opcodes.ref similarity index 100% rename from test/assembler/huc6280-opcodes.ref rename to test/asm/huc6280-opcodes.ref diff --git a/test/assembler/huc6280-opcodes.s b/test/asm/huc6280-opcodes.s similarity index 100% rename from test/assembler/huc6280-opcodes.s rename to test/asm/huc6280-opcodes.s diff --git a/test/assembler/m740-opcodes.s b/test/asm/m740-opcodes.s similarity index 100% rename from test/assembler/m740-opcodes.s rename to test/asm/m740-opcodes.s diff --git a/test/disassembler/4510-disass.s b/test/dasm/4510-disass.s similarity index 100% rename from test/disassembler/4510-disass.s rename to test/dasm/4510-disass.s diff --git a/test/disassembler/Makefile b/test/dasm/Makefile similarity index 100% rename from test/disassembler/Makefile rename to test/dasm/Makefile From 4a6bca0b560ae2c1a7cfe3b14f75ee38094b9b76 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 19 Mar 2017 20:07:19 +0100 Subject: [PATCH 040/199] Run test for the 65C02 code generator / runtime too. Now that sim65's 65C02 support is actually functional we can run test for the 65C02 support in the compiler and the runtime. We learn the hard way this is a good idea as there are tests failing when built with optimizations for the 65C02: - val/compare7 - val/compare8 - val/compare9 - val/compare10 - val/or1 --- test/misc/Makefile | 27 ++++++++++++++------------- test/ref/Makefile | 11 ++++++----- test/val/Makefile | 18 +++++++++++++----- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/test/misc/Makefile b/test/misc/Makefile index 6512a9fd9..06ee2a84f 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -20,7 +20,6 @@ else DEL = $(RM) $1 endif -CC65FLAGS = -t sim6502 SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) @@ -38,7 +37,8 @@ CFLAGS = -O2 .PHONY: all clean SOURCES := $(wildcard *.c) -TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg)) +TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg)) +TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg)) all: $(TESTS) @@ -51,34 +51,35 @@ $(DIFF): ../bdiff.c | $(WORKDIR) define PRG_template # should compile, but then hangs in an endless loop -$(WORKDIR)/endless.$1.prg: endless.c | $(WORKDIR) - $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< +$(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR) + $(CL65) -t sim$2 -$1 -o $$@ $$< $(NOT) $(SIM65) $(SIM65FLAGS) $$@ # these need reference data that can't be generated by a host-compiled program, # in a useful way -$(WORKDIR)/limits.$1.prg: limits.c $(DIFF) - $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< +$(WORKDIR)/limits.$1.$2.prg: limits.c $(DIFF) + $(CL65) -t sim$2 -$1 -o $$@ $$< $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.out $(DIFF) $(WORKDIR)/limits.$1.out limits.ref # the rest are tests that fail currently for one reason or another -$(WORKDIR)/fields.$1.prg: fields.c | $(WORKDIR) +$(WORKDIR)/fields.$1.$2.prg: fields.c | $(WORKDIR) @echo "FIXME: " $$@ "currently will fail." - $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + $(CL65) -t sim$2 -$1 -o $$@ $$< -$(SIM65) $(SIM65FLAGS) $$@ -$(WORKDIR)/sitest.$1.prg: sitest.c | $(WORKDIR) +$(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR) @echo "FIXME: " $$@ "currently will fail." - -$(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + -$(CL65) -t sim$2 -$1 -o $$@ $$< # -$(SIM65) $(SIM65FLAGS) $$@ -$(WORKDIR)/cc65141011.$1.prg: cc65141011.c | $(WORKDIR) +$(WORKDIR)/cc65141011.$1.$2.prg: cc65141011.c | $(WORKDIR) @echo "FIXME: " $$@ "currently can fail." - $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + $(CL65) -t sim$2 -$1 -o $$@ $$< -$(SIM65) $(SIM65FLAGS) $$@ endef # PRG_template -$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option)))) +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502))) +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02))) clean: @$(call RMDIR,$(WORKDIR)) diff --git a/test/ref/Makefile b/test/ref/Makefile index 7bd10cf14..55c859af1 100644 --- a/test/ref/Makefile +++ b/test/ref/Makefile @@ -19,7 +19,6 @@ else DEL = $(RM) $1 endif -CC65FLAGS = -t sim6502 SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) @@ -38,7 +37,8 @@ CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow SOURCES := $(wildcard *.c) REFS = $(SOURCES:%.c=$(WORKDIR)/%.ref) -TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg)) +TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg)) +TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg)) all: $(REFS) $(TESTS) @@ -70,14 +70,15 @@ $(WORKDIR)/yaccdbg.%.prg: yacc.c define PRG_template -$(WORKDIR)/%.$1.prg: %.c $(WORKDIR)/%.ref $(DIFF) - $(CL65) $$(CC65FLAGS) -$1 -o $$@ $$< +$(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(DIFF) + $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.out $(DIFF) $(WORKDIR)/$$*.out $(WORKDIR)/$$*.ref endef # PRG_template -$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option)))) +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502))) +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02))) clean: @$(call RMDIR,$(WORKDIR)) diff --git a/test/val/Makefile b/test/val/Makefile index 8a07045ee..425d8ace6 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -14,7 +14,6 @@ else DEL = $(RM) $1 endif -CC65FLAGS = -t sim6502 SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) @@ -27,7 +26,15 @@ OPTIONS = g O Os Osi Osir Oi Oir Or .PHONY: all clean SOURCES := $(wildcard *.c) -TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg)) +TESTS := $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg)) +TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg)) + +# FIXME: These tests fail when built with optimizations for the 65c02 +TESTS := $(filter-out $(WORKDIR)/compare7.O%.65c02.prg,$(TESTS)) +TESTS := $(filter-out $(WORKDIR)/compare8.O%.65c02.prg,$(TESTS)) +TESTS := $(filter-out $(WORKDIR)/compare9.O%.65c02.prg,$(TESTS)) +TESTS := $(filter-out $(WORKDIR)/compare10.O%.65c02.prg,$(TESTS)) +TESTS := $(filter-out $(WORKDIR)/or1.O%.65c02.prg,$(TESTS)) all: $(TESTS) @@ -46,13 +53,14 @@ $(WORKDIR)/cq84.%.prg: CC65FLAGS += -Wc --all-cdecl define PRG_template -$(WORKDIR)/%.$1.prg: %.c | $(WORKDIR) - $(CL65) $$(CC65FLAGS) -$1 -o $$@ $$< +$(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR) + $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(SIM65) $(SIM65FLAGS) $$@ endef # PRG_template -$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option)))) +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502))) +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02))) clean: @$(call RMDIR,$(WORKDIR)) From 50174d98601856b656ea07e03aaed7b9250752c8 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 19 Mar 2017 20:32:23 +0100 Subject: [PATCH 041/199] Hide stdout of tests returning an exit code. Now that we doubled our tests by running them for both 6502 and 65C02 Travis CI complains (again) about a too long build output. So let's reduce it by omitting the (useless) stdout of tests. --- test/val/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/val/Makefile b/test/val/Makefile index 425d8ace6..2ae3e3b28 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -5,10 +5,14 @@ ifneq ($(shell echo),) endif ifdef CMD_EXE + S = $(subst /,\,/) + NULLDEV = nul: MKDIR = mkdir $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1) DEL = del /f $(subst /,\,$1) else + S = / + NULLDEV = /dev/null MKDIR = mkdir -p $1 RMDIR = $(RM) -r $1 DEL = $(RM) $1 @@ -17,7 +21,7 @@ endif SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) -SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65) +SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ../../testwrk/val @@ -55,7 +59,7 @@ define PRG_template $(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR) $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< - $(SIM65) $(SIM65FLAGS) $$@ + $(SIM65) $(SIM65FLAGS) $$@ >$(NULLDEV) endef # PRG_template From 1abfa982902ba04b333e42e415ec540689d5d704 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sun, 19 Mar 2017 20:51:54 +0100 Subject: [PATCH 042/199] minor style changes --- libsrc/runtime/along.s | 1 - libsrc/runtime/lsave.s | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libsrc/runtime/along.s b/libsrc/runtime/along.s index 25eb78c45..bd3462915 100644 --- a/libsrc/runtime/along.s +++ b/libsrc/runtime/along.s @@ -18,4 +18,3 @@ aulong: ldx #0 store: stx sreg stx sreg+1 rts - \ No newline at end of file diff --git a/libsrc/runtime/lsave.s b/libsrc/runtime/lsave.s index 82703073a..d5f4c45b3 100644 --- a/libsrc/runtime/lsave.s +++ b/libsrc/runtime/lsave.s @@ -2,7 +2,7 @@ ; Ullrich von Bassewitz, 08.08.1998 ; Christian Krueger, 11-Mar-2017, optimization ; -; CC65 runtime: save ax into temp storage/restore ax from temp storage +; CC65 runtime: save eax into temp storage/restore eax from temp storage ; .export saveeax, resteax @@ -25,4 +25,3 @@ resteax: ldx regsave+1 lda regsave rts - From 0851e3d6942d8ebd27f13cc41dd631b6b55cf429 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Mon, 20 Mar 2017 11:22:04 +0100 Subject: [PATCH 043/199] Allow to control test Makefile output via QUIET (like libsrc). --- .travis.yml | 2 +- test/Makefile | 4 ---- test/asm/Makefile | 6 ++++++ test/dasm/Makefile | 5 +++++ test/err/Makefile | 14 ++++++++++++-- test/misc/Makefile | 30 ++++++++++++++++++++---------- test/ref/Makefile | 15 ++++++++++++--- test/val/Makefile | 13 ++++++++++--- 8 files changed, 66 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 10ea789cf..fd2672887 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ install: script: - make bin USER_CFLAGS=-Werror - make lib QUIET=1 - - make -C test + - make -C test QUIET=1 - make -C src clean - make bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32- - make doc zip diff --git a/test/Makefile b/test/Makefile index d0bee8ed8..c85883517 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,9 +1,5 @@ # top-level Makefile for the regression tests -# You can comment this special target when you debug the regression tests. -# Then, make will give you more progress reports. -.SILENT: - ifneq ($(shell echo),) CMD_EXE = 1 endif diff --git a/test/asm/Makefile b/test/asm/Makefile index fb840446c..93210aaee 100644 --- a/test/asm/Makefile +++ b/test/asm/Makefile @@ -16,6 +16,10 @@ else DEL = $(RM) $1 endif +ifdef QUIET + .SILENT: +endif + CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) WORKDIR = ../../testwrk/asm @@ -46,6 +50,7 @@ $(DIFF): ../bdiff.c | $(WORKDIR) define OPCODE_template $(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(DIFF) + $(if $(QUIET),echo asm/$1-opcodes.bin) $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $$@ $$< $(DIFF) $$@ $1-opcodes.ref @@ -56,6 +61,7 @@ $(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu)))) define CPUDETECT_template $(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(DIFF) + $(if $(QUIET),echo asm/$1-cpudetect.bin) $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $$@ $$< $(DIFF) $$@ $1-cpudetect.ref diff --git a/test/dasm/Makefile b/test/dasm/Makefile index f8942ef73..d70711491 100644 --- a/test/dasm/Makefile +++ b/test/dasm/Makefile @@ -16,6 +16,10 @@ else DEL = $(RM) $1 endif +ifdef QUIET + .SILENT: +endif + CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) DA65 := $(if $(wildcard ../../bin/da65*),../../bin/da65,da65) @@ -52,6 +56,7 @@ $(WORKDIR)/$1-reass.s: $(WORKDIR)/$1-disass.bin $(DA65) --cpu $1 $(START) -o $$@ $$< $(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(DIFF) + $(if $(QUIET),echo dasm/$1-reass.bin) $(CL65) --cpu $1 -t none $(START) -o $$@ $$< $(DIFF) $$@ $(WORKDIR)/$1-disass.bin diff --git a/test/err/Makefile b/test/err/Makefile index 2bcc1d264..4b05ca5db 100644 --- a/test/err/Makefile +++ b/test/err/Makefile @@ -5,16 +5,25 @@ ifneq ($(shell echo),) endif ifdef CMD_EXE + S = $(subst /,\,/) NOT = - # Hack + NULLDEV = nul: MKDIR = mkdir $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1) else + S = / NOT = ! + NULLDEV = /dev/null MKDIR = mkdir -p $1 RMDIR = $(RM) -r $1 endif -CC65 := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65) +ifdef QUIET + .SILENT: + NULLERR = 2>$(NULLDEV) +endif + +CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65) WORKDIR = ../../testwrk/err @@ -26,7 +35,8 @@ TESTS = $(patsubst %.c,$(WORKDIR)/%.s,$(SOURCES)) all: $(TESTS) $(WORKDIR)/%.s: %.c - $(NOT) $(CC65) -o $@ $< + $(if $(QUIET),echo err/$*.s) + $(NOT) $(CC65) -o $@ $< $(NULLERR) clean: @$(call RMDIR,$(WORKDIR)) diff --git a/test/misc/Makefile b/test/misc/Makefile index 06ee2a84f..39a9a3868 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -8,6 +8,7 @@ ifdef CMD_EXE S = $(subst /,\,/) NOT = - # Hack EXE = .exe + NULLDEV = nul: MKDIR = mkdir $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1) DEL = del /f $(subst /,\,$1) @@ -15,14 +16,21 @@ else S = / NOT = ! EXE = + NULLDEV = /dev/null MKDIR = mkdir -p $1 RMDIR = $(RM) -r $1 DEL = $(RM) $1 endif +ifdef QUIET + .SILENT: + NULLOUT = >$(NULLDEV) + NULLERR = 2>$(NULLDEV) +endif + SIM65FLAGS = -x 200000000 -CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) +CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ..$S..$Stestwrk$Smisc @@ -52,29 +60,31 @@ define PRG_template # should compile, but then hangs in an endless loop $(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR) - $(CL65) -t sim$2 -$1 -o $$@ $$< - $(NOT) $(SIM65) $(SIM65FLAGS) $$@ + $(if $(QUIET),echo misc/endless.$1.$2.prg) + $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) + $(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR) # these need reference data that can't be generated by a host-compiled program, # in a useful way $(WORKDIR)/limits.$1.$2.prg: limits.c $(DIFF) - $(CL65) -t sim$2 -$1 -o $$@ $$< + $(if $(QUIET),echo misc/limits.$1.$2.prg) + $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.out $(DIFF) $(WORKDIR)/limits.$1.out limits.ref # the rest are tests that fail currently for one reason or another $(WORKDIR)/fields.$1.$2.prg: fields.c | $(WORKDIR) @echo "FIXME: " $$@ "currently will fail." - $(CL65) -t sim$2 -$1 -o $$@ $$< - -$(SIM65) $(SIM65FLAGS) $$@ + $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) + -$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR) @echo "FIXME: " $$@ "currently will fail." - -$(CL65) -t sim$2 -$1 -o $$@ $$< -# -$(SIM65) $(SIM65FLAGS) $$@ + -$(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) +# -$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(WORKDIR)/cc65141011.$1.$2.prg: cc65141011.c | $(WORKDIR) @echo "FIXME: " $$@ "currently can fail." - $(CL65) -t sim$2 -$1 -o $$@ $$< - -$(SIM65) $(SIM65FLAGS) $$@ + $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) + -$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) endef # PRG_template diff --git a/test/ref/Makefile b/test/ref/Makefile index 55c859af1..c986513b8 100644 --- a/test/ref/Makefile +++ b/test/ref/Makefile @@ -8,20 +8,27 @@ endif ifdef CMD_EXE S = $(subst /,\,/) EXE = .exe + NULLDEV = nul: MKDIR = mkdir $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1) DEL = del /f $(subst /,\,$1) else S = / EXE = + NULLDEV = /dev/null MKDIR = mkdir -p $1 RMDIR = $(RM) -r $1 DEL = $(RM) $1 endif +ifdef QUIET + .SILENT: + NULLERR = 2>$(NULLDEV) +endif + SIM65FLAGS = -x 200000000 -CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) +CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ..$S..$Stestwrk$Sref @@ -46,7 +53,8 @@ $(WORKDIR): $(call MKDIR,$(WORKDIR)) $(WORKDIR)/%.ref: %.c | $(WORKDIR) - $(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< + $(if $(QUIET),echo ref/$*.host) + $(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(NULLERR) $(WORKDIR)$S$*.host > $@ $(DIFF): ../bdiff.c | $(WORKDIR) @@ -71,7 +79,8 @@ $(WORKDIR)/yaccdbg.%.prg: yacc.c define PRG_template $(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(DIFF) - $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< + $(if $(QUIET),echo ref/$$*.$1.$2.prg) + $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR) $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.out $(DIFF) $(WORKDIR)/$$*.out $(WORKDIR)/$$*.ref diff --git a/test/val/Makefile b/test/val/Makefile index 2ae3e3b28..1981b36fe 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -18,9 +18,15 @@ else DEL = $(RM) $1 endif +ifdef QUIET + .SILENT: + NULLOUT = >$(NULLDEV) + NULLERR = 2>$(NULLDEV) +endif + SIM65FLAGS = -x 200000000 -CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) +CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ../../testwrk/val @@ -58,8 +64,9 @@ $(WORKDIR)/cq84.%.prg: CC65FLAGS += -Wc --all-cdecl define PRG_template $(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR) - $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< - $(SIM65) $(SIM65FLAGS) $$@ >$(NULLDEV) + $(if $(QUIET),echo val/$$*.$1.$2.prg) + $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR) + $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) endef # PRG_template From cc82cd99923caeb3353288789208eb079c73e720 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Mon, 20 Mar 2017 21:53:07 +0100 Subject: [PATCH 044/199] Fixed addressing error for TSB/TSR and enabled tests again. --- src/sim65/6502.c | 4 ++-- test/val/Makefile | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index 0320dd895..b870dd76d 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -470,7 +470,7 @@ static void OPC_65SC02_0C (void) unsigned Addr; unsigned char Val; Cycles = 6; - Addr = MemReadByte (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); Val = MemReadByte (Addr); SET_ZF ((Val & Regs.AC) == 0); MemWriteByte (Addr, (unsigned char) (Val | Regs.AC)); @@ -604,7 +604,7 @@ static void OPC_65SC02_1C (void) unsigned Addr; unsigned char Val; Cycles = 6; - Addr = MemReadByte (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); Val = MemReadByte (Addr); SET_ZF ((Val & Regs.AC) == 0); MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC)); diff --git a/test/val/Makefile b/test/val/Makefile index 1981b36fe..95522a930 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -39,13 +39,6 @@ SOURCES := $(wildcard *.c) TESTS := $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg)) TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg)) -# FIXME: These tests fail when built with optimizations for the 65c02 -TESTS := $(filter-out $(WORKDIR)/compare7.O%.65c02.prg,$(TESTS)) -TESTS := $(filter-out $(WORKDIR)/compare8.O%.65c02.prg,$(TESTS)) -TESTS := $(filter-out $(WORKDIR)/compare9.O%.65c02.prg,$(TESTS)) -TESTS := $(filter-out $(WORKDIR)/compare10.O%.65c02.prg,$(TESTS)) -TESTS := $(filter-out $(WORKDIR)/or1.O%.65c02.prg,$(TESTS)) - all: $(TESTS) $(WORKDIR): From 669113b59521c75434380d974b900550f43b0971 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 21 Mar 2017 20:45:36 +0100 Subject: [PATCH 045/199] Added missing line continuation. Fixes https://github.com/cc65/cc65/issues/408 --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index edb6f5aa8..f4f29b949 100644 --- a/src/Makefile +++ b/src/Makefile @@ -65,7 +65,7 @@ endif CFLAGS += -MMD -MP -O -I common \ -Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \ -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) -DCL65_TGT=$(CL65_TGT) \ - -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG) + -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG) \ -DGIT_SHA=$(GIT_SHA) LDLIBS += -lm From 5b3611265bd97f9263dad6c931a2ae58ed06f42f Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 21 Mar 2017 20:54:55 +0100 Subject: [PATCH 046/199] Revert to recursively expanded var. https://github.com/cc65/cc65/commit/4a6bca0b560ae2c1a7cfe3b14f75ee38094b9b76 needed to move to a simply expanded variable but https://github.com/cc65/cc65/commit/cc82cd99923caeb3353288789208eb079c73e720 made that unnecessary again. --- test/val/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/val/Makefile b/test/val/Makefile index 95522a930..c7539c81b 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -36,7 +36,7 @@ OPTIONS = g O Os Osi Osir Oi Oir Or .PHONY: all clean SOURCES := $(wildcard *.c) -TESTS := $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg)) +TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg)) TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg)) all: $(TESTS) From 8e35a82c91c002f62befbfd29e637d9b1d8b0b0f Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Tue, 21 Mar 2017 22:35:25 +0100 Subject: [PATCH 047/199] Fix regression of #pragma bss-name Closes #409 --- cfg/sim6502.cfg | 2 +- cfg/sim65c02.cfg | 2 +- src/cc65/compile.c | 28 +++++++++++++++++++--------- src/cc65/symentry.c | 1 + src/cc65/symentry.h | 2 ++ test/err/bss-name-conflict.c | 20 ++++++++++++++++++++ test/val/bss-name-decl.c | 22 ++++++++++++++++++++++ test/val/bss-name.c | 21 +++++++++++++++++++++ 8 files changed, 87 insertions(+), 11 deletions(-) create mode 100644 test/err/bss-name-conflict.c create mode 100644 test/val/bss-name-decl.c create mode 100644 test/val/bss-name.c diff --git a/cfg/sim6502.cfg b/cfg/sim6502.cfg index b4f7738f5..530787489 100644 --- a/cfg/sim6502.cfg +++ b/cfg/sim6502.cfg @@ -3,7 +3,7 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack } MEMORY { - ZP: file = "", start = $0000, size = $001A; + ZP: file = "", start = $0000, size = $001B; HEADER: file = %O, start = $0000, size = $0001; MAIN: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__; } diff --git a/cfg/sim65c02.cfg b/cfg/sim65c02.cfg index b4f7738f5..530787489 100644 --- a/cfg/sim65c02.cfg +++ b/cfg/sim65c02.cfg @@ -3,7 +3,7 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack } MEMORY { - ZP: file = "", start = $0000, size = $001A; + ZP: file = "", start = $0000, size = $001B; HEADER: file = %O, start = $0000, size = $0001; MAIN: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__; } diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 48a5c29d3..4425b6aad 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -242,16 +242,24 @@ static void Parse (void) Error ("Variable `%s' has unknown size", Decl.Ident); } Entry->Flags &= ~(SC_STORAGE | SC_DEF); + } else { + /* A global (including static) uninitialized variable + ** is only a tentative definition. For example, this is valid: + ** int i; + ** int i; + ** static int j; + ** static int j = 42; + ** Code for these will be generated in FinishCompile. + ** For now, just save the BSS segment name + ** (can be set with #pragma bss-name) + */ + const char* bssName = GetSegName (SEG_BSS); + if (Entry->V.BssName && strcmp (Entry->V.BssName, bssName) != 0) { + Error ("Global variable `%s' has already been defined in `%s' segment", + Entry->Name, Entry->V.BssName); + } + Entry->V.BssName = xstrdup (bssName); } - - /* A global (including static) uninitialized variable - ** is only a tentative definition. For example, this is valid: - ** int i; - ** int i; - ** static int j; - ** static int j = 42; - ** Code for these will be generated in FinishCompile. - */ } } @@ -418,6 +426,8 @@ void FinishCompile (void) } else if ((Entry->Flags & (SC_STORAGE | SC_DEF | SC_STATIC)) == (SC_STORAGE | SC_STATIC)) { /* Tentative definition of uninitialized global variable */ g_usebss (); + SetSegName (SEG_BSS, Entry->V.BssName); + g_segname (SEG_BSS); /* TODO: skip if same as before */ g_defgloblabel (Entry->Name); g_res (SizeOf (Entry->Type)); /* Mark as defined, so that it will be exported not imported */ diff --git a/src/cc65/symentry.c b/src/cc65/symentry.c index 980ee27f2..d6e68d1bb 100644 --- a/src/cc65/symentry.c +++ b/src/cc65/symentry.c @@ -71,6 +71,7 @@ SymEntry* NewSymEntry (const char* Name, unsigned Flags) E->Type = 0; E->Attr = 0; E->AsmName = 0; + E->V.BssName = 0; memcpy (E->Name, Name, Len+1); /* Return the new entry */ diff --git a/src/cc65/symentry.h b/src/cc65/symentry.h index 4fa84255b..ff136702f 100644 --- a/src/cc65/symentry.h +++ b/src/cc65/symentry.h @@ -153,6 +153,8 @@ struct SymEntry { struct LiteralPool* LitPool; /* Literal pool for this function */ } F; + /* Segment name for tentantive global definitions */ + const char* BssName; } V; char Name[1]; /* Name, dynamically allocated */ }; diff --git a/test/err/bss-name-conflict.c b/test/err/bss-name-conflict.c new file mode 100644 index 000000000..1d6cd5066 --- /dev/null +++ b/test/err/bss-name-conflict.c @@ -0,0 +1,20 @@ +/* + !!DESCRIPTION!! conflicting bss-name pragmas + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/409 +*/ + +char oam_off; +#pragma bss-name (push,"ZEROPAGE") +char oam_off; +#pragma bss-name (pop) + +int main(void) +{ + return 0; +} diff --git a/test/val/bss-name-decl.c b/test/val/bss-name-decl.c new file mode 100644 index 000000000..9a535844e --- /dev/null +++ b/test/val/bss-name-decl.c @@ -0,0 +1,22 @@ +/* + !!DESCRIPTION!! bss-name pragma not affecting declarations + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/409 +*/ + +#pragma bss-name (push,"ZEROPAGE") + +char n; /* only a declaration because followed by definition */ +char n = 1; /* not BSS */ + +#pragma bss-name (pop) + +int main(void) +{ + return (unsigned) &n >= 0x100 ? 0 : 1; +} diff --git a/test/val/bss-name.c b/test/val/bss-name.c new file mode 100644 index 000000000..f0ad7111e --- /dev/null +++ b/test/val/bss-name.c @@ -0,0 +1,21 @@ +/* + !!DESCRIPTION!! bss-name pragma + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/409 +*/ + +#pragma bss-name (push,"ZEROPAGE") + +char zp_var; + +#pragma bss-name (pop) + +int main(void) +{ + return (unsigned) &zp_var < 0x100 ? 0 : 1; +} From 01f5baf03defacf5b4bed9536883559b7aeca8b6 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 21 Mar 2017 21:23:48 -0400 Subject: [PATCH 048/199] Fixed SGML typo. --- doc/cc65.sgml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 6a08cc3c3..2a0fa0260 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -4,7 +4,7 @@ <title>cc65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:gregdk@users.sf.net" name="Greg King"> -<date>2017-02-27 +<date>2017-03-21 <abstract> cc65 is a C compiler for 6502 targets. It supports several 6502 based home @@ -1276,7 +1276,7 @@ that function). As a shortcut, you can put the <tt/volatile/ qualifier in your <tt/asm/ statements. It will disable optimization for the functions in which those <tt/asm volatile/ statements sit. The effect is the same as though you put -</#pragma optimize(push, off)/ above those functions, and </#pragma +<tt/#pragma optimize(push, off)/ above those functions, and <tt/#pragma optimize(pop)/ below those functions. The string literal may contain format specifiers from the following list. For From 170d96898f3d744f131aa9c3a3cff8cf0463078c Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Thu, 30 Mar 2017 12:17:29 +0200 Subject: [PATCH 049/199] Fixed SED --- src/sim65/6502.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index 0320dd895..87cef2db6 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -39,6 +39,8 @@ 6502) * one cycle win for fetch-modify-write instructions ignored (e.g. ROL abs,x takes only 6 cycles if no page break occurs) + * BRK, IRQ, NMI and RESET are not different from 6502 which they are in + reality (e.g. D-flag handling) */ #include "memory.h" @@ -2581,7 +2583,9 @@ static void OPC_6502_F6 (void) static void OPC_6502_F8 (void) /* Opcode $F8: SED */ { + Cycles = 2; SET_DF (1); + Regs.PC += 1; } From 02daf9f8b5c1ae2267561ee05ce67b2d0393c12d Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Mon, 3 Apr 2017 23:20:26 +0200 Subject: [PATCH 050/199] So far the built-in inlining of several known standard function was always (!) enabled and the option -Os enabled additional, potentially unsafe inlining of some of those functions. There were two aspects of this behavior that were considered undesirable: - Although the safe inlining is in general desirable it should only be enabled if asked for it - like any other optimization. - The option name -Os implies that it is a safe option, the potentially unsafe inlining should have a more explicit name. So now: - The option -Os enables the safe inlining. - The new option --eagerly-inline-funcs enables the potentially unsafe inlining (including the safe inlining). Additionally was added: - The option --inline-stdfuncs that does like -Os enable the safe inlining but doesn't enable optimizations. - The pragma inline-stdfuncs that works identical to --inline-stdfuncs. - The pragma allow-eager-inline that enables the potentially unsafe inlining but doesn't include the safe inlining. That means that by itself it only marks code as safe for potentially unsafe inlining but doesn't actually enable any inlining. --- doc/cc65.sgml | 294 +++++---- doc/cl65.sgml | 4 +- include/ctype.h | 4 +- src/cc65/compile.c | 19 +- src/cc65/global.c | 3 +- src/cc65/global.h | 3 +- src/cc65/main.c | 91 +-- src/cc65/pragma.c | 62 +- src/cc65/stdfunc.c | 1421 +++++++++++++++++++++++--------------------- 9 files changed, 1033 insertions(+), 868 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 2a0fa0260..9322a2d44 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -58,7 +58,7 @@ Short options: -O Optimize code -Oi Optimize code, inline more code -Or Enable register variables - -Os Inline some known functions + -Os Inline some standard functions -T Include source as comment -V Print the compiler version number -W warning[,...] Suppress warnings @@ -88,9 +88,11 @@ Long options: --debug-opt name Debug optimization steps --dep-target target Use this dependency target --disable-opt name Disable an optimization step + --eagerly-inline-funcs Eagerly inline some known functions --enable-opt name Enable an optimization step --help Help (this text) --include-dir dir Set an include directory search path + --inline-stdfuncs Inline some standard functions --list-opt-steps List all optimizer steps and exit --list-warnings List available warning types for -W --local-strings Emit string literals immediately @@ -219,11 +221,53 @@ Here is a description of all the command line options: symbols in a special section in the object file. + <label id="option-eagerly-inline-funcs"> + <tag><tt>--eagerly-inline-funcs</tt></tag> + + Have the compiler eagerly inline these functions from the C library: + <itemize> + <item><tt/memcpy()/ + <item><tt/memset()/ + <item><tt/strcmp()/ + <item><tt/strcpy()/ + <item><tt/strlen()/ + <item>most of the functions declared in <tt/<ctype.h>/ + </itemize> + + Note: This has two consequences: + <itemize> + <item>You may not use names of standard C functions for your own functions. + If you do that, your program is not standard-compliant anyway; but, + using <tt/--eagerly-inline-funcs/ actually will break things. + <p> + <item>The inlined string and memory functions will not handle strings or + memory areas larger than 255 bytes. Similarly, the inlined <tt/is..()/ + functions will not work with values outside the char. range (such as + <tt/EOF/). + <p> + </itemize> + + <tt/--eagerly-inline-funcs/ implies the <tt/<ref id="option-inline-stdfuncs" + name="--inline-stdfuncs"/ command line option. + + See also <tt/<ref id="pragma-allow-eager-inline" name="#pragma allow-eager-inline">/. + + <tag><tt>-h, --help</tt></tag> Print the short option summary shown above. + <label id="option-inline-stdfuncs"> + <tag><tt>--inline-stdfuncs</tt></tag> + + Allow the compiler to inline some standard functions from the C library like + strlen. This will not only remove the overhead for a function call, but will + make the code visible for the optimizer. See also the <tt/<ref id="option-O" + name="-Os"/ command line option and <tt/<ref id="pragma-inline-stdfuncs" + name="#pragma inline-stdfuncs">/. + + <label id="option-list-warnings"> <tag><tt>--list-warnings</tt></tag> @@ -392,22 +436,22 @@ Here is a description of all the command line options: using <tscreen><verb> - void f (void) - { - unsigned a = 1; - ... - } + void f (void) + { + unsigned a = 1; + ... + } </verb></tscreen> the variable <tt/a/ will always have the value <tt/1/ when entering the function and using <tt/-Cl/, while in <tscreen><verb> - void f (void) - { - static unsigned a = 1; - .... - } + void f (void) + { + static unsigned a = 1; + .... + } </verb></tscreen> the variable <tt/a/ will have the value <tt/1/ only the first time that the @@ -444,23 +488,13 @@ Here is a description of all the command line options: name="--register-vars">/ command line option, and the <ref id="register-vars" name="discussion of register variables"> below. - Using <tt/-Os/ will force the compiler to inline some known functions from - the C library like strlen. Note: This has two consequences: - <p> - <itemize> - <item>You may not use names of standard C functions in your own code. If you - do that, your program is not standard compliant anyway, but using - <tt/-Os/ will actually break things. - <p> - <item>The inlined string and memory functions will not handle strings or - memory areas larger than 255 bytes. Similarly, the inlined <tt/is..()/ - functions will not work with values outside the char. range (such as - <tt/EOF/). - <p> - </itemize> - <p> + Using <tt/-Os/ will allow the compiler to inline some standard functions + from the C library like strlen. This will not only remove the overhead + for a function call, but will make the code visible for the optimizer. + See also <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs"/. + It is possible to concatenate the modifiers for <tt/-O/. For example, to - enable register variables and inlining of known functions, you may use + enable register variables and inlining of standard functions, you may use <tt/-Ors/. @@ -518,6 +552,7 @@ Here is a description of all the command line options: </descrip><p> + <sect>Input and output<p> The compiler will accept one C file per invocation and create a file with @@ -556,21 +591,21 @@ and the one defined by the ISO standard: <itemize> -<item> The datatypes "float" and "double" are not available. - <p> -<item> C Functions may not return structs (or unions), and structs may not +<item> The datatypes "float" and "double" are not available. + <p> +<item> C Functions may not return structs (or unions), and structs may not be passed as parameters by value. However, struct assignment *is* - possible. - <p> -<item> Most of the C library is available with only the fastcall calling - convention (<ref id="extension-fastcall" name="see below">). It means - that you must not mix pointers to those functions with pointers to - user-written, cdecl functions (the calling conventions are incompatible). - <p> -<item> The <tt/volatile/ keyword has almost no effect. That is not as bad + possible. + <p> +<item> Most of the C library is available with only the fastcall calling + convention (<ref id="extension-fastcall" name="see below">). It means + that you must not mix pointers to those functions with pointers to + user-written, cdecl functions (the calling conventions are incompatible). + <p> +<item> The <tt/volatile/ keyword has almost no effect. That is not as bad as it sounds, since the 6502 has so few registers that it isn't possible to keep values in registers anyway. - <p> + <p> </itemize> There may be some more minor differences I'm currently not aware of. The @@ -585,49 +620,48 @@ This cc65 version has some extensions to the ISO C standard. <itemize> -<item> The compiler allows to insert assembler statements into the output - file. The syntax is +<item> The compiler allows to insert assembler statements into the output + file. The syntax is - <tscreen><verb> - asm [optional volatile] (<string literal>[, optional parameters]) ; - </verb></tscreen> - or - <tscreen><verb> + <tscreen><verb> + asm [optional volatile] (<string literal>[, optional parameters]) ; + </verb></tscreen> + or + <tscreen><verb> __asm__ [optional volatile] (<string literal>[, optional parameters]) ; - </verb></tscreen> + </verb></tscreen> - The first form is in the user namespace; and, is disabled if the <tt/-A/ - switch is given. + The first form is in the user namespace; and, is disabled if the <tt/-A/ + switch is given. - There is a whole section covering inline assembler statements, - <ref id="inline-asm" name="see there">. - <p> + There is a whole section covering inline assembler statements, + <ref id="inline-asm" name="see there">. + <p> <label id="extension-fastcall"> -<item> The normal calling convention -- for non-variadic functions -- is - named "fastcall". The syntax for a function declaration that - <em/explicitly/ uses fastcall is +<item> The normal calling convention -- for non-variadic functions -- is + named "fastcall". The syntax for a function declaration that + <em/explicitly/ uses fastcall is - <tscreen><verb> - <return type> fastcall <function name> (<parameter list>) - </verb></tscreen> - or - <tscreen><verb> - <return type> __fastcall__ <function name> (<parameter list>) - </verb></tscreen> - An example is - <tscreen><verb> - void __fastcall__ f (unsigned char c) - </verb></tscreen> - The first form of the fastcall keyword is in the user namespace and can - therefore be disabled with the <tt><ref id="option--standard" + <tscreen><verb> + <return type> fastcall <function name> (<parameter list>) + </verb></tscreen> + or + <tscreen><verb> + <return type> __fastcall__ <function name> (<parameter list>) + </verb></tscreen> + An example is + <tscreen><verb> + void __fastcall__ f (unsigned char c) + </verb></tscreen> + The first form of the fastcall keyword is in the user namespace and can + therefore be disabled with the <tt><ref id="option--standard" name="--standard"></tt> command line option. - For functions that are <tt/fastcall/, the rightmost parameter is not - pushed on the stack but left in the primary register when the function - is called. That significantly reduces the cost of calling those functions. - <newline><newline> - <p> + For functions that are <tt/fastcall/, the rightmost parameter is not + pushed on the stack but left in the primary register when the function + is called. That significantly reduces the cost of calling those functions. + <p> <item> There is another calling convention named "cdecl". Variadic functions (their prototypes have an ellipsis [<tt/.../]) always use that @@ -652,40 +686,40 @@ This cc65 version has some extensions to the ISO C standard. For functions that are <tt/cdecl/, the rightmost parameter is pushed onto the stack before the function is called. That increases the cost of calling those functions, especially when they are called from many - places.<newline><newline> + places. <p> -<item> There are two pseudo variables named <tt/__AX__/ and <tt/__EAX__/. - Both refer to the primary register that is used by the compiler to - evaluate expressions or return function results. <tt/__AX__/ is of - type <tt/unsigned int/ and <tt/__EAX__/ of type <tt/long unsigned int/ - respectively. The pseudo variables may be used as lvalue and rvalue as - every other variable. They are most useful together with short - sequences of assembler code. For example, the macro +<item> There are two pseudo variables named <tt/__AX__/ and <tt/__EAX__/. + Both refer to the primary register that is used by the compiler to + evaluate expressions or return function results. <tt/__AX__/ is of + type <tt/unsigned int/ and <tt/__EAX__/ of type <tt/long unsigned int/ + respectively. The pseudo variables may be used as lvalue and rvalue as + every other variable. They are most useful together with short + sequences of assembler code. For example, the macro - <tscreen><verb> - #define hi(x) \ + <tscreen><verb> + #define hi(x) \ (__AX__ = (x), \ asm ("txa"), \ asm ("ldx #$00"), \ __AX__) - </verb></tscreen> + </verb></tscreen> - will give the high byte of any unsigned value. - <p> + will give the high byte of any unsigned value. + <p> -<item> Inside a function, the identifier <tt/__func__/ gives the name of the - current function as a string. Outside of functions, <tt/__func__/ is - undefined. - Example: +<item> Inside a function, the identifier <tt/__func__/ gives the name of the + current function as a string. Outside of functions, <tt/__func__/ is + undefined. + Example: - <tscreen><verb> - #define PRINT_DEBUG(s) printf ("%s: %s\n", __func__, s); - </verb></tscreen> + <tscreen><verb> + #define PRINT_DEBUG(s) printf ("%s: %s\n", __func__, s); + </verb></tscreen> - The macro will print the name of the current function plus a given - string. - <p> + The macro will print the name of the current function plus a given + string. + <p> <item> cc65 allows the initialization of <tt/void/ variables. This may be used to create arbitrary structures that are more compatible with @@ -825,6 +859,11 @@ The compiler defines several macros at startup: This macro expands to the date of translation of the preprocessing translation unit in the form "Mmm dd yyyy". + <tag><tt>__EAGERLY_INLINE_FUNCS__</tt></tag> + + Is defined if the compiler was called with the <tt/<ref id="option-eagerly-inline-funcs" + name="--eagerly-inline-funcs"/ command line option. + <tag><tt>__FILE__</tt></tag> This macro expands to a string containing the name of the C source file. @@ -912,6 +951,7 @@ The compiler defines several macros at startup: </descrip> + <sect>#pragmas<label id="pragmas"><p> The compiler understands some pragmas that may be used to change code @@ -920,6 +960,19 @@ If the first parameter is <tt/push/, the old value is saved onto a stack before changing it. The value may later be restored by using the <tt/pop/ parameter with the <tt/#pragma/. + +<sect1><tt>#pragma allow-eager-inline ([push,] on|off)</tt><label id="pragma-allow-eager-inline"><p> + + Allow eager inlining of known functions. If the argument is "off", eager + inlining is disabled, otherwise it is enabled. Please note that (in contrast + to the <tt/<ref id="option-eagerly-inline-funcs" name="--eagerly-inline-funcs"/ + command line option) this pragma does not imply the <tt/<ref id="option-inline-stdfuncs" + name="--inline-stdfuncs"/ command line option. Rather it marks code to be safe for + eager inlining of known functions if inlining of standard functions is enabled. + + The <tt/#pragma/ understands the push and pop parameters as explained above. + + <sect1><tt>#pragma bss-name ([push,] <name>)</tt><label id="pragma-bss-name"><p> This pragma changes the name used for the BSS segment (the BSS segment @@ -938,7 +991,7 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> - #pragma bss-name ("MyBSS") + #pragma bss-name ("MyBSS") </verb></tscreen> @@ -993,6 +1046,7 @@ parameter with the <tt/#pragma/. The <tt/#pragma/ understands the push and pop parameters as explained above. + <sect1><tt>#pragma code-name ([push,] <name>)</tt><label id="pragma-code-name"><p> This pragma changes the name used for the CODE segment (the CODE segment @@ -1007,7 +1061,7 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> - #pragma code-name ("MyCODE") + #pragma code-name ("MyCODE") </verb></tscreen> @@ -1035,10 +1089,21 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> - #pragma data-name ("MyDATA") + #pragma data-name ("MyDATA") </verb></tscreen> +<sect1><tt>#pragma inline-stdfuncs ([push,] on|off)</tt><label id="pragma-inline-stdfuncs"><p> + + Allow the compiler to inline some standard functions from the C library like + strlen. If the argument is "off", inlining is disabled, otherwise it is enabled. + + See also the the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs"/ + command line option. + + The <tt/#pragma/ understands the push and pop parameters as explained above. + + <sect1><tt>#pragma local-strings ([push,] on|off)</tt><label id="pragma-local-strings"><p> When "on", emit string literals to the data segment when they're encountered @@ -1083,7 +1148,7 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> - #pragma rodata-name ("MyRODATA") + #pragma rodata-name ("MyRODATA") </verb></tscreen> @@ -1105,9 +1170,9 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> - #pragma regvaraddr(on) /* Allow taking the address - * of register variables - */ + #pragma regvaraddr(on) /* Allow taking the address + * of register variables + */ </verb></tscreen> @@ -1154,7 +1219,7 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> /* Don't warn about the unused parameter in function func */ - #pragma warn (unused-param, push, off) + #pragma warn (unused-param, push, off) static int func (int unused) { return 0; @@ -1187,13 +1252,12 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> - extern int foo; - #pragma zpsym ("foo"); /* foo is in the zeropage */ + extern int foo; + #pragma zpsym ("foo"); /* foo is in the zeropage */ </verb></tscreen> - <sect>Register variables<label id="register-vars"><p> The runtime for all supported platforms has 6 bytes of zero page space @@ -1450,14 +1514,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: <enum> -<item> 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. -<item> Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. -<item> This notice may not be removed or altered from any source - distribution. +<item> 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. +<item> Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. +<item> This notice may not be removed or altered from any source + distribution. </enum> </article> diff --git a/doc/cl65.sgml b/doc/cl65.sgml index eef6a12a3..ffeba2321 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -54,9 +54,9 @@ Short options: -L path Specify a library search path -Ln name Create a VICE label file -O Optimize code - -Oi Optimize code, inline functions + -Oi Optimize code, inline more code -Or Optimize code, honour the register keyword - -Os Optimize code, inline known C funtions + -Os Optimize code, inline standard funtions -S Compile but don't assemble and link -T Include source as comment -V Print the version number diff --git a/include/ctype.h b/include/ctype.h index b440bfb70..17cbafe9f 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -89,9 +89,9 @@ unsigned char __fastcall__ toascii (unsigned char c); ** #undef'ing the macroes. ** Please note that the following macroes do NOT handle EOF correctly, as ** stated in the manual. If you need correct behaviour for EOF, don't -** use -Os, or #undefine the following macroes. +** use --eagerly-inline-funcs, or #undefine the following macroes. */ -#ifdef __OPT_s__ +#ifdef __EAGERLY_INLINE_FUNCS__ #define isalnum(c) (__AX__ = (c), \ __asm__ ("tay"), \ diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 4425b6aad..3c1042154 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -335,17 +335,22 @@ void Compile (const char* FileName) ** changes using #pragma later. */ if (IS_Get (&Optimize)) { - long CodeSize = IS_Get (&CodeSizeFactor); DefineNumericMacro ("__OPT__", 1); + } + { + long CodeSize = IS_Get (&CodeSizeFactor); if (CodeSize > 100) { DefineNumericMacro ("__OPT_i__", CodeSize); } - if (IS_Get (&EnableRegVars)) { - DefineNumericMacro ("__OPT_r__", 1); - } - if (IS_Get (&InlineStdFuncs)) { - DefineNumericMacro ("__OPT_s__", 1); - } + } + if (IS_Get (&EnableRegVars)) { + DefineNumericMacro ("__OPT_r__", 1); + } + if (IS_Get (&InlineStdFuncs)) { + DefineNumericMacro ("__OPT_s__", 1); + } + if (IS_Get (&EagerlyInlineFuncs)) { + DefineNumericMacro ("__EAGERLY_INLINE_FUNCS__", 1); } /* __TIME__ and __DATE__ macros */ diff --git a/src/cc65/global.c b/src/cc65/global.c index dbdd72f3c..a337549fe 100644 --- a/src/cc65/global.c +++ b/src/cc65/global.c @@ -53,7 +53,8 @@ unsigned RegisterSpace = 6; /* Space available for register vars */ /* Stackable options */ IntStack WritableStrings = INTSTACK(0); /* Literal strings are r/w */ IntStack LocalStrings = INTSTACK(0); /* Emit string literals immediately */ -IntStack InlineStdFuncs = INTSTACK(0); /* Inline some known functions */ +IntStack InlineStdFuncs = INTSTACK(0); /* Inline some standard functions */ +IntStack EagerlyInlineFuncs = INTSTACK(0); /* Eagerly inline some known functions */ IntStack EnableRegVars = INTSTACK(0); /* Enable register variables */ IntStack AllowRegVarAddr = INTSTACK(0); /* Allow taking addresses of register vars */ IntStack RegVarsToCallStack = INTSTACK(0); /* Save reg variables on call stack */ diff --git a/src/cc65/global.h b/src/cc65/global.h index 8b0af5a83..4ffc84a39 100644 --- a/src/cc65/global.h +++ b/src/cc65/global.h @@ -61,7 +61,8 @@ extern unsigned RegisterSpace; /* Space available for register /* Stackable options */ extern IntStack WritableStrings; /* Literal strings are r/w */ extern IntStack LocalStrings; /* Emit string literals immediately */ -extern IntStack InlineStdFuncs; /* Inline some known functions */ +extern IntStack InlineStdFuncs; /* Inline some standard functions */ +extern IntStack EagerlyInlineFuncs; /* Eagerly inline some known functions */ extern IntStack EnableRegVars; /* Enable register variables */ extern IntStack AllowRegVarAddr; /* Allow taking addresses of register vars */ extern IntStack RegVarsToCallStack; /* Save reg variables on call stack */ diff --git a/src/cc65/main.c b/src/cc65/main.c index 9ed19b90c..d3d298876 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -88,7 +88,7 @@ static void Usage (void) " -O\t\t\t\tOptimize code\n" " -Oi\t\t\t\tOptimize code, inline more code\n" " -Or\t\t\t\tEnable register variables\n" - " -Os\t\t\t\tInline some known functions\n" + " -Os\t\t\t\tInline some standard functions\n" " -T\t\t\t\tInclude source as comment\n" " -V\t\t\t\tPrint the compiler version number\n" " -W warning[,...]\t\tSuppress warnings\n" @@ -118,9 +118,11 @@ static void Usage (void) " --debug-opt name\t\tDebug optimization steps\n" " --dep-target target\t\tUse this dependency target\n" " --disable-opt name\t\tDisable an optimization step\n" + " --eagerly-inline-funcs\t\tEagerly inline some known functions\n" " --enable-opt name\t\tEnable an optimization step\n" " --help\t\t\tHelp (this text)\n" " --include-dir dir\t\tSet an include directory search path\n" + " --inline-stdfuncs\t\tInline some standard functions\n" " --list-opt-steps\t\tList all optimizer steps and exit\n" " --list-warnings\t\tList available warning types for -W\n" " --local-strings\t\tEmit string literals immediately\n" @@ -581,6 +583,16 @@ static void OptDisableOpt (const char* Opt attribute ((unused)), const char* Arg +static void OptEagerlyInlineFuncs (const char* Opt attribute((unused)), + const char* Arg attribute((unused))) +/* Eagerly inline some known functions */ +{ + IS_Set (&InlineStdFuncs, 1); + IS_Set (&EagerlyInlineFuncs, 1); +} + + + static void OptEnableOpt (const char* Opt attribute ((unused)), const char* Arg) /* Enable an optimization step */ { @@ -608,6 +620,15 @@ static void OptIncludeDir (const char* Opt attribute ((unused)), const char* Arg +static void OptInlineStdFuncs (const char* Opt attribute((unused)), + const char* Arg attribute((unused))) +/* Inline some standard functions */ +{ + IS_Set (&InlineStdFuncs, 1); +} + + + static void OptListOptSteps (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* List all optimizer steps */ @@ -819,39 +840,41 @@ int main (int argc, char* argv[]) { /* Program long options */ static const LongOpt OptTab[] = { - { "--add-source", 0, OptAddSource }, - { "--all-cdecl", 0, OptAllCDecl }, - { "--bss-name", 1, OptBssName }, - { "--check-stack", 0, OptCheckStack }, - { "--code-name", 1, OptCodeName }, - { "--codesize", 1, OptCodeSize }, - { "--cpu", 1, OptCPU }, - { "--create-dep", 1, OptCreateDep }, - { "--create-full-dep", 1, OptCreateFullDep }, - { "--data-name", 1, OptDataName }, - { "--debug", 0, OptDebug }, - { "--debug-info", 0, OptDebugInfo }, - { "--debug-opt", 1, OptDebugOpt }, - { "--debug-opt-output", 0, OptDebugOptOutput }, - { "--dep-target", 1, OptDepTarget }, - { "--disable-opt", 1, OptDisableOpt }, - { "--enable-opt", 1, OptEnableOpt }, - { "--help", 0, OptHelp }, - { "--include-dir", 1, OptIncludeDir }, - { "--list-opt-steps", 0, OptListOptSteps }, - { "--list-warnings", 0, OptListWarnings }, - { "--local-strings", 0, OptLocalStrings }, - { "--memory-model", 1, OptMemoryModel }, - { "--register-space", 1, OptRegisterSpace }, - { "--register-vars", 0, OptRegisterVars }, - { "--rodata-name", 1, OptRodataName }, - { "--signed-chars", 0, OptSignedChars }, - { "--standard", 1, OptStandard }, - { "--static-locals", 0, OptStaticLocals }, - { "--target", 1, OptTarget }, - { "--verbose", 0, OptVerbose }, - { "--version", 0, OptVersion }, - { "--writable-strings", 0, OptWritableStrings }, + { "--add-source", 0, OptAddSource }, + { "--all-cdecl", 0, OptAllCDecl }, + { "--bss-name", 1, OptBssName }, + { "--check-stack", 0, OptCheckStack }, + { "--code-name", 1, OptCodeName }, + { "--codesize", 1, OptCodeSize }, + { "--cpu", 1, OptCPU }, + { "--create-dep", 1, OptCreateDep }, + { "--create-full-dep", 1, OptCreateFullDep }, + { "--data-name", 1, OptDataName }, + { "--debug", 0, OptDebug }, + { "--debug-info", 0, OptDebugInfo }, + { "--debug-opt", 1, OptDebugOpt }, + { "--debug-opt-output", 0, OptDebugOptOutput }, + { "--dep-target", 1, OptDepTarget }, + { "--disable-opt", 1, OptDisableOpt }, + { "--eagerly-inline-funcs", 0, OptEagerlyInlineFuncs }, + { "--enable-opt", 1, OptEnableOpt }, + { "--help", 0, OptHelp }, + { "--include-dir", 1, OptIncludeDir }, + { "--inline-stdfuncs", 0, OptInlineStdFuncs }, + { "--list-opt-steps", 0, OptListOptSteps }, + { "--list-warnings", 0, OptListWarnings }, + { "--local-strings", 0, OptLocalStrings }, + { "--memory-model", 1, OptMemoryModel }, + { "--register-space", 1, OptRegisterSpace }, + { "--register-vars", 0, OptRegisterVars }, + { "--rodata-name", 1, OptRodataName }, + { "--signed-chars", 0, OptSignedChars }, + { "--standard", 1, OptStandard }, + { "--static-locals", 0, OptStaticLocals }, + { "--target", 1, OptTarget }, + { "--verbose", 0, OptVerbose }, + { "--version", 0, OptVersion }, + { "--writable-strings", 0, OptWritableStrings }, }; unsigned I; diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 86739ce22..707546e1d 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -64,6 +64,7 @@ typedef enum { PRAGMA_ILLEGAL = -1, PRAGMA_ALIGN, + PRAGMA_ALLOW_EAGER_INLINE, PRAGMA_BSS_NAME, PRAGMA_BSSSEG, /* obsolete */ PRAGMA_CHARMAP, @@ -74,6 +75,7 @@ typedef enum { PRAGMA_CODESIZE, PRAGMA_DATA_NAME, PRAGMA_DATASEG, /* obsolete */ + PRAGMA_INLINE_STDFUNCS, PRAGMA_LOCAL_STRINGS, PRAGMA_OPTIMIZE, PRAGMA_REGVARADDR, @@ -96,31 +98,33 @@ static const struct Pragma { const char* Key; /* Keyword */ pragma_t Tok; /* Token */ } Pragmas[PRAGMA_COUNT] = { - { "align", PRAGMA_ALIGN }, - { "bss-name", PRAGMA_BSS_NAME }, - { "bssseg", PRAGMA_BSSSEG }, /* obsolete */ - { "charmap", PRAGMA_CHARMAP }, - { "check-stack", PRAGMA_CHECK_STACK }, - { "checkstack", PRAGMA_CHECKSTACK }, /* obsolete */ - { "code-name", PRAGMA_CODE_NAME }, - { "codeseg", PRAGMA_CODESEG }, /* obsolete */ - { "codesize", PRAGMA_CODESIZE }, - { "data-name", PRAGMA_DATA_NAME }, - { "dataseg", PRAGMA_DATASEG }, /* obsolete */ - { "local-strings", PRAGMA_LOCAL_STRINGS }, - { "optimize", PRAGMA_OPTIMIZE }, - { "register-vars", PRAGMA_REGISTER_VARS }, - { "regvaraddr", PRAGMA_REGVARADDR }, - { "regvars", PRAGMA_REGVARS }, /* obsolete */ - { "rodata-name", PRAGMA_RODATA_NAME }, - { "rodataseg", PRAGMA_RODATASEG }, /* obsolete */ - { "signed-chars", PRAGMA_SIGNED_CHARS }, - { "signedchars", PRAGMA_SIGNEDCHARS }, /* obsolete */ - { "static-locals", PRAGMA_STATIC_LOCALS }, - { "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */ - { "warn", PRAGMA_WARN }, - { "writable-strings", PRAGMA_WRITABLE_STRINGS }, - { "zpsym", PRAGMA_ZPSYM }, + { "align", PRAGMA_ALIGN }, + { "allow-eager-inline", PRAGMA_ALLOW_EAGER_INLINE }, + { "bss-name", PRAGMA_BSS_NAME }, + { "bssseg", PRAGMA_BSSSEG }, /* obsolete */ + { "charmap", PRAGMA_CHARMAP }, + { "check-stack", PRAGMA_CHECK_STACK }, + { "checkstack", PRAGMA_CHECKSTACK }, /* obsolete */ + { "code-name", PRAGMA_CODE_NAME }, + { "codeseg", PRAGMA_CODESEG }, /* obsolete */ + { "codesize", PRAGMA_CODESIZE }, + { "data-name", PRAGMA_DATA_NAME }, + { "dataseg", PRAGMA_DATASEG }, /* obsolete */ + { "inline-stdfuncs", PRAGMA_INLINE_STDFUNCS }, + { "local-strings", PRAGMA_LOCAL_STRINGS }, + { "optimize", PRAGMA_OPTIMIZE }, + { "register-vars", PRAGMA_REGISTER_VARS }, + { "regvaraddr", PRAGMA_REGVARADDR }, + { "regvars", PRAGMA_REGVARS }, /* obsolete */ + { "rodata-name", PRAGMA_RODATA_NAME }, + { "rodataseg", PRAGMA_RODATASEG }, /* obsolete */ + { "signed-chars", PRAGMA_SIGNED_CHARS }, + { "signedchars", PRAGMA_SIGNEDCHARS }, /* obsolete */ + { "static-locals", PRAGMA_STATIC_LOCALS }, + { "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */ + { "warn", PRAGMA_WARN }, + { "writable-strings", PRAGMA_WRITABLE_STRINGS }, + { "zpsym", PRAGMA_ZPSYM }, }; /* Result of ParsePushPop */ @@ -703,6 +707,10 @@ static void ParsePragma (void) IntPragma (&B, &DataAlignment, 1, 4096); break; + case PRAGMA_ALLOW_EAGER_INLINE: + FlagPragma (&B, &EagerlyInlineFuncs); + break; + case PRAGMA_BSSSEG: Warning ("#pragma bssseg is obsolete, please use #pragma bss-name instead"); /* FALLTHROUGH */ @@ -739,6 +747,10 @@ static void ParsePragma (void) SegNamePragma (&B, SEG_DATA); break; + case PRAGMA_INLINE_STDFUNCS: + FlagPragma (&B, &InlineStdFuncs); + break; + case PRAGMA_LOCAL_STRINGS: FlagPragma (&B, &LocalStrings); break; diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index 720e6db15..7a0450146 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -261,262 +261,277 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) goto ExitPoint; } - /* We've generated the complete code for the function now and know the - ** types of all parameters. Check for situations where better code can - ** be generated. If such a situation is detected, throw away the - ** generated, and emit better code. - */ - if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || - (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && - ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || - (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) { + if (IS_Get (&InlineStdFuncs)) { - int Reg1 = ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr); - int Reg2 = ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr); - - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); - - /* We need a label */ - Label = GetLocalLabel (); - - /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127) { - - AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); - g_defcodelabel (Label); - if (Reg2) { - AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0)); - } else { - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, 0)); - } - if (Reg1) { - AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); - } else { - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); - } - AddCodeLine ("dey"); - AddCodeLine ("bpl %s", LocalLabelName (Label)); - - } else { - - AddCodeLine ("ldy #$00"); - g_defcodelabel (Label); - if (Reg2) { - AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0)); - } else { - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, 0)); - } - if (Reg1) { - AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); - } else { - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); - } - AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); - - } - - /* memcpy returns the address, so the result is actually identical - ** to the first argument. + /* We've generated the complete code for the function now and know the + ** types of all parameters. Check for situations where better code can + ** be generated. If such a situation is detected, throw away the + ** generated, and emit better code. */ - *Expr = Arg1.Expr; + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || + (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && + ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || + (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) { - } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) && - ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) && - (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) { + int Reg1 = ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr); + int Reg2 = ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr); - /* It is possible to just use one index register even if the stack - ** offset is not zero, by adjusting the offset to the constant - ** address accordingly. But we cannot do this if the data in - ** question is in the register space or at an absolute address less - ** than 256. Register space is zero page, which means that the - ** address calculation could overflow in the linker. - */ - int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) && - !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); - /* Calculate the real stack offset */ - Offs = ED_GetStackOffs (&Arg1.Expr, 0); + /* We need a label */ + Label = GetLocalLabel (); - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); + /* Generate memcpy code */ + if (Arg3.Expr.IVal <= 127) { - /* We need a label */ - Label = GetLocalLabel (); - - /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { - - if (Offs == 0) { - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); g_defcodelabel (Label); - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); - AddCodeLine ("sta (sp),y"); + if (Reg2) { + AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0)); + } else { + AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, 0)); + } + if (Reg1) { + AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); + } else { + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + } AddCodeLine ("dey"); AddCodeLine ("bpl %s", LocalLabelName (Label)); + } else { - AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + + AddCodeLine ("ldy #$00"); g_defcodelabel (Label); - AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("sta (sp),y"); - AddCodeLine ("dey"); - AddCodeLine ("dex"); - AddCodeLine ("bpl %s", LocalLabelName (Label)); + if (Reg2) { + AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0)); + } else { + AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, 0)); + } + if (Reg1) { + AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); + } else { + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + } + AddCodeLine ("iny"); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } - } else { - - if (Offs == 0 || AllowOneIndex) { - AddCodeLine ("ldy #$%02X", (unsigned char) Offs); - g_defcodelabel (Label); - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); - AddCodeLine ("sta (sp),y"); - AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); - } else { - AddCodeLine ("ldx #$00"); - AddCodeLine ("ldy #$%02X", (unsigned char) Offs); - g_defcodelabel (Label); - AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("sta (sp),y"); - AddCodeLine ("iny"); - AddCodeLine ("inx"); - AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); - } + /* memcpy returns the address, so the result is actually identical + ** to the first argument. + */ + *Expr = Arg1.Expr; + /* Bail out, no need for further processing */ + goto ExitPoint; } - /* memcpy returns the address, so the result is actually identical - ** to the first argument. - */ - *Expr = Arg1.Expr; + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) && + ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) && + (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) { - } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) && - (Arg2.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256 && - ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) { + /* It is possible to just use one index register even if the stack + ** offset is not zero, by adjusting the offset to the constant + ** address accordingly. But we cannot do this if the data in + ** question is in the register space or at an absolute address less + ** than 256. Register space is zero page, which means that the + ** address calculation could overflow in the linker. + */ + int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) && + !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256); - /* It is possible to just use one index register even if the stack - ** offset is not zero, by adjusting the offset to the constant - ** address accordingly. But we cannot do this if the data in - ** question is in the register space or at an absolute address less - ** than 256. Register space is zero page, which means that the - ** address calculation could overflow in the linker. - */ - int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) && - !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256); + /* Calculate the real stack offset */ + Offs = ED_GetStackOffs (&Arg1.Expr, 0); - /* Calculate the real stack offset */ - Offs = ED_GetStackOffs (&Arg2.Expr, 0); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); + /* We need a label */ + Label = GetLocalLabel (); - /* We need a label */ - Label = GetLocalLabel (); + /* Generate memcpy code */ + if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { - /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { + if (Offs == 0) { + AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + g_defcodelabel (Label); + AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); + AddCodeLine ("sta (sp),y"); + AddCodeLine ("dey"); + AddCodeLine ("bpl %s", LocalLabelName (Label)); + } else { + AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); + AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + g_defcodelabel (Label); + AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); + AddCodeLine ("sta (sp),y"); + AddCodeLine ("dey"); + AddCodeLine ("dex"); + AddCodeLine ("bpl %s", LocalLabelName (Label)); + } - if (Offs == 0) { + } else { + + if (Offs == 0 || AllowOneIndex) { + AddCodeLine ("ldy #$%02X", (unsigned char) Offs); + g_defcodelabel (Label); + AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); + AddCodeLine ("sta (sp),y"); + AddCodeLine ("iny"); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } else { + AddCodeLine ("ldx #$00"); + AddCodeLine ("ldy #$%02X", (unsigned char) Offs); + g_defcodelabel (Label); + AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); + AddCodeLine ("sta (sp),y"); + AddCodeLine ("iny"); + AddCodeLine ("inx"); + AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } + + } + + /* memcpy returns the address, so the result is actually identical + ** to the first argument. + */ + *Expr = Arg1.Expr; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } + + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) && + (Arg2.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256 && + ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) { + + /* It is possible to just use one index register even if the stack + ** offset is not zero, by adjusting the offset to the constant + ** address accordingly. But we cannot do this if the data in + ** question is in the register space or at an absolute address less + ** than 256. Register space is zero page, which means that the + ** address calculation could overflow in the linker. + */ + int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) && + !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256); + + /* Calculate the real stack offset */ + Offs = ED_GetStackOffs (&Arg2.Expr, 0); + + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); + + /* We need a label */ + Label = GetLocalLabel (); + + /* Generate memcpy code */ + if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { + + if (Offs == 0) { + AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); + g_defcodelabel (Label); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine ("dey"); + AddCodeLine ("bpl %s", LocalLabelName (Label)); + } else { + AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); + AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + g_defcodelabel (Label); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine ("dey"); + AddCodeLine ("dex"); + AddCodeLine ("bpl %s", LocalLabelName (Label)); + } + + } else { + + if (Offs == 0 || AllowOneIndex) { + AddCodeLine ("ldy #$%02X", (unsigned char) Offs); + g_defcodelabel (Label); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs)); + AddCodeLine ("iny"); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } else { + AddCodeLine ("ldx #$00"); + AddCodeLine ("ldy #$%02X", (unsigned char) Offs); + g_defcodelabel (Label); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine ("iny"); + AddCodeLine ("inx"); + AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } + + } + + /* memcpy returns the address, so the result is actually identical + ** to the first argument. + */ + *Expr = Arg1.Expr; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } + + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) && + (Offs = ED_GetStackOffs (&Arg2.Expr, 0)) == 0) { + + /* Drop the generated code but leave the load of the first argument*/ + RemoveCode (&Arg1.Push); + + /* We need a label */ + Label = GetLocalLabel (); + + /* Generate memcpy code */ + AddCodeLine ("sta ptr1"); + AddCodeLine ("stx ptr1+1"); + if (Arg3.Expr.IVal <= 127) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); g_defcodelabel (Label); AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine ("sta (ptr1),y"); AddCodeLine ("dey"); AddCodeLine ("bpl %s", LocalLabelName (Label)); } else { - AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + AddCodeLine ("ldy #$00"); g_defcodelabel (Label); AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); - AddCodeLine ("dey"); - AddCodeLine ("dex"); - AddCodeLine ("bpl %s", LocalLabelName (Label)); - } - - } else { - - if (Offs == 0 || AllowOneIndex) { - AddCodeLine ("ldy #$%02X", (unsigned char) Offs); - g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs)); + AddCodeLine ("sta (ptr1),y"); AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); - } else { - AddCodeLine ("ldx #$00"); - AddCodeLine ("ldy #$%02X", (unsigned char) Offs); - g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); - AddCodeLine ("iny"); - AddCodeLine ("inx"); - AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); } + /* Reload result - X hasn't changed by the code above */ + AddCodeLine ("lda ptr1"); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = GetFuncReturn (Expr->Type); + + /* Bail out, no need for further processing */ + goto ExitPoint; } - - /* memcpy returns the address, so the result is actually identical - ** to the first argument. - */ - *Expr = Arg1.Expr; - - } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) && - (Offs = ED_GetStackOffs (&Arg2.Expr, 0)) == 0) { - - /* Drop the generated code but leave the load of the first argument*/ - RemoveCode (&Arg1.Push); - - /* We need a label */ - Label = GetLocalLabel (); - - /* Generate memcpy code */ - AddCodeLine ("sta ptr1"); - AddCodeLine ("stx ptr1+1"); - if (Arg3.Expr.IVal <= 127) { - AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); - g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta (ptr1),y"); - AddCodeLine ("dey"); - AddCodeLine ("bpl %s", LocalLabelName (Label)); - } else { - AddCodeLine ("ldy #$00"); - g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta (ptr1),y"); - AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); - } - - /* Reload result - X hasn't changed by the code above */ - AddCodeLine ("lda ptr1"); - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = GetFuncReturn (Expr->Type); - - } else { - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = GetFuncReturn (Expr->Type); - } + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = GetFuncReturn (Expr->Type); + ExitPoint: /* We expect the closing brace */ ConsumeRParen (); @@ -595,140 +610,151 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr) goto ExitPoint; } - /* We've generated the complete code for the function now and know the - ** types of all parameters. Check for situations where better code can - ** be generated. If such a situation is detected, throw away the - ** generated, and emit better code. - ** Note: Lots of improvements would be possible here, but I will - ** concentrate on the most common case: memset with arguments 2 and 3 - ** being constant numerical values. Some checks have shown that this - ** covers nearly 90% of all memset calls. - */ - if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ED_IsConstAbsInt (&Arg2.Expr) && - ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || - (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) { + if (IS_Get (&InlineStdFuncs)) { - int Reg = ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr); + /* We've generated the complete code for the function now and know the + ** types of all parameters. Check for situations where better code can + ** be generated. If such a situation is detected, throw away the + ** generated, and emit better code. + ** Note: Lots of improvements would be possible here, but I will + ** concentrate on the most common case: memset with arguments 2 and 3 + ** being constant numerical values. Some checks have shown that this + ** covers nearly 90% of all memset calls. + */ + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ED_IsConstAbsInt (&Arg2.Expr) && + ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || + (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) { - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); + int Reg = ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr); - /* We need a label */ - Label = GetLocalLabel (); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); - /* Generate memset code */ - if (Arg3.Expr.IVal <= 127) { + /* We need a label */ + Label = GetLocalLabel (); + + /* Generate memset code */ + if (Arg3.Expr.IVal <= 127) { + + AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); + AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); + g_defcodelabel (Label); + if (Reg) { + AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); + } else { + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + } + AddCodeLine ("dey"); + AddCodeLine ("bpl %s", LocalLabelName (Label)); - AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); - AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); - g_defcodelabel (Label); - if (Reg) { - AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); } else { - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + + AddCodeLine ("ldy #$00"); + AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); + g_defcodelabel (Label); + if (Reg) { + AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); + } else { + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + } + AddCodeLine ("iny"); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } - AddCodeLine ("dey"); - AddCodeLine ("bpl %s", LocalLabelName (Label)); - } else { - - AddCodeLine ("ldy #$00"); - AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); - g_defcodelabel (Label); - if (Reg) { - AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); - } else { - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); - } - AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); + /* memset returns the address, so the result is actually identical + ** to the first argument. + */ + *Expr = Arg1.Expr; + /* Bail out, no need for further processing */ + goto ExitPoint; } - /* memset returns the address, so the result is actually identical - ** to the first argument. - */ - *Expr = Arg1.Expr; + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ED_IsConstAbsInt (&Arg2.Expr) && + ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) && + (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) { - } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ED_IsConstAbsInt (&Arg2.Expr) && - ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) && - (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) { + /* Calculate the real stack offset */ + int Offs = ED_GetStackOffs (&Arg1.Expr, 0); - /* Calculate the real stack offset */ - int Offs = ED_GetStackOffs (&Arg1.Expr, 0); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); + /* We need a label */ + Label = GetLocalLabel (); - /* We need a label */ - Label = GetLocalLabel (); - - /* Generate memset code */ - AddCodeLine ("ldy #$%02X", (unsigned char) Offs); - AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); - g_defcodelabel (Label); - AddCodeLine ("sta (sp),y"); - AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); - - /* memset returns the address, so the result is actually identical - ** to the first argument. - */ - *Expr = Arg1.Expr; - - } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ED_IsConstAbsInt (&Arg2.Expr) && - (Arg2.Expr.IVal != 0 || IS_Get (&CodeSizeFactor) > 200)) { - - /* Remove all of the generated code but the load of the first - ** argument. - */ - RemoveCode (&Arg1.Push); - - /* We need a label */ - Label = GetLocalLabel (); - - /* Generate code */ - AddCodeLine ("sta ptr1"); - AddCodeLine ("stx ptr1+1"); - if (Arg3.Expr.IVal <= 127) { - AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); + /* Generate memset code */ + AddCodeLine ("ldy #$%02X", (unsigned char) Offs); AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); g_defcodelabel (Label); - AddCodeLine ("sta (ptr1),y"); - AddCodeLine ("dey"); - AddCodeLine ("bpl %s", LocalLabelName (Label)); - } else { - AddCodeLine ("ldy #$00"); - AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); - g_defcodelabel (Label); - AddCodeLine ("sta (ptr1),y"); + AddCodeLine ("sta (sp),y"); AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); + + /* memset returns the address, so the result is actually identical + ** to the first argument. + */ + *Expr = Arg1.Expr; + + /* Bail out, no need for further processing */ + goto ExitPoint; } - /* Load the function result pointer into a/x (x is still valid). This - ** code will get removed by the optimizer if it is not used later. - */ - AddCodeLine ("lda ptr1"); + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ED_IsConstAbsInt (&Arg2.Expr) && + (Arg2.Expr.IVal != 0 || IS_Get (&CodeSizeFactor) > 200)) { - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = GetFuncReturn (Expr->Type); + /* Remove all of the generated code but the load of the first + ** argument. + */ + RemoveCode (&Arg1.Push); - } else { + /* We need a label */ + Label = GetLocalLabel (); - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = GetFuncReturn (Expr->Type); + /* Generate code */ + AddCodeLine ("sta ptr1"); + AddCodeLine ("stx ptr1+1"); + if (Arg3.Expr.IVal <= 127) { + AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); + AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); + g_defcodelabel (Label); + AddCodeLine ("sta (ptr1),y"); + AddCodeLine ("dey"); + AddCodeLine ("bpl %s", LocalLabelName (Label)); + } else { + AddCodeLine ("ldy #$00"); + AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); + g_defcodelabel (Label); + AddCodeLine ("sta (ptr1),y"); + AddCodeLine ("iny"); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } + /* Load the function result pointer into a/x (x is still valid). This + ** code will get removed by the optimizer if it is not used later. + */ + AddCodeLine ("lda ptr1"); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = GetFuncReturn (Expr->Type); + + /* Bail out, no need for further processing */ + goto ExitPoint; + } } + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = GetFuncReturn (Expr->Type); + ExitPoint: /* We expect the closing brace */ ConsumeRParen (); @@ -790,142 +816,142 @@ static void StdFunc_strcmp (FuncDesc* F attribute ((unused)), ExprDesc* Expr) ECount1 = ECount2; } - /* If the second argument is the empty string literal, we can generate - ** more efficient code. - */ - if (ED_IsLocLiteral (&Arg2.Expr) && - IS_Get (&WritableStrings) == 0 && - GetLiteralSize (Arg2.Expr.LVal) == 1 && - GetLiteralStr (Arg2.Expr.LVal)[0] == '\0') { + if (IS_Get (&InlineStdFuncs)) { - /* Drop the generated code so we have the first argument in the - ** primary + /* If the second argument is the empty string literal, we can generate + ** more efficient code. */ - RemoveCode (&Arg1.Push); + if (ED_IsLocLiteral (&Arg2.Expr) && + IS_Get (&WritableStrings) == 0 && + GetLiteralSize (Arg2.Expr.LVal) == 1 && + GetLiteralStr (Arg2.Expr.LVal)[0] == '\0') { - /* We don't need the literal any longer */ - ReleaseLiteral (Arg2.Expr.LVal); - - /* We do now have Arg1 in the primary. Load the first character from - ** this string and cast to int. This is the function result. - */ - IsArray = IsTypeArray (Arg1.Type) && ED_IsRVal (&Arg1.Expr); - if (IsArray && ED_IsLocStack (&Arg1.Expr) && - (Offs = ED_GetStackOffs (&Arg1.Expr, 0) < 256)) { - /* Drop the generated code */ - RemoveCode (&Arg1.Load); - - /* Generate code */ - AddCodeLine ("ldy #$%02X", Offs); - AddCodeLine ("ldx #$00"); - AddCodeLine ("lda (sp),y"); - } else if (IsArray && ED_IsLocConst (&Arg1.Expr)) { - /* Drop the generated code */ - RemoveCode (&Arg1.Load); - - /* Generate code */ - AddCodeLine ("ldx #$00"); - AddCodeLine ("lda %s", ED_GetLabelName (&Arg1.Expr, 0)); - } else { - /* Drop part of the generated code so we have the first argument - ** in the primary + /* Drop the generated code so we have the first argument in the + ** primary */ RemoveCode (&Arg1.Push); - /* Fetch the first char */ - g_getind (CF_CHAR | CF_UNSIGNED, 0); + /* We don't need the literal any longer */ + ReleaseLiteral (Arg2.Expr.LVal); + + /* We do now have Arg1 in the primary. Load the first character from + ** this string and cast to int. This is the function result. + */ + IsArray = IsTypeArray (Arg1.Type) && ED_IsRVal (&Arg1.Expr); + if (IsArray && ED_IsLocStack (&Arg1.Expr) && + (Offs = ED_GetStackOffs (&Arg1.Expr, 0) < 256)) { + /* Drop the generated code */ + RemoveCode (&Arg1.Load); + + /* Generate code */ + AddCodeLine ("ldy #$%02X", Offs); + AddCodeLine ("ldx #$00"); + AddCodeLine ("lda (sp),y"); + } else if (IsArray && ED_IsLocConst (&Arg1.Expr)) { + /* Drop the generated code */ + RemoveCode (&Arg1.Load); + + /* Generate code */ + AddCodeLine ("ldx #$00"); + AddCodeLine ("lda %s", ED_GetLabelName (&Arg1.Expr, 0)); + } else { + /* Drop part of the generated code so we have the first argument + ** in the primary + */ + RemoveCode (&Arg1.Push); + + /* Fetch the first char */ + g_getind (CF_CHAR | CF_UNSIGNED, 0); + } + + } else if ((IS_Get (&CodeSizeFactor) >= 165) && + ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || + (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && + ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || + (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr))) && + (IS_Get (&EagerlyInlineFuncs) || (ECount1 > 0 && ECount1 < 256))) { + + unsigned Entry, Loop, Fin; /* Labels */ + const char* Load; + const char* Compare; + + if (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)) { + Load = "lda (%s),y"; + } else { + Load = "lda %s,y"; + } + if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) { + Compare = "cmp (%s),y"; + } else { + Compare = "cmp %s,y"; + } + + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); + + /* We need labels */ + Entry = GetLocalLabel (); + Loop = GetLocalLabel (); + Fin = GetLocalLabel (); + + /* Generate strcmp code */ + AddCodeLine ("ldy #$00"); + AddCodeLine ("beq %s", LocalLabelName (Entry)); + g_defcodelabel (Loop); + AddCodeLine ("tax"); + AddCodeLine ("beq %s", LocalLabelName (Fin)); + AddCodeLine ("iny"); + g_defcodelabel (Entry); + AddCodeLine (Load, ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine (Compare, ED_GetLabelName (&Arg2.Expr, 0)); + AddCodeLine ("beq %s", LocalLabelName (Loop)); + AddCodeLine ("ldx #$01"); + AddCodeLine ("bcs %s", LocalLabelName (Fin)); + AddCodeLine ("ldx #$FF"); + g_defcodelabel (Fin); + + } else if ((IS_Get (&CodeSizeFactor) > 190) && + ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || + (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && + (IS_Get (&EagerlyInlineFuncs) || (ECount1 > 0 && ECount1 < 256))) { + + unsigned Entry, Loop, Fin; /* Labels */ + const char* Compare; + + if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) { + Compare = "cmp (%s),y"; + } else { + Compare = "cmp %s,y"; + } + + /* Drop the generated code */ + RemoveCode (&Arg1.Push); + + /* We need labels */ + Entry = GetLocalLabel (); + Loop = GetLocalLabel (); + Fin = GetLocalLabel (); + + /* Store Arg1 into ptr1 */ + AddCodeLine ("sta ptr1"); + AddCodeLine ("stx ptr1+1"); + + /* Generate strcmp code */ + AddCodeLine ("ldy #$00"); + AddCodeLine ("beq %s", LocalLabelName (Entry)); + g_defcodelabel (Loop); + AddCodeLine ("tax"); + AddCodeLine ("beq %s", LocalLabelName (Fin)); + AddCodeLine ("iny"); + g_defcodelabel (Entry); + AddCodeLine ("lda (ptr1),y"); + AddCodeLine (Compare, ED_GetLabelName (&Arg2.Expr, 0)); + AddCodeLine ("beq %s", LocalLabelName (Loop)); + AddCodeLine ("ldx #$01"); + AddCodeLine ("bcs %s", LocalLabelName (Fin)); + AddCodeLine ("ldx #$FF"); + g_defcodelabel (Fin); } - - } else if ((IS_Get (&CodeSizeFactor) >= 165) && - ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || - (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && - ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || - (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr))) && - (IS_Get (&InlineStdFuncs) || (ECount1 > 0 && ECount1 < 256))) { - - - unsigned Entry, Loop, Fin; /* Labels */ - const char* Load; - const char* Compare; - - if (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)) { - Load = "lda (%s),y"; - } else { - Load = "lda %s,y"; - } - if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) { - Compare = "cmp (%s),y"; - } else { - Compare = "cmp %s,y"; - } - - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); - - /* We need labels */ - Entry = GetLocalLabel (); - Loop = GetLocalLabel (); - Fin = GetLocalLabel (); - - /* Generate strcmp code */ - AddCodeLine ("ldy #$00"); - AddCodeLine ("beq %s", LocalLabelName (Entry)); - g_defcodelabel (Loop); - AddCodeLine ("tax"); - AddCodeLine ("beq %s", LocalLabelName (Fin)); - AddCodeLine ("iny"); - g_defcodelabel (Entry); - AddCodeLine (Load, ED_GetLabelName (&Arg1.Expr, 0)); - AddCodeLine (Compare, ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("beq %s", LocalLabelName (Loop)); - AddCodeLine ("ldx #$01"); - AddCodeLine ("bcs %s", LocalLabelName (Fin)); - AddCodeLine ("ldx #$FF"); - g_defcodelabel (Fin); - - } else if ((IS_Get (&CodeSizeFactor) > 190) && - ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || - (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && - (IS_Get (&InlineStdFuncs) || (ECount1 > 0 && ECount1 < 256))) { - - - unsigned Entry, Loop, Fin; /* Labels */ - const char* Compare; - - if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) { - Compare = "cmp (%s),y"; - } else { - Compare = "cmp %s,y"; - } - - /* Drop the generated code */ - RemoveCode (&Arg1.Push); - - /* We need labels */ - Entry = GetLocalLabel (); - Loop = GetLocalLabel (); - Fin = GetLocalLabel (); - - /* Store Arg1 into ptr1 */ - AddCodeLine ("sta ptr1"); - AddCodeLine ("stx ptr1+1"); - - /* Generate strcmp code */ - AddCodeLine ("ldy #$00"); - AddCodeLine ("beq %s", LocalLabelName (Entry)); - g_defcodelabel (Loop); - AddCodeLine ("tax"); - AddCodeLine ("beq %s", LocalLabelName (Fin)); - AddCodeLine ("iny"); - g_defcodelabel (Entry); - AddCodeLine ("lda (ptr1),y"); - AddCodeLine (Compare, ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("beq %s", LocalLabelName (Loop)); - AddCodeLine ("ldx #$01"); - AddCodeLine ("bcs %s", LocalLabelName (Fin)); - AddCodeLine ("ldx #$FF"); - g_defcodelabel (Fin); - } /* The function result is an rvalue in the primary register */ @@ -983,142 +1009,154 @@ static void StdFunc_strcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Get the element count of argument 1 if it is an array */ ECount = ArrayElementCount (&Arg1); - /* We've generated the complete code for the function now and know the - ** types of all parameters. Check for situations where better code can - ** be generated. If such a situation is detected, throw away the - ** generated, and emit better code. - */ - if (((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || - (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && - ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || - (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr))) && - (IS_Get (&InlineStdFuncs) || - (ECount != UNSPECIFIED && ECount < 256))) { + if (IS_Get (&InlineStdFuncs)) { - const char* Load; - const char* Store; - if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) { - Load = "lda (%s),y"; - } else { - Load = "lda %s,y"; - } - if (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)) { - Store = "sta (%s),y"; - } else { - Store = "sta %s,y"; - } - - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); - - /* We need labels */ - L1 = GetLocalLabel (); - - /* Generate strcpy code */ - AddCodeLine ("ldy #$FF"); - g_defcodelabel (L1); - AddCodeLine ("iny"); - AddCodeLine (Load, ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine (Store, ED_GetLabelName (&Arg1.Expr, 0)); - AddCodeLine ("bne %s", LocalLabelName (L1)); - - /* strcpy returns argument #1 */ - *Expr = Arg1.Expr; - - } else if (ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) && - StackPtr >= -255 && - ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) { - - /* It is possible to just use one index register even if the stack - ** offset is not zero, by adjusting the offset to the constant - ** address accordingly. But we cannot do this if the data in - ** question is in the register space or at an absolute address less - ** than 256. Register space is zero page, which means that the - ** address calculation could overflow in the linker. + /* We've generated the complete code for the function now and know the + ** types of all parameters. Check for situations where better code can + ** be generated. If such a situation is detected, throw away the + ** generated, and emit better code. */ - int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) && - !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256); + if (((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || + (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && + ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || + (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr))) && + (IS_Get (&EagerlyInlineFuncs) || + (ECount != UNSPECIFIED && ECount < 256))) { - /* Calculate the real stack offset */ - int Offs = ED_GetStackOffs (&Arg2.Expr, 0); + const char* Load; + const char* Store; + if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) { + Load = "lda (%s),y"; + } else { + Load = "lda %s,y"; + } + if (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)) { + Store = "sta (%s),y"; + } else { + Store = "sta %s,y"; + } - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); - /* We need labels */ - L1 = GetLocalLabel (); + /* We need labels */ + L1 = GetLocalLabel (); - /* Generate strcpy code */ - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs - 1)); - if (Offs == 0 || AllowOneIndex) { + /* Generate strcpy code */ + AddCodeLine ("ldy #$FF"); g_defcodelabel (L1); AddCodeLine ("iny"); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs)); - } else { - AddCodeLine ("ldx #$FF"); - g_defcodelabel (L1); - AddCodeLine ("iny"); - AddCodeLine ("inx"); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine (Load, ED_GetLabelName (&Arg2.Expr, 0)); + AddCodeLine (Store, ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine ("bne %s", LocalLabelName (L1)); + + /* strcpy returns argument #1 */ + *Expr = Arg1.Expr; + + /* Bail out, no need for further processing */ + goto ExitPoint; } - AddCodeLine ("bne %s", LocalLabelName (L1)); - /* strcpy returns argument #1 */ - *Expr = Arg1.Expr; + if (ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) && + StackPtr >= -255 && + ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) { - } else if (ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) && - ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) && - StackPtr >= -255) { + /* It is possible to just use one index register even if the stack + ** offset is not zero, by adjusting the offset to the constant + ** address accordingly. But we cannot do this if the data in + ** question is in the register space or at an absolute address less + ** than 256. Register space is zero page, which means that the + ** address calculation could overflow in the linker. + */ + int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) && + !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256); - /* It is possible to just use one index register even if the stack - ** offset is not zero, by adjusting the offset to the constant - ** address accordingly. But we cannot do this if the data in - ** question is in the register space or at an absolute address less - ** than 256. Register space is zero page, which means that the - ** address calculation could overflow in the linker. - */ - int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) && - !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256); + /* Calculate the real stack offset */ + int Offs = ED_GetStackOffs (&Arg2.Expr, 0); - /* Calculate the real stack offset */ - int Offs = ED_GetStackOffs (&Arg1.Expr, 0); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); + /* We need labels */ + L1 = GetLocalLabel (); - /* We need labels */ - L1 = GetLocalLabel (); + /* Generate strcpy code */ + AddCodeLine ("ldy #$%02X", (unsigned char) (Offs - 1)); + if (Offs == 0 || AllowOneIndex) { + g_defcodelabel (L1); + AddCodeLine ("iny"); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs)); + } else { + AddCodeLine ("ldx #$FF"); + g_defcodelabel (L1); + AddCodeLine ("iny"); + AddCodeLine ("inx"); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); + } + AddCodeLine ("bne %s", LocalLabelName (L1)); - /* Generate strcpy code */ - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs - 1)); - if (Offs == 0 || AllowOneIndex) { - g_defcodelabel (L1); - AddCodeLine ("iny"); - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); - AddCodeLine ("sta (sp),y"); - } else { - AddCodeLine ("ldx #$FF"); - g_defcodelabel (L1); - AddCodeLine ("iny"); - AddCodeLine ("inx"); - AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("sta (sp),y"); + /* strcpy returns argument #1 */ + *Expr = Arg1.Expr; + + /* Bail out, no need for further processing */ + goto ExitPoint; } - AddCodeLine ("bne %s", LocalLabelName (L1)); - /* strcpy returns argument #1 */ - *Expr = Arg1.Expr; + if (ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) && + ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) && + StackPtr >= -255) { - } else { + /* It is possible to just use one index register even if the stack + ** offset is not zero, by adjusting the offset to the constant + ** address accordingly. But we cannot do this if the data in + ** question is in the register space or at an absolute address less + ** than 256. Register space is zero page, which means that the + ** address calculation could overflow in the linker. + */ + int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) && + !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256); - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = GetFuncReturn (Expr->Type); + /* Calculate the real stack offset */ + int Offs = ED_GetStackOffs (&Arg1.Expr, 0); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); + + /* We need labels */ + L1 = GetLocalLabel (); + + /* Generate strcpy code */ + AddCodeLine ("ldy #$%02X", (unsigned char) (Offs - 1)); + if (Offs == 0 || AllowOneIndex) { + g_defcodelabel (L1); + AddCodeLine ("iny"); + AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); + AddCodeLine ("sta (sp),y"); + } else { + AddCodeLine ("ldx #$FF"); + g_defcodelabel (L1); + AddCodeLine ("iny"); + AddCodeLine ("inx"); + AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); + AddCodeLine ("sta (sp),y"); + } + AddCodeLine ("bne %s", LocalLabelName (L1)); + + /* strcpy returns argument #1 */ + *Expr = Arg1.Expr; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } } + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = GetFuncReturn (Expr->Type); + +ExitPoint: /* We expect the closing brace */ ConsumeRParen (); } @@ -1142,8 +1180,6 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr) long ECount; unsigned L; - - /* Setup the argument type string */ ArgType[1].C = GetDefaultChar () | T_QUAL_CONST; @@ -1175,125 +1211,148 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Do type conversion */ TypeConversion (&Arg, ArgType); - /* If the expression is a literal, and if string literals are read - ** only, we can calculate the length of the string and remove it - ** from the literal pool. Otherwise we have to calculate the length - ** at runtime. - */ - if (ED_IsLocLiteral (&Arg) && IS_Get (&WritableStrings) == 0) { + if (IS_Get (&Optimize)) { - /* Constant string literal */ - ED_MakeConstAbs (Expr, GetLiteralSize (Arg.LVal) - 1, type_size_t); + /* If the expression is a literal, and if string literals are read + ** only, we can calculate the length of the string and remove it + ** from the literal pool. Otherwise we have to calculate the length + ** at runtime. + */ + if (ED_IsLocLiteral (&Arg) && IS_Get (&WritableStrings) == 0) { - /* We don't need the literal any longer */ - ReleaseLiteral (Arg.LVal); + /* Constant string literal */ + ED_MakeConstAbs (Expr, GetLiteralSize (Arg.LVal) - 1, type_size_t); - /* We will inline strlen for arrays with constant addresses, if either the - ** inlining was forced on the command line, or the array is smaller than - ** 256, so the inlining is considered safe. - */ - } else if (ED_IsLocConst (&Arg) && IsArray && - (IS_Get (&InlineStdFuncs) || IsByteIndex)) { - - /* Generate the strlen code */ - L = GetLocalLabel (); - AddCodeLine ("ldy #$FF"); - g_defcodelabel (L); - AddCodeLine ("iny"); - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg, 0)); - AddCodeLine ("bne %s", LocalLabelName (L)); - AddCodeLine ("tax"); - AddCodeLine ("tya"); - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = type_size_t; - - /* We will inline strlen for arrays on the stack, if the array is - ** completely within the reach of a byte sized index register. - */ - } else if (ED_IsLocStack (&Arg) && IsArray && IsByteIndex && - (Arg.IVal - StackPtr) + ECount < 256) { - - /* Calculate the true stack offset */ - int Offs = ED_GetStackOffs (&Arg, 0); - - /* Generate the strlen code */ - L = GetLocalLabel (); - AddCodeLine ("ldx #$FF"); - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs-1)); - g_defcodelabel (L); - AddCodeLine ("inx"); - AddCodeLine ("iny"); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("bne %s", LocalLabelName (L)); - AddCodeLine ("txa"); - AddCodeLine ("ldx #$00"); - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = type_size_t; - - /* strlen for a string that is pointed to by a register variable will only - ** get inlined if requested on the command line, since we cannot know how - ** big the buffer actually is, so inlining is not always safe. - */ - } else if (ED_IsLocRegister (&Arg) && ED_IsLVal (&Arg) && IsPtr && - IS_Get (&InlineStdFuncs)) { - - /* Generate the strlen code */ - L = GetLocalLabel (); - AddCodeLine ("ldy #$FF"); - g_defcodelabel (L); - AddCodeLine ("iny"); - AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg, 0)); - AddCodeLine ("bne %s", LocalLabelName (L)); - AddCodeLine ("tax"); - AddCodeLine ("tya"); - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = type_size_t; - - /* Last check: We will inline a generic strlen routine if inlining was - ** requested on the command line, and the code size factor is more than - ** 400 (code is 13 bytes vs. 3 for a jsr call). - */ - } else if (IS_Get (&CodeSizeFactor) > 400 && IS_Get (&InlineStdFuncs)) { - - /* Load the expression into the primary */ - LoadExpr (CF_NONE, &Arg); - - /* Inline the function */ - L = GetLocalLabel (); - AddCodeLine ("sta ptr1"); - AddCodeLine ("stx ptr1+1"); - AddCodeLine ("ldy #$FF"); - g_defcodelabel (L); - AddCodeLine ("iny"); - AddCodeLine ("lda (ptr1),y"); - AddCodeLine ("bne %s", LocalLabelName (L)); - AddCodeLine ("tax"); - AddCodeLine ("tya"); - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = type_size_t; - - } else { - - /* Load the expression into the primary */ - LoadExpr (CF_NONE, &Arg); - - /* Call the strlen function */ - AddCodeLine ("jsr _%s", Func_strlen); - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = type_size_t; + /* We don't need the literal any longer */ + ReleaseLiteral (Arg.LVal); + /* Bail out, no need for further improvements */ + goto ExitPoint; + } } + if (IS_Get (&InlineStdFuncs)) { + + /* We will inline strlen for arrays with constant addresses, if either + ** requested on the command line, or the array is smaller than 256, + ** so the inlining is considered safe. + */ + if (ED_IsLocConst (&Arg) && IsArray && + (IS_Get (&EagerlyInlineFuncs) || IsByteIndex)) { + + /* Generate the strlen code */ + L = GetLocalLabel (); + AddCodeLine ("ldy #$FF"); + g_defcodelabel (L); + AddCodeLine ("iny"); + AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg, 0)); + AddCodeLine ("bne %s", LocalLabelName (L)); + AddCodeLine ("tax"); + AddCodeLine ("tya"); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = type_size_t; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } + + /* We will inline strlen for arrays on the stack, if the array is + ** completely within the reach of a byte sized index register. + */ + if (ED_IsLocStack (&Arg) && IsArray && IsByteIndex && + (Arg.IVal - StackPtr) + ECount < 256) { + + /* Calculate the true stack offset */ + int Offs = ED_GetStackOffs (&Arg, 0); + + /* Generate the strlen code */ + L = GetLocalLabel (); + AddCodeLine ("ldx #$FF"); + AddCodeLine ("ldy #$%02X", (unsigned char) (Offs-1)); + g_defcodelabel (L); + AddCodeLine ("inx"); + AddCodeLine ("iny"); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("bne %s", LocalLabelName (L)); + AddCodeLine ("txa"); + AddCodeLine ("ldx #$00"); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = type_size_t; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } + + /* strlen for a string that is pointed to by a register variable will only + ** get inlined if requested on the command line, since we cannot know how + ** big the buffer actually is, so inlining is not always safe. + */ + if (ED_IsLocRegister (&Arg) && ED_IsLVal (&Arg) && IsPtr && + IS_Get (&EagerlyInlineFuncs)) { + + /* Generate the strlen code */ + L = GetLocalLabel (); + AddCodeLine ("ldy #$FF"); + g_defcodelabel (L); + AddCodeLine ("iny"); + AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg, 0)); + AddCodeLine ("bne %s", LocalLabelName (L)); + AddCodeLine ("tax"); + AddCodeLine ("tya"); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = type_size_t; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } + + /* Last check: We will inline a generic strlen routine if inlining was + ** requested on the command line, and the code size factor is more than + ** 400 (code is 13 bytes vs. 3 for a jsr call). + */ + if (IS_Get (&CodeSizeFactor) > 400 && IS_Get (&EagerlyInlineFuncs)) { + + /* Load the expression into the primary */ + LoadExpr (CF_NONE, &Arg); + + /* Inline the function */ + L = GetLocalLabel (); + AddCodeLine ("sta ptr1"); + AddCodeLine ("stx ptr1+1"); + AddCodeLine ("ldy #$FF"); + g_defcodelabel (L); + AddCodeLine ("iny"); + AddCodeLine ("lda (ptr1),y"); + AddCodeLine ("bne %s", LocalLabelName (L)); + AddCodeLine ("tax"); + AddCodeLine ("tya"); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = type_size_t; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } + } + + /* Load the expression into the primary */ + LoadExpr (CF_NONE, &Arg); + + /* Call the strlen function */ + AddCodeLine ("jsr _%s", Func_strlen); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = type_size_t; + +ExitPoint: /* We expect the closing brace */ ConsumeRParen (); } From 9b345099569af702175cf89f3ef29838c4eeac46 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 00:41:40 +0200 Subject: [PATCH 051/199] Use the more explicit tag style for recently added internal links. --- doc/cc65.sgml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 9322a2d44..827b63c80 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -247,10 +247,10 @@ Here is a description of all the command line options: <p> </itemize> - <tt/--eagerly-inline-funcs/ implies the <tt/<ref id="option-inline-stdfuncs" - name="--inline-stdfuncs"/ command line option. + <tt/--eagerly-inline-funcs/ implies the <tt><ref id="option-inline-stdfuncs" + name="--inline-stdfuncs"></tt> command line option. - See also <tt/<ref id="pragma-allow-eager-inline" name="#pragma allow-eager-inline">/. + See also <tt><ref id="pragma-allow-eager-inline" name="#pragma allow-eager-inline"></tt>. <tag><tt>-h, --help</tt></tag> @@ -263,9 +263,9 @@ Here is a description of all the command line options: Allow the compiler to inline some standard functions from the C library like strlen. This will not only remove the overhead for a function call, but will - make the code visible for the optimizer. See also the <tt/<ref id="option-O" - name="-Os"/ command line option and <tt/<ref id="pragma-inline-stdfuncs" - name="#pragma inline-stdfuncs">/. + make the code visible for the optimizer. See also the <tt><ref id="option-O" + name="-Os"></tt> command line option and <tt><ref id="pragma-inline-stdfuncs" + name="#pragma inline-stdfuncs"></tt>. <label id="option-list-warnings"> @@ -861,8 +861,8 @@ The compiler defines several macros at startup: <tag><tt>__EAGERLY_INLINE_FUNCS__</tt></tag> - Is defined if the compiler was called with the <tt/<ref id="option-eagerly-inline-funcs" - name="--eagerly-inline-funcs"/ command line option. + Is defined if the compiler was called with the <tt><ref id="option-eagerly-inline-funcs" + name="--eagerly-inline-funcs"></tt> command line option. <tag><tt>__FILE__</tt></tag> @@ -965,9 +965,9 @@ parameter with the <tt/#pragma/. Allow eager inlining of known functions. If the argument is "off", eager inlining is disabled, otherwise it is enabled. Please note that (in contrast - to the <tt/<ref id="option-eagerly-inline-funcs" name="--eagerly-inline-funcs"/ - command line option) this pragma does not imply the <tt/<ref id="option-inline-stdfuncs" - name="--inline-stdfuncs"/ command line option. Rather it marks code to be safe for + to the <tt><ref id="option-eagerly-inline-funcs" name="--eagerly-inline-funcs"></tt> + command line option) this pragma does not imply the <tt><ref id="option-inline-stdfuncs" + name="--inline-stdfuncs"></tt> command line option. Rather it marks code to be safe for eager inlining of known functions if inlining of standard functions is enabled. The <tt/#pragma/ understands the push and pop parameters as explained above. From 3b17c3a411a6e1b2099124a76f581fe5d1d79870 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 4 Apr 2017 07:23:05 -0400 Subject: [PATCH 052/199] Fixed 2 typoes. Warning messages from nsgmls usually mean a typing mistake a few lines above the first line that's named by nsgmls. --- doc/cc65.sgml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 827b63c80..653a917db 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -491,7 +491,7 @@ Here is a description of all the command line options: Using <tt/-Os/ will allow the compiler to inline some standard functions from the C library like strlen. This will not only remove the overhead for a function call, but will make the code visible for the optimizer. - See also <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs"/. + See also <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/. It is possible to concatenate the modifiers for <tt/-O/. For example, to enable register variables and inlining of standard functions, you may use @@ -1098,7 +1098,7 @@ parameter with the <tt/#pragma/. Allow the compiler to inline some standard functions from the C library like strlen. If the argument is "off", inlining is disabled, otherwise it is enabled. - See also the the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs"/ + See also the the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/ command line option. The <tt/#pragma/ understands the push and pop parameters as explained above. From 4e856546c17603b772b4b239d8cc5caec8d88833 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 13:42:57 +0200 Subject: [PATCH 053/199] Minor language update. --- doc/cc65.sgml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 653a917db..24b37133e 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -491,7 +491,8 @@ Here is a description of all the command line options: Using <tt/-Os/ will allow the compiler to inline some standard functions from the C library like strlen. This will not only remove the overhead for a function call, but will make the code visible for the optimizer. - See also <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/. + See also the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/ + command line option. It is possible to concatenate the modifiers for <tt/-O/. For example, to enable register variables and inlining of standard functions, you may use @@ -1098,7 +1099,7 @@ parameter with the <tt/#pragma/. Allow the compiler to inline some standard functions from the C library like strlen. If the argument is "off", inlining is disabled, otherwise it is enabled. - See also the the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/ + See also the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/ command line option. The <tt/#pragma/ understands the push and pop parameters as explained above. From 275b27647ed4eeb9da98bd3227002046a52291df Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 15:43:56 +0200 Subject: [PATCH 054/199] Removed superfluous final linefeed. --- libsrc/runtime/axlong.s | 1 - 1 file changed, 1 deletion(-) diff --git a/libsrc/runtime/axlong.s b/libsrc/runtime/axlong.s index 02d0a825c..1fbd53ef0 100644 --- a/libsrc/runtime/axlong.s +++ b/libsrc/runtime/axlong.s @@ -19,4 +19,3 @@ axulong: store: sty sreg sty sreg+1 rts - From 14268510f59211d4b491d3eec937ea703a83bf0d Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 15:45:24 +0200 Subject: [PATCH 055/199] Removed workaround. --- test/val/lib_common_memmove.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/val/lib_common_memmove.c b/test/val/lib_common_memmove.c index 6c04e1951..6b2273e78 100644 --- a/test/val/lib_common_memmove.c +++ b/test/val/lib_common_memmove.c @@ -1,7 +1,3 @@ -// temporarily disable optimizations altogether until a fine grain control -// is implemented on Makefile level only disabling the compiler option -Os -#pragma optimize (off) - #include <string.h> #include "unittest.h" @@ -10,7 +6,6 @@ static char Buffer[BufferSize+3]; // +1 to move up (and down) - TEST { unsigned i, v; @@ -61,5 +56,3 @@ TEST } } ENDTEST - - From 3789174162b5a5e81703fdb3f2a8e584d428f885 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 15:51:00 +0200 Subject: [PATCH 056/199] Removed workaround. --- test/val/lib_common_strcat.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/val/lib_common_strcat.c b/test/val/lib_common_strcat.c index 6389d5651..1872053a4 100644 --- a/test/val/lib_common_strcat.c +++ b/test/val/lib_common_strcat.c @@ -1,7 +1,3 @@ -// temporarily disable optimizations altogether until a fine grain control -// is implemented on Makefile level only disabling the compiler option -Os -#pragma optimize (off) - #include <string.h> #include "unittest.h" From cd27fef6a8b2b58db36eaef767cda1a09ee2ac8c Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 15:52:01 +0200 Subject: [PATCH 057/199] Removed workaround. --- test/val/lib_common_strcspn.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/val/lib_common_strcspn.c b/test/val/lib_common_strcspn.c index 06838c435..f289ddb95 100644 --- a/test/val/lib_common_strcspn.c +++ b/test/val/lib_common_strcspn.c @@ -1,7 +1,3 @@ -// temporarily disable optimizations altogether until a fine grain control -// is implemented on Makefile level only disabling the compiler option -Os -#pragma optimize (off) - #include <string.h> #include "unittest.h" @@ -11,6 +7,7 @@ static char EstimatedString[EstimatedStringSize+1]; // +1 room for terminati static char* EmptyTestChars=""; // strlen equivalent... static char* TestChars="1234567890"; // we like to find numbers + TEST { unsigned i; @@ -26,5 +23,3 @@ TEST ASSERT_AreEqual(strlen(EstimatedString), strcspn(EstimatedString, EmptyTestChars), "%u", "Unxpected position returned for empty test case!"); } ENDTEST - - From 93193727be4bcebfa1d728b2b948a0ebba116e43 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 15:52:37 +0200 Subject: [PATCH 058/199] Removed workaround. --- test/val/lib_common_strncat.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/val/lib_common_strncat.c b/test/val/lib_common_strncat.c index 84d904fa0..a6f92ac05 100644 --- a/test/val/lib_common_strncat.c +++ b/test/val/lib_common_strncat.c @@ -1,7 +1,3 @@ -// temporarily disable optimizations altogether until a fine grain control -// is implemented on Makefile level only disabling the compiler option -Os -#pragma optimize (off) - #include <string.h> #include "unittest.h" @@ -54,5 +50,3 @@ TEST } } ENDTEST - - From e8065155416c060da83b03007ad17e9a837df2aa Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 15:53:14 +0200 Subject: [PATCH 059/199] Removed workaround. --- test/val/lib_common_strspn.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/val/lib_common_strspn.c b/test/val/lib_common_strspn.c index 693a1136a..96a006469 100644 --- a/test/val/lib_common_strspn.c +++ b/test/val/lib_common_strspn.c @@ -1,7 +1,3 @@ -// temporarily disable optimizations altogether until a fine grain control -// is implemented on Makefile level only disabling the compiler option -Os -#pragma optimize (off) - #include <string.h> #include "unittest.h" From dce5783dc96bbf9165e8815c9df1314818241cb7 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 4 Apr 2017 13:23:44 -0400 Subject: [PATCH 060/199] Fixed the simulations of the stack pointer and the "break" and decimal-mode flags. * The pointer wraps around the stack page. * The break flag exists on only the stack, and only after an interrupt. * 65C02 interrupts clear the decimal-mode flag. --- src/sim65/6502.c | 57 +++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index 81caff4da..1febef657 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -34,14 +34,12 @@ /* Known bugs and limitations of the 65C02 simulation: * support currently only on the level of 65SC02: - BBRx, BBSx, RMBx, SMBx, WAI and STP are unsupported + BBRx, BBSx, RMBx, SMBx, WAI, and STP are unsupported * BCD flag handling equals 6502 (unchecked if bug is simulated or wrong for 6502) * one cycle win for fetch-modify-write instructions ignored - (e.g. ROL abs,x takes only 6 cycles if no page break occurs) - * BRK, IRQ, NMI and RESET are not different from 6502 which they are in - reality (e.g. D-flag handling) - */ + (e.g., ROL abs,x takes only 6 cycles if no page break occurs) +*/ #include "memory.h" #include "error.h" @@ -87,12 +85,11 @@ int PrintCycles; -/* Return the flags as a boolean value (0/1) */ +/* Return the flags as boolean values (0/1) */ #define GET_CF() ((Regs.SR & CF) != 0) #define GET_ZF() ((Regs.SR & ZF) != 0) #define GET_IF() ((Regs.SR & IF) != 0) #define GET_DF() ((Regs.SR & DF) != 0) -#define GET_BF() ((Regs.SR & BF) != 0) #define GET_OF() ((Regs.SR & OF) != 0) #define GET_SF() ((Regs.SR & SF) != 0) @@ -103,7 +100,6 @@ int PrintCycles; #define SET_ZF(f) do { if (f) { Regs.SR |= ZF; } else { Regs.SR &= ~ZF; } } while (0) #define SET_IF(f) do { if (f) { Regs.SR |= IF; } else { Regs.SR &= ~IF; } } while (0) #define SET_DF(f) do { if (f) { Regs.SR |= DF; } else { Regs.SR &= ~DF; } } while (0) -#define SET_BF(f) do { if (f) { Regs.SR |= BF; } else { Regs.SR &= ~BF; } } while (0) #define SET_OF(f) do { if (f) { Regs.SR |= OF; } else { Regs.SR &= ~OF; } } while (0) #define SET_SF(f) do { if (f) { Regs.SR |= SF; } else { Regs.SR &= ~SF; } } while (0) @@ -119,8 +115,8 @@ int PrintCycles; #define PCH ((Regs.PC >> 8) & 0xFF) /* Stack operations */ -#define PUSH(Val) MemWriteByte (0x0100 + Regs.SP--, Val) -#define POP() MemReadByte (0x0100 + ++Regs.SP) +#define PUSH(Val) MemWriteByte (0x0100 | (Regs.SP-- & 0xFF), Val) +#define POP() MemReadByte (0x0100 | (++Regs.SP & 0xFF)) /* Test for page cross */ #define PAGE_CROSS(addr,offs) ((((addr) & 0xFF) + offs) >= 0x100) @@ -376,11 +372,14 @@ static void OPC_6502_00 (void) { Cycles = 7; Regs.PC += 2; - SET_BF (1); PUSH (PCH); PUSH (PCL); PUSH (Regs.SR); SET_IF (1); + if (CPU != CPU_6502) + { + SET_DF (0); + } Regs.PC = MemReadWord (0xFFFE); } @@ -403,7 +402,7 @@ static void OPC_65SC02_04 (void) ZPAddr = MemReadByte (Regs.PC+1); Val = MemReadByte (ZPAddr); SET_ZF ((Val & Regs.AC) == 0); - MemWriteByte (ZPAddr, (unsigned char)(Val | Regs.AC)); + MemWriteByte (ZPAddr, (unsigned char)(Val | Regs.AC)); Regs.PC += 2; } @@ -438,7 +437,7 @@ static void OPC_6502_08 (void) /* Opcode $08: PHP */ { Cycles = 3; - PUSH (Regs.SR & ~BF); + PUSH (Regs.SR); Regs.PC += 1; } @@ -475,7 +474,7 @@ static void OPC_65SC02_0C (void) Addr = MemReadWord (Regs.PC+1); Val = MemReadByte (Addr); SET_ZF ((Val & Regs.AC) == 0); - MemWriteByte (Addr, (unsigned char) (Val | Regs.AC)); + MemWriteByte (Addr, (unsigned char) (Val | Regs.AC)); Regs.PC += 3; } @@ -539,7 +538,7 @@ static void OPC_65SC02_14 (void) ZPAddr = MemReadByte (Regs.PC+1); Val = MemReadByte (ZPAddr); SET_ZF ((Val & Regs.AC) == 0); - MemWriteByte (ZPAddr, (unsigned char)(Val & ~Regs.AC)); + MemWriteByte (ZPAddr, (unsigned char)(Val & ~Regs.AC)); Regs.PC += 2; } @@ -609,7 +608,7 @@ static void OPC_65SC02_1C (void) Addr = MemReadWord (Regs.PC+1); Val = MemReadByte (Addr); SET_ZF ((Val & Regs.AC) == 0); - MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC)); + MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC)); Regs.PC += 3; } @@ -707,7 +706,9 @@ static void OPC_6502_28 (void) /* Opcode $28: PLP */ { Cycles = 4; - Regs.SR = (POP () & ~BF); + + /* Bits 5 and 4 aren't used, and always are 1! */ + Regs.SR = (POP () | 0x30); Regs.PC += 1; } @@ -909,7 +910,9 @@ static void OPC_6502_40 (void) /* Opcode $40: RTI */ { Cycles = 6; - Regs.SR = POP (); + + /* Bits 5 and 4 aren't used, and always are 1! */ + Regs.SR = POP () | 0x30; Regs.PC = POP (); /* PCL */ Regs.PC |= (POP () << 8); /* PCH */ } @@ -2011,7 +2014,7 @@ static void OPC_6502_BA (void) /* Opcode $BA: TSX */ { Cycles = 2; - Regs.XR = Regs.SP; + Regs.XR = Regs.SP & 0xFF; TEST_ZF (Regs.XR); TEST_SF (Regs.XR); Regs.PC += 1; @@ -3213,7 +3216,9 @@ void Reset (void) /* Reset the CPU */ HaveIRQRequest = 0; HaveNMIRequest = 0; - Regs.SR = 0; + + /* Bits 5 and 4 aren't used, and always are 1! */ + Regs.SR = 0x30; Regs.PC = MemReadWord (0xFFFC); } @@ -3228,8 +3233,12 @@ unsigned ExecuteInsn (void) HaveNMIRequest = 0; PUSH (PCH); PUSH (PCL); - PUSH (Regs.SR); + PUSH (Regs.SR & ~BF); SET_IF (1); + if (CPU != CPU_6502) + { + SET_DF (0); + } Regs.PC = MemReadWord (0xFFFA); Cycles = 7; @@ -3238,8 +3247,12 @@ unsigned ExecuteInsn (void) HaveIRQRequest = 0; PUSH (PCH); PUSH (PCL); - PUSH (Regs.SR); + PUSH (Regs.SR & ~BF); SET_IF (1); + if (CPU != CPU_6502) + { + SET_DF (0); + } Regs.PC = MemReadWord (0xFFFE); Cycles = 7; From be772c0198f2d978171e0f35b5e1f71d27c414f6 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Thu, 6 Apr 2017 12:22:39 +0200 Subject: [PATCH 061/199] Bumped version. As suggested the incompatibility resulting from https://github.com/cc65/cc65/commit/02daf9f8b5c1ae2267561ee05ce67b2d0393c12d makes a new version appropriate. --- src/common/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/version.c b/src/common/version.c index 4e61a5f83..bf0a6bf71 100644 --- a/src/common/version.c +++ b/src/common/version.c @@ -47,7 +47,7 @@ #define VER_MAJOR 2U -#define VER_MINOR 15U +#define VER_MINOR 16U From e43dbe1c24a14416b8a2802af17ecd237deef25d Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Thu, 6 Apr 2017 17:53:57 +0200 Subject: [PATCH 062/199] Just some white space fixes of recently contributed code. --- libsrc/common/strcat.s | 4 ++-- libsrc/common/strchr.s | 4 ++-- libsrc/common/strcspn.s | 5 ++--- libsrc/common/strncat.s | 2 -- libsrc/common/strspn.s | 5 ++--- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/libsrc/common/strcat.s b/libsrc/common/strcat.s index 7dce2f78a..f9cd94633 100644 --- a/libsrc/common/strcat.s +++ b/libsrc/common/strcat.s @@ -21,7 +21,7 @@ _strcat: .else lda #0 sta ptr2 ; access from page start, y contains low byte -.endif +.endif stx ptr2+1 findEndOfDest: @@ -33,7 +33,7 @@ findEndOfDest: bne findEndOfDest endOfDestFound: - sty ptr2 ; advance pointer to last y position + sty ptr2 ; advance pointer to last y position ldy #0 ; reset new y-offset copyByte: diff --git a/libsrc/common/strchr.s b/libsrc/common/strchr.s index 15c743776..206b5160e 100644 --- a/libsrc/common/strchr.s +++ b/libsrc/common/strchr.s @@ -20,7 +20,7 @@ _strchr: .else lda #0 sta ptr1 ; access from page start, y contains low byte -.endif +.endif Loop: lda (ptr1),y ; Get next char beq EOS ; Jump on end of string @@ -29,7 +29,7 @@ Loop: lda (ptr1),y ; Get next char iny bne Loop inc ptr1+1 - bne Loop ; Branch always + bne Loop ; Branch always ; End of string. Check if we're searching for the terminating zero diff --git a/libsrc/common/strcspn.s b/libsrc/common/strcspn.s index 3f7b42ed1..c9122dc90 100644 --- a/libsrc/common/strcspn.s +++ b/libsrc/common/strcspn.s @@ -40,7 +40,7 @@ checkNext: check: cpy tmp1 ; compare with length of test character string beq endOfTestChars cmp (ptr1),y ; found matching char? - bne checkNext + bne checkNext leave: txa ; restore position of finding ldx tmp2 ; and return @@ -50,5 +50,4 @@ endOfTestChars: inx bne loadChar inc tmp2 - bne loadChar ; like bra... - + bne loadChar ; like bra... diff --git a/libsrc/common/strncat.s b/libsrc/common/strncat.s index e0fa39cc0..457e39e25 100644 --- a/libsrc/common/strncat.s +++ b/libsrc/common/strncat.s @@ -71,5 +71,3 @@ L6: lda #0 L7: lda ptr3 ldx ptr3+1 rts - - diff --git a/libsrc/common/strspn.s b/libsrc/common/strspn.s index 3316f0dab..079b935ee 100644 --- a/libsrc/common/strspn.s +++ b/libsrc/common/strspn.s @@ -40,15 +40,14 @@ checkNext: check: cpy tmp1 ; compare with length of test character string beq leave cmp (ptr1),y ; found matching char? - bne checkNext + bne checkNext foundTestChar: inx bne loadChar inc tmp2 - bne loadChar ; like bra... + bne loadChar ; like bra... leave: txa ; restore position of finding ldx tmp2 ; and return rts - \ No newline at end of file From 1aab28718915964b33ae87a70617966719364663 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Fri, 7 Apr 2017 09:26:58 -0400 Subject: [PATCH 063/199] Fixed the handling of "while (0) {}". It's a corner case; but, conditional macroes might create it -- better safe than sorry. --- src/cc65/stmt.c | 6 +-- test/val/while.c | 116 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 88 insertions(+), 34 deletions(-) diff --git a/src/cc65/stmt.c b/src/cc65/stmt.c index 84b516dc3..c6167fa78 100644 --- a/src/cc65/stmt.c +++ b/src/cc65/stmt.c @@ -273,9 +273,6 @@ static void WhileStatement (void) /* Remember the current position */ GetCodePos (&CondCodeStart); - /* Emit the code position label */ - g_defcodelabel (CondLabel); - /* Test the loop condition */ TestInParens (LoopLabel, 1); @@ -288,6 +285,9 @@ static void WhileStatement (void) /* Loop body */ Statement (&PendingToken); + /* Emit the while condition label */ + g_defcodelabel (CondLabel); + /* Move the test code here */ GetCodePos (&Here); MoveCode (&CondCodeStart, &CondCodeEnd, &Here); diff --git a/test/val/while.c b/test/val/while.c index cf2147052..b86b1fba5 100644 --- a/test/val/while.c +++ b/test/val/while.c @@ -1,53 +1,107 @@ /* - !!DESCRIPTION!! + !!DESCRIPTION!! while-condition tests !!ORIGIN!! SDCC regression tests !!LICENCE!! GPL, read COPYING.GPL */ #include <stdio.h> -#include <limits.h> -unsigned char success = 0; -unsigned char failures = 0; -unsigned char dummy = 0; +static unsigned char failures = 0x00; +static unsigned char achar0 = 0; -#ifdef SUPPORT_BIT_TYPES -bit bit0 = 0; -#endif -unsigned int aint0 = 0; -unsigned int aint1 = 0; -unsigned char achar0 = 0; -unsigned char achar1 = 0; - -void -done () -{ - dummy++; -} - -void +static void while1 (void) { unsigned char i = 10; - do - { - achar0++; - } - while (--i); + do { + ++achar0; + } while (--i); - if (achar0 != 10) - failures++; + if (achar0 != 10) { + failures |= 0x01; + } +} + +static void +while2 (void) +{ + unsigned char i = 10; + + achar0 = 0; + while (--i) { + ++achar0; + } + + if (achar0 != 10 - 1) { + failures |= 0x02; + } +} + +static void +while3 (void) +{ + achar0 = 0; + do { + if (++achar0 == (unsigned char)0) { + return; + } + } while (1); + + failures |= 0x04; +} + +static void +while4 (void) +{ + achar0 = 0; + while (1) { + if (++achar0 == (unsigned char)0) { + return; + } + } + + failures |= 0x08; +} + +static void +while5 (void) +{ + achar0 = 0; + do { + ++achar0; + } while (0); + + if (achar0 != 1) { + failures |= 0x10; + } +} + +static void +while6 (void) +{ + achar0 = 0; + while (0) { + ++achar0; + } + + if (achar0 != 1 - 1) { + failures |= 0x20; + } } int main (void) { while1 (); + while2 (); + while3 (); + while4 (); + while5 (); + while6 (); - success = failures; - done (); - printf("failures: %d\n",failures); - + if (failures) { + printf("failures: 0x%02X\n", failures); + } return failures; } From 18b0aaf9f20229812ad09b87684fe5bc7e06c319 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sat, 15 Apr 2017 23:12:19 +0200 Subject: [PATCH 064/199] Removed help for non-existent option. --- src/ca65/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index 3c3daf7f7..fbca2beac 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -123,7 +123,6 @@ static void Usage (void) " --large-alignment\t\tDon't warn about large alignments\n" " --listing name\t\tCreate a listing file if assembly was ok\n" " --list-bytes n\t\tMaximum number of bytes per listing line\n" - " --macpack-dir dir\t\tSet a macro package directory\n" " --memory-model model\t\tSet the memory model\n" " --pagelength n\t\tSet the page length for the listing\n" " --relax-checks\t\tRelax some checks (see docs)\n" From 82e62209d696dcb082bd67e227dd5fe30256c776 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Mon, 1 May 2017 19:50:01 +0300 Subject: [PATCH 065/199] Document pragma trampoline --- doc/cc65.sgml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 24b37133e..99ddfc82d 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1209,6 +1209,31 @@ parameter with the <tt/#pragma/. The <tt/#pragma/ understands the push and pop parameters as explained above. +<sect1><tt>#pragma trampoline (<push&rt;, <name>, <value>)</tt><label id="pragma-trampoline"><p> + + This pragma sets a trampoline for functions. The name is either + a function returning void and taking no parameters, or the address + of an array in memory (for a RAM trampoline). The value is an + 8-bit number that's set to tmp4. + + The address of the function is passed in ptr4. + + This is useful for example with banked memory, to automatically + switch banks to where this function resides, and then restore + the bank when it returns. + + The <tt/#pragma/ requires the push and pop parameters as explained above. + + Example: + <tscreen><verb> + void mytrampoline(void); + + #pragma trampoline (push, mytrampoline, 0) + void somefunc(void); + #pragma trampoline (pop) + </verb></tscreen> + + <sect1><tt>#pragma warn (name, [push,] on|off)</tt><label id="pragma-warn"><p> Switch compiler warnings on or off. "name" is the name of a warning (see the From a84463a3dfb74b200fc208ab30f89de54631a846 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Mon, 1 May 2017 20:12:18 +0300 Subject: [PATCH 066/199] callptr4 --- libsrc/runtime/callptr4.s | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 libsrc/runtime/callptr4.s diff --git a/libsrc/runtime/callptr4.s b/libsrc/runtime/callptr4.s new file mode 100644 index 000000000..9a15609aa --- /dev/null +++ b/libsrc/runtime/callptr4.s @@ -0,0 +1,10 @@ +; +; CC65 runtime: call function via pointer in ptr4 +; + + .export callptr4 + .importzp ptr4 + +callptr4: + jmp (ptr4) ; jump there + From 679bfb0ae9353646e78a981941d525ea86b44e88 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Mon, 1 May 2017 20:46:06 +0300 Subject: [PATCH 067/199] Add IntPtrStack --- src/common/intptrstack.c | 90 +++++++++++++++++++++++++++++ src/common/intptrstack.h | 121 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+) create mode 100644 src/common/intptrstack.c create mode 100644 src/common/intptrstack.h diff --git a/src/common/intptrstack.c b/src/common/intptrstack.c new file mode 100644 index 000000000..de02c09e7 --- /dev/null +++ b/src/common/intptrstack.c @@ -0,0 +1,90 @@ +/*****************************************************************************/ +/* */ +/* intptrstack.c */ +/* */ +/* Integer+ptr stack used for program settings */ +/* */ +/* */ +/* */ +/* (C) 2017, Mega Cat Studios */ +/* */ +/* */ +/* 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. */ +/* */ +/*****************************************************************************/ + + + +/* common */ +#include "check.h" +#include "intptrstack.h" + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +void IPS_Get (const IntPtrStack* S, long *Val, void **Ptr) +/* Get the value on top of an int stack */ +{ + PRECONDITION (S->Count > 0); + if (Val) *Val = S->Stack[S->Count-1].val; + if (Ptr) *Ptr = S->Stack[S->Count-1].ptr; +} + + + +void IPS_Set (IntPtrStack* S, long Val, void *Ptr) +/* Set the value on top of an int stack */ +{ + PRECONDITION (S->Count > 0); + S->Stack[S->Count-1].val = Val; + S->Stack[S->Count-1].ptr = Ptr; +} + + + +void IPS_Drop (IntPtrStack* S) +/* Drop a value from an int stack */ +{ + PRECONDITION (S->Count > 0); + --S->Count; +} + + + +void IPS_Push (IntPtrStack* S, long Val, void *Ptr) +/* Push a value onto an int stack */ +{ + PRECONDITION (S->Count < sizeof (S->Stack) / sizeof (S->Stack[0])); + S->Stack[S->Count].val = Val; + S->Stack[S->Count++].ptr = Ptr; +} + + + +void IPS_Pop (IntPtrStack* S, long *Val, void **Ptr) +/* Pop a value from an int stack */ +{ + PRECONDITION (S->Count > 0); + if (Val) *Val = S->Stack[--S->Count].val; + if (Ptr) *Ptr = S->Stack[S->Count].ptr; +} diff --git a/src/common/intptrstack.h b/src/common/intptrstack.h new file mode 100644 index 000000000..a7b1c6683 --- /dev/null +++ b/src/common/intptrstack.h @@ -0,0 +1,121 @@ +/*****************************************************************************/ +/* */ +/* intptrstack.h */ +/* */ +/* Integer+ptr stack used for program settings */ +/* */ +/* */ +/* */ +/* (C) 2017, Mega Cat Studios */ +/* */ +/* */ +/* 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 INTPTRSTACK_H +#define INTPTRSTACK_H + + + +#include "inline.h" + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +typedef struct IntPtrStack IntPtrStack; +struct IntPtrInner { + long val; + void *ptr; +}; +struct IntPtrStack { + unsigned Count; + struct IntPtrInner Stack[8]; +}; + +/* An initializer for an empty int stack */ +#define STATIC_INTPTRSTACK_INITIALIZER { 0, { 0, 0 }, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} } } + +/* Declare an int stack with the given value as first element */ +#define INTPTRSTACK(Val, Ptr) { 1, { {Val, Ptr}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} } } + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +#if defined(HAVE_INLINE) +INLINE int IPS_IsFull (const IntPtrStack* S) +/* Return true if there is no space left on the given int stack */ +{ + return (S->Count >= sizeof (S->Stack) / sizeof (S->Stack[0])); +} +#else +# define IPS_IsFull(S) ((S)->Count >= sizeof ((S)->Stack) / sizeof ((S)->Stack[0])) +#endif + +#if defined(HAVE_INLINE) +INLINE int IPS_IsEmpty (const IntPtrStack* S) +/* Return true if there are no values on the given int stack */ +{ + return (S->Count == 0); +} +#else +# define IPS_IsEmpty(S) ((S)->Count == 0) +#endif + +#if defined(HAVE_INLINE) +INLINE unsigned IPS_GetCount (const IntPtrStack* S) +/* Return the number of elements on the given int stack */ +{ + return S->Count; +} +#else +# define IPS_GetCount(S) (S)->Count +#endif + +void IPS_Get (const IntPtrStack* S, long *Val, void **Ptr); +/* Get the value on top of an int stack */ + +void IPS_Set (IntPtrStack* S, long Val, void *Ptr); +/* Set the value on top of an int stack */ + +void IPS_Drop (IntPtrStack* S); +/* Drop a value from an int stack */ + +void IPS_Push (IntPtrStack* S, long Val, void *Ptr); +/* Push a value onto an int stack */ + +void IPS_Pop (IntPtrStack* S, long *Val, void **Ptr); +/* Pop a value from an int stack */ + + + +/* End of IntPtrStack.h */ + +#endif From d091a57e918244f0d6a7b651b908f7f08a2cee95 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Mon, 1 May 2017 21:00:28 +0300 Subject: [PATCH 068/199] Trampoline stack --- src/cc65/trampoline.c | 102 ++++++++++++++++++++++++++++++++++++++++++ src/cc65/trampoline.h | 65 +++++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 src/cc65/trampoline.c create mode 100644 src/cc65/trampoline.h diff --git a/src/cc65/trampoline.c b/src/cc65/trampoline.c new file mode 100644 index 000000000..1f35a0f3c --- /dev/null +++ b/src/cc65/trampoline.c @@ -0,0 +1,102 @@ +/*****************************************************************************/ +/* */ +/* trampoline.c */ +/* */ +/* Trampoline management */ +/* */ +/* */ +/* */ +/* (C) 2017, Mega Cat Studios */ +/* */ +/* */ +/* 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. */ +/* */ +/*****************************************************************************/ + + + +#include <stdarg.h> +#include <string.h> + +/* common */ +#include "chartype.h" +#include "check.h" +#include "coll.h" +#include "scanner.h" +#include "intptrstack.h" +#include "xmalloc.h" + +/* cc65 */ +#include "codeent.h" +#include "error.h" +#include "trampoline.h" + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + +/* Trampolines */ +static IntPtrStack Trampolines; + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +void PushTrampoline (void *Ptr, unsigned char Val) +/* Push the current trampoline */ +{ + if (IPS_IsFull (&Trampolines)) { + Error ("Trampoline stack overflow"); + } else { + IPS_Push (&Trampolines, Val, Ptr); + } +} + + + +void PopTrampoline (void) +/* Remove the current trampoline */ +{ + if (IPS_GetCount (&Trampolines) < 1) { + Error ("Trampoline stack is empty"); + } else { + IPS_Drop (&Trampolines); + } +} + + + +void GetTrampoline (void **Ptr, unsigned char *Val) +/* Get the current trampoline */ +{ + if (IPS_GetCount (&Trampolines) < 1) { + *Ptr = NULL; + *Val = 0; + } else { + long Temp; + IPS_Get (&Trampolines, &Temp, Ptr); + *Val = Temp; + } +} diff --git a/src/cc65/trampoline.h b/src/cc65/trampoline.h new file mode 100644 index 000000000..f110bd42e --- /dev/null +++ b/src/cc65/trampoline.h @@ -0,0 +1,65 @@ +/*****************************************************************************/ +/* */ +/* trampoline.h */ +/* */ +/* Trampoline management */ +/* */ +/* */ +/* */ +/* (C) 2017, Mega Cat Studios */ +/* */ +/* */ +/* 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 TRAMPOLINE_H +#define TRAMPOLINE_H + + + +#include <stdio.h> + +/* common */ +#include "attrib.h" + +/* cc65 */ +#include "opcodes.h" + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +void PushTrampoline (void *Ptr, unsigned char Val); +/* Push the current trampoline */ + +void PopTrampoline (void); +/* Pop the current trampoline */ + +void GetTrampoline (void **Ptr, unsigned char *Val); +/* Get the current trampoline, if any */ + + +/* End of trampoline.h */ + +#endif From 9c86c03a96e9885ac7aedd62b099ba43526aef4f Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 2 May 2017 18:48:31 +0300 Subject: [PATCH 069/199] Add test case --- test/val/trampoline.c | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 test/val/trampoline.c diff --git a/test/val/trampoline.c b/test/val/trampoline.c new file mode 100644 index 000000000..b5df1a22b --- /dev/null +++ b/test/val/trampoline.c @@ -0,0 +1,53 @@ +/* + !!DESCRIPTION!! trampoline pragma + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Lauri Kasanen +*/ + +static unsigned char flag; + +static void trampoline_set() { + asm("ldy tmp4"); + asm("sty %v", flag); + asm("jsr callptr4"); +} + +void trampoline_inc() { + asm("inc %v", flag); + asm("jsr callptr4"); +} + +void func3() { + +} + +unsigned char array[30]; +#pragma trampoline(push, array, 0) +#pragma trampoline(pop) + +#pragma trampoline(push, trampoline_inc, 0) + +void func2() { + func3(); +} + +#pragma trampoline(push, trampoline_set, 4) + +void func1(void); + +#pragma trampoline(pop) +#pragma trampoline(pop) + +void func1() { + func2(); +} + +int main(void) +{ + flag = 0; + + func1(); + + return flag == 5 ? 0 : 1; +} From 2890b3a810219ad512f9fdd2432811f94c0b121e Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 2 May 2017 19:06:19 +0300 Subject: [PATCH 070/199] Pragma trampoline --- src/cc65/declare.c | 21 +++++++++++ src/cc65/expr.c | 46 +++++++++++++++++++++++- src/cc65/funcdesc.c | 2 ++ src/cc65/funcdesc.h | 2 ++ src/cc65/pragma.c | 85 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 155 insertions(+), 1 deletion(-) diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 7b543aa55..2ebc09b14 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -58,6 +58,7 @@ #include "scanner.h" #include "standard.h" #include "symtab.h" +#include "trampoline.h" #include "typeconv.h" @@ -1315,6 +1316,8 @@ static FuncDesc* ParseFuncDecl (void) { unsigned Offs; SymEntry* Sym; + SymEntry* Trampoline; + unsigned char TrampolineData; /* Create a new function descriptor */ FuncDesc* F = NewFuncDesc (); @@ -1380,6 +1383,13 @@ static FuncDesc* ParseFuncDecl (void) /* Leave the lexical level remembering the symbol tables */ RememberFunctionLevel (F); + /* Did we have a trampoline for this function? */ + GetTrampoline((void **) &Trampoline, &TrampolineData); + if (Trampoline) { + F->Trampoline = Trampoline; + F->TrampolineData = TrampolineData; + } + /* Return the function descriptor */ return F; } @@ -1447,6 +1457,7 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode) /* Function declaration */ FuncDesc* F; + SymEntry* PrevEntry; /* Skip the opening paren */ NextToken (); @@ -1460,6 +1471,16 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode) Qualifiers &= ~T_QUAL_FASTCALL; } + /* Was there a previous entry? If so, copy trampoline info from it */ + PrevEntry = FindGlobalSym (D->Ident); + if (PrevEntry && PrevEntry->Flags & SC_FUNC) { + FuncDesc* D = PrevEntry->V.F.Func; + if (D->Trampoline && !F->Trampoline) { + F->Trampoline = D->Trampoline; + F->TrampolineData = D->TrampolineData; + } + } + /* Add the function type. Be sure to bounds check the type buffer */ NeedTypeSpace (D, 1); D->Type[D->Index].C = T_FUNC | Qualifiers; diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 34cf550a2..fb1232fc1 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -536,6 +536,10 @@ static void FunctionCall (ExprDesc* Expr) /* Special handling for function pointers */ if (IsFuncPtr) { + if (Func->Trampoline) { + Warning("Calling a trampolined function via a pointer, trampoline will not be used"); + } + /* If the function is not a fastcall function, load the pointer to ** the function into the primary. */ @@ -584,7 +588,47 @@ static void FunctionCall (ExprDesc* Expr) } else { /* Normal function */ - g_call (TypeOf (Expr->Type), (const char*) Expr->Name, ParamSize); + if (Func->Trampoline) { + char tmp[64]; + StrBuf S = AUTO_STRBUF_INITIALIZER; + + /* Store the trampoline data in tmp4 */ + sprintf(tmp, "ldy #%u", Func->TrampolineData); + SB_AppendStr (&S, tmp); + g_asmcode (&S); + SB_Clear(&S); + + SB_AppendStr (&S, "sty tmp4"); + g_asmcode (&S); + SB_Clear(&S); + + /* Store the original function address in ptr4 */ + SB_AppendStr (&S, "ldy #<(_"); + SB_AppendStr (&S, (const char*) Expr->Name); + SB_AppendChar (&S, ')'); + g_asmcode (&S); + SB_Clear(&S); + + SB_AppendStr (&S, "sty ptr4"); + g_asmcode (&S); + SB_Clear(&S); + + SB_AppendStr (&S, "ldy #>(_"); + SB_AppendStr (&S, (const char*) Expr->Name); + SB_AppendChar (&S, ')'); + g_asmcode (&S); + SB_Clear(&S); + + SB_AppendStr (&S, "sty ptr4+1"); + g_asmcode (&S); + SB_Clear(&S); + + SB_Done (&S); + + g_call (TypeOf (Expr->Type), Func->Trampoline->Name, ParamSize); + } else { + g_call (TypeOf (Expr->Type), (const char*) Expr->Name, ParamSize); + } } diff --git a/src/cc65/funcdesc.c b/src/cc65/funcdesc.c index b9561a97c..607094acd 100644 --- a/src/cc65/funcdesc.c +++ b/src/cc65/funcdesc.c @@ -60,6 +60,8 @@ FuncDesc* NewFuncDesc (void) F->ParamCount = 0; F->ParamSize = 0; F->LastParam = 0; + F->Trampoline = 0; + F->TrampolineData = 0; /* Return the new struct */ return F; diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index b79c6a055..b83cfa362 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -67,6 +67,8 @@ struct FuncDesc { unsigned ParamCount; /* Number of parameters */ unsigned ParamSize; /* Size of the parameters */ struct SymEntry* LastParam; /* Pointer to last parameter */ + struct SymEntry* Trampoline; /* Pointer to the trampoline */ + unsigned char TrampolineData; /* The trampoline's user data */ }; diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 707546e1d..c36811f35 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -51,6 +51,7 @@ #include "scanstrbuf.h" #include "symtab.h" #include "pragma.h" +#include "trampoline.h" @@ -87,6 +88,7 @@ typedef enum { PRAGMA_SIGNEDCHARS, /* obsolete */ PRAGMA_STATIC_LOCALS, PRAGMA_STATICLOCALS, /* obsolete */ + PRAGMA_TRAMPOLINE, PRAGMA_WARN, PRAGMA_WRITABLE_STRINGS, PRAGMA_ZPSYM, @@ -122,6 +124,7 @@ static const struct Pragma { { "signedchars", PRAGMA_SIGNEDCHARS }, /* obsolete */ { "static-locals", PRAGMA_STATIC_LOCALS }, { "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */ + { "trampoline", PRAGMA_TRAMPOLINE }, { "warn", PRAGMA_WARN }, { "writable-strings", PRAGMA_WRITABLE_STRINGS }, { "zpsym", PRAGMA_ZPSYM }, @@ -446,6 +449,84 @@ ExitPoint: } +static void TrampolinePragma (StrBuf* B) +/* Handle the trampoline pragma */ +{ + StrBuf S = AUTO_STRBUF_INITIALIZER; + const char *Name; + long Val; + SymEntry *Entry; + + /* Check for the "push" or "pop" keywords */ + switch (ParsePushPop (B)) { + + case PP_NONE: + Error ("Push or pop required"); + break; + + case PP_PUSH: + break; + + case PP_POP: + PopTrampoline(); + + /* Done */ + goto ExitPoint; + + case PP_ERROR: + /* Bail out */ + goto ExitPoint; + + default: + Internal ("Invalid result from ParsePushPop"); + + } + + /* A symbol argument must follow */ + if (!SB_GetSym (B, &S, NULL)) { + goto ExitPoint; + } + + /* Skip the following comma */ + if (!GetComma (B)) { + /* Error already flagged by GetComma */ + Error ("Value required for trampoline data"); + goto ExitPoint; + } + + if (!GetNumber (B, &Val)) { + Error ("Value required for trampoline data"); + goto ExitPoint; + } + + if (Val < 0 || Val > 255) { + Error ("Value must be between 0-255"); + goto ExitPoint; + } + + /* Get the string */ + Name = SB_GetConstBuf (&S); + Entry = FindSym(Name); + + /* Check if the name is valid */ + if (Entry && Entry->Flags & (SC_FUNC | SC_STORAGE)) { + + PushTrampoline(Entry, Val); + Entry->Flags |= SC_REF; + + } else { + + /* Segment name is invalid */ + Error ("Trampoline does not exist or is not a function or array"); + + } + +ExitPoint: + /* Call the string buf destructor */ + SB_Done (&S); +} + + static void CharMapPragma (StrBuf* B) /* Change the character map */ @@ -791,6 +872,10 @@ static void ParsePragma (void) FlagPragma (&B, &StaticLocals); break; + case PRAGMA_TRAMPOLINE: + TrampolinePragma(&B); + break; + case PRAGMA_WARN: WarnPragma (&B); break; From 767f093ff86604314a9ee42c25842c79905f3248 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Sat, 6 May 2017 13:20:55 +0300 Subject: [PATCH 071/199] Add fast path for char postinc --- src/cc65/expr.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 34cf550a2..502fd7a8e 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -1534,26 +1534,35 @@ static void PostInc (ExprDesc* Expr) /* Get the data type */ Flags = TypeOf (Expr->Type); - /* Push the address if needed */ - PushAddr (Expr); + /* Fast path: char */ + if ((Flags & CF_CHAR) == CF_CHAR && ED_GetLoc(Expr) & (E_LOC_GLOBAL | E_LOC_STATIC)) { - /* Fetch the value and save it (since it's the result of the expression) */ - LoadExpr (CF_NONE, Expr); - g_save (Flags | CF_FORCECHAR); + LoadExpr (CF_NONE, Expr); + AddCodeLine ("inc %s", ED_GetLabelName(Expr, 0)); - /* If we have a pointer expression, increment by the size of the type */ - if (IsTypePtr (Expr->Type)) { - g_inc (Flags | CF_CONST | CF_FORCECHAR, CheckedSizeOf (Expr->Type + 1)); } else { - g_inc (Flags | CF_CONST | CF_FORCECHAR, 1); + + /* Push the address if needed */ + PushAddr (Expr); + + /* Fetch the value and save it (since it's the result of the expression) */ + LoadExpr (CF_NONE, Expr); + g_save (Flags | CF_FORCECHAR); + + /* If we have a pointer expression, increment by the size of the type */ + if (IsTypePtr (Expr->Type)) { + g_inc (Flags | CF_CONST | CF_FORCECHAR, CheckedSizeOf (Expr->Type + 1)); + } else { + g_inc (Flags | CF_CONST | CF_FORCECHAR, 1); + } + + /* Store the result back */ + Store (Expr, 0); + + /* Restore the original value in the primary register */ + g_restore (Flags | CF_FORCECHAR); } - /* Store the result back */ - Store (Expr, 0); - - /* Restore the original value in the primary register */ - g_restore (Flags | CF_FORCECHAR); - /* The result is always an expression, no reference */ ED_MakeRValExpr (Expr); } From ead0338c0def811cb251090cc0851899a0cbdf8e Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Sat, 6 May 2017 13:23:50 +0300 Subject: [PATCH 072/199] Add fast path for char postdec --- src/cc65/expr.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 502fd7a8e..e5c1a17b9 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -1590,26 +1590,35 @@ static void PostDec (ExprDesc* Expr) /* Get the data type */ Flags = TypeOf (Expr->Type); - /* Push the address if needed */ - PushAddr (Expr); + /* Fast path: char */ + if ((Flags & CF_CHAR) == CF_CHAR && ED_GetLoc(Expr) & (E_LOC_GLOBAL | E_LOC_STATIC)) { - /* Fetch the value and save it (since it's the result of the expression) */ - LoadExpr (CF_NONE, Expr); - g_save (Flags | CF_FORCECHAR); + LoadExpr (CF_NONE, Expr); + AddCodeLine ("dec %s", ED_GetLabelName(Expr, 0)); - /* If we have a pointer expression, increment by the size of the type */ - if (IsTypePtr (Expr->Type)) { - g_dec (Flags | CF_CONST | CF_FORCECHAR, CheckedSizeOf (Expr->Type + 1)); } else { - g_dec (Flags | CF_CONST | CF_FORCECHAR, 1); + + /* Push the address if needed */ + PushAddr (Expr); + + /* Fetch the value and save it (since it's the result of the expression) */ + LoadExpr (CF_NONE, Expr); + g_save (Flags | CF_FORCECHAR); + + /* If we have a pointer expression, increment by the size of the type */ + if (IsTypePtr (Expr->Type)) { + g_dec (Flags | CF_CONST | CF_FORCECHAR, CheckedSizeOf (Expr->Type + 1)); + } else { + g_dec (Flags | CF_CONST | CF_FORCECHAR, 1); + } + + /* Store the result back */ + Store (Expr, 0); + + /* Restore the original value in the primary register */ + g_restore (Flags | CF_FORCECHAR); } - /* Store the result back */ - Store (Expr, 0); - - /* Restore the original value in the primary register */ - g_restore (Flags | CF_FORCECHAR); - /* The result is always an expression, no reference */ ED_MakeRValExpr (Expr); } From a2f61c667ab49cd99632cbd958ef79057d80ac77 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Sun, 7 May 2017 20:31:41 +0300 Subject: [PATCH 073/199] Update comments and location checks according to Greg --- src/cc65/expr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index e5c1a17b9..e87b02ffc 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -1534,8 +1534,8 @@ static void PostInc (ExprDesc* Expr) /* Get the data type */ Flags = TypeOf (Expr->Type); - /* Fast path: char */ - if ((Flags & CF_CHAR) == CF_CHAR && ED_GetLoc(Expr) & (E_LOC_GLOBAL | E_LOC_STATIC)) { + /* Emit smaller code if a char variable is at a constant location */ + if ((Flags & CF_CHAR) == CF_CHAR && ED_IsLocConst(Expr)) { LoadExpr (CF_NONE, Expr); AddCodeLine ("inc %s", ED_GetLabelName(Expr, 0)); @@ -1590,8 +1590,8 @@ static void PostDec (ExprDesc* Expr) /* Get the data type */ Flags = TypeOf (Expr->Type); - /* Fast path: char */ - if ((Flags & CF_CHAR) == CF_CHAR && ED_GetLoc(Expr) & (E_LOC_GLOBAL | E_LOC_STATIC)) { + /* Emit smaller code if a char variable is at a constant location */ + if ((Flags & CF_CHAR) == CF_CHAR && ED_IsLocConst(Expr)) { LoadExpr (CF_NONE, Expr); AddCodeLine ("dec %s", ED_GetLabelName(Expr, 0)); From 7adcde1707eb7ab81bc1f15099ad91276f0f11eb Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Sun, 7 May 2017 20:35:49 +0300 Subject: [PATCH 074/199] Add explicit postinc/dec testcase --- test/val/postincdec.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/val/postincdec.c diff --git a/test/val/postincdec.c b/test/val/postincdec.c new file mode 100644 index 000000000..19a6eb2a7 --- /dev/null +++ b/test/val/postincdec.c @@ -0,0 +1,23 @@ +/* + !!DESCRIPTION!! char-sized post-increment and -decrement + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Lauri Kasanen +*/ + + +static unsigned char val, array[2]; + +int main() { + + val = 0; + array[0] = array[1] = 10; + + array[val++] = 2; + array[val++] = 2; + --val; + array[val--] = 0; + array[val--] = 0; + + return (array[0] == array[1] && array[0] == 0) ? 0 : 1; +} From 077b14ccfa5f8b4defc2f98b01cf17e0f2a70922 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Mon, 8 May 2017 10:19:26 +0300 Subject: [PATCH 075/199] test/val/postincdec: Test for the final val value --- test/val/postincdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/val/postincdec.c b/test/val/postincdec.c index 19a6eb2a7..6d3e9593c 100644 --- a/test/val/postincdec.c +++ b/test/val/postincdec.c @@ -19,5 +19,5 @@ int main() { array[val--] = 0; array[val--] = 0; - return (array[0] == array[1] && array[0] == 0) ? 0 : 1; + return (array[0] == array[1] && array[0] == 0 && val == 0xff) ? 0 : 1; } From 4cbfb4e199bf019c0f4c917c6c189fe93867a05a Mon Sep 17 00:00:00 2001 From: mc78 <mc78@outlook.de> Date: Fri, 12 May 2017 12:19:40 +0200 Subject: [PATCH 076/199] added -E switch to cl65 for >>stop after the preprocessing stage<<. added compilation and assemblation disable after -Wc -E also with -E beeing part of a comma separated list of arguments --- src/cl65/main.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 7bdbe7a8a..58a1fe0c2 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -706,6 +706,7 @@ static void Usage (void) " -C name\t\t\tUse linker config file\n" " -Cl\t\t\t\tMake local variables static\n" " -D sym[=defn]\t\t\tDefine a preprocessor symbol\n" + " -E Stop after the preprocessing stage\n" " -I dir\t\t\tSet a compiler include directory path\n" " -L path\t\t\tSpecify a library search path\n" " -Ln name\t\t\tCreate a VICE label file\n" @@ -1411,14 +1412,41 @@ int main (int argc, char* argv []) /* Print version number */ OptVersion (Arg, 0); break; - + + case 'E': + /*Forward -E to compiler*/ + CmdAddArg (&CC65, Arg); + DoAssemble = 0; + DoLink = 0; + break; case 'W': if (Arg[2] == 'a' && Arg[3] == '\0') { /* -Wa: Pass options to assembler */ OptAsmArgs (Arg, GetArg (&I, 3)); - } else if (Arg[2] == 'c' && Arg[3] == '\0') { + } + else if (Arg[2] == 'c' && Arg[3] == '\0') { /* -Wc: Pass options to compiler */ - OptCCArgs (Arg, GetArg (&I, 3)); + + /* Get argument succeeding -Wc switch */ + const char* WcSubArgs = GetArg (&I, 3); + + /* Remember -Wc sub arguments in cc65 arg struct */ + OptCCArgs (Arg, WcSubArgs); + /* Check for isolated -E switch given after -Wc*/ + if (!strcmp("-E", WcSubArgs)){ + /*If both -Wc and -E given, then prevent assembling + and linking */ + DoAssemble = 0; + DoLink = 0; + }else{ + /* Check for -E beeing part of comma separated arg + list given after -Wc*/ + if ( (NULL!=strstr(WcSubArgs, "-E,")) || + (NULL!=strstr(WcSubArgs, ",-E"))){ + DoAssemble = 0; + DoLink = 0; + } + } } else if (Arg[2] == 'l' && Arg[3] == '\0') { /* -Wl: Pass options to linker */ OptLdArgs (Arg, GetArg (&I, 3)); From 691df09a1f4a6b0f95b0d6eb7fd7320eb28df2b6 Mon Sep 17 00:00:00 2001 From: mc78 <mc78@outlook.de> Date: Tue, 16 May 2017 13:13:09 +0200 Subject: [PATCH 077/199] According to recent comments on my recent pull request, -Wc checking for -E flag has been removed again. Intead, -E flag has been added to cl65 without need of -Wc. Two functions have been introduced to disable compile, link or both. These function remove assigment repetions to DoAssemble and DoLink for litte overhead, having the maintainability in mind. --- src/cl65/main.c | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 58a1fe0c2..2172700ae 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -156,7 +156,21 @@ static char* TargetLib = 0; # endif #endif +/*****************************************************************************/ +/* Credential functions */ +/*****************************************************************************/ +void DisableAssembling(void){ + DoAssemble = 0; +} +void DisableLinking(void){ + DoLink = 0; +} + +void DisableAssemblingAndLinking(void){ + DisableAssembling(); + DisableLinking(); +} /*****************************************************************************/ /* Command structure handling */ @@ -1399,8 +1413,7 @@ int main (int argc, char* argv []) case 'S': /* Dont assemble and link the created files */ - DoAssemble = 0; - DoLink = 0; + DisableAssemblingAndLinking(); break; case 'T': @@ -1416,37 +1429,16 @@ int main (int argc, char* argv []) case 'E': /*Forward -E to compiler*/ CmdAddArg (&CC65, Arg); - DoAssemble = 0; - DoLink = 0; + DisableAssemblingAndLinking(); break; case 'W': if (Arg[2] == 'a' && Arg[3] == '\0') { /* -Wa: Pass options to assembler */ OptAsmArgs (Arg, GetArg (&I, 3)); - } - else if (Arg[2] == 'c' && Arg[3] == '\0') { + } else if (Arg[2] == 'c' && Arg[3] == '\0') { /* -Wc: Pass options to compiler */ - - /* Get argument succeeding -Wc switch */ - const char* WcSubArgs = GetArg (&I, 3); - /* Remember -Wc sub arguments in cc65 arg struct */ - OptCCArgs (Arg, WcSubArgs); - /* Check for isolated -E switch given after -Wc*/ - if (!strcmp("-E", WcSubArgs)){ - /*If both -Wc and -E given, then prevent assembling - and linking */ - DoAssemble = 0; - DoLink = 0; - }else{ - /* Check for -E beeing part of comma separated arg - list given after -Wc*/ - if ( (NULL!=strstr(WcSubArgs, "-E,")) || - (NULL!=strstr(WcSubArgs, ",-E"))){ - DoAssemble = 0; - DoLink = 0; - } - } + OptCCArgs (Arg, GetArg (&I, 3)); } else if (Arg[2] == 'l' && Arg[3] == '\0') { /* -Wl: Pass options to linker */ OptLdArgs (Arg, GetArg (&I, 3)); @@ -1458,7 +1450,7 @@ int main (int argc, char* argv []) case 'c': /* Don't link the resulting files */ - DoLink = 0; + DisableLinking(); break; case 'd': From d70a9507a7c731e9b95dd615328df975a3cff58c Mon Sep 17 00:00:00 2001 From: mc78 <mc78@outlook.de> Date: Tue, 16 May 2017 13:31:10 +0200 Subject: [PATCH 078/199] replaced tabs with spaces which accidently were introduced. --- src/cl65/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 2172700ae..e428c96ac 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -157,19 +157,19 @@ static char* TargetLib = 0; #endif /*****************************************************************************/ -/* Credential functions */ +/* Credential functions */ /*****************************************************************************/ void DisableAssembling(void){ - DoAssemble = 0; + DoAssemble = 0; } void DisableLinking(void){ - DoLink = 0; + DoLink = 0; } void DisableAssemblingAndLinking(void){ - DisableAssembling(); - DisableLinking(); + DisableAssembling(); + DisableLinking(); } /*****************************************************************************/ From ca41af41c2d555355ea45dd0c83a5fa3508ddd1a Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 16 May 2017 20:10:24 +0300 Subject: [PATCH 079/199] Rename pragma trampoline to wrapped-call, value to identifier --- doc/cc65.sgml | 50 +++++++++++++++++++++---------------------- src/cc65/pragma.c | 20 ++++++++--------- test/val/trampoline.c | 12 +++++------ 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 99ddfc82d..a9b88c2b4 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1209,31 +1209,6 @@ parameter with the <tt/#pragma/. The <tt/#pragma/ understands the push and pop parameters as explained above. -<sect1><tt>#pragma trampoline (<push&rt;, <name>, <value>)</tt><label id="pragma-trampoline"><p> - - This pragma sets a trampoline for functions. The name is either - a function returning void and taking no parameters, or the address - of an array in memory (for a RAM trampoline). The value is an - 8-bit number that's set to tmp4. - - The address of the function is passed in ptr4. - - This is useful for example with banked memory, to automatically - switch banks to where this function resides, and then restore - the bank when it returns. - - The <tt/#pragma/ requires the push and pop parameters as explained above. - - Example: - <tscreen><verb> - void mytrampoline(void); - - #pragma trampoline (push, mytrampoline, 0) - void somefunc(void); - #pragma trampoline (pop) - </verb></tscreen> - - <sect1><tt>#pragma warn (name, [push,] on|off)</tt><label id="pragma-warn"><p> Switch compiler warnings on or off. "name" is the name of a warning (see the @@ -1254,6 +1229,31 @@ parameter with the <tt/#pragma/. </verb></tscreen> +<sect1><tt>#pragma wrapped-call (<push&rt;, <name>, <identifier>)</tt><label id="pragma-trampoline"><p> + + This pragma sets a wrapper for functions, often used for trampolines. + The name is either a function returning void and taking no parameters, + or the address of an array in memory (for a RAM trampoline). The identifier + is an 8-bit number that's set to tmp4. + + The address of the function is passed in ptr4. + + This is useful for example with banked memory, to automatically + switch banks to where this function resides, and then restore + the bank when it returns. + + The <tt/#pragma/ requires the push and pop parameters as explained above. + + Example: + <tscreen><verb> + void mytrampoline(void); + + #pragma wrapped-call (push, mytrampoline, 0) + void somefunc(void); + #pragma wrapped-call (pop) + </verb></tscreen> + + <sect1><tt>#pragma writable-strings ([push,] on|off)</tt><label id="pragma-writable-strings"><p> Changes the storage location of string literals. For historical reasons, diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index c36811f35..6ec2df3a3 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -88,8 +88,8 @@ typedef enum { PRAGMA_SIGNEDCHARS, /* obsolete */ PRAGMA_STATIC_LOCALS, PRAGMA_STATICLOCALS, /* obsolete */ - PRAGMA_TRAMPOLINE, PRAGMA_WARN, + PRAGMA_WRAPPED_CALL, PRAGMA_WRITABLE_STRINGS, PRAGMA_ZPSYM, PRAGMA_COUNT @@ -124,8 +124,8 @@ static const struct Pragma { { "signedchars", PRAGMA_SIGNEDCHARS }, /* obsolete */ { "static-locals", PRAGMA_STATIC_LOCALS }, { "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */ - { "trampoline", PRAGMA_TRAMPOLINE }, { "warn", PRAGMA_WARN }, + { "wrapped-call", PRAGMA_WRAPPED_CALL }, { "writable-strings", PRAGMA_WRITABLE_STRINGS }, { "zpsym", PRAGMA_ZPSYM }, }; @@ -449,8 +449,8 @@ ExitPoint: } -static void TrampolinePragma (StrBuf* B) -/* Handle the trampoline pragma */ +static void WrappedCallPragma (StrBuf* B) +/* Handle the wrapped-call pragma */ { StrBuf S = AUTO_STRBUF_INITIALIZER; const char *Name; @@ -490,17 +490,17 @@ static void TrampolinePragma (StrBuf* B) /* Skip the following comma */ if (!GetComma (B)) { /* Error already flagged by GetComma */ - Error ("Value required for trampoline data"); + Error ("Value required for wrapped-call identifier"); goto ExitPoint; } if (!GetNumber (B, &Val)) { - Error ("Value required for trampoline data"); + Error ("Value required for wrapped-call identifier"); goto ExitPoint; } if (Val < 0 || Val > 255) { - Error ("Value must be between 0-255"); + Error ("Identifier must be between 0-255"); goto ExitPoint; } @@ -517,7 +517,7 @@ static void TrampolinePragma (StrBuf* B) } else { /* Segment name is invalid */ - Error ("Trampoline does not exist or is not a function or array"); + Error ("Wrapped-call target does not exist or is not a function or array"); } @@ -872,8 +872,8 @@ static void ParsePragma (void) FlagPragma (&B, &StaticLocals); break; - case PRAGMA_TRAMPOLINE: - TrampolinePragma(&B); + case PRAGMA_WRAPPED_CALL: + WrappedCallPragma(&B); break; case PRAGMA_WARN: diff --git a/test/val/trampoline.c b/test/val/trampoline.c index b5df1a22b..aad4c96ea 100644 --- a/test/val/trampoline.c +++ b/test/val/trampoline.c @@ -23,21 +23,21 @@ void func3() { } unsigned char array[30]; -#pragma trampoline(push, array, 0) -#pragma trampoline(pop) +#pragma wrapped-call(push, array, 0) +#pragma wrapped-call(pop) -#pragma trampoline(push, trampoline_inc, 0) +#pragma wrapped-call(push, trampoline_inc, 0) void func2() { func3(); } -#pragma trampoline(push, trampoline_set, 4) +#pragma wrapped-call(push, trampoline_set, 4) void func1(void); -#pragma trampoline(pop) -#pragma trampoline(pop) +#pragma wrapped-call(pop) +#pragma wrapped-call(pop) void func1() { func2(); From ac7a0e21ac0211df2594dff303da973e88a4faee Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 16 May 2017 20:14:19 +0300 Subject: [PATCH 080/199] Correct missed doc label --- doc/cc65.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index a9b88c2b4..d87fa47a7 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1229,7 +1229,7 @@ parameter with the <tt/#pragma/. </verb></tscreen> -<sect1><tt>#pragma wrapped-call (<push&rt;, <name>, <identifier>)</tt><label id="pragma-trampoline"><p> +<sect1><tt>#pragma wrapped-call (<push&rt;, <name>, <identifier>)</tt><label id="pragma-wrapped-call"><p> This pragma sets a wrapper for functions, often used for trampolines. The name is either a function returning void and taking no parameters, From 6011bdb2f63c86424fbd6e321d3eee3408b61b62 Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Wed, 17 May 2017 10:00:35 +0200 Subject: [PATCH 081/199] Optimize the inlined strlen. --- src/cc65/stdfunc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index 7a0450146..f658f0dcb 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -1245,9 +1245,8 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("ldy #$FF"); g_defcodelabel (L); AddCodeLine ("iny"); - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg, 0)); + AddCodeLine ("ldx %s,y", ED_GetLabelName (&Arg, 0)); AddCodeLine ("bne %s", LocalLabelName (L)); - AddCodeLine ("tax"); AddCodeLine ("tya"); /* The function result is an rvalue in the primary register */ From 675dd3c9637e0f4a73ae549fefa4e312b8c4bbf5 Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Wed, 17 May 2017 10:08:08 +0200 Subject: [PATCH 082/199] Optimize the inlined memcpy/memset for the sizes of 128/129. --- src/cc65/stdfunc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index f658f0dcb..2d4317ef8 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -284,7 +284,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) Label = GetLocalLabel (); /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127) { + if (Arg3.Expr.IVal <= 129) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); g_defcodelabel (Label); @@ -355,7 +355,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) Label = GetLocalLabel (); /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { + if (Arg3.Expr.IVal <= 129 && !AllowOneIndex) { if (Offs == 0) { AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); @@ -433,7 +433,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) Label = GetLocalLabel (); /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { + if (Arg3.Expr.IVal <= 129 && !AllowOneIndex) { if (Offs == 0) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); @@ -499,7 +499,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Generate memcpy code */ AddCodeLine ("sta ptr1"); AddCodeLine ("stx ptr1+1"); - if (Arg3.Expr.IVal <= 127) { + if (Arg3.Expr.IVal <= 129) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); g_defcodelabel (Label); AddCodeLine ("lda (sp),y"); @@ -635,7 +635,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr) Label = GetLocalLabel (); /* Generate memset code */ - if (Arg3.Expr.IVal <= 127) { + if (Arg3.Expr.IVal <= 129) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); @@ -720,7 +720,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Generate code */ AddCodeLine ("sta ptr1"); AddCodeLine ("stx ptr1+1"); - if (Arg3.Expr.IVal <= 127) { + if (Arg3.Expr.IVal <= 129) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); g_defcodelabel (Label); From 298dda0e71646112f0d0a57146acbb3a62a145fd Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 17 May 2017 18:30:12 +0200 Subject: [PATCH 083/199] Increased GCC optimization level. --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index f4f29b949..3ce4b676a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -62,7 +62,7 @@ else endif endif -CFLAGS += -MMD -MP -O -I common \ +CFLAGS += -MMD -MP -O3 -I common \ -Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \ -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) -DCL65_TGT=$(CL65_TGT) \ -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG) \ From f151142e6a9935f53fb36b5c54d1031572f50d0c Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 17 May 2017 19:39:02 +0200 Subject: [PATCH 084/199] Keep GCC from complaining about 'List' may be used uninitialized in this function. --- src/ca65/pseudo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index b44c28dd8..f84f21d7f 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -1388,7 +1388,7 @@ static void DoList (void) /* Enable/disable the listing */ { /* Get the setting */ - unsigned char List; + unsigned char List = 0; SetBoolOption (&List); /* Manage the counter */ From 73f1c0e11d0162b1dbad8e1ef21a9f90f4c4f032 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 17 May 2017 20:56:21 +0200 Subject: [PATCH 085/199] Migrate 'encrypted variables' variables to 'repository settings'. The GitHub token used for GitHub Pages deployment was revoked (see https://blog.travis-ci.com/2017-05-08-security-advisory) so I took the opportunity to make use of the "new" repository settings feature instead of fiddling with variable encryption again. --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd2672887..c84eb0cc2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,3 @@ script: - make doc zip after_success: - make -f Makefile.travis -env: - global: - - secure: "h+hoQdEHGPLNwaqGKmSaM8NBRDLc2X+W05VsnNG2Feq/wPv/AiBjONNlzN7jRf6D6f3aoPXaQ2Lc3bYWdxGvFRCmwiofdxkJI9n5L8HPHLZ2lf37MQsXmGJzoTFOvjPLj73H6HlbI9Ux0El3zO6hvalxiXj6TfoZ41dbhNyvpYk=" - - secure: "A4hMEe5RRfUtYjFGbT7QAvT1Tyo434N+/TiuQeQ4q0L46c79LnXuGQzbFLOFZshZiplLkJr7lFg466CoI1bf2L0cQOew/LesMhE75v0HQ7tZnExWhdpAk0ri6nWixbjn/dmQ0+HxjzJ48A44DMMBYcvSIsO4vflvuJ8etfSg42k=" From c6cab0bb2747d26e710a0c048b74a3475d070df5 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Thu, 18 May 2017 12:59:03 +0200 Subject: [PATCH 086/199] VIC's kernal does not support CTRL+[ --- doc/vic20.sgml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/vic20.sgml b/doc/vic20.sgml index b1a08ac83..889cc266e 100644 --- a/doc/vic20.sgml +++ b/doc/vic20.sgml @@ -2,11 +2,11 @@ <article> -<title>Commodore VIC20 (aka VC20) specific information for cc65 +<title>Commodore VIC20 (aka VC20 aka VIC1001) specific information for cc65 <author> <url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal"> -<date>2014-04-12 +<date>2017-05-18 <abstract> An overview over the VIC20 runtime system as it is implemented for the cc65 C @@ -188,7 +188,7 @@ No VIC1011 drivers are currently available for the VIC20. <sect1>Escape code<p> -For an Esc, press CTRL and the <tt/[/ key. +For an Esc, pressing CTRL and the <tt/[/ key is not supported. <sect1>Passing arguments to the program<p> @@ -219,8 +219,7 @@ The program return code (low byte) is passed back to BASIC by use of the <sect1>Using extended memory<p> -The extended memory at $A000 may be added to the heap by using the following -code: +BLK5 memory may be added to the heap by using the following code: <tscreen><verb> /* Check for the existence of RAM */ From a590b99f5be4af391811d0e79520ea07852b763f Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Thu, 18 May 2017 14:21:43 +0300 Subject: [PATCH 087/199] Align with spaces instead of tabs here --- src/cc65/pragma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 6ec2df3a3..27015285e 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -125,7 +125,7 @@ static const struct Pragma { { "static-locals", PRAGMA_STATIC_LOCALS }, { "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */ { "warn", PRAGMA_WARN }, - { "wrapped-call", PRAGMA_WRAPPED_CALL }, + { "wrapped-call", PRAGMA_WRAPPED_CALL }, { "writable-strings", PRAGMA_WRITABLE_STRINGS }, { "zpsym", PRAGMA_ZPSYM }, }; From 7feced88627dc3f07fe1580e80670c234bd0a984 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Thu, 18 May 2017 15:54:47 +0300 Subject: [PATCH 088/199] More tabs to spaces --- src/cc65/pragma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 27015285e..fe7101d97 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -125,7 +125,7 @@ static const struct Pragma { { "static-locals", PRAGMA_STATIC_LOCALS }, { "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */ { "warn", PRAGMA_WARN }, - { "wrapped-call", PRAGMA_WRAPPED_CALL }, + { "wrapped-call", PRAGMA_WRAPPED_CALL }, { "writable-strings", PRAGMA_WRITABLE_STRINGS }, { "zpsym", PRAGMA_ZPSYM }, }; From f6fa74a6367f6aa8f803c867c61be9f6071bb614 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Thu, 18 May 2017 16:00:04 +0300 Subject: [PATCH 089/199] Rename trampoline to wrappedcall everywhere --- src/cc65/declare.c | 24 +++++++-------- src/cc65/expr.c | 12 ++++---- src/cc65/funcdesc.c | 4 +-- src/cc65/funcdesc.h | 4 +-- src/cc65/pragma.c | 6 ++-- src/cc65/{trampoline.c => wrappedcall.c} | 38 ++++++++++++------------ src/cc65/{trampoline.h => wrappedcall.h} | 22 +++++++------- 7 files changed, 55 insertions(+), 55 deletions(-) rename src/cc65/{trampoline.c => wrappedcall.c} (79%) rename src/cc65/{trampoline.h => wrappedcall.h} (85%) diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 2ebc09b14..a6b232905 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -58,7 +58,7 @@ #include "scanner.h" #include "standard.h" #include "symtab.h" -#include "trampoline.h" +#include "wrappedcall.h" #include "typeconv.h" @@ -1316,8 +1316,8 @@ static FuncDesc* ParseFuncDecl (void) { unsigned Offs; SymEntry* Sym; - SymEntry* Trampoline; - unsigned char TrampolineData; + SymEntry* WrappedCall; + unsigned char WrappedCallData; /* Create a new function descriptor */ FuncDesc* F = NewFuncDesc (); @@ -1383,11 +1383,11 @@ static FuncDesc* ParseFuncDecl (void) /* Leave the lexical level remembering the symbol tables */ RememberFunctionLevel (F); - /* Did we have a trampoline for this function? */ - GetTrampoline((void **) &Trampoline, &TrampolineData); - if (Trampoline) { - F->Trampoline = Trampoline; - F->TrampolineData = TrampolineData; + /* Did we have a WrappedCall for this function? */ + GetWrappedCall((void **) &WrappedCall, &WrappedCallData); + if (WrappedCall) { + F->WrappedCall = WrappedCall; + F->WrappedCallData = WrappedCallData; } /* Return the function descriptor */ @@ -1471,13 +1471,13 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode) Qualifiers &= ~T_QUAL_FASTCALL; } - /* Was there a previous entry? If so, copy trampoline info from it */ + /* Was there a previous entry? If so, copy WrappedCall info from it */ PrevEntry = FindGlobalSym (D->Ident); if (PrevEntry && PrevEntry->Flags & SC_FUNC) { FuncDesc* D = PrevEntry->V.F.Func; - if (D->Trampoline && !F->Trampoline) { - F->Trampoline = D->Trampoline; - F->TrampolineData = D->TrampolineData; + if (D->WrappedCall && !F->WrappedCall) { + F->WrappedCall = D->WrappedCall; + F->WrappedCallData = D->WrappedCallData; } } diff --git a/src/cc65/expr.c b/src/cc65/expr.c index fb1232fc1..467c30da2 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -536,8 +536,8 @@ static void FunctionCall (ExprDesc* Expr) /* Special handling for function pointers */ if (IsFuncPtr) { - if (Func->Trampoline) { - Warning("Calling a trampolined function via a pointer, trampoline will not be used"); + if (Func->WrappedCall) { + Warning("Calling a wrapped function via a pointer, wrapped-call will not be used"); } /* If the function is not a fastcall function, load the pointer to @@ -588,12 +588,12 @@ static void FunctionCall (ExprDesc* Expr) } else { /* Normal function */ - if (Func->Trampoline) { + if (Func->WrappedCall) { char tmp[64]; StrBuf S = AUTO_STRBUF_INITIALIZER; - /* Store the trampoline data in tmp4 */ - sprintf(tmp, "ldy #%u", Func->TrampolineData); + /* Store the WrappedCall data in tmp4 */ + sprintf(tmp, "ldy #%u", Func->WrappedCallData); SB_AppendStr (&S, tmp); g_asmcode (&S); SB_Clear(&S); @@ -625,7 +625,7 @@ static void FunctionCall (ExprDesc* Expr) SB_Done (&S); - g_call (TypeOf (Expr->Type), Func->Trampoline->Name, ParamSize); + g_call (TypeOf (Expr->Type), Func->WrappedCall->Name, ParamSize); } else { g_call (TypeOf (Expr->Type), (const char*) Expr->Name, ParamSize); } diff --git a/src/cc65/funcdesc.c b/src/cc65/funcdesc.c index 607094acd..273263dec 100644 --- a/src/cc65/funcdesc.c +++ b/src/cc65/funcdesc.c @@ -60,8 +60,8 @@ FuncDesc* NewFuncDesc (void) F->ParamCount = 0; F->ParamSize = 0; F->LastParam = 0; - F->Trampoline = 0; - F->TrampolineData = 0; + F->WrappedCall = 0; + F->WrappedCallData = 0; /* Return the new struct */ return F; diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index b83cfa362..966aff573 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -67,8 +67,8 @@ struct FuncDesc { unsigned ParamCount; /* Number of parameters */ unsigned ParamSize; /* Size of the parameters */ struct SymEntry* LastParam; /* Pointer to last parameter */ - struct SymEntry* Trampoline; /* Pointer to the trampoline */ - unsigned char TrampolineData; /* The trampoline's user data */ + struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ + unsigned char WrappedCallData; /* The WrappedCall's user data */ }; diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index fe7101d97..98f1a20d0 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -51,7 +51,7 @@ #include "scanstrbuf.h" #include "symtab.h" #include "pragma.h" -#include "trampoline.h" +#include "wrappedcall.h" @@ -468,7 +468,7 @@ static void WrappedCallPragma (StrBuf* B) break; case PP_POP: - PopTrampoline(); + PopWrappedCall(); /* Done */ goto ExitPoint; @@ -511,7 +511,7 @@ static void WrappedCallPragma (StrBuf* B) /* Check if the name is valid */ if (Entry && Entry->Flags & (SC_FUNC | SC_STORAGE)) { - PushTrampoline(Entry, Val); + PushWrappedCall(Entry, Val); Entry->Flags |= SC_REF; } else { diff --git a/src/cc65/trampoline.c b/src/cc65/wrappedcall.c similarity index 79% rename from src/cc65/trampoline.c rename to src/cc65/wrappedcall.c index 1f35a0f3c..2d11245fd 100644 --- a/src/cc65/trampoline.c +++ b/src/cc65/wrappedcall.c @@ -1,8 +1,8 @@ /*****************************************************************************/ /* */ -/* trampoline.c */ +/* wrappedcall.c */ /* */ -/* Trampoline management */ +/* WrappedCall management */ /* */ /* */ /* */ @@ -44,7 +44,7 @@ /* cc65 */ #include "codeent.h" #include "error.h" -#include "trampoline.h" +#include "wrappedcall.h" @@ -53,8 +53,8 @@ /*****************************************************************************/ -/* Trampolines */ -static IntPtrStack Trampolines; +/* WrappedCalls */ +static IntPtrStack WrappedCalls; @@ -64,39 +64,39 @@ static IntPtrStack Trampolines; -void PushTrampoline (void *Ptr, unsigned char Val) -/* Push the current trampoline */ +void PushWrappedCall (void *Ptr, unsigned char Val) +/* Push the current WrappedCall */ { - if (IPS_IsFull (&Trampolines)) { - Error ("Trampoline stack overflow"); + if (IPS_IsFull (&WrappedCalls)) { + Error ("WrappedCall stack overflow"); } else { - IPS_Push (&Trampolines, Val, Ptr); + IPS_Push (&WrappedCalls, Val, Ptr); } } -void PopTrampoline (void) -/* Remove the current trampoline */ +void PopWrappedCall (void) +/* Remove the current WrappedCall */ { - if (IPS_GetCount (&Trampolines) < 1) { - Error ("Trampoline stack is empty"); + if (IPS_GetCount (&WrappedCalls) < 1) { + Error ("WrappedCall stack is empty"); } else { - IPS_Drop (&Trampolines); + IPS_Drop (&WrappedCalls); } } -void GetTrampoline (void **Ptr, unsigned char *Val) -/* Get the current trampoline */ +void GetWrappedCall (void **Ptr, unsigned char *Val) +/* Get the current WrappedCall */ { - if (IPS_GetCount (&Trampolines) < 1) { + if (IPS_GetCount (&WrappedCalls) < 1) { *Ptr = NULL; *Val = 0; } else { long Temp; - IPS_Get (&Trampolines, &Temp, Ptr); + IPS_Get (&WrappedCalls, &Temp, Ptr); *Val = Temp; } } diff --git a/src/cc65/trampoline.h b/src/cc65/wrappedcall.h similarity index 85% rename from src/cc65/trampoline.h rename to src/cc65/wrappedcall.h index f110bd42e..3517c2465 100644 --- a/src/cc65/trampoline.h +++ b/src/cc65/wrappedcall.h @@ -1,8 +1,8 @@ /*****************************************************************************/ /* */ -/* trampoline.h */ +/* wrappedcall.h */ /* */ -/* Trampoline management */ +/* Wrapped-call management */ /* */ /* */ /* */ @@ -30,8 +30,8 @@ -#ifndef TRAMPOLINE_H -#define TRAMPOLINE_H +#ifndef WRAPPEDCALL_H +#define WRAPPEDCALL_H @@ -50,16 +50,16 @@ -void PushTrampoline (void *Ptr, unsigned char Val); -/* Push the current trampoline */ +void PushWrappedCall (void *Ptr, unsigned char Val); +/* Push the current WrappedCall */ -void PopTrampoline (void); -/* Pop the current trampoline */ +void PopWrappedCall (void); +/* Pop the current WrappedCall */ -void GetTrampoline (void **Ptr, unsigned char *Val); -/* Get the current trampoline, if any */ +void GetWrappedCall (void **Ptr, unsigned char *Val); +/* Get the current WrappedCall, if any */ -/* End of trampoline.h */ +/* End of wrappedcall.h */ #endif From 4c05c46cd15ade6c282bb4bf51686a07bf0b4ca3 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Thu, 18 May 2017 16:11:39 +0300 Subject: [PATCH 090/199] Remove RAM-trampoline array support --- doc/cc65.sgml | 5 ++--- src/cc65/pragma.c | 2 +- test/val/trampoline.c | 4 ---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index d87fa47a7..2e480e4c3 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1232,9 +1232,8 @@ parameter with the <tt/#pragma/. <sect1><tt>#pragma wrapped-call (<push&rt;, <name>, <identifier>)</tt><label id="pragma-wrapped-call"><p> This pragma sets a wrapper for functions, often used for trampolines. - The name is either a function returning void and taking no parameters, - or the address of an array in memory (for a RAM trampoline). The identifier - is an 8-bit number that's set to tmp4. + The name is a function returning void and taking no parameters. + The identifier is an 8-bit number that's set to tmp4. The address of the function is passed in ptr4. diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 98f1a20d0..2cd510ff8 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -509,7 +509,7 @@ static void WrappedCallPragma (StrBuf* B) Entry = FindSym(Name); /* Check if the name is valid */ - if (Entry && Entry->Flags & (SC_FUNC | SC_STORAGE)) { + if (Entry && Entry->Flags & SC_FUNC) { PushWrappedCall(Entry, Val); Entry->Flags |= SC_REF; diff --git a/test/val/trampoline.c b/test/val/trampoline.c index aad4c96ea..6723df9b3 100644 --- a/test/val/trampoline.c +++ b/test/val/trampoline.c @@ -22,10 +22,6 @@ void func3() { } -unsigned char array[30]; -#pragma wrapped-call(push, array, 0) -#pragma wrapped-call(pop) - #pragma wrapped-call(push, trampoline_inc, 0) void func2() { From 219b239a347fd07742e09628599f5d7e4f987253 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Thu, 18 May 2017 17:14:26 +0300 Subject: [PATCH 091/199] Adjustments in response to latest comments --- src/cc65/funcdesc.h | 4 ++-- src/cc65/pragma.c | 2 +- test/val/trampoline.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index 966aff573..040f6e97c 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -67,8 +67,8 @@ struct FuncDesc { unsigned ParamCount; /* Number of parameters */ unsigned ParamSize; /* Size of the parameters */ struct SymEntry* LastParam; /* Pointer to last parameter */ - struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ - unsigned char WrappedCallData; /* The WrappedCall's user data */ + struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ + unsigned char WrappedCallData;/* The WrappedCall's user data */ }; diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 2cd510ff8..8d5dfd8b1 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -517,7 +517,7 @@ static void WrappedCallPragma (StrBuf* B) } else { /* Segment name is invalid */ - Error ("Wrapped-call target does not exist or is not a function or array"); + Error ("Wrapped-call target does not exist or is not a function"); } diff --git a/test/val/trampoline.c b/test/val/trampoline.c index 6723df9b3..63741b590 100644 --- a/test/val/trampoline.c +++ b/test/val/trampoline.c @@ -1,5 +1,5 @@ /* - !!DESCRIPTION!! trampoline pragma + !!DESCRIPTION!! wrapped-call pragma used for trampolines !!ORIGIN!! cc65 regression tests !!LICENCE!! Public Domain !!AUTHOR!! Lauri Kasanen From 70b541b81ea01561f8e8d19a8f195ef55e76bc6d Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Thu, 18 May 2017 21:21:02 +0200 Subject: [PATCH 092/199] Changed section --- doc/vic20.sgml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/vic20.sgml b/doc/vic20.sgml index 889cc266e..26a4aa558 100644 --- a/doc/vic20.sgml +++ b/doc/vic20.sgml @@ -182,13 +182,14 @@ No VIC1011 drivers are currently available for the VIC20. <sect>Limitations<p> - -<sect>Other hints<p> - - <sect1>Escape code<p> -For an Esc, pressing CTRL and the <tt/[/ key is not supported. +The CTRL key cannot be used to type most control characters, +entering an Esc is not possible. + + + +<sect>Other hints<p> <sect1>Passing arguments to the program<p> From 16a2beaaca0b05b47417a396048003121e51c9ea Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Thu, 18 May 2017 22:40:18 +0200 Subject: [PATCH 093/199] Adjusted VS project files to commit https://github.com/cc65/cc65/commit/11b01b908d321c39d86de1dd12102eaa6f4053e9 --- src/cc65.vcxproj | 2 ++ src/common.vcxproj | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/cc65.vcxproj b/src/cc65.vcxproj index 1c1f993fe..70f43dc73 100644 --- a/src/cc65.vcxproj +++ b/src/cc65.vcxproj @@ -145,6 +145,7 @@ <ClInclude Include="cc65\typecmp.h" /> <ClInclude Include="cc65\typeconv.h" /> <ClInclude Include="cc65\util.h" /> + <ClInclude Include="cc65\wrappedcall.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="cc65\anonname.c" /> @@ -218,6 +219,7 @@ <ClCompile Include="cc65\typecmp.c" /> <ClCompile Include="cc65\typeconv.c" /> <ClCompile Include="cc65\util.c" /> + <ClCompile Include="cc65\wrappedcall.c" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/src/common.vcxproj b/src/common.vcxproj index 053d23981..39fea35e5 100644 --- a/src/common.vcxproj +++ b/src/common.vcxproj @@ -38,6 +38,7 @@ <ClInclude Include="common\hashtab.h" /> <ClInclude Include="common\hlldbgsym.h" /> <ClInclude Include="common\inline.h" /> + <ClInclude Include="common\intptrstack.h" /> <ClInclude Include="common\intstack.h" /> <ClInclude Include="common\inttypes.h" /> <ClInclude Include="common\libdefs.h" /> @@ -87,6 +88,7 @@ <ClCompile Include="common\gentype.c" /> <ClCompile Include="common\hashfunc.c" /> <ClCompile Include="common\hashtab.c" /> + <ClCompile Include="common\intptrstack.c" /> <ClCompile Include="common\intstack.c" /> <ClCompile Include="common\matchpat.c" /> <ClCompile Include="common\mmodel.c" /> From 75028e41087b0d0efeb1e8b75ea31cb1f3fb8521 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Thu, 18 May 2017 23:58:10 +0200 Subject: [PATCH 094/199] shorter code --- libsrc/c128/joy/c128-stdjoy.s | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libsrc/c128/joy/c128-stdjoy.s b/libsrc/c128/joy/c128-stdjoy.s index 119d3784f..a2caead1a 100644 --- a/libsrc/c128/joy/c128-stdjoy.s +++ b/libsrc/c128/joy/c128-stdjoy.s @@ -104,7 +104,7 @@ joy1: lda #$7F sei sta CIA1_PRA lda CIA1_PRB - cli +back: cli and #$1F eor #$1F rts @@ -118,9 +118,4 @@ joy2: ldx #0 sta CIA1_DDRA lda CIA1_PRA sty CIA1_DDRA - cli - and #$1F - eor #$1F - rts - - + jmp back From 80e6afd33522d4583f0753b85e4b75da0b79ebee Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 19 May 2017 14:20:04 +0300 Subject: [PATCH 095/199] Add two new trampoline test cases --- test/val/trampoline-params.c | 32 +++++++++++++++++++++++ test/val/trampoline-varargs.c | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 test/val/trampoline-params.c create mode 100644 test/val/trampoline-varargs.c diff --git a/test/val/trampoline-params.c b/test/val/trampoline-params.c new file mode 100644 index 000000000..890e43e5f --- /dev/null +++ b/test/val/trampoline-params.c @@ -0,0 +1,32 @@ +/* + !!DESCRIPTION!! wrapped-call pragma w/ many params + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Lauri Kasanen +*/ + +#include <stdarg.h> + +static unsigned char flag; + +static void trampoline_set() { + asm("ldy tmp4"); + asm("sty %v", flag); + asm("jsr callptr4"); +} + +#pragma wrapped-call(push, trampoline_set, 4) +long adder(long in); +#pragma wrapped-call(pop) + +long adder(long in) { + + return in + 7; +} + +int main() { + + flag = 0; + + return adder(70436) == 70436 + 7 && flag == 4 ? 0 : 1; +} diff --git a/test/val/trampoline-varargs.c b/test/val/trampoline-varargs.c new file mode 100644 index 000000000..5d3377c68 --- /dev/null +++ b/test/val/trampoline-varargs.c @@ -0,0 +1,48 @@ +/* + !!DESCRIPTION!! wrapped-call pragma w/ varags + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Lauri Kasanen +*/ + +#include <stdarg.h> + +static unsigned char flag; + +static void trampoline_set() { + // The Y register is used for variadics - save and restore + asm("sty tmp3"); + + asm("ldy tmp4"); + asm("sty %v", flag); + + asm("ldy tmp3"); + asm("jsr callptr4"); +} + +#pragma wrapped-call(push, trampoline_set, 4) +unsigned adder(unsigned char num, ...); +#pragma wrapped-call(pop) + +unsigned adder(unsigned char num, ...) { + + unsigned char i; + unsigned sum = 0; + va_list ap; + va_start(ap, num); + + for (i = 0; i < num; i++) { + sum += va_arg(ap, unsigned); + } + + va_end(ap); + + return sum; +} + +int main() { + + flag = 0; + + return adder(3, 0, 5, 500) == 505 && flag == 4 ? 0 : 1; +} From 901ac80026f3defad4c143d2336558384bd763ad Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 19 May 2017 15:20:36 +0300 Subject: [PATCH 096/199] Wrapper functions use all registers --- src/cc65/codeinfo.c | 4 ++++ src/cc65/funcdesc.h | 3 ++- src/cc65/pragma.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cc65/codeinfo.c b/src/cc65/codeinfo.c index de51781a6..06c66baf4 100644 --- a/src/cc65/codeinfo.c +++ b/src/cc65/codeinfo.c @@ -401,6 +401,10 @@ void GetFuncInfo (const char* Name, unsigned short* Use, unsigned short* Chg) */ if ((D->Flags & FD_VARIADIC) != 0) { *Use = REG_Y; + } else if (D->Flags & FD_CALL_WRAPPER) { + /* Wrappers may go to any functions, so mark them as using all + registers */ + *Use = REG_EAXY; } else if (D->ParamCount > 0 && (AutoCDecl ? IsQualFastcall (E->Type) : diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index 040f6e97c..a04ffb14a 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -52,9 +52,10 @@ #define FD_OLDSTYLE 0x0010U /* Old style (K&R) function */ #define FD_OLDSTYLE_INTRET 0x0020U /* K&R func has implicit int return */ #define FD_UNNAMED_PARAMS 0x0040U /* Function has unnamed params */ +#define FD_CALL_WRAPPER 0x0080U /* This function is used as a wrapper */ /* Bits that must be ignored when comparing funcs */ -#define FD_IGNORE (FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS) +#define FD_IGNORE (FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS | FD_CALL_WRAPPER) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 8d5dfd8b1..3dfc62668 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -513,6 +513,7 @@ static void WrappedCallPragma (StrBuf* B) PushWrappedCall(Entry, Val); Entry->Flags |= SC_REF; + Entry->V.F.Func->Flags |= FD_CALL_WRAPPER; } else { From e8a735492de02f1ab7dc5f28a24dc1c5022c0d82 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 19 May 2017 15:38:50 +0300 Subject: [PATCH 097/199] Correct comment style --- src/cc65/codeinfo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc65/codeinfo.c b/src/cc65/codeinfo.c index 06c66baf4..e9d98f5b8 100644 --- a/src/cc65/codeinfo.c +++ b/src/cc65/codeinfo.c @@ -403,7 +403,8 @@ void GetFuncInfo (const char* Name, unsigned short* Use, unsigned short* Chg) *Use = REG_Y; } else if (D->Flags & FD_CALL_WRAPPER) { /* Wrappers may go to any functions, so mark them as using all - registers */ + ** registers. + */ *Use = REG_EAXY; } else if (D->ParamCount > 0 && (AutoCDecl ? From 39e55bdb77bc6a2ba6ea7748e5c02c814685f0c0 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sat, 20 May 2017 01:41:49 -0400 Subject: [PATCH 098/199] Added more info to the documentation of "#pragma wrapped-call". --- doc/cc65.sgml | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 2e480e4c3..3689c0b35 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -4,7 +4,7 @@ <title>cc65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:gregdk@users.sf.net" name="Greg King"> -<date>2017-03-21 +<date>2017-05-20 <abstract> cc65 is a C compiler for 6502 targets. It supports several 6502 based home @@ -1229,27 +1229,36 @@ parameter with the <tt/#pragma/. </verb></tscreen> -<sect1><tt>#pragma wrapped-call (<push&rt;, <name>, <identifier>)</tt><label id="pragma-wrapped-call"><p> +<sect1><tt>#pragma wrapped-call (push, <name>, <identifier>)</tt><label id="pragma-wrapped-call"><p> This pragma sets a wrapper for functions, often used for trampolines. - The name is a function returning void and taking no parameters. - The identifier is an 8-bit number that's set to tmp4. - The address of the function is passed in ptr4. + The name is a function returning <tt/void/, and taking no parameters. + It must preserve the CPU's <tt/A/ and <tt/X/ registers if it wraps any + <tt/__fastcall__/ functions that have parameters. It must preserve + the <tt/Y/ register if it wraps any variadic functions (they have "<tt/.../" + in their prototypes). - This is useful for example with banked memory, to automatically - switch banks to where this function resides, and then restore - the bank when it returns. + The identifier is an 8-bit number that's set into <tt/tmp4/. - The <tt/#pragma/ requires the push and pop parameters as explained above. + The address of a wrapped function is passed in <tt/ptr4/. The wrapper can + call that function by using "<tt/jsr callptr4/". + + This feature is useful, for example, with banked memory, to switch banks + automatically to where a wrapped function resides, and then to restore the + previous bank when it returns. + + The <tt/#pragma/ requires the push or pop argument as explained above. Example: <tscreen><verb> - void mytrampoline(void); +/* Note that this code can be in a header. */ +void mytrampoline(void); /* Doesn't corrupt __AX__ */ - #pragma wrapped-call (push, mytrampoline, 0) - void somefunc(void); - #pragma wrapped-call (pop) +#pragma wrapped-call (push, mytrampoline, 5) +void somefunc1(void); +void somefunc2(int, char *); +#pragma wrapped-call (pop) </verb></tscreen> From 05b73276c2ff1b6ea88735c1d78a9da8e1d8cabc Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Sat, 20 May 2017 09:53:30 +0300 Subject: [PATCH 099/199] Update test description --- test/val/trampoline-varargs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/val/trampoline-varargs.c b/test/val/trampoline-varargs.c index 5d3377c68..d154a3da0 100644 --- a/test/val/trampoline-varargs.c +++ b/test/val/trampoline-varargs.c @@ -1,5 +1,5 @@ /* - !!DESCRIPTION!! wrapped-call pragma w/ varags + !!DESCRIPTION!! wrapped-call pragma w/ variadic function !!ORIGIN!! cc65 regression tests !!LICENCE!! Public Domain !!AUTHOR!! Lauri Kasanen From 3157e4be1ec7f2a5ac61ca45b232cd07c5e30483 Mon Sep 17 00:00:00 2001 From: mc78 <mc78@outlook.de> Date: Mon, 22 May 2017 23:07:31 +0200 Subject: [PATCH 100/199] added empty lines and spaces according to olivers comments. Made local functions static. --- src/cl65/main.c | 55 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index e428c96ac..6926199f9 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -156,22 +156,36 @@ static char* TargetLib = 0; # endif #endif + + /*****************************************************************************/ /* Credential functions */ /*****************************************************************************/ -void DisableAssembling(void){ + + + +static void DisableAssembling (void) +{ DoAssemble = 0; } -void DisableLinking(void){ + + +static void DisableLinking (void) +{ DoLink = 0; } -void DisableAssemblingAndLinking(void){ + + +static void DisableAssemblingAndLinking (void) +{ DisableAssembling(); DisableLinking(); } + + /*****************************************************************************/ /* Command structure handling */ /*****************************************************************************/ @@ -1427,22 +1441,33 @@ int main (int argc, char* argv []) break; case 'E': - /*Forward -E to compiler*/ + /* Forward -E to compiler */ CmdAddArg (&CC65, Arg); DisableAssemblingAndLinking(); break; + case 'W': - if (Arg[2] == 'a' && Arg[3] == '\0') { - /* -Wa: Pass options to assembler */ - OptAsmArgs (Arg, GetArg (&I, 3)); - } else if (Arg[2] == 'c' && Arg[3] == '\0') { - /* -Wc: Pass options to compiler */ - /* Remember -Wc sub arguments in cc65 arg struct */ - OptCCArgs (Arg, GetArg (&I, 3)); - } else if (Arg[2] == 'l' && Arg[3] == '\0') { - /* -Wl: Pass options to linker */ - OptLdArgs (Arg, GetArg (&I, 3)); - } else { + /* avoid && with'\0' in if clauses */ + if (Arg[3] == '\0') { + switch (Arg[2]) { + case 'a': + /* -Wa: Pass options to assembler */ + OptAsmArgs (Arg, GetArg (&I, 3)); + break; + case 'c': + /* -Wc: Pass options to compiler + ** Remember -Wc sub arguments in cc65 arg struct + */ + OptCCArgs (Arg, GetArg (&I, 3)); + break; + case 'l': + /* -Wl: Pass options to linker */ + OptLdArgs (Arg, GetArg (&I, 3)); + break; + default: + break; + } + }else { /* Anything else: Suppress warnings (compiler) */ CmdAddArg2 (&CC65, "-W", GetArg (&I, 2)); } From 21b1add98464367bef7819654f1643337c65260b Mon Sep 17 00:00:00 2001 From: mc78 <mc78@outlook.de> Date: Mon, 22 May 2017 23:21:55 +0200 Subject: [PATCH 101/199] added four escaped tabs to -E Stop after .... description --- src/cl65/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 6926199f9..8252b61ff 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -734,7 +734,7 @@ static void Usage (void) " -C name\t\t\tUse linker config file\n" " -Cl\t\t\t\tMake local variables static\n" " -D sym[=defn]\t\t\tDefine a preprocessor symbol\n" - " -E Stop after the preprocessing stage\n" + " -E\t\t\t\tStop after the preprocessing stage\n" " -I dir\t\t\tSet a compiler include directory path\n" " -L path\t\t\tSpecify a library search path\n" " -Ln name\t\t\tCreate a VICE label file\n" From d9a8c300538f7778e5823350a9f0e8eccc7b88cd Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Mon, 22 May 2017 23:53:51 +0200 Subject: [PATCH 102/199] typo --- doc/funcref.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index d4c2f3fe1..d160082bf 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -3710,7 +3710,7 @@ fastcall function, so it may only be used in presence of a prototype. <quote> <descrip> -<tag/Function/Check if a given character is a a white-space character. +<tag/Function/Check if a given character is a white-space character. <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/ <tag/Declaration/<tt/int __fastcall__ isspace (int c);/ <tag/Description/The function returns a non zero value if the given argument From 355696d17da9147d12f63de855ec5ff089f0c285 Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Mon, 22 May 2017 21:33:02 -0400 Subject: [PATCH 103/199] ca65 documentation of .define macros, making note that parentheses in ca65 macros are problematic especially when thinking of them as "C style", replacing unclear example with an example showing how accidental parentheses can cause a problem. --- doc/ca65.sgml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 6ce5ecef6..74e081985 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -4282,6 +4282,12 @@ different: some things may be done with both macro types, each type has special usages. The types complement each other. +<item> Parentheses work differently from C macros. + The common practice of wrapping C macros in parentheses may cause + unintended problems here, such as accidentally implying an + indirect addressing mode. While the definition of a macro requires + parentheses around its argument list, when invoked they should not be included. + </itemize> Let's look at a few examples to make the advantages and disadvantages @@ -4314,20 +4320,18 @@ Macros with parameters may also be useful: DEBUG "Assembling include file #3" </verb></tscreen> -Note that, while formal parameters have to be placed in braces, this is -not true for the actual parameters. Beware: Since the assembler cannot -detect the end of one parameter, only the first token is used. If you -don't like that, use classic macros instead: +Note that, while formal parameters have to be placed in braces, +the actual parameters used when invoking the macro should not use braces. +The invoked parameters are separated by commas only, if parentheses are +used by accident they will become part of the replaced token: <tscreen><verb> -.macro DEBUG message - .out message -.endmacro +.define COMBINE(ta,tb,tc) ta+tb*10+tc*100 + + COMBINE 5,6,7 ; 5+6*10+7*100 = 765 correct + COMBINE(5,6,7) ; (5+6*10+7)*100 = 7200 incorrect! </verb></tscreen> -(That is an example where a problem can be solved with both macro types). - - <sect1>Characters in macros<p> When using the <ref id="option-t" name="-t"> option, characters are translated From f87a575d4d32f0f2386ebd7c24dc73953eed2bef Mon Sep 17 00:00:00 2001 From: mc78 <mc78@outlook.de> Date: Tue, 23 May 2017 22:57:27 +0200 Subject: [PATCH 104/199] added missing spaces before braces. added unknown option msg if not given -Wc|l|a when passing options to subprocess --- src/cl65/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 8252b61ff..b209cb21d 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -180,8 +180,8 @@ static void DisableLinking (void) static void DisableAssemblingAndLinking (void) { - DisableAssembling(); - DisableLinking(); + DisableAssembling (); + DisableLinking (); } @@ -1427,7 +1427,7 @@ int main (int argc, char* argv []) case 'S': /* Dont assemble and link the created files */ - DisableAssemblingAndLinking(); + DisableAssemblingAndLinking (); break; case 'T': @@ -1443,7 +1443,7 @@ int main (int argc, char* argv []) case 'E': /* Forward -E to compiler */ CmdAddArg (&CC65, Arg); - DisableAssemblingAndLinking(); + DisableAssemblingAndLinking (); break; case 'W': @@ -1465,9 +1465,10 @@ int main (int argc, char* argv []) OptLdArgs (Arg, GetArg (&I, 3)); break; default: + UnknownOption (Arg); break; } - }else { + } else { /* Anything else: Suppress warnings (compiler) */ CmdAddArg2 (&CC65, "-W", GetArg (&I, 2)); } @@ -1475,7 +1476,7 @@ int main (int argc, char* argv []) case 'c': /* Don't link the resulting files */ - DisableLinking(); + DisableLinking (); break; case 'd': From 051cf11ce69ce147ff747c44e2732bf75a982c79 Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Tue, 23 May 2017 17:07:45 -0400 Subject: [PATCH 105/199] expanding macro examples, trying to adhere to style guidelines --- doc/ca65.sgml | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 74e081985..d0a3d80e7 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -4286,7 +4286,8 @@ different: The common practice of wrapping C macros in parentheses may cause unintended problems here, such as accidentally implying an indirect addressing mode. While the definition of a macro requires - parentheses around its argument list, when invoked they should not be included. + parentheses around its argument list, when invoked they should not be + included. </itemize> @@ -4320,18 +4321,44 @@ Macros with parameters may also be useful: DEBUG "Assembling include file #3" </verb></tscreen> -Note that, while formal parameters have to be placed in braces, -the actual parameters used when invoking the macro should not use braces. -The invoked parameters are separated by commas only, if parentheses are -used by accident they will become part of the replaced token: +Note that, while formal parameters have to be placed in parentheses, +the actual argument used when invoking the macro should not be. +The invoked arguments are separated by commas only, if parentheses are +used by accident they will become part of the replaced token. + +If you wish to have an expression follow the macro invocation, the +last parameter can be enclosed in curly braces {} to indicate the end of that +argument. + +Examples: <tscreen><verb> .define COMBINE(ta,tb,tc) ta+tb*10+tc*100 - COMBINE 5,6,7 ; 5+6*10+7*100 = 765 correct - COMBINE(5,6,7) ; (5+6*10+7)*100 = 7200 incorrect! +.word COMBINE 5,6,7 ; 5+6*10+7*100 = 765 +.word COMBINE(5,6,7) ; (5+6*10+7)*100 = 7200 ; incorrect use of parentheses +.word COMBINE 5,6,7+1 ; 5+6*10+7+1*100 = 172 +.word COMBINE 5,6,{7}+1 ; 5+6*10+7*100+1 = 766 ; {} encloses the argument +.word COMBINE 5,6-2,7 ; 5+6-2*10+7*100 = 691 +.word COMBINE 5,(6-2),7 ; 5+(6-2)*10+7*100 = 745 +.word COMBINE 5,6,7+COMBINE 0,1,2 ; 5+6*10+7+0+1*10+2*100*100 = 20082 +.word COMBINE 5,6,{7}+COMBINE 0,1,2 ; 5+6*10+7*100+0+1*10+2*100 = 975 </verb></tscreen> +With C macros it is common to enclose the results in parentheses to +prevent unintended interactions with the text of the arguments, but +additional care must be taken in this assembly context where parentheses +may alter the meaning of a statement. In particular, indirect addressing modes +may be accidentally implied: + +<tscreen><verb> +.define DUO(ta,tb) (ta+(tb*10)) + + lda DUO(5,4), Y ; LDA (indirect), Y + lda 0+DUO(5,4), Y ; LDA absolute indexed, Y +</verb></tscreen> + + <sect1>Characters in macros<p> When using the <ref id="option-t" name="-t"> option, characters are translated From 87a9e0ce4f88a69b2db2c047074894f05c4b8f56 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Wed, 24 May 2017 00:04:52 +0200 Subject: [PATCH 106/199] clean-up --- doc/telestrat.sgml | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index fda4dee86..243097a84 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -4,13 +4,14 @@ <title>Oric Telestrat-specific information for cc65 <author> -<url url="mailto:jede@oric.org" name="Jede">,<newline> +<url url="mailto:jede@oric.org" name="Jede"> <date>2017-01-22 <abstract> -An overview over the Telestrat (Telemon 3.0 : http://orix.oric.org) runtime system as it is implemented for the cc65 C -compiler.) +An overview over the Telestrat (<url name="Telemon 3.0" +url="http://orix.oric.org">) runtime system as it is implemented for the +cc65 C compiler. </abstract> <!-- Table of contents --> @@ -32,25 +33,28 @@ information. <sect>Binary format<p> -The standard binary output format generated the linker for the Telestrat target -is a machine language program with a 20 bytes header described here : http://orix.oric.org/doku.php?id=orix:header +The standard binary output format generated the linker for the Telestrat +target is a machine language program with a 20 bytes header described <url +name="here" url="http://orix.oric.org/doku.php?id=orix:header"> -This header is used for Telemon 3.0. +This header is used for Telemon 3.0. -Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in Telemon, there is no way to load a binary easily. +Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in Telemon, there is no way to load a binary easily. -Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk. +Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk. -There is no tool to insert a binary in a Stratsed floppy disk. +There is no tool to insert a binary in a Stratsed floppy disk. -The only way to load a binary (for Telemon 2.4) is to : +The only way to load a binary (for Telemon 2.4) is to: <itemize> <item>remove the 20 bytes header -<item>download osdk : http://osdk.defence-force.org/index?page=download +<item>download <url name="osdk" url="http://osdk.defence-force.org/index?page=download"> <item>use Floppybuilder in OSDK to insert the binary with the tool (please read FloppyBuilder manual to insert your binary, and to start microdisc boot sector when Telestrat starts) </itemize> -Please note also, that the binary converted into TAP file, will not produce a right stratsed file when tap2dsk and old2mfm are used. You will be in the case that Telestrat/Stratsed crashed when you do "DIR" command. +Please note also, that the binary converted into TAP file, will not produce +a right stratsed file when tap2dsk and old2mfm are used. You will be in the +case that Telestrat/Stratsed crashed when you do "DIR" command. If you know the Stratsed disk format, please contact the author of this doc. @@ -79,7 +83,7 @@ Special locations: <sect>Platform-specific header files<p> -Programs containing Telestrat -specific code may use the <tt/telestrat.h/ header file. +Programs containing Telestrat-specific code may use the <tt/telestrat.h/ header file. <sect1>Telestrat-specific functions<p> @@ -147,8 +151,12 @@ Telestrat has a RS232 port, but it's not used <sect1>Disk I/O<p> -Telemon 3.0 handles fopen, fread, fclose primitives. It means that this function will crash the Telestrat because Telemon 2.4 does not have these primitives. -By the way, Telemon 3.0 uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose). +Telemon 3.0 handles fopen, fread, fclose primitives. It means that this +function will crash the Telestrat because Telemon 2.4 does not have these +primitives. By the way, Telemon 3.0 uses an extension "ch376 card" which +handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, +Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, +fclose). <itemize> <item>fclose From ca1b9deb592e25889f75cc0a9f32b198e8de011c Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 24 May 2017 16:47:12 -0400 Subject: [PATCH 107/199] Added a description of the "-E" command-line option to cl65's document. Improved other descriptions, to make them more consistent and accurate. --- doc/cl65.sgml | 91 +++++++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/doc/cl65.sgml b/doc/cl65.sgml index ffeba2321..8b3c02cbb 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -2,8 +2,9 @@ <article> <title>cl65 Users Guide -<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>01.08.2000, 27.11.2000, 02.10.2001 +<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> +<url url="mailto:greg.king5@verizon.net" name="Greg King"> +<date>2017-05-24 <abstract> cl65 is the compile & link utility for cc65, the 6502 C compiler. It was @@ -50,6 +51,7 @@ Short options: -C name Use linker config file -Cl Make local variables static -D sym[=defn] Define a preprocessor symbol + -E Stop after the preprocessing stage -I dir Set a compiler include directory path -L path Specify a library search path -Ln name Create a VICE label file @@ -120,56 +122,66 @@ Long options: --------------------------------------------------------------------------- </verb></tscreen> -Most of the options have the same meaning than the corresponding compiler, -assembler or linker option. See the documentation for these tools for an +Most of the options have the same meanings as the corresponding compiler, +assembler, and linker options. See the documentation for those tools for an explanation. If an option is available for more than one of the tools, it -is set for all tools, where it is available. One example for this is <tt/-v/: -The compiler, the assembler and the linker are all called with the <tt/-v/ +is set for all tools where it is available. One example for that is <tt/-v/: +The compiler, the assembler, and the linker are all called with the <tt/-v/ switch. There are a few remaining options that control the behaviour of cl65: <descrip> + <tag><tt>-E</tt></tag> + + This option is passed to the cc65 compiler; and, it forces cl65 to stop + before the assembly step. That means that C-level preprocessor directives + are obeyed; and, macroes are expanded. But, the C source isn't compiled. + If the <tt/-o/ option isn't used, then the C code results are written into + files with a ".i" suffix on their base names. Assembler files, object + files, and libraries given on the command line are ignored. + + <tag><tt>-S</tt></tag> - This option forces cl65 to stop after the assembly step. This means that - C files are translated into assembler files, but nothing more is done. - Assembler files, object files and libraries given on the command line + This option forces cl65 to stop before the assembly step. That means that + C files are translated into assembler files; but, nothing more is done. + Assembler files, object files, and libraries given on the command line are ignored. <tag><tt>-c</tt></tag> - This options forces cl65 to stop after the assembly step. This means + This option forces cl65 to stop after the assembly step. That means that C and assembler files given on the command line are translated into - object files, but there is no link step, and object files and libraries + object files; but, there is no link step. Object files and libraries given on the command line are ignored. <tag><tt>-o name</tt></tag> - The -o option is used for the target name in the final step. This causes - problems, if the linker will not be called, and there are several input - files on the command line. In this case, the name given with -o will be + The -o option is used for the target name in the final step. That causes + problems if the linker will not be called, and there are several input + files on the command line. In that case, the name given with -o will be used for all of them, which makes the option pretty useless. You - shouldn't use -o when more than one output file is created. + shouldn't use <tt/-o/ when more than one output file is created. <tag><tt>--print-target-path</tt></tag> - This option prints the absolute path of the target file directory and exits + This option prints the absolute path of the target file directory, and exits then. It is supposed to be used with shell backquotes or the GNU make shell - function. This way you can write build scripts or Makefiles accessing target + function. That way, you can write build scripts or Makefiles accessing target files without any assumption about the cc65 installation path. <tag><tt>-t sys, --target sys</tt></tag> - The default for this option is different from the compiler and linker in the - case that the option is missing: While the other tools (compiler, assembler + The default for this option is different from the compiler and linker, in the + case that the option is missing: While the other tools (compiler, assembler, and linker) will use the "none" system settings by default, cl65 will use - the C64 as a target system by default. This was chosen since most people + "c64" as a target system by default. That was chosen because most people seem to use cc65 to develop for the C64. @@ -177,10 +189,10 @@ There are a few remaining options that control the behaviour of cl65: Pass options directly to the assembler. This may be used to pass options that aren't directly supported by cl65. Several options may be separated by - commas, the commas are replaced by spaces when passing them to the - assembler. Beware: Passing arguments directly to the assembler may interfere - with some of the defaults, because cl65 doesn't parse the options passed. So - if cl65 supports an option by itself, do not pass this option to the + commas; the commas are replaced by spaces when passing them to the + assembler. Beware: Passing arguments directly to the assembler might interfere + with some of the defaults because cl65 doesn't parse the options passed. So, + if cl65 supports an option by itself, do not pass that option to the assembler by means of the <tt/-Wa/ switch. @@ -188,10 +200,10 @@ There are a few remaining options that control the behaviour of cl65: Pass options directly to the compiler. This may be used to pass options that aren't directly supported by cl65. Several options may be separated by - commas, the commas are replaced by spaces when passing them to the - compiler. Beware: Passing arguments directly to the compiler may interfere - with some of the defaults, because cl65 doesn't parse the options passed. So - if cl65 supports an option by itself, do not pass this option to the + commas; the commas are replaced by spaces when passing them to the + compiler. Beware: Passing arguments directly to the compiler might interfere + with some of the defaults because cl65 doesn't parse the options passed. So, + if cl65 supports an option by itself, do not pass that option to the compiler by means of the <tt/-Wc/ switch. @@ -199,10 +211,10 @@ There are a few remaining options that control the behaviour of cl65: Pass options directly to the linker. This may be used to pass options that aren't directly supported by cl65. Several options may be separated by - commas, the commas are replaced by spaces when passing them to the linker. - Beware: Passing arguments directly to the linker may interfere with some of - the defaults, because cl65 doesn't parse the options passed. So if cl65 - supports an option by itself, do not pass this option to the linker by means + commas; the commas are replaced by spaces when passing them to the linker. + Beware: Passing arguments directly to the linker might interfere with some of + the defaults because cl65 doesn't parse the options passed. So, if cl65 + supports an option by itself, do not pass that option to the linker by means of the <tt/-Wl/ switch. </descrip> @@ -211,7 +223,7 @@ There are a few remaining options that control the behaviour of cl65: <sect>More usage<p> -Since cl65 was created to simplify the use of the cc65 development +Because cl65 was created to simplify the use of the cc65 development package, it tries to be smart about several things. <itemize> @@ -219,15 +231,14 @@ package, it tries to be smart about several things. <item> If you don't give a target system on the command line, cl65 defaults to the C64. -<item> When linking, cl65 will supply the names of the startup file and - library for the target system to the linker, so you don't have to do - that. +<item> When linking, cl65 will supply the name of the library file for + the target system to the linker; so, you don't have to do that. <item> If the final step is the linker, and the name of the output file was not explicitly given, cl65 will use the name of the first input file - without the extension, provided that the name of this file has an - extension. So you don't need to name the executable name in most - cases, just give the name of your "main" file as first input file. + without the extension, provided that the name of that file has an + extension. So, you don't need to give the executable name in most + cases; just give the name of your "main" file as the first input file. </itemize> The command line is parsed from left to right, and the actual processing tool @@ -248,7 +259,7 @@ The type of an input file is derived from its extension: <itemize> <item>C files: <tt/.c/ <item>Assembler files: <tt/.s/, <tt/.asm/, <tt/.a65/ -<item>Object files: <tt/.o/ <tt/.obj/ +<item>Object files: <tt/.o/, <tt/.obj/ <item>Libraries: <tt/.a/, <tt/.lib/ <item>GEOS resource files: <tt/.grc/ <item>o65 files: <tt/.o65/, <tt/.emd/, <tt/.joy/, <tt/.tgi/ From e31133c804ebb50ea89198445aec93d85584a7f8 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 24 May 2017 18:49:02 -0400 Subject: [PATCH 108/199] Added "html" and "info" goals to the top-level Makefile. They are for people who don't want to build both types of documents at the same time. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 808689c82..206f853fc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all mostlyclean clean install zip avail unavail bin lib doc samples +.PHONY: all mostlyclean clean install zip avail unavail bin lib doc html info samples .SUFFIXES: @@ -14,7 +14,7 @@ avail unavail bin: lib: @$(MAKE) -C libsrc --no-print-directory $@ -doc: +doc html info: @$(MAKE) -C doc --no-print-directory $@ samples: From 1602aab6e9aa4d89098404993526938c512d282a Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Thu, 25 May 2017 03:01:25 -0400 Subject: [PATCH 109/199] forgot to update comments from earlier #323 rand.s change --- libsrc/common/rand.s | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libsrc/common/rand.s b/libsrc/common/rand.s index 8ad7bcdb4..38d525b6b 100644 --- a/libsrc/common/rand.s +++ b/libsrc/common/rand.s @@ -2,6 +2,7 @@ ; Randum number generator ; ; Written and donated by Sidney Cadot - sidney@ch.twi.tudelft.nl +; 2016-11-07, modified by Brad Smith ; ; May be distributed with the cc65 runtime using the same license. ; @@ -13,10 +14,14 @@ ; Multiplier must be 1 (mod 4) ; Added value must be 1 (mod 2) ; This guarantees max. period (2**32) -; Bits 8-22 are returned (positive 2-byte int) -; where 0 is LSB, 31 is MSB. -; This is better as lower bits exhibit easily -; detectable patterns. +; The lowest bits have poor entropy and +; exhibit easily detectabl patterns, so +; only the upper bits 16-22 and 24-31 of the +; 4-byte state are returned. +; +; The best 8 bits, 24-31 are returned in the +; low byte A to provide the best entropy in the +; most commonly used part of the return value. ; .export _rand, _srand From 950d65e8ed4c95d8ada5540601b35cda35823a77 Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Thu, 25 May 2017 03:20:11 -0400 Subject: [PATCH 110/199] detectabl > detectable --- libsrc/common/rand.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/common/rand.s b/libsrc/common/rand.s index 38d525b6b..102dd5be2 100644 --- a/libsrc/common/rand.s +++ b/libsrc/common/rand.s @@ -15,7 +15,7 @@ ; Added value must be 1 (mod 2) ; This guarantees max. period (2**32) ; The lowest bits have poor entropy and -; exhibit easily detectabl patterns, so +; exhibit easily detectable patterns, so ; only the upper bits 16-22 and 24-31 of the ; 4-byte state are returned. ; From 3b33af88cf4c3b6fff6e8b032fe5d5f9304ab599 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Fri, 26 May 2017 01:44:33 +0200 Subject: [PATCH 111/199] Oricutron mentioned --- doc/ld65.sgml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/ld65.sgml b/doc/ld65.sgml index 5687aa8ab..8f9dd7093 100644 --- a/doc/ld65.sgml +++ b/doc/ld65.sgml @@ -247,10 +247,11 @@ Here is a description of all of the command-line options: <tag><tt>-Ln</tt></tag> This option allows you to create a file that contains all global labels and - may be loaded into the VICE emulator using the <tt/ll/ (load label) command. You + may be loaded into the VICE emulator using the <tt/ll/ (load label) command + or into the Oricutron emulator using the <tt/sl/ (symbols load) command. You may use this to debug your code with VICE. Note: Older versions had some bugs in the label code. If you have problems, please get the latest <url - url="http://vice-emu.sourceforge.net/" name="VICE"> version. + url="http://vice-emu.sourceforge.net" name="VICE"> version. <label id="option-S"> From ff339393859558323553aea89c1ecc90fcf55d01 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 00:29:53 +0200 Subject: [PATCH 112/199] Use verbosity --- src/ar65/list.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ar65/list.c b/src/ar65/list.c index 656299860..496bbcde0 100644 --- a/src/ar65/list.c +++ b/src/ar65/list.c @@ -36,6 +36,9 @@ #include <stdio.h> #include <stdlib.h> +/* common */ +#include "print.h" + /* ar65 */ #include "error.h" #include "library.h" @@ -73,6 +76,10 @@ void ListObjFiles (int argc, char* argv []) /* Get the entry */ O = CollConstAt (&ObjPool, I); + /* Print the size */ + if (Verbosity > 0) { + printf ("%5ld ", O->Size); + } /* Print the name */ printf ("%s\n", O->Name); From 9bdcb0a31bd5d164d7aa027e975e6c4b0da611af Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 00:35:38 +0200 Subject: [PATCH 113/199] More POSIX.2, staying compatible --- src/ar65/main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ar65/main.c b/src/ar65/main.c index a1839bad2..9985f1f71 100644 --- a/src/ar65/main.c +++ b/src/ar65/main.c @@ -64,8 +64,8 @@ static void Usage (void) "Operations are some of:\n" "\ta\tAdd modules\n" "\td\tDelete modules\n" - "\tl\tList library contents\n" - "\tv\tIncrease verbosity (put before other operation)\n" + "\tt\tList library table\n" + "\tv\tIncrease verbosity (put after other operation)\n" "\tx\tExtract modules\n" "\tV\tPrint the archiver version\n", ProgName); @@ -94,10 +94,6 @@ int main (int argc, char* argv []) /* Get the argument */ const char* Arg = ArgVec [I]; - /* Check for an option */ - if (strlen (Arg) != 1) { - Usage (); - } switch (Arg [0]) { case 'a': @@ -108,7 +104,11 @@ int main (int argc, char* argv []) DelObjFiles (ArgCount - I - 1, &ArgVec [I+1]); break; - case 'l': + case 't': /* POSIX.2 */ + case 'l': /* staying compatible */ + if (Arg [1] == 'v') { + ++Verbosity; + } ListObjFiles (ArgCount - I - 1, &ArgVec [I+1]); break; From 843c5442b149ca12db80dcb5f55dc61da9feaa42 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 13:13:53 +0200 Subject: [PATCH 114/199] Update list.c --- src/ar65/list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ar65/list.c b/src/ar65/list.c index 496bbcde0..e307e70a8 100644 --- a/src/ar65/list.c +++ b/src/ar65/list.c @@ -78,7 +78,7 @@ void ListObjFiles (int argc, char* argv []) /* Print the size */ if (Verbosity > 0) { - printf ("%5ld ", O->Size); + Print (stdout, 1, "%5lu ", O->Size); } /* Print the name */ printf ("%s\n", O->Name); From c9c2562c14aa296c69548bd089f5ba689abf2156 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 15:13:43 +0200 Subject: [PATCH 115/199] Update list.c --- src/ar65/list.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ar65/list.c b/src/ar65/list.c index e307e70a8..d65ad51e5 100644 --- a/src/ar65/list.c +++ b/src/ar65/list.c @@ -76,10 +76,8 @@ void ListObjFiles (int argc, char* argv []) /* Get the entry */ O = CollConstAt (&ObjPool, I); - /* Print the size */ - if (Verbosity > 0) { - Print (stdout, 1, "%5lu ", O->Size); - } + /* Print the size if verbose */ + Print (stdout, 1, "%5lu ", O->Size); /* Print the name */ printf ("%s\n", O->Name); From ea9430e28edc6b47a20bf3a94d05267a4c383569 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 15:22:33 +0200 Subject: [PATCH 116/199] Update list.c --- src/ar65/list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ar65/list.c b/src/ar65/list.c index d65ad51e5..367c950dc 100644 --- a/src/ar65/list.c +++ b/src/ar65/list.c @@ -79,7 +79,7 @@ void ListObjFiles (int argc, char* argv []) /* Print the size if verbose */ Print (stdout, 1, "%5lu ", O->Size); /* Print the name */ - printf ("%s\n", O->Name); + puts (O->Name); } From 49e22f566fa04cfaf841797732c7bb9b08a96c01 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 15:29:49 +0200 Subject: [PATCH 117/199] Update main.c --- src/ar65/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ar65/main.c b/src/ar65/main.c index 9985f1f71..9fb5d6cf8 100644 --- a/src/ar65/main.c +++ b/src/ar65/main.c @@ -65,7 +65,7 @@ static void Usage (void) "\ta\tAdd modules\n" "\td\tDelete modules\n" "\tt\tList library table\n" - "\tv\tIncrease verbosity (put after other operation)\n" + "\tv\tIncrease verbosity (put before other operation)\n" "\tx\tExtract modules\n" "\tV\tPrint the archiver version\n", ProgName); From ed65eaf682f84abcf59739d8774d61f382e5ca04 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 16:12:02 +0200 Subject: [PATCH 118/199] Verbosity was missing; POSIX operations --- doc/ar65.sgml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/doc/ar65.sgml b/doc/ar65.sgml index 136defd40..fa11cddb0 100644 --- a/doc/ar65.sgml +++ b/doc/ar65.sgml @@ -32,16 +32,17 @@ for the cc65 compiler. ar65 is part of this suite. The archiver is called as follows: <tscreen><verb> - Usage: ar65 <operation> lib file|module ... - Operation is one of: - a Add modules - d Delete modules - l List library contents - x Extract modules - V Print the archiver version + Usage: ar65 <operation ...> lib file|module ... + Operations are some of: + r Add modules + d Delete modules + t List library table + v Increase verbosity (put before other operation) + x Extract modules + V Print the archiver version </verb></tscreen> -You may add modules to a library using the `a' command. If the library +You may add modules to a library using the `r' command. If the library does not exist, it is created (and a warning message is printed which you may ignore if creation of the library was your intention). You may specify any number of modules on the command line following the library. @@ -53,7 +54,7 @@ has a newer timestamp than the one to add. Here's an example: <tscreen><verb> - ar65 a mysubs.lib sub1.o sub2.o + ar65 r mysubs.lib sub1.o sub2.o </verb></tscreen> This will add two modules to the library `mysubs.lib' creating the @@ -63,10 +64,10 @@ sub2.o, they are replaced by the new ones. Modules names in the library are stored without the path, so, using <tscreen><verb> - ar65 a mysubs.lib ofiles/sub1.o ofiles/sub2.o + ar65 v v r mysubs.lib ofiles/sub1.o ofiles/sub2.o </verb></tscreen> -will add two modules named `sub1.o' and `sub2.o' to the library. +will verbose add two modules named `sub1.o' and `sub2.o' to the library. Deleting modules from a library is done with the `d' command. You may not give a path when naming the modules. @@ -81,13 +82,13 @@ This will delete the module named `sub1.o' from the library, printing an error if the library does not contain that module. -The `l' command prints a list of all modules in the library. Any module +The `t' command prints a table of all modules in the library. Any module names on the command line are ignored. Example: <tscreen><verb> - ar65 l mysubs.lib + ar65 tv mysubs.lib </verb></tscreen> From 80feb80168eccc8b8097b9150c13deb848a8eb45 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 16:17:34 +0200 Subject: [PATCH 119/199] Update main.c --- src/ar65/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ar65/main.c b/src/ar65/main.c index 9fb5d6cf8..48561027f 100644 --- a/src/ar65/main.c +++ b/src/ar65/main.c @@ -62,7 +62,7 @@ static void Usage (void) { fprintf (stderr, "Usage: %s <operation ...> lib file|module ...\n" "Operations are some of:\n" - "\ta\tAdd modules\n" + "\tr\tAdd modules\n" "\td\tDelete modules\n" "\tt\tList library table\n" "\tv\tIncrease verbosity (put before other operation)\n" @@ -96,7 +96,8 @@ int main (int argc, char* argv []) switch (Arg [0]) { - case 'a': + case 'r': /* POSIX.2 */ + case 'a': /* staying compatible */ AddObjFiles (ArgCount - I - 1, &ArgVec[I+1]); break; From 0a011c31eab6ac137025b017c44677f929941df6 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 16:22:34 +0200 Subject: [PATCH 120/199] Update ar65.sgml --- doc/ar65.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ar65.sgml b/doc/ar65.sgml index fa11cddb0..0a55a08c0 100644 --- a/doc/ar65.sgml +++ b/doc/ar65.sgml @@ -4,7 +4,7 @@ <title>ar65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>19.07.2000 +<date>2017-05-28 <abstract> ar65 is an archiver for object files generated by ca65. It allows to create From 52642f6c8f8a2a8f687fff71661e403b0218bbdc Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Tue, 30 May 2017 02:05:35 +0200 Subject: [PATCH 121/199] Deprecated commands mentioned --- doc/ar65.sgml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/ar65.sgml b/doc/ar65.sgml index 0a55a08c0..2e01025ca 100644 --- a/doc/ar65.sgml +++ b/doc/ar65.sgml @@ -42,7 +42,7 @@ The archiver is called as follows: V Print the archiver version </verb></tscreen> -You may add modules to a library using the `r' command. If the library +You may add modules to a library using the `r' command (`a' is deprecated). If the library does not exist, it is created (and a warning message is printed which you may ignore if creation of the library was your intention). You may specify any number of modules on the command line following the library. @@ -82,8 +82,8 @@ This will delete the module named `sub1.o' from the library, printing an error if the library does not contain that module. -The `t' command prints a table of all modules in the library. Any module -names on the command line are ignored. +The `t' command prints a table of all modules in the library (`l' is deprecated). +Any module names on the command line are ignored. Example: From e75a59d7a8d9bce24a3c9731924ad3abd1ab109e Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 6 Jun 2017 18:48:25 +0300 Subject: [PATCH 122/199] Add LZ4 decompression support --- include/lz4.h | 44 +++ libsrc/common/lz4.s | 283 +++++++++++++++++++ test/val/lz4.c | 669 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 996 insertions(+) create mode 100644 include/lz4.h create mode 100644 libsrc/common/lz4.s create mode 100644 test/val/lz4.c diff --git a/include/lz4.h b/include/lz4.h new file mode 100644 index 000000000..d6bf1b17c --- /dev/null +++ b/include/lz4.h @@ -0,0 +1,44 @@ +/*****************************************************************************/ +/* */ +/* lz4.h */ +/* */ +/* Decompression routine for the 'lz4' format */ +/* */ +/* */ +/* */ +/* (C) 2017 Mega Cat Studios */ +/* */ +/* 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 _LZ4_H +#define _LZ4_H + +void __fastcall__ decompress_lz4 (const unsigned char* src, unsigned char* dst, + const unsigned short uncompressed_size); +/* + Decompresses the source buffer into the destination buffer. + The size of the decompressed data must be known in advance, LZ4 + does not include any terminator in-stream. +*/ + +/* end of lz4.h */ +#endif diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s new file mode 100644 index 000000000..ee215d4da --- /dev/null +++ b/libsrc/common/lz4.s @@ -0,0 +1,283 @@ +; +; Lauri Kasanen, 6 Jun 2017 +; (C) Mega Cat Studios +; An optimized LZ4 decompressor +; + + .importzp sp, sreg, regsave, regbank + .importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 + .macpack longbranch + .import memcpy_upwards,pushax,popax + .export _decompress_lz4 + +_out = regsave +_written = regsave + 2 +_tmp = tmp1 +_token = tmp2 +_offset = ptr3 +_in = sreg +_outlen = ptr4 + +; --------------------------------------------------------------- +; void decompress_lz4 (const u8 *in, u8 * const out, const u16 outlen) +; --------------------------------------------------------------- + +.segment "CODE" + +.proc _decompress_lz4: near + + sta _outlen + stx _outlen+1 + + jsr popax + sta _out + stx _out+1 + + jsr popax + sta _in + stx _in+1 + +; +; written = 0; +; + lda #$00 + sta _written +; +; while (written < outlen) { +; + jmp L0046 +; +; token = *in++; +; +L0004: ldy #0 + lda (_in),y + sta _token + + inc _in + bne L000A + inc _in+1 +L000A: +; +; offset = token >> 4; +; + ldx #$00 + lsr a + lsr a + lsr a + lsr a + sta _offset + stx _offset+1 +; +; token &= 0xf; +; token += 4; // Minmatch +; + lda _token + and #$0F + clc + adc #4 + sta _token +; +; if (offset == 15) { +; + lda _offset + cmp #$0F +L0013: bne L001A +; +; tmp = *in++; +; + ldy #0 + lda (_in),y + sta _tmp + + inc _in + bne L0017 + inc _in+1 +L0017: +; +; offset += tmp; +; + clc + adc _offset + sta _offset + lda #$00 + adc _offset+1 + sta _offset+1 +; +; if (tmp == 255) +; + lda _tmp + cmp #$FF +; +; goto moreliterals; +; + jmp L0013 +; +; if (offset) { +; +L001A: lda _offset + ora _offset+1 + beq L001C +; +; memcpy(&out[written], in, offset); +; + lda _out + clc + adc _written + sta ptr2 + lda _out+1 + adc _written+1 + tax + lda ptr2 + stx ptr2+1 + jsr pushax + lda _in + ldx _in+1 + sta ptr1 + stx ptr1+1 + ldy #0 + jsr memcpy_upwards +; +; written += offset; +; + lda _offset + clc + adc _written + sta _written + lda _offset+1 + adc _written+1 + sta _written+1 +; +; in += offset; +; + lda _offset + clc + adc _in + sta _in + lda _offset+1 + adc _in+1 + sta _in+1 +; +; if (written >= outlen) +; +L001C: lda _written + cmp _outlen + lda _written+1 + sbc _outlen+1 +; +; return; +; + bcc L0047 + rts +; +; memcpy(&offset, in, 2); +; +L0047: ldy #0 + lda (_in),y + sta _offset + iny + lda (_in),y + sta _offset+1 +; +; in += 2; +; + lda #$02 + clc + adc _in + sta _in + bcc L002F + inc _in+1 +; +; copysrc = out + written - offset; +; +L002F: lda _out + clc + adc _written + pha + lda _out+1 + adc _written+1 + tax + pla + sec + sbc _offset + sta ptr1 + txa + sbc _offset+1 + sta ptr1+1 +; +; offset = token; +; + lda #$00 + sta _offset+1 + lda _token + sta _offset +; +; if (token == 19) { +; + cmp #$13 +L0045: bne L003C +; +; tmp = *in++; +; + ldy #0 + lda (_in),y + sta _tmp + + inc _in + bne L0039 + inc _in+1 +L0039: +; +; offset += tmp; +; + clc + adc _offset + sta _offset + tya + adc _offset+1 + sta _offset+1 +; +; if (tmp == 255) +; + lda _tmp + cmp #$FF +; +; goto morematches; +; + jmp L0045 +; +; memcpy(&out[written], copysrc, offset); +; +L003C: lda _out + clc + adc _written + sta ptr2 + lda _out+1 + adc _written+1 + tax + lda ptr2 + stx ptr2+1 + jsr pushax + jsr memcpy_upwards +; +; written += offset; +; + lda _offset + clc + adc _written + sta _written + lda _offset+1 + adc _written+1 +L0046: sta _written+1 +; +; while (written < outlen) { +; + lda _written + cmp _outlen + lda _written+1 + sbc _outlen+1 + jcc L0004 + + rts + +.endproc + diff --git a/test/val/lz4.c b/test/val/lz4.c new file mode 100644 index 000000000..dceefbfcc --- /dev/null +++ b/test/val/lz4.c @@ -0,0 +1,669 @@ +/* + !!DESCRIPTION!! lz4 decompression + !!ORIGIN!! cc65 regression tests + !!LICENCE!! BSD 2-clause + !!AUTHOR!! Lauri Kasanen +*/ + +#include <zlib.h> +#include <stdio.h> +#include <lz4.h> + +/* The sample data is the original lz4.h, compressed with lz4 hc */ +static const unsigned char compressed[] = { +0xf0, 0x1a, 0x2f, 0x2a, 0x0a, 0x20, 0x20, 0x20, 0x4c, 0x5a, 0x34, 0x20, +0x2d, 0x20, 0x46, 0x61, 0x73, 0x74, 0x20, 0x4c, 0x5a, 0x20, 0x63, 0x6f, +0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x6c, +0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x27, 0x00, 0xb0, 0x48, 0x65, +0x61, 0x64, 0x65, 0x72, 0x20, 0x46, 0x69, 0x6c, 0x65, 0x0f, 0x00, 0xf0, +0x17, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28, +0x43, 0x29, 0x20, 0x32, 0x30, 0x31, 0x31, 0x2d, 0x32, 0x30, 0x31, 0x35, +0x2c, 0x20, 0x59, 0x61, 0x6e, 0x6e, 0x20, 0x43, 0x6f, 0x6c, 0x6c, 0x65, +0x74, 0x2e, 0x0a, 0x2a, 0x00, 0xf2, 0x22, 0x42, 0x53, 0x44, 0x20, 0x32, +0x2d, 0x43, 0x6c, 0x61, 0x75, 0x73, 0x65, 0x20, 0x4c, 0x69, 0x63, 0x65, +0x6e, 0x73, 0x65, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, +0x77, 0x77, 0x77, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x6f, 0x75, 0x72, +0x63, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x6c, 0x23, 0x00, 0x63, 0x73, +0x2f, 0x62, 0x73, 0x64, 0x2d, 0x0d, 0x00, 0x51, 0x2e, 0x70, 0x68, 0x70, +0x29, 0x4e, 0x00, 0xb1, 0x52, 0x65, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, +0x62, 0x75, 0x74, 0xa3, 0x00, 0x30, 0x6e, 0x64, 0x20, 0x58, 0x00, 0x32, +0x69, 0x6e, 0x20, 0x43, 0x00, 0x01, 0x12, 0x00, 0xf1, 0x06, 0x62, 0x69, +0x6e, 0x61, 0x72, 0x79, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2c, 0x20, +0x77, 0x69, 0x74, 0x68, 0x20, 0x6f, 0x72, 0x08, 0x00, 0x30, 0x6f, 0x75, +0x74, 0x46, 0x00, 0x80, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x63, 0x61, +0x44, 0x00, 0xf0, 0x22, 0x2c, 0x20, 0x61, 0x72, 0x65, 0x20, 0x70, 0x65, +0x72, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x20, 0x70, 0x72, 0x6f, 0x76, +0x69, 0x64, 0x65, 0x64, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x74, 0x68, +0x65, 0x20, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x20, +0x63, 0x6f, 0x6e, 0x64, 0x69, 0x35, 0x00, 0x10, 0x73, 0x35, 0x00, 0x01, +0x4a, 0x00, 0x31, 0x65, 0x74, 0x3a, 0x99, 0x00, 0x00, 0x01, 0x00, 0x1b, +0x2a, 0x9f, 0x00, 0x44, 0x73, 0x20, 0x6f, 0x66, 0x98, 0x00, 0xf1, 0x01, +0x63, 0x6f, 0x64, 0x65, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x72, 0x65, +0x74, 0x61, 0x69, 0x6e, 0x5a, 0x00, 0x40, 0x61, 0x62, 0x6f, 0x76, 0x1b, +0x00, 0x03, 0x4c, 0x01, 0x00, 0x48, 0x00, 0xf0, 0x02, 0x6e, 0x6f, 0x74, +0x69, 0x63, 0x65, 0x2c, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x6c, 0x69, +0x73, 0x74, 0x44, 0x00, 0x08, 0x78, 0x00, 0x2b, 0x6e, 0x64, 0x95, 0x00, +0xbf, 0x64, 0x69, 0x73, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x72, 0x2e, +0x89, 0x00, 0x07, 0x28, 0x69, 0x6e, 0x16, 0x01, 0x04, 0x89, 0x00, 0x76, +0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x8c, 0x00, 0x00, 0x41, 0x00, +0x05, 0x8f, 0x00, 0x0f, 0x8c, 0x00, 0x2a, 0x00, 0x4a, 0x00, 0x03, 0xe6, +0x00, 0x94, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0xb3, +0x01, 0xf6, 0x04, 0x2f, 0x6f, 0x72, 0x20, 0x6f, 0x74, 0x68, 0x65, 0x72, +0x20, 0x6d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x73, 0x77, 0x01, +0x01, 0xaf, 0x01, 0x21, 0x74, 0x68, 0x8b, 0x00, 0x08, 0xc4, 0x00, 0x02, +0x4e, 0x02, 0xf0, 0x34, 0x54, 0x48, 0x49, 0x53, 0x20, 0x53, 0x4f, 0x46, +0x54, 0x57, 0x41, 0x52, 0x45, 0x20, 0x49, 0x53, 0x20, 0x50, 0x52, 0x4f, +0x56, 0x49, 0x44, 0x45, 0x44, 0x20, 0x42, 0x59, 0x20, 0x54, 0x48, 0x45, +0x20, 0x43, 0x4f, 0x50, 0x59, 0x52, 0x49, 0x47, 0x48, 0x54, 0x20, 0x48, +0x4f, 0x4c, 0x44, 0x45, 0x52, 0x53, 0x20, 0x41, 0x4e, 0x44, 0x20, 0x43, +0x4f, 0x4e, 0x54, 0x52, 0x49, 0x42, 0x55, 0x54, 0x4f, 0x52, 0x53, 0x47, +0x00, 0x71, 0x22, 0x41, 0x53, 0x20, 0x49, 0x53, 0x22, 0x1c, 0x00, 0xf1, +0x26, 0x41, 0x4e, 0x59, 0x20, 0x45, 0x58, 0x50, 0x52, 0x45, 0x53, 0x53, +0x20, 0x4f, 0x52, 0x20, 0x49, 0x4d, 0x50, 0x4c, 0x49, 0x45, 0x44, 0x20, +0x57, 0x41, 0x52, 0x52, 0x41, 0x4e, 0x54, 0x49, 0x45, 0x53, 0x2c, 0x20, +0x49, 0x4e, 0x43, 0x4c, 0x55, 0x44, 0x49, 0x4e, 0x47, 0x2c, 0x20, 0x42, +0x55, 0x54, 0x20, 0x4e, 0x4f, 0x54, 0x3a, 0x03, 0xa1, 0x49, 0x4d, 0x49, +0x54, 0x45, 0x44, 0x20, 0x54, 0x4f, 0x2c, 0x7b, 0x00, 0x0e, 0x3a, 0x00, +0xf1, 0x04, 0x20, 0x4f, 0x46, 0x20, 0x4d, 0x45, 0x52, 0x43, 0x48, 0x41, +0x4e, 0x54, 0x41, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x73, 0x00, 0x40, +0x46, 0x49, 0x54, 0x4e, 0x6f, 0x00, 0x30, 0x46, 0x4f, 0x52, 0x49, 0x00, +0xf0, 0x06, 0x41, 0x20, 0x50, 0x41, 0x52, 0x54, 0x49, 0x43, 0x55, 0x4c, +0x41, 0x52, 0x20, 0x50, 0x55, 0x52, 0x50, 0x4f, 0x53, 0x45, 0x20, 0xe0, +0x00, 0xfa, 0x0e, 0x44, 0x49, 0x53, 0x43, 0x4c, 0x41, 0x49, 0x4d, 0x45, +0x44, 0x2e, 0x20, 0x49, 0x4e, 0x20, 0x4e, 0x4f, 0x20, 0x45, 0x56, 0x45, +0x4e, 0x54, 0x20, 0x53, 0x48, 0x41, 0x4c, 0x4c, 0xef, 0x00, 0x00, 0x48, +0x00, 0x50, 0x4f, 0x57, 0x4e, 0x45, 0x52, 0xc4, 0x00, 0x08, 0xef, 0x00, +0xa0, 0x20, 0x42, 0x45, 0x20, 0x4c, 0x49, 0x41, 0x42, 0x4c, 0x45, 0x6f, +0x00, 0x01, 0xee, 0x00, 0x60, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0xd7, +0x00, 0x06, 0x0a, 0x00, 0x90, 0x43, 0x49, 0x44, 0x45, 0x4e, 0x54, 0x41, +0x4c, 0x2c, 0x49, 0x00, 0xf3, 0x04, 0x53, 0x50, 0x45, 0x43, 0x49, 0x41, +0x4c, 0x2c, 0x20, 0x45, 0x58, 0x45, 0x4d, 0x50, 0x4c, 0x41, 0x52, 0x59, +0x2c, 0x57, 0x00, 0xff, 0x05, 0x53, 0x45, 0x51, 0x55, 0x45, 0x4e, 0x54, +0x49, 0x41, 0x4c, 0x20, 0x44, 0x41, 0x4d, 0x41, 0x47, 0x45, 0x53, 0x20, +0x28, 0x1e, 0x01, 0x0f, 0x80, 0x50, 0x52, 0x4f, 0x43, 0x55, 0x52, 0x45, +0x4d, 0xbc, 0x00, 0xf1, 0x03, 0x4f, 0x46, 0x20, 0x53, 0x55, 0x42, 0x53, +0x54, 0x49, 0x54, 0x55, 0x54, 0x45, 0x20, 0x47, 0x4f, 0x4f, 0x44, 0x77, +0x01, 0xd1, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x53, 0x3b, 0x20, +0x4c, 0x4f, 0x53, 0x39, 0x01, 0x31, 0x55, 0x53, 0x45, 0x8d, 0x00, 0x41, +0x44, 0x41, 0x54, 0x41, 0x7f, 0x00, 0x80, 0x50, 0x52, 0x4f, 0x46, 0x49, +0x54, 0x53, 0x3b, 0x0c, 0x00, 0x41, 0x42, 0x55, 0x53, 0x49, 0x43, 0x01, +0xf1, 0x0d, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x52, 0x55, 0x50, 0x54, 0x49, +0x4f, 0x4e, 0x29, 0x20, 0x48, 0x4f, 0x57, 0x45, 0x56, 0x45, 0x52, 0x20, +0x43, 0x41, 0x55, 0x53, 0x45, 0x44, 0x6c, 0x01, 0x20, 0x4f, 0x4e, 0xf4, +0x00, 0x02, 0x3c, 0x02, 0x40, 0x45, 0x4f, 0x52, 0x59, 0x5b, 0x00, 0x23, +0x4c, 0x49, 0x8e, 0x01, 0x90, 0x2c, 0x20, 0x57, 0x48, 0x45, 0x54, 0x48, +0x45, 0x52, 0x5f, 0x01, 0x01, 0x36, 0x01, 0x10, 0x41, 0x0f, 0x01, 0x68, +0x53, 0x54, 0x52, 0x49, 0x43, 0x54, 0x27, 0x00, 0x61, 0x4f, 0x52, 0x20, +0x54, 0x4f, 0x52, 0xd9, 0x00, 0x06, 0xf0, 0x00, 0xb0, 0x20, 0x4e, 0x45, +0x47, 0x4c, 0x49, 0x47, 0x45, 0x4e, 0x43, 0x45, 0x21, 0x00, 0x10, 0x4f, +0x49, 0x00, 0xa0, 0x57, 0x49, 0x53, 0x45, 0x29, 0x20, 0x41, 0x52, 0x49, +0x53, 0x21, 0x00, 0x11, 0x49, 0x7d, 0x00, 0x71, 0x20, 0x57, 0x41, 0x59, +0x20, 0x4f, 0x55, 0xfc, 0x00, 0x00, 0xb5, 0x01, 0x31, 0x55, 0x53, 0x45, +0xaf, 0x01, 0x1a, 0x46, 0xcf, 0x02, 0x11, 0x2c, 0xde, 0x01, 0x80, 0x20, +0x49, 0x46, 0x20, 0x41, 0x44, 0x56, 0x49, 0xc0, 0x00, 0x03, 0x30, 0x00, +0x53, 0x50, 0x4f, 0x53, 0x53, 0x49, 0x3f, 0x02, 0x01, 0x3f, 0x01, 0x23, +0x43, 0x48, 0x7e, 0x01, 0x02, 0x15, 0x03, 0x70, 0x59, 0x6f, 0x75, 0x20, +0x63, 0x61, 0x6e, 0x9b, 0x03, 0x32, 0x74, 0x61, 0x63, 0xb5, 0x04, 0xb0, +0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x20, 0x61, 0x74, 0x20, 0x3a, 0x23, +0x00, 0x11, 0x2d, 0xe8, 0x05, 0x03, 0x8c, 0x04, 0xd0, 0x72, 0x65, 0x70, +0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x20, 0x3a, 0x20, 0x8a, 0x05, +0xf6, 0x0c, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, +0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x79, 0x61, 0x6e, 0x34, 0x39, 0x37, +0x33, 0x2f, 0x6c, 0x7a, 0x34, 0x3d, 0x00, 0x60, 0x70, 0x75, 0x62, 0x6c, +0x69, 0x63, 0x40, 0x04, 0x28, 0x75, 0x6d, 0x38, 0x00, 0xc1, 0x72, 0x6f, +0x75, 0x70, 0x73, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x3f, 0x00, +0x01, 0x22, 0x00, 0x32, 0x2f, 0x23, 0x21, 0x08, 0x00, 0xf0, 0x1b, 0x6c, +0x7a, 0x34, 0x63, 0x0a, 0x2a, 0x2f, 0x0a, 0x23, 0x70, 0x72, 0x61, 0x67, +0x6d, 0x61, 0x20, 0x6f, 0x6e, 0x63, 0x65, 0x0a, 0x0a, 0x23, 0x69, 0x66, +0x20, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x20, 0x28, 0x5f, 0x5f, +0x63, 0x70, 0x6c, 0x75, 0x73, 0x04, 0x00, 0xf0, 0x08, 0x29, 0x0a, 0x65, +0x78, 0x74, 0x65, 0x72, 0x6e, 0x20, 0x22, 0x43, 0x22, 0x20, 0x7b, 0x0a, +0x23, 0x65, 0x6e, 0x64, 0x69, 0x66, 0x0a, 0x0a, 0xab, 0x06, 0x74, 0x2a, +0x20, 0x6c, 0x7a, 0x34, 0x2e, 0x68, 0x2a, 0x04, 0x79, 0x73, 0x20, 0x62, +0x6c, 0x6f, 0x63, 0x6b, 0xb2, 0x06, 0x41, 0x66, 0x75, 0x6e, 0x63, 0x9b, +0x04, 0x11, 0x2c, 0x9c, 0x04, 0xf1, 0x02, 0x67, 0x69, 0x76, 0x65, 0x73, +0x20, 0x66, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, +0x22, 0x01, 0x60, 0x72, 0x6f, 0x6c, 0x20, 0x74, 0x6f, 0x47, 0x00, 0x42, +0x67, 0x72, 0x61, 0x6d, 0x37, 0x05, 0xb0, 0x2a, 0x20, 0x49, 0x66, 0x20, +0x79, 0x6f, 0x75, 0x20, 0x6e, 0x65, 0xfa, 0x05, 0x90, 0x6f, 0x20, 0x67, +0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x5a, 0x06, 0xc5, 0x74, 0x65, 0x72, +0x2d, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x6e, 0x00, 0xf0, +0x01, 0x65, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x28, 0x72, 0x65, +0x73, 0x70, 0x65, 0x63, 0x74, 0xfd, 0x04, 0x00, 0x25, 0x01, 0x60, 0x66, +0x72, 0x61, 0x6d, 0x65, 0x20, 0x13, 0x00, 0x05, 0x61, 0x06, 0x20, 0x29, +0x2c, 0x60, 0x00, 0x00, 0x90, 0x00, 0x00, 0xa4, 0x01, 0x22, 0x6c, 0x65, +0xa0, 0x01, 0x40, 0x6c, 0x69, 0x62, 0x72, 0x8f, 0x05, 0xf1, 0x0e, 0x68, +0x61, 0x6e, 0x64, 0x6c, 0x65, 0x20, 0x69, 0x74, 0x73, 0x20, 0x6f, 0x77, +0x6e, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x2c, 0x20, 0x70, 0x6c, +0x65, 0x61, 0x73, 0x65, 0xdc, 0x06, 0x31, 0x6c, 0x7a, 0x34, 0x56, 0x00, +0xb0, 0x2e, 0x68, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x65, 0x61, 0x64, 0x2e, +0x50, 0x01, 0x3f, 0x0a, 0x2f, 0x2a, 0x01, 0x00, 0x12, 0x70, 0x0a, 0x2a, +0x20, 0x20, 0x56, 0x65, 0x72, 0x20, 0x01, 0x1f, 0x0a, 0x32, 0x00, 0x13, +0x32, 0x2f, 0x0a, 0x23, 0x9b, 0x01, 0x00, 0xd2, 0x00, 0xe0, 0x5f, 0x56, +0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x41, 0x4a, 0x4f, 0x52, +0x5d, 0x06, 0x10, 0x31, 0x05, 0x00, 0x20, 0x2f, 0x2a, 0x09, 0x02, 0x60, +0x20, 0x62, 0x72, 0x65, 0x61, 0x6b, 0xfc, 0x00, 0x01, 0x27, 0x01, 0x20, +0x66, 0x61, 0xe9, 0x06, 0x8f, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x20, +0x20, 0x48, 0x00, 0x05, 0x22, 0x49, 0x4e, 0x48, 0x00, 0x17, 0x37, 0x48, +0x00, 0x94, 0x6e, 0x65, 0x77, 0x20, 0x28, 0x6e, 0x6f, 0x6e, 0x2d, 0x51, +0x00, 0x18, 0x29, 0x52, 0x00, 0xbf, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, +0x69, 0x74, 0x69, 0x65, 0x73, 0x56, 0x00, 0x05, 0x7a, 0x52, 0x45, 0x4c, +0x45, 0x41, 0x53, 0x45, 0x9e, 0x00, 0xf0, 0x03, 0x74, 0x77, 0x65, 0x61, +0x6b, 0x73, 0x2c, 0x20, 0x62, 0x75, 0x67, 0x2d, 0x66, 0x69, 0x78, 0x65, +0x73, 0x2c, 0x08, 0x08, 0x70, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, +0x92, 0x06, 0x0f, 0x4e, 0x00, 0x05, 0x8e, 0x4e, 0x55, 0x4d, 0x42, 0x45, +0x52, 0x20, 0x28, 0x00, 0x01, 0x40, 0x2a, 0x31, 0x30, 0x30, 0x04, 0x00, +0x2f, 0x20, 0x2b, 0xd5, 0x00, 0x00, 0x0e, 0x19, 0x00, 0x04, 0x98, 0x00, +0x51, 0x29, 0x0a, 0x69, 0x6e, 0x74, 0x19, 0x00, 0x12, 0x76, 0x8b, 0x01, +0xef, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x28, 0x76, 0x6f, 0x69, +0x64, 0x29, 0x3b, 0xcd, 0x01, 0x1a, 0x30, 0x54, 0x75, 0x6e, 0x72, 0x01, +0x20, 0x70, 0x61, 0x15, 0x02, 0x3f, 0x74, 0x65, 0x72, 0xd6, 0x01, 0x16, +0x02, 0x45, 0x03, 0x00, 0x85, 0x00, 0xc0, 0x4d, 0x45, 0x4d, 0x4f, 0x52, +0x59, 0x5f, 0x55, 0x53, 0x41, 0x47, 0x45, 0x20, 0x04, 0x31, 0x2a, 0x20, +0x4d, 0x78, 0x02, 0x61, 0x20, 0x75, 0x73, 0x61, 0x67, 0x65, 0x23, 0x08, +0xf0, 0x1d, 0x75, 0x6c, 0x61, 0x20, 0x3a, 0x20, 0x4e, 0x2d, 0x3e, 0x32, +0x5e, 0x4e, 0x20, 0x42, 0x79, 0x74, 0x65, 0x73, 0x20, 0x28, 0x65, 0x78, +0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x20, 0x3a, 0x20, 0x31, 0x30, 0x20, +0x2d, 0x3e, 0x20, 0x31, 0x4b, 0x42, 0x3b, 0x20, 0x31, 0x32, 0x0b, 0x00, +0x80, 0x34, 0x4b, 0x42, 0x20, 0x3b, 0x20, 0x31, 0x36, 0x0c, 0x00, 0x20, +0x36, 0x34, 0x18, 0x00, 0x12, 0x32, 0x23, 0x00, 0x91, 0x4d, 0x42, 0x3b, +0x20, 0x65, 0x74, 0x63, 0x2e, 0x29, 0x66, 0x03, 0x60, 0x6e, 0x63, 0x72, +0x65, 0x61, 0x73, 0xc0, 0x00, 0x18, 0x6d, 0x72, 0x00, 0x20, 0x69, 0x6d, +0xd6, 0x03, 0x29, 0x65, 0x73, 0xce, 0x03, 0x10, 0x72, 0x3f, 0x03, 0x12, +0x0a, 0xcd, 0x08, 0x4a, 0x75, 0x63, 0x65, 0x64, 0x33, 0x00, 0x00, 0x4d, +0x03, 0x03, 0x37, 0x00, 0x00, 0x70, 0x03, 0x70, 0x65, 0x64, 0x2c, 0x20, +0x64, 0x75, 0x65, 0xbc, 0x03, 0xc0, 0x63, 0x61, 0x63, 0x68, 0x65, 0x20, +0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x3f, 0x00, 0xf1, 0x05, 0x44, 0x65, +0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, +0x69, 0x73, 0x20, 0x31, 0x34, 0x2c, 0x20, 0x02, 0xf0, 0x05, 0x31, 0x36, +0x4b, 0x42, 0x2c, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x6e, 0x69, +0x63, 0x65, 0x6c, 0x79, 0x20, 0x66, 0x89, 0x03, 0xf2, 0x02, 0x69, 0x6e, +0x74, 0x6f, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x6c, 0x20, 0x78, 0x38, 0x36, +0x20, 0x4c, 0x31, 0x53, 0x00, 0x1c, 0x0a, 0x2f, 0x02, 0x09, 0x47, 0x01, +0x3f, 0x31, 0x34, 0x0a, 0xc7, 0x01, 0x1a, 0x20, 0x53, 0x69, 0x4c, 0x01, +0x24, 0x20, 0x46, 0xb3, 0x04, 0x0f, 0xc7, 0x01, 0x16, 0x05, 0x4b, 0x02, +0x04, 0x2c, 0x01, 0x22, 0x5f, 0x64, 0xe1, 0x00, 0x60, 0x28, 0x63, 0x6f, +0x6e, 0x73, 0x74, 0x81, 0x03, 0x23, 0x72, 0x2a, 0xeb, 0x05, 0x13, 0x2c, +0x0e, 0x00, 0x50, 0x64, 0x65, 0x73, 0x74, 0x2c, 0xd8, 0x00, 0x03, 0x18, +0x00, 0x42, 0x53, 0x69, 0x7a, 0x65, 0x10, 0x00, 0x70, 0x6d, 0x61, 0x78, +0x44, 0x65, 0x73, 0x74, 0x11, 0x00, 0x25, 0x29, 0x3b, 0x5b, 0x00, 0x25, +0x64, 0x65, 0x5d, 0x00, 0x5f, 0x73, 0x61, 0x66, 0x65, 0x20, 0x5b, 0x00, +0x12, 0x06, 0x1c, 0x05, 0x0b, 0x5f, 0x00, 0x0a, 0x19, 0x00, 0x02, 0xef, +0x02, 0x1f, 0x0a, 0xc2, 0x00, 0x02, 0x12, 0x29, 0xae, 0x06, 0x24, 0x20, +0x43, 0x32, 0x00, 0x36, 0x73, 0x20, 0x27, 0xb2, 0x00, 0x31, 0x27, 0x20, +0x62, 0x89, 0x02, 0x44, 0x66, 0x72, 0x6f, 0x6d, 0xd2, 0x05, 0x03, 0x1f, +0x00, 0x11, 0x27, 0x37, 0x00, 0x01, 0xb9, 0x01, 0xe0, 0x61, 0x6c, 0x72, +0x65, 0x61, 0x64, 0x79, 0x20, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0xd3, +0x0b, 0x10, 0x27, 0xa4, 0x00, 0x14, 0x27, 0x32, 0x00, 0x00, 0x94, 0x0b, +0x57, 0x69, 0x7a, 0x65, 0x20, 0x27, 0xfb, 0x00, 0x29, 0x27, 0x2e, 0x77, +0x00, 0x00, 0x7e, 0x02, 0xa3, 0x69, 0x73, 0x20, 0x67, 0x75, 0x61, 0x72, +0x61, 0x6e, 0x74, 0x13, 0x06, 0x40, 0x73, 0x75, 0x63, 0x63, 0x0b, 0x00, +0x2a, 0x69, 0x66, 0x3b, 0x00, 0x39, 0x20, 0x3e, 0x3d, 0x8f, 0x01, 0x66, +0x42, 0x6f, 0x75, 0x6e, 0x64, 0x28, 0xb6, 0x00, 0x12, 0x29, 0x5c, 0x00, +0xf0, 0x11, 0x49, 0x74, 0x20, 0x61, 0x6c, 0x73, 0x6f, 0x20, 0x72, 0x75, +0x6e, 0x73, 0x20, 0x66, 0x61, 0x73, 0x74, 0x65, 0x72, 0x2c, 0x20, 0x73, +0x6f, 0x20, 0x69, 0x74, 0x27, 0x73, 0x20, 0x61, 0x20, 0x72, 0x26, 0x01, +0x30, 0x6d, 0x65, 0x6e, 0x03, 0x0b, 0x30, 0x73, 0x65, 0x74, 0x51, 0x06, +0x03, 0x38, 0x00, 0x12, 0x66, 0x64, 0x0b, 0x03, 0xdb, 0x06, 0x00, 0xf8, +0x02, 0x26, 0x6e, 0x6f, 0x6d, 0x01, 0x05, 0x01, 0x01, 0x03, 0xfd, 0x00, +0x40, 0x20, 0x6d, 0x6f, 0x72, 0x5e, 0x06, 0x29, 0x6d, 0x69, 0xfa, 0x00, +0x41, 0x64, 0x67, 0x65, 0x74, 0x4e, 0x09, 0x09, 0x62, 0x03, 0xf2, 0x04, +0x73, 0x74, 0x6f, 0x70, 0x73, 0x20, 0x2a, 0x69, 0x6d, 0x6d, 0x65, 0x64, +0x69, 0x61, 0x74, 0x65, 0x6c, 0x79, 0x2a, 0x3a, 0x07, 0x09, 0x72, 0x00, +0x30, 0x72, 0x65, 0x73, 0x3f, 0x03, 0x72, 0x69, 0x73, 0x20, 0x7a, 0x65, +0x72, 0x6f, 0x96, 0x00, 0x10, 0x41, 0xb4, 0x00, 0x00, 0x15, 0x02, 0x50, +0x65, 0x71, 0x75, 0x65, 0x6e, 0x0e, 0x02, 0x03, 0x6b, 0x00, 0x00, 0x62, +0x07, 0x21, 0x65, 0x6e, 0x2e, 0x00, 0x21, 0x6e, 0x6f, 0x74, 0x03, 0x22, +0x69, 0x64, 0x33, 0x00, 0x10, 0x54, 0x46, 0x0c, 0x05, 0x55, 0x00, 0x90, +0x6e, 0x65, 0x76, 0x65, 0x72, 0x20, 0x77, 0x72, 0x69, 0xd1, 0x01, 0x7a, +0x6f, 0x75, 0x74, 0x73, 0x69, 0x64, 0x65, 0xa9, 0x01, 0x60, 0x2c, 0x20, +0x6e, 0x6f, 0x72, 0x20, 0xcc, 0x01, 0x06, 0x20, 0x00, 0x04, 0xec, 0x00, +0x02, 0x22, 0x00, 0x05, 0xf0, 0x0c, 0x07, 0xd6, 0x02, 0xe0, 0x20, 0x20, +0x3a, 0x20, 0x4d, 0x61, 0x78, 0x20, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, +0x04, 0x01, 0x05, 0xf7, 0x03, 0x01, 0xb3, 0x03, 0xe5, 0x41, 0x58, 0x5f, +0x49, 0x4e, 0x50, 0x55, 0x54, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x41, +0x00, 0x07, 0xd1, 0x01, 0x22, 0x20, 0x3a, 0x33, 0x08, 0x20, 0x6f, 0x72, +0x64, 0x05, 0x42, 0x74, 0x69, 0x61, 0x6c, 0x30, 0x02, 0x25, 0x6f, 0x66, +0x74, 0x02, 0x02, 0xa7, 0x00, 0x12, 0x28, 0x3a, 0x04, 0x01, 0x4c, 0x0d, +0x2e, 0x62, 0x65, 0x78, 0x02, 0x15, 0x29, 0x5e, 0x00, 0x81, 0x72, 0x65, +0x74, 0x75, 0x72, 0x6e, 0x20, 0x3a, 0x58, 0x01, 0x12, 0x6e, 0xfb, 0x05, +0x23, 0x6f, 0x66, 0xce, 0x02, 0x00, 0x04, 0x01, 0x32, 0x74, 0x65, 0x6e, +0xc0, 0x01, 0x0b, 0x62, 0x00, 0xe0, 0x6e, 0x65, 0x63, 0x65, 0x73, 0x73, +0x61, 0x72, 0x69, 0x6c, 0x79, 0x20, 0x3c, 0x3d, 0xa6, 0x00, 0x52, 0x4f, +0x75, 0x74, 0x70, 0x75, 0xaf, 0x03, 0x29, 0x0a, 0x20, 0x01, 0x00, 0x40, +0x6f, 0x72, 0x20, 0x30, 0x9d, 0x02, 0x09, 0x11, 0x09, 0x6f, 0x61, 0x69, +0x6c, 0x73, 0x0a, 0x0a, 0xd3, 0x03, 0x00, 0x05, 0x6b, 0x03, 0x0a, 0x9d, +0x03, 0x20, 0x20, 0x3a, 0x2a, 0x01, 0x00, 0xa7, 0x00, 0x72, 0x70, 0x72, +0x65, 0x63, 0x69, 0x73, 0x65, 0x0c, 0x01, 0x04, 0x01, 0x01, 0x29, 0x74, +0x68, 0x03, 0x09, 0x01, 0x82, 0x09, 0x02, 0x86, 0x01, 0x0e, 0xe9, 0x03, +0x07, 0x4c, 0x00, 0x04, 0x3f, 0x00, 0x00, 0xd6, 0x00, 0x22, 0x69, 0x6e, +0x08, 0x0e, 0x04, 0xe5, 0x01, 0x0f, 0x45, 0x01, 0x0c, 0x2f, 0x2e, 0x0a, +0x41, 0x01, 0x0e, 0x17, 0x64, 0x78, 0x00, 0x02, 0x46, 0x01, 0x0e, 0x68, +0x00, 0x0e, 0x4b, 0x01, 0x0f, 0x99, 0x04, 0x00, 0x0a, 0x51, 0x01, 0x1f, +0x49, 0xb0, 0x00, 0x01, 0x04, 0xd8, 0x02, 0xd1, 0x6c, 0x61, 0x72, 0x67, +0x65, 0x20, 0x65, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x2c, 0x82, 0x00, 0x10, +0x64, 0xd5, 0x06, 0x41, 0x77, 0x69, 0x6c, 0x6c, 0x56, 0x03, 0x01, 0x46, +0x03, 0x11, 0x6f, 0xac, 0x01, 0x92, 0x20, 0x61, 0x6e, 0x20, 0x65, 0x72, +0x72, 0x6f, 0x72, 0x04, 0x10, 0x5d, 0x28, 0x3c, 0x30, 0x29, 0x2e, 0x6a, +0x00, 0x01, 0x26, 0x01, 0x02, 0x9e, 0x0b, 0x60, 0x73, 0x74, 0x72, 0x65, +0x61, 0x6d, 0x69, 0x00, 0x50, 0x64, 0x65, 0x74, 0x65, 0x63, 0xc3, 0x02, +0x30, 0x6d, 0x61, 0x6c, 0x94, 0x07, 0x00, 0xe4, 0x06, 0x09, 0x9a, 0x03, +0x06, 0x6f, 0x00, 0x05, 0x82, 0x00, 0x00, 0x78, 0x00, 0x03, 0x2e, 0x01, +0xa3, 0x61, 0x20, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0xc3, +0x03, 0x0b, 0x77, 0x00, 0x0a, 0x91, 0x03, 0x11, 0x69, 0x84, 0x0f, 0x03, +0x71, 0x00, 0x30, 0x61, 0x67, 0x61, 0x6c, 0x0a, 0x05, 0x33, 0x05, 0xf0, +0x01, 0x76, 0x65, 0x72, 0x66, 0x6c, 0x6f, 0x77, 0x20, 0x65, 0x78, 0x70, +0x6c, 0x6f, 0x69, 0x74, 0x73, 0xdd, 0x05, 0x31, 0x63, 0x6c, 0x75, 0x72, +0x00, 0x92, 0x6d, 0x61, 0x6c, 0x69, 0x63, 0x69, 0x6f, 0x75, 0x73, 0x12, +0x0b, 0x7c, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0xe3, 0x00, 0x1f, +0x74, 0xf2, 0x03, 0x03, 0x03, 0x23, 0x01, 0x0c, 0xf2, 0x03, 0x06, 0x21, +0x00, 0x26, 0x69, 0x6e, 0x20, 0x00, 0x02, 0xf8, 0x0a, 0x0f, 0x65, 0x07, +0x19, 0x50, 0x41, 0x64, 0x76, 0x61, 0x6e, 0x3b, 0x08, 0x0e, 0x67, 0x07, +0x0f, 0x04, 0x0b, 0x19, 0x06, 0x36, 0x04, 0x44, 0x53, 0x49, 0x5a, 0x45, +0xd4, 0x00, 0x51, 0x30, 0x78, 0x37, 0x45, 0x30, 0x01, 0x00, 0x02, 0x73, +0x0a, 0xd3, 0x32, 0x20, 0x31, 0x31, 0x33, 0x20, 0x39, 0x32, 0x39, 0x20, +0x32, 0x31, 0x36, 0x9c, 0x02, 0x0b, 0xaf, 0x0a, 0x31, 0x43, 0x4f, 0x4d, +0x69, 0x10, 0x70, 0x42, 0x4f, 0x55, 0x4e, 0x44, 0x28, 0x69, 0x18, 0x03, +0xe4, 0x29, 0x20, 0x20, 0x28, 0x28, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, +0x65, 0x64, 0x29, 0x14, 0x00, 0x26, 0x3e, 0x20, 0x14, 0x00, 0x0f, 0x82, +0x00, 0x00, 0x64, 0x3f, 0x20, 0x30, 0x20, 0x3a, 0x20, 0x2d, 0x00, 0x33, +0x2b, 0x20, 0x28, 0x0b, 0x00, 0x40, 0x2f, 0x32, 0x35, 0x35, 0x10, 0x00, +0x3d, 0x31, 0x36, 0x29, 0x65, 0x07, 0x02, 0x98, 0x06, 0x04, 0xf7, 0x03, +0x14, 0x50, 0x46, 0x0d, 0x00, 0x51, 0x02, 0x72, 0x6d, 0x61, 0x78, 0x69, +0x6d, 0x75, 0x6d, 0xa8, 0x03, 0x01, 0xf8, 0x12, 0x00, 0xcc, 0x0c, 0x08, +0x49, 0x04, 0x34, 0x6d, 0x61, 0x79, 0xac, 0x01, 0x10, 0x69, 0x5a, 0x02, +0x40, 0x22, 0x77, 0x6f, 0x72, 0x11, 0x08, 0xf2, 0x00, 0x61, 0x73, 0x65, +0x22, 0x20, 0x73, 0x63, 0x65, 0x6e, 0x61, 0x72, 0x69, 0x6f, 0x20, 0x28, +0xae, 0x01, 0x01, 0x08, 0x02, 0x08, 0xa5, 0x06, 0x33, 0x69, 0x62, 0x6c, +0x5e, 0x03, 0x0f, 0x74, 0x02, 0x00, 0x22, 0x69, 0x6d, 0x95, 0x03, 0x61, +0x75, 0x73, 0x65, 0x66, 0x75, 0x6c, 0x99, 0x09, 0x03, 0xe9, 0x09, 0x03, +0x05, 0x04, 0x00, 0x2a, 0x00, 0x50, 0x70, 0x75, 0x72, 0x70, 0x6f, 0x0f, +0x08, 0x1f, 0x28, 0x94, 0x03, 0x00, 0x16, 0x73, 0x66, 0x07, 0x5f, 0x4d, +0x61, 0x63, 0x72, 0x6f, 0x6b, 0x01, 0x00, 0x10, 0x29, 0x6c, 0x00, 0x01, +0x80, 0x07, 0x05, 0x69, 0x12, 0x11, 0x66, 0x92, 0x03, 0x41, 0x6d, 0x70, +0x69, 0x6c, 0x4d, 0x00, 0x70, 0x2d, 0x74, 0x69, 0x6d, 0x65, 0x20, 0x65, +0x2e, 0x06, 0x02, 0x5d, 0x00, 0x6f, 0x28, 0x73, 0x74, 0x61, 0x63, 0x6b, +0x8c, 0x00, 0x00, 0x00, 0x39, 0x00, 0x03, 0x0b, 0x0b, 0x03, 0x76, 0x00, +0x36, 0x4e, 0x6f, 0x74, 0x38, 0x01, 0x0f, 0xd6, 0x08, 0x01, 0x05, 0xae, +0x07, 0x02, 0xf9, 0x07, 0x51, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x5e, 0x04, +0x08, 0xc3, 0x00, 0x00, 0xa3, 0x00, 0x0f, 0x4c, 0x08, 0x03, 0x2a, 0x72, +0x63, 0xa0, 0x04, 0x01, 0x67, 0x01, 0x04, 0xee, 0x06, 0x1f, 0x6d, 0xee, +0x06, 0x11, 0x00, 0x36, 0x02, 0x0e, 0x8f, 0x06, 0x04, 0xf8, 0x01, 0x03, +0xda, 0x01, 0x02, 0x85, 0x00, 0x0f, 0xdf, 0x01, 0x06, 0x0f, 0x70, 0x06, +0x00, 0x10, 0x2c, 0x71, 0x06, 0x26, 0x69, 0x6e, 0x3d, 0x00, 0x53, 0x73, +0x20, 0x74, 0x6f, 0x6f, 0x1e, 0x05, 0x3f, 0x28, 0x20, 0x3e, 0x86, 0x00, +0x00, 0x10, 0x29, 0xc5, 0x03, 0x0c, 0xc3, 0x0a, 0x02, 0xe8, 0x00, 0x00, +0x16, 0x00, 0x05, 0xdb, 0x00, 0x0f, 0x27, 0x0a, 0x01, 0x00, 0x3e, 0x01, +0x05, 0xc2, 0x02, 0x10, 0x53, 0x6a, 0x0f, 0x2f, 0x61, 0x73, 0x73, 0x01, +0x04, 0x00, 0xf6, 0x0d, 0x11, 0x74, 0xb6, 0x01, 0x21, 0x77, 0x73, 0xbe, +0x09, 0x41, 0x65, 0x6c, 0x65, 0x63, 0x8c, 0x05, 0x81, 0x22, 0x61, 0x63, +0x63, 0x65, 0x6c, 0x65, 0x72, 0xcd, 0x01, 0x84, 0x22, 0x20, 0x66, 0x61, +0x63, 0x74, 0x6f, 0x72, 0xa3, 0x08, 0x12, 0x65, 0xbc, 0x00, 0x12, 0x72, +0x44, 0x11, 0x07, 0x29, 0x00, 0x02, 0x59, 0x01, 0x03, 0x80, 0x05, 0x02, +0xc5, 0x01, 0x01, 0x23, 0x00, 0x04, 0x24, 0x17, 0x04, 0x70, 0x00, 0x22, +0x73, 0x6f, 0xdf, 0x0f, 0x00, 0x56, 0x06, 0x19, 0x72, 0x30, 0x07, 0x01, +0xc4, 0x14, 0x02, 0x0a, 0x0a, 0x01, 0xf2, 0x09, 0xa0, 0x74, 0x72, 0x61, +0x64, 0x65, 0x2d, 0x6f, 0x66, 0x66, 0x2e, 0x1e, 0x05, 0x00, 0xcf, 0x0c, +0x31, 0x62, 0x65, 0x20, 0x2a, 0x04, 0x53, 0x74, 0x75, 0x6e, 0x65, 0x64, +0xb9, 0x16, 0x42, 0x65, 0x61, 0x63, 0x68, 0x7b, 0x0a, 0x20, 0x73, 0x73, +0xca, 0x05, 0x02, 0xe0, 0x01, 0x02, 0xc5, 0x02, 0x00, 0x7e, 0x05, 0x10, +0x72, 0x82, 0x06, 0x71, 0x6c, 0x79, 0x20, 0x2b, 0x7e, 0x33, 0x25, 0xe8, +0x00, 0x00, 0x0b, 0x0d, 0x03, 0xa4, 0x09, 0x1f, 0x6e, 0xc2, 0x00, 0x00, +0x00, 0x37, 0x07, 0x35, 0x22, 0x31, 0x22, 0x9a, 0x07, 0x03, 0x45, 0x01, +0x7f, 0x72, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x4d, 0x01, 0x04, 0x01, +0x4f, 0x00, 0x10, 0x56, 0x3f, 0x00, 0x10, 0x73, 0x3c, 0x07, 0x12, 0x30, +0x79, 0x06, 0x11, 0x62, 0x4a, 0x12, 0x20, 0x6c, 0x61, 0x60, 0x05, 0xb0, +0x62, 0x79, 0x20, 0x41, 0x43, 0x43, 0x45, 0x4c, 0x45, 0x52, 0x41, 0x8a, +0x13, 0xc1, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x20, 0x28, +0x73, 0x65, 0xc2, 0x10, 0x34, 0x2e, 0x63, 0x29, 0xeb, 0x07, 0x00, 0x81, +0x0d, 0x1f, 0x2e, 0x05, 0x02, 0x01, 0x01, 0xdf, 0x01, 0x1f, 0x20, 0xc6, +0x0c, 0x2d, 0x02, 0x11, 0x00, 0x08, 0xf9, 0x00, 0x00, 0x4a, 0x02, 0x0f, +0x4b, 0x02, 0x02, 0x9a, 0x5f, 0x65, 0x78, 0x74, 0x53, 0x74, 0x61, 0x74, +0x65, 0x54, 0x02, 0x0f, 0x52, 0x12, 0x01, 0x30, 0x2c, 0x20, 0x6a, 0xa2, +0x08, 0x22, 0x75, 0x73, 0x64, 0x07, 0x12, 0x20, 0xa6, 0x12, 0x38, 0x61, +0x6c, 0x6c, 0x68, 0x0c, 0x03, 0x2b, 0x04, 0x41, 0x73, 0x70, 0x61, 0x63, +0x89, 0x0e, 0x20, 0x73, 0x74, 0x8c, 0x0b, 0x0a, 0x71, 0x0b, 0x32, 0x61, +0x74, 0x65, 0x9e, 0x01, 0x22, 0x55, 0x73, 0x13, 0x06, 0x00, 0x38, 0x03, +0x24, 0x6f, 0x66, 0x87, 0x00, 0xf4, 0x01, 0x74, 0x6f, 0x20, 0x6b, 0x6e, +0x6f, 0x77, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x6d, 0x75, 0x63, 0x68, 0x54, +0x00, 0x06, 0x20, 0x09, 0x03, 0x6d, 0x00, 0x02, 0xcd, 0x0b, 0x00, 0xee, +0x07, 0x04, 0x13, 0x00, 0x92, 0x20, 0x69, 0x74, 0x20, 0x6f, 0x6e, 0x20, +0x38, 0x2d, 0x7a, 0x06, 0x10, 0x62, 0x53, 0x03, 0x20, 0x61, 0x72, 0x34, +0x11, 0x33, 0x28, 0x75, 0x73, 0xa9, 0x07, 0x30, 0x6c, 0x6f, 0x63, 0x65, +0x00, 0x40, 0x79, 0x70, 0x69, 0x63, 0xbc, 0x00, 0x15, 0x29, 0xf7, 0x02, +0x24, 0x6e, 0x2c, 0x19, 0x05, 0x00, 0x47, 0x00, 0x40, 0x61, 0x73, 0x20, +0x27, 0x9a, 0x10, 0x12, 0x2a, 0xb1, 0x00, 0x11, 0x27, 0x56, 0x0f, 0x0f, +0x16, 0x01, 0x00, 0x09, 0xc7, 0x01, 0x08, 0xc9, 0x00, 0x03, 0xd7, 0x10, +0x04, 0x4f, 0x0e, 0x0f, 0x76, 0x01, 0x03, 0x27, 0x20, 0x28, 0x64, 0x00, +0x2f, 0x2c, 0x20, 0xf8, 0x01, 0x11, 0x05, 0x1e, 0x04, 0x0f, 0xf7, 0x01, +0x25, 0x13, 0x64, 0x2f, 0x00, 0x05, 0xf2, 0x01, 0x10, 0x52, 0x96, 0x08, +0x12, 0x73, 0x03, 0x19, 0x60, 0x6c, 0x6f, 0x67, 0x69, 0x63, 0x2c, 0xcc, +0x02, 0x05, 0xed, 0x00, 0x00, 0xee, 0x01, 0x12, 0x73, 0x8a, 0x01, 0x01, +0xd6, 0x06, 0x52, 0x61, 0x73, 0x20, 0x70, 0x6f, 0xd1, 0x06, 0x02, 0x87, +0x0e, 0x0b, 0x93, 0x0c, 0x0f, 0x87, 0x0e, 0x09, 0x0a, 0xdc, 0x0b, 0x05, +0x87, 0x0e, 0x10, 0x74, 0x71, 0x04, 0x1b, 0x74, 0x8a, 0x0e, 0x0a, 0x2d, +0x0d, 0x21, 0x65, 0x69, 0x2e, 0x19, 0x16, 0x63, 0x16, 0x0f, 0x00, 0xaf, +0x00, 0x57, 0x65, 0x6e, 0x74, 0x69, 0x72, 0x15, 0x0d, 0x05, 0x7b, 0x0d, +0x00, 0x7f, 0x00, 0x03, 0x66, 0x00, 0x22, 0x69, 0x66, 0x61, 0x0e, 0x09, +0xb0, 0x0a, 0x13, 0x0a, 0xbf, 0x05, 0x10, 0x66, 0xc6, 0x03, 0x0a, 0x1d, +0x0f, 0x00, 0x63, 0x00, 0x20, 0x6c, 0x65, 0x0a, 0x0e, 0x02, 0x7f, 0x04, +0x0f, 0xfd, 0x00, 0x13, 0x06, 0xed, 0x09, 0x16, 0x2a, 0x9a, 0x03, 0x55, +0x50, 0x74, 0x72, 0x20, 0x3a, 0x2a, 0x04, 0x02, 0x73, 0x1b, 0x02, 0x4a, +0x0f, 0x41, 0x69, 0x6e, 0x64, 0x69, 0xb2, 0x02, 0x01, 0xe6, 0x02, 0x34, +0x61, 0x6e, 0x79, 0x0a, 0x0d, 0x42, 0x68, 0x65, 0x72, 0x65, 0xf2, 0x0d, +0x0a, 0x5c, 0x01, 0x28, 0x74, 0x6f, 0xac, 0x00, 0x0b, 0x5b, 0x0a, 0x08, +0x01, 0x00, 0x36, 0x4e, 0x65, 0x77, 0x02, 0x07, 0x0b, 0xf2, 0x0b, 0x23, +0x6f, 0x6c, 0x1e, 0x07, 0x1e, 0x2e, 0x09, 0x07, 0x2f, 0x4e, 0x62, 0x8d, +0x0d, 0x01, 0x0f, 0x86, 0x0d, 0x04, 0x0a, 0xb1, 0x01, 0x0f, 0x87, 0x0d, +0x17, 0x0e, 0xf3, 0x04, 0x06, 0x90, 0x02, 0x0f, 0xf7, 0x04, 0x12, 0x29, +0x2a, 0x20, 0x5e, 0x01, 0x02, 0xf3, 0x02, 0x0b, 0x8e, 0x00, 0x07, 0xf5, +0x02, 0x2f, 0x64, 0x65, 0x39, 0x07, 0x03, 0x8a, 0x6f, 0x72, 0x69, 0x67, +0x69, 0x6e, 0x61, 0x6c, 0xa4, 0x0d, 0x04, 0x16, 0x00, 0x04, 0x00, 0x10, +0x30, 0x72, 0x65, 0x66, 0xbe, 0x04, 0x27, 0x75, 0x6e, 0x5d, 0x0d, 0x00, +0xb1, 0x02, 0x0f, 0x90, 0x0d, 0x0f, 0x06, 0xc1, 0x01, 0x07, 0xd6, 0x0c, +0x04, 0x87, 0x0d, 0x23, 0x69, 0x6e, 0xfb, 0x1b, 0x6c, 0x77, 0x6f, 0x72, +0x64, 0x73, 0x2c, 0x52, 0x0e, 0x01, 0xcb, 0x09, 0x0f, 0x1e, 0x0d, 0x72, +0x1e, 0x44, 0x68, 0x0a, 0x0f, 0xa5, 0x0e, 0x07, 0x42, 0x20, 0x49, 0x74, +0x73, 0xcf, 0x03, 0x05, 0x24, 0x00, 0x42, 0x20, 0x6d, 0x69, 0x6e, 0x5d, +0x09, 0x38, 0x66, 0x20, 0x27, 0x73, 0x01, 0x03, 0xc6, 0x12, 0x02, 0x6f, +0x00, 0x10, 0x6e, 0x3a, 0x0a, 0x1b, 0x3a, 0xef, 0x03, 0x00, 0x73, 0x0f, +0x23, 0x79, 0x20, 0x5a, 0x18, 0x04, 0x02, 0x06, 0x07, 0xd0, 0x05, 0x00, +0x81, 0x0a, 0x20, 0x70, 0x72, 0x94, 0x18, 0x12, 0x6c, 0xd0, 0x1d, 0x2c, +0x65, 0x64, 0x99, 0x18, 0x2a, 0x2e, 0x0a, 0x7d, 0x0d, 0x00, 0xfe, 0x0a, +0x46, 0x20, 0x62, 0x69, 0x74, 0xbc, 0x08, 0x3f, 0x61, 0x6e, 0x20, 0x17, +0x10, 0x02, 0x09, 0x3a, 0x00, 0x30, 0x48, 0x6f, 0x77, 0x20, 0x05, 0x10, +0x2c, 0x15, 0x06, 0x32, 0x64, 0x6f, 0x65, 0xfc, 0x0e, 0x04, 0x29, 0x06, +0x00, 0xb9, 0x03, 0x03, 0x33, 0x0e, 0x01, 0xd9, 0x1d, 0x03, 0x34, 0x0e, +0x11, 0x69, 0x86, 0x04, 0x22, 0x69, 0x6f, 0x1e, 0x07, 0x05, 0xf8, 0x03, +0x01, 0x42, 0x04, 0x03, 0xbe, 0x01, 0x16, 0x28, 0x34, 0x0e, 0x01, 0xd2, +0x05, 0x0a, 0x75, 0x00, 0x00, 0x1a, 0x07, 0x1a, 0x74, 0x28, 0x0c, 0x60, +0x6e, 0x20, 0x74, 0x72, 0x75, 0x73, 0xed, 0x01, 0x71, 0x65, 0x6e, 0x76, +0x69, 0x72, 0x6f, 0x6e, 0xbe, 0x17, 0x61, 0x6f, 0x6e, 0x6c, 0x79, 0x20, +0x28, 0x59, 0x00, 0x22, 0x74, 0x6f, 0xe5, 0x01, 0x01, 0x4d, 0x02, 0x04, +0x23, 0x14, 0x15, 0x61, 0x36, 0x00, 0x02, 0x3d, 0x02, 0x19, 0x29, 0xb0, +0x06, 0x2f, 0x64, 0x65, 0x79, 0x08, 0x20, 0x08, 0xc9, 0x01, 0x2f, 0x29, +0x3b, 0x6b, 0x03, 0x01, 0x00, 0x46, 0x01, 0x13, 0x5f, 0x39, 0x12, 0x05, +0x73, 0x03, 0x0a, 0xcf, 0x05, 0x06, 0x2e, 0x00, 0x2d, 0x20, 0x61, 0x4f, +0x11, 0x06, 0x19, 0x06, 0x0a, 0x9e, 0x10, 0x10, 0x27, 0xcc, 0x1b, 0x01, +0xb8, 0x1b, 0x00, 0x43, 0x00, 0x0e, 0xf7, 0x14, 0x0e, 0xf4, 0x10, 0x0d, +0x6a, 0x06, 0x0f, 0xf4, 0x10, 0x00, 0x05, 0x6f, 0x06, 0x07, 0x38, 0x03, +0x11, 0x74, 0x65, 0x02, 0x26, 0x74, 0x6f, 0x3c, 0x03, 0x06, 0x0d, 0x07, +0x24, 0x6f, 0x70, 0x4e, 0x0a, 0x52, 0x61, 0x73, 0x20, 0x73, 0x6f, 0x08, +0x00, 0x03, 0xc3, 0x06, 0x06, 0x9b, 0x12, 0x90, 0x27, 0x20, 0x68, 0x61, +0x73, 0x20, 0x62, 0x65, 0x65, 0x3d, 0x14, 0x00, 0x3b, 0x17, 0x03, 0xaf, +0x08, 0x10, 0x72, 0xc9, 0x17, 0x01, 0x28, 0x20, 0x18, 0x65, 0x1f, 0x05, +0x00, 0x7a, 0x0d, 0x0f, 0xe8, 0x11, 0x14, 0x00, 0xb9, 0x0d, 0x04, 0x57, +0x20, 0x0f, 0xe5, 0x11, 0x2b, 0x12, 0x4e, 0x7a, 0x03, 0x01, 0x69, 0x02, +0x03, 0x6a, 0x00, 0x03, 0x84, 0x0b, 0x1f, 0x3c, 0xd1, 0x00, 0x01, 0x6f, +0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x01, 0x13, 0x02, 0x07, 0x7d, 0x02, +0x40, 0x62, 0x65, 0x20, 0x73, 0x67, 0x09, 0x2b, 0x65, 0x72, 0x4e, 0x04, +0x65, 0x41, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x80, 0x1c, 0x0c, 0xf9, 0x06, +0x00, 0xf8, 0x06, 0x03, 0xdf, 0x00, 0x0f, 0x1c, 0x12, 0x81, 0x0f, 0xbb, +0x11, 0x03, 0x1c, 0x66, 0xbe, 0x11, 0x00, 0x60, 0x00, 0x02, 0x2b, 0x00, +0x0a, 0xc4, 0x11, 0x2a, 0x6f, 0x66, 0xc7, 0x11, 0x03, 0x91, 0x04, 0x06, +0x65, 0x06, 0x0e, 0x79, 0x12, 0x0f, 0x55, 0x12, 0x03, 0x0e, 0xbf, 0x03, +0x0d, 0x73, 0x03, 0x0f, 0xab, 0x18, 0x27, 0x0c, 0xf4, 0x01, 0x0f, 0xc1, +0x18, 0x0a, 0x0e, 0x85, 0x12, 0x0f, 0xf3, 0x19, 0x11, 0x01, 0xbe, 0x01, +0x00, 0x8a, 0x01, 0x08, 0x69, 0x18, 0x0f, 0x9b, 0x12, 0x00, 0x0f, 0xa4, +0x12, 0x21, 0x60, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4d, 0x62, 0x0f, 0xdc, +0x5f, 0x55, 0x36, 0x34, 0x20, 0x28, 0x28, 0x31, 0x20, 0x3c, 0x3c, 0x20, +0x28, 0xa8, 0x1a, 0x30, 0x2d, 0x33, 0x29, 0x21, 0x12, 0x2f, 0x34, 0x29, +0x3d, 0x00, 0x04, 0x01, 0xfe, 0x01, 0x1f, 0x28, 0x51, 0x00, 0x00, 0x22, +0x2a, 0x20, 0xe1, 0x0b, 0x60, 0x28, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x05, +0x00, 0x27, 0x29, 0x29, 0x53, 0x1c, 0x02, 0x9a, 0x02, 0x11, 0x5f, 0x71, +0x1b, 0x20, 0x69, 0x6e, 0x92, 0x02, 0x02, 0x9a, 0x03, 0x81, 0x73, 0x74, +0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x11, 0x0d, 0x20, 0x74, 0x72, 0x52, +0x11, 0x02, 0x7a, 0x06, 0x03, 0xcc, 0x02, 0x01, 0x7d, 0x1f, 0x20, 0x69, +0x6d, 0xbe, 0x10, 0x30, 0x61, 0x6e, 0x74, 0x8f, 0x08, 0x32, 0x6e, 0x69, +0x74, 0x96, 0x03, 0x06, 0x3b, 0x00, 0x04, 0xda, 0x0a, 0x12, 0x62, 0x2f, +0x02, 0x31, 0x66, 0x69, 0x72, 0x8c, 0x0d, 0x30, 0x65, 0x20, 0x21, 0x3e, +0x00, 0x03, 0x44, 0x07, 0x29, 0x6f, 0x6e, 0x8d, 0x0d, 0x82, 0x64, 0x69, +0x72, 0x65, 0x63, 0x74, 0x6c, 0x79, 0x3f, 0x03, 0x05, 0x4b, 0x00, 0x12, +0x69, 0xe8, 0x1f, 0x00, 0xf4, 0x25, 0x00, 0x78, 0x0c, 0x02, 0x08, 0x0d, +0x53, 0x20, 0x6c, 0x69, 0x6e, 0x6b, 0xc3, 0x1f, 0x00, 0x52, 0x00, 0x06, +0x7c, 0x03, 0x04, 0x2c, 0x00, 0x02, 0x42, 0x0d, 0x60, 0x6c, 0x69, 0x62, +0x6c, 0x7a, 0x34, 0xf3, 0x04, 0x59, 0x61, 0x20, 0x44, 0x4c, 0x4c, 0xa7, +0x1f, 0x20, 0x62, 0x65, 0x21, 0x15, 0x01, 0x7d, 0x02, 0x00, 0x6c, 0x00, +0x01, 0x35, 0x13, 0x66, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0xb7, 0x1f, +0x00, 0x0f, 0x14, 0x73, 0x74, 0x79, 0x70, 0x65, 0x64, 0x65, 0x66, 0x93, +0x00, 0x35, 0x20, 0x7b, 0x20, 0x50, 0x01, 0x20, 0x20, 0x74, 0x63, 0x20, +0x1e, 0x5b, 0x7c, 0x01, 0x49, 0x5d, 0x3b, 0x20, 0x7d, 0x65, 0x01, 0x27, +0x3b, 0x0a, 0x7a, 0x01, 0x52, 0x72, 0x65, 0x73, 0x65, 0x74, 0x5b, 0x02, +0x00, 0x13, 0x00, 0x0e, 0x3e, 0x07, 0x22, 0x74, 0x6f, 0x55, 0x01, 0x27, +0x61, 0x6e, 0x1f, 0x01, 0x08, 0x4f, 0x00, 0x06, 0x1f, 0x01, 0x01, 0xa2, +0x00, 0x00, 0x96, 0x0d, 0x0c, 0x5a, 0x00, 0x28, 0x20, 0x28, 0x31, 0x00, +0x13, 0x2a, 0xbd, 0x01, 0x49, 0x50, 0x74, 0x72, 0x29, 0x8c, 0x00, 0x00, +0xde, 0x1d, 0x23, 0x74, 0x65, 0x33, 0x00, 0x01, 0x82, 0x04, 0x05, 0x9e, +0x0e, 0x00, 0x1d, 0x04, 0x00, 0x87, 0x00, 0x30, 0x69, 0x61, 0x6c, 0x8d, +0x06, 0x2f, 0x61, 0x6e, 0x83, 0x00, 0x07, 0x01, 0x1a, 0x00, 0x34, 0x66, +0x72, 0x65, 0x49, 0x00, 0x21, 0x72, 0x65, 0x67, 0x01, 0x11, 0x73, 0x26, +0x21, 0x02, 0x0f, 0x09, 0x02, 0xb4, 0x21, 0x02, 0x09, 0x06, 0x01, 0x1e, +0x02, 0x11, 0x78, 0x9d, 0x26, 0x01, 0x97, 0x01, 0x22, 0x20, 0x28, 0xa8, +0x01, 0x19, 0x29, 0xa0, 0x01, 0x55, 0x74, 0x68, 0x65, 0x73, 0x65, 0x93, +0x01, 0x44, 0x72, 0x61, 0x74, 0x68, 0x07, 0x09, 0x24, 0x74, 0x68, 0x0c, +0x02, 0x03, 0x86, 0x00, 0x01, 0x5d, 0x00, 0x41, 0x54, 0x68, 0x65, 0x79, +0xfb, 0x01, 0x01, 0x51, 0x1b, 0x42, 0x66, 0x75, 0x74, 0x75, 0xa9, 0x04, +0x20, 0x6f, 0x66, 0x19, 0x04, 0x01, 0x1b, 0x13, 0x02, 0x72, 0x00, 0x02, +0xf1, 0x20, 0x00, 0x0c, 0x00, 0x0a, 0xd1, 0x00, 0x32, 0x69, 0x7a, 0x65, +0xf2, 0x01, 0x0a, 0x3a, 0x01, 0x0c, 0x27, 0x01, 0x08, 0x2c, 0x0f, 0x06, +0x01, 0x00, 0x0b, 0x02, 0x01, 0x0f, 0x7e, 0x01, 0x13, 0x8f, 0x6c, 0x6f, +0x61, 0x64, 0x44, 0x69, 0x63, 0x74, 0x07, 0x02, 0x06, 0x00, 0x21, 0x00, +0x24, 0x20, 0x61, 0xed, 0x00, 0x21, 0x64, 0x69, 0x19, 0x00, 0x00, 0x86, +0x22, 0x01, 0x42, 0x08, 0x06, 0x64, 0x00, 0x01, 0x95, 0x03, 0x11, 0x41, +0xdf, 0x09, 0x26, 0x65, 0x76, 0x86, 0x05, 0x04, 0xcc, 0x0d, 0x50, 0x66, +0x6f, 0x72, 0x67, 0x6f, 0x27, 0x0d, 0x12, 0x2c, 0x75, 0x03, 0x16, 0x27, +0x4a, 0x00, 0x12, 0x27, 0x25, 0x00, 0x30, 0x72, 0x65, 0x6d, 0xe4, 0x28, +0x28, 0x69, 0x6e, 0xaf, 0x01, 0x32, 0x4c, 0x6f, 0x61, 0x87, 0x06, 0x05, +0x10, 0x1a, 0x12, 0x30, 0x96, 0x15, 0x31, 0x6c, 0x6f, 0x77, 0xf8, 0x06, +0x00, 0xea, 0x1f, 0x03, 0x00, 0x08, 0x07, 0x9c, 0x00, 0x13, 0x73, 0x8c, +0x05, 0x03, 0x2c, 0x07, 0x0c, 0xe4, 0x07, 0x50, 0x36, 0x34, 0x20, 0x4b, +0x42, 0x5d, 0x20, 0x06, 0x1b, 0x06, 0x04, 0x08, 0x01, 0x0f, 0x37, 0x01, +0x06, 0x0a, 0x6d, 0x10, 0x06, 0x6c, 0x00, 0x02, 0xf3, 0x05, 0x00, 0x10, +0x00, 0x07, 0xe0, 0x09, 0x2f, 0x20, 0x2a, 0xc4, 0x10, 0x00, 0x00, 0x74, +0x02, 0x31, 0x69, 0x6e, 0x75, 0xae, 0x02, 0x04, 0xcd, 0x05, 0x08, 0x65, +0x24, 0x00, 0xae, 0x04, 0x63, 0x27, 0x73, 0x72, 0x63, 0x27, 0x2c, 0x3b, +0x04, 0x01, 0x41, 0x01, 0x01, 0x96, 0x0a, 0x04, 0x54, 0x01, 0x2d, 0x6c, +0x79, 0x4a, 0x08, 0x10, 0x73, 0x5b, 0x04, 0x07, 0xfb, 0x00, 0x25, 0x74, +0x6f, 0xe3, 0x20, 0x0d, 0x19, 0x21, 0x02, 0x02, 0x03, 0x07, 0x39, 0x05, +0x19, 0x50, 0xac, 0x01, 0x04, 0x50, 0x00, 0x10, 0x72, 0xdf, 0x13, 0x33, +0x73, 0x75, 0x6d, 0xc4, 0x1e, 0x13, 0x74, 0xc3, 0x01, 0x00, 0x4c, 0x00, +0x00, 0xa4, 0x00, 0x01, 0x41, 0x2b, 0x15, 0x6e, 0xa5, 0x0b, 0x01, 0x50, +0x05, 0x27, 0x27, 0x64, 0x11, 0x10, 0x0f, 0x99, 0x1b, 0x09, 0x01, 0x36, +0x25, 0x00, 0x21, 0x07, 0x03, 0xc4, 0x0e, 0x0f, 0xbd, 0x16, 0x0a, 0x00, +0x74, 0x01, 0x0f, 0x5e, 0x1f, 0x0f, 0x02, 0x45, 0x08, 0x07, 0x24, 0x1f, +0x04, 0x67, 0x00, 0x32, 0x6e, 0x6f, 0x74, 0x1c, 0x00, 0x2d, 0x69, 0x66, +0x85, 0x25, 0x03, 0x13, 0x1f, 0x25, 0x66, 0x69, 0xfc, 0x10, 0x07, 0xc1, +0x00, 0x02, 0x3f, 0x02, 0x0d, 0xf6, 0x1e, 0x02, 0x4d, 0x00, 0x07, 0xe4, +0x1e, 0x00, 0x79, 0x02, 0x00, 0xd8, 0x05, 0x03, 0xe4, 0x1e, 0x07, 0x4f, +0x02, 0x0f, 0xfa, 0x01, 0x03, 0x0f, 0x5d, 0x02, 0x14, 0x35, 0x73, 0x72, +0x63, 0x7f, 0x08, 0x05, 0xbe, 0x14, 0x2a, 0x72, 0x63, 0x61, 0x08, 0x0f, +0xc3, 0x12, 0x09, 0x07, 0x63, 0x07, 0x34, 0x61, 0x76, 0x65, 0xdf, 0x03, +0x2f, 0x49, 0x66, 0x48, 0x02, 0x04, 0x06, 0xfd, 0x01, 0x04, 0xab, 0x1c, +0x0a, 0x68, 0x01, 0x03, 0x9a, 0x03, 0x51, 0x61, 0x76, 0x61, 0x69, 0x6c, +0xd2, 0x26, 0x27, 0x61, 0x74, 0x57, 0x05, 0x14, 0x20, 0xe5, 0x18, 0x00, +0x64, 0x00, 0x00, 0x70, 0x00, 0x14, 0x20, 0x54, 0x01, 0x20, 0x61, 0x20, +0x66, 0x09, 0x21, 0x72, 0x20, 0xf0, 0x15, 0x23, 0x20, 0x28, 0xdd, 0x00, +0x41, 0x61, 0x66, 0x65, 0x42, 0x67, 0x01, 0x01, 0xde, 0x23, 0x03, 0x53, +0x0b, 0x00, 0x34, 0x07, 0x55, 0x64, 0x6f, 0x6e, 0x27, 0x74, 0x4e, 0x27, +0x00, 0x65, 0x07, 0x09, 0x9a, 0x03, 0xa0, 0x28, 0x29, 0x20, 0x61, 0x66, +0x74, 0x65, 0x72, 0x77, 0x61, 0x05, 0x10, 0x07, 0x73, 0x07, 0x08, 0x94, +0x04, 0x27, 0x73, 0x20, 0x99, 0x20, 0x00, 0xf6, 0x23, 0x63, 0x62, 0x6c, +0x65, 0x2c, 0x20, 0x79, 0xed, 0x28, 0x06, 0x3e, 0x0a, 0x05, 0x5e, 0x00, +0x0f, 0xa9, 0x01, 0x03, 0x29, 0x28, 0x29, 0x5a, 0x04, 0x00, 0xd6, 0x00, +0x1c, 0x64, 0x60, 0x04, 0x0f, 0x5f, 0x04, 0x07, 0x05, 0x0d, 0x04, 0x15, +0x2c, 0xda, 0x11, 0x01, 0xcd, 0x1d, 0x09, 0x22, 0x02, 0x04, 0x9a, 0x01, +0x0f, 0x71, 0x04, 0x09, 0x0b, 0x31, 0x01, 0x0e, 0x6b, 0x04, 0x0e, 0x53, +0x0a, 0x0f, 0x54, 0x0a, 0x1b, 0x06, 0xa7, 0x0a, 0x0f, 0x56, 0x0a, 0x2a, +0x00, 0x63, 0x1d, 0x0e, 0x1b, 0x0a, 0x65, 0x44, 0x45, 0x43, 0x4f, 0x44, +0x45, 0x0d, 0x0a, 0x2f, 0x20, 0x34, 0x24, 0x00, 0x0a, 0x0c, 0x45, 0x0a, +0x0b, 0x3e, 0x00, 0x05, 0x4b, 0x0a, 0x04, 0xe3, 0x1c, 0x18, 0x20, 0x54, +0x0a, 0x0d, 0x21, 0x09, 0x0e, 0x26, 0x00, 0x0d, 0x2a, 0x09, 0x0a, 0x61, +0x00, 0x0b, 0x30, 0x09, 0x11, 0x44, 0x59, 0x0d, 0x00, 0x36, 0x09, 0x0c, +0xaf, 0x0a, 0x04, 0x1a, 0x00, 0x0f, 0xb5, 0x0a, 0x23, 0x0f, 0xa9, 0x0a, +0x08, 0x23, 0x75, 0x73, 0x4e, 0x0a, 0x15, 0x5f, 0x42, 0x09, 0x02, 0x6c, +0x00, 0x12, 0x20, 0xde, 0x1c, 0x20, 0x73, 0x65, 0x03, 0x03, 0x0f, 0xcf, +0x0a, 0x02, 0x0f, 0xd9, 0x08, 0x11, 0x04, 0xd8, 0x08, 0x30, 0x70, 0x72, +0x65, 0x94, 0x03, 0x02, 0x11, 0x27, 0x2f, 0x6f, 0x66, 0x7e, 0x0a, 0x03, +0x01, 0x99, 0x0a, 0x0f, 0xd3, 0x08, 0x2f, 0x04, 0x2c, 0x01, 0x05, 0x30, +0x03, 0x24, 0x74, 0x68, 0x44, 0x00, 0x1f, 0x2e, 0xff, 0x09, 0x01, 0x03, +0xf0, 0x00, 0x0f, 0x05, 0x0a, 0x17, 0x06, 0x61, 0x00, 0x0f, 0x0b, 0x0a, +0x07, 0x03, 0x55, 0x00, 0x0f, 0x11, 0x0a, 0x04, 0x2e, 0x2f, 0x0a, 0x4e, +0x00, 0x0f, 0x99, 0x00, 0x05, 0x0e, 0x77, 0x09, 0x0f, 0x7d, 0x09, 0x05, +0x03, 0x74, 0x00, 0x1f, 0x28, 0x5c, 0x00, 0x05, 0x02, 0x14, 0x00, 0x0b, +0xab, 0x05, 0x0a, 0xf6, 0x01, 0x0f, 0x98, 0x0b, 0x08, 0x03, 0xe6, 0x02, +0x02, 0xfb, 0x16, 0x01, 0xe8, 0x16, 0x03, 0x7f, 0x25, 0x06, 0xa2, 0x04, +0x01, 0x5f, 0x01, 0x12, 0x53, 0x14, 0x26, 0x0f, 0x3d, 0x09, 0x04, 0x21, +0x20, 0x28, 0xc9, 0x1b, 0x02, 0xf4, 0x28, 0x02, 0xd0, 0x1b, 0x4a, 0x73, +0x65, 0x74, 0x29, 0x54, 0x09, 0x10, 0x31, 0xbd, 0x04, 0x3f, 0x4f, 0x4b, +0x2c, 0xc6, 0x04, 0x06, 0x2f, 0x65, 0x74, 0xf2, 0x00, 0x19, 0x02, 0x14, +0x00, 0x0f, 0x4b, 0x09, 0x1a, 0x17, 0x2a, 0x95, 0x05, 0x05, 0x1a, 0x13, +0x00, 0x97, 0x0b, 0x05, 0xa3, 0x10, 0x05, 0xc2, 0x2d, 0x02, 0xda, 0x00, +0x0b, 0x29, 0x12, 0x80, 0x6f, 0x66, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, +0x39, 0x29, 0x03, 0xe1, 0x08, 0x54, 0x69, 0x6e, 0x20, 0x22, 0x73, 0x04, +0x05, 0x10, 0x22, 0x6f, 0x14, 0x03, 0x4b, 0x12, 0x16, 0x50, 0x1f, 0x07, +0x04, 0x39, 0x12, 0x03, 0x64, 0x09, 0x10, 0x2a, 0xd4, 0x08, 0x1f, 0x2a, +0x0a, 0x07, 0x02, 0x01, 0x0d, 0x21, 0x02, 0x0a, 0x07, 0x05, 0x6b, 0x13, +0x03, 0x9b, 0x01, 0x00, 0x3c, 0x03, 0x08, 0xa8, 0x11, 0x40, 0x20, 0x28, +0x75, 0x70, 0xb1, 0x01, 0x04, 0x80, 0x0a, 0x25, 0x20, 0x20, 0xb7, 0x03, +0x05, 0x48, 0x03, 0x10, 0x72, 0xd3, 0x00, 0x02, 0x88, 0x08, 0x17, 0x73, +0x26, 0x24, 0x0b, 0x5b, 0x09, 0x03, 0xde, 0x19, 0x02, 0x10, 0x01, 0x51, +0x2d, 0x20, 0x45, 0x78, 0x61, 0xb8, 0x0e, 0x01, 0xd2, 0x01, 0x01, 0x3a, +0x25, 0x59, 0x61, 0x73, 0x20, 0x65, 0x6e, 0x3c, 0x00, 0x03, 0x1d, 0x1e, +0x01, 0x23, 0x00, 0x30, 0x75, 0x70, 0x64, 0x5b, 0x03, 0x62, 0x72, 0x75, +0x6c, 0x65, 0x20, 0x28, 0xfa, 0x07, 0x07, 0x2c, 0x16, 0x22, 0x61, 0x74, +0x26, 0x00, 0x04, 0xcf, 0x00, 0x14, 0x73, 0x01, 0x13, 0x23, 0x49, 0x6e, +0x90, 0x1d, 0x00, 0xaf, 0x00, 0x02, 0x3c, 0x12, 0x05, 0x86, 0x01, 0x16, +0x26, 0x70, 0x00, 0x07, 0xc3, 0x00, 0x01, 0x77, 0x07, 0x32, 0x68, 0x61, +0x76, 0xfa, 0x15, 0x04, 0x97, 0x0b, 0x04, 0x07, 0x24, 0x42, 0x76, 0x65, +0x72, 0x79, 0xfd, 0x12, 0x30, 0x20, 0x6f, 0x6e, 0x49, 0x07, 0x23, 0x20, +0x3c, 0x1c, 0x01, 0x13, 0x2e, 0xd9, 0x00, 0x14, 0x4c, 0x5a, 0x1f, 0x2e, +0x61, 0x6e, 0xd0, 0x00, 0x2a, 0x62, 0x79, 0x33, 0x17, 0x40, 0x6d, 0x61, +0x78, 0x42, 0xcc, 0x00, 0x01, 0x59, 0x0a, 0x01, 0xb0, 0x04, 0x07, 0x36, +0x17, 0x1a, 0x20, 0x1f, 0x00, 0x01, 0x2a, 0x08, 0x36, 0x70, 0x6c, 0x65, +0x65, 0x34, 0x30, 0x64, 0x65, 0x70, 0x4b, 0x29, 0x32, 0x6e, 0x74, 0x2e, +0x6e, 0x1f, 0x0d, 0xe5, 0x22, 0x00, 0x46, 0x08, 0x01, 0xa9, 0x16, 0x18, +0x64, 0xdc, 0x1c, 0x05, 0xeb, 0x08, 0x34, 0x69, 0x6e, 0x67, 0x63, 0x02, +0x1f, 0x2e, 0x30, 0x01, 0x03, 0x27, 0x65, 0x6e, 0x55, 0x13, 0x0b, 0xda, +0x01, 0x41, 0x73, 0x20, 0x64, 0x6f, 0x7b, 0x09, 0x04, 0x00, 0x09, 0x00, +0x17, 0x14, 0x94, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, +0x0d, 0x15, 0x02, 0xbe, 0x1d, 0x0f, 0x69, 0x01, 0x1f, 0x0f, 0x64, 0x01, +0x0a, 0x40, 0x5f, 0x41, 0x74, 0x20, 0x1c, 0x05, 0x22, 0x74, 0x5f, 0x19, +0x00, 0x43, 0x20, 0x2b, 0x20, 0x38, 0xda, 0x08, 0x19, 0x2b, 0x35, 0x01, +0x0f, 0xd7, 0x00, 0x7e, 0x17, 0x6c, 0x1e, 0x02, 0x0b, 0x79, 0x00, 0x02, +0xac, 0x00, 0x32, 0x57, 0x68, 0x65, 0x5d, 0x14, 0x02, 0xca, 0x0f, 0x0a, +0x8c, 0x37, 0x02, 0x99, 0x18, 0x03, 0x9d, 0x1c, 0x12, 0x2c, 0xbb, 0x0a, +0x01, 0xd3, 0x1d, 0x00, 0xda, 0x17, 0x00, 0x90, 0x2e, 0x02, 0x7f, 0x28, +0x02, 0xba, 0x03, 0x01, 0x24, 0x0b, 0x07, 0xd6, 0x0a, 0x04, 0x85, 0x02, +0x05, 0x53, 0x1f, 0x05, 0xa1, 0x1c, 0x02, 0xfc, 0x03, 0x11, 0x69, 0xaf, +0x14, 0x02, 0x39, 0x0a, 0x0f, 0xda, 0x07, 0x06, 0x2f, 0x28, 0x29, 0x9e, +0x14, 0x09, 0x0e, 0x36, 0x0c, 0x0f, 0x55, 0x05, 0x0b, 0x0f, 0x70, 0x2d, +0x3b, 0x0f, 0xf3, 0x18, 0x04, 0x0f, 0x96, 0x00, 0x42, 0x0c, 0x22, 0x19, +0x00, 0xf8, 0x05, 0x05, 0x87, 0x27, 0x0f, 0xe8, 0x05, 0x00, 0x41, 0x3a, +0x0a, 0x2a, 0x5f, 0x55, 0x01, 0x03, 0x18, 0x0c, 0x0f, 0x17, 0x06, 0x0c, +0x48, 0x77, 0x6f, 0x72, 0x6b, 0xba, 0x22, 0x02, 0xb4, 0x01, 0x00, 0x0c, +0x01, 0x14, 0x62, 0x0d, 0x18, 0x2f, 0x6f, 0x66, 0xa0, 0x01, 0x03, 0x03, +0xa8, 0x38, 0x02, 0xae, 0x22, 0x0b, 0x0f, 0x01, 0x19, 0x78, 0x2f, 0x0c, +0x26, 0x20, 0x20, 0x2c, 0x09, 0xc2, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x2d, +0x61, 0x6c, 0x6f, 0x6e, 0x65, 0x2e, 0x16, 0x00, 0x07, 0xdc, 0x0c, 0x00, +0xb0, 0x28, 0x03, 0x80, 0x05, 0x0f, 0xcc, 0x08, 0x0c, 0x1f, 0x2e, 0x1e, +0x02, 0x09, 0x05, 0x00, 0x01, 0x0f, 0x69, 0x2f, 0x3a, 0x0e, 0x9b, 0x07, +0x5d, 0x53, 0x74, 0x61, 0x72, 0x74, 0x9a, 0x07, 0x0f, 0x1e, 0x02, 0x05, +0x0e, 0x96, 0x00, 0x0f, 0x1b, 0x1b, 0x12, 0x0f, 0x7b, 0x00, 0x19, 0x0f, +0xce, 0x29, 0x1b, 0x40, 0x4f, 0x62, 0x73, 0x6f, 0x9d, 0x20, 0x0f, 0xce, +0x29, 0x20, 0x10, 0x2f, 0x07, 0x32, 0x00, 0xd3, 0x2c, 0x00, 0xab, 0x01, +0x30, 0x57, 0x61, 0x72, 0x43, 0x33, 0x22, 0x73, 0x20, 0x19, 0x00, 0x15, +0x53, 0xdb, 0x19, 0x44, 0x73, 0x65, 0x20, 0x77, 0x1c, 0x00, 0x10, 0x6d, +0x06, 0x0e, 0x00, 0xc9, 0x34, 0x01, 0xcd, 0x1d, 0x71, 0x70, 0x72, 0x6f, +0x62, 0x6c, 0x65, 0x6d, 0x23, 0x04, 0x02, 0x0f, 0x04, 0x02, 0x22, 0x36, +0x00, 0x3d, 0x16, 0x05, 0x14, 0x21, 0x00, 0x08, 0x1a, 0x11, 0x69, 0xa7, +0x0e, 0x00, 0x4d, 0x00, 0x02, 0x2d, 0x00, 0x01, 0xa8, 0x07, 0x64, 0x2d, +0x57, 0x6e, 0x6f, 0x2d, 0x64, 0x80, 0x00, 0x72, 0x64, 0x2d, 0x64, 0x65, +0x63, 0x6c, 0x61, 0xe3, 0x0f, 0x02, 0xce, 0x1d, 0x42, 0x67, 0x63, 0x63, +0x0a, 0x3c, 0x20, 0x70, 0x5f, 0x43, 0x52, 0x54, 0x5f, 0x53, 0x45, 0x2f, +0x39, 0xc0, 0x5f, 0x4e, 0x4f, 0x5f, 0x57, 0x41, 0x52, 0x4e, 0x49, 0x4e, +0x47, 0x53, 0xe8, 0x08, 0x68, 0x56, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x7f, +0x28, 0x18, 0x2e, 0xfe, 0x37, 0x01, 0x7c, 0x26, 0x07, 0x95, 0x0d, 0x94, +0x44, 0x45, 0x50, 0x52, 0x45, 0x43, 0x41, 0x54, 0x45, 0x45, 0x00, 0x00, +0x95, 0x25, 0x61, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x2e, 0x97, 0x2a, 0x30, +0x69, 0x66, 0x6e, 0x67, 0x0d, 0x0f, 0x2b, 0x00, 0x0b, 0x3e, 0x0a, 0x23, +0x20, 0x54, 0x00, 0x0f, 0x29, 0x00, 0x10, 0x34, 0x47, 0x43, 0x43, 0x04, +0x35, 0x00, 0xe0, 0x37, 0x92, 0x47, 0x4e, 0x55, 0x43, 0x5f, 0x5f, 0x20, +0x2a, 0x20, 0x22, 0x35, 0x03, 0x11, 0x00, 0x01, 0x36, 0x35, 0x30, 0x5f, +0x5f, 0x29, 0x3c, 0x00, 0x4c, 0x69, 0x66, 0x20, 0x28, 0x39, 0x00, 0xa4, +0x3e, 0x3d, 0x20, 0x34, 0x30, 0x35, 0x29, 0x20, 0x7c, 0x7c, 0x2c, 0x38, +0x00, 0x2b, 0x38, 0x43, 0x6c, 0x61, 0x6e, 0x67, 0x35, 0x00, 0x0f, 0x9c, +0x00, 0x03, 0x23, 0x44, 0x28, 0xbc, 0x01, 0x62, 0x29, 0x20, 0x5f, 0x5f, +0x61, 0x74, 0x42, 0x3c, 0x56, 0x65, 0x5f, 0x5f, 0x28, 0x28, 0x83, 0x01, +0x05, 0x23, 0x00, 0x11, 0x29, 0x49, 0x00, 0x2f, 0x65, 0x6c, 0x80, 0x00, +0x04, 0x3f, 0x33, 0x30, 0x31, 0x6a, 0x00, 0x2c, 0x07, 0x61, 0x00, 0x05, +0xc5, 0x00, 0x21, 0x4d, 0x53, 0x65, 0x00, 0x0f, 0x5a, 0x00, 0x15, 0x00, +0x2f, 0x02, 0x00, 0x0c, 0x20, 0x0f, 0xc0, 0x00, 0x02, 0x02, 0x5e, 0x00, +0x22, 0x73, 0x65, 0x4c, 0x00, 0x03, 0x65, 0x39, 0x03, 0x1e, 0x00, 0x23, +0x28, 0x22, 0xa7, 0x01, 0x37, 0x3a, 0x20, 0x59, 0xdd, 0x38, 0x05, 0x2d, +0x09, 0x0b, 0x74, 0x00, 0x02, 0x35, 0x37, 0x00, 0xa4, 0x0c, 0x02, 0x18, +0x2b, 0x3f, 0x65, 0x72, 0x22, 0xa3, 0x00, 0x12, 0x01, 0x83, 0x00, 0x01, +0xa9, 0x39, 0x02, 0xb0, 0x39, 0x00, 0x0d, 0x2d, 0x0f, 0x2e, 0x02, 0x0b, +0x12, 0x20, 0xc1, 0x38, 0x06, 0xd2, 0x03, 0x0f, 0xc6, 0x39, 0x02, 0x03, +0xa0, 0x03, 0x02, 0x0c, 0x06, 0x07, 0x1a, 0x0c, 0x00, 0xb6, 0x0e, 0x44, +0x6c, 0x61, 0x6e, 0x6e, 0xd4, 0x14, 0x36, 0x61, 0x72, 0x74, 0xb1, 0x39, +0x05, 0xc1, 0x03, 0xf2, 0x01, 0x62, 0x79, 0x20, 0x72, 0x31, 0x33, 0x31, +0x20, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x6d, 0x47, 0x12, 0x0f, +0xd8, 0x13, 0x00, 0x0b, 0xfe, 0x0d, 0x0f, 0x81, 0x28, 0x1c, 0x0f, 0xe7, +0x26, 0x01, 0x03, 0x7f, 0x33, 0x02, 0x4c, 0x1c, 0x0f, 0xd2, 0x28, 0x26, +0x07, 0xeb, 0x31, 0x0f, 0x64, 0x00, 0x00, 0x00, 0x59, 0x04, 0x02, 0x47, +0x27, 0x0b, 0xbf, 0x00, 0x0f, 0x55, 0x27, 0x27, 0x0f, 0xcb, 0x00, 0x0e, +0x07, 0x75, 0x00, 0x0f, 0xbc, 0x27, 0x31, 0x0f, 0xe1, 0x00, 0x0b, 0x05, +0x9d, 0x08, 0x0c, 0xe1, 0x00, 0x0e, 0x50, 0x19, 0x0e, 0x7c, 0x15, 0x0f, +0xf1, 0x00, 0x35, 0x06, 0x85, 0x00, 0x0f, 0x77, 0x00, 0x38, 0x0f, 0x01, +0x01, 0x03, 0x09, 0x10, 0x03, 0x2f, 0x64, 0x65, 0x12, 0x03, 0x17, 0x30, +0x20, 0x6e, 0x61, 0xf3, 0x22, 0x13, 0x61, 0x6c, 0x2a, 0x03, 0xbf, 0x27, +0x06, 0x2c, 0x04, 0x01, 0xd3, 0x0a, 0x01, 0x6d, 0x0e, 0x21, 0x6e, 0x6f, +0x3f, 0x13, 0x41, 0x65, 0x72, 0x20, 0x62, 0x15, 0x1b, 0x02, 0x6d, 0x20, +0x05, 0xeb, 0x08, 0x01, 0xcd, 0x19, 0x05, 0x20, 0x2f, 0x01, 0xfb, 0x0a, +0x04, 0x25, 0x2f, 0x31, 0x61, 0x74, 0x69, 0x83, 0x3b, 0x03, 0x17, 0x28, +0x20, 0x6f, 0x6c, 0x0d, 0x44, 0x03, 0x43, 0x3d, 0x15, 0x73, 0xe1, 0x0d, +0x36, 0x5a, 0x34, 0x5f, 0x30, 0x26, 0x0c, 0x63, 0x2c, 0x0f, 0x63, 0x08, +0x00, 0x0f, 0x38, 0x00, 0x02, 0x30, 0x5f, 0x75, 0x6e, 0x03, 0x2b, 0x16, +0x6e, 0x1d, 0x01, 0x0f, 0x4a, 0x00, 0x0c, 0x00, 0x43, 0x09, 0x03, 0xc8, +0x00, 0x08, 0x16, 0x01, 0x00, 0x55, 0x20, 0x10, 0x6f, 0x4d, 0x14, 0x04, +0x21, 0x0c, 0x14, 0x77, 0x9e, 0x07, 0x22, 0x64, 0x3b, 0xd7, 0x26, 0x01, +0x03, 0x05, 0x00, 0xaa, 0x07, 0x02, 0xfa, 0x00, 0x03, 0x1b, 0x1e, 0x21, +0x72, 0x65, 0xd6, 0x07, 0x02, 0x2d, 0x05, 0x20, 0x68, 0x65, 0xed, 0x13, +0x04, 0x43, 0x25, 0x21, 0x68, 0x69, 0x6c, 0x2d, 0x08, 0xac, 0x37, 0x04, +0x27, 0x23, 0x02, 0x18, 0x0c, 0x02, 0x44, 0x08, 0x08, 0x7a, 0x00, 0x00, +0x7b, 0x01, 0x21, 0x69, 0x67, 0x9a, 0x04, 0x30, 0x74, 0x6f, 0x20, 0x72, +0x10, 0x21, 0x74, 0x61, 0xf6, 0x3e, 0x01, 0xc1, 0x0d, 0x02, 0xcf, 0x01, +0x04, 0x84, 0x02, 0x07, 0x3c, 0x01, 0x0f, 0x72, 0x09, 0x13, 0x07, 0x3f, +0x02, 0x0e, 0x4b, 0x00, 0x0f, 0x4f, 0x01, 0x01, 0x0f, 0x6c, 0x28, 0x17, +0x3f, 0x20, 0x69, 0x73, 0xaa, 0x02, 0x05, 0x0d, 0xbd, 0x05, 0x05, 0x80, +0x11, 0x06, 0xa8, 0x0b, 0x11, 0x3b, 0xd0, 0x14, 0x00, 0xd7, 0x3d, 0x06, +0x1d, 0x00, 0x06, 0x24, 0x3e, 0x14, 0x77, 0xcb, 0x0d, 0x05, 0x3b, 0x09, +0x03, 0xbc, 0x13, 0x07, 0x5d, 0x06, 0x11, 0x22, 0x30, 0x46, 0x0c, 0x2d, +0x1d, 0x14, 0x29, 0x4d, 0x1f, 0x32, 0x22, 0x29, 0x20, 0x82, 0x04, 0x06, +0xdf, 0x13, 0x04, 0x96, 0x18, 0x01, 0x68, 0x03, 0x03, 0x97, 0x18, 0x1f, +0x3b, 0x57, 0x00, 0x1f, 0x02, 0x12, 0x14, 0x08, 0xd2, 0x2c, 0x00, 0x23, +0x00, 0x09, 0xd8, 0x2c, 0x0f, 0x54, 0x00, 0x05, 0x07, 0x31, 0x1f, 0x09, +0x53, 0x00, 0x07, 0x54, 0x00, 0x07, 0x23, 0x00, 0x06, 0x53, 0x00, 0x06, +0x48, 0x05, 0x0f, 0xc1, 0x00, 0x18, 0x04, 0x75, 0x18, 0x0a, 0x6a, 0x00, +0x23, 0x20, 0x20, 0x45, 0x00, 0x01, 0x23, 0x00, 0x56, 0x6c, 0x69, 0x64, +0x65, 0x49, 0x4e, 0x00, 0x09, 0xb6, 0x05, 0x2f, 0x29, 0x3b, 0xc6, 0x01, +0x05, 0x0f, 0x77, 0x0d, 0x00, 0x0f, 0xa0, 0x01, 0x03, 0x0f, 0xcd, 0x0c, +0x0b, 0x0d, 0x56, 0x01, 0x0f, 0xfb, 0x0c, 0x01, 0x00, 0x4f, 0x04, 0xbf, +0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x36, 0x34, 0x6b, 0x20, 0x28, 0x3b, +0x1b, 0x0d, 0x0f, 0xfb, 0x0c, 0x05, 0x05, 0xfe, 0x2a, 0x0f, 0xa6, 0x00, +0x10, 0x0a, 0xdd, 0x0c, 0x0f, 0xa6, 0x00, 0x0d, 0x01, 0x2e, 0x00, 0x0f, +0xa6, 0x00, 0x1c, 0x0d, 0x04, 0x0f, 0x0f, 0xef, 0x42, 0x07, 0x90, 0x7d, +0x0a, 0x23, 0x65, 0x6e, 0x64, 0x69, 0x66, 0x0a, +}; + +static unsigned char buf[18830]; + +int main() { + + unsigned long cksum = adler32(0, NULL, 0); + + decompress_lz4(compressed, buf, 18830); + cksum = adler32(cksum, buf, 18830); + + return cksum == 0xf748269d ? 0 : 1; +} From ee49ecdf432fd17a706032530cc2e3b34f0074c8 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 6 Jun 2017 19:31:16 +0300 Subject: [PATCH 123/199] Expand tabs to spaces in lz4.s --- libsrc/common/lz4.s | 328 ++++++++++++++++++++++---------------------- 1 file changed, 164 insertions(+), 164 deletions(-) diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s index ee215d4da..5a07a42ed 100644 --- a/libsrc/common/lz4.s +++ b/libsrc/common/lz4.s @@ -4,11 +4,11 @@ ; An optimized LZ4 decompressor ; - .importzp sp, sreg, regsave, regbank - .importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 - .macpack longbranch - .import memcpy_upwards,pushax,popax - .export _decompress_lz4 + .importzp sp, sreg, regsave, regbank + .importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 + .macpack longbranch + .import memcpy_upwards,pushax,popax + .export _decompress_lz4 _out = regsave _written = regsave + 2 @@ -22,262 +22,262 @@ _outlen = ptr4 ; void decompress_lz4 (const u8 *in, u8 * const out, const u16 outlen) ; --------------------------------------------------------------- -.segment "CODE" +.segment "CODE" -.proc _decompress_lz4: near +.proc _decompress_lz4: near - sta _outlen - stx _outlen+1 + sta _outlen + stx _outlen+1 - jsr popax - sta _out - stx _out+1 + jsr popax + sta _out + stx _out+1 - jsr popax - sta _in - stx _in+1 + jsr popax + sta _in + stx _in+1 ; ; written = 0; ; - lda #$00 - sta _written + lda #$00 + sta _written ; ; while (written < outlen) { ; - jmp L0046 + jmp L0046 ; ; token = *in++; ; -L0004: ldy #0 - lda (_in),y - sta _token +L0004: ldy #0 + lda (_in),y + sta _token - inc _in - bne L000A - inc _in+1 + inc _in + bne L000A + inc _in+1 L000A: ; ; offset = token >> 4; ; - ldx #$00 - lsr a - lsr a - lsr a - lsr a - sta _offset - stx _offset+1 + ldx #$00 + lsr a + lsr a + lsr a + lsr a + sta _offset + stx _offset+1 ; ; token &= 0xf; ; token += 4; // Minmatch ; - lda _token - and #$0F - clc - adc #4 - sta _token + lda _token + and #$0F + clc + adc #4 + sta _token ; ; if (offset == 15) { ; - lda _offset - cmp #$0F -L0013: bne L001A + lda _offset + cmp #$0F +L0013: bne L001A ; ; tmp = *in++; ; - ldy #0 - lda (_in),y - sta _tmp + ldy #0 + lda (_in),y + sta _tmp - inc _in - bne L0017 - inc _in+1 + inc _in + bne L0017 + inc _in+1 L0017: ; ; offset += tmp; ; - clc - adc _offset - sta _offset - lda #$00 - adc _offset+1 - sta _offset+1 + clc + adc _offset + sta _offset + lda #$00 + adc _offset+1 + sta _offset+1 ; ; if (tmp == 255) ; - lda _tmp - cmp #$FF + lda _tmp + cmp #$FF ; ; goto moreliterals; ; - jmp L0013 + jmp L0013 ; ; if (offset) { ; -L001A: lda _offset - ora _offset+1 - beq L001C +L001A: lda _offset + ora _offset+1 + beq L001C ; ; memcpy(&out[written], in, offset); ; - lda _out - clc - adc _written - sta ptr2 - lda _out+1 - adc _written+1 - tax - lda ptr2 - stx ptr2+1 - jsr pushax - lda _in - ldx _in+1 - sta ptr1 - stx ptr1+1 - ldy #0 - jsr memcpy_upwards + lda _out + clc + adc _written + sta ptr2 + lda _out+1 + adc _written+1 + tax + lda ptr2 + stx ptr2+1 + jsr pushax + lda _in + ldx _in+1 + sta ptr1 + stx ptr1+1 + ldy #0 + jsr memcpy_upwards ; ; written += offset; ; - lda _offset - clc - adc _written - sta _written - lda _offset+1 - adc _written+1 - sta _written+1 + lda _offset + clc + adc _written + sta _written + lda _offset+1 + adc _written+1 + sta _written+1 ; ; in += offset; ; - lda _offset - clc - adc _in - sta _in - lda _offset+1 - adc _in+1 - sta _in+1 + lda _offset + clc + adc _in + sta _in + lda _offset+1 + adc _in+1 + sta _in+1 ; ; if (written >= outlen) ; -L001C: lda _written - cmp _outlen - lda _written+1 - sbc _outlen+1 +L001C: lda _written + cmp _outlen + lda _written+1 + sbc _outlen+1 ; ; return; ; - bcc L0047 - rts + bcc L0047 + rts ; ; memcpy(&offset, in, 2); ; -L0047: ldy #0 - lda (_in),y - sta _offset - iny - lda (_in),y - sta _offset+1 +L0047: ldy #0 + lda (_in),y + sta _offset + iny + lda (_in),y + sta _offset+1 ; ; in += 2; ; - lda #$02 - clc - adc _in - sta _in - bcc L002F - inc _in+1 + lda #$02 + clc + adc _in + sta _in + bcc L002F + inc _in+1 ; ; copysrc = out + written - offset; ; -L002F: lda _out - clc - adc _written - pha - lda _out+1 - adc _written+1 - tax - pla - sec - sbc _offset - sta ptr1 - txa - sbc _offset+1 - sta ptr1+1 +L002F: lda _out + clc + adc _written + pha + lda _out+1 + adc _written+1 + tax + pla + sec + sbc _offset + sta ptr1 + txa + sbc _offset+1 + sta ptr1+1 ; ; offset = token; ; - lda #$00 - sta _offset+1 - lda _token - sta _offset + lda #$00 + sta _offset+1 + lda _token + sta _offset ; ; if (token == 19) { ; - cmp #$13 -L0045: bne L003C + cmp #$13 +L0045: bne L003C ; ; tmp = *in++; ; - ldy #0 - lda (_in),y - sta _tmp + ldy #0 + lda (_in),y + sta _tmp - inc _in - bne L0039 - inc _in+1 + inc _in + bne L0039 + inc _in+1 L0039: ; ; offset += tmp; ; - clc - adc _offset - sta _offset - tya - adc _offset+1 - sta _offset+1 + clc + adc _offset + sta _offset + tya + adc _offset+1 + sta _offset+1 ; ; if (tmp == 255) ; - lda _tmp - cmp #$FF + lda _tmp + cmp #$FF ; ; goto morematches; ; - jmp L0045 + jmp L0045 ; ; memcpy(&out[written], copysrc, offset); ; -L003C: lda _out - clc - adc _written - sta ptr2 - lda _out+1 - adc _written+1 - tax - lda ptr2 - stx ptr2+1 - jsr pushax - jsr memcpy_upwards +L003C: lda _out + clc + adc _written + sta ptr2 + lda _out+1 + adc _written+1 + tax + lda ptr2 + stx ptr2+1 + jsr pushax + jsr memcpy_upwards ; ; written += offset; ; - lda _offset - clc - adc _written - sta _written - lda _offset+1 - adc _written+1 -L0046: sta _written+1 + lda _offset + clc + adc _written + sta _written + lda _offset+1 + adc _written+1 +L0046: sta _written+1 ; ; while (written < outlen) { ; - lda _written - cmp _outlen - lda _written+1 - sbc _outlen+1 - jcc L0004 + lda _written + cmp _outlen + lda _written+1 + sbc _outlen+1 + jcc L0004 - rts + rts .endproc From a397a8c1a18a51e8c2bc7ac7a4d70e7599a75b36 Mon Sep 17 00:00:00 2001 From: greg-king5 <greg.king5@verizon.net> Date: Wed, 7 Jun 2017 10:20:20 -0400 Subject: [PATCH 124/199] Added missing -O configuration. --- test/val/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/val/Makefile b/test/val/Makefile index c7539c81b..fe194d892 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -31,7 +31,7 @@ SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ../../testwrk/val -OPTIONS = g O Os Osi Osir Oi Oir Or +OPTIONS = g O Os Osi Osir Osr Oi Oir Or .PHONY: all clean From e24bb372d0e54201da8905d15ccf81e0c99cb890 Mon Sep 17 00:00:00 2001 From: greg-king5 <greg.king5@verizon.net> Date: Wed, 7 Jun 2017 10:26:34 -0400 Subject: [PATCH 125/199] Added a missing -O configuration. --- test/ref/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ref/Makefile b/test/ref/Makefile index c986513b8..3c2e582e4 100644 --- a/test/ref/Makefile +++ b/test/ref/Makefile @@ -33,7 +33,7 @@ SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ..$S..$Stestwrk$Sref -OPTIONS = g O Os Osi Osir Oi Oir Or +OPTIONS = g O Os Osi Osir Osr Oi Oir Or DIFF = $(WORKDIR)$Sbdiff$(EXE) From 06c3cd830747c0049ada4a5a0eef2b1ad3fd29e7 Mon Sep 17 00:00:00 2001 From: greg-king5 <greg.king5@verizon.net> Date: Wed, 7 Jun 2017 10:31:09 -0400 Subject: [PATCH 126/199] Added a missing -O configuration. --- test/misc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/misc/Makefile b/test/misc/Makefile index 39a9a3868..330c9d500 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -35,7 +35,7 @@ SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ..$S..$Stestwrk$Smisc -OPTIONS = g O Os Osi Osir Oi Oir Or +OPTIONS = g O Os Osi Osir Osr Oi Oir Or DIFF = $(WORKDIR)$Sbdiff$(EXE) From e85796e028b152c68c7451c4bc73a06aa6be3749 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 9 Jun 2017 10:35:16 +0300 Subject: [PATCH 127/199] Edit comment style, add second const --- include/lz4.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/lz4.h b/include/lz4.h index d6bf1b17c..fd11c3e2a 100644 --- a/include/lz4.h +++ b/include/lz4.h @@ -32,12 +32,11 @@ #ifndef _LZ4_H #define _LZ4_H -void __fastcall__ decompress_lz4 (const unsigned char* src, unsigned char* dst, +void __fastcall__ decompress_lz4 (const unsigned char* src, unsigned char* const dst, const unsigned short uncompressed_size); -/* - Decompresses the source buffer into the destination buffer. - The size of the decompressed data must be known in advance, LZ4 - does not include any terminator in-stream. +/* Decompresses the source buffer into the destination buffer. +** The size of the decompressed data must be known in advance, LZ4 +** does not include any terminator in-stream. */ /* end of lz4.h */ From cd460a81602851655dc83543a94609118dae976f Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 9 Jun 2017 10:37:50 +0300 Subject: [PATCH 128/199] Remove _ from internal vars --- libsrc/common/lz4.s | 190 ++++++++++++++++++++++---------------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s index 5a07a42ed..922cb2eba 100644 --- a/libsrc/common/lz4.s +++ b/libsrc/common/lz4.s @@ -10,13 +10,13 @@ .import memcpy_upwards,pushax,popax .export _decompress_lz4 -_out = regsave -_written = regsave + 2 -_tmp = tmp1 -_token = tmp2 -_offset = ptr3 -_in = sreg -_outlen = ptr4 +out = regsave +written = regsave + 2 +tmp = tmp1 +token = tmp2 +offset = ptr3 +in = sreg +outlen = ptr4 ; --------------------------------------------------------------- ; void decompress_lz4 (const u8 *in, u8 * const out, const u16 outlen) @@ -26,22 +26,22 @@ _outlen = ptr4 .proc _decompress_lz4: near - sta _outlen - stx _outlen+1 + sta outlen + stx outlen+1 jsr popax - sta _out - stx _out+1 + sta out + stx out+1 jsr popax - sta _in - stx _in+1 + sta in + stx in+1 ; ; written = 0; ; lda #$00 - sta _written + sta written ; ; while (written < outlen) { ; @@ -50,12 +50,12 @@ _outlen = ptr4 ; token = *in++; ; L0004: ldy #0 - lda (_in),y - sta _token + lda (in),y + sta token - inc _in + inc in bne L000A - inc _in+1 + inc in+1 L000A: ; ; offset = token >> 4; @@ -65,47 +65,47 @@ L000A: lsr a lsr a lsr a - sta _offset - stx _offset+1 + sta offset + stx offset+1 ; ; token &= 0xf; ; token += 4; // Minmatch ; - lda _token + lda token and #$0F clc adc #4 - sta _token + sta token ; ; if (offset == 15) { ; - lda _offset + lda offset cmp #$0F L0013: bne L001A ; ; tmp = *in++; ; ldy #0 - lda (_in),y - sta _tmp + lda (in),y + sta tmp - inc _in + inc in bne L0017 - inc _in+1 + inc in+1 L0017: ; ; offset += tmp; ; clc - adc _offset - sta _offset + adc offset + sta offset lda #$00 - adc _offset+1 - sta _offset+1 + adc offset+1 + sta offset+1 ; ; if (tmp == 255) ; - lda _tmp + lda tmp cmp #$FF ; ; goto moreliterals; @@ -114,24 +114,24 @@ L0017: ; ; if (offset) { ; -L001A: lda _offset - ora _offset+1 +L001A: lda offset + ora offset+1 beq L001C ; ; memcpy(&out[written], in, offset); ; - lda _out + lda out clc - adc _written + adc written sta ptr2 - lda _out+1 - adc _written+1 + lda out+1 + adc written+1 tax lda ptr2 stx ptr2+1 jsr pushax - lda _in - ldx _in+1 + lda in + ldx in+1 sta ptr1 stx ptr1+1 ldy #0 @@ -139,30 +139,30 @@ L001A: lda _offset ; ; written += offset; ; - lda _offset + lda offset clc - adc _written - sta _written - lda _offset+1 - adc _written+1 - sta _written+1 + adc written + sta written + lda offset+1 + adc written+1 + sta written+1 ; ; in += offset; ; - lda _offset + lda offset clc - adc _in - sta _in - lda _offset+1 - adc _in+1 - sta _in+1 + adc in + sta in + lda offset+1 + adc in+1 + sta in+1 ; ; if (written >= outlen) ; -L001C: lda _written - cmp _outlen - lda _written+1 - sbc _outlen+1 +L001C: lda written + cmp outlen + lda written+1 + sbc outlen+1 ; ; return; ; @@ -172,44 +172,44 @@ L001C: lda _written ; memcpy(&offset, in, 2); ; L0047: ldy #0 - lda (_in),y - sta _offset + lda (in),y + sta offset iny - lda (_in),y - sta _offset+1 + lda (in),y + sta offset+1 ; ; in += 2; ; lda #$02 clc - adc _in - sta _in + adc in + sta in bcc L002F - inc _in+1 + inc in+1 ; ; copysrc = out + written - offset; ; -L002F: lda _out +L002F: lda out clc - adc _written + adc written pha - lda _out+1 - adc _written+1 + lda out+1 + adc written+1 tax pla sec - sbc _offset + sbc offset sta ptr1 txa - sbc _offset+1 + sbc offset+1 sta ptr1+1 ; ; offset = token; ; lda #$00 - sta _offset+1 - lda _token - sta _offset + sta offset+1 + lda token + sta offset ; ; if (token == 19) { ; @@ -219,26 +219,26 @@ L0045: bne L003C ; tmp = *in++; ; ldy #0 - lda (_in),y - sta _tmp + lda (in),y + sta tmp - inc _in + inc in bne L0039 - inc _in+1 + inc in+1 L0039: ; ; offset += tmp; ; clc - adc _offset - sta _offset + adc offset + sta offset tya - adc _offset+1 - sta _offset+1 + adc offset+1 + sta offset+1 ; ; if (tmp == 255) ; - lda _tmp + lda tmp cmp #$FF ; ; goto morematches; @@ -247,12 +247,12 @@ L0039: ; ; memcpy(&out[written], copysrc, offset); ; -L003C: lda _out +L003C: lda out clc - adc _written + adc written sta ptr2 - lda _out+1 - adc _written+1 + lda out+1 + adc written+1 tax lda ptr2 stx ptr2+1 @@ -261,20 +261,20 @@ L003C: lda _out ; ; written += offset; ; - lda _offset + lda offset clc - adc _written - sta _written - lda _offset+1 - adc _written+1 -L0046: sta _written+1 + adc written + sta written + lda offset+1 + adc written+1 +L0046: sta written+1 ; ; while (written < outlen) { ; - lda _written - cmp _outlen - lda _written+1 - sbc _outlen+1 + lda written + cmp outlen + lda written+1 + sbc outlen+1 jcc L0004 rts From bba961e54deb382509425ec5544e68f59ed036c3 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 9 Jun 2017 10:40:17 +0300 Subject: [PATCH 129/199] Use hex immediates --- libsrc/common/lz4.s | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s index 922cb2eba..4901d1a3c 100644 --- a/libsrc/common/lz4.s +++ b/libsrc/common/lz4.s @@ -49,7 +49,7 @@ outlen = ptr4 ; ; token = *in++; ; -L0004: ldy #0 +L0004: ldy #$00 lda (in),y sta token @@ -74,7 +74,7 @@ L000A: lda token and #$0F clc - adc #4 + adc #$04 sta token ; ; if (offset == 15) { @@ -85,7 +85,7 @@ L0013: bne L001A ; ; tmp = *in++; ; - ldy #0 + ldy #$00 lda (in),y sta tmp @@ -134,7 +134,7 @@ L001A: lda offset ldx in+1 sta ptr1 stx ptr1+1 - ldy #0 + ldy #$00 jsr memcpy_upwards ; ; written += offset; @@ -171,7 +171,7 @@ L001C: lda written ; ; memcpy(&offset, in, 2); ; -L0047: ldy #0 +L0047: ldy #$00 lda (in),y sta offset iny @@ -218,7 +218,7 @@ L0045: bne L003C ; ; tmp = *in++; ; - ldy #0 + ldy #$00 lda (in),y sta tmp From c444ed5e4fbda9c011d5b2502ba4fabd9e37628c Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 9 Jun 2017 10:42:24 +0300 Subject: [PATCH 130/199] Mention the optimizations in a comment --- libsrc/common/lz4.s | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s index 4901d1a3c..a750f4bf8 100644 --- a/libsrc/common/lz4.s +++ b/libsrc/common/lz4.s @@ -2,6 +2,9 @@ ; Lauri Kasanen, 6 Jun 2017 ; (C) Mega Cat Studios ; An optimized LZ4 decompressor +; +; Almost 7 times faster, uses no RAM (vs 14 bytes BSS), and takes 1/4 the space +; vs the official C source. ; .importzp sp, sreg, regsave, regbank From 135041ac3cc809a1cc38e4567a559bdcf0f0c1dc Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 9 Jun 2017 10:54:50 +0300 Subject: [PATCH 131/199] Add lz4 doc --- doc/funcref.sgml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index d160082bf..3e74b2785 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -398,6 +398,13 @@ function. (incomplete) +<sect1><tt/lz4.h/<label id="lz4.h"><p> + +<itemize> +<item><ref id="decompress_lz4" name="decompress_lz4"> +</itemize> + + <sect1><tt/modload.h/<label id="modload.h"><p> <itemize> @@ -2632,6 +2639,23 @@ used in presence of a prototype. </quote> +<sect1>decompress_lz4<label id="decompress_lz4"><p> + +<quote> +<descrip> +<tag/Function/Uncompress a LZ4-compressed buffer. +<tag/Header/<tt/<ref id="lz4.h" name="lz4.h">/ +<tag/Declaration/<tt/void decompress_lz4 (const unsigned char* src, unsigned char* const dst, const unsigned short uncompressed_size);/ +<tag/Description/<tt/decompress_lz4/ uncompresses a LZ4-compressed buffer. +<tag/Notes/<itemize> +<item>Use LZ4_compress_HC with compression level 16 for best compression. +</itemize> +<tag/Availability/cc65 +<tag/Example/None. +</descrip> +</quote> + + <sect1>div<label id="div"><p> <quote> From 4235e569d20cf64e52a26267149f4cf4ca1d4c89 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 9 Jun 2017 16:57:47 +0300 Subject: [PATCH 132/199] Small lz4 optimizations --- libsrc/common/lz4.s | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s index a750f4bf8..4702137bc 100644 --- a/libsrc/common/lz4.s +++ b/libsrc/common/lz4.s @@ -137,7 +137,7 @@ L001A: lda offset ldx in+1 sta ptr1 stx ptr1+1 - ldy #$00 +; ldy #$00 - not needed as pushax zeroes Y jsr memcpy_upwards ; ; written += offset; @@ -195,11 +195,11 @@ L0047: ldy #$00 L002F: lda out clc adc written - pha + tay lda out+1 adc written+1 tax - pla + tya sec sbc offset sta ptr1 From 30f941ba39def8d3e3e654f3e9f6fc9dd5eadac6 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Thu, 15 Jun 2017 16:44:46 -0400 Subject: [PATCH 133/199] Added a missing label to some conio cursor movement functions. It had prevented other functions, e.g. cputs(), from being linked into a program. --- libsrc/atmos/gotoxy.s | 10 ++++++---- libsrc/creativision/gotoxy.s | 8 ++++++-- libsrc/gamate/gotoxy.s | 6 ++---- libsrc/telestrat/gotoxy.s | 35 +++++++++++++++++++++-------------- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/libsrc/atmos/gotoxy.s b/libsrc/atmos/gotoxy.s index 80d4d5251..6652c9419 100644 --- a/libsrc/atmos/gotoxy.s +++ b/libsrc/atmos/gotoxy.s @@ -1,14 +1,18 @@ ; -; Ullrich von Bassewitz, 2003-04-13 +; 2003-04-13, Ullrich von Bassewitz +; 2017-06-15, Greg King ; ; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy + .export gotoxy, _gotoxy + .import popa .include "atmos.inc" +gotoxy: jsr popa ; Get Y + .proc _gotoxy sta CURS_Y ; Set Y @@ -17,5 +21,3 @@ rts .endproc - - diff --git a/libsrc/creativision/gotoxy.s b/libsrc/creativision/gotoxy.s index 12ce0abea..588dd83a0 100644 --- a/libsrc/creativision/gotoxy.s +++ b/libsrc/creativision/gotoxy.s @@ -1,15 +1,19 @@ ; -; Ullrich von Bassewitz, 06.08.1998 +; 1998-08-06, Ullrich von Bassewitz +; 2017-06-15, Greg King ; ; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy + .export gotoxy, _gotoxy + .import setcursor .import popa .include "creativision.inc" +gotoxy: jsr popa ; Get Y + .proc _gotoxy sta CURSOR_Y ; Set Y diff --git a/libsrc/gamate/gotoxy.s b/libsrc/gamate/gotoxy.s index 4a4871444..d49bd2967 100644 --- a/libsrc/gamate/gotoxy.s +++ b/libsrc/gamate/gotoxy.s @@ -9,7 +9,7 @@ .include "extzp.inc" gotoxy: - jsr popa ; Get X + jsr popa ; Get Y _gotoxy: sta CURS_Y ; Set Y @@ -20,6 +20,4 @@ _gotoxy: ;------------------------------------------------------------------------------- ; force the init constructor to be imported - .import initconio -conio_init = initconio - + .forceimport initconio diff --git a/libsrc/telestrat/gotoxy.s b/libsrc/telestrat/gotoxy.s index e0c8154e3..e1470f848 100644 --- a/libsrc/telestrat/gotoxy.s +++ b/libsrc/telestrat/gotoxy.s @@ -1,19 +1,26 @@ ; -; jede jede@oric.org 2017-02-25 +; 2017-02-25, jede <jede@oric.org> +; 2017-06-15, Greg King +; +; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy - - .import popa - - .importzp sp - .include "telestrat.inc" + .export gotoxy, _gotoxy + + .import popa + .importzp sp + + .include "telestrat.inc" + +gotoxy: jsr popa ; Get Y .proc _gotoxy - ; This function move only cursor for display, it does not move the prompt position - ; in telemon, there is position for prompt, and another for the cursor - sta SCRY - jsr popa - sta SCRX - rts -.endproc + +; This function moves only the display cursor; it does not move the prompt position. +; In telemon, there is a position for the prompt, and another for the cursor. + + sta SCRY + jsr popa + sta SCRX + rts +.endproc From 035621aa95e2be6a6f5f0fc091e9fc4c7df2047d Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sat, 17 Jun 2017 02:26:54 +0200 Subject: [PATCH 134/199] fixed code a bit so it compiles again :) --- libsrc/c128/waitvblank.s | 15 ++++----------- libsrc/c64/waitvblank.s | 15 ++++----------- libsrc/cbm510/waitvblank.s | 27 ++++++++------------------- libsrc/vic20/waitvblank.s | 7 ++++++- 4 files changed, 22 insertions(+), 42 deletions(-) diff --git a/libsrc/c128/waitvblank.s b/libsrc/c128/waitvblank.s index a3904d858..54699286c 100644 --- a/libsrc/c128/waitvblank.s +++ b/libsrc/c128/waitvblank.s @@ -1,20 +1,13 @@ .export _waitvblank - .include "c128/c128.inc" + .include "c128.inc" _waitvblank: - lda PALFLAG - beq @ntsc - ldx #(312-24)-256 - .byte $2c -@ntsc: - ldx #(262-4)-256 @l1: lda VIC_CTRL1 - and #$80 - beq @l1 + bpl @l1 @l2: - cpx VIC_HLINE - bcs @l2 + lda VIC_CTRL1 + bmi @l2 rts diff --git a/libsrc/c64/waitvblank.s b/libsrc/c64/waitvblank.s index 09570f873..606f41681 100644 --- a/libsrc/c64/waitvblank.s +++ b/libsrc/c64/waitvblank.s @@ -1,20 +1,13 @@ .export _waitvblank - .include "c64/c64.inc" + .include "c64.inc" _waitvblank: - lda PALFLAG - beq @ntsc - ldx #(312-24)-256 - .byte $2c -@ntsc: - ldx #(262-4)-256 @l1: lda VIC_CTRL1 - and #$80 - beq @l1 + bpl @l1 @l2: - cpx VIC_HLINE - bcs @l2 + lda VIC_CTRL1 + bmi @l2 rts diff --git a/libsrc/cbm510/waitvblank.s b/libsrc/cbm510/waitvblank.s index 30cbf072f..975861f2c 100644 --- a/libsrc/cbm510/waitvblank.s +++ b/libsrc/cbm510/waitvblank.s @@ -5,33 +5,22 @@ .importzp vic - .include "cbm510/cbm510.inc" + .include "cbm510.inc" _waitvblank: rts ; FIXME jsr sys_bank ; Switch to the system bank - lda PALFLAG - beq ntsc - ldx #(312-24)-256 - .byte $2c -ntsc: - ldx #(262-2)-256 - sei - ldy #VIC_CTRL1 -l1: - lda (vic),y - and #$80 - beq l1 -;?!? -; ldy #VIC_HLINE -; txa -;l2: -; cmp (vic),y -; bcs l2 + ldy #VIC_CTRL1 +@l1: + lda (vic),y + bpl @l1 +@l2: + lda (vic),y + bmi @l2 cli jmp restore_bank diff --git a/libsrc/vic20/waitvblank.s b/libsrc/vic20/waitvblank.s index b99c74bed..246c44640 100644 --- a/libsrc/vic20/waitvblank.s +++ b/libsrc/vic20/waitvblank.s @@ -1,6 +1,11 @@ .export _waitvblank - .include "vic20/vic20.inc" + .include "vic20.inc" + +; FIXME +; this flag doesnt work on vic20!!! +; it will have to be filled by a get_tv() constructor or so +PALFLAG = $2A6 ; $01 = PAL, $00 = NTSC _waitvblank: lda PALFLAG From a42feca228d589e3d3ae3bb80da7c668c1db028f Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sat, 17 Jun 2017 02:37:34 +0200 Subject: [PATCH 135/199] fixed some stuff, compiles again :) --- asminc/c128.inc | 4 ++++ asminc/c64.inc | 3 +++ asminc/pet.inc | 5 +++++ asminc/plus4.inc | 5 +++++ asminc/vic20.inc | 3 +++ libsrc/c128/kbrepeat.s | 2 +- libsrc/c64/kbrepeat.s | 2 +- libsrc/pet/kbrepeat.s | 2 +- libsrc/plus4/kbrepeat.s | 2 +- libsrc/vic20/kbrepeat.s | 2 +- 10 files changed, 25 insertions(+), 5 deletions(-) diff --git a/asminc/c128.inc b/asminc/c128.inc index e6c89b07b..9e9acc5a8 100644 --- a/asminc/c128.inc +++ b/asminc/c128.inc @@ -38,6 +38,10 @@ INIT_STATUS := $A04 ; Flags: Reset/Restore initiation status FKEY_LEN := $1000 ; Function key lengths FKEY_TEXT := $100A ; Function key texts +KBDREPEAT := $28a +KBDREPEATRATE := $28b +KBDREPEATDELAY := $28c + ; --------------------------------------------------------------------------- ; Kernal routines diff --git a/asminc/c64.inc b/asminc/c64.inc index ababb1ea0..00b66a64f 100644 --- a/asminc/c64.inc +++ b/asminc/c64.inc @@ -33,6 +33,9 @@ CHARCOLOR := $286 CURS_COLOR := $287 ; Color under the cursor PALFLAG := $2A6 ; $01 = PAL, $00 = NTSC +KBDREPEAT := $28a +KBDREPEATRATE := $28b +KBDREPEATDELAY := $28c ; --------------------------------------------------------------------------- ; Kernal routines diff --git a/asminc/pet.inc b/asminc/pet.inc index a745a89c8..ea6eef2e0 100644 --- a/asminc/pet.inc +++ b/asminc/pet.inc @@ -31,6 +31,11 @@ BASIC_BUF_LEN = 81 ; Maximum length of command-line KEY_BUF := $26F ; Keyboard buffer +;FIXME: these are wrong? +KBDREPEAT := $28a +KBDREPEATRATE := $28b +KBDREPEATDELAY := $28c + ;---------------------------------------------------------------------------- ; PET ROM type detection diff --git a/asminc/plus4.inc b/asminc/plus4.inc index 69b2298a3..42ed314bd 100644 --- a/asminc/plus4.inc +++ b/asminc/plus4.inc @@ -33,6 +33,11 @@ FKEY_COUNT := $55D ; Characters for function key FKEY_SPACE := $55F ; Function key definitions FKEY_ORIG := $F3D2 ; Original definitions +;FIXME: he?! these ok? :o) +KBDREPEAT := $28a +KBDREPEATRATE := $28b +KBDREPEATDELAY := $28c + ; --------------------------------------------------------------------------- ; Kernal routines diff --git a/asminc/vic20.inc b/asminc/vic20.inc index 12424dc11..d882eb1ad 100644 --- a/asminc/vic20.inc +++ b/asminc/vic20.inc @@ -31,6 +31,9 @@ BASIC_BUF_LEN = 89 ; Maximum length of command-line CHARCOLOR := $286 CURS_COLOR := $287 ; Color under the cursor +KBDREPEAT := $28a +KBDREPEATRATE := $28b +KBDREPEATDELAY := $28c ; --------------------------------------------------------------------------- ; Screen size diff --git a/libsrc/c128/kbrepeat.s b/libsrc/c128/kbrepeat.s index f515e4ca3..c32e8c017 100644 --- a/libsrc/c128/kbrepeat.s +++ b/libsrc/c128/kbrepeat.s @@ -1,7 +1,7 @@ .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate - .include "c128/c128.inc" + .include "c128.inc" _kbrepeat: ldx KBDREPEAT ; get old value diff --git a/libsrc/c64/kbrepeat.s b/libsrc/c64/kbrepeat.s index b6c33250b..f59c8a6da 100644 --- a/libsrc/c64/kbrepeat.s +++ b/libsrc/c64/kbrepeat.s @@ -1,7 +1,7 @@ .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate - .include "c64/c64.inc" + .include "c64.inc" _kbrepeat: ldx KBDREPEAT ; get old value diff --git a/libsrc/pet/kbrepeat.s b/libsrc/pet/kbrepeat.s index 44d60575f..0a29d7420 100644 --- a/libsrc/pet/kbrepeat.s +++ b/libsrc/pet/kbrepeat.s @@ -1,7 +1,7 @@ .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate - .include "pet/pet.inc" + .include "pet.inc" _kbrepeat: ldx KBDREPEAT ; get old value diff --git a/libsrc/plus4/kbrepeat.s b/libsrc/plus4/kbrepeat.s index 8636d0e33..927b99e5b 100644 --- a/libsrc/plus4/kbrepeat.s +++ b/libsrc/plus4/kbrepeat.s @@ -1,7 +1,7 @@ .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate - .include "plus4/plus4.inc" + .include "plus4.inc" _kbrepeat: ldx KBDREPEAT ; get old value diff --git a/libsrc/vic20/kbrepeat.s b/libsrc/vic20/kbrepeat.s index 5a4ad96f6..5115c852e 100644 --- a/libsrc/vic20/kbrepeat.s +++ b/libsrc/vic20/kbrepeat.s @@ -1,7 +1,7 @@ .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate - .include "vic20/vic20.inc" + .include "vic20.inc" _kbrepeat: ldx KBDREPEAT ; get old value From d3ccc289c1a09d290e77935c13ac94972b18ca4c Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Fri, 16 Jun 2017 21:53:50 -0400 Subject: [PATCH 136/199] Stopped cc65 from putting redundant .segment directives into its Assembly output. --- src/cc65/compile.c | 25 +++++++++++++++---------- src/cc65/pragma.c | 20 ++++++++++++++++---- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 3c1042154..d79ef350b 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -243,19 +243,20 @@ static void Parse (void) } Entry->Flags &= ~(SC_STORAGE | SC_DEF); } else { - /* A global (including static) uninitialized variable - ** is only a tentative definition. For example, this is valid: + /* A global (including static) uninitialized variable is + ** only a tentative definition. For example, this is valid: ** int i; ** int i; ** static int j; ** static int j = 42; - ** Code for these will be generated in FinishCompile. + ** Code for them will be generated by FinishCompile(). ** For now, just save the BSS segment name - ** (can be set with #pragma bss-name) + ** (can be set by #pragma bss-name). */ const char* bssName = GetSegName (SEG_BSS); + if (Entry->V.BssName && strcmp (Entry->V.BssName, bssName) != 0) { - Error ("Global variable `%s' has already been defined in `%s' segment", + Error ("Global variable `%s' already was defined in the `%s' segment.", Entry->Name, Entry->V.BssName); } Entry->V.BssName = xstrdup (bssName); @@ -419,7 +420,7 @@ void FinishCompile (void) SymEntry* Entry; /* Walk over all global symbols: - ** - for functions do cleanup, optimizations ... + ** - for functions, do clean-up and optimizations ** - generate code for uninitialized global variables */ for (Entry = GetGlobalSymTab ()->SymHead; Entry; Entry = Entry->NextSym) { @@ -429,13 +430,17 @@ void FinishCompile (void) CS_MergeLabels (Entry->V.F.Seg->Code); RunOpt (Entry->V.F.Seg->Code); } else if ((Entry->Flags & (SC_STORAGE | SC_DEF | SC_STATIC)) == (SC_STORAGE | SC_STATIC)) { - /* Tentative definition of uninitialized global variable */ + /* Assembly definition of uninitialized global variable */ + + /* Set the segment name only when it changes */ + if (strcmp (GetSegName (SEG_BSS), Entry->V.BssName) != 0) { + SetSegName (SEG_BSS, Entry->V.BssName); + g_segname (SEG_BSS); + } g_usebss (); - SetSegName (SEG_BSS, Entry->V.BssName); - g_segname (SEG_BSS); /* TODO: skip if same as before */ g_defgloblabel (Entry->Name); g_res (SizeOf (Entry->Type)); - /* Mark as defined, so that it will be exported not imported */ + /* Mark as defined; so that it will be exported, not imported */ Entry->Flags |= SC_DEF; } } diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 3dfc62668..de1979c12 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -386,11 +386,11 @@ static void StringPragma (StrBuf* B, void (*Func) (const char*)) static void SegNamePragma (StrBuf* B, segment_t Seg) /* Handle a pragma that expects a segment name parameter */ { - StrBuf S = AUTO_STRBUF_INITIALIZER; const char* Name; + StrBuf S = AUTO_STRBUF_INITIALIZER; + int Push = 0; /* Check for the "push" or "pop" keywords */ - int Push = 0; switch (ParsePushPop (B)) { case PP_NONE: @@ -403,7 +403,13 @@ static void SegNamePragma (StrBuf* B, segment_t Seg) case PP_POP: /* Pop the old value and output it */ PopSegName (Seg); - g_segname (Seg); + + /* BSS variables are output at the end of the compilation. Don't + ** bother to change their segment, now. + */ + if (Seg != SEG_BSS) { + g_segname (Seg); + } /* Done */ goto ExitPoint; @@ -434,7 +440,13 @@ static void SegNamePragma (StrBuf* B, segment_t Seg) } else { SetSegName (Seg, Name); } - g_segname (Seg); + + /* BSS variables are output at the end of the compilation. Don't + ** bother to change their segment, now. + */ + if (Seg != SEG_BSS) { + g_segname (Seg); + } } else { From 49aad01bf105fb731270a964c6130c3f52165c0d Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Wed, 21 Jun 2017 23:18:00 +0200 Subject: [PATCH 137/199] dont trash akku if possible, use VDC register when in 80column mode --- libsrc/c128/waitvblank.s | 16 ++++++++++++++-- libsrc/c64/waitvblank.s | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libsrc/c128/waitvblank.s b/libsrc/c128/waitvblank.s index 54699286c..e0a469d0e 100644 --- a/libsrc/c128/waitvblank.s +++ b/libsrc/c128/waitvblank.s @@ -4,10 +4,22 @@ .include "c128.inc" _waitvblank: + + lda MODE + bmi @c80 + @l1: - lda VIC_CTRL1 + bit VIC_CTRL1 bpl @l1 @l2: - lda VIC_CTRL1 + bit VIC_CTRL1 bmi @l2 rts + +@c80: + ;FIXME: do we have to switch banks? +@l3: + lda VDC_INDEX + and #$20 + beq @l3 + rts diff --git a/libsrc/c64/waitvblank.s b/libsrc/c64/waitvblank.s index 606f41681..dd9087841 100644 --- a/libsrc/c64/waitvblank.s +++ b/libsrc/c64/waitvblank.s @@ -5,9 +5,9 @@ _waitvblank: @l1: - lda VIC_CTRL1 + bit VIC_CTRL1 bpl @l1 @l2: - lda VIC_CTRL1 + bit VIC_CTRL1 bmi @l2 rts From e985e0beb424f0146c1755aa8d7a310ebb90783b Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Thu, 22 Jun 2017 00:04:42 +0200 Subject: [PATCH 138/199] fixed zp locations provided by polluks :) --- asminc/pet.inc | 15 +++++++++++---- asminc/plus4.inc | 7 +++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/asminc/pet.inc b/asminc/pet.inc index ea6eef2e0..8f2f469e0 100644 --- a/asminc/pet.inc +++ b/asminc/pet.inc @@ -31,10 +31,17 @@ BASIC_BUF_LEN = 81 ; Maximum length of command-line KEY_BUF := $26F ; Keyboard buffer -;FIXME: these are wrong? -KBDREPEAT := $28a -KBDREPEATRATE := $28b -KBDREPEATDELAY := $28c +;FIXME: we must somehow handle the difference between the two - how? + +; 40-Column PETs +;KBDREPEAT := $3ee +;KBDREPEATRATE := $3ea +;KBDREPEATDELAY := $3e9 + +; 80-Column PETs +KBDREPEAT := $e4 +KBDREPEATRATE := $e5 +KBDREPEATDELAY := $e6 ;---------------------------------------------------------------------------- ; PET ROM type detection diff --git a/asminc/plus4.inc b/asminc/plus4.inc index 42ed314bd..3b2f08c54 100644 --- a/asminc/plus4.inc +++ b/asminc/plus4.inc @@ -33,10 +33,9 @@ FKEY_COUNT := $55D ; Characters for function key FKEY_SPACE := $55F ; Function key definitions FKEY_ORIG := $F3D2 ; Original definitions -;FIXME: he?! these ok? :o) -KBDREPEAT := $28a -KBDREPEATRATE := $28b -KBDREPEATDELAY := $28c +KBDREPEAT := $540 +KBDREPEATRATE := $541 +KBDREPEATDELAY := $542 ; --------------------------------------------------------------------------- ; Kernal routines From 3ff4a1333c374c0092abe227523f940e6f1d4ea6 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Thu, 22 Jun 2017 00:19:39 +0200 Subject: [PATCH 139/199] use BIT so akku wont get trashed at least in 40 cols mode --- libsrc/c128/waitvblank.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/c128/waitvblank.s b/libsrc/c128/waitvblank.s index e0a469d0e..c144e11c2 100644 --- a/libsrc/c128/waitvblank.s +++ b/libsrc/c128/waitvblank.s @@ -5,7 +5,7 @@ _waitvblank: - lda MODE + bit MODE bmi @c80 @l1: From bd883327ace3f7de952a48b394a8ce6b53636595 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Mon, 26 Jun 2017 02:34:23 -0400 Subject: [PATCH 140/199] Added two functions that make it easier to write portable programs for Ohio Scientific computers. --- libsrc/osic1p/doesclrscr.s | 14 ++++++++++++++ libsrc/osic1p/revers.s | 9 +++++++++ 2 files changed, 23 insertions(+) create mode 100644 libsrc/osic1p/doesclrscr.s create mode 100644 libsrc/osic1p/revers.s diff --git a/libsrc/osic1p/doesclrscr.s b/libsrc/osic1p/doesclrscr.s new file mode 100644 index 000000000..3d15e8ade --- /dev/null +++ b/libsrc/osic1p/doesclrscr.s @@ -0,0 +1,14 @@ +; +; 2016-06, Christian Groessler +; 2017-06-26, Greg King +; +; unsigned char doesclrscrafterexit (void); +; +; Returns 0/1 if, after program termination, the screen isn't/is cleared. +; + + .import return1 + +; cc65's OSI programs return to the monitor ROM which clears the screen. + + .export _doesclrscrafterexit := return1 diff --git a/libsrc/osic1p/revers.s b/libsrc/osic1p/revers.s new file mode 100644 index 000000000..bb178f647 --- /dev/null +++ b/libsrc/osic1p/revers.s @@ -0,0 +1,9 @@ +; +; 2017-06-26, Greg King +; +; unsigned char __fastcall__ revers (unsigned char onoff) +; + + .import return0 + + .export _revers := return0 ; no attribute From d1501731e4234354c21907a7ee42011d8d7aaf99 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 28 Jun 2017 05:51:46 -0400 Subject: [PATCH 141/199] Added a makefile dependency for the libraries' "extra" files. Some of the files in "libsrc/*/extra/" include other library files. But, the "lib/*.o" files weren't rebuilt when those other files changed. The new dependency rules must be "bootstrapped". You must force a rebuild of all of the extra library object files (it will create the dependency files). Use these commands: rm lib/*.o make lib --- libsrc/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index f4aa03101..e106aa239 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -196,6 +196,7 @@ DEPS = $(OBJS:.o=.d) EXTRA_SRCPAT = $(SRCDIR)/extra/%.s EXTRA_OBJPAT = ../lib/$(TARGET)-%.o EXTRA_OBJS := $(patsubst $(EXTRA_SRCPAT),$(EXTRA_OBJPAT),$(wildcard $(SRCDIR)/extra/*.s)) +DEPS += $(EXTRA_OBJS:../lib/%.o=../libwrk/$(TARGET)/%.d) ZPOBJ = ../libwrk/$(TARGET)/zeropage.o ifeq ($(TARGET),$(filter $(TARGET),$(EXTZP))) @@ -281,7 +282,7 @@ endef # COMPILE_recipe $(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../lib @echo $(TARGET) - $(<F) - @$(CA65) -t $(TARGET) $(CA65FLAGS) -o $@ $< + @$(CA65) -t $(TARGET) $(CA65FLAGS) --create-dep $(@:../lib/%.o=../libwrk/$(TARGET)/%.d) -o $@ $< ../lib/$(TARGET).lib: $(OBJS) | ../lib $(AR65) a $@ $? From b31ae57be106d7586b1af740505a863779933ecd Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Wed, 28 Jun 2017 20:43:31 +0200 Subject: [PATCH 142/199] Make some arrays const. --- libsrc/common/strftime.c | 4 +- libsrc/conio/cputs.s | 4 +- libsrc/dbg/dbg.c | 40 ++++++++-------- libsrc/geos-common/dlgbox/messagebox.c | 10 ++-- src/ca65/dbginfo.c | 4 +- src/ca65/feature.c | 2 +- src/ca65/pseudo.c | 10 ++-- src/ca65/scanner.c | 2 +- src/ca65/scanner.h | 2 +- src/cc65/codegen.c | 66 +++++++++++++------------- src/cc65/coptstop.c | 2 +- src/cc65/standard.c | 2 +- src/co65/model.c | 2 +- src/da65/labels.c | 4 +- src/grc65/main.c | 13 ++--- src/sp65/attr.c | 2 +- src/sp65/attr.h | 2 +- src/sp65/main.c | 6 +-- 18 files changed, 87 insertions(+), 90 deletions(-) diff --git a/libsrc/common/strftime.c b/libsrc/common/strftime.c index 25cfd0606..38ea4850e 100644 --- a/libsrc/common/strftime.c +++ b/libsrc/common/strftime.c @@ -53,11 +53,11 @@ size_t __fastcall__ strftime (char* buf, size_t bufsize, const char* format, const struct tm* tm) { - static const char* days[7] = { + static const char* const days[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; - static const char* months[12] = { + static const char* const months[12] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; diff --git a/libsrc/conio/cputs.s b/libsrc/conio/cputs.s index c9ca5df76..ef7c65462 100644 --- a/libsrc/conio/cputs.s +++ b/libsrc/conio/cputs.s @@ -1,8 +1,8 @@ ; ; Ullrich von Bassewitz, 06.08.1998 ; -; void cputsxy (unsigned char x, unsigned char y, char* s); -; void cputs (char* s); +; void cputsxy (unsigned char x, unsigned char y, const char* s); +; void cputs (const char* s); ; .export _cputsxy, _cputs diff --git a/libsrc/dbg/dbg.c b/libsrc/dbg/dbg.c index 8b09484f6..60b452799 100644 --- a/libsrc/dbg/dbg.c +++ b/libsrc/dbg/dbg.c @@ -32,7 +32,7 @@ static char DumpHandler (void); static char HelpHandler (void); /* Forwards for other functions */ -static void DisplayPrompt (char* s); +static void DisplayPrompt (const char* s); static void SingleStep (char StepInto); static void RedrawStatic (char Frame); static void Redraw (char Frame); @@ -166,7 +166,7 @@ extern unsigned DbgHI; /* High 16 bit of primary reg */ typedef struct { unsigned char x; unsigned char y; - char* text; + const char* text; } TextDesc; /* Window descriptor */ @@ -181,13 +181,13 @@ typedef struct { unsigned char fd_visible; /* Is the window currently visible? */ char (*fd_func) (void); /* Handler function */ unsigned char fd_textcount; /* Number of text lines to print */ - TextDesc* fd_text; /* Static text in the window */ + const TextDesc* fd_text; /* Static text in the window */ } FrameDesc; /* Texts for the windows */ -static TextDesc RegText [] = { +static const TextDesc RegText [] = { { 1, 0, "PC" }, { 1, 1, "SR" }, { 1, 2, "A" }, @@ -197,7 +197,7 @@ static TextDesc RegText [] = { { 1, 6, "CS" }, { 1, 7, "HI" } }; -static TextDesc HelpText [] = { +static const TextDesc HelpText [] = { { 1, 0, "F1, ? Help" }, { 1, 1, "F2, t Toggle breakpoint" }, { 1, 2, "F3, u Run until subroutine returns" }, @@ -220,7 +220,7 @@ static TextDesc HelpText [] = { /* Window data */ -static FrameDesc AsmFrame = { +static const FrameDesc AsmFrame = { CH_ULCORNER, CH_TTEE, CH_LTEE, CH_CROSS, 0, 0, MAX_X - 10, 15, MAX_X - 11, 14, @@ -228,7 +228,7 @@ static FrameDesc AsmFrame = { AsmHandler, 0, 0 }; -static FrameDesc RegFrame = { +static const FrameDesc RegFrame = { CH_TTEE, CH_URCORNER, CH_LTEE, CH_RTEE, MAX_X - 10, 0, MAX_X - 1, 9, 8, 8, @@ -236,7 +236,7 @@ static FrameDesc RegFrame = { RegHandler, sizeof (RegText) / sizeof (RegText [0]), RegText }; -static FrameDesc StackFrame = { +static const FrameDesc StackFrame = { CH_LTEE, CH_RTEE, CH_CROSS, CH_RTEE, MAX_X - 10, 9, MAX_X - 1, 15, 8, 5, @@ -244,7 +244,7 @@ static FrameDesc StackFrame = { StackHandler, 0, 0 }; -static FrameDesc CStackFrame = { +static const FrameDesc CStackFrame = { CH_CROSS, CH_RTEE, CH_BTEE, CH_LRCORNER, MAX_X - 10, 15, MAX_X - 1, MAX_Y - 1, 8, MAX_Y - 17, @@ -252,7 +252,7 @@ static FrameDesc CStackFrame = { CStackHandler, 0, 0 }; -static FrameDesc DumpFrame = { +static const FrameDesc DumpFrame = { CH_LTEE, CH_CROSS, CH_LLCORNER, CH_BTEE, 0, 15, MAX_X - 10, MAX_Y-1, MAX_X - 11, MAX_Y - 17, @@ -260,7 +260,7 @@ static FrameDesc DumpFrame = { DumpHandler, 0, 0 }; -static FrameDesc HelpFrame = { +static const FrameDesc HelpFrame = { CH_ULCORNER, CH_URCORNER, CH_LLCORNER, CH_LRCORNER, 0, 0, MAX_X - 1, MAX_Y-1, MAX_X - 2, MAX_Y - 2, @@ -268,7 +268,7 @@ static FrameDesc HelpFrame = { HelpHandler, sizeof (HelpText) / sizeof (HelpText [0]), HelpText }; -static FrameDesc* Frames [] = { +static const FrameDesc* const Frames [] = { &AsmFrame, &RegFrame, &StackFrame, @@ -297,7 +297,7 @@ static unsigned char StackAddr; /* Start address of output */ /* Prompt line data */ -static char* ActivePrompt = 0; /* Last prompt line displayed */ +static const char* ActivePrompt = 0; /* Last prompt line displayed */ static char PromptColor; /* Color behind prompt */ static char PromptLength; /* Length of current prompt string */ @@ -346,10 +346,10 @@ BreakPoint* DbgIsBreak (unsigned Addr); -static void DrawFrame (register FrameDesc* F, char Active) +static void DrawFrame (register const FrameDesc* F, char Active) /* Draw one window frame */ { - TextDesc* T; + const TextDesc* T; unsigned char Count; unsigned char tl, tr, bl, br; unsigned char x1, y1, width; @@ -410,7 +410,7 @@ static void DrawFrames (void) /* Draw all frames */ { unsigned char I; - FrameDesc* F; + const FrameDesc* F; /* Build the frame layout of the screen */ for (I = 0; I < sizeof (Frames) / sizeof (Frames [0]); ++I) { @@ -427,7 +427,7 @@ static void ActivateFrame (int Num, unsigned char Clear) /* Activate a new frame, deactivate the old one */ { unsigned char y; - register FrameDesc* F; + register const FrameDesc* F; if (ActiveFrame != Num) { @@ -462,7 +462,7 @@ static void ActivateFrame (int Num, unsigned char Clear) -static void DisplayPrompt (char* s) +static void DisplayPrompt (const char* s) /* Display a prompt */ { unsigned char OldColor; @@ -626,11 +626,11 @@ static char InputHex (char* Prompt, unsigned* Val) -static void ErrorPrompt (char* Msg) +static void ErrorPrompt (const char* Msg) /* Display an error message and wait for a key */ { /* Save the current prompt */ - char* OldPrompt = ActivePrompt; + const char* OldPrompt = ActivePrompt; /* Display the new one */ DisplayPrompt (Msg); diff --git a/libsrc/geos-common/dlgbox/messagebox.c b/libsrc/geos-common/dlgbox/messagebox.c index 533267be1..fd4a5cd11 100644 --- a/libsrc/geos-common/dlgbox/messagebox.c +++ b/libsrc/geos-common/dlgbox/messagebox.c @@ -10,21 +10,21 @@ void _mbprintout(void); -static dlgBoxStr _mbdlg_EMPTY = { +static const dlgBoxStr _mbdlg_EMPTY = { DB_DEFPOS(1), DB_OPVEC(&RstrFrmDialogue), DB_USRROUT(&_mbprintout), DB_END, }; -static dlgBoxStr _mbdlg_OK = { +static const dlgBoxStr _mbdlg_OK = { DB_DEFPOS(1), DB_USRROUT(&_mbprintout), DB_ICON(OK, DBI_X_1, DBI_Y_2), DB_END, }; -static dlgBoxStr _mbdlg_OKCANCEL = { +static const dlgBoxStr _mbdlg_OKCANCEL = { DB_DEFPOS(1), DB_USRROUT(&_mbprintout), DB_ICON(OK, DBI_X_0, DBI_Y_2), @@ -32,7 +32,7 @@ static dlgBoxStr _mbdlg_OKCANCEL = { DB_END, }; -static dlgBoxStr _mbdlg_YESNO = { +static const dlgBoxStr _mbdlg_YESNO = { DB_DEFPOS(1), DB_USRROUT(&_mbprintout), DB_ICON(YES, DBI_X_0, DBI_Y_2), @@ -40,7 +40,7 @@ static dlgBoxStr _mbdlg_YESNO = { DB_END, }; -static dlgBoxStr *_mbboxes[] = { +static const dlgBoxStr * const _mbboxes[] = { &_mbdlg_EMPTY, &_mbdlg_OK, &_mbdlg_OKCANCEL, diff --git a/src/ca65/dbginfo.c b/src/ca65/dbginfo.c index 8a55f9ddc..135739fb5 100644 --- a/src/ca65/dbginfo.c +++ b/src/ca65/dbginfo.c @@ -211,7 +211,7 @@ void DbgInfoFile (void) void DbgInfoFunc (void) /* Parse and handle func subcommand of the .dbg pseudo instruction */ { - static const char* StorageKeys[] = { + static const char* const StorageKeys[] = { "EXTERN", "STATIC", }; @@ -352,7 +352,7 @@ void DbgInfoLine (void) void DbgInfoSym (void) /* Parse and handle SYM subcommand of the .dbg pseudo instruction */ { - static const char* StorageKeys[] = { + static const char* const StorageKeys[] = { "AUTO", "EXTERN", "REGISTER", diff --git a/src/ca65/feature.c b/src/ca65/feature.c index 35bdf4b98..0fb766b6f 100644 --- a/src/ca65/feature.c +++ b/src/ca65/feature.c @@ -48,7 +48,7 @@ /* Names of the features */ -static const char* FeatureKeys[FEAT_COUNT] = { +static const char* const FeatureKeys[FEAT_COUNT] = { "dollar_is_pc", "labels_without_colons", "loose_string_term", diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index f84f21d7f..5dd67af90 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -151,7 +151,7 @@ static unsigned char OptionalAddrSize (void) static void SetBoolOption (unsigned char* Flag) /* Read a on/off/+/- option and set flag accordingly */ { - static const char* Keys[] = { + static const char* const Keys[] = { "OFF", "ON", }; @@ -451,7 +451,7 @@ static void DoASCIIZ (void) static void DoAssert (void) /* Add an assertion */ { - static const char* ActionTab [] = { + static const char* const ActionTab [] = { "WARN", "WARNING", "ERROR", "LDWARN", "LDWARNING", @@ -659,7 +659,7 @@ static void DoCode (void) static void DoConDes (void) /* Export a symbol as constructor/destructor */ { - static const char* Keys[] = { + static const char* const Keys[] = { "CONSTRUCTOR", "DESTRUCTOR", "INTERRUPTOR", @@ -744,7 +744,7 @@ static void DoData (void) static void DoDbg (void) /* Add debug information from high level code */ { - static const char* Keys[] = { + static const char* const Keys[] = { "FILE", "FUNC", "LINE", @@ -1039,7 +1039,7 @@ static void DoFileOpt (void) if (CurTok.Tok == TOK_IDENT) { /* Option given as keyword */ - static const char* Keys [] = { + static const char* const Keys [] = { "AUTHOR", "COMMENT", "COMPILER" }; diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index e186b19a7..7c291666c 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -1477,7 +1477,7 @@ CharAgain: -int GetSubKey (const char** Keys, unsigned Count) +int GetSubKey (const char* const* Keys, unsigned Count) /* Search for a subkey in a table of keywords. The current token must be an ** identifier and all keys must be in upper case. The identifier will be ** uppercased in the process. The function returns the index of the keyword, diff --git a/src/ca65/scanner.h b/src/ca65/scanner.h index c445aefa6..4fd9041c1 100644 --- a/src/ca65/scanner.h +++ b/src/ca65/scanner.h @@ -84,7 +84,7 @@ void UpcaseSVal (void); void NextRawTok (void); /* Read the next raw token from the input stream */ -int GetSubKey (const char** Keys, unsigned Count); +int GetSubKey (const char* const* Keys, unsigned Count); /* Search for a subkey in a table of keywords. The current token must be an ** identifier and all keys must be in upper case. The identifier will be ** uppercased in the process. The function returns the index of the keyword, diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index bf0251813..d9074e539 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -2211,7 +2211,7 @@ void g_cmp (unsigned flags, unsigned long val) -static void oper (unsigned Flags, unsigned long Val, const char** Subs) +static void oper (unsigned Flags, unsigned long Val, const char* const* Subs) /* Encode a binary operation. subs is a pointer to four strings: ** 0 --> Operate on ints ** 1 --> Operate on unsigneds @@ -2499,7 +2499,7 @@ void g_stackcheck (void) void g_add (unsigned flags, unsigned long val) /* Primary = TOS + Primary */ { - static const char* ops[12] = { + static const char* const ops[4] = { "tosaddax", "tosaddax", "tosaddeax", "tosaddeax" }; @@ -2515,8 +2515,8 @@ void g_add (unsigned flags, unsigned long val) void g_sub (unsigned flags, unsigned long val) /* Primary = TOS - Primary */ { - static const char* ops[12] = { - "tossubax", "tossubax", "tossubeax", "tossubeax", + static const char* const ops[4] = { + "tossubax", "tossubax", "tossubeax", "tossubeax" }; if (flags & CF_CONST) { @@ -2531,8 +2531,8 @@ void g_sub (unsigned flags, unsigned long val) void g_rsub (unsigned flags, unsigned long val) /* Primary = Primary - TOS */ { - static const char* ops[12] = { - "tosrsubax", "tosrsubax", "tosrsubeax", "tosrsubeax", + static const char* const ops[4] = { + "tosrsubax", "tosrsubax", "tosrsubeax", "tosrsubeax" }; oper (flags, val, ops); } @@ -2542,8 +2542,8 @@ void g_rsub (unsigned flags, unsigned long val) void g_mul (unsigned flags, unsigned long val) /* Primary = TOS * Primary */ { - static const char* ops[12] = { - "tosmulax", "tosumulax", "tosmuleax", "tosumuleax", + static const char* const ops[4] = { + "tosmulax", "tosumulax", "tosmuleax", "tosumuleax" }; int p2; @@ -2649,8 +2649,8 @@ void g_mul (unsigned flags, unsigned long val) void g_div (unsigned flags, unsigned long val) /* Primary = TOS / Primary */ { - static const char* ops[12] = { - "tosdivax", "tosudivax", "tosdiveax", "tosudiveax", + static const char* const ops[4] = { + "tosdivax", "tosudivax", "tosdiveax", "tosudiveax" }; /* Do strength reduction if the value is constant and a power of two */ @@ -2674,8 +2674,8 @@ void g_div (unsigned flags, unsigned long val) void g_mod (unsigned flags, unsigned long val) /* Primary = TOS % Primary */ { - static const char* ops[12] = { - "tosmodax", "tosumodax", "tosmodeax", "tosumodeax", + static const char* const ops[4] = { + "tosmodax", "tosumodax", "tosmodeax", "tosumodeax" }; int p2; @@ -2699,8 +2699,8 @@ void g_mod (unsigned flags, unsigned long val) void g_or (unsigned flags, unsigned long val) /* Primary = TOS | Primary */ { - static const char* ops[12] = { - "tosorax", "tosorax", "tosoreax", "tosoreax", + static const char* const ops[4] = { + "tosorax", "tosorax", "tosoreax", "tosoreax" }; /* If the right hand side is const, the lhs is not on stack but still @@ -2769,8 +2769,8 @@ void g_or (unsigned flags, unsigned long val) void g_xor (unsigned flags, unsigned long val) /* Primary = TOS ^ Primary */ { - static const char* ops[12] = { - "tosxorax", "tosxorax", "tosxoreax", "tosxoreax", + static const char* const ops[4] = { + "tosxorax", "tosxorax", "tosxoreax", "tosxoreax" }; @@ -2837,8 +2837,8 @@ void g_xor (unsigned flags, unsigned long val) void g_and (unsigned Flags, unsigned long Val) /* Primary = TOS & Primary */ { - static const char* ops[12] = { - "tosandax", "tosandax", "tosandeax", "tosandeax", + static const char* const ops[4] = { + "tosandax", "tosandax", "tosandeax", "tosandeax" }; /* If the right hand side is const, the lhs is not on stack but still @@ -2929,8 +2929,8 @@ void g_and (unsigned Flags, unsigned long Val) void g_asr (unsigned flags, unsigned long val) /* Primary = TOS >> Primary */ { - static const char* ops[12] = { - "tosasrax", "tosshrax", "tosasreax", "tosshreax", + static const char* const ops[4] = { + "tosasrax", "tosshrax", "tosasreax", "tosshreax" }; /* If the right hand side is const, the lhs is not on stack but still @@ -3060,8 +3060,8 @@ void g_asr (unsigned flags, unsigned long val) void g_asl (unsigned flags, unsigned long val) /* Primary = TOS << Primary */ { - static const char* ops[12] = { - "tosaslax", "tosshlax", "tosasleax", "tosshleax", + static const char* const ops[4] = { + "tosaslax", "tosshlax", "tosasleax", "tosshleax" }; @@ -3438,8 +3438,8 @@ void g_dec (unsigned flags, unsigned long val) void g_eq (unsigned flags, unsigned long val) /* Test for equal */ { - static const char* ops[12] = { - "toseqax", "toseqax", "toseqeax", "toseqeax", + static const char* const ops[4] = { + "toseqax", "toseqax", "toseqeax", "toseqeax" }; unsigned L; @@ -3492,8 +3492,8 @@ void g_eq (unsigned flags, unsigned long val) void g_ne (unsigned flags, unsigned long val) /* Test for not equal */ { - static const char* ops[12] = { - "tosneax", "tosneax", "tosneeax", "tosneeax", + static const char* const ops[4] = { + "tosneax", "tosneax", "tosneeax", "tosneeax" }; unsigned L; @@ -3546,7 +3546,7 @@ void g_ne (unsigned flags, unsigned long val) void g_lt (unsigned flags, unsigned long val) /* Test for less than */ { - static const char* ops[12] = { + static const char* const ops[4] = { "tosltax", "tosultax", "toslteax", "tosulteax", }; @@ -3708,8 +3708,8 @@ void g_lt (unsigned flags, unsigned long val) void g_le (unsigned flags, unsigned long val) /* Test for less than or equal to */ { - static const char* ops[12] = { - "tosleax", "tosuleax", "tosleeax", "tosuleeax", + static const char* const ops[4] = { + "tosleax", "tosuleax", "tosleeax", "tosuleeax" }; @@ -3823,8 +3823,8 @@ void g_le (unsigned flags, unsigned long val) void g_gt (unsigned flags, unsigned long val) /* Test for greater than */ { - static const char* ops[12] = { - "tosgtax", "tosugtax", "tosgteax", "tosugteax", + static const char* const ops[4] = { + "tosgtax", "tosugtax", "tosgteax", "tosugteax" }; @@ -3954,8 +3954,8 @@ void g_gt (unsigned flags, unsigned long val) void g_ge (unsigned flags, unsigned long val) /* Test for greater than or equal to */ { - static const char* ops[12] = { - "tosgeax", "tosugeax", "tosgeeax", "tosugeeax", + static const char* const ops[4] = { + "tosgeax", "tosugeax", "tosgeeax", "tosugeeax" }; unsigned Label; diff --git a/src/cc65/coptstop.c b/src/cc65/coptstop.c index cf6392bd3..41d928750 100644 --- a/src/cc65/coptstop.c +++ b/src/cc65/coptstop.c @@ -1711,7 +1711,7 @@ static int HarmlessCall (const char* Name) ** the pushax/op sequence when encountered. */ { - static const char* Tab[] = { + static const char* const Tab[] = { "aslax1", "aslax2", "aslax3", diff --git a/src/cc65/standard.c b/src/cc65/standard.c index 36897a059..f26b63c20 100644 --- a/src/cc65/standard.c +++ b/src/cc65/standard.c @@ -50,7 +50,7 @@ IntStack Standard = INTSTACK(STD_UNKNOWN); /* Table mapping names to standards, sorted by standard. */ -static const char* StdNames[STD_COUNT] = { +static const char* const StdNames[STD_COUNT] = { "c89", "c99", "cc65" }; diff --git a/src/co65/model.c b/src/co65/model.c index 87a6966b7..bb815cd15 100644 --- a/src/co65/model.c +++ b/src/co65/model.c @@ -52,7 +52,7 @@ O65Model Model = O65_MODEL_NONE; /* Name table */ -static const char* NameTable[O65_MODEL_COUNT] = { +static const char* const NameTable[O65_MODEL_COUNT] = { "none", "os/a65", "lunix", diff --git a/src/da65/labels.c b/src/da65/labels.c index 547a79869..6aa7f38cf 100644 --- a/src/da65/labels.c +++ b/src/da65/labels.c @@ -264,11 +264,11 @@ const char* GetLabel (unsigned Addr, unsigned RefFrom) ** of unnamed labels, to determine the name. */ { - static const char* FwdLabels[] = { + static const char* const FwdLabels[] = { ":+", ":++", ":+++", ":++++", ":+++++", ":++++++", ":+++++++", ":++++++++", ":+++++++++", ":++++++++++" }; - static const char* BackLabels[] = { + static const char* const BackLabels[] = { ":-", ":--", ":---", ":----", ":-----", ":------", ":-------", ":--------", ":---------", ":----------" }; diff --git a/src/grc65/main.c b/src/grc65/main.c index 2a1fef953..d36f039e6 100644 --- a/src/grc65/main.c +++ b/src/grc65/main.c @@ -226,18 +226,15 @@ static void openSFile (void) } -static int findToken (const char **tokenTbl, const char *token) +static int findToken (const char * const *tokenTbl, const char *token) { /* takes as input table of tokens and token, returns position in table or -1 if not found */ - int a = 0; - - while (strlen (tokenTbl[a]) != 0) { - if (strcmp (tokenTbl[a], token) == 0) break; - a++; + int i; + for (i = 0; tokenTbl[i][0]; i++) { + if (strcmp (tokenTbl[i], token) == 0) return i; } - if (strlen (tokenTbl[a]) == 0) a = -1; - return a; + return -1; } diff --git a/src/sp65/attr.c b/src/sp65/attr.c index db026af48..e57b86973 100644 --- a/src/sp65/attr.c +++ b/src/sp65/attr.c @@ -240,7 +240,7 @@ void SplitAddAttr (Collection* C, const char* Combined, const char* Name) -Collection* ParseAttrList (const char* List, const char** NameList, unsigned NameCount) +Collection* ParseAttrList (const char* List, const char* const* NameList, unsigned NameCount) /* Parse a list containing name/value pairs into a sorted collection. Some ** attributes may not need a name, so NameList contains these names. If there ** were no errors, the function returns a alphabetically sorted collection diff --git a/src/sp65/attr.h b/src/sp65/attr.h index 2b7ce68b9..e93bcd937 100644 --- a/src/sp65/attr.h +++ b/src/sp65/attr.h @@ -111,7 +111,7 @@ void SplitAddAttr (Collection* C, const char* Combined, const char* Name); ** Name is NULL, terminate with an error. */ -Collection* ParseAttrList (const char* List, const char** NameList, unsigned NameCount); +Collection* ParseAttrList (const char* List, const char* const* NameList, unsigned NameCount); /* Parse a list containing name/value pairs into a sorted collection. Some ** attributes may not need a name, so NameList contains these names. If there ** were no errors, the function returns a alphabetically sorted collection diff --git a/src/sp65/main.c b/src/sp65/main.c index 828a48fc8..5c9724a8a 100644 --- a/src/sp65/main.c +++ b/src/sp65/main.c @@ -141,7 +141,7 @@ static void SetOutputData (StrBuf* N) static void OptConvertTo (const char* Opt attribute ((unused)), const char* Arg) /* Convert the bitmap into a target format */ { - static const char* NameList[] = { + static const char* const NameList[] = { "format" }; @@ -220,7 +220,7 @@ static void OptPop (const char* Opt attribute ((unused)), static void OptRead (const char* Opt attribute ((unused)), const char* Arg) /* Read an input file */ { - static const char* NameList[] = { + static const char* const NameList[] = { "name", "format" }; @@ -294,7 +294,7 @@ static void OptVersion (const char* Opt attribute ((unused)), static void OptWrite (const char* Opt attribute ((unused)), const char* Arg) /* Write an output file */ { - static const char* NameList[] = { + static const char* const NameList[] = { "name", "format" }; From 141c25b42b4df1c32ceb36e2661cddb48ac9c0e0 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Thu, 29 Jun 2017 13:34:10 -0400 Subject: [PATCH 143/199] Added the extra dependency file's directory as an order-only prerequisite. The extra dependency files are put into different places than the extra object files' location. Therefore, the rule must pre-make two directories. --- libsrc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index e106aa239..89d4b7752 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -280,7 +280,7 @@ endef # COMPILE_recipe ../libwrk/$(TARGET)/%.o: %.c | ../libwrk/$(TARGET) $(COMPILE_recipe) -$(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../lib +$(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../libwrk/$(TARGET) ../lib @echo $(TARGET) - $(<F) @$(CA65) -t $(TARGET) $(CA65FLAGS) --create-dep $(@:../lib/%.o=../libwrk/$(TARGET)/%.d) -o $@ $< From c0812670c11411ed99404cc3f936a2cd9259bc14 Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Fri, 30 Jun 2017 07:35:21 +0200 Subject: [PATCH 144/199] Fix coding style. --- src/cc65/codegen.c | 2 +- src/grc65/main.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index d9074e539..dfc06fccc 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -3547,7 +3547,7 @@ void g_lt (unsigned flags, unsigned long val) /* Test for less than */ { static const char* const ops[4] = { - "tosltax", "tosultax", "toslteax", "tosulteax", + "tosltax", "tosultax", "toslteax", "tosulteax" }; unsigned Label; diff --git a/src/grc65/main.c b/src/grc65/main.c index d36f039e6..a53801a39 100644 --- a/src/grc65/main.c +++ b/src/grc65/main.c @@ -230,8 +230,11 @@ static int findToken (const char * const *tokenTbl, const char *token) { /* takes as input table of tokens and token, returns position in table or -1 if not found */ int i; + for (i = 0; tokenTbl[i][0]; i++) { - if (strcmp (tokenTbl[i], token) == 0) return i; + if (strcmp (tokenTbl[i], token) == 0) { + return i; + } } return -1; From 6de78c536f78bc47129a7d4da4ad10f7e3a27b8f Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Fri, 30 Jun 2017 09:50:28 +0200 Subject: [PATCH 145/199] Made DOS 3.3 IRQ statement more general. I recently came across that the question if a driver is compatible with DOS 3.3 isn't about the fact if it actually uses IRQs but if it potentially could use IRQs as the driver kernel pulls in the IRQ handler anyway. This is especially suboptimal in the scenario of statically linked drivers where it is concpetually totally clear at link time they use IRQs or not. Apart from that it might make sense to be able to define on a per-target basis if _any_ of the drivers of a certain class uses IRQs. If that isn't the cases the driver kernel for that driver class for that target could omit IRQ handling too. I'm aware that Uz imagined drivers being loaded which weren't known when the program was linked - but I don't see this. --- doc/apple2.sgml | 2 +- doc/apple2enh.sgml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index d0405b6de..3089a04c4 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -435,7 +435,7 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3: <tag/Interrupts/ There's no <tt/interruptor/ support. Any attempt to use it yields the message 'FAILED TO ALLOC INTERRUPT' on program startup. This implicitly means that - <tt/a2.stdmou.mou/ and <tt/a2.ssc.ser/ are not functional as they depend on + joystick, mouse and RS232 device drivers are not functional as they depend on interrupts. </descrip><p> diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index b5231b4cd..5e4626fbc 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -436,7 +436,7 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3: <tag/Interrupts/ There's no <tt/interruptor/ support. Any attempt to use it yields the message 'Failed to alloc interrupt' on program startup. This implicitly means that - <tt/a2e.stdmou.mou/ and <tt/a2e.ssc.ser/ are not functional as they depend on + joystick, mouse and RS232 device drivers are not functional as they depend on interrupts. </descrip><p> From ea7f4d748942ad0fd34f68502531db6c0b15aca5 Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Mon, 17 Jul 2017 19:43:11 +0200 Subject: [PATCH 146/199] pragma: bring pragma_t enum in line with Pragmas struct fixes an inconsequential inconsistency, might prevent some confusion in the future. --- src/cc65/pragma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index de1979c12..d50d151a7 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -79,8 +79,8 @@ typedef enum { PRAGMA_INLINE_STDFUNCS, PRAGMA_LOCAL_STRINGS, PRAGMA_OPTIMIZE, - PRAGMA_REGVARADDR, PRAGMA_REGISTER_VARS, + PRAGMA_REGVARADDR, PRAGMA_REGVARS, /* obsolete */ PRAGMA_RODATA_NAME, PRAGMA_RODATASEG, /* obsolete */ From 1abce3a2a1d7df81a580e9120a34e1d697085b3e Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 17 Jul 2017 23:15:05 +0200 Subject: [PATCH 147/199] rename all waitvblank() to waitvsync() --- doc/funcref.sgml | 2 +- doc/nes.sgml | 4 ++-- doc/pce.sgml | 2 +- doc/supervision.sgml | 2 +- include/gamate.h | 4 ++-- include/nes.h | 4 ++-- include/pce.h | 4 ++-- libsrc/c128/{waitvblank.s => waitvsync.s} | 4 ++-- libsrc/c64/{waitvblank.s => waitvsync.s} | 4 ++-- libsrc/cbm510/{waitvblank.s => waitvsync.s} | 4 ++-- libsrc/gamate/{waitvblank.s => waitvsync.s} | 6 +++--- libsrc/nes/{waitvblank.s => waitvsync.s} | 6 +++--- libsrc/pce/{waitvblank.s => waitvsync.s} | 6 +++--- libsrc/vic20/{waitvblank.s => waitvsync.s} | 4 ++-- testcode/lib/conio.c | 4 ++-- testcode/lib/gamate/ctest.c | 2 +- testcode/lib/pce/conio.c | 2 +- 17 files changed, 32 insertions(+), 32 deletions(-) rename libsrc/c128/{waitvblank.s => waitvsync.s} (87%) rename libsrc/c64/{waitvblank.s => waitvsync.s} (75%) rename libsrc/cbm510/{waitvblank.s => waitvsync.s} (88%) rename libsrc/gamate/{waitvblank.s => waitvsync.s} (74%) rename libsrc/nes/{waitvblank.s => waitvsync.s} (73%) rename libsrc/pce/{waitvblank.s => waitvsync.s} (71%) rename libsrc/vic20/{waitvblank.s => waitvsync.s} (88%) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index a2ccf6c73..b5295a63b 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -415,7 +415,7 @@ function. <!-- <itemize> --> <!-- <item><ref id="get_tv" name="get_tv"> --> -<!-- <item><ref id="waitvblank" name="waitvblank"> --> +<!-- <item><ref id="waitvsync" name="waitvsync"> --> <!-- </itemize> --> (incomplete) diff --git a/doc/nes.sgml b/doc/nes.sgml index 98c25b6af..31d1aa396 100644 --- a/doc/nes.sgml +++ b/doc/nes.sgml @@ -1,4 +1,4 @@ -<!doctype linuxdoc system> +<!-- <!doctype linuxdoc system> //--> <article> @@ -69,7 +69,7 @@ Programs containing NES specific code may use the <tt/nes.h/ header file. <sect1>NES specific functions<p> <itemize> -<item>waitvblank - wait until the start of vblank +<item>waitvsync - wait until the start of the next frame <item>get_tv </itemize> diff --git a/doc/pce.sgml b/doc/pce.sgml index ba59c31a7..124cb329e 100644 --- a/doc/pce.sgml +++ b/doc/pce.sgml @@ -77,7 +77,7 @@ Programs containing PCE specific code may use the <tt/pce.h/ header file. <sect1>PCE specific functions<p> <itemize> -<item>waitvblank</item> +<item>waitvsync</item> <item>get_tv (since all PCE systems are NTSC, this always returns TV_NTSC)</item> </itemize> diff --git a/doc/supervision.sgml b/doc/supervision.sgml index 97495dea5..2466aa480 100644 --- a/doc/supervision.sgml +++ b/doc/supervision.sgml @@ -66,7 +66,7 @@ Programs containing Supervision specific code may use the <tt/supervision.h/ hea <sect1>Supervision specific functions<p> <itemize> -<item>waitvblank +<item>waitvsync </itemize> diff --git a/include/gamate.h b/include/gamate.h index 82bca08b1..96c70c9bc 100644 --- a/include/gamate.h +++ b/include/gamate.h @@ -188,8 +188,8 @@ extern void gamate_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ #define JOY_START 6 #define JOY_SELECT 7 -void waitvblank (void); -/* Wait for the vertical blanking */ +void waitvsync (void); +/* Wait for start of next frame */ /* NOTE: all Gamate are "NTSC" */ #define get_tv() TV_NTSC diff --git a/include/nes.h b/include/nes.h index a472a0f3c..95e2fe93b 100644 --- a/include/nes.h +++ b/include/nes.h @@ -163,8 +163,8 @@ extern void nes_64_56_2_tgi[]; /* Referred to by tgi_static_stddrv[] */ -void waitvblank (void); -/* Wait for the vertical blanking */ +void waitvsync (void); +/* Wait for start of the next frame */ unsigned char get_tv (void); /* Return the video mode the machine is using. */ diff --git a/include/pce.h b/include/pce.h index 7700654c8..856a2fa1d 100644 --- a/include/pce.h +++ b/include/pce.h @@ -83,8 +83,8 @@ extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ #define JOY_SELECT 6 #define JOY_RUN 7 -void waitvblank (void); -/* Wait for the vertical blanking */ +void waitvsync (void); +/* Wait for start of the next frame */ /* NOTE: all PCE are NTSC */ #define get_tv() TV_NTSC diff --git a/libsrc/c128/waitvblank.s b/libsrc/c128/waitvsync.s similarity index 87% rename from libsrc/c128/waitvblank.s rename to libsrc/c128/waitvsync.s index c144e11c2..1597e5fa0 100644 --- a/libsrc/c128/waitvblank.s +++ b/libsrc/c128/waitvsync.s @@ -1,9 +1,9 @@ - .export _waitvblank + .export _waitvsync .include "c128.inc" -_waitvblank: +_waitvsync: bit MODE bmi @c80 diff --git a/libsrc/c64/waitvblank.s b/libsrc/c64/waitvsync.s similarity index 75% rename from libsrc/c64/waitvblank.s rename to libsrc/c64/waitvsync.s index dd9087841..15ef61bb7 100644 --- a/libsrc/c64/waitvblank.s +++ b/libsrc/c64/waitvsync.s @@ -1,9 +1,9 @@ - .export _waitvblank + .export _waitvsync .include "c64.inc" -_waitvblank: +_waitvsync: @l1: bit VIC_CTRL1 bpl @l1 diff --git a/libsrc/cbm510/waitvblank.s b/libsrc/cbm510/waitvsync.s similarity index 88% rename from libsrc/cbm510/waitvblank.s rename to libsrc/cbm510/waitvsync.s index 975861f2c..bd631e4d6 100644 --- a/libsrc/cbm510/waitvblank.s +++ b/libsrc/cbm510/waitvsync.s @@ -1,5 +1,5 @@ - .export _waitvblank + .export _waitvsync .import PALFLAG .import sys_bank, restore_bank @@ -7,7 +7,7 @@ .include "cbm510.inc" -_waitvblank: +_waitvsync: rts ; FIXME jsr sys_bank ; Switch to the system bank diff --git a/libsrc/gamate/waitvblank.s b/libsrc/gamate/waitvsync.s similarity index 74% rename from libsrc/gamate/waitvblank.s rename to libsrc/gamate/waitvsync.s index 66686c08a..9b1199055 100644 --- a/libsrc/gamate/waitvblank.s +++ b/libsrc/gamate/waitvsync.s @@ -1,16 +1,16 @@ ; -; void waitvblank (void); +; void waitvsync (void); ; .include "gamate.inc" .include "extzp.inc" .forceimport ticktock - .export _waitvblank + .export _waitvsync ; FIXME: is this actually correct? -.proc _waitvblank +.proc _waitvsync lda tickcount @lp: cmp tickcount diff --git a/libsrc/nes/waitvblank.s b/libsrc/nes/waitvsync.s similarity index 73% rename from libsrc/nes/waitvblank.s rename to libsrc/nes/waitvsync.s index 408646904..11a231ac4 100644 --- a/libsrc/nes/waitvblank.s +++ b/libsrc/nes/waitvsync.s @@ -2,14 +2,14 @@ ; Written by Groepaz/Hitmen <groepaz@gmx.net> ; Cleanup by Ullrich von Bassewitz <uz@cc65.org> ; -; void waitvblank(void); +; void waitvsync(void); ; - .export _waitvblank + .export _waitvsync .include "nes.inc" -.proc _waitvblank +.proc _waitvsync wait: lda PPU_STATUS bpl wait diff --git a/libsrc/pce/waitvblank.s b/libsrc/pce/waitvsync.s similarity index 71% rename from libsrc/pce/waitvblank.s rename to libsrc/pce/waitvsync.s index b9f0f902f..f1eab36f8 100644 --- a/libsrc/pce/waitvblank.s +++ b/libsrc/pce/waitvsync.s @@ -1,14 +1,14 @@ ; -; void waitvblank (void); +; void waitvsync (void); ; .include "pce.inc" .include "extzp.inc" .forceimport ticktock - .export _waitvblank + .export _waitvsync -.proc _waitvblank +.proc _waitvsync lda tickcount @lp: cmp tickcount diff --git a/libsrc/vic20/waitvblank.s b/libsrc/vic20/waitvsync.s similarity index 88% rename from libsrc/vic20/waitvblank.s rename to libsrc/vic20/waitvsync.s index 246c44640..9f0d50565 100644 --- a/libsrc/vic20/waitvblank.s +++ b/libsrc/vic20/waitvsync.s @@ -1,4 +1,4 @@ - .export _waitvblank + .export _waitvsync .include "vic20.inc" @@ -7,7 +7,7 @@ ; it will have to be filled by a get_tv() constructor or so PALFLAG = $2A6 ; $01 = PAL, $00 = NTSC -_waitvblank: +_waitvsync: lda PALFLAG beq @ntsc ldx #(312-8)/2 diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c index fe977ec08..13188d1cd 100644 --- a/testcode/lib/conio.c +++ b/testcode/lib/conio.c @@ -117,8 +117,8 @@ void main(void) gotoxy(7 + inpos,1); #if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) - /* not all targets have waitvblank */ - waitvblank(); + /* not all targets have waitvsync */ + waitvsync(); /* for targets that do not have a keyboard, read the first joystick */ joy = joy_read(JOY_1); diff --git a/testcode/lib/gamate/ctest.c b/testcode/lib/gamate/ctest.c index dfebd9bef..793770cee 100644 --- a/testcode/lib/gamate/ctest.c +++ b/testcode/lib/gamate/ctest.c @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) break; } - waitvblank(); + waitvsync(); (*((unsigned char*)LCD_XPOS)) = x; (*((unsigned char*)LCD_YPOS)) = y; diff --git a/testcode/lib/pce/conio.c b/testcode/lib/pce/conio.c index a4bd63b15..00ae3c157 100644 --- a/testcode/lib/pce/conio.c +++ b/testcode/lib/pce/conio.c @@ -123,7 +123,7 @@ void main(void) p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]); } - waitvblank(); + waitvsync(); ++n; } } From d965601a5e56a04c14ba6ba7abd6f56a459a7238 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 17 Jul 2017 23:31:01 +0200 Subject: [PATCH 148/199] fix sgml --- doc/nes.sgml | 4 ++-- doc/supervision.sgml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/nes.sgml b/doc/nes.sgml index 31d1aa396..e806d753f 100644 --- a/doc/nes.sgml +++ b/doc/nes.sgml @@ -69,8 +69,8 @@ Programs containing NES specific code may use the <tt/nes.h/ header file. <sect1>NES specific functions<p> <itemize> -<item>waitvsync - wait until the start of the next frame -<item>get_tv +<item>waitvsync - wait until the start of the next frame</item> +<item>get_tv</item> </itemize> diff --git a/doc/supervision.sgml b/doc/supervision.sgml index 2466aa480..cf2af7967 100644 --- a/doc/supervision.sgml +++ b/doc/supervision.sgml @@ -66,7 +66,7 @@ Programs containing Supervision specific code may use the <tt/supervision.h/ hea <sect1>Supervision specific functions<p> <itemize> -<item>waitvsync +<item>waitvsync</item> </itemize> From 33791c6efdae474ac2ee9fc35e4dfc942e2a6bd5 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 17 Jul 2017 23:43:08 +0200 Subject: [PATCH 149/199] added prototype to cbm.h --- include/cbm.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/cbm.h b/include/cbm.h index 701924d57..4bbd278e3 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -153,7 +153,10 @@ struct cbm_dirent { unsigned char get_tv (void); /* Return the video mode the machine is using. */ - +#if !defined(__PLUS4__) && !defined(__C16__) && !defined(__CBM610__) && !defined(__PET__) +void waitvsync (void); +/* wait for the start of the next frame */ +#endif /*****************************************************************************/ /* CBM kernal functions */ From fe850fece8d6352f695586e9c34830ae94f52ae3 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 17 Jul 2017 23:55:18 +0200 Subject: [PATCH 150/199] implement waitvsync for plus4/c16 --- include/cbm.h | 2 +- libsrc/plus4/waitvsync.s | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 libsrc/plus4/waitvsync.s diff --git a/include/cbm.h b/include/cbm.h index 4bbd278e3..f35f83828 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -153,7 +153,7 @@ struct cbm_dirent { unsigned char get_tv (void); /* Return the video mode the machine is using. */ -#if !defined(__PLUS4__) && !defined(__C16__) && !defined(__CBM610__) && !defined(__PET__) +#if !defined(__CBM610__) && !defined(__PET__) void waitvsync (void); /* wait for the start of the next frame */ #endif diff --git a/libsrc/plus4/waitvsync.s b/libsrc/plus4/waitvsync.s new file mode 100644 index 000000000..84654d996 --- /dev/null +++ b/libsrc/plus4/waitvsync.s @@ -0,0 +1,12 @@ + + .export _waitvsync + + .include "plus4.inc" + +_waitvsync: +@l1: + lda TED_VLINEHI + and #$01 + ora TED_VLINELO + bne @l1 + rts From cbdad764f0eff850d37bf0a0520a33c69c840c66 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Tue, 18 Jul 2017 00:01:15 +0200 Subject: [PATCH 151/199] oops --- doc/nes.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/nes.sgml b/doc/nes.sgml index e806d753f..8f4374e05 100644 --- a/doc/nes.sgml +++ b/doc/nes.sgml @@ -1,4 +1,4 @@ -<!-- <!doctype linuxdoc system> //--> +<!doctype linuxdoc system> <article> From c24080f28931976f8919fd1d2d65e931d0d91fa0 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Tue, 18 Jul 2017 00:41:54 +0200 Subject: [PATCH 152/199] do banking --- libsrc/cbm510/waitvsync.s | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libsrc/cbm510/waitvsync.s b/libsrc/cbm510/waitvsync.s index bd631e4d6..db6c16179 100644 --- a/libsrc/cbm510/waitvsync.s +++ b/libsrc/cbm510/waitvsync.s @@ -8,10 +8,7 @@ .include "cbm510.inc" _waitvsync: - rts ; FIXME - - jsr sys_bank ; Switch to the system bank - + jsr sys_bank ; Switch to the system bank sei ldy #VIC_CTRL1 From 8eee51913a43e1f5614033e745e6f3c1bf11000a Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Tue, 18 Jul 2017 01:04:53 +0200 Subject: [PATCH 153/199] add headers/fix formatting --- libsrc/c128/waitvsync.s | 5 +++++ libsrc/c64/waitvsync.s | 5 +++++ libsrc/cbm510/waitvsync.s | 19 ++++++++++++------- libsrc/gamate/waitvsync.s | 2 ++ libsrc/nes/waitvsync.s | 2 +- libsrc/pce/waitvsync.s | 2 ++ libsrc/plus4/waitvsync.s | 5 +++++ libsrc/vic20/waitvsync.s | 6 ++++++ 8 files changed, 38 insertions(+), 8 deletions(-) diff --git a/libsrc/c128/waitvsync.s b/libsrc/c128/waitvsync.s index 1597e5fa0..e4bbbf7c9 100644 --- a/libsrc/c128/waitvsync.s +++ b/libsrc/c128/waitvsync.s @@ -1,3 +1,8 @@ +; +; Written by Groepaz <groepaz@gmx.net> +; +; void waitvsync (void); +; .export _waitvsync diff --git a/libsrc/c64/waitvsync.s b/libsrc/c64/waitvsync.s index 15ef61bb7..a4bf13080 100644 --- a/libsrc/c64/waitvsync.s +++ b/libsrc/c64/waitvsync.s @@ -1,3 +1,8 @@ +; +; Written by Groepaz <groepaz@gmx.net> +; +; void waitvsync (void); +; .export _waitvsync diff --git a/libsrc/cbm510/waitvsync.s b/libsrc/cbm510/waitvsync.s index db6c16179..ed7300f7c 100644 --- a/libsrc/cbm510/waitvsync.s +++ b/libsrc/cbm510/waitvsync.s @@ -1,3 +1,8 @@ +; +; Written by Groepaz <groepaz@gmx.net> +; +; void waitvsync (void); +; .export _waitvsync .import PALFLAG @@ -8,16 +13,16 @@ .include "cbm510.inc" _waitvsync: - jsr sys_bank ; Switch to the system bank + jsr sys_bank ; Switch to the system bank sei - ldy #VIC_CTRL1 + ldy #VIC_CTRL1 @l1: - lda (vic),y - bpl @l1 + lda (vic),y + bpl @l1 @l2: - lda (vic),y - bmi @l2 + lda (vic),y + bmi @l2 cli - jmp restore_bank + jmp restore_bank diff --git a/libsrc/gamate/waitvsync.s b/libsrc/gamate/waitvsync.s index 9b1199055..dee83400d 100644 --- a/libsrc/gamate/waitvsync.s +++ b/libsrc/gamate/waitvsync.s @@ -1,4 +1,6 @@ ; +; Written by Groepaz <groepaz@gmx.net> +; ; void waitvsync (void); ; diff --git a/libsrc/nes/waitvsync.s b/libsrc/nes/waitvsync.s index 11a231ac4..4bdf9a9d0 100644 --- a/libsrc/nes/waitvsync.s +++ b/libsrc/nes/waitvsync.s @@ -1,5 +1,5 @@ ; -; Written by Groepaz/Hitmen <groepaz@gmx.net> +; Written by Groepaz <groepaz@gmx.net> ; Cleanup by Ullrich von Bassewitz <uz@cc65.org> ; ; void waitvsync(void); diff --git a/libsrc/pce/waitvsync.s b/libsrc/pce/waitvsync.s index f1eab36f8..c6435dabd 100644 --- a/libsrc/pce/waitvsync.s +++ b/libsrc/pce/waitvsync.s @@ -1,4 +1,6 @@ ; +; Written by Groepaz <groepaz@gmx.net> +; ; void waitvsync (void); ; diff --git a/libsrc/plus4/waitvsync.s b/libsrc/plus4/waitvsync.s index 84654d996..32b81b52b 100644 --- a/libsrc/plus4/waitvsync.s +++ b/libsrc/plus4/waitvsync.s @@ -1,3 +1,8 @@ +; +; Written by Groepaz <groepaz@gmx.net> +; +; void waitvsync (void); +; .export _waitvsync diff --git a/libsrc/vic20/waitvsync.s b/libsrc/vic20/waitvsync.s index 9f0d50565..b5861ada3 100644 --- a/libsrc/vic20/waitvsync.s +++ b/libsrc/vic20/waitvsync.s @@ -1,3 +1,9 @@ +; +; Written by Groepaz <groepaz@gmx.net> +; +; void waitvsync (void); +; + .export _waitvsync .include "vic20.inc" From b6d3d32e88468eff8c10939efb8653833702512d Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Tue, 18 Jul 2017 01:06:20 +0200 Subject: [PATCH 154/199] wait for line 0 instead of last line --- libsrc/vic20/waitvsync.s | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/libsrc/vic20/waitvsync.s b/libsrc/vic20/waitvsync.s index b5861ada3..1c76f2497 100644 --- a/libsrc/vic20/waitvsync.s +++ b/libsrc/vic20/waitvsync.s @@ -8,20 +8,9 @@ .include "vic20.inc" -; FIXME -; this flag doesnt work on vic20!!! -; it will have to be filled by a get_tv() constructor or so -PALFLAG = $2A6 ; $01 = PAL, $00 = NTSC - _waitvsync: - lda PALFLAG - beq @ntsc - ldx #(312-8)/2 - .byte $2c -@ntsc: - ldx #(262-8)/2 @l2: - cpx VIC_HLINE - bcs @l2 + lda VIC_HLINE + bne @l2 rts From 6e93c1ba7332c55eb2067d7be6d20050912ef27d Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Tue, 18 Jul 2017 18:12:19 +0200 Subject: [PATCH 155/199] pragma: add minimalist message pragma implementation for example: #pragma message ("in a bottle") results in: hello.c(207): Note: in a bottle --- src/cc65/pragma.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index d50d151a7..25bc29d43 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -78,6 +78,7 @@ typedef enum { PRAGMA_DATASEG, /* obsolete */ PRAGMA_INLINE_STDFUNCS, PRAGMA_LOCAL_STRINGS, + PRAGMA_MESSAGE, PRAGMA_OPTIMIZE, PRAGMA_REGISTER_VARS, PRAGMA_REGVARADDR, @@ -114,6 +115,7 @@ static const struct Pragma { { "dataseg", PRAGMA_DATASEG }, /* obsolete */ { "inline-stdfuncs", PRAGMA_INLINE_STDFUNCS }, { "local-strings", PRAGMA_LOCAL_STRINGS }, + { "message", PRAGMA_MESSAGE }, { "optimize", PRAGMA_OPTIMIZE }, { "register-vars", PRAGMA_REGISTER_VARS }, { "regvaraddr", PRAGMA_REGVARADDR }, @@ -750,6 +752,13 @@ static void IntPragma (StrBuf* B, IntStack* Stack, long Low, long High) +static void MakeMessage (const char* Message) +{ + fprintf (stderr, "%s(%u): Note: %s\n", GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Message); +} + + + static void ParsePragma (void) /* Parse the contents of the _Pragma statement */ { @@ -849,6 +858,10 @@ static void ParsePragma (void) FlagPragma (&B, &LocalStrings); break; + case PRAGMA_MESSAGE: + StringPragma (&B, MakeMessage); + break; + case PRAGMA_OPTIMIZE: FlagPragma (&B, &Optimize); break; From 2d9922a46e6112ed901dc675d37a6bfc4f928c4d Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Wed, 19 Jul 2017 18:02:13 +0200 Subject: [PATCH 156/199] nes: remove semiredundant KEY_ defines There are already JOY_ defines for most of these, and this should be expanded upon instead. --- include/nes.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/include/nes.h b/include/nes.h index 95e2fe93b..2687e2626 100644 --- a/include/nes.h +++ b/include/nes.h @@ -90,16 +90,6 @@ /* No support for dynamically loadable drivers */ #define DYN_DRV 0 -/* The joystick keys - all keys are supported */ -#define KEY_A 0x01 -#define KEY_B 0x02 -#define KEY_SELECT 0x04 -#define KEY_START 0x08 -#define KEY_UP 0x10 -#define KEY_DOWN 0x20 -#define KEY_LEFT 0x40 -#define KEY_RIGHT 0x80 - /* Define hardware */ /* Picture Processing Unit */ From d277055b5a06ee314fd3c93a562fd494cefbd767 Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Wed, 19 Jul 2017 18:14:44 +0200 Subject: [PATCH 157/199] nes: add system specific joy_masks array indices and macros --- include/nes.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/nes.h b/include/nes.h index 2687e2626..3e139e00c 100644 --- a/include/nes.h +++ b/include/nes.h @@ -90,6 +90,17 @@ /* No support for dynamically loadable drivers */ #define DYN_DRV 0 +/* Expanding upon joystick.h */ +#define JOY_A 4 +#define JOY_B 5 +#define JOY_SELECT 6 +#define JOY_START 7 + +#define JOY_BTN_A(v) ((v) & joy_masks[JOY_A]) +#define JOY_BTN_B(v) ((v) & joy_masks[JOY_B]) +#define JOY_BTN_SELECT(v) ((v) & joy_masks[JOY_SELECT]) +#define JOY_BTN_START(v) ((v) & joy_masks[JOY_START]) + /* Define hardware */ /* Picture Processing Unit */ From 8ad72fc9ca78b8018ec1ef223eb1911bbd8965d5 Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Wed, 19 Jul 2017 18:29:35 +0200 Subject: [PATCH 158/199] pce: add system specific joy_masks array indices and macros --- include/pce.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/pce.h b/include/pce.h index 856a2fa1d..ac6b2503f 100644 --- a/include/pce.h +++ b/include/pce.h @@ -76,6 +76,17 @@ /* No support for dynamically loadable drivers */ #define DYN_DRV 0 +/* Expanding upon joystick.h */ +#define JOY_I 4 +#define JOY_II 5 +#define JOY_SELECT 6 +#define JOY_RUN 7 + +#define JOY_BTN_I(v) ((v) & joy_masks[JOY_I]) +#define JOY_BTN_II(v) ((v) & joy_masks[JOY_II]) +#define JOY_BTN_SELECT(v) ((v) & joy_masks[JOY_SELECT]) +#define JOY_BTN_RUN(v) ((v) & joy_masks[JOY_RUN]) + /* The addresses of the static drivers */ extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ From 80b27bde5e4eff1ed11dc6c84e3fbe99ae34f038 Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Thu, 20 Jul 2017 18:13:39 +0200 Subject: [PATCH 159/199] pragma: add minimalist message pragma documentation documents 6e93c1ba7332c55eb2067d7be6d20050912ef27d --- doc/cc65.sgml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 3689c0b35..cd94f50ac 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1119,6 +1119,23 @@ parameter with the <tt/#pragma/. remembered and output as a whole when translation is finished. +<sect1><tt>#pragma message (<message>)</tt><label id="pragma-message"><p> + + This pragma is used to display informational messages at compile-time. + + The message intented to be displayed must be a string literal. + + Example: + <tscreen><verb> + #pragma message ("in a bottle") + </verb></tscreen> + + Results in the compiler outputting the following to stderr: + <tscreen><verb> + example.c(42): Note: in a bottle + </verb></tscreen> + + <sect1><tt>#pragma optimize ([push,] on|off)</tt><label id="pragma-optimize"><p> Switch optimization on or off. If the argument is "off", optimization is From 64581b65b037b09e0ba80198c092a976a2d49076 Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Sat, 22 Jul 2017 16:33:42 +0200 Subject: [PATCH 160/199] samples: install to subdirectory --- samples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Makefile b/samples/Makefile index 949940022..eb2b78f1c 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -237,7 +237,7 @@ samples.atr: samples # Installation rules INSTALL = install -samplesdir = $(prefix)/share/cc65 +samplesdir = $(prefix)/share/cc65/samples install: $(if $(prefix),,$(error variable `prefix' must be set)) From 19f6ae1d54da28dc6d4c13828262a9ea3cd1c5cc Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Sat, 22 Jul 2017 16:38:50 +0200 Subject: [PATCH 161/199] make: change uppercase prefix var --- doc/Makefile | 6 +++--- libsrc/Makefile | 4 ++-- samples/Makefile | 4 ++-- src/Makefile | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 96a3ba59b..33b5c2686 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -6,8 +6,8 @@ endif .SUFFIXES: -htmldir = $(prefix)/share/doc/cc65$(DESTPACKAGE_SUFFIX)/html -infodir = $(prefix)/share/info +htmldir = $(PREFIX)/share/doc/cc65$(DESTPACKAGE_SUFFIX)/html +infodir = $(PREFIX)/share/info ifdef CMD_EXE @@ -46,7 +46,7 @@ clean: $(RM) -r ../html ../info install: - $(if $(prefix),,$(error variable `prefix' must be set)) + $(if $(PREFIX),,$(error variable `PREFIX' must be set)) ifeq ($(wildcard ../html),../html) $(INSTALL) -d $(DESTDIR)$(htmldir) $(INSTALL) -m0644 ../html/*.* $(DESTDIR)$(htmldir) diff --git a/libsrc/Makefile b/libsrc/Makefile index 89d4b7752..0583b6761 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -72,7 +72,7 @@ endif ifndef TARGET -datadir = $(prefix)/share/cc65 +datadir = $(PREFIX)/share/cc65 all lib: $(TARGETS) @@ -92,7 +92,7 @@ INSTALL = install define INSTALL_recipe -$(if $(prefix),,$(error variable `prefix' must be set)) +$(if $(PREFIX),,$(error variable `PREFIX' must be set)) $(INSTALL) -d $(DESTDIR)$(datadir)/$(dir) $(INSTALL) -m0644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir) diff --git a/samples/Makefile b/samples/Makefile index eb2b78f1c..59841d655 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -237,10 +237,10 @@ samples.atr: samples # Installation rules INSTALL = install -samplesdir = $(prefix)/share/cc65/samples +samplesdir = $(PREFIX)/share/cc65/samples install: - $(if $(prefix),,$(error variable `prefix' must be set)) + $(if $(PREFIX),,$(error variable `PREFIX' must be set)) $(INSTALL) -d $(DESTDIR)$(samplesdir) $(INSTALL) -d $(DESTDIR)$(samplesdir)/geos $(INSTALL) -d $(DESTDIR)$(samplesdir)/tutorial diff --git a/src/Makefile b/src/Makefile index 3ce4b676a..8b41ceb9c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -19,8 +19,8 @@ PROGS = ar65 \ .SUFFIXES: -bindir := $(prefix)/bin -datadir := $(if $(prefix),$(prefix)/share/cc65,$(abspath ..)) +bindir := $(PREFIX)/bin +datadir := $(if $(PREFIX),$(PREFIX)/share/cc65,$(abspath ..)) CA65_INC = $(datadir)/asminc CC65_INC = $(datadir)/include @@ -107,7 +107,7 @@ $(RM) /usr/local/bin/$(prog) endef # UNAVAIL_recipe install: - $(if $(prefix),,$(error variable `prefix' must be set)) + $(if $(PREFIX),,$(error variable `PREFIX' must be set)) $(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) ../bin/* $(DESTDIR)$(bindir) From c802c9c946376801a0bbf5c501f5f73716c2b00f Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Sat, 22 Jul 2017 15:49:34 +0200 Subject: [PATCH 162/199] joy: refactor generic joy_masks array indices and macros --- include/cbm.h | 7 +++++++ include/gamate.h | 26 +++++++++++--------------- include/joystick.h | 32 ++++++++++++++++++-------------- include/lynx.h | 9 +++++++++ include/nes.h | 16 ++++++++-------- include/pce.h | 20 ++++++++------------ 6 files changed, 61 insertions(+), 49 deletions(-) diff --git a/include/cbm.h b/include/cbm.h index 226a09793..27e82f9f3 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -75,6 +75,13 @@ +/* Expanding upon joystick.h */ +#define JOY_FIRE_IDX 4 + +#define JOY_FIRE(v) ((v) & joy_masks[JOY_FIRE_IDX]) + + + /*****************************************************************************/ /* Variables */ /*****************************************************************************/ diff --git a/include/gamate.h b/include/gamate.h index 96c70c9bc..7355ede84 100644 --- a/include/gamate.h +++ b/include/gamate.h @@ -80,17 +80,6 @@ bit 3: */ -#define JOY_DATA 0x4400 - -#define JOY_DATA_UP 0x01 -#define JOY_DATA_DOWN 0x02 -#define JOY_DATA_LEFT 0x04 -#define JOY_DATA_RIGHT 0x08 -#define JOY_DATA_FIRE_A 0x10 -#define JOY_DATA_FIRE_B 0x20 -#define JOY_DATA_START 0x40 -#define JOY_DATA_SELECT 0x80 - /* LCD resolution 160x152 in 4 greys/greens @@ -181,13 +170,20 @@ /* No support for dynamically loadable drivers */ #define DYN_DRV 0 +/* Expanding upon joystick.h */ +#define JOY_BTN_A_IDX 4 +#define JOY_BTN_B_IDX 5 +#define JOY_START_IDX 6 +#define JOY_SELECT_IDX 7 + +#define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX]) +#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX]) +#define JOY_START(v) ((v) & joy_masks[JOY_START_IDX]) +#define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX]) + /* The addresses of the static drivers */ extern void gamate_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ -#define JOY_FIRE_B 5 -#define JOY_START 6 -#define JOY_SELECT 7 - void waitvsync (void); /* Wait for start of next frame */ diff --git a/include/joystick.h b/include/joystick.h index 710d9b5a6..f08dd432a 100644 --- a/include/joystick.h +++ b/include/joystick.h @@ -52,27 +52,31 @@ #define JOY_ERR_NO_DEVICE 4 /* Device (hardware) not found */ /* Argument for the joy_read function */ -#define JOY_1 0 -#define JOY_2 1 +#define JOY_1 0 +#define JOY_2 1 /* The following codes are *indices* into the joy_masks array */ -#define JOY_UP 0 -#define JOY_DOWN 1 -#define JOY_LEFT 2 -#define JOY_RIGHT 3 -#define JOY_FIRE 4 -#define JOY_FIRE2 5 /* Second fire button if available */ +#define JOY_UP_IDX 0 +#define JOY_DOWN_IDX 1 +#define JOY_LEFT_IDX 2 +#define JOY_RIGHT_IDX 3 +#define JOY_BTN_1_IDX 4 /* Universally available */ +#define JOY_BTN_2_IDX 5 /* Second fire button if available */ +#define JOY_BTN_3_IDX 6 /* Third fire button if available */ +#define JOY_BTN_4_IDX 7 /* Fourth fire button if available */ /* Array of masks used to check the return value of joy_read for a state */ extern const unsigned char joy_masks[8]; /* Macros that evaluate the return code of joy_read */ -#define JOY_BTN_UP(v) ((v) & joy_masks[JOY_UP]) -#define JOY_BTN_DOWN(v) ((v) & joy_masks[JOY_DOWN]) -#define JOY_BTN_LEFT(v) ((v) & joy_masks[JOY_LEFT]) -#define JOY_BTN_RIGHT(v) ((v) & joy_masks[JOY_RIGHT]) -#define JOY_BTN_FIRE(v) ((v) & joy_masks[JOY_FIRE]) -#define JOY_BTN_FIRE2(v) ((v) & joy_masks[JOY_FIRE2]) +#define JOY_UP(v) ((v) & joy_masks[JOY_UP_IDX]) +#define JOY_DOWN(v) ((v) & joy_masks[JOY_DOWN_IDX]) +#define JOY_LEFT(v) ((v) & joy_masks[JOY_LEFT_IDX]) +#define JOY_RIGHT(v) ((v) & joy_masks[JOY_RIGHT_IDX]) +#define JOY_BTN_1(v) ((v) & joy_masks[JOY_BTN_1_IDX]) +#define JOY_BTN_2(v) ((v) & joy_masks[JOY_BTN_2_IDX]) +#define JOY_BTN_3(v) ((v) & joy_masks[JOY_BTN_3_IDX]) +#define JOY_BTN_4(v) ((v) & joy_masks[JOY_BTN_4_IDX]) /* The name of the standard joystick driver for a platform */ extern const char joy_stddrv[]; diff --git a/include/lynx.h b/include/lynx.h index 72f3d5bfd..c30ca6265 100644 --- a/include/lynx.h +++ b/include/lynx.h @@ -92,6 +92,15 @@ +/* Expanding upon joystick.h */ +#define JOY_BTN_A_IDX 4 +#define JOY_BTN_B_IDX 5 + +#define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX]) +#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX]) + + + /*****************************************************************************/ /* Variables */ /*****************************************************************************/ diff --git a/include/nes.h b/include/nes.h index 3e139e00c..0b65cdbe4 100644 --- a/include/nes.h +++ b/include/nes.h @@ -91,15 +91,15 @@ #define DYN_DRV 0 /* Expanding upon joystick.h */ -#define JOY_A 4 -#define JOY_B 5 -#define JOY_SELECT 6 -#define JOY_START 7 +#define JOY_BTN_A_IDX 4 +#define JOY_BTN_B_IDX 5 +#define JOY_SELECT_IDX 6 +#define JOY_START_IDX 7 -#define JOY_BTN_A(v) ((v) & joy_masks[JOY_A]) -#define JOY_BTN_B(v) ((v) & joy_masks[JOY_B]) -#define JOY_BTN_SELECT(v) ((v) & joy_masks[JOY_SELECT]) -#define JOY_BTN_START(v) ((v) & joy_masks[JOY_START]) +#define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX]) +#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX]) +#define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX]) +#define JOY_START(v) ((v) & joy_masks[JOY_START_IDX]) /* Define hardware */ diff --git a/include/pce.h b/include/pce.h index ac6b2503f..12b596cf9 100644 --- a/include/pce.h +++ b/include/pce.h @@ -77,23 +77,19 @@ #define DYN_DRV 0 /* Expanding upon joystick.h */ -#define JOY_I 4 -#define JOY_II 5 -#define JOY_SELECT 6 -#define JOY_RUN 7 +#define JOY_BTN_I_IDX 4 +#define JOY_BTN_II_IDX 5 +#define JOY_SELECT_IDX 6 +#define JOY_RUN_IDX 7 -#define JOY_BTN_I(v) ((v) & joy_masks[JOY_I]) -#define JOY_BTN_II(v) ((v) & joy_masks[JOY_II]) -#define JOY_BTN_SELECT(v) ((v) & joy_masks[JOY_SELECT]) -#define JOY_BTN_RUN(v) ((v) & joy_masks[JOY_RUN]) +#define JOY_BTN_I(v) ((v) & joy_masks[JOY_BTN_I_IDX]) +#define JOY_BTN_II(v) ((v) & joy_masks[JOY_BTN_II_IDX]) +#define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX]) +#define JOY_RUN(v) ((v) & joy_masks[JOY_RUN_IDX]) /* The addresses of the static drivers */ extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ -#define JOY_FIRE_B 5 -#define JOY_SELECT 6 -#define JOY_RUN 7 - void waitvsync (void); /* Wait for start of the next frame */ From a623169477d5925a1a4e43085f34d0f589804353 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Wed, 26 Jul 2017 11:15:49 -0400 Subject: [PATCH 163/199] Added ProDOS file type definitions --- .gitignore | 3 + include/apple2.h | 1 + include/apple2_filetype.h | 254 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 258 insertions(+) create mode 100644 include/apple2_filetype.h diff --git a/.gitignore b/.gitignore index ad4d26c3f..39d5b59fa 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ /testwrk/ /wrk/ /cc65.zip + +# Vim swap files +.*.swp diff --git a/include/apple2.h b/include/apple2.h index a1b094d4d..a2150c173 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -42,6 +42,7 @@ #endif +#include <apple2_filetype.h> /*****************************************************************************/ /* Data */ diff --git a/include/apple2_filetype.h b/include/apple2_filetype.h new file mode 100644 index 000000000..51e7d3e51 --- /dev/null +++ b/include/apple2_filetype.h @@ -0,0 +1,254 @@ +/*****************************************************************************/ +/* */ +/* apple2_filetype.h */ +/* */ +/* Apple ][ file type definitions */ +/* */ +/* */ +/* */ +/* (C) 2000 Kevin Ruland, <kevin@rodin.wustl.edu> */ +/* (C) 2003 Ullrich von Bassewitz, <uz@cc65.org> */ +/* */ +/* */ +/* 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 _APPLE2_FILETYPE_H +#define _APPLE2_FILETYPE_H + + + +/* Check for errors */ +#if !defined(__APPLE2__) +# error This module may only be used when compiling for the Apple ][! +#endif + + +/* ProDOS general file types */ +#define PRODOS_FILE_TYPE_UNK 0x00 /* Unknown */ +#define PRODOS_FILE_TYPE_BAD 0x01 /* Bad blocks */ +#define PRODOS_FILE_TYPE_PCD 0x02 /* Pascal code */ +#define PRODOS_FILE_TYPE_PTX 0x03 /* Pascal text */ +#define PRODOS_FILE_TYPE_TXT 0x04 /* ASCII text */ +#define PRODOS_FILE_TYPE_PDA 0x05 /* Pascal data */ +#define PRODOS_FILE_TYPE_BIN 0x06 /* Binary */ +#define PRODOS_FILE_TYPE_FNT 0x07 /* Apple III font */ +#define PRODOS_FILE_TYPE_FOT 0x08 /* Hi-res, dbl hi-res graphics */ +#define PRODOS_FILE_TYPE_BA3 0x09 /* Apple III BASIC program */ +#define PRODOS_FILE_TYPE_DA3 0x09 /* Apple III BASIC data */ +#define PRODOS_FILE_TYPE_WPF 0x0A /* Generic word processing */ +#define PRODOS_FILE_TYPE_SOS 0x0B /* SOS system */ +#define PRODOS_FILE_TYPE_DIR 0x0F /* ProDOS directory */ + +/* ProDOS productivity file types */ +#define PRODOS_FILE_TYPE_RPD 0x10 /* RPS data */ +#define PRODOS_FILE_TYPE_RPI 0x11 /* RPS index */ +#define PRODOS_FILE_TYPE_AFD 0x12 /* AppleFile discard */ +#define PRODOS_FILE_TYPE_AFM 0x13 /* AppleFile model */ +#define PRODOS_FILE_TYPE_AFR 0x14 /* AppleFile report */ +#define PRODOS_FILE_TYPE_SCL 0x15 /* Screen library */ +#define PRODOS_FILE_TYPE_PFS 0x16 /* PFS document */ +#define PRODOS_FILE_TYPE_ADB 0x19 /* AppleWorks database */ +#define PRODOS_FILE_TYPE_AWP 0x1A /* AppleWorks word processing */ +#define PRODOS_FILE_TYPE_ASP 0x1B /* AppleWorks spreadsheet */ + +/* ProDOS code file types */ +#define PRODOS_FILE_TYPE_TDM 0x20 /* Desktop Manager */ +#define PRODOS_FILE_TYPE_IPS 0x21 /* Instant Pascal source */ +#define PRODOS_FILE_TYPE_UPV 0x22 /* USCD Pascal volume */ +#define PRODOS_FILE_TYPE_3SD 0x29 /* SOS directory */ +#define PRODOS_FILE_TYPE_8SC 0x2A /* Source code */ +#define PRODOS_FILE_TYPE_8OB 0x2B /* Object code */ +#define PRODOS_FILE_TYPE_8IC 0x2C /* Interpreted code */ +#define PRODOS_FILE_TYPE_8LD 0x2D /* Language data */ +#define PRODOS_FILE_TYPE_P8C 0x2E /* ProDOS 8 code module */ + +/* ProDOS miscellaneous file types */ +#define PRODOS_FILE_TYPE_OCR 0x41 /* Optical char recognition */ +#define PRODOS_FILE_TYPE_FTD 0x42 /* File type definitions */ + +/* ProDOS Apple IIgs general file types */ +#define PRODOS_FILE_TYPE_GWP 0x50 /* Apple IIgs word processing */ +#define PRODOS_FILE_TYPE_GSS 0x51 /* Apple IIgs spreadsheet */ +#define PRODOS_FILE_TYPE_GDB 0x52 /* Apple IIgs database */ +#define PRODOS_FILE_TYPE_DRW 0x53 /* Object oriented graphics */ +#define PRODOS_FILE_TYPE_GDP 0x54 /* Apple IIgs desktop publish */ +#define PRODOS_FILE_TYPE_HMD 0x55 /* HyperMedia */ +#define PRODOS_FILE_TYPE_EDU 0x56 /* Educational program data */ +#define PRODOS_FILE_TYPE_STN 0x57 /* Stationary */ +#define PRODOS_FILE_TYPE_HLP 0x58 /* Help */ +#define PRODOS_FILE_TYPE_COM 0x59 /* Communications */ +#define PRODOS_FILE_TYPE_CFG 0x5A /* Configuration */ +#define PRODOS_FILE_TYPE_ANM 0x5B /* Animation */ +#define PRODOS_FILE_TYPE_MUM 0x5C /* Multimedia */ +#define PRODOS_FILE_TYPE_ENT 0x5D /* Entertainment */ +#define PRODOS_FILE_TYPE_DVU 0x5E /* Development utility */ + +/* ProDOS PC Transporter file types */ +#define PRODOS_FILE_TYPE_PRE 0x60 /* PC pre-boot */ +#define PRODOS_FILE_TYPE_BIO 0x6B /* PC BIOS */ +#define PRODOS_FILE_TYPE_NCF 0x66 /* ProDOS File Nav command file */ +#define PRODOS_FILE_TYPE_DVR 0x6D /* PC driver */ +#define PRODOS_FILE_TYPE_PRE2 0x6E /* PC pre-boot */ +#define PRODOS_FILE_TYPE_HDV 0x6F /* PC hard disk image */ + +/* ProDOS Kreative Software file types */ +#define PRODOS_FILE_TYPE_SN2 0x70 /* Sabine's Notebook 2.0 */ +#define PRODOS_FILE_TYPE_KMT 0x71 +#define PRODOS_FILE_TYPE_DSR 0x72 +#define PRODOS_FILE_TYPE_BAN 0x73 +#define PRODOS_FILE_TYPE_CG7 0x74 +#define PRODOS_FILE_TYPE_TNJ 0x75 +#define PRODOS_FILE_TYPE_SA7 0x76 +#define PRODOS_FILE_TYPE_KES 0x77 +#define PRODOS_FILE_TYPE_JAP 0x78 +#define PRODOS_FILE_TYPE_CSL 0x79 +#define PRODOS_FILE_TYPE_TME 0x7A +#define PRODOS_FILE_TYPE_TLB 0x7B +#define PRODOS_FILE_TYPE_MR7 0x7C +#define PRODOS_FILE_TYPE_MLR 0x7D /* Mika City */ +#define PRODOS_FILE_TYPE_MMM 0x7E +#define PRODOS_FILE_TYPE_JCP 0x7F + +/* ProDOS GEOS file types */ +#define PRODOS_FILE_TYPE_GES 0x80 /* GEOS system file */ +#define PRODOS_FILE_TYPE_GEA 0x81 /* GEOS desk accessory */ +#define PRODOS_FILE_TYPE_GEO 0x82 /* GEOS application */ +#define PRODOS_FILE_TYPE_GED 0x83 /* GEOS document */ +#define PRODOS_FILE_TYPE_GEF 0x84 /* GEOS font */ +#define PRODOS_FILE_TYPE_GEP 0x85 /* GEOS printer driver */ +#define PRODOS_FILE_TYPE_GEI 0x86 /* GEOS input driver */ +#define PRODOS_FILE_TYPE_GEX 0x87 /* GEOS auxiliary driver */ +#define PRODOS_FILE_TYPE_GEV 0x89 /* GEOS swap file */ +#define PRODOS_FILE_TYPE_GEC 0x8B /* GEOS clock driver */ +#define PRODOS_FILE_TYPE_GEK 0x8C /* GEOS interface card driver */ +#define PRODOS_FILE_TYPE_GEW 0x8D /* GEOS formatting data */ + +/* ProDOS Apple IIgs BASIC file types */ +#define PRODOS_FILE_TYPE_WP 0xA0 /* WordPerfect */ +#define PRODOS_FILE_TYPE_GSB 0xAB /* Apple IIgs BASIC program */ +#define PRODOS_FILE_TYPE_TDF 0xAB /* Apple IIgs BASIC TDF */ +#define PRODOS_FILE_TYPE_BDF 0xAB /* Apple IIgs BASIC data */ + +/* ProDOS Apple IIgs system file types */ +#define PRODOS_FILE_TYPE_SRC 0xB0 /* Apple IIgs source code */ +#define PRODOS_FILE_TYPE_OBJ 0xB1 /* Apple IIgs object code */ +#define PRODOS_FILE_TYPE_LIB 0xB2 /* Apple IIgs library */ +#define PRODOS_FILE_TYPE_S16 0xB3 /* Apple IIgs application pgm */ +#define PRODOS_FILE_TYPE_RTL 0xB4 /* Apple IIgs runtime library */ +#define PRODOS_FILE_TYPE_EXE 0xB5 /* Apple IIgs shell script */ +#define PRODOS_FILE_TYPE_PIF 0xB6 /* Apple IIgs permanent init */ +#define PRODOS_FILE_TYPE_TIF 0xB7 /* Apple IIgs temporary init */ +#define PRODOS_FILE_TYPE_NDA 0xB8 /* Apple IIgs new desk accesry */ +#define PRODOS_FILE_TYPE_CDA 0xB9 /* Apple IIgs classic desk aces */ +#define PRODOS_FILE_TYPE_TOL 0xBA /* Apple IIgs tool */ +#define PRODOS_FILE_TYPE_DRV 0xBB /* Apple IIgs device driver */ +#define PRODOS_FILE_TYPE_LDF 0xBC /* Apple IIgs generic load file */ +#define PRODOS_FILE_TYPE_FST 0xBD /* Apple IIgs file sys translat */ +#define PRODOS_FILE_TYPE_DOC 0xBF /* Apple IIgs document */ + +/* ProDOS graphics file types */ +#define PRODOS_FILE_TYPE_PNT 0xC0 /* Apple IIgs packed sup hi-res */ +#define PRODOS_FILE_TYPE_PIC 0xC1 /* Apple IIgs super hi-res */ +#define PRODOS_FILE_TYPE_ANI 0xC2 /* PaintWorks animation */ +#define PRODOS_FILE_TYPE_PAL 0xC3 /* PaintWorks palette */ +#define PRODOS_FILE_TYPE_OOG 0xC5 /* Object-oriented graphics */ +#define PRODOS_FILE_TYPE_SCR 0xC6 /* Script */ +#define PRODOS_FILE_TYPE_CDV 0xC7 /* Apple IIgs control panel */ +#define PRODOS_FILE_TYPE_FON 0xC8 /* Apple IIgs font */ +#define PRODOS_FILE_TYPE_FND 0xC9 /* Apple IIgs Finder data */ +#define PRODOS_FILE_TYPE_ICN 0xCA /* Apple IIgs icon */ + +/* ProDOS audio file types */ +#define PRODOS_FILE_TYPE_MUS 0xD5 /* Music */ +#define PRODOS_FILE_TYPE_INS 0xD6 /* Instrument */ +#define PRODOS_FILE_TYPE_MID 0xD7 /* MIDI */ +#define PRODOS_FILE_TYPE_SND 0xD8 /* Apple IIgs audio */ +#define PRODOS_FILE_TYPE_DBM 0xDB /* DB master document */ + +/* ProDOS miscellaneous file types */ +#define PRODOS_FILE_TYPE_LBR 0xE0 /* Archive */ +#define PRODOS_FILE_TYPE_ATK 0xE2 /* AppleTalk data */ +#define PRODOS_FILE_TYPE_R16 0xEE /* EDASM 816 relocatable code */ +#define PRODOS_FILE_TYPE_PAR 0xEF /* Pascal area */ + +/* ProDOS system file types */ +#define PRODOS_FILE_TYPE_CMD 0xF0 /* ProDOS command file */ +#define PRODOS_T_OVL 0xF1 /* User defined 1 */ +#define PRODOS_FILE_TYPE_UD2 0xF2 /* User defined 2 */ +#define PRODOS_FILE_TYPE_UD3 0xF3 /* User defined 3 */ +#define PRODOS_FILE_TYPE_UD4 0xF4 /* User defined 4 */ +#define PRODOS_FILE_TYPE_BAT 0xF5 /* User defined 5 */ +#define PRODOS_FILE_TYPE_UD6 0xF6 /* User defined 6 */ +#define PRODOS_FILE_TYPE_UD7 0xF7 /* User defined 7 */ +#define PRODOS_FILE_TYPE_PRG 0xF8 /* User defined 8 */ +#define PRODOS_FILE_TYPE_P16 0xF9 /* ProDOS-16 system file */ +#define PRODOS_FILE_TYPE_INT 0xFA /* Integer BASIC program */ +#define PRODOS_FILE_TYPE_IVR 0xFB /* Integer BASIC variables */ +#define PRODOS_FILE_TYPE_BAS 0xFC /* Applesoft BASIC program */ +#define PRODOS_FILE_TYPE_VAR 0xFD /* Applesoft BASIC variables */ +#define PRODOS_FILE_TYPE_REL 0xFE /* EDASM relocatable code */ +#define PRODOS_FILE_TYPE_SYS 0xFF /* ProDOS-8 system file */ + +/* The auxiliary type of a text file specifies its record length. +** A record length of 0 indicates a sequential text file, which is +** equivalent to text files of other operating systems like MacOS +** or Windows, except that lines are delimited by carriage returns +** only. An auxiliary type value greater than 0 for a text file, +** which is the record length, indicates a random access text file +** with fixed-length lines. +*/ +#define PRODOS_AUX_T_TXT_SEQ 0x0000 /* Sequential text */ + +/* 8IC auxiliary type */ +#define PRODOS_AUX_T_8IC_APEX_PGM 0x8003 /* Apex program */ + +/* GWP auxiliary types */ +#define PRODOS_AUX_T_GWP_TEACH 0x5445 /* Teach */ +#define PRODOS_AUX_T_GWP_DELUXEWRITE 0x8001 /* DeluxeWrite */ +#define PRODOS_AUX_T_GWP_APPLEWORKS_GS 0x8010 /* AppleWorks GS */ + +/* GSS auxiliary type */ +#define PRODOS_AUX_T_GSS_APPLEWORKS_GS 0x8010 /* AppleWorks GS */ + +/* GDB auxiliary types */ +#define PRODOS_GDB_AUX_TYPE_APLWRKSGS 0x8010 /* AppleWorks GS DB */ +#define PRODOS_GDB_AUX_TYPE_AWGS_TMPL 0x8011 /* AWGS template */ +#define PRODOS_GDB_AUX_TYPE_GSAS 0x8013 + +/* DRW auxiliary type */ +#define PRODOS_DRW_AUX_TYPE_APLWRKSGS 0x8013 /* AWGS O-O graphics */ + +/* GDP auxiliary types */ +#define PRODOS_GDP_AUX_TYPE_GRFCWRTR 0x8002 /* AWGS GraphicWriter */ +#define PRODOS_GDP_AUX_TYPE_APLWRKSGS 0x8010 /* AWGS */ + +/* HMD auxiliary types */ +#define PRODOS_HMD_AUX_TYPE_HYPRCRDGS 0x0001 /* HyperCard GS */ +#define PRODOS_HMD_AUX_TYPE_TUTORTECH 0x8001 /* Tutor-Tech */ +#define PRODOS_HMD_AUX_TYPE_HYPRSTDIO 0x8002 /* HyperStudio */ +#define PRODOS_HMD_AUX_TYPE_NEXUS 0x8003 /* Nexus */ + +/* COM auxiliary type */ +#define PRODOS_COM_AUX_TYPE_APLWRKSGS 0x8003 /* AppleWorks GS */ + +/* End of apple2_filetypes.h */ +#endif From e64e11d2c5e43962967b6bc9664fd67e113c38fd Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Thu, 27 Jul 2017 14:44:02 -0400 Subject: [PATCH 164/199] Finished adding all types and comments --- include/apple2_filetype.h | 372 ++++++++++++++++++++++---------------- 1 file changed, 213 insertions(+), 159 deletions(-) diff --git a/include/apple2_filetype.h b/include/apple2_filetype.h index 51e7d3e51..96cf49581 100644 --- a/include/apple2_filetype.h +++ b/include/apple2_filetype.h @@ -42,171 +42,178 @@ #endif + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + /* ProDOS general file types */ -#define PRODOS_FILE_TYPE_UNK 0x00 /* Unknown */ -#define PRODOS_FILE_TYPE_BAD 0x01 /* Bad blocks */ -#define PRODOS_FILE_TYPE_PCD 0x02 /* Pascal code */ -#define PRODOS_FILE_TYPE_PTX 0x03 /* Pascal text */ -#define PRODOS_FILE_TYPE_TXT 0x04 /* ASCII text */ -#define PRODOS_FILE_TYPE_PDA 0x05 /* Pascal data */ -#define PRODOS_FILE_TYPE_BIN 0x06 /* Binary */ -#define PRODOS_FILE_TYPE_FNT 0x07 /* Apple III font */ -#define PRODOS_FILE_TYPE_FOT 0x08 /* Hi-res, dbl hi-res graphics */ -#define PRODOS_FILE_TYPE_BA3 0x09 /* Apple III BASIC program */ -#define PRODOS_FILE_TYPE_DA3 0x09 /* Apple III BASIC data */ -#define PRODOS_FILE_TYPE_WPF 0x0A /* Generic word processing */ -#define PRODOS_FILE_TYPE_SOS 0x0B /* SOS system */ -#define PRODOS_FILE_TYPE_DIR 0x0F /* ProDOS directory */ +#define PRODOS_T_UNK 0x00 /* Unknown */ +#define PRODOS_T_BAD 0x01 /* Bad blocks */ +#define PRODOS_T_PCD 0x02 /* Pascal code */ +#define PRODOS_T_PTX 0x03 /* Pascal text */ +#define PRODOS_T_TXT 0x04 /* ASCII text */ +#define PRODOS_T_PDA 0x05 /* Pascal data */ +#define PRODOS_T_BIN 0x06 /* Binary */ +#define PRODOS_T_FNT 0x07 /* Apple III font */ +#define PRODOS_T_FOT 0x08 /* Hi-res, dbl hi-res graphics */ +#define PRODOS_T_BA3 0x09 /* Apple III BASIC program */ +#define PRODOS_T_DA3 0x09 /* Apple III BASIC data */ +#define PRODOS_T_WPF 0x0A /* Generic word processing */ +#define PRODOS_T_SOS 0x0B /* SOS system */ +#define PRODOS_T_DIR 0x0F /* ProDOS directory */ /* ProDOS productivity file types */ -#define PRODOS_FILE_TYPE_RPD 0x10 /* RPS data */ -#define PRODOS_FILE_TYPE_RPI 0x11 /* RPS index */ -#define PRODOS_FILE_TYPE_AFD 0x12 /* AppleFile discard */ -#define PRODOS_FILE_TYPE_AFM 0x13 /* AppleFile model */ -#define PRODOS_FILE_TYPE_AFR 0x14 /* AppleFile report */ -#define PRODOS_FILE_TYPE_SCL 0x15 /* Screen library */ -#define PRODOS_FILE_TYPE_PFS 0x16 /* PFS document */ -#define PRODOS_FILE_TYPE_ADB 0x19 /* AppleWorks database */ -#define PRODOS_FILE_TYPE_AWP 0x1A /* AppleWorks word processing */ -#define PRODOS_FILE_TYPE_ASP 0x1B /* AppleWorks spreadsheet */ +#define PRODOS_T_RPD 0x10 /* RPS data */ +#define PRODOS_T_RPI 0x11 /* RPS index */ +#define PRODOS_T_AFD 0x12 /* AppleFile discard */ +#define PRODOS_T_AFM 0x13 /* AppleFile model */ +#define PRODOS_T_AFR 0x14 /* AppleFile report */ +#define PRODOS_T_SCL 0x15 /* Screen library */ +#define PRODOS_T_PFS 0x16 /* PFS document */ +#define PRODOS_T_ADB 0x19 /* AppleWorks database */ +#define PRODOS_T_AWP 0x1A /* AppleWorks word processing */ +#define PRODOS_T_ASP 0x1B /* AppleWorks spreadsheet */ /* ProDOS code file types */ -#define PRODOS_FILE_TYPE_TDM 0x20 /* Desktop Manager */ -#define PRODOS_FILE_TYPE_IPS 0x21 /* Instant Pascal source */ -#define PRODOS_FILE_TYPE_UPV 0x22 /* USCD Pascal volume */ -#define PRODOS_FILE_TYPE_3SD 0x29 /* SOS directory */ -#define PRODOS_FILE_TYPE_8SC 0x2A /* Source code */ -#define PRODOS_FILE_TYPE_8OB 0x2B /* Object code */ -#define PRODOS_FILE_TYPE_8IC 0x2C /* Interpreted code */ -#define PRODOS_FILE_TYPE_8LD 0x2D /* Language data */ -#define PRODOS_FILE_TYPE_P8C 0x2E /* ProDOS 8 code module */ +#define PRODOS_T_TDM 0x20 /* Desktop Manager */ +#define PRODOS_T_IPS 0x21 /* Instant Pascal source */ +#define PRODOS_T_UPV 0x22 /* USCD Pascal volume */ +#define PRODOS_T_3SD 0x29 /* SOS directory */ +#define PRODOS_T_8SC 0x2A /* Source code */ +#define PRODOS_T_8OB 0x2B /* Object code */ +#define PRODOS_T_8IC 0x2C /* Interpreted code */ +#define PRODOS_T_8LD 0x2D /* Language data */ +#define PRODOS_T_P8C 0x2E /* ProDOS 8 code module */ /* ProDOS miscellaneous file types */ -#define PRODOS_FILE_TYPE_OCR 0x41 /* Optical char recognition */ -#define PRODOS_FILE_TYPE_FTD 0x42 /* File type definitions */ +#define PRODOS_T_OCR 0x41 /* Optical char recognition */ +#define PRODOS_T_FTD 0x42 /* File type definitions */ /* ProDOS Apple IIgs general file types */ -#define PRODOS_FILE_TYPE_GWP 0x50 /* Apple IIgs word processing */ -#define PRODOS_FILE_TYPE_GSS 0x51 /* Apple IIgs spreadsheet */ -#define PRODOS_FILE_TYPE_GDB 0x52 /* Apple IIgs database */ -#define PRODOS_FILE_TYPE_DRW 0x53 /* Object oriented graphics */ -#define PRODOS_FILE_TYPE_GDP 0x54 /* Apple IIgs desktop publish */ -#define PRODOS_FILE_TYPE_HMD 0x55 /* HyperMedia */ -#define PRODOS_FILE_TYPE_EDU 0x56 /* Educational program data */ -#define PRODOS_FILE_TYPE_STN 0x57 /* Stationary */ -#define PRODOS_FILE_TYPE_HLP 0x58 /* Help */ -#define PRODOS_FILE_TYPE_COM 0x59 /* Communications */ -#define PRODOS_FILE_TYPE_CFG 0x5A /* Configuration */ -#define PRODOS_FILE_TYPE_ANM 0x5B /* Animation */ -#define PRODOS_FILE_TYPE_MUM 0x5C /* Multimedia */ -#define PRODOS_FILE_TYPE_ENT 0x5D /* Entertainment */ -#define PRODOS_FILE_TYPE_DVU 0x5E /* Development utility */ +#define PRODOS_T_GWP 0x50 /* Apple IIgs word processing */ +#define PRODOS_T_GSS 0x51 /* Apple IIgs spreadsheet */ +#define PRODOS_T_GDB 0x52 /* Apple IIgs database */ +#define PRODOS_T_DRW 0x53 /* Object oriented graphics */ +#define PRODOS_T_GDP 0x54 /* Apple IIgs desktop publish */ +#define PRODOS_T_HMD 0x55 /* HyperMedia */ +#define PRODOS_T_EDU 0x56 /* Educational program data */ +#define PRODOS_T_STN 0x57 /* Stationary */ +#define PRODOS_T_HLP 0x58 /* Help */ +#define PRODOS_T_COM 0x59 /* Communications */ +#define PRODOS_T_CFG 0x5A /* Configuration */ +#define PRODOS_T_ANM 0x5B /* Animation */ +#define PRODOS_T_MUM 0x5C /* Multimedia */ +#define PRODOS_T_ENT 0x5D /* Entertainment */ +#define PRODOS_T_DVU 0x5E /* Development utility */ /* ProDOS PC Transporter file types */ -#define PRODOS_FILE_TYPE_PRE 0x60 /* PC pre-boot */ -#define PRODOS_FILE_TYPE_BIO 0x6B /* PC BIOS */ -#define PRODOS_FILE_TYPE_NCF 0x66 /* ProDOS File Nav command file */ -#define PRODOS_FILE_TYPE_DVR 0x6D /* PC driver */ -#define PRODOS_FILE_TYPE_PRE2 0x6E /* PC pre-boot */ -#define PRODOS_FILE_TYPE_HDV 0x6F /* PC hard disk image */ +#define PRODOS_T_PRE 0x60 /* PC pre-boot */ +#define PRODOS_T_BIO 0x6B /* PC BIOS */ +#define PRODOS_T_NCF 0x66 /* ProDOS File Nav command file */ +#define PRODOS_T_DVR 0x6D /* PC driver */ +#define PRODOS_T_PRE2 0x6E /* PC pre-boot */ +#define PRODOS_T_HDV 0x6F /* PC hard disk image */ /* ProDOS Kreative Software file types */ -#define PRODOS_FILE_TYPE_SN2 0x70 /* Sabine's Notebook 2.0 */ -#define PRODOS_FILE_TYPE_KMT 0x71 -#define PRODOS_FILE_TYPE_DSR 0x72 -#define PRODOS_FILE_TYPE_BAN 0x73 -#define PRODOS_FILE_TYPE_CG7 0x74 -#define PRODOS_FILE_TYPE_TNJ 0x75 -#define PRODOS_FILE_TYPE_SA7 0x76 -#define PRODOS_FILE_TYPE_KES 0x77 -#define PRODOS_FILE_TYPE_JAP 0x78 -#define PRODOS_FILE_TYPE_CSL 0x79 -#define PRODOS_FILE_TYPE_TME 0x7A -#define PRODOS_FILE_TYPE_TLB 0x7B -#define PRODOS_FILE_TYPE_MR7 0x7C -#define PRODOS_FILE_TYPE_MLR 0x7D /* Mika City */ -#define PRODOS_FILE_TYPE_MMM 0x7E -#define PRODOS_FILE_TYPE_JCP 0x7F +#define PRODOS_T_SN2 0x70 /* Sabine's Notebook 2.0 */ +#define PRODOS_T_KMT 0x71 +#define PRODOS_T_DSR 0x72 +#define PRODOS_T_BAN 0x73 +#define PRODOS_T_CG7 0x74 +#define PRODOS_T_TNJ 0x75 +#define PRODOS_T_SA7 0x76 +#define PRODOS_T_KES 0x77 +#define PRODOS_T_JAP 0x78 +#define PRODOS_T_CSL 0x79 +#define PRODOS_T_TME 0x7A +#define PRODOS_T_TLB 0x7B +#define PRODOS_T_MR7 0x7C +#define PRODOS_T_MLR 0x7D /* Mika City */ +#define PRODOS_T_MMM 0x7E +#define PRODOS_T_JCP 0x7F /* ProDOS GEOS file types */ -#define PRODOS_FILE_TYPE_GES 0x80 /* GEOS system file */ -#define PRODOS_FILE_TYPE_GEA 0x81 /* GEOS desk accessory */ -#define PRODOS_FILE_TYPE_GEO 0x82 /* GEOS application */ -#define PRODOS_FILE_TYPE_GED 0x83 /* GEOS document */ -#define PRODOS_FILE_TYPE_GEF 0x84 /* GEOS font */ -#define PRODOS_FILE_TYPE_GEP 0x85 /* GEOS printer driver */ -#define PRODOS_FILE_TYPE_GEI 0x86 /* GEOS input driver */ -#define PRODOS_FILE_TYPE_GEX 0x87 /* GEOS auxiliary driver */ -#define PRODOS_FILE_TYPE_GEV 0x89 /* GEOS swap file */ -#define PRODOS_FILE_TYPE_GEC 0x8B /* GEOS clock driver */ -#define PRODOS_FILE_TYPE_GEK 0x8C /* GEOS interface card driver */ -#define PRODOS_FILE_TYPE_GEW 0x8D /* GEOS formatting data */ +#define PRODOS_T_GES 0x80 /* GEOS system file */ +#define PRODOS_T_GEA 0x81 /* GEOS desk accessory */ +#define PRODOS_T_GEO 0x82 /* GEOS application */ +#define PRODOS_T_GED 0x83 /* GEOS document */ +#define PRODOS_T_GEF 0x84 /* GEOS font */ +#define PRODOS_T_GEP 0x85 /* GEOS printer driver */ +#define PRODOS_T_GEI 0x86 /* GEOS input driver */ +#define PRODOS_T_GEX 0x87 /* GEOS auxiliary driver */ +#define PRODOS_T_GEV 0x89 /* GEOS swap file */ +#define PRODOS_T_GEC 0x8B /* GEOS clock driver */ +#define PRODOS_T_GEK 0x8C /* GEOS interface card driver */ +#define PRODOS_T_GEW 0x8D /* GEOS formatting data */ /* ProDOS Apple IIgs BASIC file types */ -#define PRODOS_FILE_TYPE_WP 0xA0 /* WordPerfect */ -#define PRODOS_FILE_TYPE_GSB 0xAB /* Apple IIgs BASIC program */ -#define PRODOS_FILE_TYPE_TDF 0xAB /* Apple IIgs BASIC TDF */ -#define PRODOS_FILE_TYPE_BDF 0xAB /* Apple IIgs BASIC data */ +#define PRODOS_T_WP 0xA0 /* WordPerfect */ +#define PRODOS_T_GSB 0xAB /* Apple IIgs BASIC program */ +#define PRODOS_T_TDF 0xAB /* Apple IIgs BASIC TDF */ +#define PRODOS_T_BDF 0xAB /* Apple IIgs BASIC data */ /* ProDOS Apple IIgs system file types */ -#define PRODOS_FILE_TYPE_SRC 0xB0 /* Apple IIgs source code */ -#define PRODOS_FILE_TYPE_OBJ 0xB1 /* Apple IIgs object code */ -#define PRODOS_FILE_TYPE_LIB 0xB2 /* Apple IIgs library */ -#define PRODOS_FILE_TYPE_S16 0xB3 /* Apple IIgs application pgm */ -#define PRODOS_FILE_TYPE_RTL 0xB4 /* Apple IIgs runtime library */ -#define PRODOS_FILE_TYPE_EXE 0xB5 /* Apple IIgs shell script */ -#define PRODOS_FILE_TYPE_PIF 0xB6 /* Apple IIgs permanent init */ -#define PRODOS_FILE_TYPE_TIF 0xB7 /* Apple IIgs temporary init */ -#define PRODOS_FILE_TYPE_NDA 0xB8 /* Apple IIgs new desk accesry */ -#define PRODOS_FILE_TYPE_CDA 0xB9 /* Apple IIgs classic desk aces */ -#define PRODOS_FILE_TYPE_TOL 0xBA /* Apple IIgs tool */ -#define PRODOS_FILE_TYPE_DRV 0xBB /* Apple IIgs device driver */ -#define PRODOS_FILE_TYPE_LDF 0xBC /* Apple IIgs generic load file */ -#define PRODOS_FILE_TYPE_FST 0xBD /* Apple IIgs file sys translat */ -#define PRODOS_FILE_TYPE_DOC 0xBF /* Apple IIgs document */ +#define PRODOS_T_SRC 0xB0 /* Apple IIgs source code */ +#define PRODOS_T_OBJ 0xB1 /* Apple IIgs object code */ +#define PRODOS_T_LIB 0xB2 /* Apple IIgs library */ +#define PRODOS_T_S16 0xB3 /* Apple IIgs application pgm */ +#define PRODOS_T_RTL 0xB4 /* Apple IIgs runtime library */ +#define PRODOS_T_EXE 0xB5 /* Apple IIgs shell script */ +#define PRODOS_T_PIF 0xB6 /* Apple IIgs permanent init */ +#define PRODOS_T_TIF 0xB7 /* Apple IIgs temporary init */ +#define PRODOS_T_NDA 0xB8 /* Apple IIgs new desk accesry */ +#define PRODOS_T_CDA 0xB9 /* Apple IIgs classic desk aces */ +#define PRODOS_T_TOL 0xBA /* Apple IIgs tool */ +#define PRODOS_T_DRV 0xBB /* Apple IIgs device driver */ +#define PRODOS_T_LDF 0xBC /* Apple IIgs generic load file */ +#define PRODOS_T_FST 0xBD /* Apple IIgs file sys translat */ +#define PRODOS_T_DOC 0xBF /* Apple IIgs document */ /* ProDOS graphics file types */ -#define PRODOS_FILE_TYPE_PNT 0xC0 /* Apple IIgs packed sup hi-res */ -#define PRODOS_FILE_TYPE_PIC 0xC1 /* Apple IIgs super hi-res */ -#define PRODOS_FILE_TYPE_ANI 0xC2 /* PaintWorks animation */ -#define PRODOS_FILE_TYPE_PAL 0xC3 /* PaintWorks palette */ -#define PRODOS_FILE_TYPE_OOG 0xC5 /* Object-oriented graphics */ -#define PRODOS_FILE_TYPE_SCR 0xC6 /* Script */ -#define PRODOS_FILE_TYPE_CDV 0xC7 /* Apple IIgs control panel */ -#define PRODOS_FILE_TYPE_FON 0xC8 /* Apple IIgs font */ -#define PRODOS_FILE_TYPE_FND 0xC9 /* Apple IIgs Finder data */ -#define PRODOS_FILE_TYPE_ICN 0xCA /* Apple IIgs icon */ +#define PRODOS_T_PNT 0xC0 /* Apple IIgs packed sup hi-res */ +#define PRODOS_T_PIC 0xC1 /* Apple IIgs super hi-res */ +#define PRODOS_T_ANI 0xC2 /* PaintWorks animation */ +#define PRODOS_T_PAL 0xC3 /* PaintWorks palette */ +#define PRODOS_T_OOG 0xC5 /* Object-oriented graphics */ +#define PRODOS_T_SCR 0xC6 /* Script */ +#define PRODOS_T_CDV 0xC7 /* Apple IIgs control panel */ +#define PRODOS_T_FON 0xC8 /* Apple IIgs font */ +#define PRODOS_T_FND 0xC9 /* Apple IIgs Finder data */ +#define PRODOS_T_ICN 0xCA /* Apple IIgs icon */ /* ProDOS audio file types */ -#define PRODOS_FILE_TYPE_MUS 0xD5 /* Music */ -#define PRODOS_FILE_TYPE_INS 0xD6 /* Instrument */ -#define PRODOS_FILE_TYPE_MID 0xD7 /* MIDI */ -#define PRODOS_FILE_TYPE_SND 0xD8 /* Apple IIgs audio */ -#define PRODOS_FILE_TYPE_DBM 0xDB /* DB master document */ +#define PRODOS_T_MUS 0xD5 /* Music */ +#define PRODOS_T_INS 0xD6 /* Instrument */ +#define PRODOS_T_MID 0xD7 /* MIDI */ +#define PRODOS_T_SND 0xD8 /* Apple IIgs audio */ +#define PRODOS_T_DBM 0xDB /* DB master document */ /* ProDOS miscellaneous file types */ -#define PRODOS_FILE_TYPE_LBR 0xE0 /* Archive */ -#define PRODOS_FILE_TYPE_ATK 0xE2 /* AppleTalk data */ -#define PRODOS_FILE_TYPE_R16 0xEE /* EDASM 816 relocatable code */ -#define PRODOS_FILE_TYPE_PAR 0xEF /* Pascal area */ +#define PRODOS_T_LBR 0xE0 /* Archive */ +#define PRODOS_T_ATK 0xE2 /* AppleTalk data */ +#define PRODOS_T_R16 0xEE /* EDASM 816 relocatable code */ +#define PRODOS_T_PAR 0xEF /* Pascal area */ /* ProDOS system file types */ -#define PRODOS_FILE_TYPE_CMD 0xF0 /* ProDOS command file */ +#define PRODOS_T_CMD 0xF0 /* ProDOS command file */ #define PRODOS_T_OVL 0xF1 /* User defined 1 */ -#define PRODOS_FILE_TYPE_UD2 0xF2 /* User defined 2 */ -#define PRODOS_FILE_TYPE_UD3 0xF3 /* User defined 3 */ -#define PRODOS_FILE_TYPE_UD4 0xF4 /* User defined 4 */ -#define PRODOS_FILE_TYPE_BAT 0xF5 /* User defined 5 */ -#define PRODOS_FILE_TYPE_UD6 0xF6 /* User defined 6 */ -#define PRODOS_FILE_TYPE_UD7 0xF7 /* User defined 7 */ -#define PRODOS_FILE_TYPE_PRG 0xF8 /* User defined 8 */ -#define PRODOS_FILE_TYPE_P16 0xF9 /* ProDOS-16 system file */ -#define PRODOS_FILE_TYPE_INT 0xFA /* Integer BASIC program */ -#define PRODOS_FILE_TYPE_IVR 0xFB /* Integer BASIC variables */ -#define PRODOS_FILE_TYPE_BAS 0xFC /* Applesoft BASIC program */ -#define PRODOS_FILE_TYPE_VAR 0xFD /* Applesoft BASIC variables */ -#define PRODOS_FILE_TYPE_REL 0xFE /* EDASM relocatable code */ -#define PRODOS_FILE_TYPE_SYS 0xFF /* ProDOS-8 system file */ +#define PRODOS_T_UD2 0xF2 /* User defined 2 */ +#define PRODOS_T_UD3 0xF3 /* User defined 3 */ +#define PRODOS_T_UD4 0xF4 /* User defined 4 */ +#define PRODOS_T_BAT 0xF5 /* User defined 5 */ +#define PRODOS_T_UD6 0xF6 /* User defined 6 */ +#define PRODOS_T_UD7 0xF7 /* User defined 7 */ +#define PRODOS_T_PRG 0xF8 /* User defined 8 */ +#define PRODOS_T_P16 0xF9 /* ProDOS-16 system file */ +#define PRODOS_T_INT 0xFA /* Integer BASIC program */ +#define PRODOS_T_IVR 0xFB /* Integer BASIC variables */ +#define PRODOS_T_BAS 0xFC /* Applesoft BASIC program */ +#define PRODOS_T_VAR 0xFD /* Applesoft BASIC variables */ +#define PRODOS_T_REL 0xFE /* EDASM relocatable code */ +#define PRODOS_T_SYS 0xFF /* ProDOS-8 system file */ /* The auxiliary type of a text file specifies its record length. ** A record length of 0 indicates a sequential text file, which is @@ -216,39 +223,86 @@ ** which is the record length, indicates a random access text file ** with fixed-length lines. */ -#define PRODOS_AUX_T_TXT_SEQ 0x0000 /* Sequential text */ +#define PRODOS_AUX_T_TXT_SEQ 0x0000 /* Sequential text */ -/* 8IC auxiliary type */ -#define PRODOS_AUX_T_8IC_APEX_PGM 0x8003 /* Apex program */ +/* 8IC auxiliary types */ +#define PRODOS_AUX_T_8IC_APEX_PGM 0x8003 /* Apex program */ /* GWP auxiliary types */ -#define PRODOS_AUX_T_GWP_TEACH 0x5445 /* Teach */ -#define PRODOS_AUX_T_GWP_DELUXEWRITE 0x8001 /* DeluxeWrite */ -#define PRODOS_AUX_T_GWP_APPLEWORKS_GS 0x8010 /* AppleWorks GS */ +#define PRODOS_AUX_T_GWP_TEACH 0x5445 /* Teach */ +#define PRODOS_AUX_T_GWP_DELUXEWRITE 0x8001 /* DeluxeWrite */ +#define PRODOS_AUX_T_GWP_APPLEWORKS_GS 0x8010 /* AppleWorks GS */ -/* GSS auxiliary type */ -#define PRODOS_AUX_T_GSS_APPLEWORKS_GS 0x8010 /* AppleWorks GS */ +/* GSS auxiliary types */ +#define PRODOS_AUX_T_GSS_APPLEWORKS_GS 0x8010 /* AppleWorks GS */ /* GDB auxiliary types */ -#define PRODOS_GDB_AUX_TYPE_APLWRKSGS 0x8010 /* AppleWorks GS DB */ -#define PRODOS_GDB_AUX_TYPE_AWGS_TMPL 0x8011 /* AWGS template */ -#define PRODOS_GDB_AUX_TYPE_GSAS 0x8013 +#define PRODOS_AUX_T_GDB_APPLEWORKS_GS 0x8010 /* AppleWorks GS DB */ +#define PRODOS_AUX_T_GDB_AWGS_TMPL 0x8011 /* AWGS template */ +#define PRODOS_AUX_T_GDB_GSAS 0x8013 -/* DRW auxiliary type */ -#define PRODOS_DRW_AUX_TYPE_APLWRKSGS 0x8013 /* AWGS O-O graphics */ +/* DRW auxiliary types */ +#define PRODOS_AUX_T_DRW_OO_GRAPHICS 0x8013 /* AWGS O-O graphics */ /* GDP auxiliary types */ -#define PRODOS_GDP_AUX_TYPE_GRFCWRTR 0x8002 /* AWGS GraphicWriter */ -#define PRODOS_GDP_AUX_TYPE_APLWRKSGS 0x8010 /* AWGS */ +#define PRODOS_AUX_T_GDP_GRAPHICWRITER 0x8002 /* A2gs GraphicWriter */ +#define PRODOS_AUX_T_GDP_APPLEWORKS_GS 0x8010 /* A2gs AWGS */ /* HMD auxiliary types */ -#define PRODOS_HMD_AUX_TYPE_HYPRCRDGS 0x0001 /* HyperCard GS */ -#define PRODOS_HMD_AUX_TYPE_TUTORTECH 0x8001 /* Tutor-Tech */ -#define PRODOS_HMD_AUX_TYPE_HYPRSTDIO 0x8002 /* HyperStudio */ -#define PRODOS_HMD_AUX_TYPE_NEXUS 0x8003 /* Nexus */ +#define PRODOS_AUX_T_HMD_HYPERCARD_GS 0x0001 /* HyperCard GS */ +#define PRODOS_AUX_T_HMD_TUTOR_TECH 0x8001 /* Tutor-Tech */ +#define PRODOS_AUX_T_HMD_HYPERSTUDIO 0x8002 /* HyperStudio */ +#define PRODOS_AUX_T_HMD_NEXUS 0x8003 /* Nexus */ -/* COM auxiliary type */ -#define PRODOS_COM_AUX_TYPE_APLWRKSGS 0x8003 /* AppleWorks GS */ +/* COM auxiliary types */ +#define PRODOS_AUX_T_COM_APPLEWORKS_GS 0x8003 /* AppleWorks GS */ -/* End of apple2_filetypes.h */ +/* MLR auxiliary types */ +#define PRODOS_AUX_T_MLR_SCRIPT 0x005C /* Mika City script */ +#define PRODOS_AUX_T_MLR_COLOR_TABLE 0xC7AB /* Mika City color table */ +#define PRODOS_AUX_T_MLR_CHARACTER_DEF 0xCDEF /* Mika City character def */ + +/* LDF auxiliary types */ +#define PRODOS_AUX_T_LDF_NIFTY_LIST_MOD 0x4001 /* Nifty list module */ +#define PRODOS_AUX_T_LDF_SUPER_INFO_MOD 0x4002 /* Super info module */ +#define PRODOS_AUX_T_LDF_TWILIGHT_MOD 0x4004 /* Twilight module */ +#define PRODOS_AUX_T_LDF_MARINETTI_LLM 0x4004 /* Marinetti link layer mod */ + +/* PNT auxiliary types */ +#define PRODOS_AUX_T_PNT_PK_SUPER_HIRES 0x0001 /* Packed super hi-res */ +#define PRODOS_AUX_T_PNT_APPLE_PREF 0x0002 /* Apple preferred format */ +#define PRODOS_AUX_T_PNT_PK_QUICKDRAWII 0x0003 /* Packed QuickDraw II */ + +/* PIC auxiliary types */ +#define PRODOS_AUX_T_PIC_QUICKDRAW 0x0001 /* QuickDraw image */ +#define PRODOS_AUX_T_PIC_SHIRES_3200 0x0002 /* Super hi-res 3200 */ + +/* FON auxiliary types */ +#define PRODOS_AUX_T_FON_QUICKDRAW_BIT 0x0000 /* QuickDraw bitmap font */ +#define PRODOS_AUX_T_FON_POINTLESS_TT 0x0001 /* Pointless TrueType font */ + +/* SND auxiliary types */ +#define PRODOS_AUX_T_SND_AIFF 0x0000 /* AIFF */ +#define PRODOS_AUX_T_SND_AIFF_C 0x0001 /* AIFF-C */ +#define PRODOS_AUX_T_SND_ASIF_INSTR 0x0002 /* ASIF instrument */ +#define PRODOS_AUX_T_SND_SOUND_RSRC 0x0003 /* Sound resource */ +#define PRODOS_AUX_T_SND_MIDI_SYNTH_WAV 0x0004 /* MIDI synth wave */ +#define PRODOS_AUX_T_SND_HYPERSTUDIO 0x8001 /* HyperStudio sound */ + +/* LBR auxiliary types */ +#define PRODOS_AUX_T_LBR_ALU 0x0000 /* ALU */ +#define PRODOS_AUX_T_LBR_APPLE_SINGLE 0x0001 /* AppleSingle */ +#define PRODOS_AUX_T_LBR_APPLEDBL_HDR 0x0002 /* AppleDouble header */ +#define PRODOS_AUX_T_LBR_APPLEDBL_DATA 0x0003 /* AppleDouble data */ +#define PRODOS_AUX_T_LBR_BINARY_II 0x8000 /* Binary II */ +#define PRODOS_AUX_T_LBR_APPLELINK_ACU 0x8001 /* AppleLink ACU */ +#define PRODOS_AUX_T_LBR_SHRINKIT 0x8002 /* ShrinkIt */ + +/* LBR auxiliary types */ +#define PRODOS_AUX_T_ATK_EASYMNT_ALIAS 0x0000 /* EasyMount alias */ + +/* BAS auxiliary types */ +#define PRODOS_AUX_T_BAS_PGM_LOAD_ADDR 0x0801 /* Applesoft pgm load addr */ + +/* End of apple2_filetype.h */ #endif From 91d06596635980e3ba4110faa702b1972e9b0f81 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Fri, 28 Jul 2017 11:29:11 -0400 Subject: [PATCH 165/199] Rolled back changes to exclude vim swap files Only files generated by the tools in the project are to be ignored --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 39d5b59fa..ad4d26c3f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,3 @@ /testwrk/ /wrk/ /cc65.zip - -# Vim swap files -.*.swp From 9459f11688542104c2dbb4d32d9b6e0ec59ecc25 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Fri, 28 Jul 2017 12:01:57 -0400 Subject: [PATCH 166/199] Corrected copyright and moved file type globals The file type globals., _filetype and _auxtype, were moved from apple2.h to this file. --- include/apple2_filetype.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/apple2_filetype.h b/include/apple2_filetype.h index 96cf49581..bdfa93093 100644 --- a/include/apple2_filetype.h +++ b/include/apple2_filetype.h @@ -6,8 +6,7 @@ /* */ /* */ /* */ -/* (C) 2000 Kevin Ruland, <kevin@rodin.wustl.edu> */ -/* (C) 2003 Ullrich von Bassewitz, <uz@cc65.org> */ +/* (C) 2017 Bill Chatfield, <bill_chatfield@yahoo.com> */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -304,5 +303,12 @@ /* BAS auxiliary types */ #define PRODOS_AUX_T_BAS_PGM_LOAD_ADDR 0x0801 /* Applesoft pgm load addr */ +/* The file stream implementation and the POSIX I/O functions will use the +** following variables to determine the file type and auxiliary type to use. +** This applies specifically to the fopen and open functions. +*/ +extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ +extern unsigned int _auxtype; /* Default: 0 */ + /* End of apple2_filetype.h */ #endif From abb2e8034b4ead55364f75938ae894826339f54e Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Fri, 28 Jul 2017 12:09:58 -0400 Subject: [PATCH 167/199] Moved file type variables to apple2_filetype.h --- include/apple2.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/apple2.h b/include/apple2.h index a2150c173..e73023693 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -137,11 +137,9 @@ extern unsigned char _dos_type; /* The file stream implementation and the POSIX I/O functions will use the -** following variables to determine the file type, aux type and creation time -** stamp to use. +** following struct to set the date and time stamp on files. This specificially +** applies to the open and fopen functions. */ -extern unsigned char _filetype; /* Default: 6 */ -extern unsigned int _auxtype; /* Default: 0 */ extern struct { struct { unsigned day :5; From f40bb936777ecc223723b6f502e9a94eccd09541 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Fri, 28 Jul 2017 12:12:18 -0400 Subject: [PATCH 168/199] Added Variables section comment per convention --- include/apple2_filetype.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/apple2_filetype.h b/include/apple2_filetype.h index bdfa93093..be17274fa 100644 --- a/include/apple2_filetype.h +++ b/include/apple2_filetype.h @@ -303,6 +303,14 @@ /* BAS auxiliary types */ #define PRODOS_AUX_T_BAS_PGM_LOAD_ADDR 0x0801 /* Applesoft pgm load addr */ + + +/*****************************************************************************/ +/* Variables */ +/*****************************************************************************/ + + + /* The file stream implementation and the POSIX I/O functions will use the ** following variables to determine the file type and auxiliary type to use. ** This applies specifically to the fopen and open functions. From 80c1c94a87aca1b0b7a4b0521d140493d20ba4b0 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Fri, 28 Jul 2017 12:16:55 -0400 Subject: [PATCH 169/199] Corrected comment formatting --- include/apple2_filetype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/apple2_filetype.h b/include/apple2_filetype.h index be17274fa..83a44f532 100644 --- a/include/apple2_filetype.h +++ b/include/apple2_filetype.h @@ -316,7 +316,7 @@ ** This applies specifically to the fopen and open functions. */ extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ -extern unsigned int _auxtype; /* Default: 0 */ +extern unsigned int _auxtype; /* Default: 0 */ /* End of apple2_filetype.h */ #endif From 375ee571c235250bebd3ea10af5830b38d870747 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Fri, 28 Jul 2017 19:19:11 +0200 Subject: [PATCH 170/199] Removed 'fire'. --- include/joystick.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/joystick.h b/include/joystick.h index f08dd432a..27c4af81a 100644 --- a/include/joystick.h +++ b/include/joystick.h @@ -61,9 +61,9 @@ #define JOY_LEFT_IDX 2 #define JOY_RIGHT_IDX 3 #define JOY_BTN_1_IDX 4 /* Universally available */ -#define JOY_BTN_2_IDX 5 /* Second fire button if available */ -#define JOY_BTN_3_IDX 6 /* Third fire button if available */ -#define JOY_BTN_4_IDX 7 /* Fourth fire button if available */ +#define JOY_BTN_2_IDX 5 /* Second button if available */ +#define JOY_BTN_3_IDX 6 /* Third button if available */ +#define JOY_BTN_4_IDX 7 /* Fourth button if available */ /* Array of masks used to check the return value of joy_read for a state */ extern const unsigned char joy_masks[8]; From 2c7b757b4caf152e26f9bb0bbb3fb0dba0b69f6c Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Fri, 28 Jul 2017 17:44:13 -0400 Subject: [PATCH 171/199] Documented _filetype and _auxtype --- doc/apple2.sgml | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index 3089a04c4..fe5c98767 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -511,6 +511,104 @@ url="ca65.html" name="assembler manual">. </descrip><p> +<sect1>Specifying ProDOS File Types<p> + +<descrip> + + <tag>Problem Explanation</tag> + + ProDOS associates a file type and an auxiliary type with each file. + These type specifications are separate from the file's name, unlike + Windows and UNIX-like systems which use the file name's suffix (a.k.a. + extension) to specify the file type. For example, .exe, .doc, or .bat. + The ProDOS low-level + Machine-Language Interface (MLI) functions for creating and opening + files require these types to be specified. And if they don't match + with the file being opened, the operation may fail. + + In contrast, the ISO C function <tt/fopen()/ and the POSIX function + <tt/open()/ have no parameter to specify either a file type or an + auxiliary type. Therefore, some additional mechanism for specifying + the file types is needed. + + <tag>Solution</tag> + + There are two global variables provided that allow the file type + and auxiliary type to be specified before a call to <tt/fopen()/ + or <tt/open/. They are defined in <tt/apple2_filetype.h/: + + <quote> + <verb> + extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ + extern unsigned int _auxtype; /* Default: 0 */ + </verb> + </quote> + + The header file <tt/apple2_filetype.h/ also defines many values + that can be used to set these variables. It is included in + <tt/apple2.h/, which is in turn included in <tt/apple2enh.h/. + So it + not necessary to include it directly. Just + include one of <tt/apple2.h/ or <tt/apple2enh.h/. + + <tag>Example</tag> + + A text file cannot be created with just the + standard C functions because they default to the binary type + <tt/PRODOS_T_BIN/. The <tt/_filetype/ variable must be set to + <tt/PRODOS_T_TXT/ to create a text file. + + For a text file, + <tt/_auxtype/ specifies the record length. A zero record + length text file is referred to as a sequential text file. + This is equivalent to text files on + other operating systems, except that the line terminator is a + carriage return instead of a new line (Linux/BSD/MacOS) or + carriage return, new line pair (Windows). + + The "sequential" text file terminology is in contrast to a + "random-access" text file which would + have a fixed-length, non-zero record length, so that the + file position of any individual record can be calculated. + + For this example, the + <tt/_auxtype/ does not need to be set because it defaults to + the desired value, which is zero. To be more explicit, + <tt/_auxtype/ can also be set to <tt/PRODOS_AUX_T_TXT_SEQ/ + which is defined as zero. + + <quote> + <verb> + #include <stdio.h> + #include <string.h> + #include <errno.h> + #include <apple2.h> + void main() + { + FILE *out; + char *name = "MY.FAVS"; + + _filetype = PRODOS_T_TXT; + _auxtype = PRODOS_AUX_T_TXT_SEQ; + + if ((out = fopen(name, "w")) != NULL) { + fputs("Jorah Mormont\r", out); + fputs("Brienne of Tarth\r", out); + fputs("Daenerys Targaryen\r", out); + fputs("Sandor Clegane\r", out); + if (fclose(out) == EOF) { + fprintf(stderr, "fclose failed for %s: %s", name, strerror(errno)); + } + } + else { + fprintf(stderr, "fopen failed for %s: %s", name, strerror(errno)); + } + } + </verb> + </quote> + +</descrip><p> + <sect>License<p> From 9d89613bb2d5f8817cd38886acdb92fa1f5395c5 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Sat, 29 Jul 2017 01:25:07 -0400 Subject: [PATCH 172/199] Added documentation for setting the file type for fopen. --- doc/apple2.sgml | 27 ++++++++++++++++----------- doc/apple2enh.sgml | 8 ++++++++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index fe5c98767..4ed2af48c 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -511,11 +511,11 @@ url="ca65.html" name="assembler manual">. </descrip><p> -<sect1>Specifying ProDOS File Types<p> +<sect1>Specifying file types for fopen<p> <descrip> - <tag>Problem Explanation</tag> + <tag>Explanation of File Types</tag> ProDOS associates a file type and an auxiliary type with each file. These type specifications are separate from the file's name, unlike @@ -531,18 +531,18 @@ url="ca65.html" name="assembler manual">. auxiliary type. Therefore, some additional mechanism for specifying the file types is needed. - <tag>Solution</tag> + <tag>Specifying the File Type and Auxiliary Type</tag> There are two global variables provided that allow the file type and auxiliary type to be specified before a call to <tt/fopen()/ or <tt/open/. They are defined in <tt/apple2_filetype.h/: - <quote> + <tscreen> <verb> extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ extern unsigned int _auxtype; /* Default: 0 */ </verb> - </quote> + </tscreen> The header file <tt/apple2_filetype.h/ also defines many values that can be used to set these variables. It is included in @@ -577,20 +577,25 @@ url="ca65.html" name="assembler manual">. <tt/_auxtype/ can also be set to <tt/PRODOS_AUX_T_TXT_SEQ/ which is defined as zero. - <quote> + <tscreen> <verb> - #include <stdio.h> - #include <string.h> - #include <errno.h> - #include <apple2.h> + #include <stdio.h> + #include <string.h> + #include <errno.h> + #include <apple2.h> + void main() { FILE *out; char *name = "MY.FAVS"; + /*-----------------------------*/ + _filetype = PRODOS_T_TXT; _auxtype = PRODOS_AUX_T_TXT_SEQ; + /*-----------------------------*/ + if ((out = fopen(name, "w")) != NULL) { fputs("Jorah Mormont\r", out); fputs("Brienne of Tarth\r", out); @@ -605,7 +610,7 @@ url="ca65.html" name="assembler manual">. } } </verb> - </quote> + </tscreen> </descrip><p> diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index 5e4626fbc..672f5d6aa 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -517,6 +517,14 @@ url="ca65.html" name="assembler manual">. </descrip><p> +<sect1>Specifying file types for fopen<p> + +See section +<url url="apple2.html#ss9.4" name="Specifying file types for fopen"> +in the apple2 docoumentation. + + + <sect>License<p> From 85e572f4e12e071ef61fb5846b8839b6e2781df8 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Sun, 30 Jul 2017 19:49:20 -0400 Subject: [PATCH 173/199] Made corrections according to review comments --- doc/apple2.sgml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index 4ed2af48c..33a878223 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -519,8 +519,9 @@ url="ca65.html" name="assembler manual">. ProDOS associates a file type and an auxiliary type with each file. These type specifications are separate from the file's name, unlike - Windows and UNIX-like systems which use the file name's suffix (a.k.a. - extension) to specify the file type. For example, .exe, .doc, or .bat. + Windows which uses the file name's suffix (a.k.a. + extension) to specify the file type. For example, <tt/.exe/, + <tt/.doc/, or <tt/.bat/. The ProDOS low-level Machine-Language Interface (MLI) functions for creating and opening files require these types to be specified. And if they don't match @@ -535,7 +536,7 @@ url="ca65.html" name="assembler manual">. There are two global variables provided that allow the file type and auxiliary type to be specified before a call to <tt/fopen()/ - or <tt/open/. They are defined in <tt/apple2_filetype.h/: + or <tt/open()/. They are defined in <tt/apple2_filetype.h/: <tscreen> <verb> @@ -547,8 +548,7 @@ url="ca65.html" name="assembler manual">. The header file <tt/apple2_filetype.h/ also defines many values that can be used to set these variables. It is included in <tt/apple2.h/, which is in turn included in <tt/apple2enh.h/. - So it - not necessary to include it directly. Just + So it isn't necessary to include it directly. Just include one of <tt/apple2.h/ or <tt/apple2enh.h/. <tag>Example</tag> @@ -563,8 +563,8 @@ url="ca65.html" name="assembler manual">. length text file is referred to as a sequential text file. This is equivalent to text files on other operating systems, except that the line terminator is a - carriage return instead of a new line (Linux/BSD/MacOS) or - carriage return, new line pair (Windows). + carriage return instead of a line-feed (Linux/BSD/MacOS) or + carriage return, line-feed pair (Windows). The "sequential" text file terminology is in contrast to a "random-access" text file which would @@ -584,7 +584,7 @@ url="ca65.html" name="assembler manual">. #include <errno.h> #include <apple2.h> - void main() + void main(void) { FILE *out; char *name = "MY.FAVS"; From 0bd5a8a3314b1b6b8047dc31113bd5ead59d706e Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Sun, 30 Jul 2017 19:51:23 -0400 Subject: [PATCH 174/199] Made corrections according to review comments --- doc/apple2enh.sgml | 105 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 3 deletions(-) diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index 672f5d6aa..c7be9b474 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -519,9 +519,108 @@ url="ca65.html" name="assembler manual">. <sect1>Specifying file types for fopen<p> -See section -<url url="apple2.html#ss9.4" name="Specifying file types for fopen"> -in the apple2 docoumentation. +<descrip> + + <tag>Explanation of File Types</tag> + + ProDOS associates a file type and an auxiliary type with each file. + These type specifications are separate from the file's name, unlike + Windows which uses the file name's suffix (a.k.a. + extension) to specify the file type. For example, <tt/.exe/, + <tt/.doc/, or <tt/.bat/. + The ProDOS low-level + Machine-Language Interface (MLI) functions for creating and opening + files require these types to be specified. And if they don't match + with the file being opened, the operation may fail. + + In contrast, the ISO C function <tt/fopen()/ and the POSIX function + <tt/open()/ have no parameter to specify either a file type or an + auxiliary type. Therefore, some additional mechanism for specifying + the file types is needed. + + <tag>Specifying the File Type and Auxiliary Type</tag> + + There are two global variables provided that allow the file type + and auxiliary type to be specified before a call to <tt/fopen()/ + or <tt/open()/. They are defined in <tt/apple2_filetype.h/: + + <tscreen> + <verb> + extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ + extern unsigned int _auxtype; /* Default: 0 */ + </verb> + </tscreen> + + The header file <tt/apple2_filetype.h/ also defines many values + that can be used to set these variables. It is included in + <tt/apple2.h/, which is in turn included in <tt/apple2enh.h/. + So it isn't necessary to include it directly. Just + include one of <tt/apple2.h/ or <tt/apple2enh.h/. + + <tag>Example</tag> + + A text file cannot be created with just the + standard C functions because they default to the binary type + <tt/PRODOS_T_BIN/. The <tt/_filetype/ variable must be set to + <tt/PRODOS_T_TXT/ to create a text file. + + For a text file, + <tt/_auxtype/ specifies the record length. A zero record + length text file is referred to as a sequential text file. + This is equivalent to text files on + other operating systems, except that the line terminator is a + carriage return instead of a line-feed (Linux/BSD/MacOS) or + carriage return, line-feed pair (Windows). + + The "sequential" text file terminology is in contrast to a + "random-access" text file which would + have a fixed-length, non-zero record length, so that the + file position of any individual record can be calculated. + + For this example, the + <tt/_auxtype/ does not need to be set because it defaults to + the desired value, which is zero. To be more explicit, + <tt/_auxtype/ can also be set to <tt/PRODOS_AUX_T_TXT_SEQ/ + which is defined as zero. + + <tscreen> + <verb> + #include <stdio.h> + #include <string.h> + #include <errno.h> + #include <apple2.h> + + void main(void) + { + FILE *out; + char *name = "MY.FAVS"; + + /*-----------------------------*/ + + _filetype = PRODOS_T_TXT; + _auxtype = PRODOS_AUX_T_TXT_SEQ; + + /*-----------------------------*/ + + if ((out = fopen(name, "w")) != NULL) { + fputs("Jorah Mormont\r", out); + fputs("Brienne of Tarth\r", out); + fputs("Daenerys Targaryen\r", out); + fputs("Sandor Clegane\r", out); + if (fclose(out) == EOF) { + fprintf(stderr, "fclose failed for %s: %s", name, strerror(errno)); + } + } + else { + fprintf(stderr, "fopen failed for %s: %s", name, strerror(errno)); + } + } + </verb> + </tscreen> + +</descrip><p> + + From 92ff854bff8cd3b93b37acebc4048626b93a83fc Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Mon, 31 Jul 2017 13:50:27 +0200 Subject: [PATCH 175/199] Removed undesirable empty lines. --- doc/apple2enh.sgml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index c7be9b474..4f5202543 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -621,10 +621,6 @@ url="ca65.html" name="assembler manual">. </descrip><p> - - - - <sect>License<p> This software is provided 'as-is', without any expressed or implied From f9c59a0976ff3eb654a7152ef31c4e1af59aa06b Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 2 Aug 2017 23:56:52 +0200 Subject: [PATCH 176/199] atari5200.inc: fix formatting --- asminc/atari5200.inc | 107 +++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/asminc/atari5200.inc b/asminc/atari5200.inc index b67c9a8db..91fae4a9a 100644 --- a/asminc/atari5200.inc +++ b/asminc/atari5200.inc @@ -8,42 +8,42 @@ ; ATASCII CHARACTER DEFS ;------------------------------------------------------------------------- -ATEOL = $9B ;END-OF-LINE, used by CONIO +ATEOL = $9B ; END-OF-LINE, used by CONIO ;------------------------------------------------------------------------- ; Zero Page ;------------------------------------------------------------------------- -POKMSK = $00 ;Mask for Pokey IRQ enable -RTCLOK = $01 ;60 hz. clock +POKMSK = $00 ; Mask for Pokey IRQ enable +RTCLOK = $01 ; 60 hz. clock JUMP = $01 -CRITIC = $03 ;Critical section -ATRACT = $04 ;Attract Mode +CRITIC = $03 ; Critical section +ATRACT = $04 ; Attract Mode -SDLSTL = $05 ;DLISTL Shadow -SDLSTH = $06 ;DLISTH " -SDMCTL = $07 ;DMACTL " +SDLSTL = $05 ; DLISTL Shadow +SDLSTH = $06 ; DLISTH " +SDMCTL = $07 ; DMACTL " -PCOLR0 = $08 ;COLPM0 Shadow -PCOLR1 = $09 ;COLPM1 " -PCOLR2 = $0A ;COLPM2 " -PCOLR3 = $0B ;COLPM3 " +PCOLR0 = $08 ; COLPM0 Shadow +PCOLR1 = $09 ; COLPM1 " +PCOLR2 = $0A ; COLPM2 " +PCOLR3 = $0B ; COLPM3 " -COLOR0 = $0C ;COLPF0 Shadow -COLOR1 = $0D ;COLPF1 " -COLOR2 = $0E ;COLPF2 " -COLOR3 = $0F ;COLPF3 " -COLOR4 = $10 ;COLBK " +COLOR0 = $0C ; COLPF0 Shadow +COLOR1 = $0D ; COLPF1 " +COLOR2 = $0E ; COLPF2 " +COLOR3 = $0F ; COLPF3 " +COLOR4 = $10 ; COLBK " -PADDL0 = $11 ;POT0 Shadow -PADDL1 = $12 ;POT1 " -PADDL2 = $13 ;POT2 " -PADDL3 = $14 ;POT3 " -PADDL4 = $15 ;POT4 " -PADDL5 = $16 ;POT5 " -PADDL6 = $17 ;POT6 " -PADDL7 = $18 ;POT7 " +PADDL0 = $11 ; POT0 Shadow +PADDL1 = $12 ; POT1 " +PADDL2 = $13 ; POT2 " +PADDL3 = $14 ; POT3 " +PADDL4 = $15 ; POT4 " +PADDL5 = $16 ; POT5 " +PADDL6 = $17 ; POT6 " +PADDL7 = $18 ; POT7 " ; cc65 runtime zero page variables @@ -57,26 +57,26 @@ SAVMSC = $1B ; pointer to screen memory (conio) ;Interrupt Vectors -VIMIRQ = $0200 ;Immediate IRQ - ;Preset $FC03 (SYSIRQ) -VVBLKI = $0202 ;Vblank immediate - ;Preset $FCB8 (SYSVBL) -VVBLKD = $0204 ;Vblank deferred - ;Preset $FCB2 (XITVBL) -VDSLST = $0206 ;Display List - ;Preset $FEA1 (OSDLI) -VKYBDI = $0208 ;Keyboard immediate - ;Preset $FD02 (SYSKBD) -VKYBDF = $020A ;Deferred Keyboard - ;Preset $FCB2 (XITVBL) -VTRIGR = $020C ;Soft Trigger -VBRKOP = $020E ;BRK Opcode -VSERIN = $0210 ;Serial in Ready -VSEROR = $0212 ;Serial Out Ready -VSEROC = $0214 ;Serial Output complete -VTIMR1 = $0216 ;Pokey Timer 1 -VTIMR2 = $0218 ;Pokey Timer 2 -VTIMR4 = $021A ;Pokey Timer 4 +VIMIRQ = $0200 ; Immediate IRQ + ; Preset $FC03 (SYSIRQ) +VVBLKI = $0202 ; Vblank immediate + ; Preset $FCB8 (SYSVBL) +VVBLKD = $0204 ; Vblank deferred + ; Preset $FCB2 (XITVBL) +VDSLST = $0206 ; Display List + ; Preset $FEA1 (OSDLI) +VKYBDI = $0208 ; Keyboard immediate + ; Preset $FD02 (SYSKBD) +VKYBDF = $020A ; Deferred Keyboard + ; Preset $FCB2 (XITVBL) +VTRIGR = $020C ; Soft Trigger +VBRKOP = $020E ; BRK Opcode +VSERIN = $0210 ; Serial in Ready +VSEROR = $0212 ; Serial Out Ready +VSEROC = $0214 ; Serial Output complete +VTIMR1 = $0216 ; Pokey Timer 1 +VTIMR2 = $0218 ; Pokey Timer 2 +VTIMR4 = $021A ; Pokey Timer 4 @@ -84,21 +84,21 @@ VTIMR4 = $021A ;Pokey Timer 4 ; CTIA/GTIA Address Equates ;------------------------------------------------------------------------- -GTIA = $C000 ;CTIA/GTIA area +GTIA = $C000 ; CTIA/GTIA area .include "atari_gtia.inc" ;------------------------------------------------------------------------- ; ANTIC Address Equates ;------------------------------------------------------------------------- -ANTIC = $D400 ;ANTIC area +ANTIC = $D400 ; ANTIC area .include "atari_antic.inc" ;------------------------------------------------------------------------- ; POKEY Address Equates ;------------------------------------------------------------------------- -POKEY = $E800 ;POKEY area +POKEY = $E800 ; POKEY area .include "atari_pokey.inc" @@ -106,11 +106,10 @@ POKEY = $E800 ;POKEY area ; Cartridge Parameters ;------------------------------------------------------------------------- -CARTNM = $BFE8 ;Cartridge Name Area -COPYD = $BFFC ;Copyright Decade in Cart -COPYR = $BFFD ;Copyright Year in Cart +CARTNM = $BFE8 ; Cartridge Name Area +COPYD = $BFFC ; Copyright Decade in Cart +COPYR = $BFFD ; Copyright Year in Cart ; $FF=Diagnostic Cart -GOCART = $BFFE ;Cartridge Start Vector +GOCART = $BFFE ; Cartridge Start Vector - -CHRORG = $F800 ;Character Generator Base +CHRORG = $F800 ; Character Generator Base From bd9208879e723cc663f67559b54d1cb50dd6fa91 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 6 Aug 2017 18:09:40 +0200 Subject: [PATCH 177/199] added prototypes and proposed constants --- include/cbm.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/cbm.h b/include/cbm.h index 701924d57..5bb860e4f 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -153,7 +153,13 @@ struct cbm_dirent { unsigned char get_tv (void); /* Return the video mode the machine is using. */ +#define KBDREPEAT_CURSOR 0x00 +#define KBDREPEAT_NONE 0x40 +#define KBDREPEAT_ALL 0x80 +unsigned char kbrepeat(unsigned char); +unsigned char kbrepeatdelay(unsigned char); +unsigned char kbrepeatrate(unsigned char); /*****************************************************************************/ /* CBM kernal functions */ From dafe3c1e3cc3316ff187e4adfd756097865d2ae4 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 6 Aug 2017 20:15:35 +0200 Subject: [PATCH 178/199] added documentation for the kbrepeat... functions --- doc/funcref.sgml | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index a2ccf6c73..d7c477958 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -179,6 +179,9 @@ function. <!-- <item><ref id="cbm_save" name="cbm_save"> --> <!-- <item><ref id="cbm_write" name="cbm_write"> --> <!-- <item><ref id="get_tv" name="get_tv"> --> +<item><ref id="kbrepeat" name="kbrepeat"> +<item><ref id="kbrepeatdelay" name="kbrepeatdelay"> +<item><ref id="kbrepeatrate" name="kbrepeatrate"> </itemize> (incomplete) @@ -2063,6 +2066,70 @@ to get off the serial bus so it can be used for other purposes. </descrip> </quote> +<sect1>kbrepeat<label id="kbrepeat"><p> + +<quote> +<descrip> +<tag/Function/Set keyboard repeat mode +<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/ +<tag/Declaration/<tt/unsigned char kbrepeat (unsigned char);/ +<tag/Description/This function changes what keys will have automatic repeat when +being hold down for a certain time. Possible values are KBDREPEAT_CURSOR (repeat +only cursor-related keys), KBDREPEAT_NONE (no repeat for any keys) and +KBDREPEAT_ALL (repeat all keys). +The old mode is returned so it can be restored later. +<tag/Notes/<itemize> +<item> +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="kbrepeatdelay" name="kbrepeatdelay"> +<ref id="kbrepeatrate" name="kbrepeatrate"> +<tag/Example/None. +</descrip> +</quote> + +<sect1>kbrepeatdelay<label id="kbrepeatdelay"><p> + +<quote> +<descrip> +<tag/Function/Set keyboard repeat delay +<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/ +<tag/Declaration/<tt/unsigned char kbrepeatdelay (unsigned char);/ +<tag/Description/This function changes the delay until a keypress is being +repeated automatically. +The old value is returned so it can be restored later. +<tag/Notes/<itemize> +<item> +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="kbrepeat" name="kbrepeat"> +<ref id="kbrepeatrate" name="kbrepeatrate"> +<tag/Example/None. +</descrip> +</quote> + +<sect1>kbrepeatrate<label id="kbrepeatrate"><p> + +<quote> +<descrip> +<tag/Function/Set keyboard repeat rate +<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/ +<tag/Declaration/<tt/unsigned char kbrepeatrate (unsigned char);/ +<tag/Description/This function changes the keyboard repeat rate (the time between +repeated keypresses). +The old value is returned so it can be restored later. +<tag/Notes/<itemize> +<item> +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="kbrepeat" name="kbrepeat"> +<ref id="kbrepeatdelay" name="kbrepeatdelay"> +<tag/Example/None. +</descrip> +</quote> <sect1>cclear<label id="cclear"><p> From 99e6dd18d680382c7780f0569329a89be386493d Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 6 Aug 2017 20:20:22 +0200 Subject: [PATCH 179/199] resolve conflict --- include/cbm.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/cbm.h b/include/cbm.h index 5bb860e4f..cdbd7b886 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -161,6 +161,11 @@ unsigned char kbrepeat(unsigned char); unsigned char kbrepeatdelay(unsigned char); unsigned char kbrepeatrate(unsigned char); +#if !defined(__CBM610__) && !defined(__PET__) +void waitvsync (void); +/* wait for the start of the next frame */ +#endif + /*****************************************************************************/ /* CBM kernal functions */ /*****************************************************************************/ From 7f52a770d9c6a43dde67689032bb3a4848eb6b30 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sat, 19 Aug 2017 19:11:28 +0200 Subject: [PATCH 180/199] Removed joy_masks array. So far the joy_masks array allowed several joystick drivers for a single target to each have different joy_read return values. However this meant that every call to joy_read implied an additional joy_masks lookup to post-process the return value. Given that almost all targets only come with a single joystick driver this seems an inappropriate overhead. Therefore now the target header files contain constants matching the return value of the joy_read of the joystick driver(s) on that target. If there indeed are several joystick drivers for a single target they must agree on a common return value for joy_read. In some cases this was alredy the case as there's a "natural" return value for joy_read. However a few joystick drivers need to be adjusted. This may cause some overhead inside the driver. But that is for sure smaller than the overhead introduced by the joy_masks lookup before. !!! ToDo !!! The following three joystick drivers become broken with this commit and need to be adjusted: - atrmj8.s - c64-numpad.s - vic20-stdjoy.s --- asminc/joy-kernel.inc | 1 - include/apple2.h | 8 +++++ include/atari.h | 9 ++++- include/atari5200.h | 9 ++++- include/atmos.h | 9 +++++ include/c128.h | 7 ++++ include/c64.h | 7 ++++ include/cbm.h | 6 ++-- include/cbm264.h | 11 +++++++ include/cbm510.h | 7 ++++ include/creativision.h | 8 +++++ include/em/em-kernel.h | 1 + include/gamate.h | 27 ++++++++++----- include/geos.h | 6 ++++ include/joystick.h | 29 +++++----------- include/joystick/joy-kernel.h | 7 +--- include/lynx.h | 23 ++++++++----- include/nes.h | 31 ++++++++++------- include/pce.h | 33 ++++++++++++------- include/pet.h | 7 ++++ include/vic20.h | 9 +++++ libsrc/apple2/joy/a2.stdjoy.s | 17 ++-------- libsrc/atari/joy/atrstd.s | 11 ------- libsrc/atari5200/joy/atr5200std.s | 13 +------- libsrc/atmos/joy/atmos-pase.s | 11 ------- libsrc/c128/joy/c128-ptvjoy.s | 11 ------- libsrc/c128/joy/c128-stdjoy.s | 11 ------- libsrc/c64/joy/c64-hitjoy.s | 11 ------- libsrc/c64/joy/c64-ptvjoy.s | 11 ------- libsrc/c64/joy/c64-stdjoy.s | 11 ------- libsrc/cbm510/joy/cbm510-std.s | 21 +++--------- libsrc/creativision/joy/creativision-stdjoy.s | 29 +++++----------- libsrc/gamate/joy/gamate-stdjoy.s | 11 ------- libsrc/geos-cbm/joy/geos-stdjoy.s | 11 ------- libsrc/joystick/joy-kernel.s | 22 +++---------- libsrc/lynx/joy/lynx-stdjoy.s | 12 ------- libsrc/nes/joy/nes-stdjoy.s | 11 ------- libsrc/pce/joy/pce-stdjoy.s | 11 ------- libsrc/pet/joy/pet-ptvjoy.s | 11 ------- libsrc/pet/joy/pet-stdjoy.s | 11 ------- libsrc/plus4/joy/plus4-stdjoy.s | 13 +------- libsrc/vic20/joy/vic20-ptvjoy.s | 12 ------- testcode/lib/joy-test.c | 22 ++++++------- testcode/lib/pce/conio.c | 17 +++++----- 44 files changed, 222 insertions(+), 354 deletions(-) diff --git a/asminc/joy-kernel.inc b/asminc/joy-kernel.inc index 4fe5572cf..ba969da1d 100644 --- a/asminc/joy-kernel.inc +++ b/asminc/joy-kernel.inc @@ -43,7 +43,6 @@ ID .byte 3 ; $6A, $6F, $79 ("joy") VERSION .byte 1 ; Interface version LIBREF .addr ; Library reference - MASKS .byte 8 ; Joystick state mask array JUMPTAB .struct INSTALL .addr ; INSTALL routine UNINSTALL .addr ; UNINSTALL routine diff --git a/include/apple2.h b/include/apple2.h index e73023693..421b5db6c 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -91,6 +91,14 @@ #define CH_RTEE '+' #define CH_CROSS '+' +/* Masks for joy_read */ +#define JOY_UP_MASK 0x10 +#define JOY_DOWN_MASK 0x20 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x40 +#define JOY_BTN_2_MASK 0x80 + /* Return codes for get_ostype */ #define APPLE_UNKNOWN 0x00 #define APPLE_II 0x10 /* Apple ][ */ diff --git a/include/atari.h b/include/atari.h index fa99fca20..ca4b2ef26 100644 --- a/include/atari.h +++ b/include/atari.h @@ -149,6 +149,13 @@ #define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE #define TGI_COLOR_GRAY3 COLOR_GRAY3 +/* Masks for joy_read */ +#define JOY_UP_MASK 0x01 +#define JOY_DOWN_MASK 0x02 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x10 + /* color register functions */ extern void __fastcall__ _setcolor (unsigned char color_reg, unsigned char hue, unsigned char luminace); extern void __fastcall__ _setcolor_low (unsigned char color_reg, unsigned char color_value); @@ -346,4 +353,4 @@ struct __iocb { #define IOCB_FORMAT 0xFE /* format */ /* End of atari.h */ -#endif /* #ifndef _ATARI_H */ +#endif diff --git a/include/atari5200.h b/include/atari5200.h index 4bd5bc0fd..12c2bb349 100644 --- a/include/atari5200.h +++ b/include/atari5200.h @@ -87,6 +87,13 @@ extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */ #define COLOR_LIGHTBLUE _gtia_mkcolor(HUE_BLUE,6) #define COLOR_GRAY3 _gtia_mkcolor(HUE_GREY,5) +/* Masks for joy_read */ +#define JOY_UP_MASK 0x01 +#define JOY_DOWN_MASK 0x02 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x10 + /* get_tv return values */ #define AT_NTSC 0 #define AT_PAL 1 @@ -104,4 +111,4 @@ extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */ #define ANTIC (*(struct __antic*)0xD400) /* End of atari5200.h */ -#endif /* #ifndef _ATARI5200_H */ +#endif diff --git a/include/atmos.h b/include/atmos.h index 72388c974..c642f9e2a 100644 --- a/include/atmos.h +++ b/include/atmos.h @@ -113,6 +113,15 @@ +/* Masks for joy_read */ +#define JOY_UP_MASK 0x10 +#define JOY_DOWN_MASK 0x08 +#define JOY_LEFT_MASK 0x01 +#define JOY_RIGHT_MASK 0x02 +#define JOY_BTN_1_MASK 0x20 + + + /* No support for dynamically loadable drivers */ #define DYN_DRV 0 diff --git a/include/c128.h b/include/c128.h index 565fbc9ce..356140d41 100644 --- a/include/c128.h +++ b/include/c128.h @@ -91,6 +91,13 @@ #define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE #define TGI_COLOR_GRAY3 COLOR_GRAY3 +/* Masks for joy_read */ +#define JOY_UP_MASK 0x01 +#define JOY_DOWN_MASK 0x02 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x10 + /* Video mode defines */ #define VIDEOMODE_40x25 0x00 #define VIDEOMODE_80x25 0x80 diff --git a/include/c64.h b/include/c64.h index adf3840b9..eb10600d6 100644 --- a/include/c64.h +++ b/include/c64.h @@ -99,6 +99,13 @@ #define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE #define TGI_COLOR_GRAY3 COLOR_GRAY3 +/* Masks for joy_read */ +#define JOY_UP_MASK 0x01 +#define JOY_DOWN_MASK 0x02 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x10 + /* Define hardware */ #include <_vic2.h> #define VIC (*(struct __vic2*)0xD000) diff --git a/include/cbm.h b/include/cbm.h index 27e82f9f3..129b0295b 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -75,10 +75,8 @@ -/* Expanding upon joystick.h */ -#define JOY_FIRE_IDX 4 - -#define JOY_FIRE(v) ((v) & joy_masks[JOY_FIRE_IDX]) +#define JOY_FIRE_MASK JOY_BTN_1_MASK +#define JOY_FIRE(v) ((v) & JOY_FIRE_MASK) diff --git a/include/cbm264.h b/include/cbm264.h index ff7468d30..46fa64050 100644 --- a/include/cbm264.h +++ b/include/cbm264.h @@ -112,6 +112,17 @@ #define COLOR_LIGHTBLUE (BCOLOR_LIGHTBLUE | CATTR_LUMA7) #define COLOR_GRAY3 (BCOLOR_WHITE | CATTR_LUMA5) + + +/* Masks for joy_read */ +#define JOY_UP_MASK 0x01 +#define JOY_DOWN_MASK 0x02 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x80 + + + /* Define hardware */ #include <_ted.h> #define TED (*(struct __ted*)0xFF00) diff --git a/include/cbm510.h b/include/cbm510.h index 25ea07540..3d6ccd209 100644 --- a/include/cbm510.h +++ b/include/cbm510.h @@ -92,6 +92,13 @@ #define COLOR_LIGHTBLUE 0x0E #define COLOR_GRAY3 0x0F +/* Masks for joy_read */ +#define JOY_UP_MASK 0x01 +#define JOY_DOWN_MASK 0x02 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x10 + /* Define hardware */ #include <_vic2.h> #define VIC (*(struct __vic2*)0xD800) diff --git a/include/creativision.h b/include/creativision.h index 5cc99b7af..a97109029 100644 --- a/include/creativision.h +++ b/include/creativision.h @@ -40,6 +40,14 @@ #define CH_LLCORNER 37 #define CH_LRCORNER 38 +/* Masks for joy_read */ +#define JOY_UP_MASK 0x10 +#define JOY_DOWN_MASK 0x04 +#define JOY_LEFT_MASK 0x20 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x01 +#define JOY_BTN_2_MASK 0x02 + /* no support for dynamically loadable drivers */ #define DYN_DRV 0 diff --git a/include/em/em-kernel.h b/include/em/em-kernel.h index e5df80321..a1ce9a253 100644 --- a/include/em/em-kernel.h +++ b/include/em/em-kernel.h @@ -52,6 +52,7 @@ typedef struct { /* Driver header */ char id[3]; /* Contains 0x65, 0x6d, 0x64 ("emd") */ unsigned char version; /* Interface version */ + void* /* Library reference */ /* Jump vectors. Note that these are not C callable */ void* install; /* INSTALL routine */ diff --git a/include/gamate.h b/include/gamate.h index 7355ede84..0af21623d 100644 --- a/include/gamate.h +++ b/include/gamate.h @@ -170,16 +170,25 @@ /* No support for dynamically loadable drivers */ #define DYN_DRV 0 -/* Expanding upon joystick.h */ -#define JOY_BTN_A_IDX 4 -#define JOY_BTN_B_IDX 5 -#define JOY_START_IDX 6 -#define JOY_SELECT_IDX 7 +/* Masks for joy_read */ +#define JOY_UP_MASK 0x01 +#define JOY_DOWN_MASK 0x02 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x10 +#define JOY_BTN_2_MASK 0x20 +#define JOY_BTN_3_MASK 0x40 +#define JOY_BTN_4_MASK 0x80 -#define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX]) -#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX]) -#define JOY_START(v) ((v) & joy_masks[JOY_START_IDX]) -#define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX]) +#define JOY_BTN_A_MASK JOY_BTN_1_MASK +#define JOY_BTN_B_MASk JOY_BTN_2_MASK +#define JOY_START_MASK JOY_BTN_3_MASK +#define JOY_SELECT_MASK JOY_BTN_4_MASK + +#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK) +#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK) +#define JOY_START(v) ((v) & JOY_START_MASK) +#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK) /* The addresses of the static drivers */ extern void gamate_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ diff --git a/include/geos.h b/include/geos.h index 65b85cd59..ae356d679 100644 --- a/include/geos.h +++ b/include/geos.h @@ -133,6 +133,12 @@ #define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE #define TGI_COLOR_GRAY3 COLOR_GRAY3 +#define JOY_UP_MASK 0x01 +#define JOY_DOWN_MASK 0x02 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x10 + /* End of geos.h */ #endif diff --git a/include/joystick.h b/include/joystick.h index 27c4af81a..26f339fe4 100644 --- a/include/joystick.h +++ b/include/joystick.h @@ -55,28 +55,15 @@ #define JOY_1 0 #define JOY_2 1 -/* The following codes are *indices* into the joy_masks array */ -#define JOY_UP_IDX 0 -#define JOY_DOWN_IDX 1 -#define JOY_LEFT_IDX 2 -#define JOY_RIGHT_IDX 3 -#define JOY_BTN_1_IDX 4 /* Universally available */ -#define JOY_BTN_2_IDX 5 /* Second button if available */ -#define JOY_BTN_3_IDX 6 /* Third button if available */ -#define JOY_BTN_4_IDX 7 /* Fourth button if available */ - -/* Array of masks used to check the return value of joy_read for a state */ -extern const unsigned char joy_masks[8]; - /* Macros that evaluate the return code of joy_read */ -#define JOY_UP(v) ((v) & joy_masks[JOY_UP_IDX]) -#define JOY_DOWN(v) ((v) & joy_masks[JOY_DOWN_IDX]) -#define JOY_LEFT(v) ((v) & joy_masks[JOY_LEFT_IDX]) -#define JOY_RIGHT(v) ((v) & joy_masks[JOY_RIGHT_IDX]) -#define JOY_BTN_1(v) ((v) & joy_masks[JOY_BTN_1_IDX]) -#define JOY_BTN_2(v) ((v) & joy_masks[JOY_BTN_2_IDX]) -#define JOY_BTN_3(v) ((v) & joy_masks[JOY_BTN_3_IDX]) -#define JOY_BTN_4(v) ((v) & joy_masks[JOY_BTN_4_IDX]) +#define JOY_UP(v) ((v) & JOY_UP_MASK) +#define JOY_DOWN(v) ((v) & JOY_DOWN_MASK) +#define JOY_LEFT(v) ((v) & JOY_LEFT_MASK) +#define JOY_RIGHT(v) ((v) & JOY_RIGHT_MASK) +#define JOY_BTN_1(v) ((v) & JOY_BTN_1_MASK) /* Universally available */ +#define JOY_BTN_2(v) ((v) & JOY_BTN_2_MASK) /* Second button if available */ +#define JOY_BTN_3(v) ((v) & JOY_BTN_3_MASK) /* Third button if available */ +#define JOY_BTN_4(v) ((v) & JOY_BTN_4_MASK) /* Fourth button if available */ /* The name of the standard joystick driver for a platform */ extern const char joy_stddrv[]; diff --git a/include/joystick/joy-kernel.h b/include/joystick/joy-kernel.h index bb571de3d..cec2633ab 100644 --- a/include/joystick/joy-kernel.h +++ b/include/joystick/joy-kernel.h @@ -52,9 +52,7 @@ typedef struct { /* Driver header */ char id[3]; /* Contains 0x6a, 0x6f, 0x79 ("joy") */ unsigned char version; /* Interface version */ - - /* Bitmasks for the joystick states. See joystick.h for indices */ - unsigned char masks[8]; + void* /* Library reference */ /* Jump vectors. Note that these are not C callable */ void* install; /* INSTALL routine */ @@ -85,6 +83,3 @@ void joy_clear_ptr (void); /* End of joy-kernel.h */ #endif - - - diff --git a/include/lynx.h b/include/lynx.h index c30ca6265..3629f322e 100644 --- a/include/lynx.h +++ b/include/lynx.h @@ -87,20 +87,25 @@ #define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE #define TGI_COLOR_WHITE COLOR_WHITE +/* Masks for joy_read */ +#define JOY_UP_MASK 0x80 +#define JOY_DOWN_MASK 0x40 +#define JOY_LEFT_MASK 0x20 +#define JOY_RIGHT_MASK 0x10 +#define JOY_BTN_1_MASK 0x01 +#define JOY_BTN_2_MASK 0x02 + +#define JOY_BTN_A_MASK JOY_BTN_1_MASK +#define JOY_BTN_B_MASK JOY_BTN_2_MASK + +#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK) +#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK) + /* No support for dynamically loadable drivers */ #define DYN_DRV 0 -/* Expanding upon joystick.h */ -#define JOY_BTN_A_IDX 4 -#define JOY_BTN_B_IDX 5 - -#define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX]) -#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX]) - - - /*****************************************************************************/ /* Variables */ /*****************************************************************************/ diff --git a/include/nes.h b/include/nes.h index 0b65cdbe4..217a90779 100644 --- a/include/nes.h +++ b/include/nes.h @@ -82,6 +82,26 @@ #define COLOR_LIGHTBLUE 0x0E #define COLOR_GRAY3 0x0F +/* Masks for joy_read */ +#define JOY_UP_MASK 0x10 +#define JOY_DOWN_MASK 0x20 +#define JOY_LEFT_MASK 0x40 +#define JOY_RIGHT_MASK 0x80 +#define JOY_BTN_1_MASK 0x01 +#define JOY_BTN_2_MASK 0x02 +#define JOY_BTN_3_MASK 0x04 +#define JOY_BTN_4_MASK 0x08 + +#define JOY_BTN_A_MASK JOY_BTN_1_MASK +#define JOY_BTN_B_MASK JOY_BTN_2_MASK +#define JOY_SELECT_MASK JOY_BTN_3_MASK +#define JOY_START_MASK JOY_BTN_4_MASK + +#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK) +#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK) +#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK) +#define JOY_START(v) ((v) & JOY_START_MASK) + /* Return codes of get_tv */ #define TV_NTSC 0 #define TV_PAL 1 @@ -90,17 +110,6 @@ /* No support for dynamically loadable drivers */ #define DYN_DRV 0 -/* Expanding upon joystick.h */ -#define JOY_BTN_A_IDX 4 -#define JOY_BTN_B_IDX 5 -#define JOY_SELECT_IDX 6 -#define JOY_START_IDX 7 - -#define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX]) -#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX]) -#define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX]) -#define JOY_START(v) ((v) & joy_masks[JOY_START_IDX]) - /* Define hardware */ /* Picture Processing Unit */ diff --git a/include/pce.h b/include/pce.h index 12b596cf9..7744d0148 100644 --- a/include/pce.h +++ b/include/pce.h @@ -73,19 +73,28 @@ #define TV_PAL 1 #define TV_OTHER 2 +/* Masks for joy_read */ +#define JOY_UP_MASK 0x10 +#define JOY_DOWN_MASK 0x40 +#define JOY_LEFT_MASK 0x80 +#define JOY_RIGHT_MASK 0x20 +#define JOY_BTN_1_MASK 0x01 +#define JOY_BTN_2_MASK 0x02 +#define JOY_BTN_3_MASK 0x04 +#define JOY_BTN_4_MASK 0x08 + +#define JOY_BTN_I_MASK JOY_BTN_1_MASK +#define JOY_BTN_II_MASK JOY_BTN_2_MASK +#define JOY_SELECT_MASK JOY_BTN_3_MASK +#define JOY_RUN_MASK JOY_BTN_4_MASK + +#define JOY_BTN_I(v) ((v) & JOY_BTN_I_MASK) +#define JOY_BTN_II(v) ((v) & JOY_BTN_II_MASK) +#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK) +#define JOY_RUN(v) ((v) & JOY_RUN_MASK) + /* No support for dynamically loadable drivers */ -#define DYN_DRV 0 - -/* Expanding upon joystick.h */ -#define JOY_BTN_I_IDX 4 -#define JOY_BTN_II_IDX 5 -#define JOY_SELECT_IDX 6 -#define JOY_RUN_IDX 7 - -#define JOY_BTN_I(v) ((v) & joy_masks[JOY_BTN_I_IDX]) -#define JOY_BTN_II(v) ((v) & joy_masks[JOY_BTN_II_IDX]) -#define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX]) -#define JOY_RUN(v) ((v) & joy_masks[JOY_RUN_IDX]) +#define DYN_DRV 0 /* The addresses of the static drivers */ extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ diff --git a/include/pet.h b/include/pet.h index 720e40a78..e9659d524 100644 --- a/include/pet.h +++ b/include/pet.h @@ -55,6 +55,13 @@ #define COLOR_BLACK 0x00 #define COLOR_WHITE 0x01 +/* Masks for joy_read */ +#define JOY_UP_MASK 0x01 +#define JOY_DOWN_MASK 0x02 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x10 + /* Define hardware */ #include <_pia.h> #define PIA1 (*(struct __pia*)0xE810) diff --git a/include/vic20.h b/include/vic20.h index c675de6d2..c6ad9632d 100644 --- a/include/vic20.h +++ b/include/vic20.h @@ -77,6 +77,15 @@ +/* Masks for joy_read */ +#define JOY_UP_MASK 0x01 +#define JOY_DOWN_MASK 0x02 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x10 + + + /* Define hardware */ #include <_vic.h> #define VIC (*(struct __vic*)0x9000) diff --git a/libsrc/apple2/joy/a2.stdjoy.s b/libsrc/apple2/joy/a2.stdjoy.s index e4097e043..ed2083255 100644 --- a/libsrc/apple2/joy/a2.stdjoy.s +++ b/libsrc/apple2/joy/a2.stdjoy.s @@ -46,17 +46,6 @@ PREAD := $FB1E ; Read paddle in X, return AD conv. value in Y .addr $0000 -; Button state masks (8 values) - - .byte $10 - .byte $20 - .byte $04 - .byte $08 - .byte $40 - .byte $80 - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table .addr INSTALL @@ -119,7 +108,7 @@ READJOY: lda BUTN0-1,x ; Check button (1, 3) asl tya - ror ; FIRE DOWN !UP RIGHT !LEFT 0 0 0 + ror ; BTN DOWN !UP RIGHT !LEFT 0 0 0 ; Read secondary button tay @@ -130,10 +119,10 @@ READJOY: lda BUTN0-1,x ; Check button (2, 0) asl tya - ror ; FIRE2 FIRE DOWN !UP RIGHT !LEFT 0 0 + ror ; BTN2 BTN DOWN !UP RIGHT !LEFT 0 0 ; Finalize - eor #%00010100 ; FIRE2 FIRE DOWN UP RIGHT LEFT 0 0 + eor #%00010100 ; BTN2 BTN DOWN UP RIGHT LEFT 0 0 ldx #$00 bit $C080 ; Switch in LC bank 2 for R/O rts diff --git a/libsrc/atari/joy/atrstd.s b/libsrc/atari/joy/atrstd.s index fc7aa55f4..0c8799e21 100644 --- a/libsrc/atari/joy/atrstd.s +++ b/libsrc/atari/joy/atrstd.s @@ -34,17 +34,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 not available - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL diff --git a/libsrc/atari5200/joy/atr5200std.s b/libsrc/atari5200/joy/atr5200std.s index 3483cc11a..0b8b93b63 100644 --- a/libsrc/atari5200/joy/atr5200std.s +++ b/libsrc/atari5200/joy/atr5200std.s @@ -27,17 +27,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $20 ; JOY_FIRE2 - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL @@ -99,7 +88,7 @@ READJOY: lda #0 ; Initialize return value cmp TRIG0,y bne @notrg - lda #$10 ; JOY_FIRE + lda #$10 ; JOY_BTN ; Read joystick diff --git a/libsrc/atmos/joy/atmos-pase.s b/libsrc/atmos/joy/atmos-pase.s index 26d7c74d8..637571c04 100644 --- a/libsrc/atmos/joy/atmos-pase.s +++ b/libsrc/atmos/joy/atmos-pase.s @@ -28,17 +28,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $10 ; JOY_UP - .byte $08 ; JOY_DOWN - .byte $01 ; JOY_LEFT - .byte $02 ; JOY_RIGHT - .byte $20 ; JOY_FIRE - .byte $00 ; Future expansion - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL diff --git a/libsrc/c128/joy/c128-ptvjoy.s b/libsrc/c128/joy/c128-ptvjoy.s index 6f65ce5eb..c9ae39a47 100644 --- a/libsrc/c128/joy/c128-ptvjoy.s +++ b/libsrc/c128/joy/c128-ptvjoy.s @@ -30,17 +30,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL diff --git a/libsrc/c128/joy/c128-stdjoy.s b/libsrc/c128/joy/c128-stdjoy.s index a2caead1a..943361da5 100644 --- a/libsrc/c128/joy/c128-stdjoy.s +++ b/libsrc/c128/joy/c128-stdjoy.s @@ -30,17 +30,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL diff --git a/libsrc/c64/joy/c64-hitjoy.s b/libsrc/c64/joy/c64-hitjoy.s index a798100a7..10c936399 100644 --- a/libsrc/c64/joy/c64-hitjoy.s +++ b/libsrc/c64/joy/c64-hitjoy.s @@ -29,17 +29,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL diff --git a/libsrc/c64/joy/c64-ptvjoy.s b/libsrc/c64/joy/c64-ptvjoy.s index 31850488c..e916d887a 100644 --- a/libsrc/c64/joy/c64-ptvjoy.s +++ b/libsrc/c64/joy/c64-ptvjoy.s @@ -29,17 +29,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL diff --git a/libsrc/c64/joy/c64-stdjoy.s b/libsrc/c64/joy/c64-stdjoy.s index 2932c77fd..930ad6227 100644 --- a/libsrc/c64/joy/c64-stdjoy.s +++ b/libsrc/c64/joy/c64-stdjoy.s @@ -29,17 +29,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL diff --git a/libsrc/cbm510/joy/cbm510-std.s b/libsrc/cbm510/joy/cbm510-std.s index 7133f9379..0c2efc12d 100644 --- a/libsrc/cbm510/joy/cbm510-std.s +++ b/libsrc/cbm510/joy/cbm510-std.s @@ -30,17 +30,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL @@ -105,7 +94,7 @@ READ: ldx #$0F ; Switch to the system bank lda (cia2),y ; Read joystick inputs sta tmp1 -; Get the fire bits +; Get the push button bits ldy #CIA::PRA lda (cia2),y @@ -115,12 +104,12 @@ READ: ldx #$0F ; Switch to the system bank cpx #$00 ; Joystick 0? bne @L1 ; Jump if no -; Joystick 1, fire is in bit 6, direction in bit 0-3 +; Joystick 1, push button is in bit 6, direction in bit 0-3 asl a jmp @L2 -; Joystick 2, fire is in bit 7, direction in bit 5-7 +; Joystick 2, push button is in bit 7, direction in bit 5-7 @L1: ldx #$00 ; High byte of return value lsr tmp1 @@ -128,9 +117,9 @@ READ: ldx #$0F ; Switch to the system bank lsr tmp1 lsr tmp1 -; Mask the relavant bits, get the fire bit +; Mask the relavant bits, get the push button bit -@L2: asl a ; Fire bit into carry +@L2: asl a ; push button bit into carry lda tmp1 and #$0F bcc @L3 diff --git a/libsrc/creativision/joy/creativision-stdjoy.s b/libsrc/creativision/joy/creativision-stdjoy.s index 3f167464a..9a5afc42b 100644 --- a/libsrc/creativision/joy/creativision-stdjoy.s +++ b/libsrc/creativision/joy/creativision-stdjoy.s @@ -27,26 +27,6 @@ .addr $0000 -; Symbolic names for joystick masks (similar names like the defines in joystick.h, but not related to them) - -JOY_UP = $10 -JOY_DOWN = $04 -JOY_LEFT = $20 -JOY_RIGHT = $08 -JOY_FIRE = $01 -JOY_FIRE2 = $02 - -; Joystick state masks (8 values) - - .byte JOY_UP - .byte JOY_DOWN - .byte JOY_LEFT - .byte JOY_RIGHT - .byte JOY_FIRE - .byte JOY_FIRE2 - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL @@ -60,6 +40,13 @@ JOY_FIRE2 = $02 JOY_COUNT = 2 ; Number of joysticks we support +; Symbolic names for joystick masks (similar names like the defines in joystick.h, but not related to them) + +JOY_UP = $10 +JOY_DOWN = $04 +JOY_LEFT = $20 +JOY_RIGHT = $08 + ; ------------------------------------------------------------------------ ; Code @@ -129,7 +116,7 @@ convert: ; values were shifted to the right to be identical). ; Why are there two bits indicating a pressed trigger? ; According to the "Second book of programs for the Dick Smith Wizard" -; (pg. 88ff), the left hand fire button gives the value of +; (pg. 88ff), the left hand button gives the value of ; %00010001 and the right hand button gives %00100010 ; Why two bits? Can there be cases that just one of those bits is set? ; Until these questions have been answered, we only use the lower two diff --git a/libsrc/gamate/joy/gamate-stdjoy.s b/libsrc/gamate/joy/gamate-stdjoy.s index 8b18bae7a..d10eb6f41 100644 --- a/libsrc/gamate/joy/gamate-stdjoy.s +++ b/libsrc/gamate/joy/gamate-stdjoy.s @@ -24,17 +24,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE_A - .byte $20 ; JOY_FIRE_B - .byte $80 ; JOY_SELECT - .byte $40 ; JOY_START - ; Jump table. .addr INSTALL diff --git a/libsrc/geos-cbm/joy/geos-stdjoy.s b/libsrc/geos-cbm/joy/geos-stdjoy.s index 6afe46092..2787cb594 100644 --- a/libsrc/geos-cbm/joy/geos-stdjoy.s +++ b/libsrc/geos-cbm/joy/geos-stdjoy.s @@ -28,17 +28,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; Future expansion - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .word INSTALL diff --git a/libsrc/joystick/joy-kernel.s b/libsrc/joystick/joy-kernel.s index 2b1dcf884..0746709e9 100644 --- a/libsrc/joystick/joy-kernel.s +++ b/libsrc/joystick/joy-kernel.s @@ -19,8 +19,6 @@ .bss _joy_drv: .res 2 ; Pointer to driver -_joy_masks: .res .sizeof(JOY_HDR::MASKS) - ; Jump table for the driver functions. .data joy_vectors: @@ -65,38 +63,28 @@ _joy_install: lda #>joy_libref sta (ptr1),y -; Copy the mask array - - ldy #JOY_HDR::MASKS + .sizeof(JOY_HDR::MASKS) - 1 - ldx #.sizeof(JOY_HDR::MASKS)-1 -@L1: lda (ptr1),y - sta _joy_masks,x - dey - dex - bpl @L1 - ; Copy the jump vectors ldy #JOY_HDR::JUMPTAB ldx #0 -@L2: inx ; Skip the JMP opcode +@L1: inx ; Skip the JMP opcode jsr copy ; Copy one byte jsr copy ; Copy one byte cpy #(JOY_HDR::JUMPTAB + .sizeof(JOY_HDR::JUMPTAB)) - bne @L2 + bne @L1 jsr joy_install ; Call driver install routine tay ; Test error code - bne @L3 ; Bail out if install had errors + bne @L2 ; Bail out if install had errors ; Install the IRQ vector if the driver needs it. A/X contains the error code ; from joy_install, so don't use it. ldy joy_irq+2 ; Check high byte of IRQ vector - beq @L3 ; Jump if vector invalid + beq @L2 ; Jump if vector invalid ldy #$4C ; JMP opcode sty joy_irq ; Activate IRQ routine -@L3: rts +@L2: rts ; Driver signature invalid diff --git a/libsrc/lynx/joy/lynx-stdjoy.s b/libsrc/lynx/joy/lynx-stdjoy.s index 114647072..2e91cc43b 100644 --- a/libsrc/lynx/joy/lynx-stdjoy.s +++ b/libsrc/lynx/joy/lynx-stdjoy.s @@ -31,18 +31,6 @@ .addr $0000 -; Button state masks (8 values) - -joy_mask: - .byte $80 ; JOY_UP - .byte $40 ; JOY_DOWN - .byte $20 ; JOY_LEFT - .byte $10 ; JOY_RIGHT - .byte $01 ; JOY_FIRE - .byte $02 ; JOY_FIRE1 - .byte $00 ; - .byte $00 ; - ; Jump table. .addr INSTALL diff --git a/libsrc/nes/joy/nes-stdjoy.s b/libsrc/nes/joy/nes-stdjoy.s index b5e653c16..3032e9330 100644 --- a/libsrc/nes/joy/nes-stdjoy.s +++ b/libsrc/nes/joy/nes-stdjoy.s @@ -29,17 +29,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $10 ; JOY_UP - .byte $20 ; JOY_DOWN - .byte $40 ; JOY_LEFT - .byte $80 ; JOY_RIGHT - .byte $01 ; JOY_FIRE (A) - .byte $02 ; JOY_FIRE2 (B) - .byte $04 ; (Select) - .byte $08 ; (Start) - ; Jump table. .addr INSTALL diff --git a/libsrc/pce/joy/pce-stdjoy.s b/libsrc/pce/joy/pce-stdjoy.s index 746929dd2..ab25134dd 100644 --- a/libsrc/pce/joy/pce-stdjoy.s +++ b/libsrc/pce/joy/pce-stdjoy.s @@ -24,17 +24,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $10 ; JOY_UP - .byte $40 ; JOY_DOWN - .byte $80 ; JOY_LEFT - .byte $20 ; JOY_RIGHT - .byte $01 ; JOY_FIRE_A - .byte $02 ; JOY_FIRE_B - .byte $04 ; JOY_SELECT - .byte $08 ; JOY_RUN - ; Jump table. .addr INSTALL diff --git a/libsrc/pet/joy/pet-ptvjoy.s b/libsrc/pet/joy/pet-ptvjoy.s index 229055fcb..3bb368355 100644 --- a/libsrc/pet/joy/pet-ptvjoy.s +++ b/libsrc/pet/joy/pet-ptvjoy.s @@ -28,17 +28,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL diff --git a/libsrc/pet/joy/pet-stdjoy.s b/libsrc/pet/joy/pet-stdjoy.s index 5847c2b09..29c6de627 100644 --- a/libsrc/pet/joy/pet-stdjoy.s +++ b/libsrc/pet/joy/pet-stdjoy.s @@ -27,17 +27,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL diff --git a/libsrc/plus4/joy/plus4-stdjoy.s b/libsrc/plus4/joy/plus4-stdjoy.s index 4a5132887..d998b2699 100644 --- a/libsrc/plus4/joy/plus4-stdjoy.s +++ b/libsrc/plus4/joy/plus4-stdjoy.s @@ -31,17 +31,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $80 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL @@ -107,7 +96,7 @@ READ: ldy #%11111011 ; Load index for joystick #1 cli eor #%11111111 -; The fire buttons are in bits 6 and 7. Both of them cannot be %1 together. +; The push buttons are in bits 6 and 7. Both of them cannot be %1 together. ; Therefore, bit 6 can be merged with bit 7. clc diff --git a/libsrc/vic20/joy/vic20-ptvjoy.s b/libsrc/vic20/joy/vic20-ptvjoy.s index cdd4c274f..07c979443 100644 --- a/libsrc/vic20/joy/vic20-ptvjoy.s +++ b/libsrc/vic20/joy/vic20-ptvjoy.s @@ -30,17 +30,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL @@ -152,4 +141,3 @@ joy3: lda #$00 ; via port B read/write ldx #0 rts - diff --git a/testcode/lib/joy-test.c b/testcode/lib/joy-test.c index fc751ebdc..fdd83bb4e 100644 --- a/testcode/lib/joy-test.c +++ b/testcode/lib/joy-test.c @@ -58,21 +58,19 @@ int main (void) #if defined(__ATARI5200__) || defined(__CREATIVISION__) cprintf ("%1d:%-3s%-3s%-3s%-3s%-3s%-3s", i, - (j & joy_masks[JOY_UP])? " U " : " ", - (j & joy_masks[JOY_DOWN])? " D " : " ", - (j & joy_masks[JOY_LEFT])? " L " : " ", - (j & joy_masks[JOY_RIGHT])? " R " : " ", - (j & joy_masks[JOY_FIRE])? " 1 " : " ", - (j & joy_masks[JOY_FIRE2])? " 2 " : " "); + JOY_UP(j)? " U " : " - ", + JOY_DOWN(j)? " D " : " - ", + JOY_LEFT(j)? " L " : " - ", + JOY_RIGHT(j)? " R " : " - ", + JOY_BTN_1(j)? " 1 " : " - "); #else cprintf ("%2d: %-6s%-6s%-6s%-6s%-6s%-6s", i, - (j & joy_masks[JOY_UP])? " up " : " ---- ", - (j & joy_masks[JOY_DOWN])? " down " : " ---- ", - (j & joy_masks[JOY_LEFT])? " left " : " ---- ", - (j & joy_masks[JOY_RIGHT])? "right " : " ---- ", - (j & joy_masks[JOY_FIRE])? " fire " : " ---- ", - (j & joy_masks[JOY_FIRE2])? "fire2 " : " ---- "); + JOY_UP(j)? " up " : " ---- ", + JOY_DOWN(j)? " down " : " ---- ", + JOY_LEFT(j)? " left " : " ---- ", + JOY_RIGHT(j)? "right " : " ---- ", + JOY_BTN_1(j)? "button" : " ---- "); #endif } } diff --git a/testcode/lib/pce/conio.c b/testcode/lib/pce/conio.c index 00ae3c157..ed3f86240 100644 --- a/testcode/lib/pce/conio.c +++ b/testcode/lib/pce/conio.c @@ -1,3 +1,4 @@ +#include <pce.h> #include <conio.h> #include <time.h> #include <joystick.h> @@ -97,14 +98,14 @@ void main(void) j = joy_read (i); cprintf ("pad %d: %02x %-6s%-6s%-6s%-6s%-6s%-6s%-6s%-6s", i, j, - (j & joy_masks[JOY_UP])? " up " : " ---- ", - (j & joy_masks[JOY_DOWN])? " down " : " ---- ", - (j & joy_masks[JOY_LEFT])? " left " : " ---- ", - (j & joy_masks[JOY_RIGHT])? "right " : " ---- ", - (j & joy_masks[JOY_FIRE])? " fire " : " ---- ", - (j & joy_masks[JOY_FIRE2])? "fire2 " : " ---- ", - (j & joy_masks[JOY_SELECT])? "select" : " ---- ", - (j & joy_masks[JOY_RUN])? " run " : " ---- "); + JOY_UP(j)? " up " : " ---- ", + JOY_DOWN(j)? " down " : " ---- ", + JOY_LEFT(j)? " left " : " ---- ", + JOY_RIGHT(j)? "right " : " ---- ", + JOY_BTN_I(j)? "btn I " : " ---- ", + JOY_BTN_II(j)? "btn II" : " ---- ", + JOY_SELECT(j)? "select" : " ---- ", + JOY_RUN(j)? " run " : " ---- "); } gotoxy(xsize - 10, 3); From 960957075ff828c51d0150a8bd5d6da213db431e Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sat, 19 Aug 2017 19:14:24 +0200 Subject: [PATCH 181/199] use fastcall --- include/cbm.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/cbm.h b/include/cbm.h index d15ec5381..a1734d41a 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -164,9 +164,9 @@ unsigned char get_tv (void); #define KBDREPEAT_NONE 0x40 #define KBDREPEAT_ALL 0x80 -unsigned char kbrepeat(unsigned char); -unsigned char kbrepeatdelay(unsigned char); -unsigned char kbrepeatrate(unsigned char); +unsigned char __fastcall__ kbrepeat(unsigned char); +unsigned char __fastcall__ kbrepeatdelay(unsigned char); +unsigned char __fastcall__ kbrepeatrate(unsigned char); #if !defined(__CBM610__) && !defined(__PET__) void waitvsync (void); From 3c3558892e75a7a44a36eaf566fbad3fb903b221 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sat, 19 Aug 2017 19:16:31 +0200 Subject: [PATCH 182/199] add note on fastcall --- doc/funcref.sgml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 8e6b1b153..f866dea5f 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -2181,7 +2181,8 @@ only cursor-related keys), KBDREPEAT_NONE (no repeat for any keys) and KBDREPEAT_ALL (repeat all keys). The old mode is returned so it can be restored later. <tag/Notes/<itemize> -<item> +<item>The function is available only as a fastcall function; so, it may be used +only in the presence of a prototype. </itemize> <tag/Availability/cc65 <tag/See also/ @@ -2202,7 +2203,8 @@ The old mode is returned so it can be restored later. repeated automatically. The old value is returned so it can be restored later. <tag/Notes/<itemize> -<item> +<item>The function is available only as a fastcall function; so, it may be used +only in the presence of a prototype. </itemize> <tag/Availability/cc65 <tag/See also/ @@ -2223,7 +2225,8 @@ The old value is returned so it can be restored later. repeated keypresses). The old value is returned so it can be restored later. <tag/Notes/<itemize> -<item> +<item>The function is available only as a fastcall function; so, it may be used +only in the presence of a prototype. </itemize> <tag/Availability/cc65 <tag/See also/ From 0c54a19a0b482e5498c0c95ab1588731d34623d4 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 20 Aug 2017 11:49:02 +0200 Subject: [PATCH 183/199] Adjusted to recent driver interface change. The change is inspired by the code of the standard joystick driver. It is however absolutely untested. Note: Sites like http://raster.atariportal.cz/english.htm state that there needs to be a delay when reading joysticks via the MultiJoy adapter. There's no such delay in the driver. But I don't dare to decide to add it. --- libsrc/atari/joy/atrmj8.s | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/libsrc/atari/joy/atrmj8.s b/libsrc/atari/joy/atrmj8.s index 46766070b..0e8cd2a0a 100644 --- a/libsrc/atari/joy/atrmj8.s +++ b/libsrc/atari/joy/atrmj8.s @@ -35,17 +35,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $02 ; JOY_UP - .byte $04 ; JOY_DOWN - .byte $08 ; JOY_LEFT - .byte $10 ; JOY_RIGHT - .byte $01 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 not available - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL @@ -115,10 +104,12 @@ READJOY: ; Read joystick - lda PORTA ; get position - and #%00001111 + lda STRIG0 ; get button asl a - ora TRIG0 ; add button information - eor #%00011111 + asl a + asl a + asl a + ora PORTA ; add position information + eor #$1F ldx #0 ; fix X rts From a817da7c6bc0db40cbe23866b4b7a04b280ab612 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 20 Aug 2017 14:25:02 +0200 Subject: [PATCH 184/199] Adjusted to recent driver interface change. Please note that this change is absolutely untested! --- libsrc/c64/joy/c64-numpad.s | 70 +++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/libsrc/c64/joy/c64-numpad.s b/libsrc/c64/joy/c64-numpad.s index 5f6464215..5ed7af187 100644 --- a/libsrc/c64/joy/c64-numpad.s +++ b/libsrc/c64/joy/c64-numpad.s @@ -30,17 +30,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $02 ; JOY_UP "8" - .byte $10 ; JOY_DOWN "2" - .byte $20 ; JOY_LEFT "4" - .byte $08 ; JOY_RIGHT "6" - .byte $04 ; JOY_FIRE "5" ENTER - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL @@ -58,6 +47,49 @@ JOY_COUNT = 1 ; Number of joysticks we support ; ------------------------------------------------------------------------ ; Data. +.rodata + +; <U>p '8' key +; <D>own '2' key +; <L>eft '4' key +; <R>ight '6' key +; <B>utton '5' or ENTER key + +masktable: + ; Input: LDRBU + ; Output: BRLDU + .byte %00000000 ; $00 + .byte %00000001 ; $01 + .byte %00010000 ; $02 + .byte %00010001 ; $03 + .byte %00001000 ; $04 + .byte %00001001 ; $05 + .byte %00011000 ; $06 + .byte %00011001 ; $07 + .byte %00000010 ; $08 + .byte %00000011 ; $09 + .byte %00010010 ; $0A + .byte %00010011 ; $0B + .byte %00001010 ; $0C + .byte %00001011 ; $0D + .byte %00011010 ; $0E + .byte %00011011 ; $0F + .byte %00000100 ; $10 + .byte %00000101 ; $11 + .byte %00010100 ; $12 + .byte %00010101 ; $13 + .byte %00001100 ; $14 + .byte %00001101 ; $15 + .byte %00011100 ; $16 + .byte %00011101 ; $17 + .byte %00000110 ; $18 + .byte %00000111 ; $19 + .byte %00010110 ; $1A + .byte %00010111 ; $1B + .byte %00001110 ; $1C + .byte %00001111 ; $1D + .byte %00011110 ; $1E + .byte %00011111 ; $1F .code @@ -100,21 +132,23 @@ COUNT: lda #JOY_COUNT ; READ: tax ; Clear high byte - lda #$FD - ldy #$FE + lda #$FD ; For ENTER and '6' + ldy #$FE ; For '8', '5', '2', '4' sei sta VIC_KBD_128 lda CIA1_PRB and #%00110000 eor #%00110000 - lsr - lsr + lsr ; Map ENTER ... + lsr ; ... onto '5' sty VIC_KBD_128 eor CIA1_PRB iny sty VIC_KBD_128 ; Reset to $FF cli - and #%11111110 - eor #%11111110 + and #%00111110 + eor #%00111110 + lsr + tay + lda masktable,y ; Convert LDRBU to BRLDU rts - From 20c85c8a1c35004f83ea5ba621dcd73145caf377 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 20 Aug 2017 14:53:40 +0200 Subject: [PATCH 185/199] Minor style adjustment. --- libsrc/c64/joy/c64-ptvjoy.s | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libsrc/c64/joy/c64-ptvjoy.s b/libsrc/c64/joy/c64-ptvjoy.s index e916d887a..af5c27e13 100644 --- a/libsrc/c64/joy/c64-ptvjoy.s +++ b/libsrc/c64/joy/c64-ptvjoy.s @@ -122,8 +122,8 @@ joy3: sta CIA2_PRB ; (output one at PB7) lda CIA2_PRB ; cia 2 port B read/write - and #$1f ; get bit 4-0 (PB4-PB0) - eor #$1f + and #$1F ; get bit 4-0 (PB4-PB0) + eor #$1F rts ; Read joystick 4 @@ -132,14 +132,14 @@ joy4: lda #$00 ; cia 2 port B read/write sta CIA2_PRB ; (output zero at PB7) lda CIA2_PRB ; cia 2 port B read/write - and #$0f ; get bit 3-0 (PB3-PB0) + and #$0F ; get bit 3-0 (PB3-PB0) sta tmp1 ; joy 4 directions lda CIA2_PRB ; cia 2 port B read/write and #%00100000 ; get bit 5 (PB5) lsr ora tmp1 - eor #$1f + eor #$1F ldx #0 rts From acf831658f591675b890c9c191fcc540094ae77e Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 20 Aug 2017 16:39:07 +0200 Subject: [PATCH 186/199] Adjusted to recent driver interface change. Please note that this change is absolutely untested! Apart from the recent driver interface change: - vic20-stdjoy.s was "slightly broken" because it didn't clear x on return from joy_read. - vic20-ptvjoy.s was "heavily broken" because it returned a totally different set of bits of the first joystick. --- libsrc/vic20/joy/vic20-ptvjoy.s | 25 ++++++++++++++++++------- libsrc/vic20/joy/vic20-stdjoy.s | 17 ++++++++++++++--- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/libsrc/vic20/joy/vic20-ptvjoy.s b/libsrc/vic20/joy/vic20-ptvjoy.s index 07c979443..3b1db402a 100644 --- a/libsrc/vic20/joy/vic20-ptvjoy.s +++ b/libsrc/vic20/joy/vic20-ptvjoy.s @@ -102,10 +102,21 @@ joy1: lda #$7F ; mask for VIA2 JOYBIT: sw3 sty VIA1_DDRA ; restore the state of DDRA cli ; necessary? - ror ; Shift sw3 into bit 7 - and #$9E ; Mask relevant bits - eor #$9E ; Active states are inverted + php ; Save sw3 in carry + lsr ; Shift sw0,sw1,sw2,sw4 into bits 1-4 + tax ; Save sw0,sw1,sw2 + and #$10 ; Extract sw4 in bit 4 + sta tmp1 ; Save sw4 in bit 4 + txa ; Restore sw0,sw1,sw2 + lsr ; Shift sw0,sw1,sw2 into bits 0-2 + and #$07 ; Mask bits 0-2 + plp ; Restore sw3 in carry + bcc @L0 ; Is sw3 set? + ora #$08 ; Yes: Add sw3 in bit 3 +@L0: ora tmp1 ; Add sw4 in bit 4 + eor #$1F ; Active states are inverted + ldx #0 rts ; Read joystick 2 @@ -120,8 +131,8 @@ joy2: lda #%10000000 ; via port B Data-Direction sta VIA1_PRB ; (output one at PB7) lda VIA1_PRB ; via port B read/write - and #$1f ; get bit 4-0 (PB4-PB0) - eor #$1f + and #$1F ; get bit 4-0 (PB4-PB0) + eor #$1F rts ; Read joystick 3 @@ -130,14 +141,14 @@ joy3: lda #$00 ; via port B read/write sta VIA1_PRB ; (output zero at PB7) lda VIA1_PRB ; via port B read/write - and #$0f ; get bit 3-0 (PB3-PB0) + and #$0F ; get bit 3-0 (PB3-PB0) sta tmp1 ; joy 4 directions lda VIA1_PRB ; via port B read/write and #%00100000 ; get bit 5 (PB5) lsr ora tmp1 - eor #$1f + eor #$1F ldx #0 rts diff --git a/libsrc/vic20/joy/vic20-stdjoy.s b/libsrc/vic20/joy/vic20-stdjoy.s index 56fb35ae4..bf10acce5 100644 --- a/libsrc/vic20/joy/vic20-stdjoy.s +++ b/libsrc/vic20/joy/vic20-stdjoy.s @@ -112,10 +112,21 @@ READ: lda #$7F ; mask for VIA2 JOYBIT: sw3 sty VIA1_DDRA ; restore the state of DDRA cli ; necessary? - ror ; Shift sw3 into bit 7 - and #$9E ; Mask relevant bits - eor #$9E ; Active states are inverted + php ; Save sw3 in carry + lsr ; Shift sw0,sw1,sw2,sw4 into bits 1-4 + tax ; Save sw0,sw1,sw2 + and #$10 ; Extract sw4 in bit 4 + sta tmp1 ; Save sw4 in bit 4 + txa ; Restore sw0,sw1,sw2 + lsr ; Shift sw0,sw1,sw2 into bits 0-2 + and #$07 ; Mask bits 0-2 + plp ; Restore sw3 in carry + bcc @L0 ; Is sw3 set? + ora #$08 ; Yes: Add sw3 in bit 3 +@L0: ora tmp1 ; Add sw4 in bit 4 + eor #$1F ; Active states are inverted + ldx #0 rts From 7a1f5358df2817809464ceeebfd34844c5a2a04e Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 23 Aug 2017 01:46:57 -0400 Subject: [PATCH 187/199] Fixed missing name and semicolon in two device structs. --- include/em/em-kernel.h | 5 +---- include/joystick/joy-kernel.h | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/include/em/em-kernel.h b/include/em/em-kernel.h index a1ce9a253..ffc6e131a 100644 --- a/include/em/em-kernel.h +++ b/include/em/em-kernel.h @@ -52,7 +52,7 @@ typedef struct { /* Driver header */ char id[3]; /* Contains 0x65, 0x6d, 0x64 ("emd") */ unsigned char version; /* Interface version */ - void* /* Library reference */ + void* libreference; /* Library reference */ /* Jump vectors. Note that these are not C callable */ void* install; /* INSTALL routine */ @@ -75,6 +75,3 @@ extern em_drv_header* em_drv; /* Pointer to driver */ /* End of em-kernel.h */ #endif - - - diff --git a/include/joystick/joy-kernel.h b/include/joystick/joy-kernel.h index cec2633ab..e984291f7 100644 --- a/include/joystick/joy-kernel.h +++ b/include/joystick/joy-kernel.h @@ -52,7 +52,7 @@ typedef struct { /* Driver header */ char id[3]; /* Contains 0x6a, 0x6f, 0x79 ("joy") */ unsigned char version; /* Interface version */ - void* /* Library reference */ + void* libreference; /* Library reference */ /* Jump vectors. Note that these are not C callable */ void* install; /* INSTALL routine */ From 4aa19494f5346a79d4c940903ad93f06be79915e Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 30 Aug 2017 16:37:31 +0200 Subject: [PATCH 188/199] Removed dysfunctional kbrepeatdelay() and kbrepeatrate(). As discussed in https://github.com/cc65/cc65/pull/452 after my premature merge the two functions in question don't work as expected. Additionally I adjusted several style deviations in the pull request in question. --- doc/funcref.sgml | 61 ++++------------------------------------- include/cbm.h | 13 ++++----- libsrc/c128/kbrepeat.s | 18 ++++-------- libsrc/c64/kbrepeat.s | 18 ++++-------- libsrc/pet/kbrepeat.s | 18 ++++-------- libsrc/plus4/kbrepeat.s | 18 ++++-------- libsrc/vic20/kbrepeat.s | 18 ++++-------- 7 files changed, 37 insertions(+), 127 deletions(-) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index f866dea5f..5ef773b95 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -184,8 +184,6 @@ function. <!-- <item><ref id="cbm_write" name="cbm_write"> --> <!-- <item><ref id="get_tv" name="get_tv"> --> <item><ref id="kbrepeat" name="kbrepeat"> -<item><ref id="kbrepeatdelay" name="kbrepeatdelay"> -<item><ref id="kbrepeatrate" name="kbrepeatrate"> </itemize> (incomplete) @@ -2174,64 +2172,17 @@ to get off the serial bus so it can be used for other purposes. <descrip> <tag/Function/Set keyboard repeat mode <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/ -<tag/Declaration/<tt/unsigned char kbrepeat (unsigned char);/ -<tag/Description/This function changes what keys will have automatic repeat when -being hold down for a certain time. Possible values are KBDREPEAT_CURSOR (repeat -only cursor-related keys), KBDREPEAT_NONE (no repeat for any keys) and -KBDREPEAT_ALL (repeat all keys). -The old mode is returned so it can be restored later. +<tag/Declaration/<tt/unsigned char __fastcall__ kbrepeat (unsigned char mode);/ +<tag/Description/This function changes which keys have automatic repeat when +being hold down for a certain time. Possible values are KBREPEAT_CURSOR (repeat +only cursor-related keys), KBREPEAT_NONE (no repeat for any keys) and +KBREPEAT_ALL (repeat all keys). The old mode is returned so it can be restored +later. <tag/Notes/<itemize> <item>The function is available only as a fastcall function; so, it may be used only in the presence of a prototype. </itemize> <tag/Availability/cc65 -<tag/See also/ -<ref id="kbrepeatdelay" name="kbrepeatdelay"> -<ref id="kbrepeatrate" name="kbrepeatrate"> -<tag/Example/None. -</descrip> -</quote> - -<sect1>kbrepeatdelay<label id="kbrepeatdelay"><p> - -<quote> -<descrip> -<tag/Function/Set keyboard repeat delay -<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/ -<tag/Declaration/<tt/unsigned char kbrepeatdelay (unsigned char);/ -<tag/Description/This function changes the delay until a keypress is being -repeated automatically. -The old value is returned so it can be restored later. -<tag/Notes/<itemize> -<item>The function is available only as a fastcall function; so, it may be used -only in the presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="kbrepeat" name="kbrepeat"> -<ref id="kbrepeatrate" name="kbrepeatrate"> -<tag/Example/None. -</descrip> -</quote> - -<sect1>kbrepeatrate<label id="kbrepeatrate"><p> - -<quote> -<descrip> -<tag/Function/Set keyboard repeat rate -<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/ -<tag/Declaration/<tt/unsigned char kbrepeatrate (unsigned char);/ -<tag/Description/This function changes the keyboard repeat rate (the time between -repeated keypresses). -The old value is returned so it can be restored later. -<tag/Notes/<itemize> -<item>The function is available only as a fastcall function; so, it may be used -only in the presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="kbrepeat" name="kbrepeat"> -<ref id="kbrepeatdelay" name="kbrepeatdelay"> <tag/Example/None. </descrip> </quote> diff --git a/include/cbm.h b/include/cbm.h index c1762b1a9..a4b232406 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -158,17 +158,16 @@ struct cbm_dirent { unsigned char get_tv (void); /* Return the video mode the machine is using. */ -#define KBDREPEAT_CURSOR 0x00 -#define KBDREPEAT_NONE 0x40 -#define KBDREPEAT_ALL 0x80 +#define KBREPEAT_CURSOR 0x00 +#define KBREPEAT_NONE 0x40 +#define KBREPEAT_ALL 0x80 -unsigned char __fastcall__ kbrepeat(unsigned char); -unsigned char __fastcall__ kbrepeatdelay(unsigned char); -unsigned char __fastcall__ kbrepeatrate(unsigned char); +unsigned char __fastcall__ kbrepeat (unsigned char mode); +/* Changes which keys have automatic repeat. */ #if !defined(__CBM610__) && !defined(__PET__) void waitvsync (void); -/* wait for the start of the next frame */ +/* Wait for the start of the next frame */ #endif /*****************************************************************************/ diff --git a/libsrc/c128/kbrepeat.s b/libsrc/c128/kbrepeat.s index c32e8c017..4b9bc22af 100644 --- a/libsrc/c128/kbrepeat.s +++ b/libsrc/c128/kbrepeat.s @@ -1,5 +1,8 @@ +; +; unsigned char __fastcall__ kbrepeat (unsigned char mode); +; - .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate + .export _kbrepeat .include "c128.inc" @@ -7,16 +10,5 @@ _kbrepeat: ldx KBDREPEAT ; get old value sta KBDREPEAT ; store new value txa ; return old value - rts - -_kbrepeatdelay: - ldx KBDREPEATDELAY ; get old value - sta KBDREPEATDELAY ; store new value - txa ; return old value - rts - -_kbrepeatrate: - ldx KBDREPEATRATE ; get old value - sta KBDREPEATRATE ; store new value - txa ; return old value + ldx #0 rts diff --git a/libsrc/c64/kbrepeat.s b/libsrc/c64/kbrepeat.s index f59c8a6da..0df13e58d 100644 --- a/libsrc/c64/kbrepeat.s +++ b/libsrc/c64/kbrepeat.s @@ -1,5 +1,8 @@ +; +; unsigned char __fastcall__ kbrepeat (unsigned char mode); +; - .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate + .export _kbrepeat .include "c64.inc" @@ -7,16 +10,5 @@ _kbrepeat: ldx KBDREPEAT ; get old value sta KBDREPEAT ; store new value txa ; return old value - rts - -_kbrepeatdelay: - ldx KBDREPEATDELAY ; get old value - sta KBDREPEATDELAY ; store new value - txa ; return old value - rts - -_kbrepeatrate: - ldx KBDREPEATRATE ; get old value - sta KBDREPEATRATE ; store new value - txa ; return old value + ldx #0 rts diff --git a/libsrc/pet/kbrepeat.s b/libsrc/pet/kbrepeat.s index 0a29d7420..8299f5103 100644 --- a/libsrc/pet/kbrepeat.s +++ b/libsrc/pet/kbrepeat.s @@ -1,5 +1,8 @@ +; +; unsigned char __fastcall__ kbrepeat (unsigned char mode); +; - .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate + .export _kbrepeat .include "pet.inc" @@ -7,16 +10,5 @@ _kbrepeat: ldx KBDREPEAT ; get old value sta KBDREPEAT ; store new value txa ; return old value - rts - -_kbrepeatdelay: - ldx KBDREPEATDELAY ; get old value - sta KBDREPEATDELAY ; store new value - txa ; return old value - rts - -_kbrepeatrate: - ldx KBDREPEATRATE ; get old value - sta KBDREPEATRATE ; store new value - txa ; return old value + ldx #0 rts diff --git a/libsrc/plus4/kbrepeat.s b/libsrc/plus4/kbrepeat.s index 927b99e5b..9c0dc6855 100644 --- a/libsrc/plus4/kbrepeat.s +++ b/libsrc/plus4/kbrepeat.s @@ -1,5 +1,8 @@ +; +; unsigned char __fastcall__ kbrepeat (unsigned char mode); +; - .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate + .export _kbrepeat .include "plus4.inc" @@ -7,16 +10,5 @@ _kbrepeat: ldx KBDREPEAT ; get old value sta KBDREPEAT ; store new value txa ; return old value - rts - -_kbrepeatdelay: - ldx KBDREPEATDELAY ; get old value - sta KBDREPEATDELAY ; store new value - txa ; return old value - rts - -_kbrepeatrate: - ldx KBDREPEATRATE ; get old value - sta KBDREPEATRATE ; store new value - txa ; return old value + ldx #0 rts diff --git a/libsrc/vic20/kbrepeat.s b/libsrc/vic20/kbrepeat.s index 5115c852e..dce4949fb 100644 --- a/libsrc/vic20/kbrepeat.s +++ b/libsrc/vic20/kbrepeat.s @@ -1,5 +1,8 @@ +; +; unsigned char __fastcall__ kbrepeat (unsigned char mode); +; - .export _kbrepeat, _kbrepeatdelay, _kbrepeatrate + .export _kbrepeat .include "vic20.inc" @@ -7,16 +10,5 @@ _kbrepeat: ldx KBDREPEAT ; get old value sta KBDREPEAT ; store new value txa ; return old value - rts - -_kbrepeatdelay: - ldx KBDREPEATDELAY ; get old value - sta KBDREPEATDELAY ; store new value - txa ; return old value - rts - -_kbrepeatrate: - ldx KBDREPEATRATE ; get old value - sta KBDREPEATRATE ; store new value - txa ; return old value + ldx #0 rts From 929553dc8df122916d89d97afb4adc2ccb141e29 Mon Sep 17 00:00:00 2001 From: Phil Smith <phil.h.smith@gmail.com> Date: Fri, 1 Sep 2017 23:11:54 -0700 Subject: [PATCH 189/199] At most 256 bytes will be reserved --- doc/ca65.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 33acc0a80..cb4fbb500 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -1695,7 +1695,7 @@ either a string or an expression. Example: <tscreen><verb> - ; Reserve space for some data, but 256 bytes minimum + ; Reserve space for some data, but 256 bytes maximum savearea: .min (.sizeof (foo), 256) </verb></tscreen> From ded1c201904e8a0b8f2ffb792438226a977f0fab Mon Sep 17 00:00:00 2001 From: Phil Smith <phil.h.smith@gmail.com> Date: Sat, 2 Sep 2017 19:25:49 -0700 Subject: [PATCH 190/199] Reserve space in examples with .res --- doc/ca65.sgml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index cb4fbb500..715ecd89e 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -1636,7 +1636,7 @@ either a string or an expression. <tscreen><verb> ; Reserve space for the larger of two data blocks - savearea: .max (.sizeof (foo), .sizeof (bar)) + savearea: .res .max (.sizeof (foo), .sizeof (bar)) </verb></tscreen> See: <tt><ref id=".MIN" name=".MIN"></tt> @@ -1696,7 +1696,7 @@ either a string or an expression. <tscreen><verb> ; Reserve space for some data, but 256 bytes maximum - savearea: .min (.sizeof (foo), 256) + savearea: .res .min (.sizeof (foo), 256) </verb></tscreen> See: <tt><ref id=".MAX" name=".MAX"></tt> From 0deeccebf8bc0e7658213b12875efaad3abf216f Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Mon, 4 Sep 2017 09:41:19 +0200 Subject: [PATCH 191/199] Added JOY_FIRE. According to https://en.wikipedia.org/wiki/Atari_8-bit_computer_peripherals it seems appropriate to add a JOY_FIRE definition for the ATARI. --- include/atari.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/atari.h b/include/atari.h index ca4b2ef26..bf1af7d7b 100644 --- a/include/atari.h +++ b/include/atari.h @@ -156,6 +156,9 @@ #define JOY_RIGHT_MASK 0x08 #define JOY_BTN_1_MASK 0x10 +#define JOY_FIRE_MASK JOY_BTN_1_MASK +#define JOY_FIRE(v) ((v) & JOY_FIRE_MASK) + /* color register functions */ extern void __fastcall__ _setcolor (unsigned char color_reg, unsigned char hue, unsigned char luminace); extern void __fastcall__ _setcolor_low (unsigned char color_reg, unsigned char color_value); From 3c0b8c4e862de0b54e547aa3ad0dfa7e6fd668f2 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 5 Sep 2017 03:40:34 -0400 Subject: [PATCH 192/199] Made the CBM Pet kbrepeat() work on both 40-column and 80-column machines. Put the kbrepeat() description in an alphabetical position in the function document. --- asminc/pet.inc | 23 +++++++++------------ doc/funcref.sgml | 47 +++++++++++++++++++++++-------------------- libsrc/pet/kbrepeat.s | 25 ++++++++++++++++++----- 3 files changed, 55 insertions(+), 40 deletions(-) diff --git a/asminc/pet.inc b/asminc/pet.inc index 8f2f469e0..43d52a5d5 100644 --- a/asminc/pet.inc +++ b/asminc/pet.inc @@ -26,22 +26,21 @@ SCR_LINELEN := $D5 ; Screen line length CURS_Y := $D8 ; Cursor row FNADR := $DA ; Pointer to file name +; 80-Column CBMs +KBDREPEAT80 := $E4 +KBDRPTRATE80 := $E5 +KBDRPTDELAY80 := $E6 + BASIC_BUF := $200 ; Location of command-line BASIC_BUF_LEN = 81 ; Maximum length of command-line KEY_BUF := $26F ; Keyboard buffer -;FIXME: we must somehow handle the difference between the two - how? - -; 40-Column PETs -;KBDREPEAT := $3ee -;KBDREPEATRATE := $3ea -;KBDREPEATDELAY := $3e9 - -; 80-Column PETs -KBDREPEAT := $e4 -KBDREPEATRATE := $e5 -KBDREPEATDELAY := $e6 +; 40-Column PETs/CBMs +KBDRPTDELAY40 := $3E9 +KBDRPTRATE40 := $3EA +KBDREPEAT40 := $3EE +KBDREPEAT40B := $3F8 ;---------------------------------------------------------------------------- ; PET ROM type detection @@ -67,5 +66,3 @@ VIA_PRB := $E840 VIA_PRA := $E841 VIA_DDRB := $E842 VIA_DDRA := $E843 - - diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 5ef773b95..1d5ee7c19 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -2,8 +2,9 @@ <article> <title>cc65 function reference -<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>2016-08-07 +<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> +<url url="mailto:greg.king5@verizon.net" name="Greg King"> +<date>2017-09-02 <abstract> cc65 is a C compiler for 6502 based systems. This function reference describes @@ -2166,26 +2167,6 @@ to get off the serial bus so it can be used for other purposes. </descrip> </quote> -<sect1>kbrepeat<label id="kbrepeat"><p> - -<quote> -<descrip> -<tag/Function/Set keyboard repeat mode -<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/ -<tag/Declaration/<tt/unsigned char __fastcall__ kbrepeat (unsigned char mode);/ -<tag/Description/This function changes which keys have automatic repeat when -being hold down for a certain time. Possible values are KBREPEAT_CURSOR (repeat -only cursor-related keys), KBREPEAT_NONE (no repeat for any keys) and -KBREPEAT_ALL (repeat all keys). The old mode is returned so it can be restored -later. -<tag/Notes/<itemize> -<item>The function is available only as a fastcall function; so, it may be used -only in the presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/Example/None. -</descrip> -</quote> <sect1>cclear<label id="cclear"><p> @@ -4062,6 +4043,28 @@ do), the function is rather useless. </quote> +<sect1>kbrepeat<label id="kbrepeat"><p> + +<quote> +<descrip> +<tag/Function/Set the keyboard repeat mode. +<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/ +<tag/Declaration/<tt/unsigned char __fastcall__ kbrepeat (unsigned char mode);/ +<tag/Description/This function changes which keys have automatic repeat when +being held down for a certain time. Possible values are <tt/KBREPEAT_CURSOR/ +(repeat only cursor-related keys), <tt/KBREPEAT_NONE/ (no repeat for any +keys), and <tt/KBREPEAT_ALL/ (repeat all keys). The old mode is returned, so +it can be restored later. +<tag/Notes/<itemize> +<item>The function is available only as a fastcall function; so, it may be used +only in the presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/Example/None. +</descrip> +</quote> + + <sect1>labs<label id="labs"><p> <quote> diff --git a/libsrc/pet/kbrepeat.s b/libsrc/pet/kbrepeat.s index 8299f5103..100d8502a 100644 --- a/libsrc/pet/kbrepeat.s +++ b/libsrc/pet/kbrepeat.s @@ -1,14 +1,29 @@ ; ; unsigned char __fastcall__ kbrepeat (unsigned char mode); +; +; 2017-06-16, Groepaz +; 2017-09-05, Greg King ; - .export _kbrepeat + .export _kbrepeat .include "pet.inc" _kbrepeat: - ldx KBDREPEAT ; get old value - sta KBDREPEAT ; store new value - txa ; return old value - ldx #0 + ldx #>$0000 + ldy SCR_LINELEN + cpy #40 + 1 + bcc L1 ; branch if screen is 40 columns wide + + ldy KBDREPEAT80 ; get old value + sta KBDREPEAT80 ; store new value + tya ; return old value + rts + +L1: tay + lda KBDREPEAT40B ; get REPEAT-key flag (used by some editor ROMs) + lsr a ; move bit 0 into bit 7 + ror a + ora KBDREPEAT40 ; combine with old key-REPEAT flags + sty KBDREPEAT40 rts From 51765c6e5c01cacda99621809e97dcd45ce295ff Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 5 Sep 2017 16:56:20 -0400 Subject: [PATCH 193/199] Removed an unwanted button mask table from a VIC-20 joystick driver. It had put the jump table at the wrong place. Programs crashed as soon as they tried to initiate the driver. --- libsrc/vic20/joy/vic20-stdjoy.s | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/libsrc/vic20/joy/vic20-stdjoy.s b/libsrc/vic20/joy/vic20-stdjoy.s index bf10acce5..67299cc1a 100644 --- a/libsrc/vic20/joy/vic20-stdjoy.s +++ b/libsrc/vic20/joy/vic20-stdjoy.s @@ -30,17 +30,6 @@ .addr $0000 -; Button state masks (8 values) - - .byte $02 ; JOY_UP - .byte $04 ; JOY_DOWN - .byte $08 ; JOY_LEFT - .byte $80 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion - ; Jump table. .addr INSTALL @@ -128,5 +117,3 @@ READ: lda #$7F ; mask for VIA2 JOYBIT: sw3 ldx #0 rts - - From 5802b0963fcd222eb2352525428789a857b23bda Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 10 Sep 2017 12:27:57 -0400 Subject: [PATCH 194/199] Made <conio.h> include <atari5200.h> when we compile for the Atari 5200 console. atari5200.lib has some conio functions. --- include/conio.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/conio.h b/include/conio.h index 9eb68e565..4f414105c 100644 --- a/include/conio.h +++ b/include/conio.h @@ -63,6 +63,8 @@ # include <apple2enh.h> #elif defined(__APPLE2__) # include <apple2.h> +#elif defined(__ATARI5200__) +# include <atari5200.h> #elif defined(__ATARI__) # include <atari.h> #elif defined(__ATMOS__) @@ -225,6 +227,3 @@ void __fastcall__ cputhex16 (unsigned val); /* End of conio.h */ #endif - - - From 7623d4ea83ab9f64f5b66c9781e6a607a625038b Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 12 Sep 2017 21:57:16 +0200 Subject: [PATCH 195/199] conio.h: include 'creativision.h' when compiling for this target. --- include/conio.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/conio.h b/include/conio.h index 4f414105c..baf55dd08 100644 --- a/include/conio.h +++ b/include/conio.h @@ -71,6 +71,8 @@ # include <atmos.h> #elif defined(__CBM__) # include <cbm.h> +#elif defined(__CREATIVISION__) +# include <creativision.h> #elif defined(__GAMATE__) # include <gamate.h> #elif defined(__GEOS__) From 945dcfd63ad23d1ac93edab8112cec0798bfccdd Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Wed, 13 Sep 2017 23:51:07 +0200 Subject: [PATCH 196/199] Fixed address See cbm510.cfg --- doc/cbm510.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cbm510.sgml b/doc/cbm510.sgml index c24eba142..b171c2ce3 100644 --- a/doc/cbm510.sgml +++ b/doc/cbm510.sgml @@ -67,7 +67,7 @@ Special locations: <descrip> <tag/Stack/ - The C runtime stack is located at $FF81, and grows downwards. + The C runtime stack is located at $FEC2, and grows downwards. <tag/Heap/ The C heap is located at the end of the program, and grows towards the C From ca4ed290d5964dbe833224d967d3707e20972278 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 3 Oct 2017 18:46:39 +0300 Subject: [PATCH 197/199] cl65: Add support for --all-cdecl --- src/cl65/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cl65/main.c b/src/cl65/main.c index b209cb21d..565f20b45 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -752,6 +752,7 @@ static void Usage (void) "\n" "Long options:\n" " --add-source\t\t\tInclude source as comment\n" + " --all-cdecl\t\t\tMake functions default to __cdecl__\n" " --asm-args options\t\tPass options to the assembler\n" " --asm-define sym[=v]\t\tDefine an assembler symbol\n" " --asm-include-dir dir\t\tSet an assembler include directory\n" @@ -815,6 +816,14 @@ static void OptAddSource (const char* Opt attribute ((unused)), } +static void OptAllCDecl (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) +/* Make functions default to __cdecl__ */ +{ + CmdAddArg (&CC65, "--all-cdecl"); +} + + static void OptAsmArgs (const char* Opt attribute ((unused)), const char* Arg) /* Pass arguments to the assembler */ @@ -1290,6 +1299,7 @@ int main (int argc, char* argv []) /* Program long options */ static const LongOpt OptTab[] = { { "--add-source", 0, OptAddSource }, + { "--all-cdecl", 0, OptAllCDecl }, { "--asm-args", 1, OptAsmArgs }, { "--asm-define", 1, OptAsmDefine }, { "--asm-include-dir", 1, OptAsmIncludeDir }, From a084ea8e42487602fdf6bb475fe44ce6edb01739 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 3 Oct 2017 21:58:52 +0200 Subject: [PATCH 198/199] Atari: split "setcursor" function out of cgetc.s source file into setcursor.s. This function is used by many other CONIO functions, and the user program not necessarily uses 'cgetc'. Having "setcursor" in a different object file saves space in this case and also allows the user program to override it (e.g. when not using GRAPHICS 0 mode). --- libsrc/atari/cgetc.s | 44 ++---------------------------------- libsrc/atari/setcursor.s | 48 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 42 deletions(-) create mode 100644 libsrc/atari/setcursor.s diff --git a/libsrc/atari/cgetc.s b/libsrc/atari/cgetc.s index 2e9ebcb31..f8d938dfb 100644 --- a/libsrc/atari/cgetc.s +++ b/libsrc/atari/cgetc.s @@ -6,9 +6,9 @@ ; .include "atari.inc" - .export _cgetc,setcursor + .export _cgetc + .import setcursor .import KEYBDV_handler - .import cursor,mul40 _cgetc: jsr setcursor @@ -29,43 +29,3 @@ _cgetc: pha rts .endif - -.proc setcursor - - ldy #0 - lda OLDCHR - sta (OLDADR),y - - lda ROWCRS - jsr mul40 - clc - adc SAVMSC ; add start of screen memory - sta OLDADR - txa - adc SAVMSC+1 - sta OLDADR+1 - lda COLCRS - adc OLDADR - sta OLDADR - bcc nc - inc OLDADR+1 -nc: lda (OLDADR),y - sta OLDCHR - - ldx cursor ; current cursor setting as requested by the user - beq off - ldx #0 - beq cont - -off: inx -cont: stx CRSINH ; update system variable - - beq turnon - and #$7f ; clear high bit / inverse flag -finish: sta (OLDADR),y ; update on-screen display - rts - -turnon: ora #$80 ; set high bit / inverse flag - bne finish - -.endproc diff --git a/libsrc/atari/setcursor.s b/libsrc/atari/setcursor.s new file mode 100644 index 000000000..cf596d4fe --- /dev/null +++ b/libsrc/atari/setcursor.s @@ -0,0 +1,48 @@ +; +; Christian Groessler, November-2002 +; +; cursor handling, internal function + + .include "atari.inc" + .import cursor,mul40 + .export setcursor + +.proc setcursor + + ldy #0 + lda OLDCHR + sta (OLDADR),y + + lda ROWCRS + jsr mul40 + clc + adc SAVMSC ; add start of screen memory + sta OLDADR + txa + adc SAVMSC+1 + sta OLDADR+1 + lda COLCRS + adc OLDADR + sta OLDADR + bcc nc + inc OLDADR+1 +nc: lda (OLDADR),y + sta OLDCHR + + ldx cursor ; current cursor setting as requested by the user + beq off + ldx #0 + beq cont + +off: inx +cont: stx CRSINH ; update system variable + + beq turnon + and #$7f ; clear high bit / inverse flag +finish: sta (OLDADR),y ; update on-screen display + rts + +turnon: ora #$80 ; set high bit / inverse flag + bne finish + +.endproc From bea5364b978b69125ec65adaa4f906ce062364a5 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Mon, 16 Oct 2017 09:39:33 -0400 Subject: [PATCH 199/199] Added commit ca4ed290d5964dbe833224d967d3707e20972278's command-line option to the cl65 document. --- doc/cl65.sgml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/cl65.sgml b/doc/cl65.sgml index 8b3c02cbb..ca5f9d2af 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -4,7 +4,7 @@ <title>cl65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:greg.king5@verizon.net" name="Greg King"> -<date>2017-05-24 +<date>2017-10-16 <abstract> cl65 is the compile & link utility for cc65, the 6502 C compiler. It was @@ -69,6 +69,7 @@ Short options: Long options: --add-source Include source as comment + --all-cdecl Make functions default to __cdecl__ --asm-args options Pass options to the assembler --asm-define sym[=v] Define an assembler symbol --asm-include-dir dir Set an assembler include directory